:root {
  --bg: #f6f4ef;
  --ink: #1f2a2e;
  --muted: #647174;
  --line: #d9ddd6;
  --panel: #ffffff;
  --accent: #0b6b68;
  --accent-strong: #084f4d;
  --warn: #9a5b12;
  --good: #18764d;
  --bad: #9b2c2c;
}

* {
  box-sizing: border-box;
}

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

body.locked .shell {
  display: none;
}

body:not(.locked) .authGate {
  display: none;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  border-radius: 6px;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 700;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.authGate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.authPanel {
  width: min(980px, 100%);
  display: grid;
  gap: 24px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.authCopy,
.authStatus,
.storeLabel {
  margin: 6px 0 0;
  color: var(--muted);
}

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

.authForms form,
.boughtForm {
  display: grid;
  gap: 10px;
}

.authForms form {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafaf8;
}

.authForms label,
.boughtForm label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
}

h1 {
  font-size: 34px;
}

h2 {
  font-size: 18px;
}

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

.primary {
  color: white;
  background: var(--accent);
}

.primary:hover {
  background: var(--accent-strong);
}

.ghost {
  color: var(--ink);
  border: 1px solid var(--line);
  background: white;
}

.grid {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 18px;
  align-items: start;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 1px 2px rgba(31, 42, 46, 0.04);
}

.controls {
  position: sticky;
  top: 18px;
  padding: 16px;
}

.upload {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px dashed #9fb2ad;
  border-radius: 8px;
  background: #f4fbf9;
  font-weight: 800;
}

.upload input {
  width: 100%;
}

.settings {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.settings label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

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

.summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 18px;
}

.summary div {
  padding: 12px;
  border-radius: 8px;
  background: #eef2ed;
}

.summary strong,
.summary span {
  display: block;
}

.summary strong {
  font-size: 24px;
}

.summary span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.note {
  margin-top: 18px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.workarea {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.tablepanel {
  min-height: 380px;
}

.sectionhead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.sectionhead p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.sectionhead input {
  max-width: 290px;
}

.tablewrap {
  overflow: auto;
  max-height: 460px;
}

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

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

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

tr {
  cursor: pointer;
}

tbody tr:hover,
tbody tr.active {
  background: #eef8f6;
}

.subtext {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #eef2ed;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.pill.ready {
  color: var(--good);
  background: #eaf7ef;
}

.pill.review {
  color: var(--warn);
  background: #fff4df;
}

.detailgrid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(360px, 0.9fr);
  gap: 18px;
}

.detail,
.offer {
  min-height: 330px;
}

.complist {
  display: grid;
  gap: 10px;
  padding: 16px;
  max-height: 430px;
  overflow: auto;
}

.comp {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.comp strong {
  font-size: 18px;
}

.offer {
  padding: 16px;
}

.offerSheet {
  min-height: 250px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
}

.offerSheet h2 {
  font-size: 22px;
}

.offerAmount {
  margin: 20px 0;
  color: var(--accent);
  font-size: 42px;
  font-weight: 900;
}

.signature {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 24px;
  color: var(--muted);
  font-size: 13px;
}

.messageTools {
  display: flex;
  gap: 10px;
  margin: 14px 0 10px;
}

.messageTools button {
  border: 1px solid var(--line);
  background: white;
}

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

.boughtForm {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.boughtForm button {
  color: white;
  background: var(--good);
}

.reports {
  min-height: 170px;
}

.segment {
  display: flex;
  gap: 6px;
}

.segment button {
  min-width: 48px;
  border: 1px solid var(--line);
  background: white;
}

.segment button.active {
  color: white;
  border-color: var(--accent);
  background: var(--accent);
}

.reportCards {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 10px;
  padding: 16px;
}

.metric {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafaf8;
}

.metric strong,
.metric span {
  display: block;
}

.metric strong {
  font-size: 24px;
}

.metric span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

@media (max-width: 1000px) {
  .topbar,
  .grid,
  .detailgrid,
  .authForms {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }

  .controls {
    position: static;
  }
}

@media (max-width: 760px) {
  .reportCards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media print {
  body {
    background: white;
  }

  .topbar,
  .controls,
  .tablepanel,
  .detail,
  .messageTools,
  textarea {
    display: none;
  }

  .shell,
  .offer,
  .offerSheet {
    width: 100%;
    padding: 0;
    border: 0;
    box-shadow: none;
  }

  .grid,
  .workarea,
  .detailgrid {
    display: block;
  }
}
