/* ---------- tokens ---------- */
:root {
  --red: #E32636; --red-deep: #B51225; --red-accent: #FF4655;
  --ok: #16A34A; --warn: #D97706; --down: #E32636; --none: #CBD2DC;
  --bg: #F7F8FA; --surface: #FFFFFF; --surface-2: #F0F2F5; --border: #E3E7ED;
  --text: #0E1320; --muted: #5B6575;
  --shadow: 0 1px 2px rgb(9 11 16 / .04), 0 8px 24px -12px rgb(9 11 16 / .12);
  --radius: 16px;
  --font: 'Inter', 'IBM Plex Sans Arabic', system-ui, sans-serif;
  --font-head: 'Plus Jakarta Sans', 'IBM Plex Sans Arabic', 'Inter', system-ui, sans-serif;
  color-scheme: light;
}
:root[lang='ar'] { --font: 'IBM Plex Sans Arabic', 'Inter', system-ui, sans-serif; --font-head: 'IBM Plex Sans Arabic', system-ui, sans-serif; }

:root[data-theme='dark'], :root[data-theme='system'].is-dark {
  --ok: #22C55E; --warn: #F59E0B; --down: #FF4655; --none: #2A3344;
  --bg: #090B10; --surface: #171E2B; --surface-2: #121722; --border: #232C3D;
  --text: #F2F4F8; --muted: #AAB2C0;
  --shadow: 0 1px 0 rgb(255 255 255 / .03) inset, 0 12px 32px -16px rgb(0 0 0 / .6);
  color-scheme: dark;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100dvh; display: flex; flex-direction: column;
  background: var(--bg); color: var(--text); font: 15px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--font-head); margin: 0; letter-spacing: -.01em; }
