:root {
  color-scheme: light dark;
  --bg: #f4f7f5;
  --surface: #ffffff;
  --surface-soft: #edf3f0;
  --text: #17211f;
  --muted: #5b6865;
  --line: #d3ded9;
  --accent: #17685e;
  --accent-strong: #0d5048;
  --accent-soft: #d9eee9;
  --focus: #1769aa;
  --review: #8a5a12;
  --review-soft: #fff0cf;
  --danger: #a63838;
  --danger-soft: #fae2e1;
  --positive: #25825a;
  --shadow: 0 8px 28px rgba(24, 54, 48, 0.08);
  --radius: 18px;
}

* { box-sizing: border-box; }

html { min-height: 100%; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  text-rendering: optimizeLegibility;
}

button, input, select { font: inherit; }
button, select { cursor: pointer; }
button:disabled, select:disabled { cursor: not-allowed; opacity: 0.62; }
[hidden] { display: none !important; }

.shell {
  width: min(100% - 28px, 1120px);
  margin-inline: auto;
}

.site-header {
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
}

.header-inner {
  min-height: 84px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: nowrap;
  padding-block: 12px;
}
.header-scan { display: grid; flex: 0 0 auto; min-width: 180px; justify-items: end; gap: 4px; margin-left: auto; text-align: right; }
.header-scan p { max-width: 180px; margin: 0; color: var(--muted); font-size: 0.72rem; line-height: 1.25; }

h1, h2, h3, h4, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(1.45rem, 5vw, 2rem); letter-spacing: -0.025em; }
h2 { margin-bottom: 10px; font-size: clamp(1.45rem, 5vw, 2.15rem); line-height: 1.16; letter-spacing: -0.025em; }
h3 { margin-bottom: 8px; font-size: clamp(1.18rem, 3vw, 1.45rem); line-height: 1.25; }
h4 { margin-bottom: 6px; font-size: 0.96rem; }

.eyebrow {
  margin-bottom: 3px;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.muted { color: var(--muted); }
.count {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 750;
  white-space: nowrap;
}

main { padding-block: 20px 48px; }
.panel {
  margin-bottom: 18px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.view-nav {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) 46px;
  gap: 4px;
  max-width: 430px;
  margin: 0 auto 18px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface-soft);
}
.view-tab {
  min-height: 42px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-weight: 760;
}
.view-tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: inset 0 3px 0 var(--review), 0 2px 8px rgba(20, 50, 44, 0.1);
}
.settings-tab { display: grid; place-items: center; padding: 0; }
.settings-tab svg { display: block; }

.task-status { margin-bottom: 18px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.task-status > p { margin: 5px 0 0; }
.task-status > .button { margin-top: 12px; }
.button {
  min-height: 46px;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: 11px;
  font-weight: 760;
  text-align: center;
}
.button.primary { background: var(--accent); color: #fff; }
.button.primary:hover { background: var(--accent-strong); }
.button.secondary { border-color: var(--accent); background: transparent; color: var(--accent); }
.button.quiet { border-color: var(--line); background: var(--surface); color: var(--muted); }
.scan-button { min-width: 140px; padding-inline: 10px; white-space: nowrap; }
.button:focus-visible, input:focus-visible, select:focus-visible, .view-tab:focus-visible,
.ledger-month > summary:focus-visible, .ledger-trade-card > summary:focus-visible,
.ledger-sort:focus-visible, .ledger-trade-toggle:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--focus) 55%, transparent);
  outline-offset: 2px;
}

.status-line { display: flex; align-items: center; gap: 9px; }
.phase-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.phase-dot.running { background: var(--accent); box-shadow: 0 0 0 5px var(--accent-soft); animation: pulse 1.5s ease-in-out infinite; }
.phase-dot.complete { background: #25825a; }
.phase-dot.error { background: var(--danger); }
.progress-wrap { margin-top: 14px; }
.progress-track { display: block; width: 100%; height: 9px; overflow: hidden; border: 0; border-radius: 99px; background: var(--surface-soft); appearance: none; }
.progress-track::-webkit-progress-bar { border-radius: 99px; background: var(--surface-soft); }
.progress-track::-webkit-progress-value { border-radius: 99px; background: var(--accent); transition: width 250ms ease; }
.progress-track::-moz-progress-bar { border-radius: 99px; background: var(--accent); }
.progress-wrap p { margin: 7px 0 0; font-size: 0.88rem; }
@keyframes pulse { 50% { box-shadow: 0 0 0 2px var(--accent-soft); } }
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; animation: none !important; transition: none !important; } }

