:root {
  --bg: #f3f4f6;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --text: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --primary: #066fd1;
  --primary-dark: #064f96;
  --ink: #1f2937;
  --success: #2fb344;
  --warning: #f59f00;
  --warning-text: #8a5a00;
  --danger: #d63939;
  --cyan: #17a2b8;
  --teal: #0ca678;
  --blue-soft: #e7f1ff;
  --green-soft: #eaf7ec;
  --yellow-soft: #fff4de;
  --red-soft: #fdecec;
  --cyan-soft: #e9f8fb;
  --input-bg: #ffffff;
  --drop-bg: linear-gradient(180deg, #f8fbff 0%, var(--blue-soft) 100%);
  --drop-hover: #eef6ff;
  --sidebar-bg: #111827;
  --sidebar-text: #f9fafb;
  --sidebar-muted: #b8c2d3;
  --row-hover: #f8fafc;
  --preview-bg: #f1f3f6;
  --empty-bg: #fafbfc;
  --radius: 8px;
  --radius-soft: 10px;
  --content-max: 1260px;
  --shadow: 0 8px 24px rgba(31, 41, 55, 0.06);
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
}

:root[data-theme="dark"] {
  --bg: #0f172a;
  --surface: #111827;
  --surface-soft: #162033;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --line: #273449;
  --primary: #60a5fa;
  --primary-dark: #93c5fd;
  --ink: #f9fafb;
  --success: #4ade80;
  --warning: #fbbf24;
  --warning-text: #fbbf24;
  --danger: #f87171;
  --cyan: #22d3ee;
  --teal: #2dd4bf;
  --blue-soft: rgba(96, 165, 250, 0.16);
  --green-soft: rgba(74, 222, 128, 0.14);
  --yellow-soft: rgba(251, 191, 36, 0.16);
  --red-soft: rgba(248, 113, 113, 0.16);
  --cyan-soft: rgba(34, 211, 238, 0.14);
  --input-bg: #0b1220;
  --drop-bg: linear-gradient(180deg, rgba(96, 165, 250, 0.12) 0%, rgba(34, 211, 238, 0.10) 100%);
  --drop-hover: rgba(96, 165, 250, 0.18);
  --sidebar-bg: #030712;
  --sidebar-text: #f9fafb;
  --sidebar-muted: #9ca3af;
  --row-hover: rgba(96, 165, 250, 0.08);
  --preview-bg: #0b1220;
  --empty-bg: #111827;
  --shadow: 0 12px 28px rgba(0, 0, 0, 0.24);
}

* {
  box-sizing: border-box;
}

html {
  width: 100%;
  max-width: 100%;
  min-height: 100%;
  overflow-x: hidden;
}

html[data-theme="light"] {
  color-scheme: light;
}

html[data-theme="dark"] {
  color-scheme: dark;
}

body {
  width: 100%;
  max-width: 100%;
  margin: 0;
  min-height: 100dvh;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: "Aptos", "Segoe UI Variable", "Segoe UI", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
}

body.modal-open,
body.mobile-nav-open {
  overflow: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

a:hover {
  color: var(--primary-dark);
}

.icon {
  display: inline-block;
  width: 1.1rem;
  height: 1.1rem;
  flex: 0 0 auto;
  vertical-align: -0.18em;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
a,
select,
input,
textarea {
  outline-color: var(--primary);
  outline-offset: 3px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: 16px;
  top: -44px;
  z-index: 10;
  background: var(--ink);
  color: white;
  padding: 10px 14px;
  border-radius: var(--radius);
  transition: top 160ms var(--ease-out);
}

.skip-link:focus {
  top: 12px;
}

.app-shell {
  display: block;
  width: 100%;
  max-width: 100%;
  min-height: 100dvh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 80;
  display: flex;
  flex-direction: column;
  flex: 0 0 264px;
  width: 264px;
  height: 100dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 22px 18px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 26px;
}

.brand span,
.sidebar-foot span {
  display: block;
  color: var(--sidebar-muted);
  font-size: 0.86rem;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(147, 197, 253, 0.42);
  border-radius: 8px;
  overflow: hidden;
  background: #f8fbff;
  color: white;
  font-weight: 600;
  letter-spacing: 0;
  box-shadow: 0 8px 24px rgba(6, 111, 209, 0.22);
}

.brand-logo {
  display: block;
  width: 94%;
  height: 94%;
  object-fit: contain;
  object-position: center;
}

.brand-mark.large {
  width: 54px;
  height: 54px;
}

.brand-mark.large .brand-logo {
  width: 94%;
  height: 94%;
}

.nav-list {
  display: grid;
  gap: 6px;
}

.nav-list a {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 11px 12px;
  border-radius: var(--radius);
  color: #d8deea;
  transition: background 160ms var(--ease-out), color 160ms var(--ease-out), transform 160ms var(--ease-out);
}

.nav-list a:hover,
.nav-list a.active {
  background: rgba(255, 255, 255, 0.09);
  color: white;
}

.nav-list a:hover {
  transform: translateX(2px);
}

.nav-list .icon {
  color: #7dd3fc;
}

.nav-list a.active .icon {
  color: white;
}

.nav-badge {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  margin-left: auto;
  border-radius: 999px;
  background: var(--warning);
  color: #1f2937;
  padding: 0 6px;
  font-size: 0.72rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.sidebar-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: auto;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.sidebar-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 16px;
}

.sidebar-controls form {
  margin: 0;
}

.quick-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: 100%;
  min-height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.06);
  color: white;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  transition: background 160ms var(--ease-out), transform 140ms var(--ease-out);
}

.quick-toggle:hover {
  background: rgba(255, 255, 255, 0.12);
}

.quick-toggle:active {
  transform: scale(0.97);
}

.sidebar-foot a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: white;
  font-weight: 700;
}

.mobile-tabbar,
.mobile-more-panel {
  display: none;
}

.mobile-tabbar-item,
.mobile-more-link,
.mobile-more-logout {
  touch-action: manipulation;
}

.mobile-more-panel[hidden] {
  display: none !important;
}

.main {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: hidden;
  overflow-x: clip;
  padding: 34px;
}

.app-shell.has-sidebar .main {
  width: calc(100% - 264px);
  margin-left: 264px;
}

.app-shell.no-sidebar .main {
  width: 100%;
  margin-left: 0;
}

.main > * {
  width: 100%;
  max-width: var(--content-max);
  min-width: 0;
  margin-right: auto;
  margin-left: auto;
}

.main > .ui-modal,
.main > .document-modal {
  width: auto;
  max-width: none;
  margin: 0;
}

.main-centered {
  display: grid;
  place-items: center;
  padding: 24px;
}

.main-centered > * {
  margin-right: 0;
  margin-left: 0;
}

.route-transition-overlay {
  position: fixed;
  inset: 0;
  z-index: 260;
  display: grid;
  place-items: start center;
  padding: 40px 34px;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 0%, rgba(6, 111, 209, 0.10), transparent 36%),
    color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
}

.app-shell.has-sidebar ~ .route-transition-overlay {
  left: 264px;
}

.route-transition-card {
  width: min(100%, var(--content-max));
  display: grid;
  gap: 18px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius-soft);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  box-shadow: var(--shadow);
}

.route-transition-status {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-weight: 600;
}

.route-transition-spinner {
  width: 22px;
  height: 22px;
  border: 3px solid color-mix(in srgb, var(--primary) 18%, transparent);
  border-top-color: var(--primary);
  border-radius: 999px;
  animation: button-spinner 780ms linear infinite;
}

.route-skeleton {
  display: grid;
  gap: 18px;
}

.route-skeleton-line,
.route-skeleton-card,
.route-skeleton-row span {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--muted) 13%, transparent);
}

.route-skeleton-line::after,
.route-skeleton-card::after,
.route-skeleton-row span::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--surface) 54%, transparent), transparent);
  animation: route-skeleton-shimmer 1.1s var(--ease-out) infinite;
}

.route-skeleton-line {
  height: 24px;
  max-width: 360px;
}

.route-skeleton-line.large {
  height: 54px;
  max-width: 520px;
}

.route-skeleton-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.route-skeleton-card {
  min-height: 112px;
}

.route-skeleton-table {
  display: grid;
  gap: 10px;
  padding-top: 8px;
}

.route-skeleton-row {
  display: grid;
  grid-template-columns: minmax(140px, 2fr) repeat(4, minmax(80px, 1fr));
  gap: 12px;
}

.route-skeleton-row span {
  height: 34px;
}

@keyframes route-skeleton-shimmer {
  100% {
    transform: translateX(100%);
  }
}

.page-header,
.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.section-heading.compact {
  margin-bottom: 14px;
}

.header-actions,
.page-actions,
.status-pair {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.page-actions form {
  margin: 0;
}

.inline-icon-form {
  display: inline-flex;
  margin: 0;
}

.ai-reanalyze-button {
  color: var(--primary);
}

.detail-header-with-back {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  align-items: start;
  gap: 12px;
  margin-bottom: 22px;
}

.detail-header-with-back .page-header {
  min-width: 0;
  margin-bottom: 0;
}

.detail-back-link {
  margin-top: 4px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--primary-dark);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 2.4rem;
  line-height: 1.05;
  letter-spacing: 0;
  overflow-wrap: anywhere;
  text-wrap: balance;
}

h2 {
  margin-bottom: 0;
  font-size: 1.05rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
  text-wrap: pretty;
}

h3 {
  margin-bottom: 6px;
  font-size: 1rem;
}

.grid {
  display: grid;
  gap: 18px;
}

.grid.two {
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
}

.single-upload {
  display: grid;
  max-width: 760px;
}

.home-page {
  display: grid;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  gap: 18px;
  overflow-x: hidden;
  overflow-x: clip;
}

.home-header {
  margin-bottom: 0;
}

.home-workbench {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.75fr);
  width: 100%;
  max-width: 100%;
  min-width: 0;
  gap: 18px;
  align-items: stretch;
}

.home-upload-panel {
  position: relative;
  display: grid;
  align-content: start;
  gap: 10px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 220px;
  overflow: hidden;
  padding: 16px;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--primary) 7%, var(--surface)) 0%, var(--surface) 46%),
    var(--surface);
}

.home-upload-panel::before {
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--primary);
  content: "";
}

.home-upload-head {
  display: flex;
  align-items: flex-start;
  min-width: 0;
  gap: 10px;
}

.home-upload-head > div {
  min-width: 0;
  max-width: 100%;
}

.home-upload-head .hint {
  max-width: 58ch;
  margin-top: 2px;
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.home-upload-icon {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  background: var(--blue-soft);
  color: var(--primary);
}

.home-upload-icon .icon {
  width: 1.08rem;
  height: 1.08rem;
}

.home-file-drop {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 96px;
  align-content: center;
  padding: 12px;
}

.home-file-drop .drop-icon {
  width: 36px;
  height: 36px;
}

.home-file-drop .file-name {
  display: none;
}

.home-upload-controls {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  gap: 12px;
  align-items: end;
}

.home-upload-controls label,
.home-upload-controls select,
.home-upload-controls .button {
  min-width: 0;
  max-width: 100%;
}

.home-upload-controls .button {
  min-width: 220px;
}

.home-upload-actions {
  display: flex;
  justify-content: flex-end;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.home-upload-actions .button {
  width: min(100%, 280px);
  min-width: 200px;
  min-height: 46px;
}

.home-overview {
  display: grid;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.home-stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  width: 100%;
  max-width: 100%;
  min-width: 0;
  gap: 12px;
}

.home-stat-card {
  position: relative;
  display: grid;
  align-content: space-between;
  min-width: 0;
  min-height: 166px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-soft);
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 16px;
  text-decoration: none;
  transition: transform 160ms var(--ease-out), border-color 160ms var(--ease-out), background 160ms var(--ease-out);
}

.home-stat-card::before {
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  content: "";
}

.home-stat-card:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--primary) 28%, var(--line));
  background: color-mix(in srgb, var(--primary) 4%, var(--surface));
}

.home-stat-card span:not(.stat-icon) {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.home-stat-card strong {
  color: var(--ink);
  font-size: 1.75rem;
  line-height: 1;
  overflow-wrap: anywhere;
}

.home-lower-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(300px, 0.92fr);
  width: 100%;
  max-width: 100%;
  min-width: 0;
  gap: 18px;
  align-items: stretch;
}

.home-lower-grid > .panel {
  min-width: 0;
}

.home-activity {
  margin-top: 0;
}

.panel,
.table-section,
.login-panel,
.document-panel {
  max-width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-soft);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel,
.table-section,
.document-panel {
  padding: 20px;
}

.login-panel {
  width: min(440px, 100%);
  padding: 28px;
}

.error-page {
  display: grid;
  min-height: 100dvh;
  place-items: center;
  background:
    radial-gradient(circle at 50% 20%, rgba(6, 111, 209, 0.12), transparent 32%),
    var(--bg);
  padding: 24px;
}

.error-panel {
  display: grid;
  gap: 14px;
  width: min(560px, 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius-soft);
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 28px;
}

