/* PAC Optimizer — Vercel/Linear dark theme */
:root {
  --bg: #0a0a0a;
  --card: #141414;
  --card-hover: #1a1a1a;
  --border: #262626;
  --text: #ededed;
  --muted: #888;
  --accent: #fff;
  --blue: #3b82f6;
  --green: #22c55e;
  --red: #ef4444;
  --amber: #f59e0b;
  --radius: 12px;
  --mono: 'SF Mono', 'Fira Code', 'JetBrains Mono', 'Consolas', monospace;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: 640px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
  transition: max-width 0.4s ease;
}
/* Widen container when results are visible */
.container.wide {
  max-width: 1120px;
}

/* Results 2-column grid */
.results-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 1.5rem;
  align-items: start;
}
.results-main {
  min-width: 0;
}
.results-sidebar {
  position: sticky;
  top: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
@media (max-width: 900px) {
  .container.wide { max-width: 640px; }
  .results-grid {
    grid-template-columns: 1fr;
  }
  .results-sidebar {
    position: static;
  }
}

/* ── Header ────────────────────────── */
.header {
  text-align: center;
  margin-bottom: 2.5rem;
}
.header h1 {
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.header p {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.3rem;
}

/* ── Stepper ───────────────────────── */
.stepper {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin-bottom: 2.5rem;
}
.step-dot {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: var(--muted);
  cursor: default;
}
.step-dot .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--border);
  transition: all 0.3s;
}
.step-dot.active .dot { background: var(--text); box-shadow: 0 0 8px rgba(255,255,255,0.15); }
.step-dot.active { color: var(--text); font-weight: 500; }
.step-dot.done .dot { background: var(--green); }
.step-dot.done { color: var(--green); }

/* ── Sections ──────────────────────── */
section {
  display: none;
  animation: fadeIn 0.3s ease;
}
section.active { display: block; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Card ──────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1rem;
}
.card-title {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 1rem;
}

/* ── Form ──────────────────────────── */
.form-group {
  margin-bottom: 1.2rem;
}
.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  margin-bottom: 0.4rem;
  color: var(--text);
}
.form-group .hint {
  font-size: 0.7rem;
  color: var(--muted);
  margin-top: 0.25rem;
}
input[type="number"],
input[type="text"],
select {
  width: 100%;
  padding: 0.6rem 0.8rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.85rem;
  font-family: var(--mono);
  outline: none;
  transition: border-color 0.2s;
}
input:focus, select:focus {
  border-color: var(--muted);
}
input::placeholder { color: #444; }

/* Range slider */
input[type="range"] {
  width: 100%;
  -webkit-appearance: none;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--text);
  cursor: pointer;
}
.range-value {
  font-family: var(--mono);
  font-size: 0.85rem;
  font-weight: 600;
  text-align: right;
  margin-top: 0.3rem;
}

/* ── Buttons ───────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.6rem 1.4rem;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  border: none;
  font-family: inherit;
}
.btn-primary {
  background: var(--text);
  color: var(--bg);
}
.btn-primary:hover { opacity: 0.85; }
.btn-primary:disabled { opacity: 0.3; cursor: not-allowed; }

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover { border-color: var(--muted); color: var(--text); }

.btn-sm {
  padding: 0.35rem 0.8rem;
  font-size: 0.75rem;
}

.btn-danger {
  color: var(--red);
  background: transparent;
  border: none;
  font-size: 0.75rem;
  cursor: pointer;
  padding: 0.3rem;
}

.actions {
  display: flex;
  gap: 0.8rem;
  justify-content: flex-end;
  margin-top: 1.5rem;
}

/* ── Computed display ──────────────── */
.computed {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.8rem 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-top: 1rem;
}
.computed .label { font-size: 0.78rem; color: var(--muted); }
.computed .value {
  font-family: var(--mono);
  font-size: 1rem;
  font-weight: 600;
}

