/* AkoDesk Panel — راست‌چین، سبز پسته‌ای */
@font-face {
  font-family: "Vazirmatn";
  src: url("fonts/Vazirmatn[wght].woff2") format("woff2-variations"),
       url("fonts/Vazirmatn-Variable.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  color-scheme: light;
  --bg: #f4f6f1;
  --surface: #ffffff;
  --surface-2: #f8faf6;
  --border: #e1e8da;
  --border-strong: #c9d6be;
  --ink: #1b2418;
  --ink-2: #4a5646;
  --ink-3: #6b7766;
  --brand: #3f6b26;
  --brand-strong: #2c4c1a;
  --brand-soft: #e6f1db;
  --pistachio: #93c572;
  --on-brand: #ffffff;
  --good: #2f7d32;
  --warn: #9a6400;
  --bad: #b03a2e;
  --good-soft: #e5f3e3;
  --warn-soft: #fbf0d9;
  --bad-soft: #f8e3e0;
  --s1: #3f7a22;
  --s2: #2a78d6;
  --s3: #d55181;
  --grid: #e9eee4;
  --seq-0: #eef5e8;
  --seq-1: #3f6b26;
  --shadow: 0 1px 2px rgba(27, 36, 24, .06), 0 2px 8px rgba(27, 36, 24, .04);
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --bg: #10140e;
    --surface: #171d15;
    --surface-2: #1d241a;
    --border: #2a3326;
    --border-strong: #3a4635;
    --ink: #eef2ea;
    --ink-2: #c3ccbd;
    --ink-3: #9aa694;
    --brand: #93c572;
    --brand-strong: #b4d99a;
    --brand-soft: #24321d;
    --on-brand: #10140e;
    --good: #7cc47f;
    --warn: #e0b04f;
    --bad: #ef8a7f;
    --good-soft: #1d2e1d;
    --warn-soft: #33290f;
    --bad-soft: #3a1d19;
    --s1: #5f9e3f;
    --s2: #3987e5;
    --s3: #d55181;
    --grid: #252d22;
    --seq-0: #1d241a;
    --seq-1: #93c572;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #10140e;
  --surface: #171d15;
  --surface-2: #1d241a;
  --border: #2a3326;
  --border-strong: #3a4635;
  --ink: #eef2ea;
  --ink-2: #c3ccbd;
  --ink-3: #9aa694;
  --brand: #93c572;
  --brand-strong: #b4d99a;
  --brand-soft: #24321d;
  --on-brand: #10140e;
  --good: #7cc47f;
  --warn: #e0b04f;
  --bad: #ef8a7f;
  --good-soft: #1d2e1d;
  --warn-soft: #33290f;
  --bad-soft: #3a1d19;
  --s1: #5f9e3f;
  --s2: #3987e5;
  --s3: #d55181;
  --grid: #252d22;
  --seq-0: #1d241a;
  --seq-1: #93c572;
  --shadow: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Vazirmatn", Tahoma, "Segoe UI", sans-serif;
  font-size: 14.5px;
  line-height: 1.7;
  font-feature-settings: "ss01";
}
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-strong); text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.4; }
h1 { font-size: 22px; font-weight: 800; }
h2 { font-size: 16px; font-weight: 700; }
h3 { font-size: 14.5px; font-weight: 700; }
.ltr { direction: ltr; unicode-bidi: isolate; display: inline-block; }
div.ltr, dd.ltr, td.ltr { display: block; text-align: right; }
td.ltr { display: table-cell; }
.muted { color: var(--ink-3); }
.small { font-size: 12.5px; }
.mono { font-family: Consolas, "SFMono-Regular", monospace; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- قالب کلی ---------- */
.shell { display: flex; min-height: 100vh; }
.side {
  width: 236px; flex-shrink: 0; background: var(--surface); border-inline-start: 0;
  border-inline-end: 1px solid var(--border); padding: 18px 12px; display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; }
.brand b { font-size: 18px; font-weight: 800; direction: ltr; }
.brand b span { color: var(--s1); }
.brand small { display: block; color: var(--ink-3); font-size: 11.5px; margin-top: -4px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px;
  color: var(--ink-2); font-weight: 500; text-decoration: none;
}
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a.on { background: var(--brand-soft); color: var(--ink); font-weight: 700; }
.nav a.on svg { stroke: var(--brand); }
.nav svg { width: 18px; height: 18px; stroke: var(--ink-3); fill: none; stroke-width: 2; flex-shrink: 0; }
.nav .sep { height: 1px; background: var(--border); margin: 10px 8px; }
.side .grow { flex: 1; }
.me { padding: 10px 12px; border-radius: 12px; background: var(--surface-2); font-size: 13px; }
.me b { display: block; }
.me .row { display: flex; gap: 6px; margin-top: 8px; }

.main { flex: 1; min-width: 0; padding: 24px 28px 48px; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.top .actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.crumb { color: var(--ink-3); font-size: 13px; }

.side .menu-btn { display: none; }
@media (max-width: 920px) {
  .shell { flex-direction: column; }
  .side { position: static; width: 100%; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 12px; }
  .side .nav { display: none; width: 100%; }
  .side.open .nav { display: block; }
  .side .grow, .side .me { display: none; }
  .side.open .me { display: block; width: 100%; }
  .brand { padding: 4px 6px; flex: 1; }
  .side .menu-btn { display: inline-flex; }
  .main { padding: 16px; }
}

/* ---------- اجزا ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; min-width: 0; }
.card > header { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.card > header .sub { color: var(--ink-3); font-size: 12.5px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-2-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
@media (max-width: 1100px) { .g2, .g3, .g-2-1 { grid-template-columns: minmax(0, 1fr); } }
.stack { display: flex; flex-direction: column; gap: 16px; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.kpi .lbl { color: var(--ink-3); font-size: 12.5px; font-weight: 500; }
.kpi .val { font-size: 28px; font-weight: 800; line-height: 1.3; margin-top: 2px; }
.kpi .val small { font-size: 14px; font-weight: 500; color: var(--ink-3); margin-inline-start: 4px; }
.kpi .foot { color: var(--ink-3); font-size: 12px; }
.kpi.hero { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.kpi.hero .lbl, .kpi.hero .foot, .kpi.hero .val small { color: inherit; opacity: .85; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; padding: 0 14px;
  border-radius: 10px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink);
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); text-decoration: none; color: var(--ink); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn.primary:hover { background: var(--brand-strong); border-color: var(--brand-strong); color: var(--on-brand); }
.btn.danger { color: var(--bad); border-color: var(--bad); background: transparent; }
.btn.danger:hover { background: var(--bad-soft); }
.btn.sm { min-height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible {
  outline: 2px solid var(--brand); outline-offset: 2px;
}

.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 10px; overflow: hidden; }
.seg a { padding: 6px 12px; color: var(--ink-2); font-weight: 500; font-size: 13px; text-decoration: none; }
.seg a + a { border-inline-start: 1px solid var(--border-strong); }
.seg a.on { background: var(--brand); color: var(--on-brand); }
.seg a:hover:not(.on) { background: var(--surface-2); }

label { font-size: 12.5px; color: var(--ink-2); font-weight: 500; display: block; margin-bottom: 4px; }
input[type=text], input[type=password], input[type=search], input[type=number], select, textarea {
  width: 100%; min-height: 38px; padding: 6px 12px; border: 1px solid var(--border-strong); border-radius: 10px;
  background: var(--surface); color: var(--ink); font: inherit;
}
textarea { min-height: 80px; resize: vertical; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; }
.filters .f { min-width: 140px; }
.filters .f.wide { flex: 1; min-width: 200px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; align-items: end; }

.table-wrap { overflow-x: auto; margin: 0 -4px; }
table.t { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.t th { text-align: start; font-weight: 600; color: var(--ink-3); font-size: 12.5px; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.t td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.t tr:last-child td { border-bottom: 0; }
.t tbody tr:hover td { background: var(--surface-2); }
.t .num { text-align: end; font-variant-numeric: tabular-nums; white-space: nowrap; }
.empty { padding: 28px; text-align: center; color: var(--ink-3); }

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge svg { width: 12px; height: 12px; }
.badge.on { background: var(--good-soft); color: var(--good); }
.badge.off { background: var(--surface-2); color: var(--ink-3); border: 1px solid var(--border); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.info { background: var(--brand-soft); color: var(--ink); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.dot.on { background: var(--good); box-shadow: 0 0 0 3px var(--good-soft); }
.dot.off { background: var(--ink-3); opacity: .5; }

.flash { padding: 10px 14px; border-radius: 10px; margin-bottom: 12px; font-weight: 500; border: 1px solid; }
.flash.ok { background: var(--good-soft); color: var(--good); border-color: transparent; }
.flash.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.flash.err { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.secret { background: var(--surface-2); border: 1px dashed var(--border-strong); padding: 12px 14px; border-radius: 10px; word-break: break-all; }

.pager { display: flex; gap: 6px; justify-content: center; margin-top: 14px; flex-wrap: wrap; align-items: center; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: 13.5px; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.meter { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; border: 1px solid var(--border); min-width: 80px; }
.meter > i { display: block; height: 100%; background: var(--brand); border-radius: 99px; }
.meter.warn > i { background: var(--warn); }
.meter.bad > i { background: var(--bad); }
details.box summary { cursor: pointer; font-weight: 600; }

/* ---------- نمودارها ---------- */
.chart { position: relative; width: 100%; min-height: 220px; }
.chart[data-kind="hbar"] { min-height: 0; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .axis text { fill: var(--ink-3); font-size: 11px; font-family: inherit; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: var(--border-strong); stroke-width: 1; }
.chart .hover-line { stroke: var(--ink-3); stroke-width: 1; stroke-dasharray: 3 3; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 12.5px; color: var(--ink-2); margin-bottom: 8px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.chart-legend i.line { height: 3px; border-radius: 2px; width: 16px; }
.tip {
  position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 10px;
  padding: 8px 12px; font-size: 12.5px; box-shadow: 0 4px 16px rgba(0,0,0,.12); min-width: 140px; z-index: 5; display: none; white-space: nowrap;
}
.tip b { display: block; margin-bottom: 2px; }
.tip .r { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.tip .r span { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); }
.tip .r i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.chart-empty { display: flex; align-items: center; justify-content: center; min-height: 200px; color: var(--ink-3); border: 1px dashed var(--border); border-radius: 10px; }
.chart-table { margin-top: 10px; }
.chart-tools { display: flex; justify-content: flex-end; }
.chart-tools button { font-size: 12px; }

/* ---------- ورود ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login { width: 100%; max-width: 400px; }
.login .card { padding: 28px; }
.login .brand { justify-content: center; padding-bottom: 8px; }
.login form { display: flex; flex-direction: column; gap: 14px; margin-top: 14px; }
