/* ==========================================================================
   Design tokens — brand green #3E7A5A (from the Schedule logo) and its ramp.
   ========================================================================== */
:root {
  --g50:  #EEF5F1;
  --g100: #D9EBE1;
  --g200: #BFDCCB;
  --g300: #94C2A8;
  --g400: #62A07E;
  --g500: #3E7A5A;   /* brand primary */
  --g600: #33694D;
  --g700: #2A5840;
  --g800: #1F4431;
  --g900: #153022;

  --bg: #F4F6F3;
  --surface: #FFFFFF;
  --surface-2: #EDF1EE;
  --text: #15241C;
  --text-2: #43524A;
  --muted: #68766E;
  --line: #DFE6E1;
  --grid: #E8EDE9;

  --primary: var(--g500);
  --primary-strong: var(--g700);
  --primary-soft: var(--g50);
  --on-primary: #FFFFFF;
  --focus: #1F7A55;

  /* chart marks (validated for colour-blind separation: see README) */
  --series-income: #2F8659;
  --series-expense: #D9892B;
  --series-muted: #C9D3CD;

  /* status */
  --ok: #2F8659;
  --warn: #9A5B00;
  --warn-fill: #D9892B;
  --warn-bg: #FFF4E0;
  --danger: #B3261E;
  --danger-fill: #C8412F;
  --danger-bg: #FCEBE8;

  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(21, 36, 28, .06), 0 4px 16px rgba(21, 36, 28, .05);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0F1512;
    --surface: #18211C;
    --surface-2: #202B25;
    --text: #E6EDE8;
    --text-2: #B6C4BB;
    --muted: #8E9D94;
    --line: #2B3731;
    --grid: #26312B;
    --primary: #3E8A62;
    --primary-strong: #86CBA5;
    --primary-soft: #1C2F24;
    --focus: #86CBA5;
    --series-income: #48A274;
    --series-expense: #C97A1E;
    --series-muted: #3A4640;
    --ok: #6CC096;
    --warn: #F0B35A;
    --warn-fill: #C97A1E;
    --warn-bg: #33270F;
    --danger: #FF9C8F;
    --danger-fill: #D65A48;
    --danger-bg: #3A1D19;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0F1512;
  --surface: #18211C;
  --surface-2: #202B25;
  --text: #E6EDE8;
  --text-2: #B6C4BB;
  --muted: #8E9D94;
  --line: #2B3731;
  --grid: #26312B;
  --primary: #3E8A62;
  --primary-strong: #86CBA5;
  --primary-soft: #1C2F24;
  --focus: #86CBA5;
  --series-income: #48A274;
  --series-expense: #C97A1E;
  --series-muted: #3A4640;
  --ok: #6CC096;
  --warn: #F0B35A;
  --warn-fill: #C97A1E;
  --warn-bg: #33270F;
  --danger: #FF9C8F;
  --danger-fill: #D65A48;
  --danger-bg: #3A1D19;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  color-scheme: dark;
}

/* ==========================================================================
   Base
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3 { margin: 0; line-height: 1.25; }
p { margin: 0; }
a { color: var(--primary-strong); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.boot { display: grid; place-items: center; min-height: 100vh; color: var(--muted); }
.icon { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ==========================================================================
   App shell: top bar + bottom nav (mobile), sidebar (desktop)
   ========================================================================== */
