@font-face {
  font-family: Vazirmatn;
  src: url("../fonts/Vazirmatn-Regular.ttf") format("truetype");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: Vazirmatn;
  src: url("../fonts/Vazirmatn-Medium.ttf") format("truetype");
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: Vazirmatn;
  src: url("../fonts/Vazirmatn-SemiBold.ttf") format("truetype");
  font-weight: 600;
  font-display: swap;
}
@font-face {
  font-family: Vazirmatn;
  src: url("../fonts/Vazirmatn-Bold.ttf") format("truetype");
  font-weight: 700;
  font-display: swap;
}

:root {
  --bg: #10120f;
  --bg-2: #171a15;
  --panel: #1c211b;
  --panel-2: #242a22;
  --line: #32382e;
  --cream: #f3ead6;
  --muted: #9b937d;
  --gold: #d7b56d;
  --gold-2: #f0d48a;
  --plant: #7dbe8f;
  --animal: #e09a5a;
  --danger: #d36a5a;
  --info: #7aa3c4;
  --ours: #d7b56d;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: Vazirmatn, Tahoma, sans-serif;
  background:
    radial-gradient(1200px 500px at 80% -10%, rgba(215, 181, 109, 0.08), transparent 50%),
    var(--bg);
  color: var(--cream);
  line-height: 1.65;
}

.app { max-width: 1280px; margin: 0 auto; padding: 20px 18px 48px; }

