/* Ledger — the expense tracker design system.
   Semantic color still lives in app.css (--accent, --danger, palettes).
   This file owns type, paper, elevation, radius, focus, and the
   chrome every screen shares: header, cards, money tiles, controls, tab bar.
   Scene CSS (motion backgrounds) stays in its own files. */

:root{
  --font-ui:"Outfit",-apple-system,BlinkMacSystemFont,"SF Pro Text","Segoe UI",sans-serif;
  --font-display:"Fraunces","Iowan Old Style",Palatino,Georgia,serif;
  --font-mono:ui-monospace,"SF Mono",Menlo,Consolas,monospace;

  --space-1:4px; --space-2:8px; --space-3:12px; --space-4:16px; --space-5:24px;
  --radius-sm:10px; --radius-md:14px; --radius-lg:18px; --radius-pill:999px;
  --radius:16px;

  --ease-out:cubic-bezier(.2,.7,.2,1);
  --dur:160ms;
  --focus:0 0 0 2px var(--bg), 0 0 0 4px var(--accent);

  /* Light paper: sage field, warm-white cards, forest ink. */
  --bg:#eef3ef;
  --card:#fffcf8;
  --text:#1a2620;
  --muted:#5c6b63;
  --border:#d4e0d8;
  --accent:#0f6e4c;
  --accent-soft:#e3f4eb;
  --accent-faint:#f1f8f4;
  --track:#e6eee8;
  --th-bg:#eef3ef;
  --input-bg:#fffcf8;
  --seg-bg:#e5eee7;
  --tabbar-bg:rgba(255,252,248,.88);
  --fcard:#f6faf7;
  /* Primary buttons. Accent is the fill; the label flips to ink when the
     accent is light (see palette overrides below). --blue stays for links
     and filter chips, not for buttons. */
  --on-accent:#fff;
  color-scheme:light;
}

/* Forest night — same palette family as the light paper.
   Other dark palettes keep the surfaces set in app.css. */
[data-theme="dark"][data-dark-palette="forest"]{
  --bg:#0c1210;
  --card:#16211c;
  --fcard:#1c2923;
  --text:#e7f2eb;
  --muted:#93a89c;
  --border:#2c4036;
  --accent:#3dcb8c;
  --accent-soft:#123528;
  --accent-faint:#10281f;
  --track:#1a2822;
  --th-bg:#14201b;
  --input-bg:#101a16;
  --seg-bg:#1a2822;
  --tabbar-bg:rgba(12,18,16,.9);
  --on-accent:#06281a;
  color-scheme:dark;
}
/* These accents are light enough that white label text fails. */
[data-theme="dark"][data-dark-palette="graphite"],
[data-theme="dark"][data-dark-palette="violet"],
[data-theme="dark"][data-dark-palette="ember"],
[data-theme="dark"][data-dark-palette="ocean"],
[data-theme="dark"][data-dark-palette="rose"],
[data-theme="dark"][data-dark-palette="midnight"],
[data-theme="dark"][data-dark-palette="sand"]{
  --on-accent:#14120e;
}
[data-theme="dark"]{ color-scheme:dark; }

body{
  font-family:var(--font-ui);
  font-optical-sizing:auto;
  letter-spacing:-.011em;
  text-rendering:optimizeLegibility;
}
button,input,select,textarea{ font-family:inherit; }
::selection{
  background:color-mix(in srgb, var(--accent) 28%, transparent);
  color:var(--text);
}

/* ---------- header ---------- */
.app-header{
  background:color-mix(in srgb, var(--card) 78%, transparent);
  -webkit-backdrop-filter:saturate(1.35) blur(18px);
  backdrop-filter:saturate(1.35) blur(18px);
  border-bottom:1px solid color-mix(in srgb, var(--border) 80%, transparent);
}
.app-header h1{
  font-family:var(--font-display);
  font-weight:600;
  font-size:22px;
  letter-spacing:-.03em;
  white-space:nowrap;
}
.brand-icon{
  border-radius:9px;
  box-shadow:0 0 0 1px color-mix(in srgb, var(--accent) 28%, transparent);
}
.hdr-news,.user-chip{
  border-radius:var(--radius-pill);
  transition:background var(--dur) var(--ease-out), border-color var(--dur) var(--ease-out), color var(--dur) var(--ease-out);
}
.user-chip{ font-weight:600; letter-spacing:-.01em; white-space:nowrap; }

/* ---------- surfaces ---------- */
html:not(.card-shadow-custom) .card,
html:not(.card-shadow-custom) .stat,
html:not(.card-shadow-custom) .bill-tile{
  box-shadow:
    inset 0 1px 0 color-mix(in srgb, #fff 65%, transparent),
    0 1px 1px rgba(16,28,22,.04),
    0 14px 34px rgba(16,28,22,.05);
}
html[data-theme="dark"]:not(.card-shadow-custom) .card,
html[data-theme="dark"]:not(.card-shadow-custom) .stat,
html[data-theme="dark"]:not(.card-shadow-custom) .bill-tile{
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.05),
    0 1px 1px rgba(0,0,0,.25),
    0 16px 36px rgba(0,0,0,.22);
}
.card{ padding:16px 16px 14px; }
.card h2{
  letter-spacing:-.02em;
  font-weight:650;
}

