:root {
  --bg: #fbfaf7;
  --surface: #ffffff;
  --ink: #1d2327;
  --muted: #5b6670;
  --line: #e4e1da;
  --accent: #0f6e78;      /* bleu persan */
  --accent-soft: #e3f1f1;
  --on-accent: #ffffff;
  --gold: #b07a1f;
  --warn-bg: #fdf6e7;
  --warn-line: #e8cf95;
  --c1: #0f6e78; --c2: #c2852b; --c3: #6b5ca5; --c4: #3f8f4f; --c5: #b8504b; --c6: #8a96a0;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121618; --surface: #1a2023; --ink: #e8ecee; --muted: #9aa6ae; --line: #2c3539;
    --accent: #4fb5bf; --accent-soft: #17302f; --on-accent: #0b1a1c; --gold: #d9a54c;
    --warn-bg: #2a2416; --warn-line: #5c4a22;
    --c1: #4fb5bf; --c2: #e0a14a; --c3: #9d8fd6; --c4: #6cbf7a; --c5: #e07b74; --c6: #8f9ba3;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121618; --surface: #1a2023; --ink: #e8ecee; --muted: #9aa6ae; --line: #2c3539;
  --accent: #4fb5bf; --accent-soft: #17302f; --on-accent: #0b1a1c; --gold: #d9a54c;
  --warn-bg: #2a2416; --warn-line: #5c4a22;
  --c1: #4fb5bf; --c2: #e0a14a; --c3: #9d8fd6; --c4: #6cbf7a; --c5: #e07b74; --c6: #8f9ba3;
  color-scheme: dark;
}

@font-face { font-family: Vazirmatn; src: url("fonts/Vazirmatn.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 72px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 17px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow-x: hidden;
}
a { color: var(--accent); text-underline-offset: 2px; }
.wrap { max-width: 980px; margin: 0 auto; padding: 0 16px; }

.hero .wrap { max-width: 1200px; }
.hero { background: var(--accent-soft); border-bottom: 1px solid var(--line); padding: 48px 0 32px; }
.kicker { margin: 0 0 6px; color: var(--muted); font-size: 14px; }
h1 { margin: 0 0 12px; font-size: clamp(30px, 6vw, 44px); line-height: 1.1; letter-spacing: -0.01em; }
.lead { margin: 0; max-width: 680px; font-size: 18px; color: var(--ink); }

[lang="fa"] body { font-family: Vazirmatn, Tahoma, sans-serif; line-height: 1.85; }
[lang="fa"] h1, [lang="fa"] h2, [lang="fa"] h3 { line-height: 1.5; letter-spacing: 0; }
.ltr { direction: ltr; unicode-bidi: isolate; }
.hero-actions { margin: 20px 0 0; display: flex; flex-wrap: wrap; gap: 10px; }
.btn { display: inline-flex; padding: 10px 18px; border-radius: 999px; background: var(--accent); color: var(--on-accent); text-decoration: none; font-weight: 600; font-size: 15px; }
.btn.ghost { background: transparent; color: var(--accent); border: 1px solid var(--accent); }

/* ─── Barre du haut ─── */
.topbar { position: sticky; top: 0; z-index: 1200; height: 56px; display: flex; align-items: center; gap: 12px; padding: 0 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
.tb-brand { font-weight: 700; color: var(--ink); text-decoration: none; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-links { margin-inline-start: auto; display: flex; align-items: center; gap: 4px; }
.tb-links a { color: var(--muted); text-decoration: none; font-size: 15px; padding: 6px 10px; border-radius: 8px; white-space: nowrap; }
.tb-links a:hover { background: var(--accent-soft); color: var(--accent); }
.tb-links .tb-lang { border: 1px solid var(--accent); color: var(--accent); border-radius: 999px; padding: 4px 12px; }
.tb-icon { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; padding: 0; border: 0; border-radius: 10px; background: transparent; color: var(--muted); cursor: pointer; }
.tb-links a.tb-icon { padding: 0; }
.tb-icon:hover { background: var(--accent-soft); color: var(--accent); }
.tb-theme .i-sun { display: none; }
:root[data-theme="dark"] .tb-theme .i-sun { display: block; }
:root[data-theme="dark"] .tb-theme .i-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .tb-theme .i-sun { display: block; }
  :root:not([data-theme="light"]) .tb-theme .i-moon { display: none; }
}
.btn { display: inline-flex; align-items: center; gap: 8px; }
.tb-menu { display: none; border: 0; background: transparent; color: var(--ink); padding: 6px; margin-inline-start: -6px; border-radius: 8px; cursor: pointer; }

/* ─── Mise en page : menu latéral + contenu ─── */
.layout { max-width: 1200px; margin: 0 auto; padding: 0 16px; display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 40px; }
main { min-width: 0; max-width: 900px; }
.sidebar { position: sticky; top: 56px; align-self: start; max-height: calc(100vh - 56px); overflow-y: auto; padding: 28px 0 24px; }
.sb-head { display: flex; justify-content: space-between; align-items: center; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 8px; padding-inline-start: 12px; }
.sb-close { display: none; font-size: 26px; line-height: 1; border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 4px 8px; }
.sidebar ol { list-style: none; margin: 0; padding: 0; counter-reset: s; }
.sidebar li { margin: 0; counter-increment: s; }
.sidebar a { display: flex; gap: 10px; padding: 8px 12px; border-radius: 8px; color: var(--ink); text-decoration: none; font-size: 15px; border-inline-start: 3px solid transparent; }
.sidebar a::before { content: counter(s); color: var(--muted); font-variant-numeric: tabular-nums; min-width: 1.2em; }
[lang="fa"] .sidebar a::before { content: counter(s, persian); }
.sidebar a:hover { background: var(--accent-soft); }
.sidebar a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; border-inline-start-color: var(--accent); }
.sb-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 1250; }