.error-icon {
  display: inline-grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: var(--radius);
  background: var(--red-soft);
  color: var(--danger);
}

.error-icon .icon {
  width: 1.45rem;
  height: 1.45rem;
}

.error-panel h1 {
  margin-bottom: 0;
}

.error-copy {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
}

.error-code-box {
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 14px;
}

.error-code-box span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
}

.error-code-box code {
  color: var(--ink);
  font-size: 1.05rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.error-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
}

.login-brand h1 {
  font-size: 2rem;
}

.stack {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--input-bg);
  color: var(--text);
  padding: 10px 12px;
  transition: border-color 160ms var(--ease-out), box-shadow 160ms var(--ease-out);
}

select {
  appearance: none;
  padding-right: 40px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 50%,
    calc(100% - 12px) 50%;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}

textarea {
  min-height: 110px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(6, 111, 209, 0.14);
}

.custom-select {
  position: relative;
  display: block;
  width: 100%;
  min-width: 0;
}

.custom-select-native {
  position: absolute;
  inset: 0 auto auto 0;
  width: 1px;
  height: 1px;
  min-height: 1px;
  opacity: 0;
  pointer-events: none;
}

.custom-select-trigger {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 18px;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--input-bg);
  color: var(--text);
  padding: 10px 12px;
  text-align: left;
  cursor: pointer;
  transition: border-color 160ms var(--ease-out), box-shadow 160ms var(--ease-out), background-color 160ms var(--ease-out);
}

.custom-select-trigger:focus-visible {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(6, 111, 209, 0.14);
}

.custom-select.is-open .custom-select-trigger {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(6, 111, 209, 0.14);
}

.custom-select-value {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  overflow: hidden;
  font-weight: 600;
  white-space: nowrap;
}

.custom-option-icon {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  color: var(--muted);
}

.custom-option-icon .icon {
  width: 1rem;
  height: 1rem;
}

.custom-option-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.custom-select-option:hover .custom-option-icon,
.custom-select-option:focus-visible .custom-option-icon,
.custom-select-option.is-selected .custom-option-icon,
.custom-select-trigger .custom-option-icon {
  color: inherit;
}

.filter-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.filter-label .icon {
  width: 0.95rem;
  height: 0.95rem;
  color: var(--muted);
}

.custom-select-chevron {
  position: relative;
  width: 16px;
  height: 16px;
}

.custom-select-chevron::before {
  position: absolute;
  left: 3px;
  top: 4px;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  content: "";
  transform: rotate(45deg);
  transition: transform 160ms var(--ease-out), top 160ms var(--ease-out);
}

.custom-select.is-open .custom-select-chevron::before {
  top: 7px;
  transform: rotate(225deg);
}

.custom-select-menu {
  position: absolute;
  z-index: 90;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  display: grid;
  gap: 3px;
  max-height: min(320px, 52vh);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-soft);
  background: var(--surface);
  box-shadow: 0 18px 40px rgba(31, 41, 55, 0.18);
  padding: 6px;
}

:root[data-theme="dark"] .custom-select-menu {
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.38);
}

.custom-select-menu[hidden] {
  display: none;
}

.custom-select-group {
  display: grid;
  gap: 3px;
}

.custom-select-group + .custom-select-group {
  border-top: 1px solid var(--line);
  margin-top: 4px;
  padding-top: 4px;
}

.custom-select-group-label {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 7px 9px 4px;
  text-transform: uppercase;
}

.custom-select-option {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 38px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  padding: 8px 10px;
  text-align: left;
  cursor: pointer;
}

.custom-select-option:hover,
.custom-select-option:focus-visible {
  background: var(--blue-soft);
  color: var(--primary-dark);
  outline: 0;
}

.custom-select-option.is-selected {
  background: var(--primary);
  color: white;
  font-weight: 700;
}

.custom-select-option:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.custom-select.is-disabled .custom-select-trigger {
  cursor: not-allowed;
  opacity: 0.55;
}

.custom-date-field {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  width: 100%;
}

.custom-date-field .custom-date-input {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
  padding-right: 10px;
}

.custom-date-field .custom-date-input:focus {
  position: relative;
  z-index: 1;
}

.custom-date-input.is-invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--danger) 16%, transparent);
}

.custom-date-trigger {
  display: inline-grid;
  place-items: center;
  width: 44px;
  min-height: 44px;
  border: 1px solid var(--line);
  border-left: 0;
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--surface-soft);
  color: var(--primary);
  cursor: pointer;
  transition: background 160ms var(--ease-out), border-color 160ms var(--ease-out), color 160ms var(--ease-out);
}

.custom-date-trigger:hover,
.custom-date-field:focus-within .custom-date-trigger {
  border-color: var(--primary);
  background: var(--blue-soft);
  color: var(--primary-dark);
}

.custom-date-trigger .icon {
  width: 1.05rem;
  height: 1.05rem;
}

.custom-date-picker {
  position: fixed;
  z-index: 220;
  display: grid;
  gap: 10px;
  width: 344px;
  max-width: calc(100vw - 24px);
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.22);
  padding: 12px;
}

.custom-date-picker[hidden] {
  display: none;
}

.custom-date-header {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) 40px;
  gap: 8px;
  align-items: center;
}

.custom-date-header strong {
  color: var(--ink);
  font-size: 1.02rem;
  font-weight: 700;
  text-align: center;
}

.custom-date-nav {
  display: inline-grid;
  place-items: center;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  color: var(--ink);
  cursor: pointer;
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1;
}

.custom-date-nav:hover {
  border-color: #bfdbfe;
  background: var(--blue-soft);
  color: var(--primary-dark);
}

.custom-date-weekdays,
.custom-date-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
}

.custom-date-weekdays span {
  min-height: 26px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-align: center;
}

.custom-date-day {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font-weight: 600;
}

.custom-date-day:hover {
  border-color: #bfdbfe;
  background: var(--blue-soft);
  color: var(--primary-dark);
}

.custom-date-day.is-muted {
  color: var(--muted);
  opacity: 0.54;
}

.custom-date-day.is-today {
  border-color: color-mix(in srgb, var(--primary) 44%, var(--line));
  color: var(--primary-dark);
}

.custom-date-day.is-selected {
  border-color: var(--primary);
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 8px 20px rgba(6, 111, 209, 0.2);
}

.custom-date-day:disabled {
  cursor: not-allowed;
  opacity: 0.3;
}

.custom-date-footer {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.custom-date-footer .button {
  min-height: 40px;
  padding-block: 8px;
}

.custom-date-picker.is-mobile {
  right: 12px;
  bottom: 14px;
  left: 12px;
  top: auto;
  width: auto;
  max-width: none;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  max-width: 100%;
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 600;
  text-align: center;
  transition: transform 140ms var(--ease-out), background 160ms var(--ease-out), border-color 160ms var(--ease-out);
}

.button .icon {
  width: 1rem;
  height: 1rem;
}

.button:active {
  transform: scale(0.97);
}

.button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.button.is-processing {
  gap: 0;
  opacity: 1;
  pointer-events: none;
}

.button-spinner {
  width: 1.15rem;
  height: 1.15rem;
  border: 2px solid color-mix(in srgb, currentColor 26%, transparent);
  border-top-color: currentColor;
  border-radius: 999px;
  animation: button-spinner 780ms linear infinite;
}

@keyframes button-spinner {
  to {
    transform: rotate(360deg);
  }
}

.button.primary {
  background: var(--primary);
  color: white;
}

.button.primary:hover {
  background: var(--primary-dark);
}

:root[data-theme="dark"] .button.primary,
:root[data-theme="dark"] .custom-select-option.is-selected,
:root[data-theme="dark"] .custom-date-day.is-selected {
  color: #0b1220;
}

.button.secondary {
  border-color: var(--line);
  background: var(--surface);
  color: var(--ink);
}

.button.secondary:hover {
  border-color: #bfdbfe;
  background: var(--blue-soft);
  color: var(--primary-dark);
}

.button.warning-soft {
  border-color: color-mix(in srgb, var(--warning) 42%, var(--line));
  background: var(--yellow-soft);
  color: var(--warning-text);
}

.button.warning-soft:hover {
  border-color: var(--warning);
  background: color-mix(in srgb, var(--warning) 16%, var(--surface));
}

.button.icon-only {
  flex: 0 0 auto;
  width: 44px;
  padding: 0;
}

.button.danger-soft {
  border-color: #f4b6b6;
  background: var(--red-soft);
  color: var(--danger);
}

.button.dark {
  background: var(--ink);
  color: white;
}

.section-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: -10px 0 20px;
}

.section-tabs a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
  padding: 9px 13px;
  font-weight: 600;
  text-decoration: none;
}

.section-tabs a:hover,
.section-tabs a.active {
  border-color: #bfdbfe;
  background: var(--blue-soft);
  color: var(--primary-dark);
}

.section-tabs .icon {
  width: 1rem;
  height: 1rem;
}

.employee-header-actions,
.employee-detail-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.employee-page {
  display: grid;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.employee-page > .page-header,
.employee-page > .section-tabs,
.employee-page > .employee-kpi-strip,
.employee-page > .employee-workbench,
.employee-page > .table-section {
  width: 100%;
}

.employee-kpi-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  width: 100%;
  max-width: 100%;
  min-width: 0;
  gap: 12px;
  align-items: stretch;
  margin: 0 0 18px;
}

.employee-kpi {
  display: grid;
  gap: 2px;
  min-width: 0;
  min-height: 72px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 12px 14px;
}

.employee-kpi.needs-attention {
  border-color: color-mix(in srgb, var(--warning) 42%, var(--line));
  background: color-mix(in srgb, var(--warning) 9%, var(--surface));
}

.employee-kpi span,
.employee-kpi small {
  color: var(--muted);
  font-weight: 600;
}

.employee-kpi strong {
  color: var(--ink);
  font-size: 1.45rem;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.employee-workbench {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  gap: 18px;
  align-items: start;
}

.employee-side-stack {
  display: grid;
  gap: 18px;
}

.employee-toolbar {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(160px, 220px) auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 16px;
}

.employee-toolbar label {
  display: grid;
  gap: 6px;
}

.employee-profile-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) repeat(3, minmax(180px, 0.8fr));
  gap: 14px;
  margin-bottom: 18px;
}

.employee-profile-card {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-soft);
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 18px;
}

.employee-profile-card.primary {
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--primary) 10%, var(--surface)) 0%, var(--surface) 58%);
}

.employee-profile-card h2 {
  font-size: 1.35rem;
}

.employee-profile-card strong {
  color: var(--ink);
  font-size: 1.45rem;
  line-height: 1.1;
}

.employee-readout {
  display: grid;
  gap: 8px;
  margin: 0;
}

.employee-readout div {
  display: grid;
  gap: 2px;
}

.employee-readout.compact div {
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.employee-readout dt {
  color: var(--muted);
  font-weight: 600;
}

.employee-readout dd {
  margin: 0;
  color: var(--ink);
  font-weight: 700;
  overflow-wrap: anywhere;
}

.employee-edit-disclosure {
  margin-bottom: 18px;
}

.employee-edit-disclosure > summary {
  width: fit-content;
  cursor: pointer;
  list-style: none;
}

.employee-edit-disclosure > summary::-webkit-details-marker {
  display: none;
}

.employee-edit-panel {
  margin-top: 12px;
}

.table-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}

.table-actions form {
  margin: 0;
}

.employee-payroll-title {
  display: inline-block;
  max-width: min(420px, 42vw);
  font-weight: 600;
  overflow-wrap: anywhere;
}

.payroll-status-pill {
  min-width: 74px;
  justify-content: center;
}

.employee-form-panel {
  max-width: 980px;
}

.form-section-divider {
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.form-section-divider .eyebrow {
  margin-bottom: 0;
}

.wide-field {
  grid-column: 1 / -1;
}

.payroll-add-disclosure {
  position: relative;
  z-index: 4;
}

.payroll-add-disclosure > summary {
  cursor: pointer;
  list-style: none;
}

.payroll-add-disclosure > summary::-webkit-details-marker {
  display: none;
}

.payroll-add-disclosure[open] > summary {
  background: var(--primary-dark);
}

.payroll-inline-upload {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  display: grid;
  gap: 14px;
  width: min(520px, calc(100vw - 56px));
  border: 1px solid var(--line);
  border-radius: var(--radius-soft);
  background: var(--surface);
  box-shadow: 0 18px 44px rgba(31, 41, 55, 0.18);
  padding: 16px;
}

.payroll-inline-upload h3 {
  margin: 0;
  font-size: 1.15rem;
}

.final-action .button {
  width: 100%;
}

.workflow {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(176px, 1fr));
  width: 100%;
  max-width: 100%;
  min-width: 0;
  gap: 10px;
  margin-bottom: 18px;
}

.workflow .stat-card,
.metric-list div,
.metric-list a {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 16px;
}

.stat-card {
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  content: "";
}