/* ── Portfolio table ───────────────── */
.pos-table { width: 100%; border-collapse: collapse; }
.pos-table th {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  text-align: left;
  padding: 0.4rem 0.3rem;
  border-bottom: 1px solid var(--border);
}
.pos-table td {
  padding: 0.5rem 0.3rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.pos-table input, .pos-table select {
  width: 100%;
  padding: 0.4rem 0.5rem;
  font-size: 0.8rem;
}
.pos-table .ticker-col { width: 25%; }
.pos-table .num-col { width: 22%; }
.pos-table .price-col { width: 22%; }
.pos-table .del-col { width: 9%; text-align: center; }

.pos-total {
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
  align-items: center;
  margin-top: 0.8rem;
  font-size: 0.82rem;
}
.pos-total .label { color: var(--muted); }
.pos-total .value { font-family: var(--mono); font-weight: 600; }

/* ── Progress ──────────────────────── */
.progress-wrap {
  text-align: center;
  padding: 3rem 0;
}
.progress-spinner {
  width: 32px; height: 32px;
  border: 2px solid var(--border);
  border-top-color: var(--text);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 1.5rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

.progress-step {
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
}
.progress-bar-wrap {
  width: 100%;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  margin: 1rem 0;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: var(--text);
  border-radius: 2px;
  transition: width 0.5s ease;
  width: 0%;
  position: relative;
  overflow: hidden;
}
.progress-bar::after {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255,255,255,0.3) 50%,
    transparent 100%
  );
  animation: shimmer 1.5s infinite;
}
@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}
.progress-elapsed {
  font-size: 0.75rem;
  color: var(--muted);
  font-family: var(--mono);
}

/* ── Email notify ─────────────────── */
.notify-email-wrap {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  text-align: left;
}
.notify-email-wrap label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  margin-bottom: 0.4rem;
}
.notify-email-row {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
}
.notify-email-wrap input {
  flex: 1;
  min-width: 0;
  padding: 0.6rem 0.8rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.85rem;
  outline: none;
  transition: border-color 0.2s;
}
.notify-email-wrap input:focus { border-color: var(--muted); }
#btn-notify {
  padding: 0.6rem 1rem;
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.2s;
}
#btn-notify:hover { opacity: 0.85; }
#btn-notify:disabled { opacity: 0.5; cursor: default; }
.notify-email-wrap .hint {
  font-size: 0.7rem;
  color: var(--muted);
  margin-top: 0.25rem;
}

/* ── Results ───────────────────────── */
.result-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.3rem 1.5rem;
  margin-bottom: 0.8rem;
  transition: border-color 0.2s;
}
.result-card.best {
  border-color: var(--green);
}
.result-rank {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 0.5rem;
}
.result-card.best .result-rank { color: var(--green); }

.result-label {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.8rem;
  line-height: 1.3;
}
.result-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.6rem 1rem;
}
@media (min-width: 700px) {
  .result-metrics {
    grid-template-columns: repeat(6, 1fr);
  }
  .result-metrics-primary {
    grid-template-columns: repeat(3, 1fr);
  }
  .result-metrics-secondary {
    grid-template-columns: repeat(3, 1fr);
  }
}
.metric {
  text-align: center;
  padding: 0.4rem 0;
}
.metric .m-label {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 0.2rem;
}
.metric .m-value {
  font-family: var(--mono);
  font-size: 1rem;
  font-weight: 600;
}
.metric .m-value.positive { color: var(--green); }
.metric .m-value.negative { color: var(--red); }
.metric .m-value.warn { color: var(--amber); }

/* Range bar */
.range-bar {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.8rem;
  font-size: 0.7rem;
  font-family: var(--mono);
  color: var(--muted);
}
.range-bar .bar-track {
  flex: 1;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  position: relative;
}
.range-bar .bar-fill {
  position: absolute;
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--red), var(--amber), var(--green));
  opacity: 0.6;
}

/* ── Result detail (expandable) ───── */
.result-card.expanded {
  border-color: var(--muted);
}
.result-detail {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  animation: fadeIn 0.2s ease;
}
.detail-composition {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.8rem;
}
.comp-item {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.6rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.75rem;
}
.comp-ticker {
  font-family: var(--mono);
  font-weight: 600;
  color: var(--text);
}
.comp-weight {
  color: var(--muted);
  font-family: var(--mono);
}
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}
.detail-item {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  padding: 0.3rem 0;
}
.detail-label { color: var(--muted); }
.detail-value {
  font-family: var(--mono);
  font-weight: 500;
  text-align: right;
}

