/* WIZI Premium Market Data
   Layout: deep-navy hero band (wordmark, tagline, latest-month KPI strip), sticky pill-tab section nav,
   then light sections on the portal ground, max content width 1180px. Phone: one column, tabs scroll sideways.
   Tokens follow docs/site-spec.md (light = portal values, dark = derived, same hues). */

:root {
  --navy: #0B2138;
  --navy-2: #15365C;
  --navy-3: #06182B;
  --bg: #FAFBFD;
  --surface: #FFFFFF;
  --surface-2: #F2F6FB;
  --tint: #EAF1F8;
  --ink: #11203A;
  --ink-2: #42526B;
  --muted: #5C6B85;
  --line: #E1E8F1;
  --brand: #1E50A8;
  --brand-soft: #A6C6FF;
  --sky: #28A8E9;
  --cream: #F2ECDD;
  --gold: #FFDFA8;
  --up: #1F7A4D;
  --down: #B23A2E;
  --on-brand: #FFFFFF;
  /* fixed colours on the navy hero band (same in both themes) */
  --hero-cta: #1E50A8;
  --hero-up: #7EE0AE;
  --hero-down: #FFA59C;
  --hero-sky: #28A8E9;
  /* chart series: 1 brand (Title Deed / Combined / Apartments), 2 sky (Oqood / New), 3 villas / Renew */
  --s3: #15365C;
  --s4: #A6C6FF;
  --s5: #9AA8BE;
  --s6: #A8741A;               /* 6th series (gold): mortgages and land charts; 4.1:1 on white */
  --scroll-shade: rgba(11, 33, 56, .24);   /* table scroll hint: a shadow at the edge with more columns */
  --up-bg: rgba(31, 122, 77, .10);
  --down-bg: rgba(178, 58, 46, .10);
  --shadow: 0 24px 44px -30px rgba(12, 35, 64, .4);
  --focus: #1E50A8;            /* 7.3:1 on the page ground (the sky blue was 2.6:1) */
  --control-border: #7D8DA6;   /* borders of inputs, pills and buttons: >= 3:1 on surface and surface-2 */

  --font-display: "Playfair Display", "Iowan Old Style", Georgia, "Times New Roman", serif;
  --font-body: "Onest", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --radius-card: 16px;
  --radius-pill: 40px;
  --maxw: 1180px;
  --gutter: 16px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --navy: #0B2138;
    --navy-2: #15365C;
    --navy-3: #06182B;
    --bg: #06182B;
    --surface: #0B2138;
    --surface-2: #11294A;
    --tint: #15365C;
    --ink: #EEF2F8;
    --ink-2: #B9C5D8;
    --muted: #8C9BB3;
    --line: #1F3A5E;
    --brand: #6E9BEA;
    --brand-soft: #A6C6FF;
    --sky: #4CBBF0;
    --cream: #F2ECDD;
    --gold: #FFDFA8;
    --up: #4CC38A;
    --down: #F0857A;
    --on-brand: #06182B;
    --s3: #E9E1CC;
    --s4: #A6C6FF;
    --s5: #7D8FAE;
    --s6: #E0AE52;
    --scroll-shade: rgba(166, 198, 255, .26);   /* dark ground: a light glow, a dark shadow was invisible */
    --up-bg: rgba(76, 195, 138, .14);
    --down-bg: rgba(240, 133, 122, .14);
    --shadow: 0 24px 44px -30px rgba(0, 0, 0, .7);
    --focus: #4CBBF0;
    --control-border: #5C7BA6;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --navy: #0B2138;
  --navy-2: #15365C;
  --navy-3: #06182B;
  --bg: #06182B;
  --surface: #0B2138;
  --surface-2: #11294A;
  --tint: #15365C;
  --ink: #EEF2F8;
  --ink-2: #B9C5D8;
  --muted: #8C9BB3;
  --line: #1F3A5E;
  --brand: #6E9BEA;
  --brand-soft: #A6C6FF;
  --sky: #4CBBF0;
  --cream: #F2ECDD;
  --gold: #FFDFA8;
  --up: #4CC38A;
  --down: #F0857A;
  --on-brand: #06182B;
  --s3: #E9E1CC;
  --s4: #A6C6FF;
  --s5: #7D8FAE;
  --s6: #E0AE52;
  --scroll-shade: rgba(166, 198, 255, .26);   /* dark ground: a light glow, a dark shadow was invisible */
  --up-bg: rgba(76, 195, 138, .14);
  --down-bg: rgba(240, 133, 122, .14);
  --shadow: 0 24px 44px -30px rgba(0, 0, 0, .7);
  --focus: #4CBBF0;
  --control-border: #5C7BA6;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 72px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  overflow-x: hidden;
}
img, svg, canvas { max-width: 100%; }
[hidden] { display: none !important; }
a { color: var(--brand); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.hero :focus-visible { outline-color: var(--hero-sky); }   /* on the navy band the light focus colour is too dark */
button { font: inherit; color: inherit; }
.mono, .num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip {
  position: absolute; left: 16px; top: -60px; z-index: 50; background: var(--surface); color: var(--ink);
  padding: 8px 14px; border-radius: var(--radius-pill);
}
.skip:focus { top: 12px; }

.wrap { max-width: var(--maxw); margin-inline: auto; padding-inline: var(--gutter); }

/* ---------- Hero (navy in both themes) ---------- */
.hero {
  background: radial-gradient(120% 140% at 85% -10%, var(--navy-2) 0%, var(--navy) 52%, var(--navy-3) 100%);
  color: var(--cream);
  padding-block: 18px 34px;
}
.topbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px 20px; }
.brand { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; text-decoration: none; color: var(--cream); }
.wordmark { font-family: var(--font-body); font-weight: 600; letter-spacing: .32em; font-size: 15px; }
.brand-label {
  font-family: var(--font-mono); font-size: 11px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--gold); border-left: 1px solid rgba(242, 236, 221, .3); padding-left: 14px;
}
.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.seg {
  display: inline-flex; border: 1px solid rgba(242, 236, 221, .28); border-radius: var(--radius-pill); padding: 3px;
}
.seg button {
  border: 0; background: transparent; color: var(--cream); padding: 5px 11px; border-radius: var(--radius-pill);
  font-size: 13px; font-weight: 500; cursor: pointer; line-height: 1.3; min-height: 30px;
}
.seg button[aria-pressed="true"] { background: var(--cream); color: var(--navy); }
.seg button:hover:not([aria-pressed="true"]) { background: rgba(242, 236, 221, .12); }
.rate { font-family: var(--font-mono); font-size: 11px; color: rgba(242, 236, 221, .75); letter-spacing: .02em; }
.icon-btn {
  border: 1px solid rgba(242, 236, 221, .28); background: transparent; color: var(--cream); border-radius: var(--radius-pill);
  padding: 5px 12px; font-size: 13px; cursor: pointer; min-height: 38px;
}
.icon-btn:hover { background: rgba(242, 236, 221, .12); }
.cta {
  display: inline-flex; align-items: center; gap: 6px; background: var(--brand); color: var(--on-brand); text-decoration: none;
  border-radius: var(--radius-pill); padding: 8px 16px; font-size: 14px; font-weight: 500; min-height: 38px;
}
.hero .cta { background: var(--hero-cta); color: var(--cream); }
.cta:hover { filter: brightness(1.1); }

