/* ============================================================
   FreeTrader Hub — Custom Styles
   Tailwind handles layout/spacing; this file handles
   component-level tokens and non-utility patterns.
   ============================================================ */

/* ---------- Global ---------- */
*, *::before, *::after {
  box-sizing: border-box;
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

/* ---------- Calculator Inputs ---------- */
.calc-input {
  width: 100%;
  background: #0f172a;               /* slate-950 */
  border: 1px solid #1e293b;         /* slate-800 */
  border-radius: 0.5rem;
  padding: 0.625rem 0.875rem;
  font-size: 0.9rem;
  color: #e2e8f0;                     /* slate-200 */
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.calc-input:focus {
  border-color: #22c55e;             /* emerald-500 */
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.12);
}

.calc-input:hover:not(:focus) {
  border-color: #334155;             /* slate-700 */
}

/* Invalid field state — main calculator */
.calc-input.input-error {
  border-color: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.12);
}

/* Number input — hide spin buttons */
.calc-input[type="number"]::-webkit-outer-spin-button,
.calc-input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.calc-input[type="number"] { -moz-appearance: textfield; }

/* Select styling — single custom arrow, no system arrow (dark mode base) */
select.calc-input,
select.addon-select {
  cursor: pointer;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23888' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px 8px;
  padding-right: 36px;
}

/* Input with addon (currency prefix / percent suffix) */
.input-with-addon {
  display: flex;
  align-items: stretch;
}

.input-with-addon .addon-select {
  background: #1e293b;
  border: 1px solid #1e293b;
  border-right: none;
  border-radius: 0.5rem 0 0 0.5rem;
  padding: 0.625rem 0.75rem;
  font-size: 0.8rem;
  color: #94a3b8;
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  min-width: 68px;
  text-align: center;
}

.input-with-addon .addon-select:focus {
  border-color: #22c55e;
}

.input-with-addon .calc-input.with-addon {
  border-radius: 0 0.5rem 0.5rem 0;
  border-left: 1px solid #334155;
}

.input-with-addon .addon-suffix {
  background: #1e293b;
  border: 1px solid #1e293b;
  border-left: none;
  border-radius: 0 0.5rem 0.5rem 0;
  padding: 0.625rem 0.875rem;
  font-size: 0.85rem;
  color: #64748b;
  display: flex;
  align-items: center;
  user-select: none;
}

/* Static text prefix (for drawdown $) */
.addon-prefix {
  background: #1e293b;
  border: 1px solid #1e293b;
  border-right: none;
  border-radius: 0.5rem 0 0 0.5rem;
  padding: 0.625rem 0.875rem;
  font-size: 0.9rem;
  color: #64748b;
  display: flex;
  align-items: center;
  user-select: none;
}

.input-with-addon .calc-input:not(.with-addon) {
  border-radius: 0.5rem 0 0 0.5rem;
  flex: 1;
}

/* Input group */
.input-group {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.input-label {
  font-size: 0.8rem;
  font-weight: 500;
  color: #94a3b8;                    /* slate-400 */
  letter-spacing: 0.01em;
}

.input-hint {
  font-size: 0.7rem;
  color: #475569;                    /* slate-600 */
}

/* ---------- Buttons ---------- */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: #22c55e;              /* emerald-500 */
  color: #052e16;
  font-weight: 600;
  font-size: 0.875rem;
  padding: 0.625rem 1.5rem;
  border-radius: 0.5rem;
  border: none;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
  user-select: none;
}

.btn-primary:hover {
  background: #16a34a;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.2);
}

.btn-primary:active { transform: scale(0.97); }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: transparent;
  color: #94a3b8;
  font-weight: 500;
  font-size: 0.875rem;
  padding: 0.625rem 1.5rem;
  border-radius: 0.5rem;
  border: 1px solid #334155;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  user-select: none;
}

.btn-secondary:hover {
  background: #1e293b;
  color: #e2e8f0;
  border-color: #475569;
}

.btn-secondary:active { transform: scale(0.97); }

/* Small button variant */
.btn-xs {
  font-size: 0.75rem;
  padding: 0.375rem 0.75rem;
}

/* ---------- Keyboard shortcut hint ---------- */
.kbd-hint {
  font-family: 'JetBrains Mono', 'Fira Code', Consolas, monospace;
  font-size: 0.6rem;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(0, 0, 0, 0.3);
  border-radius: 0.25rem;
  padding: 0.1rem 0.35rem;
  color: rgba(5, 46, 22, 0.75);
  margin-left: 0.125rem;
  vertical-align: middle;
  letter-spacing: 0;
  white-space: nowrap;
}

/* ---------- Result Stats ---------- */
.stat-card {
  background: #0f172a;
  border: 1px solid #1e293b;
  border-radius: 0.625rem;
  padding: 0.875rem 1rem;
}

.stat-label {
  font-size: 0.7rem;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 500;
  margin-bottom: 0.25rem;
}

.stat-value {
  font-family: 'JetBrains Mono', 'Fira Code', Consolas, monospace;
  font-size: 1.05rem;
  font-weight: 600;
}

/* ---------- Scenario Comparison Table ---------- */
.scenario-table {
  font-size: 0.8rem;
  border-collapse: collapse;
  width: 100%;
}

.scenario-table th {
  text-align: left;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #64748b;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid #1e293b;
  background: #0f172a;
}

.scenario-table td {
  padding: 0.5rem 0.75rem;
  color: #cbd5e1;
  border-bottom: 1px solid #1e293b;
  font-family: 'JetBrains Mono', 'Fira Code', Consolas, monospace;
  font-size: 0.78rem;
  white-space: nowrap;
}

.scenario-table tr:last-child td { border-bottom: none; }

.scenario-table tr:hover td { background: #1e293b40; }

.scenario-table .scenario-active td {
  background: rgba(34, 197, 94, 0.06);
}

/* Scenario custom % input */
.scenario-input {
  width: 70px;
  background: #0f172a;
  border: 1px solid #1e293b;
  border-radius: 0.375rem;
  padding: 0.25rem 0.5rem;
  font-size: 0.8rem;
  color: #e2e8f0;
  outline: none;
  -moz-appearance: textfield;
  text-align: center;
}
.scenario-input::-webkit-outer-spin-button,
.scenario-input::-webkit-inner-spin-button { -webkit-appearance: none; }
.scenario-input:focus { border-color: #22c55e; box-shadow: 0 0 0 2px rgba(34,197,94,0.12); }

/* ---------- Drawdown Chart ---------- */
.dd-chart {
  min-height: 140px;
  display: block;
}

/* ---------- News Cards ---------- */
.news-card {
  background: #0f172a;
  border: 1px solid #1e293b;
  border-radius: 0.625rem;
  padding: 0.875rem 1rem;
  transition: border-color 0.15s, background 0.15s;
}


.news-card:hover {
  border-color: #334155;
  background: #1e293b;
}

.news-card a {
  text-decoration: none;
}

.news-card a:hover h3 {
  color: #4ade80;
}

.news-title {
  font-size: 0.85rem;
  font-weight: 500;
  color: #cbd5e1;                    /* slate-300 */
  line-height: 1.45;
  margin-bottom: 0.375rem;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  transition: color 0.15s;
}

.news-snippet {
  font-size: 0.75rem;
  color: #64748b;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 0.5rem;
}

.news-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.7rem;
  color: #475569;
}

.news-source-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
  background: #e8f4fd;
  color: #1a6fa8;
}

