:root {
  color-scheme: light;
  --ink: #2c292a;
  --muted: #665f62;
  --line: #dacbd1;
  --panel: #ffffff;
  --surface: #f0e7eb;
  --accent: #007ab6;
  --accent-strong: #005f8f;
  --accent-soft: #95d7e2;
  --accent-electric: #00dde4;
  --shadow: 0 16px 40px rgba(44, 41, 42, 0.12);
}

body.dark-mode {
  color-scheme: dark;
  --ink: #f4edf0;
  --muted: #c8b9c0;
  --line: #3b3438;
  --panel: #191719;
  --surface: #2c292a;
  --accent: #00dde4;
  --accent-strong: #95d7e2;
  --accent-soft: #007ab6;
  --accent-electric: #00dde4;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.32);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--surface);
  color: var(--ink);
  font-family: Futura, "Open Sans", Arial, sans-serif;
}

button,
input,
select {
  font: inherit;
}

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

.workspace {
  max-width: 1440px;
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 4vw, 3.5rem);
  line-height: 0.95;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 1rem;
}

.top-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
}

button {
  border: 1px solid var(--line);
  border-radius: 6px;
  min-height: 42px;
  padding: 0 14px;
  cursor: pointer;
}

.primary-button {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

.ghost-button {
  background: var(--panel);
  color: var(--ink);
}

.header-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  max-width: 820px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.35;
}

.header-meta a {
  color: var(--accent);
  font-weight: 800;
  text-decoration: none;
}

.header-meta a:hover {
  text-decoration: underline;
}

.header-meta span {
  position: relative;
}

.header-meta span::before {
  content: "";
  display: inline-block;
  width: 5px;
  height: 5px;
  margin: 0 8px 2px 0;
  border-radius: 50%;
  background: var(--accent-electric);
}

.theme-toggle {
  display: inline-grid;
  grid-template-columns: 44px auto;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  margin: 0;
  color: var(--ink);
  font-size: 0.84rem;
  text-transform: none;
  cursor: pointer;
}

.language-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  min-height: 42px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
}

.language-toggle label {
  display: block;
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  cursor: pointer;
}

.language-toggle input {
  position: absolute;
  opacity: 0;
}

.language-toggle span {
  display: grid;
  place-items: center;
  min-width: 44px;
  min-height: 32px;
  border-radius: 4px;
  padding: 0 8px;
  font-weight: 900;
}

.language-toggle input:checked + span {
  background: var(--accent);
  color: #fff;
}

body.dark-mode .language-toggle input:checked + span {
  color: #10282f;
}

.theme-toggle input {
  position: absolute;
  opacity: 0;
}

.toggle-track {
  position: relative;
  display: block;
  width: 44px;
  height: 24px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  box-shadow: inset 0 0 0 2px transparent;
}

.toggle-track::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  top: 2px;
  left: 3px;
  border-radius: 50%;
  background: var(--accent);
  transition: transform 160ms ease;
}

.theme-toggle input:checked + .toggle-track {
  background: #10282f;
  border-color: var(--accent);
}

.theme-toggle input:checked + .toggle-track::after {
  transform: translateX(18px);
  background: var(--accent-electric);
}

body.dark-mode .primary-button {
  color: #10282f;
}

.layout {
  display: grid;
  grid-template-columns: minmax(340px, 440px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.floating-summary {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 10;
  display: grid;
  gap: 2px;
  min-width: 190px;
  max-width: min(260px, calc(100vw - 28px));
  padding: 14px 16px;
  border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--line));
  border-radius: 8px;
  background: color-mix(in srgb, var(--panel) 88%, var(--accent-soft));
  color: var(--ink);
  box-shadow: var(--shadow);
}

.floating-summary::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  border: 1px solid rgba(0, 221, 228, 0.4);
  pointer-events: none;
}

