/* ══════════════════════════════════════════════════
   CEG Broker Dashboard — matches ceg.ag palette
   Dark navy sidebar · Light gray content · Orange accent
══════════════════════════════════════════════════ */
:root {
  /* CEG exact palette */
  --navy:         #101b2e;   /* sidebar, header bg */
  --navy-light:   #1a2d47;   /* sidebar hover, dark cards */
  --navy-dark:    #0a1220;   /* deepest navy */

  /* Content surfaces — matches ceg.ag */
  --bg-page:      #f8f8f8;   /* main content background */
  --bg-card:      #ffffff;   /* cards */
  --bg-card-2:    #f4f4f4;   /* secondary card / alt rows */
  --bg-input:     #f0f0f0;   /* inputs */

  /* CEG orange */
  --accent:       #f58c18;
  --accent-light: #f7a340;
  --accent-dark:  #d97a0e;
  --accent-dim:   rgba(245,140,24,0.10);
  --accent-border:rgba(245,140,24,0.30);

  /* Borders */
  --border:       #e2e8f0;
  --border-dark:  rgba(255,255,255,0.08);  /* for dark sidebar */

  /* Text on light — matches ceg.ag */
  --text-head:    #101b2e;   /* headings — CEG navy */
  --text-body:    #3a3a3a;   /* body — ceg.ag dark-gray */
  --text-muted:   #888888;   /* muted */
  --text-xmuted:  #aaaaaa;   /* very muted */

  /* Text on dark (sidebar) */
  --sidebar-text:       #c8d8ea;
  --sidebar-muted:      #4d6888;
  --sidebar-active-bg:  rgba(245,140,24,0.12);
  --sidebar-active-text:#f58c18;

  /* Status */
  --green:     #10B981;
  --green-dim: rgba(16,185,129,0.10);
  --red:       #EF4444;
  --red-dim:   rgba(239,68,68,0.10);
  --blue:      #3B82F6;
  --blue-dim:  rgba(59,130,246,0.10);
  --purple:    #8B5CF6;

  /* Legacy aliases so inline styles keep working */
  --bg-secondary: #f4f4f4;
  --bg-primary:   #f8f8f8;
  --gold:          #f58c18;
  --gold-dim:      rgba(245,140,24,0.10);
  --border-accent: rgba(245,140,24,0.30);
  --text-primary:  #101b2e;
  --text-secondary:#888888;

  /* Fonts */
  --font-body:    'DM Sans', system-ui, sans-serif;
  --font-display: 'DM Serif Display', 'Times New Roman', serif;
  --font-mono:    'JetBrains Mono', ui-monospace, monospace;

  --sidebar-w: 244px;
  --radius:    10px;
  --shadow:    0 1px 3px rgba(16,27,46,0.08), 0 4px 12px rgba(16,27,46,0.04);
  --shadow-md: 0 4px 16px rgba(16,27,46,0.12), 0 1px 3px rgba(16,27,46,0.06);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }

body {
  font-family: var(--font-body);
  background: var(--bg-page);
  color: var(--text-body);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Scrollbars ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ══ APP SHELL ════════════════════════════════════ */
#app { display: flex; height: 100vh; }

/* ══ SIDEBAR (dark navy — matches ceg.ag nav) ═════ */
#sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--navy);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 2px 0 8px rgba(0,0,0,0.15);
}

.sidebar-logo {
  padding: 18px 16px 16px;
  border-bottom: 1px solid var(--border-dark);
  background: #fff;
}
.sidebar-logo-img {
  display: block;
  width: 148px;
  height: auto;
  margin-bottom: 6px;
}
.sidebar-logo .brand-sub {
  font-size: 9px;
  color: #8a9bb0;
  text-transform: uppercase;
  letter-spacing: 2px;
  font-weight: 700;
  padding-left: 2px;
}

.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 10px; }

