/* Athena tokens (subset of athenaTheme.css) plus the few components the
   simplified Home needs. Identical in both spikes. Phone-first at 390px. */

:root {
	--ac-black-rock: #04062c;
	--ac-ink-900: #04062c;
	--ac-ink-600: #2c3475;
	--ac-ink-500: #545d99;
	--ac-ink-450: #666d91;
	--ac-ink-420: #7f86ae;
	--ac-ink-200: #c9cee0;
	--ac-ink-100: #dfe4ea;
	--ac-ink-50: #f1f2f6;
	--ac-ink-25: #f8f9fb;
	--ac-white: #ffffff;
	--ac-mystic: #dfe4ea;
	--ac-royal-700: #2a36c9;
	--ac-royal-600: #3847ef;
	--ac-royal-500: #5256e3;
	--ac-royal-50: #f1f3fe;
	--ac-green-500: #99e9a5;
	--ac-green-50: #effdf2;
	--ac-amber-700: #8a5a13;
	--ac-amber-500: #f0a73c;
	--ac-amber-100: #fde7c5;
	--ac-red-800: #a02a30;
	--ac-red-100: #fbdcdd;

	--bg: var(--ac-ink-25);
	--surface: var(--ac-white);
	--surface-2: var(--ac-ink-25);
	--surface-3: var(--ac-ink-50);
	--border: var(--ac-mystic);
	--border-soft: #eef0f4;
	--text: var(--ac-ink-900);
	--text-dim: var(--ac-ink-500);
	--text-mute: var(--ac-ink-450);
	--accent: var(--ac-royal-600);
	--accent-hi: var(--ac-royal-700);
	--accent-soft: var(--ac-royal-50);
	--accent-text: var(--ac-royal-700);
	--on-accent: var(--ac-white);
	--green: #1f7a3a;
	--green-soft: var(--ac-green-50);
	--amber: var(--ac-amber-700);
	--amber-soft: var(--ac-amber-100);
	--red: var(--ac-red-800);
	--red-soft: var(--ac-red-100);
	--focus-ring: var(--ac-royal-700);

	--sans: 'Figtree', 'Helvetica Neue', Arial, sans-serif;
	--mono: 'JetBrains Mono', 'SFMono-Regular', ui-monospace, Menlo, Consolas, monospace;

	--type-size-caption: 12px; --type-lh-caption: 16px;
	--type-size-body: 14px;    --type-lh-body: 20px;
	--type-size-title: 17px;   --type-lh-title: 24px;
	--type-size-heading: 22px; --type-lh-heading: 28px;
	--type-size-display: 28px; --type-lh-display: 32px;
	--type-weight-text: 500; --type-weight-strong: 700; --type-weight-display: 800; --type-weight-figure: 600;
	--type-track-caps: .06em; --type-track-heading: -.01em; --type-track-display: -.02em;

	--space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px; --space-5: 20px; --space-6: 24px; --space-8: 32px;
	--page-gutter: 16px;
	--radius-xs: 4px; --radius-sm: 6px; --radius: 14px; --radius-md: 10px; --radius-pill: 999px; --radius-round: 50%;
	--shadow-sm: 0 1px 3px rgba(4, 6, 44, .06), 0 1px 2px rgba(4, 6, 44, .04);
	--shadow-focus: 0 0 0 3px color-mix(in srgb, var(--focus-ring) 28%, transparent);
	--control-h: 32px; --control-h-lg: 40px; --touch: 44px;
	--tabbar-h: 64px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
	margin: 0;
	background: var(--bg);
	color: var(--text);
	font: var(--type-weight-text) var(--type-size-body) / var(--type-lh-body) var(--sans);
	padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
}
a { color: var(--accent-text); }
button { font: inherit; }
:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
.num { font-family: var(--mono); font-weight: var(--type-weight-figure); font-variant-numeric: tabular-nums; }
.caption { font-size: var(--type-size-caption); line-height: var(--type-lh-caption); color: var(--text-mute); }
.caps { font-size: var(--type-size-caption); line-height: var(--type-lh-caption); letter-spacing: var(--type-track-caps); text-transform: uppercase; font-weight: var(--type-weight-strong); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Header */
.hdr { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--page-gutter); background: var(--surface); border-bottom: 1px solid var(--border-soft); position: sticky; top: 0; z-index: 10; }
.mark { width: 32px; height: 32px; border-radius: var(--radius-sm); background: var(--ac-black-rock); color: var(--ac-white); display: grid; place-items: center; font-weight: var(--type-weight-display); flex: none; }
.hdr-text { flex: 1; min-width: 0; }
.hdr-name { font-weight: var(--type-weight-strong); line-height: var(--type-lh-body); }
.entity { display: inline-flex; align-items: center; gap: var(--space-1); background: none; border: 0; padding: 0; color: var(--text-dim); font-size: var(--type-size-caption); line-height: var(--type-lh-caption); min-height: 24px; }
.avatar { width: 36px; height: 36px; border-radius: var(--radius-round); background: var(--accent-soft); color: var(--accent-text); display: grid; place-items: center; font-weight: var(--type-weight-strong); font-size: var(--type-size-caption); border: 0; flex: none; }

