/* Invoices to file — review prototype.
   Tokens copied verbatim from apps/web/src/assets/styles/globals.css.
   Shape and state rules follow DESIGN.md: borderless by default, rounded-3xl
   surfaces, rounded-full pills, borders only for error and focus. */

:root {
  --background: #f3effa;
  --foreground: #121021;
  --card: #ffffff;
  --primary: #06041f;
  --primary-foreground: #ffffff;
  --secondary: #e8e5f0;
  --muted: #e8e5f0;
  --muted-foreground: #6e6a8b;
  --accent-soft: #e9e5f9;
  --accent-soft-hover: #ddd6f3;
  --border: #d4c5e6;
  --destructive: #e62b0f;
  --success: #0cc078;
  --warning: #f9c152;
  --ring: #5935e9;

  --radius-surface: 24px;
  --radius-pill: 999px;
  --shadow-card: 0 1px 2px rgba(18, 16, 33, .04), 0 8px 24px rgba(18, 16, 33, .05);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: #eae5f5;
  color: var(--foreground);
  font: 14px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }

/* ------------------------------------------------------------ review shell */

.review-toolbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; flex-wrap: wrap; gap: 16px; align-items: center; justify-content: space-between;
  padding: 14px 24px;
  background: var(--primary); color: var(--primary-foreground);
}
.review-kicker { display: block; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; opacity: .65; }
.review-brand strong { font-size: 15px; font-weight: 600; }
.review-controls { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; }
.review-controls label { display: flex; gap: 8px; align-items: center; font-size: 12px; opacity: .9; }
.review-controls select {
  padding: 7px 12px; border: 0; border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, .12); color: inherit; font: inherit;
}
.review-controls select option { color: var(--foreground); }
.notes-toggle input { accent-color: var(--ring); }
.quiet-button {
  padding: 7px 16px; border: 0; border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, .16); color: inherit; font: inherit; cursor: pointer;
}
.quiet-button:hover { background: rgba(255, 255, 255, .26); }

.state-pills { display: flex; flex-wrap: wrap; gap: 8px; padding: 14px 24px 0; }
.state-pill {
  padding: 7px 14px; border: 0; border-radius: var(--radius-pill);
  background: var(--card); color: var(--muted-foreground);
  font: inherit; font-size: 12px; cursor: pointer; transition: background 180ms, color 180ms;
}
.state-pill:hover { background: var(--accent-soft-hover); }
.state-pill.is-active { background: var(--primary); color: var(--primary-foreground); }

.prototype-layout {
  display: grid; grid-template-columns: minmax(0, 1fr) 340px;
  gap: 20px; padding: 18px 24px 48px; align-items: start;
}
body.notes-hidden .prototype-layout { grid-template-columns: minmax(0, 1fr); }

.review-notes {
  position: sticky; top: 84px;
  display: flex; flex-direction: column; gap: 14px;
  padding: 20px; border-radius: var(--radius-surface);
  background: var(--card); box-shadow: var(--shadow-card);
}
.note-heading { display: flex; align-items: center; justify-content: space-between; }
.note-group { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted-foreground); }
.score-target { font-size: 11px; color: var(--success); font-weight: 600; }
.review-notes h2 { margin: 0; font-size: 16px; }
.review-notes h3 { margin: 0 0 4px; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted-foreground); }
.review-notes p, .review-notes li { margin: 0; font-size: 13px; }
.review-notes ul { margin: 0; padding-left: 16px; display: grid; gap: 4px; }
.question-card { padding: 12px; border-radius: 16px; background: var(--accent-soft); }

/* --------------------------------------------------------------- app frame */

.screen-root { border-radius: var(--radius-surface); overflow: hidden; box-shadow: var(--shadow-card); }
.app { display: grid; grid-template-columns: 210px minmax(0, 1fr); background: var(--background); min-height: 720px; position: relative; }

