:root {
  --bg: #0c0f14; --panel: #141922; --panel2: #1b222e; --line: #273041; --text: #e9eef6; --muted: #93a0b5;
  --accent: #63e6a4; --accent-ink: #062414; --blue: #6fb1ff; --warn: #ffc857; --bad: #ff6b6b; --radius: 12px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0 0 4px; letter-spacing: -0.01em; }
h2 { font-size: 1.05rem; margin: 0 0 12px; }
h3 { font-size: 0.8rem; margin: 0 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
p { margin: 0 0 10px; }
.sub { color: var(--muted); margin-bottom: 18px; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

.topbar { position: fixed; inset: 0 0 auto 0; height: 54px; display: flex; align-items: center; gap: 10px; padding: 0 14px; background: rgba(12, 15, 20, 0.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); z-index: 30; }
.brand { display: flex; align-items: center; gap: 8px; color: var(--accent); font-weight: 800; font-size: 1.2rem; letter-spacing: -0.02em; }
.brand:hover { text-decoration: none; }
.brand span { color: var(--text); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: 0.85rem; color: var(--muted); min-width: 0; }
.topbar-right img { width: 28px; height: 28px; border-radius: 50%; }
.icon-btn { display: none; background: none; border: 0; color: var(--text); font-size: 1.3rem; padding: 6px 8px; cursor: pointer; }

.sidebar { position: fixed; top: 54px; bottom: 0; left: 0; width: 220px; overflow-y: auto; padding: 10px 10px 30px; border-right: 1px solid var(--line); background: var(--bg); z-index: 20; }
.sidebar a { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; border-radius: 8px; color: var(--text); font-size: 0.93rem; }
.sidebar a:hover { background: var(--panel); text-decoration: none; }
.sidebar a.active { background: var(--panel2); color: var(--accent); font-weight: 600; }
.nav-group { margin: 16px 12px 6px; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.pill { background: var(--bad); color: #fff; border-radius: 99px; font-size: 0.7rem; padding: 1px 7px; font-weight: 700; }
.scrim { display: none; }

main { margin: 54px 0 0 220px; padding: 24px 28px 80px; max-width: 1180px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 16px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid > .card { margin-bottom: 0; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.top { align-items: flex-start; }
.grow { flex: 1 1 200px; min-width: 0; }
.right { margin-left: auto; }

input, select, textarea, button { font: inherit; color: inherit; }
input[type=text], input[type=password], input[type=search], input[type=number], select, textarea {
  width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { min-height: 110px; resize: vertical; }
label { display: block; font-size: 0.82rem; color: var(--muted); margin: 10px 0 4px; }
input[type=color] { width: 44px; height: 36px; padding: 2px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; }
input[type=range] { width: 100%; accent-color: var(--accent); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 8px; padding: 9px 16px; font-weight: 700; cursor: pointer; white-space: nowrap; }
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn:disabled { opacity: 0.5; cursor: wait; }
.btn.ghost { background: var(--panel2); color: var(--text); border: 1px solid var(--line); font-weight: 600; }
.btn.danger { background: transparent; color: var(--bad); border: 1px solid var(--bad); font-weight: 600; }
.btn.sm { padding: 5px 10px; font-size: 0.82rem; }
.search { display: flex; gap: 8px; margin-bottom: 16px; }
.search input { flex: 1; }

.stat { display: flex; flex-direction: column; gap: 2px; }
.stat b { font-size: 1.45rem; letter-spacing: -0.02em; }
.stat span { color: var(--muted); font-size: 0.8rem; }
.delta-up { color: var(--accent); } .delta-down { color: var(--bad); }
.ring { position: relative; width: 108px; height: 108px; flex: none; }
.ring svg { transform: rotate(-90deg); }
.ring .num { position: absolute; inset: 0; display: grid; place-items: center; font-size: 1.7rem; font-weight: 800; }
.ring.sm { width: 54px; height: 54px; } .ring.sm .num { font-size: 0.95rem; }
.meter { height: 8px; background: var(--panel2); border-radius: 99px; overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: 99px; background: var(--accent); }
.tag { display: inline-block; background: var(--panel2); border: 1px solid var(--line); border-radius: 99px; padding: 3px 10px; font-size: 0.82rem; margin: 0 6px 6px 0; cursor: default; }
button.tag, a.tag { cursor: pointer; color: var(--text); }
button.tag:hover, a.tag:hover { border-color: var(--accent); text-decoration: none; }
.badge { display: inline-block; border-radius: 6px; padding: 1px 7px; font-size: 0.74rem; font-weight: 700; background: var(--panel2); color: var(--muted); }
.badge.good { background: rgba(99, 230, 164, 0.15); color: var(--accent); }
.badge.mid { background: rgba(255, 200, 87, 0.15); color: var(--warn); }
.badge.bad { background: rgba(255, 107, 107, 0.15); color: var(--bad); }

.vrow { display: flex; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); align-items: flex-start; }
.vrow:first-child { border-top: 0; }
.vrow img { width: 128px; aspect-ratio: 16/9; object-fit: cover; border-radius: 8px; background: var(--panel2); flex: none; }
.vrow .t { font-weight: 600; color: var(--text); display: block; overflow-wrap: anywhere; }
.vrow .m { color: var(--muted); font-size: 0.82rem; }
.check { display: flex; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); }
.check:first-child { border-top: 0; }
.check .dot { width: 20px; height: 20px; border-radius: 50%; flex: none; display: grid; place-items: center; font-size: 0.75rem; font-weight: 800; margin-top: 2px; }
.check .dot.ok { background: rgba(99, 230, 164, 0.18); color: var(--accent); }
.check .dot.no { background: rgba(255, 107, 107, 0.18); color: var(--bad); }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 8px 10px; border-top: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; border-top: 0; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; }
.scroll-x { overflow-x: auto; }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--panel2); flex: none; object-fit: cover; }
.notice { border-left: 3px solid var(--warn); background: rgba(255, 200, 87, 0.08); padding: 10px 14px; border-radius: 0 8px 8px 0; margin-bottom: 16px; }
.notice.info { border-color: var(--blue); background: rgba(111, 177, 255, 0.08); }
.empty { text-align: center; color: var(--muted); padding: 34px 10px; }
.chart { width: 100%; height: auto; display: block; }
.tabs { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.tabs button { background: var(--panel); border: 1px solid var(--line); color: var(--muted); border-radius: 99px; padding: 6px 14px; cursor: pointer; font-weight: 600; }
.tabs button.on { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }
.chat { display: flex; flex-direction: column; gap: 10px; min-height: 240px; }
.msg { max-width: 85%; padding: 10px 14px; border-radius: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; background: var(--accent); color: var(--accent-ink); }
.msg.assistant { align-self: flex-start; background: var(--panel2); }
.comment { padding: 12px 0; border-top: 1px solid var(--line); }
.comment:first-child { border-top: 0; }
.comment .reply { margin: 8px 0 0 28px; padding-left: 12px; border-left: 2px solid var(--line); font-size: 0.9rem; }
canvas#thumb { width: 100%; height: auto; border-radius: 10px; border: 1px solid var(--line); background: #000; }
code, .mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.85em; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 2px 6px; overflow-wrap: anywhere; }
.copybox { display: flex; gap: 8px; align-items: center; }
.copybox input { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.82rem; }
#toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); background: var(--panel2); border: 1px solid var(--line); padding: 10px 16px; border-radius: 10px; opacity: 0; pointer-events: none; transition: opacity 0.2s; z-index: 50; max-width: 90vw; }
#toast.show { opacity: 1; }
#toast.err { border-color: var(--bad); }
.spinner { width: 22px; height: 22px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.login { max-width: 340px; margin: 12vh auto; }

@media (max-width: 900px) {
  .icon-btn { display: block; }
  .sidebar { transform: translateX(-100%); transition: transform 0.2s; width: 250px; }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: 54px 0 0 0; background: rgba(0, 0, 0, 0.55); z-index: 15; }
  main { margin-left: 0; padding: 18px 14px 80px; }
  .g2, .g3 { grid-template-columns: 1fr; }
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .vrow img { width: 96px; }
  .topbar-right .hide-sm { display: none; }
}
