/* ---------- design tokens ---------- */
:root {
  --bg: #07090f;
  --bg-elevated: #0f1320;
  --surface: #131826;
  --surface-2: #191f30;
  --border: #262e45;
  --border-soft: #1b2135;
  --text: #eef0f7;
  --text-dim: #939bb0;
  --text-faint: #5c6478;
  --accent-1: #6ea8fe;
  --accent-2: #a78bfa;
  --accent-3: #f0abfc;
  --accent-grad: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  --accent-grad-3: linear-gradient(135deg, var(--accent-1), var(--accent-2), var(--accent-3));
  --green: #34d399;
  --green-bg: rgba(52, 211, 153, .12);
  --red: #f87171;
  --red-bg: rgba(248, 113, 113, .12);
  --amber: #fbbf24;
  --amber-bg: rgba(251, 191, 36, .12);
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 9px;
  --shadow-card: 0 1px 2px rgba(0,0,0,.5), 0 16px 40px -16px rgba(0,0,0,.65);
  --shadow-card-hover: 0 1px 2px rgba(0,0,0,.5), 0 20px 48px -14px rgba(110,168,254,.18);
  --shadow-modal: 0 30px 80px -16px rgba(0,0,0,.75);
  --font: "Vazirmatn", -apple-system, "Segoe UI", Tahoma, sans-serif;
  --ease: cubic-bezier(.2,.7,.3,1);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  margin: 0;
  -webkit-font-smoothing: antialiased;
  position: relative;
}
.bg-glow {
  position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden;
  background: radial-gradient(700px 460px at 50% 115%, rgba(240,171,252,.05), transparent 60%);
}
.bg-glow::before, .bg-glow::after {
  content: ""; position: absolute; width: 56vw; height: 56vw; max-width: 760px; max-height: 760px;
  border-radius: 50%; filter: blur(90px); opacity: .18;
}
.bg-glow::before { background: var(--accent-1); top: -18%; right: -12%; animation: floatBlobA 24s ease-in-out infinite; }
.bg-glow::after { background: var(--accent-2); bottom: -22%; left: -12%; animation: floatBlobB 28s ease-in-out infinite; }
@keyframes floatBlobA { 0%, 100% { transform: translate(0,0) scale(1); } 50% { transform: translate(-50px, 46px) scale(1.16); } }
@keyframes floatBlobB { 0%, 100% { transform: translate(0,0) scale(1); } 50% { transform: translate(55px, -36px) scale(1.12); } }
.grid-overlay {
  position: fixed; inset: 0; z-index: 0; pointer-events: none; opacity: .5;
  background-image: linear-gradient(rgba(255,255,255,.028) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.028) 1px, transparent 1px);
  background-size: 42px 42px;
  -webkit-mask-image: radial-gradient(ellipse 85% 55% at 50% 0%, black 25%, transparent 72%);
  mask-image: radial-gradient(ellipse 85% 55% at 50% 0%, black 25%, transparent 72%);
}
.app { position: relative; z-index: 1; min-height: 100vh; display: flex; flex-direction: column; }
.grad-text { background: var(--accent-grad-3); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }

