@import url("/static/mahan-theme/tokens.css");

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

/* the Console's own names for the Mahan theme colours (mahan-theme/tokens.css) */
:root {
  --panel: var(--surface);
  --panel-2: var(--surface-2);
  --border: var(--line);
  --text: var(--ink);
  --muted: var(--ink-3);
  --accent-2: var(--accent);
  --ok: var(--st-idle);
  --warn: var(--st-ring);
  --bad: var(--st-talk);
  --radius: .6rem;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Vazirmatn", Tahoma, sans-serif;
  font-size: 14px;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.ltr { direction: ltr; unicode-bidi: embed; }
.hidden { display: none !important; }
:where(a, button, select, [tabindex]):focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- layout ---------- */
.shell { display: flex; height: 100vh; }
.sidebar {
  flex: none; width: 16rem; background: var(--nav-bg); color: var(--nav-ink);
  display: flex; flex-direction: column; transition: width .2s, transform .2s;
}
.brand { display: flex; align-items: center; gap: 10px; flex: none; height: 68px; padding-inline: 20px; border-bottom: 1px solid var(--nav-line); }
.brand img { width: 36px; height: 36px; flex: none; }
.brand-name { font-weight: 700; font-size: 15px; line-height: 1.3; color: #fff; }
.brand-sub { font-size: 11px; color: var(--nav-label); }
.nav { flex: 1; overflow-y: auto; padding: 12px; }
.nav a {
  display: flex; align-items: center; gap: 12px; margin-bottom: 2px; padding: 10px 12px; border-radius: 6px;
  font-size: 13.5px; color: var(--nav-ink); text-decoration: none; transition: background .15s, color .15s;
}
.nav a svg { flex: none; opacity: .8; }
.nav a:hover { background: var(--nav-hover); color: #fff; }
.nav a.active { background: var(--nav-active); color: #fff; font-weight: 600; }
.nav a.active svg { opacity: 1; }
.nav .badge { margin-inline-start: auto; }
.shell.collapsed .sidebar { width: 76px; }
.shell.collapsed .brand { justify-content: center; padding-inline: 0; }
.shell.collapsed .brand > div, .shell.collapsed .nav a span { display: none; }
.shell.collapsed .nav a { justify-content: center; padding-inline: 0; }
.scrim { display: none; position: fixed; inset: 0; z-index: 45; background: rgb(0 0 0 / .4); }
.main { flex: 1; overflow: auto; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 20; flex: none; display: flex; align-items: center; gap: 8px; height: 68px; padding-inline: 24px;
  background: var(--panel); border-bottom: 1px solid var(--border);
}
.topbar .spacer { flex: 1; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; flex: none; width: 36px; height: 36px; padding: 0; border: 0; border-radius: 7px;
  background: none; color: var(--ink-3); cursor: pointer; transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--panel-2); color: var(--text); }
.icon-btn.outline { border: 1px solid var(--border); background: var(--panel); }
.date-pill { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border: 1px solid var(--border); border-radius: 6px; background: var(--panel-2); font-size: 13px; color: var(--ink-2); white-space: nowrap; }
.date-pill svg { color: var(--ink-3); }
.who { display: flex; align-items: center; gap: 10px; min-width: 0; margin-inline-start: 6px; }
.who-text { min-width: 0; line-height: 1.35; }
.who-name { font-size: 13px; font-weight: 600; white-space: nowrap; }
.who-role { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.avatar { display: flex; align-items: center; justify-content: center; flex: none; width: 36px; height: 36px; border-radius: 8px; background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 20px 24px 0; font-size: 13px; color: var(--accent); }
.crumbs :last-child { color: var(--text); font-weight: 600; }
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 8px 24px 0; }
.page-head h1 { font-size: 20px; font-weight: 700; line-height: 1.4; margin: 0; margin-inline-end: auto; }
.page { padding: 16px 24px 24px; flex: 1; min-height: 0; }

@media (max-width: 1023px) {
  .sidebar { position: fixed; inset-block: 0; inset-inline-start: 0; z-index: 50; transform: translateX(100%); }
  .sidebar:dir(ltr) { transform: translateX(-100%); }
  .sidebar.open, .sidebar.open:dir(ltr) { transform: none; }
  .sidebar.open + .scrim { display: block; }
  .shell.collapsed .sidebar { width: 16rem; }
  .shell.collapsed .brand { justify-content: flex-start; padding-inline: 20px; }
  .shell.collapsed .brand > div { display: block; }
  .shell.collapsed .nav a { justify-content: flex-start; padding-inline: 12px; }
  .shell.collapsed .nav a span { display: inline; }
  .topbar { padding-inline: 12px; }
  .crumbs { padding: 14px 12px 0; }
  .page-head { padding: 6px 12px 0; }
  .page { padding: 12px; }
}
@media (max-width: 640px) { .date-pill, .who-text { display: none; } }

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  background: var(--panel); border: 1px solid var(--border); border-radius: .45rem; color: var(--text);
  padding: 7px 15px; font-size: 14px; font-weight: 500; cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--panel-2); }
.btn.primary, .btn.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); box-shadow: 0 2px 6px color-mix(in srgb, var(--accent) 30%, transparent); }
.btn.primary:hover, .btn.on:hover { background: var(--accent); filter: brightness(1.08); }
.btn.danger { color: var(--bad); }
.btn.small { padding: 4px 10px; font-size: 13px; border-radius: .4rem; }
.btn.icon { padding: 6px 9px; }
.btn[disabled] { opacity: .5; cursor: default; pointer-events: none; }
.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.seg button { white-space: nowrap; background: var(--panel); border: 1px solid var(--border); border-radius: .4rem; padding: 4px 11px; font-size: 12.5px; color: var(--ink-2); cursor: pointer; }
.seg button:hover { background: var(--panel-2); }
.seg button.on { background: var(--accent-soft); border-color: transparent; color: var(--accent); font-weight: 600; }

