:root {
  --bg: #f7f7f5; --panel: #ffffff; --text: #1d1d1b; --muted: #6b6b66; --line: #e2e2dc;
  --accent: #1f5fbf; --ok: #1b7f3b; --warn: #a86400; --bad: #b3261e; --skip: #6b6b66; --rej: #6a3fb5;
  --banner-bg: #fff4d6; --banner-text: #6b4a00; --code-bg: #f0f0ea;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141413; --panel: #1d1d1b; --text: #ecece6; --muted: #a3a39c; --line: #33332f;
    --accent: #7fb0ff; --ok: #5fd184; --warn: #f0b04a; --bad: #ff7a70; --skip: #a3a39c; --rej: #b99bff;
    --banner-bg: #3a2f10; --banner-text: #ffd98a; --code-bg: #2a2a27;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
header { background: var(--panel); border-bottom: 1px solid var(--line); padding: 10px 16px;
  display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: center; }
header .brand { font-weight: 700; }
header nav { display: flex; gap: 14px; flex-wrap: wrap; }
header nav a { text-decoration: none; }
header nav a.on { font-weight: 700; text-decoration: underline; }
header form { margin-left: auto; }
.banner { background: var(--banner-bg); color: var(--banner-text); padding: 6px 16px; font-weight: 600; }
main { max-width: 1100px; margin: 0 auto; padding: 16px; }
h1 { font-size: 1.35rem; margin: 4px 0 14px; }
h2 { font-size: 1.05rem; margin: 0 0 10px; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 14px; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.flash { padding: 8px 12px; border-radius: 6px; margin-bottom: 12px; border: 1px solid; }
.flash.ok { color: var(--ok); border-color: var(--ok); }
.flash.err { color: var(--bad); border-color: var(--bad); }
.pill { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 0.8rem; font-weight: 600;
  border: 1px solid currentColor; }
.st-connected, .st-ok { color: var(--ok); }
.st-connecting, .st-starting, .st-warn, .st-not_configured, .st-disconnected { color: var(--warn); }
.st-error, .st-logged_out, .st-critical { color: var(--bad); }
.st-info { color: var(--muted); }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; }
td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.table-wrap { overflow-x: auto; }
.msg { white-space: pre-wrap; word-break: break-word; font-family: ui-monospace, Consolas, monospace; font-size: 0.85rem; }
.orig { color: var(--muted); }
form.stack { display: grid; gap: 8px; max-width: 460px; }
label { font-weight: 600; font-size: 0.9rem; }
input[type=text], input[type=password], input[type=tel], select {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg);
  color: var(--text); font: inherit; }
