:root {
  --paper: #f7f5ef;
  --surface: #ffffff;
  --ink: #171717;
  --muted: #5f635d;
  --line: #d8d3c8;
  --teal: #0a7a75;
  --teal-ink: #05413f;
  --lime: #d6f264;
  --amber: #f7c948;
  --rose: #d9485f;
  --blue: #2e66a8;
  --shadow: 0 22px 70px rgba(29, 34, 31, 0.12);
  font-family: "Aptos", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(10, 122, 117, 0.12), transparent 34%),
    linear-gradient(315deg, rgba(247, 201, 72, 0.2), transparent 32%),
    var(--paper);
}

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

a {
  color: var(--teal-ink);
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 0 22px;
}

.topbar h1 {
  margin: 2px 0 0;
  font-size: clamp(2rem, 4vw, 4.25rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.hero-hook {
  max-width: 760px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: clamp(1.02rem, 1.4vw, 1.28rem);
  line-height: 1.42;
}

.hero-proof {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.hero-proof span {
  border: 1px solid rgba(10, 122, 117, 0.2);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.68);
  color: var(--teal-ink);
  padding: 7px 10px;
  font-size: 0.78rem;
  font-weight: 850;
}

.eyebrow {
  margin: 0;
  color: var(--teal-ink);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.topbar-actions,
.message-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(360px, 0.88fr) minmax(460px, 1.12fr);
  gap: 16px;
  align-items: start;
}

.trust-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 16px;
  border: 1px solid #b9d8d2;
  border-radius: 8px;
  background: rgba(238, 248, 245, 0.9);
  color: var(--teal-ink);
  padding: 12px 14px;
  line-height: 1.45;
}

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

.quick-guide div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.74);
  padding: 12px;
}

.quick-guide strong,
.quick-guide span {
  display: block;
}

.quick-guide strong {
  color: var(--teal-ink);
  font-size: 0.88rem;
}

.quick-guide span,
.panel-note {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.4;
}

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

.input-panel,
.cases-panel,
.pricing-panel,
.summary-panel,
.message-panel,
.timeline-panel {
  padding: 18px;
}

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

.output-stack {
  display: grid;
  gap: 16px;
}

.section-heading {
  margin-bottom: 14px;
}

.section-heading h2 {
  margin: 4px 0 0;
  font-size: 1.35rem;
  line-height: 1.15;
}

.panel-note {
  margin: 6px 0 0;
}

.form-hint {
  max-width: 48ch;
  margin: 8px 0 0;
  color: rgba(95, 99, 93, 0.78);
  font-size: 0.88rem;
  line-height: 1.45;
}

.inline-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

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

.profile-tools {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
  border-block: 1px solid var(--line);
  padding: 12px 0;
}

.profile-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: end;
}

.helper-card {
  border: 1px solid #d9c783;
  border-radius: 8px;
  background: #fff9df;
  color: #5b4212;
  padding: 11px 12px;
}

.helper-card strong {
  display: block;
  font-size: 0.9rem;
}

.helper-card p {
  margin: 5px 0 0;
  font-size: 0.86rem;
  line-height: 1.45;
}

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

.wide {
  grid-column: 1 / -1;
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
  color: var(--ink);
  padding: 10px 11px;
  outline: none;
  transition: border-color 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

textarea {
  resize: vertical;
}

input::placeholder,
textarea::placeholder {
  color: rgba(95, 99, 93, 0.44);
  font-style: italic;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--teal);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(10, 122, 117, 0.14);
}

.btn,
.segment {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 9px 13px;
  font-weight: 850;
  cursor: pointer;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
}

.btn:hover,
.segment:hover {
  transform: translateY(-1px);
}

.btn.primary {
  color: #fff;
  background: var(--teal);
}

.btn.secondary {
  color: var(--teal-ink);
  background: #eef8f5;
  border-color: #b9d8d2;
}

.btn.locked {
  border-color: #e7d79c;
  background: #fff8dc;
  color: #684910;
}

.pricing-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
}

.pricing-grid strong {
  display: block;
  font-size: 1.45rem;
  line-height: 1.1;
}

.pricing-grid p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.segmented {
  display: inline-grid;
  grid-template-columns: repeat(3, minmax(64px, 1fr));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
}

.segment {
  border-radius: 0;
  background: transparent;
  color: var(--muted);
}

.segment.active {
  color: #062f2d;
  background: var(--lime);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  border-radius: 999px;
  background: #e7f8ef;
  color: #0f5b34;
  padding: 6px 10px;
  font-size: 0.8rem;
  font-weight: 900;
}

.status-pill.warn {
  color: #713f12;
  background: #fff2c2;
}

.status-pill.danger {
  color: #7c1d2f;
  background: #ffe1e7;
}

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

.totals-grid div,
.facts-grid div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
  padding: 12px;
}

.totals-grid span,
.facts-grid dt {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 850;
}

.totals-grid strong {
  display: block;
  margin-top: 6px;
  font-size: clamp(1.05rem, 1.7vw, 1.45rem);
  line-height: 1.1;
}

.totals-grid .grand-total {
  background: #102f2d;
  color: #ffffff;
  border-color: #102f2d;
}

.totals-grid .grand-total span {
  color: #cdece5;
}

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

.facts-grid dd {
  margin: 6px 0 0;
  font-size: 0.98rem;
  font-weight: 900;
}

.warnings {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

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

.case-stat {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
  padding: 10px 12px;
}

.case-stat span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 850;
}

.case-stat strong {
  display: block;
  margin-top: 5px;
  font-size: 1.02rem;
  line-height: 1.15;
}