/* Source badge colour tokens — unified soft blue */
.source-bbc,
.source-guardian,
.source-ft,
.source-investing,
.source-default    { background: #e8f4fd; color: #1a6fa8; }

/* ---------- Scrollable News Panel ---------- */
.news-panel {
  max-height: min(78vh, 720px);
  overflow-y: auto;
}

/* Custom scrollbar for the news panel */
.news-panel::-webkit-scrollbar { width: 4px; }
.news-panel::-webkit-scrollbar-track { background: transparent; }
.news-panel::-webkit-scrollbar-thumb { background: #334155; border-radius: 2px; }
.news-panel::-webkit-scrollbar-thumb:hover { background: #22c55e; }

.news-panel-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #0f172a;  /* slate-900 — matches card bg */
}

/* ---------- Filter Chips ---------- */
.filter-chip {
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.7rem;
  font-weight: 500;
  border: 1px solid #334155;
  color: #94a3b8;
  background: transparent;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.filter-chip:hover {
  border-color: #475569;
  color: #e2e8f0;
}

.filter-chip.active {
  background: #22c55e;
  border-color: #22c55e;
  color: #052e16;
}

/* ---------- Preset Instrument Pills ---------- */
.preset-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.72rem;
  font-weight: 500;
  border: 1px solid #334155;
  color: #94a3b8;
  background: transparent;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  letter-spacing: 0.02em;
  user-select: none;
}

.preset-pill:hover {
  border-color: #22c55e;
  color: #4ade80;
  background: rgba(34, 197, 94, 0.06);
}

.preset-pill.active {
  background: rgba(34, 197, 94, 0.15);
  border-color: #22c55e;
  color: #4ade80;
  font-weight: 600;
}

/* ---------- Muted kbd variant (for Reset button) ---------- */
.kbd-hint--muted {
  background: rgba(148, 163, 184, 0.05);
  border-color: rgba(148, 163, 184, 0.18);
  color: rgba(148, 163, 184, 0.45);
}

/* ---------- Economic Calendar widget wrapper ---------- */
.calendar-wrapper {
  background: #ffffff;
  border-radius: 10px;
  padding: 16px;
  /* No min-height — let the widget set its own height */
}

.calendar-wrapper .tradingview-widget-container {
  width: 100%;
}

/* Loading placeholder shown while the widget script is still running.
   :empty matches before TradingView injects the iframe into __widget. */
.tradingview-widget-container__widget:empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  color: #334155;
  font-size: 0.8rem;
  letter-spacing: 0.02em;
}
.tradingview-widget-container__widget:empty::before {
  content: 'Loading economic calendar…';
}

/* Style the mandatory TradingView copyright line to match dark theme */
.tradingview-widget-copyright {
  padding: 0.25rem 1rem 0.5rem;
  font-size: 0.65rem;
}
.tradingview-widget-copyright a,
.tradingview-widget-copyright .blue-text {
  color: #334155 !important;
  text-decoration: none;
}
.tradingview-widget-copyright a:hover {
  color: #475569 !important;
}

/* ---------- Spinning refresh icon ---------- */
@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

.spinning { animation: spin 0.8s linear infinite; }

/* ---------- News status dot ---------- */
.dot-live {
  background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.2);
  animation: pulse-dot 2s ease-in-out infinite;
}

.dot-error { background: #ef4444; }

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ---------- Scrollbar (WebKit) ---------- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #334155; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #475569; }

/* ---------- Result animation ---------- */
@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.result-animate {
  animation: fadeSlideIn 0.3s ease forwards;
}

/* ---------- Disclaimer ribbon ---------- */
.disclaimer-ribbon {
  background: #0f172a;
  height: 34px;
  display: flex;
  align-items: center;
  padding: 0 24px;
  font-size: 11px;
  color: rgba(241, 245, 249, 0.4);
  letter-spacing: 0.01em;
  border-bottom: 0.5px solid rgba(15,23,42,0.08);
}

@media (max-width: 640px) {
  .disclaimer-ribbon {
    height: auto;
    padding: 8px 16px;
  }
}

.disclaimer-dot {
  margin: 0 7px;
  opacity: 0.5;
}

/* ---------- Responsive tweaks ---------- */
@media (max-width: 640px) {
  .stat-value { font-size: 0.9rem; }
  #calcResults .text-4xl { font-size: 2rem; }
  .scenario-table th,
  .scenario-table td { padding: 0.4rem 0.5rem; font-size: 0.72rem; }
  /* calendar: no min-height override needed, widget is responsive */
}

/* =============================================================
   THEME TOGGLE — Pill design
   ============================================================= */

.theme-toggle {
  display: flex;
  align-items: center;
  gap: 0;
  margin-left: 4px;
}

.theme-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: #94a3b8;
  margin-right: 8px;
  min-width: 28px;
  text-align: right;
}

.toggle-pill {
  position: relative;
  width: 56px;
  height: 28px;
  border-radius: 14px;
  cursor: pointer;
  border: 1.5px solid #334155;
  background: #f1f5f9;
  transition: background 0.25s ease, border-color 0.25s ease;
  flex-shrink: 0;
  padding: 0;
}

.toggle-pill.dark-mode {
  background: #1e293b;
  border-color: #475569;
}

.toggle-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  position: absolute;
  top: 2px;
  left: 0;
  background: white;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  transform: translateX(2px);
  transition: transform 0.25s ease, background 0.25s ease;
  pointer-events: none;
}

.toggle-pill.dark-mode .toggle-thumb {
  transform: translateX(28px);
  background: #475569;
}

.toggle-icon-left,
.toggle-icon-right {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  line-height: 1;
  pointer-events: none;
}

.toggle-icon-left  { left: 5px; }
.toggle-icon-right { right: 5px; }

/* Light mode label color */
html.light .theme-label { color: #94a3b8; }

/* =============================================================
   LIGHT MODE — CSS Variables + Full Component Redesign
   ============================================================= */

html.light {
  --bg-primary:         #f4f6f9;
  --bg-card:            #ffffff;
  --bg-input:           #f8fafc;
  --bg-nav:             #ffffff;
  --border-color:       #e2e8f0;
  --border-input:       #cbd5e1;
  --text-primary:       #0f172a;
  --text-secondary:     #475569;
  --text-muted:         #94a3b8;
  --accent-green:       #16a34a;
  --accent-green-hover: #15803d;
  --accent-green-light: #dcfce7;
  --shadow-card:        0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-hover:       0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.05);
}