button { padding: 8px 14px; border-radius: 6px; border: 1px solid var(--accent); background: var(--accent);
  color: #fff; font: inherit; font-weight: 600; cursor: pointer; }
button.link { background: none; color: var(--accent); border: none; padding: 0; text-decoration: underline; }
button.secondary { background: none; color: var(--accent); }
.saved { color: var(--ok); font-weight: 600; }
.missing { color: var(--warn); font-weight: 600; }
code, .code { background: var(--code-bg); padding: 1px 6px; border-radius: 4px; font-family: ui-monospace, Consolas, monospace; }
.bigcode { font-size: 1.4rem; letter-spacing: 2px; padding: 6px 12px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.qr { background: #fff; padding: 8px; border-radius: 6px; width: 220px; height: 220px; }
.daynav { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.kind-edit { color: var(--warn); }
.kind-delete { color: var(--bad); }
footer { color: var(--muted); font-size: 0.8rem; text-align: center; padding: 16px; }
.mt { margin-top: 14px; }
/* v0.2 simple-UI pieces */
.chip { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 0.82rem; font-weight: 600; }
.chip.good { color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, transparent); }
.chip.todo { color: var(--warn); background: color-mix(in srgb, var(--warn) 14%, transparent); }
.chip.later { color: var(--muted); background: color-mix(in srgb, var(--muted) 14%, transparent); }
a.btn { display: inline-block; padding: 5px 12px; border-radius: 6px; border: 1px solid var(--accent);
  color: var(--accent); text-decoration: none; font-weight: 600; font-size: 0.9rem; margin-left: 6px; }
a.btn.big, button.big { font-size: 1.05rem; padding: 10px 18px; }
a.btn.big { background: var(--accent); color: #fff; }
.stepno { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent); color: #fff; font-size: 0.9rem; margin-right: 6px; }
ol.checklist { padding-left: 20px; margin: 0; display: grid; gap: 10px; }
ul.plain { margin: 6px 0 0; padding-left: 18px; font-size: 0.9rem; }
.callout { border: 2px dashed var(--accent); border-radius: 8px; padding: 12px; margin: 10px 0; }
.tabs { display: flex; gap: 10px; flex-wrap: wrap; }
.tabs a { text-decoration: none; padding: 2px 8px; border-radius: 6px; }
.tabs a.on { background: var(--accent); color: #fff; }
details > summary { cursor: pointer; color: var(--accent); font-weight: 600; }
.card.danger { border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
button.danger { background: var(--bad); border-color: var(--bad); }
.row.between { justify-content: space-between; }
label.plainlabel { font-weight: 400; }
/* trading pages */
.chip.bad { color: var(--bad); background: color-mix(in srgb, var(--bad) 12%, transparent); }
.chip.rej { color: var(--rej); background: color-mix(in srgb, var(--rej) 14%, transparent); }
.pos { color: var(--ok); font-weight: 600; }
.neg { color: var(--bad); font-weight: 600; }
p.big, .big { font-size: 1.35rem; font-weight: 700; margin: 4px 0; }
.grid.settings { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; display: grid; gap: 6px; margin: 0; }
legend { font-weight: 700; padding: 0 4px; }
input.short { width: 7.5em; }
input[type=checkbox], input[type=radio] { margin-right: 6px; }
.ipbox { border: 2px solid var(--accent); border-radius: 8px; padding: 10px 12px; margin-top: 8px; }
.ipbox code.big { font-size: 1.3rem; padding: 4px 10px; }
.portal-nav { display: flex; gap: 14px; flex-wrap: wrap; }
table.summary td:first-child { color: var(--muted); white-space: nowrap; width: 1%; padding-right: 14px; }
/* ---------- settings v2: tabs → clusters → cells ---------- */
.tabset { margin-top: 6px; }
.tabbar { display: flex; gap: 4px; overflow-x: auto; border-bottom: 2px solid var(--line); margin-bottom: 12px;
  position: sticky; top: 0; background: var(--panel); z-index: 2; scrollbar-width: thin; }
.tabbar button { background: none; color: var(--muted); border: none; border-bottom: 3px solid transparent;
  border-radius: 0; padding: 9px 14px; font-weight: 600; white-space: nowrap; }
.tabbar button.on { color: var(--accent); border-bottom-color: var(--accent); }
.tabbar button:hover { color: var(--text); }
.pane-title { font-size: 1rem; margin: 14px 0 8px; }
.js .pane-title { display: none; }
.js .tabpane { display: none; }
.js .tabpane.on { display: block; }
.clusters { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); align-items: start; }
.cluster { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px 10px; margin: 0; display: grid; gap: 2px; }
.cluster.wide { grid-column: 1 / -1; }
.cluster legend { font-weight: 700; padding: 0 6px; }
.cell { padding: 9px 0; border-bottom: 1px dashed var(--line); }
.cell:last-child { border-bottom: none; }
.cell-top { display: flex; align-items: center; gap: 10px; }
.cell-title { font-weight: 600; font-size: 0.93rem; }
.cell-ctrl { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; }
.cell-ctrl:empty { display: none; }
.cell-help { color: var(--muted); font-size: 0.8rem; margin-top: 4px; }
.cell.off .cell-ctrl, .cell.off .cell-help { opacity: 0.4; }
.numbox { display: inline-flex; align-items: center; gap: 6px; }
.numbox .unit, .tp-unit { color: var(--muted); font-size: 0.85rem; }
input.short { width: 6.5em; } input.mid { width: 9em; }
.choices { display: grid; gap: 6px; width: 100%; }
.choice { display: flex; gap: 8px; align-items: center; border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 10px; font-weight: 500; cursor: pointer; }
.choice:has(input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); }
.switch { position: relative; display: inline-block; width: 40px; height: 22px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider { position: absolute; inset: 0; background: var(--line); border-radius: 22px; transition: .15s; cursor: pointer; }
.switch .slider::before { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: .15s; }
.switch input:checked + .slider { background: var(--ok); }
.switch input:checked + .slider::before { transform: translateX(18px); }
.switch input:focus-visible + .slider { outline: 2px solid var(--accent); }
table.tpplan td, table.tpplan th { vertical-align: middle; }
table.tpplan select { min-width: 12em; }
table.tpplan tr.off td:not(:first-child) { opacity: 0.4; }
table.tpplan tr.extra td:nth-child(2)::after { content: " (only if more lots)"; color: var(--muted); font-weight: 400; font-size: 0.8rem; }
table.tpplan tr.rest { background: color-mix(in srgb, var(--accent) 6%, transparent); }
.summary-grid { display: grid; gap: 10px 18px; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.summary-grid h4 { margin: 0 0 2px; font-size: 0.85rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.summary-grid p { margin: 2px 0; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
