:root {
  color-scheme: light;
  --bg: #050505;
  --canvas: #eef7fb;
  --panel: #f8f7f1;
  --panel-strong: #f0f5cf;
  --text: #050505;
  --muted: #77756e;
  --border: #111111;
  --accent: #ff7433;
  --accent-strong: #f45d16;
  --green: #101010;
  --amber: #f9c934;
  --peach: #f6d9b4;
  --lime: #c7d957;
  --pink: #e7a7df;
  --graph-net-excluding-meal: #9fd7e9;
  --graph-social-security: var(--pink);
  --graph-irs: var(--accent);
  --shadow: 0 28px 70px rgba(0, 0, 0, 0.22);
  --radius: 24px;
  font-family: "Inter", "Helvetica Neue", Arial, ui-sans-serif, system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(1180px, calc(100vw - 40px));
  margin: 0 auto;
  padding: 48px 0;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: flex-start;
  gap: 28px;
  margin-bottom: 20px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--canvas);
  padding: 26px;
  box-shadow: var(--shadow);
}

.topbar > div:first-child {
  min-width: 0;
}

.topbar h1 {
  margin: 0;
  max-width: 640px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.4rem, 6vw, 5rem);
  font-weight: 500;
  line-height: 0.95;
  letter-spacing: 0;
}

.topbar p {
  max-width: 680px;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: clamp(1.05rem, 1.9vw, 1.45rem);
  line-height: 1.12;
  letter-spacing: 0;
}

.top-actions {
  display: grid;
  align-items: start;
  gap: 12px;
  min-width: 198px;
}

.language-select,
.notes-control {
  display: grid;
  gap: 6px;
  color: var(--text);
  font-size: 0.72rem;
  font-weight: 850;
}

.language-select > span,
.notes-control > span {
  color: var(--muted);
}

.language-select select {
  min-height: 44px;
}

.source-chip {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: 0;
  background: #fffdf7;
  padding: 13px 15px;
  box-shadow: none;
  cursor: pointer;
  text-align: left;
}

.source-chip span,
.source-chip strong {
  display: block;
}

.source-chip span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 750;
}

.source-chip strong {
  margin-top: 3px;
  color: var(--text);
  font-size: 0.9rem;
}

.source-chip:hover {
  background: var(--accent);
  border-color: var(--border);
  color: var(--text);
}

.calculator-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  align-items: start;
}

.calculator-form {
  display: contents;
}

.panel {
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.mode-panel {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  padding: 20px 22px;
}

.input-panel,
.result-panel {
  padding: 22px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1.5px solid var(--border);
  margin: -22px -22px 20px;
  padding: 18px 22px;
}

.panel h2,
.panel-heading h2 {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 850;
  line-height: 1.2;
}

.ghost-button {
  border: 1.5px solid var(--border);
  border-radius: 999px;
  background: #050505;
  color: #fffaf1;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 850;
  padding: 8px 13px;
}

.ghost-button:hover {
  background: var(--accent);
  color: var(--text);
}

.compact-action {
  padding: 7px 12px;
  white-space: nowrap;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1.5px solid var(--border);
  border-radius: 999px;
  background: var(--text);
  color: #fffaf1;
  cursor: pointer;
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1;
}

.icon-button:hover {
  background: var(--accent);
  color: var(--text);
}

.control-group {
  margin: 0 0 16px;
  padding: 0;
  border: 0;
}

.mode-panel .control-group {
  margin: 0;
}

.control-group legend {
  margin-bottom: 8px;
  color: var(--text);
  font-size: 0.74rem;
  font-weight: 850;
  text-transform: uppercase;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border: 1.5px solid var(--border);
  border-radius: 999px;
  background: #fffdf7;
  overflow: hidden;
}

.segmented label {
  min-width: 0;
}

.segmented input {
  position: absolute;
  width: 0;
  min-height: 0;
  height: 0;
  margin: 0;
  opacity: 0;
  pointer-events: none;
}

.segmented span {
  display: block;
  color: var(--text);
  cursor: pointer;
  font-size: 0.84rem;
  font-weight: 850;
  padding: 12px;
  text-align: center;
}

.segmented input:checked + span {
  background: var(--accent);
  color: var(--text);
  box-shadow: none;
}

.field-row,
.field-grid label {
  display: grid;
  gap: 7px;
  color: var(--text);
  font-size: 0.74rem;
  font-weight: 850;
}

.field-row {
  margin-bottom: 14px;
}

.field-note {
  margin: 0;
  color: rgba(5, 5, 5, 0.68);
  font-size: 0.75rem;
  font-weight: 750;
  line-height: 1.35;
}

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

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

input,
select {
  width: 100%;
  min-height: 44px;
  border: 1.5px solid var(--border);
  border-radius: 0;
  background: #fffdf7;
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 750;
  padding: 10px 12px;
}

input:focus,
select:focus,
button:focus-visible {
  outline: 3px solid rgba(255, 116, 51, 0.3);
  outline-offset: 2px;
  border-color: var(--accent);
}

.money-input,
.suffix-input {
  display: flex;
  align-items: center;
  min-height: 44px;
  border: 1.5px solid var(--border);
  border-radius: 0;
  background: #fffdf7;
  overflow: hidden;
}

.money-input span,
.suffix-input span {
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 850;
  padding: 0 10px;
}

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

.money-input input {
  padding-left: 0;
}

.suffix-input input {
  padding-left: 12px;
}

.money-input:not(.compact) input {
  font-size: 1.25rem;
}

.toggle-line {
  align-content: end;
  grid-template-columns: auto 1fr;
  gap: 10px;
  min-height: 67px;
}

.toggle-line input {
  width: 18px;
  min-height: 18px;
  align-self: center;
  accent-color: var(--accent);
}

.toggle-line span {
  align-self: center;
  color: var(--text);
  font-size: 0.85rem;
}

.details-toggle {
  border-top: 1.5px solid var(--border);
  border-bottom: 1.5px solid var(--border);
  margin: 16px -22px 0;
}

.details-toggle summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  list-style: none;
  min-height: 48px;
  padding: 14px 22px;
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 900;
}

