/* ===== CSS Custom Properties ===== */
:root {
  --bg-primary: #0a0e1a;
  --bg-secondary: #111827;
  --bg-card: rgba(17, 24, 39, 0.7);
  --bg-card-hover: rgba(25, 34, 56, 0.85);
  --bg-glass: rgba(255, 255, 255, 0.04);
  --bg-glass-border: rgba(255, 255, 255, 0.08);
  --bg-input: rgba(255, 255, 255, 0.06);
  --bg-input-focus: rgba(255, 255, 255, 0.1);

  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-tertiary: #64748b;
  --text-muted: #475569;

  --accent-teal: #2dd4bf;
  --accent-cyan: #22d3ee;
  --accent-green: #34d399;
  --accent-red: #f87171;
  --accent-magenta: #f472b6;
  --accent-amber: #fbbf24;
  --accent-blue: #60a5fa;
  --accent-purple: #a78bfa;

  --gradient-positive: linear-gradient(135deg, #2dd4bf, #22d3ee);
  --gradient-negative: linear-gradient(135deg, #f87171, #f472b6);
  --gradient-neutral: linear-gradient(135deg, #60a5fa, #a78bfa);
  --gradient-header: linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #0f172a 100%);

  --border-radius: 16px;
  --border-radius-sm: 10px;
  --border-radius-xs: 6px;

  --shadow-card: 0 8px 32px rgba(0, 0, 0, 0.3);
  --shadow-glow-teal: 0 0 20px rgba(45, 212, 191, 0.15);
  --shadow-glow-red: 0 0 20px rgba(248, 113, 113, 0.15);

  --transition-fast: 0.15s ease;
  --transition-medium: 0.3s ease;
  --transition-slow: 0.5s ease;

  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ===== Reset & Base ===== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-family);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  background-image:
    radial-gradient(ellipse at 10% 20%, rgba(45, 212, 191, 0.05) 0%, transparent 50%),
    radial-gradient(ellipse at 90% 80%, rgba(99, 102, 241, 0.05) 0%, transparent 50%);
}

/* ===== Header ===== */
.app-header {
  background: var(--gradient-header);
  border-bottom: 1px solid var(--bg-glass-border);
  padding: 1.5rem 2rem;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(20px);
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-icon {
  font-size: 1.75rem;
  animation: pulse-glow 3s ease-in-out infinite;
}

@keyframes pulse-glow {

  0%,
  100% {
    filter: drop-shadow(0 0 4px rgba(45, 212, 191, 0.3));
  }

  50% {
    filter: drop-shadow(0 0 12px rgba(45, 212, 191, 0.6));
  }
}

.logo h1 {
  font-size: 1.4rem;
  font-weight: 700;
  background: var(--gradient-positive);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.02em;
}

.tagline {
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 400;
}

/* ===== Main Layout ===== */
.app-main {
  max-width: 1400px;
  margin: 2rem auto;
  padding: 0 1.5rem;
  display: grid;
  grid-template-columns: 420px 1fr;
  gap: 2rem;
  align-items: start;
  min-height: 0;
}

/* ===== Panels ===== */
.panel {
  background: var(--bg-card);
  border: 1px solid var(--bg-glass-border);
  border-radius: var(--border-radius);
  padding: 1.75rem;
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow-card);
  transition: all var(--transition-medium);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.panel-header h2 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.date-range-label {
  font-size: 0.8rem;
  color: var(--text-tertiary);
  background: var(--bg-glass);
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--bg-glass-border);
}

.builder-panel {
  position: sticky;
  top: 6rem;
}

@media (min-width: 961px) {
  .app-main {
    height: calc(100vh - 8.5rem);
    margin: 1.25rem auto;
  }

  .builder-panel,
  .results-panel {
    height: 100%;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: rgba(148, 163, 184, 0.28) transparent;
  }

  .builder-panel {
    position: static;
    top: auto;
  }

  .builder-panel::-webkit-scrollbar,
  .results-panel::-webkit-scrollbar {
    width: 8px;
  }

  .builder-panel::-webkit-scrollbar-track,
  .results-panel::-webkit-scrollbar-track {
    background: transparent;
  }

  .builder-panel::-webkit-scrollbar-thumb,
  .results-panel::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.22);
    border-radius: 999px;
  }

  .builder-panel:hover::-webkit-scrollbar-thumb,
  .results-panel:hover::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.38);
  }
}