.stat-card.accent-blue::before {
  background: var(--primary);
}

.home-stat-card.accent-blue::before {
  background: var(--primary);
}

.stat-card.accent-cyan::before {
  background: var(--cyan);
}

.home-stat-card.accent-cyan::before {
  background: var(--cyan);
}

.stat-card.accent-green::before {
  background: var(--success);
}

.home-stat-card.accent-green::before {
  background: var(--success);
}

.stat-card.accent-red::before {
  background: var(--danger);
}

.home-stat-card.accent-red::before {
  background: var(--danger);
}

.stat-icon {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  margin-bottom: 12px;
  border-radius: var(--radius);
}

.accent-blue .stat-icon {
  background: var(--blue-soft);
  color: var(--primary);
}

.accent-cyan .stat-icon {
  background: var(--cyan-soft);
  color: var(--cyan);
}

.accent-green .stat-icon {
  background: var(--green-soft);
  color: var(--success);
}

.accent-red .stat-icon {
  background: var(--red-soft);
  color: var(--danger);
}

.workflow .stat-card > span:not(.stat-icon),
.metric-list span {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  min-width: 0;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.workflow .stat-icon {
  display: inline-grid;
}

.workflow strong,
.metric-list strong {
  display: block;
  margin-top: 8px;
  color: var(--ink);
  font-size: 1.45rem;
  line-height: 1;
  overflow-wrap: anywhere;
}

.metric-list {
  display: grid;
  gap: 10px;
  margin-top: 20px;
}

.mini-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.mini-list a,
.mini-list div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 12px;
  color: var(--text);
  text-decoration: none;
}

.mini-list span {
  min-width: 0;
  color: var(--muted);
  font-weight: 600;
  overflow-wrap: anywhere;
}

.mini-list strong {
  color: var(--ink);
  white-space: nowrap;
}

.payroll-latest-list {
  gap: 8px;
}

.payroll-latest-item {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
}

.mini-list .payroll-latest-main,
.mini-list .payroll-latest-amount {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.mini-list .payroll-latest-main {
  color: var(--text);
}

.mini-list .payroll-latest-main strong {
  color: var(--ink);
  font-size: 1rem;
  font-weight: 700;
  overflow-wrap: anywhere;
  white-space: normal;
}

.mini-list .payroll-latest-main small,
.mini-list .payroll-latest-amount small {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 600;
  line-height: 1.2;
}

.mini-list .payroll-latest-amount {
  justify-items: end;
  text-align: right;
}

.mini-list .payroll-latest-amount strong {
  color: var(--ink);
  font-size: 1.05rem;
  font-weight: 700;
}

.compact-metrics {
  margin-top: 14px;
}

.file-drop {
  display: grid;
  gap: 7px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 152px;
  place-items: center;
  border: 1px dashed #93c5fd;
  border-radius: var(--radius);
  background: var(--drop-bg);
  cursor: pointer;
  padding: 18px;
  text-align: center;
  transition: border-color 160ms var(--ease-out), background 160ms var(--ease-out), transform 160ms var(--ease-out);
}

.file-drop.compact-drop {
  min-height: 124px;
  align-content: center;
}

.upload-progress {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 12px;
}

.upload-progress[hidden] {
  display: none;
}

.upload-progress span {
  color: var(--ink);
  font-weight: 700;
}

.upload-progress small {
  color: var(--muted);
  font-weight: 700;
}

.progress-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--line);
}

.progress-track span {
  display: block;
  width: 38%;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
  animation: progress-slide 1100ms ease-in-out infinite;
}

@keyframes progress-slide {
  0% {
    transform: translateX(-110%);
  }

  100% {
    transform: translateX(270%);
  }
}

.file-drop:hover,
.file-drop:focus-within {
  border-color: var(--primary);
  background: var(--drop-hover);
  transform: translateY(-1px);
}

.file-drop input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  clip: rect(0 0 0 0);
  overflow: hidden;
}

.file-title {
  max-width: 100%;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.file-name {
  max-width: 100%;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.drop-icon {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--primary);
  box-shadow: 0 8px 16px rgba(6, 111, 209, 0.12);
}

.upload-strip {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: end;
  margin-bottom: 18px;
}

.inline-drop {
  min-height: 88px;
}

.table-section {
  margin-top: 18px;
}

.table-section.flush {
  margin-top: 0;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.documents-page {
  display: grid;
  gap: 18px;
}

.documents-header {
  margin-bottom: 0;
}

.documents-overview {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  width: 100%;
  max-width: 100%;
  min-width: 0;
  gap: 12px;
}

/* En tablet portrait las 4 tarjetas KPI quedan 2x2 equilibradas,
   en lugar de 3 + 1 suelta. */
@media (min-width: 681px) and (max-width: 860px) {
  .documents-overview,
  .home-stat-grid,
  .liquidation-overview {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.invoice-section-tabs {
  margin: 0;
}

.invoice-filter-bar {
  display: grid;
  /* Columnas fluidas: se reparten segun el ancho disponible y se apilan
     solas en tablet y movil sin desbordar (tecnica auto-fit + minmax). */
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr));
  gap: 12px 14px;
  align-items: end;
  padding: 16px;
}

/* El campo de busqueda ocupa todo el ancho cuando los filtros se apilan */
@media (max-width: 680px) {
  .invoice-search-field {
    grid-column: 1 / -1;
  }
}

.invoice-filter-bar label {
  display: grid;
  gap: 6px;
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 600;
}

.search-input-wrap {
  position: relative;
  display: block;
}

.search-input-wrap .icon {
  position: absolute;
  left: 13px;
  top: 50%;
  width: 1rem;
  height: 1rem;
  color: var(--muted);
  transform: translateY(-50%);
  pointer-events: none;
}

.search-input-wrap input {
  width: 100%;
  padding-left: 40px;
}

.invoice-filter-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.invoice-filter-actions .button {
  min-height: 44px;
  white-space: nowrap;
}

.invoice-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 18px;
}

.invoice-summary-card {
  display: grid;
  gap: 18px;
}

.invoice-summary-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
}

.invoice-summary-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  color: var(--primary);
  background: var(--blue-soft);
}

.invoice-summary-icon .icon {
  width: 1.35rem;
  height: 1.35rem;
}

.invoice-summary-head h2 {
  margin: 2px 0 0;
}

.invoice-summary-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.invoice-summary-metrics div {
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 12px;
}

.invoice-summary-metrics span,
.invoice-summary-totals dt {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
}

.invoice-summary-metrics strong {
  color: var(--ink);
  font-size: 1.45rem;
  line-height: 1;
}

.invoice-summary-totals {
  display: grid;
  gap: 0;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.invoice-summary-totals div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  padding: 13px 14px;
  background: var(--surface);
}

.invoice-summary-totals div + div {
  border-top: 1px solid var(--line);
}

.invoice-summary-totals dd {
  margin: 0;
  color: var(--ink);
  font-weight: 700;
}

.customer-summary .invoice-summary-icon {
  color: var(--cyan);
  background: var(--cyan-soft);
}

.cash-summary .invoice-summary-icon {
  color: #0f8a4b;
  background: #e7f7ed;
}

.cash-overview .document-kpi strong {
  white-space: nowrap;
}

.quote-total-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  width: 100%;
  max-width: 100%;
  min-width: 0;
  gap: 12px;
}

.quote-total-card {
  display: grid;
  gap: 8px;
  min-width: 0;
  min-height: 92px;
  padding: 16px;
}

.quote-total-card span {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 600;
}

.quote-total-card strong {
  color: var(--ink);
  font-size: 1.45rem;
  line-height: 1;
  overflow-wrap: anywhere;
}

.quote-total-card.primary {
  border-color: color-mix(in srgb, var(--primary) 35%, var(--line));
  background: color-mix(in srgb, var(--primary) 7%, var(--surface));
}

.quote-status {
  min-width: 92px;
  justify-content: center;
}

.quote-status-draft {
  color: var(--muted);
  background: var(--surface-soft);
}

.quote-status-sent {
  color: var(--primary);
  background: var(--blue-soft);
}

.quote-status-accepted {
  color: var(--success);
  background: var(--success-soft);
}

.quote-status-rejected {
  color: var(--danger);
  background: var(--danger-soft);
}

.quote-page {
  display: grid;
  gap: 18px;
}

.quote-builder {
  display: grid;
  gap: 18px;
}

.quote-builder-grid,
.quote-catalog-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.form-grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-grid .span-2 {
  grid-column: 1 / -1;
}

.section-heading-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.quote-lines-panel {
  overflow: hidden;
}

.quote-lines-table {
  display: grid;
  gap: 8px;
}

.quote-line-header,
.quote-line-row {
  display: grid;
  grid-template-columns: minmax(160px, 0.9fr) minmax(240px, 1.4fr) minmax(84px, 0.45fr) minmax(104px, 0.55fr) minmax(84px, 0.45fr) minmax(112px, 0.55fr);
  gap: 8px;
  align-items: center;
}

.quote-line-header {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0 6px;
}

.quote-line-row {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 8px;
}

.quote-line-row strong {
  color: var(--ink);
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.quote-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.quote-builder-totals {
  display: flex;
  gap: 18px;
  margin: 0;
  flex-wrap: wrap;
}

.quote-builder-totals div {
  display: grid;
  gap: 4px;
  min-width: 130px;
}

.quote-builder-totals dt {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
}

.quote-builder-totals dd {
  margin: 0;
  color: var(--ink);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.quote-footer-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.quote-delete-form {
  justify-self: start;
}

.income-page {
  display: grid;
  gap: 18px;
}

.income-form {
  display: grid;
  gap: 20px;
}

.income-form-grid {
  display: grid;
  grid-template-columns: minmax(180px, 0.7fr) minmax(220px, 1fr) minmax(280px, 1.35fr);
  gap: 14px;
  align-items: end;
}

.income-description {
  min-width: 0;
}

.income-tax-panel {
  display: grid;
  gap: 10px;
}

.income-tax-table {
  display: grid;
  gap: 8px;
}

.income-tax-header,
.income-tax-row {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(140px, 0.5fr) minmax(150px, 0.65fr) 44px;
  gap: 10px;
  align-items: center;
}

.income-tax-header {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0 6px;
}

.income-tax-row {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 8px;
}

.income-tax-row label {
  min-width: 0;
}

.income-tax-row strong {
  justify-self: end;
  color: var(--ink);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.income-total-strip {
  border: 1px solid var(--line);
  border-radius: var(--radius-soft);
  background: var(--surface-soft);
  padding: 12px;
}

.income-totals {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
}

.income-totals div {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 12px;
}

.income-totals .primary {
  border-color: color-mix(in srgb, var(--primary) 26%, var(--line));
  background: color-mix(in srgb, var(--primary) 7%, var(--surface));
}

.income-totals dt {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 600;
}

.income-totals dd {
  margin: 0;
  color: var(--ink);
  font-size: 1.2rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.income-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.quote-catalog-form {
  align-self: start;
}

.quote-catalog-table {
  margin-top: 0;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.toggle-row input {
  width: 18px;
  min-height: auto;
  height: 18px;
}

.document-kpi {
  position: relative;
  display: grid;
  gap: 8px;
  min-width: 0;
  min-height: 92px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-soft);
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 14px 16px;
}

.document-kpi::before {
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  content: "";
}

.document-kpi span {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  min-width: 0;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.document-kpi .icon {
  width: 1rem;
  height: 1rem;
}

.document-kpi strong {
  color: var(--ink);
  font-size: 1.55rem;
  line-height: 1;
  overflow-wrap: anywhere;
}

.document-kpi.accent-blue::before {
  background: var(--primary);
}

.document-kpi.accent-green::before {
  background: var(--success);
}

.document-kpi.accent-cyan::before {
  background: var(--cyan);
}

.document-kpi.accent-red::before {
  background: var(--danger);
}

.documents-upload-strip,
.documents-table-section {
  margin-top: 0;
}

.page-subtitle {
  max-width: 780px;
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 1rem;
  font-weight: 600;
}

.mailbox-page {
  display: grid;
  gap: 18px;
}

.mailbox-header {
  margin-bottom: 0;
}

.mailbox-header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.mailbox-header-actions form {
  margin: 0;
}

.mailbox-overview {
  margin: 0;
}

.mailbox-layout,
.mailbox-detail-layout,
.mailbox-reader-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(340px, 0.95fr);
  gap: 18px;
  align-items: start;
}

.mailbox-flow,
.mailbox-connector,
.mailbox-message-card,
.mailbox-reader-card,
.mailbox-side {
  display: grid;
  gap: 16px;
}

.mailbox-steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  width: 100%;
  max-width: 100%;
  min-width: 0;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.mailbox-steps li {
  display: grid;
  gap: 10px;
  align-content: start;
  min-height: 116px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 14px;
}

.mailbox-steps span,
.mailbox-attachment-icon {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius);
  background: var(--blue-soft);
  color: var(--primary);
}

.mailbox-steps strong {
  color: var(--ink);
  font-size: 0.92rem;
}

.mailbox-status-list,
.mailbox-meta-grid {
  display: grid;
  gap: 0;
  margin: 0;
}

.mailbox-status-list div,
.mailbox-meta-grid div {
  display: grid;
  grid-template-columns: minmax(120px, 0.75fr) minmax(0, 1.25fr);
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 11px 0;
}

.mailbox-status-list div:last-child,
.mailbox-meta-grid div:last-child {
  border-bottom: 0;
}

.mailbox-status-list dt,
.mailbox-meta-grid dt {
  color: var(--muted);
  font-weight: 600;
}

.mailbox-status-list dd,
.mailbox-meta-grid dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-weight: 600;
}

.mailbox-table-section {
  margin-top: 0;
}

.mailbox-filter-bar {
  grid-template-columns:
    minmax(260px, 1.25fr)
    minmax(310px, 1fr)
    minmax(190px, 0.78fr)
    minmax(210px, 0.88fr)
    auto;
  margin: 0 0 16px;
}

.mailbox-date-range-field {
  min-width: 0;
}

.date-range-picker {
  display: block;
  width: 100%;
}

.date-range-trigger {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 20px;
  gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  padding: 10px 14px;
  text-align: left;
  font: inherit;
  font-weight: 600;
  transition: border-color 160ms var(--ease-out), box-shadow 160ms var(--ease-out), background 160ms var(--ease-out);
}

.date-range-trigger:hover,
.date-range-trigger[aria-expanded="true"] {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 5%, var(--surface));
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 15%, transparent);
}

