:root {
  color-scheme: dark;
  --bg: #0b0d0c;
  --ink: #f2f6f3;
  --muted: #a7b1aa;
  --soft: #d6ddd8;
  --surface: #111512;
  --surface-2: #151b17;
  --surface-3: #1b221d;
  --line: #2b352e;
  --line-strong: #425045;
  --accent: #46d08f;
  --accent-ink: #07130d;
  --warn: #d6b36b;
  --radius: 6px;
  --page: min(1440px, calc(100vw - 48px));
}

* { box-sizing: border-box; }

html { background: var(--bg); }

body {
  margin: 0;
  background:
    linear-gradient(90deg, rgba(70, 208, 143, 0.035) 1px, transparent 1px),
    linear-gradient(rgba(70, 208, 143, 0.025) 1px, transparent 1px),
    var(--bg);
  background-size: 48px 48px;
  color: var(--ink);
  font-family: "Dubai", "IBM Plex Sans Arabic", "Noto Sans Arabic", "Segoe UI", Tahoma, Arial, sans-serif;
  line-height: 1.65;
}

a { color: inherit; text-decoration: none; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  min-height: 68px;
  padding: 12px max(24px, calc((100vw - var(--page)) / 2));
  border-bottom: 1px solid var(--line);
  background: rgba(11, 13, 12, 0.94);
  backdrop-filter: blur(16px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 240px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0;
}

.brand strong {
  display: block;
  font-size: 15px;
  line-height: 1.2;
}

.brand small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

nav {
  display: flex;
  gap: 4px;
  flex-wrap: nowrap;
  white-space: nowrap;
}

nav a {
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 14px;
}

nav a:hover,
nav a:focus-visible {
  border-color: var(--line-strong);
  color: var(--ink);
  outline: 0;
}

main {
  width: var(--page);
  margin-inline: auto;
  padding: 28px 0 56px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(360px, 0.72fr);
  gap: 18px;
  min-height: calc(100dvh - 124px);
  align-items: stretch;
}

.hero-copy,
.page-head,
.report-head {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(17, 21, 18, 0.82);
  padding: clamp(22px, 4vw, 48px);
}

.hero-copy { min-height: 540px; }

.eyebrow {
  margin: 0 0 12px;
  color: var(--accent);
  font-size: 14px;
  font-weight: 700;
}

h1, h2, p { margin-top: 0; }

h1 {
  max-width: 880px;
  margin-bottom: 16px;
  font-size: clamp(42px, 6vw, 88px);
  line-height: 1.02;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 10px;
  font-size: 18px;
  line-height: 1.35;
}

.hero-lede {
  max-width: 640px;
  margin-bottom: 0;
  color: var(--soft);
  font-size: 19px;
}

.decision-form {
  display: grid;
  gap: 14px;
  max-width: 860px;
  margin-top: 30px;
}

.field {
  display: grid;
  gap: 7px;
}

label {
  color: var(--soft);
  font-size: 13px;
  font-weight: 700;
}

textarea,
input {
  width: 100%;
  color: var(--ink);
  background: #0e1210;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 12px 14px;
  font: inherit;
}

textarea::placeholder,
input::placeholder { color: #78837c; }

textarea:focus,
input:focus {
  outline: 2px solid rgba(70, 208, 143, 0.5);
  outline-offset: 2px;
}

.form-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 210px auto;
  gap: 12px;
  align-items: end;
}

button {
  min-height: 51px;
  border: 0;
  border-radius: var(--radius);
  padding: 0 22px;
  color: var(--accent-ink);
  background: var(--accent);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

button:hover { filter: brightness(1.04); }
button:active { transform: translateY(1px); }

.uae-map {
  position: relative;
  min-height: 540px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(70, 208, 143, 0.16), transparent 34%),
    linear-gradient(315deg, rgba(214, 179, 107, 0.13), transparent 28%),
    #0f1411;
  overflow: hidden;
}

.decision-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  opacity: 0.9;
}

.uae-map::before {
  content: "";
  position: absolute;
  z-index: 2;
  inset: 28px;
  border: 1px solid rgba(214, 221, 216, 0.12);
  border-radius: var(--radius);
}

.map-meta {
  position: absolute;
  z-index: 2;
  inset-block-start: 24px;
  inset-inline-end: 24px;
  display: grid;
  gap: 2px;
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: rgba(11, 13, 12, 0.72);
}

.map-meta strong {
  color: var(--accent);
  font-size: 28px;
  line-height: 1;
}

.map-meta span { color: var(--muted); font-size: 12px; }

.map-grid {
  position: relative;
  z-index: 3;
  height: 100%;
  min-height: 540px;
}

.node {
  position: absolute;
  min-width: 92px;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: rgba(21, 27, 23, 0.92);
  color: var(--ink);
  text-align: center;
  font-size: 14px;
  font-weight: 700;
}

.node::before {
  content: "";
  position: absolute;
  inset-inline-start: -7px;
  top: 50%;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  transform: translateY(-50%);
}