.mode-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.mode-tab {
  flex: 1;
  justify-content: center;
}

.mode-tab.active {
  background: rgba(45, 212, 191, 0.18);
  color: var(--accent-teal);
  border-color: var(--accent-teal);
}

/* ===== Form Elements ===== */
.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-row {
  display: flex;
  gap: 1rem;
}

.form-group.half {
  flex: 1;
}

.earliest-start-hint {
  font-size: 0.72rem;
  color: var(--text-tertiary);
  margin-top: 0.35rem;
}

#preset-search {
  margin-bottom: 0.5rem;
}

.picker-search {
  margin-bottom: 0.5rem;
}

#index-search,
#commodity-search {
  margin-bottom: 0.5rem;
}

.scenario-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}

#saved-scenarios-select {
  flex: 1;
  min-width: 170px;
}

#scenario-status {
  min-height: 1.1rem;
}

input[type="text"],
input[type="number"],
input[type="date"],
select {
  width: 100%;
  padding: 0.65rem 0.85rem;
  background: var(--bg-input);
  border: 1px solid var(--bg-glass-border);
  border-radius: var(--border-radius-xs);
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 0.9rem;
  transition: all var(--transition-fast);
  outline: none;
}

input:focus,
select:focus {
  background: var(--bg-input-focus);
  border-color: var(--accent-teal);
  box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.1);
}

select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M6 8.825L.35 3.175l.7-.7L6 7.425l4.95-4.95.7.7z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.85rem center;
  padding-right: 2rem;
}

select option {
  background: #1e293b;
  color: #f1f5f9;
}

input[type="range"] {
  width: 100%;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--bg-input);
  border-radius: 999px;
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  background: var(--accent-teal);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 0 8px rgba(45, 212, 191, 0.4);
  transition: transform var(--transition-fast);
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

/* ===== Holdings Row ===== */
.holding-row {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  margin-bottom: 0.5rem;
  animation: slideIn 0.25s ease;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.holding-row input[type="text"] {
  text-transform: uppercase;
}

.holding-ticker-wrap {
  flex: 2;
  min-width: 0;
}

.holding-ticker-caption {
  margin-top: 0.25rem;
  font-size: 0.68rem;
  color: var(--text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.holding-row input[type="number"] {
  flex: 1;
  min-width: 80px;
}

.btn-remove {
  background: rgba(248, 113, 113, 0.15);
  border: 1px solid rgba(248, 113, 113, 0.25);
  color: var(--accent-red);
  width: 32px;
  height: 32px;
  min-width: 32px;
  border-radius: var(--border-radius-xs);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: all var(--transition-fast);
}

.btn-remove:hover {
  background: rgba(248, 113, 113, 0.3);
  transform: scale(1.1);
}

/* ===== Toggle Switch ===== */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.switch input {
  display: none;
}

.slider {
  position: absolute;
  inset: 0;
  background: var(--bg-input);
  border-radius: 999px;
  cursor: pointer;
  transition: background var(--transition-medium);
  border: 1px solid var(--bg-glass-border);
}

.slider::before {
  content: '';
  position: absolute;
  height: 18px;
  width: 18px;
  left: 2px;
  bottom: 2px;
  background: var(--text-secondary);
  border-radius: 50%;
  transition: all var(--transition-medium);
}

.switch input:checked+.slider {
  background: rgba(45, 212, 191, 0.25);
  border-color: var(--accent-teal);
}

.switch input:checked+.slider::before {
  transform: translateX(20px);
  background: var(--accent-teal);
  box-shadow: 0 0 8px rgba(45, 212, 191, 0.4);
}

/* ===== Leverage Settings ===== */
.leverage-settings {
  background: var(--bg-glass);
  border: 1px solid var(--bg-glass-border);
  border-radius: var(--border-radius-sm);
  padding: 1rem;
  margin-bottom: 1.25rem;
  transition: all var(--transition-medium);
}

#tax-mode-panel .form-group label {
  text-transform: none;
  letter-spacing: 0.02em;
}

#tax-mode-panel .auto-franking-row {
  align-items: flex-start;
  justify-content: flex-start;
  gap: 0.6rem;
}

#tax-mode-panel .auto-franking-row label[for="franking-auto-toggle"] {
  flex: 1;
  min-width: 0;
  line-height: 1.35;
}