.date-range-chevron {
  width: 9px;
  height: 9px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translateY(-2px);
  justify-self: center;
  opacity: 0.82;
}

.date-range-panel {
  position: fixed;
  z-index: 230;
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  gap: 18px;
  max-width: calc(100vw - 24px);
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 24px 90px rgba(15, 23, 42, 0.18);
  padding: 18px;
}

.date-range-panel.is-mobile {
  right: 12px;
  bottom: 14px;
  left: 12px;
  top: auto;
  grid-template-columns: 1fr;
  width: auto;
  max-width: none;
  max-height: calc(100dvh - 28px);
  overflow: auto;
}

.date-range-presets {
  display: grid;
  gap: 8px;
  align-content: start;
  min-height: 330px;
}

.date-range-presets button {
  min-height: 42px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  padding: 8px 10px;
  text-align: left;
  font: inherit;
  font-weight: 600;
}

.date-range-presets button:hover {
  background: var(--blue-soft);
  color: var(--primary-dark);
}

.date-range-presets .date-range-reset {
  align-self: end;
  margin-top: auto;
  color: var(--primary);
}

.date-range-calendar {
  display: grid;
  gap: 12px;
}

.date-range-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.date-range-header strong {
  color: var(--ink);
  font-size: 1.12rem;
  font-weight: 700;
  text-align: center;
}

.date-range-nav {
  display: inline-flex;
  gap: 6px;
}

.date-range-nav button {
  display: inline-grid;
  place-items: center;
  width: 40px;
  min-height: 40px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1;
}

.date-range-nav button:hover {
  background: var(--blue-soft);
  color: var(--primary-dark);
}

.date-range-weekdays,
.date-range-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.date-range-weekdays span {
  min-height: 28px;
  color: var(--muted);
  font-weight: 600;
  text-align: center;
}

.date-range-day {
  position: relative;
  isolation: isolate;
  min-height: 42px;
  border: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-weight: 600;
}

.date-range-day:hover {
  background: var(--blue-soft);
  color: var(--primary-dark);
}

.date-range-day.is-muted {
  color: var(--muted);
  opacity: 0.56;
}

.date-range-day.is-today {
  color: var(--primary-dark);
}

.date-range-day.is-in-range,
.date-range-day.is-range-start,
.date-range-day.is-range-end {
  background: color-mix(in srgb, var(--primary) 15%, transparent);
}

.date-range-day.is-range-start,
.date-range-day.is-range-end {
  color: #fff;
}

.date-range-day.is-range-start::after,
.date-range-day.is-range-end::after {
  position: absolute;
  inset: 4px;
  z-index: -1;
  border-radius: 999px;
  background: var(--primary);
  box-shadow: 0 10px 20px rgba(6, 111, 209, 0.22);
  content: "";
}

.date-range-day.is-range-start {
  border-radius: 999px 0 0 999px;
}

.date-range-day.is-range-end {
  border-radius: 0 999px 999px 0;
}

.mailbox-filter-actions {
  align-self: end;
}

.mailbox-clear-button {
  min-width: 48px;
}

.mailbox-page-size {
  display: grid;
  grid-template-columns: minmax(190px, auto) auto;
  gap: 10px;
  align-items: end;
}

.mailbox-page-size label {
  display: grid;
  gap: 6px;
  min-width: 190px;
}

.mailbox-table-footer {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 14px;
  border-top: 1px solid var(--line);
  margin-top: 16px;
  padding-top: 16px;
}

.mailbox-table-footer .hint {
  margin: 0 0 8px;
}

[data-mailbox-results] {
  transition: opacity 0.15s ease;
}

[data-mailbox-results].is-loading {
  opacity: 0.62;
}

.table-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}

.table-section-header h2 {
  margin: 0;
}

.mailbox-table {
  min-width: 980px;
}

.mailbox-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 6px 11px;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
}

.mailbox-status-pill .icon {
  width: 1rem;
  height: 1rem;
}

.mailbox-status-pill.is-icon-only {
  position: relative;
  justify-content: center;
  width: 38px;
  min-width: 38px;
  min-height: 38px;
  padding: 0;
  cursor: help;
}

.mailbox-status-pill.is-icon-only .icon {
  width: 1.05rem;
  height: 1.05rem;
}

.mailbox-status-pill.is-icon-only::before,
.mailbox-status-pill.is-icon-only::after {
  position: absolute;
  left: 50%;
  z-index: 80;
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transition:
    opacity 80ms var(--ease-out),
    transform 80ms var(--ease-out),
    visibility 0s linear 80ms;
}

.mailbox-status-pill.is-icon-only::after {
  bottom: calc(100% + 9px);
  max-width: 220px;
  border: 1px solid color-mix(in srgb, var(--ink) 10%, transparent);
  border-radius: 10px;
  background: var(--ink);
  box-shadow: 0 14px 38px rgba(15, 23, 42, 0.18);
  color: #fff;
  content: attr(data-tooltip);
  padding: 8px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  transform: translate(-50%, 4px);
  white-space: nowrap;
}

.mailbox-status-pill.is-icon-only::before {
  bottom: calc(100% + 4px);
  width: 9px;
  height: 9px;
  background: var(--ink);
  content: "";
  transform: translate(-50%, 4px) rotate(45deg);
}

.mailbox-status-pill.is-icon-only:hover::before,
.mailbox-status-pill.is-icon-only:hover::after,
.mailbox-status-pill.is-icon-only:focus-visible::before,
.mailbox-status-pill.is-icon-only:focus-visible::after {
  opacity: 1;
  visibility: visible;
  transition-delay: 0s;
}

.mailbox-status-pill.is-icon-only:hover::after,
.mailbox-status-pill.is-icon-only:focus-visible::after {
  transform: translate(-50%, 0);
}

.mailbox-status-pill.is-icon-only:hover::before,
.mailbox-status-pill.is-icon-only:focus-visible::before {
  transform: translate(-50%, 0) rotate(45deg);
}

.mailbox-status-pending {
  border-color: color-mix(in srgb, var(--danger) 28%, transparent);
  background: var(--red-soft);
  color: var(--danger);
}

.mailbox-status-received {
  border-color: color-mix(in srgb, var(--primary) 24%, transparent);
  background: var(--blue-soft);
  color: var(--primary-dark);
}

.mailbox-status-completed {
  border-color: color-mix(in srgb, var(--warning) 34%, transparent);
  background: var(--yellow-soft);
  color: var(--warning-text);
}

.mailbox-status-accounted {
  border-color: color-mix(in srgb, var(--success) 26%, transparent);
  background: var(--green-soft);
  color: var(--success);
}

.mailbox-status-rejected {
  border-color: color-mix(in srgb, var(--danger) 28%, transparent);
  background: var(--red-soft);
  color: var(--danger);
}

.mailbox-status-rejected-credit {
  border-color: color-mix(in srgb, #7c3aed 30%, transparent);
  background: color-mix(in srgb, #7c3aed 12%, var(--surface));
  color: #6d28d9;
}

.mailbox-message-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.mailbox-reader-layout {
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
}

.mailbox-reader-card {
  min-height: 620px;
}

.mailbox-reader-head {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: start;
  border-bottom: 1px solid var(--line);
  padding-bottom: 16px;
}

.mailbox-reader-head h2 {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: clamp(1.4rem, 2vw, 2.25rem);
  line-height: 1.08;
}

.mailbox-reader-icon {
  display: inline-grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: var(--radius);
  background: var(--blue-soft);
  color: var(--primary);
}

.mailbox-envelope-grid {
  display: grid;
  gap: 0;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.mailbox-envelope-grid div {
  display: grid;
  grid-template-columns: minmax(120px, 0.24fr) minmax(0, 1fr);
  gap: 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 13px 16px;
}

.mailbox-envelope-grid div:last-child {
  border-bottom: 0;
}

.mailbox-envelope-grid dt {
  color: var(--muted);
  font-weight: 600;
}

.mailbox-envelope-grid dd {
  display: grid;
  gap: 2px;
  min-width: 0;
  margin: 0;
  color: var(--ink);
  font-weight: 600;
  overflow-wrap: anywhere;
}

.mailbox-envelope-grid dd span {
  color: var(--muted);
  font-size: 0.9rem;
}

.mailbox-body {
  display: grid;
  gap: 8px;
}

.mailbox-message-viewer {
  display: grid;
  gap: 10px;
}

.mailbox-body-text {
  min-height: 220px;
  max-height: 62dvh;
  overflow: auto;
  white-space: pre-wrap;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--surface), var(--surface-soft));
  color: var(--ink);
  padding: 22px;
  font-weight: 500;
  line-height: 1.55;
}

.mailbox-attachment-list {
  display: grid;
  gap: 10px;
}

.mailbox-attachment {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 10px;
}

.mailbox-attachment strong,
.mailbox-attachment span {
  display: block;
  overflow-wrap: anywhere;
}

.mailbox-attachment span {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 600;
}

.mailbox-attachment .row-actions {
  justify-content: end;
}

.mailbox-attachment .row-actions form {
  display: inline-flex;
  margin: 0;
}

.mailbox-attachment.is-registered {
  border-color: rgba(87, 184, 97, 0.28);
  background: var(--green-soft);
}

.mailbox-attachment.is-registered .mailbox-attachment-icon {
  background: rgba(87, 184, 97, 0.16);
  color: var(--success);
}

.mailbox-attachment.has-error {
  border-color: rgba(215, 54, 54, 0.3);
  background: var(--red-soft);
}

.mailbox-attachment.has-error .mailbox-attachment-icon {
  background: rgba(215, 54, 54, 0.12);
  color: var(--danger);
}

.mailbox-linked {
  display: grid;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.mailbox-history-dialog {
  width: min(620px, 100%);
}

.mailbox-history-result {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  border: 1px solid color-mix(in srgb, var(--primary) 28%, var(--line));
  border-radius: var(--radius);
  background: var(--blue-soft);
  padding: 14px;
}

.mailbox-history-result-icon {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--primary);
}

.mailbox-history-result strong,
.mailbox-history-result span,
.mailbox-history-result small {
  display: block;
}

.mailbox-history-result strong {
  color: var(--ink);
  font-size: 1.05rem;
}

.mailbox-history-result span {
  color: var(--text);
  font-weight: 600;
}

.mailbox-history-result small {
  margin-top: 4px;
  color: var(--muted);
  font-weight: 600;
}

.pagination-bar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  border-top: 1px solid var(--line);
  margin-top: 16px;
  padding-top: 16px;
}

.pagination-bar span {
  color: var(--muted);
  font-weight: 600;
}

.button.is-disabled,
.button[aria-disabled="true"] {
  pointer-events: none;
  opacity: 0.5;
}

.year-filter label {
  display: grid;
  gap: 6px;
  min-width: 160px;
}

.liquidation-overview {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  width: 100%;
  max-width: 100%;
  min-width: 0;
  gap: 14px;
  margin-bottom: 18px;
}

.liquidation-card,
.quarter-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-soft);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.liquidation-card {
  display: grid;
  gap: 8px;
  min-width: 0;
  min-height: 112px;
  padding: 18px;
  border-left: 4px solid var(--primary);
}

.liquidation-card span,
.quarter-totals span {
  color: var(--muted);
  font-weight: 600;
}

.liquidation-card strong {
  color: var(--ink);
  font-size: 1.55rem;
  line-height: 1;
  overflow-wrap: anywhere;
}

.liquidation-section {
  margin-bottom: 18px;
}

