:root {
  color-scheme: light;
  --ink: #162033;
  --muted: #627084;
  --line: #d7dee8;
  --panel: #ffffff;
  --soft: #f4f7fb;
  --blue: #1b5f9e;
  --blue-2: #0c7c86;
  --gold: #b98718;
  --green: #217a52;
  --red: #b42318;
  --shadow: 0 18px 50px rgba(22, 32, 51, .12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(244, 247, 251, .96), rgba(233, 239, 247, .96)),
    repeating-linear-gradient(90deg, rgba(22, 32, 51, .04) 0 1px, transparent 1px 80px);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px 22px;
  background: rgba(255, 255, 255, .92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 280px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 8px;
  color: #fff;
  background: linear-gradient(135deg, var(--blue), var(--blue-2));
  font-weight: 900;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .28);
}

.brand-logo {
  width: 64px;
  height: 64px;
  object-fit: contain;
  flex: none;
  filter: drop-shadow(0 8px 14px rgba(22, 32, 51, .18));
}

.brand-logo-button {
  position: relative;
  display: block;
  width: 64px;
  height: 64px;
  padding: 0;
  border: 0;
  background: transparent;
  flex: none;
}

.brand-logo-button:focus-visible {
  outline: 3px solid rgba(27, 95, 158, .45);
  outline-offset: 4px;
}

.brand-logo-preview {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(9, 17, 32, .72);
  opacity: 0;
  pointer-events: none;
  transition: opacity .16s ease;
  backdrop-filter: blur(8px);
}

.brand-logo-preview img {
  width: min(90vw, 90vh, 620px);
  height: min(90vw, 90vh, 620px);
  object-fit: contain;
  filter: drop-shadow(0 24px 48px rgba(0, 0, 0, .35));
}

.brand-logo-button:hover .brand-logo-preview,
.brand-logo-button:focus-visible .brand-logo-preview {
  opacity: 1;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 20px;
  letter-spacing: 0;
}

.brand-block p {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
}

.mode-switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
}

.mode-switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch-track {
  display: inline-flex;
  align-items: center;
  width: 44px;
  height: 24px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #dbe3ee;
  transition: background .16s ease, border-color .16s ease;
}

.switch-track span {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 8px rgba(22, 32, 51, .22);
  transition: transform .16s ease;
}

.mode-switch input:checked + .switch-track {
  border-color: var(--blue-2);
  background: var(--blue-2);
}

.mode-switch input:checked + .switch-track span {
  transform: translateX(20px);
}

.mode-switch input:focus-visible + .switch-track {
  outline: 3px solid rgba(27, 95, 158, .45);
  outline-offset: 3px;
}

button,
.open-link {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
}

a.tab {
  text-decoration: none;
}

.guide-link {
  display: inline-flex;
  align-items: center;
}

.tab {
  padding: 10px 12px;
  color: var(--muted);
}

.tab.active {
  color: #fff;
  border-color: transparent;
  background: var(--ink);
}

main {
  padding: 24px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, .75fr);
  gap: 28px;
  min-height: 430px;
  align-items: center;
  padding: clamp(28px, 5vw, 56px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(120deg, rgba(255, 255, 255, .96), rgba(255, 255, 255, .84)),
    url("apps/takeoff/assets/logo.jpg");
  background-size: cover;
  background-position: center;
  box-shadow: var(--shadow);
}

.eyebrow {
  color: var(--gold);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}

h2 {
  margin-top: 8px;
  max-width: 900px;
  font-size: clamp(32px, 5vw, 66px);
  line-height: .98;
  letter-spacing: 0;
}

.hero-copy {
  max-width: 740px;
  margin-top: 18px;
  color: #35445b;
  font-size: 18px;
  line-height: 1.55;
}

.hero-actions,
.actions,
.button-stack {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.hero-actions {
  margin-top: 28px;
}

.primary,
.secondary,
.open-link {
  padding: 12px 16px;
}

.primary {
  border-color: transparent;
  color: #fff;
  background: linear-gradient(135deg, var(--blue), var(--blue-2));
}

.secondary,
.open-link {
  color: var(--ink);
  background: #fff;
}

.workflow {
  display: grid;
  gap: 10px;
}

.workflow div,
.compact-grid div,
.accuracy-grid article,
.metrics article,
.drop-panel,
.ledger-main,
.band {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, .92);
}

.workflow div {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 12px;
  align-items: center;
  padding: 16px;
}

.workflow strong {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  color: #fff;
  background: var(--ink);
}

.workflow span {
  font-weight: 800;
}

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

.metrics article {
  padding: 18px;
}

.label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.metrics strong {
  display: block;
  margin-top: 8px;
  font-size: 34px;
}

.band {
  display: grid;
  grid-template-columns: minmax(280px, .9fr) minmax(0, 1.1fr);
  gap: 22px;
  margin-top: 18px;
  padding: 24px;
}

.band p,
.compact-grid span,
.drop-panel p,
.handoff-note,
.accuracy-grid p {
  color: var(--muted);
  line-height: 1.55;
}

.band h3,
.accuracy-grid h3 {
  margin-bottom: 8px;
  font-size: 18px;
}

.compact-grid {
  display: grid;
  gap: 10px;
}

.compact-grid div {
  display: grid;
  gap: 4px;
  padding: 14px;
}

.design-layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 16px;
}

.design-main {
  display: grid;
  gap: 16px;
}