.nav-section-label {
  font-size: 9px;
  font-weight: 700;
  color: var(--sidebar-muted);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  padding: 12px 12px 5px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--sidebar-text);
  font-weight: 500;
  font-size: 13px;
  transition: all 0.15s;
  margin-bottom: 1px;
  border: 1px solid transparent;
}
.nav-item:hover {
  background: rgba(255,255,255,0.06);
  color: #fff;
}
.nav-item.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
  border-color: var(--accent-border);
  font-weight: 600;
}
.nav-item .nav-icon { width: 16px; height: 16px; opacity: 0.55; flex-shrink: 0; }
.nav-item:hover .nav-icon { opacity: 0.85; }
.nav-item.active .nav-icon { opacity: 1; }
.nav-item .badge {
  margin-left: auto;
  background: var(--red);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 20px;
}

.sidebar-footer {
  padding: 14px 18px;
  border-top: 1px solid var(--border-dark);
}
.sidebar-footer .updated { font-size: 11px; color: var(--sidebar-muted); }
.sidebar-footer .dot {
  display: inline-block;
  width: 6px; height: 6px;
  background: var(--green);
  border-radius: 50%;
  margin-right: 6px;
  animation: pulse 2s infinite;
}
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.3} }

/* ══ MAIN ═════════════════════════════════════════ */
#main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

/* Top header — white bar like ceg.ag */
#top-header {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  box-shadow: 0 1px 4px rgba(16,27,46,0.06);
}

.header-title { display: flex; flex-direction: column; gap: 1px; }
.header-title .eyebrow {
  font-size: 9px;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 1.8px;
}
.header-title .main {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 400;
  color: var(--text-head);
  letter-spacing: -0.2px;
}

.header-kpis { display: flex; gap: 28px; align-items: center; }
.hkpi { text-align: right; }
.hkpi-val {
  font-size: 14px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-head);
}
.hkpi-label {
  font-size: 9px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-top: 1px;
}
.hkpi-val.up { color: var(--green); }
.hkpi-val.down { color: var(--red); }

/* Content */
#content { flex: 1; overflow-y: auto; padding: 28px; }

.section { display: none; }
.section.active { display: block; }

/* ══ SECTION HEADERS ═══════════════════════════════ */
.section-header { margin-bottom: 24px; }
.section-header .eyebrow {
  font-size: 10px;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 5px;
}
.section-header h2 {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 400;
  color: var(--text-head);
  letter-spacing: -0.4px;
  line-height: 1.15;
  margin-bottom: 5px;
}
.section-header p { font-size: 13px; color: var(--text-muted); }

/* ══ KPI CARDS ════════════════════════════════════ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}
.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
  transition: box-shadow 0.2s, border-color 0.2s, transform 0.15s;
}
.kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-light));
  opacity: 0;
  transition: opacity 0.2s;
}
.kpi-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--accent-border);
  transform: translateY(-1px);
}
.kpi-card:hover::before { opacity: 1; }
.kpi-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 700;
  margin-bottom: 10px;
}
.kpi-val {
  font-size: 22px;
  font-weight: 700;
  font-family: var(--font-mono);
  line-height: 1;
  margin-bottom: 8px;
  color: var(--text-head);
}
.kpi-change { font-size: 12px; font-weight: 600; }
.kpi-change.up { color: var(--green); }
.kpi-change.down { color: var(--red); }

/* ══ GRIDS ════════════════════════════════════════ */
.chart-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 20px; }
.chart-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; margin-bottom: 20px; }

/* ══ CARDS ════════════════════════════════════════ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 18px;
}
.card-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--accent);
}
.card-subtitle { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.card-badge {
  font-size: 10px;
  padding: 3px 10px;
  border-radius: 20px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.card-badge.green { background: var(--green-dim); color: var(--green); }
.card-badge.gold  { background: var(--accent-dim); color: var(--accent); }
.card-badge.red   { background: var(--red-dim);   color: var(--red); }
.card-badge.blue  { background: var(--blue-dim);  color: var(--blue); }

/* ══ TABLES ═══════════════════════════════════════ */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: left;
  padding: 10px 14px;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  background: var(--bg-card-2);
}
.data-table th:hover { color: var(--accent); }
.data-table th.sorted { color: var(--accent); }
.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  vertical-align: middle;
  color: var(--text-body);
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #fdf6ee; }
.data-table tr { cursor: pointer; transition: background 0.1s; }