.shell { min-height: 100vh; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 8px;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid transparent;
}
.topbar.scrolled { border-bottom-color: var(--line); }
.topbar h1 { font-size: 19px; font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; color: var(--primary-strong); letter-spacing: .01em; }
.brand img { width: 28px; height: 28px; border-radius: 8px; }
.icon-btn {
  position: relative; display: inline-grid; place-items: center;
  width: 40px; height: 40px; border-radius: 12px; border: 0; background: transparent; color: var(--text-2); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn .dot {
  position: absolute; top: 6px; right: 6px; min-width: 17px; height: 17px; padding: 0 4px;
  border-radius: 9px; background: var(--danger-fill); color: #fff; font-size: 10.5px; font-weight: 700; line-height: 17px; text-align: center;
  box-shadow: 0 0 0 2px var(--bg);
}
.avatar {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  background: var(--g100); color: var(--g800); font-weight: 700; font-size: 14px; border: 0; cursor: pointer; text-decoration: none; flex: none;
}
:root[data-theme="dark"] .avatar { background: var(--g800); color: var(--g100); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .avatar { background: var(--g800); color: var(--g100); } }

main.page { padding: 4px 16px calc(96px + var(--safe-bottom)); max-width: 640px; margin: 0 auto; }

.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: end;
  padding: 6px 6px calc(6px + var(--safe-bottom));
  background: var(--surface); border-top: 1px solid var(--line);
}
.bottomnav a {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 0; font-size: 11px; font-weight: 600; color: var(--muted); text-decoration: none; border-radius: 10px;
}
.bottomnav a.active { color: var(--primary-strong); }
.bottomnav a .icon { width: 22px; height: 22px; }
.bottomnav .fab {
  justify-self: center; width: 54px; height: 54px; margin-top: -22px; border-radius: 18px;
  background: var(--primary); color: var(--on-primary); display: grid; place-items: center;
  box-shadow: 0 6px 18px rgba(42, 88, 64, .35); padding: 0;
}
.bottomnav .fab .icon { width: 26px; height: 26px; stroke-width: 2.2; }

.sidenav { display: none; }

@media (min-width: 960px) {
  .shell { display: grid; grid-template-columns: 240px 1fr; }
  .bottomnav { display: none; }
  .sidenav {
    display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh;
    padding: 20px 14px; border-right: 1px solid var(--line); background: var(--surface);
  }
  .sidenav .brand { padding: 4px 10px 18px; font-size: 17px; }
  .sidenav a {
    display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px;
    color: var(--text-2); text-decoration: none; font-weight: 600;
  }
  .sidenav a:hover { background: var(--surface-2); }
  .sidenav a.active { background: var(--primary-soft); color: var(--primary-strong); }
  .sidenav .add-btn { margin: 8px 0 14px; justify-content: center; }
  .sidenav .section-label { margin: 18px 12px 4px; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
  .sidenav .soon { margin-left: auto; font-size: 10.5px; font-weight: 700; color: var(--muted); background: var(--surface-2); border-radius: 6px; padding: 1px 6px; }
  main.page { max-width: 1080px; padding: 8px 32px 48px; }
  .topbar { padding-left: 32px; padding-right: 32px; }
  .topbar .brand { display: none; }
}

/* ==========================================================================
   Building blocks
   ========================================================================== */
.card { background: var(--surface); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.card + .card, .stack > * + * { margin-top: 12px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.card-head h2 { font-size: 15.5px; font-weight: 700; }
.card-head .sub { font-size: 12.5px; color: var(--muted); }
.section-title { font-size: 13px; font-weight: 700; color: var(--muted); letter-spacing: .02em; margin: 22px 2px 8px; }

.grid-2 { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); }
.grid-2 > * { min-width: 0; }
.grid-2 > .card + .card { margin-top: 0; }
@media (min-width: 960px) {
  .grid-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
  .span-2 { grid-column: 1 / -1; }
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: 12px; border: 1px solid transparent;
  font-weight: 650; font-size: 15px; cursor: pointer; text-decoration: none; white-space: nowrap;
  background: var(--surface-2); color: var(--text);
}
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover:not(:disabled) { background: var(--g600); }
.btn-ghost { background: transparent; color: var(--primary-strong); }
.btn-outline { background: transparent; border-color: var(--line); }
.btn-danger { background: var(--danger-bg); color: var(--danger); }
.btn-block { width: 100%; }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: 13.5px; border-radius: 10px; }
.link-btn { background: none; border: 0; padding: 0; color: var(--primary-strong); font-weight: 600; cursor: pointer; font-size: inherit; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > span { font-size: 13px; font-weight: 600; color: var(--text-2); }
.field .hint { font-size: 12.5px; color: var(--muted); }
.input, select.input, textarea.input {
  width: 100%; min-height: 46px; padding: 10px 12px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface); font-size: 16px;   /* 16px stops iOS zoom-on-focus */
}
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 22%, transparent); }
.input[aria-invalid="true"] { border-color: var(--danger); }
.input-group { position: relative; }
.input-group .input { padding-right: 48px; }
.input-group .reveal { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; min-width: 0; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; color: var(--text-2); }
.check input { width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--primary); flex: none; }

