/* ============================================================
   EduMarkets — Component Styles
   ============================================================ */

/* ── Unified Header (logo + tabs + settings) ── */
.app-header {
  display: flex;
  align-items: stretch;
  padding: 0;
  min-height: 64px;
  border-bottom: none;
  background: var(--bg-surface);
  position: sticky;
  top: 0;
  z-index: 200;
  flex-shrink: 0;
}

.header-logo {
  display: flex;
  align-items: center;
  width: calc(var(--workspace-gutter) + var(--sidebar-width));
  flex-shrink: 0;
  padding-left: 24px;
}

.header-logo-img {
  height: 50px;
  width: auto;
  display: block;
}

/* ── Tab Navigation (inside header) ── */
.header-tab-nav {
  flex: 1;
  display: flex;
  align-items: flex-end;
  gap: 0;
  overflow-x: auto;
  min-width: 0;
}

/* Legacy .tab-nav fallback (modules that haven't migrated yet) */
.tab-nav {
  display: flex;
  align-items: flex-end;
  gap: 0;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
  overflow-x: auto;
  flex-shrink: 0;
  z-index: 100;
}

.tab-btn {
  padding: 20px 22px 14px;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-muted);
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--transition), border-color var(--transition);
  font-family: var(--font);
}

.tab-btn:hover { color: var(--text-secondary); }
.tab-btn.active {
  color: var(--text);
  border-bottom-color: var(--color-accent);
}

/* ── Logo trigger (module switcher) ── */
.logo-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px 8px 6px 0;
  border-radius: var(--r-md);
  transition: opacity var(--transition);
}
.logo-trigger:hover { opacity: 0.75; }

.logo-chevron {
  font-size: 0.65rem;
  color: var(--text-muted);
  transition: transform 0.2s ease;
  line-height: 1;
  display: block;
}
.logo-trigger[aria-expanded="true"] .logo-chevron {
  transform: rotate(180deg);
}

/* ── Module Switcher Overlay ── */
.module-switcher-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
}
.module-switcher-overlay[hidden] { display: none; }

@keyframes msOverlayIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes msModalIn {
  from { opacity: 0; transform: scale(0.95) translateY(-10px); }
  to   { opacity: 1; transform: scale(1)    translateY(0); }
}
.module-switcher-overlay:not([hidden]) {
  animation: msOverlayIn 0.18s ease;
}
.module-switcher-overlay:not([hidden]) .module-switcher-modal {
  animation: msModalIn 0.2s ease;
}

.module-switcher-modal {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 36px;
  max-width: 860px;
  width: 92vw;
  box-shadow: 0 28px 64px rgba(0, 0, 0, 0.45);
}

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

.module-card {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px 20px;
  background: var(--bg-elevated);
  border: 2px solid transparent;
  border-radius: var(--r-md);
  cursor: pointer;
  min-height: 96px;
  transition: border-color 0.15s, background 0.15s;
}
.module-card:hover:not(.module-card--disabled) {
  border-color: var(--border);
}
.module-card--active {
  border-color: var(--color-accent);
}
.module-card--active:hover {
  border-color: var(--color-accent);
}
.module-card--disabled {
  opacity: 0.38;
  cursor: default;
}
.module-card img {
  width: 100%;
  max-width: 210px;
  height: auto;
  display: block;
}
.module-card-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-align: center;
}
.module-card-badge {
  position: absolute;
  top: 7px;
  right: 8px;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--bg-surface);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

/* ── Share / copy-link button ── */
.header-share {
  display: flex;
  align-items: center;
  padding: 0 4px 0 0;
  flex-shrink: 0;
}

.share-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: none;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  cursor: pointer;
  color: var(--text-muted);
  transition: color var(--transition), background var(--transition), border-color var(--transition);
}
.share-btn:hover {
  background: var(--bg-elevated);
  border-color: var(--border);
  color: var(--text-secondary);
}
.share-btn.copied {
  color: var(--positive);
  border-color: var(--positive);
}

.share-icon-check { display: none; }
.share-btn.copied .share-icon-link  { display: none; }
.share-btn.copied .share-icon-check { display: block; }

/* ── Settings hamburger button ── */
.header-settings {
  display: flex;
  align-items: center;
  padding: 0 20px;
  flex-shrink: 0;
  position: relative;
}