.dubai { right: 34%; top: 46%; }
.abudhabi { right: 11%; top: 67%; }
.sharjah { right: 43%; top: 36%; }
.ajman { right: 51%; top: 29%; }
.rak { right: 63%; top: 14%; }
.fujairah { right: 68%; top: 44%; }
.uaq { right: 58%; top: 23%; }

.metrics-band {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 18px 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(17, 21, 18, 0.76);
}

.metrics-band div {
  min-height: 104px;
  padding: 16px 18px;
  border-inline-start: 1px solid var(--line);
}

.metrics-band div:first-child { border-inline-start: 0; }
.metrics-band strong {
  display: block;
  color: var(--warn);
  font-size: 30px;
  line-height: 1.15;
}

.metrics-band span { color: var(--muted); }

.intelligence-strip {
  display: grid;
  grid-template-columns: 0.8fr 1.05fr 0.85fr;
  gap: 18px;
  margin: 18px 0;
}

.intelligence-strip div {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(17, 21, 18, 0.82);
  padding: 16px;
}

.intelligence-strip span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.intelligence-strip strong {
  display: block;
  color: var(--soft);
  margin-top: 4px;
}

.workspace,
.dashboard-grid,
.report-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) minmax(0, 0.82fr);
  gap: 18px;
  align-items: start;
}

.dashboard-grid { grid-template-columns: 1.25fr 0.82fr 0.95fr; }
.report-layout { grid-template-columns: minmax(0, 1.35fr) minmax(340px, 0.65fr); }

.rail,
.panel,
.report-main section,
.source-matrix {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(17, 21, 18, 0.86);
  padding: 16px;
}

.rail {
  display: grid;
  gap: 10px;
}

.rail a {
  display: grid;
  gap: 3px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--soft);
  background: var(--surface-2);
}

.rail a small {
  color: var(--muted);
  font-size: 12px;
}

.rail a:hover,
.rail a:focus-visible {
  border-color: var(--accent);
  outline: 0;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: baseline;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.panel-head h2 { margin: 0; }
.panel-head span { color: var(--muted); font-size: 12px; }

.flow,
.category-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.flow div,
.category-grid div {
  min-height: 76px;
  display: grid;
  align-content: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  background: var(--surface-2);
  color: var(--soft);
}

.category-grid { grid-template-columns: repeat(7, minmax(0, 1fr)); }
.category-grid b { color: var(--accent); font-size: 22px; }
.category-grid span { color: var(--muted); direction: ltr; font-size: 12px; }

.snapshot-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.snapshot-grid div,
.rank-list div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  background: var(--surface-2);
}

.snapshot-grid b,
.rank-list b {
  color: var(--accent);
  font-size: 22px;
  line-height: 1;
}

.snapshot-grid span,
.rank-list span { color: var(--soft); }

.source-matrix {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 18px;
  margin-top: 18px;
}

.source-matrix p {
  margin: 0;
  color: var(--muted);
}

.mini-bars { display: grid; gap: 10px; }

.mini-bars div {
  display: grid;
  grid-template-columns: 140px 1fr 32px;
  gap: 10px;
  align-items: center;
}

meter {
  width: 100%;
  height: 8px;
}

.dense-list,
.source-list {
  display: grid;
  gap: 8px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.dense-list li,
.source-list li {
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}

.dense-list li:last-child,
.source-list li:last-child { border-bottom: 0; padding-bottom: 0; }

.source-list a { color: var(--soft); }
.source-list a:hover { color: var(--accent); }

.source-list small {
  display: block;
  color: var(--muted);
  direction: ltr;
}

.report-head {
  flex-direction: row;
  justify-content: space-between;
  align-items: end;
  gap: 20px;
  margin-bottom: 18px;
}

.report-head h1 {
  max-width: 980px;
  margin-bottom: 0;
  font-size: clamp(34px, 4.8vw, 68px);
  line-height: 1.1;
}

.score {
  min-width: 150px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 14px;
  text-align: center;
  background: var(--surface-2);
}

.score strong {
  display: block;
  color: var(--accent);
  font-size: 48px;
  line-height: 1;
}

.score span { color: var(--muted); }

.report-main {
  display: grid;
  gap: 14px;
}

.report-main p {
  margin-bottom: 0;
  color: var(--soft);
}

.stat-grid,
.budget-grid,
.info-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.stat-grid div,
.budget-grid div,
.info-grid div {
  min-height: 82px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  padding: 10px;
}

.stat-grid b,
.budget-grid b,
.info-grid b {
  display: block;
  color: var(--accent);
  font-size: 22px;
  line-height: 1.2;
}

.stat-grid span,
.budget-grid span,
.info-grid span {
  display: block;
  color: var(--soft);
}

.stat-grid small {
  color: var(--muted);
}

.budget-range {
  display: grid;
  gap: 4px;
  margin-bottom: 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-2);
  padding: 12px;
}