.hero-copy { margin-top: 44px; max-width: 860px; }
.eyebrow {
  font-family: var(--font-mono); font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--gold);
  margin: 0 0 14px;
}
.hero h1 {
  font-family: var(--font-display); font-weight: 500; letter-spacing: -1px; line-height: 1.06;
  font-size: clamp(36px, 5.5vw, 64px); margin: 0; text-wrap: balance; color: var(--cream);
}
.hero .lede { margin: 18px 0 0; max-width: 640px; color: rgba(242, 236, 221, .82); font-size: 16.5px; }

.kpis {
  margin-top: 34px; display: grid; gap: 1px; grid-template-columns: repeat(4, minmax(0, 1fr));   /* 8 tiles: 2 rows */
  background: rgba(242, 236, 221, .14); border: 1px solid rgba(242, 236, 221, .14); border-radius: var(--radius-card);
  overflow: hidden;
}
.kpi { background: var(--navy); padding: 16px 16px 14px; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.kpi-label {
  font-family: var(--font-body); font-size: 12.5px; letter-spacing: 0; text-transform: none; font-weight: 500;
  color: rgba(242, 236, 221, .78); line-height: 1.35; min-height: 2.7em;
}
.kpi-value { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 22px; font-weight: 500; color: var(--cream); line-height: 1.2; overflow-wrap: anywhere; }
.kpi-num { white-space: nowrap; }
.kpi-num.brk { white-space: normal; }   /* the sales-value tile may break before the currency on narrow phones */
/* the unit sits on its own line so that long units ("AED/sq ft per year") never overflow a narrow tile */
.kpi-unit { display: block; font-family: var(--font-body); font-size: 12px; color: rgba(242, 236, 221, .7); font-weight: 400; line-height: 1.3; overflow-wrap: anywhere; }
.kpi-sub { font-size: 12px; color: rgba(242, 236, 221, .72); font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.kpi .spark { height: 30px; width: 100%; margin-top: auto; }
.kpi-sub .up { color: var(--hero-up); }
.kpi-sub .down { color: var(--hero-down); }
.split { display: flex; height: 8px; border-radius: 6px; overflow: hidden; margin-top: 8px; background: rgba(242, 236, 221, .14); }
.split span:first-child { background: var(--brand-soft); }
.split span:last-child { background: var(--hero-sky); }
.split-legend { display: flex; justify-content: space-between; gap: 6px; font-size: 11.5px; font-family: var(--font-mono); color: rgba(242, 236, 221, .78); margin-top: 6px; }
.hero-note { margin: 14px 0 0; font-size: 12.5px; color: rgba(242, 236, 221, .66); max-width: 860px; }
.spark-hero .line { stroke: var(--brand-soft); }
.spark-hero .area { fill: rgba(166, 198, 255, .14); }
.spark-hero .dot { fill: var(--gold); stroke: var(--navy); }

/* ---------- Section nav ---------- */
.secnav {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; background: var(--bg);
  border-bottom: 1px solid var(--line);
}
/* the tabs start at the content's left edge and may use the right margin (11 tabs, Russian labels are ~100 px longer);
   when they still do not fit, the hidden side fades out (fade-l / fade-r set by app.js) and the active tab is scrolled into view */
.secnav ul {
  list-style: none; margin: 0; display: flex; gap: 2px;
  padding: 10px 0 10px max(var(--gutter), calc((100% - var(--maxw)) / 2 + var(--gutter)));
  overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain;
}
.secnav ul.fade-r { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 48px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 48px), transparent); }
.secnav ul.fade-l { -webkit-mask-image: linear-gradient(to right, transparent, #000 48px); mask-image: linear-gradient(to right, transparent, #000 48px); }
.secnav ul.fade-l.fade-r {
  -webkit-mask-image: linear-gradient(to right, transparent, #000 48px, #000 calc(100% - 48px), transparent);
          mask-image: linear-gradient(to right, transparent, #000 48px, #000 calc(100% - 48px), transparent);
}
.secnav ul::-webkit-scrollbar { display: none; }
.secnav a {
  display: inline-block; white-space: nowrap; text-decoration: none; color: var(--ink-2); font-size: 14px; font-weight: 500;
  padding: 7px 10px; border-radius: var(--radius-pill); border: 1px solid transparent;
}
.secnav a:hover { background: var(--tint); color: var(--ink); }
.secnav a[aria-current="true"] { background: var(--brand); color: var(--on-brand); }
.secnav li:last-child { padding-right: var(--gutter); }   /* space after the last tab: own padding, which Safari keeps in the scroll range */

/* ---------- Sections ---------- */
main { padding-block: 8px 40px; }
.section { padding-block: 44px 8px; }
.section + .section { border-top: 1px solid var(--line); margin-top: 32px; }
.sec-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 10px 24px; margin-bottom: 20px; }
.sec-kicker {
  font-family: var(--font-mono); font-size: 11.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--brand);
  margin: 0 0 6px;
}
.section h2 {
  font-family: var(--font-display); font-weight: 500; font-size: clamp(28px, 3.6vw, 40px); letter-spacing: -.5px;
  line-height: 1.1; margin: 0; text-wrap: balance;
}
.sec-intro { max-width: 680px; color: var(--ink-2); margin: 10px 0 0; }
.section h3 { font-family: var(--font-body); font-size: 18px; font-weight: 600; margin: 0; line-height: 1.35; text-wrap: balance; }

.grid { display: grid; gap: 20px; }
.grid > * { min-width: 0; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stack { display: grid; gap: 20px; }
.stack > * { min-width: 0; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-card); box-shadow: var(--shadow);
  padding: 20px; min-width: 0;
}
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; margin-bottom: 12px; }
.card-head > div { min-width: 0; }
.card-sub { color: var(--muted); font-size: 13.5px; margin: 2px 0 0; }

.note {
  font-size: 13px; color: var(--muted); margin: 12px 0 0; line-height: 1.55; max-width: 820px;
}
.note::before {
  content: attr(data-label); font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--ink-2); margin-right: 8px;
}
.note a { color: var(--brand); }
details.note-box { margin: 10px 0 0; }
details.note-box > summary {
  cursor: pointer; list-style: none; display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--brand);
  font-weight: 500; padding: 4px 0; min-height: 32px;
}
details.note-box > summary::-webkit-details-marker { display: none; }
details.note-box > summary::after { content: "▸"; font-size: 11px; transition: transform .15s; }
details.note-box[open] > summary::after { transform: rotate(90deg); }
details.note-box > .note { margin-top: 4px; }
details.note-box > .note::before { content: none; }
details.hero-note-box > summary { color: rgba(242, 236, 221, .78); }

