*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen,
    Ubuntu, Cantarell, 'Helvetica Neue', Arial, sans-serif;
  line-height: 1.5;
  min-height: 100vh;
}

h1, h2, h3, h4, h5, h6 {
  line-height: 1.2;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  cursor: pointer;
  font: inherit;
  border: none;
  background: none;
}

input, select, textarea {
  font: inherit;
  border: none;
  background: none;
}

ul, ol {
  list-style: none;
}

img {
  max-width: 100%;
  display: block;
}

table {
  border-collapse: collapse;
  width: 100%;
}

:root {
  /* Backgrounds */
  --bg-page: #1a1a1b;
  --bg-section: #2c2c34;
  --bg-input: #373742;
  --bg-input-general: #31333f;
  --bg-select: #383a48;
  --bg-selection-group: #26262f;
  --bg-modal: #202025;
  --bg-sim-cell: #2e2e38;

  /* Text */
  --text-white: #fff;
  --text-standard: #9799ae;
  --text-highlight: #b9b9ce;
  --text-input: #e3e3e3;
  --text-label: #dfe0df;
  --text-sidebar-header: #d3d3eb;
  --text-help: rgba(224, 226, 255, 0.6);

  /* Accent */
  --accent: #0270e8;
  --accent-hover: #2b80ff;
  --accent-active: #3d8bff;
  --primary-blue: #409dff;
  --selected-toggle: #3f5186;

  /* Semantic */
  --danger: #f40d0d;
  --danger-soft: #da6969;
  --warning: #ffa600;
  --success: #0a8c0a;
  --chart-line: #09a07f;

  /* Borders */
  --border: #343940;
  --border-sidebar: #424242;
  --border-input: #4d4d58;
  --border-input-general: #515151;
  --border-modal: #404149;
  --border-separator: #3b3a41;

  /* Sidebar */
  --sidebar-width: 18rem;

  /* Spacing */
  --sp-2: 2px;
  --sp-4: 4px;
  --sp-5: 5px;
  --sp-8: 8px;
  --sp-10: 10px;
  --sp-12: 12px;
  --sp-16: 16px;
  --sp-20: 20px;
  --sp-40: 40px;
  --sp-80: 80px;
}

@media (min-width: 1200px) {
  :root {
    --sidebar-width: 21rem;
  }
}

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg-page);
  color: var(--text-white);
  line-height: 1.15;
}

#app {
  display: flex;
  height: 100%;
  overflow: hidden;
  max-width: 1200px;
  margin: 0 auto;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--bg-page);
  overflow-y: auto;
  height: 100%;
}

.sidebar-header {
  padding: var(--sp-16);
  padding-bottom: var(--sp-8);
}

.sidebar-header h1 {
  font-size: 1.4rem;
  font-weight: 900;
  color: var(--text-white);
}

.sidebar-header p {
  font-size: 0.75rem;
  color: var(--text-standard);
  margin-top: var(--sp-4);
}

.sidebar-content {
  padding: 0;
}

/* ── Results panel ── */
.results {
  flex: 1;
  padding: var(--sp-16) 1.5rem 0.5rem;
  overflow-y: auto;
  height: 100%;
  min-width: 0;
  max-width: 830px;
}

.results-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-standard);
  text-align: center;
  gap: var(--sp-10);
}

.results-empty h2 {
  font-size: 1.5rem;
  font-weight: 900;
  color: var(--text-white);
}

.results-empty p {
  font-size: 0.9375rem;
  line-height: 1.4;
  max-width: 400px;
}

/* ── Mobile toggle button (hidden on desktop) ── */
.mobile-sidebar-toggle {
  display: none;
}

/* ── Mobile sidebar close (hidden on desktop) ── */
.mobile-sidebar-close {
  display: none;
}

/* ── Mobile overlay (hidden on desktop) ── */
.sidebar-overlay {
  display: none;
}

