:root, html[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f5f8;
  --card: #ffffff;
  --text: #14162b;
  --muted: #5c6178;
  --line: #e3e5ee;
  --brand: #010066;
  --brand-2: #1d2a8a;
  --heat: #e06a1a;
  --tuv: #d64545;
  --sv: #1f7ad1;
  --warn: #c2410c;
  --ok: #157a4b;
  --btn: #010066;
  --shadow: 0 1px 2px rgba(16, 18, 40, .06), 0 8px 24px rgba(16, 18, 40, .05);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0c0e18;
  --card: #171a2b;
  --text: #eef0f8;
  --muted: #a7adc4;
  --line: #2a2f48;
  --brand: #8ea0ff;
  --brand-2: #6f84ff;
  --heat: #ff9a4a;
  --tuv: #ff7a7a;
  --sv: #6db4ff;
  --warn: #ffb086;
  --ok: #5ddea0;
  --btn: #3d4fd6;
  --shadow: none;
}
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0c0e18;
    --card: #171a2b;
    --text: #eef0f8;
    --muted: #a7adc4;
    --line: #2a2f48;
    --brand: #8ea0ff;
    --brand-2: #6f84ff;
    --heat: #ff9a4a;
    --tuv: #ff7a7a;
    --sv: #6db4ff;
    --warn: #ffb086;
    --ok: #5ddea0;
    --btn: #3d4fd6;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
body { min-height: 100dvh; }
button, input { font: inherit; }
a { color: inherit; }

.top {
  position: sticky; top: 0; z-index: 5;
  padding: calc(10px + var(--safe-top)) 14px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 8px;
}
.top h1 { font-size: 1.05rem; margin: 0; flex: 1; line-height: 1.2; }
.top .sub { display: block; font-size: .75rem; color: var(--muted); font-weight: 500; }
.iconbtn {
  border: 1px solid var(--line); background: var(--card); color: var(--text);
  border-radius: 12px; min-width: 40px; height: 40px; padding: 0 10px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px;
  background: #e11d48; color: white; font-size: .72rem; font-weight: 700;
}
main { padding: 12px 14px calc(24px + var(--safe-bottom)); max-width: 720px; margin: 0 auto; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: var(--shadow); padding: 14px; margin: 0 0 10px;
}
.card.tap { cursor: pointer; }
.row { display: flex; align-items: center; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.title { font-weight: 700; font-size: 1.05rem; }
.muted { color: var(--muted); font-size: .86rem; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip {
  font-size: .78rem; border-radius: 99px; padding: 3px 8px;
  background: color-mix(in srgb, var(--brand) 10%, var(--card));
  border: 1px solid var(--line);
}
.chip.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, var(--line)); }
.chip.ok { color: var(--ok); }

.seg { display: flex; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 3px; gap: 3px; margin: 8px 0 12px; }
.seg button { flex: 1; border: 0; background: transparent; color: var(--muted); border-radius: 9px; padding: 8px 6px; font-weight: 600; }
.seg button.on { background: var(--btn); color: #fff; }

.login-wrap { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: calc(24px + var(--safe-top)) 18px calc(24px + var(--safe-bottom)); }
.login { width: 100%; max-width: 380px; }
.logo { width: 72px; height: 72px; border-radius: 18px; display: block; margin: 0 auto 12px; }
.login h1 { text-align: center; margin: 0 0 4px; font-size: 1.4rem; }
.login p { text-align: center; color: var(--muted); margin: 0 0 16px; }
label { display: block; font-size: .85rem; color: var(--muted); margin: 10px 0 4px; }
input[type=email], input[type=password], input[type=text] {
  width: 100%; border: 1px solid var(--line); background: var(--bg); color: var(--text);
  border-radius: 12px; padding: 12px 12px; font-size: 16px;
}
.primary {
  width: 100%; margin-top: 14px; border: 0; border-radius: 12px; padding: 13px;
  background: var(--btn, #010066); color: #fff; font-weight: 700;
}
.err { color: #e11d48; font-size: .9rem; margin-top: 10px; text-align: center; }
.note { font-size: .8rem; color: var(--muted); margin-top: 12px; text-align: center; }

.chartbox { margin-top: 6px; }
.chartbox svg { width: 100%; height: auto; display: block; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: .8rem; color: var(--muted); margin-top: 6px; }
.dot { width: 9px; height: 9px; border-radius: 99px; display: inline-block; margin-right: 4px; }
.empty {
  border: 1px dashed var(--line); border-radius: 12px; padding: 16px; text-align: center; color: var(--muted);
}
.listbtn {
  width: 100%; text-align: left; border: 1px solid var(--line); background: var(--card);
  border-radius: 14px; padding: 12px; margin: 0 0 8px; color: var(--text);
  display: flex; align-items: center; gap: 8px;
}
.chev { color: var(--muted); font-size: 1.2rem; }
table { width: 100%; border-collapse: collapse; font-size: .82rem; }
th, td { text-align: right; padding: 6px 4px; border-bottom: 1px solid var(--line); }
th:first-child, td:first-child { text-align: left; }
.section-title { font-size: .95rem; margin: 16px 0 8px; }
.small { font-size: .78rem; color: var(--muted); }
.spin { text-align: center; color: var(--muted); padding: 24px 0; }

.login-wrap { position: relative; }
.login-theme {
  position: absolute; top: calc(10px + var(--safe-top)); right: 14px;
}
.theme-ico { width: 20px; height: 20px; display: block; }
