:root {
  --primary: #155e63;
  --secondary: #e8f1f2;
  --background: #f6f8f9;
  --surface: #ffffff;
  --text: #1f2933;
  --warning: #d97706;
  --danger: #b91c1c;
  --success: #15803d;
  --muted: #6b7280;
  --line: #dde6e8;
  --soft: #f9fbfb;
  --shadow: 0 18px 50px rgba(31, 41, 51, 0.09);
  --radius-sm: 12px;
  --radius-md: 16px;
  --radius-lg: 20px;
  --space-1: 6px;
  --space-2: 10px;
  --space-3: 14px;
  --space-4: 18px;
  --space-5: 24px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--background);
  color: var(--text);
  font-family: Inter, Manrope, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
}

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

button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  padding: 0 14px;
}

button:hover {
  border-color: #b8c7cc;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(21, 94, 99, 0.24);
  outline-offset: 2px;
}

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

.primary {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
  font-weight: 700;
}

.subtle {
  background: var(--secondary);
  border-color: var(--secondary);
  color: var(--primary);
  font-weight: 700;
}

.danger {
  border-color: #f1d7d7;
  color: var(--danger);
}

.app {
  min-height: 100vh;
  padding-bottom: 76px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(246, 248, 249, 0.92);
  backdrop-filter: blur(14px);
  padding: 18px clamp(16px, 3vw, 36px);
}

.brand h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0;
}

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

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

.demo-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border-bottom: 1px solid #f4d59a;
  background: #fff8ef;
  color: #70410b;
  padding: 12px clamp(16px, 3vw, 36px);
}

.demo-banner span {
  color: #70410b;
}

.demo-banner button {
  min-height: 36px;
  border-color: #f0c36d;
  background: #fff;
  color: #70410b;
  font-weight: 700;
}

.shell {
  display: grid;
  grid-template-columns: minmax(240px, 280px) minmax(280px, 320px) minmax(0, 1fr);
  gap: 16px;
  padding: 18px clamp(16px, 3vw, 36px) 32px;
}

.shell.guide-hidden {
  grid-template-columns: minmax(280px, 320px) minmax(0, 1fr);
}

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

.panel {
  min-width: 0;
  padding: var(--space-4);
}

.guide-panel {
  position: sticky;
  top: 92px;
  max-height: calc(100vh - 116px);
  overflow: auto;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-head h2,
.section-title,
.case-title h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
}

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

.accordion {
  display: grid;
  gap: 10px;
}

details {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--soft);
  padding: 12px;
}

summary {
  cursor: pointer;
  font-weight: 700;
}

details p,
details li {
  color: var(--muted);
  line-height: 1.45;
}

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

.case-card {
  width: 100%;
  display: block;
  min-height: 108px;
  text-align: left;
  padding: 14px;
}

.case-card.active {
  border-color: var(--primary);
  box-shadow: inset 4px 0 0 var(--primary);
}

.case-card strong,
.case-card span {
  display: block;
}

.case-card span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 14px;
}

.case-main {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.hero-case {
  padding: 22px;
}

.case-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.case-title p {
  margin: 7px 0 0;
  color: var(--muted);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 999px;
  background: #edf3f5;
  color: #36525a;
  font-size: 13px;
  font-weight: 800;
  padding: 0 11px;
}

.status-pill.amber {
  background: #fff7ed;
  color: var(--warning);
}

.status-pill.green {
  background: #ecfdf3;
  color: var(--success);
}

.status-pill.neutral {
  background: #f3f4f6;
  color: #4b5563;
}

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

.alert {
  border-left: 4px solid var(--warning);
  border-radius: 14px;
  background: #fff8ef;
  color: #70410b;
  line-height: 1.45;
  padding: 12px 14px;
}

.alert.danger {
  border-left-color: var(--danger);
  background: #fff5f5;
  color: #7f1d1d;
}

.grid {
  display: grid;
  grid-template-columns: minmax(260px, 0.85fr) minmax(360px, 1.45fr);
  gap: 14px;
}

.recommended {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--soft);
  padding: 16px;
}

.recommended h3 {
  margin: 0;
  font-size: 16px;
}

.recommended p {
  color: var(--muted);
  line-height: 1.45;
}

.pricing-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--secondary);
  padding: 18px;
}

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

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

.pricing-card h2 {
  margin: 0;
  font-size: 22px;
}

.pricing-card button {
  margin-top: 14px;
}

.price-line {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.price-line strong {
  color: var(--primary);
  font-size: 34px;
  line-height: 1;
}

.price-line span {
  color: var(--primary);
  font-weight: 700;
}

.other-actions {
  margin-top: 14px;
}

.other-actions summary {
  color: var(--primary);
}

.action-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.letter-box textarea {
  width: 100%;
  min-height: 390px;
  border: 1px solid var(--line);
  border-radius: 16px;
  resize: vertical;
  padding: 14px;
  line-height: 1.55;
}

.letter-tools,
.mini-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

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

.metric {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--soft);
  padding: 13px;
}