.design-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.design-card {
  display: grid;
  gap: 12px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.design-card h3 {
  font-size: 20px;
}

.design-card label {
  display: grid;
  gap: 7px;
  color: #334158;
  font-size: 13px;
  font-weight: 900;
}

.review-card label {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  line-height: 1.35;
}

.design-check {
  width: 18px;
  height: 18px;
}

.field-control {
  width: 100%;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

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

.design-output div {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.design-output strong {
  display: block;
  margin-top: 6px;
  font-size: 30px;
}

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

.view-head h2 {
  font-size: clamp(28px, 4vw, 48px);
}

iframe {
  width: 100%;
  height: calc(100vh - 165px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.estimating-panel {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.estimating-card {
  display: flex;
  min-height: 230px;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.estimating-card h3 {
  font-size: 22px;
}

.estimating-card p:not(.eyebrow) {
  color: var(--muted);
  line-height: 1.55;
}

.estimating-card .primary,
.estimating-card .open-link {
  margin-top: auto;
}

.legacy-frame {
  grid-column: 1 / -1;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.legacy-frame summary {
  cursor: pointer;
  padding: 16px 18px;
  font-weight: 900;
}

.legacy-frame iframe {
  height: calc(100vh - 230px);
  border-width: 1px 0 0;
  border-radius: 0 0 8px 8px;
  box-shadow: none;
}

.ledger-layout,
.accuracy-layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 16px;
}

.drop-panel,
.ledger-main,
.accuracy-main {
  padding: 18px;
}

.drop-panel {
  align-self: start;
}

.drop-panel label {
  display: block;
  margin-bottom: 10px;
  font-weight: 900;
}

input[type="file"] {
  width: 100%;
  padding: 12px;
  border: 1px dashed var(--blue);
  border-radius: 8px;
  background: var(--soft);
}

.field-label {
  display: block;
  margin: 16px 0 8px;
  font-weight: 900;
}

.number-field {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
}

.review-select {
  width: 140px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 12px;
  font-weight: 800;
}

.drop-panel p {
  margin: 14px 0;
  font-size: 14px;
}

.button-stack {
  flex-direction: column;
}

.button-stack button {
  width: 100%;
}

.status {
  margin-bottom: 12px;
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--soft);
  color: var(--muted);
  font-weight: 800;
}

.status.error {
  color: var(--red);
  background: #fff0ed;
}

.status.ok {
  color: var(--green);
  background: #edf9f2;
}

.table-wrap {
  overflow: auto;
  max-height: calc(100vh - 270px);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.benchmark-table-wrap {
  max-height: calc(100vh - 430px);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fafc;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 999px;
  background: #eef4fb;
  color: var(--blue);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.badge.warn {
  background: #fff7e6;
  color: #9a6500;
}

.badge.ok {
  background: #edf9f2;
  color: var(--green);
}

.badge.high {
  background: #fff0ed;
  color: var(--red);
}

.badge.medium {
  background: #fff7e6;
  color: #9a6500;
}

.badge.low {
  background: #edf9f2;
  color: var(--green);
}

.handoff-note {
  margin: -4px 0 14px;
  padding: 12px 14px;
  border-left: 4px solid var(--blue);
  background: #fff;
  border-radius: 8px;
}

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

.accuracy-grid article {
  padding: 20px;
}

.accuracy-main {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, .92);
}

.benchmark-metrics {
  margin: 0 0 12px;
}

.benchmark-metrics strong {
  font-size: 28px;
}

.accuracy-cards {
  margin-top: 16px;
}

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

.guide-main {
  max-width: 1180px;
  margin: 0 auto;
}

.guide-hero,
.guide-section {
  margin-bottom: 18px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, .94);
  box-shadow: var(--shadow);
}

.guide-hero h2 {
  font-size: clamp(34px, 5vw, 58px);
}

.guide-section h3 {
  margin-bottom: 14px;
  font-size: 24px;
}

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

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

.guide-grid article {
  display: grid;
  gap: 8px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.guide-grid strong,
.step-list strong {
  font-size: 16px;
}

.guide-grid span,
.step-list span {
  color: var(--muted);
  line-height: 1.55;
}

.step-list {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  counter-reset: guide-step;
  list-style: none;
}

.step-list li {
  display: grid;
  grid-template-columns: 48px minmax(160px, .35fr) minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.step-list li::before {
  counter-increment: guide-step;
  content: counter(guide-step);
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-weight: 900;
}

.step-list.compact li {
  grid-template-columns: 48px minmax(160px, .3fr) minmax(0, 1fr);
}

.guide-warning {
  border-color: #f2c36b;
  background: #fff8e8;
}

.guide-warning p {
  color: #6b4a00;
  font-size: 18px;
  line-height: 1.55;
}

code {
  padding: 2px 5px;
  border-radius: 5px;
  background: #edf2f7;
  color: var(--ink);
}

@media (max-width: 920px) {
  .topbar,
  .view-head,
  .band {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar {
    position: static;
  }

  .hero,
  .band,
  .design-layout,
  .design-grid,
  .design-output,
  .estimating-panel,
  .ledger-layout,
  .accuracy-layout,
  .accuracy-grid,
  .guide-grid {
    grid-template-columns: 1fr;
  }

  .step-list li,
  .step-list.compact li {
    grid-template-columns: 42px minmax(0, 1fr);
  }

  .step-list span {
    grid-column: 2;
  }

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

  iframe {
    height: 72vh;
  }
}

@media (max-width: 560px) {
  main {
    padding: 14px;
  }

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

  .brand-block {
    min-width: 0;
  }
}
