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

:root {
  --bg: #070d18;
  --bg-2: #0b1220;
  --surface: #101a2b;
  --surface-2: #16233a;
  --line: rgba(148, 163, 184, .16);
  --line-strong: rgba(148, 163, 184, .3);
  --text: #e6edf7;
  --text-dim: #93a4bd;
  --text-mute: #6b7f9c;
  --accent: #38bdf8;
  --accent-2: #22d3ee;
  --ok: #22c55e;
  --warn: #f59e0b;
  --bad: #ef4444;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --r: 14px;
  --header-h: 60px;
}

* { box-sizing: border-box; }

/* عناصری که با صفت hidden کنترل می‌شوند نباید با display کارت/شبکه آشکار شوند */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: 'Vazirmatn', 'Tahoma', 'Segoe UI', system-ui, sans-serif;
  background: radial-gradient(1200px 700px at 85% -10%, #10233c 0%, var(--bg) 55%) fixed;
  color: var(--text);
  font-size: 14px;
  line-height: 1.65;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font-family: inherit; font-size: inherit; }

h1, h2, h3, h4 { margin: 0; font-weight: 700; line-height: 1.4; }

/* ======================= هدر ======================= */

.app-header {
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 16px;
  background: rgba(9, 16, 28, .88);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
  position: relative;
  z-index: 900;
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  width: 40px; height: 40px; flex: 0 0 40px;
  display: grid; place-items: center;
  background: linear-gradient(145deg, rgba(34, 211, 238, .18), rgba(56, 189, 248, .06));
  border: 1px solid rgba(56, 189, 248, .35);
  border-radius: 12px;
}
.brand-text { min-width: 0; }
.brand-text h1 {
  font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.brand-text p {
  margin: 0; font-size: 11px; color: var(--text-mute);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.header-status {
  margin-inline-start: auto;
  display: flex; align-items: center; gap: 7px;
  font-size: 12px; color: var(--text-dim);
  padding: 5px 11px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  white-space: nowrap;
}
.header-status .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--ok); box-shadow: 0 0 0 3px rgba(34, 197, 94, .15);
}
.header-status .dot.is-busy { background: var(--accent); box-shadow: 0 0 0 3px rgba(56, 189, 248, .18); animation: pulse 1.1s infinite; }
.header-status .dot.is-off { background: var(--bad); box-shadow: 0 0 0 3px rgba(239, 68, 68, .18); }

@keyframes pulse { 50% { opacity: .35; } }

.header-actions { display: flex; gap: 8px; align-items: center; }

