@font-face {
  font-family: "Vazirmatn";
  src: url("/fonts/vazirmatn.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --border: #e5e7ec;
  --border-strong: #d4d8e0;
  --text: #0f172a;
  --text-2: #475569;
  --muted: #8a94a6;
  --accent: #2563eb;
  --accent-soft: #eaf1ff;
  --up: #16a34a;
  --up-soft: #e8f7ee;
  --part: #f59e0b;
  --part-soft: #fff6e5;
  --down: #e11d48;
  --down-soft: #fdecf0;
  --none: #e3e7ee;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 4px 16px rgba(15, 23, 42, .04);
  --radius: 16px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c0f14;
    --surface: #141922;
    --surface-2: #10141b;
    --border: #232a36;
    --border-strong: #2f3846;
    --text: #e8ecf3;
    --text-2: #a7b0bf;
    --muted: #6f7a8c;
    --accent: #6ea0ff;
    --accent-soft: #17233b;
    --up: #34d399;
    --up-soft: #10261d;
    --part: #fbbf24;
    --part-soft: #2a2213;
    --down: #fb7185;
    --down-soft: #2c1219;
    --none: #262e3a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0c0f14;
  --surface: #141922;
  --surface-2: #10141b;
  --border: #232a36;
  --border-strong: #2f3846;
  --text: #e8ecf3;
  --text-2: #a7b0bf;
  --muted: #6f7a8c;
  --accent: #6ea0ff;
  --accent-soft: #17233b;
  --up: #34d399;
  --up-soft: #10261d;
  --part: #fbbf24;
  --part-soft: #2a2213;
  --down: #fb7185;
  --down-soft: #2c1219;
  --none: #262e3a;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 15px/1.7 "Vazirmatn", Tahoma, system-ui, sans-serif;
  font-feature-settings: "ss01";
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
.wrap { max-width: 1040px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.ltr { direction: ltr; unicode-bidi: isolate; }

/* top bar */
.top {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--border);
}
.top-in { display: flex; align-items: center; justify-content: space-between; height: 60px; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.logo { width: 32px; height: 32px; flex: none; }
.logo { filter: drop-shadow(0 2px 6px rgba(255, 110, 70, .25)); }

/* brand loader: the hexagon breathes while the bolt draws itself */
.boot { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: var(--bg); transition: opacity .35s ease, visibility .35s; }
.boot.done { opacity: 0; visibility: hidden; }
.boot-in { display: flex; flex-direction: column; align-items: center; gap: 16px; font-size: 13px; color: var(--text-2); }
.lhs-anim { width: 76px; height: 76px; overflow: visible; filter: drop-shadow(0 10px 26px rgba(255, 110, 70, .35)); }
.lhs-anim .hex { transform-box: fill-box; transform-origin: center; animation: lhs-breathe 1.6s ease-in-out infinite; }
.lhs-anim .bolt { stroke-dasharray: 100; animation: lhs-bolt 1.6s ease-in-out infinite; }
@keyframes lhs-breathe { 0%, 100% { transform: scale(.93); } 50% { transform: scale(1); } }
@keyframes lhs-bolt { 0% { stroke-dashoffset: 100; } 45%, 70% { stroke-dashoffset: 0; } 100% { stroke-dashoffset: -100; } }
.brand-txt { display: flex; flex-direction: column; line-height: 1.25; }
.brand-txt b { font-size: 15px; letter-spacing: .5px; }
.brand-txt span { font-size: 12px; color: var(--text-2); }
.top-end { display: flex; align-items: center; gap: 12px; }
.theme { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface); border: 1px solid var(--border); border-radius: 11px; }
.theme button { width: 30px; height: 28px; border: 0; background: none; border-radius: 8px; display: grid; place-items: center; color: var(--muted); }
.theme button svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.theme button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }
.updated { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-2); white-space: nowrap; }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--up); box-shadow: 0 0 0 0 color-mix(in srgb, var(--up) 60%, transparent); animation: pulse 2.4s infinite; }
.updated.stale .pulse { background: var(--part); animation: none; }
@keyframes pulse { 70% { box-shadow: 0 0 0 7px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }

/* hero */
.hero {
  margin: 24px 0 8px;
  display: grid; grid-template-columns: auto 1fr; gap: 6px 18px; align-items: center;
  padding: 22px 24px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  position: relative; overflow: hidden;
}
.hero::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--hero, var(--none)); }
.hero[data-s="up"] { --hero: var(--up); }
.hero[data-s="part"] { --hero: var(--part); }
.hero[data-s="down"] { --hero: var(--down); }
.hero-icon {
  width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center;
  background: color-mix(in srgb, var(--hero, var(--muted)) 14%, transparent); color: var(--hero, var(--muted));
}
.hero-icon svg { width: 28px; height: 28px; }
.hero h1 { margin: 0; font-size: 20px; font-weight: 750; line-height: 1.4; }
.hero p { margin: 2px 0 0; color: var(--text-2); font-size: 14px; }
.hero-stats {
  grid-column: 1 / -1; margin: 14px 0 0; padding: 14px 0 0; border-top: 1px dashed var(--border);
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px;
}
.hero-stats div { min-width: 0; }
.hero-stats dt { font-size: 12px; color: var(--muted); }
.hero-stats dd { margin: 0; font-size: 18px; font-weight: 700; }