.alert { padding: 11px 14px; border-radius: 12px; font-size: 14px; margin-bottom: 14px; display: flex; gap: 10px; align-items: flex-start; }
.alert .icon { margin-top: 1px; }
.alert-error { background: var(--danger-bg); color: var(--danger); }
.alert-info { background: var(--primary-soft); color: var(--primary-strong); }
.alert-warn { background: var(--warn-bg); color: var(--warn); }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 6px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; min-height: 36px; padding: 0 14px; border-radius: 18px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text-2); font-weight: 600; font-size: 13.5px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
}
.chip .icon { width: 16px; height: 16px; }
.chip[aria-pressed="true"] { background: var(--primary-soft); border-color: var(--primary); color: var(--primary-strong); }

.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--surface-2); padding: 4px; border-radius: 12px; gap: 4px; }
.segmented button { min-height: 38px; border: 0; background: transparent; border-radius: 9px; font-weight: 650; color: var(--text-2); cursor: pointer; }
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.empty { text-align: center; padding: 28px 12px; color: var(--muted); font-size: 14px; }
.empty .icon { width: 36px; height: 36px; margin: 0 auto 8px; display: block; color: var(--g300); }

.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 8px; font-size: 12px; font-weight: 650; }
.pill-ok { background: var(--primary-soft); color: var(--primary-strong); }
.pill-warn { background: var(--warn-bg); color: var(--warn); }
.pill-danger { background: var(--danger-bg); color: var(--danger); }
.pill .icon { width: 13px; height: 13px; stroke-width: 2.4; }

/* month switcher */
.monthbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 4px 0 12px; }
.monthbar .label { font-weight: 700; font-size: 15px; }

/* ==========================================================================
   Overview
   ========================================================================== */