/* Page */
main { padding: var(--space-5) var(--page-gutter) var(--space-6); display: grid; gap: var(--space-6); }
h1 { margin: var(--space-1) 0 0; font-size: var(--type-size-heading); line-height: var(--type-lh-heading); letter-spacing: var(--type-track-heading); font-weight: var(--type-weight-display); }
h2 { margin: 0; font-size: var(--type-size-title); line-height: var(--type-lh-title); font-weight: var(--type-weight-strong); display: flex; align-items: center; gap: var(--space-2); }
section { display: grid; gap: var(--space-3); }
.sec-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); }
.sec-head a { font-size: var(--type-size-body); font-weight: var(--type-weight-strong); text-decoration: none; min-height: var(--touch); display: inline-flex; align-items: center; }

/* Cards and pills */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: var(--space-4); display: grid; gap: var(--space-3); }
.card.attention { border-color: var(--ac-amber-500); }
.pill { display: inline-flex; align-items: center; height: 20px; padding: 0 var(--space-2); border-radius: var(--radius-pill); font-size: var(--type-size-caption); font-weight: var(--type-weight-strong); line-height: 1; }
.pill.count { background: var(--red-soft); color: var(--red); }
.pill.due { background: var(--amber-soft); color: var(--amber); }
.pill.due.urgent { background: var(--red-soft); color: var(--red); }
.pill.new { background: var(--green-soft); color: var(--green); }
.pill.ok { background: var(--green-soft); color: var(--green); }

/* Obligation card */
.ob-top { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); }
.ob-kind { color: var(--amber); }
.ob-title { font-size: var(--type-size-title); line-height: var(--type-lh-title); font-weight: var(--type-weight-strong); margin: 0; }
.ob-amount { font-size: var(--type-size-display); line-height: var(--type-lh-display); letter-spacing: var(--type-track-display); }
.bar { height: 6px; border-radius: var(--radius-pill); background: var(--surface-3); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--ac-amber-500); border-radius: inherit; }
.bar.royal > i { background: var(--ac-royal-600); }
.bar.perano > i { background: var(--ac-royal-500); }
.bar.green > i { background: var(--ac-green-500); }
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-2); }
.steps li { display: flex; align-items: center; gap: var(--space-2); color: var(--text-dim); }
.steps li.done { color: var(--green); }
.steps li.next { color: var(--text); font-weight: var(--type-weight-strong); }
.step-dot { width: 20px; height: 20px; border-radius: var(--radius-round); border: 2px solid var(--ac-ink-200); display: grid; place-items: center; font-size: 11px; flex: none; }
.done .step-dot { background: var(--green); border-color: var(--green); color: var(--ac-white); }
.next .step-dot { border-color: var(--accent); color: var(--accent-text); }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-2); }
.actions form { display: contents; }
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: var(--control-h-lg); padding: 0 var(--space-4); border-radius: var(--radius-md); font-weight: var(--type-weight-strong); text-decoration: none; border: 1px solid transparent; cursor: pointer; }
.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-hi); }
.btn.secondary { background: var(--surface); color: var(--accent-text); border-color: var(--border); }
.btn[aria-busy='true'] { opacity: .6; }

/* Portfolio */
.nav-figure { font-size: var(--type-size-display); line-height: var(--type-lh-display); letter-spacing: var(--type-track-display); }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-2); }
.stat { background: var(--surface-2); border-radius: var(--radius-md); padding: var(--space-2) var(--space-3); display: grid; gap: 2px; }
.stat .num { font-size: var(--type-size-title); line-height: var(--type-lh-title); }
.seg { display: inline-flex; background: var(--surface-3); border-radius: var(--radius-pill); padding: 2px; }
.seg a, .seg button { min-height: 36px; padding: 0 var(--space-3); border-radius: var(--radius-pill); border: 0; background: none; color: var(--text-dim); font-weight: var(--type-weight-strong); text-decoration: none; display: inline-flex; align-items: center; }
.seg [aria-pressed='true'], .seg [aria-current='true'] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.rows { display: grid; gap: var(--space-3); }
.row { display: grid; grid-template-columns: 1fr auto; gap: 2px var(--space-3); align-items: baseline; }
.row .name { font-weight: var(--type-weight-strong); }
.row .bar { grid-column: 1 / -1; margin-top: var(--space-1); }
.row .caption { grid-column: 1; }
.row .num { text-align: right; }
.row .share { grid-row: 2; grid-column: 2; text-align: right; }