:root[lang='ar'] h1, :root[lang='ar'] h2, :root[lang='ar'] h3 { letter-spacing: 0; }
a { color: inherit; }
svg { stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.wrap { width: min(100% - 32px, 960px); margin-inline: auto; }
main { flex: 1; padding-block: 28px 48px; }
.skip { position: absolute; inset-inline-start: 12px; top: -48px; background: var(--red); color: #fff; padding: 8px 14px; border-radius: 8px; z-index: 10; }
.skip:focus { top: 12px; }
:focus-visible { outline: 2px solid var(--red-accent); outline-offset: 2px; border-radius: 6px; }

.logo--light { display: none; }
:root[data-theme='light'] .logo--dark, :root[data-theme='system']:not(.is-dark) .logo--dark { display: none; }
:root[data-theme='light'] .logo--light, :root[data-theme='system']:not(.is-dark) .logo--light { display: inline-block; }

/* ---------- top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: saturate(1.4) blur(12px); border-bottom: 1px solid var(--border); }
.topbar__inner { display: flex; align-items: center; justify-content: space-between; height: 64px; gap: 16px; }
.brand { display: flex; align-items: center; gap: 14px; text-decoration: none; }
.brand .logo { height: 22px; width: auto; }
.brand__divider { width: 1px; height: 22px; background: var(--border); }
.brand__label { font: 700 12px/1 var(--font-head); letter-spacing: .22em; color: var(--muted); white-space: nowrap; }
:root[lang='ar'] .brand__label { letter-spacing: 0; font-size: 14px; }
.controls { display: flex; gap: 8px; align-items: center; }
.ctl, .seg button {
  appearance: none; border: 0; background: none; color: var(--muted); cursor: pointer;
  height: 34px; min-width: 34px; display: grid; place-items: center; border-radius: 9px; font: 600 14px var(--font);
  transition: background .15s, color .15s;
}
.ctl { border: 1px solid var(--border); padding-inline: 10px; }
.ctl:hover, .seg button:hover { color: var(--text); background: var(--surface-2); }
.seg { display: flex; padding: 3px; border: 1px solid var(--border); border-radius: 12px; gap: 2px; }
.seg button { height: 28px; min-width: 30px; border-radius: 8px; }
.seg button svg { width: 16px; height: 16px; }
.seg button[aria-checked='true'] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* ---------- hero ---------- */
.hero {
  --tone: var(--muted);
  position: relative; overflow: hidden; isolation: isolate;
  display: flex; align-items: center; gap: 22px; padding: 28px 28px 32px;
  background: var(--surface); border: 1px solid var(--border); border-radius: calc(var(--radius) + 4px); box-shadow: var(--shadow);
}
.hero[data-state='operational'] { --tone: var(--ok); }
.hero[data-state='degraded'] { --tone: var(--warn); }
.hero[data-state='partial_outage'], .hero[data-state='major_outage'] { --tone: var(--down); }
.hero__glow { position: absolute; inset: -40% auto auto -10%; width: 420px; height: 420px; z-index: -1; background: radial-gradient(closest-side, color-mix(in srgb, var(--tone) 22%, transparent), transparent); transition: background .6s; }
:root[dir='rtl'] .hero__glow { inset: -40% -10% auto auto; }
.hero__icon { position: relative; width: 64px; height: 64px; flex: none; display: grid; place-items: center; }
.core { position: relative; width: 48px; height: 48px; border-radius: 50%; background: var(--tone); color: #fff; display: grid; place-items: center; transition: background .4s; }
.core .i { width: 26px; height: 26px; stroke-width: 2.6; display: none; }
.hero[data-state='operational'] .i--ok, .hero[data-state='degraded'] .i--warn,
.hero[data-state='partial_outage'] .i--down, .hero[data-state='major_outage'] .i--down { display: block; }
.hero[data-state='loading'] .i--wait, .hero[data-state='unknown'] .i--wait { display: block; }
.ring { position: absolute; inset: 8px; border-radius: 50%; border: 2px solid var(--tone); opacity: 0; animation: ping 2.4s cubic-bezier(.2, .6, .3, 1) infinite; }
.ring--2 { animation-delay: 1.2s; }
.hero[data-state='loading'] .ring, .hero[data-state='unknown'] .ring { animation: none; }
@keyframes ping { 0% { transform: scale(.9); opacity: .55; } 100% { transform: scale(1.7); opacity: 0; } }
.hero h1 { font-size: clamp(22px, 3.4vw, 30px); line-height: 1.2; font-weight: 800; }
.hero__meta { margin: 6px 0 0; color: var(--muted); font-size: 14px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.live { display: inline-flex; align-items: center; gap: 7px; font-weight: 600; color: var(--text); }
.live__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 0 color-mix(in srgb, var(--red) 60%, transparent); animation: live 1.6s infinite; }
@keyframes live { 70% { box-shadow: 0 0 0 7px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
.refresh { position: absolute; inset-inline: 0; bottom: 0; height: 3px; background: var(--surface-2); }
.refresh span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--red-deep), var(--red-accent)); transition: width 1s linear; }

.banner { margin-top: 14px; padding: 12px 16px; border-radius: 12px; background: color-mix(in srgb, var(--warn) 12%, var(--surface)); border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent); font-size: 14px; }

/* ---------- sections ---------- */
.section { margin-top: 36px; }
.section h2 { font-size: 18px; font-weight: 700; margin-bottom: 14px; }
.section__head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.section__head h2 { margin: 0; }
.legend { display: flex; gap: 14px; list-style: none; margin: 0; padding: 0; color: var(--muted); font-size: 13px; flex-wrap: wrap; }
.legend li { display: flex; gap: 6px; align-items: center; }
.sw { width: 10px; height: 10px; border-radius: 3px; }
.sw--up { background: var(--ok); } .sw--degraded { background: var(--warn); } .sw--down { background: var(--down); } .sw--none { background: var(--none); }

.groups { display: grid; gap: 16px; }
.group { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.group__head { display: flex; justify-content: space-between; align-items: center; padding: 14px 20px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.group__head h3 { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
:root[lang='ar'] .group__head h3 { text-transform: none; letter-spacing: 0; font-size: 14px; }
.pill { font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; color: var(--c); background: color-mix(in srgb, var(--c) 14%, transparent); }

.svc { padding: 16px 20px 18px; display: grid; gap: 10px; }
.svc + .svc { border-top: 1px solid var(--border); }
.svc__top { display: flex; align-items: center; gap: 12px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); flex: none; box-shadow: 0 0 0 4px color-mix(in srgb, var(--c) 18%, transparent); }
.svc__name { font-weight: 600; flex: 1; min-width: 0; }
.svc__stats { display: flex; gap: 16px; align-items: center; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.svc__stats b { color: var(--text); font-weight: 600; }
.spark { width: 96px; height: 26px; color: var(--c); }
.spark path.area { fill: color-mix(in srgb, currentColor 14%, transparent); stroke: none; }
.spark path.line { stroke-width: 1.6; }
.state-up { --c: var(--ok); } .state-degraded { --c: var(--warn); } .state-down { --c: var(--down); } .state-none { --c: var(--muted); }

.bars { display: flex; gap: 2px; height: 32px; align-items: stretch; }
.bar { flex: 1; min-width: 2px; border-radius: 2px; background: var(--none); transition: transform .15s, opacity .15s; transform-origin: bottom; }
.bar.up { background: var(--ok); } .bar.degraded { background: var(--warn); } .bar.down { background: var(--down); }
.bars:hover .bar { opacity: .55; }
.bars .bar:hover { opacity: 1; transform: scaleY(1.12); }
.bars__axis { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; }
.bars__axis .line { flex: 1; height: 1px; background: var(--border); margin: auto 12px; }
.axis-short { display: none; }

.skeleton { height: 152px; border-radius: var(--radius); background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 50%, var(--surface) 75%) 0 0/200% 100%; border: 1px solid var(--border); animation: shimmer 1.4s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- incidents ---------- */
.incidents { display: grid; gap: 12px; }
.empty { color: var(--muted); background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); padding: 18px 20px; display: flex; gap: 10px; align-items: center; }
.empty svg { width: 18px; height: 18px; color: var(--ok); }
.inc { --c: var(--down); background: var(--surface); border: 1px solid var(--border); border-inline-start: 4px solid var(--c); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.inc.minor { --c: var(--warn); } .inc.maintenance { --c: #3B82F6; } .inc.resolved { --c: var(--ok); }
.inc__head { display: flex; justify-content: space-between; gap: 12px; align-items: start; flex-wrap: wrap; }
.inc h3 { font-size: 16px; }
.inc__when { color: var(--muted); font-size: 13px; }
.timeline { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 12px; }
.timeline li { position: relative; padding-inline-start: 18px; }
.timeline li::before { content: ''; position: absolute; inset-inline-start: 0; top: 8px; width: 7px; height: 7px; border-radius: 50%; background: var(--c); }
.timeline li + li::after { content: ''; position: absolute; inset-inline-start: 3px; bottom: calc(100% - 6px); height: 16px; width: 1px; background: var(--border); }
.timeline strong { font-weight: 600; margin-inline-end: 6px; }
.timeline time { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }

/* ---------- tooltip ---------- */
.tip { position: fixed; z-index: 20; pointer-events: none; background: var(--text); color: var(--bg); padding: 8px 10px; border-radius: 8px; font-size: 12px; line-height: 1.4; white-space: nowrap; transform: translate(-50%, calc(-100% - 10px)); box-shadow: 0 8px 24px rgb(0 0 0 / .25); }
.tip b { font-weight: 600; }

/* ---------- footer (fixed to page bottom via flex layout) ---------- */
.footer { border-top: 1px solid var(--border); background: var(--surface-2); color: var(--muted); font-size: 13px; }
.footer__inner { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding-block: 18px; flex-wrap: wrap; }
.powered { display: inline-flex; gap: 8px; align-items: center; text-decoration: none; color: var(--muted); }
.powered:hover { color: var(--text); }
.powered .logo { height: 13px; width: auto; }

@media (max-width: 640px) {
  .hero { padding: 22px 20px 26px; gap: 16px; }
  .hero__icon { width: 52px; height: 52px; } .core { width: 40px; height: 40px; }
  .svc__stats .spark, .svc__stats .lat { display: none; }
  .bars { height: 28px; gap: 1px; }
  .bar:nth-child(-n+30) { display: none; } /* last 60 days on phones */
  .axis-long { display: none; } .axis-short { display: inline; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