.message { margin: 14px 0 0; padding: 10px 12px; border-radius: 10px; background: var(--accent-soft); color: var(--accent-strong); }
.message.error { background: var(--danger-soft); color: var(--danger); }
.auth-panel { border-color: color-mix(in srgb, var(--review) 35%, var(--line)); }
.auth-panel > p:not(.eyebrow, .message) { color: var(--muted); }
.auth-actions { margin-top: 16px; }
.verifier-form { margin-top: 18px; }
.verifier-form label, .stack label, .filter-control label, .field > label { display: block; margin-bottom: 6px; font-size: 0.84rem; font-weight: 750; }
.inline-form { display: flex; flex-direction: column; gap: 9px; }
input, select {
  width: 100%;
  min-height: 46px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
}
.stack { display: grid; gap: 10px; }
.unlock-panel { max-width: 520px; margin: 32px auto; }


.candidate-section { margin: 24px 0 34px; }
.shared-filter { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.filter-control { width: 100%; }
.filter-control select { min-height: 42px; }
.filter-note { margin: 0; color: var(--muted); font-size: 0.84rem; }
#qualified-list:not(:empty) + .review-list:not(:empty) { margin-top: 14px; }
.candidate-list { display: grid; gap: 14px; }
.empty-state { padding: 24px 16px; border: 1px dashed var(--line); border-radius: 14px; color: var(--muted); text-align: center; }

.candidate-card { overflow: hidden; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: 0 5px 18px rgba(24, 54, 48, 0.06); }
.candidate-card.review { border-top: 4px solid var(--review); }
.card-head { position: relative; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 16px; background: var(--surface-soft); }
.card-toggle { position: absolute; inset: 0; z-index: 1; width: 100%; border: 0; padding: 0; border-radius: 14px; background: transparent; color: var(--muted); }
.card-toggle::after { content: "▾"; position: absolute; right: 16px; bottom: 6px; line-height: 1; }
.card-toggle[aria-expanded="true"]::after { content: "▴"; }
.card-toggle:focus-visible { outline: 3px solid var(--focus); outline-offset: -3px; }
.card-head > :not(.card-toggle) { pointer-events: none; }
.card-head button:not(.card-toggle) { position: relative; z-index: 2; pointer-events: auto; }
.candidate-identity { display: grid; min-width: 0; justify-items: start; gap: 8px; }
.symbol-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; }
.symbol { font-size: 1.3rem; font-weight: 850; letter-spacing: -0.015em; }
.expiration { color: var(--muted); font-size: 0.9rem; }
.refresh-spread { min-height: 32px; padding: 4px 9px; border-radius: 8px; font-size: 0.78rem; }
.card-head .roi { flex: 0 0 auto; text-align: right; }
.roi strong { display: block; color: var(--accent); font-size: 1.35rem; }
.roi span { color: var(--muted); font-size: 0.72rem; font-weight: 750; text-transform: uppercase; }
.position-session-summary { display: none; min-width: 0; justify-items: center; text-align: center; line-height: 1.25; }
.position-session-summary strong { font-size: clamp(0.65rem, 3.2vw, 0.9rem); }
.position-session-summary span { color: var(--muted); font-size: 0.68rem; }
.session-movement { display: flex; align-items: baseline; justify-content: center; gap: 3px; white-space: nowrap; }
.session-as-of { white-space: nowrap; }
.position-session-summary .session-delay { color: var(--review); }
.session-change { font-weight: 800; white-space: nowrap; }
.session-change.positive { color: var(--positive); }
.session-change.negative { color: var(--danger); }
.roi.positive strong { color: var(--positive); }
.roi.negative strong { color: var(--danger); }
.roi.unavailable strong { color: var(--muted); }
.card-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 0; }
.metric { min-width: 0; padding: 12px 14px; border-top: 1px solid var(--line); }
.metric:nth-child(odd) { border-right: 1px solid var(--line); }
.spread-grid .metric:nth-child(odd) { border-right: 0; }
.spread-grid .metric.grid-left { border-right: 1px solid var(--line); }
.metric dt { color: var(--muted); font-size: 0.75rem; }
.metric dd { margin: 2px 0 0; font-weight: 750; overflow-wrap: anywhere; }
.credit-quantity { grid-row: span 2; display: flex; flex-direction: column; justify-content: space-between; gap: 6px; }
.credit-values { display: grid; line-height: 1.25; }
.credit-each { font-weight: 650; }
.credit-total { color: var(--accent); font-size: 0.88rem; }
.quantity-control { display: grid; grid-template-columns: auto 26px minmax(36px, 48px) 26px; align-items: center; gap: 3px; }
.quantity-label { color: var(--muted); font-size: 0.68rem; font-weight: 700; }
.quantity-step, .quantity-input { min-height: 30px; height: 30px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); color: var(--text); text-align: center; }
.quantity-step { padding: 0; font-weight: 800; line-height: 1; }
.quantity-input { width: 100%; padding: 2px 3px; appearance: textfield; }
.quantity-input::-webkit-inner-spin-button, .quantity-input::-webkit-outer-spin-button { margin: 0; appearance: none; }
.position-grid .open-gain { grid-row: span 2; }
.position-grid .open-gain.positive dd { color: var(--positive); }
.position-grid .open-gain.negative dd, .position-grid .market-value.negative dd { color: var(--danger); }
.position-grid .profit-target { display: flex; align-items: center; justify-content: space-between; gap: 4px; padding: 4px 6px; border-right: 0; }
.position-grid .profit-target dt { order: 1; white-space: nowrap; }
.position-grid .profit-target dd { margin: 0; font-size: 0.9rem; white-space: nowrap; }
.position-grid .profit-target.reached { background: var(--positive); color: var(--surface); }
.position-grid .profit-target.reached dt { color: inherit; }
.card-foot { padding: 13px 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.82rem; }
.card-foot p { margin-bottom: 5px; }
.card-foot p:last-child { margin-bottom: 0; }
.last-price strong { color: var(--text); }
.day-change { font-weight: 750; white-space: nowrap; }
.day-change.positive { color: var(--positive); }
.day-change.negative { color: var(--danger); }
.position-extended-quote strong { color: var(--text); }
.position-extended-quote { overflow-wrap: anywhere; }
.position-extended-quote[hidden] { display: none; }
.itm-badge { display: inline-block; padding: 1px 6px; border-radius: 4px; background: var(--danger-soft); color: var(--danger); font-size: .72rem; font-weight: 800; vertical-align: baseline; }
.spread-refresh-message:empty { display: none; }
.spread-refresh-message:not(:empty) { margin: 9px 14px 13px; padding: 9px 10px; border-radius: 8px; background: var(--accent-soft); color: var(--accent-strong); }
.spread-refresh-message.error { background: var(--danger-soft); color: var(--danger); }
.inline-action { margin: 5px 0 0; padding: 0; border: 0; background: transparent; color: inherit; font-weight: 800; text-decoration: underline; }
.match-status { padding: 12px 14px; border-top: 1px solid color-mix(in srgb, var(--review) 25%, var(--line)); background: var(--review-soft); color: #68420b; }
.match-status strong { display: block; }
.match-status ul { margin: 5px 0 0; padding-left: 20px; }
.reason-box { margin: 0; padding: 12px 14px; border-top: 1px solid color-mix(in srgb, var(--review) 25%, var(--line)); background: var(--review-soft); color: #68420b; }
 .reason-box summary { font-size: 0.85rem; font-weight: 700; cursor: pointer; }
.reason-box ul { margin: 5px 0 0; padding-left: 20px; }

.detail-panel { box-shadow: none; }
.reason-list { display: grid; gap: 10px; }
.reason-row { padding: 13px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-soft); }
.reason-symbol { font-weight: 850; }
.reason-row ul { margin: 9px 0 0; padding-left: 18px; color: var(--muted); font-size: 0.87rem; }
.reason-row { display: block; }
.error-panel { border-color: color-mix(in srgb, var(--danger) 30%, var(--line)); }

.access-card { margin-bottom: 18px; padding: 12px 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-soft); }
.access-card summary { cursor: pointer; font-weight: 700; }
.access-content { display: grid; gap: 14px; padding-top: 14px; }
.access-content h3, .access-content p { margin: 0; }
.access-content p:not(.message) { color: var(--muted); font-size: 0.9rem; }
.access-content .button { justify-self: start; }
.settings-form { display: grid; gap: 18px; }
.settings-form fieldset { display: grid; grid-template-columns: 1fr; gap: 15px; margin: 0; padding: 18px; border: 1px solid var(--line); border-radius: 14px; }
.settings-form legend { padding: 0 7px; color: var(--accent); font-weight: 800; }
.field small { display: block; margin-top: 5px; color: var(--muted); font-size: 0.78rem; }
.checkbox-field { display: flex; align-items: end; }
.checkbox-field label { display: flex; align-items: center; gap: 9px; margin: 0; }
.checkbox-field input { width: 20px; min-height: 20px; accent-color: var(--accent); }
.unit-input { display: flex; align-items: center; overflow: hidden; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.unit-input input { min-width: 0; border: 0; border-radius: 0; }
.unit-input span { padding: 0 11px; color: var(--muted); font-size: 0.86rem; font-weight: 700; }
.unit-input.money span { padding-right: 0; }
.settings-actions { display: flex; flex-direction: column; gap: 9px; }
.settings-actions + p { margin-bottom: 0; font-size: 0.86rem; }

.position-progress { margin-bottom: 18px; }
.position-progress > p { margin: 5px 0 0; }
.position-list { margin: 18px 0; }
.position-list .symbol-line { flex-direction: column; align-items: flex-start; }

.ledger-view { min-width: 0; }
.ledger-heading { display: grid; gap: 16px; margin-bottom: 18px; }
.ledger-heading h2 { margin-bottom: 4px; }
.ledger-heading p { margin-bottom: 0; }
.ledger-export { min-width: 0; }
.ledger-export > label { display: block; margin-bottom: 5px; color: var(--muted); font-size: 0.78rem; font-weight: 750; }
.ledger-export-controls { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.ledger-export-controls select { min-width: 0; }
.ledger-export-controls .button { min-width: 108px; padding-inline: 10px; white-space: nowrap; }
.ledger-months { display: grid; min-width: 0; gap: 12px; }
.ledger-month {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--surface);
  box-shadow: 0 4px 14px rgba(24, 54, 48, 0.05);
}
.ledger-month > summary {
  position: relative;
  display: grid;
  gap: 7px;
  padding: 14px 38px 14px 15px;
  background: var(--surface-soft);
  cursor: pointer;
  list-style: none;
}
.ledger-month > summary::-webkit-details-marker, .ledger-trade-card > summary::-webkit-details-marker { display: none; }
.ledger-month > summary::after {
  content: "▾";
  position: absolute;
  top: 50%;
  right: 15px;
  color: var(--muted);
  transform: translateY(-50%);
}
.ledger-month[open] > summary::after { content: "▴"; }
.ledger-month-name { font-size: 1.05rem; font-weight: 850; }
.ledger-month-metrics { display: flex; flex-wrap: wrap; gap: 5px 12px; color: var(--muted); font-size: 0.79rem; }
.ledger-month-metrics > span { white-space: nowrap; }
.ledger-month-profit { font-weight: 800; }
.ledger-month-profit.positive, .ledger-card-result.positive, .ledger-table .positive { color: var(--positive); }
.ledger-month-profit.negative, .ledger-card-result.negative, .ledger-table .negative { color: var(--danger); }
.ledger-pending { color: var(--review); font-weight: 750; }
.ledger-month-content { min-width: 0; border-top: 1px solid var(--line); }
.ledger-table-wrap { display: none; max-width: 100%; overflow-x: auto; }
.ledger-table { width: 100%; min-width: 1040px; border-collapse: collapse; font-size: 0.74rem; font-variant-numeric: tabular-nums; }
.ledger-table th, .ledger-table td { padding: 8px 5px; border-bottom: 1px solid var(--line); text-align: center; vertical-align: middle; }
.ledger-table thead th { background: color-mix(in srgb, var(--surface-soft) 70%, var(--surface)); color: var(--muted); font-size: 0.67rem; line-height: 1.2; text-transform: uppercase; }
.ledger-table tbody:last-child tr:last-child > * { border-bottom: 0; }
.ledger-table .numeric { text-align: center; white-space: nowrap; }
.ledger-sort, .ledger-trade-toggle {
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 800;
  text-align: inherit;
}
.ledger-sort::after { content: " ↕"; color: var(--muted); font-size: 0.7rem; }
.ledger-table th[aria-sort="ascending"] .ledger-sort::after { content: " ↑"; color: var(--accent); }
.ledger-table th[aria-sort="descending"] .ledger-sort::after { content: " ↓"; color: var(--accent); }
.ledger-trade-toggle { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.ledger-trade-toggle::after { content: " ▾"; display: inline-block; font-size: 0.72rem; text-decoration: none; }
.ledger-trade-toggle[aria-expanded="true"]::after { content: " ▴"; }
.ledger-fee { display: inline-flex; padding: 2px 7px; border-radius: 999px; font-size: 0.7rem; font-weight: 800; white-space: nowrap; }
.ledger-fee-actual { background: var(--accent-soft); color: var(--accent-strong); }
.ledger-fee-estimated { background: var(--review-soft); color: var(--review); }
.ledger-fee-unknown { background: var(--surface-soft); color: var(--muted); }
.ledger-detail-row > td { padding: 0; background: color-mix(in srgb, var(--surface-soft) 45%, var(--surface)); }
.ledger-trade-detail { display: grid; min-width: 0; gap: 13px; padding: 14px; overflow-wrap: anywhere; text-align: left; }
.ledger-detail-column { display: contents; min-width: 0; }
.ledger-detail-section { min-width: 0; }
.ledger-detail-section h4 { margin-bottom: 7px; color: var(--accent); }
.ledger-detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); min-width: 0; gap: 0; margin: 0; }
.ledger-detail-item { min-width: 0; padding: 6px 7px 7px 0; border-bottom: 1px solid color-mix(in srgb, var(--line) 65%, transparent); }
.ledger-detail-item:nth-child(odd) { border-right: 1px solid color-mix(in srgb, var(--line) 65%, transparent); }
.ledger-detail-item:nth-child(even) { padding-left: 7px; }
.ledger-detail-item dt { color: var(--muted); font-size: 0.7rem; }
.ledger-detail-item dd { margin: 1px 0 0; font-size: 0.83rem; font-weight: 720; }
.ledger-detail-item small { display: block; margin-top: 2px; color: var(--muted); font-size: 0.67rem; line-height: 1.35; }
.ledger-evidence > summary { color: var(--muted); cursor: pointer; font-size: 0.67rem; }
.ledger-observations { grid-column: 1 / -1; }
.ledger-observation-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.ledger-observation-grid .ledger-detail-item { padding-inline: 6px; border-right: 1px solid color-mix(in srgb, var(--line) 65%, transparent); }
.ledger-observation-grid .ledger-detail-item:first-child { padding-left: 0; }
.ledger-observation-grid .ledger-detail-item:last-child { padding-right: 0; border-right: 0; }
.ledger-observation-grid .ledger-detail-item:has(.ledger-evidence[open]) { grid-column: 1 / -1; border-right: 0; }
.ledger-notes > summary { color: var(--accent); cursor: pointer; font-size: 0.8rem; font-weight: 700; }
.ledger-analysis .analysis-good, .ledger-analysis .analysis-bad { padding: 6px 8px; border-radius: 6px; }
.ledger-analysis .analysis-good { background: color-mix(in srgb, var(--positive) 12%, transparent); }
.ledger-analysis .analysis-bad { background: color-mix(in srgb, var(--danger) 12%, transparent); }
.ledger-analysis .analysis-good dd { color: var(--positive); }
.ledger-analysis .analysis-bad dd { color: var(--danger); }
.ledger-notes { grid-column: 1 / -1; }
.ledger-notes ul { margin: 0; padding-left: 18px; color: var(--muted); font-size: 0.8rem; }
.ledger-mobile-list { display: grid; gap: 10px; padding: 10px; }
.ledger-trade-card { min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.ledger-trade-card > summary {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 7px 10px;
  padding: 12px 29px 12px 12px;
  cursor: pointer;
  list-style: none;
}
.ledger-trade-card > summary::after {
  content: "▾";
  position: absolute;
  top: 14px;
  right: 10px;
  color: var(--muted);
}
.ledger-trade-card[open] > summary::after { content: "▴"; }
.ledger-card-identity, .ledger-card-result { display: grid; min-width: 0; }
.ledger-card-identity strong { font-size: 1.06rem; }
.ledger-card-identity span, .ledger-card-result span { color: var(--muted); font-size: 0.7rem; }
.ledger-card-result { justify-items: end; text-align: right; white-space: nowrap; }
.ledger-card-result strong { font-size: 0.98rem; }
.ledger-card-essentials { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-column: 1 / -1; gap: 3px 10px; color: var(--muted); font-size: 0.71rem; }
.ledger-card-essentials > span { min-width: 0; overflow-wrap: anywhere; }
.ledger-trade-card > summary > .ledger-fee { grid-column: 1 / -1; justify-self: start; }
.ledger-trade-card > .ledger-trade-detail { border-top: 1px solid var(--line); background: color-mix(in srgb, var(--surface-soft) 45%, var(--surface)); }

.site-footer { padding: 20px 0 calc(28px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); color: var(--muted); font-size: 0.83rem; text-align: center; }
.site-footer p { margin: 0; }

@media (max-width: 420px) {
  .header-inner > div:first-child { min-width: 0; }
  .site-header h1 { font-size: 1.15rem; line-height: 1.12; }
  .header-scan { min-width: 140px; }
  .scan-button { min-width: 130px; font-size: 0.9rem; }
}
.position-card .card-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; }
.position-card.card-collapsed .card-head:has(.position-session-summary:not([hidden])) { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; align-items: center; gap: 8px; padding: 12px; }
.position-card.card-collapsed .position-session-summary:not([hidden]) { display: grid; grid-column: 2; grid-row: 1; justify-self: stretch; }
.position-card.card-collapsed .card-head:has(.position-session-summary:not([hidden])) .roi { grid-column: 3; grid-row: 1; }
.position-card.card-collapsed .card-head:has(.position-session-summary:not([hidden])) .roi strong { font-size: 1.15rem; }
.position-card.card-collapsed .card-head:has(.position-session-summary:not([hidden])) .roi span { font-size: 0.58rem; }
.position-card.card-collapsed .card-head:has(.position-session-summary:not([hidden])) .expiration { font-size: 0.65rem; line-height: 1.35; }
.position-card.card-collapsed .position-session-summary span { font-size: 0.62rem; }