.quarter-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.quarter-card {
  display: grid;
  gap: 16px;
  padding: 16px;
}

.quarter-card header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.quarter-range {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.quarter-pdf-button {
  width: 36px;
  height: 36px;
  min-height: 36px;
  border-color: rgba(220, 38, 38, 0.24);
  color: #dc2626;
  background: rgba(254, 242, 242, 0.78);
}

.quarter-pdf-button .icon {
  width: 1rem;
  height: 1rem;
}

.liquidation-pdf-dialog {
  width: min(640px, 100%);
}

.liquidation-pdf-options {
  display: grid;
  gap: 12px;
}

.liquidation-pdf-option {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  min-height: 86px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  color: var(--ink);
  padding: 14px;
  text-decoration: none;
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.liquidation-pdf-option:hover,
.liquidation-pdf-option:focus-visible {
  border-color: rgba(6, 111, 209, 0.34);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.liquidation-pdf-option-icon {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 12px;
  color: #dc2626;
  background: rgba(254, 242, 242, 0.86);
}

.liquidation-pdf-option-icon .icon {
  width: 1.25rem;
  height: 1.25rem;
}

.liquidation-pdf-option strong,
.liquidation-pdf-option small {
  display: block;
}

.liquidation-pdf-option strong {
  font-size: 1rem;
}

.liquidation-pdf-option small {
  margin-top: 3px;
  color: var(--muted);
  font-weight: 600;
  line-height: 1.4;
}

.quarter-totals {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.quarter-totals div {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 12px;
}

.quarter-totals strong {
  color: var(--ink);
  font-size: 1.15rem;
}

.quarter-totals small {
  color: var(--muted);
  font-weight: 700;
}

.liquidation-results {
  display: grid;
  gap: 8px;
  margin: 0;
}

.liquidation-results div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.liquidation-results dt {
  color: var(--muted);
  font-weight: 600;
}

.liquidation-results dd {
  margin: 0;
  color: var(--ink);
  font-weight: 700;
}

.liquidation-table {
  min-width: 1180px;
}

.compact-button {
  min-height: 36px;
  padding: 7px 10px;
  font-size: 0.82rem;
  white-space: nowrap;
}

.liquidation-report-grid {
  margin-bottom: 18px;
}

.tax-disclosure {
  display: grid;
  gap: 10px;
}

.tax-disclosure summary {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  padding: 8px 34px 8px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-soft);
  color: var(--ink);
  cursor: pointer;
  list-style: none;
}

.tax-disclosure summary::-webkit-details-marker {
  display: none;
}

.tax-disclosure summary::after {
  position: absolute;
  right: 13px;
  width: 8px;
  height: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  content: "";
  transform: rotate(45deg) translateY(-2px);
  transition: transform 160ms ease;
}

.tax-disclosure[open] summary::after {
  transform: rotate(225deg) translate(-2px, -2px);
}

.tax-disclosure summary span {
  font-weight: 700;
}

.tax-disclosure summary small {
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 700;
}

.tax-breakdown-list {
  display: grid;
  gap: 7px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tax-breakdown-list li {
  display: grid;
  grid-template-columns: minmax(72px, 0.4fr) minmax(120px, 0.5fr) minmax(150px, 1fr);
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 600;
}

.tax-breakdown-list strong {
  color: var(--ink);
  font-size: 0.94rem;
}

.tax-rate {
  color: var(--primary);
  font-weight: 700;
}

.tax-breakdown-empty {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.accent-blue {
  border-left-color: var(--primary);
}

.accent-green {
  border-left-color: var(--success);
}

.accent-cyan {
  border-left-color: var(--cyan);
}

.accent-red {
  border-left-color: var(--danger);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 13px 12px;
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: none;
}

td {
  color: var(--text);
}

td a {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--ink);
  font-weight: 600;
}

tr:last-child td {
  border-bottom: 0;
}

tbody tr {
  transition: background 120ms var(--ease-out);
}

tbody tr:hover {
  background: var(--row-hover);
}

.pill,
.ai-state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  min-height: 30px;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.25;
  white-space: nowrap;
}

.pill .icon,
.ai-state .icon,
.type-label .icon {
  width: 0.95rem;
  height: 0.95rem;
}

.pill.icon-pill {
  justify-content: center;
  width: 36px;
  min-width: 36px;
  min-height: 36px;
  padding: 0;
}

/* Texto del estado solo visible cuando la tabla se vuelve tarjetas (movil) */
.pill-text-mobile {
  display: none;
}

.pill.icon-pill .icon {
  width: 1.05rem;
  height: 1.05rem;
}

.pill.analyzing,
.ai-state.off {
  background: var(--yellow-soft);
  color: var(--warning-text);
}

.pill.uploaded {
  background: var(--blue-soft);
  color: var(--primary-dark);
}

.pill.analyzed,
.pill.resolved,
.ai-state.on {
  background: var(--green-soft);
  color: var(--success);
}

.pill.posted {
  background: var(--green-soft);
  color: var(--success);
}

.pill.error {
  background: var(--red-soft);
  color: var(--danger);
}

.type-label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 100%;
  color: var(--ink);
  font-weight: 600;
  overflow-wrap: anywhere;
}

.notice.error,
.form-error {
  background: var(--red-soft);
  color: var(--danger);
}

.pill.validation-pending {
  background: var(--yellow-soft);
  color: var(--warning-text);
}

.pill.validation-valid {
  background: var(--green-soft);
  color: var(--success);
}

.pill.validation-rejected {
  background: var(--red-soft);
  color: var(--danger);
}

.document-list-table tr.needs-rectification {
  background: color-mix(in srgb, var(--warning) 10%, var(--surface));
}

.document-list-table tr.needs-rectification:hover {
  background: color-mix(in srgb, var(--warning) 16%, var(--surface));
}

.detail-layout {
  display: grid;
  grid-template-columns: minmax(320px, 0.9fr) minmax(420px, 1.1fr);
  gap: 18px;
  align-items: start;
}

.document-panel {
  position: sticky;
  top: 24px;
}

.document-preview {
  display: block;
  width: 100%;
  min-height: clamp(620px, 76dvh, 920px);
  max-height: 78dvh;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--preview-bg);
  object-fit: contain;
}

iframe.document-preview {
  object-fit: initial;
}

.pdf-raster-preview {
  display: grid;
  align-items: start;
  justify-items: center;
  gap: 16px;
  height: clamp(620px, 76dvh, 920px);
  padding: 14px;
  overflow: auto;
  background: #eef2f7;
}

:root[data-theme="dark"] .pdf-raster-preview {
  background: #0b1220;
}

.pdf-raster-preview img {
  display: block;
  width: min(100%, 760px);
  height: auto;
  border: 1px solid color-mix(in srgb, var(--line) 86%, transparent);
  border-radius: 6px;
  background: #ffffff;
  box-shadow: 0 14px 36px rgba(15, 23, 42, 0.16);
}

.document-modal[hidden] {
  display: none;
}

.document-modal {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  overflow-y: auto;
  background: rgba(9, 13, 28, 0.58);
  padding: 24px;
  backdrop-filter: blur(2px);
}

.document-modal-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: transparent;
  backdrop-filter: blur(2px);
  cursor: zoom-out;
}

.document-modal-dialog {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
  width: min(1040px, 100%);
  max-height: calc(100dvh - 48px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 16px;
}

.document-modal-dialog:focus {
  outline: 3px solid rgba(6, 111, 209, 0.26);
  outline-offset: 3px;
}

.document-modal-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
}

.document-modal-title {
  min-width: 0;
}

.document-modal-header h2 {
  margin: 0;
  font-size: 1rem;
  overflow-wrap: anywhere;
}

.document-preview-meta {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
  overflow-wrap: anywhere;
}

.document-modal-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.document-modal-actions [aria-disabled="true"] {
  pointer-events: none;
  opacity: 0.52;
}

.document-preview-stage {
  display: grid;
  align-content: start;
  align-items: start;
  justify-items: center;
  min-height: min(72dvh, 860px);
  height: min(72dvh, 860px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #0e162a;
  padding: 8px;
}

.document-preview-frame {
  display: block;
  width: 100%;
  height: 100%;
  min-height: min(72dvh, 860px);
  border: 0;
  border-radius: 8px;
  background: #ffffff;
}

.document-preview-raster-modal {
  display: grid;
  align-content: start;
  justify-items: center;
  gap: 16px;
  width: 100%;
  padding: 8px;
}

.document-preview-raster-modal img {
  display: block;
  width: min(100%, 980px);
  height: auto;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.28);
}

.ui-modal[hidden] {
  display: none;
}

.ui-modal {
  position: fixed;
  inset: 0;
  width: auto;
  max-width: none;
  margin: 0;
  z-index: 140;
  display: grid;
  place-items: center;
  overflow-y: auto;
  background: rgba(9, 13, 28, 0.58);
  padding: 22px;
  backdrop-filter: blur(3px);
}

.ui-modal-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.ui-modal-dialog {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 16px;
  width: min(560px, 100%);
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.24);
  padding: 18px;
}

.ui-modal-dialog:focus {
  outline: 3px solid rgba(6, 111, 209, 0.26);
  outline-offset: 3px;
}

.working-modal {
  z-index: 190;
  background:
    radial-gradient(circle at 50% 18%, color-mix(in srgb, var(--primary) 20%, transparent), transparent 34%),
    rgba(9, 13, 28, 0.68);
}

.working-dialog {
  width: min(520px, 100%);
  gap: 18px;
  border-color: color-mix(in srgb, var(--primary) 32%, var(--line));
}

.working-header {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
}

.working-header h2 {
  margin: 0;
  font-size: 1.24rem;
}

.working-icon {
  display: inline-grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--primary) 10%, var(--surface-soft));
  color: var(--primary);
}

.working-icon .icon {
  width: 1.35rem;
  height: 1.35rem;
  animation: working-pulse 1300ms ease-in-out infinite;
}

.working-message,
.working-detail {
  margin: 0;
  color: var(--muted);
  font-weight: 600;
}

.working-progress {
  position: relative;
  height: 12px;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--primary) 18%, var(--line));
  border-radius: 999px;
  background: color-mix(in srgb, var(--primary) 8%, var(--surface-soft));
}

.working-progress span {
  position: absolute;
  inset: 2px auto 2px 2px;
  width: 42%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), var(--cyan), var(--primary));
  box-shadow: 0 0 22px color-mix(in srgb, var(--primary) 36%, transparent);
  animation: working-progress 1250ms ease-in-out infinite;
}

@keyframes working-progress {
  0% {
    transform: translateX(-110%);
  }

  100% {
    transform: translateX(250%);
  }
}

@keyframes working-pulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.78;
  }

  50% {
    transform: scale(1.08);
    opacity: 1;
  }
}

.ui-modal-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  gap: 14px;
  align-items: start;
}

.ui-modal-header h2 {
  margin: 0;
  font-size: 1.2rem;
}

.confirm-message,
.modal-text-block p,
.modal-message p {
  margin: 0;
  color: var(--text);
}

.ui-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.unsaved-actions {
  justify-content: stretch;
}

.unsaved-actions .button {
  flex: 1 1 150px;
}

.unsaved-actions .button.primary {
  flex-basis: 190px;
}

.modal-message {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 14px;
}

.modal-message.warning {
  border-color: color-mix(in srgb, var(--warning) 42%, var(--line));
  background: var(--yellow-soft);
  color: var(--warning-text);
}

.modal-text-block {
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 14px;
}

.modal-text-block strong {
  color: var(--primary-dark);
}

.session-warning-modal,
.session-expired-modal {
  z-index: 180;
  background:
    radial-gradient(circle at 50% 18%, rgba(6, 111, 209, 0.16), transparent 30%),
    rgba(9, 13, 28, 0.68);
}

.session-warning-dialog {
  width: min(520px, 100%);
  border-color: color-mix(in srgb, var(--warning) 34%, var(--line));
}

.session-warning-icon {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  background: var(--yellow-soft);
  color: var(--warning-text);
}

.session-warning-icon .icon {
  width: 1.25rem;
  height: 1.25rem;
}

.session-warning-copy {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
}

.session-countdown {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  border: 1px solid color-mix(in srgb, var(--warning) 32%, var(--line));
  border-radius: var(--radius);
  background: var(--yellow-soft);
  padding: 14px;
}

.session-countdown span {
  color: var(--warning-text);
  font-weight: 600;
}

.session-countdown strong {
  color: var(--ink);
  font-size: 1.6rem;
  line-height: 1;
  letter-spacing: 0;
}

.document-list-table {
  min-width: 1080px;
}

.documents-table-section {
  overflow: hidden;
  padding: 0;
}

.documents-table-section .table-wrap {
  padding: 8px 14px 14px;
}

.document-list-table th {
  padding-top: 15px;
}

.document-list-table td {
  padding-top: 15px;
  padding-bottom: 15px;
}

.document-list-table .primary-cell {
  min-width: 260px;
  max-width: 340px;
  color: var(--ink);
  font-weight: 700;
}

