@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("fonts/inter.woff2") format("woff2");
}

:root {
  --bg: #f5f5f7;
  --card: #ffffff;
  --text: #1d1d1f;
  --ink: #111111;
  --muted: #6b7280;
  --surface-soft: #eef0f2;
  --sep: rgba(0,0,0,0.10);
  --accent: #3b82f6;
  --green: #10b981;
  --red: #ef4444;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0,0,0,0.05);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1c1e; --card: #2c2c2e; --text: #f5f5f7; --ink: #f5f5f7; --muted: #98989d;
    --surface-soft: #3a3a3d;
    --sep: rgba(255,255,255,0.12); --shadow: 0 1px 2px rgba(0,0,0,0.3);
  }
}

* { box-sizing: border-box; }
/* The `hidden` attribute must win over element display rules (.lock uses grid). */
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); }
button { font: inherit; cursor: pointer; }
.muted { color: var(--muted); }
.error { color: var(--red); font-size: 13px; }

/* Lock screen — terminal / ASCII vibe (white phosphor on near-black). */
.lock { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: #08080a; overflow-x: hidden; }
.term {
  --phos: #ffffff; --phos-dim: #7d8590; --phos-edge: #33383f;
  font-family: ui-monospace, "SFMono-Regular", "JetBrains Mono", Menlo, Consolas, monospace;
  color: var(--phos); background: #101013;
  width: 100%; max-width: 540px; min-width: 0; padding: 26px 26px 30px;
  border: 1px solid var(--phos-edge); border-radius: 8px;
  box-shadow: 0 0 40px rgba(255,255,255,0.10), inset 0 0 60px rgba(255,255,255,0.04);
  text-shadow: 0 0 6px rgba(255,255,255,0.35);
  display: flex; flex-direction: column; gap: 14px;
}
/* Left-align the art so columns stay aligned; center the block as a whole. */
.term .ascii { margin: 0 auto; font-size: 12px; line-height: 1.15; white-space: pre; text-align: left; align-self: center; }
.term-input {
  display: flex; align-items: center; gap: 8px;
  border-top: 1px dashed var(--phos-edge); border-bottom: 1px dashed var(--phos-edge); padding: 12px 0;
}
.term-input .ip { white-space: nowrap; }
.term-input input {
  flex: 1; min-width: 0; background: transparent; border: 0; outline: none;
  color: var(--phos); font: inherit; caret-color: var(--phos); text-shadow: inherit; letter-spacing: 2px;
}
.term-remember { font-size: 12px; color: var(--phos-dim); display: flex; gap: 8px; align-items: center; cursor: pointer; }
.term-remember input { accent-color: var(--phos); }
.term button[type=submit] {
  align-self: flex-start; background: transparent; border: 1px solid var(--phos);
  color: var(--phos); padding: 8px 16px; border-radius: 4px; font: inherit; text-shadow: inherit; cursor: pointer;
  transition: background 0.12s;
}
.term button[type=submit]:hover { background: rgba(255,255,255,0.14); }
.term .error { color: #ff5f56; text-shadow: 0 0 6px rgba(255,95,86,0.4); font-size: 13px; margin: 0; }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: saturate(180%) blur(20px); border-bottom: 0.5px solid var(--sep);
}
.topbar-inner {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px;
  padding: 12px 20px; max-width: 1200px; margin: 0 auto;
}
/* Cal.com nav-pill-group: a soft-gray wrapper with a white active pill. */
/* Discreet "Last updated" — indented so it lines up with the card text below
   (main padding 20 + card border 1 + panel-head padding 18 ≈ 19px past the bar edge). */
.last-updated { display: inline-flex; align-items: center; gap: 6px; margin-left: 19px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.last-updated .lu-icon { width: 13px; height: 13px; flex: 0 0 auto; }
.tabs { display: inline-flex; align-items: center; gap: 2px; justify-self: center; background: var(--surface-soft); padding: 4px; border-radius: 9999px; }
.controls { display: flex; align-items: center; gap: 8px; justify-self: end; }
.tab {
  display: inline-flex; align-items: center; gap: 6px;
  background: transparent; border: 0; padding: 6px 14px; border-radius: 9999px; color: var(--muted); font-weight: 600;
  transition: background 0.12s, color 0.12s;
}
.tab svg { width: 15px; height: 15px; }
.tab.active { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.picker {
  appearance: none; -webkit-appearance: none;
  padding: 7px 32px 7px 14px;
  border-radius: 9999px;
  border: 1px solid var(--sep);
  background-color: var(--card);
  color: var(--text);
  font: inherit; font-weight: 600;
  box-shadow: var(--shadow);
  cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888888' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
}
.segmented { display: inline-flex; background: var(--surface-soft); border-radius: 9999px; padding: 4px; gap: 2px; }
.segmented button { border: 0; background: transparent; padding: 6px 12px; color: var(--muted); font-weight: 600; border-radius: 9999px; transition: background 0.12s, color 0.12s; }
.segmented button.active { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.ghost { background: transparent; border: 1px solid var(--sep); border-radius: 8px; padding: 6px 12px; color: var(--muted); }

/* Content */
main { padding: 20px; max-width: 1200px; margin: 0 auto; }
.panels { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 900px) { .panels { grid-template-columns: 1fr; } }

/* Cal.com cards: flat, defined by a hairline border rather than a shadow. */
.panel, .card {
  background: var(--card); border-radius: var(--radius); box-shadow: none;
  border: 1px solid var(--sep); overflow: hidden;
}
.panel-head { padding: 16px 18px 12px; }
.panel-label { font-size: 11px; letter-spacing: 0.06em; font-weight: 500; color: var(--muted); text-transform: uppercase; }
.panel-total { font-size: 30px; font-weight: 500; margin-top: 4px; letter-spacing: -0.02em; }
.panel-total.pos { color: var(--green); } .panel-total.neg { color: var(--red); }

.grid { display: grid; grid-template-columns: repeat(10, 1fr); gap: 2px; padding: 0 16px 12px; }
.cell { aspect-ratio: 1; border-radius: 3px; opacity: 0.75; transition: opacity 0.1s; cursor: pointer; }
.cell.hot { opacity: 1; }

.rows { border-top: 0.5px solid var(--sep); }
.row {
  display: flex; align-items: center; gap: 10px; padding: 7px 18px; width: 100%;
  font-size: 13px;
  background: transparent; border: 0; text-align: left; color: var(--text); border-bottom: 0.5px solid var(--sep);
  transition: background 0.1s;
}
.row:last-child { border-bottom: 0; }
.row.hot { background: var(--hot, color-mix(in srgb, var(--accent) 8%, transparent)); }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; }
/* Icon rendered from the app's rasterised glyph (PNG alpha used as a mask). */
.icon {
  width: 16px; height: 16px; flex: 0 0 auto; display: inline-block;
  -webkit-mask-size: contain; mask-size: contain;
  -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
  -webkit-mask-position: center; mask-position: center;
}
.row .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .pct { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 11px; }
.row .amt { font-variant-numeric: tabular-nums; min-width: 84px; text-align: right; font-weight: 500; }
.clickable { cursor: pointer; }

.drill-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 0.5px solid var(--sep); }
.back { border: 1px solid var(--sep); background: var(--card); border-radius: 6px; padding: 4px 8px; }
.section-sub { padding: 8px 18px 0; font-size: 11px; letter-spacing: 0.05em; font-weight: 500; color: var(--muted); text-transform: uppercase; }

.tx { display: flex; align-items: center; gap: 10px; padding: 7px 18px; border-bottom: 0.5px solid var(--sep); font-size: 13px; }
.tx:last-child { border-bottom: 0; }
.tx .date { color: var(--muted); font-variant-numeric: tabular-nums; flex: 0 0 auto; }
.tx .desc { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx .amt { font-variant-numeric: tabular-nums; font-weight: 600; }

.empty { padding: 40px; text-align: center; color: var(--muted); }

/* Evolution */
.evo { display: flex; flex-direction: column; gap: 16px; }
.evo-top { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 900px) { .evo-top { grid-template-columns: 1fr; } }
.card-title { font-size: 11px; letter-spacing: 0.06em; font-weight: 500; color: var(--muted); text-transform: uppercase; padding: 16px 18px 0; }
.card-body { padding: 14px 18px 18px; overflow-x: auto; }  /* wide heatmap scrolls on small screens */
.chart-wrap { position: relative; height: 240px; }
/* Equal-height header above each chart so both plot areas (and their x-axes)
   line up. Cash flow puts its legend here; savings puts its net headline. */
.evo-head { height: 30px; display: flex; align-items: baseline; gap: 14px; margin-bottom: 8px; }
.evo-head .lg { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); align-self: center; }
.evo-head .lg i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.sav-net { font-size: 20px; font-weight: 600; color: #3b82f6; letter-spacing: -0.02em; }

table.heat { width: 100%; border-collapse: collapse; font-size: 13px; }
table.heat th, table.heat td { padding: 5px 8px; border-bottom: 0.5px solid var(--sep); text-align: center; white-space: nowrap; }
table.heat thead th { color: var(--muted); font-weight: 600; }
table.heat th.sortable { cursor: pointer; user-select: none; }
table.heat th.sortable:hover { color: var(--text); }
table.heat th .arrow { font-size: 9px; opacity: 0.7; }
table.heat td.cat, table.heat th.cat { text-align: left; }
table.heat td.cat { display: flex; align-items: center; gap: 8px; }
table.heat td.amt { font-variant-numeric: tabular-nums; }
/* Heat cell: category colour, opacity ∝ row max (tint set inline). */
table.heat td.mon { padding: 3px 6px; }
table.heat td.mon span { display: block; padding: 3px 6px; border-radius: 5px; font-variant-numeric: tabular-nums; }
table.heat td.mon.zero span { color: var(--muted); }
table.heat td.median { font-weight: 600; }
table.heat td.spread { color: var(--muted); }
table.heat td.trend, table.heat th.trend { padding-left: 32px; padding-right: 32px; }
.spark { display: block; margin: 0 auto; }

/* ---- Mobile ---- */
@media (max-width: 640px) {
  main { padding: 14px; }
  /* Top bar reflows: last-updated on its own centered row, then tabs, then controls. */
  .topbar-inner { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 8px 10px; padding: 10px 14px; }
  .last-updated { order: -1; width: 100%; margin-left: 0; justify-content: center; }
  .tabs { order: 1; }
  .controls { order: 2; flex-wrap: wrap; justify-content: center; }
  .picker { max-width: 100%; }
  .chart-wrap { height: 220px; }
  /* Terminal login fills the small screen. */
  .lock { padding: 12px; }
  .term { max-width: 100%; padding: 20px 16px 24px; }
  .term .ascii { font-size: 11px; }
}
@media (max-width: 380px) {
  .term .ascii { font-size: 9.5px; }
}

/* Heatmap progressive disclosure — hide columns by priority instead of
   scrolling. Priority (kept longest): Median > Low/High > Trend > months. */
@media (max-width: 1024px) { table.heat .hm-month { display: none; } }
@media (max-width: 760px)  { table.heat .hm-trend { display: none; } }
@media (max-width: 560px)  { table.heat .hm-low, table.heat .hm-high { display: none; } }

