/* Spendt brand: navy, mint and coral (theme/colors.ts). Two palettes, light and
   dark, built from the same brand colours as the app. Every colour below is a
   token; component rules never name a colour directly, so a rule cannot look
   right in one theme and unreadable in the other.

   Which palette applies: the theme button (theme.js) sets data-theme="light"
   or "dark" on <html>; "system" sets nothing and prefers-color-scheme decides.
   The dark values therefore appear twice, once for each of those routes. */
:root {
  --bg: #f8fafc;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #0a2540;
  --muted: #64748b;
  --primary: #20d68a;
  --primary-hover: #1bc27c;
  --primary-text: #0a2540;
  --link: #0b7a4b;
  --negative: #c2413f;
  --negative-bg: #fdecec;
  --negative-border: #f5c2c1;
  --warn: #b45309;
  --warn-bg: #fff4e0;
  --ok-bg: #e3f9ef;
  --ok-text: #0b7a4b;
  --row-hover: #f1f5f9;
  /* The deep navy panels (summary cards, the phone preview). */
  --inset: #0a2540;
  --inset-text: #ffffff;
  --inset-muted: #b6c6da;
  /* The chosen option in a segmented control. */
  --selected: #0a2540;
  --selected-text: #ffffff;
  --backdrop: rgba(10, 37, 64, 0.45);
  /* A notification bubble is light on every phone, whatever the console's theme. */
  --bubble: #f1f5f9;
  --bubble-text: #0a2540;
  --bubble-muted: #64748b;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a2540;
    --card: #12314f;
    --border: #2b4b70;
    --text: #f8fafc;
    --muted: #a9b8cb;
    --primary: #20d68a;
    --primary-hover: #4ae0a2;
    --primary-text: #0a2540;
    --link: #4ae0a2;
    --negative: #ff8a8a;
    --negative-bg: #4a1f2e;
    --negative-border: #7a3344;
    --warn: #fbbf24;
    --warn-bg: #423410;
    --ok-bg: #0f4a3a;
    --ok-text: #6eebb5;
    --row-hover: #1b3f63;
    --inset: #07192c;
    --inset-text: #f8fafc;
    --inset-muted: #a9b8cb;
    --selected: #20d68a;
    --selected-text: #0a2540;
    --backdrop: rgba(2, 10, 20, 0.7);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0a2540;
  --card: #12314f;
  --border: #2b4b70;
  --text: #f8fafc;
  --muted: #a9b8cb;
  --primary: #20d68a;
  --primary-hover: #4ae0a2;
  --primary-text: #0a2540;
  --link: #4ae0a2;
  --negative: #ff8a8a;
  --negative-bg: #4a1f2e;
  --negative-border: #7a3344;
  --warn: #fbbf24;
  --warn-bg: #423410;
  --ok-bg: #0f4a3a;
  --ok-text: #6eebb5;
  --row-hover: #1b3f63;
  --inset: #07192c;
  --inset-text: #f8fafc;
  --inset-muted: #a9b8cb;
  --selected: #20d68a;
  --selected-text: #0a2540;
  --backdrop: rgba(2, 10, 20, 0.7);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
h1 { font-size: 1.5rem; line-height: 1.2; margin: 0; text-wrap: balance; overflow-wrap: anywhere; }
h2 { font-size: 1.05rem; margin: 0; }
h3 { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); margin: 0; font-weight: 600; }
p { margin: 0; }
.muted { color: var(--muted); }
.error { color: var(--negative); }
code, .mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.92em; }
a { color: var(--link); font-weight: 600; }

/* Layout helpers */
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.row.end { justify-content: flex-end; }
.spacer { flex: 1; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); align-items: start; }
.grid.wide-left { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
@media (max-width: 900px) { .grid.wide-left { grid-template-columns: minmax(0, 1fr); } }

/* Sign-in */
.login { max-width: 360px; margin: 12vh auto 0; padding: 0 20px; display: flex; flex-direction: column; gap: 12px; }
.brand { font-size: 1.25rem; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.brand img { width: 30px; height: 30px; flex: none; }
/* The wordmark's last letter is mint in the logo; here it takes the mint that reads on this ground. */
.brand .t { color: var(--link); }
.theme-toggle { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; padding: 0; flex: none; }
.login .theme-toggle { align-self: flex-end; }
.tag { font-size: 0.65rem; letter-spacing: 0.08em; text-transform: uppercase; border: 1px solid var(--border); border-radius: 6px; padding: 2px 6px; color: var(--muted); font-weight: 600; }

/* Shell */
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: var(--card); border-right: 1px solid var(--border); padding: 20px 14px; display: flex; flex-direction: column; gap: 16px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
#nav { display: flex; flex-direction: column; gap: 2px; }
.nav-group { font-size: 0.68rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); font-weight: 600; margin: 14px 8px 4px; }
#nav button { display: flex; justify-content: space-between; align-items: center; text-align: left; border: 0; background: none; padding: 7px 10px; border-radius: 8px; font: inherit; color: var(--text); cursor: pointer; border-left: 3px solid transparent; }
#nav button:hover { background: var(--row-hover); }
#nav button[aria-current="page"] { background: var(--row-hover); border-left-color: var(--primary); font-weight: 600; }
.count { font-size: 0.72rem; color: var(--negative); font-weight: 700; }
.boundary { margin-top: auto; font-size: 0.78rem; color: var(--muted); background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 10px; }
.boundary strong { display: block; color: var(--text); margin-bottom: 2px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 12px 24px; background: var(--card); border-bottom: 1px solid var(--border); }
.search { flex: 1 1 220px; max-width: 360px; }
.who { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.25; font-size: 0.85rem; min-width: 0; }
.who strong { overflow-wrap: anywhere; }
.page { padding: 24px; display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 12px; }
.page-head > div { flex: 1 1 260px; min-width: 0; }

@media (max-width: 760px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--border); }
  .boundary { margin-top: 0; }
  .page { padding: 16px; }
  .topbar { padding: 12px 16px; }
}