/* ---------- login ---------- */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; background: var(--bg); position: relative; }
.login-body::before {
  content: ""; position: fixed; inset: 0;
  background: radial-gradient(900px 500px at 50% -10%, rgba(110,168,254,.16), transparent 60%),
              radial-gradient(700px 420px at 100% 100%, rgba(167,139,250,.12), transparent 60%);
}
.login-card {
  position: relative; width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-card); padding: 42px 36px; text-align: center;
}
.login-logo {
  margin: 0 auto 18px; width: 56px; height: 56px; border-radius: 16px; background: var(--accent-grad);
  display: flex; align-items: center; justify-content: center; box-shadow: 0 10px 30px -8px rgba(110,168,254,.5);
}
.login-card h1 { font-size: 20px; margin: 0 0 6px; font-weight: 700; }
.login-sub { color: var(--text-dim); font-size: 13.5px; margin: 0 0 28px; }
.login-form { display: flex; flex-direction: column; gap: 16px; text-align: right; }
.login-form label { display: flex; flex-direction: column; gap: 7px; font-size: 13px; color: var(--text-dim); font-weight: 500; }
.login-form input {
  background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px 14px; color: var(--text); font-size: 14px; outline: none; transition: all .18s var(--ease); font-family: inherit;
}
.login-form input:focus { border-color: var(--accent-1); box-shadow: 0 0 0 4px rgba(110,168,254,.13); }
.alert { border-radius: var(--radius-sm); padding: 11px 14px; font-size: 13px; margin-bottom: 18px; text-align: right; }
.alert-error { background: var(--red-bg); color: var(--red); border: 1px solid rgba(248,113,113,.25); }