.details-toggle summary::-webkit-details-marker {
  display: none;
}

.details-toggle summary::after {
  content: "+";
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 1.5px solid var(--border);
  border-radius: 999px;
  background: var(--amber);
  color: var(--text);
  font-size: 1rem;
  line-height: 1;
}

.details-toggle[open] summary {
  border-bottom: 1.5px solid var(--border);
}

.details-toggle[open] summary::after {
  content: "−";
}

.details-fields {
  padding: 18px 22px 4px;
}

.pay-graph {
  margin-top: 18px;
}

.pay-graph h3 {
  margin: 0 0 10px;
  font-size: 0.86rem;
  font-weight: 900;
  line-height: 1.2;
}

.pay-graph-bars {
  display: block;
}

.pay-donut-layout {
  display: grid;
  grid-template-columns: minmax(132px, 0.38fr) minmax(0, 1fr);
  gap: 16px;
  align-items: center;
}

.pay-donut {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  width: min(100%, 172px);
  border: 1.5px solid var(--border);
  border-radius: 50%;
  position: relative;
}

.pay-donut::after {
  content: "";
  position: absolute;
  inset: 28%;
  border: 1.5px solid var(--border);
  border-radius: 50%;
  background: var(--panel);
}

.pay-donut span {
  position: relative;
  z-index: 1;
  max-width: 58%;
  color: var(--text);
  font-size: 0.84rem;
  font-weight: 900;
  line-height: 1.15;
  text-align: center;
}

.pay-donut-legend {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.pay-donut-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  min-width: 0;
}

.pay-donut-swatch {
  width: 14px;
  height: 14px;
  border: 1.5px solid var(--border);
}

.pay-donut-row.net-excluding-meal .pay-donut-swatch {
  background: var(--graph-net-excluding-meal);
}

.pay-donut-row.social-security .pay-donut-swatch {
  background: var(--graph-social-security);
}

.pay-donut-row.irs .pay-donut-swatch {
  background: var(--graph-irs);
}

.pay-donut-label,
.pay-donut-row em {
  color: rgba(5, 5, 5, 0.68);
  font-size: 0.74rem;
  font-style: normal;
  font-weight: 850;
}

.pay-donut-label {
  min-width: 0;
  overflow-wrap: anywhere;
}

.pay-donut-row strong {
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 900;
  white-space: nowrap;
}

.pay-donut-row em {
  color: var(--text);
  text-align: right;
  white-space: nowrap;
}