/* Downloads */
.downloads {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.downloads a {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  font-size: 0.78rem;
  transition: all 0.15s;
  background: var(--card);
}
.downloads a:hover { border-color: var(--muted); background: var(--card-hover); }
.downloads .dl-icon {
  color: var(--muted);
  font-size: 0.9rem;
  flex-shrink: 0;
}

/* ── Advanced toggle ───────────────── */
.advanced-toggle {
  font-size: 0.75rem;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  margin-top: 0.5rem;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}
.advanced-toggle:hover { color: var(--text); }
.advanced-body {
  display: none;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}
.advanced-body.open { display: block; }

/* ── Error ─────────────────────────── */
.error-box {
  padding: 1rem 1.2rem;
  background: rgba(239,68,68,0.08);
  border: 1px solid rgba(239,68,68,0.2);
  border-radius: 8px;
  color: var(--red);
  font-size: 0.82rem;
  margin-top: 1rem;
}

/* ── Grid ──────────────────────────── */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

/* ── Baseline card (Conto Deposito) ── */
.baseline-card {
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.3rem;
  margin-bottom: 1.2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.baseline-label {
  font-size: 0.78rem;
  color: var(--muted);
}
.baseline-label strong {
  color: var(--text);
  font-weight: 600;
}
.baseline-value {
  text-align: right;
}
.baseline-value .amount {
  font-family: var(--mono);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
}
.baseline-gain {
  font-size: 0.7rem;
  color: var(--muted);
  font-family: var(--mono);
  margin-top: 0.15rem;
}

/* ── Goal progress bar ───────────── */
.goal-bar-wrap {
  margin-top: 0.8rem;
}
.goal-bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.65rem;
  color: var(--muted);
  margin-bottom: 0.3rem;
  font-family: var(--mono);
}
.goal-bar-track {
  width: 100%;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}
.goal-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.8s ease;
  background: var(--green);
}
.goal-bar-fill.warn { background: var(--amber); }
.goal-bar-fill.danger { background: var(--red); }

/* ── Result header + compare ─────── */
.result-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}
.compare-check {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.7rem;
  color: var(--muted);
  cursor: pointer;
  flex-shrink: 0;
  user-select: none;
}
.compare-check input[type="checkbox"] {
  -webkit-appearance: none;
  appearance: none;
  width: 16px; height: 16px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  cursor: pointer;
  margin: 0;
  flex-shrink: 0;
  transition: all 0.15s;
  position: relative;
}
.compare-check input[type="checkbox"]:hover {
  border-color: var(--muted);
}
.compare-check input[type="checkbox"]:checked {
  background: var(--blue);
  border-color: var(--blue);
}
.compare-check input[type="checkbox"]:checked::after {
  content: '✓';
  display: block;
  text-align: center;
  color: #fff;
  font-size: 10px;
  line-height: 16px;
}

/* ── Donut chart ─────────────────── */
.detail-flex {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
}
.donut-wrap {
  flex-shrink: 0;
}
.detail-info {
  flex: 1;
  min-width: 0;
}
.donut-legend {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-top: 0.6rem;
}
.donut-legend-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.72rem;
}
.donut-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.donut-legend-item span:last-child {
  color: var(--muted);
  font-family: var(--mono);
}