.sidebar { padding: 18px 12px; background: var(--card); }
.sidebar-brand { display: flex; gap: 10px; align-items: center; padding: 4px 10px 18px; font-weight: 600; }
.sidebar-brand .mark { color: var(--ring); }
.nav-item {
  display: flex; gap: 10px; align-items: center;
  padding: 8px 10px; margin-bottom: 2px; border-radius: var(--radius-pill);
  color: var(--muted-foreground); text-decoration: none; font-size: 13px;
}
.nav-item:hover { background: var(--accent-soft-hover); }
.nav-item.is-active { background: var(--accent-soft); color: var(--foreground); font-weight: 600; }
.nav-glyph { width: 16px; text-align: center; opacity: .75; }
.nav-badge {
  margin-left: auto; min-width: 20px; padding: 1px 7px; border-radius: var(--radius-pill);
  background: var(--primary); color: var(--primary-foreground); font-size: 11px; font-weight: 600; text-align: center;
}

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 14px 24px; }
.crumb { display: flex; gap: 8px; align-items: center; color: var(--muted-foreground); font-size: 13px; }
.crumb strong { color: var(--foreground); }
.topbar-actions { display: flex; gap: 10px; align-items: center; }
.icon-btn { border: 0; background: transparent; color: var(--muted-foreground); font-size: 15px; cursor: pointer; border-radius: var(--radius-pill); padding: 6px 8px; }
.icon-btn:hover { background: var(--accent-soft-hover); }
.avatar { display: grid; place-items: center; width: 30px; height: 30px; border-radius: var(--radius-pill); background: var(--accent-soft); font-size: 11px; font-weight: 600; }

.page { display: grid; gap: 18px; padding: 0 24px 28px; }
.tabs { display: flex; gap: 22px; }
.tab { padding: 8px 0; color: var(--muted-foreground); text-decoration: none; font-size: 13px; border-bottom: 2px solid transparent; }
.tab:hover { color: var(--foreground); }
.tab.is-active { color: var(--foreground); font-weight: 600; border-bottom-color: var(--primary); }

/* ------------------------------------------------------------------- queue */

.queue { display: grid; gap: 12px; padding: 18px; border-radius: var(--radius-surface); background: var(--card); box-shadow: var(--shadow-card); }
.queue-head { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; }
.queue-head h2 { margin: 0; font-size: 15px; display: flex; gap: 8px; align-items: center; }
.count { min-width: 22px; padding: 1px 8px; border-radius: var(--radius-pill); background: var(--accent-soft); font-size: 12px; text-align: center; }
.intake { display: flex; gap: 8px; align-items: center; }
.intake code { padding: 5px 12px; border-radius: var(--radius-pill); background: var(--muted); font-size: 12px; }

.rows { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.row {
  display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; gap: 14px; align-items: start;
  padding: 14px 16px; border-radius: 18px; background: var(--background);
  transition: background 180ms;
}
.row:hover { background: var(--accent-soft); }
.row--empty, .row--success { background: var(--accent-soft); }
.row--error { background: #fdecea; border: 1px solid var(--destructive); }
.row.is-busy { opacity: .75; }
.dot { width: 8px; height: 8px; margin-top: 6px; border-radius: var(--radius-pill); background: var(--muted-foreground); }
.dot--reading { background: var(--warning); }
.dot--ready { background: var(--ring); }
.dot--attention { background: var(--warning); }
.dot--done { background: var(--success); }
.dot--error { background: var(--destructive); }
.row-body { min-width: 0; display: grid; gap: 2px; }
.row-state { margin: 0; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted-foreground); }
.row-title { margin: 0; font-size: 14px; font-weight: 600; }
.row-meta { margin: 0; font-size: 12px; color: var(--muted-foreground); }
.row-hint { margin: 4px 0 0; font-size: 12px; }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: flex-end; }

.candidates { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 6px; }
.candidate { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 10px 12px; border-radius: 14px; background: var(--card); }
.candidate--search { justify-content: flex-start; }

.pending { display: inline-flex; gap: 8px; align-items: center; font-size: 12px; color: var(--muted-foreground); }
.pending--danger { color: var(--destructive); }
.spinner {
  width: 13px; height: 13px; border-radius: var(--radius-pill);
  border: 2px solid var(--accent-soft-hover); border-top-color: var(--ring);
  animation: spin 800ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }

/* ------------------------------------------------------------------ button */

