/* ===== DHER DASHBOARD — Bloomberg-style Dark Theme ===== */
:root {
  --bg: #0a0e14;
  --surface: #111820;
  --surface-2: #161d27;
  --surface-3: #1b2430;
  --border: #1e2a38;
  --border-light: #263445;
  --text: #e1e4e8;
  --text-muted: #8b949e;
  --text-faint: #484f58;
  --accent: #00e5a0;
  --accent-dim: rgba(0,229,160,0.15);
  --accent-hover: #00cc8e;
  --negative: #f85149;
  --negative-dim: rgba(248,81,73,0.15);
  --positive: #00e5a0;
  --positive-dim: rgba(0,229,160,0.15);
  --warning: #d29922;
  --blue: #58a6ff;
  --purple: #bc8cff;
  --orange: #f0883e;
  --radius: 8px;
  --radius-sm: 4px;
  --radius-lg: 12px;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  --transition: 180ms cubic-bezier(0.16, 1, 0.3, 1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ===== HEADER ===== */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  z-index: 20;
  min-height: 52px;
}

.header-left { display: flex; align-items: center; gap: 12px; }
.logo { color: var(--text); flex-shrink: 0; }

.header-title h1 {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: var(--accent);
  line-height: 1.2;
}
.header-subtitle {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.3px;
}

.header-right { display: flex; align-items: center; gap: 16px; }

.live-indicator {
  display: flex; align-items: center; gap: 6px;
  padding: 3px 10px;
  border-radius: var(--radius-sm);
  background: var(--accent-dim);
}
.pulse-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(0,229,160,0.4); }
  50% { opacity: 0.7; box-shadow: 0 0 0 6px rgba(0,229,160,0); }
}
.live-text {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 1px;
}

.last-updated {
  font-size: 11px;
  color: var(--text-faint);
  font-family: var(--font-mono);
}

.btn-refresh {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 14px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}
.btn-refresh:hover {
  background: var(--surface-3);
  border-color: var(--accent);
  color: var(--accent);
}
.btn-refresh.spinning svg { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== TAB NAV ===== */
.tab-nav {
  display: flex;
  gap: 0;
  padding: 0 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.tab-btn {
  padding: 10px 20px;
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.3px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--transition);
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ===== MAIN ===== */
.main {
  overflow-y: auto;
  overscroll-behavior: contain;
  height: calc(100dvh - 52px - 41px - 32px);
  padding: 16px 20px 24px;
}

/* ===== TAB PANELS ===== */
.tab-panel {
  display: block;
  position: absolute;
  visibility: hidden;
  pointer-events: none;
  width: 100%;
  height: 0;
  overflow: hidden;
}
.tab-panel.active {
  position: relative;
  visibility: visible;
  pointer-events: auto;
  height: auto;
  overflow: visible;
}

/* ===== KPI ROW ===== */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.kpi-card.mini {
  padding: 10px 12px;
}
.kpi-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 500;
}
.kpi-value {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums lining-nums;
  line-height: 1.2;
}
.kpi-card.mini .kpi-value { font-size: 16px; }
.kpi-delta {
  font-size: 11px;
  font-weight: 500;
  font-family: var(--font-mono);
}
.kpi-delta.positive { color: var(--positive); }
.kpi-delta.negative { color: var(--negative); }
.kpi-delta.neutral { color: var(--text-faint); }

.consensus-buy { color: var(--accent) !important; }

/* RANGE VALUE */
.range-value { display: flex; align-items: baseline; gap: 4px; font-size: 16px; }
.range-lo { color: var(--negative); }
.range-hi { color: var(--positive); }
.range-sep { color: var(--text-faint); font-size: 12px; }

.range-bar-wrap { margin-top: 4px; }
.range-bar {
  width: 100%;
  height: 4px;
  background: linear-gradient(90deg, var(--negative), var(--warning), var(--positive));
  border-radius: 2px;
  position: relative;
}
.range-marker {
  position: absolute;
  top: -4px;
  width: 8px; height: 12px;
  background: var(--text);
  border-radius: 2px;
  transform: translateX(-50%);
  box-shadow: 0 0 6px rgba(0,0,0,0.5);
}

/* ===== CHART GRID ===== */
.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.chart-card.full-h { height: 100%; }
.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 8px;
}
.chart-header h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.chart-badge {
  font-size: 10px;
  font-weight: 600;
  font-family: var(--font-mono);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}
