:root {
  color-scheme: light;
  --ink: #17211d;
  --muted: #65736c;
  --line: #dce5df;
  --paper: #fbfcfa;
  --panel: #ffffff;
  --accent: #0f7b68;
  --accent-dark: #095747;
  --blue: #3763a8;
  --rose: #b64a60;
  --gold: #a56b13;
  --shadow: 0 18px 50px rgba(23, 33, 29, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.modal-open {
  overflow: auto;
}

body.auth-locked {
  overflow: hidden;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 288px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 28px;
  background: #17211d;
  color: #f7faf7;
}

.sidebar h1,
.workspace h2,
.panel h3 {
  margin: 0;
  letter-spacing: 0;
}

.sidebar h1 {
  margin-top: 6px;
  font-size: 22px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.sidebar-copy {
  color: #c6d1cb;
  line-height: 1.55;
}

.eyebrow {
  margin: 0;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sidebar .eyebrow {
  color: #7bd3bd;
}

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

.nav-list.compact {
  margin-top: 10px;
  gap: 6px;
}

.nav-item {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 12px 14px;
  background: transparent;
  color: #dce8e1;
  text-align: left;
}

.nav-item.secondary {
  padding: 9px 11px;
  color: #b8c7bf;
  font-size: 14px;
}

.nav-item.active,
.nav-item:hover {
  background: #f7faf7;
  color: var(--ink);
}

.nav-item:focus-visible {
  outline: 2px solid #7bd3bd;
  outline-offset: 2px;
}

.secondary-nav {
  display: grid;
  gap: 8px;
}

.secondary-nav summary {
  cursor: pointer;
  color: #c6d1cb;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
  list-style-position: inside;
}

.secondary-nav summary:hover {
  color: #f7faf7;
}

.privacy-note {
  margin-top: auto;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  color: #c6d1cb;
  line-height: 1.45;
  font-size: 13px;
}

.privacy-note strong {
  display: block;
  margin-bottom: 4px;
  color: #f7faf7;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* Sidebar user menu — hidden everywhere now that the workspace top-right one
   is the single source of truth. */
.user-menu,
.user-menu[hidden] {
  display: none;
}

.workspace-user-menu {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 13px;
}

.workspace-user-menu[hidden] {
  display: none;
}

.workspace-user-menu .ghost-button {
  min-height: 32px;
  padding: 6px 12px;
  border-color: var(--line);
  background: #fff;
  color: var(--ink);
  white-space: nowrap;
}

.workspace-user-menu .ghost-button:hover {
  border-color: var(--accent);
  background: #edf7f3;
  color: var(--accent-dark);
}

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(247, 250, 247, 0.96);
}

.auth-gate[hidden] {
  display: none;
}

.auth-card {
  width: min(420px, 100%);
  display: grid;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
  background: #fff;
  box-shadow: var(--shadow);
}

.auth-card h2,
.auth-card p {
  margin: 0;
}

.auth-card label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.auth-card input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  color: var(--ink);
}

.password-field {
  position: relative;
  display: block;
}

.password-field input {
  padding-right: 44px;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 6px;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  transform: translateY(-50%);
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
}

.password-toggle:hover,
.password-toggle[aria-pressed="true"] {
  background: #edf7f3;
  color: var(--accent-dark);
}

.password-toggle svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.auth-error {
  min-height: 18px;
  color: var(--rose);
  font-size: 13px;
  font-weight: 800;
}

.backend-sync-status {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: #d7e1dc;
  font-size: 12px;
  line-height: 1.35;
}

.backend-sync-status[hidden] {
  display: none;
}

.backend-sync-heading {
  display: flex;
  align-items: center;
  gap: 8px;
}

.backend-sync-heading strong {
  color: #f7faf7;
  font-size: 12px;
}

.backend-sync-heading span:last-child {
  margin-left: auto;
  color: #a8b7b0;
  font-variant-numeric: tabular-nums;
}

.backend-sync-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: #7bd3bd;
}

.backend-sync-status.pending .backend-sync-dot,
.backend-sync-status.saving .backend-sync-dot,
.backend-sync-status.loading .backend-sync-dot,
.backend-sync-status.refreshing .backend-sync-dot {
  animation: backend-sync-pulse 1s ease-in-out infinite;
  background: #f1c55f;
}

.backend-sync-status.error {
  border-color: rgba(255, 143, 143, 0.42);
  background: rgba(182, 74, 96, 0.16);
}

.backend-sync-status.error .backend-sync-dot {
  background: #ff8f8f;
}

.backend-sync-status p,
.backend-sync-status small {
  margin: 0;
}

.backend-sync-status small {
  color: #a8b7b0;
}

@keyframes backend-sync-pulse {
  0%,
  100% {
    opacity: 0.45;
    transform: scale(0.85);
  }

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

.workspace {
  min-width: 0;
  padding: 30px;
}

.view {
  display: none;
}

.view.active {
  display: grid;
  gap: 22px;
}

.view-header,
.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.view-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.workspace h2 {
  margin-top: 4px;
  font-size: 32px;
  line-height: 1.15;
}

.panel,
.kpi {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.panel {
  padding: 20px;
}

.modal-backdrop {
  position: fixed;
  z-index: 1000;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(23, 33, 29, 0.56);
}

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

.modal-card {
  display: grid;
  width: min(480px, 100%);
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(23, 33, 29, 0.22);
}

.upload-modal {
  width: min(760px, 100%);
  max-height: min(88vh, 860px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  gap: 12px;
}

.upload-modal-csv {
  width: min(920px, 100%);
}

.upload-modal > .upload-modal-topline,
.upload-modal > .upload-modal-title {
  flex-shrink: 0;
}

.upload-modal-title {
  margin: 0;
  font-size: 20px;
  line-height: 1.3;
}

.upload-modal-subtitle {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.upload-modal-body {
  flex: 1 1 auto;
  overflow-y: auto;
  min-height: 0;
  margin: 0 -22px;
  padding: 0 22px;
}

.upload-modal-footer {
  flex-shrink: 0;
  margin: 4px -22px -22px;
  padding: 14px 22px;
  border-top: 1px solid var(--line);
  background: #fff;
}

.upload-modal-footer .modal-actions {
  margin: 0;
}

.upload-modal.pass {
  border-top: 5px solid var(--accent);
}

.upload-modal.warn {
  border-top: 5px solid var(--gold);
}

.upload-modal.risk {
  border-top: 5px solid var(--rose);
}

.upload-modal-topline,
.upload-modal-heading {
  display: flex;
  justify-content: space-between;
  gap: 14px;
}

.upload-modal-topline {
  align-items: center;
}

.upload-modal-heading {
  align-items: flex-start;
}

.upload-modal-heading h3 {
  font-size: 24px;
  line-height: 1.18;
}

.upload-modal-heading p {
  max-width: 58ch;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-weight: 900;
}

.upload-modal-meta {
  gap: 8px;
}

.upload-modal-section {
  display: grid;
  gap: 14px;
}

.picker-period-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* CSV/Excel 3-step wizard ------------------------------------------------- */

.csv-step-bar {
  display: flex;
  gap: 4px;
  align-items: center;
  flex-wrap: wrap;
}

.csv-step-pill {
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  background: var(--surface);
  color: var(--muted);
}

.csv-step-pill.active {
  background: var(--accent);
  color: #fff;
}

.csv-step-pill.done {
  background: color-mix(in srgb, var(--accent) 15%, transparent);
  color: var(--accent);
}

.csv-step-sep {
  color: var(--muted);
  font-size: 11px;
}

.ss-step-hint {
  font-size: 13px;
  color: var(--muted);
  margin: 0;
}

/* Spreadsheet table */

.ss-wrap {
  overflow-x: auto;
  overflow-y: visible;
  max-height: 420px;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.ss-map-wrap {
  max-height: none;
}

/* Mobile card views for the CSV wizard steps. Hidden on desktop where
   the spreadsheet-style table is plenty readable. */
.ss-view-mobile {
  display: none;
}

@media (max-width: 760px) {
  .ss-view-desktop {
    display: none;
  }

  .ss-view-mobile {
    display: grid;
    gap: 14px;
    min-width: 0;
  }

  /* The header/period step shows a tappable list of rows. Continue/Back are
     pinned in the sticky footer so the inner list can scroll with the modal
     body — no nested scroll container, which means a tapped row keeps its
     position across the re-render. */
  .ss-view-mobile.ss-view-rows {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 8px;
    background: #fafbfa;
  }

  .csv-step-secondary {
    display: flex;
    justify-content: center;
    margin-top: 4px;
  }

  .csv-step-secondary .ghost-button {
    font-size: 13px;
    text-decoration: underline dotted;
    background: transparent;
  }

  .csv-manual-period .picker-period-row {
    display: grid;
    gap: 12px;
  }

  .csv-manual-period .picker-period-row label {
    display: grid;
    gap: 4px;
    font-size: 13px;
    font-weight: 600;
  }

  .csv-manual-period .picker-period-row input[type="date"] {
    padding: 10px;
    font-size: 15px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
  }

  /* — column-mapping cards — */
  .ss-card {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px;
    background: #fff;
    display: grid;
    gap: 10px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    min-width: 0;
    max-width: 100%;
  }

  .ss-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--line);
  }

  .ss-card-letter {
    background: var(--accent);
    color: #fff;
    border-radius: 4px;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 800;
    flex-shrink: 0;
  }

  .ss-card-name {
    font-weight: 700;
    font-size: 14px;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
  }

  .ss-card-role {
    display: grid;
    gap: 4px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
  }

  .ss-card-role select {
    width: 100%;
    padding: 10px 12px;
    font-size: 15px;
    font-weight: 600;
    border: 1px solid var(--accent);
    border-radius: 6px;
    background: #fff;
    color: var(--text);
  }

  .ss-card-samples {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 12px;
    color: var(--muted);
    padding: 8px 10px;
    background: #f7faf9;
    border-radius: 6px;
    overflow: hidden;
    min-width: 0;
    max-width: 100%;
  }

  .ss-card-samples-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #aaa;
    margin-bottom: 2px;
  }

  .ss-card-samples span:not(.ss-card-samples-label):not(.ss-card-empty) {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text);
  }

  .ss-card-empty {
    color: #aaa;
    font-style: italic;
  }

  /* — row-pick cards for header / period selection steps — */
  .ss-row-card {
    display: grid;
    gap: 6px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    text-align: left;
    font: inherit;
    color: inherit;
    cursor: pointer;
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }

  div.ss-row-card {
    cursor: default;
  }

  .ss-row-card:hover {
    border-color: var(--accent);
  }

  .ss-row-card.active-header {
    border-color: var(--accent);
    background: #edf7f3;
  }

  .ss-row-card.active-period {
    border-color: #f0c97a;
    background: #fff8e1;
  }

  .ss-row-card-meta {
    display: flex;
    gap: 8px;
    align-items: center;
    font-size: 11px;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
  }

  .ss-row-card-marker {
    color: var(--accent-dark);
  }

  .ss-row-card.active-period .ss-row-card-marker {
    color: #8a6918;
  }

  .ss-row-card-preview {
    font-size: 13px;
    line-height: 1.4;
    color: var(--text);
    overflow-wrap: anywhere;
    word-break: break-word;
    min-width: 0;
  }
}

.ss-table {
  border-collapse: collapse;
  font-size: 12px;
  white-space: nowrap;
  background: #fff;
  width: auto;
}

.ss-table td {
  border: 1px solid #e8e8e8;
  padding: 3px 10px;
  min-width: 40px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 0; /* lets text-overflow work under table-layout:fixed */
}

.ss-corner,
.ss-col-hdr {
  background: #f0f0f0;
  border: 1px solid #d0d0d0;
  padding: 3px 8px;
  font-weight: 600;
  text-align: center;
  color: #555;
  position: sticky;
  top: 0;
  z-index: 1;
  overflow: visible;
  user-select: none;
}

.ss-resize-handle {
  position: absolute;
  right: -3px;
  top: 0;
  bottom: 0;
  width: 6px;
  cursor: col-resize;
  z-index: 3;
  touch-action: none;
}

.ss-resize-handle::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 15%;
  bottom: 15%;
  width: 2px;
  transform: translateX(-50%);
  background: transparent;
  border-radius: 1px;
  transition: background 0.1s;
}

.ss-resize-handle:hover::after,
.ss-resize-handle.ss-resizing::after {
  background: var(--accent);
}

.ss-corner {
  min-width: 32px;
  position: sticky;
  left: 0;
  z-index: 2;
}

.ss-rownum {
  background: #f0f0f0;
  border: 1px solid #d0d0d0;
  padding: 3px 6px;
  text-align: right;
  color: #666;
  font-size: 11px;
  white-space: nowrap;
  position: sticky;
  left: 0;
}

.ss-row-marker {
  display: block;
  font-size: 9px;
  color: var(--accent);
  white-space: nowrap;
}

.ss-header-change {
  display: block;
  font-size: 9px;
  color: var(--accent);
  white-space: nowrap;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  text-decoration: underline dotted;
  font-family: inherit;
}

.ss-header-change:hover {
  text-decoration: underline;
}

.ss-row.ss-clickable {
  cursor: pointer;
}

.ss-row.ss-clickable:hover td:not(.ss-rownum) {
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}

.ss-header-row td:not(.ss-rownum) {
  background: color-mix(in srgb, var(--accent) 15%, transparent);
  font-weight: 600;
}

.ss-period-row td:not(.ss-rownum) {
  background: #fff8e1;
}

.ss-map-cell {
  vertical-align: top;
  padding: 4px 6px !important;
  min-width: 90px;
  max-width: 140px;
}

.ss-col-name {
  font-size: 11px;
  font-weight: 600;
  color: #333;
  margin-bottom: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ss-role-select {
  font-size: 11px;
  padding: 1px 2px;
  width: 100%;
  border: 1px solid #ccc;
  border-radius: 3px;
  background: #fff;
}

.ss-overflow {
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

.ss-more-row {
  color: var(--muted);
  font-size: 11px;
  text-align: center;
  padding: 4px !important;
  background: var(--surface);
}

.csv-period-hint {
  background: #fff8e1;
  border: 1px solid #ffe082;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 13px;
}

.csv-map-hint {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--muted);
}

.csv-verdict-stack {
  position: sticky;
  bottom: 0;
  background: #fff;
  padding-top: 6px;
  margin-top: 6px;
  display: grid;
  gap: 4px;
  z-index: 1;
}

.csv-verify-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
  padding: 2px 0;
  line-height: 1.4;
}

.csv-verify-strip strong {
  color: var(--text);
  font-weight: 600;
}

.csv-verdict-stack .upload-problem-list {
  gap: 4px;
}

.csv-verdict-stack .upload-problem-list div {
  padding: 6px 10px;
  font-size: 13px;
  line-height: 1.35;
}

.csv-verify-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  display: grid;
  gap: 10px;
}

.csv-verify-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}

