/* =====================================================================
   CyberTarget SOC-AI — v6 (Real-time / Live / Polished)
   Auto-refresh • Sparklines • Slide-overs • Command palette
   ===================================================================== */

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

:root {
  --bg: #f5f7fa;
  --bg-soft: #eef0f4;
  --surface: #ffffff;
  --surface-2: #fafbfd;
  --sidebar-bg: #ffffff;
  --sidebar-w: 232px;
  --sidebar-collapsed: 64px;
  --topbar-h: 56px;

  --line: #e4e7ec;
  --line-soft: #eef0f4;
  --line-strong: #d1d6de;

  --text: #0c1424;
  --text-2: #4a5568;
  --text-3: #94a3b8;
  --text-inv: #ffffff;

  --brand: #4338ca;
  --brand-2: #6366f1;
  --brand-soft: #eef0ff;
  --brand-ink: #312e81;

  --ok: #059669;
  --ok-soft: #ecfdf5;
  --warn: #c2410c;
  --warn-soft: #fff7ed;
  --bad: #be123c;
  --bad-soft: #fff1f2;
  --info: #0369a1;
  --info-soft: #f0f9ff;

  --shadow-sm: 0 1px 2px rgba(12,20,36,.04), 0 1px 3px rgba(12,20,36,.04);
  --shadow:    0 1px 3px rgba(12,20,36,.05), 0 4px 12px rgba(12,20,36,.04);
  --shadow-lg: 0 1px 3px rgba(12,20,36,.05), 0 12px 32px rgba(12,20,36,.10);

  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "SF Pro Text", Roboto, "Helvetica Neue", Arial, "Noto Sans Arabic", "Segoe UI Arabic", Tahoma, sans-serif;
  --mono: ui-monospace, "JetBrains Mono", Menlo, Consolas, monospace;
}

