:root {
  --bg: #0e1116;
  --panel: #161b22;
  --panel-2: #1c222b;
  --line: #2a313c;
  --text: #e8ebf0;
  --muted: #8d97a5;
  --accent: #35d0c0;
  --dl: #4cb8ff;
  --ul: #b891ff;
  --ok: #46c27a;
  --warn: #e5b04a;
  --bad: #ef6b6b;
  --radius: 10px;
  font-family: system-ui, -apple-system, "Segoe UI", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { min-height: 100vh; font-size: 15px; line-height: 1.5; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------- login ---------- */
body.center { display: grid; place-items: center; padding: 24px; }
.login-card {
  width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 32px 28px;
}
.brand { font-size: 22px; font-weight: 700; letter-spacing: .02em; }
.brand span { color: var(--accent); }
.login-card p.sub { color: var(--muted); margin: 6px 0 24px; font-size: 14px; }
label { display: block; font-size: 13px; color: var(--muted); margin: 14px 0 6px; }
input[type=text], input[type=email], input[type=password], select {
  width: 100%; padding: 10px 12px; background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; outline: none;
}
input:focus, select:focus { border-color: var(--accent); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer;
  padding: 10px 16px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel-2);
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #05221f; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: default; }
.login-card .btn { width: 100%; margin-top: 22px; }
.error { color: var(--bad); font-size: 14px; min-height: 20px; margin-top: 12px; }

/* ---------- app shell ---------- */
.topbar {
  display: flex; align-items: center; gap: 16px; padding: 14px 24px; border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.topbar .spacer { flex: 1; }
.topbar .who { color: var(--muted); font-size: 14px; }
.topbar nav { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
main { max-width: 1040px; margin: 0 auto; padding: 24px 20px 60px; }
section { margin-top: 36px; }
section > h2 { font-size: 16px; margin: 0 0 14px; font-weight: 600; }
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

/* ---------- test ---------- */
.hero { display: grid; justify-items: center; gap: 12px; margin-top: 8px; }
.gauge-wrap { position: relative; width: min(100%, 520px); aspect-ratio: 520 / 340; }
.gauge-wrap canvas { width: 100%; height: 100%; display: block; }
.gauge-center { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.gauge-center .inner { text-align: center; margin-top: 18%; pointer-events: auto; }
#start {
  width: 132px; height: 132px; border-radius: 50%; font-size: 22px; font-weight: 700; letter-spacing: .08em;
  background: transparent; color: var(--accent); border: 3px solid var(--accent); cursor: pointer;
}
#start:hover { background: rgba(53, 208, 192, .12); }
#start.running { color: var(--muted); border-color: var(--line); font-size: 14px; width: 56px; height: 56px; margin-top: 10px; letter-spacing: 0; }
.readout { font-size: 44px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.readout small { font-size: 14px; color: var(--muted); font-weight: 400; margin-left: 4px; }
.phase { color: var(--muted); font-size: 13px; margin-top: 6px; min-height: 18px; }

.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; width: 100%; margin-top: 8px; }
.metric { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.metric .k { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 8px; }
.metric .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.metric .v { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 4px; }
.metric .v small { font-size: 13px; color: var(--muted); font-weight: 400; }
.metric .sub { color: var(--muted); font-size: 12px; min-height: 18px; }

.meta {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; width: 100%;
}
.meta > div { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; }
.meta .k { color: var(--muted); font-size: 12px; }
.meta .v { font-size: 14px; word-break: break-all; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 12px; border: 1px solid var(--line); }
.badge.ok { color: var(--ok); border-color: var(--ok); }
.badge.warn { color: var(--warn); border-color: var(--warn); }
.note { color: var(--muted); font-size: 12.5px; max-width: 760px; text-align: center; }
.alert { color: var(--bad); min-height: 20px; font-size: 14px; text-align: center; }

/* ---------- tables & charts ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.chart-box { height: 260px; }
.chart-box canvas { width: 100%; height: 100%; display: block; }
.table-wrap { overflow-x: auto; margin-top: 12px; border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
th, td { padding: 9px 12px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
th { color: var(--muted); font-weight: 500; background: var(--panel); }
tr:last-child td { border-bottom: 0; }
td.left, th.left { text-align: left; }

.form-grid { display: grid; grid-template-columns: 2fr 2fr 1fr auto; gap: 10px; align-items: end; }
.form-grid label { margin: 0 0 4px; }
dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; width: min(92vw, 380px); }
dialog::backdrop { background: rgba(0, 0, 0, .6); }

@media (max-width: 760px) {
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .meta { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .topbar { flex-wrap: wrap; padding: 12px 16px; }
}