/* ── Page shell ── */
html.light body {
  background: var(--bg-primary) !important;
  color: var(--text-primary);
}

/* ── Disclaimer ribbon ── */
html.light body .disclaimer-ribbon { background: #f4f6f9 !important; color: rgba(15,23,42,0.4) !important; border-bottom: none !important; }

/* ── Navigation bar ── */
html.light header {
  background: var(--bg-nav) !important;
  border-bottom: none !important;
  box-shadow: none !important;
}

html.light header h1 {
  color: var(--text-primary) !important;
  font-weight: 700;
}

html.light header p {
  color: var(--text-muted) !important;
  font-weight: 400;
  font-size: 0.75rem;
}

html.light nav a {
  font-weight: 500;
  font-size: 0.875rem;
  color: var(--text-secondary) !important;
  border-radius: 6px;
  transition: all 0.15s ease;
}

html.light nav a:hover {
  color: var(--text-primary) !important;
  background: #f1f5f9 !important;
}

/* ── Section headings ── */
html.light .text-slate-100 { color: var(--text-primary) !important; }
html.light .text-slate-200 { color: var(--text-primary) !important; }
html.light .text-slate-300 { color: var(--text-secondary) !important; }
html.light .text-slate-400 { color: var(--text-secondary) !important; }
html.light .text-slate-500 { color: var(--text-muted) !important; }
html.light .text-slate-600 { color: var(--text-muted) !important; }
html.light .text-slate-700 { color: var(--text-muted) !important; }

html.light h2.text-lg.font-semibold {
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--text-primary) !important;
  letter-spacing: -0.01em;
}

/* ── Borders ── */
html.light .border-slate-800 { border-color: var(--border-color) !important; }
html.light .border-slate-700 { border-color: var(--border-input) !important; }

/* ── Cards ── */
html.light .card,
html.light .news-panel {
  background: var(--bg-card) !important;
  border: 1px solid var(--border-color) !important;
  border-radius: 12px;
  box-shadow: var(--shadow-card) !important;
}

html.light .section-header .w-1 {
  background: var(--accent-green) !important;
}

/* ── Calculator inputs & selects ── */
html.light .calc-input {
  background-color: var(--bg-input) !important;
  border: 1.5px solid var(--border-input) !important;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.9rem;
  color: var(--text-primary) !important;
  transition: all 0.15s ease;
}

html.light .calc-input:focus {
  border-color: var(--accent-green) !important;
  box-shadow: 0 0 0 3px rgba(22,163,74,0.12) !important;
  outline: none;
}

html.light .calc-input:hover:not(:focus) {
  border-color: var(--border-input) !important;
}

/* Light mode select arrow — fully self-contained, no cascade dependency */
html.light select.calc-input,
html.light select.addon-select {
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
  appearance: none !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23555' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: right 12px center !important;
  background-size: 12px 8px !important;
  padding-right: 36px !important;
}

html.light .addon-select {
  background-color: #f1f5f9 !important;
  border-color: var(--border-input) !important;
  color: var(--text-secondary) !important;
}

html.light .addon-suffix,
html.light .addon-prefix {
  background: #f1f5f9 !important;
  border-color: var(--border-input) !important;
  color: var(--text-muted) !important;
}

html.light .input-with-addon .calc-input.with-addon {
  border-left: 1px solid var(--border-input) !important;
}

html.light .input-label {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text-primary) !important;
}

html.light .input-hint {
  font-weight: 400;
  font-size: 0.75rem;
  color: var(--text-secondary) !important;
}

/* ── Pip mode row ── */
html.light #pipModeRow > div {
  background: #f8fafc !important;
  border: 1px solid var(--border-color) !important;
  border-radius: 8px;
  padding: 10px 16px;
}
html.light #pipModeRow .text-slate-400 { color: var(--text-primary) !important; font-weight: 600; }
html.light #pipModeRow .text-slate-300 { color: var(--text-secondary) !important; font-weight: 500; }
html.light #pipModeRow .text-slate-600 { color: var(--text-muted) !important; }
html.light #pipModeRow .border-slate-600 { border-color: var(--border-color) !important; }

/* ── Quick Preset pills ── */
html.light .preset-pill {
  background: #f1f5f9 !important;
  border: 1.5px solid var(--border-color) !important;
  color: var(--text-secondary) !important;
  border-radius: 20px;
  padding: 5px 14px;
  font-weight: 500;
  font-size: 0.8rem;
  transition: all 0.15s ease;
}

html.light .preset-pill:hover {
  background: #f0fdf4 !important;
  border-color: #86efac !important;
  color: #15803d !important;
}

html.light .preset-pill.active {
  background: var(--accent-green-light) !important;
  border-color: var(--accent-green) !important;
  color: #15803d !important;
  font-weight: 600;
}

/* ── Scenario input ── */
html.light .scenario-input {
  background: var(--bg-card) !important;
  border-color: var(--border-input) !important;
  color: var(--text-primary) !important;
}

/* ── Buttons ── */
html.light .btn-primary {
  background: var(--accent-green) !important;
  color: white !important;
  font-weight: 600;
  font-size: 0.9rem;
  border-radius: 8px;
  padding: 11px 22px;
  border: none;
  box-shadow: 0 2px 4px rgba(22,163,74,0.25);
  transition: all 0.15s ease;
}

html.light .btn-primary:hover {
  background: var(--accent-green-hover) !important;
  box-shadow: 0 4px 8px rgba(22,163,74,0.35) !important;
  transform: translateY(-1px);
}

html.light .btn-secondary {
  background: transparent !important;
  border: 1.5px solid var(--border-input) !important;
  color: var(--text-secondary) !important;
  font-weight: 500;
  border-radius: 8px;
  padding: 11px 22px;
  transition: all 0.15s ease;
}

html.light .btn-secondary:hover {
  border-color: var(--text-secondary) !important;
  color: var(--text-primary) !important;
  background: transparent !important;
}

html.light .kbd-hint {
  background: rgba(0,0,0,0.06) !important;
  border-color: rgba(0,0,0,0.1) !important;
  color: rgba(5,46,22,0.6) !important;
}

html.light .kbd-hint--muted {
  color: rgba(71,85,105,0.5) !important;
}

/* ── Results section ── */
html.light .bg-emerald-950\/40 {
  background: #f8fafc !important;
  border: 1px solid var(--border-color) !important;
  border-top: 3px solid var(--accent-green) !important;
  border-radius: 10px;
}

html.light #resultPositionSize {
  font-weight: 700;
  font-size: 1.4rem;
  color: var(--text-primary) !important;
}

