:root {
  --bg: #f3f5ef; --card: #ffffff; --card2: #f7f8f4; --ink: #142019; --muted: #5d6b62; --line: #e1e6dc;
  --brand: #0f8a4a; --brand-ink: #ffffff; --brand-soft: #dff3e6;
  --good: #138a43; --bad: #d03232; --warn: #c27803; --warn-soft: #fff4dc; --bad-soft: #fde8e8;
  --gold: #e7a600; --shadow: 0 1px 2px rgba(20, 32, 25, .06), 0 4px 16px rgba(20, 32, 25, .06);
  --r: 16px; color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1411; --card: #17201b; --card2: #1d2822; --ink: #e9f1ec; --muted: #9aaba1; --line: #2a362f;
    --brand: #2fbf71; --brand-ink: #062513; --brand-soft: #173826;
    --good: #3ccf7f; --bad: #ff6b6b; --warn: #f5b13d; --warn-soft: #33290f; --bad-soft: #3a1c1c;
    --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1411; --card: #17201b; --card2: #1d2822; --ink: #e9f1ec; --muted: #9aaba1; --line: #2a362f;
  --brand: #2fbf71; --brand-ink: #062513; --brand-soft: #173826;
  --good: #3ccf7f; --bad: #ff6b6b; --warn: #f5b13d; --warn-soft: #33290f; --bad-soft: #3a1c1c;
  --shadow: none; color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.4 'Outfit', system-ui, -apple-system, 'Segoe UI', sans-serif; -webkit-font-smoothing: antialiased; }
h1, h2, h3 { margin: 0; line-height: 1.15; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0; }
button, input, select { font: inherit; color: inherit; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.tiny { font-size: .75rem; }
.good { color: var(--good); }
.bad { color: var(--bad); }
.warn { color: var(--warn); }
.row { display: flex; align-items: center; gap: 10px; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.stack > * + * { margin-top: 12px; }
.grow { flex: 1; min-width: 0; }
.right { text-align: right; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; box-shadow: var(--shadow); }
.card.flat { box-shadow: none; }
.card h2 + *, .card h3 + * { margin-top: 10px; }

.btn { appearance: none; border: 0; border-radius: 12px; padding: 12px 16px; font-weight: 600; cursor: pointer; background: var(--brand); color: var(--brand-ink);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; transition: transform .08s, opacity .15s; }
.btn:active { transform: scale(.97); }
a.btn { text-decoration: none; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.ghost { background: var(--card2); color: var(--ink); border: 1px solid var(--line); }
.btn.danger { background: #c62828; color: #fff; }
.btn.warnb { background: var(--warn); color: #1c1300; }
.btn.sm { padding: 7px 12px; min-height: 36px; border-radius: 10px; font-size: .9rem; }
.btn.block { width: 100%; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: var(--card2); border: 1px solid var(--line); font-size: .8rem; font-weight: 600; }
.chip.live { background: var(--brand-soft); border-color: transparent; color: var(--good); }
.chip.paused { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.chip.badc { background: var(--bad-soft); border-color: transparent; color: var(--bad); }

input[type=text], input[type=number], input[type=password], select { width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--card2); min-height: 46px; }
input:focus, select:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
label.field { display: block; }
label.field > span { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 6px; font-weight: 600; }

.bar { height: 8px; background: var(--card2); border-radius: 99px; overflow: hidden; border: 1px solid var(--line); }
.bar > i { display: block; height: 100%; background: var(--brand); border-radius: 99px; transition: width .3s linear; }

.spark .line { fill: none; stroke: var(--good); stroke-width: 2; stroke-linejoin: round; }
.spark .area { fill: var(--good); opacity: .12; }
.spark.down .line { stroke: var(--bad); }
.spark.down .area { fill: var(--bad); }

.list > * { padding: 12px 0; border-top: 1px solid var(--line); }
.list > *:first-child { border-top: 0; padding-top: 0; }
.list > *:last-child { padding-bottom: 0; }

.toggle { position: relative; width: 50px; height: 30px; flex: none; }
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle span { position: absolute; inset: 0; background: var(--line); border-radius: 99px; transition: .2s; cursor: pointer; }
.toggle span::after { content: ''; position: absolute; width: 24px; height: 24px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.toggle input:checked + span { background: var(--brand); }
.toggle input:checked + span::after { transform: translateX(20px); }

.seg { display: flex; background: var(--card2); border: 1px solid var(--line); border-radius: 12px; padding: 3px; gap: 3px; }
.seg button { flex: 1; border: 0; background: none; border-radius: 9px; padding: 8px 6px; font-weight: 600; font-size: .85rem; cursor: pointer; min-height: 38px; }
.seg button.on { background: var(--card); box-shadow: var(--shadow); color: var(--brand); outline: 1px solid var(--line); }

#toasts { position: fixed; left: 50%; transform: translateX(-50%); top: 12px; z-index: 100; display: flex; flex-direction: column; gap: 8px; width: min(92vw, 420px); pointer-events: none; }
.toast { background: var(--ink); color: var(--bg); padding: 12px 16px; border-radius: 12px; font-weight: 600; box-shadow: 0 8px 24px rgba(0,0,0,.2); animation: tin .2s; transition: opacity .4s, transform .4s; }
.toast.bad { background: var(--bad); color: #fff; }
.toast.out { opacity: 0; transform: translateY(-8px); }
@keyframes tin { from { opacity: 0; transform: translateY(-8px); } }

.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 50; display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
.sheet { background: var(--bg); width: min(100%, 520px); max-height: 92vh; overflow: auto; border-radius: 22px 22px 0 0; padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); animation: up .2s ease-out; }
@media (min-width: 640px) { .sheet-bg { align-items: center; } .sheet { border-radius: 22px; } }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(40px); opacity: .5; } }

.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: -.02em; }
.brand .logo { width: 36px; height: 36px; border-radius: 10px; background: var(--brand); color: var(--brand-ink); display: grid; place-items: center; font-size: 20px; }

/* Themed confirm pop-up (ask() in common.js); sits above sheets and modals. */
.ask-bg { position: fixed; inset: 0; z-index: 200; background: rgba(0,0,0,.55); display: grid; place-items: center; padding: 16px; animation: fade .15s; }
.ask { background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 22px; width: min(100%, 400px); text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.35); animation: askpop .18s ease-out; }
.ask-e { font-size: 2.6rem; line-height: 1; margin-bottom: 8px; }
.ask h2 { font-size: 1.2rem; }
.ask p { margin-top: 8px; font-size: .95rem; }
.ask-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 18px; }
@keyframes askpop { from { transform: scale(.94); opacity: 0; } }