.chart-badge.positive { background: var(--positive-dim); color: var(--positive); }
.chart-badge.negative { background: var(--negative-dim); color: var(--negative); }
.chart-badge.neutral { background: rgba(139,148,158,0.15); color: var(--text-muted); }

.chart-wrap { position: relative; height: 240px; }
.chart-wrap.chart-sm { height: 200px; }

/* ===== TABLE ===== */
.table-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
.table-scroll { overflow-x: auto; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  font-variant-numeric: tabular-nums lining-nums;
}
.data-table th {
  text-align: left;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-size: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-light);
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
}
.data-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 12px;
}
.data-table th.num, .data-table td.num { text-align: right; }
.data-table td.positive { color: var(--positive); }
.data-table td.negative { color: var(--negative); }

.rating-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: var(--radius-sm);
  font-size: 10px;
  font-weight: 600;
}
.rating-badge.buy { background: var(--positive-dim); color: var(--positive); }
.rating-badge.hold { background: rgba(210,153,34,0.15); color: var(--warning); }
.rating-badge.sell { background: var(--negative-dim); color: var(--negative); }

/* ===== ANNOTATION CARD ===== */
.annotation-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
.annotation-card h3 {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 12px;
}
.annotation-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
}
.annotation-item {
  display: flex;
  gap: 10px;
  padding: 10px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  font-size: 12px;
  line-height: 1.55;
  color: var(--text-muted);
}
.annotation-item strong { color: var(--text); }
.annotation-icon { font-size: 18px; flex-shrink: 0; }

/* ===== SEGMENT CARDS ===== */
.segment-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.segment-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  border-top: 3px solid var(--border-light);
}
.segment-card.asia { border-top-color: var(--blue); }
.segment-card.mena { border-top-color: var(--orange); }
.segment-card.europe { border-top-color: var(--purple); }
.segment-card.americas { border-top-color: var(--positive); }

.segment-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.segment-header h4 {
  font-size: 14px;
  font-weight: 600;
  flex: 1;
}
.segment-flag { font-size: 18px; }
.segment-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
}
.segment-badge.positive { background: var(--positive-dim); color: var(--positive); }
.segment-badge.negative { background: var(--negative-dim); color: var(--negative); }
.segment-badge.neutral { background: rgba(139,148,158,0.15); color: var(--text-muted); }