#tax-mode-panel .auto-franking-row .switch {
  flex-shrink: 0;
  margin-top: 0.05rem;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  border: none;
  border-radius: var(--border-radius-xs);
  font-family: var(--font-family);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.btn-primary {
  width: 100%;
  padding: 0.85rem;
  background: var(--gradient-positive);
  color: #0a0e1a;
  font-size: 0.95rem;
  border-radius: var(--border-radius-sm);
  box-shadow: 0 4px 16px rgba(45, 212, 191, 0.2);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(45, 212, 191, 0.35);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-secondary {
  width: 100%;
  background: var(--bg-glass);
  color: var(--text-secondary);
  border: 1px dashed var(--bg-glass-border);
  font-size: 0.8rem;
}

.btn-secondary:hover {
  background: var(--bg-input-focus);
  color: var(--text-primary);
  border-color: var(--accent-teal);
}

.btn-chip {
  padding: 0.35rem 0.85rem;
  background: var(--bg-glass);
  color: var(--text-secondary);
  border: 1px solid var(--bg-glass-border);
  font-size: 0.75rem;
  border-radius: 999px;
  text-transform: none;
}

.btn-chip.active {
  background: rgba(45, 212, 191, 0.15);
  color: var(--accent-teal);
  border-color: var(--accent-teal);
}

.btn-chip:hover:not(.active) {
  background: var(--bg-input-focus);
}

/* ===== Allocation Bar ===== */
.allocation-bar {
  padding: 0.55rem 0.85rem;
  border-radius: var(--border-radius-xs);
  font-size: 0.8rem;
  font-weight: 500;
  margin-bottom: 1.25rem;
  text-align: center;
  transition: all var(--transition-fast);
}

.allocation-bar.ok {
  background: rgba(45, 212, 191, 0.1);
  border: 1px solid rgba(45, 212, 191, 0.2);
  color: var(--accent-teal);
}

.allocation-bar.warning {
  background: rgba(251, 191, 36, 0.1);
  border: 1px solid rgba(251, 191, 36, 0.2);
  color: var(--accent-amber);
}

.allocation-bar.error {
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid rgba(248, 113, 113, 0.2);
  color: var(--accent-red);
}

/* ===== Loading ===== */
.loading {
  text-align: center;
  padding: 1.5rem;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--bg-glass-border);
  border-top-color: var(--accent-teal);
  border-radius: 50%;
  margin: 0 auto 0.75rem;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading p {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* ===== Error ===== */
.error-banner {
  padding: 0.75rem 1rem;
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid rgba(248, 113, 113, 0.25);
  border-radius: var(--border-radius-xs);
  color: var(--accent-red);
  font-size: 0.85rem;
  margin-top: 1rem;
}

.range-adjustment-banner {
  padding: 0.75rem 1rem;
  background: rgba(251, 191, 36, 0.12);
  border: 1px solid rgba(251, 191, 36, 0.28);
  border-radius: var(--border-radius-xs);
  color: #fcd34d;
  font-size: 0.8rem;
  margin-bottom: 1rem;
}

.coverage-panel {
  margin-bottom: 1.5rem;
  background: var(--bg-glass);
  border: 1px solid var(--bg-glass-border);
  border-radius: var(--border-radius-sm);
  padding: 1rem;
}

.coverage-panel h3 {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
}

.coverage-table-wrap {
  overflow-x: auto;
}

.coverage-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 620px;
}

.coverage-table th,
.coverage-table td {
  text-align: left;
  font-size: 0.75rem;
  padding: 0.55rem 0.6rem;
  border-bottom: 1px solid var(--bg-glass-border);
  color: var(--text-secondary);
  white-space: nowrap;
}

.coverage-table th {
  color: var(--text-tertiary);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

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

.limit-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.67rem;
  font-weight: 600;
  border: 1px solid rgba(251, 191, 36, 0.28);
  color: #fcd34d;
  background: rgba(251, 191, 36, 0.1);
  margin-right: 0.25rem;
}

.coverage-muted {
  color: var(--text-tertiary);
}

/* ===== Metrics Grid ===== */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.metric-card {
  background: var(--bg-glass);
  border: 1px solid var(--bg-glass-border);
  border-radius: var(--border-radius-sm);
  padding: 1.1rem;
  transition: all var(--transition-medium);
  position: relative;
}

.metric-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  border-radius: var(--border-radius-sm) var(--border-radius-sm) 0 0;
}