.metric strong {
  display: block;
  font-size: 19px;
}

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

.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.timeline li {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--soft);
  padding: 12px 12px 12px 42px;
}

.timeline li::before {
  content: "";
  position: absolute;
  left: 14px;
  top: 16px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--primary);
}

.timeline time,
.document-meta {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 4px;
}

.document-zone {
  border: 1.5px dashed #adc4ca;
  border-radius: 18px;
  background: #fbfdfd;
  padding: 18px;
  text-align: center;
}

.document-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 170px;
  gap: 10px;
  margin-bottom: 12px;
}

.document-zone.drag {
  border-color: var(--primary);
  background: var(--secondary);
}

.document-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.document-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px;
}

.document-preview {
  max-width: 100%;
  max-height: 180px;
  border-radius: 12px;
  margin-top: 10px;
}

dialog {
  width: min(620px, calc(100vw - 24px));
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 0;
}

dialog::backdrop {
  background: rgba(31, 41, 51, 0.44);
}

form {
  display: grid;
  gap: 13px;
  padding: 20px;
}

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  padding: 11px 12px;
}

.checkbox {
  grid-template-columns: auto 1fr;
  align-items: center;
  color: var(--text);
  font-weight: 500;
}

.checkbox input {
  width: 18px;
  height: 18px;
}

.bottom-nav {
  display: none;
}

.notification-system {
  position: fixed;
  z-index: 80;
  right: 18px;
  bottom: 18px;
  display: grid;
  gap: 10px;
  width: min(360px, calc(100vw - 36px));
}

.toast {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--primary);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 12px;
}

.toast.success {
  border-left-color: var(--success);
}

.toast.warning {
  border-left-color: var(--warning);
}

.toast button {
  min-height: 32px;
  width: 32px;
  padding: 0;
}

.mobile-only {
  display: none;
}

.empty-state {
  display: grid;
  min-height: 280px;
  place-content: center;
  text-align: center;
}

.skeleton {
  position: relative;
  overflow: hidden;
  background: var(--secondary);
}

.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.65), transparent);
  animation: shimmer 1.4s infinite;
}

@keyframes shimmer {
  100% {
    transform: translateX(100%);
  }
}

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

.lock-card {
  width: min(430px, 100%);
  padding: 24px;
}

.legal-gate {
  align-items: start;
  padding: 32px 18px;
}

.legal-card {
  width: min(760px, 100%);
  padding: 26px;
}

.legal-card h1 {
  margin: 0 0 10px;
  font-size: 28px;
}

.legal-card p {
  color: var(--muted);
  line-height: 1.5;
}

.legal-text {
  max-height: 42vh;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--soft);
  margin: 18px 0;
  padding: 16px;
}

.legal-text h2 {
  margin: 0 0 10px;
  font-size: 18px;
}

.legal-text li {
  color: var(--text);
  line-height: 1.5;
  margin-bottom: 10px;
}

@media (max-width: 1100px) {
  .shell,
  .shell.guide-hidden {
    grid-template-columns: 1fr;
  }

  .guide-panel {
    position: static;
    max-height: none;
  }

  .grid,
  .metrics {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .demo-banner {
    align-items: stretch;
    flex-direction: column;
    text-align: left;
  }

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

  .top-actions {
    width: 100%;
  }

  .top-actions button {
    flex: 1 1 46%;
  }

  .document-toolbar {
    grid-template-columns: 1fr;
  }

  .shell {
    padding: 12px 12px 88px;
  }

  .case-heading {
    flex-direction: column;
  }

  .case-actions {
    justify-content: flex-start;
  }

  .guide-panel.mobile-drawer {
    position: fixed;
    inset: 0;
    z-index: 50;
    max-height: none;
    overflow: auto;
    border-radius: 0;
  }

  .bottom-nav {
    position: fixed;
    z-index: 40;
    left: 10px;
    right: 10px;
    bottom: 10px;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    border: 1px solid var(--line);
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.94);
    box-shadow: var(--shadow);
    padding: 8px;
  }

  .bottom-nav button {
    min-height: 46px;
    padding: 0 8px;
    font-size: 13px;
  }

  .notification-system {
    left: 10px;
    right: 10px;
    bottom: 76px;
    width: auto;
  }
}

@media print {
  body * {
    visibility: hidden;
  }

  .letter-box,
  .letter-box * {
    visibility: visible;
  }

  .letter-box {
    position: absolute;
    inset: 0;
    border: 0;
    box-shadow: none;
  }

  .letter-tools {
    display: none;
  }

  .letter-box textarea {
    border: 0;
    min-height: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.001ms !important;
  }
}