.settings-btn {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  background: none;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  cursor: pointer;
  padding: 9px 8px;
  transition: all var(--transition);
}
.settings-btn:hover {
  background: var(--bg-elevated);
  border-color: var(--border);
}

.hamburger-line {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text-secondary);
  border-radius: 1px;
  transition: background var(--transition);
}
.settings-btn:hover .hamburger-line { background: var(--text); }

/* ── Settings dropdown ── */
.settings-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 280px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  z-index: 400;
  overflow-x: hidden;
  overflow-y: auto;
  max-height: calc(100vh - 80px);
  animation: dropdown-appear 120ms ease;
}
@keyframes dropdown-appear {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.settings-dropdown[hidden] { display: none; }

.settings-section-label {
  padding: 10px 16px 4px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
}

.settings-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  font-size: 0.9rem;
  color: var(--text-secondary);
  text-decoration: none;
  transition: background var(--transition), color var(--transition);
  cursor: pointer;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  font-family: var(--font);
}
.settings-item:hover { background: var(--bg-elevated); color: var(--text); text-decoration: none; }
.settings-item.danger { color: var(--negative); }
.settings-item.danger:hover { background: var(--negative-bg); color: var(--negative); }
.settings-item.module-active { color: var(--color-accent-light); font-weight: 600; }

.settings-item-icon {
  font-size: 1rem;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.settings-item-badge {
  margin-left: auto;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 6px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-muted);
}

.settings-divider {
  height: 1px;
  background: var(--border-subtle);
  margin: 4px 0;
}

.settings-loading {
  padding: 10px 16px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ── Tab Panels ── */
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Params Sidebar ── */
.params-sidebar {
  width: 0;
  min-width: 0;
  overflow: hidden;
  border-right: 1px solid var(--border);
  background: var(--bg-surface);
  flex-shrink: 0;
  align-self: stretch;
  transition: width 220ms ease, min-width 220ms ease;
}

.params-sidebar.visible {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  overflow-y: auto;
}

/* Collapsed by user while still on trade/sensitivity tab */
.workspace.sidebar-collapsed .params-sidebar.visible {
  width: 0;
  min-width: 0;
  overflow: hidden;
}

#params-content,
#fx-params-content,
#mm-params-content {
  padding: 20px 16px;
  min-width: var(--sidebar-width);  /* prevents reflow during animation */
}

.params-sidebar-inner {
  padding: 20px 16px;
}

.params-sidebar-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.params-section {
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-subtle);
}
.params-section:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }

/* Sidebar toggle button — floats on workspace border */
.sidebar-toggle-btn {
  position: absolute;
  top: 20px;
  left: calc(var(--workspace-gutter) + var(--sidebar-width) - 12px);
  z-index: 100;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  transition: left 220ms ease, background var(--transition), border-color var(--transition), color var(--transition);
  font-family: var(--font);
  line-height: 1;
}
.sidebar-toggle-btn:hover {
  background: var(--bg-elevated);
  border-color: var(--color-accent);
  color: var(--color-accent-light);
}
.workspace.sidebar-collapsed .sidebar-toggle-btn,
.workspace:not(:has(.params-sidebar.visible)) .sidebar-toggle-btn {
  left: calc(var(--workspace-gutter) - 12px);
}
.workspace { position: relative; }

/* ── Cards ── */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px;
}

.card-sm { padding: 16px 18px; }

.card-title {
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.card-value {
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: lining-nums tabular-nums;  /* A1: lining figures; A2: tabular alignment */
  font-family: var(--font-mono);                   /* A2: monospaced for aligned numerals */
}

/* ── Metrics header (Valuation label + model badge) ── */
.metrics-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.metrics-section-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.card-value.positive { color: var(--positive); }
.card-value.negative { color: var(--negative); }

/* ── Metric row ── */
.metrics-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font);
  white-space: nowrap;
}

.btn-primary {
  background: var(--color-accent);
  color: #fff;
  border-color: var(--color-accent);
}
.btn-primary:hover { background: var(--color-accent-light); }

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text);
  border-color: var(--sidebar-accent-dim);
}
.btn-secondary:hover { border-color: var(--sidebar-accent); color: var(--sidebar-accent); }

.btn-ghost {
  background: none;
  color: var(--text-secondary);
  border-color: transparent;
  padding: 6px 10px;
}
.btn-ghost:hover { color: var(--text); background: var(--bg-elevated); }