.csv-verify-header strong {
  font-size: 13px;
}

.csv-verify-header span {
  font-size: 12px;
  color: var(--muted);
}

.csv-verify-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.csv-verify-label {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.csv-verify-amount {
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.csv-verify-no-balance {
  font-size: 12px;
  color: var(--muted);
}

.csv-match-indicator {
  font-size: 13px;
  font-weight: 500;
  min-height: 18px;
}

.csv-match-ok {
  color: #137333;
}

.csv-match-fail {
  color: var(--rose);
}

.upload-modal-progress {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfa;
}

.upload-modal-progress strong,
.upload-modal-progress span {
  display: block;
}

.upload-modal-progress span {
  margin-top: 3px;
  color: var(--muted);
}

.upload-read-success {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  border: 1px solid #cfe1d9;
  border-radius: 8px;
  padding: 12px;
  background: #edf7f3;
}

.upload-read-success strong,
.upload-read-success span {
  display: block;
}

.upload-read-success span {
  margin-top: 3px;
  color: var(--muted);
}

.upload-problem-list {
  display: grid;
  gap: 8px;
}

.upload-problem-list div {
  border-left: 4px solid var(--rose);
  border-radius: 6px;
  padding: 10px 12px;
  background: #fff0f2;
  color: #7a2636;
  line-height: 1.45;
}

.conflict-diff {
  display: grid;
  gap: 14px;
}

.conflict-diff-section header {
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 6px;
}

.conflict-diff-section header strong {
  color: var(--text);
  font-weight: 600;
  margin-right: 4px;
}

.conflict-diff-section ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 4px;
}

.conflict-diff-section li {
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.35;
}

.conflict-diff-section.added li {
  background: #ecf7f1;
  color: #1d5a3d;
}

.conflict-diff-section.removed li {
  background: #fdecec;
  color: #7a2636;
}

.conflict-diff-date {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.conflict-diff-desc {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conflict-diff-amount {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  font-weight: 500;
}

.conflict-diff-more {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.pdf-extractor-prompt {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  border: 1px solid #cfe1d9;
  border-radius: 8px;
  padding: 14px;
  background: #edf7f3;
}

.pdf-extractor-prompt strong,
.pdf-extractor-prompt span {
  display: block;
}

.pdf-extractor-prompt span {
  margin-top: 4px;
  color: var(--muted);
  line-height: 1.4;
}

.pdf-extractor-prompt .help-extractor-file {
  min-width: 180px;
}

.split-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.modal-card h3,
.modal-card p {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

.modal-card p,
.modal-card small {
  color: var(--muted);
  line-height: 1.45;
}

.modal-kicker {
  width: max-content;
  border-radius: 999px;
  padding: 5px 9px;
  background: #edf7f3;
  color: var(--accent-dark);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.modal-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.modal-meta span {
  border: 1px solid #cfe1d9;
  border-radius: 999px;
  padding: 5px 9px;
  background: #edf7f3;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
}

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

.reading-modal {
  justify-items: center;
  text-align: center;
}

.extractor-success-modal {
  justify-items: center;
  text-align: center;
}

.extractor-success-modal label {
  width: 100%;
  text-align: left;
}

.success-mark {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 32px;
  font-weight: 900;
  box-shadow: 0 14px 36px rgba(15, 123, 104, 0.24);
}

.extractor-success-modal.risk .success-mark {
  background: var(--rose);
  box-shadow: 0 14px 36px rgba(182, 74, 96, 0.24);
}

.extractor-success-modal.risk h3,
.extractor-success-modal.risk .modal-kicker {
  color: var(--rose);
}

.statement-meta {
  justify-content: center;
}

.ocr-modal {
  width: min(560px, 100%);
  gap: 14px;
  border-color: #cfe1d9;
  background:
    linear-gradient(180deg, rgba(237, 247, 243, 0.86), rgba(255, 255, 255, 0.98) 42%),
    #fff;
}

.ocr-modal-visual {
  position: relative;
  display: grid;
  place-items: center;
  width: 92px;
  height: 72px;
}

.ocr-page-stack {
  position: relative;
  width: 58px;
  height: 68px;
}

.ocr-page-stack span {
  position: absolute;
  inset: 0;
  border: 1px solid #bfd8cf;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 10px 28px rgba(23, 33, 29, 0.12);
}

.ocr-page-stack span:nth-child(1) {
  transform: rotate(-7deg) translate(-7px, 4px);
}

.ocr-page-stack span:nth-child(2) {
  transform: rotate(5deg) translate(7px, 1px);
}

.ocr-page-stack span:nth-child(3)::before,
.ocr-page-stack span:nth-child(3)::after {
  content: "";
  position: absolute;
  left: 11px;
  right: 11px;
  height: 6px;
  border-radius: 999px;
  background: #dce8e1;
}

.ocr-page-stack span:nth-child(3)::before {
  top: 17px;
  box-shadow: 0 13px 0 #dce8e1, 0 26px 0 #dce8e1;
}

.ocr-page-stack span:nth-child(3)::after {
  top: 56px;
  right: 24px;
  background: var(--accent);
}

.ocr-modal-visual .reading-spinner {
  position: absolute;
  right: 5px;
  bottom: 0;
  width: 30px;
  height: 30px;
  border-width: 3px;
  background: #fff;
}

.reading-spinner {
  width: 44px;
  height: 44px;
  border: 4px solid #cfe1d9;
  border-top-color: var(--accent);
  border-radius: 999px;
  animation: spin 0.9s linear infinite;
}

.reading-steps {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.reading-steps span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  background: #fbfcfa;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.reading-steps span.active {
  border-color: #cfe1d9;
  background: #edf7f3;
  color: var(--accent-dark);
}

.ocr-progress-bar {
  width: 100%;
  height: 10px;
  overflow: hidden;
  border: 1px solid #cfe1d9;
  border-radius: 999px;
  background: #eef5f1;
}

.ocr-progress-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #47ad8f);
  transition: width 0.25s ease;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.import-grid,
.import-focus,
.analysis-grid,
.extractor-shell {
  display: grid;
  gap: 18px;
}

.import-grid,
.import-focus {
  grid-template-columns: minmax(320px, 1.15fr) minmax(260px, 0.85fr);
}

.import-focus {
  align-items: stretch;
}

.upload-actions {
  display: flex;
  justify-content: flex-start;
}

.upload-actions .primary-button {
  min-width: 0;
}

.upload-format-hint {
  margin: 0;
}

.upload-label {
  display: block;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 8px;
}

.file-drop {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  background: #fbfcfa;
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease;
  min-height: 56px;
}

.file-drop:hover,
.file-drop:focus-within {
  border-color: var(--accent);
  background: #f1f8f4;
}

.file-drop input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.file-drop-chip {
  flex-shrink: 0;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 6px;
}

.file-drop-name {
  flex: 1 1 auto;
  min-width: 0;
  color: var(--muted);
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-drop-name.has-file {
  color: var(--text);
  font-weight: 500;
}

@media (max-width: 760px) {
  .upload-actions .primary-button {
    width: 100%;
  }
}

.attention-panel[hidden] {
  display: none;
}

.analysis-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.linked-entities-list {
  display: grid;
  gap: 8px;
}

.linked-entity-row {
  display: grid;
  grid-template-columns: minmax(100px, 0.5fr) minmax(0, 1fr) minmax(80px, max-content);
  gap: 8px 16px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.linked-entity-row:last-child {
  border-bottom: none;
}

.linked-entity-name {
  font-weight: 700;
  font-size: 13px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.linked-entity-category {
  font-size: 13px;
  color: var(--text);
}

.linked-entity-amount {
  font-size: 13px;
  font-weight: 600;
  text-align: right;
  white-space: nowrap;
}

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

.analytics-panel {
  display: grid;
  gap: 14px;
}

.analytics-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.analytics-scope-chip {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  min-height: 36px;
}

.analytics-scope-chip:hover {
  border-color: color-mix(in srgb, var(--accent) 40%, var(--line));
}

.analytics-scope-chip > span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.analytics-scope-chip .chip-caret {
  color: var(--ink);
  font-size: 14px;
  line-height: 1;
  transition: transform 0.15s;
}

.analytics-scope-chip[aria-expanded="true"] .chip-caret {
  transform: rotate(180deg);
}

.analytics-icon-button {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  padding: 0;
}

.analytics-icon-button:hover {
  border-color: color-mix(in srgb, var(--accent) 40%, var(--line));
}

.analytics-icon-button[aria-expanded="true"] {
  background: color-mix(in srgb, var(--accent) 10%, #fff);
  border-color: color-mix(in srgb, var(--accent) 50%, var(--line));
}

.analytics-scope-panel {
  display: grid;
  gap: 14px;
}

.analytics-search-panel {
  display: grid;
  gap: 10px;
}

.analytics-search-summary {
  margin: 0;
}

.analytics-search-summary:empty {
  display: none;
}

.analytics-search-panel input[type="search"] {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 40px;
  padding: 8px 10px;
  color: var(--ink);
  font: inherit;
  background: #fff;
}

.analytics-search-results {
  display: grid;
  gap: 14px;
}

.analytics-search-section header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin: 0 0 6px;
  padding: 0 2px;
}

.search-section-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.search-section-count {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  background: #eef2ed;
  padding: 1px 7px;
  border-radius: 999px;
}

.analytics-search-section-body {
  display: grid;
  gap: 6px;
}

.analytics-search-result {
  display: grid;
  gap: 4px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fbfcfa;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.analytics-search-result:hover {
  background: #f3f6f2;
  border-color: var(--border);
}

.analytics-search-result strong {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.analytics-search-result span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.analytics-scope-grid {
  display: grid;
  grid-template-columns: minmax(220px, 1.2fr) repeat(2, minmax(150px, 0.7fr));
  gap: 8px;
  align-items: end;
}

.analytics-scope-grid label,
.analytics-filter-group {
  display: grid;
  gap: 6px;
}

.analytics-scope-grid label,
.analytics-filter-group strong {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.analytics-scope-grid select,
.analytics-scope-grid input {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 38px;
  padding: 7px 10px;
  color: var(--ink);
  font: inherit;
  background: #fff;
}

.analytics-scope-grid input:disabled {
  background: #f3f6f2;
  color: var(--muted);
}

.analytics-filter-groups {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
  gap: 8px;
}

.analytics-filter-group {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  background: #fbfcfa;
}

.analytics-filter-group label {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  color: var(--ink);
  font-size: 13px;
  font-weight: 650;
  line-height: 1.35;
}

.analytics-filter-group input[type="checkbox"] {
  width: 16px;
  min-width: 16px;
  min-height: 16px;
  height: 16px;
  margin: 1px 0 0;
  padding: 0;
  accent-color: var(--accent);
}

.analytics-check-list {
  display: grid;
  gap: 6px;
  max-height: 112px;
  overflow: auto;
  padding-right: 4px;
}

.analytics-check-list small {
  color: var(--muted);
  white-space: nowrap;
}

.analytics-table {
  display: grid;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.committed-row {
  display: grid;
  grid-template-columns: 20px 1fr auto auto;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid #f2f2f2;
}

.salary-row { background: #f7faf9; padding: 6px 8px; border-radius: 6px; border-bottom: none; }

.committed-icon { font-size: 14px; text-align: center; }
.committed-name { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.committed-tag {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.committed-tag.emi { background: #fff0f0; color: #b0220e; }
.committed-tag.investment { background: #f0f7ff; color: #1a5fa8; }
.committed-tag.subscription { background: #f5f0ff; color: #6b35b8; }
.committed-tag.recurring { background: #f5f5f5; color: #666; }
.committed-tag.salary { background: #f0faf5; color: #0a6b4a; }

.committed-amount { font-size: 13px; font-weight: 700; white-space: nowrap; }
.committed-amount.positive { color: #0f7b68; }

.committed-free-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 6px;
  padding: 10px 12px;
  background: #f7faf9;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
}

.committed-free-row strong { font-size: 16px; font-weight: 800; }
.committed-free-row strong small { font-size: 11px; font-weight: 500; color: var(--muted); }
.committed-free-row .positive { color: #0f7b68; }
.committed-free-row .negative { color: #c0392b; }

.picture-item {
  display: grid;
  grid-template-columns: 24px 1fr 20px;
  gap: 8px;
  align-items: start;
  padding: 8px 0;
  border-bottom: 1px solid #f2f2f2;
}

.picture-icon { font-size: 16px; padding-top: 1px; }

.picture-item strong { font-size: 13px; font-weight: 600; display: block; }
.picture-item small { font-size: 11px; color: var(--muted); display: block; margin-top: 2px; line-height: 1.35; }

.picture-confidence { font-size: 13px; font-weight: 700; padding-top: 2px; }
.picture-confidence.high { color: #0f7b68; }
.picture-confidence.medium { color: #b08000; }

.snapshot-inference-note {
  font-size: 10px;
  color: var(--muted);
  margin-top: 4px;
}

.snapshot-empty-col {
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
  padding: 8px 0;
}

.snapshot-observations {
  border-top: 1px solid #e8f0ed;
  padding-top: 16px;
  display: grid;
  gap: 10px;
}

.snapshot-obs-list {
  display: grid;
  gap: 8px;
}

.obs-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 13px;
  line-height: 1.45;
}

.obs-icon {
  font-size: 15px;
  flex-shrink: 0;
  width: 20px;
  text-align: center;
}

.analytics-row {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) repeat(3, minmax(96px, 0.7fr));
  gap: 10px;
  align-items: center;
  width: 100%;
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
  padding: 12px;
  background: #fff;
  color: var(--ink);
  text-align: left;
}

.analytics-row:first-child {
  border-top: 0;
}

.analytics-row:not(.analytics-head) {
  cursor: pointer;
}

.analytics-row:not(.analytics-head):hover {
  background: #edf7f3;
}

.analytics-row.warn {
  background: #fff8e8;
}

.analytics-head {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f3f6f2;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.analytics-row small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
}

.analytics-modal {
  width: min(980px, 100%);
  max-height: min(92vh, 900px);
  overflow: auto;
}

.analytics-totals,
.analytics-modal-grid {
  display: grid;
  gap: 12px;
}

.subcategory-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px 0;
}

.subcategory-chip-group {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.subcategory-chip-edit {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 50%;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--muted);
  font-size: 12px;
  padding: 0;
}

.subcategory-chip-edit:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.subcategory-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  color: var(--text);
}

.subcategory-chip-name {
  font-weight: 600;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.subcategory-chip-amount {
  font-weight: 700;
  color: var(--muted);
  flex-shrink: 0;
}

.subcategory-chip.active,
.subcategory-chip:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.subcategory-chip.active .subcategory-chip-amount,
.subcategory-chip:hover .subcategory-chip-amount {
  color: rgba(255,255,255,0.8);
}

.analytics-modal-title-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
}

.analytics-modal-title-row h3 {
  margin-bottom: 4px;
}

.analytics-modal-title-row p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.analytics-label-with-action {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  min-width: 0;
}

.analytics-label-with-action > span {
  min-width: 0;
}

.analytics-edit-icon {
  display: inline-grid;
  place-items: center;
  width: 24px;
  min-width: 24px;
  height: 24px;
  min-height: 24px;
  border: 1px solid var(--line);
  border-radius: 50%;
  padding: 0;
  background: #fff;
  color: var(--accent-dark);
  font-size: 13px;
  line-height: 1;
}

.analytics-edit-icon:hover {
  border-color: var(--accent);
  background: #edf7f3;
}

.analytics-totals {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.analytics-totals div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fbfcfa;
}

.analytics-totals span,
.analytics-totals strong {
  display: block;
}

.analytics-totals span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.analytics-modal-grid {
  grid-template-columns: minmax(0, 1fr);
}

.analytics-mini-table,
.analytics-stream-list,
.analytics-transaction-list {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.analytics-stream-list {
  max-height: min(34vh, 320px);
  overflow: auto;
  padding-right: 4px;
}

.analytics-transaction-list {
  max-height: min(42vh, 420px);
  overflow: auto;
  padding-right: 4px;
}

.analytics-transaction-head {
  position: sticky;
  top: 0;
  z-index: 1;
}

.analytics-edit-panel {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) repeat(2, minmax(160px, 1fr)) auto auto;
  gap: 10px;
  align-items: end;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #f6faf8;
}

.analytics-edit-panel span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.analytics-edit-panel label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.analytics-edit-panel input {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  color: var(--ink);
  font: inherit;
}

.analytics-mini-table div,
.analytics-transaction-line {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) repeat(3, minmax(80px, 0.7fr));
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px;
  background: #fff;
}

.analytics-stream-list button {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px;
  background: #fff;
  color: var(--ink);
  text-align: left;
}

.analytics-pattern-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 28px;
  gap: 6px;
  align-items: center;
}

.analytics-pattern-row.active button,
.analytics-stream-list button:hover {
  border-color: var(--accent);
  background: #edf7f3;
}

.analytics-edit-modal {
  width: min(780px, 100%);
  display: grid;
  max-height: min(90vh, 860px);
  overflow: auto;
}

.analytics-edit-modal.saving {
  cursor: progress;
}

.analytics-edit-modal.saving .analytics-edit-stack {
  opacity: 0.72;
  pointer-events: none;
}

.analytics-edit-modal.saving [data-save-analytics-category-edit] {
  cursor: progress;
}

.analytics-edit-stack {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}

.analytics-edit-section {
  display: grid;
  gap: 8px;
}

.analytics-edit-section > strong {
  font-size: 13px;
}

.analytics-auto-note {
  border: 1px solid rgba(181, 119, 26, 0.35);
  border-radius: 8px;
  padding: 8px;
  background: #fff8ec;
  color: #7a4b05;
  font-size: 12px;
  font-weight: 800;
}

.analytics-pattern-choice-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.analytics-pattern-choice {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 9px;
  background: #fff;
  font-size: 13px;
  font-weight: 800;
}

.analytics-edit-actions {
  display: grid;
  grid-template-columns: minmax(160px, 0.45fr) minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.transaction-context-list,
.manage-category-list {
  display: grid;
  gap: 8px;
}

.transaction-context-list {
  display: grid;
  gap: 8px;
}

.manage-category-search {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--ink);
  font: inherit;
  background: #fff;
}

.manage-category-list {
  max-height: min(58vh, 560px);
  overflow: auto;
  padding-right: 4px;
}

.transaction-context-row,
.manage-category-row {
  display: grid;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px;
  background: #fff;
}

.transaction-context-row {
  grid-template-columns: minmax(110px, 0.65fr) minmax(0, 1.35fr) minmax(120px, 0.65fr) minmax(90px, 0.45fr);
}

.transaction-context-row.active {
  border-color: var(--accent);
  background: #edf7f3;
}

.transaction-context-row span,
.manage-category-row small {
  color: var(--muted);
  font-size: 12px;
}

.manage-category-row {
  grid-template-columns: minmax(150px, 1fr) minmax(130px, 0.55fr) minmax(82px, 0.32fr);
}

.manage-category-row[hidden],
.manage-category-empty[hidden] {
  display: none;
}

.manage-category-head {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f2f6f3;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.manage-category-row strong,
.manage-category-row small {
  display: block;
}

.manage-category-row select {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 36px;
  padding: 7px 9px;
  color: var(--ink);
  font: inherit;
  background: #fff;
}

.manage-category-merge-panel {
  grid-column: 1 / -1;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fbfcfa;
}

.manage-category-merge-panel[hidden] {
  display: none;
}

.manage-category-merge-panel label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.analytics-transaction-line {
  grid-template-columns: minmax(120px, 0.65fr) minmax(0, 1.5fr) minmax(90px, 0.45fr) 28px;
}

.analytics-transaction-head {
  background: #f2f6f3;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.analysis-item {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfa;
}

.analysis-item strong,
.analysis-item span,
.analysis-item small {
  display: block;
}

.analysis-item span,
.analysis-item small {
  color: var(--muted);
  line-height: 1.4;
}

.analysis-item.good {
  border-color: rgba(15, 123, 104, 0.35);
  background: #edf7f3;
}

.analysis-item.warn {
  border-color: #e7cf9b;
  background: #fff8e8;
}

.analysis-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.extractor-shell {
  grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
  align-items: start;
}

.guided-extractor .extractor-shell {
  grid-template-columns: 1fr;
}

.guided-extractor .extractor-controls {
  display: none;
}

.guided-extractor .extractor-workbench {
  grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
}

.guided-extractor .extract-page-frame {
  padding: 6px;
}

.guided-extractor .extract-page {
  width: min(100%, 1180px);
}

.guided-extractor .extractor-toolbar {
  top: 0;
  padding: 8px 10px;
  box-shadow: 0 4px 14px rgba(23, 33, 29, 0.06);
}

.guided-extractor .extractor-field-bar {
  display: flex;
}

.extractor-main,
.extractor-controls,
.extractor-form,
.extractor-status,
.extractor-preview {
  display: grid;
  gap: 12px;
}

.extractor-coach {
  display: grid;
}

.extractor-coach[hidden] {
  display: none;
}

.extractor-coach-card {
  display: grid;
  gap: 8px;
  border: 1px solid #cfe1d9;
  border-radius: 8px;
  padding: 14px;
  background: #edf7f3;
}

.extractor-coach-card.pass,
.extractor-coach-card.ready {
  border-color: rgba(15, 123, 104, 0.35);
}

.extractor-coach-card.warn {
  background: #fff8f0;
  border-color: #f5c78a;
}

.extractor-coach-card.warn > span {
  color: #7a4200;
}

.extractor-coach-card > span {
  color: var(--accent-dark);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.extractor-coach-card strong {
  font-size: 20px;
  line-height: 1.2;
}

.extractor-coach-card small {
  max-width: 74ch;
  color: var(--muted);
  line-height: 1.45;
}

.extractor-toolbar {
  position: sticky;
  z-index: 12;
  top: 12px;
}

.extractor-page-controls {
  display: grid;
  grid-template-columns: auto minmax(110px, 1fr) auto auto;
  gap: 10px;
  align-items: center;
}

.extractor-preview[hidden] {
  display: none;
}

.page-jump-label {
  display: grid;
  grid-template-columns: auto 64px;
  gap: 6px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.page-jump-label input {
  width: 64px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 8px;
  color: var(--ink);
  font: inherit;
}

.page-jump-label input:disabled {
  background: #f5f6f3;
  color: var(--muted);
}

.extractor-field-bar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.completion-tick {
  color: var(--accent-dark);
  font-size: 14px;
  font-weight: 900;
  line-height: 1;
}

.extract-field-chip {
  display: grid;
  grid-template-columns: minmax(0, auto) auto;
  gap: 6px;
  align-items: center;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 9px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
  cursor: pointer;
}

.extract-field-chip .chip-label,
.extract-field-chip .chip-state {
  min-width: 0;
}

.extract-field-chip .chip-state {
  border-radius: 999px;
  padding: 2px 6px;
  background: #f2f4f1;
  color: var(--muted);
  font-size: 10px;
}

.extract-field-chip.done {
  color: var(--ink);
}

.extract-field-chip.done .chip-state {
  background: #edf7f3;
  color: var(--accent-dark);
}

.completion-tick {
  display: inline-grid;
  width: 18px;
  height: 18px;
  place-items: center;
  border-radius: 999px;
  background: #edf7f3;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 900;
}

.completion-tick::before {
  content: "\2713";
}

.extract-field-chip.issue {
  border-color: rgba(182, 74, 96, 0.42);
  background: #fff6f7;
  color: var(--rose);
}

.extract-field-chip.issue .chip-state {
  background: #fff0f2;
  color: var(--rose);
}

.extract-field-chip.active {
  border-color: var(--accent);
  background: #edf7f3;
  color: var(--accent-dark);
  box-shadow: inset 0 0 0 1px rgba(15, 123, 104, 0.2);
}

.guided-field-card,
.guided-field-done {
  display: grid;
  gap: 8px;
  border: 1px solid #cfe1d9;
  border-radius: 8px;
  padding: 12px;
  background: #edf7f3;
}

.guided-field-card.pass {
  border-color: #cfe1d9;
  background: #edf7f3;
}

.guided-field-card span {
  color: var(--accent-dark);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.guided-field-card small,
.guided-field-done {
  color: var(--muted);
  line-height: 1.4;
}

.guided-nav-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.guided-nav-actions .skip-action {
  grid-column: 1 / -1;
}

.guided-issue-note {
  display: grid;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
  line-height: 1.35;
}

.guided-issue-note strong {
  font-size: 13px;
}

.guided-issue-note span {
  color: var(--muted);
  font-size: 13px;
}

.extract-unable-note {
  display: grid;
  gap: 5px;
  border-left: 4px solid var(--rose);
  border-radius: 6px;
  padding: 10px 12px;
  background: #fff0f2;
  color: #7a2636;
}

.extract-unable-note span {
  color: #7a2636;
  line-height: 1.4;
}

.extract-unable-contact {
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px solid #e5b8bf;
  font-weight: 600;
  color: #5a1a28;
}

.compact-secondary {
  width: 100%;
}

.manual-extractor-entry {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr)) auto;
  gap: 8px;
  align-items: end;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: #fff;
}

.page-table-controls {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: #fff;
}

.page-table-controls > div:first-child {
  display: grid;
  gap: 3px;
}

.page-table-controls small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.page-table-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.page-table-actions .table-button {
  width: 100%;
  min-height: 38px;
  white-space: normal;
  text-align: center;
}

.period-read-feedback {
  font-size: 12px;
  padding: 6px 8px;
  border-radius: 6px;
  line-height: 1.4;
}

.period-read-feedback.pass {
  background: #f0faf4;
  color: #1a6b3a;
  border: 1px solid #b3dfc5;
}

.period-read-feedback.warn {
  background: #fff8f0;
  color: #7a4200;
  border: 1px solid #f5c78a;
}

.manual-entry-toggle {
  padding: 2px 0;
}

.manual-entry-header {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.manual-entry-header > span {
  color: var(--muted);
  font-size: 12px;
}

.manual-entry-header .compact {
  font-size: 11px;
  padding: 3px 8px;
  min-height: unset;
}

.manual-extractor-entry > span {
  grid-column: 1 / -1;
  color: var(--muted);
}

.manual-extractor-entry small {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.manual-extractor-entry label {
  gap: 4px;
  font-size: 12px;
}

.manual-extractor-entry input {
  min-height: 36px;
}

.extractor-controls {
  position: sticky;
  top: 18px;
}

.extractor-status small,
.extractor-preview small {
  color: var(--muted);
  line-height: 1.45;
}

.extractor-preview .check-context {
  display: block;
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.extractor-pill {
  width: max-content;
  border-radius: 999px;
  padding: 5px 9px;
  background: #edf7f3;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
}

.extractor-pill.warning {
  background: #fff5df;
  color: var(--gold);
}

.extractor-pill.risk {
  background: #fff0f2;
  color: var(--rose);
}

.extractor-workbench {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(160px, 220px);
  gap: 12px;
  align-items: stretch;
}

.extractor-side-panel {
  display: grid;
  gap: 12px;
  align-content: start;
  position: sticky;
  top: 12px;
  max-height: calc(100vh - 24px);
  overflow: auto;
}

.extractor-steps {
  display: flex;
  position: static;
  max-height: none;
  flex-direction: column;
  gap: 10px;
  align-self: start;
  overflow: visible;
  padding: 12px;
}

.extractor-preview {
  position: static;
  align-self: start;
}

.extractor-steps + .extractor-preview {
  top: auto;
}

.extract-row-focus {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fbfcfa;
}

.extract-row-focus span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.extractor-rail-title {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.extract-step-list {
  display: grid;
  gap: 8px;
}

.extract-step {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 10px 7px 7px;
  background: #fff;
  color: var(--ink);
  text-align: left;
}

.extract-step span {
  display: grid;
  width: 20px;
  height: 20px;
  place-items: center;
  border-radius: 999px;
  background: #edf3ef;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.extract-step strong {
  min-width: 0;
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.extract-step small {
  grid-column: 2;
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.extract-step.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(15, 123, 104, 0.12);
}

.extract-step.issue {
  border-color: #efcf9b;
  background: #fffaf0;
}

.extract-step.done span {
  background: transparent;
  color: var(--accent-dark);
  font-size: 15px;
  font-weight: 900;
}

.extract-step.done span::before {
  content: "\2713";
}

.extract-step.issue span {
  background: var(--gold);
  color: #fff;
}

.extractor-pass-note {
  display: grid;
  gap: 4px;
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #edf7f3;
  color: var(--muted);
  line-height: 1.35;
}

.extractor-pass-note strong {
  color: var(--accent-dark);
}

.extractor-toolbar {
  display: grid;
  gap: 10px;
  align-items: center;
}

.extractor-page-controls span {
  color: var(--muted);
  font-weight: 800;
  text-align: center;
}

.extractor-canvas-wrap {
  min-width: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eef3ef;
}

.extract-page-frame {
  min-width: min(820px, 100%);
  padding: 14px;
}

.extract-page {
  position: relative;
  width: min(100%, 860px);
  overflow: hidden;
  touch-action: none;
  border: 1px solid #c9d3cc;
  border-radius: 6px;
  background:
    linear-gradient(#f7f9f6 1px, transparent 1px),
    linear-gradient(90deg, #f7f9f6 1px, transparent 1px),
    #fff;
  background-size: 20px 20px;
  box-shadow: 0 14px 40px rgba(23, 33, 29, 0.14);
  user-select: none;
}

.extract-pdf-canvas,
.extract-text-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.extract-pdf-canvas {
  z-index: 0;
}

.extract-text-layer {
  z-index: 1;
}

.extract-text-layer.hidden {
  opacity: 0;
}

.extract-token {
  position: absolute;
  overflow: hidden;
  pointer-events: none;
  color: #22302a;
  font-size: 9px;
  line-height: 1.1;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.extract-region {
  position: absolute;
  z-index: 3;
  --box-color: var(--accent);
  border: 2px solid var(--box-color);
  border-radius: 4px;
  background: rgba(15, 123, 104, 0.14);
  cursor: move;
  pointer-events: auto;
}

.extract-region.live {
  border-color: var(--gold);
  background: rgba(165, 107, 19, 0.14);
  pointer-events: none;
}

.extract-region.suggested {
  border-style: dashed;
}

.extract-region.suggested span {
  background: var(--box-color);
}

.extract-region span {
  position: absolute;
  left: -2px;
  bottom: 100%;
  max-width: 180px;
  overflow: hidden;
  border-radius: 4px 4px 0 0;
  padding: 2px 5px;
  background: var(--box-color);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.extract-region.live span {
  background: var(--gold);
}

.extract-region.active {
  box-shadow: 0 0 0 3px rgba(23, 33, 29, 0.18);
}

.extract-region.field-period_hint {
  --box-color: #3763a8;
  background: rgba(55, 99, 168, 0.14);
}

.extract-region.field-table_start {
  --box-color: #4d74a8;
  background: rgba(77, 116, 168, 0.14);
}

.extract-region.field-table_area {
  --box-color: #4d74a8;
  background: rgba(77, 116, 168, 0.07);
  box-shadow: inset 0 0 0 2px rgba(77, 116, 168, 0.35);
}

.extract-region.field-transaction_date {
  --box-color: #0f7b68;
  background: rgba(15, 123, 104, 0.14);
}

.extract-region.field-particulars {
  --box-color: #5b6b2f;
  background: rgba(91, 107, 47, 0.14);
}

.extract-region.field-debit,
.extract-region.field-amount,
.extract-region.field-total_debit {
  --box-color: #b64a60;
  background: rgba(182, 74, 96, 0.16);
}

.extract-region.field-credit,
.extract-region.field-total_credit {
  --box-color: #2f7d45;
  background: rgba(47, 125, 69, 0.16);
}

.extract-region.field-balance,
.extract-region.field-opening_balance,
.extract-region.field-closing_balance {
  --box-color: #a56b13;
  background: rgba(165, 107, 19, 0.16);
}

.extract-region.boundary-region {
  border: 0;
  border-radius: 0;
  background: transparent;
  cursor: ns-resize;
}

.extract-region.boundary-region::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  border-top: 3px solid var(--box-color);
  box-shadow: 0 1px 4px rgba(23, 33, 29, 0.28);
}

.extract-region.boundary-region.suggested::before {
  border-top-style: dashed;
}

.extract-region.field-table_start.boundary-region::before {
  top: 0;
}

.extract-region.boundary-region span {
  bottom: auto;
  top: -21px;
  border-radius: 4px;
}

.extract-region.column-guide-region {
  border-width: 0 2px;
  border-radius: 0;
  background: color-mix(in srgb, var(--box-color) 12%, transparent);
  cursor: ew-resize;
}

.extract-region.column-guide-region.suggested {
  border-style: dashed;
}

.extract-region.column-guide-region span {
  top: 0;
  bottom: auto;
  border-radius: 0 0 4px 4px;
}

.resize-handle {
  position: absolute;
  z-index: 4;
  width: 14px;
  height: 14px;
  margin: -7px;
  border: 2px solid #fff;
  border-radius: 999px;
  background: var(--box-color);
  box-shadow: 0 1px 5px rgba(23, 33, 29, 0.25);
  pointer-events: auto;
}

.extract-region:not(.active):not(:hover) .resize-handle {
  opacity: 0;
  pointer-events: none;
}

.resize-handle.nw {
  left: 0;
  top: 0;
  cursor: nwse-resize;
}

.resize-handle.n {
  left: 50%;
  top: 0;
  cursor: ns-resize;
}

.resize-handle.ne {
  right: 0;
  top: 0;
  cursor: nesw-resize;
}

.resize-handle.e {
  right: 0;
  top: 50%;
  cursor: ew-resize;
}

.resize-handle.se {
  right: 0;
  bottom: 0;
  cursor: nwse-resize;
}

.resize-handle.s {
  left: 50%;
  bottom: 0;
  cursor: ns-resize;
}

.resize-handle.sw {
  left: 0;
  bottom: 0;
  cursor: nesw-resize;
}

.resize-handle.w {
  left: 0;
  top: 50%;
  cursor: ew-resize;
}

/* AI rule suggestion cards */
.ai-suggestions-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ai-suggestion-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 12px;
  background: var(--surface-alt, #f7f9f8);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.ai-suggestion-info {
  flex: 1;
  min-width: 0;
}

.ai-suggestion-pattern {
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ai-suggestion-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.ai-suggestion-sample {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 3px;
  font-style: italic;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ai-suggestion-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  align-items: center;
}

.ai-suggestions-empty {
  font-size: 13px;
  color: var(--text-muted);
  padding: 4px 0;
}

.ai-suggestions-loading {
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
}

.ai-suggestions-footer {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.ai-suggestions-loading::before {
  content: "";
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid var(--border);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.extractor-empty {
  display: grid;
  min-height: 280px;
  place-content: center;
  gap: 6px;
  color: var(--muted);
  text-align: center;
}

.extractor-empty strong {
  color: var(--ink);
}

.extract-preview-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

/* AI categorization status banner */
.ai-categorization-status {
  padding: 10px 14px;
  background: color-mix(in srgb, var(--accent) 8%, var(--panel));
  border: 1px solid color-mix(in srgb, var(--accent) 20%, var(--line));
  border-radius: 8px;
  color: var(--ink);
  margin: 0;
}

/* AI progress overlay shown while AI is categorising */
.analytics-ai-overlay {
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ai-progress-message {
  font-size: 0.9rem;
  color: var(--text-secondary, #666);
}

.ai-progress-bar {
  height: 4px;
  border-radius: 2px;
  background: color-mix(in srgb, var(--accent) 15%, var(--panel));
  overflow: hidden;
}

.ai-progress-bar-inner {
  height: 100%;
  width: 40%;
  border-radius: 2px;
  background: var(--accent, #0d7a5f);
  animation: ai-progress-sweep 1.6s ease-in-out infinite;
}

@keyframes ai-progress-sweep {
  0%   { transform: translateX(-150%); }
  100% { transform: translateX(350%); }
}

.extract-statement-line {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  align-items: center;
  color: var(--muted);
}

.extract-statement-line strong {
  color: var(--ink);
}

.extract-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.extract-check {
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 800;
}

.extract-check.pass {
  background: #edf7f3;
  color: var(--accent-dark);
}

.extract-check.warn {
  background: #fff5df;
  color: var(--gold);
}

.extract-validation-banner {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  line-height: 1.35;
}

.extract-validation-banner.pass {
  border-color: #b8d8ca;
  background: #edf7f3;
  color: var(--accent-dark);
}

.extract-validation-banner.warn {
  border-color: #efcf9b;
  background: #fffaf0;
  color: #7a4d0d;
}

.extract-validation-banner span {
  color: var(--muted);
}

.extract-success-popup {
  display: grid;
  gap: 5px;
  border: 1px solid #b8d8ca;
  border-radius: 8px;
  padding: 14px;
  background: #edf7f3;
  color: var(--accent-dark);
  box-shadow: 0 8px 24px rgba(15, 123, 104, 0.12);
}

.extract-success-popup.warn {
  border-color: #efcf9b;
  background: #fffaf0;
  color: #7a4d0d;
}

.extract-success-popup span {
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.extract-success-popup strong,
.extract-success-popup small {
  color: inherit;
}

.extract-issue-list {
  display: grid;
  gap: 8px;
}

.extract-issue-card {
  display: grid;
  gap: 3px;
  border-left: 4px solid var(--gold);
  border-radius: 6px;
  padding: 9px 10px;
  background: #fffaf0;
}

.extract-issue-card span {
  color: var(--muted);
  line-height: 1.4;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.import-panel,
.review-actions,
.metric-list {
  display: flex;
  gap: 16px;
}

.import-panel,
.metric-list {
  display: grid;
}

.import-activity {
  margin: 12px 0 16px;
}

.activity-card {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--gold);
  border-radius: 8px;
  padding: 12px;
  background: #fffaf0;
}

.activity-card.pass {
  border-left-color: var(--accent);
  background: #edf7f3;
}

.activity-card.risk {
  border-left-color: var(--rose);
  background: #fff0f2;
}

.activity-card.empty {
  border-left-color: var(--line);
  background: #fbfcfa;
}

.activity-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.activity-card small {
  color: var(--muted);
  line-height: 1.4;
}

.manager-empty {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfa;
}

.manager-empty strong,
.manager-empty span {
  display: block;
}

.manager-empty span {
  margin-top: 3px;
  color: var(--muted);
  line-height: 1.35;
}

.combo-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px;
  gap: 6px;
  align-items: center;
  min-width: 0;
}

.mini-button {
  width: 34px;
  min-width: 34px;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--accent-dark);
  font-size: 18px;
  font-weight: 800;
  line-height: 1;
  padding: 0;
}

.mini-button:hover {
  border-color: var(--accent);
  background: #edf7f3;
}

.remark-input {
  min-width: 0;
}

.segmented-control {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px;
  background: #fbfcfa;
}

.segment {
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.segment.active {
  background: var(--accent);
  color: #fff;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
  background: #fff;
  color: var(--ink);
}

.hint {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.hint.warn {
  color: var(--rose);
}

.extractor-mobile-hint {
  display: none;
}

@media (max-width: 760px) {
  .extractor-mobile-hint {
    display: block;
    margin: 0;
    padding: 10px 12px;
    background: #fff7e6;
    border: 1px solid #f0d8a6;
    border-radius: 8px;
    color: #6b4f0d;
    font-size: 13px;
    line-height: 1.45;
  }
}

.primary-button,
.ghost-button {
  min-height: 42px;
  border-radius: 8px;
  padding: 10px 14px;
  font-weight: 800;
}

.primary-button {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
}

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

.ghost-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.metric-list div,
.account-row,
.inbox-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  border-top: 1px solid var(--line);
  padding: 14px 0;
}

.metric-list div:first-child,
.account-row:first-child,
.inbox-row:first-child {
  border-top: 0;
}

.metric-list span,
.account-row span,
.inbox-row span,
.kpi span {
  color: var(--muted);
}

.account-list,
.inbox-list {
  display: grid;
}

.account-row {
  display: block;
}

.account-summary-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  cursor: pointer;
  list-style: none;
}

.account-summary-row::-webkit-details-marker {
  display: none;
}

.account-summary-row::after {
  content: "▾";
  display: grid;
  width: 26px;
  height: 26px;
  flex: 0 0 26px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  font-size: 13px;
  transition: transform 0.15s;
}

.success-mark.compact {
  width: 38px;
  height: 38px;
  font-size: 12px;
}

.account-row[open] .account-summary-row::after {
  transform: rotate(180deg);
}

.account-detail {
  display: grid;
  gap: 10px;
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.account-detail-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
}

.statement-list {
  display: grid;
}

.statement-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.statement-row:first-child {
  border-top: 0;
}

.statement-row.validation-failed {
  margin: 4px 0;
  border: 1px solid rgba(182, 74, 96, 0.35);
  border-radius: 8px;
  padding: 12px;
  background: #fff0f2;
}

.statement-row small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  line-height: 1.45;
}

.statement-actions {
  align-content: start;
  min-width: 74px;
}

.inbox-row {
  align-items: flex-start;
}

.inbox-row strong {
  display: block;
}

.inbox-row small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  line-height: 1.45;
}

.inbox-row .primary-issue {
  color: var(--ink);
  font-weight: 800;
}

.coverage-bands {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.coverage-bands span {
  border: 1px solid #cfe1d9;
  border-radius: 999px;
  padding: 4px 8px;
  background: #edf7f3;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
}

.inbox-row {
  align-items: center;
}

.inbox-actions {
  display: grid;
  gap: 8px;
  min-width: 230px;
}

.conflict-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.help-extractor-file {
  display: grid;
  gap: 6px;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 900;
}

.help-extractor-file input {
  min-height: 38px;
  padding: 7px;
  font-size: 12px;
}

.inbox-period {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 8px;
}

.inbox-period input {
  min-height: 36px;
}

.inbox-review,
.account-name-review {
  display: grid;
  gap: 8px;
}

.inbox-review {
  min-width: min(360px, 100%);
}

.account-name-review small {
  color: var(--muted);
  line-height: 1.35;
}

.existing-account-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.existing-account-buttons .table-button {
  width: auto;
  min-height: 34px;
  padding: 7px 10px;
}

.modal-account-buttons {
  margin-top: 2px;
}

.workbench {
  display: grid;
  gap: 12px;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.mapping-helper,
.mapping-step,
.reader-problems {
  display: grid;
  gap: 10px;
}

.mapping-helper {
  border-left: 4px solid var(--gold);
  border-radius: 6px;
  padding: 10px 12px;
  background: #fffaf0;
}

.mapping-helper span,
.mapping-step span {
  color: var(--muted);
  line-height: 1.4;
}

.mapping-step {
  max-width: 560px;
}

.mapping-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mapping-or {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.mapped-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.mapped-chips span {
  border: 1px solid #cfe1d9;
  border-radius: 999px;
  padding: 4px 8px;
  background: #edf7f3;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
}

.reader-problems small {
  display: block;
  color: var(--muted);
  line-height: 1.4;
}

.workbench label {
  gap: 5px;
  font-size: 12px;
}

.workbench input,
.workbench select {
  min-height: 36px;
}

.mini-table {
  max-width: min(100%, 860px);
}

.mini-table table {
  min-width: 640px;
  font-size: 12px;
}

.mini-table th,
.mini-table td {
  padding: 7px 8px;
}

.mini-table .row-warning td {
  background: #fffaf0;
}

.extraction-table-scroll {
  max-height: min(440px, 54vh);
  overflow: auto;
}

.extraction-table-scroll thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fbf6;
}

.issue-badge {
  min-width: 88px;
  border-radius: 999px;
  padding: 5px 9px;
  background: #edf7f3;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

.issue-badge.warning {
  background: #fff5df;
  color: var(--gold);
}

.issue-badge.risk {
  background: #fff0f2;
  color: var(--rose);
}

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

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

td input,
td select {
  min-width: 180px;
}

.table-button {
  min-height: 36px;
  padding: 7px 10px;
}

.table-actions {
  display: grid;
  gap: 6px;
  min-width: 96px;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.remark-wrap {
  display: none;
  margin-top: 8px;
}

.remark-wrap.visible {
  display: block;
}

.amount-credit {
  color: var(--accent-dark);
  font-weight: 800;
}

.amount-debit {
  color: var(--rose);
  font-weight: 800;
}

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

.kpi {
  display: grid;
  gap: 8px;
  padding: 18px;
}

.kpi strong {
  font-size: 24px;
}

.empty-state {
  display: grid;
  gap: 4px;
  padding: 32px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.empty-state strong {
  color: var(--ink);
}

@media (max-width: 980px) {
  .app-shell,
  .import-grid,
  .import-focus,
  .analysis-grid,
  .extractor-shell,
  .kpi-grid {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
  }

  .nav-list {
    grid-template-columns: 1fr;
  }

  .nav-list.compact {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .extractor-controls {
    position: static;
  }

  .extractor-steps {
    position: static;
    max-height: none;
    overflow: visible;
  }

  .extractor-preview {
    position: static;
  }

  .extractor-workbench {
    grid-template-columns: 1fr;
  }

  .guided-extractor .extractor-workbench {
    grid-template-columns: 1fr;
  }

  .extractor-side-panel {
    position: static;
    max-height: none;
    overflow: visible;
  }

  .workbench-meta,
  .mapping-grid {
    grid-template-columns: 1fr 1fr;
  }

  .upload-modal-heading {
    display: grid;
  }
}

@media (max-width: 640px) {
  .app-shell {
    display: block;
  }

  .workspace,
  .sidebar {
    padding: 14px;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 25;
    gap: 10px;
    box-shadow: 0 10px 24px rgba(23, 33, 29, 0.16);
  }

  .sidebar > div:first-child {
    display: flex;
    align-items: center;
    min-width: 0;
  }

  .sidebar .eyebrow,
  .sidebar-copy,
  .privacy-note,
  .backend-sync-status {
    display: none;
  }

  .sidebar h1 {
    margin: 0;
    font-size: 18px;
    line-height: 1.15;
    /* Reserve space for the absolute-positioned user menu in the top-right */
    padding-right: 96px;
    overflow-wrap: anywhere;
  }

  /* On mobile, the user menu lives inside the sticky dark sidebar, top-right. */
  .sidebar .user-menu {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    position: absolute;
    top: 14px;
    right: 14px;
    margin: 0;
    padding: 0;
    border: none;
    background: transparent;
    color: #dce8e1;
    font-size: 11px;
    line-height: 1.2;
  }

  .sidebar .user-menu[hidden] {
    display: none;
  }

  /* Hide the "Signed in as" prefix on mobile — show only the username. */
  .sidebar .user-menu > span {
    font-size: 0;
    max-width: 60px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .sidebar .user-menu > span strong {
    font-size: 11px;
    font-weight: 600;
    color: #f7faf7;
  }

  .sidebar .user-menu .ghost-button {
    width: auto;
    min-height: 26px;
    padding: 3px 9px;
    font-size: 11px;
    background: transparent;
    color: #f7faf7;
    border-color: rgba(255, 255, 255, 0.32);
  }

  .sidebar .user-menu .ghost-button:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.55);
    color: #fff;
  }

  /* The desktop's workspace user menu would be redundant alongside the sidebar
     menu — hide it on mobile. */
  .workspace-user-menu {
    display: none;
  }

  .workspace-user-menu[hidden] {
    display: none;
  }

  .view-header,
  .section-title {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
  }

  .view.active {
    gap: 14px;
  }

  .panel,
  .modal-card {
    padding: 14px;
  }

  .upload-modal-body {
    margin: 0 -14px;
    padding: 0 14px;
  }

  .upload-modal-footer {
    margin: 4px -14px -14px;
    padding: 12px 14px;
  }

  .upload-modal-title {
    font-size: 18px;
  }

  .primary-button,
  .ghost-button {
    width: 100%;
  }

  .nav-list {
    gap: 8px;
  }

  .nav-list,
  .nav-list.compact {
    grid-template-columns: 1fr 1fr;
  }

  .nav-item {
    min-height: 40px;
    padding: 9px 10px;
    text-align: center;
  }

  .workspace h2 {
    font-size: 23px;
  }

  .analytics-table {
    max-height: none;
    overflow: visible;
    border: 0;
    gap: 10px;
  }

  .analytics-head,
  .analytics-transaction-head {
    display: none;
  }

  .analytics-row {
    grid-template-columns: minmax(0, 1fr) minmax(96px, max-content);
    gap: 8px 12px;
    align-items: start;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
  }

  .analytics-row:not(.analytics-head) > span:nth-child(n + 2) {
    min-width: 0;
    overflow-wrap: anywhere;
    font-size: 15px;
  }

  .analytics-row:not(.analytics-head) > span:first-child {
    grid-column: 1;
    grid-row: 1 / span 2;
  }

  .analytics-row:not(.analytics-head) > span:nth-child(2),
  .analytics-row:not(.analytics-head) > span:nth-child(3) {
    color: var(--muted);
    text-align: left;
    white-space: nowrap;
  }

  .analytics-row:not(.analytics-head) > span:nth-child(2) {
    grid-column: 1;
    grid-row: 3;
  }

  .analytics-row:not(.analytics-head) > span:nth-child(3) {
    grid-column: 2;
    grid-row: 3;
    text-align: right;
  }

  .analytics-row:not(.analytics-head) > span:nth-child(4) {
    grid-column: 2;
    grid-row: 1 / span 2;
    align-self: center;
    font-size: 18px;
    font-weight: 900;
    text-align: right;
    white-space: nowrap;
  }

  .analytics-row:not(.analytics-head) > span:nth-child(2)::before {
    content: "In ";
    color: var(--muted);
    font-weight: 800;
  }

  .analytics-row:not(.analytics-head) > span:nth-child(3)::before {
    content: "Out ";
    color: var(--muted);
    font-weight: 800;
  }

  .analytics-row:not(.analytics-head) > span:nth-child(4)::before {
    content: "Net";
    display: block;
    margin-bottom: 2px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.04em;
  }

  .analytics-row:not(.analytics-head) > span:first-child strong {
    font-size: 17px;
    line-height: 1.25;
  }

  .analytics-row small {
    font-size: 14px;
    line-height: 1.45;
  }

  /* All chips visible at once — wrap to multiple rows. Long names (the
     BRN-Flexi/…/AMEET case) get capped to 100% of the row width and
     ellipsised inside so they can't push the modal sideways. */
  .subcategory-filter-bar {
    gap: 6px;
    padding: 2px 0;
  }

  .subcategory-chip {
    font-size: 14px;
    padding: 6px 12px;
    min-height: 36px;
    max-width: 100%;
  }

  .subcategory-chip-group {
    max-width: 100%;
  }

  .subcategory-chip-name {
    font-size: 14px;
  }

  .subcategory-chip-amount {
    font-size: 12px;
  }

  .subcategory-chip-edit {
    width: 28px;
    height: 28px;
    font-size: 13px;
    flex-shrink: 0;
  }

  .analytics-check-list small {
    white-space: normal;
  }

  .account-summary-row,
  .account-detail-header,
  .statement-row,
  .inbox-row,
  .manager-empty {
    display: grid;
    grid-template-columns: 1fr;
  }

  .statement-row,
  .inbox-row {
    gap: 10px;
  }

  .account-summary-row::after {
    justify-self: start;
  }

  .statement-actions,
  .table-actions,
  .inbox-actions,
  .inbox-review {
    width: 100%;
    min-width: 0;
  }

  .statement-actions,
  .table-actions {
    grid-template-columns: 1fr 1fr;
  }

  .table-button {
    width: 100%;
  }

  .existing-account-buttons .table-button {
    width: auto;
  }

  .workbench-meta,
  .mapping-grid,
  .inbox-period,
  .split-actions,
  .pdf-extractor-prompt,
  .upload-modal-progress,
  .analytics-scope-grid,
  .analytics-filter-groups,
  .analytics-modal-grid,
  .analytics-edit-panel,
  .analytics-edit-actions,
  .analytics-mini-table div,
  .analytics-transaction-line,
  .transaction-context-row,
  .manage-category-row {
    grid-template-columns: 1fr;
  }

  /* Category modal totals — keep all three on one tight row on mobile so the
     transaction list isn't pushed off screen by Credit / Debit / Net cards. */
  .analytics-totals {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  .analytics-totals div {
    padding: 6px 8px;
  }

  .analytics-totals span {
    font-size: 11px;
    letter-spacing: 0.04em;
  }

  .analytics-totals strong {
    font-size: 17px;
  }

  .analytics-transaction-list {
    padding-right: 0;
  }

  .analytics-transaction-line:not(.analytics-transaction-head) {
    grid-template-columns: minmax(0, 1fr) minmax(86px, max-content);
    gap: 5px 10px;
    align-items: start;
  }

  .analytics-transaction-line:not(.analytics-transaction-head) > span:first-child {
    grid-column: 1;
    grid-row: 1;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
  }

  .analytics-transaction-line:not(.analytics-transaction-head) > strong:first-of-type {
    grid-column: 1 / -1;
    grid-row: 2;
    min-width: 0;
    overflow-wrap: anywhere;
    line-height: 1.4;
    font-size: 15px;
  }

  .analytics-transaction-line:not(.analytics-transaction-head) > strong:nth-of-type(2) {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
    font-size: 16px;
    line-height: 1.25;
    text-align: right;
    white-space: nowrap;
  }

  .analytics-transaction-line:not(.analytics-transaction-head) > .analytics-edit-icon {
    grid-column: 2;
    grid-row: 3;
    justify-self: end;
  }

  .analytics-modal-title-row {
    display: grid;
  }

  table,
  .mini-table table {
    min-width: 0;
    font-size: 11px;
  }

  th,
  td {
    padding: 7px 6px;
  }

  td input,
  td select {
    width: 100%;
    min-width: 0;
  }

  .mini-table,
  .extraction-table-scroll {
    max-width: 100%;
  }

  .extractor-toolbar {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .guided-extractor .extractor-toolbar {
    position: static;
  }

  .extractor-field-bar,
  .guided-extractor .extractor-field-bar {
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .extractor-field-bar button {
    flex: 0 0 auto;
  }

  .extractor-steps {
    overflow-x: auto;
  }

  .extract-step-list {
    display: flex;
    min-width: max-content;
  }

  .extractor-page-controls span {
    order: -1;
  }

  .extractor-page-controls {
    grid-template-columns: 1fr 1fr 1fr;
  }

  .extractor-page-controls span,
  .page-jump-label {
    grid-column: 1 / -1;
  }

  .extract-page-frame {
    min-width: 640px;
    padding: 8px;
  }

  .extractor-canvas-wrap {
    border-radius: 6px;
    -webkit-overflow-scrolling: touch;
  }

  .auth-gate {
    align-items: start;
    overflow: auto;
    padding: 20px;
  }

  .auth-card {
    margin-top: max(8vh, env(safe-area-inset-top));
    padding: 22px 20px;
  }

  .resize-handle {
    width: 20px;
    height: 20px;
    margin: -10px;
  }
}

@media (max-width: 380px) {
  .workspace,
  .sidebar {
    padding: 12px;
  }

  .workspace-user-menu {
    align-items: stretch;
    flex-direction: column;
  }

  .workspace-user-menu .ghost-button {
    width: 100%;
  }
}

/* New utility styles */

.view-subtitle {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.clear-data-row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 14px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.danger-button {
  border-color: #e5b8bf;
  color: var(--rose);
  white-space: nowrap;
}

.danger-button:hover {
  border-color: var(--rose);
  background: #fff0f2;
  color: var(--rose);
}

.risk-kicker {
  background: #fff0f2;
  color: var(--rose);
}

.clear-data-mark {
  background: var(--rose);
  box-shadow: 0 14px 36px rgba(182, 74, 96, 0.24);
}

.clear-data-modal {
  justify-items: center;
  text-align: center;
}

.clear-data-modal .modal-actions {
  width: 100%;
  justify-content: stretch;
}

.clear-data-modal .modal-actions button {
  flex: 1;
}