/* ── Mobile ── */
@media (max-width: 900px) {
  html, body {
    height: auto;
    overflow: auto;
  }

  #app {
    flex-direction: column;
    height: auto;
    overflow: visible;
    position: relative;
  }

  /* Sidebar becomes a slide-out overlay */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 85%;
    max-width: 360px;
    min-width: unset;
    height: 100%;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform 250ms ease;
    background: var(--bg-page);
    box-shadow: none;
  }

  .sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.5);
  }

  .mobile-sidebar-close {
    display: block;
    font-size: 1.5rem;
    color: var(--text-standard);
    padding: 2px 8px;
    border-radius: 4px;
  }

  .mobile-sidebar-close:hover {
    color: var(--text-white);
  }

  /* Dark overlay behind sidebar */
  .sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 199;
    opacity: 0;
    pointer-events: none;
    transition: opacity 250ms ease;
  }

  .sidebar-overlay.active {
    opacity: 1;
    pointer-events: auto;
  }

  /* Toggle button */
  .mobile-sidebar-toggle {
    display: flex;
    align-items: center;
    gap: var(--sp-5);
    background: var(--bg-section);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.4rem 0.75rem;
    color: var(--text-highlight);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    flex-shrink: 0;
  }

  .mobile-sidebar-toggle:hover {
    border-color: var(--accent);
  }

  .mobile-sidebar-toggle-icon {
    font-size: 1.1rem;
  }

  /* Results take full screen */
  .results {
    width: 100%;
    height: auto;
    padding: var(--sp-12);
    max-width: 100%;
    overflow: visible;
  }

  /* Portfolio bar adjustments */
  .portfolio-bar-summary {
    font-size: 0.82rem;
    padding: 0.5rem var(--sp-12);
    flex-wrap: wrap;
    gap: var(--sp-4);
  }

  .alloc-slider-row {
    padding: 0 var(--sp-8) 0.55rem;
    gap: var(--sp-6);
  }

  .alloc-slider-label {
    font-size: 0.72rem;
    min-width: 0;
    flex-shrink: 0;
  }

  .alloc-slider {
    min-width: 0;
  }

  /* Results header stacks */
  .results-header {
    flex-direction: column;
    gap: var(--sp-8);
  }

  .results-actions {
    width: 100%;
  }

  .results-actions .btn {
    flex: 1;
  }

  /* Stat cards single column */
  .stats-grid-2col {
    grid-template-columns: 1fr;
  }

  /* Chart aspect ratio taller on mobile */
  .chart-wrapper {
    aspect-ratio: 4 / 3;
  }

  /* Results blocks less spacing */
  .results-block {
    margin-bottom: 40px;
  }

  /* Sim grid smaller cells */
  .sim-grid {
    grid-template-columns: repeat(auto-fill, minmax(55px, 1fr));
  }

  .sim-cell {
    font-size: 0.65rem;
    padding: 4px;
  }

  /* Modal full width on mobile */
  .modal {
    width: 95%;
    max-height: 90vh;
  }

  /* Optimizer table scroll */
  .compare-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* Small phones */
@media (max-width: 480px) {
  .results {
    padding: var(--sp-8);
  }

  .portfolio-bar-summary {
    font-size: 0.75rem;
  }

  .stat-card-2col {
    padding: var(--sp-12);
  }

  .stat-card-value {
    font-size: 24px;
  }

  .stat-card-desc {
    font-size: 0.82rem;
  }
}

/* ── Hide number input spinners ── */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="number"] {
  -moz-appearance: textfield;
}

/* ── Sidebar Sections ── */
.section {
  background: var(--bg-section);
  border-radius: 8px;
  margin: 0 var(--sp-16) var(--sp-16);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 2.5rem;
  padding: 0 var(--sp-16);
  cursor: pointer;
  user-select: none;
  border-radius: 8px;
}

.section-header:hover {
  background: rgba(255, 255, 255, 0.03);
}

.section-header h2 {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text-sidebar-header);
}

.section-chevron {
  font-size: 0.65rem;
  color: var(--text-help);
  transition: transform 150ms ease;
}

.section.open .section-chevron {
  transform: rotate(180deg);
}

.section-body {
  padding: 0.325rem 0.75rem 0.75rem;
  display: none;
  font-size: 0.75rem;
  color: #eee;
}

.section.open .section-body {
  display: block;
}

/* ── Form Controls ── */
.form-group {
  margin-bottom: 0.75rem;
}

