/* Salah Analytics — modern light theme.
   Color roles follow the validated dataviz reference palette (light mode). */

:root {
  color-scheme: light;
  --plane: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --series-1: #2a78d6;  /* blue  — early bird / primary */
  --series-2: #eb6834;  /* orange — discounted price */
  --series-3: #1baf7a;  /* aqua  — normal booking */
  --series-4: #8a5cd6;  /* purple — pre-booking */
  --meter-track: #cde2fb;
  --good-text: #006300;
  --danger: #d03b3b;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.04), 0 4px 16px rgba(11, 11, 11, 0.05);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { background: var(--plane); color: var(--ink); font-size: 14.5px; line-height: 1.45; }
h1, h2 { margin: 0; font-weight: 650; }
[hidden] { display: none !important; }

/* ---------- Buttons & forms ---------- */

.btn {
  font: inherit; font-weight: 550; cursor: pointer;
  border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 16px; background: var(--surface); color: var(--ink);
  transition: background .12s, border-color .12s;
}
.btn:hover { background: #f2f1ee; }
.btn-primary { background: var(--series-1); border-color: var(--series-1); color: #fff; }
.btn-primary:hover { background: #256abf; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: rgba(11, 11, 11, 0.05); color: var(--ink); }
.btn-block { width: 100%; }
.btn-danger-ghost { border-color: transparent; background: transparent; color: var(--danger); padding: 4px 10px; }
.btn-danger-ghost:hover { background: rgba(208, 59, 59, 0.08); }

input, select {
  font: inherit; color: var(--ink);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 10px; background: #fff; width: 100%;
}
input:focus-visible, select:focus-visible, .btn:focus-visible {
  outline: 2px solid var(--series-1); outline-offset: 1px;
}
label { display: block; font-weight: 550; color: var(--ink-2); }
label > input, label > select { margin-top: 4px; font-weight: 400; }

.form-error { color: var(--danger); margin: 4px 0 0; }
.saved-note { color: var(--good-text); font-weight: 550; margin-left: 10px; }

/* ---------- Login ---------- */

.login-plane { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: 360px; max-width: 100%;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; box-shadow: var(--shadow);
  padding: 36px 32px; display: grid; gap: 14px;
}
.login-card h1 { font-size: 22px; }
.login-sub { margin: -10px 0 4px; color: var(--muted); }
.brand-mark {
  width: 40px; height: 40px; display: inline-grid; place-items: center;
  background: var(--series-1); color: #fff; font-weight: 700; font-size: 15px;
  border-radius: 10px; letter-spacing: .5px;
}

/* ---------- Shell ---------- */

.topbar {
  display: flex; align-items: center; gap: 28px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 10px 28px; position: sticky; top: 0; z-index: 5;
}
.topbar-brand { display: flex; align-items: center; gap: 10px; font-weight: 650; font-size: 15px; }
.topbar-brand .brand-mark { width: 30px; height: 30px; font-size: 12px; border-radius: 8px; }
.topbar-nav { display: flex; gap: 4px; flex: 1; }
.topbar-nav a {
  text-decoration: none; color: var(--ink-2); font-weight: 550;
  padding: 7px 14px; border-radius: 8px;
}
.topbar-nav a:hover { background: rgba(11, 11, 11, 0.05); color: var(--ink); }
.topbar-nav a.active { background: #eaf2fc; color: #1c5cab; }
.topbar-user { display: flex; align-items: center; gap: 10px; color: var(--ink-2); }

.plane { max-width: 1180px; margin: 0 auto; padding: 26px 28px 64px; }

/* ---------- Cards ---------- */

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 22px 24px; margin-bottom: 20px;
}
.card.narrow { max-width: 640px; }
.card-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.card-head h2 { font-size: 16px; }
.muted { color: var(--muted); font-size: 13px; }

/* ---------- Filters ---------- */

.filter-row {
  display: flex; gap: 14px; align-items: end; flex-wrap: wrap;
  margin-bottom: 20px;
}
.filter { width: auto; }
.filter span { display: block; font-size: 12px; color: var(--muted); font-weight: 550; margin-bottom: 4px; }
.filter select, .filter input { width: auto; min-width: 130px; background: var(--surface); }

/* ---------- Target hero ---------- */

.hero-row { display: flex; align-items: end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.hero-figure { font-size: 52px; font-weight: 650; letter-spacing: -0.5px; line-height: 1.05; }
.hero-sub { color: var(--ink-2); margin-top: 6px; }
.hero-pct { font-size: 26px; font-weight: 650; color: #1c5cab; }
.meter {
  height: 14px; border-radius: 7px; background: var(--meter-track);
  margin-top: 18px; overflow: hidden;
}
.meter-fill {
  height: 100%; background: var(--series-1); border-radius: 7px;
  transition: width .5s ease;
}
.meter-legend { display: flex; justify-content: space-between; color: var(--muted); font-size: 12.5px; margin-top: 6px; }

/* ---------- KPI tiles ---------- */

.kpi-row, .tile-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.kpi-row { margin-bottom: 20px; }
.kpi-row .tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.tile { padding: 16px 18px; border-radius: 10px; }
.tile-label { color: var(--ink-2); font-size: 13px; display: flex; align-items: center; gap: 7px; }
.tile-value { font-size: 26px; font-weight: 650; margin-top: 4px; }
.tile-sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.tile-row { margin-bottom: 18px; }
.tile-row .tile { background: #f7f6f3; }
.key-dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex: none; }

/* ---------- Stacked bar / legend ---------- */

.stack-bar { display: flex; height: 26px; border-radius: 6px; overflow: hidden; background: var(--grid); }
.stack-seg { height: 100%; border-right: 2px solid var(--surface); transition: filter .12s; }
.stack-seg:last-child { border-right: 0; }
.stack-seg:hover, .stack-seg:focus-visible { filter: brightness(1.08); outline: none; }
.legend { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 12px; color: var(--ink-2); font-size: 13px; }
.legend-item { display: inline-flex; align-items: center; gap: 7px; }

/* ---------- Charts ---------- */

.chart-host { position: relative; }
.chart-host svg { display: block; width: 100%; height: auto; }
.axis-text { fill: var(--muted); font-size: 11.5px; font-family: inherit; font-variant-numeric: tabular-nums; }
.grid-line { stroke: var(--grid); stroke-width: 1; }
.baseline { stroke: var(--baseline); stroke-width: 1; }
.bar-value { fill: var(--ink-2); font-size: 11.5px; font-family: inherit; font-variant-numeric: tabular-nums; }
.bar-cat { fill: var(--ink-2); font-size: 12px; font-family: inherit; }

.tooltip {
  position: fixed; z-index: 50; pointer-events: none;
  background: #fff; border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 4px 18px rgba(11, 11, 11, 0.12);
  padding: 8px 11px; font-size: 12.5px; color: var(--ink-2);
  max-width: 260px;
}
.tooltip .tt-value { color: var(--ink); font-weight: 650; font-size: 14px; }
.tooltip .tt-row { display: flex; align-items: center; gap: 7px; margin-top: 2px; }
.tooltip .tt-key { width: 12px; height: 0; border-top: 2.5px solid; display: inline-block; }

/* ---------- Country section ---------- */

.country-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 26px; align-items: start; }
@media (max-width: 900px) { .country-grid { grid-template-columns: 1fr; } }

.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table th {
  text-align: left; color: var(--muted); font-weight: 550; font-size: 12px;
  border-bottom: 1px solid var(--grid); padding: 6px 10px;
}
.data-table td { padding: 8px 10px; border-bottom: 1px solid var(--grid); }
.data-table tr:last-child td { border-bottom: 0; }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Misc ---------- */

.stack-form { display: grid; gap: 14px; max-width: 380px; }
.empty-state { text-align: center; padding: 70px 0; color: var(--ink-2); font-size: 16px; }
.dash.loading { opacity: .45; transition: opacity .15s; }