.hero { background: linear-gradient(150deg, var(--g700), var(--g900)); color: #fff; border-radius: 18px; padding: 18px 18px 16px; box-shadow: var(--shadow); }
.hero .label { font-size: 13px; opacity: .85; font-weight: 600; }
.hero .value { font-size: clamp(30px, 9vw, 44px); font-weight: 750; letter-spacing: -.02em; margin: 2px 0 12px; line-height: 1.1; }
.hero-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.hero-stat { background: rgba(255, 255, 255, .1); border-radius: 12px; padding: 10px 12px; }
.hero-stat .k { font-size: 12px; opacity: .85; display: flex; align-items: center; gap: 6px; }
.hero-stat .v { font-weight: 700; font-size: 16px; margin-top: 2px; }
.hero-stat .sw { width: 8px; height: 8px; border-radius: 50%; }
.sw-income { background: #7ED0A5; }
.sw-expense { background: #F2B061; }
.hero .net { margin-top: 10px; font-size: 13px; opacity: .9; }

.meter { height: 10px; border-radius: 6px; background: var(--g100); overflow: hidden; }
:root[data-theme="dark"] .meter { background: var(--g800); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .meter { background: var(--g800); } }
.meter > i { display: block; height: 100%; border-radius: 6px; background: var(--primary); }
.meter.warn { background: var(--warn-bg); }
.meter.warn > i { background: var(--warn-fill); }
.meter.over { background: var(--danger-bg); }
.meter.over > i { background: var(--danger-fill); }

.kv { display: flex; justify-content: space-between; gap: 8px; font-size: 13.5px; color: var(--text-2); margin-top: 8px; }
.kv b { color: var(--text); font-weight: 650; }

.list { list-style: none; margin: 0; padding: 0; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-top: 1px solid var(--line); }
.list-item:first-child { border-top: 0; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .meta { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .amt { font-weight: 700; text-align: right; white-space: nowrap; }
.list-item.tap { cursor: pointer; border-radius: 10px; }
.list-item.tap:hover { background: var(--surface-2); }
.amt-income { color: var(--primary-strong); }
.cat-ico {
  width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; flex: none;
  background: var(--surface-2); color: var(--text-2);
}
.cat-ico.income { background: var(--primary-soft); color: var(--primary-strong); }

/* ==========================================================================
   Charts
   ========================================================================== */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .axis text, .chart .lbl { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.chart .lbl-strong { fill: var(--text); font-size: 11.5px; font-weight: 650; font-family: var(--font); }
.chart .gridline { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.chart .baseline { stroke: var(--line); stroke-width: 1; shape-rendering: crispEdges; }
.chart .bar-income { fill: var(--series-income); }
.chart .bar-expense { fill: var(--series-expense); }
.chart .bar-muted { fill: var(--series-muted); }
.chart .avg { stroke: var(--text-2); stroke-width: 1.5; stroke-dasharray: 4 4; }
.chart .hover-band { fill: var(--text); opacity: 0; }
.chart .hit:hover + .hover-band, .chart .hit.on + .hover-band { opacity: .05; }
.chart .hit { fill: transparent; cursor: pointer; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12.5px; color: var(--text-2); margin-bottom: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.l-income { background: var(--series-income); }
.l-expense { background: var(--series-expense); }
.legend .l-avg { width: 14px; height: 0; border-top: 1.5px dashed var(--text-2); border-radius: 0; }
.tooltip {
  position: absolute; z-index: 5; pointer-events: none; min-width: 120px;
  background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 10px; font-size: 12.5px; box-shadow: 0 6px 20px rgba(0, 0, 0, .12);
}
.tooltip .t { font-weight: 700; margin-bottom: 4px; }
.tooltip .r { display: flex; align-items: center; gap: 6px; justify-content: space-between; }
.tooltip .r span { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); }
.tooltip i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.table-view { width: 100%; border-collapse: collapse; font-size: 13px; }
.table-view th, .table-view td { text-align: left; padding: 6px 4px; border-top: 1px solid var(--line); }
.table-view td.r, .table-view th.r { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { max-height: 280px; overflow: auto; }

.hbar-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; align-items: center; padding: 6px 0; }
.hbar-row .name { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-row .val { font-size: 13px; font-weight: 650; }
.hbar-row .track { grid-column: 1 / -1; height: 8px; }
.hbar-row .track > i { display: block; height: 8px; border-radius: 0 4px 4px 0; background: var(--series-expense); min-width: 2px; }

/* ==========================================================================
   Entry form (add transaction)
   ========================================================================== */
.amount-box { text-align: center; padding: 18px 0 8px; }
.amount-box label { font-size: 13px; color: var(--muted); font-weight: 600; }
.amount-input {
  width: 100%; border: 0; background: transparent; text-align: center; outline: none;
  font-size: 40px; font-weight: 750; letter-spacing: -.02em; padding: 4px 0; color: var(--text);
}
.amount-input::placeholder { color: var(--line); }
.cat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
@media (min-width: 520px) { .cat-grid { grid-template-columns: repeat(5, 1fr); } }
.cat-opt {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 4px; min-height: 76px;
  border-radius: 12px; border: 1px solid var(--line); background: var(--surface); cursor: pointer;
  font-size: 11.5px; font-weight: 600; color: var(--text-2); text-align: center; line-height: 1.2;
}
.cat-opt[aria-pressed="true"] { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-strong); }

/* ==========================================================================
   Checklist
   ========================================================================== */
.todo { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.todo:first-child { border-top: 0; }
.todo .box {
  width: 28px; height: 28px; border-radius: 9px; border: 2px solid var(--g300); background: transparent; flex: none;
  display: grid; place-items: center; cursor: pointer; color: #fff; padding: 0;
}
.todo .box .icon { width: 16px; height: 16px; stroke-width: 3; opacity: 0; }
.todo.done .box { background: var(--primary); border-color: var(--primary); }
.todo.done .box .icon { opacity: 1; }
.todo.done .title { color: var(--muted); text-decoration: line-through; }
.todo .grow { flex: 1; min-width: 0; cursor: pointer; }
.todo .title { font-weight: 600; }
.todo .meta { font-size: 12.5px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; }
.icon.small-ico { width: 13px; height: 13px; vertical-align: -2px; }
.todo .amt { font-weight: 650; white-space: nowrap; font-size: 14px; }

/* ==========================================================================
   Budget
   ========================================================================== */
.alloc { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.alloc > div { background: var(--surface-2); border-radius: 12px; padding: 10px; }
.alloc .k { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.alloc .v { font-weight: 700; font-size: 14.5px; margin-top: 2px; overflow-wrap: anywhere; }
.budget-row { padding: 12px 0; border-top: 1px solid var(--line); }
.budget-row:first-child { border-top: 0; }
.budget-row .top { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.budget-row .top .grow { flex: 1; min-width: 0; }
.budget-row .name { font-weight: 600; }
.budget-row .nums { font-size: 12.5px; color: var(--muted); }
.budget-row .right { text-align: right; font-size: 13px; }
.budget-edit { display: grid; grid-template-columns: 1fr 150px; gap: 10px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.budget-edit .row-name { font-size: 14px; }
.hbar-row .track > i.guide { background: var(--primary); }
.budget-edit .input { min-height: 40px; text-align: right; }

/* ==========================================================================
   Sheet (bottom drawer on mobile, dialog on desktop), toast, banner
   ========================================================================== */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(10, 18, 14, .45); z-index: 50; display: flex; align-items: flex-end; justify-content: center; animation: fade .15s ease; }
.sheet {
  width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; background: var(--surface);
  border-radius: 20px 20px 0 0; padding: 8px 18px calc(18px + var(--safe-bottom)); animation: up .2s ease;
}
.sheet .grabber { width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 4px auto 12px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.sheet-head h2 { font-size: 18px; }
.sheet-actions { margin-top: 18px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
@media (min-width: 640px) {
  .sheet-backdrop { align-items: center; }
  .sheet { border-radius: 20px; padding-bottom: 20px; }
  .sheet .grabber { display: none; }
}
@keyframes up { from { transform: translateY(24px); opacity: .5; } }
@keyframes fade { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .sheet, .sheet-backdrop { animation: none; } }

#toast-root { position: fixed; left: 0; right: 0; bottom: calc(86px + var(--safe-bottom)); display: flex; justify-content: center; z-index: 60; pointer-events: none; padding: 0 16px; }
.toast { background: var(--g900); color: #fff; padding: 11px 16px; border-radius: 12px; font-size: 14px; box-shadow: 0 8px 24px rgba(0, 0, 0, .2); pointer-events: auto; display: flex; gap: 12px; align-items: center; max-width: 520px; }
.toast .link-btn { color: #9FE0BB; }
.toast.error { background: #6E1A14; }
@media (min-width: 960px) { #toast-root { bottom: 24px; } }

.page-banners.pad { max-width: 640px; margin: 0 auto; padding: 0 16px; }
@media (min-width: 960px) { .page-banners.pad { max-width: 1080px; padding: 0 32px; } }
.banner { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: var(--primary-soft); color: var(--primary-strong); font-size: 13.5px; border-radius: 12px; margin: 8px 0 4px; }
.banner .grow { flex: 1; }

/* ==========================================================================
   Auth pages
   ========================================================================== */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: radial-gradient(120% 60% at 50% 0%, var(--g100), var(--bg) 70%); }
:root[data-theme="dark"] .auth { background: var(--bg); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .auth { background: var(--bg); } }
.auth-card { width: 100%; max-width: 400px; }
.auth-card .brand { justify-content: center; font-size: 20px; margin-bottom: 18px; }
.auth-card .brand img { width: 40px; height: 40px; border-radius: 12px; }
.auth-card h1 { font-size: 22px; margin-bottom: 4px; }
.auth-card .lead { color: var(--muted); font-size: 14px; margin-bottom: 18px; }
.forgot-row { display: flex; justify-content: flex-end; margin-top: -4px; }
.auth-foot { text-align: center; margin-top: 16px; font-size: 14px; color: var(--text-2); }
.pw-meter { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-top: 2px; }
.pw-meter i { height: 4px; border-radius: 2px; background: var(--line); }
.pw-meter[data-score="1"] i:nth-child(-n+1) { background: var(--danger-fill); }
.pw-meter[data-score="2"] i:nth-child(-n+2) { background: var(--warn-fill); }
.pw-meter[data-score="3"] i:nth-child(-n+3) { background: var(--g400); }
.pw-meter[data-score="4"] i { background: var(--primary); }

/* settings */
.menu a, .menu button.menu-item {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 13px 4px; border: 0; background: none;
  border-top: 1px solid var(--line); color: var(--text); text-decoration: none; font-weight: 550; cursor: pointer; text-align: left;
}
.menu > :first-child { border-top: 0; }
.menu .chev { margin-left: auto; color: var(--muted); }
.legal h2 { font-size: 16px; margin: 20px 0 6px; }
.legal p, .legal li { color: var(--text-2); font-size: 14.5px; }
.legal ul { padding-left: 20px; }
.list-item .meta.wrap { white-space: normal; }
.entry > button[type="submit"] { position: sticky; bottom: 8px; z-index: 2; box-shadow: 0 6px 18px rgba(42, 88, 64, .3); }
/* Stack the three figures whenever the card itself is narrow (phone, or a half-width card on desktop). */
.card { container-type: inline-size; }
@container (max-width: 460px) {
  .alloc { grid-template-columns: 1fr; gap: 0; background: var(--surface-2); border-radius: 12px; padding: 4px 12px; }
  .alloc > div { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; background: none; border-radius: 0; padding: 8px 0; }
  .alloc > div + div { border-top: 1px solid var(--line); }
  .alloc .k { font-size: 13px; }
  .alloc .v { margin-top: 0; white-space: nowrap; }
}

/* ==========================================================================
   Finance sub-tabs
   ========================================================================== */
.subnav {
  display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none;
  padding: 0 16px 8px; max-width: 640px; margin: 0 auto;
}
.subnav::-webkit-scrollbar { display: none; }
.subnav a {
  flex: none; padding: 7px 14px; border-radius: 18px; font-size: 13.5px; font-weight: 650;
  color: var(--text-2); text-decoration: none; background: var(--surface); border: 1px solid var(--line);
}
.subnav a.active { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
@media (min-width: 960px) {
  .subnav { display: none; }
  .sidenav a[data-sub] { padding-left: 12px; }
}

/* ==========================================================================
   Jadwal: hero clock, prayer strip, timeline, calendar
   ========================================================================== */
.hero-jadwal .label { margin-bottom: 2px; }
.hero-jadwal .clock { font-size: clamp(34px, 11vw, 48px); font-weight: 750; letter-spacing: -.02em; line-height: 1.1; }
.hero-jadwal .clock small { font-size: 14px; font-weight: 600; opacity: .8; letter-spacing: 0; }
.hero-jadwal .dates { font-size: 14px; opacity: .92; margin-top: 6px; line-height: 1.45; }
.next-prayer {
  display: flex; align-items: center; gap: 8px; margin-top: 12px; padding: 9px 12px;
  background: rgba(255, 255, 255, .12); border-radius: 12px; font-size: 14px;
}
.datenav { display: flex; align-items: center; gap: 8px; margin-top: 14px; }
.datenav .on-dark { color: #fff; background: rgba(255, 255, 255, .12); }
.datenav .on-dark:hover { background: rgba(255, 255, 255, .2); }
.datenav .btn.on-dark { border: 0; }
.btn-light { background: #fff; color: var(--g800); border: 0; }

.prayer-strip { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.ps { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 9px 2px; border-radius: 12px; background: var(--surface-2); }
.ps-name { font-size: 12px; font-weight: 600; color: var(--muted); }
.ps-time { font-size: 16px; font-weight: 750; }
.ps.past { opacity: .5; }
.ps.next { background: var(--primary); color: var(--on-primary); }
.ps.next .ps-name { color: inherit; opacity: .85; }
.prayer-strip.compact .ps { padding: 7px 2px; }
.prayer-strip.compact .ps-time { font-size: 14.5px; }

.tl-key { width: 10px; height: 10px; display: inline-block; }
.tl-key.fardhu, .tl-item.fardhu .tl-node { background: var(--primary-strong); border-radius: 50%; }
.tl-key.sunnah, .tl-item.sunnah .tl-node { background: var(--surface); border: 2.5px solid var(--g400); border-radius: 50%; }
.tl-key.personal, .tl-item.personal .tl-node { background: var(--warn-fill); border-radius: 3px; }

.timeline { margin-top: 4px; }
.tl-item { display: grid; grid-template-columns: 46px 18px minmax(0, 1fr) auto; column-gap: 8px; align-items: stretch; }
.tl-time { font-weight: 700; font-size: 14px; padding-top: 10px; text-align: right; }
.tl-rail { position: relative; display: flex; justify-content: center; }
.tl-rail::before { content: ""; position: absolute; top: 0; bottom: 0; width: 2px; background: var(--line); }
.tl-item:first-child .tl-rail::before { top: 16px; }
.tl-item:last-child .tl-rail::before { bottom: calc(100% - 16px); }
.tl-node { position: relative; z-index: 1; width: 12px; height: 12px; margin-top: 12px; flex: none; box-shadow: 0 0 0 3px var(--surface); }
.tl-body { padding: 8px 0 12px; min-width: 0; }
.tl-body.tap { cursor: pointer; border-radius: 10px; }
.tl-body.tap:hover .tl-title { text-decoration: underline; }
.tl-title { font-weight: 650; }
.tl-item.fardhu .tl-title { color: var(--primary-strong); }
.tl-sub { font-size: 12.5px; color: var(--muted); }
.tl-note { font-size: 13px; color: var(--text-2); margin-top: 4px; background: var(--surface-2); border-radius: 8px; padding: 6px 8px; white-space: pre-line; }
.tl-item.past { opacity: .5; }
.tl-item.next .tl-node { box-shadow: 0 0 0 3px var(--surface), 0 0 0 6px color-mix(in srgb, var(--primary) 35%, transparent); }
.tl-item.next .tl-time { color: var(--primary-strong); }
.timeline.compact .tl-body { padding-bottom: 8px; }
.tl-item > .muted { padding-top: 10px; }
.bell-btn {
  align-self: start; margin-top: 4px; width: 38px; height: 38px; border-radius: 10px; border: 0; background: transparent;
  color: var(--muted); display: grid; place-items: center; cursor: pointer; opacity: .7;
}
.bell-btn:hover { background: var(--surface-2); opacity: 1; }
.bell-btn.on { color: var(--primary-strong); opacity: 1; }
.bell-btn .icon { width: 19px; height: 19px; }

.desktop-only { display: none; }
@media (min-width: 960px) {
  .desktop-only { display: block; }
  .grid-2.jadwal { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); }
}

.cal-head { display: flex; align-items: center; justify-content: space-between; text-align: center; margin-bottom: 8px; }
.cal-title { font-weight: 700; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; text-align: center; }
.cal-dow span { font-size: 11.5px; font-weight: 700; color: var(--muted); padding: 4px 0; }
.cal-day {
  position: relative; aspect-ratio: 1; min-height: 36px; border: 0; border-radius: 10px; background: transparent;
  font-weight: 600; font-size: 14px; cursor: pointer; color: var(--text);
}
.cal-day:hover { background: var(--surface-2); }
.cal-dow .sun, .cal-day.sun { color: var(--danger); }
.cal-day.today { box-shadow: inset 0 0 0 1.5px var(--primary); }
.cal-day.selected { background: var(--primary); color: var(--on-primary); }
.cal-day.holiday::after { content: ""; position: absolute; left: 50%; bottom: 5px; width: 5px; height: 5px; margin-left: -2.5px; border-radius: 50%; background: var(--primary); }
.cal-day.selected.holiday::after { background: #fff; }
.cal-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--primary); }
.sun-key { color: var(--danger); }

/* settings form */
.calib-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.calib-grid label { display: flex; flex-direction: column; gap: 4px; }
.calib-grid .input { padding: 8px 6px; text-align: center; min-height: 42px; }
@media (max-width: 420px) { .calib-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.sunnah-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.sunnah-row:first-of-type { border-top: 0; }
.sunnah-row .grow { flex: 1; min-width: 0; }
.sunnah-row .offset { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; width: 104px; flex: none; }
.sunnah-row .offset .input { min-height: 38px; text-align: center; padding: 6px; }
.sticky-save { position: sticky; bottom: calc(80px + var(--safe-bottom)); z-index: 5; box-shadow: 0 6px 18px rgba(42, 88, 64, .3); }
@media (min-width: 960px) { .sticky-save { bottom: 16px; } }
.preview { background: var(--surface-2); border-radius: 12px; padding: 10px; }
.preview .ps { background: var(--surface); }
.subnav a { flex: 1 0 auto; text-align: center; padding: 7px 8px; font-size: 13px; }