/* ---------- layout ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; padding: 16px 32px;
  border-bottom: 1px solid var(--border-soft); background: rgba(10,13,20,.72); backdrop-filter: blur(14px);
  position: sticky; top: 0; z-index: 20;
}
.topbar-brand { display: flex; align-items: center; gap: 12px; }
.brand-icon {
  position: relative; width: 36px; height: 36px; border-radius: 11px; background: var(--accent-grad);
  display: flex; align-items: center; justify-content: center; box-shadow: 0 8px 20px -6px rgba(110,168,254,.55);
}
.brand-icon::after {
  content: ""; position: absolute; inset: -5px; border-radius: 14px; border: 1px solid var(--accent-1);
  opacity: .5; animation: pulsering 2.6s ease-out infinite;
}
@keyframes pulsering { 0% { transform: scale(1); opacity: .5; } 100% { transform: scale(1.35); opacity: 0; } }
.brand-title { font-size: 15px; font-weight: 700; line-height: 1.3; }
.brand-sub { font-size: 11.5px; color: var(--text-faint); }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.content { padding: 32px; max-width: 1320px; width: 100%; margin: 0 auto; }

.live-badge {
  display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--green);
  background: var(--green-bg); border: 1px solid rgba(52,211,153,.25); border-radius: 20px; padding: 5px 12px 5px 10px;
}
.live-badge i { width: 6px; height: 6px; border-radius: 50%; background: var(--green); display: inline-block; animation: pulse 2s infinite; }

/* ---------- buttons ---------- */
.btn {
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
  padding: 10px 18px; border-radius: var(--radius-sm); cursor: pointer; font-size: 13px; font-weight: 500;
  font-family: inherit; transition: all .18s var(--ease); display: inline-flex; align-items: center; gap: 7px;
}
.btn:hover { border-color: var(--accent-1); transform: translateY(-1px); }
.btn.primary { background: var(--accent-grad); border: none; color: #0a0d14; font-weight: 700; box-shadow: 0 8px 22px -8px rgba(110,168,254,.55); }
.btn.primary:hover { filter: brightness(1.08); box-shadow: 0 10px 26px -6px rgba(110,168,254,.65); }
.btn.ghost { background: transparent; }
.btn.danger { background: linear-gradient(135deg, #f87171, #ef4444); border: none; color: #200606; font-weight: 700; box-shadow: 0 8px 22px -8px rgba(248,113,113,.5); }
.btn.danger:hover { filter: brightness(1.08); box-shadow: 0 10px 26px -6px rgba(248,113,113,.6); }
.btn.full { width: 100%; padding: 12px; justify-content: center; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.icon-btn { padding: 9px; }

.mini {
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
  padding: 6px 12px; border-radius: 8px; cursor: pointer; font-size: 12px; font-family: inherit;
  transition: all .15s var(--ease); display: inline-flex; align-items: center; gap: 5px;
}
.mini:hover { border-color: var(--accent-1); color: var(--accent-1); transform: translateY(-1px); }
.mini.danger:hover { border-color: var(--red); color: var(--red); }
.mini.accent { background: rgba(110,168,254,.12); border-color: rgba(110,168,254,.3); color: var(--accent-1); }
.mini:disabled { opacity: .5; cursor: not-allowed; transform: none; }

/* ---------- stats row ---------- */
.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 32px; }
.stat-card {
  position: relative; background: linear-gradient(160deg, rgba(25,31,48,.92), rgba(17,21,34,.94));
  backdrop-filter: blur(8px); border: 1px solid var(--border-soft); border-radius: var(--radius-md);
  padding: 18px 20px; display: flex; align-items: center; gap: 14px; box-shadow: var(--shadow-card);
  transition: all .2s var(--ease); overflow: hidden;
}
.stat-card:hover { border-color: var(--border); transform: translateY(-3px); box-shadow: var(--shadow-card-hover); }
.stat-icon { width: 40px; height: 40px; border-radius: 11px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.stat-icon.iran { background: rgba(167,139,250,.14); color: var(--accent-2); }
.stat-icon.foreign { background: rgba(110,168,254,.14); color: var(--accent-1); }
.stat-icon.tunnel { background: rgba(240,171,252,.14); color: var(--accent-3); }
.stat-icon.active { background: var(--green-bg); color: var(--green); }
.stat-value { font-size: 22px; font-weight: 800; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat-label { font-size: 11.5px; color: var(--text-faint); margin-top: 1px; }

/* ---------- live status table ---------- */
.live-status-section { margin-bottom: 32px; }
.live-status-card {
  background: linear-gradient(180deg, rgba(24,29,45,.88), rgba(15,19,32,.92));
  border: 1px solid var(--border-soft); border-radius: var(--radius-lg); padding: 20px 22px;
  box-shadow: var(--shadow-card); backdrop-filter: blur(12px);
}
.live-status-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; cursor: pointer; user-select: none; }
.live-status-head h2 { margin: 0; font-size: 15px; font-weight: 800; }
.live-status-table-wrap { overflow-x: auto; }
.ls-chevron { transition: transform .25s ease; color: var(--text-faint); flex-shrink: 0; }
.live-status-card.open .ls-chevron, .topology-card.open .ls-chevron { transform: rotate(180deg); color: var(--accent-1); }
.live-status-collapse {
  display: grid; grid-template-rows: 0fr; transition: grid-template-rows .3s ease, opacity .25s ease; opacity: 0;
}
.live-status-collapse > * { overflow: hidden; min-height: 0; }
.live-status-card.open .live-status-collapse, .topology-card.open .live-status-collapse { grid-template-rows: 1fr; opacity: 1; margin-top: 16px; }
.topology-head { cursor: pointer; user-select: none; }
.live-status-table { width: 100%; border-collapse: collapse; font-size: 12px; white-space: nowrap; }
.live-status-table th {
  text-align: center; padding: 8px 10px; color: var(--text-faint); font-weight: 600; font-size: 10.5px;
  border-bottom: 1px solid var(--border-soft); cursor: default; user-select: none;
}
.live-status-table th:first-child, .live-status-table th:nth-child(2) { text-align: right; }
.live-status-table th[data-sort] { cursor: pointer; }
.live-status-table th[data-sort]:hover { color: var(--accent-1); }
.live-status-table th.sorted { color: var(--accent-1); }
.live-status-table td { padding: 7px 10px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; text-align: center; font-variant-numeric: tabular-nums; }
.live-status-table td:first-child, .live-status-table td:nth-child(2) { text-align: right; }
.live-status-table tr:last-child td { border-bottom: none; }
.live-status-table tr:hover td { background: rgba(255,255,255,.015); }
.health-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.health-dot.good { background: var(--green); box-shadow: 0 0 6px var(--green); }
.health-dot.warn { background: var(--amber); box-shadow: 0 0 6px var(--amber); }
.health-dot.bad { background: var(--red); box-shadow: 0 0 6px var(--red); animation: pulse 1.4s infinite; }
.gauge-text { fill: var(--text); font-size: 9.5px; font-weight: 700; font-family: var(--font); }
.ls-server-name { font-weight: 700; }
.ls-server-role { font-size: 10px; color: var(--text-faint); margin-inline-start: 5px; }

/* ---------- network topology ---------- */
.topology-section { margin-bottom: 32px; }
.topology-card {
  position: relative; background: linear-gradient(180deg, rgba(24,29,45,.88), rgba(15,19,32,.92));
  border: 1px solid var(--border-soft); border-radius: var(--radius-lg); padding: 20px 22px 8px;
  box-shadow: var(--shadow-card); overflow: hidden; backdrop-filter: blur(12px);
}
.topology-card::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .6; z-index: 0;
  background-image: linear-gradient(rgba(255,255,255,.03) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.03) 1px, transparent 1px);
  background-size: 26px 26px;
  -webkit-mask-image: radial-gradient(ellipse at center, black 35%, transparent 78%);
  mask-image: radial-gradient(ellipse at center, black 35%, transparent 78%);
}
.topology-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; position: relative; z-index: 1; flex-wrap: wrap; gap: 8px; }
.topology-head h2 { margin: 0; font-size: 15px; font-weight: 800; }
.topology-legend { display: flex; gap: 14px; font-size: 11px; color: var(--text-faint); flex-wrap: wrap; }
.topology-legend span { display: flex; align-items: center; gap: 5px; }
.topology-legend i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.topology-legend i.ok { background: var(--green); box-shadow: 0 0 6px var(--green); }
.topology-legend i.partial { background: var(--amber); box-shadow: 0 0 6px var(--amber); }
.topology-legend i.error { background: var(--red); box-shadow: 0 0 6px var(--red); }
.topology-legend i.creating { background: var(--accent-1); box-shadow: 0 0 6px var(--accent-1); }

.topology-svg { width: 100%; height: auto; display: block; position: relative; z-index: 1; }
.topology-empty {
  display: none; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  padding: 46px 10px 40px; color: var(--text-faint); font-size: 12.5px; position: relative; z-index: 1; text-align: center;
}
.topology-empty svg { opacity: .5; }

.topo-link { stroke-width: 2.4; opacity: .55; stroke-linecap: round; }
.topo-link.ok { stroke: var(--green); stroke-dasharray: 7 7; animation: dashflow 1.1s linear infinite; opacity: .9; }
.topo-link.partial { stroke: var(--amber); stroke-dasharray: 5 9; animation: dashflow 1.6s linear infinite; opacity: .8; }
.topo-link.error { stroke: var(--red); stroke-dasharray: 2 6; opacity: .55; }
.topo-link.creating { stroke: var(--accent-1); stroke-dasharray: 4 8; animation: dashflow 1.8s linear infinite; opacity: .65; }
@keyframes dashflow { to { stroke-dashoffset: -28; } }

.topo-node-circle { stroke-width: 2; transition: r .2s var(--ease); }
.topo-node-circle.iran { fill: rgba(167,139,250,.18); stroke: var(--accent-2); }
.topo-node-circle.foreign { fill: rgba(110,168,254,.18); stroke: var(--accent-1); }
.topo-node-glow { fill: none; stroke-width: 1.4; opacity: 0; }
.topo-node.ready .topo-node-glow { stroke: var(--green); animation: nodepulse 2.4s ease-out infinite; }
.topo-node.error .topo-node-glow { stroke: var(--red); animation: nodepulse 1.5s ease-out infinite; }
.topo-node.pending .topo-node-glow { stroke: var(--amber); opacity: .3; }
.topo-node-label { fill: var(--text-dim); font-size: 11px; font-family: var(--font); font-weight: 600; }
.topo-node-sub { fill: var(--text-faint); font-size: 8.5px; font-family: var(--font); direction: ltr; }
@keyframes nodepulse { 0% { r: 17; opacity: .55; } 100% { r: 30; opacity: 0; } }

/* ---- topology: glow halo + flow particles + hover interactivity ---- */
.topo-link-wrap { cursor: pointer; transition: opacity .25s var(--ease); }
.topo-link-hit { stroke: transparent; stroke-width: 16; pointer-events: stroke; }

.topo-link-halo { stroke-width: 9; opacity: .16; filter: blur(4px); pointer-events: none; }
.topo-link-halo.ok { stroke: var(--green); animation: haloPulse 2.4s ease-in-out infinite; }
.topo-link-halo.partial { stroke: var(--amber); animation: haloPulse 2.4s ease-in-out infinite; }
.topo-link-halo.creating { stroke: var(--accent-1); animation: haloPulse 2.8s ease-in-out infinite; }
.topo-link-halo.error { stroke: var(--red); opacity: .08; }
@keyframes haloPulse { 0%, 100% { opacity: .14; } 50% { opacity: .34; } }

.topo-particle { pointer-events: none; filter: drop-shadow(0 0 4px currentColor); }
.topo-particle.ok { fill: var(--green); color: var(--green); }
.topo-particle.partial { fill: var(--amber); color: var(--amber); }
.topo-particle.creating { fill: var(--accent-1); color: var(--accent-1); }

.topo-link-tag {
  fill: var(--text-dim); font-size: 9.5px; font-family: var(--font); direction: ltr;
  opacity: 0; pointer-events: none; transition: opacity .2s var(--ease);
}
.topo-link-wrap:hover .topo-link-tag, .topo-link-wrap.active .topo-link-tag { opacity: 1; }
.topo-link-wrap:hover .topo-link, .topo-link-wrap.active .topo-link { stroke-width: 3.6; opacity: 1; }
.topo-link-wrap:hover .topo-link-halo, .topo-link-wrap.active .topo-link-halo { opacity: .45; }
.topology-svg.hovering .topo-link-wrap:not(.active) { opacity: .18; }

.topo-node { cursor: pointer; }
.topo-node:hover .topo-node-circle, .topo-node.active .topo-node-circle { r: 20; }
.topo-node-icon { opacity: .85; pointer-events: none; }

/* ---- map view tabs (schematic vs geographic) ---- */
.map-tabs { display: flex; gap: 8px; margin-bottom: 14px; position: relative; z-index: 1; }
.map-tab {
  background: var(--surface-2); color: var(--text-dim); border: 1px solid var(--border); border-radius: 20px;
  padding: 6px 16px; font-size: 12.5px; font-weight: 600; cursor: pointer; font-family: var(--font);
  transition: all .18s var(--ease);
}
.map-tab:hover { border-color: var(--accent-1); color: var(--text); }
.map-tab.active { background: var(--accent-grad); color: #0a0d14; border-color: transparent; }
#mapViewWrap[data-view="geo"] .schematic-view { display: none; }
#mapViewWrap[data-view="schematic"] .geo-view { display: none; }

/* ---- geographic map: world silhouette + smaller nodes ---- */
.geo-land { fill: rgba(110,168,254,.07); stroke: rgba(110,168,254,.2); stroke-width: .6; pointer-events: none; }
.geo-unknown-note {
  display: flex; align-items: center; gap: 8px; margin-top: 10px; padding: 8px 14px;
  background: var(--amber-bg); border: 1px solid rgba(251,191,36,.25); border-radius: var(--radius-sm);
  color: var(--amber); font-size: 11.5px; position: relative; z-index: 1;
}
.geo-unknown-note svg { flex-shrink: 0; }

/* geo nodes render at r=9 instead of the schematic map's r=17, so the pulse/
   hover growth needs its own smaller keyframe and target radius - otherwise
   the shared schematic values would make the glow ring jump on every tick. */
@keyframes nodepulseSmall { 0% { r: 9; opacity: .55; } 100% { r: 17; opacity: 0; } }
.topo-node.geo-node.ready .topo-node-glow,
.topo-node.geo-node.error .topo-node-glow { animation-name: nodepulseSmall; }
.geo-node:hover .topo-node-circle, .geo-node.active .topo-node-circle { r: 13; }

/* ---------- sections & cards ---------- */
.fs-section { margin-bottom: 40px; }
.fs-head { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 18px; gap: 12px; flex-wrap: wrap; }
.fs-head-title h2 { margin: 0 0 3px; font-size: 18px; font-weight: 800; }
.fs-head-sub { margin: 0; font-size: 12.5px; color: var(--text-faint); }
.col-title { font-size: 12.5px; color: var(--text-dim); font-weight: 600; margin: 0 0 12px; display: flex; align-items: center; gap: 7px; }
.col-dot { width: 8px; height: 8px; border-radius: 50%; }
.col-dot.iran { background: var(--accent-2); box-shadow: 0 0 0 3px rgba(167,139,250,.18); }
.col-dot.foreign { background: var(--accent-1); box-shadow: 0 0 0 3px rgba(110,168,254,.18); }
.server-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; }

.fs-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.tunnels-grid { grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); }
.fs-empty-hint {
  color: var(--text-faint); font-size: 13px; padding: 28px 16px; border: 1.5px dashed var(--border);
  border-radius: var(--radius-md); text-align: center; grid-column: 1 / -1; background: rgba(255,255,255,.01);
}
.skeleton-card {
  height: 150px; border-radius: var(--radius-lg); background: linear-gradient(100deg, var(--surface) 30%, var(--surface-2) 50%, var(--surface) 70%);
  background-size: 200% 100%; animation: shimmer 1.4s infinite; border: 1px solid var(--border-soft);
}
@keyframes shimmer { 0% { background-position: 150% 0; } 100% { background-position: -50% 0; } }

