/* Cited design system. Warm paper, black ink, a newspaper serif, and a highlighter-yellow footnote.
   Brand guide: "Brand identities: Atrium, Cited, Leadline". */
:root {
  --font: "Inter Tight", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --serif: "Newsreader", "Iowan Old Style", Georgia, serif;

  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #fafaf8;
  --sunken: #f4f3ef;
  --text: #111111;
  --text-2: #3b3936;
  --muted: #6b6862;
  --faint: #8a867f;
  --line: #e7e4dd;
  --line-strong: #d4cfc4;

  --ink: #111111;
  --ink-text: #fbfaf7;
  --accent: #111111;
  --accent-soft: #fff4bf;
  --focus: #c9a400;

  --ok: #1f7a4d;
  --warn: #b4580e;
  --danger: #c2331f;
  --info: #111111;
  --idle: #8a867f;
  --ok-soft: #e7f2ec; --warn-soft: #faeee2; --danger-soft: #f9e5e1; --info-soft: #f1efe9; --idle-soft: #f1efe9;
  --mark: #ffe066;
  --mark-soft: #fff4bf;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 0 rgba(20, 20, 19, 0.04);
  --shadow: 0 1px 2px rgba(20, 20, 19, 0.06), 0 12px 32px -12px rgba(20, 20, 19, 0.16);
  --sidebar-w: 252px;
}
:root[data-theme="dark"] {
  --bg: #2a2a28; --surface: #333331; --surface-2: #2f2f2d; --sunken: #3a3a37;
  --text: #ebe8e1; --text-2: #d3cfc6; --muted: #aaa69c; --faint: #8c887f; --line: #474641; --line-strong: #57554f;
  --ink: #ebe8e1; --ink-text: #2a2a28; --accent: #ebe8e1; --accent-soft: #4a4430; --focus: #d9b84a;
  --mark: #d9b84a; --mark-soft: #4a4430;
  --ok: #92d1ad; --warn: #e8b382; --danger: #f2a08f; --info: #ebe8e1; --idle: #8c887f;
  --ok-soft: #36423b; --warn-soft: #4a3e31; --danger-soft: #4b3632; --info-soft: #3a3a37; --idle-soft: #3a3a37;
  --shadow-sm: none; --shadow: 0 12px 32px -14px rgba(0, 0, 0, 0.45);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 400 14.5px/1.55 var(--font); background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
a { color: var(--text); text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px; }
a:hover { text-decoration-color: currentColor; }
.nav a, .btn, .menu a, .segmented a, .logo, .row-link, .workspace, .mk-nav .links a, .crumbs a, .icon-btn { text-decoration: none; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3, h4 { margin: 0; color: var(--text); text-wrap: balance; }
h1 { font: 400 34px/1.1 var(--serif); letter-spacing: -0.01em; }
h2 { font-size: 15.5px; font-weight: 600; letter-spacing: -0.005em; }
h3 { font-size: 14.5px; font-weight: 600; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.serif { font-family: var(--serif); font-weight: 400; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); border: 0; }
.icon { width: 18px; height: 18px; flex: none; }
.icon-sm { width: 15px; height: 15px; flex: none; }

/* ---------- App shell ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 2px; padding: 18px 14px; background: var(--bg); border-right: 1px solid var(--line); overflow-y: auto; }
.workspace { display: flex; align-items: center; gap: 11px; padding: 6px 8px 18px; margin-bottom: 4px; }
.workspace .mark { width: 34px; height: 34px; border-radius: 9px; background: var(--ink); color: var(--ink-text); display: grid; place-items: center; font: 400 17px/1 var(--serif); flex: none; }
.workspace .name { font-weight: 600; line-height: 1.2; }
.workspace .sub { font-size: 12px; color: var(--muted); }
.nav-label { font-size: 11px; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint); padding: 16px 10px 6px; }
.nav a { position: relative; display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px; color: var(--text-2); font-weight: 500; }
.nav a .icon { color: var(--faint); }
.nav a:hover { background: var(--sunken); text-decoration: none; color: var(--text); }
.nav a[aria-current="page"] { background: var(--surface); color: var(--text); box-shadow: inset 0 0 0 1px var(--line); }
.nav a[aria-current="page"] .icon { color: var(--text); }
.nav a[aria-current="page"]::before { content: ""; position: absolute; left: -14px; top: 9px; bottom: 9px; width: 3px; border-radius: 0 3px 3px 0; background: var(--mark); }
.nav a .count { margin-left: auto; font-size: 11.5px; font-weight: 600; color: var(--danger); font-variant-numeric: tabular-nums; }
.sidebar-foot { margin-top: auto; padding: 14px 10px 4px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); display: grid; gap: 6px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 12px 32px; background: color-mix(in srgb, var(--bg) 86%, transparent); backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line); }
.search { flex: 1; max-width: 480px; position: relative; }
.search input { width: 100%; padding-left: 34px; background: var(--surface); border-color: var(--line); }
.search .icon-sm { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--faint); pointer-events: none; }
.topbar .spacer { flex: 1; }
.icon-btn { position: relative; display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 8px; color: var(--text-2); background: transparent; border: 1px solid transparent; cursor: pointer; }
.icon-btn:hover { background: var(--sunken); text-decoration: none; }
.icon-btn .dot { position: absolute; top: 4px; right: 3px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px; background: var(--danger); color: #fff; font-size: 10px; font-weight: 700; display: grid; place-items: center; border: 2px solid var(--bg); }
.user-menu { position: relative; }
.user-menu summary { list-style: none; display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 3px 10px 3px 3px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); }
.user-menu summary::-webkit-details-marker { display: none; }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--ink); color: var(--ink-text); display: grid; place-items: center; font-size: 11.5px; font-weight: 600; flex: none; letter-spacing: 0.02em; }
.menu { position: absolute; right: 0; top: calc(100% + 6px); width: 248px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 6px; z-index: 30; }
.menu .who { padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.menu a, .menu button { display: flex; width: 100%; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 6px; color: var(--text); font: inherit; background: none; border: 0; text-align: left; cursor: pointer; }
.menu a:hover, .menu button:hover { background: var(--sunken); text-decoration: none; }
.mobile-nav-toggle { display: none; }

.content { padding: 36px 32px 72px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px; max-width: 1240px; width: 100%; }

@media (max-width: 960px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(300px, 86vw); z-index: 50; transform: translateX(-102%); transition: transform 0.2s ease; box-shadow: var(--shadow); background: var(--surface); }
  .shell[data-nav="open"] .sidebar { transform: none; }
  .shell[data-nav="open"]::after { content: ""; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.35); z-index: 40; }
  .mobile-nav-toggle { display: inline-grid; }
  .topbar { padding: 10px 16px 10px 58px; }
  .topbar .spacer { display: none; }
  .content { padding: 24px 16px 56px; }
  .user-menu .user-name { display: none; }
  h1 { font-size: 28px; }
}

/* ---------- Page structure ---------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; padding-bottom: 4px; }
.page-head .lead { color: var(--muted); margin-top: 8px; max-width: 680px; font-size: 15px; }
.crumbs { display: flex; gap: 6px; align-items: center; font-size: 13px; color: var(--muted); margin-bottom: 8px; flex-wrap: wrap; }
.crumbs a { color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.card-pad { padding: 20px 22px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 18px 22px 14px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.card-head p { color: var(--muted); font-size: 13px; margin-top: 2px; }
.card-body { padding: 18px 22px; }
.card-foot { padding: 14px 22px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

.grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px; align-content: start; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); }
@media (max-width: 1100px) { .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-main { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 720px) { .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); } }

/* KPIs: one card split by hairlines, serif figures. */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; }
.kpis > .card { border: 0; border-radius: 0; box-shadow: none; border-right: 1px solid var(--line); }
.kpis > .card:last-child { border-right: 0; }
@media (max-width: 1100px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } .kpis > .card:nth-child(2n) { border-right: 0; } .kpis > .card:nth-child(-n + 2) { border-bottom: 1px solid var(--line); } }
.kpi { padding: 18px 22px 20px; }
.kpi .label { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.kpi .value { font: 400 34px/1.1 var(--serif); letter-spacing: -0.01em; margin-top: 8px; font-variant-numeric: tabular-nums lining-nums; }
.kpi .hint { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.kpi.alert .value { color: var(--danger); }
@media (max-width: 480px) { .kpi { padding: 14px 16px; } .kpi .value { font-size: 26px; } .kpi .hint { font-size: 12px; } .list > li { padding: 12px 16px; flex-wrap: wrap; } .card-head, .card-body { padding-left: 16px; padding-right: 16px; } }
@media (max-width: 340px) { .kpis { grid-template-columns: minmax(0, 1fr); } .kpis > .card { border-right: 0; border-bottom: 1px solid var(--line); } }

/* ---------- Help ---------- */
.help { position: relative; display: inline-grid; place-items: center; color: var(--faint); cursor: help; }
.help .tip { position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%); width: 240px; padding: 9px 11px; border-radius: 8px; background: var(--ink); color: var(--ink-text); font-size: 12.5px; font-weight: 400; line-height: 1.45; text-transform: none; letter-spacing: 0; display: none; pointer-events: none; z-index: 60; }
.help:hover .tip, .help:focus .tip, .help:focus-within .tip { display: block; }
@media (max-width: 720px) { .help .tip { left: auto; right: -8px; transform: none; width: min(240px, 70vw); } }
.callout { display: flex; gap: 10px; padding: 12px 14px; border-radius: var(--radius); background: var(--sunken); color: var(--text-2); font-size: 13.5px; }
.callout .icon-sm { margin-top: 2px; color: var(--muted); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; position: relative; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
thead th { font-size: 11.5px; font-weight: 500; letter-spacing: 0.06em; text-transform: uppercase; color: var(--faint); white-space: nowrap; background: transparent; }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
th.r, td.r { text-align: right; font-variant-numeric: tabular-nums; }
td .sub { display: block; font-size: 12.5px; color: var(--muted); }
td.strong, .strong { font-weight: 600; color: var(--text); }
.row-link { color: var(--text); font-weight: 600; }

/* ---------- Status: a dot and a word ---------- */
.badge { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 500; white-space: nowrap; color: var(--text-2); }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--idle); }
.badge.paid::before, .badge.done::before { background: var(--ok); }
.badge.open::before, .badge.review::before { background: var(--warn); }
.badge.overdue { color: var(--danger); }
.badge.overdue::before { background: var(--danger); }
.badge.in_progress::before { background: var(--accent); }
.badge.void { color: var(--faint); }