.btn-sm { padding: 6px 12px; font-size: 0.82rem; }
.btn-icon { padding: 7px; width: 34px; height: 34px; justify-content: center; }

/* ── Form controls ── */
.form-group {
  margin-bottom: 14px;
}

.form-label {
  display: block;
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 5px;
}

.form-control {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-left: 2px solid var(--border);            /* B1: stable 2px left border (no layout shift on focus) */
  border-radius: var(--r-md);
  color: var(--text);
  font-size: 0.925rem;
  font-family: var(--font);
  transition: border-color var(--transition);
  -webkit-appearance: none;
  appearance: none;
}

.form-control:focus {
  outline: none;
  border-color: var(--color-accent);
  border-left-color: var(--color-accent);          /* B1: accent left-border highlights editable field */
  box-shadow: 0 0 0 2px rgba(46, 109, 164, 0.2);
}

/* B1: Inline input + action button layout (e.g., rate input + "Par" button) */
.input-with-action {
  display: flex;
  gap: 6px;
  align-items: center;
}
.input-with-action .form-control { flex: 1; min-width: 0; }

/* D1: "Par" solver button — inline, compact */
.btn-par {
  white-space: nowrap;
  padding: 6px 9px;
  font-size: 0.72rem;
  font-weight: 600;
  border-radius: var(--r-sm);
  border: 1px solid var(--color-accent);
  background: transparent;
  color: var(--color-accent-light);
  cursor: pointer;
  font-family: var(--font);
  transition: all var(--transition);
  flex-shrink: 0;
}
.btn-par:hover { background: rgba(46,109,164,0.12); }

.form-control::placeholder { color: var(--text-muted); }

select.form-control {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%238b8fa8'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* Field hint — formatted display below a number input */
.field-hint {
  display: block;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 3px;
  font-variant-numeric: tabular-nums;
}

/* Range slider */
input[type="range"] {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 5px;
  background: var(--border);
  border-radius: 3px;
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  background: var(--color-accent);
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid var(--bg-surface);
}
input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  background: var(--color-accent);
  border-radius: 50%;
  border: 2px solid var(--bg-surface);
  cursor: pointer;
}

.slider-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.slider-row .form-control { width: 70px; text-align: right; }

/* Checkbox / toggle */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
}
.toggle-label {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.toggle {
  position: relative;
  display: inline-block;
  width: 38px;
  height: 22px;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--border);
  border-radius: 22px;
  transition: background var(--transition);
}
.toggle-slider::before {
  content: '';
  position: absolute;
  height: 16px; width: 16px;
  left: 3px; top: 3px;
  background: white;
  border-radius: 50%;
  transition: transform var(--transition);
}
.toggle input:checked + .toggle-slider { background: var(--color-accent); }
.toggle input:checked + .toggle-slider::before { transform: translateX(16px); }

/* Radio group */
.radio-group {
  display: flex;
  gap: 2px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 3px;
}
.radio-group label {
  flex: 1;
  text-align: center;
  padding: 6px 8px;
  font-size: 0.85rem;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-muted);
  transition: all var(--transition);
}
.radio-group input[type="radio"] { display: none; }
.radio-group input[type="radio"]:checked + label {
  background: var(--color-accent);
  color: white;
}

/* B3: Perspective toggle — semantic colors for bilateral contract direction */
/* Receive USD = blue (default accent, you receive USD fixed = long rates) */
/* Pay USD     = red  (you pay USD fixed = short rates) */
#tb-p-pay:checked + label {
  background: var(--negative);
  color: white;
}

/* ── Section divider ── */
.section-divider {
  border: none;
  border-top: 1px solid var(--border-subtle);
  margin: 20px 0;
}

/* ── Callout / insight box ── */
.callout {
  border-left: 3px solid var(--color-accent);
  background: var(--bg-elevated);
  border-radius: 0 var(--r-md) var(--r-md) 0;
  padding: 14px 18px;
  font-size: 0.925rem;
  color: var(--text-secondary);
  margin: 16px 0;
}

.callout.positive { border-left-color: var(--positive); background: var(--positive-bg); }
.callout.negative { border-left-color: var(--negative); background: var(--negative-bg); }
.callout.info     { border-left-color: var(--info);     background: var(--info-bg); }