.segment-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
}
.seg-metric {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.seg-label { font-size: 10px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.4px; }
.seg-val { font-family: var(--font-mono); font-size: 13px; font-weight: 600; }
.seg-val.positive { color: var(--positive); }
.seg-val.negative { color: var(--negative); }

.segment-note {
  font-size: 11px;
  line-height: 1.55;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

/* ===== BULLS VS BEARS ===== */
.bulls-bears { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.bb-col { padding: 12px; border-radius: var(--radius-sm); }
.bb-col.bull { background: rgba(0,229,160,0.06); border: 1px solid rgba(0,229,160,0.15); }
.bb-col.bear { background: rgba(248,81,73,0.06); border: 1px solid rgba(248,81,73,0.15); }
.bb-col h4 { font-size: 13px; margin-bottom: 10px; }
.bb-col ul { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.bb-col li { font-size: 12px; color: var(--text-muted); line-height: 1.5; padding-left: 14px; position: relative; }
.bb-col li::before { content: '•'; position: absolute; left: 0; }
.bb-col.bull li::before { color: var(--positive); }
.bb-col.bear li::before { color: var(--negative); }

/* ===== NEWS FEED ===== */
.news-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
.news-feed { display: flex; flex-direction: column; gap: 10px; }
.news-item {
  display: flex;
  gap: 12px;
  padding: 10px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--border-light);
}
.news-item.high-impact { border-left-color: var(--warning); }
.news-date {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
  white-space: nowrap;
  min-width: 44px;
  padding-top: 2px;
}
.news-body { flex: 1; }
.news-tag {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 1px 6px;
  border-radius: 2px;
  margin-right: 6px;
  vertical-align: middle;
}
.news-tag.positive { background: var(--positive-dim); color: var(--positive); }
.news-tag.negative { background: var(--negative-dim); color: var(--negative); }
.news-tag.neutral { background: rgba(139,148,158,0.15); color: var(--text-muted); }
.news-body strong { font-size: 13px; color: var(--text); }
.news-body p { font-size: 11px; color: var(--text-muted); line-height: 1.5; margin-top: 4px; }

/* ===== CALCULATOR ===== */
.calc-header { margin-bottom: 16px; }
.calc-header h3 { font-size: 15px; font-weight: 600; }
.calc-subtitle { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.calc-grid {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
.calc-inputs {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.input-group label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 6px;
}
.input-val {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--accent);
}
input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: var(--border-light);
  outline: none;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg);
  cursor: pointer;
  box-shadow: 0 0 8px rgba(0,229,160,0.3);
}
input[type="range"]::-moz-range-thumb {
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg);
  cursor: pointer;
}
.range-labels {
  display: flex;
  justify-content: space-between;
  font-size: 9px;
  color: var(--text-faint);
  margin-top: 4px;
  font-family: var(--font-mono);
}

.btn-reset-calc {
  padding: 8px 16px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  margin-top: auto;
}
.btn-reset-calc:hover { border-color: var(--accent); color: var(--accent); }

.calc-output { display: flex; flex-direction: column; gap: 12px; }
.calc-kpis {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

/* ===== FOOTER ===== */
.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 20px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  font-size: 10px;
  color: var(--text-faint);
  min-height: 32px;
}
.footer a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--transition);
}
.footer a:hover { color: var(--accent); }

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
  .calc-grid { grid-template-columns: 1fr; }
  .calc-kpis { grid-template-columns: repeat(2, 1fr); }
  .bulls-bears { grid-template-columns: 1fr; }
  .chart-grid { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .header { padding: 8px 12px; gap: 8px; }
  .header-left { min-width: 0; }
  .header-title h1 { font-size: 14px; }
  .header-subtitle { display: none; }
  .header-right { gap: 6px; }
  .last-updated { display: none; }
  .tab-nav { overflow-x: auto; padding: 0 12px; -webkit-overflow-scrolling: touch; }
  .tab-btn { padding: 8px 14px; font-size: 11px; white-space: nowrap; }
  .main { padding: 12px; }
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
  .segment-grid { grid-template-columns: 1fr; }
  .annotation-grid { grid-template-columns: 1fr; }
  .calc-kpis { grid-template-columns: 1fr 1fr; }
  .calc-inputs { padding: 14px; gap: 14px; }
  .input-group label { font-size: 13px; }
  .input-val { font-size: 13px; }
  .footer { flex-direction: column; gap: 4px; text-align: center; }
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

/* ===== TOOLTIPS (rendered by JS into body — see app.js) ===== */
[data-tip] { cursor: help; }
#tip-box {
  position: fixed;
  background: #1a2332;
  color: #c9d1d9;
  font-size: 11px;
  font-family: 'Inter', sans-serif;
  font-weight: 400;
  line-height: 1.55;
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid #263445;
  max-width: 260px;
  z-index: 9999;
  pointer-events: none;
  display: none;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
  text-align: left;
}

/* IR newsroom link */
.ir-link-block {
  padding: 20px 24px;
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}
.ir-link-block p { color: var(--text-muted); font-size: 13px; margin: 0; flex: 1 1 200px; }
.ir-link-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: all var(--transition);
  white-space: nowrap;
}
.ir-link-btn:hover { background: var(--accent); color: #0a0e14; }
