:root {
  --bg: #0f1113;
  --panel: #171a1d;
  --panel-2: #1e2226;
  --line: #2a2f35;
  --line-2: #353b42;
  --text: #e4e7ea;
  --muted: #8a929b;
  --accent: #93c24e;
  --accent-2: #a9d464;
  --accent-ink: #11190a;
  --good: #8fc65a;
  --bad: #e8675f;
  --warn: #e3a945;
  --info: #62a8e6;
  --radius: 10px;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f3f4f2; --panel: #ffffff; --panel-2: #f6f7f5; --line: #e1e4df; --line-2: #d2d6cf;
    --text: #1b1f1a; --muted: #687066; --accent: #5e8f1f; --accent-2: #4f7c17; --accent-ink: #ffffff;
    --good: #3f7d1c; --bad: #c43d35; --warn: #a96d00; --info: #2b6fb3;
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--info); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 22px; }
h2 { font-size: 20px; letter-spacing: -0.01em; }
h3 { font-size: 15px; }
code { font-family: var(--mono); font-size: 12.5px; background: var(--panel-2); padding: 1px 5px; border-radius: 4px; border: 1px solid var(--line); }
.muted { color: var(--muted); }
.good { color: var(--good); }
.bad { color: var(--bad); }
.spacer { flex: 1; }
[hidden] { display: none !important; }