.form-group:last-child {
  margin-bottom: 0;
}

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-label);
  margin-bottom: 0.35rem;
}

.form-input {
  width: 100%;
  padding: 0.5em;
  background: var(--bg-input);
  border: 1px solid var(--border-input);
  border-radius: 6px;
  color: #fff;
  font-size: 0.9375rem;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.form-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.form-input::placeholder {
  color: var(--text-help);
}

.form-select {
  width: 100%;
  padding: 0.35rem 1.7rem 0.35rem 0.625rem;
  background: var(--bg-select);
  border: 1px solid var(--border-input);
  border-radius: 6px;
  color: var(--text-input);
  font-size: 0.9375rem;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%239799ae' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  box-shadow: 0 2px 2px rgba(0, 0, 0, 0.05);
}

.form-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.form-row {
  display: flex;
  gap: var(--sp-10);
}

.form-row > * {
  flex: 1;
}

.form-hint {
  font-size: 0.75rem;
  color: var(--text-standard);
  margin-top: var(--sp-4);
}

.form-checkbox {
  display: flex;
  align-items: center;
  gap: var(--sp-8);
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--text-label);
}

.form-checkbox input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* ── Input with unit prefix/suffix ── */
.input-with-unit {
  position: relative;
}

.input-prefix {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-standard);
  font-size: 0.9375rem;
  pointer-events: none;
}

.input-suffix {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-standard);
  font-size: 0.9375rem;
  pointer-events: none;
}

.input-with-unit .form-input.has-prefix {
  padding-left: 24px;
}

.input-with-unit .form-input.has-suffix {
  padding-right: 24px;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-5);
  padding: 0.5em 0.8em;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 600;
  color: #fff;
  transition: background 150ms ease;
}

.btn-primary {
  background: var(--accent);
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: rgba(189, 177, 255, 0.14);
}

.btn-secondary:hover {
  background: rgba(189, 177, 255, 0.19);
}

.btn-danger {
  background: #ca1010;
}

.btn-danger:hover {
  background: #e01d1d;
}

/* ── Portfolio Bar ── */
.portfolio-bar {
  margin-bottom: var(--sp-12);
  background: var(--bg-section);
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: border-color 150ms ease;
}

.portfolio-bar:hover {
  border-color: var(--accent);
}

.portfolio-bar-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-12);
  padding: 0.6rem var(--sp-16);
  cursor: pointer;
  font-size: 0.9375rem;
  color: var(--text-highlight);
}

.portfolio-bar-summary strong {
  color: var(--text-white);
  font-weight: 900;
}

.portfolio-bar-sep {
  color: var(--text-help);
  margin: 0 2px;
}

.portfolio-bar-edit {
  color: var(--primary-blue);
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Allocation Slider ── */
.alloc-slider-row {
  display: flex;
  align-items: center;
  gap: var(--sp-10);
  padding: 0 var(--sp-16) 0.55rem;
}

.alloc-slider-label {
  font-size: 0.875rem;
  font-weight: 600;
  white-space: nowrap;
  min-width: 78px;
}

.alloc-slider-label:first-child {
  text-align: right;
  color: var(--primary-blue);
}

.alloc-slider-label:last-child {
  text-align: left;
  color: var(--warning);
}

.alloc-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 5px;
  border-radius: 3px;
  background: linear-gradient(to right, var(--primary-blue) 0%, var(--primary-blue) var(--pct, 50%), var(--warning) var(--pct, 50%));
  outline: none;
  cursor: pointer;
}

.alloc-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--text-white);
  border: 2px solid var(--border);
  cursor: pointer;
  transition: box-shadow 150ms ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.alloc-slider::-webkit-slider-thumb:hover {
  box-shadow: 0 0 0 4px rgba(64, 157, 255, 0.2), 0 1px 3px rgba(0, 0, 0, 0.4);
}

.alloc-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--text-white);
  border: 2px solid var(--border);
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.alloc-slider::-moz-range-track {
  height: 5px;
  border-radius: 3px;
  background: var(--warning);
}

/* ── Results Header ── */
.results-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  margin-bottom: var(--sp-16);
}

.results-header h2 {
  font-size: 1.75rem;
  font-weight: 900;
}