.card {
  position: relative; background: linear-gradient(180deg, rgba(25,31,48,.92), rgba(17,21,34,.94));
  backdrop-filter: blur(8px); border: 1px solid var(--border-soft); border-radius: var(--radius-lg);
  padding: 21px 20px 20px; box-shadow: var(--shadow-card); transition: all .2s var(--ease); animation: cardIn .25s var(--ease);
  overflow: hidden;
}
.card::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 3px;
  background: var(--accent-grad-3); opacity: .9;
}
.card.role-iran::before { background: linear-gradient(90deg, var(--accent-2), var(--accent-3)); }
.card.role-foreign::before { background: linear-gradient(90deg, var(--accent-1), var(--accent-2)); }
.card.role-tunnel::before { background: var(--accent-grad-3); }
.card:hover { border-color: var(--border); box-shadow: var(--shadow-card-hover); transform: translateY(-3px); }
@keyframes cardIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px; gap: 8px; }
.card-head h2, .card-head h3 { margin: 0; font-size: 15px; font-weight: 700; }
.card-subtitle { font-size: 11.5px; color: var(--text-faint); margin-top: 3px; direction: ltr; text-align: right; font-family: "Cascadia Code", Consolas, monospace; }

.traffic-block { margin: 12px 0; padding: 8px 12px; background: var(--bg-elevated); border: 1px solid var(--border-soft); border-radius: var(--radius-sm); }
.traffic-row { display: flex; gap: 14px; font-size: 11.5px; font-variant-numeric: tabular-nums; }
.traffic-item { display: flex; align-items: center; gap: 5px; font-weight: 600; direction: ltr; }
.traffic-item.down { color: var(--green); }
.traffic-item.up { color: var(--accent-1); }
.traffic-item .tv { min-width: 2ch; }
.ttv { margin-top: 6px; padding-top: 6px; border-top: 1px dashed var(--border-soft); font-size: 10.5px; color: var(--text-faint); font-variant-numeric: tabular-nums; }

