:root {
  color-scheme: light;
  --ink: #18201f;
  --muted: #68706d;
  --line: #dbe2de;
  --surface: #ffffff;
  --wash: #f4f7f5;
  --teal: #0f766e;
  --teal-dark: #0b514c;
  --green: #2f7d32;
  --amber: #9a6700;
  --red: #b42318;
  --blue: #2458a6;
  --shadow: 0 18px 50px rgb(24 32 31 / 8%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--wash);
  color: var(--ink);
}

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

button {
  border: 0;
  border-radius: 7px;
  background: var(--teal);
  color: white;
  cursor: pointer;
  font-weight: 700;
  min-height: 40px;
  padding: 0 14px;
}

button:hover {
  background: var(--teal-dark);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: white;
  color: var(--ink);
  min-height: 40px;
  padding: 9px 10px;
}

textarea {
  resize: vertical;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.shell {
  width: min(1480px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 42px;
}

.topbar,
.panel-heading,
.proposal-header,
.line-main,
.line-totals,
.proposal-lines li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.topbar {
  margin-bottom: 18px;
}

.topbar h1,
.panel h2,
.proposal h2,
.proposal h3 {
  margin: 0;
  letter-spacing: 0;
}

.topbar h1 {
  font-size: clamp(1.8rem, 3vw, 3rem);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--teal);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-select {
  min-width: 132px;
}

.save-state {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.icon-button {
  min-width: 72px;
}

.quiet {
  background: #eef3f1;
  color: var(--ink);
}

.quiet:hover {
  background: #e2ebe7;
}

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

.metric,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metric {
  display: grid;
  gap: 4px;
  min-height: 104px;
  padding: 16px;
}

.metric span,
.metric small {
  color: var(--muted);
}

.metric strong {
  font-size: 1.65rem;
}

.metric.good {
  border-color: rgb(47 125 50 / 35%);
}

.metric.warn {
  border-color: rgb(154 103 0 / 35%);
}

.metric.bad {
  border-color: rgb(180 35 24 / 35%);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(280px, 0.95fr) minmax(420px, 1.45fr) minmax(330px, 0.95fr);
  align-items: start;
  gap: 16px;
}

.panel {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.loading-panel {
  min-height: 160px;
  place-items: center;
  color: var(--muted);
  font-weight: 800;
}

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

.line-grid {
  grid-template-columns: repeat(5, minmax(74px, 1fr));
}

.upload input {
  padding: 8px;
}

.photo-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.photo-strip img {
  aspect-ratio: 1.2 / 1;
  width: 100%;
  border-radius: 7px;
  object-fit: cover;
}

.line-items {
  display: grid;
  gap: 12px;
}

.line-item {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.line-main input {
  font-weight: 800;
}

.line-totals {
  justify-content: flex-start;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

.price-book {
  display: grid;
  gap: 10px;
}

.price-book h3 {
  margin: 0;
}

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

.price-book-item {
  display: grid;
  gap: 4px;
  min-height: 76px;
  border: 1px solid var(--line);
  background: #f8faf9;
  color: var(--ink);
  text-align: left;
}

.price-book-item:hover {
  border-color: rgb(15 118 110 / 40%);
  background: #eef7f5;
}

.price-book-item span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 650;
}

.proposal-panel {
  position: sticky;
  top: 16px;
}

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

.proposal p,
.proposal ul {
  margin: 0;
  color: #3f4946;
  line-height: 1.5;
}

.proposal ul {
  padding-left: 18px;
}

.status-pill,
.margin-banner {
  border-radius: 999px;
  padding: 7px 10px;
  font-size: 0.78rem;
  font-weight: 800;
}

.status-pill {
  background: #eef3f1;
}

.proposal-total {
  display: flex;
  align-items: end;
  justify-content: space-between;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 16px 0;
}

.proposal-total strong {
  font-size: 2rem;
}

.margin-banner.good {
  background: rgb(47 125 50 / 12%);
  color: var(--green);
}

.margin-banner.warn {
  background: rgb(154 103 0 / 14%);
  color: var(--amber);
}

.margin-banner.bad {
  background: rgb(180 35 24 / 12%);
  color: var(--red);
}

.proposal-lines {
  display: grid;
  gap: 8px;
  padding-left: 0;
  list-style: none;
}

.proposal-lines li {
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}

.follow-up {
  border-left: 3px solid var(--blue);
  padding-left: 10px;
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 1fr 1fr;
  }

  .proposal-panel {
    position: static;
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .shell {
    width: min(100% - 20px, 1480px);
    padding-top: 14px;
  }

  .topbar,
  .topbar-actions,
  .workspace,
  .metrics,
  .field-row,
  .line-grid,
  .price-book-grid {
    grid-template-columns: 1fr;
  }

  .topbar,
  .topbar-actions {
    display: grid;
    align-items: stretch;
  }

  .metrics,
  .workspace {
    display: grid;
  }

  .line-main,
  .line-totals {
    align-items: stretch;
    flex-direction: column;
  }
}

@media print {
  body {
    background: white;
  }

  .topbar,
  .metrics,
  .job-panel,
  .workspace > .panel:nth-child(2) {
    display: none;
  }

  .shell,
  .workspace,
  .proposal-panel {
    display: block;
    width: 100%;
    margin: 0;
    padding: 0;
    box-shadow: none;
  }

  .proposal-panel {
    border: 0;
  }
}