.callout-title {
  font-weight: 600;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-accent-light);
  margin-bottom: 4px;
}

/* ── Badge ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 20px;
  border: 1px solid;
}
.badge-default  { color: var(--text-muted);  border-color: var(--border); }
.badge-accent   { color: var(--color-accent-light); border-color: var(--color-accent); background: rgba(46,109,164,0.1); }
.badge-positive { color: var(--positive); border-color: var(--positive); background: var(--positive-bg); }
.badge-negative { color: var(--negative); border-color: var(--negative); background: var(--negative-bg); }
.badge-warning  { color: var(--warning);  border-color: var(--warning);  background: rgba(245,158,11,0.08); }  /* E1: static data */

/* ── Data table ── */
.data-table-wrap {
  overflow-x: auto;
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.data-table thead th {
  padding: 8px 10px;                               /* D5: compact header height (was 11px 14px) */
  text-align: right;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table thead th:first-child { text-align: left; }

.data-table tbody td {
  padding: 6px 10px;                               /* D5: compact row height (was 9px 14px) */
  text-align: right;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-subtle);
  font-variant-numeric: lining-nums tabular-nums;  /* A1: lining + tabular numerals */
  white-space: nowrap;
}
.data-table tbody td:first-child { text-align: left; }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: var(--bg-elevated); }

.data-table .positive { color: var(--positive); }
.data-table .negative { color: var(--negative); }
.data-table .neutral  { color: var(--neutral); }  /* B2: zero / unchanged amounts */
.data-table .row-principal td { font-weight: 600; color: var(--text); }

/* ── Loading skeleton ── */
.skeleton {
  background: linear-gradient(90deg, var(--bg-elevated) 25%, var(--border) 50%, var(--bg-elevated) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s infinite;
  border-radius: var(--r-sm);
}
@keyframes skeleton-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Error state ── */
.error-box {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  background: var(--negative-bg);
  border: 1px solid rgba(239,68,68,0.25);
  border-radius: var(--r-md);
  font-size: 0.9rem;
  color: var(--negative);
}

/* ── Expandable section ── */
.expander {
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  margin-bottom: 12px;
}

.expander-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--bg-surface);
  cursor: pointer;
  user-select: none;
  font-weight: 600;
  font-size: 0.95rem;
  transition: background var(--transition);
}
.expander-header:hover { background: var(--bg-elevated); }

.expander-icon {
  font-size: 0.85rem;
  color: var(--text-muted);
  transition: transform var(--transition);
}
.expander.open .expander-icon { transform: rotate(180deg); }

.expander-body {
  display: none;
  padding: 18px;
  border-top: 1px solid var(--border);
  background: var(--bg-surface);
}
.expander.open .expander-body { display: block; }

/* ── Chart container ── */
.chart-wrap {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px;
  margin-bottom: 16px;
  position: relative;
}

/* C1: crosshair cursor on the Plotly drag layer (Bloomberg/TradingView convention) */
.chart-wrap .main-svg { cursor: crosshair; }
.chart-wrap .nsewdrag  { cursor: crosshair !important; }

/* C4: chart section titles rendered in HTML, not inside Plotly (saves chart space) */
.chart-section-header {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

/* D3 / E1: data source footer at bottom of params sidebar */
.data-source-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 12px;
  margin-top: 12px;
  border-top: 1px solid var(--border-subtle);
  font-size: 0.75rem;
  color: var(--text-muted);
  flex-wrap: wrap;
}

/* Fullscreen state */
.chart-wrap.is-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 500;
  border-radius: 0;
  margin: 0;
  padding: 20px;
  display: flex;
  flex-direction: column;
}
.chart-wrap.is-fullscreen > div[id] {
  flex: 1;
}

.chart-fullscreen-btn {
  position: absolute;
  top: 8px;
  left: 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.82rem;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: all var(--transition);
  font-family: var(--font);
  opacity: 0.55;
}
.chart-fullscreen-btn:hover { color: var(--text); border-color: var(--color-accent); opacity: 1; }

.chart-title {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 12px;
}

/* ── Theme toggle (inside settings dropdown) ── */
#theme-toggle {
  font-size: 0.9rem;
  font-weight: 500;
}

