/* KAIZEN — navy & gold. Dark by default, light when the device asks for it. */
:root {
  --bg: #0b0e14; --panel: #131823; --panel2: #1a2130; --line: #252d3d;
  --text: #e8eaf0; --muted: #8e97a9; --gold: #d4a843; --gold-soft: rgba(212,168,67,.14);
  --good: #3fb27f; --mid: #d4a843; --bad: #e5675e; --blue: #5b8def; --violet: #9b7bea;
  --radius: 14px; --nav-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f5f3ee; --panel: #ffffff; --panel2: #f0ede6; --line: #e3ded3;
    --text: #18202e; --muted: #6a7282; --gold: #a87a1a; --gold-soft: rgba(168,122,26,.12);
    --good: #1f8a5a; --bad: #c4443b; color-scheme: light;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 15px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif; min-height: 100vh; padding-bottom: calc(var(--nav-h) + var(--safe-b) + 16px); }
body.locked { overflow: hidden; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
h1 { font-size: 24px; line-height: 1.15; margin: 2px 0 4px; letter-spacing: -.01em; }
h2 { font-size: 19px; margin: 0; }
h3 { font-size: 15px; margin: 0 0 10px; font-weight: 650; }
label { display: block; font-size: 12px; color: var(--muted); margin: 10px 0 4px; }
code { font-size: 12px; background: var(--panel2); padding: 1px 5px; border-radius: 5px; }
small { display: block; color: var(--muted); font-size: 12px; }
.muted { color: var(--muted); } .small { font-size: 12px; } .center { text-align: center; } .pad { padding: 0 4px; }
.good { color: var(--good); } .bad { color: var(--bad); } .warnc { color: var(--gold); } .hi { color: var(--gold); }
.eyebrow { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--gold); font-weight: 650; margin: 6px 0 4px; }

/* top bar + nav */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px; padding: calc(var(--safe-t) + 10px) 16px 10px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.brand { font-weight: 800; letter-spacing: .28em; font-size: 13px; color: var(--gold); flex: 1; }
.sync { font-size: 11px; padding: 4px 9px; border-radius: 99px; border: 1px solid var(--line); color: var(--muted); }
.sync.ok { color: var(--good); border-color: color-mix(in srgb, var(--good) 40%, transparent); }
.sync.error, .sync.offline { color: var(--gold); }
.sync.syncing { color: var(--blue); }
#nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-template-columns: repeat(5, 1fr); height: calc(var(--nav-h) + var(--safe-b)); padding-bottom: var(--safe-b); background: color-mix(in srgb, var(--panel) 94%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line); }
#nav button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--muted); font-size: 11px; }
#nav button.on { color: var(--gold); }
main { max-width: 680px; margin: 0 auto; padding: 8px 16px 0; }

/* blocks */
.top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin: 10px 0 12px; }
.card { display: block; width: 100%; text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin: 0 0 12px; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.card-h h3 { margin: 0; }
.pill { font-size: 12px; padding: 2px 9px; border-radius: 99px; background: var(--panel2); color: var(--muted); font-weight: 600; white-space: nowrap; }
.pill.good { background: color-mix(in srgb, var(--good) 18%, transparent); color: var(--good); }
.cta { border-color: color-mix(in srgb, var(--gold) 45%, var(--line)); background: linear-gradient(160deg, var(--gold-soft), var(--panel) 60%); }
.warncard { border-color: color-mix(in srgb, var(--gold) 45%, var(--line)); }
.warn { font-size: 12px; color: var(--gold); margin-top: 4px; }
.warn::before { content: "▲ "; font-size: 9px; vertical-align: 1px; }
.row { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.row.wrap { flex-wrap: wrap; } .row.between { justify-content: space-between; } .row .in { margin: 0; }
.grow { flex: 1; min-width: 0; }
.in.full { flex: 1 1 100%; }
.lrow { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); }
.lrow:first-of-type { border-top: 0; } .lrow > div { flex: 1; min-width: 0; }

/* inputs */
.in { width: 100%; background: var(--panel2); border: 1px solid var(--line); color: var(--text); border-radius: 10px; padding: 10px 11px; font: inherit; font-size: 16px; outline: none; }
.in:focus { border-color: var(--gold); }
.in.sm { width: auto; flex: 1 1 110px; font-size: 15px; padding: 8px 9px; }
textarea.in { resize: vertical; min-height: 44px; line-height: 1.4; }
.in:disabled { opacity: .6; }
.btn { background: var(--gold); color: #14110a; font-weight: 700; padding: 10px 16px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap; }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); font-weight: 600; }
.btn.sm { padding: 6px 12px; font-size: 13px; }
.btn.wide { width: 100%; margin: 4px 0 12px; }
.btn.danger, .icon-btn.danger { color: var(--bad); }
.icon-btn { width: 36px; height: 36px; flex: none; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; font-size: 22px; color: var(--muted); }
.icon-btn:hover { background: var(--panel2); }
.link { color: var(--gold); font-size: 13px; font-weight: 600; padding: 4px 0; }
.q { color: var(--text); font-size: 13px; margin-top: 12px; }

/* check rows */
.check { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 9px 0; border-top: 1px solid var(--line); cursor: pointer; }
.card > .check:first-of-type, .card-h + .check, h3 + .check { border-top: 0; }
.check .box, .mini-box span { flex: none; width: 22px; height: 22px; border-radius: 7px; border: 2px solid var(--muted); display: inline-block; position: relative; }
.check.on .box, .mini-box input:checked + span { background: var(--good); border-color: var(--good); }
.check.on .box::after, .mini-box input:checked + span::after { content: ""; position: absolute; left: 6px; top: 2px; width: 6px; height: 11px; border: solid #fff; border-width: 0 2.5px 2.5px 0; transform: rotate(45deg); }
.check.on b { color: var(--muted); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--muted) 60%, transparent); }
.check .t { flex: 1; min-width: 0; text-align: left; }
.check b { font-weight: 550; display: block; }
.check.pri-1 .box { border-color: var(--gold); }
.check.bill.on b { text-decoration: none; }
.mini-box { margin: 0; cursor: pointer; } .mini-box input { display: none; }
.trow { display: flex; gap: 10px; align-items: center; margin-top: 8px; }
.num { width: 22px; flex: none; text-align: center; color: var(--gold); font-weight: 700; }
.tagx { color: var(--blue); }
.amt { font-variant-numeric: tabular-nums; font-weight: 650; white-space: nowrap; }
.amt-in { width: 96px; flex: none; text-align: right; padding: 7px 8px; font-size: 15px; }

/* details */
.det { padding: 0; }
.det > summary { list-style: none; padding: 14px; font-weight: 650; display: flex; align-items: center; gap: 8px; cursor: pointer; }
.det > summary::-webkit-details-marker { display: none; }
.det > summary::after { content: "›"; margin-left: auto; color: var(--muted); font-size: 20px; transition: transform .2s; }
.det[open] > summary::after { transform: rotate(90deg); }
.det-b { padding: 0 14px 14px; }
.sub { border-top: 1px solid var(--line); margin-top: 14px; padding-top: 8px; }

/* today */
.now { cursor: pointer; border-color: color-mix(in srgb, var(--gold) 40%, var(--line)); background: linear-gradient(150deg, var(--gold-soft), var(--panel) 65%); }
.now-t { font-size: 20px; font-weight: 700; margin-bottom: 2px; }
.bar { height: 6px; border-radius: 99px; background: var(--panel2); overflow: hidden; margin: 8px 0; }
.bar i { display: block; height: 100%; background: var(--gold); border-radius: 99px; }
.daynav { display: flex; align-items: center; gap: 2px; }
.habit { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); }
.habit:first-child { border-top: 0; }
.seg { display: inline-flex; background: var(--panel2); border-radius: 10px; padding: 3px; gap: 2px; flex: none; }
.seg button { min-width: 32px; height: 32px; border-radius: 8px; font-weight: 650; color: var(--muted); }
.seg button.on { background: var(--gold); color: #14110a; }
.seg.wide { display: flex; } .seg.wide button { flex: 1; }

/* schedule */
.timeline { margin-bottom: 12px; }
.block { display: flex; gap: 12px; padding: 12px 14px; background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--c, var(--muted)); border-radius: 12px; margin-bottom: 8px; }
.block.on { background: linear-gradient(150deg, var(--gold-soft), var(--panel) 70%); border-color: color-mix(in srgb, var(--gold) 50%, var(--line)); border-left-color: var(--c); }
.bt { width: 64px; flex: none; font-weight: 650; font-size: 14px; font-variant-numeric: tabular-nums; }
.bb { flex: 1; min-width: 0; }
.tag-spirit { --c: var(--violet); } .tag-body { --c: var(--good); } .tag-work { --c: var(--gold); } .tag-learn { --c: var(--blue); } .tag-todo { --c: #e08a4f; } .tag-rest { --c: #5d6a85; }
.edit-block { padding: 10px 0; border-top: 1px solid var(--line); }
.edit-block:first-child { border-top: 0; }
.edit-block input[type=time] { flex: 1; }

/* to-do */
.addbar .small-row { flex-wrap: wrap; }
.chips { display: flex; gap: 8px; overflow-x: auto; margin: 0 0 12px; padding-bottom: 2px; scrollbar-width: none; }
.chips.wrap { flex-wrap: wrap; overflow: visible; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 99px; border: 1px solid var(--line); background: var(--panel); color: var(--text); font-size: 13px; margin: 0; white-space: nowrap; cursor: pointer; }
.chip.on { border-color: var(--gold); color: var(--gold); background: var(--gold-soft); }
.chip b { color: var(--muted); font-weight: 600; }
.chip.big { white-space: normal; border-radius: 12px; padding: 11px 12px; align-items: flex-start; margin-top: 12px; font-size: 14px; line-height: 1.35; }
.chip input { accent-color: var(--gold); width: 17px; height: 17px; flex: none; margin: 1px 0 0; }

/* 12 week */
.segbar { display: flex; gap: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 4px; margin-bottom: 12px; overflow-x: auto; scrollbar-width: none; }
.segbar button { flex: 1; padding: 8px 10px; border-radius: 9px; font-size: 13px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.segbar button.on { background: var(--gold); color: #14110a; }
.weeknav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.weeknav .center small { display: block; }
.score { display: flex; gap: 16px; align-items: center; }
.score > div { flex: 1; min-width: 0; }
.big { font-size: 20px; font-weight: 700; }
.ring { flex: none; } .ring-bg { fill: none; stroke: var(--panel2); stroke-width: 9; }
.ring-fg { fill: none; stroke: var(--bad); stroke-width: 9; stroke-linecap: round; transition: stroke-dasharray .4s; }
.ring.mid .ring-fg { stroke: var(--mid); } .ring.good .ring-fg { stroke: var(--good); }
.ring text { fill: var(--text); font-size: 22px; font-weight: 750; }
.gbar { display: grid; grid-template-columns: minmax(0, 1fr) 70px 38px; gap: 8px; align-items: center; font-size: 12px; margin-top: 6px; }
.gbar span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .gbar .bar { margin: 0; } .gbar b { text-align: right; }
.scroll-x { overflow-x: auto; }
.grid { width: 100%; border-collapse: collapse; font-size: 13px; table-layout: auto; }
.grid th { font-weight: 600; color: var(--muted); padding: 4px 2px; font-size: 12px; }
.grid th small { font-size: 10px; }
.grid th.today { color: var(--gold); }
.grid td { text-align: center; padding: 3px 1px; border-top: 1px solid var(--line); }
.grid td.sname { text-align: left; padding-right: 6px; font-size: 12px; line-height: 1.25; min-width: 70px; }
.grid td.off { color: var(--line); }
.grid td.tot { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12px; }
.grid tr.grow-h th { text-align: left; color: var(--gold); padding-top: 12px; font-size: 12px; letter-spacing: .04em; }
.cell { width: 28px; height: 28px; border-radius: 8px; border: 2px solid var(--line); color: #fff; font-weight: 800; }
@media (max-width: 400px) { .cell { width: 25px; height: 28px; border-radius: 7px; } .grid th { padding: 4px 0; } .grid td.tot { font-size: 11px; } }
.cell.on { background: var(--good); border-color: var(--good); }
td.today .cell { border-color: color-mix(in srgb, var(--gold) 70%, var(--line)); }
td.today .cell.on { border-color: var(--good); }
.trend { width: 100%; height: auto; }
.trend rect { fill: var(--bad); } .trend rect.mid { fill: var(--mid); } .trend rect.good { fill: var(--good); } .trend rect.fut { fill: var(--panel2); }
.trend rect.now { stroke: var(--text); stroke-width: 1.5; }
.trend text { fill: var(--muted); font-size: 10px; }
.trend .target { stroke: var(--gold); stroke-dasharray: 4 3; stroke-width: 1; }
.rules { font-size: 13px; }
.commit { padding-top: 4px; }
.yn { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.yn .muted { flex: 1; font-size: 13px; }
.yn button { padding: 6px 16px; border-radius: 9px; border: 1px solid var(--line); font-weight: 650; }
.yn button.on.good { background: var(--good); border-color: var(--good); color: #fff; }
.yn button.on.bad { background: var(--bad); border-color: var(--bad); color: #fff; }
.metric { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.metric:first-of-type { border-top: 0; }
.stepper { display: flex; align-items: center; gap: 6px; flex: none; }
.stepper button { width: 36px; height: 36px; border-radius: 10px; background: var(--panel2); font-size: 18px; font-weight: 700; }
.stepper button.small { font-size: 12px; width: 40px; }
.stepper b { min-width: 34px; text-align: center; font-size: 20px; font-variant-numeric: tabular-nums; }
.goal .eyebrow { margin-top: 14px; }
.steprow { border-top: 1px solid var(--line); padding: 8px 0; }
.days { display: flex; gap: 3px; }
.days button { width: 30px; height: 32px; border-radius: 8px; background: var(--panel2); font-size: 12px; font-weight: 700; color: var(--muted); }
.days button.on { background: var(--gold); color: #14110a; }
.dates summary { cursor: pointer; margin-top: 6px; }
.agent { cursor: pointer; }
.ag-h { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.ag-n { font-weight: 800; letter-spacing: .08em; color: var(--gold); }

/* money */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 10px; }
.tile b { font-size: 20px; font-variant-numeric: tabular-nums; }
.tiles .span { grid-column: 1 / -1; } .tiles .bar { margin: 0 0 4px; }
.splitbar { display: flex; height: 8px; border-radius: 99px; overflow: hidden; background: var(--panel2); margin-bottom: 6px; }
.splitbar i, .dot { display: block; background: var(--blue); } .splitbar .biz, .dot.biz { background: var(--gold); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; }

/* sheet + toast */
.sheet { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.55); display: none; align-items: flex-end; justify-content: center; }
.sheet.show { display: flex; }
.sheet-in { background: var(--bg); width: 100%; max-width: 680px; max-height: 92vh; overflow-y: auto; border-radius: 20px 20px 0 0; padding: 16px 16px calc(24px + var(--safe-b)); border: 1px solid var(--line); border-bottom: 0; animation: up .22s ease-out; }
.sheet-h { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; position: sticky; top: -16px; background: var(--bg); padding: 4px 0 8px; z-index: 1; }
@keyframes up { from { transform: translateY(40px); opacity: .4; } }
#toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + var(--safe-b) + 14px); transform: translate(-50%, 20px); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px; font-weight: 600; opacity: 0; pointer-events: none; transition: .2s; z-index: 60; max-width: calc(100% - 32px); }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
@media (min-width: 720px) { .tiles { grid-template-columns: repeat(4, 1fr); } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