/* Money tiles: a color spine, then the figure. */
.stat{
  text-align:left;
  padding:14px 12px 12px 14px;
  position:relative;
  overflow:hidden;
  container-type:inline-size;
}
.stat::before{
  content:"";
  position:absolute;
  left:0; top:12px; bottom:12px;
  width:3px;
  border-radius:var(--radius-pill);
  background:var(--accent);
}
#tile-expenses::before{ background:var(--danger); }
#tile-net::before{ background:var(--blue); }
#tile-net:has(.value.pos)::before{ background:var(--accent); }
#tile-net:has(.value.neg)::before{ background:var(--danger); }
.stat .label{
  font-size:11px;
  font-weight:650;
  letter-spacing:.08em;
  text-transform:uppercase;
}
.stat .value,
.paid-card-amt,
.txn .amt,
.datehead .dtot,
.bill-line1 .amt,
.bill-row .amt,
#bill-cal-total{
  font-family:var(--font-display);
  font-weight:500;
  font-variant-numeric:tabular-nums lining-nums;
  letter-spacing:-.03em;
}
.stat .value{
  font-size:clamp(15px, 18cqi, 28px);
  line-height:1.05;
  margin:6px 0 4px;
}
.stat .split{ font-variant-numeric:tabular-nums; }
.pos,.neg,.amt,.value{ font-variant-numeric:tabular-nums; }

.bar{ height:8px; }
.bar > div{ transition:width .35s var(--ease-out); }

/* ---------- controls ---------- */
.btn:not(.ghost):not(.danger),
#updNews .updNews-refresh .ubtn{
  background:var(--accent);
  color:var(--on-accent);
}
.btn,
#updNews .updNews-refresh .ubtn{
  border-radius:13px;
  font-weight:650;
  letter-spacing:-.015em;
  box-shadow:inset 0 1px 0 rgba(255,255,255,.2);
  transition:transform var(--dur) var(--ease-out), filter var(--dur) var(--ease-out);
}
.btn.ghost{ box-shadow:none; }
#updBar{
  background:var(--accent);
  color:var(--on-accent);
}
#updBar .ubtn-bar,
#updBar .card-x{
  color:var(--on-accent);
  background:color-mix(in srgb, var(--on-accent) 14%, transparent);
  border-color:color-mix(in srgb, var(--on-accent) 42%, transparent);
}
.btn:active:not(:disabled){ transform:translateY(1px); }
.btn:focus-visible,
.hdr-news:focus-visible,
.user-chip:focus-visible,
.tabbar button:focus-visible,
.linkbtn:focus-visible{
  outline:none;
  box-shadow:var(--focus);
}
.seg{ border-radius:14px; padding:3px; }
.seg button{ border-radius:11px; letter-spacing:-.01em; }
.seg button.on{
  box-shadow:
    inset 0 1px 0 color-mix(in srgb, #fff 70%, transparent),
    0 1px 2px rgba(16,28,22,.08);
}
input:focus,select:focus,textarea:focus{
  outline:2px solid color-mix(in srgb, var(--blue) 45%, transparent);
  outline-offset:1px;
  border-color:var(--blue);
}
.allchip,.catchip{ letter-spacing:-.01em; }

/* ---------- tab bar ---------- */
.tabbar{
  background:var(--tabbar-bg);
  -webkit-backdrop-filter:saturate(1.4) blur(18px);
  backdrop-filter:saturate(1.4) blur(18px);
}
.tabbar button{
  font-weight:600;
  letter-spacing:-.01em;
  border-radius:16px;
  transition:background var(--dur) var(--ease-out), color var(--dur) var(--ease-out);
}
.tabbar button.on{
  color:var(--accent);
  background:color-mix(in srgb, var(--accent) 16%, transparent);
  box-shadow:inset 0 0 0 1px color-mix(in srgb, var(--accent) 42%, transparent);
}
.tabbar button.on:focus-visible{
  box-shadow:var(--focus), inset 0 0 0 1px color-mix(in srgb, var(--accent) 42%, transparent);
}
.tab-drag-ghost{
  background:color-mix(in srgb, var(--accent) 16%, var(--card));
  box-shadow:
    inset 0 0 0 1px color-mix(in srgb, var(--accent) 42%, transparent),
    0 12px 28px rgba(0,0,0,.28);
}

/* ---------- motion ---------- */
.screen{ animation:ds-enter .32s var(--ease-out); }
@keyframes ds-enter{
  from{ opacity:0; transform:translateY(6px); }
  to{ opacity:1; transform:none; }
}
@media (prefers-reduced-motion:reduce){
  .screen{ animation:none; }
  .btn,.tabbar button,.hdr-news,.user-chip,.bar > div{ transition:none; }
}
@media (max-width:560px){
  .app-header h1{ font-size:16px; }
  .stat{ padding:10px 8px 8px 11px; }
  .stat::before{ top:8px; bottom:8px; }
}