/* ---------- Forms & buttons ---------- */
label { display: grid; gap: 6px; font-size: 13px; font-weight: 500; color: var(--text-2); align-content: start; }
label .hint { font-weight: 400; color: var(--muted); font-size: 12.5px; }
input, select, textarea { font: inherit; padding: 9px 12px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); color: var(--text); min-width: 0; width: 100%; }
input[type="file"] { padding: 6px; background: var(--surface-2); }
textarea { min-height: 88px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.form { display: grid; gap: 14px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; font: inherit; font-weight: 500; font-size: 14px; padding: 9px 18px; border-radius: 999px; border: 1px solid var(--ink); background: var(--ink); color: var(--ink-text); cursor: pointer; white-space: nowrap; line-height: 1.3; transition: opacity 0.15s; }
.btn:hover { opacity: 0.86; text-decoration: none; }
.btn.secondary { background: var(--surface); color: var(--text); border-color: var(--line-strong); }
.btn.secondary:hover { opacity: 1; background: var(--sunken); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text); padding-left: 8px; padding-right: 8px; }
.btn.ghost:hover { opacity: 1; background: var(--sunken); }
.btn.link, button.link { background: none; border: 0; padding: 0; color: var(--accent); font-weight: 500; }
.btn.sm { font-size: 13px; padding: 6px 11px; }
.btn.lg { font-size: 15px; padding: 12px 20px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- Filters ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.toolbar form { display: flex; gap: 8px; flex: 1; min-width: 220px; max-width: 420px; }
.segmented { display: inline-flex; gap: 2px; flex-wrap: wrap; }
.segmented a { padding: 6px 13px; border-radius: 999px; font-size: 13px; font-weight: 500; color: var(--muted); }
.segmented a:hover { text-decoration: none; color: var(--text); background: var(--sunken); }
.segmented a[aria-current="true"] { background: var(--ink); color: var(--ink-text); }
.segmented .n { opacity: 0.7; font-weight: 400; margin-left: 5px; }

/* ---------- Feedback ---------- */
.flash { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius); font-size: 14px; border: 1px solid; }
.flash.ok { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 25%, transparent); }
.flash.err { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.flash .icon-sm { margin-top: 2px; }

.empty { display: grid; justify-items: center; text-align: center; gap: 8px; padding: 40px 20px; color: var(--muted); }
.empty .glyph { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; border: 1px solid var(--line); color: var(--muted); }
.empty h3 { color: var(--text); font: 400 20px/1.2 var(--serif); }
.empty p { max-width: 420px; font-size: 13.5px; }

.skeleton { background: linear-gradient(90deg, var(--sunken), var(--surface-2), var(--sunken)); background-size: 200% 100%; animation: shimmer 1.2s infinite linear; border-radius: 8px; }
@keyframes shimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } * { transition: none !important; } }

