/* DBMug — زبان بصری هم‌خانواده‌ی BugMug: زغالی و نارنجی، فارسی راست‌چین.
   عددها tabular هستند تا ستون‌ها در جدول‌ها نلرزند، و کد همیشه چپ‌چین و mono. */

/*
IRAN Sans-serif fonts are considered a proprietary software. To gain information about the laws regarding the use of these fonts, please visit www.fontiran.com
--------------------------------------------------------------------------------------
This set of fonts are used in this project under the license: KBMJU7GR
--------------------------------------------------------------------------------------
*/

/* نارنگی، نسخه‌ی وریبل: یک فایل ۱۸۳ کیلوبایتی برای همه‌ی وزن‌های ۱۰۰ تا ۹۰۰.
   پیش از این نام Vazirmatn اینجا بود ولی هیچ ‎@font-face‎ی نداشت — یعنی در عمل
   همیشه Tahoma رندر می‌شد. حالا فونت واقعاً بارگذاری می‌شود.

   عمداً نسخه‌ی FaNum (ارقام فارسی) نیست: آن نسخه رقم‌های لاتین را هم فارسی نشان
   می‌دهد و در داشبورد، مسیر فایل و IP و هشِ کوئری را خراب می‌کند. قاعده‌ی faText
   در app.js تصمیم می‌گیرد کجا رقم فارسی شود؛ این کارِ فونت نیست. */
@font-face {
  font-family: 'Narengi';
  src: url('fonts/NarengiVF.woff2') format('woff2-variations'),
       url('fonts/NarengiVF.woff') format('woff');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --ink: #262A33;
  --ink-2: #343A46;
  --muted: #7a7a85;
  --line: #e6e6ea;
  --line-soft: #f0f0f3;
  --bg: #f5f5f7;
  --card: #ffffff;
  --accent: #FF6B4A;
  --accent-dark: #f05733;
  --full: #2E5AAC;
  --diff: #7A4FA3;
  --log: #0E7C86;
  --ok: #1f7a4d;
  --warn: #b06a00;
  --crit: #c0392b;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Narengi, Vazirmatn, Tahoma, 'Segoe UI', sans-serif;
  font-size: 13px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--full); text-decoration: none; }
