:root {
  --bg: #0b0b10;
  --panel: #13131b;
  --panel-2: #1b1b26;
  --border: #272735;
  --text: #ecebf5;
  --muted: #a09eb3;
  --faint: #6b6980;
  --accent: #8b5cf6;
  --accent-2: #b39dfa;
  --ok: #22c55e;
  --warn: #f59e0b;
  --danger: #ef4444;
  --radius: 14px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans', Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme='dark']) {
    --bg: #f6f6fa;
    --panel: #ffffff;
    --panel-2: #f1f0f7;
    --border: #e4e2ee;
    --text: #17161f;
    --muted: #5d5b70;
    --faint: #9a98ad;
    --accent: #7c3aed;
    --accent-2: #8b5cf6;
    color-scheme: light;
  }
}
:root[data-theme='light'] {
  --bg: #f6f6fa;
  --panel: #ffffff;
  --panel-2: #f1f0f7;
  --border: #e4e2ee;
  --text: #17161f;
  --muted: #5d5b70;
  --faint: #9a98ad;
  --accent: #7c3aed;
  --accent-2: #8b5cf6;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre, .mono { font-family: var(--mono); font-size: 12.5px; }
h1, h2, h3 { margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 15px; font-weight: 600; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.hidden { display: none !important; }

/* ---------- layout ---------- */
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 20px 60px; }
.topbar {
  position: sticky; top: 0; z-index: 5;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar .wrap { display: flex; align-items: center; gap: 18px; height: 60px; padding-bottom: 0; }
.logo { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 17px; color: var(--text); }
.logo:hover { text-decoration: none; }
.logo svg { width: 26px; height: 26px; }
.tabs { display: flex; gap: 4px; margin-left: 8px; }
.tab {
  background: none; border: 0; color: var(--muted); font: inherit; font-weight: 500;
  padding: 7px 12px; border-radius: 8px; cursor: pointer;
}
.tab:hover { color: var(--text); background: var(--panel-2); }
.tab.active { color: var(--text); background: var(--panel-2); }
.spacer { flex: 1; }

.grid { display: grid; gap: 16px; }
.grid.tiles { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-top: 22px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.panel {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; min-width: 0;
}
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.section { margin-top: 16px; }

.tile .label { font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.tile .value { font-size: 24px; font-weight: 650; margin-top: 4px; letter-spacing: -0.02em; }
.tile .note { font-size: 12px; color: var(--faint); margin-top: 2px; }

/* ---------- controls ---------- */
select, input[type='text'], input[type='password'], input[type='number'], textarea {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--border);
  border-radius: 9px; padding: 8px 11px; font: inherit; outline: none; width: 100%;
}
select { width: auto; cursor: pointer; }
select:focus, input:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 90px; font-family: var(--mono); font-size: 12.5px; }
.btn {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border);
  background: var(--panel-2); color: var(--text); font: inherit; font-weight: 500;
  padding: 8px 14px; border-radius: 9px; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--faint); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.small { padding: 5px 10px; font-size: 12.5px; }
.seg { display: inline-flex; background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; padding: 3px; }
.seg button { background: none; border: 0; color: var(--muted); font: inherit; font-size: 13px; padding: 5px 11px; border-radius: 7px; cursor: pointer; }
.seg button.active { background: var(--panel); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.25); }

.field { display: grid; gap: 6px; margin-bottom: 16px; }
.field label { font-weight: 600; font-size: 13px; }
.field .hint { font-size: 12.5px; color: var(--muted); }
.check { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 14px; cursor: pointer; }
.check input { margin-top: 3px; accent-color: var(--accent); }

.code {
  position: relative; background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 14px; padding-right: 74px; white-space: pre-wrap; overflow-wrap: anywhere; font-family: var(--mono); font-size: 12.5px;
}
.code .copy { position: absolute; top: 8px; right: 8px; }

.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 9px 16px; border-radius: 10px; font-weight: 500;
  box-shadow: 0 8px 30px rgba(0,0,0,.35); z-index: 20;
}
.banner { border: 1px solid var(--border); border-left: 3px solid var(--warn); background: var(--panel); border-radius: 10px; padding: 12px 14px; margin-top: 18px; }
.empty { color: var(--faint); padding: 18px 0; text-align: center; }

/* ---------- charts ---------- */
.bars { display: grid; gap: 11px; }
.bar-row .top { display: flex; justify-content: space-between; gap: 12px; font-size: 13.5px; }
.bar-row .name { display: flex; align-items: center; gap: 8px; min-width: 0; }
.bar-row .name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row .dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.bar-row .val { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.bar-row .track { height: 6px; background: var(--panel-2); border-radius: 4px; margin-top: 6px; overflow: hidden; }
.bar-row .fill { height: 100%; border-radius: 4px; }
.more { margin-top: 12px; }

.daily { display: flex; align-items: flex-end; gap: 3px; height: 180px; padding-top: 10px; }
.daily .col { flex: 1; min-width: 2px; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; position: relative; }
.daily .col .b { background: var(--accent); border-radius: 4px 4px 1px 1px; min-height: 0; opacity: .9; transition: opacity .15s; }
.daily .col:hover .b { opacity: 1; filter: brightness(1.15); }
.daily-axis { display: flex; justify-content: space-between; color: var(--faint); font-size: 11.5px; margin-top: 8px; }
.tip {
  position: fixed; pointer-events: none; z-index: 30; background: var(--text); color: var(--bg);
  padding: 6px 9px; border-radius: 8px; font-size: 12px; white-space: nowrap;
}

.heat-wrap { overflow-x: auto; }
.heat-inner { width: max-content; margin: 0 auto; }
.heat { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 12px); gap: 3px; width: max-content; }
.heat i { width: 12px; height: 12px; border-radius: 3px; background: var(--panel-2); display: block; }
.heat i.l1 { background: color-mix(in srgb, var(--accent) 32%, var(--panel-2)); }
.heat i.l2 { background: color-mix(in srgb, var(--accent) 56%, var(--panel-2)); }
.heat i.l3 { background: color-mix(in srgb, var(--accent) 80%, var(--panel-2)); }
.heat i.l4 { background: var(--accent); }
.heat i.out { visibility: hidden; }
.heat-months { position: relative; height: 16px; font-size: 11px; color: var(--faint); width: max-content; }
.heat-months span { position: absolute; top: 0; }
.legend { display: flex; align-items: center; gap: 4px; justify-content: flex-end; color: var(--faint); font-size: 11.5px; margin-top: 10px; }
.legend i { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }

.split { display: flex; height: 10px; border-radius: 6px; overflow: hidden; background: var(--panel-2); }
.split div { height: 100%; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login .panel { width: 100%; max-width: 420px; padding: 30px; }
.login h1 { font-size: 22px; margin: 18px 0 6px; }
.login form { display: grid; gap: 12px; margin-top: 20px; }
.err { color: var(--danger); font-size: 13px; min-height: 18px; }

/* ---------- share ---------- */
.preview { background: var(--panel-2); border: 1px dashed var(--border); border-radius: 12px; padding: 18px; display: grid; place-items: center; min-height: 140px; overflow: auto; }
.preview img { max-width: 100%; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row > label { font-size: 12.5px; color: var(--muted); display: grid; gap: 4px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 18px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

@media (max-width: 720px) {
  .tabs { overflow-x: auto; }
  .topbar .wrap { gap: 10px; }
  .logo span { display: none; }
}