/* ======================= دکمه‌ها ======================= */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  font-weight: 700;
  transition: transform .12s ease, background .16s ease, border-color .16s ease, opacity .16s;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { background: #1d2d49; border-color: rgba(148, 163, 184, .45); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn-primary {
  background: linear-gradient(135deg, #0ea5e9, #0284c7);
  border-color: transparent; color: #fff;
  box-shadow: 0 6px 18px rgba(14, 165, 233, .28);
}
.btn-primary:hover:not(:disabled) { background: linear-gradient(135deg, #38bdf8, #0ea5e9); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--text-dim); }
.btn-ghost:hover:not(:disabled) { background: var(--surface); color: var(--text); }
.btn-outline { background: transparent; }
.btn-sm { padding: 6px 10px; font-size: 12.5px; border-radius: 9px; }
.btn-xs { padding: 4px 8px; font-size: 11.5px; border-radius: 7px; }
.btn-block { width: 100%; }

.btn-ico { font-size: 11px; }

/* ======================= بدنه ======================= */

.app-body {
  height: calc(100% - var(--header-h));
  display: grid;
  grid-template-columns: 316px minmax(0, 1fr) 400px;
  gap: 0;
}

.panel {
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, .35) transparent;
  padding: 12px;
  background: rgba(9, 15, 26, .6);
}
.panel::-webkit-scrollbar { width: 9px; }
.panel::-webkit-scrollbar-thumb { background: rgba(148, 163, 184, .28); border-radius: 8px; }
.panel::-webkit-scrollbar-track { background: transparent; }

.side-panel { border-inline-end: 1px solid var(--line); }
.report-panel {
  border-inline-start: 1px solid var(--line);
  display: flex; flex-direction: column;
  padding: 10px;
}

/* ======================= کارت‌ها ======================= */

.card {
  background: linear-gradient(180deg, rgba(22, 35, 58, .92), rgba(16, 26, 43, .92));
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 12px;
  margin-bottom: 10px;
}
.card-flat { background: var(--surface); margin-bottom: 10px; }
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; margin-bottom: 10px;
}
.card-head h2 { font-size: 13.5px; color: #cfe0f5; }
.card-head h3 { font-size: 12.5px; color: #c3d4ea; }
.badge {
  font-size: 11.5px; padding: 2px 9px; border-radius: 999px;
  background: rgba(56, 189, 248, .15); color: var(--accent);
  border: 1px solid rgba(56, 189, 248, .3);
  font-weight: 700;
}

.card-actions { background: transparent; border: 0; padding: 0; }

.card-danger {
  border-color: rgba(239, 68, 68, .28);
  background: linear-gradient(180deg, rgba(45, 24, 30, .55), rgba(16, 26, 43, .92));
}
.card-danger .card-head h2 { color: #fca5a5; }

.badge-mute {
  background: rgba(148, 163, 184, .14);
  color: var(--text-dim);
  border-color: var(--line);
}

.btn-danger {
  background: rgba(239, 68, 68, .16);
  border-color: rgba(239, 68, 68, .5);
  color: #fca5a5;
}
.btn-danger:hover:not(:disabled) {
  background: rgba(239, 68, 68, .28);
  border-color: rgba(239, 68, 68, .8);
  color: #fff;
}

.hint-mute {
  color: var(--text-mute);
  background: rgba(148, 163, 184, .07);
  border-color: var(--line);
}

/* پیش‌نمایش ورود فایل */
.import-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
  margin: 10px 0;
}
.import-summary .isum {
  background: #0c1526;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 7px 9px;
}
.import-summary .isum span { display: block; font-size: 10px; color: var(--text-mute); }
.import-summary .isum b { font-size: 14px; color: #dbeafe; }

.import-table { max-height: 240px; overflow: auto; border: 1px solid var(--line); border-radius: 9px; }
.import-table table { width: 100%; border-collapse: collapse; font-size: 11.5px; }
.import-table th {
  position: sticky; top: 0; background: #16233a; color: #b9cbe3;
  padding: 6px; text-align: right; white-space: nowrap;
}
.import-table td {
  padding: 5px 6px; border-bottom: 1px solid rgba(148, 163, 184, .1);
  color: #cfe0f5; white-space: nowrap;
}
.import-table .num { direction: ltr; text-align: right; font-variant-numeric: tabular-nums; }

.warn-box {
  background: rgba(245, 158, 11, .12);
  border: 1px solid rgba(245, 158, 11, .45);
  color: #fcd34d;
  border-radius: 9px;
  padding: 8px 10px;
  font-size: 11.5px;
  margin: 8px 0;
}
.err-box {
  background: rgba(239, 68, 68, .12);
  border: 1px solid rgba(239, 68, 68, .45);
  color: #fca5a5;
  border-radius: 9px;
  padding: 8px 10px;
  font-size: 11.5px;
  margin: 8px 0;
}
.ok-box {
  background: rgba(34, 197, 94, .1);
  border: 1px solid rgba(34, 197, 94, .4);
  color: #86efac;
  border-radius: 9px;
  padding: 8px 10px;
  font-size: 11.5px;
  margin: 8px 0;
}

/* ======================= فیلدها ======================= */

.field { display: block; margin-bottom: 11px; }
.field > span {
  display: block; font-size: 12px; color: var(--text-dim);
  margin-bottom: 5px;
}
.field > span b { color: var(--accent); }

select, input[type="search"], input[type="text"], input[type="number"] {
  width: 100%;
  padding: 8px 10px;
  border-radius: 9px;
  background: #0c1526;
  border: 1px solid var(--line-strong);
  color: var(--text);
  outline: none;
}
select:focus, input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(56, 189, 248, .12); }

input[type="range"] {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 5px;
  border-radius: 999px;
  background: linear-gradient(90deg, #0ea5e9, #22d3ee) no-repeat;
  background-size: var(--fill, 50%) 100%;
  background-color: #1b2a42;
  outline: none;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px; border-radius: 50%;
  background: #e8f4ff; border: 3px solid #0ea5e9;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .4);
  cursor: grab;
}
input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%;
  background: #e8f4ff; border: 3px solid #0ea5e9;
}

.toggle {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 0; font-size: 12.5px; color: var(--text-dim);
  cursor: pointer;
}
.toggle input { width: 16px; height: 16px; accent-color: #0ea5e9; cursor: pointer; }
.toggle:hover { color: var(--text); }

.hint {
  font-size: 11.5px; color: #7dd3fc;
  background: rgba(56, 189, 248, .1);
  border: 1px dashed rgba(56, 189, 248, .4);
  border-radius: 9px;
  padding: 7px 9px; margin: 8px 0 0;
}

.btn-row { display: flex; gap: 7px; margin-bottom: 7px; }
.btn-row > .btn { flex: 1; }

.class-preview { display: flex; gap: 4px; margin-top: 4px; }
.class-preview .seg {
  flex: 1; text-align: center; font-size: 10.5px; font-weight: 700;
  padding: 4px 2px; border-radius: 6px; color: #071018;
}

/* ======================= لیست حوضچه ======================= */

.pond-list { display: flex; flex-direction: column; gap: 6px; max-height: 230px; overflow-y: auto; }

.pond-item {
  display: grid;
  grid-template-columns: 10px 1fr auto;
  gap: 8px; align-items: center;
  padding: 7px 9px;
  background: #0c1526;
  border: 1px solid var(--line);
  border-radius: 9px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.pond-item:hover { border-color: rgba(56, 189, 248, .5); background: #0f1b30; }
.pond-item.is-active { border-color: var(--accent); background: #10203a; }
.pond-item .swatch { width: 10px; height: 10px; border-radius: 3px; }
.pond-item .p-name {
  font-size: 12.5px; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pond-item .p-sub { font-size: 10.5px; color: var(--text-mute); }
.pond-item .p-del {
  border: 0; background: transparent; color: var(--text-mute);
  cursor: pointer; font-size: 13px; padding: 3px 5px; border-radius: 6px;
}
.pond-item .p-del:hover { color: var(--bad); background: rgba(239, 68, 68, .12); }
.pond-item .p-pct { font-size: 11.5px; font-weight: 700; }

.empty-note {
  font-size: 12px; color: var(--text-mute);
  text-align: center; padding: 10px; margin: 0;
}

/* ======================= نقشه ======================= */

.map-wrap { position: relative; min-width: 0; background: #05090f; }
.map-canvas { position: absolute; inset: 0; }
.leaflet-container { background: #05090f; font-family: inherit; }
.leaflet-container.drawing-mode { cursor: crosshair; }
.leaflet-control-attribution {
  background: rgba(7, 13, 24, .78) !important;
  color: #94a3b8 !important;
  font-size: 9.5px !important;
  direction: ltr;
}
.leaflet-control-attribution a { color: #38bdf8 !important; }
.leaflet-bar a {
  background: #101a2b !important; color: #e6edf7 !important;
  border-bottom-color: var(--line) !important;
}
.leaflet-bar a:hover { background: #1d2d49 !important; }

.analysis-overlay { image-rendering: pixelated; }

.pond-tip {
  background: rgba(8, 15, 26, .95) !important;
  border: 1px solid rgba(56, 189, 248, .45) !important;
  color: #e6edf7 !important;
  border-radius: 8px !important;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .5) !important;
  font-size: 11.5px !important;
  padding: 6px 9px !important;
  direction: rtl;
}
.pond-tip::before { border-top-color: rgba(56, 189, 248, .45) !important; }

.map-toolbar {
  position: absolute; top: 12px; inset-inline-start: 12px;
  display: flex; flex-direction: column; gap: 6px; z-index: 500;
}
.mtool {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: rgba(16, 26, 43, .94);
  border: 1px solid var(--line-strong);
  color: var(--text);
  cursor: pointer;
  font-size: 12.5px; font-weight: 700;
  display: grid; place-items: center;
  backdrop-filter: blur(8px);
  transition: background .15s, border-color .15s;
}
.mtool:hover { background: #1d2d49; border-color: var(--accent); }
.mtool.is-on { border-color: var(--accent); color: var(--accent); }

.map-legend {
  position: absolute; bottom: 16px; inset-inline-end: 12px;
  background: rgba(10, 17, 29, .93);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 9px 11px;
  font-size: 11px; color: var(--text-dim);
  z-index: 500; backdrop-filter: blur(8px);
  min-width: 148px;
}
.legend-title { font-weight: 700; color: #cfe0f5; margin-bottom: 6px; font-size: 11.5px; }
.legend-row { display: flex; align-items: center; gap: 6px; margin-bottom: 3px; }
.legend-row i { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }
.legend-scale {
  margin-top: 7px; height: 8px; border-radius: 4px;
  background: linear-gradient(90deg, #fff, #ffffcc, #a1dab4, #41b6c4, #2c7fb8, #253494);
  border: 1px solid var(--line);
}
.legend-scale::after {
  content: '۰٪ ← پایداری آب → ۱۰۰٪';
  display: block; font-size: 9px; color: var(--text-mute);
  text-align: center; margin-top: 3px; white-space: nowrap;
}

.map-badge {
  position: absolute; top: 12px; inset-inline-end: 12px;
  background: rgba(16, 26, 43, .94);
  border: 1px solid rgba(34, 211, 238, .45);
  color: #a5f3fc;
  padding: 5px 11px; border-radius: 999px;
  font-size: 11.5px; font-weight: 700; z-index: 500;
  direction: ltr;
}

.progress-wrap {
  position: absolute; top: 10px; inset-inline: 58px auto;
  width: min(420px, calc(100% - 130px));
  background: rgba(10, 17, 29, .96);
  border: 1px solid rgba(56, 189, 248, .35);
  border-radius: 12px;
  padding: 9px 12px;
  z-index: 700;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}
.progress-head {
  display: flex; justify-content: space-between; align-items: center;
  gap: 10px; font-size: 11.5px; color: var(--text-dim); margin-bottom: 6px;
}
.progress-head span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.progress-head b { color: var(--accent); font-size: 12px; }
.progress-track { height: 5px; background: #16233a; border-radius: 999px; overflow: hidden; }
.progress-bar {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, #0284c7, #22d3ee);
  border-radius: 999px;
  transition: width .35s ease;
}

.draw-banner {
  position: absolute; bottom: 16px; inset-inline-start: 50%;
  transform: translateX(50%);
  display: flex; align-items: center; gap: 7px;
  background: rgba(8, 15, 26, .96);
  border: 1px solid var(--accent);
  border-radius: 12px;
  padding: 8px 12px;
  z-index: 700;
  font-size: 12px;
  box-shadow: var(--shadow);
  max-width: calc(100% - 24px);
  flex-wrap: wrap;
  justify-content: center;
}
.draw-banner span { color: #a5f3fc; font-weight: 700; }

.coord-readout {
  position: absolute; bottom: 16px; inset-inline-start: 12px;
  background: rgba(10, 17, 29, .85);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 3px 9px;
  font-size: 10.5px; color: var(--text-mute);
  z-index: 500;
  direction: ltr;
  font-variant-numeric: tabular-nums;
}

/* ======================= گزارش ======================= */

.report-tabs {
  display: flex; gap: 4px; margin-bottom: 10px;
  background: #0c1526;
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 3px;
  flex: 0 0 auto;
}
.rtab {
  flex: 1;
  border: 0; background: transparent;
  color: var(--text-dim);
  padding: 7px 4px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 12px; font-weight: 700;
  transition: background .15s, color .15s;
}
.rtab:hover { color: var(--text); }
.rtab.is-active { background: var(--surface-2); color: var(--accent); }

.report-body { flex: 1 1 auto; overflow-y: auto; min-height: 0; padding-inline-end: 2px; }
.rtab-panel { display: none; }
.rtab-panel.is-active { display: block; }

.report-foot {
  flex: 0 0 auto; display: flex; gap: 7px;
  padding-top: 9px; border-top: 1px solid var(--line);
}
.report-foot .btn { flex: 1; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}
.kpi {
  background: linear-gradient(165deg, rgba(30, 47, 74, .95), rgba(16, 26, 43, .95));
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  position: relative;
  overflow: hidden;
}
.kpi::after {
  content: ''; position: absolute; inset-inline-start: 0; top: 0; bottom: 0;
  width: 3px; background: var(--accent); opacity: .8;
}
.kpi.k-ok::after { background: var(--ok); }
.kpi.k-warn::after { background: var(--warn); }
.kpi.k-bad::after { background: var(--bad); }
.kpi .k-label { font-size: 11px; color: var(--text-dim); margin-bottom: 2px; }
.kpi .k-value { font-size: 20px; font-weight: 700; line-height: 1.25; }
.kpi .k-sub { font-size: 10.5px; color: var(--text-mute); }

.donut-wrap { display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; }
.donut-legend { list-style: none; margin: 0; padding: 0; font-size: 11.5px; color: var(--text-dim); }
.donut-legend li { display: grid; grid-template-columns: 10px 1fr auto auto; gap: 6px; align-items: center; margin-bottom: 4px; }
.donut-legend i { width: 10px; height: 10px; border-radius: 3px; }
.donut-legend b { color: var(--text); }
.donut-legend em { color: var(--text-mute); font-style: normal; font-size: 10.5px; min-width: 30px; text-align: end; }

.chart-box { width: 100%; }
.chart-legend {
  display: flex; flex-wrap: wrap; gap: 4px 12px;
  font-size: 11px; color: var(--text-dim);
  margin-top: 6px; justify-content: center;
}
.chart-legend span { display: inline-flex; align-items: center; gap: 5px; }
.chart-legend i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }

.trend-controls { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.chip {
  border: 1px solid var(--line-strong);
  background: #0c1526;
  color: var(--text-dim);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 11px; cursor: pointer;
}
.chip.is-on { border-color: var(--accent); color: var(--accent); background: rgba(56, 189, 248, .1); }

.table-tools {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px; margin-bottom: 8px;
}
.table-tools input { grid-column: 1 / -1; }
.table-tools .btn { padding: 6px 8px; font-size: 11.5px; }
.table-tools select { font-size: 11.5px; padding: 6px 8px; }

.table-scroll { overflow: auto; max-height: calc(100vh - 260px); border-radius: 10px; border: 1px solid var(--line); }

.data-table { width: 100%; border-collapse: collapse; font-size: 11.5px; }
.data-table thead th {
  position: sticky; top: 0; z-index: 2;
  background: #16233a;
  color: #b9cbe3;
  padding: 7px 6px;
  text-align: right;
  font-weight: 700;
  white-space: nowrap;
  border-bottom: 1px solid var(--line-strong);
  cursor: pointer;
  user-select: none;
}
.data-table thead th[data-sort]:hover { color: var(--accent); }
.data-table tbody td {
  padding: 6px;
  border-bottom: 1px solid rgba(148, 163, 184, .09);
  color: #cfe0f5;
  white-space: nowrap;
}
.data-table tbody tr:hover { background: rgba(56, 189, 248, .07); cursor: pointer; }
.data-table tbody tr.is-active { background: rgba(56, 189, 248, .13); }
.data-table .num { font-variant-numeric: tabular-nums; direction: ltr; text-align: right; }
.data-table .name-cell { max-width: 130px; overflow: hidden; text-overflow: ellipsis; }

.pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 1px 8px; border-radius: 999px;
  font-size: 10.5px; font-weight: 700;
}
.pill.c1 { background: rgba(34, 197, 94, .16); color: #4ade80; }
.pill.c2 { background: rgba(245, 158, 11, .16); color: #fbbf24; }
.pill.c3 { background: rgba(239, 68, 68, .16); color: #f87171; }

.trend-up { color: #4ade80; }
.trend-down { color: #f87171; }
.trend-flat { color: var(--text-mute); }
.muted { color: var(--text-mute); }
.spark { display: block; }

.scene-list { display: flex; flex-direction: column; gap: 6px; }
.scene-row {
  display: grid; grid-template-columns: auto 1fr auto;
  gap: 8px; align-items: center;
  padding: 7px 9px; border-radius: 9px;
  background: #0c1526; border: 1px solid var(--line);
  font-size: 11.5px;
}
.scene-row .s-idx {
  width: 20px; height: 20px; border-radius: 6px;
  background: rgba(56, 189, 248, .15); color: var(--accent);
  display: grid; place-items: center; font-size: 10px; font-weight: 700;
}
.scene-row .s-date { font-weight: 700; color: #cfe0f5; }
.scene-row .s-meta { font-size: 10px; color: var(--text-mute); direction: ltr; text-align: left; }
.scene-row.is-ref { border-color: rgba(34, 211, 238, .5); }
.scene-row.is-fail { opacity: .55; }

.meta-list { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; font-size: 11.5px; }
.meta-item { background: #0c1526; border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; }
.meta-item span { display: block; font-size: 10px; color: var(--text-mute); }
.meta-item b { color: #cfe0f5; }

.history-list { display: flex; flex-direction: column; gap: 5px; max-height: 190px; overflow-y: auto; }
.history-row {
  display: grid; grid-template-columns: 1fr auto auto; gap: 7px; align-items: center;
  padding: 6px 8px; border-radius: 8px;
  background: #0c1526; border: 1px solid var(--line);
  font-size: 11px; cursor: pointer;
}
.history-row:hover { border-color: var(--accent); }
.history-row.is-active { border-color: var(--accent); background: rgba(56, 189, 248, .08); }

/* ======================= دیالوگ ======================= */

.modal-backdrop {
  position: fixed; inset: 0; z-index: 3000;
  background: rgba(3, 7, 14, .78);
  backdrop-filter: blur(6px);
  display: grid; place-items: center;
  padding: 16px;
}
.modal {
  width: min(660px, 100%);
  max-height: 88vh;
  display: flex; flex-direction: column;
  background: var(--bg-2);
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .6);
  overflow: hidden;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.modal-head h2 { font-size: 14.5px; }
.modal-body { padding: 14px; overflow-y: auto; font-size: 12.5px; }
.modal-body h4 { font-size: 12.5px; color: var(--accent); margin: 14px 0 6px; }
.modal-body h4:first-child { margin-top: 0; }
.modal-body p, .modal-body li { color: var(--text-dim); line-height: 1.85; }
.modal-body ul { padding-inline-start: 18px; margin: 4px 0; }
.modal-body code {
  background: #0c1526; border: 1px solid var(--line);
  border-radius: 5px; padding: 1px 5px; font-size: 11px;
  color: #7dd3fc; direction: ltr; display: inline-block;
}
.modal-foot {
  display: flex; gap: 8px; justify-content: flex-start;
  padding: 11px 14px; border-top: 1px solid var(--line);
  background: var(--surface);
}
.modal-foot .btn { min-width: 90px; }
.modal-foot .spacer { flex: 1; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid label { display: block; font-size: 11.5px; color: var(--text-dim); margin-bottom: 4px; }

.detail-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin-bottom: 12px; }
.detail-item { background: #0c1526; border: 1px solid var(--line); border-radius: 9px; padding: 8px; }
.detail-item span { display: block; font-size: 10px; color: var(--text-mute); }
.detail-item b { font-size: 14px; color: #dbeafe; }

/* ======================= توست ======================= */

.toast-stack {
  position: fixed; bottom: 16px; inset-inline-start: 16px;
  display: flex; flex-direction: column; gap: 7px;
  z-index: 4000; max-width: min(360px, calc(100vw - 32px));
}
.toast {
  background: rgba(16, 26, 43, .97);
  border: 1px solid var(--line-strong);
  border-inline-start: 3px solid var(--accent);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 12px; color: var(--text);
  box-shadow: var(--shadow);
  animation: toastIn .22s ease;
}
.toast.ok { border-inline-start-color: var(--ok); }
.toast.warn { border-inline-start-color: var(--warn); }
.toast.err { border-inline-start-color: var(--bad); }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } }

.skeleton {
  height: 56px; border-radius: 10px;
  background: linear-gradient(90deg, #101a2b 25%, #16233a 50%, #101a2b 75%);
  background-size: 200% 100%;
  animation: sk 1.3s infinite;
}
@keyframes sk { to { background-position: -200% 0; } }

/* ======================= موبایل ======================= */

.mobile-tabs { display: none; }

@media (max-width: 1180px) {
  .app-body { grid-template-columns: 280px minmax(0, 1fr) 350px; }
}

@media (max-width: 980px) {
  body { overflow: auto; }
  .app-body {
    display: block;
    height: calc(100% - var(--header-h) - 46px);
    overflow: hidden;
  }
  .mobile-tabs {
    display: flex;
    height: 46px;
    background: rgba(9, 16, 28, .95);
    border-bottom: 1px solid var(--line);
    position: relative; z-index: 850;
  }
  .mtab {
    flex: 1; border: 0; background: transparent; color: var(--text-dim);
    font-size: 12.5px; font-weight: 700; cursor: pointer;
    border-bottom: 2px solid transparent;
  }
  .mtab.is-active { color: var(--accent); border-bottom-color: var(--accent); }

  .panel, .map-wrap {
    display: none;
    height: 100%;
    overflow-y: auto;
  }
  .panel.is-shown, .map-wrap.is-shown { display: block; }
  .map-wrap.is-shown { display: block; position: relative; }
  .map-canvas { position: absolute; inset: 0; }
  .report-panel.is-shown { display: flex; }
  .side-panel { border: 0; }
  .report-panel { border: 0; }

  .brand-text p { display: none; }
  .header-status { display: none; }
  .app-header { gap: 8px; padding: 0 10px; flex-wrap: nowrap; }
  .brand-text h1 { font-size: 13px; white-space: normal; line-height: 1.25; }
  .header-actions .btn-ghost { display: none; }
  .btn { padding: 7px 11px; font-size: 12.5px; }

  .map-legend { font-size: 10px; min-width: 128px; padding: 7px 9px; }
  .table-scroll { max-height: none; }
  .progress-wrap { width: calc(100% - 76px); inset-inline-start: 12px; }
}

@media (max-width: 560px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi .k-value { font-size: 17px; }
  .detail-grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
  .map-legend { display: none; }
  .coord-readout { display: none; }
  .draw-banner { font-size: 11px; }
}

@media print {
  body { overflow: visible; background: #fff; color: #111; }
  .app-header, .map-wrap, .side-panel, .report-tabs, .report-foot,
  .table-tools, .toast-stack, .modal-backdrop, .mobile-tabs { display: none !important; }
  .app-body { display: block; height: auto; }
  .report-panel { display: block; border: 0; overflow: visible; }
  .rtab-panel { display: block !important; }
  .card, .kpi { background: #fff !important; border: 1px solid #ccc !important; color: #111 !important; }
  .kpi .k-value, .kpi .k-label, .kpi .k-sub { color: #111 !important; }
  .data-table thead th { background: #eee !important; color: #111 !important; }
  .data-table tbody td { color: #111 !important; }
  .print-only { display: block !important; }
}

.print-only { display: none; }
