:root {
  color-scheme: light;
  --bg: #f3f0e8;
  --paper: #fbfaf6;
  --surface: #ffffff;
  --surface-soft: #f7f5ee;
  --ink: #141a1f;
  --ink-soft: #2b343d;
  --muted: #69737c;
  --line: #ded8ca;
  --line-strong: #c8bfad;
  --navy: #132238;
  --navy-soft: #e8edf2;
  --green: #166c55;
  --green-soft: #e4f2ec;
  --red: #b6403c;
  --red-soft: #fae8e5;
  --gold: #a87522;
  --gold-soft: #f7ead1;
  --blue: #275c9b;
  --shadow: 0 18px 44px rgba(29, 35, 41, 0.1);
  --shadow-strong: 0 28px 70px rgba(19, 34, 56, 0.2);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(rgba(20, 26, 31, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(20, 26, 31, 0.035) 1px, transparent 1px),
    var(--bg);
  background-size: 48px 48px;
  color: var(--ink);
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 26px;
}

.topbar {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 22px;
  min-height: 190px;
  margin-bottom: 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius);
  background:
    linear-gradient(90deg, rgba(19, 34, 56, 0.96), rgba(20, 26, 31, 0.98)),
    var(--navy);
  box-shadow: var(--shadow-strong);
  color: #fff;
  padding: 26px;
  overflow: hidden;
  position: relative;
}

.topbar::after {
  content: "";
  position: absolute;
  inset: auto 26px 24px auto;
  width: 240px;
  height: 86px;
  border-top: 1px solid rgba(218, 180, 112, 0.45);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  opacity: 0.8;
}

.brand-lockup {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 18px;
  align-items: center;
  max-width: 820px;
  position: relative;
  z-index: 1;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 76px;
  height: 76px;
  border: 1px solid rgba(218, 180, 112, 0.75);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.08);
  color: #f4d79b;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 27px;
  font-weight: 800;
}

.topbar h1 {
  margin: 5px 0 0;
  color: #ffffff;
  font-size: clamp(34px, 5vw, 64px);
  line-height: 0.95;
  letter-spacing: 0;
}

.topbar-copy {
  max-width: 650px;
  margin: 14px 0 0;
  color: rgba(255, 255, 255, 0.72);
  font-size: clamp(14px, 1.6vw, 17px);
  line-height: 1.55;
}

.topbar-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  min-width: 260px;
  position: relative;
  z-index: 1;
}

.domain-link {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  color: #f6e2b6;
  padding: 7px 13px;
  text-decoration: none;
  font-size: 13px;
  font-weight: 800;
}

.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.topbar .eyebrow {
  color: #f4d79b;
}

.mode-switch {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  min-width: 236px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(8px);
}

.mode-button {
  min-height: 44px;
  border: 0;
  border-right: 1px solid rgba(255, 255, 255, 0.14);
  background: transparent;
  color: rgba(255, 255, 255, 0.68);
  padding: 11px 18px;
  font-weight: 900;
}

.mode-button:last-child {
  border-right: 0;
}

.mode-button.active {
  background: #f5dba9;
  color: var(--navy);
}

.executive-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.executive-item {
  min-height: 74px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow);
  padding: 14px 16px;
}

.executive-item span {
  display: block;
  color: var(--gold);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.executive-item strong {
  display: block;
  margin-top: 6px;
  color: var(--ink);
  font-size: 16px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.42fr) minmax(380px, 0.78fr);
  gap: 18px;
  align-items: start;
}

.input-panel,
.result-panel {
  display: grid;
  gap: 14px;
}

.result-panel {
  position: sticky;
  top: 18px;
}

.section-block,
.status-card,
.metric-card,
.comparison-section,
.breakdown-section,
.recommendation-box {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.section-block {
  padding: 18px;
}

.section-block:first-child {
  border-top: 4px solid var(--gold);
}

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

.section-heading.flat {
  margin-bottom: 12px;
}

.section-heading h2,
.comparison-section h2,
.breakdown-section h2 {
  margin: 2px 0 0;
  color: var(--ink);
  font-size: 20px;
  line-height: 1.2;
  letter-spacing: 0;
}

.section-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
  padding: 5px 11px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

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

.field-grid.compact {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.field,
.toggle-line {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.field > span,
.toggle-line > span,
.extra-row > span {
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 850;
}

input,
select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  padding: 10px 12px;
  outline: none;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    background-color 160ms ease;
}

input:focus,
select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(39, 92, 155, 0.16);
}

.money-input,
.suffix-input {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #fff;
}

.money-input:focus-within,
.suffix-input:focus-within {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(39, 92, 155, 0.16);
}

.money-input input,
.suffix-input input {
  min-height: 42px;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.money-input span,
.suffix-input span {
  min-width: 38px;
  padding-right: 12px;
  color: var(--gold);
  font-weight: 950;
  text-align: right;
}

.toggle-line {
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 0 12px;
}

.toggle-line input,
.extra-row input[type="checkbox"] {
  width: 18px;
  min-height: 18px;
  accent-color: var(--green);
}

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

.scenario-box {
  min-width: 0;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  padding: 14px;
}

.scenario-box.selected {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(22, 108, 85, 0.13);
}

.scenario-box legend {
  padding: 0 6px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 950;
}

.ghost-button {
  min-height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--ink);
  color: #fff;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
}

.ghost-button:hover {
  background: var(--navy);
}

.extras-list {
  display: grid;
  gap: 10px;
}

.extra-row {
  display: grid;
  grid-template-columns: auto minmax(150px, 1fr) minmax(150px, 210px);
  gap: 10px;
  align-items: center;
}

.status-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px;
  background: var(--navy);
  color: #fff;
}