/* ── Loading spinner ── */
.spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Shared pricer loading state ── */
.pricer-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 40px 24px;
  color: var(--text-muted);
  font-size: 0.9rem;
}
.pricer-loading-spinner {
  width: 24px; height: 24px;
  border: 2.5px solid var(--border);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  flex-shrink: 0;
}

/* ── Standardised error display (use anywhere via innerHTML) ── */
.result-error,
.error-msg {
  box-sizing: border-box;
  width: 100%;
  padding: 10px 14px;
  background: var(--negative-bg);
  border: 1px solid rgba(239,68,68,0.28);
  border-radius: var(--r-md);
  color: var(--negative);
  font-size: 0.875rem;
  overflow-wrap: break-word;
  word-break: break-word;
}

/* ── Scenario card ── */
.scenario-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px;
  cursor: pointer;
  transition: all var(--transition);
}
.scenario-card:hover { border-color: var(--color-accent); }
.scenario-card.selected {
  border-color: var(--color-accent);
  background: rgba(46,109,164,0.06);
}

.scenario-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 8px;
}

.scenario-card-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

.scenario-card-meta {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.scenario-card-narrative {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.55;
  margin-top: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ── Glossary (global — used by all modules) ───────────────────────────────
   HTML structure:
     .glossary-wrap
       .glossary-controls
         .glossary-search-row
           input.form-control.glossary-search
           span.glossary-count
         .glossary-filter-row
           button.glossary-filter-btn[.active]
       .glossary-body
         .glossary-section[.hidden]
           .glossary-section-label
           .glossary-cards
             .glossary-card[.hidden]
               .glossary-card-term
               .glossary-card-def
   ── */

.glossary-wrap {
  max-width: 820px;
}

.glossary-controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 28px;
  position: sticky;
  top: 60px;
  z-index: 19;
  background: var(--bg-surface);
  padding-top: 4px;
  padding-bottom: 12px;
}

.glossary-search-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.glossary-search {
  flex: 1;
  max-width: 440px;
}

.glossary-count {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.glossary-filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.glossary-filter-btn {
  padding: 4px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: transparent;
  cursor: pointer;
  font-family: Inter, sans-serif;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.03em;
  transition: all 0.15s ease;
}

.glossary-filter-btn:hover {
  border-color: var(--color-accent);
  color: var(--text);
}

.glossary-filter-btn.active {
  background: color-mix(in srgb, var(--color-accent) 10%, var(--bg-elevated));
  border-color: var(--color-accent);
  color: var(--color-accent);
}

.glossary-section {
  margin-bottom: 32px;
}

.glossary-section.hidden {
  display: none;
}

.glossary-section-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-accent-light);
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 10px;
}

