@font-face { font-family: Vazirmatn; src: url(vendor/fonts/Vazirmatn-Regular.woff2) format("woff2"); font-weight: 400; }
@font-face { font-family: Vazirmatn; src: url(vendor/fonts/Vazirmatn-Medium.woff2) format("woff2"); font-weight: 500; }
@font-face { font-family: Vazirmatn; src: url(vendor/fonts/Vazirmatn-Bold.woff2) format("woff2"); font-weight: 700; }

:root {
  --bg: #0b1120; --panel: #111a2c; --panel2: #172238; --hover: #1c2943; --line: #22304b; --text: #e6edf7; --muted: #8b9ab4;
  --accent: #4f8cff; --accent-soft: rgba(79,140,255,.14);
  --ok: #22c55e; --warn: #f5a524; --down: #ef4444; --unknown: #64748b; --info: #38bdf8;
  --rx: #38bdf8; --tx: #a78bfa;
  --radius: 14px; --shadow: 0 1px 2px rgba(0,0,0,.25), 0 8px 24px rgba(0,0,0,.18);
}
:root[data-theme="light"] {
  --bg: #f2f5fa; --panel: #ffffff; --panel2: #f5f7fb; --hover: #eef2f8; --line: #e1e7f0; --text: #172033; --muted: #66748c;
  --accent-soft: rgba(79,140,255,.10); --shadow: 0 1px 2px rgba(16,24,40,.05), 0 6px 18px rgba(16,24,40,.06);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.65 Vazirmatn, Tahoma, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
.ltr { direction: ltr; unicode-bidi: isolate; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12.5px; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.spacer { flex: 1; }

/* ---------- shell */
.app { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
aside { background: var(--panel); border-left: 1px solid var(--line); padding: 18px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; }
.brand { display: flex; gap: 11px; align-items: center; padding: 2px 8px 18px; }
.brand .logo { width: 38px; height: 38px; border-radius: 11px; background: linear-gradient(135deg, #2563eb, #06b6d4); display: grid; place-items: center; color: #fff; font-weight: 700; letter-spacing: .5px; }
.brand b { display: block; font-size: 14px; }
.brand small { color: var(--muted); font-size: 11.5px; }
nav { display: grid; gap: 2px; }
nav .sep { height: 1px; background: var(--line); margin: 8px 6px; }
nav button { display: flex; width: 100%; align-items: center; gap: 11px; background: none; border: 0; padding: 9px 12px; border-radius: 10px; cursor: pointer; color: var(--muted); text-align: right; transition: background .12s, color .12s; }
nav button:hover { background: var(--hover); color: var(--text); }
nav button.active { background: var(--accent-soft); color: var(--text); font-weight: 500; }
nav button.active svg { color: var(--accent); }
nav button .count { margin-right: auto; background: var(--down); color: #fff; border-radius: 10px; font-size: 11px; padding: 0 7px; line-height: 18px; }
nav svg { width: 18px; height: 18px; flex: none; }
.side-foot { margin-top: auto; padding: 12px 8px 0; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); display: grid; gap: 8px; }
.side-foot .btns { display: flex; gap: 6px; }
.side-foot button { flex: 1; background: var(--panel2); border: 1px solid var(--line); border-radius: 9px; padding: 6px; cursor: pointer; }
.side-foot button:hover { background: var(--hover); }

main { padding: 22px 26px 48px; min-width: 0; }
header.top { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
header.top h1 { font-size: 21px; margin: 0; font-weight: 700; }
.live { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.live i { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 0 rgba(34,197,94,.6); animation: pulse 2s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 7px rgba(34,197,94,0); } 100% { box-shadow: 0 0 0 0 rgba(34,197,94,0); } }
.search { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 13px; min-width: 250px; outline: none; }
.search:focus { border-color: var(--accent); }

/* ---------- cards & grids */
.grid { display: grid; gap: 16px; }
.g-hero { grid-template-columns: 1fr 1fr 1fr; }
.g-kpi { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }
.g-cards { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.mb { margin-bottom: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; min-width: 0; box-shadow: var(--shadow); }
.card.click { cursor: pointer; transition: border-color .15s, transform .15s; }
.card.click:hover { border-color: var(--accent); }
.card-h { display: flex; align-items: center; gap: 10px; margin: -2px 0 12px; }
.card-h h3 { margin: 0; font-size: 14.5px; font-weight: 700; }
.card-h .end { margin-right: auto; display: flex; gap: 8px; align-items: center; }
.icon-box { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex: none; }
.icon-box svg { width: 18px; height: 18px; }

/* KPI */
.kpi .label { color: var(--muted); font-size: 12.5px; }
.kpi .val { font-size: 26px; font-weight: 700; line-height: 1.3; margin: 4px 0 6px; }
.kpi .val small { font-size: 13px; color: var(--muted); font-weight: 400; }
.bar { display: flex; height: 6px; border-radius: 4px; overflow: hidden; background: var(--panel2); }
.bar span { display: block; height: 100%; }

/* traffic hero */
.traffic .nums { display: flex; gap: 22px; margin: 2px 0 4px; }
.traffic .nums div { display: grid; }
.traffic .nums b { font-size: 24px; font-weight: 700; line-height: 1.25; }
.traffic .nums b small { font-size: 12px; font-weight: 400; color: var(--muted); margin-right: 3px; }
.traffic .nums .rx b { color: var(--rx); }
.traffic .nums .tx b { color: var(--tx); }
.traffic .nums span { font-size: 11.5px; color: var(--muted); }
.traffic .chart { height: 92px; margin: 6px -4px 0; }
.traffic .foot { display: flex; gap: 10px; font-size: 12px; color: var(--muted); margin-top: 6px; flex-wrap: wrap; }

/* status */
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; background: var(--unknown); }
.dot.ok { background: var(--ok); box-shadow: 0 0 0 3px rgba(34,197,94,.16); }
.dot.warning { background: var(--warn); box-shadow: 0 0 0 3px rgba(245,165,36,.18); }
.dot.down { background: var(--down); box-shadow: 0 0 0 3px rgba(239,68,68,.2); animation: blink 1.2s infinite; }
@keyframes blink { 50% { opacity: .35; } }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 1px 10px; border-radius: 99px; font-size: 12px; background: var(--panel2); border: 1px solid var(--line); white-space: nowrap; }
.sev { font-size: 11.5px; padding: 1px 9px; border-radius: 99px; font-weight: 500; white-space: nowrap; }
.sev.critical, .sev.down, .sev.Failed { background: rgba(239,68,68,.15); color: #f87171; }
.sev.warning, .sev.Warning { background: rgba(245,165,36,.15); color: #fbbf24; }
.sev.info, .sev.None { background: rgba(56,189,248,.13); color: #38bdf8; }
.sev.ok, .sev.Success { background: rgba(34,197,94,.14); color: #4ade80; }
:root[data-theme="light"] .sev.critical, :root[data-theme="light"] .sev.Failed { color: #dc2626; }
:root[data-theme="light"] .sev.warning, :root[data-theme="light"] .sev.Warning { color: #b45309; }
:root[data-theme="light"] .sev.ok, :root[data-theme="light"] .sev.Success { color: #15803d; }
:root[data-theme="light"] .sev.info { color: #0369a1; }

/* tables */
.tbl-wrap { overflow-x: auto; margin: 0 -6px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; vertical-align: middle; }
th { color: var(--muted); font-weight: 500; font-size: 12px; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover { background: var(--hover); }
td.wrap { white-space: normal; }
.meter { width: 96px; height: 7px; background: var(--panel2); border-radius: 4px; overflow: hidden; display: inline-block; vertical-align: middle; margin-left: 7px; }
.meter span { display: block; height: 100%; background: var(--ok); border-radius: 4px; }
.meter.w span { background: var(--warn); } .meter.d span { background: var(--down); }

.list { display: grid; gap: 6px; max-height: 360px; overflow-y: auto; }
.list .item { display: flex; gap: 10px; align-items: center; padding: 8px 11px; background: var(--panel2); border-radius: 10px; cursor: pointer; }
.list .item:hover { background: var(--hover); }
.empty { color: var(--muted); padding: 28px; text-align: center; }
.note { background: var(--accent-soft); border: 1px solid rgba(79,140,255,.3); border-radius: 12px; padding: 12px 14px; font-size: 13px; }
.note.warn { background: rgba(245,165,36,.1); border-color: rgba(245,165,36,.35); }

/* resource rows inside server cards */
.res { display: grid; grid-template-columns: 40px 1fr 44px; gap: 8px; align-items: center; font-size: 12px; margin-top: 6px; }
.res .meter { width: 100%; margin: 0; }
.res .v { text-align: left; direction: ltr; }

/* ---------- device schematic */
.device-card .chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.chip { display: inline-flex; gap: 6px; align-items: center; background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 4px 10px; font-size: 12.5px; }
.chip b { font-weight: 500; }
.chip.ok b { color: var(--ok); } .chip.bad b { color: var(--down); }
.panel-svg { background: linear-gradient(180deg, #2b3446, #1d2433); border-radius: 12px; padding: 12px 14px; border: 1px solid #39445a; overflow-x: auto; }
:root[data-theme="light"] .panel-svg { background: linear-gradient(180deg, #3a4559, #29313f); }
.panel-svg { display: flex; justify-content: center; }
.panel-svg svg { display: block; max-width: 100%; height: auto; flex: none; }
.panel-svg .port { cursor: pointer; }
.panel-svg .port:hover rect.body { stroke: #fff; stroke-width: 1.6; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin: 10px 0 2px; }
.legend span { display: inline-flex; gap: 6px; align-items: center; }
.legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }

/* ---------- cameras */
.cams { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.cam { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 13px; display: grid; gap: 3px; position: relative; overflow: hidden; }
.cam::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--ok); }
.cam.off::before { background: var(--down); }
.cam .n { font-weight: 700; font-size: 14px; }
.cam .meta { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
.rec { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 700; color: #f87171; }
.rec i { width: 7px; height: 7px; border-radius: 50%; background: #ef4444; animation: blink 1.6s infinite; }

/* ---------- topology (fixed org-chart tree; straight right-angle connectors) */
.tsite { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px 18px; box-shadow: var(--shadow); }
.tsite-h { display: flex; gap: 12px; align-items: baseline; margin-bottom: 6px; }
.tsite-h b { font-size: 15px; }
.tree-wrap { overflow-x: auto; padding-bottom: 6px; direction: ltr; }
.tree, .tree ul { --tl: #5b6b85; direction: ltr; display: flex; justify-content: center; margin: 0; padding: 22px 0 0; position: relative; }
.tree { padding-top: 6px; width: max-content; min-width: 100%; }
.tree li { list-style: none; position: relative; padding: 22px 6px 0; display: flex; flex-direction: column; align-items: center; }
.tree li::before, .tree li::after { content: ""; position: absolute; top: 0; right: 50%; width: 50%; height: 22px; border-top: 2px solid var(--tl); }
.tree li::after { right: auto; left: 50%; border-left: 2px solid var(--tl); }
.tree li:only-child::before, .tree li:only-child::after { display: none; }
.tree li:only-child { padding-top: 0; }
.tree li:first-child::before, .tree li:last-child::after { border: 0 none; }
.tree li:last-child::before { border-right: 2px solid var(--tl); border-radius: 0 6px 0 0; }
.tree li:first-child::after { border-radius: 6px 0 0 0; }
.tree ul::before { content: ""; position: absolute; top: 0; left: 50%; height: 22px; border-left: 2px solid var(--tl); }
.tree > li { padding-top: 0; }
.tree ul.leafgrid { display: grid; grid-template-columns: repeat(3, 200px); gap: 10px; justify-content: center; align-items: start;
  margin-top: 22px; padding: 12px; border: 2px solid var(--tl); border-radius: 14px; }
.tree ul.leafgrid::before { top: -24px; height: 22px; }
.tree ul.leafgrid > li { padding: 0; }
.tree ul.leafgrid > li::before, .tree ul.leafgrid > li::after { display: none; }
.tree ul.leafgrid > li:has(.wide) { grid-column: span 2; }
.tree ul.leafgrid .tnode { width: 100%; max-width: none; }
.tnode { direction: rtl; background: var(--panel2); border: 1px solid var(--line); border-top: 3px solid var(--unknown); border-radius: 12px; padding: 8px 10px; min-width: 150px; max-width: 230px; cursor: pointer; transition: border-color .15s, transform .15s; }
.tnode:hover { border-color: var(--accent); transform: translateY(-1px); }
.tnode.big { min-width: 190px; }
.tnode.st-ok { border-top-color: var(--ok); } .tnode.st-warning { border-top-color: var(--warn); } .tnode.st-down { border-top-color: var(--down); background: rgba(239,68,68,.08); }
.tn-h { display: flex; gap: 8px; align-items: center; }
.tn-t { display: grid; line-height: 1.35; min-width: 0; }
.tn-t b { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tn-t .ltr { font-size: 11px; color: var(--muted); text-align: right; }
.tn-badge { margin-top: 5px; font-size: 11.5px; color: var(--muted); }
.tn-port { margin-top: 5px; padding-top: 5px; border-top: 1px dashed var(--line); display: flex; justify-content: space-between; gap: 8px; font-size: 10.5px; color: var(--muted); }
.vm-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; margin-top: 8px; }
.tnode.wide { max-width: none; width: 440px; }
.tree ul.leafgrid .tnode.wide { width: 100%; }
.vm { display: flex; gap: 5px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: 7px; padding: 3px 6px; font-size: 11px; overflow: hidden; }
.vm span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vm:hover { border-color: var(--accent); }
.vm .dot { width: 7px; height: 7px; }
.tunnel-bar { display: flex; align-items: center; gap: 12px; margin: 14px 0; font-size: 13px; }
.tunnel-bar .line { flex: 1; height: 0; border-top: 3px dashed var(--ok); }
.tunnel-bar.down .line { border-top-color: var(--down); }
.toolbar select, .toolbar input[type=text], .toolbar input[type=number] { background: var(--panel); border: 1px solid var(--line); border-radius: 9px; padding: 6px 10px; }
.btn { background: var(--panel2); border: 1px solid var(--line); border-radius: 9px; padding: 6px 14px; cursor: pointer; font-size: 13px; }
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: #f87171; }
.seg { display: inline-flex; background: var(--panel2); border: 1px solid var(--line); border-radius: 9px; padding: 2px; }
.seg button { background: none; border: 0; padding: 4px 12px; border-radius: 7px; cursor: pointer; font-size: 12.5px; color: var(--muted); }
.seg button.active { background: var(--panel); color: var(--text); box-shadow: var(--shadow); }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }

/* ---------- modal */
.modal { position: fixed; inset: 0; z-index: 50; display: none; }
.modal.open { display: block; }
.modal .backdrop { position: absolute; inset: 0; background: rgba(5,10,20,.6); backdrop-filter: blur(2px); animation: fade .15s; }
.modal .dialog { position: relative; margin: 4vh auto; width: min(920px, calc(100vw - 32px)); max-height: 92vh; display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 24px 80px rgba(0,0,0,.45); animation: pop .16s ease-out; }
.modal .m-head { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal .m-head h2 { margin: 0; font-size: 17px; }
.modal .m-head .sub { color: var(--muted); font-size: 12.5px; }
.modal .m-close { margin-right: auto; display: inline-flex; align-items: center; gap: 6px; background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 7px 14px; cursor: pointer; font-size: 13px; }
.modal .m-close:hover { background: var(--down); border-color: var(--down); color: #fff; }
.modal .m-body { padding: 18px 20px 22px; overflow-y: auto; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.985); } }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 7px 14px; font-size: 13.5px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.chart-box { height: 180px; margin: 6px 0 14px; }
.section-t { font-size: 13px; font-weight: 700; margin: 18px 0 8px; color: var(--muted); }
form.edit { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; }
form.edit label { display: grid; gap: 4px; font-size: 12.5px; color: var(--muted); }
form.edit .full { grid-column: 1 / -1; }
form.edit input, form.edit select, form.edit textarea { background: var(--panel2); border: 1px solid var(--line); border-radius: 9px; padding: 7px 10px; color: var(--text); }
details.edit-box { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 12px; }
details.edit-box summary { cursor: pointer; color: var(--muted); font-size: 13px; }

/* ---------- file report */
.fname { font-weight: 500; overflow-wrap: anywhere; }
.fpath { font-size: 11px; color: var(--muted); text-align: right; overflow-wrap: anywhere; direction: ltr; unicode-bidi: plaintext; }

/* ---------- physical server */
.hw-wrap { overflow-x: auto; display: flex; justify-content: center; background: var(--panel2); border-radius: 12px; padding: 10px; }
.hw-svg { max-width: 100%; height: auto; flex: none; }
.hw-part { cursor: pointer; }
.hw-part:hover rect { filter: brightness(1.15); }
.fans { display: flex; gap: 14px; flex-wrap: wrap; }
.fan { display: grid; justify-items: center; gap: 2px; background: var(--panel2); border-radius: 12px; padding: 10px 14px; font-size: 12px; min-width: 84px; }
.spin { animation: spin 1.6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin, .dot.down, .live i { animation: none; } }

@media (max-width: 1200px) { .g-kpi { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 1000px) { .g-hero, .g-2 { grid-template-columns: 1fr; } }
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  aside { position: static; height: auto; }
  nav { grid-template-columns: repeat(3, 1fr); }
  nav .sep { display: none; }
  main { padding: 16px; }
  .g-kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .search { min-width: 0; width: 100%; }
  .kv { grid-template-columns: 110px 1fr; }
}