/* ---------- Lists, bars, timeline ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { display: flex; gap: 12px; align-items: center; padding: 13px 22px; border-bottom: 1px solid var(--line); }
.list > li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .title { font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
@media (max-width: 480px) { .list .title { white-space: normal; } }
.file-icon { width: 34px; height: 40px; border-radius: 4px 10px 4px 4px; display: grid; place-items: end center; padding-bottom: 6px; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); flex: none; font-size: 9.5px; font-weight: 600; letter-spacing: 0.04em; }

.timeline { list-style: none; margin: 0; padding: 6px 0; }
.timeline li { display: grid; grid-template-columns: 28px 1fr; gap: 12px; padding: 10px 22px; position: relative; }
.timeline .node { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; border: 1px solid var(--line); background: var(--surface); color: var(--muted); }
.timeline .node.paid { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 35%, transparent); }
.timeline .node.file { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
.timeline .node.warn { color: var(--warn); }
.timeline li.unread { background: color-mix(in srgb, var(--accent-soft) 60%, transparent); }

.bars { display: grid; gap: 14px; }
.bar-row { display: grid; grid-template-columns: 120px 1fr 100px; gap: 14px; align-items: center; font-size: 13px; }
.bar-track { height: 8px; border-radius: 999px; background: var(--sunken); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; background: var(--ink); }
.bar-fill.warn { background: var(--warn); } .bar-fill.danger { background: var(--danger); }
.stack-bar { display: flex; height: 10px; border-radius: 999px; overflow: hidden; background: var(--sunken); gap: 2px; }
.stack-bar span { height: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12.5px; color: var(--text-2); margin-top: 12px; }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }

.progress { display: flex; gap: 4px; }
.progress span { flex: 1; height: 4px; border-radius: 999px; background: var(--sunken); }
.progress span.on { background: var(--ink); }

.dl { display: grid; grid-template-columns: max-content 1fr; gap: 9px 20px; font-size: 13.5px; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; color: var(--text); font-weight: 500; }

/* ---------- Dialog ---------- */
dialog { border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 0; width: min(460px, calc(100vw - 32px)); background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(20, 20, 19, 0.4); backdrop-filter: blur(2px); }
dialog .dlg-body { padding: 22px 24px; display: grid; gap: 8px; }
dialog .dlg-body h2 { font: 400 22px/1.2 var(--serif); }
dialog .dlg-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 24px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