.results-actions {
  display: flex;
  gap: var(--sp-8);
}

/* ── Results info bar (bordered card) ── */
.results-info-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: var(--sp-16);
  margin-bottom: var(--sp-16);
  font-size: 0.9375rem;
  color: var(--text-standard);
}

/* ── Stats Grid (2-column cards matching ficalc) ── */
.stats-grid-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-10);
  margin-bottom: var(--sp-40);
}

@media (max-width: 700px) {
  .stats-grid-2col {
    grid-template-columns: 1fr;
  }
}

.stat-card-2col {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: var(--sp-16);
  display: flex;
  flex-direction: column;
}

.stat-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-5);
  font-size: 0.9375rem;
  font-weight: 700;
  line-height: 1.4;
  color: var(--text-highlight);
  margin-bottom: 1.125rem;
}

.stat-customized {
  color: var(--warning);
  font-size: 0.8rem;
  cursor: help;
  position: relative;
}

.stat-customized:hover::after {
  content: attr(data-tip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-modal);
  border: 1px solid var(--border-modal);
  color: var(--text-standard);
  font-size: 0.75rem;
  font-weight: 400;
  padding: 4px 8px;
  border-radius: 4px;
  white-space: nowrap;
  z-index: 400;
  pointer-events: none;
}

.stat-help {
  font-size: 1.1rem;
  color: var(--text-help);
  cursor: pointer;
  flex-shrink: 0;
  transition: color 150ms ease;
}

.stat-help:hover {
  color: var(--text-highlight);
}

/* ── Help Popover ── */
.help-popover {
  position: fixed;
  z-index: 350;
  width: 320px;
  background: var(--bg-modal);
  border: 1px solid var(--border-modal);
  border-radius: 8px;
  padding: var(--sp-16);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  font-size: 0.9375rem;
  line-height: 1.5;
  color: var(--text-standard);
}

.help-popover-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-8);
  color: var(--text-white);
}

.help-popover-close {
  font-size: 1.2rem;
  color: var(--text-standard);
  padding: 2px 6px;
}

.help-popover-close:hover {
  color: var(--text-white);
}

.help-popover p {
  margin: 0;
}

.stat-card-value {
  font-size: 30px;
  font-weight: 900;
  color: var(--text-white);
  margin-bottom: 0.5rem;
}

.stat-card-desc {
  font-size: 0.9375rem;
  line-height: 1.4;
  color: var(--text-standard);
}

/* ── Stat card links ── */
.stat-link {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
  font-weight: 600;
}

.stat-link:hover {
  color: var(--text-white);
}

.stat-customize {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.stat-customize:hover {
  color: var(--text-white);
}

/* ── Sim cell highlight/dim states ── */
.sim-cell.highlighted {
  outline: 2px solid var(--primary-blue);
  outline-offset: -1px;
  z-index: 1;
  transform: scale(1.08);
}

.sim-cell.dimmed {
  opacity: 0.2;
}

/* ── Results blocks spacing ── */
.results-block {
  margin-bottom: calc(var(--sp-80) / 3);
}

.results-block-sm {
  margin-bottom: var(--sp-40);
}

.results-block h3 {
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: var(--sp-16);
}

/* ── Chart Container ── */
.chart-section {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: var(--sp-16);
  margin-bottom: var(--sp-16);
}

.chart-section h3 {
  font-size: 0.9375rem;
  font-weight: 700;
  margin-bottom: var(--sp-12);
  color: var(--text-highlight);
}

.chart-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 13 / 7;
}

@media (max-width: 700px) {
  .chart-wrapper {
    aspect-ratio: 6 / 5;
  }
}

/* ── Customize Modal ── */
.customize-modal {
  max-width: 520px;
}

.customize-body {
  padding: 0;
}

.customize-desc {
  font-size: 0.9375rem;
  line-height: 1.5;
  color: var(--text-standard);
  margin-bottom: var(--sp-12);
}

.customize-input-row {
  max-width: 140px;
  margin-bottom: var(--sp-12);
}

.customize-input-row .form-input {
  font-size: 1.1rem;
  padding: 0.5em;
}

.customize-divider {
  border-top: 1px solid var(--border-separator);
  margin: var(--sp-16) 0;
}

