/* Ledger design language, lifted from Project/gui/css/01-tokens.css, 02-components.css
   and 06-overview.css. Dark by default; light follows the OS with Ledger's light values. */
@font-face {
  font-family: "Quicksand";
  src: url("fonts/Quicksand-variable.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "Heebo";
  src: url("fonts/Heebo-variable.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --bg: #0a0c10;
  --surface: #1b1f26;
  --surface2: #21262e;
  --surface3: #262b33;
  --tile: #242931;
  --tile-edge: rgba(255, 255, 255, 0.06);
  --border: #2e333d;
  --border-hover: #434a56;
  --text: #e9ebef;
  --muted: #9aa3b2;
  --pos: #00a94d;
  --neg: #ff5754;
  --accent: #c18700;
  --accent-bright: #efa800;
  --accent-bright-ink: #16181d;
  --violet: #5d8dff;
  --chart-pos: #00873c;
  --chart-neg: #ea0027;
  --chart-committed: #9b6c00;
  --chart-balance: #9b6c00;
  --tint-green: #172f1d;
  --tint-amber: #36270e;
  --elev: inset 0 0 0 1px rgba(255, 255, 255, 0.07), 0 1px 2px rgba(0, 0, 0, 0.6),
    0 6px 18px -6px rgba(0, 0, 0, 0.7);
  --elev-hover: inset 0 0 0 1px rgba(255, 255, 255, 0.11), 0 2px 6px rgba(0, 0, 0, 0.6),
    0 14px 30px -12px rgba(0, 0, 0, 0.8);

  --sp-1: 0.25rem;
  --sp-2: 0.5rem;
  --sp-3: 0.75rem;
  --sp-4: 1rem;
  --sp-5: 1.5rem;
  --sp-6: 2rem;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 14px;
  --radius-pill: 999px;
  --fs-display: 1.75rem;
  --fs-figure: 1.125rem;
  --fs-body: 0.875rem;
  --fs-label: 0.8125rem;
  --fs-meta: 0.75rem;
  --fs-micro: 0.6875rem;
  --hover-dur: 0.28s;
  --hover-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --face-ui: "Quicksand", "Heebo", system-ui, sans-serif;
  --face-text: "Heebo", "Quicksand", system-ui, sans-serif;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f5f5f6;
    --surface: #ffffff;
    --surface2: #f1f2f4;
    --surface3: #e7e9ec;
    --tile: #eaedf1;
    --tile-edge: rgba(22, 24, 29, 0.08);
    --border: #e6e7ea;
    --border-hover: #c9cdd4;
    --text: #16181d;
    --muted: #5d6675;
    --pos: #007936;
    --neg: #d30022;
    --accent: #8c6000;
    --violet: #3c46c4;
    --chart-pos: #007936;
    --chart-neg: #d30022;
    --chart-committed: #8c6000;
    --chart-balance: #8c6000;
    --tint-green: #d8f2dc;
    --tint-amber: #fae9ce;
    --elev: 0 1px 2px rgba(16, 18, 24, 0.05), 0 1px 3px rgba(16, 18, 24, 0.04);
    --elev-hover: 0 2px 6px rgba(16, 18, 24, 0.08), 0 12px 26px -14px rgba(16, 18, 24, 0.18);
  }
}

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

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--face-text);
  font-size: var(--fs-body);
  font-weight: 400;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: var(--sp-5) var(--sp-4) calc(var(--sp-6) * 2);
}

/* ── Top bar ── */
.topbar {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) 0 var(--sp-5);
}
.mark {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: var(--radius-sm);
  background: var(--accent-bright);
  color: var(--accent-bright-ink);
}
.mark svg {
  width: 1.125rem;
  height: 1.125rem;
}
.brand {
  font-family: var(--face-ui);
  font-size: var(--fs-figure);
  font-weight: 600;
  letter-spacing: -0.02em;
}

/* ── Hero ── */
.hero {
  padding: var(--sp-6) 0;
}
.hero h1 {
  margin: 0;
  max-width: 18ch;
  font-family: var(--face-ui);
  font-size: clamp(2rem, 5.2vw, 3.25rem);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.08;
  text-wrap: balance;
}
.hero p {
  margin: var(--sp-4) 0 0;
  max-width: 48ch;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.6;
}