section { padding: 40px 0 8px; border-bottom: 1px solid var(--line); }
section:last-of-type { border-bottom: 0; }
h2 { font-size: 28px; line-height: 1.2; margin: 0 0 16px; }
h3 { font-size: 19px; margin: 28px 0 10px; }
ul, ol { padding-inline-start: 22px; }
li { margin: 6px 0; }

.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 4px; }
.kpi .v { font-size: 30px; font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; line-height: 1.1; }
.kpi .l { font-size: 15px; color: var(--ink); }
.kpi .s { font-size: 13px; color: var(--muted); margin-top: auto; }

.callout { background: var(--surface); border: 1px solid var(--line); border-inline-start: 4px solid var(--accent); border-radius: 10px; padding: 4px 20px 12px; margin: 24px 0; }
.callout h3 { margin-top: 16px; }
.defs dt { font-weight: 700; margin-top: 10px; }
.defs dd { margin: 2px 0 0; }
.callout.alert { border-inline-start-color: var(--c5); padding: 12px 20px; }
.callout.alert p { margin: 0; }
h4 { font-size: 16px; margin: 20px 0 6px; }
.warn { background: var(--warn-bg); border: 1px solid var(--warn-line); border-radius: 10px; padding: 12px 16px; font-size: 16px; }

.card { margin: 16px 0 24px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px; min-width: 0; }
.card figcaption { font-weight: 600; margin-bottom: 12px; }
.chart { position: relative; height: 340px; }
.chart.short { height: 260px; }
.src { font-size: 13.5px; color: var(--muted); margin: 10px 0 0; line-height: 1.5; }

