:root {
  color-scheme: light;
  --bg: #f5f7f2;
  --surface: #ffffff;
  --surface-alt: #eef3ea;
  --ink: #17201b;
  --muted: #5b665f;
  --subtle: #d9e0d7;
  --line: #c9d4ca;
  --green: #176b4c;
  --green-dark: #0f5138;
  --teal: #247c89;
  --coral: #c6553d;
  --gold: #b47a24;
  --shadow: 0 20px 45px rgba(31, 45, 35, 0.12);
  --radius: 8px;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(238, 243, 234, 0.88), rgba(245, 247, 242, 1) 360px),
    var(--bg);
  color: var(--ink);
}

a {
  color: var(--green-dark);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin: 0 auto;
  max-width: 1280px;
  padding: 22px 24px 8px;
}

.brand {
  align-items: center;
  color: var(--ink);
  display: inline-flex;
  gap: 12px;
  text-decoration: none;
}

.brand-mark {
  align-items: center;
  background: var(--green-dark);
  border-radius: 6px;
  color: #fff;
  display: inline-flex;
  font-size: 0.82rem;
  font-weight: 800;
  height: 38px;
  justify-content: center;
  letter-spacing: 0;
  width: 38px;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 0.98rem;
  line-height: 1.1;
}

.brand small {
  color: var(--muted);
  font-size: 0.78rem;
  margin-top: 3px;
}

.topbar-actions {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-size: 0.84rem;
  gap: 10px;
}

.topbar-actions span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 10px;
}

.workspace {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(300px, 0.86fr) minmax(420px, 1.14fr);
  margin: 0 auto;
  max-width: 1280px;
  padding: 24px;
}

.intro-panel,
.control-panel,
.result-panel,
.scenario-panel,
.projection-panel,
.assumptions-panel {
  background: var(--surface);
  border: 1px solid rgba(201, 212, 202, 0.92);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 0;
}

.intro-panel {
  background:
    linear-gradient(135deg, rgba(23, 107, 76, 0.97), rgba(36, 124, 137, 0.94)),
    var(--green-dark);
  color: #fff;
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 0.8fr);
  min-height: 230px;
  overflow: hidden;
  padding: 30px;
  position: relative;
}

.intro-panel::after {
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.14) 1px, transparent 1px),
    linear-gradient(180deg, rgba(255, 255, 255, 0.1) 1px, transparent 1px);
  background-size: 34px 34px;
  content: "";
  inset: auto 0 0 auto;
  height: 100%;
  opacity: 0.42;
  position: absolute;
  width: 48%;
}

.intro-panel > * {
  position: relative;
  z-index: 1;
}

.intro-panel h1 {
  font-size: clamp(2.2rem, 5vw, 4.8rem);
  line-height: 0.95;
  margin: 10px 0 18px;
  max-width: 860px;
}

.intro-panel p {
  color: rgba(255, 255, 255, 0.84);
  font-size: 1rem;
  line-height: 1.6;
  margin: 0;
  max-width: 700px;
}

.section-label {
  color: currentColor;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0;
  margin: 0;
  text-transform: uppercase;
}

.control-panel .section-label,
.result-panel .section-label,
.scenario-panel .section-label,
.projection-panel .section-label,
.assumptions-panel .section-label {
  color: var(--green);
}

.quick-stats {
  align-self: end;
  background: rgba(255, 255, 255, 0.11);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: var(--radius);
  display: grid;
  gap: 1px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 0;
  overflow: hidden;
}

.quick-stats div {
  background: rgba(255, 255, 255, 0.09);
  min-width: 0;
  padding: 18px;
}

.quick-stats dt {
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.76rem;
  font-weight: 700;
}

.quick-stats dd {
  font-size: clamp(1.35rem, 2vw, 2rem);
  font-weight: 850;
  line-height: 1.1;
  margin: 8px 0 0;
  overflow-wrap: anywhere;
}

.control-panel,
.result-panel,
.scenario-panel,
.projection-panel,
.assumptions-panel {
  padding: 22px;
}

.control-panel {
  grid-row: span 3;
}

.panel-header,
.stack-card-header {
  align-items: flex-start;
  display: flex;
  gap: 16px;
  justify-content: space-between;
}

.panel-header h2,
.stack-card h3,
.projection-panel h2,
.assumptions-panel h2 {
  font-size: 1.18rem;
  line-height: 1.2;
  margin: 5px 0 0;
}

.ghost-button,
.status-pill {
  align-items: center;
  border-radius: 999px;
  display: inline-flex;
  font-size: 0.82rem;
  font-weight: 800;
  min-height: 34px;
  padding: 0 12px;
  white-space: nowrap;
}

