/* ============================================================
   WAF Console — dark-first security dashboard
   Palette calibrated from the dataviz reference instance.
   ============================================================ */

/* ---- reset ---- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html, body { height: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  color: var(--text);
  background: var(--bg);
}
img, svg, canvas { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }
a { color: inherit; text-decoration: none; }
table { border-collapse: collapse; width: 100%; }
h1, h2, h3, h4 { font-weight: 600; line-height: 1.25; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ---- tokens: dark (default) ---- */
:root {
  --bg:            #0b0c0e;
  --surface:       #131519;
  --surface-2:     #1a1d22;
  --surface-3:     #21252b;
  --sidebar:       #0e0f12;
  --border:        rgba(255,255,255,0.08);
  --border-strong: rgba(255,255,255,0.15);
  --text:          #f3f4f6;
  --text-2:        #a7adb7;
  --muted:         #6b717c;
  --accent:        #4d8dff;
  --accent-weak:   rgba(77,141,255,0.14);
  --accent-ink:    #0b0c0e;

  /* series (dark steps) */
  --s-blue:   #3987e5;
  --s-green:  #199e70;
  --s-yellow: #c98500;
  --s-violet: #9085e9;
  --s-red:    #e66767;
  --s-orange: #d95926;
  --s-magenta:#d55181;

  /* status */
  --ok:       #2ecc71;
  --ok-bg:    rgba(46,204,113,0.14);
  --warn:     #fab219;
  --warn-bg:  rgba(250,178,25,0.14);
  --serious:  #ec835a;
  --serious-bg:rgba(236,131,90,0.14);
  --danger:   #f0605f;
  --danger-bg:rgba(240,96,95,0.14);
  --info-bg:  rgba(77,141,255,0.14);
  --neutral-bg:rgba(255,255,255,0.07);

  --grid:     rgba(255,255,255,0.06);
  --axis:     #383835;

  --radius:   12px;
  --radius-sm:8px;
  --shadow:   0 1px 2px rgba(0,0,0,.4), 0 8px 24px -8px rgba(0,0,0,.6);
  --shadow-lg:0 16px 48px -12px rgba(0,0,0,.7);
  --sidebar-w: 244px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg:            #f7f8fa;
    --surface:       #ffffff;
    --surface-2:     #f4f6f9;
    --surface-3:     #eaedf1;
    --sidebar:       #14161b;   /* keep sidebar dark for identity */
    --border:        rgba(17,20,24,0.10);
    --border-strong: rgba(17,20,24,0.18);
    --text:          #14181d;
    --text-2:        #4b525c;
    --muted:         #838a94;
    --accent:        #2a6df0;
    --accent-weak:   rgba(42,109,240,0.10);
    --s-blue:   #2a78d6;
    --s-green:  #1baf7a;
    --s-yellow: #eda100;
    --s-violet: #4a3aa7;
    --s-red:    #e34948;
    --s-orange: #eb6834;
    --s-magenta:#e87ba4;
    --ok:#0ca30c; --ok-bg:rgba(12,163,12,.12);
    --warn:#c98500; --warn-bg:rgba(201,133,0,.14);
    --serious:#d1622f; --serious-bg:rgba(209,98,47,.12);
    --danger:#d03b3b; --danger-bg:rgba(208,59,59,.12);
    --info-bg:rgba(42,109,240,.10);
    --neutral-bg:rgba(17,20,24,.06);
    --grid:rgba(17,20,24,.07);
    --axis:#c3c2b7;
    --shadow:0 1px 2px rgba(20,24,29,.06),0 8px 24px -10px rgba(20,24,29,.18);
    --shadow-lg:0 20px 50px -16px rgba(20,24,29,.28);
  }
}

/* ============================================================
   Boot splash
   ============================================================ */