.customize-footer {
  display: flex;
  gap: var(--sp-8);
  padding-top: var(--sp-16);
  border-top: 1px solid var(--border-separator);
  margin-top: var(--sp-8);
}

/* ── Simulation Filter Bar ── */
.sim-filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-section);
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 0.5rem var(--sp-12);
  margin-bottom: var(--sp-10);
  font-size: 0.875rem;
  color: var(--text-highlight);
}

.sim-filter-clear {
  color: var(--text-standard);
  font-size: 0.8rem;
  padding: 0.25em 0.5em;
  border-radius: 4px;
  white-space: nowrap;
}

.sim-filter-clear:hover {
  color: var(--text-white);
  background: rgba(255, 255, 255, 0.05);
}

/* ── Simulation Grid ── */
.sim-list {
  margin-top: var(--sp-40);
}

.sim-list h3 {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-white);
  margin-bottom: var(--sp-16);
}

.sim-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
  gap: var(--sp-4);
}

.sim-cell {
  padding: 6px;
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  background: var(--bg-sim-cell);
  color: var(--text-standard);
  transition: transform 100ms ease;
}

.sim-cell:hover {
  transform: scale(1.08);
}

.sim-cell.success {
  background: rgba(10, 140, 10, 0.15);
  color: #4caf50;
  border: 1px solid rgba(10, 140, 10, 0.3);
}

.sim-cell.fail {
  background: rgba(244, 13, 13, 0.12);
  color: var(--danger-soft);
  border: 1px solid rgba(244, 13, 13, 0.25);
}

/* ── Detail Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
}

.modal {
  background: var(--bg-modal);
  border: 1px solid var(--border-modal);
  border-radius: var(--sp-16);
  padding: 1.5rem;
  max-width: 900px;
  width: 90%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-16);
}

.modal-header h2 {
  font-size: 1.25rem;
  font-weight: 700;
}

.modal-close {
  font-size: 1.5rem;
  color: var(--text-standard);
  padding: var(--sp-4);
}

.modal-close:hover {
  color: var(--text-white);
}

/* ── Allocation Bar ── */
.allocation-bar {
  display: flex;
  height: 6px;
  border-radius: 3px;
  overflow: hidden;
  margin: var(--sp-8) 0;
}

.allocation-bar .equity {
  background: var(--primary-blue);
}

.allocation-bar .bond {
  background: var(--warning);
}

.allocation-bar .cash {
  background: var(--chart-line);
}

/* ── Entry List (extra withdrawals / income) ── */
.entry-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
}

.entry-card {
  display: flex;
  align-items: center;
  gap: var(--sp-8);
  padding: 0.5em 0.75em;
  border: 1px solid var(--border-modal);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.02);
  font-size: 0.875rem;
}

.entry-card .entry-name {
  flex: 1;
  color: var(--text-label);
}

.entry-card .entry-amount {
  color: var(--text-standard);
  font-weight: 600;
}

.entry-card .entry-detail {
  color: var(--text-standard);
  font-size: 0.75rem;
  white-space: nowrap;
  margin-left: auto;
  margin-right: var(--sp-4);
}

.entry-card .entry-remove {
  color: var(--text-standard);
  font-size: 1rem;
  padding: 2px 4px;
}

.entry-card .entry-remove:hover {
  color: var(--danger);
}

.entry-card .entry-toggle {
  width: 14px;
  height: 14px;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}

.entry-card.entry-disabled {
  opacity: 0.4;
}

.entry-card.entry-disabled .entry-name,
.entry-card.entry-disabled .entry-amount {
  text-decoration: line-through;
}

/* ── Loading ── */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-8);
  padding: var(--sp-40);
  color: var(--text-standard);
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Strategy params sub-form ── */
.strategy-params {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-separator);
}

/* ── Stats Table (for detail modal) ── */
.stats-table {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.stats-table-row {
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  padding: 0.75rem var(--sp-16);
  font-size: 0.9375rem;
}

.stats-table-row:last-child {
  border-bottom: none;
}

.stats-table-label {
  color: var(--text-standard);
  font-weight: 500;
}

.stats-table-value {
  color: var(--text-white);
  text-align: right;
  flex: 1;
}

/* ── Scrollbar ── */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border-input);
}

