/* Insight by Saqrions 0.1: one stylesheet, no build step. Colours of the agreed screens (dark console),
   brand red from the Saqrion design tokens. Logical properties throughout, so Arabic flips cleanly to right-to-left. */
:root {
  --brand-red: #c0152a;
  --bg-0: #121822;
  --bg-1: #1b2433;
  --panel: rgba(29, 36, 49, .85);
  --panel-solid: #1d2431;
  --sunk: #232b39;
  --track: #273041;
  --line: #2c3647;
  --line-soft: #232b39;
  --fg: #dfe5ee;
  --muted: #a0abbd;
  --ok: #6fcf9f;
  --warn: #e9bb67;
  --bad: #f0727d;
  --info: #6cc6d6;
  --ink-on-chip: #161c27;
  --radius: 12px;
  --font: 'Segoe UI', system-ui, -apple-system, Roboto, 'Noto Sans Arabic', Tahoma, Arial, sans-serif;
  color-scheme: dark;
}
:root[data-theme="light"] { color-scheme: dark; }   /* the console is dark in both themes, as agreed */

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: radial-gradient(ellipse at 50% 30%, var(--bg-1) 0%, var(--bg-0) 70%) fixed, var(--bg-0);
  color: var(--fg); font-family: var(--font); font-size: 13px; line-height: 1.4;
  overflow-x: hidden;
}
a { color: var(--info); } a:hover { color: #9edbe6; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--info); outline-offset: 2px; }
.hidden { display: none !important; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.ok { color: var(--ok); } .warn { color: var(--warn); } .bad { color: var(--bad); } .info { color: var(--info); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- animations (from the agreed screens) ---------- */
@keyframes ins-pulse { 0% { transform: scale(1); opacity: .9 } 70% { transform: scale(2.6); opacity: 0 } 100% { opacity: 0 } }
@keyframes ins-spin { to { transform: rotate(360deg) } }
@keyframes ins-spinrev { to { transform: rotate(-360deg) } }
@keyframes ins-blink { 50% { opacity: .35 } }
@keyframes ins-in { from { transform: translateY(-8px); opacity: 0 } to { transform: none; opacity: 1 } }
@keyframes ins-breathe { 0%, 100% { transform: scale(1) } 12% { transform: scale(1.18) } 24% { transform: scale(1.04) } 36% { transform: scale(1.12) } }
@keyframes ins-move { 0% { offset-distance: 0%; opacity: 0 } 8% { opacity: 1 } 90% { opacity: 1 } 100% { offset-distance: 100%; opacity: 0 } }
@keyframes ins-attack { 0% { offset-distance: 0%; opacity: 0; transform: scale(.6) } 10% { opacity: 1 } 85% { offset-distance: 100%; opacity: 1; transform: scale(1) } 100% { offset-distance: 100%; opacity: 0; transform: scale(3.2) } }
@keyframes ins-shield { 0%, 100% { opacity: .25 } 50% { opacity: .7 } }
@keyframes ins-ecg { to { stroke-dashoffset: -1200 } }
@keyframes ins-glow { 0%, 100% { opacity: .45 } 50% { opacity: 1 } }
@keyframes sc-arc { to { stroke-dashoffset: 0 } }
@keyframes sc-fly { 0% { offset-distance: 0%; opacity: 0 } 10% { opacity: 1 } 92% { opacity: 1 } 100% { offset-distance: 100%; opacity: 0 } }
@keyframes sc-hit { 0%, 100% { transform: scale(1); opacity: .6 } 50% { transform: scale(1.9); opacity: 1 } }
@keyframes sc-scan { 0% { transform: translateX(-100%) } 100% { transform: translateX(420%) } }
@keyframes sc-in { from { transform: translateX(18px); opacity: 0 } to { transform: none; opacity: 1 } }
@keyframes sc-blip { 0% { opacity: 0; transform: scale(.4) } 15% { opacity: 1; transform: scale(1.2) } 100% { opacity: 0; transform: scale(.8) } }
@keyframes sc-trap { 0%, 100% { box-shadow: 0 0 0 0 rgba(233,187,103,0) } 50% { box-shadow: 0 0 22px 4px rgba(233,187,103,.45) } }

.ins-ping { position: absolute; inset: 0; border-radius: 50%; animation: ins-pulse 1.8s ease-out infinite; }
.ins-blink { animation: ins-blink 1.2s ease-in-out infinite; }
.ins-new { animation: ins-in .5s ease-out; }
.ins-bar { transition: width .8s ease, background .8s ease; }
.sweep { transform-origin: 50% 50%; animation: ins-spin 6s linear infinite; }
.sc-sweep { animation: ins-spin 4s linear infinite; }
.sc-arc { stroke-dasharray: 600; stroke-dashoffset: 600; animation: sc-arc 2.4s ease-out infinite; }
.sc-fly { position: absolute; left: 0; top: 0; width: 6px; height: 6px; border-radius: 50%; animation: sc-fly linear infinite; }
.sc-hit { animation: sc-hit 1.2s ease-in-out infinite; }
.sc-scanbar { animation: sc-scan 2.6s linear infinite; }
.sc-in { animation: sc-in .45s ease-out; }
.sc-blip { position: absolute; width: 8px; height: 8px; border-radius: 50%; animation: sc-blip 4s ease-out infinite; }
.sc-trap { animation: sc-trap 2.2s ease-in-out infinite; }
.sc-ring { transition: stroke-dashoffset 1s ease; }

/* ---------- shell ---------- */
.top { display: flex; align-items: center; gap: 14px; padding: 14px 20px 0; flex-wrap: wrap; }
.logo { width: 40px; height: 40px; border-radius: 10px; background: var(--brand-red); display: grid; place-items: center; flex-shrink: 0; }
.brand { display: flex; flex-direction: column; min-width: 0; }
.brand b { font-size: 20px; font-weight: 700; white-space: nowrap; }
.brand span { color: var(--muted); font-size: 12px; }
.live-pill { display: flex; align-items: center; gap: 8px; padding: 5px 12px; border-radius: 999px; background: rgba(111,207,159,.14); color: var(--ok); font-weight: 600; white-space: nowrap; }
.live-pill.off { background: rgba(160,171,189,.12); color: var(--muted); }
.demo-pill { padding: 5px 12px; border-radius: 999px; background: rgba(233,187,103,.16); color: var(--warn); font-weight: 700; letter-spacing: .04em; white-space: nowrap; }
.dot { position: relative; width: 9px; height: 9px; flex-shrink: 0; display: inline-block; }
.dot > i { position: absolute; inset: 0; border-radius: 50%; background: currentColor; }
.grow { flex-grow: 1; }
.nav { display: flex; gap: 4px; padding: 10px 20px 0; flex-wrap: wrap; align-items: center; }
.nav a { padding: 7px 12px; border-radius: 8px; color: var(--muted); text-decoration: none; font-weight: 600; border: 1px solid transparent; }
.nav a[aria-current="page"] { color: var(--fg); background: var(--panel); border-color: var(--line); }
.switcher { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
select, input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], input[type=date], textarea {
  background: var(--sunk); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; min-height: 36px; max-width: 100%;
}
.btn { height: 36px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--sunk); color: var(--fg); cursor: pointer; font-weight: 600; white-space: nowrap; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--bad); color: var(--ink-on-chip); border: 0; }
.btn.small { height: 28px; padding: 0 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: default; }
main { padding: 12px 20px 24px; }

.panel { border-radius: var(--radius); border: 1px solid var(--line); background: var(--panel); padding: 14px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.panel.flat { background: var(--panel-solid); }
.h { font-size: 11px; font-weight: 700; letter-spacing: .09em; color: var(--muted); text-transform: uppercase; }
:lang(ar) .h { letter-spacing: 0; font-size: 12px; }
.row { display: flex; align-items: center; gap: 10px; min-width: 0; }
.row.between { justify-content: space-between; }
.kpis { display: flex; gap: 8px; flex-wrap: wrap; }
.kpi { min-width: 104px; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; gap: 2px; }
.kpi span:first-child { font-size: 10.5px; font-weight: 600; letter-spacing: .09em; color: var(--muted); }
.kpi b { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.chip { justify-self: start; display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 10.5px; font-weight: 700; letter-spacing: .05em; color: var(--ink-on-chip); white-space: nowrap; }
.chip.Critical, .chip.bad { background: var(--bad); } .chip.Warning, .chip.warn { background: var(--warn); } .chip.Info, .chip.info { background: var(--info); }
.chip.ok { background: var(--ok); } .chip.mute { background: var(--track); color: var(--fg); }
.later { display: inline-block; padding: 3px 10px; border-radius: 999px; border: 1px dashed var(--muted); color: var(--muted); font-size: 11.5px; font-weight: 600; background: rgba(18,24,34,.75); }
.empty { color: var(--muted); padding: 6px 0; }

/* ---------- console ---------- */
.console { display: grid; grid-template-columns: 300px minmax(0, 1fr) 330px; gap: 12px; align-items: start; }
.col { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.gauge .bar { height: 8px; border-radius: 6px; background: var(--track); overflow: hidden; }
.gauge .bar > div { height: 100%; border-radius: 6px; }
.trio { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.trio span { color: var(--muted); font-size: 11px; display: block; }
.trio b { font-weight: 600; }
.svc { display: flex; align-items: center; gap: 10px; }
.svc .name { flex-grow: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bk { display: grid; grid-template-columns: minmax(0, 1fr) 70px 56px; gap: 8px; align-items: center; }
.bk span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.fe { position: relative; border-radius: var(--radius); border: 1px solid var(--line); background: radial-gradient(circle at 50% 52%, #1f2a3c 0%, #141b27 62%); overflow: hidden; aspect-ratio: 836 / 420; width: 100%; }
.fe .lbl { position: absolute; inset-inline-start: 14px; top: 12px; z-index: 3; }
.fe .lbr { position: absolute; inset-inline-end: 14px; top: 12px; z-index: 3; color: var(--muted); }
.fe-stage { position: absolute; left: 0; top: 0; width: 836px; height: 420px; transform-origin: 0 0; direction: ltr; }
.fe-ring { position: absolute; border-radius: 50%; left: 418px; top: 210px; }
.fe-spin { animation: ins-spin 24s linear infinite; }
.fe-spin-mid { animation: ins-spinrev 14s linear infinite; }
.fe-spin-fast { animation: ins-spin 7s linear infinite; }
.fe-pupil { animation: ins-breathe var(--beat, 1.1s) ease-in-out infinite; transition: width .8s ease, height .8s ease, margin .8s ease; }
.fe-pkt { position: absolute; left: 0; top: 0; width: 7px; height: 7px; border-radius: 50%; animation: ins-move linear infinite; }
.fe-atk { position: absolute; left: 0; top: 0; width: 6px; height: 6px; border-radius: 50%; background: var(--bad); box-shadow: 0 0 10px 3px rgba(240,114,125,.7); animation: ins-attack ease-in infinite; }
.fe-shield { animation: ins-shield 2.4s ease-in-out infinite; }
.fe-ecg { stroke-dasharray: 600 600; animation: ins-ecg 3s linear infinite; }
.fe-glow { animation: ins-glow 2s ease-in-out infinite; }
.fe-node { position: absolute; z-index: 2; display: flex; align-items: center; gap: 8px; padding: 4px 8px; border-radius: 8px; background: rgba(20,27,39,.88); border: 1px solid; cursor: pointer; }
.fe-node.left { flex-direction: row-reverse; text-align: right; transform: translateX(-100%); }
.fe-node .t { display: flex; flex-direction: column; line-height: 1.2; }
.fe-node .t b { font-weight: 600; color: var(--fg); }
.fe-node .t span { color: var(--muted); font-size: 11.5px; }
.fe-beat { position: absolute; left: 418px; top: 330px; transform: translateX(-50%); color: var(--muted); font-size: 11.5px; letter-spacing: .08em; white-space: nowrap; }

.legend { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.legend i { width: 14px; height: 3px; display: inline-block; }
.stats4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.stats4 span { color: var(--muted); font-size: 11px; display: block; }
.stats4 b { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }

.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.tile { border-radius: 10px; background: var(--sunk); padding: 10px; display: flex; flex-direction: column; gap: 2px; }
.tile span { color: var(--muted); font-size: 11.5px; }
.tile b { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.ev { border-radius: 10px; background: var(--sunk); padding: 9px 10px; display: flex; flex-direction: column; gap: 3px; }
.ev.crit { box-shadow: inset 3px 0 0 var(--bad); }
:dir(rtl) .ev.crit, [dir=rtl] .ev.crit { box-shadow: inset -3px 0 0 var(--bad); }
.ev .row b { font-weight: 600; flex-grow: 1; min-width: 0; }
.ev small { color: var(--muted); font-size: 12px; }
.events { display: flex; flex-direction: column; gap: 8px; max-height: 560px; overflow-y: auto; }

table.list { width: 100%; border-collapse: collapse; }
table.list th { text-align: start; font-size: 11px; font-weight: 600; letter-spacing: .06em; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.list td { padding: 9px 10px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
table.list tr.click { cursor: pointer; } table.list tr.click:hover td { background: rgba(44,54,71,.4); }
.scroll-x { overflow-x: auto; max-width: 100%; }
.devl { max-height: 560px; overflow-y: auto; }
.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.filters button { padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--muted); cursor: pointer; font-size: 12px; }
.filters button[aria-pressed="true"] { color: var(--fg); border-color: var(--info); background: rgba(108,198,214,.12); }

/* ---------- drawer, dialogs ---------- */
.drawer-bg { position: fixed; inset: 0; background: rgba(8,12,18,.6); z-index: 40; }
.drawer { position: fixed; top: 0; bottom: 0; inset-inline-end: 0; width: min(880px, 100vw); background: var(--bg-0); border-inline-start: 1px solid var(--line); z-index: 41; overflow-y: auto; padding: 18px 20px; display: flex; flex-direction: column; gap: 12px; }
.dialog { position: fixed; z-index: 50; inset: 0; display: grid; place-items: center; padding: 16px; background: rgba(8,12,18,.6); }
.dialog > form, .dialog > div { width: min(520px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; background: var(--panel-solid); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field > span { color: var(--muted); font-size: 12px; }
.check { display: flex; gap: 8px; align-items: center; }
.err { color: var(--bad); min-height: 1em; }
.secret { font-family: ui-monospace, Consolas, monospace; background: var(--sunk); padding: 8px 10px; border-radius: 8px; word-break: break-all; direction: ltr; text-align: left; user-select: all; }
.charts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.chart svg { width: 100%; height: 120px; display: block; }
.ranges { display: flex; gap: 6px; }

/* ---------- sign-in ---------- */
.signin { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.signin form { width: min(400px, 100%); background: var(--panel-solid); border: 1px solid var(--line); border-radius: 16px; padding: 24px; display: flex; flex-direction: column; gap: 14px; }
.qr { background: #fff; border-radius: 8px; padding: 6px; align-self: center; line-height: 0; }
.codes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; direction: ltr; }

/* ---------- Security Centre ---------- */
.security { display: grid; grid-template-columns: 300px minmax(0, 1fr) 340px; gap: 12px; align-items: start; }
.score { position: relative; align-self: center; width: 220px; max-width: 100%; }
.score svg { width: 100%; height: auto; display: block; }
.parts { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; width: 100%; }
.parts div { display: flex; justify-content: space-between; gap: 6px; }
.radar { position: relative; width: 300px; height: 190px; align-self: center; max-width: 100%; direction: ltr; }
.map { position: relative; border-radius: var(--radius); border: 1px solid var(--line); background: rgba(20,27,39,.92); overflow: hidden; aspect-ratio: 856 / 420; width: 100%; }
.map-stage { position: absolute; left: 0; top: 0; width: 856px; height: 420px; transform-origin: 0 0; direction: ltr; }
.later-veil { position: absolute; inset: 0; z-index: 4; display: grid; place-items: center; pointer-events: none; }
.heat { display: grid; grid-template-columns: 40px repeat(24, minmax(0, 1fr)); gap: 3px; direction: ltr; }
.heat span { height: 16px; border-radius: 3px; }
.heat .d { font-size: 11px; color: var(--muted); display: flex; align-items: center; height: auto; }
.three { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.ports { display: flex; flex-wrap: wrap; gap: 6px; }
.ports span { padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; border: 1px solid; }
.fw { display: grid; grid-template-columns: 52px minmax(0, 1fr) 76px; gap: 8px; align-items: center; font-variant-numeric: tabular-nums; }
.fw span:nth-child(2) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; direction: ltr; text-align: start; }

/* ---------- People and alerts, master console ---------- */
.people-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.pill { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--bad); color: var(--bad); font-weight: 600; }
.pill.off { border-color: var(--line); color: var(--muted); }
.role { padding: 3px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.role.Owner { background: rgba(240,114,125,.16); color: var(--bad); }
.role.Operator { background: rgba(108,198,214,.16); color: var(--info); }
.role.Viewer { background: var(--track); color: var(--fg); }
.role.Super { background: rgba(192,21,42,.3); color: #fff; }
.note { border-radius: 10px; border: 1px solid var(--warn); background: rgba(233,187,103,.08); padding: 10px 12px; color: var(--fg); }
.stack { display: flex; flex-direction: column; gap: 16px; }

/* ---------- widths: 1366 laptop, tablet, 390 phone ---------- */
@media (max-width: 1440px) {
  .console { grid-template-columns: 280px minmax(0, 1fr) 310px; }
  .security { grid-template-columns: 280px minmax(0, 1fr) 320px; }
}
@media (max-width: 1180px) {
  .console, .security { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .console > .center, .security > .center { grid-column: 1 / -1; order: -1; }
}
@media (max-width: 760px) {
  main { padding: 10px 16px 20px; }
  .top { padding: 12px 16px 0; gap: 10px; }
  .nav { padding: 8px 16px 0; }
  .console, .security, .people-grid, .charts, .three { grid-template-columns: minmax(0, 1fr); }
  .kpis { width: 100%; }
  .kpi { min-width: 0; flex: 1 1 calc(33% - 8px); padding: 6px 8px; }
  .kpi b { font-size: 16px; }
  .stats4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .brand b { font-size: 17px; }
  .hide-phone { display: none !important; }
  .fe .lbr { display: none; }
  table.list th, table.list td { padding: 7px 6px; }
  .drawer { padding: 14px 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .ins-ping, .ins-blink, .ins-new, .sweep, .sc-sweep, .fe-spin, .fe-spin-mid, .fe-spin-fast, .fe-pupil, .fe-pkt, .fe-atk,
  .fe-shield, .fe-ecg, .fe-glow, .sc-arc, .sc-fly, .sc-hit, .sc-scanbar, .sc-in, .sc-blip, .sc-trap { animation: none !important; }
  .sc-arc { stroke-dashoffset: 0; }
  .fe-pkt, .sc-fly, .fe-atk { display: none; }
  .sc-blip { opacity: 1; }
  .ins-bar, .sc-ring, .fe-pupil { transition: none; }
}

/* Arabic: numbers and units keep their order ("2 / 25", "8.5 kb/s") while Arabic words stay right-to-left */
.kpi b, .tile b, .stats4 b, .trio b, .gauge .muted, .num, .fe-node .t span, .bk span, .svc .muted, .parts b, table.list td { unicode-bidi: plaintext; }
[dir=rtl] .kpi b, [dir=rtl] .tile b, [dir=rtl] .stats4 b, [dir=rtl] .trio b, [dir=rtl] table.list td { text-align: right; }