.ghost-button {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--green-dark);
  cursor: pointer;
}

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

.status-pill {
  background: var(--surface-alt);
  border: 1px solid var(--line);
  color: var(--green-dark);
}

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

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

.control-panel > .field-grid:not(.compact) > .field:first-child {
  grid-column: 1 / -1;
}

.preset-card {
  background: #fbfcfa;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: grid;
  gap: 10px;
  margin-top: 20px;
  padding: 14px;
}

.preset-card > span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
}

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

.preset-actions button {
  background: var(--surface-alt);
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--green-dark);
  cursor: pointer;
  font-size: 0.84rem;
  font-weight: 850;
  min-height: 40px;
  padding: 8px 10px;
}

.preset-actions button:hover {
  background: #fff;
  border-color: var(--green);
}

.field {
  display: grid;
  gap: 7px;
}

.field span,
.range-card label,
.segmented-field legend {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.field input,
.field select,
.range-row input[type="number"] {
  background: #fbfcfa;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  min-height: 44px;
  outline: none;
  padding: 9px 11px;
  width: 100%;
}

.field input:focus,
.field select:focus,
.range-row input[type="number"]:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(23, 107, 76, 0.14);
}

.segmented-field,
.bonus-input-card {
  border: 0;
  margin: 22px 0 0;
  padding: 0;
}

.bonus-input-card {
  background: #fbfcfa;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}

.bonus-input-card legend {
  color: var(--green);
  font-size: 0.72rem;
  font-weight: 850;
  padding: 0 6px;
  text-transform: uppercase;
}

.bonus-input-card .field-grid.compact {
  margin-top: 0;
}

.segmented-control {
  background: var(--surface-alt);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 8px;
  padding: 4px;
}

.segmented-control label {
  cursor: pointer;
  min-width: 0;
}

.segmented-control input {
  position: absolute;
  transform: scale(0);
}

.segmented-control span {
  align-items: center;
  border-radius: 6px;
  color: var(--muted);
  display: flex;
  font-size: 0.82rem;
  font-weight: 850;
  justify-content: center;
  min-height: 36px;
  padding: 0 10px;
  text-align: center;
}

.segmented-control input:checked + span {
  background: #fff;
  box-shadow: 0 8px 18px rgba(31, 45, 35, 0.1);
  color: var(--green-dark);
}

.is-hidden {
  display: none;
}

.range-card {
  background: #fbfcfa;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-top: 18px;
  padding: 16px;
}

.range-row {
  align-items: center;
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr) 104px;
  margin-top: 10px;
}

input[type="range"] {
  accent-color: var(--green);
  width: 100%;
}

.check-row {
  align-items: center;
  color: var(--ink);
  display: flex;
  font-size: 0.88rem;
  font-weight: 800;
  gap: 10px;
  margin-top: 18px;
}

.check-row input {
  accent-color: var(--green);
  height: 18px;
  width: 18px;
}

.primary-metric {
  background: var(--ink);
  border-radius: var(--radius);
  color: #fff;
  margin-top: 22px;
  padding: 24px;
}

.primary-metric span,
.primary-metric small {
  color: rgba(255, 255, 255, 0.72);
  display: block;
  font-size: 0.84rem;
  font-weight: 800;
}

.primary-metric strong {
  display: block;
  font-size: clamp(2.25rem, 7vw, 4.6rem);
  line-height: 0.92;
  margin: 10px 0;
  overflow-wrap: anywhere;
}

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

.metric-grid div,
.salary-grid div,
.bonus-grid div,
.hourly-grid div,
.assumption-grid div {
  background: #fbfcfa;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-width: 0;
  padding: 16px;
}

.metric-grid span,
.salary-grid span,
.bonus-grid span,
.hourly-grid span,
.assumption-grid span {
  color: var(--muted);
  display: block;
  font-size: 0.76rem;
  font-weight: 800;
}

.metric-grid strong,
.salary-grid strong,
.bonus-grid strong,
.hourly-grid strong,
.assumption-grid strong {
  display: block;
  font-size: 1.12rem;
  line-height: 1.2;
  margin-top: 7px;
  overflow-wrap: anywhere;
}

.salary-panel,
.bonus-panel,
.hourly-panel,
.stack-card {
  margin-top: 22px;
}

.panel-subheader,
.bonus-panel h3,
.hourly-panel h3,
.stack-card-header {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 12px;
}

.panel-subheader h3,
.bonus-panel h3,
.hourly-panel h3,
.tuition-card h3 {
  font-size: 1.05rem;
  line-height: 1.2;
  margin: 0 0 12px;
}