.glossary-cards {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.glossary-card {
  padding: 11px 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-left: 3px solid var(--color-accent);
  border-radius: 0 var(--r-md) var(--r-md) 0;
}

.glossary-card:hover {
  border-left-color: var(--color-accent-light);
}

.glossary-card.hidden {
  display: none;
}

.glossary-card-term {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.glossary-card-def {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* ── Reference sub-tab pills ─────────────────────────────────────────────── */

.ref-sub-tabs-wrap {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg);
  padding: 4px 0 12px;
}

.ref-sub-tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  width: fit-content;
}

.ref-sub-tab {
  padding: 7px 20px;
  border-radius: 7px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  transition: all 0.15s ease;
}

.ref-sub-tab:hover {
  color: var(--text-secondary);
  background: color-mix(in srgb, var(--text-muted) 8%, transparent);
}

.ref-sub-tab.active {
  background: var(--bg-surface);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.ref-sub-panel {
  display: none;
}

.ref-sub-panel.active {
  display: block;
}

/* ── Learn/Conventions layout (sidebar TOC + content) ────────────────────── */

.learn-layout {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 32px;
  align-items: start;
}

.learn-nav {
  position: sticky;
  top: 80px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
  padding-right: 8px;
}

.learn-nav-link {
  display: block;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  transition: all 0.15s ease;
  line-height: 1.4;
}

.learn-nav-link:hover {
  color: var(--text-secondary);
  background: var(--bg-elevated);
}

.learn-nav-link.active {
  color: var(--color-accent);
  background: color-mix(in srgb, var(--color-accent) 8%, transparent);
  font-weight: 600;
}

.learn-content {
  min-width: 0;
}

.learn-chapter {
  margin-bottom: 48px;
  scroll-margin-top: 80px;
}

.learn-chapter:last-child {
  margin-bottom: 24px;
}

.learn-chapter-body p {
  font-size: 0.925rem;
  color: var(--text-secondary);
  line-height: 1.65;
  margin-bottom: 12px;
}

/* ── Shared content components (Learn/Conventions) ───────────────────────── */

.learn-key-facts {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 20px;
  align-items: center;
  padding: 16px 20px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  margin: 16px 0;
}

.learn-key-sym {
  font-weight: 700;
  font-family: var(--font-mono, monospace);
  color: var(--color-accent-light);
  font-size: 0.95rem;
  white-space: nowrap;
}

.learn-key-def {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.learn-formula-box {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 24px 20px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  margin: 16px 0;
}

.learn-formula-inline {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 13px 20px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-family: var(--font-mono, monospace);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  margin: 14px 0;
}

.learn-example {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  margin: 16px 0;
  overflow: hidden;
}

.learn-example-title {
  padding: 9px 16px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
}

.learn-example-body {
  padding: 16px 18px;
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.65;
}

.learn-example-body strong { color: var(--text); }

.learn-example-result {
  margin-top: 10px;
  padding: 10px 14px;
  background: color-mix(in srgb, var(--color-accent) 8%, var(--bg-elevated));
  border: 1px solid color-mix(in srgb, var(--color-accent) 25%, transparent);
  border-radius: var(--r-md);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  font-family: var(--font-mono, monospace);
}

.learn-callout {
  padding: 14px 18px;
  background: var(--bg-elevated);
  border-left: 3px solid var(--color-accent);
  border-radius: 0 var(--r-md) var(--r-md) 0;
  margin: 16px 0;
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.learn-callout-title {
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
  font-size: 0.82rem;
}

/* ── Glossary pricer deep-link ───────────────────────────────────────────── */

.glossary-card-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.glossary-pricer-link {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--color-accent);
  text-decoration: none;
  white-space: nowrap;
  transition: opacity 0.15s;
}

.glossary-pricer-link:hover {
  opacity: 0.75;
}

/* ── Responsive: collapse sidebar on narrow screens ──────────────────────── */

@media (max-width: 768px) {
  .learn-layout {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .learn-nav {
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 4px;
    max-height: none;
    padding-right: 0;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
  }
}

/* ── Learn tab (legacy — kept for backward compat) ── */
.learn-section {
  margin-bottom: 36px;
}

.learn-section-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-subtle);
}

.concept-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px;
  transition: border-color var(--transition);
}
.concept-card-title {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 6px;
}
.concept-card-text {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.user-type-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.rfr-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  margin-top: 12px;
}
.rfr-table th {
  text-align: left;
  padding: 9px 12px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
}
.rfr-table td {
  padding: 9px 12px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-subtle);
}
.rfr-table td:first-child { font-weight: 600; color: var(--text); }
.rfr-table tbody tr:last-child td { border-bottom: none; }

/* ── CIP diagram ── */
.cip-diagram {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 24px;
  text-align: center;
  margin: 16px 0;
}

.flow-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 10px 0;
  font-size: 0.9rem;
}

.flow-box {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 8px 14px;
  font-weight: 600;
  font-size: 0.875rem;
  white-space: nowrap;
}
.flow-box.usd  { border-color: var(--color-accent); color: var(--color-accent-light); }
.flow-box.eur  { border-color: var(--positive);     color: var(--positive); }
.flow-arrow { color: var(--text-muted); font-size: 1.2rem; }
.flow-label { font-size: 0.82rem; color: var(--text-muted); }

/* ── Sensitivity controls ── */
.sensitivity-controls {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px 20px;
  margin-bottom: 16px;
}

.shock-type-selector {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.shock-type-btn {
  padding: 7px 16px;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font);
}
.shock-type-btn:hover { color: var(--text); border-color: var(--color-accent); }
.shock-type-btn.active {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: white;
}

/* (User menu styles removed — replaced by .settings-* above) */

/* ── Shared sidebar form controls (used by MM, FX, and other modules) ── */

.sidebar-section {
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-subtle);
}
.sidebar-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.sidebar-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin: 10px 0 4px;
}
.sidebar-label:first-child { margin-top: 0; }

