/* Budget Planner · PZMEER LLC */
:root {
  color-scheme: light;
  --bg: #f5f6fa; --card: #fff; --muted-card: #f9fafc; --border: #e3e6ee;
  --fg: #1f2433; --muted: #5b6275; --on-primary: #fff;
  --primary: #4c63e0; --secondary: #6e5cc7;
  --success: #1b7f53; --warning: #a85a0c; --danger: #c43d3d;
  --s1: #2a78d6; --s2: #eb6834;
  --shadow: 0 1px 2px rgb(16 24 40 / .04), 0 1px 3px rgb(16 24 40 / .06);
  --shadow-lg: 0 12px 40px rgb(16 24 40 / .16);
  --r: 14px; --r-sm: 10px;
  --sidebar: 236px;
}
[data-theme="violet"]   { --primary: #7c4ddb; --secondary: #c04fa0; }
[data-theme="teal"]     { --primary: #0f8b8d; --secondary: #2a78d6; }
[data-theme="emerald"]  { --primary: #1b8a5a; --secondary: #0f8b8d; }
[data-theme="rose"]     { --primary: #d6406e; --secondary: #eb6834; }
[data-theme="sunset"]   { --primary: #e0662b; --secondary: #d6406e; }
[data-theme="graphite"] { --primary: #3f4654; --secondary: #6b7280; }
.dark {
  color-scheme: dark;
  --bg: #0f121a; --card: #161a24; --muted-card: #1b2030; --border: #272d3d;
  --fg: #e8eaf0; --muted: #9aa1b2;
  --success: #4cc18f; --warning: #f0a65a; --danger: #f07f7f;
  --s1: #3987e5; --s2: #d95926;
  --shadow: 0 1px 2px rgb(0 0 0 / .3); --shadow-lg: 0 12px 40px rgb(0 0 0 / .5);
}
.dark[data-theme="graphite"] { --primary: #9aa3b5; --on-primary: #10131b; }
:root {
  --primary-soft: color-mix(in srgb, var(--primary) 9%, var(--card));
  --success-soft: color-mix(in srgb, var(--success) 12%, var(--card));
  --warning-soft: color-mix(in srgb, var(--warning) 12%, var(--card));
  --danger-soft: color-mix(in srgb, var(--danger) 11%, var(--card));
}
.dark { --primary-soft: color-mix(in srgb, var(--primary) 18%, var(--card)); }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 14.5px/1.5 "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
svg { display: block; }
.num, .money { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.pos { color: var(--success); }
.neg { color: var(--danger); }
.warn-text { color: var(--warning); }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---------- Layout ---------- */
.demo-banner {
  position: sticky; top: 0; z-index: 30; text-align: center; font-size: .86rem; font-weight: 500;
  padding: .45rem 1rem; background: var(--primary); color: var(--on-primary);
}
.demo-banner a { color: inherit; text-decoration: underline; margin-left: .4rem; font-weight: 600; }
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar); flex: none; position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: var(--card); border-right: 1px solid var(--border);
  padding: 1.1rem .8rem; display: flex; flex-direction: column; gap: .9rem; z-index: 40;
}
.demo-banner ~ .layout .sidebar { top: 34px; height: calc(100vh - 34px); }
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 700; font-size: 1rem; color: var(--fg); padding: 0 .3rem; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; flex: none;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
}
.brand-mark svg { width: 20px; height: 20px; fill: none; stroke: #fff; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
#nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: .7rem; padding: .52rem .7rem; border-radius: var(--r-sm);
  color: var(--muted); font-weight: 500; position: relative;
}
.nav-item:hover { background: var(--muted-card); color: var(--fg); text-decoration: none; }
.nav-item.on { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.nav-item svg { width: 18px; height: 18px; flex: none; }
.nav-item .count {
  margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; font-size: .72rem; font-weight: 700;
  display: grid; place-items: center; background: var(--danger); color: #fff;
}
.side-foot { margin-top: auto; display: grid; gap: .6rem; font-size: .8rem; color: var(--muted); text-align: center; padding-top: .6rem; }
.plan-chip {
  display: flex; align-items: center; justify-content: space-between; gap: .5rem; text-align: left;
  border: 1px solid var(--border); border-radius: var(--r-sm); padding: .55rem .7rem; background: var(--muted-card); color: var(--fg);
}
.plan-chip:hover { text-decoration: none; border-color: var(--primary); }
.get-app { display: block; padding: .5rem; border-radius: var(--r-sm); font-weight: 600; color: var(--fg); }
.get-app:hover { background: var(--muted-card); text-decoration: none; }
.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
main { width: 100%; max-width: 1000px; margin: 0 auto; padding: 1.9rem 1.6rem 6rem; outline: none; }
main:focus, main:focus-visible { outline: none; }
.topbar { display: none; }
.scrim { display: none; }
.fab { display: none; }
.loading { color: var(--muted); padding: 4rem 0; text-align: center; }

/* ---------- Page header ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.3rem; flex-wrap: wrap; }
.page-head h1 { font-size: 1.6rem; font-weight: 700; letter-spacing: -.01em; }
.page-head .sub { color: var(--muted); margin-top: .25rem; }
.eyebrow { color: var(--muted); font-size: .88rem; }
.hello h1 { font-size: 1.75rem; margin: .1rem 0 .15rem; }

/* ---------- Grid & cards ---------- */
.grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 1rem; }
.s3 { grid-column: span 3; } .s4 { grid-column: span 4; } .s5 { grid-column: span 5; } .s6 { grid-column: span 6; }
.s7 { grid-column: span 7; } .s8 { grid-column: span 8; } .s12 { grid-column: span 12; }
.stack { display: grid; gap: 1rem; align-content: start; }
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow);
  padding: 1.15rem 1.2rem; min-width: 0;
}
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: .8rem; margin-bottom: .85rem; }
.card-head h2, .card h2 { font-size: 1rem; font-weight: 650; }
.card-head .link { font-weight: 600; font-size: .9rem; }
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.tile .label { color: var(--muted); font-size: .85rem; }
.tile .value { font-size: 1.5rem; font-weight: 700; margin-top: .15rem; letter-spacing: -.01em; }
.tile .hint { color: var(--muted); font-size: .82rem; margin-top: .15rem; }

/* ---------- Buttons & forms ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; white-space: nowrap;
  border: 1px solid var(--border); background: var(--card); color: var(--fg);
  border-radius: var(--r-sm); padding: .55rem .95rem; font-weight: 600; cursor: pointer; text-decoration: none; line-height: 1.2;
  transition: filter .15s, background .15s, border-color .15s, transform .05s;
}
.btn:hover { border-color: color-mix(in srgb, var(--primary) 45%, var(--border)); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--primary); padding-inline: .5rem; }
.btn.ghost:hover { background: var(--primary-soft); }
.btn.sm { padding: .38rem .7rem; font-size: .85rem; }
.btn.block, .btn.wide { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.link { background: none; border: 0; padding: 0; color: var(--primary); font-weight: 600; cursor: pointer; }
.icon-btn {
  width: 34px; height: 34px; border-radius: var(--r-sm); border: 1px solid var(--border); background: var(--card);
  display: inline-grid; place-items: center; cursor: pointer; color: var(--muted); position: relative; flex: none;
}
.icon-btn:hover { color: var(--fg); border-color: var(--primary); }
.icon-btn svg, .ico { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn.plain { border-color: transparent; background: transparent; width: 30px; height: 30px; }
.dot-badge { position: absolute; top: 5px; right: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); }

.field { display: grid; gap: .3rem; font-size: .86rem; font-weight: 600; color: var(--fg); }
.field .help { font-weight: 400; color: var(--muted); font-size: .8rem; }
input:not([type=checkbox]):not([type=radio]), select, textarea {
  width: 100%; border: 1px solid var(--border); background: var(--card); color: var(--fg);
  border-radius: var(--r-sm); padding: .58rem .75rem; font-weight: 400; min-height: 40px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent); }
input::placeholder { color: color-mix(in srgb, var(--muted) 70%, transparent); }
.form { display: grid; gap: .85rem; }
.form .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.form .actions { display: flex; gap: .5rem; justify-content: flex-end; align-items: center; margin-top: .2rem; flex-wrap: wrap; }
.form .actions .spacer { flex: 1; }
.inline-form { display: flex; gap: .45rem; align-items: center; }
.inline-form input[name] { min-height: 34px; padding: .35rem .6rem; width: 120px; flex: none; }
.check { display: flex; align-items: center; gap: .6rem; font-weight: 500; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); }

.seg { display: inline-flex; background: var(--muted-card); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: .38rem .8rem; border-radius: 8px; cursor: pointer; font-weight: 600; font-size: .86rem; color: var(--muted); }
.seg button.on { background: var(--card); color: var(--fg); box-shadow: var(--shadow); }
.seg.full { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }

.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip {
  border: 1px solid var(--border); background: var(--card); border-radius: 99px; padding: .32rem .75rem; cursor: pointer;
  font-size: .86rem; font-weight: 500; display: inline-flex; align-items: center; gap: .4rem;
}
.chip.on { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.chip .dot { width: 8px; height: 8px; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; flex: none; }

.pill { display: inline-block; font-size: .74rem; font-weight: 700; padding: .14rem .5rem; border-radius: 99px; white-space: nowrap; }
.pill.warn { background: var(--warning-soft); color: var(--warning); }
.pill.bad { background: var(--danger-soft); color: var(--danger); }
.pill.good { background: var(--success-soft); color: var(--success); }
.pill.info { background: var(--primary-soft); color: var(--primary); }
.badge { display: inline-block; font-size: .66rem; font-weight: 800; letter-spacing: .06em; padding: .14rem .45rem; border-radius: 6px;
  background: linear-gradient(135deg, #f59e0b, #ec4899); color: #fff; vertical-align: middle; }

/* ---------- Progress ---------- */
.bar { height: 8px; border-radius: 99px; background: color-mix(in srgb, var(--border) 75%, transparent); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 99px; background: var(--primary); transition: width .4s ease; }
.bar.good > span { background: var(--success); }
.bar.warn > span { background: var(--warning); }
.bar.bad > span { background: var(--danger); }
.bar.thin { height: 6px; }

/* ---------- Lists ---------- */
.list { display: grid; }
.row { display: flex; align-items: center; gap: .8rem; padding: .7rem 0; border-top: 1px solid var(--border); min-width: 0; }
.row:first-child { border-top: 0; padding-top: 0; }
.card.flush .row { padding: .8rem 1.2rem; }
.card.flush .row:first-child { padding-top: .8rem; }
.row .grow { flex: 1; min-width: 0; }
.row .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .sub { color: var(--muted); font-size: .82rem; }
.row .amt { font-weight: 650; white-space: nowrap; font-variant-numeric: tabular-nums; }
.row.click { cursor: pointer; }
.card.flush .row.click:hover { background: var(--muted-card); }
.date-box {
  width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; flex: none;
  font-weight: 700; font-size: .9rem; background: var(--primary-soft); color: var(--primary);
}
.date-box.warn { background: var(--warning-soft); color: var(--warning); }
.date-box.bad { background: var(--danger-soft); color: var(--danger); }
.ico-box { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; flex: none; background: var(--warning-soft); color: var(--warning); }
.ico-box.info { background: var(--primary-soft); color: var(--primary); }
.ico-box.good { background: var(--success-soft); color: var(--success); }
.ico-box.bad { background: var(--danger-soft); color: var(--danger); }
.ico-box svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.day-head { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted);
  padding: .75rem 1.2rem .35rem; background: var(--muted-card); border-top: 1px solid var(--border); }
.day-head:first-child { border-top: 0; }
.empty { text-align: center; color: var(--muted); padding: 2rem 1rem; }
.empty .big { font-size: 1.8rem; margin-bottom: .3rem; }
.note-line { color: var(--muted); font-size: .84rem; margin-top: .8rem; }

/* ---------- Dashboard ---------- */
.next-step { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.next-step .grow { flex: 1; min-width: 180px; }
.next-step .kicker { font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.next-step h2 { font-size: 1.15rem; margin: .1rem 0; }
.next-step .btns { display: flex; gap: .5rem; }
.hero {
  position: relative; overflow: hidden; color: #fff; border: 0;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  min-height: 220px; display: flex; flex-direction: column; justify-content: center; padding: 1.4rem 1.5rem;
}
.hero::after { content: ""; position: absolute; right: -50px; top: -70px; width: 200px; height: 200px; border-radius: 50%; background: rgb(255 255 255 / .09); }
.hero::before { content: ""; position: absolute; right: 80px; bottom: -90px; width: 160px; height: 160px; border-radius: 50%; background: rgb(255 255 255 / .06); }
.hero > * { position: relative; z-index: 1; }
.hero .tabs { display: flex; gap: .3rem; flex-wrap: wrap; margin-bottom: 1rem; }
.hero .tabs button { border: 0; background: transparent; color: rgb(255 255 255 / .85); font-weight: 600; font-size: .84rem; padding: .35rem .75rem; border-radius: 99px; cursor: pointer; }
.hero .tabs button.on { background: rgb(255 255 255 / .2); color: #fff; }
.hero .tabs button:disabled { opacity: .45; cursor: default; }
.hero .label { font-weight: 600; opacity: .92; }
.hero .big { font-size: clamp(2.2rem, 5vw, 3rem); font-weight: 800; letter-spacing: -.02em; line-height: 1.1; margin: .25rem 0; font-variant-numeric: tabular-nums; }
.hero .sub { opacity: .9; }
.hero details { margin-top: .9rem; }
.hero summary { cursor: pointer; font-weight: 700; font-size: .88rem; list-style: none; }
.hero summary::-webkit-details-marker { display: none; }
.hero summary::before { content: "▸ "; }
.hero details[open] summary::before { content: "▾ "; }
.calc { margin-top: .6rem; background: rgb(0 0 0 / .14); border-radius: var(--r-sm); padding: .65rem .8rem; font-size: .86rem; display: grid; gap: .25rem; max-width: 420px; }
.calc div { display: flex; justify-content: space-between; gap: 1rem; }
.calc .total { border-top: 1px solid rgb(255 255 255 / .25); padding-top: .3rem; font-weight: 700; }
.kv { display: flex; justify-content: space-between; gap: 1rem; padding: .32rem 0; }
.kv b { font-variant-numeric: tabular-nums; }
.afford-result { margin-top: .75rem; padding: .7rem .8rem; border-radius: var(--r-sm); font-size: .88rem; }
.afford-result.good { background: var(--success-soft); color: var(--success); }
.afford-result.bad { background: var(--danger-soft); color: var(--danger); }
.afford-result.warn { background: var(--warning-soft); color: var(--warning); }
.mini-row { padding: .45rem 0; }
.mini-row .top { display: flex; justify-content: space-between; gap: .6rem; font-size: .9rem; margin-bottom: .35rem; }
.mini-row .top span:last-child { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- Budget ---------- */
.budget-row { padding: 1rem 1.2rem; border-top: 1px solid var(--border); display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .4rem 1.2rem; align-items: center; }
.budget-row:first-child { border-top: 0; }
.budget-row .top { display: flex; justify-content: space-between; gap: .6rem; margin-bottom: .45rem; }
.budget-row .top .name { font-weight: 650; display: flex; align-items: center; gap: .5rem; min-width: 0; }
.budget-row .top .name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.budget-row .top .of { color: var(--muted); font-size: .86rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.budget-row .left { font-size: .82rem; color: var(--muted); margin-top: .35rem; }
.limit-box { display: flex; align-items: flex-end; gap: .4rem; }
.limit-box label { display: grid; gap: .15rem; font-size: .74rem; color: var(--muted); font-weight: 600; }
.limit-box input[name] { width: 100px; min-height: 34px; padding: .32rem .55rem; }
.period-nav { display: inline-flex; align-items: center; gap: .4rem; }
.period-nav .label { font-weight: 600; min-width: 9rem; text-align: center; font-size: .92rem; }

/* ---------- Transactions ---------- */
.filters { display: grid; grid-template-columns: minmax(0, 2fr) 1fr 1fr; gap: .6rem; padding: 1rem 1.2rem; border-bottom: 1px solid var(--border); }
.tx-row .x { opacity: .5; }
.tx-row:hover .x { opacity: 1; }
.x-btn { border: 0; background: none; color: var(--muted); cursor: pointer; width: 28px; height: 28px; border-radius: 8px; font-size: .9rem; }
.x-btn:hover { background: var(--danger-soft); color: var(--danger); }
.x-btn.armed { background: var(--danger); color: #fff; width: auto; padding: 0 .55rem; font-size: .78rem; font-weight: 700; }

/* ---------- Calendar ---------- */
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: .8rem; flex-wrap: wrap; margin-bottom: .8rem; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-top: 1px solid var(--border); border-left: 1px solid var(--border); border-radius: var(--r-sm); overflow: hidden; }
.cal-dow { font-size: .74rem; font-weight: 700; color: var(--muted); text-align: center; padding: .45rem 0; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); background: var(--muted-card); }
.cal-day {
  min-height: 92px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: .35rem;
  cursor: pointer; display: flex; flex-direction: column; gap: 3px; background: var(--card); min-width: 0; text-align: left;
  border-top: 0; border-left: 0; font: inherit; color: inherit;
}
.cal-day:hover { background: var(--muted-card); }
.cal-day.other { color: var(--muted); background: var(--muted-card); }
.cal-day.other .ev { opacity: .55; }
.cal-day.sel { box-shadow: inset 0 0 0 2px var(--primary); }
.cal-day .n { font-size: .8rem; font-weight: 600; width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; }
.cal-day.today .n { background: var(--primary); color: var(--on-primary); }
.ev { font-size: .7rem; font-weight: 600; padding: 1px 5px; border-radius: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev.payday { background: var(--success-soft); color: var(--success); }
.ev.bill { background: var(--warning-soft); color: var(--warning); }
.ev.debt { background: var(--danger-soft); color: var(--danger); }
.ev.recurring { background: var(--primary-soft); color: var(--primary); }
.ev.more { color: var(--muted); background: none; }
.legend { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .8rem; color: var(--muted); margin-top: .8rem; }
.legend span { display: inline-flex; align-items: center; gap: .35rem; }

/* ---------- Charts ---------- */
.chart { width: 100%; height: auto; overflow: visible; }
.chart text { fill: var(--muted); font-size: 11px; font-family: inherit; }
.chart .grid-line { stroke: var(--border); }
.chart-legend { display: flex; gap: 1rem; font-size: .82rem; color: var(--muted); margin-bottom: .6rem; }
.chart-legend span { display: inline-flex; align-items: center; gap: .35rem; }
.chart-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
table.simple { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.simple th, table.simple td { padding: .55rem .4rem; border-bottom: 1px solid var(--border); text-align: right; font-variant-numeric: tabular-nums; }
table.simple th:first-child, table.simple td:first-child { text-align: left; }
table.simple th { color: var(--muted); font-weight: 600; font-size: .8rem; }

/* ---------- Settings ---------- */
.swatches { display: flex; flex-wrap: wrap; gap: .6rem; }
.swatch {
  width: 40px; height: 40px; border-radius: 12px; border: 2px solid transparent; cursor: pointer; position: relative;
  box-shadow: inset 0 0 0 2px var(--card); display: grid; place-items: center; color: #fff; font-weight: 800;
}
.swatch.on { border-color: var(--fg); }
.setting-row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .7rem 0; border-top: 1px solid var(--border); }
.setting-row:first-of-type { border-top: 0; }

/* ---------- Modal, toast ---------- */
dialog {
  border: 0; border-radius: 18px; padding: 0; width: min(480px, calc(100vw - 1.5rem)); max-height: calc(100vh - 2rem);
  background: var(--card); color: var(--fg); box-shadow: var(--shadow-lg);
}
dialog[open] { animation: pop .18s ease-out; }
dialog::backdrop { background: rgb(12 15 24 / .5); backdrop-filter: blur(2px); }
@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0; } }
#modalBody { padding: 1.3rem 1.35rem 1.25rem; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.modal-head h2 { font-size: 1.2rem; }
.amount-input { position: relative; }
.amount-input input { font-size: 1.6rem !important; font-weight: 700; padding: .6rem .8rem !important; min-height: 56px !important; }
#toast {
  position: fixed; left: 50%; bottom: 1.5rem; transform: translate(-50%, 140%); opacity: 0; visibility: hidden;
  background: var(--fg); color: var(--bg); padding: .65rem 1.05rem; border-radius: 12px; font-weight: 600; font-size: .9rem;
  transition: transform .25s, opacity .25s; z-index: 100; box-shadow: var(--shadow-lg); max-width: calc(100vw - 2rem);
}
#toast.show { transform: translate(-50%, 0); opacity: 1; visibility: visible; }
.plan-note { background: var(--primary-soft); padding: .6rem .8rem; border-radius: var(--r-sm); font-size: .9rem; margin: 0 0 .9rem; }
.perks { padding-left: 1.2rem; margin: .4rem 0 .8rem; }

/* ---------- Auth, billing, admin pages ---------- */
body.auth { display: grid; place-items: center; min-height: 100vh; padding: 1.5rem 1rem; background:
  radial-gradient(1200px 500px at 10% -10%, color-mix(in srgb, var(--primary) 14%, transparent), transparent),
  radial-gradient(900px 500px at 110% 110%, color-mix(in srgb, var(--secondary) 14%, transparent), transparent), var(--bg); }
.auth-card { background: var(--card); border: 1px solid var(--border); border-radius: 20px; padding: 1.8rem; width: min(430px, 100%); box-shadow: var(--shadow-lg); }
.auth-card.wide { width: min(940px, 100%); }
.auth-card .brand { margin-bottom: 1.3rem; padding: 0; }
.auth-card .brand .logo { width: 32px; height: 32px; border-radius: 9px; background: linear-gradient(135deg, var(--primary), var(--secondary)); color: transparent; display: inline-block; }
.auth-card h1 { font-size: 1.45rem; margin: 0 0 .6rem; }
.auth-card form { display: grid; gap: .85rem; }
.auth-card label { display: grid; gap: .3rem; font-size: .88rem; font-weight: 600; }
.auth-card label.check { display: flex; font-weight: 500; }
.auth-card fieldset { border: 1px solid var(--border); border-radius: 14px; display: grid; gap: .75rem; padding: 1rem; margin: 0; }
.auth-card legend { font-weight: 700; padding: 0 .35rem; }
.auth-card .btn { padding: .7rem 1rem; }
.auth-card button.btn:not(.secondary):not(.link) { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.auth-card .btn.secondary { background: var(--muted-card); }
.auth-card code { background: var(--muted-card); border: 1px solid var(--border); padding: .1rem .35rem; border-radius: 6px; word-break: break-all; }
.links { margin-top: 1.1rem; text-align: center; }
.auth-card .error { background: var(--danger-soft); color: var(--danger); padding: .65rem .85rem; border-radius: var(--r-sm); }
.auth-card .warn { background: var(--warning-soft); color: var(--warning); padding: .65rem .85rem; border-radius: var(--r-sm); }
.auth-card .label-row { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; }
.auth-card .label-row a { font-weight: 500; font-size: .85rem; }
.auth-card .notice-good { background: var(--success-soft); color: var(--success); padding: .65rem .85rem; border-radius: var(--r-sm); }
.auth-card .redeem { margin-top: 1.2rem; padding-top: 1.1rem; border-top: 1px solid var(--border); }
.auth-card .inline { display: flex; gap: .5rem; }
.auth-card .inline input { flex: 1; min-width: 0; }
.auth-card .inline .btn { flex: none; }
.foot { text-align: center; color: var(--muted); font-size: .8rem; padding: 1rem; }
.plans { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; margin: .9rem 0 1rem; }
.plan { border: 1px solid var(--border); border-radius: 14px; padding: .9rem; }
.plan.pro { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary) inset; background: var(--primary-soft); }
.plan h2 { display: flex; justify-content: space-between; align-items: baseline; gap: .4rem; flex-wrap: wrap; font-size: 1.05rem; }
.plan .price { font-size: .85rem; color: var(--primary); }
.plan ul { padding-left: 1.1rem; margin: .5rem 0; font-size: .9rem; }
form.inline { display: inline-flex; gap: .4rem; align-items: center; margin: .3rem 0; }
.user-list { margin-top: .6rem; }
.user-row { display: flex; justify-content: space-between; align-items: center; gap: .8rem; padding: .65rem 0; border-top: 1px solid var(--border); flex-wrap: wrap; }
.user-row .right { display: flex; gap: .6rem; align-items: center; }


/* ---------- Admin ---------- */
.admin-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: .6rem; margin: .4rem 0 1rem; }
.stat-row div { background: var(--muted-card); border: 1px solid var(--border); border-radius: 12px; padding: .65rem .8rem; display: grid; }
.stat-row b { font-size: 1.3rem; }
.stat-row span { color: var(--muted); font-size: .8rem; }
.admin-tabs, .pills { display: flex; gap: .3rem; border-bottom: 1px solid var(--border); margin-bottom: 1rem; flex-wrap: wrap; }
.admin-tabs a, .pills a { padding: .55rem .9rem; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.admin-tabs a:hover, .pills a:hover { color: var(--fg); text-decoration: none; }
.admin-tabs a.on, .pills a.on { color: var(--primary); border-bottom-color: var(--primary); }
.pills { border: 0; margin: 0; }
.pills a { border: 1px solid var(--border); border-radius: 99px; padding: .3rem .8rem; margin: 0; font-size: .85rem; }
.pills a.on { background: var(--primary-soft); border-color: var(--primary); }
.box { border: 1px solid var(--border); border-radius: 14px; padding: 1rem; margin-bottom: 1rem; background: var(--muted-card); }
.box h2 { font-size: 1.05rem; margin-bottom: .3rem; }
.box summary { cursor: pointer; font-weight: 700; color: var(--primary); }
.box[open] summary { margin-bottom: .8rem; }
.auth-card .grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .75rem; align-items: end; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: .8rem; margin: .4rem 0 .8rem; flex-wrap: wrap; }
.search { margin-bottom: .8rem !important; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; }
.admin-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.admin-table th { text-align: left; font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: var(--muted-card); padding: .6rem .75rem; }
.admin-table td { padding: .65rem .75rem; border-top: 1px solid var(--border); vertical-align: top; }
.admin-table tr.off td { opacity: .55; }
.admin-table .actions { white-space: nowrap; }
.admin-table .actions form, .admin-table .actions details { display: inline-flex; margin-right: .6rem; }
.admin-table select { min-height: 34px; padding: .3rem .5rem; width: auto; }
.admin-table .btn { padding: .4rem .7rem; font-size: .85rem; }
.danger-zone summary { list-style: none; cursor: pointer; color: var(--danger); }
.danger-zone summary::-webkit-details-marker { display: none; }
.danger-zone[open] { display: flex !important; gap: .4rem; align-items: center; }
.danger-zone input { width: 110px; min-height: 32px; padding: .3rem .5rem; }
.danger-text { color: var(--danger) !important; }
.auth-card button.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.tag { display: inline-block; font-size: .76rem; font-weight: 700; padding: .15rem .55rem; border-radius: 99px; background: var(--muted-card); border: 1px solid var(--border); white-space: nowrap; }
.tag.lifetime { background: linear-gradient(135deg, #f59e0b, #ec4899); color: #fff; border: 0; }
.tag.gift, .tag.stripe { background: var(--primary-soft); color: var(--primary); border-color: transparent; }
textarea.reveal { width: 100%; font: .85rem/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; border: 1px dashed var(--primary); background: var(--primary-soft); color: var(--fg); border-radius: 12px; padding: .8rem; resize: vertical; margin-top: .6rem; }
@media (max-width: 640px) { .stat-row { grid-template-columns: repeat(2, 1fr); } }

/* ---------- Responsive ---------- */
@media (max-width: 1080px) {
  .s3 { grid-column: span 6; }
}
@media (max-width: 920px) {
  .sidebar { position: fixed; left: 0; top: 0 !important; height: 100vh !important; transform: translateX(-105%); transition: transform .22s ease; box-shadow: var(--shadow-lg); z-index: 60; }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgb(12 15 24 / .45); z-index: 55; }
  .topbar {
    display: flex; align-items: center; justify-content: space-between; gap: .6rem; position: sticky; top: 0; z-index: 20;
    padding: .6rem .9rem; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border);
  }
  .demo-banner ~ .layout .topbar { top: 34px; }
  .topbar .brand-mark { width: 28px; height: 28px; }
  main { padding: 1.2rem 1rem 6rem; }
  .s4, .s5, .s6, .s7, .s8 { grid-column: span 12; }
  .fab {
    display: grid; place-items: center; position: fixed; right: 1.1rem; bottom: calc(1.1rem + env(safe-area-inset-bottom)); z-index: 50;
    width: 56px; height: 56px; border-radius: 18px; border: 0; cursor: pointer; font-size: 1.8rem; font-weight: 400; line-height: 1;
    background: linear-gradient(135deg, var(--primary), var(--secondary)); color: #fff; box-shadow: 0 10px 28px color-mix(in srgb, var(--primary) 45%, transparent);
  }
}
@media (max-width: 640px) {
  .s3 { grid-column: span 12; }
  .tiles { grid-template-columns: 1fr; gap: .6rem; }
  .tile { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
  .tile .value { font-size: 1.2rem; margin: 0; }
  .page-head h1 { font-size: 1.35rem; }
  .filters { grid-template-columns: 1fr 1fr; }
  .filters .q { grid-column: span 2; }
  .budget-row { grid-template-columns: 1fr; }
  .cal-day { min-height: 58px; padding: .2rem; }
  .cal-day .ev { font-size: 0; height: 6px; padding: 0; border-radius: 3px; }
  .form .row2 { grid-template-columns: 1fr; }
  .plans { grid-template-columns: 1fr; }
  .hero { min-height: 0; }
  .demo-banner { font-size: .76rem; }
  .demo-banner ~ .layout .topbar { top: 46px; }
  .next-step .btns { width: 100%; }
  .next-step .btns .btn { flex: 1; }
  dialog { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: 20px 20px 0 0; max-height: 92vh; }
  dialog[open] { animation: up .22s ease-out; }
  @keyframes up { from { transform: translateY(40px); opacity: 0; } }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- Public site pages (download) ---------- */
body.site { background:
  radial-gradient(1100px 480px at 0% -10%, color-mix(in srgb, var(--primary) 12%, transparent), transparent),
  radial-gradient(900px 420px at 100% 0%, color-mix(in srgb, var(--secondary) 10%, transparent), transparent), var(--bg); }
.site-nav { max-width: 1080px; margin: 0 auto; padding: 1rem 1.2rem; display: flex; align-items: center; gap: 1.2rem; }
.site-nav nav { display: flex; gap: .3rem; margin-left: .6rem; }
.site-nav nav a { color: var(--muted); font-weight: 600; padding: .45rem .7rem; border-radius: 8px; }
.site-nav nav a:hover, .site-nav nav a.on { color: var(--fg); background: var(--muted-card); text-decoration: none; }
.site-cta { margin-left: auto; display: flex; gap: .5rem; }
.site-main { max-width: 1080px; margin: 0 auto; padding: 1rem 1.2rem 3rem; }
.dl-hero { text-align: center; padding: 2.5rem 0 2rem; }
.dl-hero h1 { font-size: clamp(2rem, 5vw, 3.1rem); letter-spacing: -.02em; margin: .3rem 0 .8rem; }
.dl-hero .lead { color: var(--muted); font-size: 1.1rem; max-width: 620px; margin: 0 auto 1.4rem; }
.dl-actions { display: flex; gap: .7rem; justify-content: center; flex-wrap: wrap; align-items: center; }
.btn.big { padding: .8rem 1.3rem; font-size: 1rem; border-radius: 12px; }
.dl-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; margin-top: 1rem; }
.dl-card { position: relative; padding: 1.4rem; }
.dl-card.mine { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary), var(--shadow-lg); }
.dl-card h2 { font-size: 1.2rem; margin: .5rem 0 .2rem; }
.dl-card ol { padding-left: 1.2rem; margin: 1rem 0 0; display: grid; gap: .6rem; }
.dl-ico { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; font-size: 1.5rem; background: var(--primary-soft); flex: none; }
.dl-you { position: absolute; top: 1rem; right: 1rem; }
.share-ico { display: inline-grid; place-items: center; width: 22px; height: 22px; border: 1px solid var(--border); border-radius: 6px; font-size: .8rem; vertical-align: middle; background: var(--muted-card); }
.dl-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1rem; margin-top: 1rem; }
.dl-qr, .dl-safe { display: flex; gap: 1.1rem; align-items: center; }
.dl-qr img { background: #fff; border-radius: 12px; padding: 6px; flex: none; }
.dl-qr h2, .dl-safe h2 { font-size: 1.05rem; margin-bottom: .2rem; }
.dl-faq { margin-top: 1rem; padding: .4rem 1.3rem; }
.dl-faq details { border-top: 1px solid var(--border); padding: .9rem 0; }
.dl-faq details:first-child { border-top: 0; }
.dl-faq summary { cursor: pointer; font-weight: 650; }
.dl-faq p { color: var(--muted); margin: .5rem 0 0; }
.site-foot { border-top: 1px solid var(--border); text-align: center; padding: 2rem 1rem; display: grid; gap: .6rem; color: var(--muted); }
.site-foot nav { display: flex; gap: 1.2rem; justify-content: center; flex-wrap: wrap; }
.install-card { display: flex; align-items: center; gap: 1rem; }
@media (max-width: 820px) {
  .dl-grid { grid-template-columns: 1fr; }
  .site-nav nav { display: none; }
  .dl-hero { padding-top: 1.2rem; }
}
@media (max-width: 420px) { .site-cta .btn { padding: .5rem .7rem; } }
