@font-face {
  font-family: Estedad;
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/Estedad-Regular.woff2") format("woff2");
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0898-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
}
@font-face {
  font-family: Estedad;
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("fonts/Estedad-SemiBold.woff2") format("woff2");
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0898-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
}
@font-face {
  font-family: Estedad;
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("fonts/Estedad-Bold.woff2") format("woff2");
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0898-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
}
@font-face {
  font-family: Estedad;
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url("fonts/Estedad-ExtraBold.woff2") format("woff2");
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0898-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
}
@font-face {
  font-family: Estedad;
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/Estedad-Latin-Regular.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: Estedad;
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("fonts/Estedad-Latin-Bold.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: Vazirmatn;
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/Vazirmatn-Regular.woff2") format("woff2");
}
@font-face {
  font-family: Vazirmatn;
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("fonts/Vazirmatn-SemiBold.woff2") format("woff2");
}
@font-face {
  font-family: Vazirmatn;
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("fonts/Vazirmatn-Bold.woff2") format("woff2");
}

:root {
  --ink: #121a26;
  --ink-strong: #0b1220;
  --ink-soft: #3d4b63;
  --muted: #6b778c;
  --font: "Estedad", "Vazirmatn", Tahoma, sans-serif;
  --font-num: "Vazirmatn", Tahoma, sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --bg: #f3f6fb;
  --card: #ffffff;
  --surface-strong: #ffffff;
  --surface-soft: #f7f9fc;
  --line-soft: rgba(18, 26, 38, 0.08);
  --chip-bg: #eef2f7;
  --chip-ink: #4b5568;
  --mood: #0d9488;
  --mood-2: #0284c7;
  --mood-deep: #0f766e;
  --mood-rgb: 13, 148, 136;
  --mood2-rgb: 2, 132, 199;
  --ok: #059669;
  --warn: #b45309;
  --err: #dc2626;
  --rail: 212px;
  --glass: 0 1px 0 rgba(255,255,255,0.9) inset, 0 0 0 1px var(--line-soft), 0 10px 28px rgba(15, 23, 42, 0.04);
  color-scheme: light;
}

html[data-theme="dark"] {
  --ink: #e8edf5;
  --ink-strong: #f8fafc;
  --ink-soft: #cbd5e1;
  --muted: #94a3b8;
  --bg: #0a101a;
  --card: #111827;
  --surface-strong: #151c2a;
  --surface-soft: #0f1623;
  --line-soft: rgba(148, 163, 184, 0.14);
  --chip-bg: rgba(148, 163, 184, 0.14);
  --chip-ink: #e2e8f0;
  --ok: #34d399;
  --warn: #fbbf24;
  --err: #f87171;
  --glass: 0 1px 0 rgba(255,255,255,0.03) inset, 0 0 0 1px var(--line-soft), 0 12px 32px rgba(0,0,0,0.28);
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  min-height: 100%;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-synthesis: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
a { color: inherit; text-decoration: none; }
::selection { background: rgba(var(--mood-rgb), 0.28); }
:focus-visible { outline: 2px solid var(--mood); outline-offset: 2px; }
.hidden { display: none !important; }
.mono { font-family: var(--font-num); font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; }

.fx {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(900px 420px at 100% -10%, rgba(var(--mood-rgb), 0.09), transparent 55%),
    radial-gradient(700px 380px at 0% 100%, rgba(var(--mood2-rgb), 0.07), transparent 50%),
    var(--bg);
}
html[data-theme="dark"] .fx {
  background:
    radial-gradient(800px 400px at 100% -8%, rgba(var(--mood-rgb), 0.12), transparent 55%),
    radial-gradient(640px 360px at 0% 100%, rgba(var(--mood2-rgb), 0.08), transparent 50%),
    var(--bg);
}
@media (prefers-reduced-motion: reduce) {
  .fx { background: var(--bg); }
}

#login-screen {
  position: relative; z-index: 2; min-height: 100dvh;
  display: grid; place-items: center; padding: 24px;
}
.login-card {
  width: min(380px, 100%);
  background: var(--card);
  border-radius: 20px;
  box-shadow: var(--glass);
  padding: 28px 26px 24px;
}
.login-card__mark {
  width: 44px; height: 44px; border-radius: 14px; margin-bottom: 14px;
  display: grid; place-items: center; font-weight: 800; color: #fff; font-size: 0.95rem;
  background: linear-gradient(135deg, var(--mood-2), var(--mood));
}
.login-card h1 {
  font-size: 1.5rem; font-weight: 800; letter-spacing: -0.03em;
  color: var(--ink-strong);
}
.login-card .sub { color: var(--muted); margin: 6px 0 20px; font-size: 0.9rem; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; font-size: 0.8rem; color: var(--muted); font-weight: 600; }
.field input {
  width: 100%;
  padding: 11px 13px;
  border-radius: 12px;
  border: 1px solid var(--line-soft);
  background: var(--surface-strong);
  color: var(--ink);
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
}
.field input:focus {
  border-color: rgba(var(--mood-rgb), 0.55);
  box-shadow: 0 0 0 3px rgba(var(--mood-rgb), 0.15);
  outline: none;
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 14px; border-radius: 10px; border: 1px solid transparent;
  font-weight: 700; font-size: 0.875rem;
  transition: background .15s var(--ease), border-color .15s, color .15s;
}
.btn:disabled { opacity: 0.45; pointer-events: none; }
.btn-primary { background: var(--mood); color: #fff; }
.btn-primary:hover { background: var(--mood-deep); }
.btn-ghost { background: transparent; color: var(--ink-soft); border-color: var(--line-soft); }
.btn-ghost:hover { background: var(--surface-soft); color: var(--ink); }
html[data-theme="dark"] .btn-ghost:hover { background: rgba(148,163,184,0.12); }
.btn-block { width: 100%; }
.alert {
  margin-top: 4px; margin-bottom: 12px; padding: 10px 12px; border-radius: 12px; font-size: 0.85rem;
  background: rgba(220, 38, 38, 0.1); color: var(--err);
}

#app {
  position: relative; z-index: 1;
  display: grid;
  grid-template-columns: var(--rail) 1fr;
  min-height: 100dvh;
}
.rail {
  position: sticky; top: 0; height: 100dvh;
  padding: 16px 12px;
  display: flex; flex-direction: column; gap: 4px;
  background: var(--surface-soft);
  border-left: 1px solid var(--line-soft);
}
.rail__brand {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px 14px;
}
.rail__mark {
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(145deg, var(--mood-2), var(--mood));
  color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 0.85rem; flex-shrink: 0;
}
.rail__title { font-weight: 800; font-size: 0.98rem; line-height: 1.15; letter-spacing: -0.02em; }
.rail__sub { font-size: 0.7rem; color: var(--muted); margin-top: 2px; }
.rail__nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow: auto; }
.rail__sec {
  margin: 12px 10px 4px;
  font-size: 0.68rem; font-weight: 700; color: var(--muted);
}
.rail__item {
  display: flex; align-items: center;
  padding: 9px 12px; border-radius: 10px;
  background: transparent; color: var(--ink-soft); font-weight: 600; font-size: 0.875rem; text-align: right;
  min-height: 40px;
  transition: background .12s var(--ease), color .12s;
}
.rail__item:hover { background: rgba(var(--mood-rgb), 0.07); color: var(--ink); }
html[data-theme="dark"] .rail__item:hover { background: rgba(148,163,184,0.08); }
.rail__item.is-active {
  background: rgba(var(--mood-rgb), 0.14);
  color: var(--mood-deep);
  font-weight: 700;
}
html[data-theme="dark"] .rail__item.is-active { color: #5eead4; background: rgba(var(--mood-rgb), 0.18); }
.rail__foot {
  display: flex; flex-direction: row; gap: 6px;
  padding: 12px 4px 4px; border-top: 1px solid var(--line-soft);
}
.icon-btn {
  flex: 1; min-height: 36px; border-radius: 10px; border: 1px solid var(--line-soft);
  background: transparent; color: var(--muted); font-weight: 700; font-size: 0.8rem;
}
.icon-btn:hover { color: var(--ink); background: var(--surface-soft); }
html[data-theme="dark"] .icon-btn:hover { background: rgba(148,163,184,0.08); }

.main { padding: 20px 28px 48px; min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  margin-bottom: 18px; flex-wrap: wrap;
}
.topbar h1 { font-size: 1.35rem; font-weight: 800; letter-spacing: -0.03em; }
.topbar .hint { color: var(--muted); font-size: 0.84rem; margin-top: 2px; }
.topbar__actions { display: none; gap: 6px; }
.topbar__actions .icon-btn { flex: 0 0 auto; width: auto; padding: 0 12px; }
.lamps { display: flex; gap: 8px; flex-wrap: wrap; }
.lamp {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 10px; border-radius: 999px;
  background: var(--chip-bg); color: var(--chip-ink);
  font-size: 0.78rem; font-weight: 700;
}
.bead { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.bead.ok { background: var(--ok); }
.bead.warn { background: var(--warn); }
.bead.bad { background: var(--err); }

.panel {
  background: var(--card);
  border-radius: 16px;
  box-shadow: var(--glass);
  padding: 16px 18px;
  margin-bottom: 12px;
}
.panel h2 { font-size: 0.95rem; font-weight: 800; margin-bottom: 12px; }
.row.split { display: grid; grid-template-columns: 1.2fr 1fr; gap: 12px; }
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  margin-bottom: 14px;
  background: var(--line-soft);
  border: 1px solid var(--line-soft);
  border-radius: 16px;
  overflow: hidden;
}
.kpi { background: var(--card); padding: 16px 18px; }
.kpi__label { font-size: 0.72rem; color: var(--muted); font-weight: 600; }
.kpi__value {
  font-family: var(--font-num); font-size: 1.35rem; font-weight: 800;
  margin-top: 4px; letter-spacing: -0.03em; color: var(--ink-strong);
}
.kpi.is-ok .kpi__value { color: var(--ok); }
.kpi.is-warn .kpi__value { color: var(--warn); }
.kpi.is-err .kpi__value { color: var(--err); }

.kv { display: grid; grid-template-columns: 7.5rem 1fr; gap: 8px 12px; font-size: 0.88rem; }
.kv dt { color: var(--muted); font-weight: 600; }
.kv dd { font-weight: 600; min-width: 0; word-break: break-word; }
.pill {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 999px;
  font-size: 0.72rem; font-weight: 700;
  background: var(--chip-bg); color: var(--chip-ink);
}
.pill.ok { background: rgba(5,150,105,.12); color: var(--ok); }
.pill.warn { background: rgba(180,83,9,.12); color: var(--warn); }
.pill.bad { background: rgba(220,38,38,.12); color: var(--err); }

.svc {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line-soft);
}
.svc:last-child { border-bottom: 0; }
.svc__meta { font-size: 0.78rem; color: var(--muted); margin-top: 2px; }