.app-boot { display: grid; place-items: center; min-height: 100vh; }
.boot-splash { display: flex; flex-direction: column; align-items: center; gap: 18px; color: var(--text-2); }
.boot-mark { color: var(--accent); }
.boot-title { font-weight: 600; letter-spacing: .2px; color: var(--text); }
.spinner {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2.5px solid var(--border-strong); border-top-color: var(--accent);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   App shell
   ============================================================ */
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

.sidebar {
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  color: #e7e9ee;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 20px 20px 16px; }
.brand .logo { color: var(--accent); display: grid; place-items: center; }
.brand .name { font-weight: 700; font-size: 15px; letter-spacing: .3px; color: #fff; }
.brand .name small { display: block; font-weight: 500; font-size: 11px; color: #8b93a1; letter-spacing: .4px; }

.nav { padding: 6px 12px; flex: 1; overflow-y: auto; }
.nav-section { padding: 14px 10px 6px; font-size: 10.5px; font-weight: 600; letter-spacing: .8px; text-transform: uppercase; color: #6a7280; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 10px; border-radius: var(--radius-sm);
  color: #b9bfca; font-weight: 500; font-size: 13.5px;
  position: relative; transition: background .12s, color .12s;
}
.nav-item:hover { background: rgba(255,255,255,.05); color: #fff; }
.nav-item.active { background: var(--accent-weak); color: #fff; }
.nav-item.active::before {
  content: ""; position: absolute; left: -12px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 20px; border-radius: 0 3px 3px 0; background: var(--accent);
}
.nav-item svg { width: 17px; height: 17px; flex: none; opacity: .9; }
.nav-item .count { margin-left: auto; font-size: 11px; color: #8b93a1; }

.side-foot { border-top: 1px solid var(--border); padding: 12px; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: var(--radius-sm); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: linear-gradient(135deg,var(--accent),var(--s-violet)); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; }
.user-chip .who { min-width: 0; }
.user-chip .who b { display: block; font-size: 13px; color: #fff; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip .who span { font-size: 11px; color: #8b93a1; }
.user-chip button { margin-left: auto; color: #8b93a1; padding: 6px; border-radius: 6px; }
.user-chip button:hover { color: #fff; background: rgba(255,255,255,.06); }

/* main */
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  padding: 14px 28px; border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
}
.topbar h1 { font-size: 18px; font-weight: 650; letter-spacing: -.2px; }
.topbar .sub { color: var(--muted); font-size: 12.5px; }
.topbar .spacer { flex: 1; }
.content { padding: 24px 28px 64px; max-width: 1360px; width: 100%; }

.menu-toggle { display: none; }

/* ============================================================
   Generic bits
   ============================================================ */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card-pad { padding: 18px 20px; }
.card-head { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.card-head h3 { font-size: 14px; font-weight: 600; }
.card-head .sub { color: var(--muted); font-size: 12px; }
.card-head .spacer { flex: 1; }

.grid { display: grid; gap: 16px; }
.section-title { font-size: 13px; font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: .6px; margin: 6px 2px 12px; }
.row { display: flex; align-items: center; gap: 10px; }
.wrap { flex-wrap: wrap; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }

/* ---- buttons ---- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 14px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 550;
  border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text);
  transition: background .12s, border-color .12s, transform .04s;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: color-mix(in srgb, var(--accent) 88%, #fff); }
.btn.danger { background: transparent; border-color: color-mix(in srgb,var(--danger) 45%,transparent); color: var(--danger); }
.btn.danger:hover { background: var(--danger-bg); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn.icon { padding: 7px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn.attack { background: var(--danger); border-color: var(--danger); color:#fff; }
.btn.attack:hover { background: color-mix(in srgb,var(--danger) 85%,#fff); }

.btn-group { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; }
.btn-group button { padding: 6px 12px; font-size: 12.5px; font-weight: 550; color: var(--text-2); background: var(--surface); border-right: 1px solid var(--border); }
.btn-group button:last-child { border-right: none; }
.btn-group button:hover { background: var(--surface-2); color: var(--text); }
.btn-group button.on { background: var(--accent-weak); color: var(--text); }

/* ---- forms ---- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > label { font-size: 12.5px; font-weight: 550; color: var(--text-2); }
.field .hint { font-size: 11.5px; color: var(--muted); }
input[type=text], input[type=password], input[type=email], input[type=number], input[type=search], select, textarea {
  width: 100%; padding: 9px 11px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--border-strong); color: var(--text);
  transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); }
input::placeholder, textarea::placeholder { color: var(--muted); }
textarea { resize: vertical; min-height: 84px; font-family: var(--mono); font-size: 12.5px; line-height: 1.6; }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b717c' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 9px center; padding-right: 30px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.form-grid .full { grid-column: 1 / -1; }
.inline-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: end; }

/* switch */
.switch { position: relative; display: inline-flex; align-items: center; width: 38px; height: 22px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch .track { position: absolute; inset: 0; border-radius: 999px; background: var(--surface-3); border: 1px solid var(--border-strong); transition: background .15s; }
.switch .thumb { position: absolute; top: 3px; left: 3px; width: 15px; height: 15px; border-radius: 50%; background: #fff; transition: transform .16s; box-shadow: 0 1px 2px rgba(0,0,0,.4); }
.switch input:checked + .track { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .track + .thumb { transform: translateX(16px); }
.switch input:focus-visible + .track { box-shadow: 0 0 0 3px var(--accent-weak); }

.checkline { display: flex; align-items: center; gap: 9px; padding: 4px 0; font-size: 13px; color: var(--text-2); }

/* ---- badges ---- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600;
  letter-spacing: .2px; line-height: 1.4; white-space: nowrap;
  background: var(--neutral-bg); color: var(--text-2);
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.ok       { background: var(--ok-bg);      color: var(--ok); }
.badge.info     { background: var(--info-bg);    color: var(--accent); }
.badge.warn     { background: var(--warn-bg);    color: var(--warn); }
.badge.serious  { background: var(--serious-bg); color: var(--serious); }
.badge.danger   { background: var(--danger-bg);  color: var(--danger); }
.badge.violet   { background: rgba(144,133,233,.16); color: var(--s-violet); }
.badge.neutral  { background: var(--neutral-bg);  color: var(--text-2); }

/* mode badges */
.mode-off     { background: var(--neutral-bg);  color: var(--text-2); }
.mode-low     { background: var(--ok-bg);       color: var(--ok); }
.mode-medium  { background: var(--warn-bg);     color: var(--warn); }
.mode-high    { background: var(--serious-bg);  color: var(--serious); }
.mode-uam     { background: var(--danger-bg);   color: var(--danger); }

/* ---- tables ---- */
.table-wrap { overflow-x: auto; }
table.data { font-size: 13px; }
table.data thead th {
  text-align: left; font-weight: 600; font-size: 11px; letter-spacing: .5px; text-transform: uppercase;
  color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap;
  position: sticky; top: 0; background: var(--surface); z-index: 1;
}
table.data tbody td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tbody tr:last-child td { border-bottom: none; }
table.data tbody tr { transition: background .1s; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data .actions { display: flex; gap: 4px; justify-content: flex-end; }
.cell-strong { font-weight: 600; }
.cell-sub { color: var(--muted); font-size: 12px; }

/* ---- KPI / stat tiles ---- */
.kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.kpi {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; display: flex; flex-direction: column; gap: 8px; box-shadow: var(--shadow);
  position: relative; overflow: hidden;
}
.kpi .k-label { font-size: 11.5px; font-weight: 600; letter-spacing: .5px; text-transform: uppercase; color: var(--muted); display: flex; align-items: center; gap: 7px; }
.kpi .k-label .ic { color: var(--text-2); display: inline-flex; }
.kpi .k-value { font-size: 30px; font-weight: 680; letter-spacing: -.5px; line-height: 1; }
.kpi .k-foot { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.kpi.live .k-value { color: var(--accent); }
.k-delta { font-weight: 600; }
.k-delta.up { color: var(--ok); } .k-delta.down { color: var(--danger); }
.pulse-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 0 var(--ok); animation: pulse 1.8s infinite; }
@keyframes pulse { 0%{box-shadow:0 0 0 0 color-mix(in srgb,var(--ok) 60%,transparent);} 70%{box-shadow:0 0 0 7px transparent;} 100%{box-shadow:0 0 0 0 transparent;} }

/* ---- layout helpers ---- */
.cols-2 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
.cols-2e { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.stack { display: grid; gap: 16px; }

/* system status strip */
.status-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px,1fr)); gap: 1px; background: var(--border); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); }
.status-cell { background: var(--surface); padding: 14px 16px; display: flex; flex-direction: column; gap: 5px; }
.status-cell .s-k { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); font-weight: 600; }
.status-cell .s-v { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.status-cell .s-sub { font-size: 11.5px; color: var(--muted); }

/* ---- chart ---- */
.chart-host { position: relative; width: 100%; }
.chart-host canvas { width: 100%; display: block; }
.chart-tip {
  position: absolute; pointer-events: none; z-index: 5;
  background: var(--surface-3); border: 1px solid var(--border-strong); border-radius: 8px;
  padding: 8px 10px; font-size: 12px; box-shadow: var(--shadow-lg);
  min-width: 120px; opacity: 0; transition: opacity .08s; transform: translate(-50%, -100%);
}
.chart-tip .t-time { color: var(--muted); font-size: 11px; margin-bottom: 5px; }
.chart-tip .t-row { display: flex; align-items: center; gap: 7px; justify-content: space-between; }
.chart-tip .t-row .t-key { display: flex; align-items: center; gap: 6px; color: var(--text-2); }
.chart-tip .t-row .t-val { font-weight: 600; font-variant-numeric: tabular-nums; }
.chart-tip .swatch { width: 8px; height: 8px; border-radius: 2px; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; }
.legend .lg { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--text-2); }
.legend .swatch { width: 10px; height: 10px; border-radius: 3px; }

/* bar list */
.barlist { display: flex; flex-direction: column; gap: 10px; }
.barlist .bl-item { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center; }
.barlist .bl-key { font-size: 13px; display: flex; align-items: center; gap: 8px; min-width: 0; }
.barlist .bl-key .truncate { max-width: 190px; }
.barlist .bl-val { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.barlist .bl-track { grid-column: 1 / -1; height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.barlist .bl-fill { height: 100%; border-radius: 999px; background: var(--accent); min-width: 3px; transition: width .4s ease; }
.flag { font-size: 15px; line-height: 1; }

/* ---- toasts ---- */
.toaster { position: fixed; right: 20px; bottom: 20px; z-index: 1000; display: flex; flex-direction: column; gap: 10px; max-width: min(92vw, 380px); }
.toast {
  display: flex; align-items: flex-start; gap: 11px; padding: 12px 14px;
  background: var(--surface-3); border: 1px solid var(--border-strong); border-radius: 10px;
  box-shadow: var(--shadow-lg); animation: toast-in .2s ease;
}
.toast .t-ic { flex: none; margin-top: 1px; }
.toast .t-body { font-size: 13px; }
.toast .t-body b { display: block; margin-bottom: 1px; }
.toast.ok .t-ic { color: var(--ok); }
.toast.error .t-ic { color: var(--danger); }
.toast.info .t-ic { color: var(--accent); }
.toast .t-close { margin-left: auto; color: var(--muted); padding: 2px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---- modal ---- */
.modal-backdrop { position: fixed; inset: 0; z-index: 500; background: rgba(0,0,0,.55); backdrop-filter: blur(3px); display: grid; place-items: center; padding: 24px; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.modal {
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 14px;
  box-shadow: var(--shadow-lg); width: 100%; max-width: 620px; max-height: 90vh;
  display: flex; flex-direction: column; animation: modal-in .18s ease;
}
.modal.wide { max-width: 820px; }
@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(.99); } }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-head h2 { font-size: 16px; font-weight: 650; }
.modal-head .sub { font-size: 12.5px; color: var(--muted); }
.modal-head .x { margin-left: auto; color: var(--muted); padding: 6px; border-radius: 8px; }
.modal-head .x:hover { background: var(--surface-2); color: var(--text); }
.modal-body { padding: 20px 22px; overflow-y: auto; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 16px 22px; border-top: 1px solid var(--border); background: var(--surface); border-radius: 0 0 14px 14px; }

/* ---- states ---- */
.state { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 56px 20px; text-align: center; color: var(--muted); }
.state svg { width: 40px; height: 40px; opacity: .5; }
.state h3 { color: var(--text-2); font-size: 15px; }
.state.error { color: var(--danger); }
.skeleton { background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: shimmer 1.3s infinite; border-radius: 6px; }
@keyframes shimmer { to { background-position: -200% 0; } }
.sk-line { height: 12px; margin: 8px 0; }
.spinner.sm { width: 15px; height: 15px; border-width: 2px; }
.loading-inline { display: flex; align-items: center; gap: 10px; color: var(--muted); padding: 40px; justify-content: center; }

/* ---- auth / setup ---- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; background:
  radial-gradient(1200px 600px at 50% -10%, rgba(77,141,255,.10), transparent 60%), var(--bg); }
.auth-card { width: 100%; max-width: 400px; }
.auth-card .card { padding: 30px 30px 26px; }
.auth-brand { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-bottom: 22px; }
.auth-brand .logo { color: var(--accent); }
.auth-brand h1 { font-size: 19px; }
.auth-brand p { color: var(--muted); font-size: 13px; text-align: center; }
.auth-card .btn.primary { width: 100%; justify-content: center; padding: 11px; }
.auth-err { background: var(--danger-bg); color: var(--danger); border: 1px solid color-mix(in srgb,var(--danger) 30%,transparent); border-radius: 8px; padding: 10px 12px; font-size: 12.5px; margin-bottom: 14px; }
.steps { display: flex; gap: 8px; margin-bottom: 20px; }
.steps .step { flex: 1; height: 3px; border-radius: 3px; background: var(--surface-3); }
.steps .step.on { background: var(--accent); }

/* rule builder */
.rb-group { border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface-2); padding: 14px; margin-bottom: 12px; position: relative; }
.rb-group-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.rb-group-head .lbl { font-size: 11px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; color: var(--accent); }
.rb-cond { display: grid; grid-template-columns: 150px 130px 1fr auto; gap: 8px; align-items: start; margin-bottom: 8px; }
.rb-cond .and { position: relative; }
.rb-and-label { font-size: 10.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; padding: 4px 0; }
.rb-or { display: flex; align-items: center; gap: 12px; margin: 4px 0 14px; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .5px; }
.rb-or::before, .rb-or::after { content: ""; height: 1px; background: var(--border); flex: 1; }
.chip-x { color: var(--muted); padding: 6px; border-radius: 6px; }
.chip-x:hover { background: var(--danger-bg); color: var(--danger); }

/* upstreams editor */
.up-row { display: grid; grid-template-columns: 1fr 130px auto; gap: 8px; align-items: center; margin-bottom: 8px; }

/* pill toolbar */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .spacer { flex: 1; }
.search-box { position: relative; }
.search-box svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--muted); }
.search-box input { padding-left: 32px; min-width: 220px; }

.tag { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 6px; background: var(--surface-3); font-size: 11.5px; color: var(--text-2); font-family: var(--mono); }

.scope-head { display: flex; align-items: center; gap: 10px; margin: 22px 2px 10px; }
.scope-head h3 { font-size: 14px; }
.scope-head .line { flex: 1; height: 1px; background: var(--border); }

.countdown { font-variant-numeric: tabular-nums; }
.expired { color: var(--danger); }

/* ---- status-class totals ---- */
.status-totals { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 16px; }
.status-totals .st-cell { display: flex; align-items: center; gap: 9px; }
.status-totals .st-dot { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.status-totals .st-k { font-size: 11px; font-weight: 600; letter-spacing: .4px; color: var(--muted); }
.status-totals .st-v { font-size: 15px; font-weight: 650; font-variant-numeric: tabular-nums; }
.status-totals .st-v .st-pct { font-size: 12px; font-weight: 500; color: var(--muted); margin-left: 6px; }

/* ---- geographic world map (choropleth) ---- */
.worldmap-host { position: relative; }
.worldmap-wrap { overflow-x: auto; }
.worldmap { width: 100%; min-width: 560px; height: auto; display: block; }
.worldmap .wm-country {
  fill: var(--surface-3);
  stroke: var(--surface);
  stroke-width: 0.4;
  stroke-linejoin: round;
  transition: fill .2s, stroke .1s;
  cursor: default;
}
.worldmap .wm-country:hover { stroke: var(--text); stroke-width: 0.7; }
.map-tip {
  position: absolute; pointer-events: none; z-index: 5; transform: translate(-50%, calc(-100% - 10px));
  background: var(--surface-3); border: 1px solid var(--border-strong); border-radius: 8px;
  padding: 7px 10px; font-size: 12px; box-shadow: var(--shadow-lg); white-space: nowrap;
  opacity: 0; transition: opacity .08s;
}
.map-tip .mt-name { font-weight: 600; }
.map-tip .mt-val { color: var(--muted); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.map-legend { display: flex; align-items: center; gap: 8px; }
.map-legend .ml-label { font-size: 11px; color: var(--muted); }
.map-legend .ml-bar { width: 96px; height: 8px; border-radius: 999px; background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 50%, var(--surface-3)), var(--accent)); }

/* ---- logs view ---- */
.logs-layout { display: grid; grid-template-columns: 320px 1fr; gap: 16px; align-items: start; }
.log-list { overflow: hidden; }
.log-list-head { padding: 14px 16px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--border); }
.log-items { display: flex; flex-direction: column; }
.log-item { display: flex; align-items: center; gap: 10px; padding: 11px 14px; text-align: left; width: 100%; border-bottom: 1px solid var(--border); transition: background .1s; }
.log-item:last-child { border-bottom: none; }
.log-item:hover { background: var(--surface-2); }
.log-item.active { background: var(--accent-weak); }
.log-item .li-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.log-item .li-dot.on { background: var(--ok); } .log-item .li-dot.off { background: var(--muted); }
.log-item .li-main { flex: 1; min-width: 0; }
.log-item .li-domain { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log-item .li-path { font-size: 11.5px; color: var(--muted); }
.log-item .li-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: none; }
.log-item .li-size { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.log-detail-body { display: flex; flex-direction: column; gap: 14px; }
.log-tail-wrap { min-height: 60px; }
.log-tail { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; max-height: 460px; overflow: auto; font-size: 12px; line-height: 1.55; white-space: pre; color: var(--text-2); }
.log-trunc { font-size: 11.5px; color: var(--muted); margin-bottom: 8px; }

/* ---- PHP view ---- */
.php-versions { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.php-ver { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px; background: var(--surface-2); }
.php-ver .pv-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.php-ver .pv-num { font-weight: 650; font-size: 15px; }
.php-ver .pv-bins { font-size: 11px; color: var(--muted); display: flex; flex-direction: column; gap: 2px; margin-bottom: 10px; }
.php-ver .pv-bins .mono { font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ext-chip { font-size: 11px; padding: 2px 8px; border-radius: 6px; background: var(--surface-3); color: var(--text-2); font-family: var(--mono); }
.ext-select { display: flex; flex-wrap: wrap; gap: 8px; }
.ext-toggle { display: inline-flex; align-items: center; gap: 5px; padding: 5px 10px; border-radius: 999px; font-size: 12px; font-weight: 550; border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text-2); }
.ext-toggle svg { width: 13px; height: 13px; }
.ext-toggle:hover { background: var(--surface-3); }
.ext-toggle.on { background: var(--accent-weak); border-color: color-mix(in srgb, var(--accent) 45%, transparent); color: var(--text); }

/* ---- uptime view ---- */
.uptime-list { display: flex; flex-direction: column; gap: 10px; }
.up-card { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; background: var(--surface-2); }
.up-top { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.up-id { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.up-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--muted); box-shadow: 0 0 0 3px transparent; }
.up-dot.up { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-bg); }
.up-dot.down { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-bg); }
.up-url { font-size: 13px; font-weight: 550; }
.up-probe { flex: none; }
.up-stats { display: flex; gap: 22px; flex: none; }
.up-stat { display: flex; flex-direction: column; gap: 3px; text-align: right; }
.up-stat-k { font-size: 10.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); font-weight: 600; }
.up-stat-v { font-size: 14px; font-weight: 650; font-variant-numeric: tabular-nums; }
.up-spark-wrap { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.up-spark { flex: 1; min-width: 0; }
.up-spark-label { font-size: 10.5px; color: var(--muted); flex: none; }
.up-spark-empty { font-size: 11.5px; color: var(--muted); }
.up-strip { display: flex; width: 100%; height: 20px; border-radius: 4px; overflow: hidden; background: var(--surface-3); }
.up-seg { height: 100%; }
.up-seg.up { background: var(--ok); }
.up-seg.down { background: var(--danger); }
.up-err { display: flex; align-items: center; gap: 7px; margin-top: 10px; font-size: 12px; color: var(--danger); }
.up-err svg { flex: none; }

/* responsive */
@media (max-width: 900px) {
  .logs-layout { grid-template-columns: 1fr; }
  .status-totals { grid-template-columns: repeat(2, 1fr); }
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 60; width: var(--sidebar-w); transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: var(--shadow-lg); }
  .menu-toggle { display: inline-flex; }
  .content { padding: 18px 16px 60px; }
  .topbar { padding: 12px 16px; }
  .kpi-row { grid-template-columns: repeat(2,1fr); }
  .cols-2, .cols-2e { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .rb-cond { grid-template-columns: 1fr 1fr; }
  .scrim { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 55; }
}
@media (max-width: 560px) { .kpi-row { grid-template-columns: 1fr; } }