html.light .text-emerald-300 { color: var(--text-primary) !important; }
html.light .text-emerald-400 { color: var(--accent-green) !important; }
html.light .text-emerald-500 { color: var(--accent-green) !important; }

html.light .stat-card {
  background: #f8fafc !important;
  border: 1px solid var(--border-color) !important;
  border-top: 3px solid var(--accent-green) !important;
  border-radius: 10px;
  padding: 16px;
}

html.light .stat-label {
  font-weight: 600;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary) !important;
}

html.light .stat-value {
  font-weight: 700;
  font-size: 1.05rem;
}

html.light .bg-slate-950,
html.light [class*="bg-slate-950"] { background: #f8fafc !important; }
html.light .bg-slate-800\/50        { background: #f3f4f6 !important; }

/* ── Scenario comparison table ── */
html.light .scenario-table th {
  background: #f8fafc !important;
  border-bottom: 2px solid var(--border-color) !important;
  font-weight: 600;
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary) !important;
}

html.light .scenario-table td {
  color: var(--text-primary) !important;
  border-bottom: 1px solid #f1f5f9 !important;
  font-size: 0.875rem;
}

html.light .scenario-table tbody tr:nth-child(even) td { background: white; }
html.light .scenario-table tbody tr:nth-child(odd)  td { background: #fafafa; }
html.light .scenario-table tr:hover td { background: #f0fdf4 !important; }
html.light .scenario-table .scenario-active td { background: rgba(22,163,74,0.06) !important; }

/* ── Drawdown results ── */
html.light #ddMaxLoss.stat-value      { color: #dc2626 !important; }
html.light #ddSurviving.stat-value    { color: var(--accent-green) !important; }
html.light #ddRecovery.stat-value     { color: #d97706 !important; }
html.light .text-red-400              { color: #dc2626 !important; }
html.light .text-orange-400           { color: #d97706 !important; }

/* ── Drawdown chart container ── */
html.light #ddChartContainer {
  background: #f8fafc !important;
  border-color: var(--border-color) !important;
  border-radius: 12px;
}

/* ── News panel ── */
html.light .news-panel {
  max-height: 75vh;
  overflow-y: auto;
}

html.light .news-panel::-webkit-scrollbar       { width: 4px; }
html.light .news-panel::-webkit-scrollbar-track { background: transparent; }
html.light .news-panel::-webkit-scrollbar-thumb { background: #e2e8f0; border-radius: 2px; }
html.light .news-panel::-webkit-scrollbar-thumb:hover { background: #cbd5e1; }

html.light .news-panel-header {
  background: var(--bg-card) !important;
  border-color: var(--border-color) !important;
}

html.light .news-card {
  background: transparent !important;
  border: none !important;
  border-bottom: 1px solid #f1f5f9 !important;
  border-radius: 8px;
  margin-bottom: 4px;
  padding: 14px 16px;
  transition: all 0.15s ease;
}

html.light .news-card:hover {
  background: #f8fafc !important;
  border-left: 3px solid var(--accent-green) !important;
  padding-left: 13px;
}

html.light .news-title {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-primary) !important;
  line-height: 1.4;
}

html.light .news-snippet  { color: var(--text-secondary) !important; }
html.light .news-meta     { color: var(--text-muted) !important; }

html.light .news-source-badge {
  background: #e8f4fd !important;
  color: #1a6fa8 !important;
  border: none !important;
  border-radius: 9999px;
  font-size: 0.65rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  padding: 0.15rem 0.5rem;
}

/* ── Filter / source chips ── */
html.light .filter-chip {
  background: #f1f5f9 !important;
  border: 1.5px solid var(--border-color) !important;
  color: var(--text-secondary) !important;
  border-radius: 20px;
  padding: 5px 14px;
  font-weight: 500;
  font-size: 0.8rem;
  transition: all 0.15s ease;
}

html.light .filter-chip:hover {
  background: #f0fdf4 !important;
  border-color: #86efac !important;
  color: #15803d !important;
}

html.light .filter-chip.active {
  background: var(--accent-green-light) !important;
  border-color: var(--accent-green) !important;
  color: #15803d !important;
  font-weight: 600;
}

/* ── Economic Calendar wrapper ── */
html.light .calendar-wrapper {
  background: var(--bg-card) !important;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

/* ── About section feature cards ── */
html.light #about .card > div > div {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 20px;
  box-shadow: var(--shadow-card);
}

html.light #about .text-emerald-400 { color: var(--accent-green) !important; font-size: 1.4rem; }

/* ── Footer ── */
html.light footer {
  background: #f8fafc !important;
  border-top: 1px solid var(--border-color) !important;
  padding: 32px 0;
}

html.light footer .font-semibold {
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary) !important;
  margin-bottom: 12px;
}

html.light footer p      { color: var(--text-secondary) !important; font-size: 0.8rem; }
html.light footer a      { color: var(--text-secondary) !important; }
html.light footer a:hover { color: var(--accent-green) !important; }

/* ── Footer legal small print ── */
.footer-legal {
  font-size: 11px;
  opacity: 0.28;
  line-height: 1.6;
}

html.light .footer-legal { color: #0f172a; }
html.dark .footer-legal { color: rgba(241,245,249,0.28); font-size: 11px; }

html.light .border-slate-800.mt-6 {
  border-color: var(--border-color) !important;
}

html.light footer .text-slate-600 { color: var(--text-muted) !important; font-size: 0.75rem; }

html.light .text-amber-200\/80 { color: #78350f !important; font-size: 0.85rem; }
html.light .text-amber-300     { color: #92400e !important; }

/* ============================================================
   SITE HEADER
   ============================================================ */
.site-header {
  background: #0f172a;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  position: sticky;
  top: 0;
  z-index: 100;
}

.site-header__inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
}

.site-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.site-logo__icon {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: rgba(34,197,94,0.15);
  border: 1px solid rgba(34,197,94,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.site-logo__name {
  display: block;
  font-size: 1rem;
  font-weight: 600;
  color: #ffffff;
  line-height: 1.2;
}

.site-logo__tagline {
  display: block;
  font-size: 0.7rem;
  color: #64748b;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-link {
  color: #f1f5f9;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 6px;
  text-decoration: none;
  transition: color 0.15s, background 0.15s;
  white-space: nowrap;
}

.nav-link:hover {
  color: #22c55e;
  background: rgba(34,197,94,0.08);
}

.nav-cta {
  background: #22c55e;
  color: #0f172a;
  font-weight: 600;
  font-size: 0.875rem;
  padding: 8px 18px;
  border-radius: 6px;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: background 0.15s;
  margin-left: 8px;
  white-space: nowrap;
}

.nav-cta:hover { background: #16a34a; }

.nav-hamburger {
  display: none;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 6px;
  color: #f1f5f9;
  font-size: 1.2rem;
  width: 36px;
  height: 36px;
  cursor: pointer;
  flex-shrink: 0;
}

@media (max-width: 768px) {
  .nav-hamburger { display: flex; }

  .site-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: -24px;
    right: -24px;
    background: #0f172a;
    border-top: 1px solid rgba(255,255,255,0.08);
    flex-direction: column;
    align-items: stretch;
    padding: 12px 24px 16px;
    gap: 2px;
  }

  .site-nav.open { display: flex; }

  .nav-cta {
    margin-left: 0;
    margin-top: 8px;
    text-align: center;
  }
}

/* Light mode — site header */
html.light .site-header {
  background: var(--bg-nav);
  border-bottom-color: var(--border-color);
}
html.light .site-logo__name  { color: var(--text-primary) !important; }
html.light .site-logo__tagline { color: var(--text-muted) !important; }
html.light .nav-link          { color: var(--text-secondary) !important; }
html.light .nav-link:hover    { color: var(--accent-green) !important; background: #f1f5f9 !important; }
html.light .nav-cta           { background: var(--accent-green) !important; color: white !important; }
html.light .nav-cta:hover     { background: var(--accent-green-hover) !important; }
html.light .site-nav          { background: var(--bg-nav); }
@media (max-width: 768px) {
  html.light .site-nav { background: var(--bg-nav) !important; border-top-color: var(--border-color) !important; }
}
html.light .nav-hamburger { border-color: var(--border-color); color: var(--text-secondary); }

/* ============================================================
   HERO
   ============================================================ */
.hero {
  background: linear-gradient(180deg, #0f172a 0%, #131f35 100%);
  padding: 80px 24px;
  text-align: center;
}

.hero__inner {
  max-width: 680px;
  margin: 0 auto;
}

.hero h1 {
  font-size: clamp(28px, 5vw, 48px);
  font-weight: 700;
  line-height: 1.2;
  color: #ffffff;
}

.hero p {
  font-size: 18px;
  color: #94a3b8;
  margin-top: 16px;
  line-height: 1.6;
}

.hero__cta {
  display: inline-block;
  background: #22c55e;
  color: #0f172a;
  font-weight: 600;
  font-size: 1rem;
  padding: 14px 32px;
  border-radius: 6px;
  text-decoration: none;
  margin-top: 32px;
  transition: background 0.15s, transform 0.1s;
}

.hero__cta:hover {
  background: #16a34a;
  transform: translateY(-1px);
}

/* Light mode — hero */
html.light .hero { background: linear-gradient(180deg, #f0fdf4 0%, #dcfce7 100%) !important; }
html.light .hero h1 { color: #0f172a !important; }
html.light .hero p  { color: var(--text-secondary) !important; }
html.light .hero__cta { background: var(--accent-green) !important; color: white !important; }
html.light .hero__cta:hover { background: var(--accent-green-hover) !important; }

/* ============================================================
   TOOLS GRID
   ============================================================ */
.tools-grid-section {
  background: #0d1729;
  padding: 60px 24px;
  border-top: 1px solid rgba(255,255,255,0.06);
}

.tools-grid-section__inner {
  max-width: 1280px;
  margin: 0 auto;
}

.tools-grid-section__inner h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: #f1f5f9;
  margin-bottom: 32px;
  text-align: center;
}

.tools-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

@media (max-width: 768px) { .tools-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .tools-grid { grid-template-columns: 1fr; } }

.tool-card {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 10px;
  padding: 24px;
  transition: box-shadow 0.2s, transform 0.2s, border-color 0.2s;
  display: flex;
  flex-direction: column;
}

.tool-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
  transform: translateY(-2px);
  border-color: #475569;
}

.tool-card__title {
  font-size: 1rem;
  font-weight: 600;
  color: #f1f5f9;
}

.tool-card__desc {
  font-size: 0.875rem;
  color: #64748b;
  margin-top: 8px;
  line-height: 1.5;
  flex: 1;
}

.tool-card__link {
  display: block;
  color: #22c55e;
  font-weight: 500;
  font-size: 0.875rem;
  margin-top: 16px;
  text-decoration: none;
}

.tool-card__link:hover { color: #4ade80; }

/* Light mode — tools grid */
html.light .tools-grid-section { background: #f8fafc !important; border-top-color: var(--border-color) !important; }
html.light .tools-grid-section__inner h2 { color: var(--text-primary) !important; }
html.light .tool-card { background: #ffffff !important; border-color: #e2e8f0 !important; }
html.light .tool-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.08) !important; }
html.light .tool-card__title { color: #0f172a !important; }
html.light .tool-card__desc  { color: #64748b !important; }
html.light .tool-card__link  { color: var(--accent-green) !important; }
html.light .tool-card__link:hover { color: var(--accent-green-hover) !important; }

/* ============================================================
   CALCULATOR PAGES (lot-size, pip, etc.)
   ============================================================ */

.calculator-page {
  flex: 1;
  max-width: 800px;
  margin: 0 auto;
  padding: 32px 24px;
  width: 100%;
}

/* Ad Slot */
.ad-slot {
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  padding: 24px;
  text-align: center;
  color: #94a3b8;
  font-size: 13px;
  margin: 24px 0;
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Calculator Card */
.calculator-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 32px;
  max-width: 640px;
  margin: 0 auto;
}

.calculator-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.calculator-header h1 {
  font-size: 1.375rem;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.2;
  margin: 0;
}

.calculator-badge {
  font-size: 12px;
  font-weight: 600;
  color: #1d4ed8;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 20px;
  padding: 3px 10px;
  white-space: nowrap;
  flex-shrink: 0;
}

.seo-description {
  font-size: 14px;
  color: #64748b;
  line-height: 1.6;
  margin-bottom: 24px;
}

/* Form Fields */
.calculator-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-bottom: 24px;
}

.form-field {
  display: flex;
  flex-direction: column;
}

.calculator-form label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: #374151;
  margin-bottom: 6px;
}

.calculator-form input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 15px;
  color: #0f172a;
  background: #ffffff;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none;
  appearance: none;
}

.calculator-form input:focus {
  border-color: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.15);
}

.calculator-form input.input-error {
  border-color: #ef4444;
}

.calculator-form input[type="number"]::-webkit-outer-spin-button,
.calculator-form input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.error-msg {
  font-size: 12px;
  color: #ef4444;
  margin-top: 4px;
  display: none;
}

/* Calculate Button */
.btn-calculate {
  width: 100%;
  background: #22c55e;
  color: #0f172a;
  font-size: 15px;
  font-weight: 600;
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.btn-calculate:hover {
  background: #16a34a;
  transform: translateY(-1px);
}

.btn-calculate:active { transform: translateY(0); }

/* Results */
.calculator-results {
  display: none;
  margin-top: 24px;
  border-top: 1px solid #e2e8f0;
  padding-top: 24px;
}

.result-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 10px 0;
  border-bottom: 1px solid #f1f5f9;
}

.result-row:last-of-type { border-bottom: none; }

.result-label {
  font-size: 14px;
  color: #64748b;
  font-weight: 500;
}

.result-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: #0f172a;
  font-family: 'JetBrains Mono', 'Fira Code', Consolas, monospace;
}

.result-note {
  font-size: 12px;
  color: #94a3b8;
  margin-top: 16px;
  line-height: 1.5;
  padding: 10px 14px;
  background: #f8fafc;
  border-radius: 6px;
  border-left: 3px solid #e2e8f0;
}

.calc-disclaimer {
  font-size: 12px;
  color: #94a3b8;
  line-height: 1.6;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid #e2e8f0;
}

.calc-note {
  font-size: 12px;
  color: #64748b;
  margin-top: -12px;
  margin-bottom: 16px;
}

/* Related Tools */
.related-tools {
  max-width: 640px;
  margin: 40px auto 0;
}

.related-tools h2 {
  font-size: 1.125rem;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 16px;
}

.related-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

@media (max-width: 600px) { .related-grid { grid-template-columns: 1fr; } }

.related-card {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 16px;
  text-decoration: none;
  display: block;
  transition: border-color 0.15s, background 0.15s;
}

.related-card:hover {
  border-color: #22c55e;
  background: #f0fdf4;
}

.related-card strong {
  display: block;
  font-size: 14px;
  color: #0f172a;
  font-weight: 600;
}

.related-card span {
  font-size: 13px;
  color: #64748b;
  margin-top: 4px;
  display: block;
}

/* ── Dark mode overrides for calculator page ── */
html:not(.light) .calculator-card {
  background: #1e293b;
  border-color: #334155;
}

html:not(.light) .calculator-header h1 { color: #f1f5f9; }

html:not(.light) .calculator-badge {
  background: #1e3a5f;
  border-color: #1d4ed8;
  color: #93c5fd;
}

html:not(.light) .seo-description { color: #94a3b8; }

html:not(.light) .calculator-form label { color: #cbd5e1; }

html:not(.light) .calculator-form input {
  background: #0f172a;
  border-color: #334155;
  color: #e2e8f0;
}

html:not(.light) .calculator-form input:focus { border-color: #22c55e; }

html:not(.light) .calculator-results { border-top-color: #334155; }

html:not(.light) .result-row { border-bottom-color: #1e293b; }

html:not(.light) .result-label { color: #94a3b8; }

html:not(.light) .result-value { color: #f1f5f9; }

html:not(.light) .result-note {
  background: #0f172a;
  border-left-color: #334155;
  color: #64748b;
}

html:not(.light) .related-tools h2 { color: #f1f5f9; }

html:not(.light) .related-card {
  border-color: #334155;
  background: #1e293b;
}

html:not(.light) .related-card:hover {
  border-color: #22c55e;
  background: rgba(34, 197, 94, 0.08);
}

html:not(.light) .related-card strong { color: #f1f5f9; }

html:not(.light) .related-card span { color: #94a3b8; }

html:not(.light) .ad-slot {
  background: #1e293b;
  border-color: #334155;
  color: #64748b;
}

/* ── Calculator page — wide variant (for position-size page) ── */
.calculator-page--wide { max-width: 960px; }

/* ── Select inputs inside calculator forms ── */
.calculator-form select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 15px;
  color: #0f172a;
  background: #ffffff;
  outline: none;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2394a3b8' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

.calculator-form select:focus {
  border-color: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.15);
}

html:not(.light) .calculator-form select {
  background-color: #0f172a;
  border-color: #334155;
  color: #e2e8f0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2364748b' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
}

html:not(.light) .calculator-form select:focus { border-color: #22c55e; }

/* ── Direction toggle (profit calculator) ── */
.direction-toggle {
  display: flex;
  gap: 8px;
}

.direction-btn {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  background: transparent;
  color: #374151;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.direction-btn.active {
  background: #22c55e;
  color: #ffffff;
  border-color: #22c55e;
}

html:not(.light) .direction-btn {
  border-color: #334155;
  color: #cbd5e1;
  background: transparent;
}

html:not(.light) .direction-btn.active {
  background: #22c55e;
  color: #0f172a;
  border-color: #22c55e;
}

/* ── Growth table (compounding calculator) ── */
.growth-table-wrap {
  overflow-x: auto;
  margin-top: 24px;
  border-top: 1px solid #e2e8f0;
  padding-top: 16px;
}

.growth-table-wrap h2 {
  font-size: 13px;
  font-weight: 600;
  color: #374151;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 12px;
}

.growth-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.growth-table th {
  text-align: left;
  padding: 8px 12px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  font-weight: 600;
  color: #374151;
}

.growth-table td {
  padding: 8px 12px;
  border: 1px solid #e2e8f0;
  color: #374151;
  font-family: 'JetBrains Mono', 'Fira Code', Consolas, monospace;
}

.growth-table tbody tr:nth-child(even) td { background: #f8fafc; }
.growth-table tbody tr:nth-child(odd)  td { background: #ffffff; }

html:not(.light) .growth-table-wrap { border-top-color: #334155; }

html:not(.light) .growth-table-wrap h2 { color: #94a3b8; }

html:not(.light) .growth-table th {
  background: #1e293b;
  border-color: #334155;
  color: #94a3b8;
}

html:not(.light) .growth-table td {
  border-color: #334155;
  color: #e2e8f0;
}

html:not(.light) .growth-table tbody tr:nth-child(even) td { background: #0f172a; }
html:not(.light) .growth-table tbody tr:nth-child(odd)  td { background: #1e293b; }

/* ── Result value colour modifiers ── */
.result-value--green { color: #22c55e !important; }
.result-value--amber { color: #f59e0b !important; }
.result-value--red   { color: #ef4444 !important; }

/* ── News retry button ── */
.news-retry-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 16px;
  background: transparent;
  border: 1px solid #475569;
  border-radius: 6px;
  color: #94a3b8;
  font-size: 12px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.news-retry-btn:hover {
  border-color: #22c55e;
  color: #4ade80;
}

/* ── Scenario table placeholder ── */
.scenario-placeholder-cell {
  text-align: center;
  color: #475569;
  font-size: 13px;
  font-style: italic;
  padding: 20px 12px;
}

/* ============================================================
   NAV DROPDOWN
   ============================================================ */
.nav-dropdown {
  position: relative;
  list-style: none;
}

.nav-dropdown-toggle {
  color: #f1f5f9;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 6px;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
  white-space: nowrap;
}

.nav-dropdown-toggle:hover,
.nav-dropdown.open .nav-dropdown-toggle {
  color: #22c55e;
  background: rgba(34,197,94,0.08);
}

.nav-dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  background: #0f172a;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  min-width: 220px;
  padding: 8px 0;
  display: none;
  z-index: 200;
  list-style: none;
  margin: 4px 0 0;
}

.nav-dropdown:hover .nav-dropdown-menu,
.nav-dropdown.open  .nav-dropdown-menu { display: block; }

.nav-dropdown-menu a {
  display: block;
  padding: 10px 16px;
  color: #f1f5f9;
  font-size: 14px;
  text-decoration: none;
}

.nav-dropdown-menu a:hover {
  background: rgba(255,255,255,0.06);
  color: #22c55e;
}

html.light .nav-dropdown-toggle { color: var(--text-secondary) !important; }
html.light .nav-dropdown-toggle:hover,
html.light .nav-dropdown.open .nav-dropdown-toggle { color: var(--accent-green) !important; background: #f1f5f9 !important; }
html.light .nav-dropdown-menu { background: #ffffff; border-color: var(--border-color); }
html.light .nav-dropdown-menu a { color: var(--text-secondary); }
html.light .nav-dropdown-menu a:hover { background: #f1f5f9; color: var(--accent-green); }

@media (max-width: 768px) {
  .nav-dropdown-menu {
    position: static;
    border: none;
    border-radius: 0;
    background: transparent;
    padding: 0;
    min-width: auto;
    margin: 0;
  }
  .nav-dropdown-menu a { padding: 8px 16px 8px 24px; }
}

/* =============================================================
   UTILITY LAYER
   Replaces Tailwind CDN — defines every utility class used
   across all HTML files in this project.
   ============================================================= */

/* ── Display ── */
.block       { display: block; }
.inline-flex { display: inline-flex; }
.flex        { display: flex; }
.grid        { display: grid; }
.hidden      { display: none !important; }

/* ── Flex ── */
.flex-col      { flex-direction: column; }
.flex-wrap     { flex-wrap: wrap; }
.flex-1        { flex: 1 1 0%; }
.flex-none     { flex: none; }
.items-start   { align-items: flex-start; }
.items-center  { align-items: center; }
.items-baseline{ align-items: baseline; }
.justify-center  { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-end     { justify-content: flex-end; }
.shrink-0      { flex-shrink: 0; }
.ml-auto       { margin-left: auto; }

/* ── Grid ── */
.grid-cols-1 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
.grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.col-span-2  { grid-column: span 2 / span 2; }

/* ── Gap ── */
.gap-1\.5 { gap: 0.375rem; }
.gap-2    { gap: 0.5rem; }
.gap-3    { gap: 0.75rem; }
.gap-4    { gap: 1rem; }
.gap-5    { gap: 1.25rem; }
.gap-6    { gap: 1.5rem; }
.gap-x-5  { column-gap: 1.25rem; }
.gap-y-2  { row-gap: 0.5rem; }

/* ── Space-y ── */
.space-y-2 > :not([hidden]) ~ :not([hidden]) { margin-top: 0.5rem; }
.space-y-4 > :not([hidden]) ~ :not([hidden]) { margin-top: 1rem; }
.space-y-5 > :not([hidden]) ~ :not([hidden]) { margin-top: 1.25rem; }
.space-y-8 > :not([hidden]) ~ :not([hidden]) { margin-top: 2rem; }

/* ── Position ── */
.relative { position: relative; }
.sticky   { position: sticky; }
.top-0    { top: 0; }
.z-10     { z-index: 10; }

/* ── Sizing ── */
.w-full  { width: 100%; }
.w-1     { width: 0.25rem; }
.w-1\.5  { width: 0.375rem; }
.w-3\.5  { width: 0.875rem; }
.w-4     { width: 1rem; }
.w-5     { width: 1.25rem; }
.w-1\/4  { width: 25%; }
.w-1\/3  { width: 33.3333%; }
.w-2\/5  { width: 40%; }
.w-3\/4  { width: 75%; }
.w-4\/5  { width: 80%; }
.w-5\/6  { width: 83.3333%; }
.h-1\.5  { height: 0.375rem; }
.h-3     { height: 0.75rem; }
.h-3\.5  { height: 0.875rem; }
.h-4     { height: 1rem; }
.h-5     { height: 1.25rem; }
.h-6     { height: 1.5rem; }
.min-h-screen { min-height: 100vh; }
.max-w-7xl    { max-width: 80rem; }
.mx-auto      { margin-left: auto; margin-right: auto; }

/* ── Overflow / Scroll ── */
.overflow-hidden  { overflow: hidden; }
.overflow-x-auto  { overflow-x: auto; }
.scroll-mt-20     { scroll-margin-top: 5rem; }

/* ── Interaction ── */
.pointer-events-none { pointer-events: none; }
.cursor-pointer      { cursor: pointer; }
.select-none         { user-select: none; }
.accent-emerald-500  { accent-color: #10b981; }

/* ── Padding ── */
.p-1\.5  { padding: 0.375rem; }
.p-3     { padding: 0.75rem; }
.p-4     { padding: 1rem; }
.p-5     { padding: 1.25rem; }
.p-6     { padding: 1.5rem; }
.px-1    { padding-left: 0.25rem; padding-right: 0.25rem; }
.px-2    { padding-left: 0.5rem;  padding-right: 0.5rem; }
.px-4    { padding-left: 1rem;    padding-right: 1rem; }
.px-5    { padding-left: 1.25rem; padding-right: 1.25rem; }
.px-6    { padding-left: 1.5rem;  padding-right: 1.5rem; }
.py-0\.5 { padding-top: 0.125rem; padding-bottom: 0.125rem; }
.py-2    { padding-top: 0.5rem;   padding-bottom: 0.5rem; }
.py-2\.5 { padding-top: 0.625rem; padding-bottom: 0.625rem; }
.py-3    { padding-top: 0.75rem;  padding-bottom: 0.75rem; }
.py-4    { padding-top: 1rem;     padding-bottom: 1rem; }
.py-5    { padding-top: 1.25rem;  padding-bottom: 1.25rem; }
.py-6    { padding-top: 1.5rem;   padding-bottom: 1.5rem; }
.py-8    { padding-top: 2rem;     padding-bottom: 2rem; }
.pt-3    { padding-top: 0.75rem; }
.pt-4    { padding-top: 1rem; }
.pt-5    { padding-top: 1.25rem; }
.pb-3    { padding-bottom: 0.75rem; }
.pb-4    { padding-bottom: 1rem; }
.pl-3    { padding-left: 0.75rem; }

/* ── Margin ── */
.-mx-1   { margin-left: -0.25rem; margin-right: -0.25rem; }
.mt-0\.5 { margin-top: 0.125rem; }
.mt-1    { margin-top: 0.25rem; }
.mt-2    { margin-top: 0.5rem; }
.mt-4    { margin-top: 1rem; }
.mt-5    { margin-top: 1.25rem; }
.mt-6    { margin-top: 1.5rem; }
.mt-12   { margin-top: 3rem; }
.mb-0\.5 { margin-bottom: 0.125rem; }
.mb-1    { margin-bottom: 0.25rem; }
.mb-2    { margin-bottom: 0.5rem; }
.mb-3    { margin-bottom: 0.75rem; }
.mb-4    { margin-bottom: 1rem; }
.mb-5    { margin-bottom: 1.25rem; }
.mb-6    { margin-bottom: 1.5rem; }

/* ── Typography ── */
.font-sans    { font-family: 'Inter', system-ui, -apple-system, sans-serif; }
.font-mono    { font-family: 'JetBrains Mono', 'Fira Code', Consolas, ui-monospace, monospace; }
.antialiased  { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
.text-xs      { font-size: 0.75rem;  line-height: 1rem; }
.text-sm      { font-size: 0.875rem; line-height: 1.25rem; }
.text-lg      { font-size: 1.125rem; line-height: 1.75rem; }
.text-4xl     { font-size: 2.25rem;  line-height: 2.5rem; }
.text-center  { text-align: center; }
.text-right   { text-align: right; }
.font-medium  { font-weight: 500; }
.font-semibold{ font-weight: 600; }
.font-bold    { font-weight: 700; }
.leading-relaxed  { line-height: 1.625; }
.tracking-wider   { letter-spacing: 0.05em; }
.uppercase        { text-transform: uppercase; }
.whitespace-nowrap{ white-space: nowrap; }
.underline        { text-decoration-line: underline; }
.underline-offset-2 { text-underline-offset: 2px; }

/* ── Text colours ── */
.text-white       { color: #ffffff; }
.text-slate-100   { color: #f1f5f9; }
.text-slate-200   { color: #e2e8f0; }
.text-slate-300   { color: #cbd5e1; }
.text-slate-400   { color: #94a3b8; }
.text-slate-500   { color: #64748b; }
.text-slate-600   { color: #475569; }
.text-slate-700   { color: #334155; }
.text-amber-200   { color: #fde68a; }
.text-amber-200\/80 { color: rgba(253, 230, 138, 0.8); }
.text-amber-300   { color: #fcd34d; }
.text-amber-400   { color: #fbbf24; }
.text-amber-500   { color: #f59e0b; }
.text-amber-500\/80 { color: rgba(245, 158, 11, 0.8); }
.text-emerald-300 { color: #6ee7b7; }
.text-emerald-400 { color: #34d399; }
.text-emerald-500 { color: #10b981; }
.text-red-300     { color: #fca5a5; }
.text-red-400     { color: #f87171; }
.text-orange-400  { color: #fb923c; }
.text-blue-400    { color: #60a5fa; }
.text-purple-400  { color: #c084fc; }

/* ── Background colours ── */
.bg-slate-600      { background-color: #475569; }
.bg-slate-700      { background-color: #334155; }
.bg-slate-800      { background-color: #1e293b; }
.bg-slate-800\/50  { background-color: rgba(30, 41, 59, 0.5); }
.bg-slate-900      { background-color: #0f172a; }
.bg-slate-900\/60  { background-color: rgba(15, 23, 42, 0.6); }
.bg-slate-950      { background-color: #020617; }
.bg-amber-900\/60  { background-color: rgba(120, 53, 15, 0.6); }
.bg-amber-950\/30  { background-color: rgba(69, 26, 3, 0.3); }
.bg-red-500        { background-color: #ef4444; }
.bg-red-500\/10    { background-color: rgba(239, 68, 68, 0.1); }
.bg-red-950\/60    { background-color: rgba(69, 10, 10, 0.6); }
.bg-blue-500       { background-color: #3b82f6; }
.bg-blue-500\/10   { background-color: rgba(59, 130, 246, 0.1); }
.bg-emerald-500    { background-color: #10b981; }
.bg-emerald-500\/10{ background-color: rgba(16, 185, 129, 0.1); }
.bg-emerald-950\/40{ background-color: rgba(2, 44, 34, 0.4); }
.bg-purple-500     { background-color: #a855f7; }
.bg-purple-500\/10 { background-color: rgba(168, 85, 247, 0.1); }

/* ── Border ── */
.border   { border-width: 1px; border-style: solid; }
.border-t { border-top-width: 1px; border-top-style: solid; }
.border-b { border-bottom-width: 1px; border-bottom-style: solid; }
.border-l { border-left-width: 1px; border-left-style: solid; }
.border-slate-600    { border-color: #475569; }
.border-slate-700    { border-color: #334155; }
.border-slate-700\/40{ border-color: rgba(51, 65, 85, 0.4); }
.border-slate-800    { border-color: #1e293b; }
.border-amber-700\/50{ border-color: rgba(180, 83, 9, 0.5); }
.border-amber-800\/30{ border-color: rgba(146, 64, 14, 0.3); }
.border-red-500\/20  { border-color: rgba(239, 68, 68, 0.2); }
.border-red-800\/60  { border-color: rgba(153, 27, 27, 0.6); }
.border-blue-500\/20 { border-color: rgba(59, 130, 246, 0.2); }
.border-emerald-500  { border-color: #10b981; }
.border-emerald-500\/20{ border-color: rgba(16, 185, 129, 0.2); }
.border-emerald-800\/40{ border-color: rgba(6, 95, 70, 0.4); }
.border-purple-500\/20 { border-color: rgba(168, 85, 247, 0.2); }

/* ── Border radius ── */
.rounded     { border-radius: 0.25rem; }
.rounded-md  { border-radius: 0.375rem; }
.rounded-lg  { border-radius: 0.5rem; }
.rounded-xl  { border-radius: 0.75rem; }
.rounded-full{ border-radius: 9999px; }

/* ── Shadow ── */
.shadow-xl { box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.1); }

/* ── Animation ── */
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
.animate-pulse { animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite; }

/* ── Transition ── */
.transition-colors { transition: color 0.15s, background-color 0.15s, border-color 0.15s; }

/* ── Hover states ── */
.hover\:text-slate-300:hover { color: #cbd5e1; }
.hover\:text-slate-400:hover { color: #94a3b8; }
.hover\:bg-slate-800:hover   { background-color: #1e293b; }

/* ── Responsive: sm breakpoint (640px+) ── */
@media (min-width: 640px) {
  .sm\:flex-none    { flex: none; }
  .sm\:col-span-2   { grid-column: span 2 / span 2; }
  .sm\:grid-cols-2  { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sm\:grid-cols-3  { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .sm\:grid-cols-4  { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .sm\:px-6         { padding-left: 1.5rem; padding-right: 1.5rem; }
  .sm\:table-cell   { display: table-cell; }
}

