:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --canvas: #ffffff;
  --ink: #101828;
  --muted: #667085;
  --faint: #98a2b3;
  --line: #e4e7ec;
  --line-strong: #d0d5dd;
  --blue: #155eef;
  --green: #079455;
  --red: #d92d20;
  --amber: #b54708;
  --radius: 12px;
  --workspace-scale: 1;
  --workspace-width: 100vw;
  --workspace-height: 100vh;
  --font: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; }
body {
  min-width: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: var(--font);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; }
button, input[type="range"] { cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 2px solid rgba(21,94,239,.25); outline-offset: 1px; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

.app-shell {
  width: 100%;
  height: 100vh;
  padding: 8px;
}

.dashboard {
  display: grid;
  width: 100%;
  height: 100%;
  min-height: 0;
  grid-template-columns: 292px minmax(0, 1fr);
  grid-template-rows: 54px minmax(0, 1fr);
  grid-template-areas: "header header" "sidebar results";
  gap: 8px;
  padding: 0 10px 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--canvas);
  box-shadow: 0 8px 28px rgba(16,24,40,.06);
}

/* All modules share the same canvas; structure comes from lines and spacing only. */
.panel {
  min-width: 0;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: transparent;
  box-shadow: none;
}

.app-header {
  grid-area: header;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 -10px;
  padding: 0 14px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 14px 14px 0 0;
}
.brand-group, .header-actions, .controls-header, .section-title-row,
.hero-label-row, .slider-heading, .legend-heading, .metric {
  display: flex;
  align-items: center;
}
.brand-group { gap: 10px; }
.brand-mark {
  display: grid;
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  background: var(--blue);
}
.brand-mark span { font-size: 10px; font-weight: 850; letter-spacing: .05em; }
.eyebrow, .panel-kicker {
  margin: 0 0 2px;
  color: var(--blue);
  font-size: 7px;
  line-height: 1;
  font-weight: 850;
  letter-spacing: .12em;
}
.app-header h1, .controls-header h2, .section-title-row h2 { margin: 0; }
.app-header h1 { font-size: 16px; line-height: 1.08; letter-spacing: -.03em; }
.lead { display: inline; margin: 0 0 0 8px; color: var(--muted); font-size: 8px; }
.brand-copy { display: grid; grid-template-columns: auto auto; align-items: end; }
.brand-group .eyebrow { grid-column: 1 / -1; }
.header-actions { gap: 7px; }
.local-badge, .live-chip, .calculation-badge, .target-badge, .current-badge {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  border-radius: 999px;
  font-weight: 750;
}
.local-badge { gap: 5px; padding: 5px 8px; color: var(--muted); border: 1px solid var(--line); font-size: 8px; }
.local-badge i, .live-chip i { width: 5px; height: 5px; border-radius: 50%; background: #17b26a; }
.reset-button, .apply-button, .table-action {
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: transparent;
  font-weight: 750;
}
.reset-button {
  display: inline-flex;
  height: 28px;
  align-items: center;
  gap: 5px;
  padding: 0 9px;
  color: #344054;
  font-size: 8px;
}
.reset-button:hover, .table-action:hover:not(:disabled) { border-color: var(--blue); color: var(--blue); }
.reset-button svg { width: 12px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.sidebar-column { grid-area: sidebar; min-height: 0; }
.controls {
  display: grid;
  height: 100%;
  min-height: 0;
  grid-template-rows: 31px minmax(0, .84fr) minmax(0, 1fr) minmax(0, 1fr);
  gap: 6px;
  padding: 8px;
}
.controls-header { justify-content: space-between; padding: 0 2px; }
.controls-header h2, .section-title-row h2 { font-size: 11px; line-height: 1.1; letter-spacing: -.015em; }
.live-chip { gap: 4px; padding: 4px 6px; color: var(--green); border: 1px solid #abefc6; font-size: 7px; }
.control-section {
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: transparent;
}
.control-section legend {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  padding: 0 0 6px;
}
.legend-heading { gap: 5px; }
.legend-heading > span { color: #344054; font-size: 9px; font-weight: 800; }
.legend-heading small { color: var(--faint); font-size: 7px; font-weight: 600; }
.legend-note { color: var(--faint); font-size: 6px; font-weight: 800; letter-spacing: .08em; }
.legend-value { color: var(--blue); font-size: 8px; }
.field, .target-inline-field { display: grid; min-width: 0; gap: 3px; }
.field > span:first-child, .field-title, .target-inline-field > span:first-child, .slider-heading label {
  color: var(--muted);
  font-size: 7px;
  font-weight: 700;
}
.field-title b { margin-left: 3px; color: var(--blue); font-size: 6px; }
.input-wrap {
  display: flex;
  min-width: 0;
  height: 28px;
  align-items: center;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: transparent;
}
.input-wrap:focus-within { border-color: #84adff; box-shadow: 0 0 0 2px rgba(21,94,239,.08); }
.input-wrap input {
  width: 100%;
  min-width: 0;
  height: 26px;
  padding: 0 3px 0 7px;
  color: var(--ink);
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 10px;
  font-weight: 750;
}
.input-wrap small { flex: 0 0 auto; padding-right: 6px; color: var(--faint); font-size: 6px; }
.primary-market-field { margin-bottom: 6px; }
.primary-market-field .input-wrap { height: 34px; border-color: #b2ccff; }
.primary-market-field .input-wrap input { height: 32px; color: var(--blue); font-size: 15px; font-weight: 850; }
.basis-field-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 5px; }
.compact-field .input-wrap input { padding-left: 5px; font-size: 9px; }
.compact-field .input-wrap small { padding-right: 4px; }

.slider-field {
  display: grid;
  grid-template-columns: minmax(0,1fr) 86px;
  grid-template-areas: "heading exact" "range range" "scale scale";
  gap: 2px 6px;
  margin-bottom: 6px;
}
.slider-heading { grid-area: heading; }
.price-input { grid-area: exact; height: 26px; }
.price-input input { height: 24px; font-size: 9px; text-align: right; }
input[type="range"] {
  grid-area: range;
  width: 100%;
  height: 11px;
  margin: 2px 0 0;
  padding: 0;
  appearance: none;
  background: transparent;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 3px;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--blue) var(--fill,0%), #dfe3e8 var(--fill,0%));
}
.sell-slider input[type="range"]::-webkit-slider-runnable-track { background: linear-gradient(90deg, #f79009 var(--fill,0%), #dfe3e8 var(--fill,0%)); }
input[type="range"]::-webkit-slider-thumb {
  width: 11px;
  height: 11px;
  margin-top: -4px;
  appearance: none;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 0 0 1px rgba(21,94,239,.3);
}
.sell-slider input[type="range"]::-webkit-slider-thumb { background: #f79009; box-shadow: 0 0 0 1px rgba(247,144,9,.35); }
.range-scale { grid-area: scale; display: flex; justify-content: space-between; color: var(--faint); font-size: 6px; line-height: 1; }
.field-grid, .order-field-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 5px; }

.results {
  grid-area: results;
  display: grid;
  min-width: 0;
  min-height: 0;
  grid-template-columns: minmax(0, 1.42fr) minmax(330px, .92fr);
  gap: 8px;
  overflow: hidden;
}
.result-column {
  display: grid;
  min-width: 0;
  min-height: 0;
  gap: 8px;
  overflow: hidden;
}
.result-main-column { grid-template-rows: 132px 64px 126px minmax(0,1fr); }
.result-side-column { grid-template-rows: 112px minmax(176px,1fr) 84px 150px; }
.result-column > * { min-width: 0; min-height: 0; }

.result-hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0,1.45fr) minmax(180px,.7fr);
  gap: 12px;
  align-items: stretch;
  padding: 13px 15px;
  overflow: hidden;
  border-color: var(--line-strong);
}
.hero-glow { display: none; }
.hero-copy { align-self: center; min-width: 0; }
.hero-label-row { gap: 6px; }
.hero-label-row p { margin: 0; color: var(--muted); font-size: 8px; font-weight: 750; }
.calculation-badge { padding: 3px 6px; color: var(--blue); border: 1px solid #b2ccff; font-size: 6px; }
.hero-number { display: flex; align-items: flex-end; gap: 7px; margin-top: 5px; line-height: .88; }
.hero-number span { color: #0b4ccc; font-size: clamp(42px,4.2vw,58px); font-weight: 820; letter-spacing: -.06em; }
.hero-number small { padding-bottom: 4px; color: var(--faint); font-size: 7px; white-space: nowrap; }
.cost-change { margin: 8px 0 0; color: var(--muted); font-size: 8px; font-weight: 650; }
.cost-change.cost-lower::before { content: "↓ "; color: var(--green); }
.cost-change.cost-higher::before { content: "↑ "; color: var(--red); }
.cost-change.cost-neutral::before { content: "→ "; color: var(--blue); }
.cashflow-card {
  display: flex;
  min-width: 0;
  flex-direction: column;
  justify-content: center;
  padding: 11px;
  border-left: 1px solid var(--line);
}
.cashflow-card > span { color: var(--muted); font-size: 7px; font-weight: 700; }
.cashflow-card strong { display: block; margin-top: 6px; color: var(--ink); font-size: 14px; line-height: 1.15; }
.cashflow-card small { margin-top: 6px; color: var(--faint); font-size: 6px; }
.positive { color: var(--green) !important; }
.negative { color: var(--red) !important; }
.validation-message { margin: 0; padding: 6px 8px; color: var(--red); border: 1px solid #fecdca; border-radius: 7px; font-size: 8px; }
.validation-message[hidden] { display: none; }

.metric-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 6px; }
.metric { gap: 7px; padding: 8px; }
.metric-icon {
  display: grid;
  width: 25px;
  height: 25px;
  flex: 0 0 25px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--blue);
  font-size: 7px;
  font-weight: 850;
}
.metric-icon.pnl-icon.negative { color: var(--red); }
.metric-icon.pnl-icon.positive { color: var(--green); }
.metric div { min-width: 0; }
.metric div > span { display: block; overflow: hidden; color: var(--muted); font-size: 6.5px; text-overflow: ellipsis; white-space: nowrap; }
.metric strong { display: block; margin-top: 4px; overflow: hidden; color: var(--ink); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }

.section-title-row { justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.section-title-row > span { color: var(--faint); font-size: 6.5px; font-weight: 650; white-space: nowrap; }
.target-plan, .chart-section, .stage-section, .comparison-section, .price-position, .breakdown { padding: 10px; }
.target-plan { position: relative; overflow: hidden; }
.target-plan-accent { position: absolute; top: 0; left: 0; width: 34px; height: 2px; background: var(--blue); }
.target-badge { padding: 3px 6px; color: var(--blue) !important; border: 1px solid #b2ccff; font-size: 6px !important; }
.target-plan-body { display: grid; grid-template-columns: 118px minmax(0,1fr) auto; gap: 8px; align-items: end; }
.target-input-wrap input { color: var(--blue); font-size: 11px; }
.target-plan-copy { min-width: 0; }
.target-plan-copy > p { margin: 0 0 5px; overflow: hidden; color: var(--muted); font-size: 7px; line-height: 1.3; text-overflow: ellipsis; white-space: nowrap; }
.target-plan-stats { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 5px; }
.target-plan-stats span { min-width: 0; padding: 5px 6px; border-left: 1px solid var(--line); color: var(--faint); font-size: 6px; }
.target-plan-stats strong { display: block; margin-top: 2px; overflow: hidden; color: var(--ink); font-size: 8px; text-overflow: ellipsis; white-space: nowrap; }
.apply-button { height: 28px; padding: 0 9px; color: #fff; border-color: var(--blue); background: var(--blue); font-size: 7px; white-space: nowrap; }
.apply-button:hover { background: #004eeb; }
.apply-button:disabled { cursor: not-allowed; color: var(--faint); border-color: var(--line); background: transparent; }
.target-plan-invalid .target-plan-copy > p, .target-plan-impossible .target-plan-copy > p { color: var(--red); }
.target-plan-reached .target-plan-copy > p { color: var(--green); }

.chart-section { overflow: hidden; }
#costChart { display: block; width: 100%; height: calc(100% - 45px); min-height: 116px; overflow: visible; }
.chart-area { fill: rgba(21,94,239,.05); }
.chart-line { fill: none; stroke: var(--blue); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.chart-guide { stroke: #b2ccff; stroke-width: 1; stroke-dasharray: 4 4; }
.chart-evolution-line { stroke: #8098f9; stroke-width: 2; stroke-dasharray: 3 3; }
.chart-basis-point { fill: #fff; stroke: #667085; stroke-width: 2.5; }
.chart-point { fill: #fff; stroke: var(--blue); stroke-width: 3; }
.chart-basis-label { fill: #344054; font-size: 10px; font-weight: 800; }
.chart-point-label { fill: #0b4ccc; font-size: 10px; font-weight: 800; }
.chart-grid-line { stroke: #edf0f3; stroke-width: 1; }
.chart-axis-label { fill: var(--faint); font-size: 8px; }
.formula { margin: 3px 0 0; overflow: hidden; color: var(--faint); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 6.5px; line-height: 1.2; text-overflow: ellipsis; white-space: nowrap; }

.stage-grid { display: grid; grid-template-columns: minmax(0,1fr) 25px minmax(0,1fr) 25px minmax(0,1fr); align-items: center; }
.stage-card { min-width: 0; padding: 7px 4px; text-align: center; border: 1px solid var(--line); border-radius: 7px; }
.stage-step, .stage-card small { display: block; color: var(--faint); font-size: 6px; }
.stage-card strong { display: block; margin: 3px 0 2px; overflow: hidden; color: var(--ink); font-size: 8px; text-overflow: ellipsis; white-space: nowrap; }
.stage-connector { display: grid; justify-items: center; gap: 3px; color: var(--faint); }
.stage-connector i { position: relative; display: block; width: 16px; height: 1px; background: var(--line-strong); }
.stage-connector i::after { content: ""; position: absolute; right: 0; top: -2px; width: 4px; height: 4px; border-top: 1px solid var(--line-strong); border-right: 1px solid var(--line-strong); transform: rotate(45deg); }
.stage-connector b { font-size: 5.5px; font-weight: 700; }

.table-scroll { width: 100%; height: calc(100% - 27px); overflow: hidden; }
.comparison-table { width: 100%; height: 100%; border-collapse: collapse; table-layout: fixed; font-size: 7px; }
.comparison-table th { height: 20px; padding: 2px 4px; color: var(--faint); border-bottom: 1px solid var(--line); font-size: 6px; font-weight: 750; text-align: right; white-space: nowrap; }
.comparison-table th:first-child, .comparison-table td:first-child { text-align: left; }
.comparison-table td { height: 24px; padding: 2px 4px; overflow: hidden; color: #344054; border-bottom: 1px solid #f0f1f3; text-align: right; text-overflow: ellipsis; white-space: nowrap; }
.comparison-table tbody tr:last-child td { border-bottom: 0; }
.comparison-table tbody tr.is-selected { box-shadow: inset 2px 0 var(--blue); }
.current-badge { margin-left: 2px; padding: 2px 3px; color: var(--blue); border: 1px solid #b2ccff; font-size: 5px; }
.table-action { height: 20px; padding: 0 5px; color: var(--blue); font-size: 6px; }
.table-action:disabled { cursor: default; color: var(--green); border-color: #abefc6; }

.compact-title-row { margin-bottom: 8px; }
.position-visual { padding-top: 1px; }
.position-track { position: relative; height: 5px; border-radius: 99px; background: #e7e9ed; }
.position-fill { width: 0; height: 100%; border-radius: inherit; background: var(--blue); }
.position-dot { position: absolute; top: 50%; left: 0; width: 10px; height: 10px; border: 2px solid #fff; border-radius: 50%; background: var(--blue); box-shadow: 0 0 0 1px var(--blue); transform: translate(-50%,-50%); }
.position-labels { display: flex; justify-content: space-between; margin-top: 6px; color: var(--faint); font-size: 6px; }
.position-labels span:last-child { color: var(--muted); font-weight: 700; }

.breakdown dl { display: grid; gap: 0; margin: 0; }
.breakdown dl > div { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 5px 0; border-bottom: 1px solid #f0f1f3; }
.breakdown dl > div:last-child { border-bottom: 0; }
.breakdown dt { color: var(--muted); font-size: 6.5px; }
.breakdown dd { margin: 0; color: var(--ink); font-size: 8px; font-weight: 750; white-space: nowrap; }
.disclaimer { margin: 0; color: var(--faint); font-size: 6px; line-height: 1.35; }
.header-disclaimer {
  min-width: 0;
  max-width: 520px;
  padding: 0 12px;
  overflow: hidden;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Keep the complete desktop workspace inside one viewport at common laptop sizes. */
@media (max-height: 760px) {
  .dashboard { grid-template-rows: 50px minmax(0,1fr); }
  .result-main-column { grid-template-rows: 122px 58px 116px minmax(0,1fr); }
  .result-side-column { grid-template-rows: 103px minmax(164px,1fr) 76px 135px; }
  .controls { grid-template-rows: 27px minmax(0,.82fr) minmax(0,1fr) minmax(0,1fr); padding: 7px; }
  .control-section { padding: 7px; }
  .target-plan, .chart-section, .stage-section, .comparison-section, .price-position, .breakdown { padding: 8px; }
  .section-title-row { margin-bottom: 6px; }
}

@media (max-width: 1180px) {
  body { min-width: 0; }
  .dashboard { grid-template-columns: 270px minmax(0,1fr); }
  .results { grid-template-columns: minmax(0,1.3fr) minmax(300px,.9fr); }
  .result-hero { grid-template-columns: minmax(0,1fr) 160px; }
  .metric-icon { display: none; }
  .metric { padding: 7px; }
  .target-plan-body { grid-template-columns: 105px minmax(0,1fr) auto; }
}

@media (max-width: 1040px) {
  .app-shell { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

/* Transaction ticket detail pass */
.controls {
  grid-template-rows: 34px minmax(0, .78fr) minmax(0, 1fr) minmax(0, 1fr);
  gap: 7px;
  padding: 9px;
}

.controls-header {
  position: relative;
  padding: 0 1px 5px;
  border-bottom: 1px solid var(--line);
}

.controls-header::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: -1px;
  width: 34px;
  height: 1px;
  background: var(--blue);
}

.controls-header h2 {
  font-size: 12px;
  font-weight: 800;
}

.live-chip {
  height: 20px;
  padding-inline: 7px;
  border-color: #abefc6;
  letter-spacing: .02em;
}

.control-section {
  position: relative;
  padding: 9px 10px;
  border-color: #d9dde3;
  border-radius: 10px;
}

.control-section::after {
  content: "";
  position: absolute;
  top: 9px;
  bottom: 9px;
  left: -1px;
  width: 2px;
  border-radius: 2px;
  background: var(--line-strong);
}

.sell-section::after { background: #f79009; }
.buy-section::after { background: var(--blue); }

.control-section legend {
  min-height: 21px;
  padding-bottom: 7px;
}

.legend-heading::before {
  content: "";
  width: 6px;
  height: 6px;
  flex: 0 0 6px;
  border: 1.5px solid var(--line-strong);
  border-radius: 50%;
}

.sell-section .legend-heading::before { border-color: #f79009; }
.buy-section .legend-heading::before { border-color: var(--blue); }

.legend-heading > span {
  color: #1d2939;
  font-size: 9px;
  letter-spacing: .01em;
}

.legend-heading small { font-size: 6.5px; }
.legend-note { padding: 3px 5px; border: 1px solid var(--line); border-radius: 999px; }
.legend-value {
  min-width: 44px;
  padding: 3px 6px;
  border: 1px solid #b2ccff;
  border-radius: 999px;
  text-align: center;
}
.sell-section .legend-value { color: var(--amber); border-color: #fedf89; }

.field { gap: 4px; }
.field > span:first-child,
.field-title,
.slider-heading label,
.target-inline-field > span:first-child {
  color: #475467;
  font-size: 7.5px;
  letter-spacing: .01em;
}

.field-title,
.slider-heading label {
  display: flex;
  align-items: center;
  gap: 4px;
}

.field-title b {
  margin-left: auto;
  padding: 2px 4px;
  border: 1px solid #b2ccff;
  border-radius: 4px;
  font-size: 5.5px;
  letter-spacing: .08em;
}

.input-wrap {
  position: relative;
  height: 30px;
  border-color: #cfd4dc;
  transition: border-color .14s ease, box-shadow .14s ease;
}

.input-wrap:hover { border-color: #98a2b3; }
.input-wrap:focus-within { border-color: var(--blue); box-shadow: 0 0 0 2px rgba(21,94,239,.09); }

.input-wrap input {
  height: 28px;
  padding-inline: 7px 4px;
  text-align: right;
  font-size: 10.5px;
  font-weight: 780;
}

.input-wrap input::-webkit-outer-spin-button,
.input-wrap input::-webkit-inner-spin-button {
  margin: 0;
  appearance: none;
}

.input-wrap input[type="number"] { -moz-appearance: textfield; }
.input-wrap small {
  min-width: 25px;
  padding-right: 7px;
  color: #98a2b3;
  font-size: 6.5px;
  text-align: right;
}

.primary-market-field { margin-bottom: 7px; }
.primary-market-field .input-wrap {
  height: 38px;
  border-color: #b2ccff;
}
.primary-market-field .input-wrap::before,
.price-input::before {
  content: "HK$";
  flex: 0 0 auto;
  padding-left: 8px;
  color: var(--faint);
  font-size: 7px;
  font-weight: 700;
}
.primary-market-field .input-wrap input {
  height: 36px;
  padding-left: 4px;
  font-size: 16px;
  text-align: left;
}
.primary-market-field .input-wrap small {
  min-width: 27px;
  font-size: 6.5px;
}

.basis-field-grid { gap: 6px; }
.compact-field .input-wrap input { padding-left: 4px; font-size: 9.5px; }
.compact-field .input-wrap small { min-width: 18px; padding-right: 5px; }

.slider-field {
  grid-template-columns: minmax(0, 1fr) 92px;
  gap: 3px 7px;
  margin-bottom: 7px;
}
.slider-heading::before {
  content: "";
  width: 14px;
  height: 1px;
  margin-right: 5px;
  background: var(--line-strong);
}
.sell-slider .slider-heading::before { background: #f79009; }
.buy-slider .slider-heading::before { background: var(--blue); }
.price-input { height: 28px; }
.price-input input { height: 26px; padding-left: 3px; font-size: 10px; }
.price-input small { display: none; }

input[type="range"] { height: 13px; margin-top: 2px; }
input[type="range"]::-webkit-slider-runnable-track { height: 4px; }
input[type="range"]::-webkit-slider-thumb {
  width: 12px;
  height: 12px;
  margin-top: -4px;
  border-width: 2px;
}
.range-scale { margin-top: -1px; font-size: 6px; }
.order-field-grid { gap: 6px; }

@media (max-height: 760px) {
  .controls {
    grid-template-rows: 31px minmax(0, .78fr) minmax(0, 1fr) minmax(0, 1fr);
    gap: 6px;
    padding: 8px;
  }
  .control-section { padding: 8px 9px; }
  .control-section legend { padding-bottom: 5px; }
  .primary-market-field .input-wrap { height: 35px; }
  .primary-market-field .input-wrap input { height: 33px; }
  .input-wrap { height: 28px; }
  .input-wrap input { height: 26px; }
  .slider-field { margin-bottom: 5px; }
}

/* Readability pass: stronger secondary text and slightly larger supporting type. */
:root {
  --muted: #475467;
  --faint: #667085;
}

.eyebrow,
.panel-kicker { font-size: 7.5px; }
.lead { font-size: 9px; }
.local-badge,
.reset-button { font-size: 8.5px; }
.controls-header h2,
.section-title-row h2 { font-size: 12px; }
.live-chip { font-size: 7.5px; }
.legend-heading > span { font-size: 9.5px; }
.legend-heading small,
.legend-note { font-size: 7px; }
.legend-value { font-size: 8.5px; }

.field > span:first-child,
.field-title,
.slider-heading label,
.target-inline-field > span:first-child { font-size: 8px; }
.field-title b { font-size: 6.5px; }
.input-wrap small {
  color: var(--faint);
  font-size: 7px;
}
.primary-market-field .input-wrap::before,
.price-input::before { font-size: 7.5px; }
.primary-market-field .input-wrap small { font-size: 7px; }
.range-scale { font-size: 7px; }

.hero-label-row p { font-size: 9px; }
.calculation-badge { font-size: 7px; }
.hero-number small { font-size: 8px; }
.cost-change { font-size: 9px; }
.cashflow-card > span { font-size: 8px; }
.cashflow-card small { font-size: 7px; }
.metric div > span { font-size: 7.5px; }
.metric strong { font-size: 10.5px; }
.section-title-row > span { font-size: 7.5px; }
.target-badge { font-size: 7px !important; }
.target-plan-copy > p { font-size: 8px; }
.target-plan-stats span { font-size: 7px; }
.target-plan-stats strong { font-size: 9px; }
.apply-button { font-size: 8px; }
.formula { font-size: 7px; }

.stage-step,
.stage-card small { font-size: 7px; }
.stage-card strong { font-size: 9px; }
.stage-connector b { font-size: 6.5px; }
.comparison-table { font-size: 8px; }
.comparison-table th { font-size: 7px; }
.current-badge { font-size: 6px; }
.table-action { font-size: 7px; }
.position-labels { font-size: 7px; }
.breakdown dt { font-size: 7.5px; }
.breakdown dd { font-size: 9px; }
.disclaimer { font-size: 7px; }

/* Keep both cost labels in a reserved top band, away from the graph lines. */
.chart-basis-callout rect,
.chart-point-callout rect {
  fill: rgba(255, 255, 255, .98);
  stroke-width: 1;
}
.chart-basis-callout rect { stroke: #d0d5dd; }
.chart-point-callout rect { stroke: #b2ccff; }
.chart-basis-label,
.chart-point-label {
  dominant-baseline: auto;
  paint-order: stroke;
  stroke: #fff;
  stroke-width: 2px;
  stroke-linejoin: round;
}

/* Cost-basis guidance, fee settings, and result sharing. */
.header-actions { gap: 5px; }
.header-tool-button {
  display: inline-flex;
  height: 28px;
  align-items: center;
  gap: 5px;
  padding: 0 8px;
  color: #344054;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: transparent;
  font-size: 8.5px;
  font-weight: 750;
  white-space: nowrap;
}
.header-tool-button:hover { color: var(--blue); border-color: var(--blue); }
.header-tool-button:disabled { cursor: not-allowed; color: var(--faint); border-color: var(--line); }
.header-tool-button svg {
  width: 12px;
  height: 12px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.controls-header-tools { display: flex; align-items: center; gap: 5px; }
.fee-mode-button {
  height: 20px;
  padding: 0 6px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  font-size: 7px;
  font-weight: 750;
  white-space: nowrap;
}
.fee-mode-button:hover,
.fee-mode-button.is-auto { color: var(--blue); border-color: #b2ccff; }
.input-wrap.is-auto-fee {
  border-style: dashed;
  border-color: #b2ccff;
}
.input-wrap.is-auto-fee input { color: var(--blue); cursor: default; }

.info-button {
  display: inline-grid;
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  padding: 0;
  place-items: center;
  color: var(--blue);
  border: 1px solid #b2ccff;
  border-radius: 50%;
  background: transparent;
  font-size: 9px;
  font-weight: 850;
  line-height: 1;
}
.info-button:hover { border-color: var(--blue); }

.app-dialog {
  width: min(520px, calc(100vw - 32px));
  max-height: calc(100vh - 40px);
  padding: 0;
  overflow: hidden;
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 20px 60px rgba(16, 24, 40, .2);
  font-family: var(--font);
  font-variant-numeric: tabular-nums;
}
.app-dialog::backdrop { background: rgba(16, 24, 40, .28); backdrop-filter: blur(2px); }
.fee-dialog { width: min(600px, calc(100vw - 32px)); }
.dialog-header,
.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
}
.dialog-header { border-bottom: 1px solid var(--line); }
.dialog-header h2 { margin: 0; font-size: 15px; letter-spacing: -.02em; }
.dialog-close {
  width: 28px;
  height: 28px;
  padding: 0;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 7px;
  background: transparent;
  font-size: 18px;
  line-height: 1;
}
.dialog-close:hover { color: var(--ink); border-color: var(--line-strong); }
.dialog-body { padding: 16px; }
.dialog-actions { border-top: 1px solid var(--line); }
.dialog-actions-split > span { color: var(--muted); font-size: 10px; }
.dialog-primary {
  min-width: 76px;
  height: 32px;
  padding: 0 13px;
  color: #fff;
  border: 1px solid var(--blue);
  border-radius: 8px;
  background: var(--blue);
  font-size: 10px;
  font-weight: 750;
}
.dialog-primary:hover { background: #004eeb; }
.dialog-lead { margin: 0 0 12px; color: #344054; font-size: 12px; line-height: 1.6; }
.basis-formula {
  padding: 10px 12px;
  color: #0b4ccc;
  border: 1px solid #b2ccff;
  border-radius: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.5;
}
.basis-explanation ul { display: grid; gap: 8px; margin: 14px 0 0; padding-left: 18px; }
.basis-explanation li { color: var(--muted); font-size: 11px; line-height: 1.55; }

.fee-mode-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 9px;
}
.fee-mode-switch label { position: relative; cursor: pointer; }
.fee-mode-switch input { position: absolute; opacity: 0; pointer-events: none; }
.fee-mode-switch span {
  display: grid;
  height: 30px;
  place-items: center;
  color: var(--muted);
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 750;
}
.fee-mode-switch input:checked + span { color: var(--blue); border-color: #b2ccff; box-shadow: 0 1px 3px rgba(16,24,40,.06); }
.auto-fee-settings { margin-top: 14px; }
.fee-setting-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; }
.dialog-field { display: grid; gap: 5px; color: var(--muted); font-size: 10px; font-weight: 700; }
.dialog-input {
  display: flex;
  height: 34px;
  align-items: center;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
}
.dialog-input:focus-within { border-color: var(--blue); box-shadow: 0 0 0 2px rgba(21,94,239,.08); }
.dialog-input input { width: 100%; min-width: 0; height: 32px; padding: 0 8px; border: 0; outline: 0; background: transparent; font-size: 11px; font-weight: 750; }
.dialog-input small { padding-right: 9px; color: var(--faint); font-size: 9px; }
.fee-check-grid { display: flex; gap: 18px; margin-top: 12px; }
.fee-check-grid label { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 10px; cursor: pointer; }
.fee-check-grid input { accent-color: var(--blue); }
.fee-rate-list { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 6px; margin-top: 12px; }
.fee-rate-list span {
  padding: 7px 6px;
  color: var(--faint);
  border-left: 1px solid var(--line);
  font-size: 8.5px;
}
.fee-rate-list b { display: block; margin-top: 3px; color: #344054; font-size: 10px; }
.fee-preview { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px; margin-top: 12px; }
.fee-preview span { display: flex; align-items: center; justify-content: space-between; padding: 9px 10px; color: var(--muted); border: 1px solid var(--line); border-radius: 8px; font-size: 10px; }
.fee-preview strong { color: var(--blue); font-size: 12px; }
.dialog-note { margin: 10px 0 0; color: var(--faint); font-size: 9px; line-height: 1.5; }

.copy-toast {
  position: fixed;
  z-index: 100;
  left: 50%;
  bottom: 22px;
  padding: 9px 14px;
  color: #fff;
  border-radius: 8px;
  background: #101828;
  box-shadow: 0 8px 24px rgba(16,24,40,.2);
  font-size: 10px;
  font-weight: 750;
  transform: translateX(-50%);
}
.copy-toast.is-error { background: var(--red); }

/* Scenario comparison and share-link controls. */
#scenarioCount { color: var(--blue); font-weight: 850; }
.scenario-dialog { width: min(720px, calc(100vw - 32px)); }
.scenario-dialog-body { padding-top: 13px; padding-bottom: 13px; }
.scenario-intro {
  margin: 0 0 11px;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.45;
}
.scenario-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.scenario-slot {
  min-width: 0;
  padding: 11px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: transparent;
}
.scenario-slot-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}
.scenario-slot-header strong { font-size: 12px; }
.scenario-slot-header span {
  color: var(--faint);
  font-size: 8.5px;
  font-weight: 750;
}
.scenario-slot.has-scenario .scenario-slot-header span { color: var(--green); }
.scenario-empty {
  min-height: 63px;
  margin: 10px 0 0;
  color: var(--faint);
  font-size: 10px;
  line-height: 1.55;
}
.scenario-order {
  margin: 9px 0 7px;
  overflow: hidden;
  color: #344054;
  font-size: 9.5px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.scenario-content dl {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 10px;
  margin: 0;
}
.scenario-content dl div {
  min-width: 0;
  padding-left: 7px;
  border-left: 1px solid var(--line);
}
.scenario-content dt { color: var(--faint); font-size: 8px; }
.scenario-content dd {
  margin: 3px 0 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 10px;
  font-weight: 780;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.scenario-actions { display: flex; gap: 6px; margin-top: 10px; }
.scenario-actions button {
  height: 27px;
  padding: 0 8px;
  color: #344054;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: transparent;
  font-size: 8.5px;
  font-weight: 750;
}
.scenario-actions button:first-child { color: var(--blue); border-color: #b2ccff; }
.scenario-actions button:hover:not(:disabled) { color: var(--blue); border-color: var(--blue); }
.scenario-actions button:disabled { cursor: not-allowed; color: var(--faint); border-color: var(--line); }
.scenario-comparison {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
  padding: 9px 11px;
  border: 1px solid #b2ccff;
  border-radius: 9px;
  color: var(--muted);
  font-size: 9px;
}
.scenario-comparison strong { color: #0b4ccc; font-size: 10px; text-align: right; }
.privacy-note {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 10px 0 0;
  color: var(--faint);
  font-size: 8.5px;
  line-height: 1.4;
}
.privacy-note i {
  width: 6px;
  height: 6px;
  flex: 0 0 6px;
  border-radius: 50%;
  background: var(--green);
}
.scenario-comparison[hidden] { display: none; }

/* Refined HK monogram used by the header and favicon. */
.brand-mark svg { display: block; width: 25px; height: 25px; overflow: visible; }
.brand-monogram {
  fill: none;
  stroke: #fff;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Friendly visual identity for 小算盘 / costbuddy. */
:root {
  --bg: #f5f6fb;
  --canvas: #fffefe;
  --ink: #26324b;
  --muted: #526078;
  --faint: #748198;
  --line: #e6e9f2;
  --line-strong: #d5daea;
  --blue: #536ff0;
  --green: #12a66a;
  --amber: #cf7212;
  --radius: 14px;
}
.dashboard {
  border-radius: 20px;
  box-shadow: 0 10px 34px rgba(49, 60, 103, .08);
}
.panel { border-radius: 14px; }
.app-header { border-radius: 19px 19px 0 0; }
.brand-group { gap: 11px; }
.brand-mark {
  width: 34px;
  height: 34px;
  flex-basis: 34px;
  border-radius: 11px;
  background: linear-gradient(145deg, #7894ff, #4f65e8);
  box-shadow: 0 5px 12px rgba(83, 111, 240, .24);
}
.brand-mark svg { width: 31px; height: 31px; }
.calculator-body { fill: #fff; }
.calculator-screen { fill: #dfe5ff; }
.calculator-button { fill: #7188f5; }
.calculator-smile {
  fill: none;
  stroke: #4f65e8;
  stroke-width: 1.8;
  stroke-linecap: round;
}
.calculator-spark { fill: #ffbd70; stroke: #fff; stroke-width: 1; }
.app-header h1 { color: #26324b; letter-spacing: -.025em; }
.eyebrow { color: #657ff2; letter-spacing: .14em; }
.lead { color: #66738a; }
.control-section,
.target-plan,
.chart-section,
.stage-section,
.comparison-section,
.position-section,
.breakdown { border-color: var(--line); }
.reset-button,
.header-tool-button,
.fee-mode-button,
.table-action { border-radius: 9px; }
.info-button { border-color: #c9d2ff; }
.hero-number span { color: #4d65df; }
.chart-line { stroke: #6079ec; }
.chart-point { stroke: #6079ec; }
.app-dialog { border-radius: 18px; }
.dialog-primary { border-radius: 10px; background: #536ff0; border-color: #536ff0; }
.copy-toast { border-radius: 10px; }

/* Security identity, result guidance, and safer reset interaction. */
.stock-identity-grid {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  gap: 6px;
  margin-bottom: 5px;
}
.stock-identity-grid .field { gap: 2px; }
.stock-identity-grid .input-wrap { height: 26px; }
.stock-identity-grid .input-wrap input { height: 24px; font-size: 9px; }
.stock-name-field > span:first-child { display: flex; align-items: center; justify-content: space-between; }
.stock-name-field > span:first-child b { color: var(--faint); font-size: 6.5px; font-weight: 650; }
.stock-code-field input { letter-spacing: .035em; }
.stock-identity-grid input::placeholder { color: #a0a9bb; font-weight: 600; }

.result-insight {
  max-width: 100%;
  margin: 5px 0 0;
  overflow: hidden;
  color: #8a4b08;
  font-size: 8px;
  font-weight: 700;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.result-insight::before { content: "提示 · "; color: var(--amber); }
.result-insight[hidden] { display: none; }

.reset-button.is-confirming {
  color: var(--red);
  border-color: #fda29b;
}

.security-type-setting { margin-bottom: 12px; }
.dialog-section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}
.dialog-section-heading span { color: var(--muted); font-size: 10px; font-weight: 750; }
.dialog-section-heading small { color: var(--faint); font-size: 8.5px; }
.security-type-switch {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}
.security-type-switch label { position: relative; cursor: pointer; }
.security-type-switch input { position: absolute; opacity: 0; pointer-events: none; }
.security-type-switch span {
  display: grid;
  height: 30px;
  place-items: center;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 9.5px;
  font-weight: 750;
}
.security-type-switch input:checked + span {
  color: var(--blue);
  border-color: #b2ccff;
  box-shadow: 0 1px 3px rgba(49, 60, 103, .07);
}
.fee-check-grid label.is-locked { cursor: default; opacity: .72; }

@media (max-height: 760px) {
  .controls { grid-template-rows: 31px repeat(3, minmax(0, 1fr)); }
  .stock-identity-grid { margin-bottom: 4px; }
  .result-insight { margin-top: 3px; font-size: 7.5px; }
}

/* Transaction ticket spacing pass: clearer hierarchy without colored module fills. */
.dashboard {
  grid-template-columns: clamp(308px, 26vw, 332px) minmax(0, 1fr);
}

.controls {
  grid-template-rows: 34px minmax(0, 1.1fr) minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
  padding: 9px 10px;
}

.controls-header {
  padding-inline: 2px;
}

.controls-header h2 {
  font-size: 13px;
  letter-spacing: -.02em;
}

.controls-header-tools {
  gap: 6px;
}

.fee-mode-button,
.live-chip {
  height: 22px;
}

.control-section {
  padding: 9px 11px 10px;
  border-radius: 11px;
}

.control-section::after {
  top: 10px;
  bottom: 10px;
  width: 3px;
}

.control-section legend {
  min-height: 31px;
  padding-bottom: 7px;
}

.legend-heading {
  display: grid;
  min-width: 0;
  grid-template-columns: 8px minmax(0, 1fr);
  grid-template-rows: auto auto;
  column-gap: 7px;
  row-gap: 1px;
  align-items: center;
}

.legend-heading::before {
  grid-column: 1;
  grid-row: 1 / span 2;
  align-self: center;
  width: 7px;
  height: 7px;
  margin: 0;
}

.legend-heading > span,
.legend-heading small {
  grid-column: 2;
  min-width: 0;
}

.legend-heading > span {
  grid-row: 1;
  font-size: 10.5px;
  line-height: 1.15;
}

.legend-heading small {
  grid-row: 2;
  overflow: hidden;
  color: var(--faint);
  font-size: 7.8px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.legend-note,
.legend-value {
  flex: 0 0 auto;
}

.legend-note {
  padding: 4px 6px;
  font-size: 7.2px;
}

.legend-value {
  min-width: 55px;
  padding: 4px 7px;
  font-size: 9px;
  line-height: 1;
}

.field,
.stock-identity-grid .field {
  gap: 4px;
}

.field > span:first-child,
.field-title,
.slider-heading label,
.target-inline-field > span:first-child {
  color: var(--muted);
  font-size: 9px;
  line-height: 1.15;
}

.input-wrap {
  height: 31px;
  border-radius: 8px;
}

.input-wrap input {
  height: 29px;
  padding-inline: 8px 5px;
  font-size: 11.5px;
}

.input-wrap small {
  min-width: 28px;
  padding-right: 7px;
  color: var(--faint);
  font-size: 7.5px;
}

.stock-identity-grid {
  grid-template-columns: 98px minmax(0, 1fr);
  gap: 8px;
  margin-bottom: 6px;
}

.stock-identity-grid .input-wrap {
  height: 30px;
}

.stock-identity-grid .input-wrap input {
  height: 28px;
  padding-inline: 8px;
  font-size: 10.5px;
  text-align: left;
}

.stock-name-field > span:first-child b {
  font-size: 7px;
}

.primary-market-field {
  margin-bottom: 7px;
}

.primary-market-field .input-wrap {
  height: 39px;
}

.primary-market-field .input-wrap input {
  height: 37px;
  font-size: 17px;
}

.primary-market-field .input-wrap::before,
.price-input::before {
  font-size: 8px;
}

.basis-field-grid {
  grid-template-columns: 1fr 1.08fr .86fr;
  gap: 7px;
}

.compact-field .input-wrap input {
  padding-left: 6px;
  font-size: 10.5px;
}

.compact-field .input-wrap small {
  min-width: 20px;
  padding-right: 6px;
}

.slider-field {
  grid-template-columns: minmax(0, 1fr) 106px;
  gap: 4px 8px;
  margin-bottom: 7px;
}

.slider-heading::before {
  width: 18px;
  margin-right: 6px;
}

.price-input {
  height: 31px;
}

.price-input input {
  height: 29px;
  padding-right: 8px;
  font-size: 12px;
}

input[type="range"] {
  height: 14px;
  margin-top: 2px;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
}

input[type="range"]::-webkit-slider-thumb {
  width: 13px;
  height: 13px;
  margin-top: -4.5px;
}

.range-scale {
  margin-top: -1px;
  font-size: 7.5px;
}

.order-field-grid {
  grid-template-columns: .9fr 1.1fr;
  gap: 7px;
}

@media (max-height: 760px) {
  .controls {
    grid-template-rows: 34px minmax(0, 1.1fr) minmax(0, 1fr) minmax(0, 1fr);
    gap: 7px;
    padding: 8px 9px;
  }

  .control-section {
    padding: 8px 10px 9px;
  }

  .control-section legend {
    min-height: 29px;
    padding-bottom: 6px;
  }

  .stock-identity-grid {
    margin-bottom: 5px;
  }

  .primary-market-field {
    margin-bottom: 6px;
  }

  .slider-field {
    margin-bottom: 6px;
  }
}

.control-section legend .legend-heading {
  flex: 1 1 auto;
  margin-right: 10px;
}

/* Keep compact result headings aligned on one baseline. */
:is(.target-plan, .chart-section, .stage-section, .comparison-section, .price-position, .breakdown) .section-title-row {
  flex-wrap: nowrap;
  align-items: baseline;
}

:is(.target-plan, .chart-section, .stage-section, .comparison-section, .price-position, .breakdown) .section-title-row > div {
  display: flex;
  min-width: 0;
  align-items: baseline;
  gap: 7px;
}

:is(.target-plan, .chart-section, .stage-section, .comparison-section, .price-position, .breakdown) .section-title-row .panel-kicker {
  flex: 0 0 auto;
  margin: 0;
  white-space: nowrap;
}

:is(.target-plan, .chart-section, .stage-section, .comparison-section, .price-position, .breakdown) .section-title-row h2 {
  overflow: hidden;
  font-size: 11.5px;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

:is(.target-plan, .chart-section, .stage-section, .comparison-section, .price-position, .breakdown) .section-title-row > span {
  flex: 0 0 auto;
  line-height: 1;
}

/* Align the app identity and transaction-ticket headings with the result titles. */
.brand-copy {
  grid-template-columns: auto auto;
  grid-template-rows: auto auto;
  column-gap: 8px;
  align-items: baseline;
}

.brand-group .eyebrow {
  grid-column: 1;
  grid-row: 1;
  margin: 0;
  white-space: nowrap;
}

.brand-group h1 {
  grid-column: 2;
  grid-row: 1;
  line-height: 1.15;
  white-space: nowrap;
}

.brand-group .lead {
  display: block;
  grid-column: 1 / -1;
  grid-row: 2;
  margin: 2px 0 0;
  white-space: nowrap;
}

.controls-header > div:first-child {
  display: flex;
  min-width: 0;
  align-items: baseline;
  gap: 7px;
}

.controls-header > div:first-child .panel-kicker {
  flex: 0 0 auto;
  margin: 0;
  white-space: nowrap;
}

.controls-header > div:first-child h2 {
  line-height: 1.15;
  white-space: nowrap;
}

/* Stronger lowercase wordmark for the costbuddy brand. */
.brand-group .eyebrow {
  color: #4f65e8;
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -.025em;
}

/* Multi-stock holding book: compact controls stay inside the one-screen workspace. */
#holdingCount,
#scenarioCount {
  color: var(--blue);
  font-weight: 850;
}

.new-measurement-button svg {
  stroke-width: 1.9;
}

.save-holding-button {
  display: inline-flex;
  height: 24px;
  align-items: center;
  gap: 4px;
  padding: 0 8px;
  color: var(--blue);
  border: 1px solid #b2ccff;
  border-radius: 999px;
  background: transparent;
  font-size: 8.5px;
  font-weight: 800;
  white-space: nowrap;
}

.save-holding-button:hover {
  border-color: var(--blue);
}

.save-holding-button svg {
  width: 10px;
  height: 10px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.save-holding-button.is-saved {
  color: var(--green);
  border-color: #abefc6;
}

.save-holding-button.is-dirty {
  color: var(--amber);
  border-color: #f7c98b;
}

.dialog-secondary {
  min-width: 76px;
  height: 32px;
  padding: 0 13px;
  color: #344054;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: transparent;
  font-size: 10px;
  font-weight: 750;
}

.dialog-secondary:hover {
  color: var(--blue);
  border-color: var(--blue);
}

.compact-dialog-button {
  min-width: 0;
  height: 29px;
  padding-inline: 11px;
}

.danger-text {
  color: #b42318;
}

.holding-book-dialog {
  width: min(760px, calc(100vw - 32px));
}

.holding-book-dialog-body {
  max-height: min(500px, calc(100vh - 150px));
  overflow: hidden;
}

.holding-book-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.holding-book-summary p {
  margin: 0;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.45;
}

.holding-list {
  display: grid;
  max-height: min(360px, calc(100vh - 285px));
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

.holding-card {
  min-width: 0;
  padding: 11px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: transparent;
}

.holding-card.is-current {
  border-color: #b2ccff;
  box-shadow: inset 3px 0 0 var(--blue);
}

.holding-card-header,
.holding-card-footer,
.holding-card-title,
.holding-card-actions {
  display: flex;
  align-items: center;
}

.holding-card-header,
.holding-card-footer {
  justify-content: space-between;
  gap: 10px;
}

.holding-card-title {
  min-width: 0;
  gap: 7px;
}

.holding-card-title strong {
  color: var(--ink);
  font-size: 12px;
  letter-spacing: .02em;
  white-space: nowrap;
}

.holding-card-title span {
  overflow: hidden;
  color: #344054;
  font-size: 10.5px;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.holding-card-status {
  flex: 0 0 auto;
  color: var(--faint);
  font-size: 8.5px;
  font-weight: 750;
  white-space: nowrap;
}

.holding-card.is-current .holding-card-status {
  color: var(--blue);
}

.holding-card-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px 11px;
  margin: 10px 0;
  padding: 9px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.holding-card-metrics div {
  display: flex;
  min-width: 0;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
}

.holding-card-metrics span {
  color: var(--faint);
  font-size: 8.5px;
  white-space: nowrap;
}

.holding-card-metrics strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.holding-card-footer time {
  color: var(--faint);
  font-size: 8px;
  white-space: nowrap;
}

.holding-card-actions {
  flex: 0 0 auto;
  gap: 5px;
}

.holding-card-actions button {
  height: 25px;
  padding: 0 8px;
  color: var(--blue);
  border: 1px solid #b2ccff;
  border-radius: 7px;
  background: transparent;
  font-size: 8.5px;
  font-weight: 780;
}

.holding-card-actions button:hover {
  border-color: var(--blue);
}

.holding-card-actions .holding-delete-button {
  color: var(--muted);
  border-color: var(--line-strong);
}

.holding-card-actions .holding-delete-button.is-confirming {
  color: #b42318;
  border-color: #fda29b;
}

.holding-empty {
  display: grid;
  min-height: 165px;
  place-content: center;
  gap: 7px;
  text-align: center;
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
}

.holding-empty[hidden] {
  display: none;
}

.holding-empty strong {
  color: #344054;
  font-size: 12px;
}

.holding-empty span {
  color: var(--faint);
  font-size: 9.5px;
}

.unsaved-dialog {
  width: min(540px, calc(100vw - 32px));
}

.unsaved-dialog-body {
  display: flex;
  align-items: center;
  gap: 13px;
}

.unsaved-icon {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  place-items: center;
  color: var(--amber);
  border: 1px solid #f7c98b;
  border-radius: 50%;
  font-size: 16px;
  font-weight: 850;
}

.unsaved-dialog-body strong {
  display: block;
  margin-bottom: 5px;
  color: var(--ink);
  font-size: 12px;
}

.unsaved-dialog-body p {
  margin: 0;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.5;
}

.unsaved-dialog-actions {
  justify-content: flex-end;
}

@media (max-width: 1180px) {
  .local-badge {
    display: none;
  }

  .header-disclaimer {
    max-width: 255px;
    padding-inline: 6px;
  }

  .header-actions {
    gap: 4px;
  }

  .header-tool-button,
  .reset-button {
    padding-inline: 6px;
  }

  .controls-header .live-chip {
    display: none;
  }
}

/* Local backup controls keep browser-only data portable between devices. */
.holding-book-summary-copy {
  min-width: 0;
}

.holding-book-summary-copy small {
  display: block;
  margin-top: 3px;
  color: var(--faint);
  font-size: 10px;
  line-height: 1.4;
}

.holding-book-summary-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 6px;
}

.import-backup-dialog {
  width: min(560px, calc(100vw - 32px));
}

.import-backup-dialog-body {
  display: flex;
  align-items: center;
  gap: 13px;
}

.import-backup-icon {
  display: grid;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  place-items: center;
  color: var(--blue);
  border: 1px solid #b2ccff;
  border-radius: 50%;
  font-size: 17px;
  font-weight: 900;
}

.import-backup-copy strong {
  display: block;
  margin-bottom: 5px;
  color: var(--ink);
  font-size: 12px;
}

.import-backup-copy p {
  margin: 0;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.5;
}

.import-backup-dialog-actions {
  justify-content: flex-end;
}

@media (max-width: 640px) {
  .holding-book-summary {
    align-items: flex-start;
    flex-direction: column;
    gap: 9px;
  }

  .holding-book-summary-actions {
    width: 100%;
    flex-wrap: wrap;
  }
}

/* Scale the desktop workspace down only when the browser window is smaller than
   the complete one-screen layout. Dialogs stay at native size for readability. */
body.is-window-fitted .app-shell {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--workspace-width);
  height: var(--workspace-height);
  transform: scale(var(--workspace-scale));
  transform-origin: 0 0;
}

/* Three-column workspace redesign: inputs, core result, and action tools each
   have a clear lane while staying inside a single desktop viewport. */
.dashboard {
  grid-template-columns: minmax(292px, .88fr) 1px minmax(0, 2.52fr);
  grid-template-areas:
    "header header header"
    "sidebar divider results";
  column-gap: 5px;
  row-gap: 10px;
}

/* Dividers are real grid tracks rather than offset borders, so they resize with
   the columns and are always clipped safely inside the workspace. */
.dashboard::before,
.results::before {
  content: "";
  width: 1px;
  height: calc(100% - 8px);
  align-self: center;
  border-radius: 999px;
  background: var(--line-strong);
  pointer-events: none;
}

.dashboard::before {
  grid-column: 2;
  grid-row: 2;
}

.results {
  grid-template-columns: minmax(420px, 1.6fr) 1px minmax(320px, 1fr);
  column-gap: 5px;
  row-gap: 0;
}

.results::before {
  grid-column: 2;
  grid-row: 1;
}

.result-column {
  gap: 10px;
}

/* Core result: conclusion -> summary -> basis flow -> market curve. */
.result-main-column {
  grid-column: 1;
  grid-row: 1;
  grid-template-rows: 126px 64px 112px minmax(0, 1fr);
}

/* Decision tools: target plan -> lot matrix -> price position -> cash ledger. */
.result-side-column {
  grid-column: 3;
  grid-row: 1;
  grid-template-rows: 146px minmax(190px, 1fr) 80px 142px;
}

/* The target planner becomes a compact vertical card in the decision column. */
.result-side-column .target-plan-body {
  grid-template-columns: 118px minmax(0, 1fr);
  grid-template-areas:
    "field action"
    "details details";
  column-gap: 8px;
  row-gap: 6px;
  align-items: end;
}

.result-side-column .target-inline-field {
  grid-area: field;
}

.result-side-column .target-plan-copy {
  grid-area: details;
}

.result-side-column .apply-button {
  grid-area: action;
  width: 100%;
}

.result-side-column .target-plan-copy > p {
  margin-bottom: 4px;
}

.result-side-column .target-plan-stats span {
  padding: 4px 5px;
}

/* Give the basis-flow cards more room in the primary reading column. */
.result-main-column .stage-grid {
  grid-template-columns: minmax(0, 1fr) 34px minmax(0, 1fr) 34px minmax(0, 1fr);
}

.result-main-column .stage-card {
  padding-inline: 8px;
}

@media (max-height: 760px) {
  .result-main-column {
    grid-template-rows: 122px 58px 103px minmax(0, 1fr);
  }

  .result-side-column {
    grid-template-rows: 136px minmax(178px, 1fr) 76px 135px;
  }
}

@media (max-width: 1180px) {
  .dashboard {
    grid-template-columns: minmax(276px, .82fr) 1px minmax(0, 2.5fr);
  }

  .results {
    grid-template-columns: minmax(400px, 1.48fr) 1px minmax(292px, 1fr);
  }
}

/* Real-time recalculation is implicit; removing the redundant chip keeps the
   order-ticket header calm and prevents it from squeezing the first column. */
.controls-header .live-chip {
  display: none;
}

/* HK / US market selector and market-specific ticket presentation. */
:root { --currency-symbol: "HK$"; }

.market-switch {
  display: inline-grid;
  flex: 0 0 auto;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 2px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: transparent;
}

.market-switch button {
  display: inline-flex;
  height: 22px;
  min-width: 44px;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 0 6px;
  color: var(--muted);
  border: 0;
  border-radius: 6px;
  background: transparent;
  font-size: 7.5px;
  font-weight: 760;
}

.market-switch button b {
  font-size: 8px;
  letter-spacing: .04em;
}

.market-switch button.is-active {
  color: #fff;
  background: var(--blue);
  box-shadow: 0 1px 3px rgba(21, 94, 239, .2);
}

.primary-market-field .input-wrap::before,
.price-input::before {
  content: var(--currency-symbol);
}

body[data-market="us"] .basis-field-grid {
  grid-template-columns: 1fr 1.08fr;
}

.market-fee-panel + .fee-preview {
  margin-top: 12px;
}

.us-fee-panel .dialog-section-heading {
  margin-bottom: 10px;
}

.target-plan-stats i {
  display: block;
  overflow: hidden;
  color: inherit;
  font-size: inherit;
  font-style: normal;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.holding-market-badge {
  display: inline-flex;
  min-width: 27px;
  height: 17px;
  align-items: center;
  justify-content: center;
  color: var(--blue);
  border: 1px solid #b2ccff;
  border-radius: 999px;
  font-size: 7px;
  font-style: normal;
  font-weight: 850;
  letter-spacing: .04em;
}

@media (max-height: 760px) {
  .market-switch button {
    height: 20px;
    min-width: 41px;
  }
}

/* Mobile workspace: preserve the desktop three-column cockpit above this
   breakpoint, but use a readable result-first vertical flow on phones instead
   of shrinking the complete desktop canvas to an unusable scale. */
@media (max-width: 820px), (max-height: 520px) and (pointer: coarse) {
  html,
  body {
    width: 100%;
    height: auto;
    min-height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-x: none;
  }

  body {
    min-width: 0;
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--canvas);
  }

  .app-shell,
  body.is-window-fitted .app-shell {
    position: relative;
    inset: auto;
    width: 100%;
    height: auto;
    min-height: 100svh;
    padding: 0;
    transform: none;
  }

  .dashboard {
    display: grid;
    width: 100%;
    height: auto;
    min-height: 100svh;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto;
    grid-template-areas:
      "header"
      "sidebar"
      "results";
    gap: 12px;
    padding: 0 12px calc(24px + env(safe-area-inset-bottom));
    overflow: visible;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .dashboard::before,
  .results::before {
    display: none;
  }

  .app-header {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
    margin: 0 -12px;
    padding: calc(12px + env(safe-area-inset-top)) 12px 11px;
    border: 0;
    border-bottom: 1px solid var(--line);
    border-radius: 0;
    background: rgba(255, 254, 254, .96);
  }

  .brand-group {
    gap: 10px;
  }

  .brand-mark {
    width: 38px;
    height: 38px;
    flex-basis: 38px;
    border-radius: 11px;
  }

  .brand-mark svg {
    width: 29px;
    height: 29px;
  }

  .brand-group .eyebrow {
    font-size: 15px;
  }

  .brand-group h1 {
    font-size: 18px;
  }

  .brand-group .lead {
    margin-top: 4px;
    font-size: 11px;
  }

  .header-actions {
    display: grid;
    width: 100%;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 7px;
  }

  .local-badge {
    display: none;
  }

  .header-tool-button,
  .reset-button {
    width: 100%;
    height: 40px;
    justify-content: center;
    gap: 6px;
    padding: 0 7px;
    border-radius: 10px;
    font-size: 11px;
  }

  .header-tool-button svg,
  .reset-button svg {
    width: 15px;
    height: 15px;
  }

  .header-disclaimer {
    max-width: none;
    padding: 0;
    overflow: visible;
    color: var(--faint);
    font-size: 10px;
    line-height: 1.5;
    text-align: left;
    text-overflow: clip;
    white-space: normal;
  }

  .sidebar-column,
  .results,
  .result-column,
  .result-column > * {
    min-height: 0;
    overflow: visible;
  }

  .controls {
    display: grid;
    height: auto;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: none;
    gap: 12px;
    padding: 13px;
    overflow: hidden;
    border-radius: 16px;
  }

  .controls-header {
    display: grid;
    width: 100%;
    min-height: 38px;
    min-width: 0;
    grid-template-columns: minmax(0, 1fr);
    gap: 9px;
    padding: 0 1px 10px;
  }

  .controls-header > div:first-child {
    gap: 8px;
  }

  .controls-header > div:first-child .panel-kicker {
    font-size: 9px;
  }

  .controls-header h2 {
    font-size: 17px;
  }

  .controls-header-tools {
    display: grid;
    width: 100%;
    min-width: 0;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
  }

  .save-holding-button,
  .fee-mode-button {
    width: 100%;
    height: 34px;
    justify-content: center;
    padding-inline: 10px;
    font-size: 10.5px;
  }

  .control-section {
    width: 100%;
    max-width: 100%;
    min-height: auto;
    padding: 13px;
    border-radius: 13px;
  }

  .control-section legend {
    max-width: 100%;
    min-height: 38px;
    flex-wrap: wrap;
    gap: 8px;
    padding-bottom: 10px;
  }

  .legend-heading {
    gap: 7px;
  }

  .legend-heading > span {
    font-size: 14px;
  }

  .legend-heading small,
  .legend-note {
    font-size: 10px;
  }

  .legend-value {
    font-size: 12px;
  }

  .market-switch {
    width: 100%;
    flex-basis: 100%;
    padding: 3px;
    border-radius: 10px;
  }

  .market-switch button,
  .market-switch button b {
    height: 31px;
    min-width: 0;
    font-size: 10px;
  }

  .stock-identity-grid,
  .basis-field-grid,
  body[data-market="us"] .basis-field-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  #lotSizeField {
    grid-column: 1 / -1;
  }

  .field,
  .target-inline-field {
    gap: 6px;
  }

  .field > span:first-child,
  .field-title,
  .target-inline-field > span:first-child,
  .slider-heading label {
    font-size: 11px;
  }

  .field-title b {
    font-size: 9px;
  }

  .primary-market-field {
    margin-block: 10px;
  }

  .input-wrap,
  .primary-market-field .input-wrap {
    height: 44px;
    border-radius: 10px;
  }

  .input-wrap input,
  .primary-market-field .input-wrap input,
  .price-input input,
  .target-input-wrap input {
    height: 42px;
    font-size: 16px;
  }

  .input-wrap::before,
  .price-input::before,
  .price-input > span:first-child {
    font-size: 12px;
  }

  .input-wrap small {
    padding-right: 10px;
    font-size: 10px;
  }

  .slider-field {
    margin-bottom: 11px;
  }

  .slider-heading {
    margin-bottom: 7px;
  }

  .slider-heading output {
    font-size: 12px;
  }

  input[type="range"] {
    height: 22px;
  }

  input[type="range"]::-webkit-slider-thumb {
    width: 20px;
    height: 20px;
    margin-top: -8px;
  }

  .range-scale {
    font-size: 10px;
  }

  .order-field-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .results {
    display: block;
  }

  .result-column {
    display: grid;
    height: auto;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: none;
    gap: 12px;
  }

  .result-main-column,
  .result-side-column {
    grid-column: auto;
    grid-row: auto;
  }

  .result-side-column {
    margin-top: 12px;
  }

  .result-hero {
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
    min-height: 148px;
    padding: 16px;
    border-radius: 16px;
  }

  .hero-label-row {
    flex-wrap: wrap;
    gap: 7px;
  }

  .hero-label-row p {
    font-size: 12px;
  }

  .calculation-badge {
    padding: 4px 7px;
    font-size: 9px;
  }

  .info-button {
    width: 24px;
    height: 24px;
    font-size: 11px;
  }

  .hero-number {
    margin-top: 10px;
  }

  .hero-number span {
    font-size: clamp(43px, 15vw, 58px);
  }

  .hero-number small {
    padding-bottom: 5px;
    font-size: 10px;
  }

  .cost-change,
  .result-insight {
    margin-top: 9px;
    font-size: 11px;
    white-space: normal;
  }

  .cashflow-card {
    display: grid;
    align-self: stretch;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "label value"
      "note note";
    gap: 5px 10px;
    align-items: center;
    padding: 12px 10px;
    border-radius: 12px;
    text-align: left;
  }

  .cashflow-card > span {
    grid-area: label;
    font-size: 9px;
  }

  .cashflow-card strong {
    grid-area: value;
    margin: 0;
    font-size: 14px;
    white-space: normal;
  }

  .cashflow-card small {
    grid-area: note;
    font-size: 9px;
  }

  .validation-message {
    padding: 11px 13px;
    font-size: 11px;
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .metric {
    min-height: 72px;
    padding: 11px;
    border-radius: 12px;
  }

  .metric-icon {
    display: grid;
    width: 28px;
    height: 28px;
    flex: 0 0 28px;
    font-size: 10px;
  }

  .metric div > span {
    font-size: 10px;
    white-space: normal;
  }

  .metric div > strong {
    margin-top: 6px;
    font-size: 13px;
  }

  .target-plan,
  .chart-section,
  .stage-section,
  .comparison-section,
  .price-position,
  .breakdown {
    height: auto;
    padding: 14px;
    border-radius: 14px;
  }

  .section-title-row {
    align-items: flex-start;
    gap: 9px;
    margin-bottom: 12px;
  }

  .section-title-row > div {
    min-width: 0;
  }

  :is(.target-plan, .chart-section, .stage-section, .comparison-section, .price-position, .breakdown) .section-title-row h2 {
    overflow: visible;
    font-size: 15px;
    line-height: 1.3;
    text-overflow: clip;
    white-space: normal;
  }

  .panel-kicker {
    font-size: 9px;
  }

  .section-title-row > span,
  :is(.target-plan, .chart-section, .stage-section, .comparison-section, .price-position, .breakdown) .section-title-row > span {
    max-width: 46%;
    overflow: hidden;
    font-size: 10px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .stage-grid,
  .result-main-column .stage-grid {
    grid-template-columns: minmax(0, 1fr) 27px minmax(0, 1fr) 27px minmax(0, 1fr);
  }

  .stage-card,
  .result-main-column .stage-card {
    padding: 11px 4px;
    border-radius: 10px;
  }

  .stage-step,
  .stage-card small {
    font-size: 9px;
  }

  .stage-card strong {
    margin-block: 5px;
    font-size: 11px;
  }

  .stage-connector b {
    font-size: 8px;
  }

  .chart-section {
    min-height: 270px;
  }

  #costChart {
    height: 210px;
    min-height: 210px;
  }

  .chart-axis-label {
    font-size: 10px;
  }

  .formula {
    margin-top: 7px;
    overflow: visible;
    font-size: 9px;
    line-height: 1.45;
    text-overflow: clip;
    white-space: normal;
  }

  .result-side-column .target-plan-body,
  .target-plan-body {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "field"
      "details"
      "action";
    gap: 11px;
    align-items: stretch;
  }

  .target-plan-copy > p {
    margin-bottom: 9px;
    overflow: visible;
    font-size: 11px;
    line-height: 1.45;
    text-overflow: clip;
    white-space: normal;
  }

  .target-plan-stats {
    gap: 7px;
  }

  .target-plan-stats span,
  .result-side-column .target-plan-stats span {
    padding: 8px;
    font-size: 9px;
  }

  .target-plan-stats strong {
    margin-top: 4px;
    font-size: 11px;
  }

  .apply-button {
    height: 42px;
    border-radius: 10px;
    font-size: 12px;
  }

  .comparison-section {
    min-height: 286px;
  }

  .table-scroll {
    height: auto;
    overflow: visible;
  }

  .comparison-table {
    height: auto;
    font-size: 10px;
  }

  .comparison-table th {
    height: 34px;
    padding-inline: 3px;
    font-size: 9px;
  }

  .comparison-table td {
    height: 42px;
    padding-inline: 3px;
    font-size: 10px;
  }

  .current-badge {
    display: none;
  }

  .table-action {
    min-width: 42px;
    height: 30px;
    padding-inline: 5px;
    border-radius: 8px;
    font-size: 9px;
  }

  .position-track {
    height: 7px;
  }

  .position-dot {
    width: 14px;
    height: 14px;
  }

  .position-labels {
    margin-top: 9px;
    font-size: 10px;
  }

  .breakdown dl > div {
    padding-block: 10px;
  }

  .breakdown dt {
    font-size: 11px;
  }

  .breakdown dd {
    font-size: 12px;
  }

  .app-dialog {
    width: calc(100vw - 24px);
    max-width: none;
    max-height: calc(100dvh - 24px);
    margin: auto;
    border-radius: 16px;
  }

  .dialog-header {
    padding: 15px 16px 12px;
  }

  .dialog-header h2 {
    font-size: 17px;
  }

  .dialog-body {
    max-height: calc(100dvh - 150px);
    padding: 14px 16px;
    overflow-y: auto;
  }

  .dialog-actions {
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  }

  .fee-setting-grid,
  .fee-check-grid,
  .scenario-grid,
  .holding-list {
    grid-template-columns: minmax(0, 1fr);
  }

  .holding-book-dialog-body,
  .holding-list {
    max-height: none;
  }

  .holding-book-summary,
  .holding-book-summary-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .unsaved-dialog-actions,
  .import-backup-dialog-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
  }

  .dialog-primary,
  .dialog-secondary {
    width: 100%;
    min-height: 42px;
  }
}

/* Desktop readability pass: keep the one-screen cockpit while lifting the type floor. */
@media (min-width: 821px) and (min-height: 521px) {
  .brand-group .eyebrow {
    font-size: 15px;
    font-weight: 900;
  }
  .app-header h1 { font-size: 17px; }
  .lead { font-size: 10px; }
  .header-disclaimer { font-size: 8.5px; }
  .local-badge,
  .header-tool-button,
  .reset-button { font-size: 9px; }

  .controls-header .panel-kicker,
  .section-title-row .panel-kicker { font-size: 8.75px; }
  .controls-header h2 { font-size: 14px; }
  .save-holding-button,
  .fee-mode-button { font-size: 9px; }
  .legend-heading > span { font-size: 11px; }
  .legend-heading small { font-size: 9px; }
  .legend-note { font-size: 8.5px; }
  .legend-value { font-size: 10px; }
  .market-switch button { font-size: 9px; }
  .market-switch button b { font-size: 9.5px; }

  .field > span:first-child,
  .field-title,
  .slider-heading label,
  .target-inline-field > span:first-child { font-size: 10px; }
  .field-title b,
  .stock-name-field > span:first-child b { font-size: 8px; }
  .input-wrap input { font-size: 12.5px; }
  .stock-identity-grid .input-wrap input { font-size: 12px; }
  .input-wrap small { font-size: 8.5px; }
  .primary-market-field .input-wrap::before,
  .price-input::before { font-size: 9px; }
  .primary-market-field .input-wrap input { font-size: 18px; }
  .primary-market-field .input-wrap small { font-size: 8.5px; }
  .compact-field .input-wrap input { font-size: 11.5px; }
  .price-input input { font-size: 13px; }
  .range-scale { font-size: 9px; }

  .hero-label-row p { font-size: 10.5px; }
  .calculation-badge { font-size: 9px; }
  .hero-number small { font-size: 9.5px; }
  .cost-change { font-size: 10px; }
  .result-insight { font-size: 9px; }
  .cashflow-card > span { font-size: 9.5px; }
  .cashflow-card strong { font-size: 15px; }
  .cashflow-card small { font-size: 9px; }
  .metric-icon { display: none; }
  .metric div > span { font-size: 9px; }
  .metric div > strong { font-size: 11.5px; }

  :is(.target-plan, .chart-section, .stage-section, .comparison-section, .price-position, .breakdown) .section-title-row h2 {
    font-size: 13.25px;
  }
  .section-title-row > span { font-size: 9px; }
  .target-badge { font-size: 9px !important; }
  .target-input-wrap input { font-size: 12.5px; }
  .target-plan-copy > p { font-size: 9.5px; }
  .target-plan-stats span,
  .result-side-column .target-plan-stats span { font-size: 9px; }
  .target-plan-stats strong { font-size: 10.5px; }
  .apply-button { font-size: 9.5px; }

  .stage-step,
  .stage-card small { font-size: 9px; }
  .stage-card strong { font-size: 10.5px; }
  .stage-connector b { font-size: 8.5px; }
  .chart-axis-label { font-size: 9.5px; }
  .chart-basis-label,
  .chart-point-label { font-size: 11px; }
  .formula { font-size: 8.5px; }

  .comparison-table { font-size: 9.5px; }
  .comparison-table th { font-size: 9px; }
  .comparison-table td { font-size: 9.5px; }
  .comparison-table :is(th, td):nth-child(1) { width: 16%; }
  .comparison-table :is(th, td):nth-child(2) { width: 16%; }
  .comparison-table :is(th, td):nth-child(3) { width: 28%; }
  .comparison-table :is(th, td):nth-child(4) { width: 24%; }
  .comparison-table :is(th, td):nth-child(5) { width: 16%; }
  .current-badge { font-size: 8px; }
  .table-action { font-size: 8.5px; }
  .position-labels { font-size: 9px; }
  .breakdown dt { font-size: 9px; }
  .breakdown dd { font-size: 10.5px; }

  /* Keep the compact right-hand tools readable on desktop. */
  .result-side-column
    :is(.target-plan, .comparison-section, .price-position, .breakdown)
    .panel-kicker,
  .result-side-column
    :is(.comparison-section, .price-position, .breakdown)
    .section-title-row > span,
  .target-plan .target-inline-field > span:first-child,
  .target-plan .input-wrap small,
  .target-plan .target-plan-copy > p,
  .target-plan .target-plan-stats span,
  .comparison-section .comparison-table th,
  .comparison-section .comparison-table td,
  .price-position .position-labels,
  .price-position .position-labels span:last-child,
  .breakdown dt,
  .breakdown dd {
    color: #101828;
  }

  /* Preserve status colors when the target calculation needs attention. */
  .target-plan.target-plan-invalid .target-plan-copy > p,
  .target-plan.target-plan-impossible .target-plan-copy > p {
    color: var(--red);
  }

  .target-plan.target-plan-reached .target-plan-copy > p {
    color: var(--green);
  }

  /* The larger target details need a little more vertical room; the matrix
     remains comfortably above its minimum height in the same fixed viewport. */
  .result-side-column {
    grid-template-rows: 148px minmax(166px, 1fr) 76px 135px;
  }
}

/* Cohesive desktop workspace refresh: a calmer header, one clear input rail,
   a stronger result hierarchy, and fewer nested card outlines. */
@media (min-width: 821px) and (min-height: 521px) {
  .app-shell {
    padding: 10px;
  }

  .dashboard {
    grid-template-columns: clamp(310px, 25.2vw, 326px) 1px minmax(0, 1fr);
    grid-template-rows: 60px minmax(0, 1fr);
    column-gap: 10px;
    row-gap: 12px;
    padding: 0 12px 12px;
    border-color: #dfe3ec;
    border-radius: 18px;
    box-shadow: 0 12px 36px rgba(49, 60, 103, .08);
  }

  .dashboard::before,
  .results::before {
    height: calc(100% - 12px);
    background: #dfe3ec;
  }

  .app-header {
    display: grid;
    grid-template-columns: auto minmax(170px, 1fr) auto;
    gap: 14px;
    margin-inline: -12px;
    padding-inline: 16px;
    border-radius: 18px 18px 0 0;
  }

  .brand-group {
    gap: 12px;
  }

  .brand-mark {
    width: 38px;
    height: 38px;
    flex-basis: 38px;
    border-radius: 11px;
  }

  .brand-mark svg {
    width: 29px;
    height: 29px;
  }

  .brand-group .lead {
    margin-top: 3px;
  }

  .header-disclaimer {
    width: 100%;
    max-width: 420px;
    justify-self: center;
    padding-inline: 8px;
    overflow: visible;
    color: #526078;
    line-height: 1.3;
    text-overflow: clip;
    white-space: normal;
  }

  .header-actions {
    gap: 0;
    overflow: hidden;
    border: 1px solid var(--line-strong);
    border-radius: 10px;
  }

  .local-badge,
  .header-tool-button,
  .reset-button {
    height: 31px;
    border: 0;
    border-left: 1px solid var(--line);
    border-radius: 0;
    background: transparent;
  }

  .local-badge {
    padding-inline: 9px;
    border-left: 0;
  }

  .header-tool-button,
  .reset-button {
    padding-inline: 8px;
  }

  .header-tool-button:hover,
  .reset-button:hover {
    color: var(--blue);
    border-color: var(--line);
    background: transparent;
  }

  .new-measurement-button {
    color: var(--blue);
    font-weight: 850;
  }

  .sidebar-column,
  .results {
    min-height: 0;
  }

  .controls {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: 38px minmax(0, 1.13fr) minmax(0, 1fr) minmax(0, 1fr);
    gap: 10px;
    padding: 0;
    border: 0;
    border-radius: 0;
  }

  .controls > .controls-header,
  .controls > .control-section {
    min-width: 0;
  }

  .controls-header {
    padding: 0 2px 6px;
    border-bottom: 1px solid var(--line);
  }

  .controls-header-tools {
    gap: 5px;
  }

  .save-holding-button,
  .fee-mode-button {
    height: 25px;
    border-radius: 8px;
  }

  .control-section {
    padding: 10px 11px 11px;
    border-color: #dfe3ec;
    border-radius: 12px;
  }

  .control-section::after {
    top: 12px;
    bottom: 12px;
    width: 3px;
  }

  .control-section legend {
    min-height: 30px;
    padding-bottom: 7px;
  }

  .legend-heading {
    column-gap: 8px;
  }

  .legend-heading > span {
    color: #101828;
    font-weight: 800;
  }

  .legend-heading small,
  .legend-note {
    color: #526078;
  }

  .field > span:first-child,
  .field-title,
  .slider-heading label,
  .target-inline-field > span:first-child {
    color: #344054;
    font-weight: 650;
  }

  .input-wrap {
    border-color: #d5dae5;
    border-radius: 9px;
  }

  .input-wrap:hover {
    border-color: #98a2b3;
  }

  .input-wrap:focus-within {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(83, 111, 240, .1);
  }

  .input-wrap small,
  .range-scale {
    color: #526078;
  }

  .results {
    grid-template-columns: minmax(390px, 1.62fr) 1px minmax(312px, 1fr);
    column-gap: 10px;
  }

  .result-column {
    gap: 10px;
  }

  .result-main-column {
    grid-template-rows: 132px 68px 104px minmax(0, 1fr);
  }

  .result-side-column {
    grid-template-rows: 152px minmax(158px, 1fr) 76px 130px;
  }

  .result-column > .panel,
  .result-column > .metric-grid {
    border-color: #dfe3ec;
  }

  .result-hero {
    grid-template-columns: minmax(0, 1.4fr) minmax(168px, .72fr);
    gap: 14px;
    padding: 14px 16px 13px;
    border-left: 3px solid var(--blue);
    border-radius: 12px;
  }

  .hero-label-row {
    gap: 7px;
  }

  .hero-number {
    margin-top: 6px;
    line-height: .96;
  }

  .hero-number span {
    font-size: clamp(45px, 4vw, 54px);
  }

  .cost-change {
    margin-top: 9px;
  }

  .cashflow-card {
    padding: 10px 4px 10px 16px;
  }

  .metric-grid {
    gap: 0;
    overflow: hidden;
    border: 1px solid #dfe3ec;
    border-radius: 12px;
  }

  .metric-grid .metric {
    justify-content: center;
    padding: 9px 10px;
    border: 0;
    border-right: 1px solid var(--line);
    border-radius: 0;
  }

  .metric-grid .metric:last-child {
    border-right: 0;
  }

  .metric div > span {
    color: #475467;
  }

  .metric div > strong {
    margin-top: 5px;
    color: #101828;
  }

  .target-plan,
  .chart-section,
  .stage-section,
  .comparison-section,
  .price-position,
  .breakdown {
    padding: 11px 12px;
    border-radius: 12px;
  }

  .section-title-row {
    gap: 10px;
    margin-bottom: 9px;
  }

  .section-title-row > div {
    gap: 8px;
  }

  :is(.target-plan, .chart-section, .stage-section, .comparison-section, .price-position, .breakdown) .section-title-row h2 {
    color: #101828;
    font-size: 13.5px;
    font-weight: 800;
  }

  .result-main-column .section-title-row .panel-kicker {
    color: #536ff0;
  }

  .stage-section .stage-grid {
    height: calc(100% - 25px);
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 10px;
  }

  .result-main-column .stage-card {
    height: 100%;
    padding: 5px 6px;
    border: 0;
    border-radius: 0;
  }

  .stage-connector {
    height: 100%;
    align-content: center;
    border-inline: 1px solid #eef0f5;
  }

  .stage-section .section-title-row {
    margin-bottom: 7px;
  }

  #costChart {
    height: calc(100% - 45px);
  }

  .target-plan-accent {
    top: 12px;
    bottom: 12px;
    left: -1px;
    width: 3px;
    height: auto;
    border-radius: 0 3px 3px 0;
  }

  .result-side-column .target-plan-body {
    grid-template-columns: 122px minmax(0, 1fr);
    column-gap: 9px;
    row-gap: 4px;
  }

  .result-side-column .target-plan-copy > p {
    margin-bottom: 3px;
  }

  .target-plan-stats {
    gap: 0;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 9px;
  }

  .target-plan-stats span,
  .result-side-column .target-plan-stats span {
    padding: 4px 6px;
    border-left: 1px solid var(--line);
  }

  .target-plan-stats span:first-child {
    border-left: 0;
  }

  .apply-button {
    height: 31px;
    border-radius: 9px;
  }

  .comparison-section .table-scroll {
    height: calc(100% - 31px);
  }

  .comparison-table th {
    height: 24px;
    border-bottom-color: #dfe3ec;
  }

  .comparison-table td {
    border-bottom-color: #eceff4;
  }

  .comparison-table tbody tr.is-selected {
    box-shadow: inset 3px 0 var(--blue);
  }

  .comparison-table .current-badge {
    display: none;
  }

  .position-track {
    height: 6px;
  }

  .breakdown dl > div {
    padding-block: 4px;
    border-bottom-color: #eceff4;
  }

  @media (max-width: 1180px) {
    .dashboard {
      grid-template-columns: minmax(282px, .82fr) 1px minmax(0, 2.5fr);
      column-gap: 8px;
    }

    .results {
      grid-template-columns: minmax(390px, 1.45fr) 1px minmax(286px, 1fr);
      column-gap: 8px;
    }

    .app-header {
      grid-template-columns: auto minmax(120px, 1fr) auto;
      gap: 9px;
      padding-inline: 12px;
    }

    .header-disclaimer {
      max-width: 240px;
      padding-inline: 4px;
    }

    .header-tool-button,
    .reset-button {
      padding-inline: 6px;
    }

    .save-holding-button {
      width: 27px;
      flex: 0 0 27px;
      justify-content: center;
      padding-inline: 0;
    }

    .save-holding-button span {
      display: none;
    }

    .trade-section .slider-field {
      margin-bottom: 4px;
    }

    .comparison-section .table-scroll {
      height: calc(100% - 27px);
    }

    .comparison-table th {
      height: 18px;
      padding: 1px 3px;
    }

    .comparison-table td {
      height: 18px;
      padding: 0 3px;
    }

    .comparison-table :is(th, td):nth-child(1) { width: 14%; }
    .comparison-table :is(th, td):nth-child(2) { width: 15%; }
    .comparison-table :is(th, td):nth-child(3) { width: 31%; }
    .comparison-table :is(th, td):nth-child(4) { width: 24%; }
    .comparison-table :is(th, td):nth-child(5) { width: 16%; }

    .table-action {
      height: 16px;
      padding-inline: 3px;
      font-size: 8px;
    }

    .result-hero {
      grid-template-columns: minmax(0, 1fr) 148px;
      gap: 10px;
      padding-inline: 13px;
    }

    .cashflow-card {
      padding-left: 11px;
    }

    .result-side-column .target-plan-body {
      grid-template-columns: 112px minmax(0, 1fr);
    }
  }
}

/* Keep the mobile lot matrix readable without clipping larger cash amounts. */
@media (max-width: 820px), (max-height: 520px) and (pointer: coarse) {
  .comparison-table :is(th, td):nth-child(1) { width: 13%; }
  .comparison-table :is(th, td):nth-child(2) { width: 15%; }
  .comparison-table :is(th, td):nth-child(3) { width: 30%; }
  .comparison-table :is(th, td):nth-child(4) { width: 25%; }
  .comparison-table :is(th, td):nth-child(5) { width: 17%; }
}

/* Selective trade-plan clearing: compact in the ticket header, explicit on action. */
.clear-plan-control {
  position: relative;
  z-index: 12;
  flex: 0 0 auto;
}

.clear-plan-button {
  display: inline-flex;
  height: 25px;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 0 7px;
  color: #475467;
  border: 1px solid #d0d5dd;
  border-radius: 8px;
  background: transparent;
  font-size: 8.5px;
  font-weight: 800;
  white-space: nowrap;
  transition: color .16s ease, border-color .16s ease, background-color .16s ease;
}

.clear-plan-button:hover,
.clear-plan-button.is-open {
  color: #b42318;
  border-color: #fda29b;
  background: #fffafa;
}

.clear-plan-button svg {
  width: 11px;
  height: 11px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.clear-plan-button .clear-plan-chevron {
  width: 8px;
  height: 8px;
  margin-left: 1px;
  transition: transform .16s ease;
}

.clear-plan-button.is-open .clear-plan-chevron {
  transform: rotate(180deg);
}

.clear-plan-menu {
  position: absolute;
  top: calc(100% + 7px);
  right: 0;
  width: 226px;
  padding: 7px;
  overflow: hidden;
  border: 1px solid #d0d5dd;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 14px 30px rgba(16, 24, 40, .14), 0 3px 8px rgba(16, 24, 40, .08);
}

.clear-plan-menu[hidden] {
  display: none;
}

.clear-plan-menu > p {
  margin: 1px 5px 6px;
  color: #667085;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: .04em;
}

.clear-plan-menu button {
  display: grid;
  width: 100%;
  gap: 2px;
  padding: 7px 8px;
  color: #344054;
  border: 0;
  border-radius: 8px;
  background: transparent;
  text-align: left;
}

.clear-plan-menu button:hover,
.clear-plan-menu button:focus-visible {
  background: #f5f7fa;
  outline: none;
}

.clear-plan-menu button + button {
  margin-top: 2px;
}

.clear-plan-menu button > span {
  display: flex;
  align-items: center;
  gap: 7px;
}

.clear-plan-menu button b {
  display: inline-grid;
  width: 19px;
  height: 19px;
  flex: 0 0 19px;
  place-items: center;
  color: #475467;
  border: 1px solid #d0d5dd;
  border-radius: 6px;
  font-size: 8px;
}

.clear-plan-menu button strong {
  color: #101828;
  font-size: 9.5px;
  font-weight: 800;
}

.clear-plan-menu button small {
  padding-left: 26px;
  color: #667085;
  font-size: 8px;
  line-height: 1.35;
}

.clear-plan-menu .clear-plan-all {
  margin-top: 5px;
  padding-top: 8px;
  border-top: 1px solid #eaecf0;
  border-radius: 0 0 8px 8px;
}

.clear-plan-menu .clear-plan-all b,
.clear-plan-menu .clear-plan-all strong {
  color: #b42318;
}

.clear-plan-menu .clear-plan-all b {
  border-color: #fda29b;
  background: #fff5f4;
}

@media (max-width: 1180px) and (min-width: 821px) {
  .clear-plan-button {
    width: 27px;
    flex: 0 0 27px;
    padding-inline: 0;
  }

  .clear-plan-button > span,
  .clear-plan-button .clear-plan-chevron {
    display: none;
  }
}

@media (max-width: 820px), (max-height: 520px) and (pointer: coarse) {
  .controls-header-tools {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .clear-plan-control,
  .clear-plan-button {
    width: 100%;
  }

  .clear-plan-button {
    height: 34px;
    padding-inline: 10px;
    font-size: 10.5px;
  }

  .clear-plan-button svg {
    width: 13px;
    height: 13px;
  }

  .clear-plan-button .clear-plan-chevron {
    width: 9px;
    height: 9px;
  }

  .clear-plan-menu {
    width: min(244px, calc(100vw - 38px));
    padding: 8px;
  }

  .clear-plan-menu > p {
    font-size: 9px;
  }

  .clear-plan-menu button {
    padding: 9px;
  }

  .clear-plan-menu button strong {
    font-size: 11px;
  }

  .clear-plan-menu button small {
    font-size: 9px;
  }
}

/* Mobile uses two focused views instead of one very long calculator canvas. */
.mobile-page-switcher,
.mobile-results-cta {
  display: none;
}

@media (max-width: 820px), (max-height: 520px) and (pointer: coarse) {
  .dashboard {
    grid-template-areas:
      "header"
      "mobile-nav"
      "sidebar"
      "results";
  }

  .mobile-page-switcher {
    position: sticky;
    top: 0;
    z-index: 20;
    grid-area: mobile-nav;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px;
    margin: 0 -2px;
    padding: 4px;
    border: 1px solid #dfe3ec;
    border-radius: 12px;
    background: rgba(255, 255, 255, .94);
    box-shadow: 0 5px 18px rgba(16, 24, 40, .06);
    backdrop-filter: blur(12px);
  }

  .mobile-page-switcher button {
    display: inline-flex;
    height: 40px;
    align-items: center;
    justify-content: center;
    gap: 7px;
    color: #667085;
    border: 0;
    border-radius: 9px;
    background: transparent;
    font-size: 12px;
    font-weight: 800;
  }

  .mobile-page-switcher button span {
    display: inline-grid;
    width: 22px;
    height: 22px;
    place-items: center;
    color: #667085;
    border: 1px solid #d0d5dd;
    border-radius: 7px;
    font-size: 8px;
    letter-spacing: .04em;
  }

  .mobile-page-switcher button.is-active {
    color: #fff;
    background: var(--blue);
    box-shadow: 0 3px 10px rgba(21, 94, 239, .22);
  }

  .mobile-page-switcher button.is-active span {
    color: #fff;
    border-color: rgba(255, 255, 255, .48);
  }

  body[data-mobile-page="ticket"] .results,
  body[data-mobile-page="results"] .sidebar-column {
    display: none;
  }

  .mobile-results-cta {
    position: sticky;
    bottom: calc(10px + env(safe-area-inset-bottom));
    z-index: 18;
    display: grid;
    width: calc(100% - 8px);
    min-height: 58px;
    grid-template-columns: minmax(0, 1fr) auto 18px;
    align-items: center;
    gap: 10px;
    margin: 2px 4px 0;
    padding: 9px 12px 9px 15px;
    color: #fff;
    border: 0;
    border-radius: 14px;
    background: var(--blue);
    box-shadow: 0 12px 28px rgba(21, 94, 239, .28);
    text-align: left;
  }

  .mobile-results-cta > span {
    display: grid;
    gap: 2px;
    font-size: 13px;
    font-weight: 850;
  }

  .mobile-results-cta small {
    color: rgba(255, 255, 255, .72);
    font-size: 8.5px;
    font-weight: 600;
  }

  .mobile-results-cta strong {
    font-size: 11px;
    font-weight: 850;
    white-space: nowrap;
  }

  .mobile-results-cta svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  body[data-mobile-page="results"] .results {
    animation: mobile-view-enter .2s ease both;
  }

  body[data-mobile-page="ticket"] .sidebar-column {
    animation: mobile-view-enter .2s ease both;
  }

  .chart-basis-label,
  .chart-point-label {
    font-size: 14px;
  }
}

@keyframes mobile-view-enter {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  body[data-mobile-page] :is(.results, .sidebar-column) {
    animation: none;
  }
}


/* 2026 readability and theme pass: stronger type contrast with an X-inspired dark blue mode. */
:root {
  --ink: #0f172a;
  --muted: #1f2937;
  --faint: #374151;
}

.theme-toggle {
  display: inline-flex;
  min-width: 62px;
  height: 31px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  gap: 5px;
  margin-left: 3px;
  padding: 0 8px;
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: transparent;
  font-size: 10px;
  font-weight: 800;
}
.theme-toggle:hover { color: var(--blue); border-color: var(--blue); }
.theme-icon { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.theme-icon-sun { display: none; }
html[data-theme="dark"] .theme-icon-moon { display: none; }
html[data-theme="dark"] .theme-icon-sun { display: block; }

/* Remove low-contrast gray text from the light theme. */
.lead, .header-disclaimer, .local-badge,
.legend-heading small, .legend-note, .input-wrap small, .range-scale,
.hero-label-row p, .hero-number small, .cashflow-card > span, .cashflow-card small,
.metric div > span, .section-title-row > span, .target-plan-copy > p,
.target-plan-stats span, .stage-step, .stage-card small, .stage-connector,
.comparison-table th, .comparison-table td, .position-labels, .breakdown dt,
.formula, .disclaimer, .clear-plan-menu > p, .clear-plan-menu button small,
.holding-book-summary-copy small, .dialog-section-heading small {
  color: var(--muted);
}
.chart-axis-label { fill: var(--muted); }

@media (min-width: 821px) and (min-height: 521px) {
  .brand-group .eyebrow { font-size: 16px; }
  .app-header h1 { font-size: 18px; }
  .lead { font-size: 11px; }
  .header-disclaimer { font-size: 9.5px; }
  .local-badge, .header-tool-button, .reset-button { font-size: 10px; }
  .controls-header .panel-kicker, .section-title-row .panel-kicker { font-size: 9.5px; }
  .controls-header h2 { font-size: 15px; }
  .save-holding-button, .fee-mode-button, .clear-plan-button { font-size: 9.5px; }
  .legend-heading > span { font-size: 12px; }
  .legend-heading small, .legend-note { font-size: 9.5px; }
  .legend-value { font-size: 11px; }
  .field > span:first-child, .field-title, .slider-heading label, .target-inline-field > span:first-child { font-size: 11px; }
  .field-title b, .stock-name-field > span:first-child b { font-size: 9px; }
  .input-wrap input { font-size: 13.5px; }
  .stock-identity-grid .input-wrap input { font-size: 13px; }
  .input-wrap small { font-size: 9.5px; }
  .primary-market-field .input-wrap input { font-size: 19px; }
  .compact-field .input-wrap input { font-size: 12.5px; }
  .price-input input { font-size: 14px; }
  .range-scale { font-size: 9.5px; }
  .hero-label-row p { font-size: 11.5px; }
  .hero-number small, .cost-change { font-size: 10.5px; }
  .result-insight { font-size: 10px; }
  .cashflow-card > span, .cashflow-card small { font-size: 10px; }
  .cashflow-card strong { font-size: 16px; }
  .metric div > span { font-size: 10px; }
  .metric div > strong { font-size: 12.5px; }
  :is(.target-plan,.chart-section,.stage-section,.comparison-section,.price-position,.breakdown) .section-title-row h2 { font-size: 14.5px; }
  .section-title-row > span, .target-badge { font-size: 10px !important; }
  .target-plan-copy > p, .target-plan-stats span { font-size: 10px; }
  .target-plan-stats strong { font-size: 11.5px; }
  .stage-step, .stage-card small { font-size: 9.5px; }
  .stage-card strong { font-size: 11.5px; }
  .chart-axis-label { font-size: 10.5px; }
  .chart-basis-label, .chart-point-label { font-size: 12px; }
  .formula { font-size: 9.5px; }
  .comparison-table, .comparison-table th, .comparison-table td { font-size: 10px; }
  .position-labels, .breakdown dt { font-size: 10px; }
  .breakdown dd { font-size: 11.5px; }
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1419;
  --canvas: #15202b;
  --ink: #f7f9f9;
  --muted: #d6d9db;
  --faint: #aab8c2;
  --line: #2f3b46;
  --line-strong: #425466;
  --blue: #1d9bf0;
  --green: #00ba7c;
  --red: #f4212e;
  --amber: #ffad1f;
}
html[data-theme="dark"] body { background: #0f1419; }
html[data-theme="dark"] .dashboard { background: #15202b; border-color: #2f3b46; box-shadow: 0 12px 36px rgba(0,0,0,.3); }
html[data-theme="dark"] .app-header,
html[data-theme="dark"] .mobile-page-switcher { background: rgba(21,32,43,.96); }
html[data-theme="dark"] .app-header h1,
html[data-theme="dark"] .controls-header h2,
html[data-theme="dark"] :is(.target-plan,.chart-section,.stage-section,.comparison-section,.price-position,.breakdown) .section-title-row h2,
html[data-theme="dark"] .legend-heading > span,
html[data-theme="dark"] .metric div > strong,
html[data-theme="dark"] .comparison-table td,
html[data-theme="dark"] .breakdown dd,
html[data-theme="dark"] .clear-plan-menu button strong { color: var(--ink); }
html[data-theme="dark"] .panel,
html[data-theme="dark"] .control-section,
html[data-theme="dark"] .metric-grid,
html[data-theme="dark"] .stage-grid,
html[data-theme="dark"] .target-plan-stats { border-color: var(--line); }
html[data-theme="dark"] .input-wrap,
html[data-theme="dark"] .price-input,
html[data-theme="dark"] .target-input-wrap,
html[data-theme="dark"] .clear-plan-menu,
html[data-theme="dark"] .app-dialog { color: var(--ink); border-color: var(--line-strong); background: #192734; }
html[data-theme="dark"] input { color: var(--ink); }
html[data-theme="dark"] input::placeholder { color: #8899a6; }
html[data-theme="dark"] .header-tool-button,
html[data-theme="dark"] .reset-button,
html[data-theme="dark"] .theme-toggle,
html[data-theme="dark"] .fee-mode-button,
html[data-theme="dark"] .clear-plan-button { color: var(--ink); border-color: var(--line-strong); }
html[data-theme="dark"] .header-tool-button:hover,
html[data-theme="dark"] .reset-button:hover,
html[data-theme="dark"] .theme-toggle:hover { color: var(--blue); }
html[data-theme="dark"] .metric-grid .metric,
html[data-theme="dark"] .cashflow-card,
html[data-theme="dark"] .stage-card { border-color: var(--line); background: transparent; }
html[data-theme="dark"] .chart-grid-line { stroke: #2f3b46; }
html[data-theme="dark"] .chart-area { fill: rgba(29,155,240,.1); }
html[data-theme="dark"] .chart-guide { stroke: #536471; }
html[data-theme="dark"] .chart-basis-point,
html[data-theme="dark"] .chart-point { fill: #15202b; }
html[data-theme="dark"] .chart-basis-callout rect,
html[data-theme="dark"] .chart-point-callout rect { fill: rgba(25,39,52,.98); }
html[data-theme="dark"] .chart-basis-label { fill: #d6d9db; stroke: #192734; }
html[data-theme="dark"] .chart-point-label { fill: #8ecdf7; stroke: #192734; }
html[data-theme="dark"] .comparison-table td,
html[data-theme="dark"] .comparison-table th,
html[data-theme="dark"] .breakdown dl > div { border-bottom-color: #263746; }
html[data-theme="dark"] .comparison-table tbody tr.is-selected { background: rgba(29,155,240,.08); }
html[data-theme="dark"] .position-track { background: #2f3b46; }
html[data-theme="dark"] .clear-plan-menu button:hover,
html[data-theme="dark"] .clear-plan-menu button:focus-visible { background: #22303c; }
html[data-theme="dark"] .copy-toast { color: #f7f9f9; background: #192734; border-color: #425466; }

@media (max-width: 820px), (max-height: 520px) and (pointer: coarse) {
  .theme-toggle { margin-left: auto; min-width: 72px; height: 36px; font-size: 11px; }
  .header-disclaimer { color: var(--muted); font-size: 11px; }
  .field > span:first-child, .field-title, .target-inline-field > span:first-child, .slider-heading label { font-size: 12px; }
  .legend-heading small, .legend-note, .input-wrap small, .range-scale { font-size: 11px; }
  .metric div > span, .cashflow-card > span, .cashflow-card small { font-size: 11px; }
  .section-title-row > span, .target-plan-copy > p, .target-plan-stats span, .stage-step, .stage-card small,
  .comparison-table th, .comparison-table td, .position-labels, .breakdown dt, .formula { font-size: 10.5px; }
}

/* Readability pass v2: raise the type floor again, keep the one-screen desktop,
   and make the dark theme consistently legible instead of inheriting light-only ink. */
:root {
  --muted: #111827;
  --faint: #1f2937;
}

@media (min-width: 821px) and (min-height: 521px) {
  .brand-group .eyebrow { font-size: 17px; }
  .app-header h1 { font-size: 19px; }
  .lead { font-size: 11.5px; }
  .header-disclaimer { font-size: 10px; }
  .local-badge, .header-tool-button, .reset-button { font-size: 10.5px; }
  .theme-toggle { min-width: 66px; height: 33px; font-size: 10.5px; }

  .controls-header .panel-kicker,
  .section-title-row .panel-kicker { font-size: 10px; }
  .controls-header h2 { font-size: 15.5px; }
  .save-holding-button, .fee-mode-button, .clear-plan-button { font-size: 10px; }
  .legend-heading > span { font-size: 12.5px; }
  .legend-heading small, .legend-note { font-size: 10px; }
  .legend-value { font-size: 11.5px; }
  .market-switch button { font-size: 10px; }
  .market-switch button b { font-size: 10.5px; }

  .field > span:first-child,
  .field-title,
  .slider-heading label,
  .target-inline-field > span:first-child { font-size: 11.5px; }
  .field-title b, .stock-name-field > span:first-child b { font-size: 9.5px; }
  .input-wrap input { font-size: 14px; }
  .stock-identity-grid .input-wrap input { font-size: 13.5px; }
  .input-wrap small { font-size: 10px; }
  .primary-market-field .input-wrap::before,
  .price-input::before { font-size: 10px; }
  .primary-market-field .input-wrap input { font-size: 20px; }
  .compact-field .input-wrap input { font-size: 13px; }
  .price-input input { font-size: 14.5px; }
  .range-scale { font-size: 10px; }

  .hero-label-row p { font-size: 12px; }
  .calculation-badge { font-size: 10px; }
  .hero-number small, .cost-change { font-size: 11px; }
  .result-insight { font-size: 10.5px; }
  .cashflow-card > span, .cashflow-card small { font-size: 10.5px; }
  .cashflow-card strong { font-size: 17px; }
  .metric div > span { font-size: 10.5px; }
  .metric div > strong { font-size: 13px; }

  :is(.target-plan,.chart-section,.stage-section,.comparison-section,.price-position,.breakdown) .section-title-row h2 {
    flex: 0 0 auto;
    font-size: 15px;
  }
  :is(.target-plan,.chart-section,.stage-section,.comparison-section,.price-position,.breakdown) .section-title-row > span {
    min-width: 0;
    flex: 1 1 auto;
    overflow: hidden;
    font-size: 10.5px !important;
    text-align: right;
    text-overflow: ellipsis;
  }
  .target-badge { font-size: 10.5px !important; }
  .target-input-wrap input { font-size: 14px; }
  .target-plan-copy > p, .target-plan-stats span { font-size: 10.5px; }
  .target-plan-stats strong { font-size: 12px; }
  .apply-button { font-size: 10.5px; }

  .stage-step, .stage-card small { font-size: 10px; }
  .stage-card strong { font-size: 12px; }
  .stage-connector b { font-size: 9.5px; }
  .chart-axis-label { font-size: 11px; }
  .chart-basis-label, .chart-point-label { font-size: 12.5px; }
  .formula { font-size: 10px; }

  .comparison-table, .comparison-table th, .comparison-table td { font-size: 10.5px; }
  .current-badge { font-size: 9px; }
  .table-action { font-size: 9.5px; }
  .position-labels, .breakdown dt { font-size: 10.5px; }
  .breakdown dd { font-size: 12px; }

  /* Give enlarged target and flow content real room instead of clipping it. */
  .result-main-column { grid-template-rows: 132px 68px 108px minmax(0, 1fr); }
  .result-side-column { grid-template-rows: 162px minmax(148px, 1fr) 76px 134px; }
  .stage-section .stage-grid { height: calc(100% - 24px); }

  /* Preserve the complete Chinese section titles; secondary data may ellipsize first. */
  .section-title-row > div { flex: 0 0 auto; }
  #positionSummary, #comparisonMeta { max-width: 92px; }
}

@media (min-width: 1200px) and (min-height: 720px) {
  .brand-group .eyebrow { font-size: 18px; }
  .app-header h1 { font-size: 20px; }
  .lead { font-size: 12px; }
  .header-disclaimer { font-size: 10.5px; }
  .controls-header h2 { font-size: 16px; }
  .field > span:first-child, .field-title, .slider-heading label,
  .target-inline-field > span:first-child { font-size: 12px; }
  :is(.target-plan,.chart-section,.stage-section,.comparison-section,.price-position,.breakdown) .section-title-row h2 { font-size: 15.5px; }
}

@media (max-width: 1180px) and (min-width: 821px) {
  .header-disclaimer { font-size: 9.75px; }
  .header-actions :is(.local-badge, .header-tool-button, .reset-button) { font-size: 10px; }
  .metric-grid .metric { padding-inline: 6px; }
  .metric div > strong { font-size: 12.5px; }
  #positionSummary, #comparisonMeta { max-width: 64px; }
}

/* X-inspired dark blue: every light-theme hard-coded label gets a dark equivalent. */
html[data-theme="dark"] .mobile-page-switcher,
html[data-theme="dark"] .app-header,
html[data-theme="dark"] .controls-header,
html[data-theme="dark"] .header-actions,
html[data-theme="dark"] .stage-grid { border-color: var(--line); }

html[data-theme="dark"] .brand-group .eyebrow,
html[data-theme="dark"] .app-header h1,
html[data-theme="dark"] .controls-header h2,
html[data-theme="dark"] .legend-heading > span,
html[data-theme="dark"] .field > span:first-child,
html[data-theme="dark"] .field-title,
html[data-theme="dark"] .slider-heading label,
html[data-theme="dark"] .target-inline-field > span:first-child,
html[data-theme="dark"] .metric div > strong,
html[data-theme="dark"] .stage-card strong,
html[data-theme="dark"] .target-plan-stats strong,
html[data-theme="dark"] .comparison-table td,
html[data-theme="dark"] .breakdown dd {
  color: var(--ink);
}

html[data-theme="dark"] .lead,
html[data-theme="dark"] .header-disclaimer,
html[data-theme="dark"] .local-badge,
html[data-theme="dark"] .legend-heading small,
html[data-theme="dark"] .legend-note,
html[data-theme="dark"] .input-wrap small,
html[data-theme="dark"] .range-scale,
html[data-theme="dark"] .hero-label-row p,
html[data-theme="dark"] .hero-number small,
html[data-theme="dark"] .cashflow-card > span,
html[data-theme="dark"] .cashflow-card small,
html[data-theme="dark"] .metric div > span,
html[data-theme="dark"] .section-title-row > span,
html[data-theme="dark"] .target-plan-copy > p,
html[data-theme="dark"] .target-plan-stats span,
html[data-theme="dark"] .target-plan-stats i,
html[data-theme="dark"] .stage-step,
html[data-theme="dark"] .stage-card small,
html[data-theme="dark"] .stage-connector,
html[data-theme="dark"] .stage-connector b,
html[data-theme="dark"] .comparison-table th,
html[data-theme="dark"] .position-labels,
html[data-theme="dark"] .breakdown dt,
html[data-theme="dark"] .formula,
html[data-theme="dark"] .clear-plan-menu > p,
html[data-theme="dark"] .clear-plan-menu button small {
  color: var(--muted);
}

html[data-theme="dark"] .section-title-row .panel-kicker { color: #8ecdf7; }
html[data-theme="dark"] .controls-header .panel-kicker { color: var(--muted); }
html[data-theme="dark"] .comparison-table tbody tr:hover { background: rgba(29,155,240,.06); }
html[data-theme="dark"] .table-action:not(:disabled) { color: #8ecdf7; border-color: #425466; }
html[data-theme="dark"] .clear-plan-menu button b { color: var(--muted); border-color: var(--line-strong); }
html[data-theme="dark"] .clear-plan-menu .clear-plan-all b { color: #ff8a80; border-color: rgba(244,33,46,.5); background: rgba(244,33,46,.08); }

@media (max-width: 820px), (max-height: 520px) and (pointer: coarse) {
  .brand-group .eyebrow { font-size: 18px; }
  .app-header h1 { font-size: 20px; }
  .lead { font-size: 12px; }
  .theme-toggle { font-size: 12px; }
  .controls-header h2,
  :is(.target-plan,.chart-section,.stage-section,.comparison-section,.price-position,.breakdown) .section-title-row h2 { font-size: 16px; }
  .controls-header .panel-kicker, .section-title-row .panel-kicker { font-size: 10.5px; }
  .field > span:first-child, .field-title, .target-inline-field > span:first-child, .slider-heading label { font-size: 13px; }
  .input-wrap input, .price-input input, .target-input-wrap input { font-size: 14.5px; }
  .legend-heading small, .legend-note, .input-wrap small, .range-scale { font-size: 11.5px; }
  .metric div > span, .cashflow-card > span, .cashflow-card small { font-size: 11.5px; }
  .section-title-row > span, .target-plan-copy > p, .target-plan-stats span, .stage-step, .stage-card small,
  .comparison-table th, .comparison-table td, .position-labels, .breakdown dt, .formula { font-size: 11px; }
}

html[data-theme="dark"] #comparisonMeta,
html[data-theme="dark"] #positionSummary,
html[data-theme="dark"] #breakEvenLabel,
html[data-theme="dark"] .breakdown .section-title-row > span {
  color: var(--muted) !important;
}

@media (max-width: 820px), (max-height: 520px) and (pointer: coarse) {
  .mobile-page-switcher button,
  .mobile-page-switcher button span {
    color: var(--muted);
    border-color: var(--line-strong);
  }

  .mobile-page-switcher button.is-active,
  .mobile-page-switcher button.is-active span {
    color: #fff;
  }
}

/* Keep the compact desktop target planner readable before the full 125% baseline kicks in. */
@media (min-width: 821px) and (min-height: 521px) {
  .result-side-column .target-plan-stats {
    grid-template-columns: .72fr 1.28fr 1fr;
  }

  .result-side-column .target-plan-stats span {
    min-width: 0;
    padding-inline: 5px;
  }

  .result-side-column .target-plan-stats strong {
    letter-spacing: -.015em;
    font-variant-numeric: tabular-nums;
  }
}

/* 125% desktop baseline: keep the three-column dashboard airy and numeric values intact. */
@media (min-width: 1200px) and (min-height: 700px) {
  .result-side-column .target-plan-stats {
    grid-template-columns: .8fr 1.32fr 1fr;
  }

  .result-side-column .target-plan-stats span {
    min-width: 0;
    padding-inline: 7px;
  }

  .result-side-column .target-plan-stats strong { letter-spacing: -.01em; }

  #comparisonMeta {
    max-width: 106px;
  }

  #positionSummary {
    max-width: 132px;
    font-variant-numeric: tabular-nums;
  }
}

/* ORDER TICKET desktop reflow: use the room available at the preferred 125% view. */
@media (min-width: 1200px) and (min-height: 680px) {
  .dashboard {
    grid-template-columns: clamp(334px, 27vw, 358px) 1px minmax(0, 1fr);
  }

  .controls {
    grid-template-rows: 66px minmax(0, .94fr) minmax(0, 1fr) minmax(0, 1fr);
    gap: 8px;
  }

  .controls-header {
    display: grid;
    min-width: 0;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto 30px;
    align-content: start;
    gap: 7px;
    padding: 0 2px 8px;
  }

  .controls-header > div:first-child {
    justify-content: flex-start;
    gap: 9px;
  }

  .controls-header > div:first-child .panel-kicker {
    font-size: 10.5px;
    letter-spacing: .1em;
  }

  .controls-header > div:first-child h2 {
    font-size: 18px;
    letter-spacing: -.025em;
  }

  .controls-header-tools {
    display: grid;
    width: 100%;
    min-width: 0;
    grid-template-columns: 1.15fr 1fr .82fr;
    gap: 6px;
  }

  .save-holding-button,
  .fee-mode-button,
  .clear-plan-control,
  .clear-plan-button {
    width: 100%;
    min-width: 0;
  }

  .save-holding-button,
  .fee-mode-button,
  .clear-plan-button {
    height: 30px;
    justify-content: center;
    padding-inline: 8px;
    border-radius: 9px;
    font-size: 10.5px;
  }

  .save-holding-button svg,
  .clear-plan-button svg {
    width: 12px;
    height: 12px;
  }

  .control-section {
    padding: 10px 12px 11px;
  }

  .control-section legend {
    min-height: 32px;
    padding-bottom: 8px;
  }

  .legend-heading > span {
    font-size: 13px;
  }

  .legend-heading small,
  .legend-note {
    font-size: 10.5px;
  }

  .legend-value {
    min-width: 60px;
    padding: 5px 8px;
    font-size: 11px;
  }

  .market-switch button,
  .market-switch button b {
    font-size: 10.5px;
  }

  .controls .field > span:first-child,
  .controls .field-title,
  .controls .slider-heading label {
    font-size: 12px;
  }

  .controls .input-wrap {
    height: 34px;
  }

  .controls .input-wrap input {
    height: 32px;
    font-size: 14.5px;
  }

  .controls .input-wrap small {
    font-size: 10px;
  }

  .stock-identity-grid {
    grid-template-columns: 108px minmax(0, 1fr);
    gap: 9px;
    margin-bottom: 8px;
  }

  .stock-identity-grid .input-wrap {
    height: 33px;
  }

  .stock-identity-grid .input-wrap input {
    height: 31px;
    font-size: 14px;
  }

  .primary-market-field .input-wrap {
    height: 42px;
  }

  .primary-market-field .input-wrap input {
    height: 40px;
    font-size: 21px;
  }

  .position-input-grid {
    display: grid;
    grid-template-columns: minmax(112px, .84fr) minmax(0, 1.56fr);
    gap: 9px;
    align-items: end;
  }

  .position-input-grid .primary-market-field {
    min-width: 0;
    margin-bottom: 0;
  }

  .position-input-grid .primary-market-field .field-title b {
    display: none;
  }

  .position-input-grid .primary-market-field .input-wrap::before {
    padding-left: 7px;
    font-size: 9px;
  }

  .position-input-grid .primary-market-field .input-wrap input {
    min-width: 0;
    padding-inline: 3px 2px;
    font-size: 19px;
  }

  .position-input-grid .primary-market-field .input-wrap small {
    min-width: 22px;
    padding-right: 6px;
    font-size: 9px;
  }

  .compact-field .input-wrap input {
    font-size: 13.5px;
  }

  .basis-field-grid {
    grid-template-columns: 1fr 1.08fr .9fr;
    gap: 7px;
  }

  body[data-market="hk"] .position-input-grid .basis-field-grid,
  body[data-market="us"] .position-input-grid .basis-field-grid {
    grid-template-columns: 1fr 1.24fr 1fr;
  }

  .position-input-grid .compact-field .input-wrap input {
    min-width: 0;
    padding-left: 5px;
    font-size: 13px;
  }

  .position-input-grid .compact-field .input-wrap small {
    min-width: 20px;
    padding-right: 5px;
    font-size: 9px;
  }

  .trade-section .slider-field {
    grid-template-columns: minmax(0, 1fr) 116px;
    gap: 4px 9px;
    margin-bottom: 7px;
  }

  .price-input,
  .controls .price-input {
    height: 34px;
  }

  .price-input input,
  .controls .price-input input {
    height: 32px;
    font-size: 15px;
  }

  .range-scale {
    font-size: 10px;
  }

  .order-field-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
}

/* Keep the compact ticket actions legible on the X-inspired dark palette. */
html[data-theme="dark"] .controls-header-tools .clear-plan-button {
  color: #f7f9f9;
  border-color: #425466;
  background: transparent;
}

html[data-theme="dark"] .controls-header-tools .clear-plan-button:hover,
html[data-theme="dark"] .controls-header-tools .clear-plan-button.is-open {
  color: #ff8a80;
  border-color: rgba(244, 33, 46, .58);
  background: rgba(244, 33, 46, .08);
}

/* One-line bilingual heading system: English label and Chinese title share one visual center line. */
.brand-copy,
.controls-header > div:first-child,
:is(.target-plan, .chart-section, .stage-section, .comparison-section, .price-position, .breakdown) .section-title-row > div,
.dialog-header > div {
  align-items: center;
}

.controls-header > div:first-child,
:is(.target-plan, .chart-section, .stage-section, .comparison-section, .price-position, .breakdown) .section-title-row > div,
.dialog-header > div {
  display: flex;
  min-width: 0;
  flex-wrap: nowrap;
  gap: 7px;
}

.controls-header > div:first-child .panel-kicker,
.section-title-row > div .panel-kicker,
.dialog-header > div .panel-kicker {
  flex: 0 0 auto;
  margin: 0;
  line-height: 1;
  white-space: nowrap;
}

.controls-header > div:first-child h2,
.section-title-row > div h2,
.dialog-header > div h2 {
  flex: 0 0 auto;
  margin: 0;
  line-height: 1;
  white-space: nowrap;
}

.section-title-row {
  align-items: center;
}

.section-title-row > div {
  flex: 0 1 auto;
  overflow: hidden;
}

.section-title-row > span {
  min-width: 0;
  margin-left: auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Protect the complete bilingual title; secondary status text yields space first. */
.section-title-row > div {
  flex: 0 0 auto;
  overflow: visible;
}

.section-title-row > span {
  flex: 1 1 auto;
}

:is(.target-plan, .chart-section, .stage-section, .comparison-section, .price-position, .breakdown) .section-title-row > div h2 {
  white-space: nowrap;
}

/* Support and feedback: one compact entry in the brand area, one focused dialog. */
.support-toggle {
  display: inline-flex;
  min-width: 62px;
  height: 31px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 0 8px;
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: transparent;
  font-size: 10px;
  font-weight: 800;
  white-space: nowrap;
}

.support-toggle svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.support-toggle:hover {
  color: #e54878;
  border-color: #e54878;
}

.support-dialog {
  width: min(760px, calc(100vw - 32px));
  max-width: 760px;
}

.support-dialog-body {
  max-height: min(570px, calc(100vh - 150px));
  padding: 18px;
  overflow-y: auto;
}

.support-intro {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.65;
}

.support-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(0, .88fr);
  gap: 14px;
}

.support-card {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 13px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: transparent;
}

.support-card-heading {
  display: flex;
  align-items: center;
  gap: 10px;
}

.support-card-heading > div {
  display: grid;
  gap: 3px;
}

.support-card-heading strong {
  color: var(--ink);
  font-size: 15px;
  line-height: 1.2;
}

.support-card-heading small {
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .09em;
}

.support-card-icon {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  place-items: center;
  color: var(--blue);
  border: 1px solid currentColor;
  border-radius: 10px;
}

.reward-card .support-card-icon { color: var(--green); }

.support-card-icon svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.support-contact-line {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.support-contact-line span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
}

.support-contact-line strong {
  min-width: 0;
  color: var(--ink);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.feedback-compose {
  display: grid;
  gap: 7px;
}

.feedback-compose > span {
  color: var(--ink);
  font-size: 11px;
  font-weight: 800;
}

.feedback-compose textarea {
  width: 100%;
  min-height: 98px;
  resize: vertical;
  padding: 10px 11px;
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  outline: 0;
  background: transparent;
  font: inherit;
  font-size: 12px;
  line-height: 1.55;
}

.feedback-compose textarea::placeholder { color: var(--faint); }
.feedback-compose textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(21,94,239,.1); }

.reward-copy {
  flex: 1 1 auto;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}

.support-actions {
  display: grid;
  grid-template-columns: minmax(0, .78fr) minmax(0, 1.22fr);
  gap: 8px;
}

.support-actions-single { grid-template-columns: minmax(0, 1fr); }

.support-actions .dialog-primary,
.support-actions .dialog-secondary {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  text-align: center;
  text-decoration: none;
  font-size: 11px;
  font-weight: 800;
}

.reward-copy-button {
  color: #fff;
  border-color: #079455;
  background: #079455;
}

.reward-copy-button:hover { border-color: #067647; background: #067647; }

.support-privacy {
  margin: -3px 0 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.5;
}

.support-dialog-footer > span { color: var(--muted); }

html[data-theme="dark"] .support-toggle {
  color: var(--ink);
  border-color: var(--line-strong);
}

html[data-theme="dark"] .support-toggle:hover {
  color: #f57b9d;
  border-color: #f57b9d;
}

html[data-theme="dark"] .support-card { border-color: var(--line); }
html[data-theme="dark"] .feedback-compose textarea { color: var(--ink); border-color: var(--line-strong); background: transparent; }
html[data-theme="dark"] .feedback-compose textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(29,155,240,.12); }

@media (min-width: 821px) and (max-width: 1400px) and (min-height: 521px) {
  .support-toggle {
    width: 31px;
    min-width: 31px;
    padding: 0;
  }

  .support-toggle span { display: none; }
}

@media (max-width: 820px), (max-height: 520px) and (pointer: coarse) {
  .support-toggle {
    width: 36px;
    min-width: 36px;
    height: 36px;
    margin-left: -4px;
    padding: 0;
    font-size: 11px;
  }

  .support-toggle span { display: none; }

  .support-dialog {
    width: calc(100vw - 20px);
    max-width: none;
  }

  .support-dialog-body {
    max-height: calc(100svh - 136px);
    padding: 14px;
  }

  .support-intro { font-size: 12px; }

  .support-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }

  .support-card { padding: 14px; }
  .support-card-heading strong { font-size: 15px; }
  .support-card-heading small { font-size: 9px; }
  .support-contact-line span { font-size: 11px; }
  .support-contact-line strong { font-size: 13px; }
  .feedback-compose > span { font-size: 12px; }
  .feedback-compose textarea { min-height: 104px; font-size: 13px; }
  .reward-copy { font-size: 12px; }
  .support-privacy { font-size: 10.5px; }
  .support-dialog-footer > span { display: none; }
}

@media (max-width: 360px) {
  .brand-group { gap: 8px; }

  .theme-toggle {
    width: 36px;
    min-width: 36px;
    padding: 0;
  }

  .theme-toggle span { display: none; }
}

/* LOT MATRIX / CASH LEDGER: remove low-contrast gray copy in both modules. */
#comparisonMeta,
.comparison-section .comparison-table th,
.comparison-section .comparison-table td,
.breakdown .section-title-row > span,
.breakdown dt,
.breakdown dd {
  color: var(--ink) !important;
}

html[data-theme="dark"] #comparisonMeta,
html[data-theme="dark"] .breakdown .section-title-row > span {
  color: var(--ink) !important;
}

/* 4K / ultra-wide workstation mode.
   Keep the calculator focused in the center instead of stretching data across the full panel. */
@media (min-width: 2200px) and (min-height: 1200px) {
  :root {
    --radius: 18px;
  }

  body {
    display: grid;
    place-items: center;
  }

  .app-shell {
    width: min(100vw, 3000px);
    height: min(100vh, 1800px);
    padding: 18px;
  }

  .dashboard {
    grid-template-columns: clamp(500px, 18.5vw, 555px) 1px minmax(0, 1fr);
    grid-template-rows: 92px minmax(0, 1fr);
    column-gap: 18px;
    row-gap: 18px;
    padding: 0 22px 22px;
    border-radius: 28px;
    box-shadow: 0 18px 56px rgba(16, 24, 40, .09);
  }

  .dashboard::before,
  .results::before {
    width: 1px;
  }

  .app-header {
    margin: 0 -22px;
    padding: 0 28px;
    border-radius: 28px 28px 0 0;
  }

  .brand-group { gap: 16px; }

  .brand-mark {
    width: 52px;
    height: 52px;
    flex-basis: 52px;
    border-radius: 14px;
  }

  .brand-mark svg {
    width: 42px;
    height: 42px;
  }

  .brand-copy {
    column-gap: 12px;
  }

  .brand-group .eyebrow {
    margin-bottom: 4px;
    font-size: 26px;
    letter-spacing: -.035em;
  }

  .app-header h1 {
    font-size: 28px;
    line-height: 1;
  }

  .lead {
    margin-left: 12px;
    font-size: 16px;
  }

  .header-actions { gap: 10px; }

  .header-disclaimer {
    max-width: 420px;
    font-size: 13px;
    line-height: 1.45;
  }

  .local-badge,
  .header-tool-button,
  .reset-button,
  .theme-toggle,
  .support-toggle {
    min-height: 42px;
    padding-inline: 14px;
    border-radius: 999px;
    font-size: 14px;
  }

  .theme-toggle,
  .support-toggle {
    min-width: 94px;
    gap: 8px;
  }

  .theme-icon,
  .support-toggle svg,
  .header-tool-button svg,
  .reset-button svg {
    width: 18px;
    height: 18px;
  }

  .controls {
    grid-template-rows: 94px minmax(0, .94fr) minmax(0, 1fr) minmax(0, 1fr);
    gap: 16px;
    padding: 14px;
  }

  .controls-header {
    grid-template-rows: auto 42px;
    gap: 12px;
    padding: 2px 3px 10px;
  }

  .controls-header > div:first-child { gap: 12px; }

  .controls-header > div:first-child .panel-kicker,
  .section-title-row .panel-kicker {
    margin-bottom: 0;
    font-size: 13px;
    letter-spacing: .11em;
  }

  .controls-header > div:first-child h2 {
    font-size: 23px;
  }

  .controls-header-tools { gap: 9px; }

  .save-holding-button,
  .fee-mode-button,
  .clear-plan-button {
    height: 42px;
    padding-inline: 11px;
    border-radius: 12px;
    font-size: 13px;
  }

  .save-holding-button svg,
  .clear-plan-button svg {
    width: 16px;
    height: 16px;
  }

  .control-section {
    padding: 16px 18px 18px;
    border-radius: 16px;
  }

  .control-section legend {
    min-height: 46px;
    padding-bottom: 12px;
  }

  .legend-heading { gap: 9px; }
  .legend-heading > span { font-size: 17px; }
  .legend-heading small,
  .legend-note { font-size: 13px; }

  .legend-value {
    min-width: 82px;
    padding: 7px 11px;
    border-radius: 9px;
    font-size: 14px;
  }

  .market-switch { min-height: 40px; }
  .market-switch button,
  .market-switch button b { font-size: 14px; }

  .stock-identity-grid {
    grid-template-columns: 148px minmax(0, 1fr);
    gap: 13px;
    margin-bottom: 13px;
  }

  .position-input-grid {
    grid-template-columns: minmax(158px, .86fr) minmax(0, 1.54fr);
    gap: 13px;
  }

  .basis-field-grid { gap: 10px; }
  .field-grid,
  .order-field-grid { gap: 11px; }

  .field,
  .target-inline-field { gap: 6px; }

  .controls .field > span:first-child,
  .controls .field-title,
  .controls .slider-heading label,
  .target-inline-field > span:first-child {
    font-size: 15px;
  }

  .field-title b,
  .stock-name-field > span:first-child b { font-size: 11px; }

  .controls .input-wrap,
  .stock-identity-grid .input-wrap,
  .compact-field .input-wrap {
    height: 46px;
    border-radius: 11px;
  }

  .controls .input-wrap input,
  .stock-identity-grid .input-wrap input,
  .compact-field .input-wrap input {
    height: 44px;
    font-size: 17px;
  }

  .controls .input-wrap small { font-size: 12px; }

  .primary-market-field .input-wrap {
    height: 54px;
  }

  .primary-market-field .input-wrap input {
    height: 52px;
    font-size: 27px;
  }

  .position-input-grid .primary-market-field .input-wrap input { font-size: 24px; }
  .position-input-grid .compact-field .input-wrap input { font-size: 16px; }

  .slider-heading { margin-top: 9px; }
  input[type="range"] { height: 20px; }
  .range-scale { font-size: 12px; }

  .price-input {
    height: 44px;
    border-radius: 10px;
  }

  .price-input input {
    height: 42px;
    font-size: 17px;
  }

  .results {
    grid-template-columns: minmax(0, 1.56fr) 1px minmax(620px, .94fr);
    column-gap: 18px;
  }

  .result-column {
    gap: 16px;
  }

  .result-main-column {
    grid-template-rows: 260px 126px 226px minmax(0, 1fr);
  }

  .result-side-column {
    grid-template-rows: 270px minmax(330px, 1fr) 136px 246px;
  }

  .result-hero {
    padding: 26px 30px;
    border-radius: 18px;
  }

  .hero-copy { align-self: center; }
  .hero-label-row { gap: 12px; }
  .hero-label-row p { font-size: 16px; }

  .calculation-badge,
  .current-badge {
    padding: 6px 10px;
    font-size: 12px;
  }

  .hero-number {
    gap: 13px;
    margin-top: 15px;
  }

  .hero-number span {
    font-size: clamp(72px, 3.2vw, 96px);
  }

  .hero-number small {
    padding-bottom: 9px;
    font-size: 14px;
  }

  .cost-change {
    margin-top: 12px;
    font-size: 14px;
  }

  .result-insight {
    margin-top: 10px;
    font-size: 13px;
  }

  .cashflow-summary {
    gap: 14px;
    padding: 24px 28px;
    border-radius: 18px;
  }

  .cashflow-card { padding-inline: 18px; }
  .cashflow-card > span,
  .cashflow-card small { font-size: 13px; }
  .cashflow-card strong { font-size: 22px; }

  .metric-grid { gap: 12px; }
  .metric {
    gap: 13px;
    padding: 17px 18px;
    border-radius: 15px;
  }

  .metric-icon {
    width: 40px;
    height: 40px;
    flex-basis: 40px;
    border-radius: 11px;
  }

  .metric-icon svg {
    width: 20px;
    height: 20px;
  }

  .metric div > span { font-size: 13px; }
  .metric div > strong {
    margin-top: 6px;
    font-size: 18px;
  }

  .target-plan,
  .chart-section,
  .stage-section,
  .comparison-section,
  .price-position,
  .breakdown {
    padding: 20px 22px;
    border-radius: 18px;
  }

  .section-title-row { min-height: 42px; }
  :is(.target-plan,.chart-section,.stage-section,.comparison-section,.price-position,.breakdown) .section-title-row h2 {
    font-size: 20px;
  }

  .section-title-row > span,
  .target-badge {
    font-size: 13px !important;
  }

  .target-badge { padding: 6px 9px; }

  .target-plan-body {
    grid-template-columns: 180px minmax(0, 1fr) auto;
    gap: 15px;
  }

  .target-input-wrap input { font-size: 18px; }
  .target-plan-copy > p {
    margin-bottom: 11px;
    font-size: 13px;
  }

  .target-plan-stats { gap: 9px; }
  .result-side-column .target-plan-stats span {
    padding: 8px 9px;
    font-size: 12px;
  }
  .target-plan-stats i { font-size: inherit; }
  .target-plan-stats strong {
    margin-top: 5px;
    font-size: 15px;
  }

  .apply-button {
    min-height: 46px;
    padding-inline: 16px;
    border-radius: 11px;
    font-size: 14px;
  }

  .stage-grid { gap: 14px; }
  .stage-step { font-size: 12px; }
  .stage-card { padding: 13px 15px; }
  .stage-card small { font-size: 12px; }
  .stage-card strong { font-size: 16px; }
  .stage-connector { font-size: 12px; }

  .chart-wrap,
  #costChart {
    min-height: 0;
  }

  .chart-axis-label { font-size: 13px; }
  .chart-basis-label,
  .chart-point-label { font-size: 15px; }
  .formula { font-size: 12px; }

  .comparison-section .section-title-row { margin-bottom: 14px; }
  #comparisonMeta { max-width: none; }
  .comparison-table,
  .comparison-table th,
  .comparison-table td { font-size: 14px; }
  .comparison-table th { padding: 10px 9px; }
  .comparison-table td { padding: 12px 9px; }

  .table-action {
    min-height: 34px;
    padding-inline: 10px;
    border-radius: 8px;
    font-size: 13px;
  }

  #positionSummary { max-width: none; }
  .position-visual { margin-top: 16px; }
  .position-track { height: 8px; }
  .position-dot {
    width: 18px;
    height: 18px;
  }
  .position-labels { font-size: 13px; }

  .breakdown dl {
    gap: 0;
    margin-top: 13px;
  }

  .breakdown dl > div { padding: 8px 0; }
  .breakdown dt { font-size: 14px; }
  .breakdown dd { font-size: 16px; }

  .disclaimer {
    padding: 0 4px;
    font-size: 13px;
    line-height: 1.5;
  }

  .support-dialog { width: min(920px, calc(100vw - 64px)); }
  .support-dialog-body { padding: 26px; }
  .support-intro { font-size: 15px; }
  .support-card { padding: 22px; }
  .support-card-heading strong { font-size: 20px; }
  .support-card-heading small { font-size: 12px; }
  .support-card-icon {
    width: 46px;
    height: 46px;
    flex-basis: 46px;
  }
  .support-card-icon svg {
    width: 23px;
    height: 23px;
  }
  .support-contact-line span { font-size: 14px; }
  .support-contact-line strong { font-size: 16px; }
  .feedback-compose > span { font-size: 14px; }
  .feedback-compose textarea { min-height: 132px; font-size: 15px; }
  .reward-copy { font-size: 15px; }
  .support-actions .dialog-primary,
  .support-actions .dialog-secondary {
    min-height: 46px;
    font-size: 14px;
  }
}

/* Keep enlarged 4K module contents inside their grid rows. */
@media (min-width: 2200px) and (min-height: 1200px) {
  .stage-section { overflow: hidden; }
  .stage-section .stage-grid { height: calc(100% - 49px); }
  .chart-section #costChart { height: calc(100% - 66px); }
  .comparison-section { overflow: hidden; }
  .comparison-section .table-scroll { height: calc(100% - 56px); }
}

/* Keep email feedback direct while making the address easy to copy. */
.support-email-contact {
  margin-top: 2px;
  padding-block: 14px;
}

.support-email-actions {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
}

.support-email-link {
  min-width: 0;
  color: var(--blue);
  font-size: 14px;
  font-weight: 850;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.support-email-link:hover { text-decoration: underline; }

.support-copy-button {
  min-height: 31px;
  flex: 0 0 auto;
  padding: 6px 10px;
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: transparent;
  font: inherit;
  font-size: 11px;
  font-weight: 850;
  line-height: 1;
  cursor: pointer;
}

.support-copy-button:hover {
  color: var(--blue);
  border-color: var(--blue);
}

.support-copy-button:focus-visible {
  outline: 3px solid rgba(21, 94, 239, .18);
  outline-offset: 2px;
}

.feedback-direct-note {
  flex: 1 1 auto;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}

html[data-theme="dark"] .support-email-link { color: #8ecdf7; }
html[data-theme="dark"] .support-copy-button {
  color: #e7e9ea;
  border-color: #536471;
}
html[data-theme="dark"] .support-copy-button:hover {
  color: #8ecdf7;
  border-color: #8ecdf7;
}

@media (max-width: 820px), (max-height: 520px) and (pointer: coarse) {
  .support-email-contact {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }
  .support-email-actions {
    width: 100%;
    justify-content: space-between;
  }
  .support-email-link { font-size: 14px; }
  .support-copy-button { min-height: 34px; font-size: 12px; }
  .feedback-direct-note { font-size: 12px; }
}

@media (min-width: 2200px) and (min-height: 1200px) {
  .support-email-link { font-size: 17px; }
  .support-copy-button { min-height: 40px; padding-inline: 14px; font-size: 14px; }
  .feedback-direct-note { font-size: 15px; }
}

/* LOT MATRIX readability: lock every informational label and value to a high-contrast tone. */
.comparison-section,
.comparison-section .section-title-row h2,
.comparison-section .section-title-row .panel-kicker,
.comparison-section #comparisonMeta,
.comparison-section .comparison-table,
.comparison-section .comparison-table th,
.comparison-section .comparison-table td,
.comparison-section .comparison-table td strong {
  color: #0f172a !important;
}

.comparison-section .section-title-row .panel-kicker,
.comparison-section .section-title-row h2,
.comparison-section #comparisonMeta,
.comparison-section .comparison-table th {
  font-weight: 800;
}

.comparison-section .comparison-table td {
  font-weight: 650;
}

/* Keep actions recognizable without falling back to pale gray-blue. */
.comparison-section .current-badge,
.comparison-section .table-action:not(:disabled) {
  color: #155eef !important;
  font-weight: 850;
}

html[data-theme="dark"] .comparison-section,
html[data-theme="dark"] .comparison-section .section-title-row h2,
html[data-theme="dark"] .comparison-section .section-title-row .panel-kicker,
html[data-theme="dark"] .comparison-section #comparisonMeta,
html[data-theme="dark"] .comparison-section .comparison-table,
html[data-theme="dark"] .comparison-section .comparison-table th,
html[data-theme="dark"] .comparison-section .comparison-table td,
html[data-theme="dark"] .comparison-section .comparison-table td strong {
  color: #f7f9f9 !important;
}

html[data-theme="dark"] .comparison-section .current-badge,
html[data-theme="dark"] .comparison-section .table-action:not(:disabled) {
  color: #8ecdf7 !important;
}
