:root {
  --bg: #f6f7f2;
  --ink: #1d2522;
  --muted: #64716c;
  --line: #d8ddd5;
  --panel: #ffffff;
  --accent: #0f766e;
  --accent-strong: #0b5d55;
  --warm: #d97706;
  --soft: #e8f4f1;
  --shadow: 0 18px 60px rgba(29, 37, 34, 0.1);
}

* {
  box-sizing: border-box;
}

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

button,
input,
textarea {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  padding: 32px;
}

.workspace {
  width: min(1180px, 100%);
  margin: 0 auto;
}

.toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  max-width: 680px;
  font-size: clamp(2rem, 5vw, 4.3rem);
  line-height: 0.98;
  letter-spacing: 0;
}

.status-pill {
  flex: 0 0 auto;
  min-width: 104px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--accent-strong);
  font-size: 0.9rem;
  font-weight: 700;
  text-align: center;
}

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

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

.controls {
  display: grid;
  gap: 18px;
  padding: 20px;
}

fieldset {
  display: grid;
  gap: 14px;
  min-width: 0;
  margin: 0;
  padding: 0 0 18px;
  border: 0;
  border-bottom: 1px solid var(--line);
}

fieldset:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

legend {
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

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

.input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  color: var(--muted);
}

input[type="number"],
input[type="text"] {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-weight: 800;
}

textarea {
  width: 100%;
  min-width: 0;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  color: var(--ink);
  font-weight: 700;
  line-height: 1.5;
  outline: 0;
  padding: 10px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eef2ed;
}

.segmented label {
  display: block;
  cursor: pointer;
}

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

.segmented span {
  display: flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
}

.segmented input:checked + span {
  background: var(--accent);
  color: #fff;
}

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

.results {
  display: grid;
  gap: 14px;
  padding: 20px;
}

.metric {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.metric.primary {
  background: var(--soft);
  border-color: #b8dad3;
}

.metric span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.metric strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: clamp(1.4rem, 4vw, 2.8rem);
  line-height: 1;
}

.metric-grid .metric strong {
  font-size: clamp(1.1rem, 2.4vw, 1.55rem);
}

.insight {
  padding: 16px;
  border-left: 4px solid var(--warm);
  background: #fff8ec;
}

.insight h2,
.next-action h2,
.draft-box h2 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.insight p {
  margin: 0;
  color: #5f4630;
  line-height: 1.6;
}

.next-action {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 16px;
  border: 1px solid #b8dad3;
  border-radius: 8px;
  background: var(--soft);
}

.next-action p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

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

.action-button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.action-button.primary {
  background: var(--accent);
  color: #fff;
}

.action-button.secondary {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

button.action-button {
  border: 0;
  cursor: pointer;
}

.draft-box {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.draft-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
}

.draft-head p,
.copy-status {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

#listingDraft {
  min-height: 360px;
  background: #fff;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.9rem;
  font-weight: 500;
}

.copy-status {
  min-height: 22px;
  font-size: 0.86rem;
  font-weight: 700;
}

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

table {
  width: 100%;
  min-width: 520px;
  border-collapse: collapse;
  background: #fff;
}

th,
td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
}

th:first-child,
td:first-child {
  text-align: left;
}

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

th {
  color: var(--muted);
  font-size: 0.82rem;
}

td {
  font-weight: 750;
}

@media (max-width: 820px) {
  .app-shell {
    padding: 18px;
  }

  .toolbar,
  .layout {
    display: grid;
  }

  .toolbar {
    align-items: start;
  }

  .status-pill {
    justify-self: start;
  }

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

@media (max-width: 520px) {
  .fee-grid,
  .metric-grid,
  .next-action,
  .draft-head {
    grid-template-columns: 1fr;
  }

  .action-row {
    justify-content: stretch;
  }

  .action-button {
    flex: 1 1 150px;
  }

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