.document-main {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.document-list-table .document-title {
  display: inline-block;
  max-width: 100%;
  color: var(--ink);
  font-weight: 700;
  overflow-wrap: anywhere;
}

.document-meta {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.actions-column {
  width: 104px;
}

.row-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

/* Patron generico tabla -> tarjetas en tablet estrecho y movil.
   Cualquier tabla con la clase .cards-mobile reorganiza cada fila como una
   tarjeta apilada; cada celda con data-label muestra su etiqueta a la
   izquierda y su valor a la derecha, evitando el scroll horizontal. */
@media (max-width: 860px) {
  .cards-mobile-wrap,
  .documents-table-section .table-wrap {
    padding: 0;
    overflow: visible;
  }

  table.cards-mobile {
    min-width: 0;
    border-collapse: separate;
  }

  table.cards-mobile thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  table.cards-mobile tr {
    display: block;
    margin-bottom: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius-soft);
    background: var(--surface);
    padding: 14px 16px;
    box-shadow: var(--shadow);
  }

  table.cards-mobile td {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    border: 0;
    padding: 5px 0;
    text-align: right;
  }

  table.cards-mobile td[data-label]::before {
    content: attr(data-label);
    margin-right: auto;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 600;
    text-align: left;
  }

  /* La primera celda encabeza la tarjeta a todo el ancho, alineada izquierda */
  table.cards-mobile td:first-child {
    min-width: 0;
    max-width: none;
    justify-content: flex-start;
    margin-bottom: 6px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--line);
    text-align: left;
  }

  table.cards-mobile td:first-child::before {
    content: none;
  }

  table.cards-mobile td:first-child .document-main,
  table.cards-mobile td:first-child .party-table-name {
    width: 100%;
  }

  /* Texto del estado/validacion junto al icono dentro de la tarjeta */
  table.cards-mobile .pill-text-mobile {
    display: inline;
    color: var(--ink);
    font-weight: 600;
  }

  /* Importes destacados */
  table.cards-mobile td[data-label] strong {
    font-size: 1.05rem;
  }

  /* Ultima celda (acciones) a todo el ancho con buen tamano de toque */
  table.cards-mobile td:last-child {
    justify-content: flex-start;
    padding-top: 10px;
  }

  table.cards-mobile td:last-child:not([data-label])::before {
    content: none;
  }

  table.cards-mobile .row-actions,
  table.cards-mobile .table-actions {
    display: inline-flex;
    gap: 8px;
    width: 100%;
    justify-content: flex-start;
  }
}

.row-actions form {
  margin: 0;
}

.party-table-name {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: var(--ink);
  font-weight: 700;
}

.party-report-dialog {
  width: min(680px, 100%);
}

.party-report-presets {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
  gap: 10px;
}

.modal-help {
  margin: -2px 0 0;
  color: var(--muted);
  font-weight: 600;
}

.report-range-form {
  display: grid;
  gap: 14px;
  margin-top: 2px;
}

.report-range-form label {
  display: grid;
  gap: 8px;
  color: var(--ink);
  font-weight: 600;
}

.table-icon-button {
  width: 38px;
  min-height: 38px;
  border-radius: 12px;
}

.table-icon-button .icon {
  width: 1rem;
  height: 1rem;
}

.document-preview-image {
  display: block;
  max-width: 100%;
  max-height: 100%;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: #0e162a;
  object-fit: contain;
}

.document-preview-fallback {
  display: grid;
  place-items: center;
  gap: 10px;
  text-align: center;
  color: #d8deea;
  padding: 28px;
}

.review-panel {
  display: grid;
  gap: 18px;
}

.review-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.review-form .section-heading {
  align-items: center;
}

.review-fieldset {
  display: grid;
  gap: 14px;
  min-width: 0;
  margin: 0;
  border: 0;
  padding: 0;
}

.review-form.is-locked .review-fieldset {
  opacity: 0.72;
}

.review-form.is-locked input,
.review-form.is-locked select,
.review-form.is-locked textarea {
  cursor: not-allowed;
}

.review-save-button,
.review-cancel-button {
  display: none;
}

.review-form.is-editing .review-save-button,
.review-form.is-editing .review-cancel-button {
  display: inline-flex;
}

.review-form.is-editing .review-edit-button {
  display: none;
}

.review-locked-note {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  margin: -4px 0 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  padding: 8px 12px;
  font-size: 0.86rem;
  font-weight: 600;
}

.final-action-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, 0.38fr);
  gap: 10px;
}

.final-action-grid form {
  margin: 0;
}

.final-action-grid .button,
.final-action-grid form .button {
  width: 100%;
}

.final-edit-large {
  grid-column: span 1;
}

.reject-options {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.reject-options form {
  margin: 0;
}

.reject-options .button {
  width: 100%;
  justify-content: flex-start;
  text-align: left;
  white-space: normal;
}

.chat-float-button {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 44;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 54px;
  min-width: 54px;
  height: 54px;
  min-height: 54px;
  border: 1px solid color-mix(in srgb, var(--primary) 34%, var(--line));
  border-radius: 999px;
  background: var(--surface);
  color: var(--primary);
  padding: 0;
  box-shadow: 0 18px 50px rgba(6, 111, 209, 0.22);
  cursor: pointer;
  transition: transform 160ms var(--ease-out), opacity 160ms var(--ease-out), background 160ms var(--ease-out), color 160ms var(--ease-out);
}

.chat-float-button .icon {
  width: 1.35rem;
  height: 1.35rem;
}

.chat-float-button:hover {
  background: var(--primary);
  color: white;
  transform: translateY(-2px);
}

.chat-float-button:active {
  transform: translateY(0) scale(0.96);
}

body.chat-open .chat-float-button {
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px) scale(0.96);
}

.invoice-chat {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 45;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: min(430px, calc(100vw - 32px));
  max-height: min(690px, calc(100dvh - 44px));
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.22);
  opacity: 0;
  pointer-events: none;
  transform: translateY(16px) scale(0.98);
  transition: opacity 180ms var(--ease-out), transform 180ms var(--ease-out);
}

.invoice-chat.is-open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.chat-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  padding: 16px;
}

.chat-header p:last-child {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.chat-icon-button,
.chat-send {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 160ms var(--ease-out), color 160ms var(--ease-out), transform 140ms var(--ease-out);
}

.chat-icon-button {
  background: var(--surface-soft);
  color: var(--muted);
}

.chat-icon-button:hover {
  color: var(--ink);
}

.chat-log {
  display: grid;
  align-content: start;
  gap: 12px;
  min-height: 260px;
  overflow-y: auto;
  background: var(--surface-soft);
  padding: 16px;
}

.chat-message {
  max-width: 86%;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  color: var(--text);
  padding: 10px 12px;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.05);
}

.chat-markdown > * {
  margin: 0;
}

.chat-markdown > * + * {
  margin-top: 8px;
}