#table-badge {
  border: 1.5px solid var(--border);
  border-radius: 999px;
  background: var(--amber);
  color: var(--text);
  font-size: 0.76rem;
  font-weight: 850;
  padding: 7px 11px;
}

.hero-result {
  border: 1.5px solid var(--border);
  border-radius: 16px;
  background: var(--accent);
  padding: 22px;
}

.hero-result span,
.hero-result small {
  display: block;
}

.hero-result span {
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 850;
  text-transform: uppercase;
}

.hero-result strong {
  display: block;
  margin: 8px 0;
  color: var(--text);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(3rem, 8vw, 5.6rem);
  font-weight: 500;
  letter-spacing: -0.06em;
  line-height: 0.9;
}

.hero-result small {
  color: rgba(5, 5, 5, 0.72);
  line-height: 1.35;
}

.metric-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  border: 1.5px solid var(--border);
  border-radius: 16px;
  margin: 14px 0;
  overflow: hidden;
}

.metric-row div {
  border: 0;
  border-right: 1.5px solid var(--border);
  padding: 11px;
}

.metric-row div:nth-child(1) {
  background: var(--peach);
}

.metric-row div:nth-child(2) {
  background: var(--amber);
}

.metric-row div:nth-child(3) {
  background: var(--pink);
}

.metric-row div:nth-child(4) {
  background: var(--lime);
  border-right: 0;
}

.metric-row span,
.metric-row strong {
  display: block;
}

.metric-row span {
  color: rgba(5, 5, 5, 0.68);
  font-size: 0.74rem;
  font-weight: 850;
}

.metric-row strong {
  margin-top: 4px;
  font-size: 1rem;
}

.metric-note {
  margin: -6px 0 14px;
  color: rgba(5, 5, 5, 0.68);
  font-size: 0.75rem;
  font-weight: 750;
  line-height: 1.35;
}

.breakdown {
  border: 1.5px solid var(--border);
  border-radius: 16px;
  background: #fffdf7;
  margin-top: 14px;
  overflow: hidden;
  padding-top: 0;
}

.breakdown-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1.5px solid var(--border);
  padding: 12px 14px;
}

.breakdown-row span {
  color: var(--muted);
  font-size: 0.88rem;
}

.breakdown-row strong {
  white-space: nowrap;
}

.breakdown-row.total {
  border-bottom: 0;
}

.breakdown-row.total span,
.breakdown-row.total strong {
  color: var(--text);
  font-weight: 900;
}

.cost-of-living {
  border: 1.5px solid var(--border);
  border-radius: 16px;
  background: var(--panel-strong);
  margin-top: 14px;
  overflow: hidden;
}

.cost-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1.5px solid var(--border);
  padding: 14px;
}

.cost-heading h2 {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 850;
}

.cost-heading p {
  margin: 5px 0 0;
  color: rgba(5, 5, 5, 0.72);
  font-size: 0.78rem;
  font-weight: 800;
}

.cost-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.cost-card {
  min-width: 0;
  background: #fffdf7;
  border-right: 1.5px solid var(--border);
}

.cost-card:last-child {
  border-right: 0;
}

.cost-card-heading {
  border-bottom: 1.5px solid var(--border);
  padding: 13px;
}

.cost-card h3 {
  margin: 0 0 9px;
  font-size: 0.92rem;
  line-height: 1.15;
}

.cost-card-heading span,
.cost-card dt {
  color: rgba(5, 5, 5, 0.68);
  font-size: 0.72rem;
  font-weight: 850;
}

.cost-card-heading strong {
  display: block;
  margin-top: 3px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.75rem;
  font-weight: 500;
  line-height: 1;
}

.salary-after-cost {
  border-top: 1.5px solid var(--border);
  margin: 12px -13px -13px;
  padding: 10px 13px;
}

.salary-after-cost.positive {
  background: #d8f3c5;
  color: #12350c;
}

.salary-after-cost.negative {
  background: #ffd2cc;
  color: #7c140c;
}

.salary-after-cost.neutral {
  background: #fffdf7;
  color: var(--text);
}

.salary-after-cost span {
  display: block;
  color: currentColor;
  font-size: 0.72rem;
  font-weight: 850;
  line-height: 1.2;
  opacity: 0.82;
}