.status-card h2 {
  margin: 2px 0 0;
  color: #fff;
  font-size: 20px;
}

.status-card .eyebrow {
  color: rgba(255, 255, 255, 0.62);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border-radius: 999px;
  padding: 7px 12px;
  background: var(--gold-soft);
  color: var(--gold);
  font-size: 13px;
  font-weight: 950;
  white-space: nowrap;
}

.status-pill.good {
  background: var(--green-soft);
  color: var(--green);
}

.status-pill.bad {
  background: var(--red-soft);
  color: var(--red);
}

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

.metric-card {
  display: grid;
  gap: 6px;
  min-height: 108px;
  padding: 15px;
}

.metric-card.highlight {
  grid-column: 1 / -1;
  background: #fff;
  border-color: rgba(168, 117, 34, 0.42);
  color: var(--ink);
}

.metric-card.highlight::before {
  content: "";
  width: 54px;
  height: 4px;
  border-radius: 999px;
  background: var(--gold);
}

.metric-card span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 950;
}

.metric-card.highlight span,
.metric-card.highlight small {
  color: var(--muted);
}

.metric-card strong {
  align-self: end;
  color: var(--ink);
  font-size: clamp(24px, 3.2vw, 34px);
  line-height: 1;
}

.metric-card small {
  color: var(--muted);
  font-size: 12px;
}

.recommendation-box {
  display: grid;
  gap: 9px;
  min-height: 78px;
  padding: 15px;
  border-left: 5px solid var(--gold);
}

.recommendation-box.good {
  border-left-color: var(--green);
  background: #fbfffc;
}

.recommendation-box.bad {
  border-left-color: var(--red);
  background: #fffafa;
}

.recommendation-box strong {
  color: var(--ink);
  font-size: 15px;
}

.recommendation-box p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.comparison-section,
.breakdown-section {
  padding: 15px;
}

.comparison-table,
.breakdown-list {
  display: grid;
  gap: 8px;
}

.comparison-row,
.breakdown-row {
  display: grid;
  grid-template-columns: minmax(110px, 1fr) minmax(88px, auto) minmax(88px, auto);
  gap: 10px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding: 9px 0;
  font-size: 13px;
}

.comparison-row:last-child,
.breakdown-row:last-child {
  border-bottom: 0;
}

.comparison-row.header {
  color: var(--muted);
  font-weight: 950;
}

.comparison-row strong,
.breakdown-row strong {
  text-align: right;
}

.breakdown-row {
  grid-template-columns: minmax(130px, 1fr) auto;
}

.positive {
  color: var(--green);
}

.negative {
  color: var(--red);
}

.muted {
  color: var(--muted);
}

body[data-mode="simple"] .detail-only {
  display: none !important;
}

.manual-cpa.is-hidden {
  display: none;
}

@media (max-width: 1120px) {
  .topbar {
    min-height: auto;
    flex-direction: column;
  }

  .topbar-actions {
    align-items: stretch;
    min-width: 0;
  }

  .domain-link {
    justify-content: center;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .result-panel {
    position: static;
  }
}

@media (max-width: 760px) {
  .app-shell {
    padding: 14px;
  }

  .topbar {
    padding: 18px;
  }

  .topbar::after {
    display: none;
  }

  .brand-lockup {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .brand-mark {
    width: 58px;
    height: 58px;
    font-size: 22px;
  }

  .mode-switch,
  .domain-link {
    width: 100%;
  }

  .executive-strip,
  .field-grid,
  .field-grid.compact,
  .scenario-grid,
  .metric-grid {
    grid-template-columns: 1fr;
  }

  .extra-row {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .extra-row .money-input {
    grid-column: 1 / -1;
  }

  .section-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .section-chip,
  .ghost-button {
    width: 100%;
  }
}

@media (max-width: 460px) {
  .comparison-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .comparison-row strong {
    text-align: left;
  }

  .comparison-row.header {
    display: none;
  }
}