input[type=text], input[type=password], input[type=number], input[type=date], input[type=url], input[type=search], select, textarea {
  background: var(--panel); color: var(--text); border: 1px solid var(--border); border-radius: .45rem; padding: 8px 11px; width: 100%; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
label.field { display: grid; gap: 5px; }
label.field > span { color: var(--muted); font-size: 13px; }
label.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 600px) { .form-grid { grid-template-columns: 1fr; } }

.card { background: var(--panel); border: 1px solid var(--card-border); border-radius: var(--radius); box-shadow: var(--shadow-card); padding: 18px 20px; }
.card h3 { margin: 0 0 12px; font-size: 15px; font-weight: 600; }
.stack { display: grid; gap: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 500; white-space: nowrap; background: var(--panel-2); color: var(--ink-2); }
.badge.ok { background: var(--st-idle-soft); color: var(--st-idle); }
.badge.bad { background: var(--st-talk-soft); color: var(--st-talk); }
.badge.warn { background: var(--st-ring-soft); color: var(--st-ring); }
.badge.count { background: var(--bad); color: #fff; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--muted); flex: none; }
.dot.online { background: var(--ok); }
.dot.offline, .dot.error { background: var(--bad); }
.dot.unknown { background: var(--warn); }

table.list { width: 100%; border-collapse: collapse; }
table.list th, table.list td { padding: 10px 12px; text-align: start; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.list th { color: var(--muted); font-weight: 500; font-size: 12.5px; }
table.list tr:hover td { background: var(--panel-2); }
.table-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--card-border); border-radius: var(--radius); box-shadow: var(--shadow-card); }

/* ---------- stats ---------- */
.stats { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 600px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1100px) { .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.stat { display: flex; align-items: center; gap: 12px; background: var(--panel); border: 1px solid var(--card-border); border-radius: var(--radius); box-shadow: var(--shadow-card); padding: 18px 20px; }
.stat > div:first-child { flex: 1; min-width: 0; }
.stat .label { color: var(--muted); font-size: 13px; }
.stat .value { font-size: 26px; font-weight: 700; line-height: 1.25; margin-top: 4px; font-variant-numeric: tabular-nums; }
/* round icon: tinted disc inside a thin ring of the same hue (set --tone on the element) */
.stat-icon { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 48px; height: 48px; border-radius: 999px;
  color: var(--tone); background: color-mix(in srgb, var(--tone) 12%, var(--panel)); border: 1.5px solid color-mix(in srgb, var(--tone) 45%, transparent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--tone) 8%, transparent); }