html, body { height: 100%; font: 13.5px/1.55 var(--font); background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
html[dir="rtl"] body { font-family: "Segoe UI", "Tahoma", "Noto Sans Arabic", sans-serif; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre, kbd, samp { font-family: var(--mono); font-size: 12px; }

.ic { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; vertical-align: middle; }
.ic-sm { width: 14px; height: 14px; stroke-width: 2; }
.ic-lg { width: 22px; height: 22px; }

.app { display: flex; min-height: 100vh; }
html[dir="rtl"] .app { flex-direction: row-reverse; }

/* ============== SIDEBAR ============== */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-inline-end: 1px solid var(--line);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  flex-shrink: 0;
  transition: width .2s ease;
}
.sidebar.collapsed { width: var(--sidebar-collapsed); }

.sidebar-head {
  padding: 14px 16px;
  display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid var(--line-soft);
  min-height: var(--topbar-h);
}
.sidebar-head .logo {
  width: 32px; height: 32px; border-radius: 9px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 13px;
  flex-shrink: 0; box-shadow: 0 2px 6px rgba(67,56,202,.25);
}
.sidebar-head .text { line-height: 1.15; min-width: 0; }
.sidebar-head .name { font-weight: 700; font-size: 13.5px; color: var(--text); }
.sidebar-head .sub { font-size: 10.5px; color: var(--text-3); margin-top: 1px; }
.sidebar.collapsed .sidebar-head .text { display: none; }

.sidebar-mode { padding: 12px 12px 8px; }
.mode-toggle {
  display: flex; background: var(--bg-soft); border-radius: 8px; padding: 2px;
  border: 1px solid var(--line);
}
.mode-toggle button {
  flex: 1; border: 0; background: transparent; cursor: pointer;
  padding: 6px 8px; border-radius: 6px; font-size: 11px; font-weight: 700;
  color: var(--text-2); letter-spacing: .03em;
  display: flex; align-items: center; justify-content: center; gap: 5px;
}
.mode-toggle button.active.blue { background: var(--brand); color: #fff; }
.mode-toggle button.active.red  { background: #b91c1c; color: #fff; }
.sidebar.collapsed .mode-toggle button span { display: none; }

.sidebar-section {
  padding: 14px 16px 4px;
  font-size: 10px; color: var(--text-3);
  text-transform: uppercase; letter-spacing: .08em; font-weight: 700;
  display: flex; align-items: center; justify-content: space-between;
}
.sidebar.collapsed .sidebar-section span { display: none; }

.nav { display: flex; flex-direction: column; gap: 1px; padding: 4px 10px; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: 7px;
  color: var(--text-2); font-weight: 500; font-size: 13px;
  transition: all .1s ease;
  white-space: nowrap; overflow: hidden;
  position: relative;
}
.nav a:hover { background: var(--bg-soft); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.nav a.active::before {
  content: ''; position: absolute; inset-inline-start: 0; top: 6px; bottom: 6px;
  width: 3px; background: var(--brand); border-radius: 0 2px 2px 0;
}
.nav a .ic { color: var(--text-3); flex-shrink: 0; }
.nav a.active .ic { color: var(--brand); }
.nav a .text { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.nav a .count {
  background: var(--bg-soft); color: var(--text-2);
  padding: 1px 6px; border-radius: 999px;
  font-size: 10px; font-weight: 700;
  min-width: 18px; text-align: center;
}
.nav a.active .count { background: var(--brand); color: #fff; }
.nav a.has-threats .count { background: var(--bad); color: #fff; animation: pulse 2s infinite; }

.sidebar.collapsed .nav a { justify-content: center; padding: 8px; }
.sidebar.collapsed .nav a .text,
.sidebar.collapsed .nav a .count { display: none; }
.sidebar.collapsed .nav a::before { display: none; }

.sidebar-foot {
  margin-top: auto;
  padding: 10px;
  border-top: 1px solid var(--line-soft);
}
.sidebar-foot .user {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; border-radius: 7px;
  background: var(--bg-soft); margin-bottom: 4px;
}
.sidebar-foot .user .avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 11px;
  flex-shrink: 0;
}
.sidebar-foot .user .info { line-height: 1.2; min-width: 0; flex: 1; }
.sidebar-foot .user .info .who { font-size: 12.5px; font-weight: 600; color: var(--text); }
.sidebar-foot .user .info .role { font-size: 10.5px; color: var(--text-3); }
.sidebar-foot .logout-btn {
  width: 100%; padding: 7px 10px; border-radius: 6px;
  background: transparent; border: 1px solid var(--line);
  color: var(--text-2); font-size: 12px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.sidebar-foot .logout-btn:hover { background: var(--bad-soft); color: var(--bad); border-color: #fecdd3; }
.sidebar.collapsed .sidebar-foot .user .info { display: none; }

/* ============== TOPBAR ============== */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: var(--topbar-h);
  background: rgba(255,255,255,.92);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px;
  padding: 0 18px;
  position: sticky; top: 0; z-index: 10;
}
.topbar .crumbs { flex: 1; display: flex; align-items: center; gap: 8px; min-width: 0; }
.topbar .crumbs .ic { color: var(--brand); }
.topbar .crumbs .label { font-size: 13.5px; font-weight: 600; color: var(--text); }
.topbar .crumbs .sep { color: var(--line-strong); }
.topbar .crumbs .updated { font-size: 11.5px; color: var(--text-3); display: flex; align-items: center; gap: 5px; }
.topbar .crumbs .updated .pulse-dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--ok);
  animation: pulse 2s infinite;
}
.topbar .right { display: flex; align-items: center; gap: 6px; }

.lang-toggle {
  display: flex; background: var(--bg-soft); border-radius: 6px; padding: 2px;
  border: 1px solid var(--line);
}
.lang-toggle button {
  border: 0; background: transparent; cursor: pointer;
  padding: 3px 10px; font-size: 11px; font-weight: 600; color: var(--text-2); border-radius: 4px;
}
.lang-toggle button.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(12,20,36,.06); }

.icon-btn {
  width: 32px; height: 32px; border-radius: 7px;
  background: var(--bg-soft); border: 1px solid var(--line);
  color: var(--text-2); cursor: pointer; display: grid; place-items: center;
  position: relative;
}
.icon-btn:hover { background: var(--surface); color: var(--text); }
.icon-btn .notif-dot {
  position: absolute; top: 6px; right: 6px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--bad); border: 2px solid var(--bg-elev);
}

/* Command palette trigger button */
.cmd-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px; border-radius: 7px;
  background: var(--bg-soft); border: 1px solid var(--line);
  color: var(--text-3); cursor: pointer; font-size: 12px;
  min-width: 220px;
}
.cmd-btn:hover { background: var(--surface); color: var(--text); }
.cmd-btn .ic { color: var(--text-3); }
.cmd-btn .kbd { margin-inline-start: auto; padding: 1px 5px; background: var(--surface); border: 1px solid var(--line); border-radius: 4px; font-family: var(--mono); font-size: 10px; }

/* ============== CONTENT ============== */
.content { padding: 22px; flex: 1; max-width: 1280px; width: 100%; margin: 0 auto; }

.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 16px; gap: 14px;
}
.page-header h1 { font-size: 21px; font-weight: 700; letter-spacing: -0.015em; display: flex; align-items: center; gap: 8px; }
.page-header h1 .ic { color: var(--brand); }
.page-header .sub { color: var(--text-2); font-size: 13px; margin-top: 4px; max-width: 700px; line-height: 1.5; }
.page-header .actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }

/* ============== HERO ============== */
.hero {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-2) 100%);
  color: #fff;
  border-radius: var(--radius-lg);
  padding: 18px 22px;
  display: flex; align-items: center; gap: 20px;
  box-shadow: var(--shadow-lg);
  position: relative; overflow: hidden;
  margin-bottom: 14px;
}
.hero::before {
  content: ''; position: absolute; right: -60px; top: -60px;
  width: 220px; height: 220px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,.10) 0%, transparent 70%);
  pointer-events: none;
}
.hero .icon-wrap {
  width: 52px; height: 52px; border-radius: 13px;
  background: rgba(255,255,255,.15);
  display: grid; place-items: center; flex-shrink: 0;
}
.hero .icon-wrap .ic { width: 26px; height: 26px; color: #fff; }
.hero .body { flex: 1; min-width: 0; }
.hero .kicker {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; opacity: .85;
  display: flex; align-items: center; gap: 7px;
}
.hero .kicker .pulse {
  width: 8px; height: 8px; border-radius: 50%; background: #34d399;
  box-shadow: 0 0 0 4px rgba(52,211,153,.25);
  animation: pulse 2s infinite;
}
.hero h2 { font-size: 13px; font-weight: 500; opacity: .9; margin-top: 2px; }
.hero .stat-row { display: flex; align-items: baseline; gap: 8px; margin-top: 4px; }
.hero .stat { font-size: 32px; font-weight: 800; letter-spacing: -0.025em; line-height: 1; }
.hero .label { font-size: 13px; opacity: .85; }
.hero-divider { width: 1px; height: 42px; background: rgba(255,255,255,.18); flex-shrink: 0; }
.hero-stat { display: flex; flex-direction: column; gap: 2px; min-width: 80px; }
.hero-stat .l { font-size: 10px; text-transform: uppercase; letter-spacing: .07em; opacity: .8; font-weight: 700; display: flex; align-items: center; gap: 4px; }
.hero-stat .v { font-size: 17px; font-weight: 700; line-height: 1.1; }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(16,185,129,.5); }
  50% { box-shadow: 0 0 0 6px rgba(16,185,129,.0); }
}

/* ============== KPI TILES WITH SPARKLINES ============== */
.kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}
@media (max-width: 900px) { .kpis { grid-template-columns: repeat(2, 1fr); } }