.top {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 20px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; gap: 14px; align-items: center; }
.mark {
  width: 52px; height: 52px; border-radius: 14px;
  background: linear-gradient(160deg, #f0d48a, #b8893a);
  color: #1a1408; font-weight: 700; display: grid; place-items: center;
  letter-spacing: -0.02em; box-shadow: var(--shadow);
}
h1 { margin: 0; font-size: 1.7rem; font-weight: 700; }
.sub { margin: 2px 0 0; color: var(--muted); font-size: 0.9rem; }
.meta-col { text-align: left; }
.when { font-weight: 600; color: var(--gold-2); }
.scrape { color: var(--muted); font-size: 0.85rem; }
.chips { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; margin-top: 8px; }
.chip {
  border: 1px solid var(--line); background: var(--panel);
  color: var(--cream); border-radius: 999px; padding: 4px 10px;
  font-size: 0.8rem; cursor: pointer;
}
.chip.on { border-color: var(--gold); color: var(--gold-2); background: #2a2618; }
.chip.off { opacity: 0.45; }
.chip:disabled { cursor: not-allowed; opacity: 0.35; }

.banner {
  margin: 14px 0 0; padding: 10px 14px; border-radius: 10px;
  background: #2a2114; border: 1px solid #5a4630; color: var(--gold-2);
}
.banner.sample { background: #2c1c18; border-color: #6a3a30; color: #f0c2b0; }

.filters {
  display: flex; flex-wrap: wrap; gap: 10px 12px; align-items: end;
  margin: 18px 0; padding: 14px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 14px;
}
.filters label { font-size: 0.75rem; color: var(--muted); display: grid; gap: 4px; }
.filters select, .filters button, .mini select {
  font-family: inherit; background: var(--bg-2); color: var(--cream);
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px;
}
.toggle { display: flex !important; flex-direction: row; align-items: center; gap: 6px; color: var(--cream) !important; font-size: 0.85rem !important; }
.ghost { cursor: pointer; }
.ghost:hover { border-color: var(--gold); color: var(--gold-2); }

.kpis { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 16px; }
.kpi {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px;
}
.kpi .lbl { color: var(--muted); font-size: 0.8rem; }
.kpi .val { font-size: 1.55rem; font-weight: 700; color: var(--gold-2); margin-top: 4px; }
.kpi .subv { color: var(--muted); font-size: 0.78rem; }

.grid-2 { display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 14px; margin-bottom: 14px; }
.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 16px; padding: 14px 16px 16px; box-shadow: var(--shadow);
}
.card-h { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.card h2 { margin: 0; font-size: 1.05rem; }
.inner { margin: 14px 0 6px; font-size: 0.85rem; color: var(--gold); font-weight: 600; }
.hint, .muted { color: var(--muted); font-size: 0.8rem; margin: 4px 0 10px; }

#map { height: 420px; border-radius: 12px; background: #141811; border: 1px solid var(--line); }
.map-card .leaflet-container {
  background: #141811;
  font-family: Vazirmatn, sans-serif;
  direction: ltr; /* Leaflet mouse/fitBounds break under html[dir=rtl] */
}
.map-card .leaflet-tooltip,
.map-card .leaflet-popup-content { direction: rtl; text-align: right; }

.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
th, td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
th { color: var(--muted); font-weight: 500; font-size: 0.75rem; }
tr:hover td { background: rgba(255,255,255,0.02); }
.ours { color: var(--gold-2); }
.bar {
  height: 6px; background: #2c3329; border-radius: 99px; position: relative; min-width: 80px;
}
.bar > i {
  position: absolute; top: 0; bottom: 0; background: linear-gradient(90deg, #7dbe8f, #d7b56d);
  border-radius: 99px;
}

.anom {
  display: grid; gap: 8px;
}
.anom article {
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: var(--bg-2);
}
.anom .k { font-size: 0.75rem; color: var(--gold); }
.sev-high .k { color: var(--danger); }
.sev-medium .k { color: var(--animal); }
.empty {
  padding: 22px; text-align: center; color: var(--muted);
  border: 1px dashed var(--line); border-radius: 12px;
}

.foot { margin-top: 22px; color: var(--muted); font-size: 0.8rem; text-align: center; }

.leaflet-popup-content-wrapper, .leaflet-popup-tip,
.leaflet-tooltip.prov-tip {
  background: #1c211b; color: #f3ead6;
  border: 1px solid #32382e;
  box-shadow: 0 10px 24px rgba(0,0,0,0.35);
}
.leaflet-popup-content, .leaflet-tooltip.prov-tip {
  font-family: Vazirmatn, sans-serif; margin: 10px 12px;
}
.leaflet-tooltip.prov-tip { border-radius: 8px; padding: 8px 10px; }

@media (max-width: 980px) {
  .grid-2 { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .top { flex-direction: column; align-items: stretch; }
  .meta-col { text-align: right; }
  .chips { justify-content: flex-start; }
  #map { height: 300px; }
}
@media (max-width: 560px) {
  .kpis { grid-template-columns: 1fr; }
  h1 { font-size: 1.35rem; }
  .app { padding: 12px 10px 36px; }
  .filters { padding: 10px; }
}

/* Permanent province names — dark canvas, no tile/API watermark */
.leaflet-tooltip.prov-label,
.prov-name {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  color: #f3ead6;
  font-family: Vazirmatn, Tahoma, sans-serif;
  font-weight: 700;
  font-size: 11px;
  line-height: 1.2;
  text-align: center;
  text-shadow:
    0 0 4px #10120f,
    0 1px 2px #000,
    0 0 8px #10120f,
    1px 1px 0 #10120f,
    -1px -1px 0 #10120f;
  pointer-events: none !important;
  white-space: nowrap;
}
.leaflet-tooltip.prov-label::before { display: none; }
.prov-name span { display: inline-block; padding: 0 2px; }

.row-census td { color: var(--muted); }
.row-empty td { color: #6e6858; font-style: italic; }
.cov-bar {
  height: 8px; background: #2c3329; border-radius: 99px; min-width: 72px; position: relative;
}
.cov-bar > i {
  position: absolute; top: 0; bottom: 0; right: 0;
  background: linear-gradient(90deg, #d7b56d, #f0d48a);
  border-radius: 99px;
}
.note-dk { font-size: 0.75rem; color: var(--muted); margin-top: 8px; }

tr.pin-sub td { color: var(--muted); font-size: 0.92em; background: var(--bg-2); }
tr.pin-sub td:nth-child(4) { padding-right: 1.4rem; }

.btn-export {
  display: inline-block; text-decoration: none; padding: 7px 12px;
  border: 1px solid var(--gold); color: var(--gold-2); border-radius: 8px;
  font-size: 0.85rem;
}
.btn-export:hover { background: #2a2618; }

.quality-strip {
  display: flex; flex-wrap: wrap; gap: 10px; margin: 0 0 16px;
}
.quality-strip .q {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 12px; min-width: 120px;
}
.quality-strip .q .n { color: var(--gold-2); font-weight: 700; font-size: 1.1rem; }
.quality-strip .q .l { color: var(--muted); font-size: 0.75rem; }

.sku-grid {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin-top: 8px;
}
.sku-card {
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px;
}
.sku-card h3 { margin: 0 0 6px; font-size: 0.95rem; color: var(--gold-2); }
.sku-card .big { font-size: 1.35rem; font-weight: 700; color: var(--gold); }
.sku-card .per100 { color: var(--gold-2); font-weight: 600; }
.sku-card a { color: var(--info); }

.heat {
  text-align: center !important; font-variant-numeric: tabular-nums;
}
.col-per100 { color: var(--gold-2); font-weight: 600; }

.h-bar { display: grid; grid-template-columns: 88px 1fr 52px; gap: 8px; align-items: center; margin: 6px 0; }
.h-bar .fill { height: 10px; background: #2c3329; border-radius: 99px; position: relative; }
.h-bar .fill > i {
  position: absolute; top: 0; bottom: 0; right: 0;
  background: linear-gradient(90deg, #d7b56d, #f0d48a); border-radius: 99px;
}
.h-bar .nm { font-size: 0.8rem; }
.h-bar.ours .nm { color: var(--gold-2); }

.boxrow { display: grid; grid-template-columns: 88px 1fr 70px; gap: 8px; align-items: center; margin: 8px 0; }
.boxtrack { position: relative; height: 14px; background: #2c3329; border-radius: 99px; }
.boxspan {
  position: absolute; top: 3px; bottom: 3px;
  background: rgba(215,181,109,0.35); border-radius: 99px;
}
.boxmed {
  position: absolute; top: 0; bottom: 0; width: 3px; background: var(--gold-2);
  border-radius: 2px;
}

.anom-col { margin-bottom: 12px; }
.anom-col h3 { margin: 0 0 6px; font-size: 0.85rem; color: var(--gold); }
.anom-col a { color: var(--info); }

.unit-toggle { display: flex; gap: 8px; }
@media (max-width: 1100px) {
  .sku-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  .sku-grid { grid-template-columns: 1fr; }
}


#map { height: 480px; }
.store-legend {
  display: flex; gap: 14px; flex-wrap: wrap;
  font-size: 0.78rem; color: var(--muted); margin: 0 0 8px;
}
.store-legend i {
  display: inline-block; width: 10px; height: 10px; border-radius: 50%;
  margin-left: 5px; vertical-align: -1px;
}
.store-legend .lg-mahgol { background: #d7b56d; border: 1px solid #f0d48a; }
.store-legend .lg-butter { background: transparent; border: 2px solid #7aa3c4; }
.store-legend .lg-census { background: #2a2a24; border: 1px solid #5a5648; }

.store-cluster {
  background: rgba(215, 181, 109, 0.28);
  border: 2px solid #d7b56d;
  border-radius: 50%;
  color: #f0d48a;
  font-family: Vazirmatn, Tahoma, sans-serif;
  font-weight: 700;
  font-size: 12px;
  text-align: center;
  line-height: 32px;
}
.leaflet-marker-icon.store-cluster {
  margin-left: -18px !important;
  margin-top: -18px !important;
}

.store-panel {
  margin-top: 12px;
  background: var(--bg-2);
  border: 1px solid var(--gold);
  border-radius: 12px;
  padding: 12px;
}
.store-panel[hidden] { display: none !important; }
.store-h { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.store-h h3 { margin: 0; color: var(--gold-2); font-size: 1rem; }
.store-meta { color: var(--muted); font-size: 0.85rem; margin: 8px 0; line-height: 1.7; }
.store-vs {
  background: #2a2618; border-radius: 8px; padding: 8px 10px;
  margin: 8px 0; color: var(--gold-2); font-size: 0.85rem;
}
.store-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: #2a2618; border: 1px solid var(--gold);
  color: var(--gold-2); border-radius: 999px; padding: 4px 10px;
  font-size: 0.8rem;
}
.store-chip[hidden] { display: none !important; }
.store-chip button {
  font-family: inherit; background: transparent; border: 0;
  color: var(--gold-2); cursor: pointer; padding: 0 2px;
}
.marker-selected { filter: drop-shadow(0 0 6px #f0d48a); }


.leaflet-pane.leaflet-labels-pane { transition: opacity 0.25s ease; }

.leaflet-div-icon.store-dot,
.store-dot {
  background: transparent !important;
  border: none !important;
  padding: 0 !important;
}
.store-dot span {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  box-sizing: border-box;
}
.store-dot-mahgol span {
  background: #d7b56d;
  border: 1.5px solid #f0d48a;
  box-shadow: 0 0 0 1px #10120f;
}
.store-dot-butter span {
  background: #1c211b;
  border: 2px solid #7aa3c4;
}
.store-dot-census span {
  background: #2a2a24;
  border: 1px solid #5a5648;
}
.store-dot.is-sel span {
  box-shadow: 0 0 0 2px #f0d48a;
}
