:root {
  color-scheme: light;
  --ink: #1d2340;
  --muted: #667085;
  --subtle: #8b92a7;
  --line: #dfe3ee;
  --line-strong: #c9cede;
  --canvas: #f5f7fc;
  --panel: #ffffff;
  --panel-soft: #f8f9fd;
  --accent: #3157d5;
  --accent-dark: #2444ad;
  --accent-soft: #e9edff;
  --secondary: #079b96;
  --secondary-dark: #08736f;
  --secondary-soft: #e5f7f5;
  --violet: #7052c8;
  --violet-soft: #f0ecff;
  --official: #167853;
  --official-soft: #e7f7f0;
  --estimate: #6849b8;
  --estimate-soft: #f1edff;
  --warning: #963f25;
  --warning-soft: #fff5ee;
  --focus: rgb(49 87 213 / 24%);
  --shadow: 0 14px 34px rgb(36 52 99 / 9%);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--canvas);
}

body {
  margin: 0;
  min-height: 100vh;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
  background: var(--canvas);
  color: var(--ink);
}

button,
select,
input {
  font: inherit;
}

button,
select,
input,
summary,
a {
  -webkit-tap-highlight-color: transparent;
}

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

.topbar {
  min-height: 48px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  font-weight: 850;
}

.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  flex: 0 0 34px;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  box-shadow: 4px 4px 0 var(--secondary);
  font-size: 18px;
  font-weight: 900;
}

.maker-credit {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.maker-credit-text {
  color: inherit;
}

.linkedin-link {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  line-height: 0;
  transition:
    transform 140ms ease,
    box-shadow 140ms ease;
}

.linkedin-link:hover,
.linkedin-link:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 5px 12px rgb(10 102 194 / 22%);
}

.linkedin-link:focus-visible,
button:focus-visible,
select:focus-visible,
input:focus-visible,
summary:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.linkedin-link img {
  display: block;
  width: 18px;
  max-width: 18px;
  height: 18px;
  max-height: 18px;
  object-fit: contain;
}

.page-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 480px);
  gap: 48px;
  align-items: end;
  padding: 34px 0 28px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--secondary-dark);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

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

h1 {
  max-width: 720px;
  margin-bottom: 0;
  font-size: 42px;
  line-height: 1.08;
  letter-spacing: 0;
}

.intro {
  max-width: 480px;
  margin: 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.55;
}

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

.controls-panel,
.results-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.controls-panel {
  position: sticky;
  top: 16px;
  border-top: 3px solid var(--secondary);
  padding: 20px;
}

.results-panel {
  border-top: 3px solid var(--accent);
  padding: 20px 24px 24px;
}

.section-heading {
  min-height: 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.section-heading > div {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 9px;
}

.section-step {
  color: var(--secondary-dark);
  font-size: 11px;
  font-weight: 900;
}

.results-heading .section-step {
  color: var(--accent);
}

h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.25;
  letter-spacing: 0;
}

.scenario-count {
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--violet-soft);
  color: #58409d;
  font-size: 12px;
  font-weight: 750;
}

.scenario-profile {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin: 16px 0 20px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.scenario-profile span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.scenario-profile span::before {
  content: "";
  width: 6px;
  height: 6px;
  flex: 0 0 6px;
  border-radius: 50%;
  background: var(--secondary);
}

.scenario-profile span:nth-child(2)::before {
  background: var(--violet);
}

form {
  display: grid;
  gap: 18px;
}

.settings-grid {
  display: grid;
  gap: 16px;
}

.field {
  min-width: 0;
  display: grid;
  gap: 8px;
}

.field-label {
  color: #535c74;
  font-size: 12px;
  font-weight: 800;
}

.field-heading {
  display: flex;
  align-items: center;
  gap: 6px;
}

select,
input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
}

select {
  padding: 0 38px 0 12px;
  cursor: pointer;
  font-weight: 750;
}

input {
  padding: 0 12px;
}

select:hover,
input:hover {
  border-color: #9da8ca;
}

