@font-face { font-family: 'Plex Arabic'; font-weight: 400; font-display: swap; src: url(/fonts/ibm-plex-sans-arabic-arabic-400-normal.woff2) format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFF; }
@font-face { font-family: 'Plex Arabic'; font-weight: 500; font-display: swap; src: url(/fonts/ibm-plex-sans-arabic-arabic-500-normal.woff2) format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFF; }
@font-face { font-family: 'Plex Arabic'; font-weight: 600; font-display: swap; src: url(/fonts/ibm-plex-sans-arabic-arabic-600-normal.woff2) format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFF; }
@font-face { font-family: 'Plex Arabic'; font-weight: 700; font-display: swap; src: url(/fonts/ibm-plex-sans-arabic-arabic-700-normal.woff2) format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFF; }
@font-face { font-family: 'Plex Arabic'; font-weight: 400; font-display: swap; src: url(/fonts/ibm-plex-sans-arabic-latin-400-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+2000-206F, U+20AC; }
@font-face { font-family: 'Plex Arabic'; font-weight: 500; font-display: swap; src: url(/fonts/ibm-plex-sans-arabic-latin-500-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+2000-206F, U+20AC; }
@font-face { font-family: 'Plex Arabic'; font-weight: 600; font-display: swap; src: url(/fonts/ibm-plex-sans-arabic-latin-600-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+2000-206F, U+20AC; }
@font-face { font-family: 'Plex Arabic'; font-weight: 700; font-display: swap; src: url(/fonts/ibm-plex-sans-arabic-latin-700-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+2000-206F, U+20AC; }

:root {
  color-scheme: dark;
  --bg: #0b0e14;
  --surface-1: #121722;
  --surface-2: #171e2b;
  --surface-3: #1e2635;
  --line: #232c3d;
  --line-soft: #1a2130;
  --text-primary: #e8ebf1;
  --text-secondary: #9aa3b5;
  --text-muted: #6b7488;
  --brand: #f5b93d;
  --brand-ink: #1a1407;
  --series-1: #338ced;
  --series-2: #e76624;
  --series-3: #9887ef;
  --series-4: #e24d8b;
  --series-5: #d28e05;
  --series-6: #00a888;
  --critical: #ff5a5f;
  --high: #ff8f3d;
  --medium: #f2c14e;
  --low: #6aa8ff;
  --info: #8a93a6;
  --good: #4cc9e8;
  --radius: 14px;
  --font: 'Plex Arabic', system-ui, -apple-system, 'Segoe UI', Tahoma, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text-primary); font-family: var(--font); font-size: 14px; -webkit-font-smoothing: antialiased; }
body { min-height: 100vh; background: radial-gradient(1200px 600px at 85% -10%, rgba(51, 140, 237, .10), transparent 60%), radial-gradient(900px 500px at 0% 0%, rgba(245, 185, 61, .06), transparent 55%), var(--bg); }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
a { color: var(--series-1); text-decoration: none; }
.num, .mono { font-variant-numeric: tabular-nums; }
.mono { font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; font-size: 12.5px; direction: ltr; unicode-bidi: isolate; }
.ltr { direction: ltr; unicode-bidi: isolate; display: inline-block; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; padding: 20px 14px; border-left: 1px solid var(--line-soft); background: rgba(11, 14, 20, .7); backdrop-filter: blur(10px); display: flex; flex-direction: column; gap: 4px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 22px; }
.brand-mark { width: 34px; height: 34px; }
.brand b { font-size: 18px; letter-spacing: -.2px; display: block; }
.brand small { color: var(--text-muted); font-size: 11.5px; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 10px; color: var(--text-secondary); font-weight: 500; position: relative; }
.nav a svg { width: 18px; height: 18px; flex: none; opacity: .85; }
.nav a:hover { background: var(--surface-1); color: var(--text-primary); }
.nav a.on { background: var(--surface-2); color: var(--text-primary); }
.nav a.on::before { content: ''; position: absolute; right: -14px; top: 9px; bottom: 9px; width: 3px; border-radius: 3px; background: var(--brand); }
.nav .count { margin-inline-start: auto; background: var(--critical); color: #fff; border-radius: 99px; font-size: 11px; padding: 1px 7px; font-weight: 600; }
.side-foot { margin-top: auto; padding: 12px; border-radius: 12px; background: var(--surface-1); border: 1px solid var(--line-soft); font-size: 12px; color: var(--text-secondary); display: grid; gap: 6px; }
.side-foot button { background: none; border: 1px solid var(--line); border-radius: 8px; padding: 6px; cursor: pointer; color: var(--text-secondary); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--text-muted); }
.dot.ok { background: var(--good); box-shadow: 0 0 0 4px rgba(76, 201, 232, .14); }
.dot.bad { background: var(--critical); }

main { min-width: 0; padding: 18px 26px 60px; }
.topbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; position: sticky; top: 0; z-index: 500; padding: 10px 0; background: linear-gradient(var(--bg) 70%, transparent); }
.topbar h1 { font-size: 21px; margin: 0; font-weight: 700; letter-spacing: -.2px; }
.topbar .sub { color: var(--text-muted); font-size: 12.5px; }
.topbar .grow { flex: 1; }
.seg { display: inline-flex; background: var(--surface-1); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.seg button { background: none; border: 0; padding: 6px 11px; border-radius: 7px; color: var(--text-secondary); cursor: pointer; font-weight: 500; white-space: nowrap; }
.seg button.on { background: var(--surface-3); color: var(--text-primary); }
select.sel, input.inp, textarea.inp { background: var(--surface-1); border: 1px solid var(--line); border-radius: 10px; padding: 8px 11px; min-width: 0; }
select.sel { padding-left: 28px; }
.btn { background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 13px; cursor: pointer; font-weight: 600; display: inline-flex; gap: 7px; align-items: center; white-space: nowrap; }
.btn:hover { border-color: #33405a; }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.btn.ghost { background: none; }
.btn.sm { padding: 5px 10px; font-size: 12.5px; border-radius: 8px; }
.btn svg { width: 16px; height: 16px; }
.live-pill { display: inline-flex; align-items: center; gap: 7px; padding: 6px 11px; border-radius: 99px; background: rgba(76, 201, 232, .08); border: 1px solid rgba(76, 201, 232, .25); color: var(--good); font-weight: 600; font-size: 12.5px; }
.live-pill .dot { background: var(--good); animation: pulse 1.6s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(76, 201, 232, .5); } 100% { box-shadow: 0 0 0 9px rgba(76, 201, 232, 0); } }

/* ---------- grid & cards ---------- */
.grid { display: grid; gap: 14px; }
.g-kpi { grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); }
@media (min-width: 821px) { .g-kpi.k4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-21 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.g-12 { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }
.sp { margin-top: 14px; }
.card { background: linear-gradient(180deg, var(--surface-1), rgba(18, 23, 34, .86)); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 16px 18px; min-width: 0; position: relative; }
.card h3 { margin: 0; font-size: 14.5px; font-weight: 600; }
.card .hd { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; min-height: 26px; }
.card .hd .note { color: var(--text-muted); font-size: 12px; font-weight: 400; }
.card .hd .grow { flex: 1; }
.chart { width: 100%; height: 280px; }
.chart.sm { height: 220px; }
.chart.lg { height: 340px; }
.empty { color: var(--text-muted); text-align: center; padding: 36px 10px; font-size: 13px; }

.kpi { padding: 15px 16px 13px; }
.kpi .lbl { color: var(--text-secondary); font-size: 12.5px; font-weight: 500; display: flex; align-items: center; gap: 7px; }
.kpi .lbl svg { width: 15px; height: 15px; opacity: .8; }
.kpi .val { font-size: 27px; font-weight: 700; margin: 6px 0 4px; letter-spacing: -.5px; line-height: 1.15; }
.kpi .val small { font-size: 13px; color: var(--text-secondary); font-weight: 500; margin-inline-start: 4px; }
.kpi .delta { font-size: 12px; font-weight: 600; display: inline-flex; align-items: center; gap: 3px; }
.kpi .delta.up { color: var(--good); }
.kpi .delta.down { color: var(--high); }
.kpi .delta.flat { color: var(--text-muted); }
.kpi .delta span { color: var(--text-muted); font-weight: 400; }
.kpi.accent { border-color: rgba(245, 185, 61, .28); background: linear-gradient(160deg, rgba(245, 185, 61, .10), var(--surface-1) 55%); }

/* score ring */
.score-wrap { display: flex; align-items: center; gap: 16px; }
.ring { width: 92px; height: 92px; flex: none; }
.ring text { font-family: var(--font); }
.score-meta { display: grid; gap: 6px; font-size: 12.5px; color: var(--text-secondary); }
.sevrow { display: flex; gap: 6px; flex-wrap: wrap; }

/* badges */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px 2px 8px; border-radius: 99px; font-size: 11.5px; font-weight: 600; white-space: nowrap; border: 1px solid transparent; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.critical { color: var(--critical); background: rgba(255, 90, 95, .12); border-color: rgba(255, 90, 95, .3); }
.badge.high { color: var(--high); background: rgba(255, 143, 61, .12); border-color: rgba(255, 143, 61, .28); }
.badge.medium { color: var(--medium); background: rgba(242, 193, 78, .1); border-color: rgba(242, 193, 78, .25); }
.badge.low { color: var(--low); background: rgba(106, 168, 255, .1); border-color: rgba(106, 168, 255, .25); }
.badge.info, .badge.neutral { color: var(--info); background: rgba(138, 147, 166, .1); border-color: rgba(138, 147, 166, .22); }
.badge.good { color: var(--good); background: rgba(76, 201, 232, .1); border-color: rgba(76, 201, 232, .25); }
.badge.nodot::before { display: none; }
.tag { display: inline-block; padding: 1px 7px; border-radius: 6px; font-size: 11px; background: var(--surface-3); color: var(--text-secondary); margin: 1px; white-space: nowrap; }
.tag.bad { background: rgba(255, 90, 95, .14); color: #ff9a9d; }
.grade { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; font-weight: 700; font-size: 15px; direction: ltr; }
.grade.A { background: rgba(76, 201, 232, .14); color: var(--good); }
.grade.B { background: rgba(106, 168, 255, .14); color: var(--low); }
.grade.C { background: rgba(242, 193, 78, .14); color: var(--medium); }
.grade.D { background: rgba(255, 143, 61, .15); color: var(--high); }
.grade.F { background: rgba(255, 90, 95, .16); color: var(--critical); }

/* tables */
.tbl-wrap { overflow-x: auto; margin: 0 -18px; padding: 0 18px; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: right; font-weight: 500; color: var(--text-muted); font-size: 12px; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 9px 10px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr.click { cursor: pointer; }
.tbl tr.click:hover td { background: rgba(255, 255, 255, .025); }
.tbl td.n, .tbl th.n { text-align: left; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl .muted { color: var(--text-muted); font-size: 12px; white-space: nowrap; }
.trunc { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; vertical-align: middle; }
.pname { font-weight: 600; }
.hosts { color: var(--text-muted); font-size: 11.5px; }

/* bar list */
.barlist { display: grid; gap: 7px; }
.barlist .row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; position: relative; padding: 6px 10px; border-radius: 8px; }
.barlist .row .fill { position: absolute; inset: 0 0 0 auto; border-radius: 8px; background: rgba(51, 140, 237, .16); z-index: 0; }
.barlist .row.warn .fill { background: rgba(255, 90, 95, .14); }
.barlist .row > *:not(.fill) { position: relative; z-index: 1; }
.barlist .k { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.barlist .v { font-variant-numeric: tabular-nums; color: var(--text-secondary); font-weight: 600; }
.flag { font-size: 15px; margin-inline-end: 6px; }

/* feed */
.feed { display: grid; gap: 2px; max-height: 520px; overflow-y: auto; }
.feed .it { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 8px 6px; border-bottom: 1px solid var(--line-soft); }
.feed .ic { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: var(--surface-3); }
.feed .ic svg { width: 16px; height: 16px; }
.feed .t1 { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed .t2 { color: var(--text-muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed .when { color: var(--text-muted); font-size: 11.5px; white-space: nowrap; }

/* findings */
.finding { border: 1px solid var(--line-soft); border-radius: 12px; padding: 12px 14px; display: grid; gap: 6px; background: var(--surface-2); }
.finding + .finding { margin-top: 8px; }
.finding .top { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.finding .title { font-weight: 600; flex: 1; min-width: 200px; }
.finding .det { color: var(--text-secondary); font-size: 13px; line-height: 1.7; }
.finding .fix { font-size: 13px; line-height: 1.7; padding: 8px 11px; border-radius: 9px; background: rgba(76, 201, 232, .06); border: 1px dashed rgba(76, 201, 232, .2); }
.finding .fix b { color: var(--good); font-weight: 600; }
.finding .meta { display: flex; gap: 12px; flex-wrap: wrap; color: var(--text-muted); font-size: 12px; align-items: center; }
.finding .acts { display: flex; gap: 6px; margin-inline-start: auto; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; align-items: center; }
.chip { border: 1px solid var(--line); background: var(--surface-1); padding: 5px 11px; border-radius: 99px; cursor: pointer; font-size: 12.5px; color: var(--text-secondary); }
.chip.on { background: var(--surface-3); color: var(--text-primary); border-color: #3a4660; }

.funnel { display: grid; gap: 10px; }
.funnel .st { display: grid; grid-template-columns: 90px minmax(0, 1fr) 80px; gap: 12px; align-items: center; }
.funnel .bar { height: 34px; border-radius: 9px; background: linear-gradient(90deg, rgba(51, 140, 237, .55), rgba(51, 140, 237, .9)); min-width: 4px; margin-inline-start: auto; display: flex; align-items: center; padding: 0 10px; font-weight: 700; font-variant-numeric: tabular-nums; }
.funnel .rate { color: var(--text-secondary); font-size: 12px; text-align: left; }

#map { height: 360px; border-radius: 10px; background: #0d1119; }
.leaflet-container { font-family: var(--font); background: #0d1119; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--surface-2); color: var(--text-primary); border: 1px solid var(--line); }
.leaflet-control-attribution { background: rgba(11, 14, 20, .75) !important; color: var(--text-muted) !important; font-size: 10px; }
.leaflet-control-attribution a { color: var(--text-secondary) !important; }

.heat { display: grid; grid-template-columns: 52px repeat(24, minmax(0, 1fr)); gap: 3px; font-size: 10.5px; color: var(--text-muted); }
.heat .c { aspect-ratio: 1.2; border-radius: 3px; background: var(--surface-3); }
.heat .lab { display: flex; align-items: center; }
.heat .hl { text-align: center; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--text-secondary); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-inline-end: 6px; vertical-align: -1px; }

/* drawer */
.drawer-bg { position: fixed; inset: 0; background: rgba(4, 6, 10, .6); z-index: 1000; backdrop-filter: blur(2px); }
.drawer { position: fixed; top: 0; left: 0; bottom: 0; width: min(620px, 100vw); background: var(--surface-1); border-right: 1px solid var(--line); z-index: 1001; overflow-y: auto; padding: 20px 22px 40px; box-shadow: 20px 0 60px rgba(0, 0, 0, .4); }
.drawer h2 { margin: 0 0 4px; font-size: 19px; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 8px 12px; font-size: 13px; margin: 14px 0; }
.kv dt { color: var(--text-muted); }
.kv dd { margin: 0; }
.code { background: #0a0d13; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; direction: ltr; text-align: left; white-space: pre-wrap; word-break: break-all; color: #cfd6e4; position: relative; }
.copy { position: absolute; top: 8px; right: 8px; }
.steps { display: grid; gap: 10px; counter-reset: s; }
.steps li { list-style: none; counter-increment: s; position: relative; padding-inline-start: 34px; line-height: 1.8; color: var(--text-secondary); }
.steps li::before { content: counter(s); position: absolute; right: 0; top: 2px; width: 24px; height: 24px; border-radius: 7px; background: var(--surface-3); color: var(--brand); display: grid; place-items: center; font-weight: 700; font-size: 12px; }
.steps b { color: var(--text-primary); }
.status-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 10px; }
.status-item { display: flex; gap: 10px; align-items: flex-start; padding: 12px; border-radius: 11px; background: var(--surface-2); border: 1px solid var(--line-soft); font-size: 13px; }
.status-item small { display: block; color: var(--text-muted); margin-top: 2px; line-height: 1.6; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login form { width: min(380px, 100%); background: var(--surface-1); border: 1px solid var(--line); border-radius: 18px; padding: 28px; display: grid; gap: 14px; }
.login h1 { margin: 0; font-size: 22px; display: flex; align-items: center; gap: 10px; }
.login label { display: grid; gap: 6px; color: var(--text-secondary); font-size: 13px; }
.login .err { color: var(--critical); font-size: 13px; min-height: 18px; }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--surface-3); border: 1px solid var(--line); padding: 10px 16px; border-radius: 10px; z-index: 2000; box-shadow: 0 10px 30px rgba(0, 0, 0, .4); }
.skeleton { height: 120px; border-radius: var(--radius); background: linear-gradient(90deg, var(--surface-1), var(--surface-2), var(--surface-1)); background-size: 200% 100%; animation: sh 1.3s infinite; }
@keyframes sh { to { background-position: -200% 0; } }

/* mobile */
.mnav { display: none; }
@media (max-width: 1100px) {
  .g-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-21, .g-12 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: none; }
  main { padding: 10px 12px 90px; }
  .g-2, .g-3 { grid-template-columns: minmax(0, 1fr); }
  .g-kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi .val { font-size: 22px; }
  .topbar { gap: 8px; }
  .topbar h1 { font-size: 18px; width: 100%; }
  .topbar .grow { display: none; }
  .mnav { display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 900; background: rgba(11, 14, 20, .94); backdrop-filter: blur(10px); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); overflow-x: auto; }
  .mnav a { flex: 1 0 auto; display: grid; justify-items: center; gap: 3px; font-size: 10.5px; color: var(--text-muted); padding: 4px 8px; min-width: 62px; }
  .mnav a svg { width: 20px; height: 20px; }
  .mnav a.on { color: var(--brand); }
  .chart { height: 240px; }
  .trunc { max-width: 170px; }
  .card { padding: 14px; }
  .tbl-wrap { margin: 0 -14px; padding: 0 14px; }
  .funnel .st { grid-template-columns: 70px minmax(0, 1fr) 60px; }
}
