:root {
  --bg: #08080a;
  --panel: #111115;
  --panel-2: #16161b;
  --line: rgba(244, 243, 239, .08);
  --line-2: rgba(244, 243, 239, .14);
  --text: #f4f3ef;
  --muted: #a3a3a8;
  --dim: #6b6b70;
  --accent: #8f7dff;
  --accent-soft: rgba(143, 125, 255, .16);
  --ok: #3ecf8e;
  --down: #ff5a5f;
  --warn: #f5a524;
  --pink: #ff7ad9;
  --blue: #5b8def;
  --radius: 14px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 "Aptos Narrow", "Barlow Semi Condensed", system-ui, -apple-system, "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12.5px; }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.nowrap { white-space: nowrap; }

/* shell */
.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 20px; padding: 0 24px; height: 56px; background: rgba(8, 8, 10, .8); backdrop-filter: blur(16px); border-bottom: 1px solid var(--line); }
nav.tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
nav.tabs a { padding: 6px 12px; border-radius: 8px; color: var(--muted); white-space: nowrap; }
nav.tabs a:hover { background: var(--panel-2); color: var(--text); text-decoration: none; }
nav.tabs a.on { background: var(--accent-soft); color: var(--text); }
.top .spacer { flex: 1; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line-2); font-size: 12px; color: var(--muted); white-space: nowrap; }
.pill .led { width: 7px; height: 7px; border-radius: 50%; background: var(--dim); }
.pill.ok .led { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.pill.down .led { background: var(--down); box-shadow: 0 0 8px var(--down); }
.pill.live .led { background: var(--pink); animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.btn { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--line-2); background: transparent; cursor: pointer; color: var(--text); white-space: nowrap; }
.btn:hover { background: var(--panel-2); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #08080a; font-weight: 600; }
.btn.primary:hover { opacity: .9; }

main { max-width: 1440px; margin: 0 auto; padding: 24px; }
.head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.head h1 { margin: 0; font-size: 26px; font-weight: 600; letter-spacing: -.02em; }
.head p { margin: 4px 0 0; color: var(--muted); }
.seg { display: inline-flex; padding: 3px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); }
.seg button { border: 0; background: none; padding: 5px 11px; border-radius: 7px; color: var(--muted); cursor: pointer; }
.seg button.on { background: var(--panel-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-2); }

/* grid */
.grid { display: grid; gap: 14px; grid-template-columns: repeat(12, minmax(0, 1fr)); margin-bottom: 14px; }
.c3 { grid-column: span 3; } .c4 { grid-column: span 4; } .c5 { grid-column: span 5; } .c6 { grid-column: span 6; }
.c7 { grid-column: span 7; } .c8 { grid-column: span 8; } .c12 { grid-column: span 12; }
@media (max-width: 1100px) { .c3, .c4 { grid-column: span 6; } .c5, .c6, .c7, .c8 { grid-column: span 12; } }
@media (max-width: 640px) { .c3, .c4, .c6 { grid-column: span 12; } main { padding: 16px; } .top { padding: 0 16px; } }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; min-width: 0; }
.card h3 { margin: 0 0 12px; font-size: 13px; font-weight: 500; color: var(--muted); display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.card h3 .hint { color: var(--dim); font-weight: 400; font-size: 12px; }
.section-title { margin: 28px 0 12px; font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--dim); display: flex; align-items: center; gap: 10px; }
.section-title::before { content: ""; width: 16px; height: 1px; background: var(--accent); }