.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex; align-items: flex-start; gap: 11px;
  position: relative; overflow: hidden;
  transition: all .12s ease;
}
.kpi:hover { box-shadow: var(--shadow-sm); border-color: var(--line-strong); }
.kpi.flash { animation: flash-update 1s ease; }
@keyframes flash-update {
  0% { background: var(--brand-soft); }
  100% { background: var(--surface); }
}
.kpi .icon-circle {
  width: 36px; height: 36px; border-radius: 9px;
  display: grid; place-items: center; flex-shrink: 0;
}
.kpi.k-brand  .icon-circle { background: var(--brand-soft); color: var(--brand); }
.kpi.k-ok     .icon-circle { background: var(--ok-soft); color: var(--ok); }
.kpi.k-warn   .icon-circle { background: var(--warn-soft); color: var(--warn); }
.kpi.k-bad    .icon-circle { background: var(--bad-soft); color: var(--bad); }
.kpi.k-violet .icon-circle { background: #f3e8ff; color: #7c3aed; }
.kpi.k-cyan   .icon-circle { background: #cffafe; color: #0e7490; }
.kpi .body { flex: 1; min-width: 0; }
.kpi .label { font-size: 11.5px; color: var(--text-2); font-weight: 500; }
.kpi .value { font-size: 20px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; margin-top: 2px; }
.kpi .delta { font-size: 10.5px; color: var(--text-3); margin-top: 2px; display: flex; align-items: center; gap: 3px; }
.kpi .delta.up { color: var(--ok); }
.kpi .delta.down { color: var(--bad); }
.kpi .spark { position: absolute; bottom: 0; left: 0; right: 0; height: 22px; opacity: 0.45; pointer-events: none; }
.kpi .spark path { fill: none; stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.kpi .spark path.area { fill: currentColor; opacity: 0.12; stroke: none; }
.kpi.k-brand  .spark path { color: var(--brand); stroke: var(--brand); }
.kpi.k-ok     .spark path { color: var(--ok); stroke: var(--ok); }
.kpi.k-warn   .spark path { color: var(--warn); stroke: var(--warn); }
.kpi.k-bad    .spark path { color: var(--bad); stroke: var(--bad); }
.kpi.k-violet .spark path { color: #7c3aed; stroke: #7c3aed; }
.kpi.k-cyan   .spark path { color: #0e7490; stroke: #0e7490; }

/* ============== BENTO ============== */
.bento { display: grid; gap: 12px; }
.bento.cols-2 { grid-template-columns: 1fr 1fr; }
.bento.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.bento.h-2-1 { grid-template-columns: 2fr 1fr; }
.bento.h-1-2 { grid-template-columns: 1fr 2fr; }
.bento.h-1-1-1 { grid-template-columns: 1fr 1fr 1fr; }
.bento.h-3-2 { grid-template-columns: 3fr 2fr; }
@media (max-width: 1000px) {
  .bento > * { grid-column: span 1; }
  .bento.cols-2, .bento.cols-3, .bento.h-2-1, .bento.h-1-2,
  .bento.h-1-1-1, .bento.h-3-2 { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, 1fr) !important; }
}

/* ============== CARDS ============== */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card-head {
  padding: 11px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  border-bottom: 1px solid var(--line-soft);
  min-height: 42px;
}
.card-head h2 { font-size: 13px; font-weight: 600; color: var(--text); display: flex; align-items: center; gap: 7px; }
.card-head h2 .ic { color: var(--brand); }
.card-head .count {
  background: var(--bg-soft); color: var(--text-2);
  padding: 1px 7px; border-radius: 999px; font-weight: 600; font-size: 11px;
}
.card-head .right { display: flex; gap: 6px; align-items: center; }
.card-head .meta { color: var(--text-3); font-size: 12px; }
.card-body { padding: 14px 16px; }
.card-body.tight { padding: 0; }
.card-body.compact { padding: 11px 14px; }

/* ============== BADGES ============== */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px;
  font-size: 10px; font-weight: 700; letter-spacing: .03em;
  text-transform: uppercase;
}
.badge .dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.badge.info    { background: var(--info-soft); color: #0c4a6e; }
.badge.low     { background: var(--ok-soft); color: #065f46; }
.badge.medium  { background: var(--warn-soft); color: #9a3412; }
.badge.high    { background: var(--bad-soft); color: #9f1239; }
.badge.critical{ background: #fecaca; color: #7f1d1d; }
.badge.ok      { background: var(--ok-soft); color: #047857; }
.badge.degraded{ background: var(--warn-soft); color: #9a3412; }
.badge.failed  { background: var(--bad-soft); color: #9f1239; }
.badge.unknown { background: var(--bg-soft); color: var(--text-2); }

/* ============== BUTTONS ============== */
.btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 11px; border-radius: 6px;
  border: 1px solid var(--line-strong); background: var(--surface);
  color: var(--text); cursor: pointer; font-size: 12.5px; font-weight: 500;
  transition: all .1s ease;
}
.btn:hover { background: var(--surface-2); border-color: var(--text-3); }
.btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn.primary:hover { background: var(--brand-ink); }
.btn.danger  { background: var(--bad-soft); color: #9f1239; border-color: #fecdd3; }
.btn.danger:hover { background: var(--bad); color: #fff; }
.btn.ghost   { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--bg-soft); color: var(--text); }
.btn.sm { padding: 3px 8px; font-size: 11px; border-radius: 5px; }

input, select, textarea {
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 6px;
  padding: 6px 10px; font-size: 12.5px; color: var(--text); font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(67,56,202,.12);
}

/* ============== TABLES ============== */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 9px 16px; text-align: start; border-bottom: 1px solid var(--line-soft); font-size: 12.5px; }
.table th {
  color: var(--text-3); font-weight: 700; text-transform: uppercase;
  font-size: 10px; letter-spacing: .06em; background: var(--surface-2);
  padding: 7px 16px;
}
.table tbody tr { transition: background .08s ease; }
.table tbody tr:hover td { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr.clickable { cursor: pointer; }
.table .ip { font-family: var(--mono); font-size: 12px; }
.table .dim { color: var(--text-3); font-size: 12px; }
.table .who { display: flex; align-items: center; gap: 8px; }
.table .who .ic { color: var(--text-3); }

/* ============== LIVE STREAM ============== */
.stream {
  background: #0c1424; color: #e2e8f0;
  font-family: var(--mono); font-size: 12px; line-height: 1.7;
  padding: 12px 16px; max-height: 280px; overflow: auto;
}
.stream .e {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  padding: 3px 0;
  display: flex; gap: 8px; align-items: center;
  border-bottom: 1px solid rgba(255,255,255,.04);
  animation: slide-in .3s ease;
}
@keyframes slide-in { from { opacity: 0; transform: translateX(-8px); } to { opacity: 1; transform: none; } }
.stream .e.fresh { background: rgba(67,56,202,.08); }
.stream .e:last-child { border-bottom: 0; }
.stream .e .sev { min-width: 60px; font-weight: 700; }
.stream .e .sev.info { color: #93c5fd; }
.stream .e .sev.low { color: #86efac; }
.stream .e .sev.medium { color: #fbbf24; }
.stream .e .sev.high { color: #fb7185; }
.stream .e .sev.critical { color: #fca5a5; }
.stream .e .ts { opacity: .55; flex-shrink: 0; font-size: 11px; }
.stream .e .ip { color: #a5b4fc; flex-shrink: 0; }
.stream .e .what { opacity: .9; overflow: hidden; text-overflow: ellipsis; }

/* ============== SLIDE-OVER PANEL ============== */
.overlay {
  position: fixed; inset: 0; background: rgba(12,20,36,.45);
  backdrop-filter: blur(2px);
  z-index: 100; opacity: 0; pointer-events: none;
  transition: opacity .2s ease;
}
.overlay.show { opacity: 1; pointer-events: auto; }
.slideover {
  position: fixed; top: 0; bottom: 0; inset-inline-end: 0;
  width: 540px; max-width: 100%;
  background: var(--surface);
  border-inline-start: 1px solid var(--line);
  box-shadow: -8px 0 32px rgba(12,20,36,.12);
  z-index: 101;
  transform: translateX(100%); transition: transform .25s ease;
  display: flex; flex-direction: column;
  overflow: hidden;
}
html[dir="rtl"] .slideover { transform: translateX(-100%); }
.slideover.show { transform: translateX(0); }
.slideover-head {
  padding: 14px 18px; display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--line-soft); background: var(--bg-elev);
}
.slideover-head h2 { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.slideover-head .close-btn {
  width: 30px; height: 30px; border-radius: 7px;
  background: transparent; border: 0; cursor: pointer;
  display: grid; place-items: center; color: var(--text-3);
}
.slideover-head .close-btn:hover { background: var(--bg-soft); color: var(--text); }
.slideover-body { flex: 1; overflow-y: auto; padding: 18px; }

/* ============== COMMAND PALETTE ============== */
.cmd-overlay {
  position: fixed; inset: 0; background: rgba(12,20,36,.5); backdrop-filter: blur(4px);
  z-index: 200; opacity: 0; pointer-events: none;
  transition: opacity .15s ease;
  display: flex; align-items: flex-start; justify-content: center; padding-top: 12vh;
}
.cmd-overlay.show { opacity: 1; pointer-events: auto; }
.cmd-modal {
  width: 640px; max-width: 90vw;
  background: var(--surface); border-radius: 14px;
  box-shadow: 0 20px 60px rgba(12,20,36,.4);
  overflow: hidden;
  transform: translateY(-10px); transition: transform .15s ease;
}
.cmd-overlay.show .cmd-modal { transform: translateY(0); }
.cmd-modal .cmd-input {
  width: 100%; padding: 16px 20px; border: 0; border-bottom: 1px solid var(--line-soft);
  font-size: 16px; outline: none; background: transparent;
}
.cmd-modal .results {
  max-height: 420px; overflow-y: auto;
}
.cmd-modal .results .empty {
  padding: 40px 20px; color: var(--text-3); text-align: center; font-size: 13px;
}
.cmd-modal .result {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 20px; cursor: pointer;
  border-bottom: 1px solid var(--line-soft);
}
.cmd-modal .result:last-child { border-bottom: 0; }
.cmd-modal .result:hover,
.cmd-modal .result.focused { background: var(--brand-soft); }
.cmd-modal .result .ic {
  width: 28px; height: 28px; border-radius: 7px;
  background: var(--bg-soft); display: grid; place-items: center; color: var(--brand);
}
.cmd-modal .result .body { flex: 1; min-width: 0; }
.cmd-modal .result .body .title { font-size: 13.5px; font-weight: 500; color: var(--text); }
.cmd-modal .result .body .sub { font-size: 11.5px; color: var(--text-3); margin-top: 2px; }
.cmd-modal .result .tag { background: var(--bg-soft); padding: 2px 7px; border-radius: 4px; font-size: 10px; font-weight: 600; }

/* ============== MISC ============== */
.tag { background: var(--bg-soft); border: 1px solid var(--line); padding: 0 7px; border-radius: 999px; font-size: 11px; color: var(--text-2); display: inline-block; font-weight: 500; }
.muted { color: var(--text-3); font-size: 12px; }
.row { display: flex; gap: 6px; align-items: center; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: 6px; }
.spacer { height: 12px; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 6px 14px; font-size: 13px; }
.kv dt { color: var(--text-3); font-weight: 500; }
.kv dd { margin: 0; word-break: break-word; }

.empty { padding: 30px 16px; text-align: center; color: var(--text-3); font-size: 13px; }
.empty .icon-big { width: 36px; height: 36px; margin-bottom: 8px; color: var(--ok); }
.empty .icon-big.warn { color: var(--warn); }
.empty .icon-big.bad { color: var(--bad); }
.empty h3 { color: var(--text); font-size: 14px; font-weight: 600; margin-bottom: 3px; }
.empty p { color: var(--text-3); font-size: 12px; max-width: 320px; margin: 0 auto 12px; }
.empty .btn { margin-top: 4px; }

.toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }

/* ============== TIMELINE (incident detail) ============== */
.timeline { position: relative; padding-left: 22px; }
.timeline::before {
  content: ''; position: absolute; left: 8px; top: 4px; bottom: 4px;
  width: 2px; background: var(--line);
}
.timeline .item {
  position: relative; padding: 8px 0;
}
.timeline .item::before {
  content: ''; position: absolute; left: -19px; top: 14px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--brand); border: 2px solid var(--surface);
}
.timeline .item.success::before { background: var(--ok); }
.timeline .item.danger::before { background: var(--bad); }
.timeline .item .when { font-size: 11px; color: var(--text-3); }
.timeline .item .what { font-size: 13px; color: var(--text); margin-top: 2px; }

/* ============== LOGIN ============== */
.login-shell {
  min-height: 100vh;
  display: grid; place-items: center;
  background:
    radial-gradient(700px 400px at 100% 0%, rgba(99,102,241,.10), transparent 70%),
    radial-gradient(600px 400px at 0% 100%, rgba(67,56,202,.08), transparent 70%),
    var(--bg);
  padding: 20px;
}
.login-card {
  width: 380px; max-width: 100%;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 32px 36px 26px; box-shadow: var(--shadow-lg);
}
.login-card .brand { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.login-card .brand .logo { width: 38px; height: 38px; border-radius: 9px; background: linear-gradient(135deg, var(--brand), var(--brand-2)); display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 16px; }
.login-card .brand .name { font-weight: 700; font-size: 16px; }
.login-card .brand .tag { font-size: 10.5px; margin-top: 1px; }
.login-card h1 { font-size: 18px; margin-bottom: 4px; }
.login-card .sub { color: var(--text-2); font-size: 13px; margin-bottom: 18px; }
.login-card label { display: block; font-size: 11px; font-weight: 700; margin: 12px 0 5px; color: var(--text-2); text-transform: uppercase; letter-spacing: .05em; }
.login-card input { width: 100%; padding: 10px 12px; font-size: 14px; }
.login-card .btn { width: 100%; margin-top: 16px; justify-content: center; padding: 11px; }
.login-card .err { color: var(--bad); font-size: 12px; margin-top: 10px; min-height: 16px; font-weight: 600; }
.login-card .hint { color: var(--text-3); font-size: 11.5px; margin-top: 16px; text-align: center; padding-top: 12px; border-top: 1px solid var(--line-soft); }
.login-card .lang { margin-bottom: 14px; display: inline-flex; }

/* ============== SKELETON LOADERS ============== */
@keyframes shimmer { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }
.skel {
  background: linear-gradient(90deg, var(--bg-soft) 0%, var(--surface) 50%, var(--bg-soft) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 4px;
  height: 14px;
}

/* ============== RTL ============== */
html[dir="rtl"] { direction: rtl; }
html[dir="rtl"] .sidebar { border-inline-end: none; border-inline-start: 1px solid var(--line); }
html[dir="rtl"] .table th, html[dir="rtl"] .table td { text-align: right; }
html[dir="rtl"] .row { flex-direction: row-reverse; }
html[dir="rtl"] .card-head { flex-direction: row-reverse; }
html[dir="rtl"] .page-header { flex-direction: row-reverse; }
html[dir="rtl"] .kv { direction: rtl; }

/* ============== SCROLLBAR ============== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }
::-webkit-scrollbar-track { background: transparent; }

/* ============== RESPONSIVE ============== */
@media (max-width: 760px) {
  .sidebar { width: var(--sidebar-collapsed); }
  .sidebar .sidebar-head .text,
  .sidebar .mode-toggle button span,
  .sidebar .sidebar-section span,
  .sidebar .nav a .text,
  .sidebar .nav a .count,
  .sidebar .sidebar-foot .user .info,
  .sidebar .sidebar-foot .logout-btn span { display: none; }
  .sidebar .sidebar-head,
  .sidebar .nav a,
  .sidebar .sidebar-foot .user { justify-content: center; padding: 8px; }
  .content { padding: 16px 14px 60px; }
  .kpis { grid-template-columns: repeat(2, 1fr) !important; }
  .hero { flex-wrap: wrap; gap: 12px; padding: 16px; }
  .hero-divider { display: none; }
  .slideover { width: 100%; }
  .cmd-btn { min-width: 0; }
  .cmd-btn .label { display: none; }
}