:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1b1f24;
  --muted: #5f6b7a;
  --border: #dde2e8;
  --accent: #1f6feb;
  --accent-text: #ffffff;
  --danger: #c62828;
  --success: #1b7f3b;
  --notice-bg: #fff6db;
  --notice-border: #f0d68a;
  --chip-business: #1b7f3b;
  --chip-isp: #6b7280;
  --chip-mobile: #8a5a00;
  --chip-hosting: #7c3aed;
  --chip-vpn: #b42318;
  --chip-bot: #475569;
  --chip-unknown: #64748b;
  --chip-pending: #0e7490;
  --chip-new: #1f6feb;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1216;
    --surface: #171b21;
    --text: #e6e9ee;
    --muted: #97a3b2;
    --border: #2a313a;
    --accent: #4c8dff;
    --accent-text: #0b0e12;
    --danger: #ff6b6b;
    --success: #4ade80;
    --notice-bg: #2a2410;
    --notice-border: #5b4b16;
    --chip-business: #4ade80;
    --chip-isp: #a3acb9;
    --chip-mobile: #f0b44c;
    --chip-hosting: #b794ff;
    --chip-vpn: #ff8a80;
    --chip-bot: #a3acb9;
    --chip-unknown: #a3acb9;
    --chip-pending: #5ec8de;
    --chip-new: #79a8ff;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.1rem; margin: 1.5rem 0 .75rem; }
.card h2:first-child { margin-top: 0; }
code { font: 13px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.error { color: var(--danger); font-weight: 600; }
.success { color: var(--success); font-weight: 600; }
.hint { display: block; color: var(--muted); font-size: .85rem; font-weight: 400; margin-top: .25rem; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .5rem;
  padding: .75rem 1rem; background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 800; color: var(--text); font-size: 1.1rem; }
.brand span { font-weight: 400; color: var(--muted); font-size: .85rem; margin-left: .5rem; }
.topbar nav { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.topbar nav a { color: var(--muted); font-weight: 500; }
.topbar nav a.active { color: var(--text); }
.topbar nav form { margin: 0; }

main { max-width: 960px; margin: 0 auto; padding: 1.25rem 1rem 3rem; }
main.wide { max-width: 1400px; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 1rem 1.25rem; margin-bottom: 1rem;
}

label { display: flex; flex-direction: column; gap: .25rem; font-size: .85rem; font-weight: 600; color: var(--muted); }
input, select, textarea, button, .button {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 7px; padding: .45rem .65rem;
}
textarea { resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
button, .button { cursor: pointer; display: inline-block; font-weight: 600; color: var(--text); }
.button:hover { text-decoration: none; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
button.danger { color: var(--danger); border-color: var(--danger); background: transparent; }
button.small, .button.small { padding: .25rem .55rem; font-size: .85rem; }
button.link { border: 0; background: none; padding: 0; color: var(--muted); font-weight: 500; }
form.inline { display: inline; margin: 0; }

.form { display: flex; flex-direction: column; gap: .85rem; max-width: 560px; }
.form.row { flex-direction: row; flex-wrap: wrap; align-items: flex-end; max-width: none; }
.form label.check { flex-direction: row; align-items: center; font-weight: 500; }
.grow { flex: 1 1 220px; }
.login { max-width: 360px; margin: 10vh auto; display: flex; flex-direction: column; gap: .85rem; }
.danger-zone h2 { color: var(--danger); }

.filters {
  display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 1rem;
  margin-bottom: 1rem;
}
.filters .narrow input { width: 6rem; }
.filters [hidden] { display: none; }
.filters .actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.types { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: .4rem; flex-basis: 100%; }
.types legend { font-size: .85rem; font-weight: 600; color: var(--muted); margin-bottom: .3rem; padding: 0; }
.chip {
  flex-direction: row; align-items: center; gap: .35rem; font-weight: 500; color: var(--text);
  border: 1px solid var(--border); border-radius: 999px; padding: .2rem .7rem; cursor: pointer;
}
.chip input { margin: 0; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: .85rem 1rem; }
.kpi .label { display: block; color: var(--muted); font-size: .85rem; }
.kpi .value { display: block; font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }

.notice { background: var(--notice-bg); border: 1px solid var(--notice-border); border-radius: 8px; padding: .5rem .85rem; }
.notice.muted { background: transparent; border-style: dashed; }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .6rem .8rem; border-bottom: 1px solid var(--border); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); white-space: nowrap; }
th a { color: inherit; }
th a.sorted { color: var(--text); }
th a.sorted::after { content: " ↓"; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
td .company { display: flex; gap: .65rem; min-width: 260px; }
td .company .name { font-weight: 600; }
td .sub { color: var(--muted); font-size: .85rem; }
td.pages code { display: block; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.logo { width: 24px; height: 24px; border-radius: 5px; flex: none; margin-top: 2px; background: var(--bg); }
.logo.big { width: 44px; height: 44px; border-radius: 8px; }

.badge {
  display: inline-block; font-size: .72rem; font-weight: 600; padding: 0 .45rem; border-radius: 999px;
  border: 1px solid currentColor; margin-left: .3rem; vertical-align: 1px; color: var(--muted);
}
.type-business.badge { color: var(--chip-business); }
.type-isp.badge { color: var(--chip-isp); }
.type-mobile.badge { color: var(--chip-mobile); }
.type-hosting.badge { color: var(--chip-hosting); }
.type-vpn.badge { color: var(--chip-vpn); }
.type-bot.badge { color: var(--chip-bot); }
.type-unknown.badge { color: var(--chip-unknown); }
.type-pending.badge { color: var(--chip-pending); }
.badge.new { color: var(--chip-new); }

.empty { text-align: center; padding: 2rem 1rem; }
.empty h2 { margin-top: 0; }

.company-head { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 1rem; }
.company-head .company { display: flex; gap: .85rem; align-items: center; }
.company-head h1 { margin: 0; }
.company-head p { margin: .2rem 0 0; }
.facts { display: flex; gap: 1.5rem; flex-wrap: wrap; margin: 0; }
.facts dt { color: var(--muted); font-size: .8rem; }
.facts dd { margin: 0; font-weight: 600; }

.sessions { display: grid; gap: .75rem; }
.session { margin: 0; }
.session header { display: flex; flex-wrap: wrap; gap: .5rem; align-items: baseline; }
.session .source { margin: .4rem 0 0; font-size: .9rem; word-break: break-all; }
.timeline { margin: .6rem 0 0; padding-left: 1.2rem; }
.timeline li { margin: .2rem 0; word-break: break-word; }
.timeline .time { color: var(--muted); font-variant-numeric: tabular-nums; margin-right: .35rem; }

.snippet { display: flex; gap: .5rem; align-items: flex-start; }
.snippet pre {
  flex: 1; margin: 0; padding: .75rem; background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; overflow-x: auto;
}

@media (max-width: 640px) {
  .filters > label { flex: 1 1 100%; }
  .kpi .value { font-size: 1.3rem; }
  .snippet { flex-direction: column; }
}
