/* Layout: dark side rail with the modules, a light working surface, cards for records, one blue accent for actions. */
:root {
  --bg: #F4F5F7; --surface: #FFFFFF; --surface-2: #EEF0F4; --ink: #172033; --muted: #55607A;
  --line: #DDE1E8; --line-strong: #A9B2C4; --rail: #172033; --rail-ink: #C9D2E3; --rail-active: #2A3654; --rail-ink-strong: #FFFFFF;
  --accent: #1F4FBF; --accent-ink: #FFFFFF; --accent-tint: #E8EEFB; --accent-strong: #163A8C;
  --good: #14653B; --good-tint: #E3F4EA; --warn: #8A4300; --warn-tint: #FFF1DC; --bad: #A32020; --bad-tint: #FCE8E8;
  --shadow: 0 12px 40px rgba(23, 32, 51, 0.25); --overlay: rgba(23, 32, 51, 0.5);
  --font: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --display: 'Source Serif 4', Georgia, 'Times New Roman', serif;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #0F1522; --surface: #182032; --surface-2: #212B40; --ink: #E8ECF4; --muted: #A3AEC4;
  --line: #2C3750; --line-strong: #46536F; --rail: #0B101B; --rail-ink: #AEB9D0; --rail-active: #222D45; --rail-ink-strong: #FFFFFF;
  --accent: #7FA4FF; --accent-ink: #0B1220; --accent-tint: #1E2C4F; --accent-strong: #A9C1FF;
  --good: #6FD39B; --good-tint: #173526; --warn: #F3B36A; --warn-tint: #3A2A14; --bad: #FF9A9A; --bad-tint: #3D1A1A;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.55); --overlay: rgba(0, 0, 0, 0.6); color-scheme: dark;
} }
:root[data-theme="dark"] {
  --bg: #0F1522; --surface: #182032; --surface-2: #212B40; --ink: #E8ECF4; --muted: #A3AEC4;
  --line: #2C3750; --line-strong: #46536F; --rail: #0B101B; --rail-ink: #AEB9D0; --rail-active: #222D45; --rail-ink-strong: #FFFFFF;
  --accent: #7FA4FF; --accent-ink: #0B1220; --accent-tint: #1E2C4F; --accent-strong: #A9C1FF;
  --good: #6FD39B; --good-tint: #173526; --warn: #F3B36A; --warn-tint: #3A2A14; --bad: #FF9A9A; --bad-tint: #3D1A1A;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.55); --overlay: rgba(0, 0, 0, 0.6); color-scheme: dark;
}

html, body, #root { height: 100%; }
body { background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 15px; line-height: 1.45; }
* { box-sizing: border-box; }
h1, h2, h3, h4, p { margin: 0; }
a { color: var(--accent); }
a:hover { color: var(--accent-strong); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* Shell */
.app { display: flex; flex-wrap: wrap; min-height: 100%; }
.nav { flex: 1 1 210px; max-width: 240px; background: var(--rail); padding: 20px 12px; display: flex; flex-direction: column; gap: 2px; }
.nav-brand { color: var(--rail-ink-strong); font-weight: 600; font-size: 17px; padding: 0 12px 16px; }
.nav-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; min-height: 42px; padding: 0 12px; border: 0; border-radius: 8px; background: none; color: var(--rail-ink); text-align: left; cursor: pointer; }
.nav-item:hover { background: var(--rail-active); color: var(--rail-ink-strong); }
.nav-item.active { background: var(--rail-active); color: var(--rail-ink-strong); font-weight: 500; }
.nav-badge { min-width: 22px; padding: 0 6px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-size: 12px; font-weight: 600; text-align: center; }
.nav-foot { margin-top: auto; padding: 12px; color: var(--rail-ink); font-size: 12px; }
.main { flex: 999 1 560px; min-width: 0; padding: 28px 28px 80px; display: flex; flex-direction: column; gap: 20px; }
@media (max-width: 820px) {
  .nav { max-width: none; flex: 1 1 100%; flex-direction: row; overflow-x: auto; padding: 8px 16px; align-items: center; }
  .nav-brand { padding: 0 12px 0 0; white-space: nowrap; }
  .nav-item { width: auto; white-space: nowrap; }
  .nav-foot { display: none; }
  .main { padding: 20px 16px 80px; }
}