/* ── Card: background, 1px border, radius, --elev. Every card lifts on hover. ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--elev);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--elev-hover);
}
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--sp-2);
  margin: 0 0 var(--sp-3);
  padding-bottom: var(--sp-3);
  border-bottom: 1px solid var(--border);
  font-family: var(--face-ui);
  font-size: var(--fs-label);
  font-weight: 500;
}
.card-head .cap {
  font-family: var(--face-text);
  font-size: var(--fs-meta);
  font-weight: 400;
  color: var(--muted);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  padding: var(--sp-1) var(--sp-3);
  border-radius: var(--radius-pill);
  font-family: var(--face-ui);
  font-size: var(--fs-meta);
  font-weight: 600;
  line-height: 1.35;
  white-space: nowrap;
}
.pill.sm {
  padding: 0 var(--sp-2);
  font-size: var(--fs-micro);
  font-weight: 500;
}
.pill.quiet {
  background: var(--surface2);
  color: var(--muted);
}
.pill.pos {
  background: var(--tint-green);
  color: var(--pos);
}
.pill.warn {
  background: var(--tint-amber);
  color: var(--accent);
}
.pill.dot::before {
  content: "";
  width: var(--sp-2);
  height: var(--sp-2);
  border-radius: 50%;
  background: currentColor;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: 2.25rem;
  padding: 0 var(--sp-4);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-family: var(--face-ui);
  font-size: var(--fs-body);
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition: filter var(--hover-dur) var(--hover-ease), transform 0.12s;
}
.btn:active {
  transform: scale(0.97);
}
.btn.primary {
  background: var(--accent-bright);
  color: var(--accent-bright-ink);
  font-weight: 600;
}
.btn.primary:hover {
  filter: brightness(1.1);
}
.btn svg {
  width: 1rem;
  height: 1rem;
}

/* ── Featured: the one live app. A card that groups cards → --radius-lg. ── */
.featured {
  padding: var(--sp-5);
  border-radius: var(--radius-lg);
}
.intro {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--sp-4) var(--sp-5);
  margin-top: var(--sp-4);
}
.app-title {
  margin: 0;
  font-family: var(--face-ui);
  font-size: var(--fs-display);
  font-weight: 600;
  letter-spacing: -0.022em;
  line-height: 1.15;
}
.app-desc {
  margin: var(--sp-2) 0 0;
  max-width: 52ch;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.6;
}
.app-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin-top: var(--sp-3);
}
.app-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--sp-2);
}
.app-url {
  color: var(--muted);
  font-size: var(--fs-meta);
}

/* ── Overview preview: the real Overview, drawn from sample data ── */
.preview {
  margin-top: var(--sp-5);
  padding: var(--sp-4);
  border-radius: var(--radius);
  background: var(--tile);
  box-shadow: inset 0 0 0 1px var(--tile-edge);
}
.sec-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--sp-3);
  margin: 0 0 var(--sp-2);
  font-family: var(--face-ui);
  font-size: var(--fs-label);
  font-weight: 500;
  white-space: nowrap;
}
.sec-head + .kpis,
.sec-head + .pcard {
  margin-top: 0;
}
.sec-head .cap {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: var(--face-text);
  font-size: var(--fs-meta);
  font-weight: 400;
  color: var(--muted);
}
.pcard {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--elev);
}

/* KPI row: Balance / Income / Spent share one card, Financial trend is its own.
   The cards share four row tracks (label, figure, sub-line, meter) by subgrid. */