/* ---------- Invoice document ---------- */
.doc { padding: 44px 48px; display: grid; gap: 32px; }
.doc-head { display: flex; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
.doc-brand { font: 400 24px/1.1 var(--serif); }
.doc-title { text-align: right; }
.doc-title .big { font: 400 36px/1.05 var(--serif); letter-spacing: -0.01em; }
.doc-total { display: flex; justify-content: flex-end; }
.doc-total table { width: auto; min-width: 300px; }
.doc-total td { border: 0; padding: 6px 0 6px 24px; }
.doc-total tr.grand td { font: 400 24px/1.2 var(--serif); border-top: 1px solid var(--line-strong); padding-top: 14px; }
@media (max-width: 640px) { .doc { padding: 26px 20px; } .doc-title { text-align: left; } }
@media print {
  .sidebar, .topbar, .no-print, .mobile-nav-toggle { display: none !important; }
  .shell { display: block; }
  body { background: #fff; color: #000; }
  .card { box-shadow: none; border: 0; }
  .content { padding: 0; }
}

/* ---------- Auth ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; }
.auth-side { background: #111111; color: #d9d6cf; padding: 48px 56px; display: flex; flex-direction: column; justify-content: space-between; gap: 32px; position: relative; overflow: hidden; }
.auth-side::after { content: ""; position: absolute; right: -120px; bottom: -160px; width: 520px; height: 620px; border: 1px solid rgba(246, 244, 239, 0.12); border-radius: 260px 260px 0 0; }
.auth-side::before { content: ""; position: absolute; right: -40px; bottom: -160px; width: 360px; height: 480px; border: 1px solid rgba(246, 244, 239, 0.08); border-radius: 180px 180px 0 0; }
.auth-side h2 { color: #f6f4ef; font: 400 40px/1.1 var(--serif); letter-spacing: -0.01em; max-width: 460px; }
.auth-side ul { padding: 0; margin: 0; list-style: none; display: grid; gap: 16px; max-width: 420px; position: relative; z-index: 1; }
.auth-side li { display: flex; gap: 12px; }
.auth-main { display: grid; place-items: center; padding: 32px 16px; }
.auth-card { width: min(400px, 100%); display: grid; gap: 20px; }
.auth-card h1 { font-size: 36px; }
.demo-accounts { display: grid; gap: 8px; }
@media (max-width: 860px) { .auth { grid-template-columns: 1fr; } .auth-side { display: none; } }

/* ---------- Marketing ---------- */
mark, .hl { background: linear-gradient(transparent 55%, var(--mark) 55%, var(--mark) 92%, transparent 92%); color: inherit; padding: 0 2px; }
.mk-nav { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid transparent; }
.mk-nav .inner, .mk-wrap { max-width: 1180px; margin: 0 auto; padding: 0 24px; }
.mk-nav .inner { display: flex; align-items: center; gap: 28px; height: 68px; }
.mk-nav .links { display: flex; gap: 26px; font-size: 14px; }
.mk-nav .links a { color: var(--text-2); }
@media (max-width: 760px) { .mk-nav .links { display: none; } }
@media (max-width: 560px) { .mk-nav .btn.ghost { display: none; } .mk-nav .inner { gap: 12px; } }
.logo { display: inline-flex; align-items: center; gap: 9px; font: 400 23px/1 var(--serif); color: var(--text); letter-spacing: -0.01em; }
.logo:hover { text-decoration: none; }
.mk-hero { padding: 88px 0 40px; text-align: center; display: grid; justify-items: center; }
.eyebrow { display: inline-flex; gap: 8px; align-items: center; font-size: 13px; font-weight: 500; color: var(--muted); padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface); }
.eyebrow .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--mark); box-shadow: 0 0 0 3px var(--mark-soft); }
.mk-hero h1 { font: 400 clamp(44px, 7vw, 88px)/1 var(--serif); letter-spacing: -0.025em; margin: 26px 0 22px; max-width: 980px; }
.mk-hero h1 em { font-style: italic; color: var(--muted); }
.mk-hero .sub { font-size: 18.5px; line-height: 1.55; color: var(--text-2); max-width: 620px; }
.mk-hero .cta { display: flex; gap: 10px; margin-top: 30px; flex-wrap: wrap; justify-content: center; }
.mk-hero .fine { margin-top: 14px; font-size: 13px; color: var(--muted); }
.stage { margin: 8px auto 0; max-width: 1180px; padding: 0 24px; }
.stage-frame { border-radius: 18px; background: radial-gradient(120% 90% at 50% 0%, #fff1b0 0%, #fbf3d4 35%, #fbfaf7 75%); padding: 28px 28px 0; border: 1px solid var(--line); overflow: hidden; }
:root[data-theme="dark"] .stage-frame { background: radial-gradient(120% 90% at 50% 0%, #4a4430 0%, #2a2a28 75%); }
:root[data-theme="dark"] .auth-side, :root[data-theme="dark"] .mk-cta, :root[data-theme="dark"] pre.code { background: #222220; }
.preview { border-radius: 12px 12px 0 0; border: 1px solid var(--line); border-bottom: 0; background: var(--bg); box-shadow: var(--shadow); overflow: hidden; text-align: left; }
.preview-bar { display: flex; gap: 6px; padding: 11px 14px; border-bottom: 1px solid var(--line); background: var(--surface); }
.preview-bar i { width: 9px; height: 9px; border-radius: 50%; background: var(--line-strong); }
.preview-app { display: grid; grid-template-columns: 200px minmax(0, 1fr); min-height: 420px; }
.preview-app .side { border-right: 1px solid var(--line); padding: 16px 12px; display: grid; gap: 2px; align-content: start; font-size: 13px; }
.preview-app .side > span { padding: 6px 10px; border-radius: 7px; color: var(--text-2); }
.preview-app .side > span.on { background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); color: var(--text); font-weight: 500; }
.preview-app .body { padding: 22px 26px; display: grid; gap: 16px; align-content: start; }
@media (max-width: 760px) { .preview-app { grid-template-columns: 1fr; } .preview-app .side { display: none; } .stage-frame { padding: 14px 14px 0; } }
.mk-section { padding: 88px 0; }
.mk-section.alt { background: var(--surface); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.mk-section .intro { max-width: 680px; margin-bottom: 40px; }
.kicker { font-size: 12.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); margin-bottom: 14px; display: block; }
.mk-section h2 { font: 400 clamp(32px, 4vw, 48px)/1.08 var(--serif); letter-spacing: -0.02em; }
.mk-section .intro p { font-size: 17px; color: var(--text-2); margin-top: 14px; }
.feature { padding: 26px; display: grid; gap: 10px; align-content: start; }
.feature .fi { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; border: 1px solid var(--line); color: var(--text); margin-bottom: 8px; }
.feature h3 { font: 400 22px/1.2 var(--serif); }
.feature p { color: var(--text-2); font-size: 14.5px; }
.features { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.features > .feature { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 32px 30px; }
@media (max-width: 900px) { .features { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 600px) { .features { grid-template-columns: minmax(0, 1fr); } }
.steps { counter-reset: s; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; border-top: 1px solid var(--ink); }
.steps li { list-style: none; counter-increment: s; padding: 22px 24px 0 0; }
.steps li::before { content: "0" counter(s); display: block; font: 400 15px/1 var(--serif); color: var(--muted); margin-bottom: 16px; }
.steps h3 { font: 400 23px/1.2 var(--serif); }
.steps p { color: var(--text-2); font-size: 14.5px; margin-top: 8px; }
@media (max-width: 900px) { .steps { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 28px; } }
@media (max-width: 560px) { .steps { grid-template-columns: minmax(0, 1fr); } }
.compare { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; }
.compare ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 12px; }
.compare li { display: flex; gap: 10px; font-size: 15px; }
@media (max-width: 760px) { .compare { grid-template-columns: minmax(0, 1fr); } }
.quote { font: italic 400 clamp(26px, 3.2vw, 38px)/1.25 var(--serif); letter-spacing: -0.01em; max-width: 880px; }
.faq details { border-bottom: 1px solid var(--line); padding: 20px 0; }
.faq summary { cursor: pointer; font: 400 21px/1.3 var(--serif); list-style: none; display: flex; justify-content: space-between; gap: 16px; }
.faq summary::after { content: "+"; font-family: var(--font); color: var(--muted); }
.faq details[open] summary::after { content: "–"; }
.faq summary::-webkit-details-marker { display: none; }
.faq details p { color: var(--text-2); margin-top: 10px; max-width: 760px; font-size: 15px; }
.mk-cta { margin: 0 0 88px; padding: 64px 48px; border-radius: 24px; background: #111111; color: #d9d6cf; display: grid; justify-items: center; text-align: center; gap: 20px; position: relative; overflow: hidden; }
.mk-cta h2 { color: #f6f4ef; font: 400 clamp(32px, 4vw, 52px)/1.05 var(--serif); letter-spacing: -0.02em; }
.mk-cta .btn { background: var(--mark); color: #111; border-color: var(--mark); }
.mk-foot { border-top: 1px solid var(--line); padding: 28px 0 40px; color: var(--muted); font-size: 13px; }
.mk-foot .inner { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }

/* ---------- Cited: chat, footnotes, charts ---------- */
.fn { display: inline-grid; place-items: center; min-width: 17px; height: 17px; padding: 0 4px; margin: 0 1px; border-radius: 4px; background: var(--mark); color: #111; font: 600 10.5px/1 var(--font); vertical-align: super; }
.chat-demo { display: grid; gap: 14px; }
.bubble { max-width: 88%; padding: 12px 15px; border-radius: 16px; font-size: 14.5px; line-height: 1.5; }
.bubble.user { justify-self: end; background: var(--ink); color: var(--ink-text); border-bottom-right-radius: 5px; }
.bubble.bot { justify-self: start; background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 5px; }
.sources { display: grid; gap: 6px; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line-strong); }
.source { display: grid; grid-template-columns: auto 1fr; gap: 8px; font-size: 12.5px; color: var(--muted); align-items: start; }
.source .fn { vertical-align: 0; margin-top: 1px; }
.source b { color: var(--text); font-weight: 600; }
.source q { display: block; font: italic 13.5px/1.45 var(--serif); color: var(--text-2); quotes: "“" "”"; }
.bubble .tk { display: flex; gap: 6px; align-items: center; margin-top: 10px; font-size: 12.5px; color: var(--warn); }
.transcript { display: grid; gap: 14px; padding: 20px 22px; background: var(--surface-2); }
.flow { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0; border-top: 1px solid var(--ink); }
.flow li { list-style: none; padding: 22px 20px 0 0; }
.flow li .n { font: 400 15px/1 var(--serif); color: var(--muted); }
.flow li h3 { font: 400 22px/1.2 var(--serif); margin: 12px 0 8px; }
.flow li p { font-size: 14px; color: var(--text-2); }
@media (max-width: 1000px) { .flow { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 24px; } }
@media (max-width: 560px) { .flow { grid-template-columns: minmax(0, 1fr); } }
.chart { display: flex; align-items: flex-end; gap: 3px; height: 160px; padding-top: 8px; }
.chart .col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; gap: 1px; min-width: 3px; height: 100%; }
.chart .col span { display: block; border-radius: 3px 3px 0 0; }
.chart .q { background: var(--ink); }
.chart .h { background: var(--mark); border-radius: 0 !important; }
.axis { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--muted); margin-top: 8px; }
pre.code { margin: 0; padding: 16px 18px; border-radius: var(--radius); background: #111; color: #f3f1ec; font: 13px/1.6 ui-monospace, "SF Mono", Menlo, monospace; overflow-x: auto; white-space: pre; }
code { font: 0.9em ui-monospace, "SF Mono", Menlo, monospace; background: var(--sunken); padding: 1px 5px; border-radius: 4px; }
pre.code code { background: none; padding: 0; }
.section-text { white-space: pre-wrap; color: var(--text-2); font: 17px/1.65 var(--serif); }
.hit { border-left: 3px solid var(--mark); padding-left: 12px; }
.score { font: 400 15px/1 var(--serif); color: var(--muted); }
.swatch { display: inline-block; width: 14px; height: 14px; border-radius: 50%; vertical-align: -2px; margin-right: 6px; border: 1px solid var(--line); }
.big-figure { font: 400 64px/1 var(--serif); letter-spacing: -0.02em; }
.big-figure mark { padding: 0 6px; }

/* ---------- Cited layout: top tabs, centred document column (no sidebar) ---------- */
.cshell { min-height: 100vh; display: flex; flex-direction: column; }
.tophead { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.tophead .bar { max-width: 1120px; margin: 0 auto; padding: 0 24px; height: 60px; display: flex; align-items: center; gap: 18px; }
.tophead .search { max-width: 280px; }
.tabs { max-width: 1120px; margin: 0 auto; padding: 0 24px; display: flex; gap: 26px; overflow-x: auto; scrollbar-width: none; }
.tabs a { position: relative; display: inline-flex; align-items: center; gap: 7px; padding: 12px 0 13px; font-size: 14px; font-weight: 500; color: var(--muted); text-decoration: none; white-space: nowrap; }
.tabs a:hover { color: var(--text); }
.tabs a[aria-current="page"] { color: var(--text); }
.tabs a[aria-current="page"]::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 3px; background: var(--mark); border-radius: 3px 3px 0 0; }
.tabs .count { font: 600 11px/1 var(--font); padding: 3px 6px; border-radius: 999px; background: var(--mark); color: #111; }
.cshell .content { max-width: 1120px; margin: 0 auto; padding: 40px 24px 80px; }
@media (max-width: 720px) { .tophead .search { display: none; } .tabs { gap: 20px; padding: 0 16px; } .tophead .bar { padding: 0 16px; } .cshell .content { padding: 28px 16px 64px; } }
/* Editorial cards: sharp corners, ruled headings, no shadow. */
.cshell .card { border-radius: 4px; box-shadow: none; }
.cshell .card-head h2 { font: 500 21px/1.2 var(--serif); letter-spacing: -0.01em; }
.cshell .card-head { border-bottom-style: dashed; }
/* Ledger KPIs: big serif numbers on a rule, no boxes. */
.cshell .kpis { background: transparent; border: 0; border-top: 2px solid var(--ink); border-radius: 0; }
.cshell .kpis > .card { background: transparent; border-right: 1px solid var(--line); }
.cshell .kpis > .kpi { padding: 16px 22px 18px; }
.cshell .kpis > .kpi:first-child { padding-left: 0; }
.cshell .kpi .value { font-size: 46px; }
.cshell .page-head h1 { font-size: 44px; }

/* ---------- Theme toggle ---------- */
.theme-toggle { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--text-2); cursor: pointer; }
.theme-toggle:hover { color: var(--text); background: var(--sunken); }
.theme-toggle .sun { display: none; }
:root[data-theme="dark"] .theme-toggle .moon { display: none; } :root[data-theme="dark"] .theme-toggle .sun { display: block; }

/* ---------- Editorial split hero ---------- */
.mk-hero.split { text-align: left; grid-template-columns: minmax(0, 1fr) minmax(0, 0.95fr); justify-items: stretch; gap: 56px; align-items: center; padding: 72px 0 80px; }
.mk-hero.split .cta { justify-content: flex-start; }
.mk-hero.split h1 { font-size: clamp(42px, 5.6vw, 76px); margin-top: 22px; }
@media (max-width: 960px) { .mk-hero.split { grid-template-columns: minmax(0, 1fr); padding-top: 48px; } }
.ruled { background-image: repeating-linear-gradient(transparent 0 31px, var(--line) 31px 32px); border: 1px solid var(--line); border-radius: 6px; background-color: var(--surface); padding: 22px; box-shadow: var(--shadow); }

.tophead .search { margin: 0; align-self: center; }
.tophead .search input { height: 38px; }

/* White page: cards defined by rules, not tint. */
:root:not([data-theme="dark"]) .card { border-color: #e4e2dc; }
:root:not([data-theme="dark"]) .tophead { background: rgba(255,255,255,.92); }
:root:not([data-theme="dark"]) .ruled { background-color: #fffdf6; }

/* ---------- Cited background: white paper with faint ruled lines and a margin line ---------- */
body { background-color: var(--bg); background-image:
  linear-gradient(90deg, transparent 0 calc(50% - 640px), color-mix(in srgb, var(--mark) 55%, transparent) calc(50% - 640px) calc(50% - 639px), transparent calc(50% - 639px)),
  repeating-linear-gradient(to bottom, transparent 0 35px, color-mix(in srgb, var(--line) 70%, transparent) 35px 36px); }
.mk-section.alt, .tophead, .mk-nav { background-color: var(--bg); }
@media (max-width: 1320px) { body { background-image: repeating-linear-gradient(to bottom, transparent 0 35px, color-mix(in srgb, var(--line) 70%, transparent) 35px 36px); } }

/* ---------- Hand-drawn illustrations ---------- */
.intro-art { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.8fr); gap: 40px; align-items: center; margin-bottom: 40px; }
.illo { margin: 0; color: var(--text); max-width: 340px; justify-self: end; width: 100%; }
.illo svg { width: 100%; height: auto; display: block; }
@media (max-width: 760px) { .intro-art { grid-template-columns: minmax(0, 1fr); } .illo { justify-self: start; max-width: 260px; } }
