:root {
  --bg: #F3F5F1;
  --surface: #FFFFFF;
  --surface-2: #E9EEE7;
  --ink: #1B2E22;
  --muted: #5C6E62;
  --line: #D5DED3;
  --accent: #2E7D4F;
  --accent-ink: #FFFFFF;
  --accent-soft: #DCEEE1;
  --zd: #7A8F84;
  --amber: #B97A12;
  --amber-soft: #F5EAD3;
  --danger: #B0412D;
  --danger-soft: #F6E0DA;
  --focus: #1F6FD1;
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101914; --surface: #17231C; --surface-2: #203027; --ink: #E3EDE6; --muted: #9DB1A4;
    --line: #2C3E33; --accent: #4CB87C; --accent-ink: #0C1A11; --accent-soft: #1E3A2A; --zd: #6F8579;
    --amber: #E0AA4A; --amber-soft: #3A2E17; --danger: #E57A64; --danger-soft: #3C211B; --focus: #7DB4FF;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; line-height: 1.2; text-wrap: balance; }
h1 { font-size: 26px; } h2 { font-size: 19px; } h3 { font-size: 16px; margin-bottom: 10px; }
p { margin: 0; }
.wrap { max-width: 780px; margin: 0 auto; padding: 0 16px; }
.narrow { max-width: 420px; padding-top: 12vh; }
main.wrap { padding-top: 18px; padding-bottom: 64px; }
.stack { display: flex; flex-direction: column; gap: 12px; margin-top: 14px; }
.stack-lg { display: flex; flex-direction: column; gap: 16px; }
.muted { color: var(--muted); } .small { font-size: 13px; } .hint { font-size: 12.5px; color: var(--muted); margin-top: 4px; font-weight: 400; }
.eyebrow { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); font-weight: 700; margin-bottom: 2px; }