.fs-pill { padding: 3px 11px; border-radius: 20px; font-size: 10.5px; white-space: nowrap; font-weight: 600; letter-spacing: .2px; }
.fs-pill.ready, .fs-pill.ok { background: var(--green-bg); color: var(--green); }
.fs-pill.pending, .fs-pill.creating, .fs-pill.preparing { background: rgba(110,168,254,.12); color: var(--accent-1); }
.fs-pill.partial { background: var(--amber-bg); color: var(--amber); }
.fs-pill.error { background: var(--red-bg); color: var(--red); }
.fs-pill.iran { background: rgba(167,139,250,.15); color: var(--accent-2); }
.fs-pill.foreign { background: rgba(110,168,254,.15); color: var(--accent-1); }

/* ---------- forms (inline in cards + modal) ---------- */
.fs-form-row { display: flex; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.fs-form-row label { flex: 1; min-width: 130px; display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: var(--text-dim); font-weight: 500; }
.fs-form-row input, .fs-form-row select {
  background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 9px 12px; color: var(--text); font-size: 13px; outline: none; font-family: inherit; transition: all .15s var(--ease);
}
.fs-form-row input:focus, .fs-form-row select:focus { border-color: var(--accent-1); box-shadow: 0 0 0 3px rgba(110,168,254,.13); }
.field-hint { font-size: 11px; color: var(--text-faint); margin-top: -8px; margin-bottom: 12px; }

.fs-port-list { display: flex; flex-direction: column; gap: 7px; margin: 12px 0; }
.fs-port-row { display: flex; gap: 7px; }
.fs-port-row .fs-port-input {
  flex: 1; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 8px 11px; color: var(--text); font-size: 13px; font-variant-numeric: tabular-nums; outline: none; transition: all .15s var(--ease);
}
.fs-port-row .fs-port-input:focus { border-color: var(--accent-1); }
.fs-port-results { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }

.btnrow { display: flex; gap: 6px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.side-label { font-size: 11px; color: var(--text-faint); min-width: 32px; font-weight: 600; flex-shrink: 0; }
.btnrow .mini { flex: 0 1 auto; }
.card-footer-actions { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border-soft); }

/* ---------- progress list ---------- */
.fs-progress { background: var(--bg-elevated); border: 1px solid var(--border-soft); border-radius: var(--radius-md); padding: 14px; margin-top: 14px; }
.fs-progress-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 7px; }
.fs-progress-list li {
  display: flex; align-items: center; gap: 9px; font-size: 12.5px; color: var(--text-dim);
  padding: 7px 10px; border-radius: var(--radius-sm); background: var(--surface-2); transition: all .2s var(--ease);
}
.fs-progress-list li.running { color: var(--amber); }
.fs-progress-list li.running .fs-step-icon { animation: spin 1s linear infinite; }
.fs-progress-list li.done { color: var(--green); }
.fs-progress-list li.error { color: var(--red); background: var(--red-bg); }
.fs-step-icon { width: 16px; text-align: center; display: inline-block; }
@keyframes spin { from { transform: rotate(0); } to { transform: rotate(360deg); } }