.panel-subheader h3 {
  margin: 0;
}

.panel-subheader span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 850;
  text-align: right;
}

.salary-grid,
.bonus-grid,
.hourly-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.stack-card-header span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.deduction-stack {
  display: grid;
  gap: 10px;
}

.deduction-row {
  display: grid;
  gap: 9px;
}

.deduction-row-label {
  align-items: center;
  display: flex;
  font-size: 0.82rem;
  font-weight: 850;
  justify-content: space-between;
}

.deduction-track {
  background: var(--surface-alt);
  border-radius: 999px;
  height: 10px;
  overflow: hidden;
}

.deduction-fill {
  border-radius: inherit;
  height: 100%;
  min-width: 4px;
}

.fill-federal {
  background: var(--green);
}

.fill-provincial {
  background: var(--teal);
}

.fill-cpp {
  background: var(--gold);
}

.fill-ei {
  background: var(--coral);
}

.fill-other {
  background: #6c6f64;
}

.table-wrap {
  max-width: 100%;
  margin-top: 18px;
  overflow-x: auto;
}

table {
  border-collapse: collapse;
  table-layout: fixed;
  width: 100%;
}

th,
td {
  border-bottom: 1px solid var(--line);
  font-size: 0.88rem;
  padding: 13px 10px;
  text-align: right;
  white-space: nowrap;
}

th:first-child,
td:first-child {
  text-align: left;
}

th {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 850;
  text-transform: uppercase;
}

tbody tr.is-active {
  background: rgba(23, 107, 76, 0.08);
}

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

.tuition-card {
  background: #fbfcfa;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-top: 18px;
  padding: 16px;
}

.tuition-card dl {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 0;
}

.tuition-card div {
  min-width: 0;
}

.tuition-card dt {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 850;
}

.tuition-card dd {
  font-size: 1.04rem;
  font-weight: 850;
  margin: 6px 0 0;
  overflow-wrap: anywhere;
}

.small-note {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.6;
  margin: 18px 0 0;
}

.projection-note {
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.55;
  margin: 12px 0 0;
}

.source-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.source-links a {
  background: var(--surface-alt);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--green-dark);
  font-size: 0.8rem;
  font-weight: 850;
  padding: 8px 11px;
  text-decoration: none;
}

@media (max-width: 1020px) {
  .workspace,
  .intro-panel {
    grid-template-columns: 1fr;
  }

  .control-panel {
    grid-row: auto;
  }

  .metric-grid,
  .salary-grid,
  .bonus-grid,
  .hourly-grid,
  .assumption-grid,
  .tuition-card dl {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  .topbar {
    align-items: flex-start;
    gap: 14px;
    padding: 18px 16px 4px;
  }

  .topbar-actions {
    display: none;
  }

  .workspace {
    gap: 14px;
    padding: 16px;
  }

  .intro-panel,
  .control-panel,
  .result-panel,
  .scenario-panel,
  .projection-panel,
  .assumptions-panel {
    padding: 18px;
  }

  .intro-panel {
    min-height: auto;
  }

  .intro-panel h1 {
    font-size: 2.35rem;
  }

  .quick-stats,
  .field-grid,
  .field-grid.compact,
  .preset-actions,
  .metric-grid,
  .salary-grid,
  .bonus-grid,
  .hourly-grid,
  .assumption-grid,
  .tuition-card dl {
    grid-template-columns: 1fr;
  }

  .range-row {
    grid-template-columns: 1fr;
  }

  .primary-metric strong {
    font-size: 2.35rem;
  }

  .panel-header {
    align-items: flex-start;
  }

  .panel-subheader {
    align-items: flex-start;
    flex-direction: column;
  }

  .panel-subheader span {
    text-align: left;
  }

  .table-wrap {
    overflow-x: visible;
  }

  table,
  tbody,
  tr,
  td {
    display: block;
    width: 100%;
  }

  thead {
    display: none;
  }

  tbody {
    display: grid;
    gap: 10px;
  }

  tbody tr {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 10px 12px;
  }

  tbody tr.is-active {
    background: rgba(23, 107, 76, 0.08);
  }

  td,
  td:first-child {
    align-items: center;
    border-bottom: 0;
    display: flex;
    gap: 14px;
    justify-content: space-between;
    padding: 8px 0;
    text-align: right;
    white-space: normal;
  }

  td::before {
    color: var(--muted);
    content: attr(data-label);
    font-size: 0.72rem;
    font-weight: 850;
    text-align: left;
    text-transform: uppercase;
  }
}