.budget-range strong {
  color: var(--warn);
  font-size: 24px;
}

.budget-range span {
  color: var(--muted);
}

.report-main ul {
  margin: 0;
  padding-inline-start: 22px;
}

.report-main li { margin-bottom: 8px; }
.report-main li:last-child { margin-bottom: 0; }

.report-side {
  display: grid;
  gap: 14px;
}

.rank-list {
  display: grid;
  gap: 8px;
}

@media (prefers-reduced-motion: no-preference) {
  nav a,
  .rail a,
  button,
  textarea,
  input {
    transition: border-color 160ms ease, color 160ms ease, filter 160ms ease, transform 120ms ease;
  }
}

@media (max-width: 1080px) {
  :root { --page: min(100vw - 32px, 1440px); }

  .hero,
  .workspace,
  .dashboard-grid,
  .report-layout,
  .source-matrix {
    grid-template-columns: 1fr;
  }

  .hero-copy,
  .uae-map { min-height: auto; }

  .map-grid { min-height: 420px; }

  .form-row,
  .metrics-band,
  .flow,
  .category-grid {
    grid-template-columns: 1fr;
  }

  .snapshot-grid { grid-template-columns: 1fr; }
  .intelligence-strip,
  .stat-grid,
  .budget-grid,
  .info-grid { grid-template-columns: 1fr; }
  button { width: 100%; }
  .report-head { align-items: stretch; flex-direction: column; }
}

@media (max-width: 680px) {
  :root { --page: min(100vw - 24px, 1440px); }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    min-height: auto;
  }

  nav { width: 100%; overflow-x: auto; }
  main { padding-top: 14px; }

  .hero-copy,
  .page-head,
  .report-head,
  .panel,
  .rail,
  .report-main section,
  .source-matrix {
    padding: 14px;
  }

  h1 { font-size: 38px; }
  .report-head h1 { font-size: 30px; }
  .hero-lede { font-size: 16px; }
}

@media print {
  @page {
    margin: 14mm 12mm;
    /* engines that support margin boxes get page numbers; Chrome uses its own footer */
    @bottom-center { content: "صفحة " counter(page) " / " counter(pages); }
  }

  html, body {
    background: #fff !important;
    color: #111 !important;
    font-size: 11.5pt;
    line-height: 1.5;
  }

  /* hide all chrome + interactive controls */
  .topbar, nav, button, .no-print, .decision-canvas, .uae-map, .map-grid { display: none !important; }
  main { width: auto !important; margin: 0 !important; padding: 0 !important; }

  /* collapse every multi-column grid to a single readable column */
  .report-layout, .report-main, .report-side,
  .stat-grid, .info-grid, .budget-grid, .snapshot-grid, .rank-list, .dense-list {
    display: block !important;
  }
  .report-side { margin-top: 12px; }
  .report-main section, .panel, .stat-grid div, .info-grid div,
  .budget-range, .rank-list div, .snapshot-grid div { margin-bottom: 8px; }

  /* surfaces → clean white cards, no blur/shadow */
  .panel, .report-main section, .score, .report-head,
  .stat-grid div, .info-grid div, .budget-grid div, .budget-range,
  .rank-list div, .snapshot-grid div {
    background: #fff !important;
    border: 1px solid #b9c0ba !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
  }

  /* readable ink in black & white: accents/warns → near-black */
  h1, h2, .eyebrow, .score strong, .stat-grid b, .info-grid b, .budget-grid b,
  .snapshot-grid b, .rank-list b, .budget-range strong, .category-grid b {
    color: #111 !important;
  }
  p, span, small, li, .report-main p, .citation-line, .panel-head span { color: #333 !important; }
  .source-list a, .citation-line a { color: #111 !important; text-decoration: none; }

  /* keep blocks and headings intact across page breaks */
  .report-main section, .panel, .score, .stat-grid div, .info-grid div, li {
    break-inside: avoid;
    page-break-inside: avoid;
  }
  h1, h2 { break-after: avoid; page-break-after: avoid; }

  /* make the printout self-contained: reveal citation URLs */
  .source-list a[href]::after,
  .citation-line a[href]::after {
    content: " (" attr(href) ")";
    font-size: 9pt;
    color: #555;
    word-break: break-all;
  }
}

/* Live-data states: honest errors + citations */
.error-panel {
  border: 1px solid var(--warn);
  background: var(--surface-2);
  margin-bottom: 18px;
}

.error-panel p,
.error-text {
  color: var(--warn);
  font-size: 14px;
  line-height: 1.7;
  margin: 8px 0 0;
}

.citation-line {
  margin: 10px 0 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.7;
}

.citation-line a {
  color: var(--accent);
  text-decoration: none;
}

@media print {
  .error-panel { border-color: #aeb8af; background: #f6f7f4; }
  .error-panel p,
  .error-text { color: #6b5b23; }
  .citation-line { color: #454b46; }
}