.case-filters {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(150px, 0.35fr) auto;
  gap: 10px;
  align-items: end;
  margin: 0 0 12px;
}

.case-list {
  display: grid;
  gap: 10px;
}

.case-empty {
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #fffdf8;
  padding: 16px;
  line-height: 1.45;
}

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

.case-title {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 5px;
}

.case-title strong {
  font-size: 1rem;
}

.case-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: #e7f8ef;
  color: #0f5b34;
  padding: 4px 8px;
  font-size: 0.72rem;
  font-weight: 900;
}

.case-pill.warn {
  color: #713f12;
  background: #fff2c2;
}

.case-pill.danger {
  color: #7c1d2f;
  background: #ffe1e7;
}

.case-pill.paid {
  color: #0f4c2d;
  background: #dff7e8;
}

.case-meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.82rem;
}

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

.case-row.paid {
  border-color: #b7ddc5;
  background: #f4fff8;
}

.case-row:has(.case-pill.danger) {
  border-color: #f1a9b5;
}

.case-row:has(.case-pill.warn) {
  border-color: #efd88d;
}

.case-status-select {
  width: auto;
  min-width: 130px;
  min-height: 34px;
  padding: 7px 10px;
  font-size: 0.82rem;
  font-weight: 850;
}

.case-payment-input {
  width: 96px;
  min-height: 34px;
  padding: 7px 9px;
  font-size: 0.82rem;
}

.case-payment-date {
  width: 138px;
  min-height: 34px;
  padding: 7px 9px;
  font-size: 0.82rem;
}

.btn.tiny {
  min-height: 34px;
  padding: 7px 10px;
  font-size: 0.82rem;
}

.warning {
  border-left: 4px solid var(--amber);
  border-radius: 8px;
  background: #fff8de;
  padding: 9px 11px;
  color: #5b4212;
  font-size: 0.88rem;
  line-height: 1.4;
}

.warning.danger {
  border-color: var(--rose);
  background: #ffe9ed;
  color: #7c1d2f;
}

.subject-label {
  margin-top: 12px;
}

.send-workflow {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.send-group {
  display: grid;
  grid-template-columns: 118px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
  padding: 10px;
}

.send-group-title {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.send-final {
  border-color: #b9d8d2;
  background: #f3fbf8;
}

.send-checklist-wrap {
  display: grid;
  gap: 9px;
  margin-top: 12px;
  border: 1px dashed #c9c0ad;
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.72);
  padding: 11px;
}

.send-checklist-wrap strong {
  color: var(--ink);
  font-size: 0.9rem;
}

.send-checklist-wrap p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.35;
}

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

.send-checklist label {
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
  padding: 9px 10px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.25;
}

.send-checklist input {
  width: auto;
  margin: 0;
  accent-color: var(--teal);
}

.message-body {
  min-height: 360px;
  margin-top: 10px;
  line-height: 1.5;
}

.timeline {
  display: grid;
  gap: 10px;
  margin: 0;
  padding-left: 22px;
}

.timeline li {
  border-bottom: 1px solid var(--line);
  padding: 0 0 10px;
  line-height: 1.45;
}

.timeline li:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.source-note {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.5;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: min(380px, calc(100vw - 40px));
  transform: translateY(18px);
  opacity: 0;
  pointer-events: none;
  border-radius: 8px;
  background: #171717;
  color: #ffffff;
  padding: 12px 14px;
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.22);
  transition: transform 180ms ease, opacity 180ms ease;
  z-index: 10;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.success-shell {
  width: min(720px, calc(100vw - 32px));
  min-height: 100vh;
  display: grid;
  place-items: center;
  margin: 0 auto;
}

.legal-shell {
  width: min(860px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 40px 0;
}

.success-panel {
  padding: 28px;
}

.legal-panel,
.success-panel {
  padding: 28px;
}

.legal-panel h1,
.success-panel h1 {
  margin: 4px 0 12px;
  font-size: clamp(2rem, 5vw, 4rem);
  line-height: 1;
}

.legal-panel h2 {
  margin: 26px 0 8px;
  font-size: 1.15rem;
}

.legal-panel p,
.success-panel p {
  color: var(--muted);
  line-height: 1.55;
}

.site-footer {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: center;
  padding: 22px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

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

  .input-panel {
    position: static;
  }
}

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

  .topbar,
  .inline-heading,
  .trust-banner {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions,
  .message-actions {
    justify-content: stretch;
  }

  .btn {
    flex: 1 1 150px;
  }

  .form-grid,
  .totals-grid,
  .facts-grid,
  .case-stats,
  .case-row,
  .profile-row,
  .case-filters,
  .send-checklist,
  .quick-guide {
    grid-template-columns: 1fr;
  }

  .case-actions {
    justify-content: stretch;
  }

  .case-status-select {
    width: 100%;
  }

  .send-group {
    grid-template-columns: 1fr;
  }

  .case-payment-input,
  .case-payment-date {
    width: 100%;
  }

  .segmented {
    width: 100%;
  }

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

@media print {
  body {
    background: #ffffff;
  }

  .topbar-actions,
  .input-panel,
  .message-actions,
  .segmented,
  .toast {
    display: none !important;
  }

  .app-shell {
    width: 100%;
    padding: 0;
  }

  .workspace {
    display: block;
  }

  .panel {
    border: 1px solid #bbbbbb;
    box-shadow: none;
    break-inside: avoid;
    margin-bottom: 14px;
  }

  .output-stack {
    display: block;
  }
}