.metric-card.positive::before {
  background: var(--gradient-positive);
}

.metric-card.negative::before {
  background: var(--gradient-negative);
}

.metric-card.neutral::before {
  background: var(--gradient-neutral);
}

.metric-card:hover {
  background: var(--bg-card-hover);
  transform: translateY(-3px);
  box-shadow: var(--shadow-card);
}

.metric-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.35rem;
}

.metric-value {
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.metric-value.positive {
  color: var(--accent-green);
}

.metric-value.negative {
  color: var(--accent-red);
}

.metric-value.neutral {
  color: var(--accent-blue);
}

.metric-sub {
  font-size: 0.72rem;
  color: var(--text-tertiary);
  margin-top: 0.25rem;
}

.metric-help,
.chart-help {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--bg-glass);
  border: 1px solid var(--bg-glass-border);
  color: var(--text-muted);
  font-size: 0.6rem;
  font-weight: 700;
  cursor: help;
  transition: all var(--transition-fast);
  position: relative;
}

.metric-help {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  z-index: 2;
}

.chart-help {
  margin-left: 0.5rem;
  flex-shrink: 0;
}

.metric-help:hover,
.chart-help:hover {
  background: var(--accent-teal);
  color: #0a0e1a;
  border-color: var(--accent-teal);
}

.metric-tooltip,
.chart-tooltip {
  display: none;
  position: absolute;
  width: 240px;
  padding: 0.65rem 0.8rem;
  background: #1e293b;
  border: 1px solid rgba(45, 212, 191, 0.25);
  border-radius: var(--border-radius-xs);
  color: var(--text-secondary);
  font-size: 0.72rem;
  line-height: 1.55;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  z-index: 100;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.6);
  pointer-events: none;
}

.metric-tooltip {
  top: calc(100% + 4px);
  right: 0;
}

.chart-tooltip {
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
}

.builder-panel .form-group label {
  position: relative;
}

.builder-panel .chart-help {
  position: static;
}

.builder-panel .chart-tooltip {
  width: min(240px, calc(100% - 0.5rem), calc(100vw - 2.5rem));
  left: auto;
  right: 0;
  transform: none;
}

.metric-help:hover .metric-tooltip,
.chart-help:hover .chart-tooltip {
  display: block;
}

.metric-help.tooltip-open .metric-tooltip,
.chart-help.tooltip-open .chart-tooltip {
  display: block;
}

/* ===== Charts ===== */
.chart-container {
  background: var(--bg-glass);
  border: 1px solid var(--bg-glass-border);
  border-radius: var(--border-radius-sm);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}