a:hover { color: #1f3f7d; }

.num { font-variant-numeric: tabular-nums; }
.mono {
  font-family: 'Cascadia Mono', Consolas, 'Courier New', monospace;
  direction: ltr;
  text-align: left;
  font-size: 12px;
}
.lb { color: var(--muted); font-size: 11.5px; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: #d8d8de; border-radius: 9px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- چیدمان ---------- */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }

.side {
  background: var(--ink);
  color: #fff;
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand { display: flex; align-items: baseline; gap: 2px; padding: 0 8px; }
.brand b { font-size: 19px; font-weight: 700; }
.brand span { font-size: 19px; font-weight: 700; color: var(--accent); }
.brand small { display: block; color: #9a9aa5; font-size: 10.5px; margin-top: -4px; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  color: #c9c9d1;
  padding: 8px 10px;
  border-radius: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.nav a:hover { background: var(--ink-2); color: #fff; }
.nav a.on { background: var(--accent); color: #fff; }
.nav .badge {
  background: rgba(255, 255, 255, .16);
  border-radius: 999px;
  padding: 0 7px;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.nav a.on .badge { background: rgba(0, 0, 0, .2); }

.side-foot { margin-top: auto; color: #7c7c88; font-size: 11px; padding: 0 8px; }
.side-foot button {
  background: none;
  border: 1px solid #43485a;
  color: #c9c9d1;
  border-radius: 8px;
  padding: 5px 10px;
  font-family: inherit;
  font-size: 11.5px;
  cursor: pointer;
  margin-top: 8px;
}
.side-foot button:hover { border-color: var(--accent); color: #fff; }

.main { padding: 22px 26px 48px; max-width: 1360px; }

.head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.head h1 { font-size: 20px; margin: 0 0 2px; font-weight: 600; }
.head .sub { color: var(--muted); font-size: 12px; }

/* ---------- اجزا ---------- */
.cd { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.cd-h {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.cd-h h2 { font-size: 13.5px; margin: 0; font-weight: 600; }
.cd-b { padding: 14px 16px; }

.grid { display: grid; gap: 14px; }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1100px) { .g-3, .g-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 720px) {
  .app { grid-template-columns: 1fr; }
  .side { position: static; height: auto; }
  .g-2, .g-3, .g-4 { grid-template-columns: 1fr; }
}

.kpi { padding: 14px 16px; }
.kpi .v { font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.3; }
.kpi .s { color: var(--muted); font-size: 11.5px; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}
.p-ok { background: #e8f5ee; color: var(--ok); }
.p-warn { background: #fdf3e2; color: var(--warn); }
.p-crit { background: #fdecea; color: var(--crit); }
.p-info { background: #eef2fb; color: var(--full); }
.p-mute { background: #f2f2f5; color: var(--muted); }
.p-full { background: #eaf0fb; color: var(--full); }
.p-diff { background: #f3edf9; color: var(--diff); }
.p-log { background: #e6f4f5; color: var(--log); }

table { width: 100%; border-collapse: collapse; }
th {
  font-weight: 500;
  color: var(--muted);
  font-size: 11.5px;
  text-align: right;
  padding: 8px 12px;
  background: #fafafb;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
td { padding: 9px 12px; border-bottom: 1px solid var(--line-soft); font-size: 12.5px; vertical-align: top; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fcfcfd; }
.tbl-wrap { overflow-x: auto; }

.bt {
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.bt-p { background: var(--accent); color: #fff; }
.bt-p:hover { background: var(--accent-dark); }
.bt-g { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.bt-g:hover { background: #fafafb; }
.bt-d { background: var(--ink); color: #fff; }
.bt-d:hover { background: var(--ink-2); }
.bt:disabled { opacity: .5; cursor: default; }

.bar { height: 7px; background: var(--line-soft); border-radius: 999px; overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 999px; background: var(--full); }

pre.code {
  background: #fafafb;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 11px 13px;
  overflow-x: auto;
  margin: 0;
  font-family: 'Cascadia Mono', Consolas, 'Courier New', monospace;
  direction: ltr;
  text-align: left;
  font-size: 12px;
  line-height: 1.65;
  white-space: pre;
}

.rows { display: flex; flex-direction: column; }
.row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 0;
  border-bottom: 1px solid var(--line-soft);
}
.row:last-child { border-bottom: none; }

/* ---------- ایرادات ---------- */
.f-list { display: flex; flex-direction: column; gap: 10px; }
.f-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-right: 3px solid var(--muted);
  border-radius: var(--radius);
  padding: 12px 15px;
  cursor: pointer;
}
.f-card:hover { border-color: #d5d5dd; }
.f-card.sev-critical { border-right-color: var(--crit); }
.f-card.sev-high { border-right-color: var(--accent); }
.f-card.sev-medium { border-right-color: var(--warn); }
.f-card.sev-low { border-right-color: var(--muted); }
.f-card.on { box-shadow: 0 0 0 2px rgba(255, 107, 74, .25); }
.f-card h3 { font-size: 13px; margin: 4px 0 6px; font-weight: 600; line-height: 1.6; }
.f-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.detail { display: grid; gap: 14px; }
.ev-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 18px; }
.ev-grid .k { color: var(--muted); font-size: 11.5px; }
.ev-grid .v { font-variant-numeric: tabular-nums; }

.hours { display: flex; gap: 3px; align-items: flex-end; height: 46px; }
.hours i {
  flex: 1;
  background: var(--line);
  border-radius: 2px 2px 0 0;
  min-height: 2px;
  position: relative;
}
.hours i.hot { background: var(--accent); }
.hours-x { display: flex; gap: 3px; margin-top: 3px; }
.hours-x span { flex: 1; text-align: center; font-size: 9px; color: var(--muted); }

.tl { display: flex; flex-direction: column; gap: 0; }
.tl-item { display: flex; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line-soft); }
.tl-item:last-child { border-bottom: none; }
.tl-item .t { color: var(--muted); font-size: 11px; white-space: nowrap; min-width: 108px; }

/* ---------- ورود ---------- */
.gate { max-width: 380px; margin: 12vh auto; }
.gate input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  font-family: inherit;
  font-size: 13px;
  direction: ltr;
  text-align: left;
}
.gate .err { color: var(--crit); font-size: 12px; min-height: 20px; }

.empty { color: var(--muted); text-align: center; padding: 26px 10px; }
.spinner { color: var(--muted); padding: 20px; }

.toast {
  position: fixed;
  bottom: 18px;
  left: 18px;
  background: var(--ink);
  color: #fff;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 12.5px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .18);
  z-index: 40;
}
.toast.err { background: var(--crit); }

.sev-dot { width: 8px; height: 8px; border-radius: 999px; display: inline-block; }
.d-critical { background: var(--crit); }
.d-high { background: var(--accent); }
.d-medium { background: var(--warn); }
.d-low { background: var(--muted); }

.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; background: #fff; }
.seg button {
  border: none;
  background: #fff;
  padding: 6px 12px;
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  color: var(--muted);
}
.seg button.on { background: var(--ink); color: #fff; }

/* ---------- کاربران ---------- */
select.seg-select {
  font-family: inherit;
  font-size: 12px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}
select.seg-select:hover { border-color: #d0d0d8; }

.gate label.lb { display: block; margin-bottom: 4px; }
.gate input { margin-bottom: 2px; }
.gate .bt { margin-top: 10px; }