/* ---------- status dots ---------- */
.status-row { display: flex; gap: 10px; margin-bottom: 14px; }
.status-chip {
  display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-dim);
  background: var(--bg-elevated); border: 1px solid var(--border-soft); border-radius: 20px; padding: 6px 13px;
}
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-faint); }
.dot.active { background: var(--green); box-shadow: 0 0 0 3px var(--green-bg); animation: pulse 2s infinite; }
.dot.inactive, .dot.failed { background: var(--red); box-shadow: 0 0 0 3px var(--red-bg); }
.dot.unknown { background: var(--amber); box-shadow: 0 0 0 3px var(--amber-bg); }
.status-text { color: var(--text); font-weight: 700; }

/* ---------- modal ---------- */
.modal-backdrop {
  display: none; position: fixed; inset: 0; background: rgba(4,5,10,.7); backdrop-filter: blur(4px);
  align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.modal-backdrop.open { display: flex; animation: fadeIn .15s var(--ease); }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: 100%; max-width: 560px; max-height: 86vh; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-modal); animation: modalIn .22s var(--ease);
}
@keyframes modalIn { from { opacity: 0; transform: translateY(14px) scale(.97); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 22px; border-bottom: 1px solid var(--border-soft); }
.modal-head h3 { margin: 0; font-size: 15.5px; font-weight: 700; }
.modal-body { padding: 20px 22px; overflow: auto; flex: 1; }
.modal-actions { padding: 16px 22px; border-top: 1px solid var(--border-soft); display: flex; gap: 9px; justify-content: flex-end; }
.modal-body pre {
  background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 13px; font-size: 11.5px; line-height: 1.65; max-height: 60vh; overflow: auto;
  direction: ltr; text-align: left; white-space: pre-wrap; word-break: break-all; font-family: "Cascadia Code", Consolas, monospace;
}
.modal-msg { font-size: 12.5px; margin-top: 12px; padding: 10px 12px; border-radius: var(--radius-sm); }
.modal-msg.err { color: var(--red); background: var(--red-bg); }
.modal-msg.ok { color: var(--green); background: var(--green-bg); }
.modal-body p { line-height: 1.8; color: var(--text-dim); font-size: 13.5px; }

/* ---------- toast ---------- */
.toast-stack { position: fixed; bottom: 24px; left: 24px; z-index: 200; display: flex; flex-direction: column; gap: 10px; max-width: 360px; }
.toast {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 13px 16px; box-shadow: var(--shadow-modal); display: flex; align-items: flex-start; gap: 10px;
  font-size: 13px; animation: toastIn .25s var(--ease); position: relative; overflow: hidden;
}
.toast::before { content: ""; position: absolute; inset-inline-start: 0; top: 0; bottom: 0; width: 3px; }
.toast.error { color: var(--text); }
.toast.error::before { background: var(--red); }
.toast.success::before { background: var(--green); }
.toast.info::before { background: var(--accent-1); }
.toast.warn::before { background: var(--amber); }
.toast-icon { flex-shrink: 0; margin-top: 1px; }
.toast.error .toast-icon { color: var(--red); }
.toast.success .toast-icon { color: var(--green); }
.toast.info .toast-icon { color: var(--accent-1); }
.toast.warn .toast-icon { color: var(--amber); }
.toast-msg { flex: 1; line-height: 1.6; padding-top: 1px; }
.toast-close { cursor: pointer; color: var(--text-faint); background: none; border: none; padding: 0; margin-inline-start: auto; flex-shrink: 0; }
.toast-close:hover { color: var(--text); }
.toast.leaving { animation: toastOut .18s ease forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; transform: translateX(20px); } }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .4; } }

@media (max-width: 780px) {
  .content { padding: 18px; }
  .topbar { padding: 14px 18px; }
  .server-columns { grid-template-columns: 1fr; }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .fs-grid, .tunnels-grid { grid-template-columns: 1fr; }
  .topology-card { padding: 16px 14px 6px; }
  .topology-head { flex-direction: column; align-items: flex-start; }
  .topology-legend { gap: 10px; font-size: 10px; }
  .fs-head { flex-direction: column; align-items: stretch; }
  .fs-head .btn { width: 100%; justify-content: center; }
  .btnrow { gap: 5px; }
  .btnrow .mini { flex: 1 1 auto; justify-content: center; }
  .modal { max-height: 92vh; }
  .modal-actions { flex-wrap: wrap; }
  .modal-actions .btn { flex: 1 1 auto; justify-content: center; }
  .toast-stack { left: 12px; right: 12px; bottom: 12px; max-width: none; }
}

@media (max-width: 460px) {
  .stats-row { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { padding: 14px; gap: 10px; }
  .stat-value { font-size: 18px; }
  .brand-sub { display: none; }
}