.chart-box { position: relative; height: 300px; width: 100%; }
.chart-box.tall { height: 340px; }
.chart-box.short { height: 220px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--ink-2); margin: 0 0 10px; padding: 0; list-style: none; }
.legend li { display: inline-flex; align-items: center; gap: 7px; }
.legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.legend i.ln { height: 3px; border-radius: 2px; width: 16px; }
.legend i.dash { background: transparent !important; border-top: 3px dashed var(--s4); height: 0; }

/* chips & pills */
.pills { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.pill {
  border: 1px solid var(--control-border); background: var(--surface); color: var(--ink-2); border-radius: var(--radius-pill);
  padding: 5px 13px; font-size: 13px; font-weight: 500; cursor: pointer; line-height: 1.35; min-height: 32px;
}
.pill:hover { border-color: var(--brand); color: var(--ink); }
.pill[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.pill:disabled { opacity: .45; cursor: not-allowed; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-bottom: 12px; }
.toolbar .fl { font-family: var(--font-body); font-size: 12.5px; color: var(--muted); }
.search {
  flex: 1 1 220px; min-width: 0; max-width: 360px; border: 1px solid var(--control-border); background: var(--surface-2); color: var(--ink);
  border-radius: var(--radius-pill); padding: 8px 16px; font: inherit; font-size: 14px; min-height: 38px;
}
.search::placeholder { color: var(--muted); }
select.sel {
  border: 1px solid var(--control-border); background: var(--surface-2); color: var(--ink); border-radius: var(--radius-pill);
  padding: 7px 12px; font: inherit; font-size: 14px; min-height: 38px; max-width: 100%;
}

.chip {
  display: inline-flex; align-items: center; gap: 3px; font-family: var(--font-mono); font-variant-numeric: tabular-nums;
  font-size: 12px; padding: 2px 8px; border-radius: var(--radius-pill); white-space: nowrap; line-height: 1.5;
}
.chip.up { color: var(--up); background: var(--up-bg); }
.chip.down { color: var(--down); background: var(--down-bg); }
.chip.flat { color: var(--muted); background: var(--surface-2); }
.chip.na { color: var(--muted); background: transparent; padding-inline: 2px; }
.tag {
  display: inline-block; font-family: var(--font-body); font-size: 12px; font-weight: 500;
  padding: 2px 8px; border-radius: var(--radius-pill); background: var(--tint); color: var(--ink-2); white-space: nowrap;
}
.tag.st-ACTIVE { background: rgba(40, 168, 233, .16); color: var(--ink); }
.tag.st-FINISHED { background: var(--up-bg); color: var(--up); }
.tag.st-NOT_STARTED, .tag.st-PENDING, .tag.st-CONDITIONAL_ACTIVATING, .tag.st-FRIEZED { background: transparent; color: var(--ink-2); padding-inline: 0; }
.tag.st-NOT_IN_REGISTER { background: transparent; color: var(--muted); padding-inline: 0; }
.tag.warn { background: var(--down-bg); color: var(--down); }
.supp { color: var(--muted); font-family: var(--font-mono); font-size: 12.5px; }

/* tables */
/* scroll hint: shadows appear at the edge that has more columns (background-attachment local/scroll trick) */
.table-wrap {
  overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: 12px;
  background:
    linear-gradient(to right, var(--surface) 30%, transparent) left / 40px 100% no-repeat local,
    linear-gradient(to left, var(--surface) 30%, transparent) right / 40px 100% no-repeat local,
    linear-gradient(to right, var(--scroll-shade), transparent) left / 18px 100% no-repeat scroll,
    linear-gradient(to left, var(--scroll-shade), transparent) right / 18px 100% no-repeat scroll,
    var(--surface);
}
/* the first column (community / project / measure) stays visible while the numbers scroll */
table.dt th:first-child, table.dt td:first-child { position: sticky; left: 0; z-index: 1; background: var(--surface); }
table.dt thead th:first-child { z-index: 2; background: var(--surface-2); }
table.dt tbody tr:hover td:first-child { background: var(--surface-2); }
table.dt tbody tr.sel td:first-child { background: var(--tint); }
table.dt tbody tr.grp td:first-child { position: static; }
.detail { scroll-margin-top: 76px; }
table.dt { width: 100%; border-collapse: collapse; font-size: 14px; }
table.dt caption { text-align: left; }
table.dt th, table.dt td { padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
table.dt thead th {
  font-family: var(--font-body); font-size: 12px; letter-spacing: 0; text-transform: none; font-weight: 600;
  color: var(--muted); background: var(--surface-2); white-space: nowrap; position: sticky; top: 0;
}
table.dt th.n, table.dt td.n { text-align: right; }
table.dt td.n { font-family: var(--font-mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
table.dt td.name { min-width: 160px; }
table.dt td.loc { min-width: 190px; }   /* projects: area + DLD name + community in one column */
table.dt tbody tr:last-child td { border-bottom: 0; }
table.dt tbody tr:hover td { background: var(--surface-2); }
table.dt tbody tr.click { cursor: pointer; }
table.dt tbody tr.sel td { background: var(--tint); }
table.dt tbody tr.grp td {
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--brand);
  background: var(--surface); padding-top: 14px;
}
table.dt th button.sort {
  all: unset; cursor: pointer; display: inline-flex; gap: 4px; align-items: center;
}
table.dt th button.sort:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
table.dt th[aria-sort="ascending"] button.sort::after { content: "▲"; font-size: 8px; }
table.dt th[aria-sort="descending"] button.sort::after { content: "▼"; font-size: 8px; }
.tbl-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; font-size: 13px; color: var(--muted); }
.spark { display: block; }
.spark .line { fill: none; stroke: var(--brand); stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round; }
.spark .area { fill: var(--tint); stroke: none; }
.spark .dot { fill: var(--surface); stroke: var(--brand); stroke-width: 1.6; }
.bar-cell { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.bar-cell .b { height: 6px; border-radius: 4px; background: var(--brand); min-width: 2px; }
.prog { width: 64px; height: 6px; background: var(--surface-2); border-radius: 4px; overflow: hidden; display: inline-block; vertical-align: middle; margin-left: 6px; }
.prog i { display: block; height: 100%; background: var(--sky); }

/* stat tiles inside sections */
.tiles { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; min-width: 0; }
.tile .t-label { font-family: var(--font-body); font-size: 12.5px; letter-spacing: 0; text-transform: none; font-weight: 500; color: var(--muted); }
.tile .t-value { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 22px; font-weight: 500; margin-top: 4px; line-height: 1.25; }
.tile .t-sub { font-size: 12.5px; color: var(--ink-2); margin-top: 4px; }

/* net yield calculator */
.calc { display: grid; gap: 14px; }
.calc-row { display: grid; gap: 12px 14px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); align-items: end; }
.calc-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; font-size: 13px; color: var(--ink-2); }
.calc-field.wide { grid-column: span 2; }
.calc-field > span { font-family: var(--font-body); font-size: 12.5px; letter-spacing: 0; text-transform: none; font-weight: 500; color: var(--muted); }
.calc-field .sel { width: 100%; }
.inp[aria-invalid="true"] { border-color: var(--down); box-shadow: 0 0 0 1px var(--down); }
.inp {
  border: 1px solid var(--control-border); background: var(--surface-2); color: var(--ink); border-radius: 10px;
  padding: 8px 12px; font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 14px; min-height: 38px; width: 100%;
}
.calc-out { margin-top: 16px; }
.calc-stats { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.calc-stat { background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.calc-stat .t-label { font-family: var(--font-body); font-size: 12.5px; letter-spacing: 0; text-transform: none; font-weight: 500; color: var(--muted); }
.calc-stat .t-value { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 20px; font-weight: 500; overflow-wrap: anywhere; }
.calc-stat.main { background: var(--tint); border-color: var(--brand); }
.calc-stat.main .t-value { color: var(--brand); font-size: 24px; }
/* "not included: size not entered" in place of a service charge figure */
.calc-stat .t-value .na { font-family: var(--font-body); font-size: 13.5px; color: var(--muted); }
.calc-out .supp { display: block; margin-top: 8px; }
.calc-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-top: 16px; }

/* area names as people say them, the official DLD name small and grey underneath */
.an { display: block; }
.an-dld, .an-ms { display: block; font-size: 12px; color: var(--muted); line-height: 1.3; }
/* the community line under a project area stays on one line (full name on hover): long master names wrapped cells to 4+ lines */
.an-ms { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 250px; }
/* one-line plain-language explanations next to a table (always visible, not folded like the method notes) */
.help { font-size: 13px; color: var(--muted); margin: 0 0 10px; max-width: 820px; }
.tbl-foot + .help { margin: 10px 0 0; }

/* detail panels */
.detail { margin-top: 16px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.detail h4 { margin: 0 0 4px; font-size: 16px; font-weight: 600; }
.detail .chart-box { height: 260px; }
.detail h5 { margin: 18px 0 8px; font-size: 14px; font-weight: 600; color: var(--ink); }
.detail .tiles { margin-top: 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.detail .tile .t-value { font-size: 18px; overflow-wrap: anywhere; }
.detail .tile .t-value .arrow { color: var(--muted); font-weight: 400; }
.detail .tile .t-sub .chip { margin-right: 4px; }
.detail .pd-msg { margin: 10px 0 0; font-size: 14px; color: var(--ink-2); }
.detail .pd-fact { margin: 8px 0 0; font-size: 13.5px; color: var(--ink-2); }
.detail .pd-fact strong { font-weight: 600; color: var(--ink); }
.detail .pd-foot { margin: 8px 0 0; font-size: 12.5px; color: var(--muted); }
.detail .note { margin-bottom: 0; }
/* the bedroom tables in the detail cards keep the scroll hint (they used to cover it with a flat background) and sit
   under the chart at the full card width at every screen width: beside it (half the card) the Russian or AED table did
   not fit even at 1440 px */
.detail .g2 { grid-template-columns: minmax(0, 1fr); }
.detail .tag { white-space: normal; }

/* service charges */
.results { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 4px; max-height: 280px; overflow-y: auto; }
.results button {
  width: 100%; text-align: left; border: 1px solid var(--control-border); background: var(--surface); border-radius: 10px; padding: 8px 12px;
  cursor: pointer; display: flex; justify-content: space-between; gap: 10px; font-size: 14px;
}
.results button:hover, .results button[aria-pressed="true"] { border-color: var(--brand); background: var(--tint); }
.results .r-name { min-width: 0; overflow-wrap: anywhere; }
.results .r-meta { color: var(--muted); font-size: 12.5px; font-family: var(--font-mono); text-align: right; max-width: 45%; overflow-wrap: anywhere; }
.catbars { display: grid; gap: 6px; margin-top: 8px; }
.catbar { display: grid; grid-template-columns: minmax(0, 150px) 1fr auto; gap: 10px; align-items: center; font-size: 13px; }
.catbar .track { height: 8px; background: var(--surface-2); border-radius: 5px; overflow: hidden; }
.catbar .track i { display: block; height: 100%; background: var(--sky); border-radius: 5px; }
.catbar .v { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 12.5px; white-space: nowrap; }

.btn-ghost {
  border: 1px solid var(--control-border); background: var(--surface); color: var(--ink); border-radius: var(--radius-pill); padding: 6px 14px;
  font-size: 13px; cursor: pointer; min-height: 34px;
}
.btn-ghost:hover { border-color: var(--brand); }
.err { background: var(--down-bg); color: var(--down); border-radius: 12px; padding: 12px 14px; font-size: 14px; }
/* a section whose data file is still loading (or failed): one line under the heading */
.sec-status { margin: 0 0 14px; font-size: 14px; color: var(--muted); }
.sec-status.err { color: var(--down); }

/* footer: compact small print (attribution, licence, not-affiliated note, methodology) */
.footer { background: var(--navy-3); color: var(--cream); padding-block: 22px 26px; margin-top: 40px; }
.footer a { color: var(--brand-soft); }
.footer-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px 28px; }
.footer .wordmark { font-size: 12px; color: var(--cream); text-decoration: none; }
.footer-fine { flex: 1 1 420px; min-width: 0; }
.footer p { margin: 0 0 4px; font-size: 12.5px; line-height: 1.5; color: rgba(242, 236, 221, .78); }
.footer ul { list-style: none; padding: 0; margin: 6px 0 0; display: flex; flex-wrap: wrap; gap: 4px 18px; font-size: 12.5px; }

/* report for a client: built into #report on demand, visible only while printing (A4, black on white) */
.report { display: none; }
@media print {
  @page { size: A4; margin: 12mm 13mm; }
  body.printing { background: #fff !important; color: #000; }
  body.printing > *:not(#report) { display: none !important; }
  body.printing #report { display: block !important; font-family: var(--font-body); font-size: 9.6pt; line-height: 1.38; color: #000; }
  #report .rp-head { display: flex; justify-content: space-between; align-items: baseline; border-bottom: 1.5pt solid #000; padding-bottom: 6pt; }
  #report .rp-mark { font-weight: 600; letter-spacing: .32em; font-size: 11pt; }
  #report .rp-date { font-size: 9.5pt; }
  #report h1 { font-family: var(--font-display); font-weight: 500; font-size: 17pt; margin: 10pt 0 3pt; }
  #report h2 { font-size: 10.5pt; font-weight: 600; margin: 10pt 0 3pt; break-after: avoid; page-break-after: avoid; }
  #report h2 + table { break-before: avoid; page-break-before: avoid; }
  #report .rp-prop { margin: 0 0 4pt; }
  #report table { width: 100%; border-collapse: collapse; page-break-inside: avoid; }
  #report th, #report td { text-align: left; padding: 2.6pt 5pt; border-bottom: .5pt solid #777; vertical-align: top; font-weight: 400; }
  #report thead th { font-weight: 600; border-bottom: 1pt solid #000; }
  #report tbody th, #report table:not(.rp-ctx) th { width: 52%; }
  #report td { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
  #report .rp-ctx td:last-child { font-family: var(--font-body); font-size: 8.8pt; }
  #report .rp-res tr:first-child td, #report .rp-res tr:first-child th { font-weight: 600; font-size: 11pt; }
  #report .rp-note, #report .rp-disc, #report .rp-src { font-size: 8.3pt; line-height: 1.35; margin: 7pt 0 0; break-inside: avoid; page-break-inside: avoid; }
  #report .rp-disc { font-weight: 600; }
}

@media (max-width: 900px) {
  .g2, .g3 { grid-template-columns: minmax(0, 1fr); }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  /* phone header: one compact row of switches, the content starts on the first screen */
  .topbar { gap: 10px; }
  .controls { gap: 6px; width: 100%; }
  .seg button { padding: 5px 10px; font-size: 13px; min-height: 32px; }
  .rate, #theme-btn, .hero .topbar .cta { display: none; }
  .hero-copy { margin-top: 18px; }
  .hero h1 { font-size: 34px; }
  .hero .lede { font-size: 15px; }
  .calc-field.wide { grid-column: auto; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-value { font-size: 19px; }
  .card { padding: 16px; }
  .chart-box { height: 250px; }
  .chart-box.tall { height: 280px; }
  .section { padding-block: 34px 4px; }
  .brand-label { border-left: 0; padding-left: 0; }
  table.dt { font-size: 13px; }
  .search, select.sel, .inp { font-size: 16px; }
  #ov-table table.dt th:nth-child(3), #ov-table table.dt td:nth-child(3),
  #ov-table table.dt th:nth-child(5), #ov-table table.dt td:nth-child(5) { display: none; }
  table.dt th, table.dt td { padding: 8px 9px; }
  .catbar { grid-template-columns: minmax(0, 110px) 1fr auto; }
  /* the DLD name stays visible on phones (two DLD areas can share a label): small, one line, ellipsis */
  .an-dld, .an-ms { font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
