/* تم داشبورد سیمان — مطابق CallLogToSheet spec 013 brief-theme.md
   (تم تیره «پنل کاربری»؛ تنها تم نسخه اول). همه رنگ‌ها توکن‌اند. */

:root {
  color-scheme: dark;  /* پاپ‌آپ بومی select و اسکرول‌بار هم تیره رندر شود */
  --bg: #2f3140;
  --surface: #343646;
  --deep: #242636;
  --primary: #1fcc94;
  --primary-ink: #06251c;
  --text: #f2f4fa;
  --muted: #8f94ad;
  --warn: #f08a4b;
  --bad: #ff5d6c;
  --info: #5b8def;
  --amber: #f5b94a;
  --hover: #3a3d52;
  --line: #3d4054;
  --r: 16px;
  --rail: 56px;
  --side: 205px;  /* bug sidebar-width-trim: فقط به اندازهٔ متن + کمی فاصله */
}

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

* { box-sizing: border-box; }
html { direction: rtl; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.8 Vazirmatn, Tahoma, sans-serif;
}
a { color: var(--primary); }

/* ---- Shell: منو در لبهٔ راست (018) + محتوا چپ ----
   در RTL ستون ۱ گرید در راست می‌نشیند؛ پس سایدبار ستون ۱ است. */