/* ── App Footer (disclaimer + donate) ── */
.app-footer {
  text-align: center;
  padding: var(--sp-12) 0 var(--sp-12);
  margin-top: 15px;
  border-top: 1px solid var(--border);
}

.disclaimer {
  font-size: 0.75rem;
  line-height: 1.6;
  color: var(--text-help);
  max-width: 520px;
  margin: 0 auto var(--sp-16);
}

.btn-donate {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-5);
  padding: 0.5em 1.2em;
  background: linear-gradient(135deg, #ffc439, #ffb347);
  color: #1a1a1b;
  font-size: 0.9rem;
  font-weight: 700;
  border-radius: 20px;
  text-decoration: none;
  transition: transform 150ms ease, box-shadow 150ms ease;
}

.btn-donate:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(255, 196, 57, 0.3);
}

.app-footer-buttons {
  display: flex;
  gap: var(--sp-12);
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
}

.btn-contact {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-5);
  padding: 0.5em 1.2em;
  background: var(--bg-section);
  border: 1px solid var(--border);
  color: var(--text-highlight);
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: 20px;
  cursor: pointer;
  transition: transform 150ms ease, border-color 150ms ease;
}

.btn-contact:hover {
  transform: scale(1.05);
  border-color: var(--accent);
}

.soc-t {
  background: #1da1f2;
  color: #fff;
}

.soc-t:hover {
  background: #1a91da;
}

.soc-r {
  background: #ff4500;
  color: #fff;
}

.soc-r:hover {
  background: #e03d00;
}

.soc-group {
  display: flex;
  gap: var(--sp-8);
  margin-top: var(--sp-16);
  padding-top: var(--sp-16);
  border-top: 1px solid var(--border-separator);
  flex-wrap: wrap;
}

.soc-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-8);
  padding: 0.6em;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
  transition: transform 150ms ease, opacity 150ms ease;
}

.soc-btn:hover {
  transform: translateY(-2px);
  opacity: 0.9;
}

.btn-contact svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
  flex-shrink: 0;
  display: block;
}

.soc-btn svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
  flex-shrink: 0;
  display: block;
}

/* ── Compare Chips ── */
.compare-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-8);
  margin-bottom: var(--sp-16);
}

.compare-chip {
  padding: 0.45em 0.85em;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-standard);
  background: var(--bg-section);
  border: 2px solid var(--border);
  cursor: pointer;
  transition: all 150ms ease;
  user-select: none;
}

.compare-chip:hover {
  border-color: var(--text-highlight);
}

.compare-chip.selected {
  border-color: var(--chart-line);
  color: var(--text-white);
  background: rgba(9, 160, 127, 0.15);
}

#compare-overlay {
  min-height: 60vh;
}

.compare-header {
  display: flex;
  align-items: center;
  gap: var(--sp-12);
  margin-bottom: var(--sp-12);
}

.compare-hint {
  color: var(--text-highlight);
  font-size: 1.1rem;
  font-weight: 600;
  text-align: center;
  padding: var(--sp-40) 0;
}

/* ── Comparison Table ── */
.compare-table-wrap {
  overflow-x: auto;
}

.compare-table {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  border-spacing: 0;
  overflow: hidden;
  font-size: 0.9375rem;
}

.compare-table thead th {
  background: var(--bg-section);
  padding: 0.75rem var(--sp-16);
  text-align: center;
  font-weight: 700;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.compare-table thead th:first-child {
  text-align: left;
}

.compare-table tbody td {
  padding: 0.6rem var(--sp-16);
  border-bottom: 1px solid var(--border);
  text-align: center;
  color: var(--text-white);
}

.compare-table tbody tr:last-child td {
  border-bottom: none;
}

.compare-table .compare-label {
  text-align: left;
  color: var(--text-standard);
  font-weight: 500;
  white-space: nowrap;
}

.compare-table .compare-best {
  color: var(--chart-line);
  font-weight: 700;
}

/* ── Compare Section Dividers ── */
.compare-divider td {
  padding: 0 !important;
  height: 6px;
  border-bottom: 2px solid var(--border) !important;
  background: transparent;
}