.btn { padding: 7px 14px; border: 0; border-radius: var(--radius-pill); font: inherit; font-size: 12px; cursor: pointer; transition: background 180ms; }
.btn--quiet { background: var(--card); color: var(--foreground); }
.btn--quiet:hover { background: var(--accent-soft-hover); }
.btn--primary { background: var(--primary); color: var(--primary-foreground); font-weight: 600; }
.btn--primary:hover { background: #1d1940; }
.btn--danger { background: var(--destructive); color: #fff; font-weight: 600; }
.btn--danger:hover { background: #c22409; }

/* ------------------------------------------------------------------- table */

.journeys { display: grid; gap: 12px; padding: 18px; border-radius: var(--radius-surface); background: var(--card); box-shadow: var(--shadow-card); }
.journeys-toolbar { display: flex; gap: 8px; }
.search { flex: 1; max-width: 280px; padding: 8px 14px; border: 0; border-radius: var(--radius-pill); background: var(--muted); font: inherit; font-size: 12px; }
.search--block { max-width: none; width: 100%; }
.table { width: 100%; border-collapse: collapse; font-size: 12px; }
.table th { padding: 8px 10px; text-align: left; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted-foreground); font-weight: 500; }
.table td { padding: 11px 10px; }
.table tbody tr + tr td { border-top: 1px solid rgba(212, 197, 230, .4); }
/* A signed amount must never wrap between its sign and its digits. */
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table tbody td:nth-child(2) { white-space: nowrap; }
.table .strong, .strong { font-weight: 600; }
.table .muted, .muted { color: var(--muted-foreground); }
.under { color: var(--success); }
.over { color: var(--destructive); }

/* ----------------------------------------------------------------- dialogs */

.backdrop { position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; background: rgba(18, 16, 33, .38); }
.dialog { width: min(560px, 100%); max-height: 100%; overflow: auto; border-radius: var(--radius-surface); background: var(--card); box-shadow: 0 24px 60px rgba(18, 16, 33, .22); }
.dialog--wide { width: min(940px, 100%); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 10px; }
.dialog-head h3 { margin: 0; font-size: 15px; }
.dialog-body { padding: 0 20px 16px; display: grid; gap: 12px; }
.dialog-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 14px 20px 18px; }
.dialog-lead { margin: 0; font-size: 13px; }
.group-label { margin: 6px 0 0; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted-foreground); }
.picks { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.pick label { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 16px; background: var(--background); cursor: pointer; }
.pick label:hover { background: var(--accent-soft); }
.pick input { margin-top: 3px; accent-color: var(--ring); }
.pick span span { display: block; }

.doc { display: grid; grid-template-columns: minmax(0, 320px) minmax(0, 1fr); gap: 16px; }
.doc-pdf { padding: 12px; border-radius: 18px; background: var(--muted); }
.pdf-page { padding: 18px; border-radius: 12px; background: #fff; font-size: 10px; color: #333; box-shadow: var(--shadow-card); }
.pdf-head { margin: 0; font-size: 12px; font-weight: 700; letter-spacing: .04em; }
.pdf-sub { margin: 2px 0 12px; color: var(--muted-foreground); }
.pdf-lines p { display: flex; justify-content: space-between; gap: 12px; margin: 0 0 5px; }
.pdf-total { display: flex; justify-content: space-between; margin: 12px 0 0; padding-top: 8px; border-top: 1px solid var(--border); font-weight: 700; }
.doc-read { display: grid; gap: 12px; align-content: start; }
.doc-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.doc-fields > div { display: grid; gap: 2px; padding: 10px 12px; border-radius: 14px; background: var(--background); }
.field-label { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted-foreground); }
.table--lines td { padding: 8px 10px; }
.chip { display: inline-block; padding: 2px 10px; border-radius: var(--radius-pill); background: var(--accent-soft); font-size: 11px; }
.doc-foot-note { margin: 0; font-size: 11px; color: var(--muted-foreground); }

/* -------------------------------------------------------------- responsive */

@media (max-width: 1100px) {
  .prototype-layout { grid-template-columns: minmax(0, 1fr); }
  .review-notes { position: static; }
}
@media (max-width: 900px) {
  .app { grid-template-columns: 64px minmax(0, 1fr); }
  .nav-item span:not(.nav-glyph):not(.nav-badge) { display: none; }
  .sidebar-brand span:last-child { display: none; }
  .row { grid-template-columns: 10px minmax(0, 1fr); }
  .row-actions { grid-column: 2; justify-content: flex-start; }
  .doc { grid-template-columns: minmax(0, 1fr); }
  .table { display: block; overflow-x: auto; white-space: nowrap; }
}