.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.topbar-inner { display: flex; justify-content: space-between; align-items: center; padding-top: 12px; padding-bottom: 6px; gap: 12px; }
.title { font-size: 20px; }
.tabs { display: flex; gap: 4px; padding-bottom: 0; }
.tabs button { border: 0; background: none; padding: 10px 12px; font: 600 14px inherit; font-family: inherit; color: var(--muted); border-bottom: 3px solid transparent; cursor: pointer; }
.tabs button[aria-selected="true"] { color: var(--ink); border-color: var(--accent); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.card.info { gap: 0; }
.info summary { cursor: pointer; }
.info-body { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.two > div { background: var(--surface-2); border-radius: 10px; padding: 12px; }
.two h3 { margin-bottom: 4px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row.between { justify-content: space-between; }
.grow { flex: 1 1 220px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 600px) { .grid2, .two { grid-template-columns: 1fr; } }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 600; min-width: 0; }
.label { font-size: 14px; font-weight: 600; }
.inline { display: flex; align-items: center; gap: 8px; font-size: 14px; }
input[type=text], input[type=password], input[type=date], select {
  font: inherit; font-weight: 400; color: var(--ink); background: var(--bg); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; width: 100%; min-width: 0;
}
.inline select { width: auto; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: 600 14px inherit; font-family: inherit; padding: 10px 16px; border-radius: 10px; cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.big { padding: 12px 22px; font-size: 15px; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.small { padding: 6px 10px; font-size: 13px; }
.btn.danger { color: var(--danger); }
.btn.armed { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: var(--bg); color: var(--ink); border-radius: 999px; padding: 7px 13px; font: 500 14px inherit; font-family: inherit; cursor: pointer; }
.chip:hover { border-color: var(--accent); }
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); font-weight: 700; }
#cat-quick .chip { font-size: 13px; padding: 5px 11px; }

.combo { position: relative; }
#cat-search.chosen { border-color: var(--accent); background: var(--accent-soft); font-weight: 600; }
#cat-list { position: absolute; left: 0; right: 0; top: calc(100% + 4px); margin: 0; padding: 4px; list-style: none; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.12); max-height: 320px; overflow-y: auto; z-index: 10; }
#cat-list li { padding: 9px 10px; border-radius: 8px; cursor: pointer; font-weight: 400; }
#cat-list li[aria-selected="true"], #cat-list li:hover { background: var(--accent-soft); }
#cat-list li .why { display: block; font-size: 12px; color: var(--muted); }

details#more summary { cursor: pointer; font-weight: 600; font-size: 14px; }
details#more summary .muted { font-weight: 400; }
.more-body { margin-top: 12px; }
.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; font-weight: 600; }
.switch input { position: absolute; opacity: 0; }
.switch .track { width: 40px; height: 23px; border-radius: 999px; background: var(--line); position: relative; flex: none; transition: background .15s; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 17px; height: 17px; border-radius: 50%; background: var(--surface); transition: transform .15s; }
.switch input:checked + .track { background: var(--amber); }
.switch input:checked + .track::after { transform: translateX(17px); }
.switch input:focus-visible + .track { outline: 2px solid var(--focus); outline-offset: 2px; }

.notice { border-radius: 10px; padding: 10px 12px; font-size: 14px; background: var(--surface-2); }
.notice.err { background: var(--danger-soft); }
.notice.warn { background: var(--amber-soft); }
.notice.ok { background: var(--accent-soft); }

.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.list > li { display: flex; gap: 10px; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.list > li:last-child { border-bottom: 0; }
.list .meta { min-width: 0; overflow-wrap: anywhere; }
.list .acts { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.list .acts select { width: auto; max-width: 220px; padding: 6px 8px; font-size: 13px; }
.pill { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.pill.amber { background: var(--amber-soft); color: var(--amber); }
.pill.off { background: var(--danger-soft); color: var(--danger); }
.day-head { font-size: 12px !important; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; padding-top: 14px !important; border-bottom: 0 !important; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
@media (max-width: 640px) { .stats { grid-template-columns: 1fr 1fr; } }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.stat b { display: block; font-size: 24px; font-variant-numeric: tabular-nums; }
.stat span { font-size: 13px; color: var(--muted); }

.legend { display: flex; gap: 16px; font-size: 13px; color: var(--muted); flex-wrap: wrap; margin-top: -4px; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.sw.zd, .seg.zd { background: var(--zd); } .sw.lg, .seg.lg { background: var(--accent); }
.weekbars { display: flex; flex-direction: column; gap: 10px; }
.wk { display: grid; grid-template-columns: 9.5em 1fr 6.5em; gap: 10px; align-items: center; font-size: 14px; }
.wk .stack-bar { display: flex; height: 16px; background: var(--surface-2); border-radius: 6px; overflow: hidden; }
.wk .seg { height: 100%; }
.wk .val { text-align: right; font-variant-numeric: tabular-nums; font-size: 13px; }
@media (max-width: 520px) { .wk { grid-template-columns: 1fr auto; } .wk .stack-bar { grid-column: 1 / -1; grid-row: 2; } }
.bars { display: flex; flex-direction: column; gap: 8px; }
.bar { display: grid; grid-template-columns: minmax(0, 15em) 1fr 4.5em; gap: 10px; align-items: center; font-size: 14px; }
.bar .lbl { overflow-wrap: anywhere; }
.bar .track { height: 12px; background: var(--surface-2); border-radius: 6px; overflow: hidden; }
.bar .fill { height: 100%; background: var(--accent); border-radius: 6px; }
.bar .val { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
@media (max-width: 520px) { .bar { grid-template-columns: 1fr auto; } .bar .track { grid-column: 1 / -1; grid-row: 2; } }
.split { display: flex; height: 14px; border-radius: 7px; overflow: hidden; background: var(--surface-2); margin-top: 8px; }
.split .a { background: var(--amber); }

.cat-row { flex-wrap: wrap; }
.cat-row .meta { flex: 1 1 260px; display: flex; flex-direction: column; gap: 6px; }
.cat-row input { padding: 7px 10px; font-size: 14px; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: 20px; background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 600; font-size: 14px; z-index: 50; max-width: calc(100% - 32px); }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