.kpis {
  display: grid;
  grid-template-columns: minmax(0, 9fr) minmax(0, 3fr);
  grid-template-rows: repeat(4, auto);
  column-gap: var(--sp-4);
  margin-bottom: var(--sp-4);
}
.kpi-strip {
  grid-column: 1;
  grid-row: span 4;
  display: grid;
  grid-template-columns: 1.28fr 1fr 1fr;
  grid-template-rows: subgrid;
  column-gap: 1.25rem;
  padding: var(--sp-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--elev);
}
.kpi {
  position: relative;
  display: grid;
  grid-row: span 4;
  grid-template-rows: subgrid;
  grid-template-columns: minmax(0, 1fr);
  min-width: 0;
}
.kpi-strip > .kpi + .kpi::before {
  content: "";
  position: absolute;
  inset-inline-start: calc(-1.25rem / 2);
  top: 0.75rem;
  bottom: 0.75rem;
  width: 1px;
  background: var(--border);
}
.kpi.trend {
  grid-column: 2;
  padding: var(--sp-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--elev);
}
.kpi > .k {
  grid-row: 1;
  align-self: end;
  font-size: var(--fs-meta);
  font-weight: 500;
  color: var(--muted);
}
.kpi > .v {
  grid-row: 2;
  align-self: last baseline;
  margin-top: var(--sp-1);
  font-family: var(--face-ui);
  font-size: var(--fs-display);
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.kpi > .s,
.kpi > .pill {
  grid-row: 3;
  align-self: start;
  margin-top: var(--sp-1);
  font-size: var(--fs-meta);
  color: var(--muted);
}
.kpi > .pill {
  justify-self: start;
  margin-top: 0.3125rem;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kpi > .s {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kpi.trend > .s {
  white-space: normal;
}
.kpi > .ov-meter {
  grid-row: 4;
  min-width: 0;
  margin-top: 0.625rem;
}
.v.green {
  color: var(--pos);
}
.v.red {
  color: var(--neg);
}
.v.gold {
  color: var(--accent);
}

.meter {
  height: var(--sp-2);
  border-radius: var(--radius-pill);
  overflow: hidden;
  background: var(--surface2);
}
.meter > i {
  display: block;
  height: 100%;
  border-radius: var(--radius-pill);
}
.meter.track-violet {
  background: color-mix(in srgb, var(--violet) 55%, transparent);
}
.meter.track-green {
  background: color-mix(in srgb, var(--chart-pos) 55%, transparent);
}
.meter > i.fill-gold {
  background: var(--accent);
}
.meter > i.fill-violet {
  background: var(--violet);
}
.ov-meter-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--sp-1) var(--sp-2);
  margin-top: 0.375rem;
  font-size: var(--fs-micro);
  color: var(--muted);
  min-width: 0;
}
.ov-meter-legend > span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ov-meter-legend b {
  font-weight: 600;
}
.ov-meter-legend b.green {
  color: var(--pos);
}
.ov-meter-legend b.violet {
  color: var(--violet);
}
.ov-meter-legend b.gold {
  color: var(--accent);
}

/* Financial trend sparkline */
.spark-plot {
  position: relative;
}
.spark-svg {
  display: block;
  width: 100%;
  height: 1.5rem;
  overflow: visible;
}
.spark-dot {
  position: absolute;
  width: 0.25rem;
  height: 0.25rem;
  border-radius: 50%;
  background: var(--chart-balance);
  transform: translate(-50%, -50%);
  opacity: 0.85;
}
.spark-dot.est {
  background: var(--surface);
  border: 1px solid var(--chart-balance);
}

/* Spend through the month */
.key {
  display: inline-flex;
  align-items: center;
  gap: 0.875rem;
}
.key > span {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  white-space: nowrap;
}
.key i {
  display: inline-block;
  width: 1rem;
  flex: 0 0 auto;
}
.key .kl {
  height: 2px;
  border-radius: 2px;
  background: var(--chart-neg);
}
.key .kd {
  height: 0;
  border-top: 2px dotted var(--chart-neg);
}
.key .kb {
  height: 0.5rem;
  border-radius: 2px;
  background: color-mix(in srgb, var(--accent) 45%, transparent);
  border-top: 1.5px solid var(--accent);
}
.spend-card {
  padding: var(--sp-4) 1.125rem;
}
.spend {
  position: relative;
}
.spend-plot {
  position: relative;
  animation: sweep 1.4s var(--hover-ease) 0.3s backwards;
}
@keyframes sweep {
  from {
    clip-path: inset(0 100% 0 0);
  }
  to {
    clip-path: inset(0 0 0 0);
  }
}
.spend svg {
  display: block;
  width: 100%;
  height: 220px;
}
.spend-dot,
.spend-knob {
  position: absolute;
  width: 0.5625rem;
  height: 0.5625rem;
  border-radius: 50%;
  background: var(--surface);
  border: 2.5px solid var(--chart-neg);
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.spend-knob {
  opacity: 0;
  transition: opacity 0.2s ease;
}
.spend-hit {
  position: absolute;
  inset: 0 0 18px 0;
  cursor: crosshair;
}
.spend-guide {
  position: absolute;
  top: 0;
  bottom: 18px;
  width: 1px;
  background: var(--border-hover);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.spend-tip {
  position: absolute;
  z-index: 5;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
  background: var(--surface3);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-sm);
  padding: var(--sp-2) 0.6875rem;
  box-shadow: var(--elev-hover);
  white-space: nowrap;
  transform: translate(-50%, -100%);
}
.spend-tip .d {
  font-size: var(--fs-meta);
  font-weight: 500;
  color: var(--muted);
}
.spend-tip .t {
  margin-top: 0.1875rem;
  font-family: var(--face-ui);
  font-size: var(--fs-body);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.spend-tip .x,
.spend-tip .f {
  margin-top: 2px;
  font-size: var(--fs-micro);
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}
.spend-tip .f {
  color: var(--accent);
}
.spend.on .spend-guide,
.spend.on .spend-knob,
.spend.on .spend-tip {
  opacity: 1;
}
.spend-axis {
  position: relative;
  height: 18px;
  margin-top: var(--sp-1);
  color: var(--muted);
  font-size: var(--fs-micro);
}
.spend-axis span {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  white-space: nowrap;
}
.spend-axis span:first-child {
  transform: none;
}
.spend-axis span:last-child {
  transform: translateX(-100%);
}

/* ── The shelf: two empty cards, drawn as the rows they will hold ── */
.shelf {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--sp-4);
  margin-top: var(--sp-4);
}
.shelf .card {
  padding: var(--sp-4);
}
.shelf-body {
  display: grid;
  gap: var(--sp-3);
  margin: var(--sp-4) 0;
}
.ghost-row {
  display: grid;
  grid-template-columns: 4px minmax(0, 1fr) 3rem;
  align-items: center;
  gap: var(--sp-3);
  min-height: 2.25rem;
}
.ghost-row i {
  height: 100%;
  border-radius: 2px;
  background: var(--border);
}
.ghost-row b,
.ghost-row em {
  display: block;
  height: 0.5rem;
  border-radius: 4px;
  background: var(--surface2);
}
.ghost-row em {
  background: var(--surface3);
}
.ghost-row:nth-child(2) b {
  width: 70%;
}
.ghost-row:nth-child(3) b {
  width: 52%;
}
.shelf-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  color: var(--muted);
  font-size: var(--fs-label);
}

.foot {
  margin-top: var(--sp-6);
  color: var(--muted);
  font-size: var(--fs-meta);
}

@media (max-width: 900px) {
  .kpis {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: none;
    row-gap: var(--sp-3);
  }
  .kpi-strip,
  .kpi.trend {
    grid-column: 1;
    grid-row: auto;
    grid-template-rows: none;
  }
  .kpi-strip {
    grid-template-columns: minmax(0, 1fr);
    row-gap: var(--sp-4);
  }
  .kpi {
    grid-row: auto;
    display: flex;
    flex-direction: column;
    grid-template-rows: none;
  }
  .kpi > .ov-meter {
    align-self: stretch;
  }
  .kpi-strip > .kpi + .kpi::before {
    inset-inline: var(--sp-3);
    top: calc(var(--sp-4) / -2);
    bottom: auto;
    width: auto;
    height: 1px;
  }
  .app-actions {
    align-items: flex-start;
  }
  .key {
    display: none;
  }
}
@media (max-width: 640px) {
  .shelf {
    grid-template-columns: minmax(0, 1fr);
  }
  .featured {
    padding: var(--sp-4);
  }
  .preview {
    padding: var(--sp-3);
  }
  .spend svg {
    height: 170px;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition-duration: 0.01ms !important;
  }
  .card:hover {
    transform: none;
  }
  .btn:active {
    transform: none;
  }
}