/* Documents */
.docs { list-style: none; margin: 0; padding: 0; display: grid; }
.docs li { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) 0; border-top: 1px solid var(--border-soft); min-height: var(--touch); }
.docs li:first-child { border-top: 0; padding-top: 0; }
.doc-icon { width: 36px; height: 36px; border-radius: var(--radius-sm); background: var(--surface-3); color: var(--text-dim); display: grid; place-items: center; font-size: 10px; font-weight: var(--type-weight-strong); flex: none; }
.doc-text { flex: 1; min-width: 0; }
.doc-name { font-weight: var(--type-weight-strong); text-decoration: none; color: var(--text); display: block; }

/* Ask button and drawer (a bottom sheet on the phone) */
.ask-btn { display: inline-flex; align-items: center; gap: var(--space-1); min-height: 36px; padding: 0 var(--space-3); border-radius: var(--radius-pill); background: var(--ac-black-rock); color: var(--ac-white); font-weight: var(--type-weight-strong); font-size: var(--type-size-caption); text-decoration: none; border: 0; flex: none; }
.sheet { position: fixed; inset: 0; margin: auto 0 0; width: 100%; max-width: 100%; max-height: 88vh; border: 0; padding: 0; border-radius: var(--radius) var(--radius) 0 0; background: var(--surface); color: var(--text); display: flex; flex-direction: column; }
.sheet:not([open]) { display: none; }
.sheet::backdrop { background: rgba(4, 6, 44, .5); }
.sheet-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-2); padding: var(--space-4) var(--space-4) var(--space-2); }
.sheet-head p { margin: 0; }
.icon-btn { width: var(--touch); height: var(--touch); border-radius: var(--radius-round); border: 0; background: var(--surface-3); color: var(--text); font-size: 22px; line-height: 1; flex: none; }
.thread { flex: 1; overflow: auto; padding: var(--space-2) var(--space-4); display: grid; gap: var(--space-2); align-content: start; }
.thread:empty { display: none; }
.bubble { padding: var(--space-2) var(--space-3); border-radius: 12px; max-width: 92%; }
.bubble.user { justify-self: end; background: var(--accent); color: var(--on-accent); }
.bubble.ai { justify-self: start; width: 92%; background: var(--surface-2); display: grid; gap: var(--space-1); }
.bubble.ai .answer { margin: 0; }
.sources { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--space-1); }
.sources:empty { display: none; }
.sources a { display: inline-block; font-size: var(--type-size-caption); line-height: var(--type-lh-caption); padding: 2px var(--space-2); border-radius: var(--radius-pill); background: var(--surface); border: 1px solid var(--border); text-decoration: none; }
.chips { display: flex; flex-wrap: wrap; gap: var(--space-2); padding: var(--space-2) var(--space-4); }
.chip { min-height: 36px; padding: 0 var(--space-3); border-radius: var(--radius-pill); border: 1px solid var(--border); background: var(--surface); color: var(--accent-text); font-weight: var(--type-weight-strong); text-decoration: none; display: inline-flex; align-items: center; cursor: pointer; }
.ask-form { display: flex; gap: var(--space-2); padding: var(--space-2) var(--space-4); }
.ask-form input { flex: 1; min-width: 0; min-height: var(--touch); border: 1px solid var(--border-input); border-radius: var(--radius-md); padding: 0 var(--space-3); font: inherit; font-size: 16px; background: var(--surface); color: var(--text); }
.ask-ir { display: block; text-align: center; padding: var(--space-2) var(--space-4) calc(var(--space-4) + env(safe-area-inset-bottom)); font-weight: var(--type-weight-strong); text-decoration: none; }
.ask-page { display: grid; gap: var(--space-3); }

/* Tab bar */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: var(--surface); border-top: 1px solid var(--border-soft); display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; z-index: 10; }
.tab { display: grid; justify-items: center; align-content: center; gap: 2px; text-decoration: none; color: var(--text-dim); font-size: var(--type-size-caption); line-height: var(--type-lh-caption); font-weight: var(--type-weight-strong); position: relative; }
.tab[aria-current='page'] { color: var(--accent-text); }
.tab svg { width: 24px; height: 24px; }
.tab .badge { position: absolute; top: 8px; left: calc(50% + 6px); min-width: 16px; height: 16px; padding: 0 4px; border-radius: var(--radius-pill); background: var(--red); color: var(--ac-white); font-size: 10px; display: grid; place-items: center; }