.bar { height: 6px; border-radius: 4px; background: var(--surface-3); overflow: hidden; margin-top: 8px; }
.bar > i { display: block; height: 100%; background: var(--accent); }
/* bars and charts fill in when a page opens */
@keyframes fill-x { from { transform: scaleX(0); } }
.bar-fill { animation: fill-x 1.2s cubic-bezier(.33, 1, .68, 1) both; transform-origin: left; }
.bar-fill:dir(rtl) { transform-origin: right; }
@keyframes grow-up { from { transform: scaleY(0); } }
.chart-grow { animation: grow-up 1.2s cubic-bezier(.33, 1, .68, 1) both; }
@media (prefers-reduced-motion: reduce) { .bar-fill, .chart-grow { animation: none; } }
/* ---------- modal & toast ---------- */
.modal-back { position: fixed; inset: 0; background: #000a; z-index: 60; display: flex; align-items: flex-start; justify-content: center; padding: 5vh 12px; overflow-y: auto; }
.modal { background: var(--panel); border: 1px solid var(--card-border); border-radius: var(--radius); box-shadow: 0 12px 40px rgb(0 0 0 / .2); width: min(720px, 100%); }
.modal.wide { width: min(1100px, 100%); }
.modal header { display: flex; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.modal header h2 { font-size: 16px; margin: 0; margin-inline-end: auto; }
.modal .body { padding: 18px; display: grid; gap: 14px; }
.modal footer { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 18px; border-top: 1px solid var(--border); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); }
.tabs button { background: none; border: 0; padding: 8px 14px; cursor: pointer; border-bottom: 2px solid transparent; color: var(--muted); }
.tabs button.on { border-color: var(--accent); color: var(--accent); font-weight: 500; }
#toasts { position: fixed; bottom: 16px; inset-inline-start: 16px; display: grid; gap: 8px; z-index: 100; }
.toast { background: var(--panel); border: 1px solid var(--border); border-inline-start: 4px solid var(--accent); padding: 10px 14px; border-radius: 8px; max-width: 380px; box-shadow: 0 4px 16px rgb(0 0 0 / .18); }
.toast.error { border-inline-start-color: var(--bad); }
.toast.ok { border-inline-start-color: var(--ok); }

/* ---------- login ---------- */
/* fixed navy / indigo in both themes (the side menu's colours) */
.login { position: relative; min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: radial-gradient(120% 90% at 85% 0%, #3b3f9e 0%, transparent 60%), linear-gradient(160deg, #13163a 0%, #1f2353 50%, #2a2f72 100%); }
.login::before { content: ""; position: absolute; inset: 0; background-image: radial-gradient(rgba(255,255,255,.09) 1px, transparent 1px); background-size: 22px 22px;
  mask-image: radial-gradient(ellipse at center, #000 30%, transparent 75%); -webkit-mask-image: radial-gradient(ellipse at center, #000 30%, transparent 75%); }
.login form { position: relative; width: min(380px, 100%); display: grid; gap: 14px; padding: 32px; border: 0; }
.card > .lang-switch { justify-self: end; align-self: flex-end; }
.login-brand { display: grid; justify-items: center; gap: 6px; text-align: center; margin-bottom: 6px; }
.login-brand img { width: 84px; height: 84px; margin-bottom: 4px; }
.login-brand h1 { font-size: 21px; margin: 0; font-weight: 800; }

.empty-state { text-align: center; padding: 50px 20px; color: var(--muted); }
.spinner { width: 22px; height: 22px; border: 3px solid var(--surface-3); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.hint { font-size: 12.5px; line-height: 1.8; }

/* ---------- network panel ---------- */
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .grow { flex: 1; min-width: 160px; }
.toolbar input[type=text], .toolbar input[type=search], .toolbar select, .row > select { width: auto; }
.toolbar input.search { min-width: 220px; }
pre.code {
  direction: ltr; text-align: left; background: #14151c; color: #e9eaef; border: 1px solid var(--border); border-radius: 8px;
  padding: 12px 14px; margin: 0; overflow: auto; max-height: 65vh; font: 12.5px/1.55 ui-monospace, "Cascadia Mono", Consolas, monospace;
  white-space: pre; tab-size: 4;
}
pre.code.wrap { white-space: pre-wrap; word-break: break-all; }
pre.code .add { color: #86efac; background: #14532d55; display: block; }
pre.code .del { color: #fca5a5; background: #7f1d1d55; display: block; }
pre.code .hunk { color: #93c5fd; display: block; }
pre.code .err { color: #fca5a5; }
textarea.code { direction: ltr; text-align: left; font: 13px/1.55 ui-monospace, Consolas, monospace; min-height: 180px; resize: vertical; }
td.ltr, .mono { direction: ltr; unicode-bidi: embed; font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; }
td .sub { color: var(--muted); font-size: 12px; }
table.list td.nowrap, table.list th { white-space: nowrap; }
table.list.compact th, table.list.compact td { padding: 6px 10px; font-size: 13px; }
table.list tr.clickable { cursor: pointer; }
table.list input[type=checkbox] { width: 16px; height: 16px; }
.vendor { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 2px 8px; border-radius: 6px; border: 1px solid var(--border); white-space: nowrap; }
.vendor.cisco { color: #67e8f9; border-color: #155e75; }
.vendor.mikrotik { color: #fda4af; border-color: #881337; }
.vendor.fortinet { color: #fdba74; border-color: #7c2d12; }
.vendor.sophos { color: #93c5fd; border-color: #1e3a8a; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; font-size: 13.5px; }
.kv > :nth-child(odd) { color: var(--muted); }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; align-items: start; }
.split { display: grid; grid-template-columns: 300px 1fr; gap: 16px; align-items: start; }
@media (max-width: 960px) { .split { grid-template-columns: 1fr; } }
.picker { max-height: 52vh; overflow-y: auto; display: grid; gap: 2px; }
.picker label { display: flex; align-items: center; gap: 8px; padding: 5px 8px; border-radius: 6px; cursor: pointer; }
.picker label:hover { background: var(--panel-2); }
.picker .grp { color: var(--muted); font-size: 12px; padding: 8px 8px 2px; }
.list-item { display: flex; gap: 10px; align-items: center; padding: 9px 10px; border-radius: 8px; cursor: pointer; border: 1px solid transparent; }
.list-item:hover { background: var(--panel-2); }
.list-item.on { border-color: var(--accent); background: var(--panel-2); }
.feed { display: grid; gap: 2px; }
.feed .item { display: flex; flex-wrap: wrap; gap: 10px; align-items: baseline; padding: 7px 4px; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.feed .item:last-child { border-bottom: 0; }
.feed .item .when { margin-inline-start: auto; color: var(--muted); font-size: 12px; white-space: nowrap; }
.sev { width: 8px; height: 8px; border-radius: 50%; flex: none; transform: translateY(-1px); }
.sev.info { background: var(--accent); } .sev.warn { background: var(--warn); } .sev.bad { background: var(--bad); }
.result { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.result > header { display: flex; gap: 10px; align-items: center; padding: 9px 12px; background: var(--panel-2); cursor: pointer; flex-wrap: wrap; }
.result > .content { padding: 10px; display: grid; gap: 8px; }
.result .error { color: var(--st-talk); white-space: pre-wrap; font-size: 13px; }
.progress { height: 6px; background: var(--panel-2); border-radius: 3px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--accent); transition: width .3s; }
.add-txt { color: var(--st-idle); } .del-txt { color: var(--st-talk); }
.pill-row { display: flex; gap: 6px; flex-wrap: wrap; }

.form-section { margin: 8px 0 0; font-size: 14px; color: var(--muted); border-top: 1px solid var(--border); padding-top: 12px; }

/* charts */
.chart { display: grid; gap: 8px; }
.chart-box { position: relative; min-height: 120px; }
.chart-box svg { display: block; overflow: visible; }
.chart .grid { stroke: var(--border); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 11px; font-family: inherit; }
.chart .cross { stroke: var(--muted); stroke-width: 1; }
.chart-empty { color: var(--muted); padding: 30px 8px; text-align: center; font-size: 13px; }
.chart-legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--muted); }
.chart-legend span, .tip-row { display: inline-flex; align-items: center; gap: 6px; }
.key { display: inline-block; width: 14px; height: 3px; border-radius: 2px; }
.chart-tip { position: absolute; pointer-events: none; background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 10px; font-size: 12.5px; display: grid; gap: 4px; min-width: 140px; z-index: 2;
  box-shadow: 0 6px 18px rgba(0,0,0,.35); }
.tip-time { color: var(--muted); font-size: 11.5px; }
.tip-row b { color: var(--text); font-weight: 600; direction: ltr; }
.tip-row span { color: var(--muted); }
.meter { display: inline-flex; align-items: center; gap: 8px; min-width: 120px; }
.meter-bar { flex: 1; height: 6px; background: var(--panel-2); border-radius: 3px; overflow: hidden; min-width: 60px; }
.meter-bar i { display: block; height: 100%; border-radius: 3px; }
.meter-bar i.ok { background: var(--ok); } .meter-bar i.warn { background: var(--warn); } .meter-bar i.bad { background: var(--bad); }
.meter-val { font-variant-numeric: tabular-nums; font-size: 12.5px; min-width: 38px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-inline-end: 6px; }
.dot.up { background: var(--ok); } .dot.down { background: var(--bad); } .dot.off { background: var(--muted); }
tr.clickable { cursor: pointer; } tr.clickable:hover td { background: var(--panel-2); }
tr.sel td { background: var(--panel-2); }

/* syslog */
.sev-tag { display: inline-block; min-width: 58px; text-align: center; font-size: 11.5px; border-radius: 5px; padding: 1px 6px;
  border: 1px solid var(--border); color: var(--muted); }
.sev-tag.s0, .sev-tag.s1, .sev-tag.s2 { color: var(--st-talk); border-color: #7f1d1d; background: rgba(239,68,68,.12); }
.sev-tag.s3 { color: var(--st-talk); border-color: #7f1d1d; }
.sev-tag.s4 { color: var(--st-ring); border-color: #78350f; }
.log-msg { font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; white-space: pre-wrap; word-break: break-word; direction: ltr; text-align: left; }

/* network map */
.topo { position: relative; height: calc(100vh - 210px); min-height: 420px; border: 1px solid var(--border); border-radius: 12px;
  background: var(--panel); overflow: hidden; touch-action: none; }
.topo svg { width: 100%; height: 100%; display: block; cursor: grab; }
.topo .link { stroke: var(--ink-3); stroke-width: 1.5; }
.topo .link.ext { stroke-dasharray: 4 4; }
.topo .node circle { stroke: var(--panel); stroke-width: 2; cursor: pointer; }
.topo .node text { fill: var(--text); font-size: 12px; font-family: inherit; pointer-events: none; }
.topo .node .sub { fill: var(--muted); font-size: 10.5px; }
.topo .port { fill: var(--muted); font-size: 10px; font-family: inherit; }
.topo-legend { position: absolute; inset-inline-start: 12px; bottom: 10px; display: flex; gap: 14px; font-size: 12px; color: var(--muted);
  background: var(--panel); padding: 6px 10px; border-radius: 8px; }
.score { font-weight: 700; font-variant-numeric: tabular-nums; }
.score.ok { color: var(--ok); } .score.warn { color: var(--warn); } .score.bad { color: var(--bad); }
td a { white-space: nowrap; }
