:root {
  color-scheme: light dark;
  --bg: #f6f7f9; --panel: #ffffff; --border: #e2e4e9; --text: #1b1d22; --muted: #686d78;
  --accent: #2563eb; --human: #16a34a; --bot: #d4d7de; --bad: #dc2626; --warn: #b45309; --ok: #15803d;
}
@media (prefers-color-scheme: dark) {
  :root { --bg:#131417; --panel:#1c1d21; --border:#2c2e34; --text:#eef0f3; --muted:#9ca1ab; --accent:#5b8def; --human:#22c55e; --bot:#454a55; --bad:#f87171; --warn:#fbbf24; --ok:#4ade80; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
code { background: color-mix(in srgb, var(--accent) 8%, transparent); padding: 1px 5px; border-radius: 4px; word-break: break-all; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 15px; margin: 0 0 12px; }
.shell { display: flex; min-height: 100vh; }
.sidebar { width: 190px; flex-shrink: 0; border-right: 1px solid var(--border); padding: 20px 14px; display: flex; flex-direction: column; gap: 22px; position: sticky; top: 0; height: 100vh; }
.brand { font-weight: 700; font-size: 15px; padding: 0 10px; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidebar nav a { padding: 8px 10px; border-radius: 8px; color: var(--muted); font-weight: 500; }
.sidebar nav a:hover { background: color-mix(in srgb, var(--accent) 8%, transparent); color: var(--text); text-decoration: none; }
.sidebar nav a.active { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
.logout-form button { background: none; border: 0; color: var(--muted); cursor: pointer; font: inherit; padding: 8px 10px; }
main { flex: 1; min-width: 0; padding: 24px 28px 60px; max-width: 1400px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn { display: inline-block; background: var(--accent); color: #fff; border: 1px solid var(--accent); border-radius: 8px; padding: 8px 14px; font: 600 13px/1.2 inherit; cursor: pointer; }
.btn:hover { text-decoration: none; filter: brightness(1.05); }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn.danger { background: var(--bad); border-color: var(--bad); }
.link-btn { background: none; border: 0; color: var(--muted); cursor: pointer; font: inherit; padding: 0; }
.link-btn:hover { color: var(--bad); }
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 18px; margin-bottom: 16px; }
.panel.danger { border-color: color-mix(in srgb, var(--bad) 35%, var(--border)); display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.panel.danger h2 { margin: 0; width: 100%; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.panel-head h2 { margin: 0; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.cols > .panel { min-width: 0; }
.tiles { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 14px; min-width: 0; }
.tile-label { color: var(--muted); font-size: 12px; font-weight: 600; }
.tile-value { font-size: 22px; font-weight: 700; margin: 4px 0 2px; font-variant-numeric: tabular-nums; }
.tile-sub { color: var(--muted); font-size: 12px; }
.range { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.range input[type=date] { padding: 5px 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel); color: var(--text); font: inherit; font-size: 12px; }
.pills { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.pill { padding: 5px 11px; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); font-size: 12px; font-weight: 600; background: var(--panel); }
.pill.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.pill:hover { text-decoration: none; color: var(--text); }
.pill.on:hover { color: #fff; }
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.data td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.data tr:last-child td { border-bottom: 0; }
table.data.compact td, table.data.compact th { padding: 6px 8px; }
.num { text-align: right !important; font-variant-numeric: tabular-nums; white-space: nowrap; }
.strong { font-weight: 700; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.ellipsis { display: block; max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
tr.paused td { opacity: .55; }
.badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 999px; background: color-mix(in srgb, var(--muted) 15%, transparent); color: var(--muted); vertical-align: middle; }
.badge.ok { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.badge.bad { background: color-mix(in srgb, var(--bad) 14%, transparent); color: var(--bad); }
.badge.warn { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.copy-row { display: flex; gap: 8px; align-items: center; margin-top: 4px; flex-wrap: wrap; }
.copy-row.big { margin-bottom: 16px; }
.copy-row.big code { font-size: 14px; padding: 6px 10px; }
.copy { font: 600 11px/1 inherit; padding: 4px 8px; border-radius: 6px; border: 1px solid var(--border); background: var(--panel); color: var(--muted); cursor: pointer; }
.copy.done { color: var(--ok); border-color: var(--ok); }
.chart { width: 100%; height: 190px; display: block; }
.chart text { font-size: 10px; fill: var(--muted); }
.bar-human { fill: var(--human); }
.bar-bot { fill: var(--bot); }
.legend { display: flex; gap: 6px; align-items: center; font-size: 12px; color: var(--muted); margin-top: 6px; }
.sw { width: 10px; height: 10px; border-radius: 2px; display: inline-block; margin-left: 8px; }
.sw.human { background: var(--human); } .sw.bot { background: var(--bot); }
.split-bar { display: flex; height: 12px; border-radius: 6px; overflow: hidden; background: var(--bot); margin-bottom: 8px; }
.split-bar .human { background: var(--human); } .split-bar .bot { background: var(--bot); }
details summary { cursor: pointer; color: var(--muted); font-size: 13px; margin-top: 10px; }
.notice { background: color-mix(in srgb, var(--ok) 12%, var(--panel)); border: 1px solid color-mix(in srgb, var(--ok) 35%, var(--border)); padding: 10px 14px; border-radius: 10px; margin-bottom: 14px; }
.error-msg { background: color-mix(in srgb, var(--bad) 12%, var(--panel)); border: 1px solid color-mix(in srgb, var(--bad) 35%, var(--border)); color: var(--bad); padding: 10px 14px; border-radius: 10px; margin-bottom: 12px; }
.warn-text { color: var(--warn); font-weight: 600; }
.hint { color: var(--muted); font-size: 12.5px; margin: 6px 0 0; }
.edit-form label { display: flex; flex-direction: column; gap: 5px; font-weight: 600; font-size: 13px; margin-bottom: 12px; }
.edit-form label.check { flex-direction: row; align-items: flex-start; gap: 8px; font-weight: 400; }
.edit-form label.check input { margin-top: 3px; }
label.check.inline { display: inline-flex; gap: 6px; align-items: center; margin-right: 8px; }
input, select, textarea { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; min-width: 0; }
.edit-table input, .edit-table select { padding: 6px 8px; width: 100%; }
.edit-table input.narrow { width: 84px; }
.edit-table input.wide { min-width: 260px; }
.edit-table input[name="dest_name[]"] { min-width: 150px; }
.edit-table input[type=checkbox] { width: auto; }
.edit-table tr.tpl { display: none; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.prefix-input { display: flex; align-items: stretch; }
.prefix-input span { padding: 8px 10px; background: color-mix(in srgb, var(--muted) 10%, transparent); border: 1px solid var(--border); border-right: 0; border-radius: 8px 0 0 8px; color: var(--muted); font-weight: 400; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 55%; }
.prefix-input input { border-radius: 0 8px 8px 0; flex: 1; }
.form-actions { display: flex; gap: 8px; margin-bottom: 20px; }
form.inline { display: inline-flex; align-items: center; gap: 8px; margin: 0; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.filters input[name=q] { min-width: 260px; }
.pager { display: flex; gap: 12px; align-items: center; }
ul.plain { padding-left: 18px; margin: 0; } ul.plain li { margin-bottom: 6px; }
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-box { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 28px; width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: 10px; }
.login-box h1 { margin-bottom: 8px; }
.login-box button { background: var(--accent); color: #fff; border: 0; border-radius: 8px; padding: 10px; font-weight: 600; cursor: pointer; }
body:not(.is-rotator) .rotator-only { display: none !important; }
body.is-rotator .link-only { display: none !important; }
.bot-url { display: none !important; }
body.bot-redirect .bot-url { display: flex !important; }
@media (max-width: 1100px) { .tiles { grid-template-columns: repeat(3, 1fr); } .cols { grid-template-columns: 1fr; } }
@media (max-width: 760px) {
  .shell { flex-direction: column; }
  .sidebar { width: auto; height: auto; position: static; flex-direction: row; align-items: center; border-right: 0; border-bottom: 1px solid var(--border); padding: 10px 16px; gap: 10px; overflow-x: auto; }
  .sidebar nav { flex-direction: row; }
  main { padding: 16px; }
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .grid2 { grid-template-columns: 1fr; }
}