.hint { font-size: 14px; color: var(--muted); background: var(--accent-soft); border-radius: 8px; padding: 8px 12px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; padding: 2px; margin-bottom: 10px; }
.seg button { font: inherit; font-size: 14px; border: 0; background: transparent; color: var(--muted); padding: 5px 14px; border-radius: 999px; cursor: pointer; }
.seg-wrap { display: flex; flex-wrap: wrap; border-radius: 14px; gap: 2px; }
.seg button.on { background: var(--accent); color: var(--on-accent); }
.explore .yr { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.explore input[type=range] { width: 100%; accent-color: var(--accent); }
.explore-in { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: center; }
.explore-in .facts li { display: flex; justify-content: space-between; gap: 10px; }
.explore-in .facts i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-inline-end: 6px; }
@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .tb-menu { display: inline-flex; }
  .sidebar { position: fixed; top: 0; bottom: 0; inset-inline-start: 0; width: min(300px, 85vw); height: 100vh; height: 100dvh; max-height: none; z-index: 1300; background: var(--surface); padding: 12px 12px 24px; box-shadow: 0 0 24px rgba(0,0,0,.2); transform: translateX(-105%); transition: transform .25s ease; }
  [dir="rtl"] .sidebar { transform: translateX(105%); }
  body.sb-open .sidebar { transform: none; }
  .sb-close { display: block; }
}
@media (max-width: 560px) {
  .tb-links a:not(.tb-lang):not(.tb-icon) { display: none; }
}
@media (max-width: 760px) { .explore-in { grid-template-columns: 1fr; } }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin: 20px 0; }
.grid3 .card { margin: 0; }
.grid3 h3 { margin-top: 0; font-size: 17px; }
.grid3 ul { font-size: 15px; }
table.wrap-cells td, table.wrap-cells th { white-space: normal; min-width: 180px; }
@media (max-width: 1100px) { .grid3 { grid-template-columns: 1fr; } }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.grid2 > * { min-width: 0; }
.facts { list-style: none; padding: 0; }
.facts li { padding: 10px 0; border-bottom: 1px solid var(--line); }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); margin: 8px 0; }
table { border-collapse: collapse; width: 100%; font-size: 15px; }
th, td { padding: 8px 12px; text-align: start; border-bottom: 1px solid var(--line); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
th { font-size: 13px; color: var(--muted); font-weight: 600; }
.n { text-align: end; font-variant-numeric: tabular-nums; }

#map { height: 460px; border-radius: 8px; background: var(--bg); }
.leaflet-container { font: inherit; background: var(--bg); direction: ltr; }
.leaflet-tooltip { direction: auto; unicode-bidi: plaintext; }
.leaflet-bar a, .leaflet-bar a:hover { background: var(--surface); color: var(--ink); border-bottom-color: var(--line); }
.leaflet-bar { border-color: var(--line) !important; }
.leaflet-tooltip { background: var(--surface); color: var(--ink); border-color: var(--line); }
.leaflet-tooltip-top:before { border-top-color: var(--surface); }
.map-tools { display: flex; gap: 6px; margin-bottom: 10px; }
.map-tools button { font: inherit; font-size: 14px; padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; }
.map-tools button.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--muted); margin-top: 10px; align-items: center; }
.legend i { display: inline-block; width: 14px; height: 14px; border-radius: 3px; vertical-align: -2px; margin-inline-end: 5px; }
.legend .dot { border-radius: 50%; background: var(--gold); opacity: .8; }
.leaflet-tooltip { font-size: 13px; }

.docs { list-style: none; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.docs li { margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; }
.docs .t { font-weight: 600; }
.docs .m { font-size: 13px; color: var(--muted); }
.docs .a { display: flex; gap: 14px; font-size: 14px; }

.refs li { font-size: 15px; }
.refs li:target, .kpi:target { background: var(--accent-soft); }

.fab {
  position: fixed; inset-inline-end: 16px; bottom: 16px; z-index: 1100;
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--accent); color: var(--on-accent); text-decoration: none; font-weight: 600; font-size: 15px;
  padding: 10px 16px; border-radius: 999px; box-shadow: 0 4px 14px rgba(0,0,0,.18);
}
footer { padding: 32px 0 80px; color: var(--muted); font-size: 14px; }

@media (max-width: 760px) {
  body { font-size: 16px; }
  .hero { padding: 32px 0 24px; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .kpi .v { font-size: 24px; }
  .grid2, .docs { grid-template-columns: 1fr; }
  .chart { height: 300px; }
  #map { height: 380px; }
  h2 { font-size: 24px; }
}
@media (max-width: 400px) { .kpis { grid-template-columns: 1fr; } }

@media print {
  .layout { display: block; padding: 0; }
  main { max-width: none; }
  .topbar, .sidebar, .sb-overlay, .fab, .map-tools, .hint, .seg, .explore .yr, .hero-actions, .leaflet-control-zoom { display: none; }
  #map { height: 520px; }
  th, td { white-space: normal; }
  .table-wrap { overflow: visible; }
  section { break-inside: auto; }
  .card { break-inside: avoid; }
  body { background: #fff; }
}
