/* AI&I Ledger planner. Mobile-first. All sizes in rem so the text-size selector scales everything. */

:root {
  --font-head: "Space Grotesk", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-body: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --indigo: #6366f1;
  --purple: #a855f7;
  --indigo-soft: #818cf8;
  --purple-soft: #c084fc;
  --pink: #f472b6;
  --radius: 1.1rem;
}

html[data-font-size="sm"] { font-size: 93.75%; }
html[data-font-size="md"] { font-size: 106.25%; }
html[data-font-size="lg"] { font-size: 118.75%; }
html[data-font-size="xl"] { font-size: 131.25%; }

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0a0a1a;
  --text: #eeecff;
  --muted: #b9b5dc;
  --line: rgba(160, 150, 255, 0.22);
  --glass: rgb(22, 20, 44);
  --glass-mix: rgba(22, 20, 44, 0.62);
  --glass-strong: rgb(28, 26, 56);
  --field: rgb(16, 15, 34);
  --accent-text: #a5b4fc;
  --link: #c4b5fd;
  --bubble-user: linear-gradient(135deg, #4f46e5, #7e22ce);
  --bubble-user-text: #ffffff;
  --bubble-bot: rgb(36, 33, 70);
  --error: #ff9b8a;
  --error-bg: rgba(255, 120, 100, 0.12);
  --ok: #6ee7b7;
  --btn-text: #ffffff;
  --btn-bg: linear-gradient(135deg, #4f46e5, #9333ea);
  --btn-bg-flat: #5b3fd9;
  --glow-a: rgba(99, 102, 241, 0.45);
  --glow-b: rgba(168, 85, 247, 0.38);
  --glow-c: rgba(244, 114, 182, 0.28);
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f3ff;
  --text: #1a1638;
  --muted: #4a4670;
  --line: rgba(80, 70, 180, 0.2);
  --glass: rgb(255, 255, 255);
  --glass-mix: rgba(255, 255, 255, 0.78);
  --glass-strong: rgb(255, 255, 255);
  --field: rgb(250, 249, 255);
  --accent-text: #4338ca;
  --link: #5b21b6;
  --bubble-user: linear-gradient(135deg, #4f46e5, #7e22ce);
  --bubble-user-text: #ffffff;
  --bubble-bot: rgb(237, 235, 255);
  --error: #b42318;
  --error-bg: rgba(220, 70, 50, 0.1);
  --ok: #047857;
  --btn-text: #ffffff;
  --btn-bg: linear-gradient(135deg, #4f46e5, #7e22ce);
  --btn-bg-flat: #5534d6;
  --glow-a: rgba(99, 102, 241, 0.28);
  --glow-b: rgba(168, 85, 247, 0.22);
  --glow-c: rgba(244, 114, 182, 0.2);
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
  position: relative;
}

/* Vibrant background glow, never dimmed by a scrim */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(40rem 28rem at 12% 8%, var(--glow-a), transparent 70%),
    radial-gradient(36rem 26rem at 88% 18%, var(--glow-b), transparent 70%),
    radial-gradient(40rem 30rem at 60% 100%, var(--glow-c), transparent 70%);
}

h1, h2, h3 { font-family: var(--font-head); line-height: 1.15; margin: 0; }
p { margin: 0; }
a { color: var(--link); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
:focus-visible { outline: 0.18rem solid var(--purple-soft); outline-offset: 0.15rem; }
[hidden] { display: none !important; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip {
  position: absolute; left: 1rem; top: -4rem; z-index: 100;
  background: var(--glass-strong); color: var(--text); padding: 0.5rem 0.9rem; border-radius: 0.6rem;
}
.skip:focus { top: calc(0.75rem + env(safe-area-inset-top)); }

/* ---------- glass panels ---------- */
.card, .nav {
  background: var(--glass);
  background: var(--glass-mix);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  backdrop-filter: blur(18px) saturate(140%);
}

/* ---------- nav ---------- */
.nav {
  position: sticky;
  top: 0;
  z-index: 20;
  width: 100%;
  border-bottom: 1px solid var(--line);
  padding: calc(0.5rem + env(safe-area-inset-top)) calc(1rem + env(safe-area-inset-right)) 0.5rem calc(1rem + env(safe-area-inset-left));
}
.nav-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.5rem 1.25rem;
  width: min(100%, 90rem);
  margin: 0 auto;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--text);
  text-decoration: none;
  min-width: 0;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 2.3rem;
  height: 2.3rem;
  border-radius: 0.7rem;
  background: #5b21b6;
  background: linear-gradient(135deg, #4f46e5, #7e22ce 55%, #be185d);
  color: #ffffff;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 0.02em;
  flex: none;
}
.brand-name { display: flex; flex-direction: column; line-height: 1.1; text-align: left; }
.brand-name strong { font-family: var(--font-head); font-size: 1.05rem; }
.brand-name span { font-size: 0.75rem; color: var(--muted); }
.nav-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.25rem; }
.nav-links a {
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.9rem;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
}
.nav-links a:hover, .nav-links a[aria-current="page"] { background: rgba(129, 140, 248, 0.16); }
.prefs { display: flex; align-items: center; gap: 0.5rem; }
.size-group {
  display: inline-flex;
  align-items: flex-end;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.15rem;
}
.size-btn {
  border: 0;
  background: transparent;
  border-radius: 999px;
  min-width: 2rem;
  height: 2rem;
  font-family: var(--font-head);
  font-weight: 600;
  line-height: 1;
}
.size-btn[data-size="sm"] { font-size: 0.75rem; }
.size-btn[data-size="md"] { font-size: 0.9rem; }
.size-btn[data-size="lg"] { font-size: 1.05rem; }
.size-btn[data-size="xl"] { font-size: 1.2rem; }
.size-btn[aria-pressed="true"] { background: var(--btn-bg-flat); background: var(--btn-bg); color: var(--btn-text); }
.theme-btn {
  display: grid;
  place-items: center;
  width: 2.3rem;
  height: 2.3rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
}
.theme-btn svg { width: 1.15rem; height: 1.15rem; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.theme-btn .icon-moon { fill: currentColor; stroke: none; }
html[data-theme="dark"] .theme-btn .icon-sun { display: none; }
html[data-theme="light"] .theme-btn .icon-moon { display: none; }

/* ---------- hero ---------- */
main { display: block; }
.hero {
  width: min(100% - 2rem, 83.75rem);
  margin: 0 auto;
  padding: 1.1rem 0 0.9rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}
.chip {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent-text);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.25rem 0.75rem;
}
.hero h1 { font-size: clamp(1.7rem, 1.2rem + 2.2vw, 2.75rem); font-weight: 700; letter-spacing: -0.01em; }
.grad {
  color: var(--purple-soft);
  background: linear-gradient(90deg, var(--indigo-soft), var(--purple-soft), var(--pink));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
html[data-theme="light"] .grad {
  color: #7e22ce;
  background-image: linear-gradient(90deg, #4338ca, #7e22ce, #be185d);
}
.subline { font-weight: 600; font-size: 0.98rem; max-width: 46rem; }
.hero-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.5rem; margin-top: 0.15rem; }
.chip-link {
  display: inline-block;
  padding: 0.4rem 0.95rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.88rem;
  background: rgba(129, 140, 248, 0.12);
}
.chip-link:hover { background: rgba(129, 140, 248, 0.24); }

/* ---------- board ---------- */
.board {
  width: min(100% - 3rem, clamp(56.25rem, 66vw, 83.75rem));
  margin: 0 auto 2rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.75rem;
  align-items: start;
}
.card {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  min-width: 0;
  box-shadow: 0 1rem 2.5rem rgba(10, 8, 40, 0.18);
  overflow: hidden;
}
.card::before {
  content: "";
  position: absolute;
  left: 0; right: 0; top: 0;
  height: 0.2rem;
  background: linear-gradient(90deg, var(--indigo), var(--purple));
}
.top-card::before { background: linear-gradient(90deg, var(--purple), var(--pink)); }
.short-card::before { background: linear-gradient(90deg, var(--indigo-soft), var(--purple-soft)); }
.detail-card::before { background: linear-gradient(90deg, var(--pink), var(--indigo)); }
.card h2 { font-size: 1.1rem; }
.card-sub { color: var(--muted); font-size: 0.85rem; margin-top: 0.15rem; }

/* chat */
.chat-slot { padding: 0; }
.chat-panel {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  height: clamp(24rem, 72svh, 36rem);
  padding: 1rem;
  min-width: 0;
  /* The card is 2rem wider than this panel's content box (1rem padding each side). */
  container-type: inline-size;
}
.chat-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 0.5rem; }
.chat-title-wrap { min-width: 0; flex: 1 1 12rem; }
.chat-tools { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.count-chip {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.2rem 0.6rem;
  white-space: nowrap;
}
.icon-btn {
  display: grid;
  place-items: center;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
}
.icon-btn svg { width: 1.1rem; height: 1.1rem; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn:disabled { opacity: 0.4; }
.pill-btn {
  border: 1px solid var(--line);
  background: rgba(129, 140, 248, 0.12);
  border-radius: 999px;
  padding: 0.35rem 0.8rem;
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
}
.pill-btn[aria-pressed="true"] { background: var(--btn-bg-flat); background: var(--btn-bg); color: var(--btn-text); border-color: transparent; }

.log {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 0.25rem 0.1rem;
  overscroll-behavior: contain;
}
.log-empty { color: var(--muted); font-size: 0.92rem; margin: auto 0; text-align: center; padding: 0 0.5rem; }
.log-empty strong { color: var(--text); }
.msg { max-width: 92%; border-radius: 1rem; padding: 0.6rem 0.85rem; font-size: 0.95rem; }
.msg p { white-space: pre-wrap; }
.from-user { align-self: flex-end; background: var(--btn-bg-flat); background: var(--bubble-user); color: var(--bubble-user-text); border-bottom-right-radius: 0.3rem; }
.from-planner { align-self: flex-start; background: var(--bubble-bot); border-bottom-left-radius: 0.3rem; }
.msg.is-error { background: var(--error-bg); color: var(--error); border: 1px solid currentColor; }
.thinking { display: flex; flex-direction: column; gap: 0.35rem; min-width: 4.5rem; }
.dots { display: inline-flex; gap: 0.3rem; align-items: center; height: 1.2rem; }
.dots span {
  width: 0.5rem; height: 0.5rem; border-radius: 50%;
  background: var(--purple-soft);
  animation: pulse 1.2s ease-in-out infinite;
}
html[data-theme="light"] .dots span { background: #7e22ce; }
.dots span:nth-child(2) { animation-delay: 0.2s; }
.dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes pulse { 0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); } 40% { opacity: 1; transform: scale(1); } }
@media (prefers-reduced-motion: reduce) { .dots span { animation: none; opacity: 1; transform: none; } }
.wait-note { color: var(--muted); font-size: 0.82rem; }

.composer {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: flex-end;
}
.composer textarea {
  flex: 1 1 100%;
  min-width: 0;
  resize: none;
  max-height: 8rem;
  overflow-y: hidden;
  border: 1px solid var(--line);
  border-radius: 1.2rem;
  background: var(--field);
  padding: 0.6rem 0.9rem;
  line-height: 1.4;
}
.composer textarea::placeholder { color: var(--muted); opacity: 1; }
.composer-actions { display: flex; gap: 0.5rem; justify-content: flex-end; width: 100%; }
/* Inline composer when the chat card is at least 18.5rem wide (content box 16.5rem). */
@container (min-width: 16.5rem) {
  .composer { flex-wrap: nowrap; }
  .composer textarea { flex: 1 1 auto; }
  .composer-actions { width: auto; flex: none; }
}
.mic-btn {
  display: grid;
  place-items: center;
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: transparent;
  flex: none;
}
.mic-btn svg { width: 1.15rem; height: 1.15rem; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.mic-btn[aria-pressed="true"] { background: var(--btn-bg-flat); background: var(--btn-bg); color: var(--btn-text); border-color: transparent; box-shadow: 0 0 0 0.25rem rgba(168, 85, 247, 0.3); }
.mic-btn.small { width: 2.3rem; height: 2.3rem; }
.send-btn {
  border: 0;
  border-radius: 999px;
  padding: 0 1.2rem;
  min-height: 2.6rem;
  font-weight: 700;
  color: var(--btn-text);
  background: var(--btn-bg-flat);
  background: var(--btn-bg);
  white-space: nowrap;
}
.send-btn:disabled { opacity: 0.7; }
.voice-status { color: var(--muted); font-size: 0.8rem; }
.voice-error { color: var(--error); font-size: 0.82rem; font-weight: 600; }
.chat-foot { display: flex; flex-direction: column; gap: 0.3rem; }
.check { display: inline-flex; align-items: center; gap: 0.45rem; font-size: 0.85rem; font-weight: 600; }
.check input { width: 1.05rem; height: 1.05rem; accent-color: var(--purple); }
.note { color: var(--muted); font-size: 0.78rem; }

/* full page overlay */
.chat-panel.is-full {
  position: fixed;
  inset: 0;
  z-index: 50;
  height: auto;
  background: var(--glass-strong);
  padding: calc(1rem + env(safe-area-inset-top)) calc(1rem + env(safe-area-inset-right)) calc(1rem + env(safe-area-inset-bottom)) calc(1rem + env(safe-area-inset-left));
}
.chat-panel.is-full .log, .chat-panel.is-full .composer, .chat-panel.is-full .chat-head, .chat-panel.is-full .chat-foot {
  width: min(100%, 56rem);
  margin-left: auto;
  margin-right: auto;
}
body.has-full { overflow: hidden; }
/* backdrop-filter and overflow on the card would make it the containing block for the
   fixed overlay (so the overlay only filled the card). Drop them while full page is open. */
.chat-slot.is-hosting-full {
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  overflow: visible;
}

/* side cards */
.pill {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--btn-text);
  background: var(--btn-bg-flat);
  background: linear-gradient(90deg, #7e22ce, #be185d);
  border-radius: 999px;
  padding: 0.2rem 0.65rem;
}
.tile {
  margin-top: 0.7rem;
  border-radius: 0.9rem;
  padding: 0.9rem;
  background: #4c1d95;
  background: linear-gradient(135deg, #3730a3, #6b21a8 60%, #9d174d);
  color: #ffffff;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.tile-kind { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; color: #e9e3ff; }
.tile-title { font-family: var(--font-head); font-size: 1.15rem; font-weight: 700; line-height: 1.2; }
.score-row { display: flex; justify-content: space-between; align-items: baseline; margin-top: 0.75rem; gap: 0.5rem; }
.score-label { color: var(--muted); font-size: 0.85rem; }
.score-value { font-family: var(--font-head); font-size: 1.35rem; font-weight: 700; color: var(--accent-text); }
.why { margin-top: 0.35rem; font-size: 0.88rem; }

.short-head { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; }
.gauge { position: relative; width: 3.6rem; height: 3.6rem; flex: none; }
.gauge svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.gauge circle { fill: none; stroke-width: 3.4; }
.gauge-track { stroke: var(--line); }
.gauge-fill { stroke: var(--purple-soft); stroke-linecap: round; transition: stroke-dasharray 0.4s ease; }
html[data-theme="light"] .gauge-fill { stroke: #7e22ce; }
.gauge-num { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--font-head); font-weight: 700; font-size: 0.95rem; }
.rank-note { color: var(--muted); font-size: 0.82rem; margin-top: 0.35rem; }
.short-list { list-style: none; margin: 0.6rem 0 0; padding: 0; display: flex; flex-direction: column; gap: 0.35rem; }
.short-item {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 0.7rem;
  background: transparent;
  padding: 0.45rem 0.65rem;
  font-size: 0.86rem;
}
.short-item[aria-pressed="true"] { border-color: var(--purple-soft); background: rgba(168, 85, 247, 0.14); }
.short-title { min-width: 0; font-weight: 600; }
.short-score { font-family: var(--font-head); font-weight: 700; color: var(--accent-text); flex: none; }

.detail-name { font-weight: 700; margin-top: 0.4rem; }
.fields { margin: 0.5rem 0 0; display: flex; flex-direction: column; gap: 0.35rem; }
.fields div { display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr); gap: 0.5rem; font-size: 0.84rem; border-top: 1px solid var(--line); padding-top: 0.35rem; }
.fields dt { color: var(--muted); }
.fields dd { margin: 0; font-weight: 600; }
.guide-link { display: inline-block; margin-top: 0.6rem; font-weight: 600; font-size: 0.86rem; }
.next-step { margin-top: 0.8rem; border-top: 1px solid var(--line); padding-top: 0.6rem; }
.next-step h3 { font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent-text); }
.next-step p { font-size: 0.88rem; margin-top: 0.25rem; }

/* ---------- vault ---------- */
.vault {
  width: min(100% - 3rem, clamp(56.25rem, 66vw, 83.75rem));
  margin: 0 auto 2.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  scroll-margin-top: 5rem;
}
.vault-head { text-align: center; display: flex; flex-direction: column; gap: 0.35rem; align-items: center; }
.vault-head h2 { font-size: 1.6rem; }
.vault-head p { color: var(--muted); max-width: 44rem; }
.vault-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0.75rem; align-items: start; }
.vault .card h3 { font-size: 1.05rem; display: flex; align-items: center; gap: 0.5rem; }
.drop {
  margin-top: 0.75rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  border: 2px dashed var(--line);
  border-radius: 0.9rem;
  padding: 1.2rem 0.75rem;
  cursor: pointer;
  text-align: center;
}
.drop:hover, .drop.is-over, .drop:focus-within { border-color: var(--purple-soft); background: rgba(168, 85, 247, 0.08); }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop-title { font-weight: 700; color: var(--accent-text); }
.drop-sub { color: var(--muted); font-size: 0.82rem; }
.scan-queue { list-style: none; margin: 0.6rem 0 0; padding: 0; display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.82rem; text-align: left; }
.scan-queue li { display: flex; flex-direction: column; border-top: 1px solid var(--line); padding-top: 0.3rem; }
.q-name { font-weight: 600; }
.q-state { color: var(--muted); }
.scan-queue li.is-error .q-state { color: var(--error); font-weight: 600; }
.scan-queue li.is-done .q-state { color: var(--ok); font-weight: 600; }

.entry-form { margin-top: 0.6rem; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0.6rem; }
.field { display: flex; flex-direction: column; gap: 0.25rem; min-width: 0; }
.field.wide, .form-actions.wide { grid-column: 1 / -1; }
.field label { font-size: 0.8rem; font-weight: 600; color: var(--muted); }
.field input, .field select, .sum-head select {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 0.65rem;
  background: var(--field);
  padding: 0.5rem 0.65rem;
  min-height: 2.5rem;
}
.with-mic { display: flex; gap: 0.4rem; align-items: center; }
.with-mic input { flex: 1 1 auto; }
.form-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.ghost-btn {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  padding: 0.45rem 0.9rem;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text);
}
.ghost-btn.danger, .mini-btn.danger { color: var(--error); }
.file-btn { position: relative; cursor: pointer; }
.file-btn input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.file-btn:focus-within { outline: 0.18rem solid var(--purple-soft); outline-offset: 0.15rem; }

.sum-head { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; }
.sum-head select { width: auto; }
.totals { margin: 0.6rem 0 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0.5rem; }
.totals div { border: 1px solid var(--line); border-radius: 0.7rem; padding: 0.5rem 0.6rem; min-width: 0; }
.totals dt { color: var(--muted); font-size: 0.76rem; }
.totals dd { margin: 0; font-family: var(--font-head); font-weight: 700; font-size: 1.05rem; }
.totals .is-key { border-color: var(--purple-soft); background: rgba(168, 85, 247, 0.1); }
.sum-card .note { margin-top: 0.6rem; }
.vault-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.7rem; }
.vault-msg { margin-top: 0.4rem; font-size: 0.82rem; color: var(--ok); font-weight: 600; min-height: 1.2em; }
.vault-msg.is-error { color: var(--error); }

.ledger { width: 100%; border-collapse: collapse; margin-top: 0.6rem; font-size: 0.86rem; }
.ledger th { text-align: left; font-size: 0.76rem; color: var(--muted); font-weight: 600; padding: 0.4rem; border-bottom: 1px solid var(--line); }
.ledger td { padding: 0.45rem 0.4rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.ledger .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.ledger .is-in { color: var(--ok); font-weight: 700; }
.ledger .nowrap { white-space: nowrap; }
.ledger tr.needs-review td { background: rgba(244, 114, 182, 0.07); }
.flag { display: inline-block; font-size: 0.7rem; font-weight: 700; color: var(--error); border: 1px solid currentColor; border-radius: 999px; padding: 0 0.4rem; }
.row-actions { white-space: nowrap; text-align: right; }
.mini-btn { border: 1px solid var(--line); background: transparent; border-radius: 999px; padding: 0.2rem 0.55rem; font-size: 0.76rem; font-weight: 600; margin: 0.1rem; color: var(--text); }
.empty { color: var(--muted); font-size: 0.88rem; margin-top: 0.6rem; text-align: center; }

/* table becomes stacked label/value cards on small screens */
@media (max-width: 47.99rem) {
  .ledger thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .ledger, .ledger tbody, .ledger tr, .ledger td { display: block; width: 100%; }
  .ledger tr { border: 1px solid var(--line); border-radius: 0.8rem; margin-bottom: 0.5rem; padding: 0.35rem 0.6rem; }
  .ledger td { display: grid; grid-template-columns: 6rem minmax(0, 1fr); gap: 0.5rem; border-bottom: 0; padding: 0.25rem 0; text-align: left; }
  .ledger td::before { content: attr(data-label); color: var(--muted); font-size: 0.76rem; font-weight: 600; }
  .ledger .num, .row-actions { text-align: left; white-space: normal; }
  .ledger td.row-actions { display: flex; flex-wrap: wrap; gap: 0.35rem; padding-top: 0.4rem; }
  .ledger td.row-actions::before { content: none; }
  .row-actions .mini-btn { margin: 0; padding: 0.35rem 0.8rem; }
  .ledger tr.needs-review td { background: transparent; }
  .ledger tr.needs-review { background: rgba(244, 114, 182, 0.07); }
}

.foot {
  width: min(100% - 2rem, 70rem);
  margin: 0 auto;
  padding: 1rem 0 calc(2rem + env(safe-area-inset-bottom));
  color: var(--muted);
  font-size: 0.8rem;
  text-align: center;
}

/* ---------- larger screens ---------- */
@media (min-width: 700px) {
  .board { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .chat-slot { grid-column: 1 / -1; grid-row: 1; }
  .top-card { grid-column: 1; grid-row: 2; }
  .short-card { grid-column: 2; grid-row: 2; }
  .detail-card { grid-column: 3; grid-row: 2; }
  .vault-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sum-card { grid-column: 1 / -1; }
  .hero { text-align: center; }
}
@media (min-width: 1100px) {
  .board { grid-template-columns: 1.36fr 1.06fr 0.98fr 0.98fr; }
  .chat-slot { grid-column: 1; grid-row: 1; }
  .top-card { grid-column: 2; grid-row: 1; }
  .short-card { grid-column: 3; grid-row: 1; }
  .detail-card { grid-column: 4; grid-row: 1; }
  .chat-panel { height: clamp(22rem, 100svh - 21rem, 38rem); }
  .vault-grid { grid-template-columns: 1fr 1.1fr 1fr; }
  .sum-card { grid-column: auto; }
}
