:root {
  color-scheme: light;
  --ink: #111827;
  --muted: #607089;
  --line: #d5deea;
  --soft: #f3f7fc;
  --panel: #ffffff;
  --navy: #07111f;
  --blue: #0057ff;
  --ice: #55d7ff;
  --teal: #047c91;
  --green: #16834a;
  --amber: #b66a00;
  --red: #c1352b;
  --violet: #6d43bf;
  --shadow: 0 16px 45px rgba(7, 17, 31, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(0, 87, 255, 0.08), rgba(243, 247, 252, 0) 260px),
    #eef3f8;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 12px;
  color: var(--ink);
  background: var(--panel);
  cursor: pointer;
}

button:hover {
  border-color: var(--blue);
}

button.primary {
  color: white;
  border-color: var(--blue);
  background: var(--blue);
}

.app-shell {
  width: min(1420px, calc(100vw - 32px));
  margin: 0 auto;
}

header.app-shell {
  padding-top: 20px;
}

.brand-row,
.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
}

.brand-row {
  padding: 20px 22px;
  color: white;
  background:
    linear-gradient(135deg, rgba(0, 87, 255, 0.58), rgba(85, 215, 255, 0.08) 42%, rgba(7, 17, 31, 0) 70%),
    var(--navy);
  border-radius: 8px 8px 0 0;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.toolbar,
.tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.brand-row button {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(85, 215, 255, 0.34);
  color: white;
}

.brand-row button:hover {
  border-color: var(--ice);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

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

h1 {
  font-size: clamp(28px, 5vw, 42px);
  letter-spacing: 0;
  line-height: 1;
}

.brand-subtitle {
  margin-top: 8px;
  max-width: 520px;
  color: #c8d8f1;
  font-size: 13px;
}

h2 {
  max-width: 820px;
  font-size: 20px;
  letter-spacing: 0;
  line-height: 1.2;
}

.eyebrow {
  margin-bottom: 5px;
  color: var(--teal);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.brand-row .eyebrow {
  color: var(--ice);
}

.tabs {
  padding: 10px;
  background: #e1e8f2;
  border: 1px solid #cfd7e5;
  border-top: 0;
  border-radius: 0 0 8px 8px;
}

.tab {
  color: var(--muted);
  background: transparent;
}

.tab.is-active {
  color: white;
  background: var(--blue);
  border-color: var(--blue);
}

main.app-shell {
  padding: 18px 0 56px;
}

.view {
  display: none;
  padding: 22px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.view.is-active {
  display: block;
}

.section-head {
  margin-bottom: 18px;
}

.section-head.tight {
  margin-top: 26px;
}

.grid {
  display: grid;
  gap: 14px;
}

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

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

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

.analyze-grid {
  grid-template-columns: minmax(180px, 260px) minmax(220px, 320px) 1fr;
  align-items: start;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

input,
select,
textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 10px;
  color: var(--ink);
  background: white;
  text-transform: none;
  letter-spacing: 0;
}

textarea {
  min-height: 78px;
  resize: vertical;
}

.analysis-text {
  min-height: 260px;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 13px;
  line-height: 1.55;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(0, 87, 255, 0.22);
  border-color: var(--blue);
}

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

.metrics.wide {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin: 0 0 18px;
}

.metrics + .grid {
  margin-top: 18px;
}

.bidder-card,
.metric,
.report-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.bidder-card {
  padding: 14px;
}

.bidder-card header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 0;
  margin-bottom: 12px;
}

.bidder-card h3 {
  font-size: 15px;
}

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

.card-total {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}

.card-total strong {
  display: block;
  font-size: 24px;
  line-height: 1.1;
}

.card-total small,
.metric small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

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

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: white;
}

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

th {
  color: white;
  background: var(--navy);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

td input,
td select,
td textarea {
  min-width: 110px;
}

td textarea {
  min-width: 220px;
}

tr:last-child td {
  border-bottom: 0;
}

.compact th,
.compact td {
  padding: 7px;
}

.mini-button {
  min-height: 30px;
  padding: 0 9px;
}

.danger {
  color: var(--red);
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.pill.inc {
  color: var(--green);
  background: #dcf6e8;
}

.pill.exc {
  color: var(--red);
  background: #ffe4e0;
}

.pill.add,
.pill.tbd,
.pill.partial {
  color: var(--amber);
  background: #fff0d1;
}

.pill.na {
  color: var(--muted);
  background: var(--soft);
}

.pill.excluded {
  color: var(--red);
  background: #ffe4e0;
}

.pill.included {
  color: var(--green);
  background: #dcf6e8;
}

.pill.allowance {
  color: var(--violet);
  background: #eee7ff;
}

.risk-chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 4px;
  padding: 2px 8px;
  color: var(--muted);
  background: var(--soft);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.risk-chip.high {
  color: var(--red);
  background: #ffe4e0;
}

.risk-chip.medium {
  color: var(--amber);
  background: #fff0d1;
}

.risk-chip.low {
  color: var(--green);
  background: #dcf6e8;
}

.metric {
  padding: 16px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  margin-top: 5px;
  font-size: 24px;
  font-variant-numeric: tabular-nums;
}

.report {
  display: grid;
  gap: 18px;
}

.report-hero {
  padding: 22px;
  color: white;
  background: var(--navy);
  border-radius: 8px;
}

.report-hero h2 {
  margin-top: 4px;
  font-size: 28px;
}

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

.report-panel {
  padding: 16px;
}

.report-panel h3 {
  margin-bottom: 10px;
  color: var(--navy);
  font-size: 14px;
  text-transform: uppercase;
}

.report-number {
  font-size: 26px;
  font-weight: 850;
  font-variant-numeric: tabular-nums;
}

.money {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.best {
  color: var(--green);
}

.variance-high {
  color: var(--red);
  font-weight: 800;
}

.download {
  display: none;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  max-width: min(420px, calc(100vw - 36px));
  border: 1px solid rgba(22, 33, 58, 0.18);
  border-radius: 8px;
  padding: 12px 14px;
  color: white;
  background: var(--navy);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.analysis-preview {
  margin-top: 18px;
}

.analysis-preview .report-panel {
  margin-top: 12px;
}

@media (max-width: 940px) {
  .grid.two,
  .grid.three,
  .project-grid,
  .analyze-grid,
  .bidder-grid,
  .metrics,
  .metrics.wide,
  .report-grid {
    grid-template-columns: 1fr;
  }

  .brand-row,
  .section-head {
    align-items: stretch;
    flex-direction: column;
  }
}

@media print {
  body {
    background: white;
  }

  header.app-shell,
  .section-head button,
  .toolbar,
  .tabs,
  #levelingView,
  #riskView {
    display: none !important;
  }

  .app-shell {
    width: 100%;
  }

  main.app-shell {
    padding: 0;
  }

  .view,
  #reportView {
    display: block !important;
    border: 0;
    box-shadow: none;
    padding: 0;
  }
}