button {
  width: 100%;
  min-height: 46px;
  border: 0;
  border-radius: 6px;
  padding: 0 18px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 850;
  transition:
    background 140ms ease,
    box-shadow 140ms ease,
    transform 140ms ease;
  box-shadow: 0 7px 16px rgb(49 87 213 / 18%);
}

button:hover {
  background: var(--accent-dark);
  box-shadow: 0 9px 20px rgb(49 87 213 / 24%);
  transform: translateY(-1px);
}

button:active {
  transform: translateY(1px);
}

button:disabled {
  background: #9299ad;
  box-shadow: none;
  cursor: wait;
  transform: none;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 3px;
  min-height: 44px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eef1f8;
}

.segmented.safety {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.segmented input[type="radio"] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.segmented label {
  min-width: 0;
  min-height: 36px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
  font-weight: 800;
  text-align: center;
  transition:
    background 140ms ease,
    color 140ms ease,
    transform 140ms ease;
}

.segmented label:hover {
  color: var(--ink);
}

.segmented label:has(input:checked) {
  background: #fff;
  color: var(--accent);
  box-shadow: 0 2px 7px rgb(36 52 99 / 14%);
  transform: translateY(-1px);
}

.segmented-loading {
  min-height: 36px;
  display: grid;
  grid-column: 1 / -1;
  place-items: center;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.custom-margin[hidden],
.result[hidden] {
  display: none;
}

.profile-help {
  position: relative;
}

.profile-help summary {
  width: 19px;
  height: 19px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: #fff;
  color: var(--accent-dark);
  cursor: pointer;
  font-size: 11px;
  font-weight: 900;
  list-style: none;
}

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

.profile-help[open] summary {
  border-color: var(--accent);
}

.profile-tooltip {
  display: none;
  position: absolute;
  z-index: 20;
  top: 24px;
  left: 0;
  width: min(360px, calc(100vw - 48px));
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 16px 36px rgb(24 37 35 / 16%);
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.5;
}

.profile-help[open] .profile-tooltip {
  display: block;
}

.profile-tooltip strong {
  color: var(--ink);
}

.profile-tooltip p,
.profile-tooltip ul {
  margin: 8px 0;
}

.profile-tooltip ul {
  padding-left: 18px;
}

.profile-tooltip a {
  color: var(--accent-dark);
  font-weight: 750;
}

.results-heading {
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.live-indicator {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
}

.live-indicator > span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #2d8a54;
  box-shadow: 0 0 0 4px #e8f4ec;
}

.result {
  min-width: 0;
}

.loading-card {
  min-height: 320px;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 9px;
  color: var(--muted);
  text-align: center;
}

.loading-card strong {
  color: var(--ink);
  font-size: 16px;
}

.loading-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid rgb(49 87 213 / 17%);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 850ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.result.is-updating {
  position: relative;
  opacity: 0.72;
}

.result.is-updating .estimate-status {
  color: var(--accent);
}

.estimate-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  align-items: end;
  padding: 28px 0 24px;
}

.estimate-city {
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 750;
}

.amount-group {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.amount {
  min-width: 0;
  color: var(--accent);
  font-size: 60px;
  line-height: 0.95;
  font-weight: 900;
}

.amount-period {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.profile-summary {
  max-width: 520px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.estimate-status {
  align-self: start;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding-top: 4px;
  color: var(--official);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}

.estimate-status::before {
  content: "";
  width: 7px;
  height: 7px;
  flex: 0 0 7px;
  border-radius: 50%;
  background: currentcolor;
}

.result.is-updating .estimate-status::before {
  animation: status-pulse 850ms ease-in-out infinite alternate;
}

@keyframes status-pulse {
  to {
    opacity: 0.28;
    transform: scale(0.72);
  }
}

.summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 26px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.metric {
  min-width: 0;
  padding: 15px 18px;
}

.metric + .metric {
  border-left: 1px solid var(--line);
}

.metric:first-child {
  padding-left: 0;
}

.metric:last-child {
  padding-right: 0;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
}

.metric strong {
  display: block;
  margin-top: 5px;
  font-size: 19px;
}

.metric:nth-child(2) strong {
  color: var(--violet);
}

.metric:nth-child(3) strong {
  color: var(--accent);
}

.breakdown-heading {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0 0 8px;
}

.breakdown-heading > strong {
  font-size: 15px;
}

.breakdown {
  display: grid;
}

.row {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 20px;
  padding: 17px 0;
  border-top: 1px solid var(--line);
  transition:
    background 140ms ease,
    box-shadow 140ms ease;
}

.row:hover {
  background: var(--panel-soft);
  box-shadow: -10px 0 0 var(--panel-soft), 10px 0 0 var(--panel-soft);
}

.row > strong {
  color: var(--ink);
  font-size: 17px;
  white-space: nowrap;
}

.row-title {
  min-width: 0;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 15px;
  font-weight: 850;
}

.badge {
  max-width: 100%;
  border-radius: 999px;
  padding: 3px 8px;
  overflow: hidden;
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 9px;
  font-weight: 900;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.badge.official_source,
.badge.published_source {
  background: var(--official-soft);
  color: var(--official);
}

.badge.city_estimate {
  background: var(--estimate-soft);
  color: var(--estimate);
}

.badge.calculated {
  background: #eef0f3;
  color: #5d6470;
}

.source {
  max-width: 760px;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.source-meta {
  color: #505a73;
  font-weight: 800;
}

.source-attribution {
  margin-top: 4px;
  color: var(--subtle);
  font-size: 11px;
}

.warnings {
  margin-top: 18px;
  padding: 14px 16px;
  border: 1px solid #efc8b6;
  border-radius: 8px;
  background: var(--warning-soft);
  color: var(--warning);
  font-size: 12px;
}

.warnings strong {
  font-size: 13px;
}

.warnings p {
  margin: 8px 0 0;
}

.warnings ul {
  margin: 8px 0 0;
  padding-left: 18px;
}

@media (min-width: 861px) and (hover: hover) and (pointer: fine) {
  .profile-help:hover .profile-tooltip,
  .profile-help:focus-within .profile-tooltip {
    display: block;
  }
}

@media (max-width: 980px) {
  .page-heading {
    grid-template-columns: 1fr;
    gap: 14px;
  }

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

  .controls-panel {
    position: static;
  }

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

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 24px, 1240px);
    padding-top: 12px;
  }

  .topbar {
    gap: 12px;
    padding-bottom: 12px;
  }

  .brand {
    font-size: 14px;
  }

  .brand-mark {
    width: 30px;
    height: 30px;
    flex-basis: 30px;
    font-size: 16px;
  }

  .maker-credit {
    font-size: 11px;
  }

  .page-heading {
    padding: 24px 0 20px;
  }

  h1 {
    font-size: 32px;
  }

  .intro {
    font-size: 14px;
  }

  .controls-panel,
  .results-panel {
    padding: 16px;
  }

  .settings-grid,
  .summary {
    grid-template-columns: 1fr;
  }

  .metric {
    padding: 11px 0;
  }

  .metric + .metric {
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .estimate-header {
    grid-template-columns: 1fr;
    gap: 10px;
    padding-top: 22px;
  }

  .estimate-status {
    grid-row: 1;
  }

  .amount {
    font-size: 48px;
  }

  .row {
    gap: 12px;
  }

  .profile-tooltip {
    left: -110px;
    width: min(330px, calc(100vw - 36px));
  }

  .source-help .profile-tooltip {
    left: -140px;
  }
}

@media (max-width: 420px) {
  .maker-credit-text {
    display: none;
  }

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

  .scenario-profile {
    gap: 7px 14px;
  }

  .results-heading .live-indicator {
    display: none;
  }

  .amount-group {
    display: block;
  }

  .amount-period {
    display: block;
    margin-top: 6px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