.chat-markdown p {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.chat-markdown h3,
.chat-markdown h4 {
  color: inherit;
  font-size: 0.98rem;
  line-height: 1.25;
}

.chat-markdown ul {
  padding-left: 1.05rem;
}

.chat-markdown li + li {
  margin-top: 4px;
}

.chat-markdown code {
  border: 1px solid color-mix(in srgb, currentColor 18%, transparent);
  border-radius: 6px;
  background: color-mix(in srgb, currentColor 8%, transparent);
  padding: 1px 5px;
  font-size: 0.88em;
  font-weight: 600;
}

.chat-message.user {
  justify-self: end;
  border-color: transparent;
  border-bottom-right-radius: 5px;
  background: var(--primary);
  color: white;
}

.chat-message.assistant {
  justify-self: start;
  border-bottom-left-radius: 5px;
}

.chat-message.pending .chat-markdown {
  color: var(--muted);
}

.chat-message.typing .chat-markdown {
  position: relative;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.chat-message.typing .chat-markdown::after {
  content: "";
  display: inline-block;
  width: 7px;
  height: 1em;
  margin-left: 3px;
  border-radius: 999px;
  background: currentColor;
  opacity: 0.5;
  vertical-align: -0.12em;
  animation: typing-caret 900ms steps(2, end) infinite;
}

@keyframes typing-caret {
  50% {
    opacity: 0;
  }
}

.chat-message.error {
  border-color: #f4b6b6;
  background: var(--red-soft);
  color: var(--danger);
}

.chat-message.notice {
  border-color: color-mix(in srgb, var(--success) 36%, var(--line));
  background: var(--green-soft);
  color: var(--success);
}

.chat-learning-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  min-height: 34px;
  margin-top: 10px;
  border: 1px solid color-mix(in srgb, var(--success) 42%, var(--line));
  border-radius: 8px;
  background: var(--surface);
  color: var(--success);
  padding: 7px 10px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}

.chat-learning-action:hover {
  background: color-mix(in srgb, var(--success) 10%, var(--surface));
}

.chat-learning-action:disabled {
  cursor: wait;
  opacity: 0.65;
}

.chat-empty {
  align-self: center;
  justify-self: center;
  max-width: 300px;
  color: var(--muted);
  text-align: center;
}

.chat-empty .icon {
  width: 2rem;
  height: 2rem;
  margin-bottom: 10px;
  color: var(--primary);
}

.chat-empty h3 {
  color: var(--ink);
}

.chat-form {
  display: grid;
  gap: 8px;
  border-top: 1px solid var(--line);
  padding: 12px;
}

.chat-format-bar {
  display: flex;
  gap: 6px;
  align-items: center;
}

.chat-format-button {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  transition: border-color 160ms var(--ease-out), color 160ms var(--ease-out), background 160ms var(--ease-out), transform 140ms var(--ease-out);
}

.chat-format-button:hover {
  border-color: color-mix(in srgb, var(--primary) 44%, var(--line));
  background: var(--blue-soft);
  color: var(--primary-dark);
}

.chat-learning-button {
  margin-left: 2px;
}

.chat-learning-button.is-active {
  border-color: #f59e0b;
  background: color-mix(in srgb, #f59e0b 20%, var(--surface));
  color: #b45309;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.18), 0 8px 20px rgba(245, 158, 11, 0.18);
}

.chat-learning-button.is-active .icon {
  filter: drop-shadow(0 0 5px rgba(245, 158, 11, 0.55));
}

.chat-format-button:active {
  transform: scale(0.96);
}

.chat-format-button .icon {
  width: 1rem;
  height: 1rem;
}

.chat-compose-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  gap: 10px;
}

.chat-form textarea {
  min-height: 46px;
  max-height: 140px;
  resize: vertical;
}

.chat-format-help {
  margin: 0;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
}

.chat-send {
  align-self: end;
  background: var(--primary);
  color: white;
}

.chat-send:hover {
  background: var(--primary-dark);
}

.chat-send:active {
  transform: scale(0.96);
}

.chat-send:disabled {
  cursor: wait;
  opacity: 0.62;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.key-values {
  display: grid;
  gap: 10px;
  margin: 16px 0 0;
}

.key-values.spaced {
  gap: 14px;
}

.key-values div {
  display: grid;
  grid-template-columns: minmax(110px, 0.38fr) minmax(0, 1fr);
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.key-values div:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.key-values dt {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  min-width: 0;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 600;
}

.key-values dt .icon {
  width: 0.95rem;
  height: 0.95rem;
  color: var(--primary);
}

.key-values dd {
  min-width: 0;
  margin: 0;
  color: var(--ink);
  font-weight: 700;
  overflow-wrap: anywhere;
}

.document-summary .key-values {
  margin-bottom: 14px;
}

.tax-breakdown {
  display: grid;
  gap: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.tax-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-height: 42px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  padding: 10px 12px;
}

.tax-row:last-child {
  border-bottom: 0;
}

.tax-row span {
  min-width: 0;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.tax-row strong {
  color: var(--ink);
  white-space: nowrap;
}

.tax-row.muted {
  background: var(--surface-soft);
}

.tax-row.surcharge {
  background: var(--blue-soft);
}

.tax-row.withholding {
  background: var(--red-soft);
}

.tax-row.withholding strong,
.tax-row.withholding span {
  color: var(--danger);
}

.month-accordion {
  display: grid;
  gap: 12px;
}

.month-group {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

.month-group summary {
  display: grid;
  grid-template-columns: minmax(130px, 1fr) auto auto;
  gap: 14px;
  align-items: center;
  cursor: pointer;
  padding: 16px;
  color: var(--ink);
  font-weight: 700;
}

.month-group summary::marker {
  color: var(--primary);
}

.month-group summary strong {
  white-space: nowrap;
}

.month-group summary em {
  color: var(--muted);
  font-style: normal;
  font-size: 0.9rem;
  white-space: nowrap;
}

.table-wrap.nested {
  border-width: 1px 0 0;
  border-radius: 0;
  box-shadow: none;
}

.tax-note {
  margin: 0;
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--muted);
  padding: 0 12px 10px;
  font-size: 0.82rem;
}

.line-tree {
  display: grid;
  gap: 10px;
}

.line-tools-heading {
  align-items: start;
}

.line-reanalysis-form {
  justify-self: end;
}

.line-reanalysis-form .button {
  white-space: nowrap;
}

.line-reanalysis-button {
  border-color: var(--line);
  background: var(--surface);
  color: var(--ink);
  box-shadow: none;
}

.line-reanalysis-button:hover {
  border-color: #bfdbfe;
  background: var(--blue-soft);
  color: var(--primary-dark);
}

.line-reanalysis-button.needs-attention {
  border-color: color-mix(in srgb, var(--warning) 46%, var(--line));
  background: var(--yellow-soft);
  color: var(--warning-text);
}

.line-reanalysis-button.needs-attention:hover {
  border-color: var(--warning);
  background: color-mix(in srgb, var(--warning) 16%, var(--surface));
}

.line-reanalysis-warning {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin: -2px 0 14px;
  border: 1px solid color-mix(in srgb, var(--warning) 34%, var(--line));
  border-radius: var(--radius);
  background: var(--yellow-soft);
  color: var(--warning-text);
  padding: 10px 12px;
  font-size: 0.88rem;
  font-weight: 600;
}

.line-reanalysis-warning .icon {
  width: 1.05rem;
  height: 1.05rem;
  margin-top: 2px;
}

.line-group {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.line-group summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-height: 48px;
  padding: 12px 14px;
  cursor: pointer;
  list-style: none;
}

.line-group summary::-webkit-details-marker {
  display: none;
}

.line-group summary::after {
  content: "+";
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-weight: 700;
  grid-column: 2;
  grid-row: 1;
}

.line-group[open] > summary::after {
  content: "-";
}

.line-group-title {
  display: flex;
  gap: 10px;
  align-items: center;
  min-width: 0;
}

.line-group-title .icon {
  flex: 0 0 auto;
  width: 1rem;
  height: 1rem;
  color: var(--primary);
}

.line-group-title span {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.line-group-title em {
  color: var(--muted);
  font-size: 0.72rem;
  font-style: normal;
  font-weight: 700;
}

.line-group-title strong,
.line-item-row span {
  overflow-wrap: anywhere;
}

.line-group-amounts {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-right: 34px;
  color: var(--ink);
  font-weight: 700;
  white-space: nowrap;
}

.line-group-body {
  display: grid;
  gap: 8px;
  border-top: 1px solid var(--line);
  background: var(--surface-soft);
  padding: 10px;
}

.line-group.subsection {
  border-color: color-mix(in srgb, var(--primary) 18%, var(--line));
}

.line-group.subsection > summary {
  min-height: 42px;
  background: color-mix(in srgb, var(--primary) 5%, var(--surface));
}

.line-item-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(42px, auto) auto;
  gap: 12px;
  align-items: center;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 9px 10px;
}

.line-item-row.standalone {
  border-radius: var(--radius);
}

.line-item-row small {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
}

.line-item-row strong {
  white-space: nowrap;
}

.lower-grid {
  margin-top: 18px;
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.form-error {
  margin: 0;
  border-radius: var(--radius);
  padding: 10px 12px;
  font-weight: 700;
}

.notice {
  margin-bottom: 18px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 12px 14px;
  font-weight: 600;
}

.notice.success {
  border-color: #bce7c5;
  background: var(--green-soft);
  color: var(--success);
}

.notice.info {
  border-color: #bfdbfe;
  background: var(--blue-soft);
  color: var(--primary-dark);
}

.notice.error {
  border-color: #f4b6b6;
}

.toast-stack {
  position: fixed;
  top: calc(18px + env(safe-area-inset-top));
  right: 18px;
  z-index: 50;
  display: grid;
  gap: 10px;
  width: min(380px, calc(100vw - 32px));
  pointer-events: none;
}

.toast {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) 42px;
  align-items: center;
  gap: 12px;
  min-height: 72px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-soft);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 16px 42px rgba(15, 23, 42, 0.16);
  padding: 12px 8px 12px 14px;
  pointer-events: auto;
  opacity: 0;
  transform: translateY(-8px) scale(0.98);
  animation:
    toast-in 180ms var(--ease-out) forwards,
    toast-fallback-hide 5400ms ease forwards;
}

.toast.is-managed {
  animation: toast-in 180ms var(--ease-out) forwards;
}

.toast.success {
  border-left-color: var(--success);
}

.toast.info {
  border-left-color: var(--primary);
}

.toast.warning {
  border-left-color: var(--warning);
}

.toast.error {
  border-left-color: var(--danger);
}

.toast-icon {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  background: var(--blue-soft);
  color: var(--primary-dark);
}

.toast-icon .icon {
  width: 1.25rem;
  height: 1.25rem;
}

.toast.success .toast-icon {
  background: var(--green-soft);
  color: var(--success);
}

.toast.warning .toast-icon {
  background: var(--yellow-soft);
  color: var(--warning-text);
}

.toast.error .toast-icon {
  background: var(--red-soft);
  color: var(--danger);
}

.toast-title {
  min-width: 0;
  margin: 0;
  color: var(--text);
  font-size: 0.98rem;
  line-height: 1.35;
  font-weight: 600;
  overflow-wrap: anywhere;
  text-wrap: pretty;
}

.toast-close {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 160ms var(--ease-out), color 160ms var(--ease-out);
}

.toast-close:hover {
  background: var(--surface-soft);
  color: var(--ink);
}

.toast-close .icon {
  width: 1rem;
  height: 1rem;
}

.toast.is-hiding {
  animation: toast-out 170ms ease-in forwards;
}

.toast-progress {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 3px;
  background: var(--primary);
  transform-origin: left;
  animation: toast-progress var(--toast-duration, 4200ms) linear forwards;
}

.toast.success .toast-progress {
  background: var(--success);
}

.toast.warning .toast-progress {
  background: var(--warning);
}

.toast.error .toast-progress {
  background: var(--danger);
}

@keyframes toast-in {
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateY(-8px) scale(0.98);
  }
}

@keyframes toast-fallback-hide {
  0%,
  88% {
    opacity: 1;
    visibility: visible;
  }

  100% {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(-8px) scale(0.98);
  }
}

@keyframes toast-progress {
  to {
    transform: scaleX(0);
  }
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: var(--empty-bg);
  padding: 32px;
  text-align: center;
}

.empty-state.small {
  padding: 22px;
  text-align: left;
}

.empty-state p {
  margin-bottom: 0;
  color: var(--muted);
}

.compact-table table {
  min-width: 520px;
}

.final-action {
  margin: 0;
}

.settings-page {
  display: grid;
  width: min(1120px, 100%);
  margin-inline: auto;
}

.settings-page > .page-header,
.settings-section-tabs,
.settings-tab-panel {
  width: 100%;
  max-width: none;
  margin-right: 0;
  margin-left: 0;
}

.settings-page > .page-header {
  margin-bottom: 22px;
}

.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.8fr);
  gap: 18px;
  align-items: start;
}

.settings-section-tabs {
  margin: -10px 0 18px;
}

.settings-tab-panel {
  display: grid;
  gap: 18px;
}

.settings-tab-panel > .panel {
  width: 100%;
}

.settings-password {
  width: 100%;
}

.settings-mailbox {
  width: 100%;
}

.settings-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.switch-control {
  display: inline-grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  max-width: max-content;
  cursor: pointer;
}

.switch-control input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch-control span {
  position: relative;
  width: 48px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
  transition: background 160ms var(--ease-out), border-color 160ms var(--ease-out);
}

.switch-control span::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  background: var(--muted);
  content: "";
  transition: transform 160ms var(--ease-out), background 160ms var(--ease-out);
}

.switch-control input:focus-visible + span {
  outline: 3px solid color-mix(in srgb, var(--primary) 35%, transparent);
  outline-offset: 3px;
}

.switch-control input:checked + span {
  border-color: color-mix(in srgb, var(--primary) 42%, var(--line));
  background: var(--blue-soft);
}

.switch-control input:checked + span::after {
  background: var(--primary);
  transform: translateX(20px);
}

.switch-control strong {
  color: var(--ink);
  font-weight: 700;
}

.settings-actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.settings-password .form-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.settings-choice-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.settings-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--ink);
  padding: 6px 10px;
  font-size: 0.82rem;
  font-weight: 600;
}

@media (max-width: 1040px) {
  .app-shell {
    display: block;
  }

  .app-shell.has-sidebar ~ .route-transition-overlay {
    left: 0;
  }

  .sidebar {
    display: none;
  }

  .app-shell.has-sidebar .main,
  .app-shell.no-sidebar .main {
    width: 100%;
    margin-left: 0;
  }

  .main {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
    overflow-x: clip;
    padding: 24px 24px calc(108px + env(safe-area-inset-bottom));
  }

  .mobile-tabbar {
    position: fixed;
    right: 14px;
    bottom: calc(12px + env(safe-area-inset-bottom));
    left: 14px;
    z-index: 110;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px;
    width: min(560px, calc(100% - 28px));
    min-height: 68px;
    margin: 0 auto;
    border: 1px solid color-mix(in srgb, var(--line) 82%, transparent);
    border-radius: 26px;
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    box-shadow: 0 18px 44px rgba(15, 23, 42, 0.2);
    padding: 7px;
    backdrop-filter: blur(18px) saturate(1.25);
  }

  .mobile-tabbar-item {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-width: 0;
    min-height: 52px;
    border: 0;
    border-radius: 20px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    padding: 8px 6px;
    font-size: 0.73rem;
    font-weight: 600;
    line-height: 1.1;
    text-align: center;
    transition:
      background 180ms var(--ease-out),
      color 180ms var(--ease-out),
      transform 160ms var(--ease-out);
  }

  .mobile-tabbar-item .icon {
    width: 1.25rem;
    height: 1.25rem;
  }

  .mobile-tabbar-item span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-tabbar-item {
    position: relative;
  }

  .mobile-tabbar-item .nav-badge {
    position: absolute;
    top: 4px;
    right: calc(50% - 26px);
    min-width: 17px;
    height: 17px;
    margin-left: 0;
    font-size: 0.66rem;
  }

  .mobile-tabbar-item:hover,
  .mobile-tabbar-item.active {
    background: var(--blue-soft);
    color: var(--primary-dark);
  }

  .mobile-tabbar-item:active {
    transform: scale(0.96);
  }

  .mobile-more-panel {
    position: fixed;
    inset: 0;
    z-index: 130;
    display: block;
    pointer-events: none;
  }

  .mobile-more-panel.is-open {
    pointer-events: auto;
  }

  .mobile-more-backdrop {
    position: absolute;
    inset: 0;
    border: 0;
    background: rgba(9, 13, 28, 0.5);
    cursor: pointer;
    opacity: 0;
    backdrop-filter: blur(6px);
    transition: opacity 220ms var(--ease-out);
  }

  .mobile-more-panel.is-open .mobile-more-backdrop {
    opacity: 1;
  }

  .mobile-more-sheet {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    display: grid;
    gap: 16px;
    width: min(640px, 100%);
    max-height: min(82dvh, 720px);
    margin: 0 auto;
    overflow-y: auto;
    border: 1px solid color-mix(in srgb, var(--line) 88%, transparent);
    border-bottom: 0;
    border-radius: 26px 26px 0 0;
    background: var(--surface);
    box-shadow: 0 -22px 54px rgba(15, 23, 42, 0.26);
    padding: 10px 18px calc(22px + env(safe-area-inset-bottom));
    transform: translateY(105%);
    transition: transform 240ms var(--ease-out);
  }

  .mobile-more-panel.is-open .mobile-more-sheet {
    transform: translateY(0);
  }

  .mobile-more-sheet:focus {
    outline: 3px solid color-mix(in srgb, var(--primary) 28%, transparent);
    outline-offset: -3px;
  }

  .mobile-more-handle {
    justify-self: center;
    width: 44px;
    height: 5px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--muted) 32%, transparent);
  }

  .mobile-more-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 44px;
    gap: 12px;
    align-items: center;
  }

  .mobile-more-header .brand {
    align-items: center;
    min-width: 0;
    max-width: none;
    margin: 0;
    padding-bottom: 0;
  }

  .mobile-more-header .brand strong {
    color: var(--ink);
  }

  .mobile-more-header .brand span {
    color: var(--muted);
  }

  .mobile-more-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .mobile-more-link {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    min-height: 56px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--surface-soft);
    color: var(--ink);
    padding: 12px;
    font-weight: 600;
    transition:
      border-color 180ms var(--ease-out),
      background 180ms var(--ease-out),
      color 180ms var(--ease-out),
      transform 160ms var(--ease-out);
  }

  .mobile-more-link .icon {
    width: 1.22rem;
    height: 1.22rem;
    color: var(--primary);
  }

  .mobile-more-link span {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .mobile-more-link:hover,
  .mobile-more-link.active {
    border-color: color-mix(in srgb, var(--primary) 35%, var(--line));
    background: var(--blue-soft);
    color: var(--primary-dark);
  }

  .mobile-more-link:active {
    transform: scale(0.98);
  }

  .mobile-more-actions {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 10px;
    align-items: stretch;
    border-top: 1px solid var(--line);
    padding-top: 14px;
  }

  .mobile-more-actions form {
    margin: 0;
  }

  .mobile-more-actions .quick-toggle,
  .mobile-more-logout {
    min-height: 48px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--surface-soft);
    color: var(--ink);
  }

  .mobile-more-actions .quick-toggle:hover,
  .mobile-more-logout:hover {
    border-color: color-mix(in srgb, var(--primary) 30%, var(--line));
    background: var(--blue-soft);
    color: var(--primary-dark);
  }

  .mobile-more-logout {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 10px 12px;
    font-weight: 600;
  }

  h1 {
    font-size: 2.1rem;
  }

  .grid.two,
  .detail-layout,
  .settings-grid,
  .home-workbench,
  .home-lower-grid,
  .employee-workbench,
  .employee-profile-grid,
  .mailbox-layout,
  .mailbox-detail-layout,
  .mailbox-reader-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .quote-builder-grid,
  .quote-catalog-layout,
  .income-form-grid {
    grid-template-columns: 1fr;
  }

  .quote-line-header {
    display: none;
  }

  .quote-line-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .income-tax-header,
  .income-tax-row {
    grid-template-columns: minmax(0, 1fr) minmax(120px, 0.55fr) minmax(120px, 0.65fr) 44px;
  }

  .income-totals {
    grid-template-columns: 1fr;
  }

  .settings-password {
    grid-column: auto;
  }

  .settings-password .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .document-panel {
    position: static;
  }

  .invoice-chat {
    right: 16px;
    bottom: calc(98px + env(safe-area-inset-bottom));
    max-height: min(640px, calc(100dvh - 128px - env(safe-area-inset-bottom)));
  }

  .chat-float-button {
    bottom: calc(96px + env(safe-area-inset-bottom));
  }

  .workflow {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .home-stat-card {
    min-height: 136px;
  }
}