@media (min-width: 640px) {
  .card-head > :not(.card-toggle) { pointer-events: auto; }
  .shell { width: min(100% - 48px, 1120px); }
  main { padding-top: 28px; }
  .panel { padding: 26px; }
  .inline-form { flex-direction: row; }
  .inline-form input { flex: 1; }
  .section-heading { flex-direction: row; justify-content: space-between; align-items: end; }
  .ledger-heading { grid-template-columns: minmax(0, 1fr) auto; align-items: end; }
  .ledger-export { width: 330px; }
  .position-card .card-head { display: flex; }
  .filter-control { width: 245px; }
  .shared-filter { flex-direction: row; align-items: end; }
  .shared-filter .filter-note { margin-bottom: 10px; }
  .candidate-list { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
  .position-list { align-items: stretch; }
  .position-list > .candidate-card { display: grid; grid-template-rows: subgrid; grid-row: span 7; row-gap: 0; }
  .position-list .card-head { grid-row: 1; }
  .position-list .position-grid { grid-row: 2 / span 4; grid-template-rows: subgrid; row-gap: 0; }
  .position-list .reason-box { grid-row: 6; }
  .position-list .card-foot { grid-row: 7; }
  .settings-form fieldset { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .field.full { grid-column: 1 / -1; }
  .settings-actions { flex-direction: row; }
}

@media (min-width: 760px) {
  .ledger-month > summary { grid-template-columns: minmax(170px, 0.7fr) minmax(0, 2fr); align-items: center; }
  .ledger-month-metrics { justify-content: flex-end; }
  .ledger-table-wrap { display: block; }
  .ledger-mobile-list { display: none; }
  .ledger-trade-detail { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 16px 18px; }
  .ledger-detail-column { display: grid; grid-template-columns: minmax(0, 1fr); align-content: start; gap: 13px; }
}

@media (min-width: 980px) {
  .candidate-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1715;
    --surface: #14221f;
    --surface-soft: #1b2c28;
    --text: #ebf4f1;
    --muted: #a8bbb5;
    --line: #314640;
    --accent: #62c5b4;
    --accent-strong: #86d6c8;
    --accent-soft: #183f38;
    --focus: #70bff5;
    --review: #e9b75f;
    --review-soft: #3c2f19;
    --danger: #f0908d;
    --danger-soft: #402322;
    --shadow: 0 8px 28px rgba(0, 0, 0, 0.2);
    --positive: #72d5a2;
  }
  .button.primary { color: #071915; }
  .reason-box, .match-status { color: #f3d79d; }
  .phase-dot.complete { background: #72d5a2; }
}