/* Type */
.h1 { font-family: var(--display); font-weight: 600; font-size: 28px; line-height: 1.2; text-wrap: balance; }
.h2 { font-size: 17px; font-weight: 600; }
.h3 { font-size: 15px; font-weight: 600; }
.display { font-family: var(--display); font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.strong { font-weight: 600; }
.num { font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.pre { white-space: pre-wrap; }
.label { font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }

/* Layout helpers */
.row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.row.between { justify-content: space-between; }
.row.top { align-items: flex-start; }
.row.tight { gap: 8px; }
.row.nowrap { flex-wrap: nowrap; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack.tight { gap: 6px; }
.stack.loose { gap: 20px; }
.grow { flex: 1 1 260px; min-width: 0; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; align-items: start; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; align-items: start; }
.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.split { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.split > .split-main { flex: 3 1 420px; min-width: 0; display: flex; flex-direction: column; gap: 20px; }
.split > .split-side { flex: 2 1 280px; min-width: 0; display: flex; flex-direction: column; gap: 20px; }
.page-head { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; justify-content: space-between; }

/* Surfaces */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 18px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.card.flush { padding: 0; }
.card-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; }
.list { display: flex; flex-direction: column; }
.list-item { border-top: 1px solid var(--line); padding: 12px 0; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; }
.list-item:first-child { border-top: 0; padding-top: 0; }
.list-item:last-child { padding-bottom: 0; }
.list-item > .grow { flex: 1 1 220px; }
.clickable { cursor: pointer; }
.clickable:hover { background: var(--surface-2); }
.kpi { display: flex; flex-direction: column; gap: 2px; }
.kpi-value { font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; }
.empty { padding: 24px; text-align: center; color: var(--muted); border: 1px dashed var(--line-strong); border-radius: 12px; }
.banner { padding: 12px 14px; border-radius: 10px; background: var(--accent-tint); color: var(--ink); display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; }
.banner.warn { background: var(--warn-tint); }
.banner.bad { background: var(--bad-tint); }
.banner.good { background: var(--good-tint); }
.divider { border: 0; border-top: 1px solid var(--line); margin: 0; }

/* Controls */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font-weight: 500; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--surface-2); color: var(--ink); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: var(--accent-ink); }
.btn.danger { border-color: var(--bad); color: var(--bad); }
.btn.ghost { border-color: transparent; background: none; color: var(--accent); }
.btn.ghost:hover { background: var(--accent-tint); }
.btn.sm { min-height: 32px; padding: 0 10px; font-size: 13px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.link { border: 0; background: none; padding: 0; color: var(--accent); cursor: pointer; font-weight: 500; text-align: left; }
.link:hover { color: var(--accent-strong); text-decoration: underline; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label, .field-label { font-size: 13px; font-weight: 500; }
.field-hint { font-size: 12px; color: var(--muted); }
.input, .select, .textarea { width: 100%; min-height: 40px; padding: 8px 11px; border-radius: 8px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); }
.textarea { min-height: 96px; resize: vertical; }
.check { display: inline-flex; gap: 8px; align-items: center; cursor: pointer; }
.check input { width: 18px; height: 18px; }
.drop { border: 1px dashed var(--line-strong); border-radius: 10px; padding: 16px; color: var(--muted); text-align: center; cursor: pointer; background: var(--surface); }
.drop.over { border-color: var(--accent); background: var(--accent-tint); }

/* Status */
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.pill.blue { background: var(--accent-tint); color: var(--accent-strong); }
.pill.green { background: var(--good-tint); color: var(--good); }
.pill.amber { background: var(--warn-tint); color: var(--warn); }
.pill.red { background: var(--bad-tint); color: var(--bad); }
.text-good { color: var(--good); } .text-warn { color: var(--warn); } .text-bad { color: var(--bad); }

/* Tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table th.right, .table td.right { text-align: right; }
.table tfoot td { font-weight: 600; border-top: 1px solid var(--line-strong); }

/* Tabs */
.tabs { display: flex; flex-wrap: wrap; gap: 2px; border-bottom: 1px solid var(--line); }
.tab { min-height: 42px; padding: 0 14px; border: 0; border-bottom: 3px solid transparent; background: none; color: var(--muted); cursor: pointer; }
.tab:hover { color: var(--ink); }
.tab.active { color: var(--ink); font-weight: 600; border-bottom-color: var(--accent); }

/* Modal + toast */
.modal-overlay { position: fixed; inset: 0; z-index: 50; background: var(--overlay); display: flex; justify-content: center; align-items: flex-start; padding: 48px 16px; overflow-y: auto; }
.modal { width: 100%; max-width: 640px; background: var(--surface); border-radius: 16px; padding: 24px; display: flex; flex-direction: column; gap: 16px; box-shadow: var(--shadow); }
.modal.wide { max-width: 920px; }
.modal-foot { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; }
.toasts { position: fixed; z-index: 60; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100% - 32px)); }
.toast { background: var(--ink); color: var(--bg); padding: 12px 14px; border-radius: 10px; box-shadow: var(--shadow); }
.toast.bad { background: var(--bad); color: var(--surface); }
.spinner { width: 16px; height: 16px; border: 2px solid var(--line-strong); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.thumb { max-width: 100%; max-height: 220px; border: 1px solid var(--line); border-radius: 8px; }
.ai-tag { display: inline-flex; padding: 2px 10px; border-radius: 999px; background: var(--accent-tint); color: var(--accent-strong); font-size: 12.5px; font-weight: 600; }
.boot { min-height: 60vh; display: flex; flex-direction: column; gap: 12px; align-items: center; justify-content: center; text-align: center; padding: 32px 16px; }

/* Account block in the side rail, and the sign-in page (website only). */
.nav-account { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--rail-active); display: flex; flex-direction: column; gap: 2px; }
.nav-account-name { color: var(--rail-ink-strong); font-weight: 500; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-account-firm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-signout { align-self: flex-start; margin-top: 6px; min-height: 32px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--line-strong); background: none; color: var(--rail-ink); cursor: pointer; }
.nav-signout:hover { background: var(--rail-active); color: var(--rail-ink-strong); }
@media (max-width: 820px) { .nav-foot { display: flex; align-items: center; gap: 10px; margin: 0 0 0 auto; padding: 0 0 0 12px; white-space: nowrap; } .nav-account { margin: 0; padding: 0; border: 0; flex-direction: row; align-items: center; gap: 8px; } .nav-account-firm, .nav-account-name { display: none; } .nav-signout { margin: 0; } }
.auth { min-height: 100%; display: flex; flex-wrap: wrap; }
.auth-side { flex: 1 1 320px; background: var(--rail); color: var(--rail-ink); padding: 48px 40px; display: flex; flex-direction: column; gap: 20px; justify-content: center; }
.auth-side .brand { font-family: var(--display); font-weight: 600; font-size: 34px; line-height: 1.15; color: var(--rail-ink-strong); }
.auth-side ul { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 12px; max-width: 420px; }
.auth-side li { padding-left: 16px; border-left: 3px solid var(--accent); }
.auth-main { flex: 2 1 380px; display: flex; align-items: center; justify-content: center; padding: 40px 16px; }
.auth-card { width: 100%; max-width: 440px; }
.auth-error { padding: 10px 12px; border-radius: 8px; background: var(--bad-tint); color: var(--bad); }
.auth-note { padding: 10px 12px; border-radius: 8px; background: var(--warn-tint); color: var(--ink); font-size: 13px; }
@media (max-width: 820px) { .auth-side { padding: 28px 20px; } .auth-side ul { display: none; } }

body { margin: 0; }
[hidden] { display: none !important; }
@media (min-width: 821px) { .nav { position: sticky; top: 0; height: 100vh; align-self: flex-start; overflow-y: auto; } }
.az-list { margin: 0 0 4px; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; }
.steps { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 6px; }
.addr { display: inline-block; padding: 2px 8px; border-radius: 6px; background: var(--surface-2); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; overflow-wrap: anywhere; }