@media (max-width: 680px) {
  .route-transition-overlay {
    padding: 18px 14px calc(112px + env(safe-area-inset-bottom));
    align-items: start;
  }

  .route-transition-card {
    padding: 18px;
  }

  .route-skeleton-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .route-skeleton-row {
    grid-template-columns: 1.5fr 1fr;
  }

  .route-skeleton-row span:nth-child(n + 3) {
    display: none;
  }

  .toast-stack {
    top: calc(12px + env(safe-area-inset-top));
    right: 12px;
    left: 12px;
    width: auto;
  }

  .toast {
    grid-template-columns: 36px minmax(0, 1fr) 40px;
    gap: 10px;
    min-height: 64px;
    border-radius: var(--radius-soft);
    padding: 10px 6px 10px 12px;
  }

  .toast-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius);
  }

  .toast-icon .icon {
    width: 1.12rem;
    height: 1.12rem;
  }

  .toast-title {
    font-size: 0.94rem;
  }

  .toast-close {
    width: 40px;
    height: 40px;
    border-radius: var(--radius);
  }

  .toast-close .icon {
    width: 0.95rem;
    height: 0.95rem;
  }

  .custom-date-picker {
    border-radius: var(--radius-soft);
    padding: 12px;
  }

  .custom-date-day {
    min-height: 44px;
  }

  .main {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
    overflow-x: clip;
    padding: 18px 18px calc(104px + env(safe-area-inset-bottom));
  }

  .mobile-tabbar {
    right: 10px;
    bottom: calc(10px + env(safe-area-inset-bottom));
    left: 10px;
    width: min(500px, calc(100% - 20px));
    min-height: 66px;
    border-radius: 24px;
    padding: 6px;
  }

  .mobile-tabbar-item {
    min-height: 52px;
    border-radius: 18px;
    padding: 7px 4px;
    font-size: 0.68rem;
  }

  .mobile-tabbar-item .icon {
    width: 1.2rem;
    height: 1.2rem;
  }

  .mobile-more-sheet {
    gap: 14px;
    max-height: 84dvh;
    border-radius: 22px 22px 0 0;
    padding: 10px 14px calc(18px + env(safe-area-inset-bottom));
  }

  .mobile-more-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .mobile-more-link {
    min-height: 54px;
    border-radius: 14px;
    padding: 11px;
  }

  .mobile-more-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .mobile-more-logout {
    grid-column: 1 / -1;
  }

  .page-header,
  .section-heading {
    display: grid;
  }

  .employee-header-actions,
  .employee-detail-actions {
    justify-content: flex-start;
  }

  .employee-kpi-strip {
    grid-template-columns: 1fr;
  }

  .employee-kpi {
    min-height: 64px;
  }

  .employee-toolbar {
    grid-template-columns: 1fr;
  }

  .payroll-add-disclosure {
    width: 100%;
  }

  .payroll-add-disclosure > summary {
    margin-left: auto;
  }

  .payroll-inline-upload {
    position: static;
    width: 100%;
    margin-top: 10px;
  }

  .detail-header-with-back {
    grid-template-columns: 44px minmax(0, 1fr);
    gap: 10px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .month-group summary {
    grid-template-columns: 1fr;
  }

  .month-group summary strong,
  .month-group summary em {
    white-space: normal;
  }

  .settings-password .form-grid {
    grid-template-columns: 1fr;
  }

  .brand {
    align-items: flex-start;
  }

  .nav-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .nav-list a {
    justify-content: flex-start;
    min-height: 48px;
    padding: 10px;
  }

  .sidebar-controls,
  .sidebar-foot {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }

  .date-range-panel {
    padding: 14px;
  }

  .date-range-presets {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    min-height: auto;
  }

  .date-range-presets .date-range-reset {
    align-self: auto;
    margin-top: 0;
  }

  .workflow {
    grid-template-columns: 1fr;
  }

  .home-upload-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
  }

  .home-upload-panel {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    min-height: auto;
    padding: 12px;
  }

  .home-upload-head .hint,
  .home-upload-head h2,
  .home-upload-head .eyebrow {
    max-width: 100%;
    overflow-wrap: anywhere;
  }

  .home-file-drop {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    min-height: 86px;
    padding: 10px;
    place-items: center;
    justify-items: center;
  }

  .home-file-drop .drop-icon {
    width: 34px;
    height: 34px;
  }

  .home-upload-controls,
  .invoice-filter-bar,
  .mailbox-filter-bar,
  .invoice-summary-grid,
  .mailbox-steps {
    grid-template-columns: minmax(0, 1fr);
  }

  .home-upload-controls label,
  .home-upload-controls select,
  .home-upload-controls .button {
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }

  .home-upload-actions {
    justify-content: stretch;
  }

  .home-upload-actions .button {
    width: 100%;
    min-width: 0;
  }

  .home-stat-grid,
  .quote-total-strip,
  .documents-overview,
  .employee-kpi-strip,
  .liquidation-overview {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .document-kpi,
  .home-stat-card,
  .liquidation-card,
  .quote-total-card {
    min-height: 82px;
    min-width: 0;
    padding: 12px;
  }

  .home-stat-card strong,
  .document-kpi strong,
  .liquidation-card strong,
  .quote-total-card strong {
    font-size: clamp(1.35rem, 8vw, 1.85rem);
  }

  .quote-line-row {
    grid-template-columns: 1fr;
  }

  .income-tax-header {
    display: none;
  }

  .income-tax-row {
    grid-template-columns: 1fr;
  }

  .income-tax-row strong {
    justify-self: start;
  }

  .quote-line-row strong {
    text-align: left;
  }

  .quote-footer {
    display: grid;
  }

  .quote-footer-actions {
    justify-content: stretch;
  }

  .income-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .quote-footer-actions .button {
    flex: 1 1 150px;
  }

  .mailbox-message-head,
  .mailbox-reader-head,
  .table-section-header {
    display: grid;
    grid-template-columns: 1fr;
  }

  .mailbox-page-size,
  .mailbox-table-footer,
  .pagination-bar {
    display: grid;
    grid-template-columns: 1fr;
    justify-content: stretch;
  }

  .mailbox-page-size label,
  .mailbox-page-size .button,
  .pagination-bar .button {
    width: 100%;
  }

  .mailbox-status-list div,
  .mailbox-meta-grid div,
  .mailbox-envelope-grid div {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .invoice-filter-actions {
    justify-content: stretch;
  }

  .invoice-filter-actions .button {
    flex: 1 1 130px;
  }

  .invoice-summary-metrics {
    grid-template-columns: 1fr;
  }

  .home-upload-controls .button {
    min-width: 0;
  }

  .quarter-grid,
  .quarter-totals {
    grid-template-columns: 1fr;
  }

  .payroll-latest-item {
    grid-template-columns: 1fr;
  }

  .mini-list .payroll-latest-amount {
    justify-items: start;
    text-align: left;
  }

  .upload-strip {
    grid-template-columns: 1fr;
  }

  .key-values div {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .tax-disclosure summary {
    width: 100%;
    justify-content: space-between;
  }

  .tax-breakdown-list li {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .document-preview {
    min-height: 360px;
  }

  .pdf-raster-preview {
    height: 66dvh;
    min-height: 360px;
    padding: 8px;
  }

  .line-reanalysis-form {
    justify-self: end;
  }

  .line-reanalysis-form .line-reanalysis-button {
    width: 44px;
  }

  .document-modal {
    padding: 10px;
  }

  .document-modal-dialog {
    width: 100%;
    max-height: calc(100dvh - 20px);
    padding: 12px;
  }

  .document-modal-header {
    grid-template-columns: 1fr;
  }

  .document-modal-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 44px;
    width: 100%;
  }

  .ui-modal {
    padding: 10px;
  }

  .ui-modal-dialog {
    width: 100%;
    padding: 14px;
  }

  .ui-modal-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .session-countdown {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .document-preview-stage {
    min-height: 360px;
    height: 66dvh;
    padding: 6px;
  }

  .document-preview-frame {
    min-height: 100%;
  }

  .invoice-chat {
    right: 10px;
    bottom: calc(92px + env(safe-area-inset-bottom));
    left: 10px;
    width: auto;
    max-height: calc(100dvh - 116px - env(safe-area-inset-bottom));
    border-radius: var(--radius-soft);
  }

  .chat-float-button {
    right: 16px;
    bottom: calc(92px + env(safe-area-inset-bottom));
    width: 54px;
    min-width: 54px;
    height: 54px;
    min-height: 54px;
    padding: 0;
    justify-content: center;
  }

  .chat-log {
    min-height: 220px;
  }

  h1 {
    font-size: 1.8rem;
  }

  .button {
    width: 100%;
  }

  .button.icon-only {
    width: 44px;
  }

  .inline-icon-form .button.icon-only,
  .review-tools .button.icon-only {
    width: 44px;
    min-width: 44px;
  }

  .review-tools {
    justify-content: flex-start;
    width: 100%;
  }

  .review-save-button,
  .review-cancel-button {
    flex: 1 1 160px;
  }

  .final-action-grid {
    grid-template-columns: 1fr;
  }

  .status-pair {
    align-items: stretch;
  }

  .status-pair .pill {
    justify-content: center;
  }
}

@media print {
  .sidebar,
  .mobile-tabbar,
  .mobile-more-panel,
  .no-print,
  .toast-stack,
  .chat-float-button {
    display: none !important;
  }

  body {
    background: #ffffff;
  }

  .app-shell {
    display: block;
  }

  .main {
    padding: 0;
  }

  .app-shell.has-sidebar .main,
  .app-shell.no-sidebar .main {
    width: 100%;
    margin-left: 0;
  }

  .main > * {
    max-width: none;
  }

  .panel,
  .table-section,
  .liquidation-card,
  .quarter-card {
    box-shadow: none;
  }
}

@media (max-width: 420px) {
  .panel,
  .table-section,
  .document-panel,
  .login-panel {
    padding: 16px;
  }

  .main {
    padding: 14px 14px calc(100px + env(safe-area-inset-bottom));
  }

  .mobile-tabbar {
    border-radius: 22px;
  }

  .mobile-tabbar-item {
    font-size: 0.64rem;
  }

  .mobile-more-grid {
    grid-template-columns: 1fr;
  }

  .document-preview {
    min-height: 300px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .toast {
    opacity: 1;
    transform: none;
    animation: none;
  }

  .toast:not(.is-managed) {
    animation: toast-fallback-hide 5400ms steps(1, end) forwards;
  }

  .toast.is-hiding {
    opacity: 0;
    animation: none;
  }

  .toast-progress {
    animation: none;
  }

  .chat-message.typing .chat-markdown::after {
    animation: none;
  }

  .working-icon .icon,
  .working-progress span,
  .button-spinner,
  .route-transition-spinner,
  .route-skeleton-line::after,
  .route-skeleton-card::after,
  .route-skeleton-row span::after {
    animation: none;
  }

  .mobile-tabbar-item,
  .mobile-more-backdrop,
  .mobile-more-link,
  .mobile-more-sheet {
    transition: none;
  }
}