/* blocks */
.block { margin-top: 28px; }
.block-head { margin-bottom: 12px; }
.block-head.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.block-head h2 { margin: 0; font-size: 17px; font-weight: 750; }
.block-head p { margin: 2px 0 0; font-size: 13px; color: var(--text-2); }

/* ai tiles */
.ai-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.ai {
  text-align: start; padding: 16px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 10px; transition: border-color .15s, transform .15s;
}
.ai:hover { border-color: var(--border-strong); }
.ai[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.ai-top { display: flex; align-items: center; gap: 10px; }
.ai-logo { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-weight: 800; font-size: 13px; color: #fff; flex: none; }
.ai-logo.gemini { background: linear-gradient(135deg, #4f8cff, #9b72f2); }
.ai-logo.openai { background: #10a37f; }
.ai-logo.claude { background: #d97757; }
.ai-name { font-weight: 700; font-size: 15px; }
.ai-sub { font-size: 12px; color: var(--muted); }
.ai-num { font-size: 22px; font-weight: 800; line-height: 1.2; }
.ai-num small { font-size: 13px; font-weight: 500; color: var(--text-2); }
.meter { height: 6px; border-radius: 99px; background: var(--none); overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--up); border-radius: 99px; }

/* segmented + toolbar */
.seg { display: inline-flex; padding: 3px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; }
.seg button { border: 0; background: none; padding: 5px 16px; border-radius: 9px; font-size: 13.5px; color: var(--text-2); }
.seg button[aria-selected="true"] { background: var(--accent); color: #fff; font-weight: 600; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.search {
  flex: 1 1 240px; display: flex; align-items: center; gap: 8px; padding: 0 12px; height: 42px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
}
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search svg { width: 18px; height: 18px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; flex: none; }
.search input { border: 0; outline: 0; background: none; width: 100%; font-size: 14px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips button {
  height: 34px; padding: 0 13px; border-radius: 99px; font-size: 13px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text-2);
}
.chips button[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }

/* location list */
.list { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.loc {
  display: grid; grid-template-columns: minmax(170px, 1.1fr) minmax(0, 2.3fr) 76px auto; gap: 18px; align-items: center;
  padding: 14px 18px; border-top: 1px solid var(--border);
}
.loc:first-child { border-top: 0; }
.who { display: flex; align-items: center; gap: 12px; min-width: 0; }
.flag { width: 30px; height: 22px; border-radius: 4px; object-fit: cover; flex: none; box-shadow: 0 0 0 1px rgba(0, 0, 0, .08); background: var(--none); }
.flag.globe { display: grid; place-items: center; color: var(--accent); background: var(--accent-soft); box-shadow: none; }
.flag.globe svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; }
.who-txt { min-width: 0; }
.who-name { font-weight: 650; font-size: 14.5px; display: flex; align-items: center; gap: 8px; }
.who-name .ltr { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who-sub { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.pack { font-size: 10.5px; font-weight: 700; padding: 0 6px; border-radius: 5px; line-height: 17px; }
.pack.pro { background: var(--accent-soft); color: var(--accent); }
.pack.eco { background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }
.state { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; }
.state i { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.state.up { color: var(--up); } .state.up i { background: var(--up); }
.state.degraded { color: var(--part); } .state.degraded i { background: var(--part); }
.state.down { color: var(--down); } .state.down i { background: var(--down); animation: pulse 2s infinite; }
.state.unknown { color: var(--muted); }

.bars-wrap { min-width: 0; }
.bars { display: flex; gap: 2px; height: 30px; align-items: stretch; direction: ltr; }
.bars i { flex: 1 1 0; min-width: 2px; border-radius: 2px; background: var(--none); transition: opacity .1s; }
.bars i.up { background: var(--up); }
.bars i.part { background: var(--part); }
.bars i.down { background: var(--down); }
.bars i:hover { opacity: .7; }
.bars-axis { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 3px; }
.pct { text-align: center; }
.pct b { display: block; font-size: 15px; font-weight: 750; direction: ltr; }
.pct span { font-size: 11px; color: var(--muted); }
.ais { display: flex; gap: 5px; justify-content: flex-end; }
.b {
  display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 8px; border-radius: 7px;
  font-size: 11.5px; font-weight: 600; direction: ltr; white-space: nowrap; border: 1px solid transparent;
}
.b svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.b.ok { background: var(--up-soft); color: var(--up); }
.b.blocked { background: var(--surface-2); color: var(--muted); border-color: var(--border); text-decoration: line-through; text-decoration-thickness: 1px; }
.b.unknown { background: var(--surface-2); color: var(--muted); border-color: var(--border); }
.empty { padding: 36px 16px; text-align: center; color: var(--muted); }

.legend { display: flex; gap: 16px; flex-wrap: wrap; justify-content: flex-end; font-size: 12px; color: var(--text-2); margin-top: 10px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.lg { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.lg.up { background: var(--up); } .lg.part { background: var(--part); } .lg.down { background: var(--down); } .lg.none { background: var(--none); }

/* incidents */
.incidents { display: flex; flex-direction: column; gap: 10px; }
.inc { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: start; padding: 14px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; }
.inc-ico { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; }
.inc-ico svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.inc.open .inc-ico { background: var(--down-soft); color: var(--down); }
.inc.done .inc-ico { background: var(--up-soft); color: var(--up); }
.inc h3 { margin: 0; font-size: 14px; font-weight: 700; }
.inc p { margin: 2px 0 0; font-size: 12.5px; color: var(--text-2); }
.inc-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.inc-tags span { font-size: 11.5px; padding: 0 7px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border); direction: ltr; }
.inc-dur { font-size: 12px; font-weight: 600; color: var(--text-2); white-space: nowrap; }
.inc.open .inc-dur { color: var(--down); }
.inc-empty { padding: 26px 16px; text-align: center; color: var(--muted); background: var(--surface); border: 1px dashed var(--border-strong); border-radius: 14px; font-size: 14px; }

.foot { padding-top: 28px; padding-bottom: 40px; font-size: 12.5px; color: var(--text-2); }
.foot p { margin: 4px 0; }

/* tooltip */
.tip {
  position: fixed; z-index: 30; pointer-events: none; max-width: 240px;
  background: var(--text); color: var(--bg); font-size: 12px; line-height: 1.6; padding: 7px 10px; border-radius: 9px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .18);
}
.tip b { font-weight: 700; }

/* skeleton */
.sk { height: 64px; border-top: 1px solid var(--border); background: linear-gradient(90deg, transparent, var(--surface-2), transparent); background-size: 200% 100%; animation: sk 1.4s infinite; }
.sk:first-child { border-top: 0; }
@keyframes sk { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* tablet: 60 days */
@media (max-width: 900px) {
  .loc { grid-template-columns: minmax(150px, 1fr) minmax(0, 2fr) 70px; }
  .ais { grid-column: 1 / -1; justify-content: flex-start; margin-top: -6px; }
  .bars i:nth-child(-n+30) { display: none; }
}

/* phone: 30 days, stacked card */
@media (max-width: 640px) {
  body { font-size: 14px; }
  .top-in { height: 56px; }
  .updated span { font-size: 11.5px; }
  .top-end { gap: 8px; }
  .theme button { width: 28px; }
  .updated .ago-pre { display: none; }
  .hero { padding: 18px 16px; grid-template-columns: auto 1fr; margin-top: 16px; }
  .hero-icon { width: 44px; height: 44px; border-radius: 12px; }
  .hero h1 { font-size: 17px; }
  .hero p { font-size: 13px; }
  .hero-stats { grid-template-columns: repeat(2, 1fr); }
  .hero-stats dd { font-size: 16px; }
  .ai-grid { grid-template-columns: 1fr; gap: 8px; }
  .ai { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 4px 12px; padding: 12px 14px; }
  .ai-top { display: contents; }
  .ai-num { grid-row: 1; grid-column: 3; font-size: 18px; text-align: end; }
  .ai .meter { grid-column: 1 / -1; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .search { flex: none; }
  .chips { overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; margin: 0 -16px; padding: 0 16px; }
  .chips::-webkit-scrollbar { display: none; }
  .chips button { flex: none; }
  .loc { grid-template-columns: 1fr auto; gap: 10px 12px; padding: 14px; }
  .bars-wrap { grid-column: 1 / -1; grid-row: 2; }
  .pct { grid-column: 2; grid-row: 1; text-align: end; }
  .ais { grid-column: 1 / -1; grid-row: 3; margin-top: 0; }
  .bars { height: 26px; }
  .bars i:nth-child(-n+60) { display: none; }
  .legend { justify-content: flex-start; gap: 12px; }
  .inc { grid-template-columns: auto 1fr; }
  .inc-dur { grid-column: 2; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