.sidebar-input,
.sidebar-select,
.param-input,
.param-select {
  width: 100%;
  padding: 7px 10px;
  font-size: 0.88rem;
  font-family: var(--font);
  background: var(--bg-input);
  color: var(--text);
  color-scheme: dark;
  border: 1px solid var(--sidebar-accent-dim);
  border-left: 2px solid var(--sidebar-accent-dim);    /* B1: stable 2px left border — no layout shift on focus */
  border-radius: var(--r-md);
  outline: none;
  transition: border-color var(--transition);
}
[data-theme="light"] .sidebar-input,
[data-theme="light"] .sidebar-select,
[data-theme="light"] .param-input,
[data-theme="light"] .param-select { color-scheme: light; }
.sidebar-input:focus,
.sidebar-select:focus,
.param-input:focus,
.param-select:focus {
  border-color: var(--sidebar-accent);
  border-left-color: var(--sidebar-accent);            /* B1: only color changes, not width */
}

/* Param controls (Money Markets, credit, etc.) */
.param-group { margin-bottom: 12px; }

.param-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.param-input-wrap {
  display: flex;
  align-items: stretch;
}
.param-prefix,
.param-suffix {
  display: flex;
  align-items: center;
  padding: 0 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--sidebar-accent-dim);
  font-size: 0.85rem;
  color: var(--text-muted);
  white-space: nowrap;
}
.param-prefix {
  border-right: none;
  border-radius: var(--r-md) 0 0 var(--r-md);
}
.param-suffix {
  border-left: none;
  border-radius: 0 var(--r-md) var(--r-md) 0;
}
.param-input-wrap .param-input {
  border-radius: 0;
}
.param-input-wrap .param-prefix + .param-input { border-radius: 0; }
.param-input-wrap .param-input:last-child { border-radius: 0 var(--r-md) var(--r-md) 0; }

/* Slider value label */
.slider-val {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
  min-width: 56px;
  text-align: right;
  flex-shrink: 0;
}

/* Inline row for small override fields */
.sidebar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.sidebar-sublabel {
  font-size: 0.78rem;
  color: var(--text-muted);
  min-width: 76px;
  flex-shrink: 0;
}
.sidebar-input-sm {
  flex: 1;
  min-width: 0;
  padding: 5px 8px;
  font-size: 0.82rem;
  font-family: var(--font);
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--sidebar-accent-dim);
  border-left: 2px solid var(--sidebar-accent-dim);   /* B1 */
  border-radius: var(--r-md);
  outline: none;
  transition: border-color var(--transition);
}
.sidebar-input-sm:focus {
  border-color: var(--sidebar-accent);
  border-left-color: var(--sidebar-accent);           /* B1 */
}

/* ── Responsive layout ── */
@media (max-width: 1024px) {
  .tab-content-area {
    padding: 20px 20px 40px;
  }
  .header-logo {
    width: auto;
    padding-left: 16px;
    padding-right: 16px;
  }
}

@media (max-width: 768px) {
  :root { --sidebar-width: 280px; --workspace-gutter: 16px; }
  .tab-content-area {
    padding: 16px 16px 32px;
  }
  .metrics-row {
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  }
  .tab-btn {
    padding: 12px 14px 11px;
    font-size: 0.875rem;
  }
  .header-logo {
    width: auto;
    padding-left: 12px;
    padding-right: 12px;
  }
  .header-logo-img { height: 36px; }
}

/* ── Command Palette (Ctrl+K) ── */
.cmd-palette-overlay {
  position: fixed;
  inset: 0;
  z-index: 600;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 14vh;
}
.cmd-palette-overlay[hidden] { display: none; }

@keyframes cmdPaletteIn {
  from { opacity: 0; transform: scale(0.97) translateY(-6px); }
  to   { opacity: 1; transform: scale(1)    translateY(0); }
}
.cmd-palette-overlay:not([hidden]) .cmd-palette {
  animation: cmdPaletteIn 0.15s ease;
}

.cmd-palette {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 92vw;
  max-width: 560px;
  box-shadow: 0 24px 56px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}

.cmd-palette-search {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.cmd-palette-search-icon {
  flex-shrink: 0;
  color: var(--text-muted);
}

.cmd-palette-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  font-size: 1rem;
  font-family: var(--font);
  color: var(--text);
  min-width: 0;
}
.cmd-palette-input::placeholder { color: var(--text-muted); }