.shell { display: grid; grid-template-columns: var(--side) 1fr; min-height: 100vh; }
.side {
  grid-column: 1; grid-row: 1;
  background: var(--deep);
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: row;
}
.rail { display: none; }  /* دسکتاپ: فقط منوی آیکن+متن — ریل فقط در نوار پایین موبایل */
.rail a {
  width: var(--rail); height: 62px;
  display: grid; place-items: center; color: #fff;
}
.rail svg { width: 22px; height: 22px; fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.menu { flex: 1; padding-top: 86px; padding-inline: 12px; display: flex; flex-direction: column; gap: 6px; }
.menu a {
  position: relative; isolation: isolate; overflow: hidden;
  display: flex; align-items: center; gap: 10px;
  height: 50px; padding-inline: 12px; border-radius: 14px;
  font-size: 14px; font-weight: 600; color: var(--text); text-decoration: none;
  white-space: nowrap;  /* bug sidebar-width-trim: «مدیریت کاربران» تک‌خط بماند */
  transition: color .25s ease;
}
.menu a .mi {
  width: 22px; height: 22px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.9;
  stroke-linecap: round; stroke-linejoin: round;
  transition: transform .4s cubic-bezier(.34,1.56,.64,1);
}
.menu a span { transition: transform .35s cubic-bezier(.34,1.56,.64,1); }
/* موشن سبز نرم: لایهٔ گرادیانی که با فنر از سمت مجاور محتوا پر می‌شود (018) */
.menu a::after {
  content: ""; position: absolute; inset: 0; z-index: -1; border-radius: inherit;
  background: linear-gradient(90deg, rgba(31,204,148,.26), rgba(31,204,148,.05));
  opacity: 0; transform: scaleX(.35); transform-origin: left center;
  transition: transform .5s cubic-bezier(.34,1.56,.64,1), opacity .3s ease;
}
.menu a:hover { color: var(--primary); }
.menu a:hover::after, .menu a.active::after { opacity: 1; transform: scaleX(1); }
.menu a:hover .mi { transform: scale(1.18) rotate(-8deg); }
.menu a:hover span { transform: translateX(3px); }
.menu a.active { color: var(--primary); }
.menu a.active::before {
  content: ""; position: absolute; left: 0; top: 12px; bottom: 12px;
  width: 3px; background: var(--primary); border-radius: 3px;
}
.brand {
  position: absolute; top: 12px; right: 10px; left: 10px;
  display: flex; align-items: center; gap: 12px; text-align: right;
}
.brand b { display: block; font-size: 15px; color: var(--primary); }
.brand small { color: var(--muted); font-size: 10.5px; }
.main { grid-column: 2; grid-row: 1; min-width: 0; }

/* ---- نمای صفحه‌ها: هر بار فقط یک نما ---- */
.view { display: none; }
.view.active { display: block; }
/* فیلتر زمان و مبنای نمودار در تنظیمات و کیفیت داده معنا ندارد */
body[data-view="settings"] #filters-card,
body[data-view="quality"] #filters-card { display: none; }

/* ---- Topbar ---- */
.top {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 24px; background: var(--surface);
  border-bottom: 1px solid #2b2d3c;
}
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  border: 0; border-radius: 10px; padding: 10px 18px;
  font: 600 13px Vazirmatn, Tahoma, sans-serif; cursor: pointer;
  text-decoration: none;
}
.btn.primary { background: var(--primary); color: var(--primary-ink); }
.btn.outline { background: transparent; color: var(--text); border: 1px solid #4a4d63; }
.btn.outline:hover { border-color: var(--primary); color: var(--primary); }
.btn.sm { padding: 5px 12px; font-size: 12px; border-radius: 8px; }
.btn.danger { background: color-mix(in srgb, var(--bad) 14%, transparent); color: var(--bad); border: 1px solid color-mix(in srgb, var(--bad) 55%, transparent); }
.btn.danger:hover, .btn.danger.solid { background: var(--bad); color: #fff; border-color: var(--bad); }
.btn.danger svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* صفحه تنظیمات */
.settings-kv { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.settings-kv:last-of-type { border-bottom: none; }
.settings-card .set-actions { margin-top: 18px; }

/* مودال تأیید خروج */
.modal-back { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; background: #0009; backdrop-filter: blur(3px); }
.modal-back[hidden] { display: none; }  /* display:grid نباید ویژگی hidden را باطل کند */
.modal { width: min(420px, 100%); background: var(--surface); border-radius: 20px; padding: 28px 26px 22px; text-align: center; box-shadow: 0 24px 60px #000a; }
.modal-ico { width: 56px; height: 56px; margin: 0 auto 14px; border-radius: 18px; display: grid; place-items: center; background: color-mix(in srgb, var(--bad) 16%, var(--deep)); color: var(--bad); }
.modal-ico svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.modal h3 { margin: 0 0 6px; }
.modal p { margin: 0 0 22px; color: var(--muted); line-height: 1.9; }
.modal-act { display: flex; gap: 10px; justify-content: center; }
@media (prefers-reduced-motion: reduce) { .modal-back { backdrop-filter: none; } }

/* لوگوی شرکت در برند سایدبار (مطابق iee-server) */
.brand .brand-mark { width: 44px; height: 44px; border-radius: 13px; object-fit: cover; box-shadow: 0 6px 18px #0007; flex: none; }

/* انتخاب بازه در هدر بالا (مطابق iee-server) */
.top select {
  border: 1px solid #4a4d63; border-radius: 10px; background: transparent;
  color: var(--text); font: 600 13px Vazirmatn, Tahoma, sans-serif;
  padding: 9px 12px; cursor: pointer;
}
.top select:hover { border-color: var(--primary); }
.top .dp-btn { border-radius: 10px; flex: none; white-space: nowrap; }
option { background: var(--deep); color: var(--text); }  /* جایگزین برای موتورهایی که color-scheme را نادیده می‌گیرند */
.preset-wrap { display: inline-flex; align-items: center; gap: 6px; }
.preset-ico { width: 22px; height: 22px; flex: none; fill: none; stroke: var(--primary); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.role-row { display: flex; align-items: center; gap: 14px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.role-row:last-of-type { border-bottom: none; }
.role-row b { min-width: 120px; }
.role-row label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }

/* کلید روشن/خاموش نقش کاربر در مدیریت کاربران */
.switch { position: relative; display: inline-block; width: 46px; height: 26px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; inset: 0; cursor: pointer;
  background: var(--hover); border: 1px solid var(--line); border-radius: 999px;
  transition: background .25s ease;
}
.switch .slider::before {
  content: ""; position: absolute; top: 2px; inset-inline-start: 2px;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--muted); transition: transform .25s ease, background .25s ease;
}
.switch input:checked + .slider { background: color-mix(in srgb, var(--primary) 35%, transparent); border-color: var(--primary); }
.switch input:checked + .slider::before { transform: translateX(-20px); background: var(--primary); }
.role-badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; background: rgba(52, 54, 70, 0.7); border: 1px solid var(--line); color: var(--muted); }
.role-row input[type="radio"] { min-width: auto; width: 16px; height: 16px; accent-color: var(--primary); }

/* انتخابگر بازهٔ زمانی و تقویم شمسی (پورت از iee-server) */
.dp-btn { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.dp-btn b { font-weight: 600; font-variant-numeric: tabular-nums; }
.dp-btn .dp-lbl { color: var(--muted); font-size: 12.5px; }
.dp-btn svg { width: 18px; height: 18px; fill: none; stroke: var(--primary); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.dp { position: fixed; z-index: 120; width: min(320px, calc(100vw - 16px)); background: var(--deep); border: 1px solid var(--line); border-radius: 20px; padding: 14px; box-shadow: 0 24px 60px #000a; }
.dp-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.dp-nav { width: 36px; height: 36px; border-radius: 12px; border: 0; background: var(--surface); color: var(--text); display: grid; place-items: center; cursor: pointer; }
.dp-nav:hover { background: color-mix(in srgb, var(--primary) 18%, var(--surface)); color: var(--primary); }
.dp-nav svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.dp-title { flex: 1; border: 0; background: none; color: var(--text); font: 700 16px Vazirmatn, Tahoma, sans-serif; padding: 6px 8px; border-radius: 10px; cursor: pointer; text-align: center; }
.dp-title:not(.static):hover { background: var(--hover); color: var(--primary); }
.dp-title.static { cursor: default; }
.dp-wd { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; color: var(--muted); font-size: 12.5px; font-weight: 600; margin-bottom: 4px; }
.dp-grid { display: grid; grid-template-columns: repeat(7, 1fr); row-gap: 2px; }
.dp-grid.dp-pick { grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 4px 0; }
.dp-d { height: 38px; border: 0; background: none; color: var(--text); font: 600 14px Vazirmatn, Tahoma, sans-serif; cursor: pointer; }
.dp-pick .dp-d { height: 44px; }
.dp-d:hover { background: color-mix(in srgb, var(--primary) 20%, transparent); color: var(--primary); }
.dp-d.rng { background: color-mix(in srgb, var(--primary) 12%, transparent); border-radius: 0; }
.dp-d.rs { border-start-start-radius: 12px; border-end-start-radius: 12px; }
.dp-d.re { border-start-end-radius: 12px; border-end-end-radius: 12px; }
.dp-d.today { box-shadow: inset 0 0 0 1.5px var(--primary); }
.dp-d.sel, .dp-d.sel:hover { background: var(--primary); color: var(--primary-ink); font-weight: 700; border-radius: 12px; }
.dp-foot { display: flex; justify-content: space-between; gap: 8px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--deep); border: 0; color: var(--text);
  display: grid; place-items: center; cursor: pointer;
  font-size: 16px; text-decoration: none;
}
.icon-btn:hover { background: var(--hover); }
:where(button, a, input, select):focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }

/* ---- Content / بنر / کارت‌ها ---- */
.content { padding: 28px; display: grid; gap: 20px; }
.banner {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border-radius: var(--r); padding: 14px 22px;
}
.banner .ico {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--warn); color: #fff;
  display: grid; place-items: center; font-size: 13px; font-weight: 700;
  flex: none;
}
.banner a { margin-inline-start: auto; font-size: 12px; text-decoration: none; }

.card { background: var(--surface); border-radius: var(--r); padding: 24px; }
.card h2 { margin: 0; font-size: 16px; font-weight: 700; }
.card .sub { color: var(--primary); font-size: 12px; margin-top: 2px; }

/* ---- فیلترها ---- */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-top: 14px; }
.filters label { display: flex; flex-direction: column; gap: 4px; font-size: 11px; color: var(--muted); }
.filters select, .filters input {
  font-family: inherit; font-size: 12.5px;
  border: 1px solid var(--line); border-radius: 10px;
  padding: 6px 9px; background: var(--deep); color: var(--text);
  min-width: 105px;
}
/* 019-multi-select-filters: چندانتخابی چک‌باکسی */
.msel { position: relative; min-width: 105px; }
.msel-btn {
  font-family: inherit; font-size: 12.5px; cursor: pointer; text-align: start;
  border: 1px solid var(--line); border-radius: 10px;
  padding: 6px 9px; background: var(--deep); color: var(--text);
  min-width: 105px; max-width: 220px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.msel.active .msel-btn { border-color: var(--primary); color: var(--primary); font-weight: 700; }
.msel-panel {
  display: none; position: absolute; top: calc(100% + 4px); inset-inline-start: 0;
  z-index: 60; min-width: 100%; max-height: 260px; overflow-y: auto;
  background: var(--deep); border: 1px solid var(--line); border-radius: 10px;
  padding: 6px; box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
}
.msel.open .msel-panel { display: block; }
.msel-search {
  font-family: inherit; font-size: 12.5px; width: 100%;
  box-sizing: border-box; margin-bottom: 6px;
  border: 1px solid var(--line); border-radius: 8px;
  padding: 5px 8px; background: var(--deep); color: var(--text);
}
/* bug msel-opt-layout-search: option rows are <label> inside .filters, so the
   generic .filters label { flex-direction: column } rule out-specifies a bare
   .msel-opt and stacked the checkbox above the text — scope it to win. */
.filters label.msel-opt {
  display: flex; flex-direction: row; align-items: center; gap: 6px;
  font-size: 12.5px; color: var(--text);
  padding: 5px 6px; border-radius: 7px; cursor: pointer; white-space: nowrap;
}
.filters label.msel-opt:hover { background: rgba(255, 255, 255, 0.06); }
.filters label.msel-opt.msel-hidden { display: none; }
.measure-switch { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; align-items: center; }
.measure-switch .lbl { color: var(--muted); font-size: 12px; margin-inline-end: 4px; }
.measure-switch button {
  font-family: inherit; font-size: 12px; cursor: pointer;
  border-radius: 999px; padding: 5px 13px;
  border: 1px solid var(--line); background: var(--deep); color: var(--muted);
}
.measure-switch button.active { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); font-weight: 700; }

/* ---- KPI tiles ---- */
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 22px 14px; }
.tile {
  background: var(--deep); border-radius: var(--r);
  padding: 56px 14px 18px; text-align: center; position: relative;
}
.tile .orb {
  position: absolute; top: -22px; left: 50%; transform: translateX(-50%);
  width: 62px; height: 62px; border-radius: 50%;
  display: grid; place-items: center;
  box-shadow: 0 10px 24px #0006, inset 0 -6px 12px #0003, inset 0 6px 10px #fff3;
}
.tile .orb svg {
  width: 28px; height: 28px; stroke: #fff; fill: none; stroke-width: 2.2;
  stroke-linecap: round; stroke-linejoin: round;
  filter: drop-shadow(0 2px 3px #0005);
}
.tile { transition: transform .2s ease, box-shadow .2s ease; }
.tile:hover { transform: translateY(-4px); box-shadow: 0 14px 30px #0005; }
/* انیمیشن‌ها: ورود پلکانی tileها + شناوری مداوم orbها (iee-server) */
.tile { animation: rise .5s cubic-bezier(.2,.8,.2,1) both; animation-delay: calc(var(--i, 0) * 70ms); }
.tile .orb { animation: bob 4.5s ease-in-out infinite; animation-delay: calc(var(--i, 0) * -1.1s); }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }
@keyframes bob { 50% { transform: translateX(-50%) translateY(-5px); } }
.pbar i { animation: fill 1s cubic-bezier(.2,.8,.2,1) both; }
@keyframes fill { from { width: 0; } }
@media (prefers-reduced-motion: reduce) {
  .tile, .tile .orb, .pbar i { animation: none; }
  .tile:hover { transform: none; }
}
.orb.g { background: radial-gradient(circle at 30% 25%, #7bf0c9, #1fcc94 60%, #0b8a63); }
.orb.o { background: radial-gradient(circle at 30% 25%, #ffd08a, #f08a4b 60%, #b4531c); }
.orb.b { background: radial-gradient(circle at 30% 25%, #9dbcff, #5b8def 60%, #2a50b0); }
.orb.r { background: radial-gradient(circle at 30% 25%, #ff9aa4, #ff5d6c 60%, #b02636); }
.orb.a { background: radial-gradient(circle at 30% 25%, #ffe09a, #f5b94a 60%, #b07d1c); }
.tile b { display: block; font-size: 19px; font-variant-numeric: tabular-nums; direction: ltr; }
.tile span { color: var(--muted); font-size: 11px; }
.tile .delta-up { color: var(--primary); }
.tile .delta-down { color: var(--bad); }

/* ---- جدول ---- */
.table-wrap { overflow-x: auto; border-radius: 10px; }
/* bug table-sticky-header-excel: جدول اصلی — wrap خودش اسکرول عمودی می‌شود تا
   thead/tfoot بچسبند؛ ارتفاع = یک نما منهای (بالای کارت + فیلترها + h2) */
#view-table .table-wrap { max-height: calc(100vh - 330px); overflow: auto; }
#view-table table.data thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--surface);
  box-shadow: 0 1px 0 var(--line);  /* جای border: با border-collapse می‌پرد */
}
#view-table table.data tfoot td {
  position: sticky; bottom: 0; z-index: 2;
  background: var(--surface);
  box-shadow: 0 -1px 0 var(--primary);
}
body[data-view="table"] .measure-switch { display: none; }
table.data { width: 100%; border-collapse: collapse; font-size: 12.5px; min-width: 900px; }
table.data thead th {
  color: var(--muted); font-weight: 500; font-size: 12px;
  padding: 10px 6px; text-align: right; white-space: nowrap;
  cursor: pointer; user-select: none; white-space: nowrap;
}
table.data thead th .arrow { font-size: 9px; margin-inline-start: 4px; }
table.data tbody td { padding: 12px 6px; border-top: 1px solid var(--line); white-space: nowrap; vertical-align: middle; }
table.data tbody tr:hover td { background: var(--hover); }
table.data tfoot td { padding: 10px 6px; font-weight: 700; border-top: 2px solid var(--primary); }
td.num, th.num { direction: ltr; text-align: right; }
.delta-up { color: var(--primary); }
.delta-down { color: var(--bad); }
.pbar { height: 3px; background: var(--deep); border-radius: 99px; position: relative; min-width: 120px; }
.pbar i { position: absolute; inset-block: 0; right: 0; background: var(--primary); border-radius: 99px; }

/* ---- نمودارها ---- */
.charts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.chart-box { height: 320px; }
.chart-box.tall { height: 420px; }
.badge {
  display: inline-block; background: var(--deep); color: var(--primary);
  border-radius: 999px; padding: 2px 10px; font-size: 11px; margin-inline-start: 6px;
}
.notice { color: var(--muted); font-size: 12px; }
.share-row { display: flex; align-items: center; gap: 8px; margin: 4px 0; }
.share-name { width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.share-track { flex: 1; background: var(--deep); border-radius: 99px; height: 3px; position: relative; }
.share-track i { position: absolute; inset-block: 0; right: 0; background: var(--primary); border-radius: 99px; }

/* ---- لاگین ---- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card { width: 360px; max-width: 100%; background: var(--surface); border-radius: 18px; padding: 30px 26px; text-align: center; }
.login-card .logo { width: 74px; height: 74px; border-radius: 20px; object-fit: cover; }
.login-card h1 { font-size: 16px; margin: 14px 0 20px; }
.login-card input {
  width: 100%; margin-bottom: 12px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 10px;
  font-family: inherit; font-size: 14px; background: var(--deep); color: var(--text);
}
.login-card .btn { width: 100%; padding: 11px; justify-content: center; }
.login-error { color: var(--bad); font-size: 12.5px; margin-bottom: 10px; }

/* ---- Responsive ---- */
@media (max-width: 1100px) {
  .charts-grid { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: repeat(2, 1fr); row-gap: 44px; }
}
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: auto 0 0 0; top: auto; height: 62px; width: 100%; flex-direction: row; z-index: 20; }
  .rail { display: flex; width: 100%; margin: 0; border-radius: 0; flex-direction: row; justify-content: space-around; padding: 0; }
  .rail a { height: 62px; flex: 1; }
  .menu, .brand { display: none; }
  .content { padding: 16px 16px 84px; }
  .top { padding: 12px 16px; flex-wrap: wrap; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ============================ نمای کل (ویژگی 012) ============================
   فقط صفحهٔ #view-kpis — همهٔ رنگ‌ها از توکن‌های موجود. */

#view-kpis { display: none; }
#view-kpis.active { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; }  /* minmax: ترک گرید تا max-content فرزندان باز نشود (bug kpis-mobile-responsive) */

/* ---- ردیف کارت‌های KPI: دسکتاپ ۱۲ ستونی (هر کارت ۲ ستون)، تبلت ۶، موبایل ۱ ---- */
.kpis-cards {
  display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 14px;
}
.kpis-card {
  grid-column: span 2;
  background: var(--deep); border-radius: var(--r);
  padding: 16px 16px 10px; position: relative; min-height: 148px;
  display: flex; flex-direction: column; gap: 6px;
  animation: rise .5s cubic-bezier(.2,.8,.2,1) both;
  animation-delay: calc(var(--i, 0) * 70ms);
  transition: transform .2s ease, box-shadow .2s ease;
}
.kpis-card:hover { transform: translateY(-4px); box-shadow: 0 14px 30px #0005; }
.kpis-card-head { display: flex; align-items: center; gap: 6px; }
.kpis-card-title { color: var(--muted); font-size: 11.5px; line-height: 1.6; }
.kpis-card-value { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; direction: ltr; text-align: right; overflow-wrap: anywhere; }
.kpis-card-value small { font-size: 11px; color: var(--muted); font-weight: 400; }
.kpis-card-delta { font-size: 12px; display: flex; align-items: center; gap: 6px; min-height: 20px; }
.kpis-card-delta .delta-note { color: var(--muted); font-size: 10px; }
.kpis-sub { color: var(--muted); font-size: 11px; border-top: 1px solid var(--line); padding-top: 6px; }
.kpis-sub b { color: var(--text); font-variant-numeric: tabular-nums; }
.kpis-spark { height: 30px; margin-top: auto; }
.kpis-info {
  width: 16px; height: 16px; flex: none; border-radius: 50%; cursor: help;
  border: 1px solid var(--line); background: transparent; color: var(--muted);
  font: 600 10px Vazirmatn, Tahoma, sans-serif; position: relative;
}
.kpis-info:hover { color: var(--primary); border-color: var(--primary); }
.kpis-info::after {
  content: attr(data-tip);
  position: absolute; bottom: 125%; right: 50%; transform: translateX(50%);
  background: var(--deep); color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 12px; width: min(210px, 78vw); white-space: normal;
  font: 400 11px/1.9 Vazirmatn, Tahoma, sans-serif; text-align: right;
  box-shadow: 0 14px 30px #000a; opacity: 0; visibility: hidden;
  transition: opacity .2s ease; z-index: 30;
}
.kpis-info:hover::after { opacity: 1; visibility: visible; }

/* ---- نمودارهای روند: دو نمودار کنار هم ---- */
.kpis-charts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }

/* ---- ساختار بازار: نقشه + هلدینگ + محصول ---- */
.kpis-structure { display: grid; grid-template-columns: 1.25fr 1fr 1fr; gap: 20px; }
.kpis-structure > .kpis-widget { min-width: 0; }
.kpis-map { height: 380px; }

/* ---- رتبه‌بندی ---- */
.kpis-see-all { float: left; font-size: 12px; text-decoration: none; margin-top: 4px; }
#kpis-ranking thead th.sortable:hover { color: var(--primary); }
#kpis-ranking td.heat-good { background: color-mix(in srgb, var(--primary) 10%, transparent); }
#kpis-ranking td.heat-bad { background: color-mix(in srgb, var(--bad) 10%, transparent); }

/* ---- نکات بازار ---- */
.kpis-insights { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.kpis-insight {
  background: var(--deep); border-radius: var(--r); padding: 14px 16px;
  display: flex; gap: 10px; align-items: flex-start;
  animation: rise .5s cubic-bezier(.2,.8,.2,1) both;
}
.kpis-insight b { display: block; font-size: 12px; color: var(--muted); font-weight: 600; }
.kpis-insight-body { font-size: 13px; margin-top: 4px; }
.kpis-insight-body small { color: var(--muted); }
.kpis-insight-body b { display: inline; color: var(--text); }
.kpis-insight-ico {
  width: 30px; height: 30px; flex: none; border-radius: 10px;
  display: grid; place-items: center; font-size: 14px; font-weight: 700;
}
.kpis-insight.good .kpis-insight-ico { background: color-mix(in srgb, var(--primary) 16%, transparent); color: var(--primary); }
.kpis-insight.bad .kpis-insight-ico { background: color-mix(in srgb, var(--bad) 16%, transparent); color: var(--bad); }
.kpis-insight.warn .kpis-insight-ico { background: color-mix(in srgb, var(--amber) 16%, transparent); color: var(--amber); }
.kpis-insight.info .kpis-insight-ico { background: color-mix(in srgb, var(--info) 16%, transparent); color: var(--info); }

/* ---- وضعیت‌های ویجت: skeleton / خالی / خطا (FR-014) ---- */
.kpis-widget, .kpis-cards { position: relative; }
.kpis-state {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 120px; color: var(--muted); font-size: 12.5px;
  flex-direction: column; text-align: center;
}
.kpis-widget.is-empty .chart-box, .kpis-widget.is-empty .kpis-map { opacity: .35; }
.kpis-cards.is-empty { display: grid; place-items: center; }
.kpis-widget.is-loading::after, .kpis-cards.is-loading::after {
  content: ""; position: absolute; inset: 10px; border-radius: 12px;
  background: linear-gradient(100deg, transparent 30%, #ffffff08 50%, transparent 70%);
  background-size: 220% 100%; animation: kpis-shimmer 1.2s ease-in-out infinite;
  pointer-events: none;
}
@keyframes kpis-shimmer { from { background-position: 120% 0; } to { background-position: -120% 0; } }
@media (prefers-reduced-motion: reduce) { .kpis-card, .kpis-insight, .kpis-widget.is-loading::after, .kpis-cards.is-loading::after { animation: none; } }

/* ---- ریسپانسیو نمای کل: تبلت/موبایل ---- */
@media (max-width: 1350px) and (min-width: 1101px) {
  .kpis-card { grid-column: span 4; }        /* سه کارت در ردیف — ۶تایی در این عرض تنگ می‌شود */
}
@media (max-width: 1100px) {
  .kpis-card { grid-column: span 6; }        /* دو کارت در ردیف (bug kpis-mobile-responsive) */
  .kpis-charts { grid-template-columns: minmax(0, 1fr); }
  .kpis-structure { grid-template-columns: minmax(0, 1fr); }
  .kpis-insights { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 820px) {
  .kpis-card { grid-column: span 12; min-height: auto; }  /* موبایل: تک‌ستون */
  .kpis-card-value { font-size: 18px; }
  .kpis-cards { gap: 10px; }
  #view-kpis .chart-box, #view-kpis .chart-box.tall { height: 260px; }  /* فقط نمای کل */
  .kpis-map { height: 280px; }
  .kpis-insights { grid-template-columns: 1fr; }
}
/* تکمیل: پیام خطای ردیف کارت‌ها تمام عرض شبکه را بگیرد */
.kpis-cards.is-error .kpis-state { grid-column: 1 / -1; }

/* bug kpis-hide-measure-switch: چیپ مبنای نمایش در «نمای کل» کاربرد ندارد —
   فقط در همین نما مخفی می‌شود (الگوی مخفی‌سازی کارت فیلترها در تنظیمات). */
body[data-view="kpis"] .measure-switch { display: none; }
/* bug analysis-num-format-charts-blank: مبنای نمایش فقط برای نمودارهاست */
body[data-view="analysis"] .measure-switch { display: none; }

/* bug dashboard-settings-quality-cleanup: دکمهٔ به‌روزرسانی و فیلتر تاریخ در
   تنظیمات و کیفیت داده معنا ندارند؛ باکس تاریخ به‌روزرسانی هم فقط در تنظیمات */
body[data-view="settings"] #refresh-btn,
body[data-view="quality"] #refresh-btn,
body[data-view="settings"] .preset-wrap,
body[data-view="quality"] .preset-wrap,
body[data-view="settings"] .dp-btn,
body[data-view="quality"] .dp-btn { display: none; }
body[data-view="settings"] .banner { display: none; }

/* نمای صادرات فقط چیدمان تازه می‌سازد — کارت/جدول/رنگ‌ها از کلاس‌های موجود
   تم (.card، table.table، توکن‌های --surface/--line/--muted) ارث می‌برند تا
   تم دست‌نخورده بماند (قانون مالک). */
/* ============================================================================
   انتخابگر بازار (bug export-same-page-toggle) — الگوی measure-switch؛
   پن‌های صادرات داخل همان صفحات؛ فقط توکن‌های موجود
   ============================================================================ */
.market-switch { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; align-items: center; }
.market-switch .lbl { color: var(--muted); font-size: 12px; margin-inline-end: 4px; }
.market-switch button {
  font-family: inherit; font-size: 12px; cursor: pointer;
  border-radius: 999px; padding: 5px 13px;
  border: 1px solid var(--line); background: var(--deep); color: var(--muted);
}
.market-switch button.active { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); font-weight: 700; }

.export-pane { display: none; }
body[data-market="export"] .export-pane {
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px;
  align-content: start;
}
body[data-market="export"] #view-kpis > :not(.export-pane),
body[data-market="export"] #view-charts > :not(.export-pane),
body[data-market="export"] #view-table > :not(.export-pane) { display: none; }
body[data-market="export"] .measure-switch { display: none; }

.export-pane table.data th, .export-pane table.data td { white-space: nowrap; }
/* گرید کارت‌های صادرات = عیناً همان .kpis-cards داخلی (۱۲ ستون، gap 14، span 2)
   — هیچ override ای نمی‌شود تا یک ردیف ۶تایی و ارتفاع داخلی حفظ شود
   (دو override قبلی همین قانون را شکسته بودند — bug export-cards-domestic-parity) */
.export-pane .kpis-state[hidden] { display: none; }  /* ریشهٔ فاصلهٔ ~۱۴۰px */

/* فیلترهای وابسته به بازار (bug export-same-page-toggle / T028) */
.filters label.f-export-only { display: none; }
body[data-market="export"] .filters label.f-export-only { display: flex; }
body[data-market="export"] .filters label.f-domestic-only { display: none; }

/* رتبه‌بندی صادرات — mirror of #kpis-ranking heat/sortable rules (append-only) */
#export-ranking thead th.sortable { cursor: pointer; }
#export-ranking thead th.sortable:hover { color: var(--primary); }
#export-ranking td.heat-green { background: color-mix(in srgb, var(--primary) 10%, transparent); }
#export-ranking td.heat-red { background: color-mix(in srgb, var(--bad) 10%, transparent); }
#export-ranking td { white-space: nowrap; }