.floating-label {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.floating-summary strong {
  color: var(--accent);
  font-size: 1.45rem;
  line-height: 1;
}

.floating-summary span:last-child {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

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

.panel-section,
.result-block,
.summary-band {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel-section {
  padding: 18px;
}

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

.section-title span,
.result-heading span {
  color: var(--accent);
  font-weight: 800;
}

label {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

select,
input[type="number"] {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  padding: 8px 10px;
  font-weight: 650;
}

select:focus,
input:focus,
button:focus-visible {
  outline: 3px solid rgba(0, 221, 228, 0.35);
  outline-offset: 2px;
}

.money-field {
  display: grid;
  grid-template-columns: 38px 1fr;
  align-items: center;
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  overflow: hidden;
}

.money-field span {
  display: grid;
  place-items: center;
  align-self: stretch;
  background: var(--accent-soft);
  color: var(--ink);
  font-weight: 900;
}

.money-field input[type="number"] {
  min-height: 40px;
  border: 0;
  border-radius: 0;
}

.field-spacer {
  display: block;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.data-rate-card {
  display: grid;
  align-content: center;
  gap: 4px;
  min-height: 72px;
  margin-bottom: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: color-mix(in srgb, var(--panel) 82%, var(--accent-soft));
}

.data-rate-card span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.data-rate-card strong {
  color: var(--accent);
  font-size: 1rem;
  line-height: 1.2;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
}

.segmented label {
  margin: 0;
  display: block;
  text-transform: none;
  font-size: 0.95rem;
}

.segmented input {
  position: absolute;
  opacity: 0;
}

.segmented span {
  display: grid;
  place-items: center;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--muted);
  font-weight: 800;
}

.segmented input:checked + span {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.work-options {
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.check-row {
  grid-template-columns: 18px 1fr;
  align-items: center;
  color: var(--ink);
  font-size: 0.9rem;
  text-transform: none;
}

.check-row input {
  inline-size: 18px;
  block-size: 18px;
  accent-color: var(--accent);
}

.summary-band {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 18px;
  gap: 12px;
}

.summary-band p {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.summary-band strong {
  display: block;
  font-size: clamp(1.35rem, 3vw, 2.2rem);
  line-height: 1;
}

.result-block {
  padding: 18px;
}

.recommendation {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 14px;
  align-items: baseline;
  margin: 8px 0;
}

.recommendation strong {
  font-size: 2rem;
}

.recommendation span {
  color: var(--muted);
  font-weight: 700;
}

.fine-print {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.bars {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.bar-row {
  display: grid;
  grid-template-columns: 110px 1fr 80px;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.bar-track {
  height: 12px;
  overflow: hidden;
  background: color-mix(in srgb, var(--surface) 75%, var(--panel));
  border-radius: 999px;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

th,
td {
  padding: 10px 8px;
  border-top: 1px solid var(--line);
  text-align: left;
}

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

td:nth-child(2),
td:nth-child(3),
th:nth-child(2),
th:nth-child(3) {
  text-align: right;
}

.two-up {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.metric-text {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.45;
}

.assumptions ul {
  margin: 10px 0 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.55;
}

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

  .topbar,
  .layout,
  .summary-band,
  .two-up {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
    align-items: start;
  }

  .summary-band {
    display: grid;
  }
}

@media (max-width: 560px) {
  .field-grid,
  .segmented {
    grid-template-columns: 1fr;
  }

  .bar-row {
    grid-template-columns: 1fr;
    gap: 5px;
  }

  .floating-summary {
    right: 14px;
    bottom: 14px;
    min-width: 0;
  }
}

@media print {
  body {
    background: #fff;
  }

  .app-shell {
    padding: 0;
  }

  .top-actions,
  .input-panel,
  .floating-summary {
    display: none;
  }

  .layout {
    display: block;
  }

  .workspace {
    max-width: none;
  }

  .topbar {
    margin: 0 0 14px;
  }

  .panel-section,
  .result-block,
  .summary-band {
    box-shadow: none;
    break-inside: avoid;
  }
}