.chart-container h3 {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.chart-header h3 {
  margin-bottom: 0;
}

.chart-controls {
  display: flex;
  gap: 0.35rem;
}

.charts-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

.charts-row .chart-container.half {
  margin-bottom: 0;
}

canvas {
  max-height: 350px;
}

/* ===== Footer ===== */
.app-footer {
  max-width: 1400px;
  margin: 2rem auto;
  padding: 1.25rem 1.5rem;
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  border-top: 1px solid var(--bg-glass-border);
}

/* ===== Utility ===== */
.hidden {
  display: none !important;
}

.field-hint {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
  font-style: italic;
}

.deposit-row {
  display: flex;
  gap: 0.5rem;
}

.deposit-row input {
  flex: 1;
}

.deposit-row select {
  width: auto;
  min-width: 120px;
}

.results-note {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  margin-bottom: 1.25rem;
  padding: 0.5rem 0.75rem;
  background: var(--bg-glass);
  border: 1px solid var(--bg-glass-border);
  border-radius: var(--border-radius-xs);
  line-height: 1.5;
}

.results-note strong {
  color: var(--accent-teal);
}

/* ===== Responsive ===== */
@media (max-width: 960px) {
  .app-main {
    grid-template-columns: 1fr;
    gap: 1.25rem;
    margin: 1.25rem auto;
  }

  .builder-panel {
    position: static;
  }

  .charts-row {
    grid-template-columns: 1fr;
  }

  .scenario-actions {
    align-items: stretch;
  }
}

@media (max-width: 600px) {
  .app-header {
    padding: 1rem;
  }

  .header-inner {
    flex-direction: column;
    align-items: flex-start;
  }

  .logo h1 {
    font-size: 1.12rem;
  }

  .tagline {
    font-size: 0.78rem;
  }

  .app-main {
    padding: 0 0.85rem;
    margin: 1rem auto;
    gap: 1rem;
  }

  .panel {
    padding: 1rem;
  }

  .metrics-grid {
    grid-template-columns: 1fr;
    gap: 0.8rem;
  }

  .coverage-table {
    min-width: 500px;
  }

  .form-row {
    flex-direction: column;
    gap: 0;
  }

  input[type="text"],
  input[type="number"],
  input[type="date"],
  select,
  .btn {
    min-height: 42px;
  }

  .btn-chip {
    min-height: 36px;
  }

  .holding-row {
    display: grid;
    grid-template-columns: 1fr 88px 36px;
    gap: 0.4rem;
    align-items: start;
  }

  .holding-row input[type="number"] {
    min-width: 0;
  }

  .holding-ticker-caption {
    white-space: normal;
    line-height: 1.25;
  }

  .btn-remove {
    width: 36px;
    height: 36px;
    min-width: 36px;
  }

  .deposit-row {
    flex-direction: column;
  }

  .deposit-row select {
    width: 100%;
    min-width: 0;
  }

  .scenario-actions {
    flex-direction: column;
  }

  .scenario-actions .btn,
  .scenario-actions select {
    width: 100%;
  }

  .mode-tabs {
    flex-direction: column;
  }

  .mode-tab {
    width: 100%;
  }

  .panel-header {
    align-items: flex-start;
  }

  .date-range-label {
    max-width: 100%;
    white-space: normal;
    line-height: 1.35;
  }

  .chart-header {
    align-items: flex-start;
    gap: 0.75rem;
  }

  .chart-controls {
    width: 100%;
    flex-wrap: wrap;
  }

  .chart-controls .btn-chip {
    flex: 1 1 auto;
    min-width: 110px;
  }

  canvas {
    max-height: 260px;
  }

  .metric-tooltip,
  .chart-tooltip {
    width: min(240px, calc(100vw - 2rem));
    left: auto;
    right: 0;
    transform: none;
  }
}

/* ===== Animations ===== */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.results-panel {
  animation: fadeInUp 0.5s ease;
}
