:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #22263a;
  --border: rgba(255,255,255,.08);
  --text: #e8eaf0;
  --muted: #7b8099;
  --accent: #4f8ef7;
  --red: #e24b4a;
  --amber: #e09c28;
  --green: #5aad6a;
  --font: 'Segoe UI', system-ui, sans-serif;
  --mono: 'Cascadia Code', 'Consolas', monospace;
  --radius: 10px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  min-height: 100vh;
}

/* Layout */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px; min-width: 220px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 0 0 1rem;
}
.main { flex: 1; overflow: hidden; display: flex; flex-direction: column; }

/* Sidebar */
.logo {
  padding: 1.25rem 1.25rem .75rem;
  font-size: 16px; font-weight: 600;
  display: flex; align-items: center; gap: 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: .5rem;
}
.logo-icon { font-size: 20px; }
.nav-item {
  padding: .55rem 1.25rem;
  color: var(--muted); cursor: pointer;
  display: flex; align-items: center; gap: 8px;
  border-left: 3px solid transparent;
  transition: all .15s; font-size: 13px;
}
.nav-item:hover { color: var(--text); background: var(--surface2); }
.nav-item.active { color: var(--accent); border-left-color: var(--accent); background: rgba(79,142,247,.07); }
.nav-section { padding: .5rem 1.25rem .25rem; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-top: .5rem; }

/* Topbar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.5rem; border-bottom: 1px solid var(--border);
  background: var(--surface); gap: 12px;
}
.topbar-title { font-size: 17px; font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
#lastUpdate { font-size: 12px; color: var(--muted); }

/* Stat cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px; padding: 1.25rem 1.5rem 0;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .9rem 1.1rem;
}
.stat-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 6px; }
.stat-value { font-size: 26px; font-weight: 600; line-height: 1; }
.stat-value.red { color: var(--red); }
.stat-value.amber { color: var(--amber); }
.stat-sub { font-size: 11px; color: var(--muted); margin-top: 4px; }

/* Toolbar */
.toolbar {
  display: flex; align-items: center; gap: 8px;
  padding: 1rem 1.5rem .5rem; flex-wrap: wrap;
}
.srv-pill {
  padding: 4px 12px; border-radius: 20px; font-size: 12px;
  border: 1px solid var(--border); background: transparent;
  color: var(--muted); cursor: pointer; transition: all .15s;
}
.srv-pill:hover { border-color: var(--accent); color: var(--text); }
.srv-pill.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.spacer { flex: 1; }
.icon-btn {
  padding: 5px 12px; border-radius: 6px; font-size: 12px;
  border: 1px solid var(--border); background: var(--surface2);
  color: var(--text); cursor: pointer; transition: all .15s;
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }
.search-input {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 6px; padding: 5px 10px; color: var(--text);
  font-size: 13px; width: 200px; font-family: var(--font);
  transition: border .15s;
}
.search-input:focus { outline: none; border-color: var(--accent); }
.search-input::placeholder { color: var(--muted); }

/* Table */
.table-wrap {
  margin: 0 1.5rem 1.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  flex: 1;
}
.tbl-scroll { overflow-y: auto; max-height: calc(100vh - 340px); }
table { width: 100%; border-collapse: collapse; }
thead { position: sticky; top: 0; z-index: 2; }
th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); padding: 9px 12px;
  background: var(--surface2); border-bottom: 1px solid var(--border);
  font-weight: 500; white-space: nowrap;
}
th.sort { cursor: pointer; user-select: none; }
th.sort:hover { color: var(--text); }
td {
  padding: 8px 12px; border-bottom: 1px solid var(--border);
  color: var(--text); font-size: 13px;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,.025); }
.ip-cell { font-family: var(--mono); font-size: 12px; color: var(--accent); }
.hits-num { font-variant-numeric: tabular-nums; }

/* Bar */
.bar-wrap { display: flex; align-items: center; gap: 8px; }
.bar-bg { flex: 1; height: 4px; background: var(--surface2); border-radius: 2px; min-width: 60px; }
.bar-fill { height: 100%; border-radius: 2px; background: var(--accent); transition: width .3s; }
.bar-fill.hi { background: var(--red); }

/* Badge */
.badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge.critical { background: rgba(226,75,74,.15); color: var(--red); border: 1px solid rgba(226,75,74,.3); }
.badge.medium   { background: rgba(224,156,40,.12); color: var(--amber); border: 1px solid rgba(224,156,40,.3); }
.badge.low      { background: rgba(90,173,106,.1); color: var(--green); border: 1px solid rgba(90,173,106,.25); }

/* Loading / empty */
.empty { text-align: center; padding: 3rem; color: var(--muted); font-size: 13px; }
.loading { text-align: center; padding: 2rem; color: var(--muted); font-size: 13px; }

/* Toast */
#toast {
  position: fixed; bottom: 1.5rem; right: 1.5rem;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 8px; padding: .7rem 1.1rem;
  font-size: 13px; color: var(--text);
  box-shadow: 0 4px 20px rgba(0,0,0,.4);
  opacity: 0; transition: opacity .25s;
  pointer-events: none; z-index: 999;
}
#toast.show { opacity: 1; }

/* API settings panel */
.settings-panel {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 1.25rem 1.5rem;
  margin: 1.25rem 1.5rem;
  max-width: 560px;
}
.settings-panel h2 { font-size: 15px; font-weight: 600; margin-bottom: 1rem; }
.field { margin-bottom: .85rem; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.field input {
  width: 100%; background: var(--surface2); border: 1px solid var(--border);
  border-radius: 6px; padding: 7px 10px; color: var(--text);
  font-family: var(--mono); font-size: 13px;
}
.field input:focus { outline: none; border-color: var(--accent); }
.btn-primary {
  background: var(--accent); color: #fff; border: none;
  border-radius: 6px; padding: 7px 18px; font-size: 13px;
  cursor: pointer; transition: opacity .15s;
}
.btn-primary:hover { opacity: .85; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