.cmd-palette-esc-hint {
  font-size: 0.7rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 6px;
  flex-shrink: 0;
}

.cmd-palette-results {
  max-height: 380px;
  overflow-y: auto;
  padding: 6px;
}
.cmd-palette-results:empty {
  padding: 20px;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.cmd-section-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 8px 10px 4px;
}

.cmd-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background 0.1s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: var(--font);
}
.cmd-item:hover,
.cmd-item.selected {
  background: var(--bg-elevated);
}
.cmd-item.selected {
  outline: 1px solid var(--color-accent);
}

.cmd-item-icon {
  font-size: 0.75rem;
  color: var(--text-muted);
  width: 18px;
  text-align: center;
  flex-shrink: 0;
}

.cmd-item-label {
  flex: 1;
  font-size: 0.9rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cmd-item-context {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.cmd-item-hint {
  font-size: 0.68rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  flex-shrink: 0;
}

.cmd-no-results {
  padding: 24px 16px;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ── Sortable table headers ── */
th.sortable {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
th.sortable:hover { color: var(--color-accent); }
th.sort-asc::after  { content: ' \25b2'; opacity: 0.7; font-size: 0.7em; }
th.sort-desc::after { content: ' \25bc'; opacity: 0.7; font-size: 0.7em; }

/* ── Table export button ── */
.table-export-btn {
  display: inline-block;
  margin-bottom: 8px;
  font-size: 0.75rem;
  padding: 3px 10px;
}

/* ── Formula Panel (floating) ── */
.formula-panel {
  position: fixed;
  top: 80px;
  right: -420px;
  width: 390px;
  max-height: calc(100vh - 100px);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: 0 8px 32px rgba(0,0,0,0.35);
  z-index: 500;
  display: flex;
  flex-direction: column;
  transition: right 0.25s ease;
  overflow: hidden;
}
.formula-panel--visible { right: 16px; }

.formula-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: grab;
  user-select: none;
  flex-shrink: 0;
}
.formula-panel-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}
.formula-panel-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.3rem;
  cursor: pointer;
  line-height: 1;
  padding: 0 4px;
}
.formula-panel-close:hover { color: var(--text); }

.formula-panel-body {
  padding: 16px;
  overflow-y: auto;
  flex: 1;
}
.formula-section {
  margin-bottom: 16px;
}
.formula-section:last-child { margin-bottom: 0; }

.formula-section-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-weight: 600;
}

.formula-symbolic,
.formula-numeric {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 12px 14px;
  overflow-x: auto;
  font-size: 1.05rem;
}
.formula-numeric {
  font-size: 0.92rem;
  color: var(--color-accent);
}

.formula-var-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}
.formula-var-table th {
  text-align: left;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 4px 6px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}
.formula-var-table td {
  padding: 5px 6px;
  border-bottom: 1px solid rgba(128,128,128,0.1);
  color: var(--text-secondary);
}
.formula-var-sym {
  color: var(--text);
  font-weight: 500;
  min-width: 40px;
}
.formula-var-val {
  font-family: var(--font-mono);
  color: var(--color-accent);
  text-align: right;
}
.formula-var-unit {
  color: var(--text-muted);
  font-size: 0.72rem;
}

.formula-intuition {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.5;
  font-style: italic;
  padding: 10px 12px;
  background: rgba(46,109,164,0.06);
  border-radius: var(--r-md);
  border-left: 3px solid var(--color-accent);
}

/* ── Formula icon button (next to result labels) ── */
.formula-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-size: 0.72rem;
  font-style: italic;
  font-family: 'Georgia', serif;
  cursor: pointer;
  margin-left: 4px;
  vertical-align: middle;
  transition: all 0.15s ease;
  line-height: 1;
  padding: 0;
}
.formula-btn:hover {
  color: var(--color-accent);
  border-color: var(--color-accent);
  background: rgba(46,109,164,0.1);
}
.formula-btn--active {
  color: var(--color-accent);
  border-color: var(--color-accent);
  background: rgba(46,109,164,0.15);
}

/* ── Custom Tooltip ── */
.edu-tooltip {
  position: fixed;
  z-index: 600;
  max-width: 280px;
  padding: 8px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
  color: var(--text-secondary);
  font-size: 0.78rem;
  line-height: 1.45;
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.edu-tooltip--visible {
  opacity: 1;
  transform: translateY(0);
}