/* ── Comparison table ────────────── */
.comparison-area {
  margin-top: 1.5rem;
  animation: fadeIn 0.3s ease;
}
.comparison-area h3 {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 0.8rem;
}
.cmp-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.cmp-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}
.cmp-table th,
.cmp-table td {
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--border);
  text-align: right;
  white-space: nowrap;
}
.cmp-table th {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.cmp-metric {
  text-align: left !important;
  color: var(--muted);
  font-weight: 500;
}
.cmp-strat {
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cmp-val {
  font-family: var(--mono);
}
.cmp-best {
  color: var(--green) !important;
  font-weight: 600;
}

/* ── Params badge ─────────────────── */
.params-badge {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.75rem;
  color: var(--muted);
}
.params-badge .pb-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.params-badge .pb-label {
  color: var(--muted);
}
.params-badge .pb-value {
  font-family: var(--mono);
  font-weight: 600;
  color: var(--text);
}

/* ── Tooltip popup ─────────────────── */
.tip-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.tip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 13px; height: 13px;
  border-radius: 50%;
  background: var(--border);
  color: var(--muted);
  font-size: 0.55rem;
  font-weight: 700;
  cursor: help;
  margin-left: 0.2rem;
  vertical-align: middle;
  transition: all 0.15s;
}
.tip:hover {
  background: var(--muted);
  color: var(--bg);
}
.tip-popup {
  display: none;
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: #2a2a2e;
  border: 1px solid #555;
  border-radius: 8px;
  padding: 0.55rem 0.75rem;
  font-size: 0.7rem;
  font-weight: 400;
  color: #f0f0f0;
  white-space: normal;
  width: max-content;
  max-width: 240px;
  line-height: 1.45;
  z-index: 100;
  box-shadow: 0 6px 20px rgba(0,0,0,0.6);
  text-transform: none;
  letter-spacing: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
.tip-popup::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: #2a2a2e;
}
.tip-wrap:hover .tip-popup,
.tip-wrap:focus-within .tip-popup {
  display: block;
}

/* ── Section divider ─────────────── */
.section-title {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 1.5rem 0 0.8rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}
.section-title:first-child { margin-top: 0; }

/* ── What-if card ────────────────── */
.whatif-card {
  margin-bottom: 0;
}
.whatif-card .grid-2 {
  grid-template-columns: 1fr;
}
.wif-results {
  margin-top: 0.8rem;
}
.wif-row {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}
.wif-row:last-child {
  border-bottom: none;
}
.wif-label {
  font-size: 0.72rem;
  font-weight: 500;
  margin-bottom: 0.3rem;
  color: var(--text);
}
.wif-bar {
  margin-bottom: 0.3rem;
}
.wif-nums {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 1rem;
  font-size: 0.68rem;
  font-family: var(--mono);
  color: var(--muted);
}
.wif-nums strong {
  color: var(--text);
}

/* ── Schedule ────────────────────────── */
.schedule-table td.positive { color: var(--green); }
.schedule-table td.negative { color: var(--red); }
.schedule-table td { white-space: nowrap; }

/* Plotly chart overrides for dark theme */
.js-plotly-plot .plotly .modebar { display: none !important; }

/* ── Recommendation banner ─────────── */
.reco-banner {
  padding: 0.8rem 1rem;
  border-radius: 8px;
  border: 1px solid rgba(34,197,94,0.25);
  background: rgba(34,197,94,0.06);
  margin-bottom: 1.2rem;
  font-size: 0.78rem;
  line-height: 1.5;
  color: var(--text);
}
.reco-banner strong { color: var(--green); }
.reco-banner .reco-title {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--green);
  margin-bottom: 0.3rem;
}

/* ── Share buttons ─────────────────── */
.share-card .card-title { margin-bottom: 0.5rem; }
.share-buttons {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.share-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.45rem 0.7rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-size: 0.7rem;
  cursor: pointer;
  transition: all 0.15s;
}
.share-btn:hover { border-color: var(--muted); color: var(--text); }
.share-btn svg { flex-shrink: 0; }
.share-whatsapp:hover { color: #25d366; border-color: #25d366; }
.share-telegram:hover { color: #0088cc; border-color: #0088cc; }
.share-x:hover { color: var(--text); border-color: var(--text); }

/* ── Hero summary ──────────────────── */
.hero-summary {
  display: flex;
  gap: 2rem;
  justify-content: center;
  align-items: center;
  padding: 1.5rem;
  margin-bottom: 1.2rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.hero-stat {
  text-align: center;
  flex: 1;
  max-width: 180px;
}
.hero-stat .hero-value {
  font-family: var(--mono);
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.2;
}
.hero-stat .hero-value.positive { color: var(--green); }
.hero-stat .hero-value.negative { color: var(--red); }
.hero-stat .hero-value.warn { color: var(--amber); }
.hero-stat .hero-label {
  font-size: 0.65rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 0.25rem;
}
.hero-stat .hero-sub {
  font-size: 0.7rem;
  color: var(--muted);
  font-family: var(--mono);
  margin-top: 0.15rem;
}
.hero-gauge {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
  position: relative;
}
.hero-gauge-inner {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--card);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.hero-gauge-pct {
  font-family: var(--mono);
  font-size: 1.3rem;
  font-weight: 700;
  line-height: 1;
}
.hero-gauge-label {
  font-size: 0.5rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 0.15rem;
}

/* ── Score badge ───────────────────── */
.score-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  background: rgba(255,255,255,0.05);
  margin-bottom: 0.5rem;
}
.score-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ── Metric tiers ──────────────────── */
.result-metrics-primary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.6rem 1rem;
}
.result-metrics-primary .m-value {
  font-size: 1.15rem;
}
.result-metrics-secondary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.4rem 1rem;
  margin-top: 0.5rem;
  opacity: 0.7;
}
.result-metrics-secondary .m-value {
  font-size: 0.85rem;
}
.result-metrics-secondary .m-label {
  font-size: 0.55rem;
}
.sharpe-sub {
  font-size: 0.6rem;
  font-family: var(--mono);
  color: var(--muted);
  margin-top: 0.1rem;
}