/* KPIs */
.kpis { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); margin-bottom: 14px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; min-width: 0; }
.kpi .l { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .v { font-size: 24px; font-weight: 600; letter-spacing: -.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .d { font-size: 12px; margin-top: 2px; color: var(--dim); }
.kpi .d.up { color: var(--ok); } .kpi .d.down { color: var(--down); }
.kpi.accent { background: linear-gradient(160deg, rgba(143, 125, 255, .18), var(--panel) 70%); border-color: rgba(143, 125, 255, .3); }

/* charts */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.axis text { fill: var(--dim); font-size: 10.5px; }
.axis line, .gridline { stroke: var(--line); }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 3px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }
.tip { position: fixed; z-index: 50; pointer-events: none; background: #1d1d23; border: 1px solid var(--line-2); border-radius: 8px; padding: 8px 10px; font-size: 12px; box-shadow: 0 8px 24px rgba(0, 0, 0, .5); max-width: 280px; }
.tip b { display: block; margin-bottom: 4px; font-weight: 600; }

.bars { display: flex; flex-direction: column; gap: 6px; }
.bar { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; position: relative; padding: 5px 8px; border-radius: 6px; font-size: 13px; }
.bar .fill { position: absolute; inset: 0 auto 0 0; border-radius: 6px; background: var(--accent-soft); }
.bar span { position: relative; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar b { position: relative; font-weight: 500; font-variant-numeric: tabular-nums; }
.empty { color: var(--dim); font-size: 13px; padding: 12px 0; }

.heat { display: grid; grid-template-columns: 34px repeat(24, minmax(0, 1fr)); gap: 3px; font-size: 10px; color: var(--dim); }
.heat div { aspect-ratio: 1; border-radius: 3px; background: var(--panel-2); }
.heat .lbl { aspect-ratio: auto; background: none; display: flex; align-items: center; }
.heat .hl { aspect-ratio: auto; background: none; text-align: center; }

.chart svg.map { overflow: hidden; }
.map path.land { fill: #1c1c22; stroke: #2a2a31; stroke-width: .4; }
.map circle { fill: var(--pink); fill-opacity: .55; stroke: var(--pink); stroke-width: .8; }

/* tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-weight: 500; color: var(--dim); font-size: 12px; padding: 8px 10px; border-bottom: 1px solid var(--line-2); white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--panel-2); }
.tag { display: inline-block; padding: 1px 7px; border-radius: 999px; font-size: 11px; border: 1px solid var(--line-2); color: var(--muted); white-space: nowrap; }
.tag.lead { border-color: var(--pink); color: var(--pink); }
.tag.hot { border-color: var(--accent); color: var(--accent); }
.tag.ret { border-color: var(--blue); color: var(--blue); }
.tag.ok { border-color: var(--ok); color: var(--ok); }
.tag.down { border-color: var(--down); color: var(--down); }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.input { height: 34px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--panel); min-width: 220px; }
select.input { min-width: 0; }

/* visit detail */
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1px; background: var(--line); border-radius: 10px; overflow: hidden; }
.kv div { background: var(--panel); padding: 10px 12px; min-width: 0; }
.kv dt { color: var(--dim); font-size: 11.5px; margin-bottom: 2px; }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.timeline { display: flex; flex-direction: column; max-height: 560px; overflow: auto; }
.ev { display: grid; grid-template-columns: 70px 110px minmax(0, 1fr); gap: 10px; padding: 7px 4px; border-bottom: 1px solid var(--line); font-size: 13px; }
.ev .t { color: var(--dim); font-variant-numeric: tabular-nums; }
.ev .ty { color: var(--accent); }
.strip { display: flex; height: 26px; border-radius: 6px; overflow: hidden; gap: 2px; }
.strip div { min-width: 3px; display: flex; align-items: center; justify-content: center; font-size: 10.5px; color: #08080a; overflow: hidden; white-space: nowrap; }
.replay-box { background: #000; border-radius: 10px; overflow: hidden; min-height: 120px; display: flex; justify-content: center; }
.replay-box .rr-player { background: #000; box-shadow: none; }
.message { white-space: pre-wrap; background: var(--panel-2); border-radius: 10px; padding: 14px; line-height: 1.55; }

footer.foot { max-width: 1440px; margin: 0 auto; padding: 24px; color: var(--dim); font-size: 12px; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; max-width: none; }
.login form { width: 100%; max-width: 320px; display: flex; flex-direction: column; gap: 12px; }
.login h1 { margin: 0 0 8px; font-size: 24px; font-weight: 600; }
.login input { height: 44px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--panel); font-size: 16px; }
.login input:focus { outline: none; border-color: var(--accent); }
.login input.code { letter-spacing: .35em; font-size: 20px; text-align: center; font-variant-numeric: tabular-nums; }
.login .btn { height: 44px; justify-content: center; font-size: 15px; }
.login .msg { margin: 0; font-size: 13px; color: var(--muted); min-height: 1.2em; }
.login .msg.err { color: var(--down); }
.login .link { align-self: flex-start; padding: 0; border: 0; background: none; color: var(--dim); font-size: 13px; cursor: pointer; }
.login .link:hover { color: var(--text); }
.hidden { display: none !important; }

/* session widget */
.session { display: flex; align-items: center; gap: 10px; height: 32px; padding: 0 4px 0 12px; border: 1px solid var(--line-2); border-radius: 999px; font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.session .who { max-width: 240px; overflow: hidden; text-overflow: ellipsis; }
.session .who b { color: var(--text); font-weight: 500; }
.session .timer { display: inline-flex; align-items: center; gap: 6px; padding-left: 10px; border-left: 1px solid var(--line-2); color: var(--text); font-variant-numeric: tabular-nums; min-width: 66px; }
.session .timer svg { width: 14px; height: 14px; transform: rotate(-90deg); }
.session .track { fill: none; stroke: var(--line-2); stroke-width: 2; }
.session .arc { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; transition: stroke-dashoffset 1s linear, stroke .3s; }
.session.warn .arc { stroke: var(--warn); }
.session.warn .timer { color: var(--warn); }
.session.crit .arc { stroke: var(--down); }
.session.crit .timer { color: var(--down); animation: pulse 1s infinite; }
.session .extend { height: 24px; padding: 0 10px; border: 0; border-radius: 999px; background: var(--accent-soft); color: var(--text); font-size: 12px; cursor: pointer; transition: background .2s; }
.session .extend:hover:not(:disabled) { background: var(--accent); color: #08080a; }
.session .extend:disabled { opacity: .35; cursor: default; }
.session.warn .extend:not(:disabled) { background: var(--accent); color: #08080a; }
@media (max-width: 1100px) { .session .who .lbl { display: none; } }
@media (max-width: 860px) { .session .who { display: none; } .session .timer { border-left: 0; padding-left: 0; } }
.session[hidden] { display: none; }