/* Controls */
label { display: flex; flex-direction: column; gap: 4px; font-size: 0.8rem; color: var(--muted); font-weight: 600; }
label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; color: var(--text); font-size: 0.9rem; }
input, select, textarea, button { font: inherit; color: var(--text); }
input:not([type="checkbox"]), select, textarea { border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; background: var(--card); width: 100%; min-width: 0; }
textarea { resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
button { border: 1px solid var(--border); background: var(--card); border-radius: 10px; padding: 8px 14px; cursor: pointer; font-weight: 600; }
button:hover:not(:disabled) { background: var(--row-hover); }
button:disabled { opacity: 0.5; cursor: default; }
button.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
button.primary:hover:not(:disabled) { background: var(--primary-hover); }
button.danger { border-color: var(--negative); color: var(--negative); }
button.link { border: 0; background: none; padding: 0; color: var(--link); }
.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.segmented button { border: 0; border-radius: 0; background: var(--card); }
.segmented button[aria-pressed="true"] { background: var(--selected); color: var(--selected-text); }

/* Cards and tables */
.card { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 18px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.card.alert { background: var(--negative-bg); border-color: var(--negative-border); }
.card.navy { background: var(--inset); color: var(--inset-text); border-color: var(--inset); }
.card.navy .muted, .card.navy h3 { color: var(--inset-muted); }
.card-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th { text-align: left; font-size: 0.7rem; letter-spacing: 0.07em; text-transform: uppercase; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: top; overflow-wrap: anywhere; }
tr:last-child td { border-bottom: 0; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--row-hover); }
td.num, th.num { text-align: right; white-space: nowrap; }

.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px 20px; }
.kv dt { font-size: 0.68rem; letter-spacing: 0.07em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.kv dd { margin: 0; overflow-wrap: anywhere; }
dl { margin: 0; }

.pill { display: inline-block; font-size: 0.72rem; font-weight: 700; border-radius: 999px; padding: 2px 9px; background: var(--row-hover); color: var(--muted); white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok-text); }
.pill.bad { background: var(--negative-bg); color: var(--negative); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.note { background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; color: var(--muted); font-size: 0.85rem; }
.stat { font-size: 1.7rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.list li { padding: 10px 0; border-bottom: 1px solid var(--border); display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; }
.list li:last-child { border-bottom: 0; }
.list li > div { flex: 1 1 220px; min-width: 0; overflow-wrap: anywhere; }

/* Bars (parser health) */
.bar { height: 8px; border-radius: 4px; background: var(--border); overflow: hidden; min-width: 80px; }
.bar > span { display: block; height: 100%; background: var(--primary); }
.bar.low > span { background: var(--negative); }

/* Phone preview */
.phone { background: var(--inset); border-radius: 18px; padding: 14px; color: var(--inset-text); display: flex; flex-direction: column; gap: 10px; }
.phone .clock { display: flex; justify-content: space-between; font-size: 0.8rem; font-weight: 600; }
.phone .bubble { background: var(--bubble); color: var(--bubble-text); border-radius: 14px; padding: 10px 12px; }
.phone .bubble .app { font-size: 0.65rem; letter-spacing: 0.08em; color: var(--bubble-muted); font-weight: 700; }
.phone .bubble .t { font-weight: 700; overflow-wrap: anywhere; }
.phone .bubble .b { font-size: 0.85rem; overflow-wrap: anywhere; }
.counter { font-weight: 400; font-variant-numeric: tabular-nums; }
.counter.over { color: var(--negative); font-weight: 700; }

dialog { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 20px; width: min(440px, calc(100vw - 32px)); color: var(--text); }
dialog::backdrop { background: var(--backdrop); }
::placeholder { color: var(--muted); opacity: 1; }
