:root {
  --red: #f52222;
  --red-dark: #d71919;
  --dark: #2f2f2f;
  --text: #333333;
  --muted: #747474;
  --line: #e6e6e6;
  --bg: #f5f5f5;
  --surface: #ffffff;
  --blue: #0b6fae;
  --teal: #16a085;
  --amber: #b26a00;
  --shadow: 0 8px 18px rgba(40, 40, 40, 0.08);
  --soft-shadow: 0 2px 8px rgba(40, 40, 40, 0.06);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Montserrat", "Helvetica Neue", Arial, sans-serif;
  font-size: 13px;
  line-height: 1.35;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
a:focus-visible,
label:focus-within {
  outline: 3px solid rgba(245, 34, 34, 0.28);
  outline-offset: 3px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(210px, 320px) auto;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 52px;
  padding: 6px 24px;
  background: var(--dark);
  color: #ffffff;
  box-shadow: 0 2px 14px rgba(0, 0, 0, 0.18);
}

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

.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 60% 45%, transparent 0 22%, #22b59f 23% 31%, transparent 32%),
    conic-gradient(from 215deg, #19a68e, #58d0c0, #19a68e, transparent 76%);
  border: 3px solid #ffffff;
}

.brand-name {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0;
}

.brand-caption {
  color: #cfcfcf;
  font-size: 9px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.primary-button,
.secondary-button,
.copy-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 34px;
  border-radius: 4px;
  border: 1px solid transparent;
  font-weight: 700;
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease;
}

.primary-button {
  padding: 0 14px;
  background: var(--red);
  color: #ffffff;
  box-shadow: 0 10px 20px rgba(245, 34, 34, 0.22);
}

.primary-button:hover,
.copy-button:hover {
  background: var(--red-dark);
  transform: translateY(-1px);
}

.secondary-button {
  padding: 0 12px;
  background: #ffffff;
  color: var(--text);
  border-color: var(--line);
}

.secondary-button:hover {
  box-shadow: var(--soft-shadow);
  transform: translateY(-1px);
}

.copy-button {
  padding: 0 12px;
  background: var(--red);
  color: #ffffff;
  white-space: nowrap;
}

.icon-button {
  width: 34px;
  padding: 0;
  color: var(--muted);
  background: #ffffff;
  border-color: var(--line);
}

svg {
  width: 16px;
  height: 16px;
  stroke-width: 2.2;
}

.app-layout {
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr);
  gap: 12px;
  max-width: 1680px;
  margin: 0 auto;
  padding: 12px 20px 28px;
}

.case-list,
.workspace > section,
.case-hero {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 5px;
  box-shadow: var(--soft-shadow);
}

.case-list {
  align-self: start;
  padding: 12px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  color: var(--dark);
  font-size: 14px;
  font-weight: 700;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 0 9px;
  margin-bottom: 8px;
  background: #fafafa;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--muted);
}

.search-box input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 12px;
}

.case-counts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 8px;
}

.case-counts span {
  min-height: 32px;
  padding: 6px 8px;
  background: #fbfbfb;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--muted);
  font-size: 11px;
}

.case-counts strong {
  color: var(--text);
}