.salary-after-cost strong {
  display: block;
  margin-top: 4px;
  color: currentColor;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 900;
  line-height: 1.2;
}

.cost-card dl {
  margin: 0;
}

.cost-card dl div {
  display: grid;
  gap: 6px;
  border-bottom: 1.5px solid var(--border);
  padding: 9px 13px;
}

.cost-card dl div:last-child {
  border-bottom: 0;
}

.cost-card dd {
  width: 100%;
  margin: 0;
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 900;
  white-space: nowrap;
}

.cost-card .cost-money-input {
  min-height: 38px;
}

.cost-card .cost-money-input input {
  flex: 1;
  min-width: 0;
  width: 100%;
  min-height: 36px;
  font-size: 0.82rem;
  font-weight: 900;
  padding: 6px 8px;
  text-align: right;
}

.cost-source-note {
  border-top: 1.5px solid var(--border);
  margin: 0;
  color: rgba(5, 5, 5, 0.68);
  font-size: 0.74rem;
  font-weight: 750;
  line-height: 1.35;
  padding: 12px 14px;
}

.coverage-list {
  margin: 14px 0 0;
  padding-left: 18px;
  color: #3f3d37;
  line-height: 1.55;
}

.rules-dialog {
  width: min(820px, calc(100vw - 32px));
  max-height: min(760px, calc(100vh - 32px));
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  overflow: hidden;
  padding: 0;
}

.rules-dialog::backdrop {
  background: rgba(5, 5, 5, 0.58);
}

.dialog-surface {
  max-height: min(760px, calc(100vh - 32px));
  overflow: auto;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.4);
  padding: 20px;
}

.dialog-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1.5px solid var(--border);
  padding-bottom: 16px;
}

.dialog-heading h2,
.dialog-grid h3 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 500;
  letter-spacing: -0.04em;
}

.dialog-heading p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.dialog-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  padding-top: 18px;
}

.dialog-grid p {
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.dialog-grid a {
  color: var(--accent-strong);
  font-weight: 800;
}

.coverage-list.compact {
  margin-top: 12px;
}

@media (max-width: 1120px) {
  .metric-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .cost-options {
    grid-template-columns: 1fr;
  }

  .cost-card {
    border-right: 0;
    border-bottom: 1.5px solid var(--border);
  }

  .cost-card:last-child {
    border-bottom: 0;
  }

  .metric-row div:nth-child(2) {
    border-right: 0;
  }

  .metric-row div:nth-child(1),
  .metric-row div:nth-child(2) {
    border-bottom: 1.5px solid var(--border);
  }

  .metric-row div:nth-child(3) {
    border-right: 1.5px solid var(--border);
  }
}

@media (max-width: 980px) {
  .topbar,
  .calculator-grid {
    grid-template-columns: 1fr;
  }

  .mode-panel {
    grid-column: auto;
  }

  .top-actions {
    align-items: stretch;
  }

  .calculator-grid {
    display: grid;
  }
}

@media (max-width: 720px) {
  .dialog-grid {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .mode-panel,
  .pay-donut-layout {
    grid-template-columns: 1fr;
  }

  .pay-donut {
    justify-self: center;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 18px, 1180px);
    padding: 18px 0;
  }

  .field-grid,
  .field-grid.three {
    grid-template-columns: 1fr;
  }

  .input-panel,
  .mode-panel,
  .result-panel {
    padding: 18px;
  }

  .top-actions {
    grid-template-columns: 1fr;
  }

  .panel-heading {
    align-items: flex-start;
    flex-direction: column;
    margin: -18px -18px 18px;
    padding: 16px 18px;
  }

  .details-toggle {
    margin-right: -18px;
    margin-left: -18px;
  }

  .details-toggle summary,
  .details-fields {
    padding-right: 18px;
    padding-left: 18px;
  }

  .dialog-surface {
    padding: 16px;
  }

  .dialog-heading {
    gap: 12px;
  }
}

@media (max-width: 520px) {
  .metric-row {
    grid-template-columns: 1fr;
  }

  .metric-row div,
  .metric-row div:nth-child(2),
  .metric-row div:nth-child(3) {
    border-right: 0;
  }

  .metric-row div:nth-child(1),
  .metric-row div:nth-child(2),
  .metric-row div:nth-child(3) {
    border-bottom: 1.5px solid var(--border);
  }

  .breakdown-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }
}