/* ── Goal bar improved ─────────────── */
.goal-bar-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.3rem;
}
.goal-pct {
  font-family: var(--mono);
  font-size: 0.85rem;
  font-weight: 700;
}
.goal-target-label {
  font-size: 0.7rem;
  color: var(--muted);
}
.goal-bar-track-lg {
  width: 100%;
  height: 10px;
  background: var(--border);
  border-radius: 5px;
  overflow: hidden;
}
.goal-bar-fill-lg {
  height: 100%;
  border-radius: 5px;
  transition: width 0.8s ease;
}

/* ── Rank card accents ─────────────── */
.result-card.rank-1 { border-left: 4px solid var(--green); }
.result-card.rank-2 { border-left: 4px solid var(--blue); }
.result-card.rank-3 { border-left: 4px solid #525252; }
.result-card {
  animation: fadeIn 0.4s ease both;
}

/* ── Range bar improved ────────────── */
.bar-breakeven {
  position: absolute;
  top: -2px;
  width: 2px;
  height: calc(100% + 4px);
  background: var(--text);
  opacity: 0.5;
  z-index: 2;
}
.bar-median {
  position: absolute;
  top: 50%;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text);
  transform: translate(-50%, -50%);
  z-index: 3;
  border: 1.5px solid var(--card);
}
.bar-fill-loss {
  position: absolute;
  height: 100%;
  border-radius: 3px 0 0 3px;
  background: rgba(239,68,68,0.25);
}
.bar-fill-gain {
  position: absolute;
  height: 100%;
  border-radius: 0 3px 3px 0;
  background: rgba(34,197,94,0.25);
}

/* ── Composition always visible ──── */
.comp-always {
  margin-top: 0.8rem;
  padding-top: 0.8rem;
  border-top: 1px solid var(--border);
}

/* ── Mobile ────────────────────────── */
@media (max-width: 480px) {
  .container { padding: 1.2rem 1rem 3rem; }
  .result-metrics { grid-template-columns: repeat(2, 1fr); }
  .result-metrics-primary { display: flex; gap: 0.8rem; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .result-metrics-primary .metric { flex-shrink: 0; min-width: 80px; }
  .result-metrics-secondary { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
  .stepper { gap: 1rem; }
  .baseline-card { flex-direction: column; gap: 0.5rem; text-align: center; }
  .baseline-value { text-align: center; }
  .detail-flex { flex-direction: column; }
  .donut-wrap { align-self: center; }
  .donut-wrap svg { width: 60px; height: 60px; }
  .cmp-table { font-size: 0.7rem; }
  .wif-nums { font-size: 0.6rem; }
  .whatif-card .grid-2 { grid-template-columns: 1fr; }
  .hero-summary { flex-direction: column; gap: 1rem; padding: 1rem; }
  .hero-gauge { width: 80px; height: 80px; }
  .hero-gauge-inner { width: 60px; height: 60px; }
  .hero-gauge-pct { font-size: 1.1rem; }
  .hero-stat .hero-value { font-size: 1.3rem; }
  /* Schedule table: hide less important columns on mobile */
  .schedule-table th:nth-child(3),
  .schedule-table td:nth-child(3),
  .schedule-table th:nth-child(6),
  .schedule-table td:nth-child(6) { display: none; }
  /* Plotly charts: taller on mobile for readability */
  .js-plotly-plot { min-height: 180px; }
  .tip-popup { max-width: 180px; left: 0; transform: none; }
  .tip-popup::after { left: 12px; transform: none; }
}