.case-row {
  display: grid;
  grid-template-columns: 10px 1fr;
  gap: 9px;
  width: 100%;
  min-height: 58px;
  padding: 9px 8px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.case-row + .case-row {
  margin-top: 6px;
}

.case-row.active,
.case-row:hover {
  background: #fafafa;
  border-color: var(--line);
}

.case-row strong,
.case-row small {
  display: block;
}

.case-row strong {
  font-size: 12px;
}

.case-row small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.case-row em {
  display: block;
  margin-top: 4px;
  color: var(--amber);
  font-size: 10px;
  font-style: normal;
  font-weight: 700;
}

.case-status {
  width: 8px;
  height: 8px;
  margin-top: 5px;
  border-radius: 50%;
}

.status-progress {
  background: var(--teal);
}

.status-wait {
  background: #c7c7c7;
}

.workspace {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.case-hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 12px;
  padding: 14px 16px 14px 22px;
  overflow: hidden;
  box-shadow: var(--soft-shadow);
}

.accent-corner {
  position: absolute;
  inset: 0 auto auto 0;
  width: 34px;
  height: 34px;
  background: var(--red);
  clip-path: polygon(0 0, 100% 0, 0 100%);
}

.eyebrow {
  color: var(--red);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  max-width: 880px;
  margin-top: 2px;
  color: #202020;
  font-size: clamp(20px, 2vw, 26px);
  line-height: 1.12;
  font-weight: 600;
  overflow-wrap: anywhere;
}

h2 {
  color: #252525;
  font-size: 18px;
  line-height: 1.2;
}

.case-title-group p,
.upload-copy p,
.letter-preview p {
  max-width: 780px;
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.case-headline {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

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

.case-facts div {
  min-height: 50px;
  padding: 7px 8px;
  background: #fbfbfb;
  border: 1px solid var(--line);
  border-radius: 4px;
}

.case-facts dt {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.case-facts dd {
  margin: 3px 0 0;
  color: #202020;
  font-size: 12px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.case-facts .needs-confirm {
  background: #fff8eb;
  border-color: #ffd89c;
}

.case-facts dd span {
  display: inline-block;
  margin-left: 3px;
  color: var(--amber);
  font-size: 10px;
}

.case-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.case-meta span {
  min-height: 24px;
  padding: 4px 7px;
  color: #4f4f4f;
  background: #f7f7f7;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
}

.hero-tools {
  display: grid;
  align-content: start;
  gap: 6px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.status-pill.ok {
  color: #0c6b55;
  background: #e8f7f2;
}

.status-pill.warning {
  color: #8a5300;
  background: #fff2db;
}

.status-pill.danger {
  color: #a31313;
  background: #ffe8e8;
}

.upload-band {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 440px);
  gap: 12px;
  padding: 12px 16px;
}

.upload-drop {
  display: grid;
  place-items: center;
  min-height: 72px;
  padding: 10px 14px;
  border: 2px dashed #d8d8d8;
  border-radius: 5px;
  background: #fafafa;
  text-align: center;
  transition:
    border 160ms ease,
    background 160ms ease;
}

.upload-drop:hover,
.upload-drop.is-dragging {
  border-color: var(--red);
  background: #fff7f7;
}

.upload-drop svg {
  width: 24px;
  height: 24px;
  color: var(--red);
}

.upload-drop span {
  margin-top: 4px;
  font-weight: 700;
}

.upload-drop small {
  color: var(--muted);
}

.hero-upload {
  min-height: 88px;
}

.process-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  padding: 0;
  overflow: hidden;
}

.process-step {
  display: flex;
  gap: 9px;
  min-height: 58px;
  padding: 10px 12px;
  border-right: 1px solid var(--line);
  background: #ffffff;
}

.process-step:last-child {
  border-right: 0;
}

.process-step strong,
.process-step small {
  display: block;
}

.process-step strong {
  font-size: 12px;
}

.process-step small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.step-dot {
  flex: 0 0 auto;
  width: 10px;
  height: 10px;
  margin-top: 3px;
  border-radius: 50%;
  border: 2px solid #cfcfcf;
}

.process-step.done .step-dot {
  background: var(--teal);
  border-color: var(--teal);
}

.process-step.active {
  background: linear-gradient(90deg, #fff7f7, #ffffff);
}

.process-step.active .step-dot {
  position: relative;
  background: var(--red);
  border-color: var(--red);
}

.process-step.active .step-dot::after {
  position: absolute;
  inset: -6px;
  content: "";
  border: 1px solid rgba(245, 34, 34, 0.35);
  border-radius: 50%;
  animation: pulse 1.7s ease-out infinite;
}

@keyframes pulse {
  0% {
    transform: scale(0.65);
    opacity: 1;
  }
  100% {
    transform: scale(1.65);
    opacity: 0;
  }
}

.passport {
  padding: 12px 16px 16px;
}

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

.facts-grid div {
  min-height: 60px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fbfbfb;
}

.facts-grid dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.facts-grid dd {
  margin: 5px 0 0;
  color: #202020;
  font-size: 12px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.facts-grid .needs-confirm {
  background: #fff8eb;
  border-color: #ffd89c;
}

.facts-grid dd span {
  display: inline-block;
  margin-top: 4px;
  color: var(--amber);
  font-size: 11px;
}

.split-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 10px;
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
}

.files-area,
.issues-area,
.questions,
.letter-preview {
  min-width: 0;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 5px;
  box-shadow: var(--soft-shadow);
}

.files-area,
.issues-area,
.questions {
  padding: 12px 16px;
}

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

.file-table {
  border: 1px solid var(--line);
  border-radius: 4px;
  overflow: hidden;
}

.table-head,
.table-row {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 130px 130px;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
}

.table-head {
  background: #f6f6f6;
  color: #555555;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.table-row {
  min-height: 50px;
  border-top: 1px solid var(--line);
  font-size: 12px;
}

.table-row.attention {
  background: #fffdf8;
}

.table-row strong,
.table-row small {
  display: block;
}

.table-row small {
  margin-top: 2px;
  color: var(--muted);
}

.issue-list {
  display: grid;
  gap: 0;
  padding: 0;
  margin: 0;
  list-style: none;
}

.issue-list li {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 8px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}

.issue-list li:last-child {
  border-bottom: 0;
}

.issue-list svg {
  color: var(--red);
}

.client-message-card {
  display: grid;
  gap: 8px;
}

.client-message {
  width: 100%;
  min-height: 300px;
  resize: vertical;
  padding: 12px 14px;
  color: #2f2f2f;
  background: #fbfbfb;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-size: 13px;
  line-height: 1.45;
  outline: none;
}

.client-message:focus {
  border-color: rgba(245, 34, 34, 0.55);
  box-shadow: 0 0 0 4px rgba(245, 34, 34, 0.08);
}

.message-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.letter-preview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 40;
  padding: 9px 12px;
  color: #ffffff;
  background: var(--dark);
  border-left: 4px solid var(--red);
  border-radius: 4px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

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

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

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

  .case-list {
    position: static;
  }

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

@media (max-width: 860px) {
  .topbar,
  .app-layout {
    padding-left: 16px;
    padding-right: 16px;
  }

  .topbar {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .primary-button {
    width: 100%;
  }

  .case-hero,
  .upload-band,
  .letter-preview {
    grid-template-columns: 1fr;
  }

  .letter-preview {
    flex-direction: column;
    align-items: stretch;
  }

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

  .process-strip,
  .facts-grid,
  .case-facts {
    grid-template-columns: 1fr;
  }

  .process-step {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .table-head {
    display: none;
  }

  .table-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .copy-button,
  .secondary-button {
    width: 100%;
  }

  .message-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .client-message {
    min-height: 430px;
    padding: 12px;
    font-size: 13px;
  }
}

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