.subtabs { display: flex; gap: 6px; margin-bottom: 10px; }
.subtabs button {
  padding: 7px 12px; border-radius: 9px; border: 1px solid var(--line-soft);
  color: var(--ink-soft); font-weight: 700; font-size: 0.8rem; min-height: 36px;
}
.subtabs button:hover { background: rgba(var(--mood-rgb), 0.07); }
html[data-theme="dark"] .subtabs button:hover { background: rgba(148,163,184,0.08); }
.subtabs button[aria-pressed="true"] {
  background: rgba(var(--mood-rgb), 0.14);
  color: var(--mood-deep);
  border-color: transparent;
}
html[data-theme="dark"] .subtabs button[aria-pressed="true"] { color: #5eead4; }

.tape {
  font-family: var(--font-num);
  font-size: 0.78rem;
  line-height: 1.55;
  direction: ltr;
  unicode-bidi: isolate;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 52vh;
  overflow: auto;
  background: var(--surface-soft);
  border-radius: 12px;
  padding: 12px;
  color: var(--ink-soft);
}
.event { padding: 6px 0; border-bottom: 1px solid var(--line-soft); }
.event:last-child { border-bottom: 0; }
.empty, .muted { color: var(--muted); font-size: 0.86rem; }
.error { color: var(--err); font-weight: 700; }
.skeleton {
  height: 14px; border-radius: 8px; margin-bottom: 10px;
  background: linear-gradient(90deg, var(--line-soft), var(--chip-bg), var(--line-soft));
  background-size: 200% 100%;
  animation: shine 1.2s ease infinite;
}
@keyframes shine { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) {
  .skeleton { animation: none; }
}

@media (max-width: 1100px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 980px) {
  #app { grid-template-columns: 1fr; }
  .rail {
    position: fixed; inset: auto 0 0 0; height: auto; z-index: 40;
    flex-direction: row; align-items: center;
    padding: 8px 10px; border: 0; border-top: 1px solid var(--line-soft);
    overflow-x: auto;
  }
  .rail__brand, .rail__foot, .rail__sec { display: none; }
  .rail__nav { flex-direction: row; flex: 1; gap: 2px; }
  .rail__item { padding: 10px 12px; font-size: 0.72rem; white-space: nowrap; }
  .main { padding: 16px 14px 88px; }
  .row.split { grid-template-columns: 1fr; }
  .topbar { padding-bottom: 4px; }
  .topbar__actions { display: flex; }
}

/* Asgar Bot registry */
.link-banner {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; margin-bottom: 14px;
  border-radius: 12px; border: 1px solid var(--line-soft);
  background: var(--surface-soft); font-size: 0.88rem; font-weight: 600;
}
.link-banner.ok { border-color: rgba(5,150,105,.28); }
.link-banner.warn { border-color: rgba(180,83,9,.28); }
.link-banner.bad { border-color: rgba(220,38,38,.28); }
.bots-layout { align-items: start; }
.bot-list { display: grid; gap: 8px; margin-bottom: 14px; }
.bot-card {
  text-align: start; width: 100%;
  padding: 10px 12px; border-radius: 12px;
  border: 1px solid var(--line-soft);
  background: var(--surface-soft); color: var(--ink);
}
.bot-card:hover { border-color: rgba(var(--mood-rgb), 0.35); }
.bot-card.is-active {
  border-color: transparent;
  background: rgba(var(--mood-rgb), 0.12);
  box-shadow: inset 3px 0 0 var(--mood);
}
html[data-theme="dark"] .bot-card:hover { background: rgba(148,163,184,0.06); }
html[data-theme="dark"] .bot-card.is-active { background: rgba(var(--mood-rgb), 0.16); }
.bot-card__top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.bot-head { display: flex; gap: 14px; align-items: center; margin-bottom: 14px; }
.bot-avatar {
  width: 72px; height: 72px; object-fit: cover; flex-shrink: 0;
  border-radius: 16px; border: 1px solid var(--line-soft); background: var(--surface-soft);
}
.bot-avatar.is-placeholder {
  display: grid; place-content: center;
  font-size: 1.5rem; font-weight: 800; color: var(--mood);
}
.bot-title { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.bot-form { margin-top: 14px; display: grid; gap: 4px; }
.bot-form h3 { font-size: 0.92rem; font-weight: 800; margin: 8px 0 4px; }
.bot-form .field { margin-bottom: 8px; }
.form-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 8px; }
.btn-danger { color: var(--err); border-color: rgba(220,38,38,.28); }
.btn-danger:hover { background: rgba(220,38,38,.1); color: var(--err); }
html[data-theme="dark"] .btn-danger:hover { background: rgba(248,113,113,.12); }
.subpanel { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line-soft); }
.subpanel h3 { font-size: 0.9rem; font-weight: 800; margin-bottom: 8px; }
.flash { color: var(--mood-deep); font-weight: 700; font-size: 0.86rem; margin-bottom: 10px; }
html[data-theme="dark"] .flash { color: #5eead4; }
.probe-out {
  margin-top: 8px; padding: 10px 12px; border-radius: 12px;
  background: var(--surface-soft); color: var(--ink-soft);
  min-height: 64px; max-height: 220px; overflow: auto;
  font-size: 0.78rem; white-space: pre-wrap; word-break: break-word;
}