/* ---------- brand / gate */
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; font-size: 15px; white-space: nowrap; }
.brand-mark {
  display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 7px;
  background: var(--accent); color: var(--accent-ink); font-size: 12px; font-weight: 800; letter-spacing: 0.02em;
}
.gate { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.gate-card { width: 100%; max-width: 380px; display: grid; gap: 14px; padding: 28px; }
.gate-card .brand { margin-bottom: 4px; }

/* ---------- top bar */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 20px;
  padding: 10px 20px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.tabs { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.tab {
  appearance: none; border: 0; background: none; color: var(--muted); font: inherit; font-weight: 550;
  padding: 7px 12px; border-radius: 7px; cursor: pointer; white-space: nowrap;
}
.tab:hover { color: var(--text); background: var(--panel-2); }
.tab.active { color: var(--text); background: var(--panel-2); box-shadow: inset 0 -2px 0 var(--accent); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.rate { color: var(--muted); font-size: 12px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.rate b { color: var(--text); font-weight: 600; }
.rate.hot b { color: var(--warn); }

/* ---------- layout */
.wrap { max-width: 1240px; margin: 0 auto; padding: 24px 20px 64px; }
.panel { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
.panel-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; }
.panel-head p { margin: 4px 0 0; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.results { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
.card, .stat { min-width: 0; }
details.card > summary { cursor: pointer; font-weight: 600; list-style: none; display: flex; gap: 8px; align-items: center; }
details.card > summary::before { content: "▸"; color: var(--muted); transition: transform .15s; }
details.card[open] > summary::before { transform: rotate(90deg); }
details.card[open] > summary { margin-bottom: 12px; }
.count {
  display: inline-block; min-width: 22px; padding: 0 7px; margin-left: 6px; border-radius: 999px;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); font-size: 12px; text-align: center; font-weight: 600;
}

/* ---------- controls */
.controls { display: grid; gap: 14px; }
.range { display: grid; gap: 10px; }
.range-inputs { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; }
.range-inputs label { display: grid; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 550; }
.tz { font-size: 11px; font-weight: 700; color: var(--muted); border: 1px solid var(--line); border-radius: 5px; padding: 3px 6px; margin-bottom: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  appearance: none; font: inherit; font-size: 12px; color: var(--muted); background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 999px; padding: 3px 11px; cursor: pointer;
}
.chip:hover { color: var(--text); border-color: var(--line-2); }
.control-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; }
.check { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; user-select: none; }
input[type="checkbox"] { accent-color: var(--accent); width: 15px; height: 15px; margin: 0; }

input[type="text"], input[type="password"], input[type="number"], input[type="search"], input[type="datetime-local"], textarea {
  font: inherit; color: var(--text); background: var(--panel-2); border: 1px solid var(--line-2);
  border-radius: 7px; padding: 7px 10px; width: 100%; min-width: 0;
}
input[type="datetime-local"] { width: auto; font-variant-numeric: tabular-nums; }
textarea { resize: vertical; font-family: inherit; }
input:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 0; border-color: var(--accent); }

.btn {
  appearance: none; font: inherit; font-weight: 600; color: var(--text); background: var(--panel-2);
  border: 1px solid var(--line-2); border-radius: 7px; padding: 7px 14px; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn:disabled { opacity: .5; cursor: progress; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); border-color: var(--line-2); }
.btn-danger:hover { color: var(--bad); border-color: var(--bad); }
.btn-sm { padding: 5px 11px; font-size: 13px; }
.btn-xs { padding: 3px 8px; font-size: 12px; font-weight: 550; }
#atkScan, #chScan, #ocScan { min-width: 110px; }

/* ---------- progress */
.progress { display: grid; gap: 6px; }
.progress .bar { height: 4px; background: var(--panel-2); border-radius: 4px; overflow: hidden; }
.progress .bar i { display: block; height: 100%; width: 2%; background: var(--accent); border-radius: 4px; transition: width .3s; }
.progress .bar.indet i { width: 30% !important; animation: indet 1.1s ease-in-out infinite; }
@keyframes indet { from { transform: translateX(-100%); } to { transform: translateX(340%); } }
.progress .ptext { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.progress.bad .ptext { color: var(--bad); }

/* ---------- stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.stat-label { font-size: 12px; color: var(--muted); font-weight: 550; }
.stat-value { font-size: 22px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.stat-sub { font-size: 12px; color: var(--muted); }

/* ---------- tables */
.table-tools { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.table-tools .filter { max-width: 240px; }
.table-wrap { overflow-x: auto; margin: 0 -4px; }
table.data { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
table.data th, table.data td { padding: 7px 10px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data th { font-size: 12px; color: var(--muted); font-weight: 600; position: sticky; top: 0; background: var(--panel); user-select: none; }
table.data th.sortable { cursor: pointer; }
table.data th.sortable:hover { color: var(--text); }
table.data th.sorted { color: var(--text); }
table.data th.sorted.desc::after { content: " ↓"; color: var(--accent); }
table.data th.sorted.asc::after { content: " ↑"; color: var(--accent); }
table.data .num { text-align: right; }
table.data .rank { color: var(--muted); width: 1%; }
table.data tbody tr:hover td { background: var(--panel-2); }
table.data tr.zero td { color: var(--muted); }
table.data tfoot td { font-weight: 700; border-bottom: 0; border-top: 1px solid var(--line-2); }
table.data td.empty { text-align: center; color: var(--muted); padding: 22px; white-space: normal; }
table.data td.wrap-cell { white-space: normal; min-width: 220px; color: var(--muted); }
table.data td.crime-cell { white-space: normal; min-width: 120px; }
table.data td.crime-cell .meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12px; color: var(--muted); margin-top: 2px; }
.of { color: var(--muted); font-size: 12px; }
.player { display: inline-flex; align-items: center; gap: 6px; }
.player a { color: var(--text); font-weight: 550; }
.player a:hover { color: var(--info); }
.item { display: inline-flex; gap: 6px; align-items: center; font-weight: 600; color: var(--warn); }

.tag { display: inline-block; font-size: 11px; font-weight: 650; padding: 1px 7px; border-radius: 999px; border: 1px solid currentColor; line-height: 1.5; }
.tag-dim { color: var(--muted); }
.tag-ok { color: var(--good); }
.tag-bad { color: var(--bad); }
.tag-travel { color: var(--info); }
.tag-live { color: var(--warn); margin-left: 6px; }
.tag-warn { color: var(--warn); }
table.data tr.group-row td { padding: 10px 10px 6px; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--line-2); }
table.data tbody tr.group-row:hover td { background: none; }

/* ---------- OC */
.msg-box { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: start; margin-bottom: 12px; }
.msg-box textarea { min-height: 64px; }
.people { list-style: none; margin: 0; padding: 0; display: grid; }
.people li { display: grid; grid-template-columns: auto 1fr auto auto; gap: 10px; align-items: center; padding: 8px 4px; border-bottom: 1px solid var(--line); }
.people li:last-child { border-bottom: 0; }
.people li.excluded .who { opacity: .55; }
.people li.empty { display: block; color: var(--muted); text-align: center; padding: 20px; }
.people .who { display: grid; min-width: 0; }
.people .meta { font-size: 12px; color: var(--muted); }
.people .state { display: flex; gap: 8px; align-items: center; justify-content: end; }
.pick { display: grid; place-items: center; cursor: pointer; padding: 2px; }
.la { font-size: 12px; color: var(--muted); white-space: nowrap; }
.la::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 5px; background: var(--muted); vertical-align: 1px; }
.la-online::before { background: var(--good); }
.la-idle::before { background: var(--warn); }

/* ---------- settings */
.form { display: grid; gap: 10px; align-content: start; }
.form h3 { margin-bottom: 4px; }
.form label { display: grid; gap: 5px; font-weight: 550; font-size: 13px; }
.hint { margin: -4px 0 4px; font-size: 12.5px; color: var(--muted); }
.form-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.form-msg { font-size: 13px; min-height: 1em; }
.form-msg.good { color: var(--good); }
.form-msg.bad { color: var(--bad); }
.version { margin-top: 12px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0 0 6px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

.alert { padding: 10px 14px; border-radius: 8px; border: 1px solid; font-size: 13.5px; }
.alert-bad { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, transparent); background: color-mix(in srgb, var(--bad) 9%, transparent); }
.alert-warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, transparent); background: color-mix(in srgb, var(--warn) 9%, transparent); }
.alert a { color: inherit; text-decoration: underline; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50;
  background: var(--text); color: var(--bg); padding: 9px 16px; border-radius: 8px; font-weight: 600; font-size: 13px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .35);
}
.offscreen { position: fixed; left: -9999px; top: 0; opacity: 0; }
.toast-bad { background: var(--bad); color: #fff; }

/* ---------- small screens */
@media (max-width: 900px) {
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; gap: 8px 12px; padding: 10px 16px; }
  .tabs { order: 3; width: 100%; }
  .wrap { padding: 16px 16px 48px; }
  .rate { display: none; }
  .people li { grid-template-columns: auto 1fr auto; }
  .people .state { grid-column: 2 / 4; grid-row: 2; justify-content: start; }
  .people li > .btn { grid-column: 3; grid-row: 1; }
  .msg-box { grid-template-columns: 1fr; }
  .range-inputs label { flex: 1 1 140px; }
  input[type="datetime-local"] { width: 100%; }
}
