:root {
  --bg: #f6f7f9; --card: #fcfcfb; --text: #0b0b0b; --muted: #52514e; --line: #e3e6ea;
  --accent: #2563eb; --red: #c62828; --warn-bg: #fff4e5; --warn-text: #8a4b00;
  --series-1: #2a78d6; --grid: #e6e6e3; --hover: rgba(42, 120, 214, 0.08);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111418; --card: #1a1a19; --text: #f0efec; --muted: #c3c2b7; --line: #2b323a;
    --accent: #5b8def; --red: #ef5350; --warn-bg: #3a2a12; --warn-text: #ffcc80;
    --series-1: #3987e5; --grid: #2e2e2c; --hover: rgba(57, 135, 229, 0.14);
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.55 system-ui, -apple-system, "Noto Sans TC", sans-serif; }
main { max-width: 760px; margin: 0 auto; padding: 16px; }
header { display: flex; align-items: center; justify-content: space-between; }
h1 { font-size: 20px; margin: 8px 0 12px; }
h2 { font-size: 16px; margin: 0 0 12px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin-bottom: 12px; }
.card.danger { border-color: var(--red); }
dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
dt { color: var(--muted); }
dd { margin: 0; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
label { display: block; margin-bottom: 12px; color: var(--muted); }
input { display: block; width: 100%; margin-top: 4px; padding: 10px; font-size: 16px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--text); }
button { padding: 10px 16px; font-size: 15px; border: 0; border-radius: 8px; background: var(--accent); color: #fff; cursor: pointer; }
button.red { background: var(--red); }
button.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.err { color: var(--red); min-height: 1.5em; }
.alert { background: var(--warn-bg); color: var(--warn-text); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; }
.muted { color: var(--muted); font-size: 13px; }

nav#tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
nav#tabs button { flex: none; background: transparent; color: var(--muted); border: 1px solid var(--line); padding: 8px 12px; font-size: 14px; }
nav#tabs button.on { background: var(--accent); color: #fff; border-color: var(--accent); }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; margin-bottom: 12px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.tile-label { color: var(--muted); font-size: 13px; }
.tile-value { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }
.tile-sub { color: var(--muted); font-size: 12px; }

.scroll { overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
table.grid th, table.grid td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
table.grid th:first-child, table.grid td:first-child { text-align: left; }
table.grid th { color: var(--muted); font-weight: 500; font-size: 13px; }

.chart svg { width: 100%; height: auto; display: block; touch-action: pan-y; }
.chart .bar { fill: var(--series-1); }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 11px; }
.chart .hover { fill: var(--hover); }
#tip { position: absolute; z-index: 10; pointer-events: none; background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; font-size: 13px; box-shadow: 0 2px 8px rgba(0,0,0,.12); white-space: nowrap; }
select { display: block; width: 100%; margin-top: 4px; padding: 10px; font-size: 16px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--text); }
.hint { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
#set-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 12px; }
h3 { font-size: 15px; margin: 16px 0 4px; }
.custom-row { border-top: 1px solid var(--line); padding-top: 8px; margin-bottom: 8px; }
.custom-title { font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.custom-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0 8px; }
.custom-grid label { margin-bottom: 4px; font-size: 12px; }
.custom-grid input, .custom-grid select { padding: 8px; font-size: 15px; }
@media (max-width: 480px) { .custom-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