.heat-score {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 8px;
  font-weight: 700; font-size: 13px;
}
.heat-5 { background: rgba(16,185,129,0.12); color: #059669; }
.heat-4 { background: rgba(16,185,129,0.08); color: #10B981; }
.heat-3 { background: rgba(245,140,24,0.12); color: var(--accent); }
.heat-2 { background: rgba(239,68,68,0.10);  color: #EF4444; }

.change-up { color: var(--green); font-weight: 600; }
.change-dn { color: var(--red);   font-weight: 600; }
.change-nu { color: var(--text-muted); }

/* ══ FILTER BAR ════════════════════════════════════ */
.filter-bar { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; align-items: center; }
.filter-btn {
  padding: 6px 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-body);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--font-body);
  box-shadow: var(--shadow);
}
.filter-btn:hover { border-color: var(--accent-border); color: var(--accent); background: #fff; }
.filter-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.search-input {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 12px;
  color: var(--text-head);
  font-size: 13px;
  font-family: var(--font-body);
  outline: none;
  width: 220px;
  transition: border-color 0.15s;
  box-shadow: var(--shadow);
}
.search-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.search-input::placeholder { color: var(--text-xmuted); }

/* ══ TRANSACTION FEED ══════════════════════════════ */
.txn-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 16px;
  padding: 14px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-bottom: 10px;
  align-items: center;
  background: var(--bg-card);
  box-shadow: var(--shadow);
  transition: box-shadow 0.15s, border-color 0.15s;
}
.txn-card:hover { box-shadow: var(--shadow-md); border-color: var(--accent-border); }
.txn-type {
  width: 42px; height: 42px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
}
.txn-type.sale { background: var(--green-dim); }
.txn-type.rent { background: var(--blue-dim); }
.txn-main .txn-bldg { font-weight: 600; font-size: 14px; color: var(--text-head); }
.txn-main .txn-meta { font-size: 12px; color: var(--text-muted); margin-top: 3px; }
.txn-meta span { margin-right: 10px; }
.txn-right { text-align: right; }
.txn-price { font-weight: 700; font-size: 15px; color: var(--accent); font-family: var(--font-mono); }
.txn-psf { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.txn-note { font-size: 11px; color: var(--green); margin-top: 2px; }

/* ══ OFF-PLAN ══════════════════════════════════════ */
.offplan-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.offplan-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s, border-color 0.2s;
}
.offplan-card:hover { box-shadow: var(--shadow-md); border-color: var(--accent-border); }
.offplan-dev {
  font-size: 9px;
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.offplan-name {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 400;
  color: var(--text-head);
  margin-bottom: 3px;
  line-height: 1.2;
}
.offplan-area { font-size: 12px; color: var(--text-muted); margin-bottom: 16px; }
.offplan-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.offplan-stat-label {
  font-size: 9px; color: var(--text-muted); text-transform: uppercase;
  letter-spacing: 1px; margin-bottom: 3px; font-weight: 700;
}
.offplan-stat-val { font-size: 14px; font-weight: 700; font-family: var(--font-mono); color: var(--text-head); }
.offplan-progress { margin-bottom: 14px; }
.progress-label { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-muted); margin-bottom: 6px; }
.progress-bar { height: 5px; background: var(--border); border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 3px; background: linear-gradient(90deg, var(--accent), var(--accent-light)); transition: width 0.4s; }
.offplan-insight {
  font-size: 12px; color: var(--text-muted); padding: 10px 12px;
  background: var(--bg-card-2); border-radius: 8px;
  border-left: 3px solid var(--accent); line-height: 1.5;
}
.premium-badge { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 10px; font-weight: 700; margin-left: 8px; text-transform: uppercase; }
.premium-up { background: var(--green-dim); color: var(--green); }
.premium-dn { background: var(--red-dim); color: var(--red); }
.dev-score { display: flex; align-items: center; gap: 6px; }
.dev-stars { color: var(--accent); font-size: 12px; }

/* ══ ROI CALCULATOR ════════════════════════════════ */
.calc-layout { display: grid; grid-template-columns: 380px 1fr; gap: 24px; }
.calc-form { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.form-group { margin-bottom: 18px; }
.form-label {
  display: block; font-size: 10px; font-weight: 700;
  color: var(--text-muted); margin-bottom: 7px;
  text-transform: uppercase; letter-spacing: 1px;
}
.form-input {
  width: 100%; background: var(--bg-input); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 12px; color: var(--text-head);
  font-size: 14px; font-family: var(--font-body); outline: none; transition: all 0.15s;
}
.form-input:focus { border-color: var(--accent); background: #fff; box-shadow: 0 0 0 3px var(--accent-dim); }
.form-select {
  width: 100%; background: var(--bg-input); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 12px; color: var(--text-head);
  font-size: 14px; font-family: var(--font-body); outline: none; cursor: pointer; appearance: none;
}
.form-select:focus { border-color: var(--accent); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.calc-btn {
  width: 100%; padding: 13px;
  background: var(--accent); color: #fff; border: none;
  border-radius: 8px; font-size: 14px; font-weight: 700;
  cursor: pointer; font-family: var(--font-body);
  text-transform: uppercase; letter-spacing: 1px;
  transition: background 0.15s, transform 0.15s; margin-top: 8px;
}
.calc-btn:hover { background: var(--accent-dark); transform: translateY(-1px); }

.result-kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 16px; }
.result-kpi { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.result-kpi.highlight { border-color: var(--accent-border); background: #fff8f0; }
.result-kpi-label { font-size: 9px; color: var(--text-muted); font-weight: 700; margin-bottom: 8px; text-transform: uppercase; letter-spacing: 1px; }
.result-kpi-val { font-size: 22px; font-weight: 700; font-family: var(--font-mono); color: var(--text-head); }
.result-kpi.highlight .result-kpi-val { color: var(--accent); }

.cost-breakdown { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; box-shadow: var(--shadow); }
.cost-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.cost-row:last-child { border-bottom: none; font-weight: 700; color: var(--accent); }
.cost-label { color: var(--text-muted); }

.projection-table-wrap { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.proj-table { width: 100%; border-collapse: collapse; }
.proj-table th { padding: 10px 14px; font-size: 9px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; border-bottom: 2px solid var(--border); text-align: right; font-weight: 700; background: var(--bg-card-2); }
.proj-table th:first-child { text-align: left; }
.proj-table td { padding: 10px 14px; font-size: 13px; text-align: right; border-bottom: 1px solid var(--border); font-family: var(--font-mono); color: var(--text-body); }
.proj-table td:first-child { text-align: left; font-weight: 600; font-family: var(--font-body); color: var(--text-head); }
.proj-table tr:last-child td { border-bottom: none; }
.proj-table tr:hover td { background: #fdf6ee; }

/* ══ MARKET SIGNALS ════════════════════════════════ */
.signals-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.signal-insight {
  display: flex; gap: 14px; padding: 16px;
  background: var(--bg-card); border-radius: var(--radius);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  margin-bottom: 10px; align-items: flex-start;
  box-shadow: var(--shadow);
}
.signal-icon { font-size: 20px; flex-shrink: 0; margin-top: 1px; }
.signal-title { font-size: 13px; font-weight: 700; margin-bottom: 4px; color: var(--text-head); }
.signal-desc { font-size: 12px; color: var(--text-muted); line-height: 1.6; }

/* ══ NEWS ══════════════════════════════════════════ */
.news-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.news-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
  box-shadow: var(--shadow); transition: box-shadow 0.2s, border-color 0.2s; cursor: pointer;
}
.news-card:hover { box-shadow: var(--shadow-md); border-color: var(--accent-border); }
.news-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.news-category {
  font-size: 9px; padding: 3px 10px; border-radius: 4px;
  font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px;
}
.news-category.Market      { background: var(--blue-dim);           color: var(--blue); }
.news-category.Finance     { background: rgba(139,92,246,0.10);     color: var(--purple); }
.news-category.Regulation  { background: var(--accent-dim);         color: var(--accent); }
.news-category.Development { background: var(--green-dim);          color: var(--green); }
.news-category.Infrastructure { background: rgba(239,68,68,0.10);  color: #EF4444; }
.news-sentiment { font-size: 11px; font-weight: 700; }
.news-sentiment.Bullish { color: var(--green); }
.news-sentiment.Neutral { color: var(--text-muted); }
.news-sentiment.Bearish { color: var(--red); }
.news-date { font-size: 11px; color: var(--text-muted); margin-left: auto; }
.news-title { font-family: var(--font-display); font-size: 16px; font-weight: 400; margin-bottom: 8px; line-height: 1.4; color: var(--text-head); }
.news-summary { font-size: 12px; color: var(--text-muted); line-height: 1.6; }
.news-source { font-size: 11px; color: var(--text-xmuted); margin-top: 10px; }
.impact-dots { display: flex; gap: 3px; margin-top: 10px; }
.impact-dot { width: 7px; height: 7px; border-radius: 50%; }
.impact-dot.filled { background: var(--accent); }
.impact-dot.empty  { background: var(--border); }

/* ══ SERVICE CHARGES ═══════════════════════════════ */
.sc-rating { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; }
.sc-rating.Ultra  { background: rgba(239,68,68,0.10); color: #EF4444; }
.sc-rating.High   { background: var(--accent-dim);    color: var(--accent); }
.sc-rating.Medium { background: var(--blue-dim);      color: var(--blue); }
.sc-rating.Low    { background: var(--green-dim);     color: var(--green); }

/* ══ MODAL ═════════════════════════════════════════ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(16,27,46,0.55);
  z-index: 100; display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity 0.2s;
  backdrop-filter: blur(4px);
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 16px; padding: 30px; width: 640px; max-height: 82vh;
  overflow-y: auto; transform: translateY(16px); transition: transform 0.2s;
  box-shadow: 0 20px 60px rgba(16,27,46,0.2);
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-close { float: right; background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 20px; padding: 0; }
.modal-close:hover { color: var(--text-head); }
.modal-area-name { font-family: var(--font-display); font-size: 26px; font-weight: 400; margin-bottom: 4px; color: var(--text-head); }
.modal-area-meta { font-size: 13px; color: var(--text-muted); margin-bottom: 22px; }
.modal-stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 20px; }
.modal-stat { background: var(--bg-card-2); border: 1px solid var(--border); border-radius: 10px; padding: 14px; }
.modal-stat-label { font-size: 9px; color: var(--text-muted); font-weight: 700; margin-bottom: 5px; text-transform: uppercase; letter-spacing: 1px; }
.modal-stat-val { font-size: 18px; font-weight: 700; font-family: var(--font-mono); color: var(--text-head); }
.modal-insight { background: #fff8f0; border: 1px solid var(--accent-border); border-left: 3px solid var(--accent); border-radius: 10px; padding: 16px; margin-bottom: 16px; }
.modal-insight-title { font-size: 9px; font-weight: 700; color: var(--accent); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 1.5px; }
.modal-insight-text { font-size: 13px; color: var(--text-muted); line-height: 1.65; }
.nat-bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.nat-name { width: 80px; font-size: 12px; color: var(--text-muted); }
.nat-bar-bg { flex: 1; height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.nat-bar-fill { height: 100%; border-radius: 3px; background: linear-gradient(90deg, var(--accent), var(--accent-light)); }
.nat-pct { width: 32px; font-size: 12px; font-weight: 700; text-align: right; color: var(--accent); }

/* ══ TOOLTIP ═══════════════════════════════════════ */
.tip { position: relative; cursor: help; }
.tip:hover::after {
  content: attr(data-tip);
  position: absolute; bottom: 130%; left: 50%; transform: translateX(-50%);
  background: var(--navy); color: #fff;
  padding: 7px 12px; border-radius: 8px;
  font-size: 11px; white-space: nowrap; z-index: 20;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}

/* ══ UTILITIES ═════════════════════════════════════ */
.text-gold      { color: var(--accent); }
.text-green     { color: var(--green); }
.text-red       { color: var(--red); }
.text-muted     { color: var(--text-muted); }
.text-secondary { color: var(--text-muted); }
.fw-700 { font-weight: 700; }
.fw-600 { font-weight: 600; }
.text-right { text-align: right; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.flex { display: flex; }
.items-center { align-items: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }

/* ══ AUTH SCREENS ══════════════════════════════════ */
#auth-wrap {
  position: fixed; inset: 0; z-index: 9999;
  background: linear-gradient(135deg, #0a1220 0%, #101b2e 50%, #0d1f38 100%);
  display: flex; align-items: center; justify-content: center;
}
#auth-wrap.hidden { display: none; }

.auth-screen { display: none; width: 100%; align-items: center; justify-content: center; }
.auth-screen.active { display: flex; }

.auth-card {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.09);
  border-radius: 16px;
  padding: 40px 44px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.5);
  backdrop-filter: blur(12px);
}

.auth-logo { text-align: center; margin-bottom: 8px; }

.auth-divider {
  height: 1px;
  background: rgba(255,255,255,0.08);
  margin: 24px 0;
}

.auth-field { margin-bottom: 14px; }

.auth-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: rgba(255,255,255,0.45);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 6px;
}

.auth-input {
  width: 100%;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  padding: 11px 14px;
  font-size: 14px;
  color: #fff;
  font-family: var(--font-sans);
  transition: border-color 0.2s, background 0.2s;
  box-sizing: border-box;
}
.auth-input::placeholder { color: rgba(255,255,255,0.25); }
.auth-input:focus {
  outline: none;
  border-color: rgba(245,140,24,0.6);
  background: rgba(255,255,255,0.09);
}

.auth-btn {
  width: 100%;
  background: #f58c18;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 13px;
  font-size: 15px;
  font-weight: 700;
  font-family: var(--font-sans);
  cursor: pointer;
  margin-top: 4px;
  transition: background 0.2s, transform 0.1s;
  letter-spacing: 0.3px;
}
.auth-btn:hover { background: #e07d10; }
.auth-btn:active { transform: scale(0.99); }

.auth-error {
  font-size: 12px;
  color: #EF4444;
  background: rgba(239,68,68,0.1);
  border-radius: 6px;
  padding: 0;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.2s, padding 0.2s;
  margin-bottom: 0;
}
.auth-error.visible {
  padding: 8px 12px;
  max-height: 60px;
  margin-bottom: 12px;
}

.auth-success {
  font-size: 12px;
  color: #10B981;
  background: rgba(16,185,129,0.1);
  border-radius: 6px;
  padding: 0;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.2s, padding 0.2s;
  margin-bottom: 0;
}
.auth-success.visible {
  padding: 8px 12px;
  max-height: 80px;
  margin-bottom: 12px;
}

.auth-links {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 18px;
}
.auth-link {
  font-size: 12px;
  color: rgba(255,255,255,0.4);
  cursor: pointer;
  transition: color 0.15s;
}
.auth-link:hover { color: #f58c18; }
.auth-link-sep { font-size: 12px; color: rgba(255,255,255,0.2); }

.auth-footer {
  font-size: 10px;
  color: rgba(255,255,255,0.15);
  text-align: center;
  margin-top: 20px;
  letter-spacing: 0.5px;
}

/* ══ SIDEBAR OVERLAY (mobile) ═════════════════════ */
#sidebar-overlay {
  display: none;
  position: fixed; inset: 0; z-index: 149;
  background: rgba(16,27,46,0.6);
  backdrop-filter: blur(2px);
}
#sidebar-overlay.open { display: block; }

/* ══ HAMBURGER BUTTON ═══════════════════════════════ */
#menu-toggle {
  display: none;
  background: none; border: none;
  cursor: pointer; padding: 7px;
  color: var(--text-head);
  border-radius: 8px;
  transition: background 0.15s;
  flex-shrink: 0;
}
#menu-toggle:hover { background: var(--bg-card-2); }

/* ══ RESPONSIVE — MOBILE ════════════════════════════ */
@media (max-width: 768px) {

  /* Sidebar: off-canvas drawer */
  #sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    z-index: 150;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: 4px 0 24px rgba(0,0,0,0.35);
  }
  #sidebar.open { transform: translateX(0); }

  /* App shell */
  #app { display: block; }
  #main { width: 100%; height: 100vh; }

  /* Hamburger visible */
  #menu-toggle { display: flex; align-items: center; justify-content: center; }

  /* Top header */
  #top-header { padding: 0 14px; height: 54px; }
  .header-kpis { display: none; }

  /* Content area */
  #content { padding: 14px 12px; }

  /* Section headers */
  .section-header { margin-bottom: 16px; }
  .section-header h2 { font-size: 22px; }

  /* KPI cards */
  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
  .kpi-card { padding: 14px; }
  .kpi-val { font-size: 18px; }

  /* Chart grids */
  .chart-grid-2 { grid-template-columns: 1fr; gap: 12px; }
  .chart-grid-3 { grid-template-columns: 1fr; }
  .signals-grid { grid-template-columns: 1fr; }
  .news-grid    { grid-template-columns: 1fr; }
  .offplan-grid { grid-template-columns: 1fr; }

  /* Inline grids: class overrides */
  .overview-yield-row { grid-template-columns: 1fr !important; }
  .kpi-grid-4 { grid-template-columns: repeat(2, 1fr) !important; }
  .kpi-grid-5 { grid-template-columns: repeat(2, 1fr) !important; }
  .est-hero-grid { grid-template-columns: 1fr !important; }
  .est-selector-grid { grid-template-columns: 1fr !important; }
  #distressed-grid { grid-template-columns: 1fr !important; }
  .reg-2col { grid-template-columns: 1fr !important; }

  /* ROI Calculator */
  .calc-layout { grid-template-columns: 1fr; gap: 16px; }
  .result-kpis { grid-template-columns: repeat(2, 1fr); }
  .form-row { grid-template-columns: 1fr; }

  /* Tables: horizontal scroll */
  .card { overflow-x: auto; }
  .data-table { min-width: 540px; }

  /* Transaction cards */
  .txn-card { grid-template-columns: auto 1fr; gap: 10px; }
  .txn-right { grid-column: 2; }

  /* Filter bar: scrollable row */
  .filter-bar { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; -webkit-overflow-scrolling: touch; }
  .filter-btn { white-space: nowrap; flex-shrink: 0; }

  /* Search inputs */
  .search-input { width: 100% !important; }

  /* Modal */
  .modal { width: calc(100vw - 24px); padding: 20px 16px; margin: 0; }
  .modal-stat-grid { grid-template-columns: repeat(2, 1fr); }
  .modal-area-name { font-size: 22px; }

  /* Auth card */
  .auth-card { padding: 28px 18px; }
  #auth-wrap { padding: 16px; }

  /* Cards general */
  .card { padding: 16px; }

  /* Market at a glance: 2-col grid inside card already ok at 2-col */

  /* Estimator: hero block min-width */
  .est-hero-grid > .card { min-width: unset !important; width: 100%; }

  /* Service charges legend wrap */
  #section-servicecharges .filter-bar > div { font-size: 10px; white-space: normal; }
}
