*, *::before, *::after { box-sizing: border-box; }

:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --line: #d9e0e7;
  --text: #17212f;
  --muted: #5f6b7a;
  --accent: #1f6f5b;
  --accent-strong: #155744;
  --warn: #9a4f14;
  --danger: #a3332c;
  --shadow: 0 12px 32px rgba(23, 33, 47, 0.08);
}

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

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

button {
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  padding: 10px 14px;
  color: #ffffff;
  background: var(--accent);
  font-weight: 700;
  cursor: pointer;
}

button:hover,
button:focus-visible {
  background: var(--accent-strong);
}

button.secondary {
  color: var(--text);
  background: #e8edf1;
}

button.secondary:hover,
button.secondary:focus-visible {
  background: #d7e0e7;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 24px clamp(16px, 4vw, 40px);
  border-bottom: 1px solid var(--line);
  background: #ffffff;
}

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

h1,
h2 {
  margin: 0;
  line-height: 1.15;
}

h1 {
  font-size: clamp(1.7rem, 3vw, 2.7rem);
}

h2 {
  font-size: 1.18rem;
}

.progress-pill {
  display: grid;
  gap: 2px;
  min-width: 132px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafb;
}

.progress-pill span {
  color: var(--muted);
  font-size: 0.78rem;
}

.progress-pill strong {
  font-size: 1.4rem;
}

.layout {
  display: grid;
  grid-template-columns: minmax(320px, 1.15fr) minmax(280px, 0.85fr);
  gap: 18px;
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 18px clamp(16px, 4vw, 40px) 40px;
}

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

.panel-heading {
  padding: 18px 18px 0;
}

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

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

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid #cbd5df;
  border-radius: 6px;
  padding: 9px 10px;
  color: var(--text);
  background: #ffffff;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  outline: 3px solid rgba(31, 111, 91, 0.16);
}

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

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
}

.check-row input {
  width: 18px;
  min-height: 18px;
}

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

.status-line {
  min-height: 38px;
  margin: 0;
  padding: 0 18px 18px;
  color: var(--muted);
  font-size: 0.92rem;
}

.status-line.is-ok {
  color: var(--accent-strong);
}

.status-line.is-error {
  color: var(--danger);
}

.summary-list {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 8px 16px;
  margin: 0;
  padding: 18px;
}

.summary-list dt {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.summary-list dd {
  margin: 0;
  min-width: 0;
  font-weight: 650;
  overflow-wrap: anywhere;
}

.letter-preview {
  margin: 0 18px 18px;
  min-height: 260px;
  max-height: 440px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 14px;
  color: #253043;
  background: #fbfcfd;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.86rem;
  line-height: 1.55;
  white-space: pre-wrap;
}

.workflow-panel,
.detail-panel {
  min-height: 420px;
}

.workflow-blocks {
  display: grid;
  gap: 8px;
  padding: 18px;
}

.block-button {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 58px;
  border: 1px solid var(--line);
  color: var(--text);
  background: #ffffff;
  text-align: left;
}

.block-button:hover,
.block-button:focus-visible,
.block-button.is-active {
  border-color: var(--accent);
  background: #eef7f3;
}

.block-code {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 6px;
  color: #ffffff;
  background: var(--accent);
  font-weight: 800;
}

.block-button strong,
.block-button small {
  display: block;
}

.block-button small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.78rem;
}

.task-list {
  display: grid;
  gap: 10px;
  padding: 18px;
}

.task-item {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  align-items: start;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  background: #fbfcfd;
  font-weight: 600;
}

.task-item input {
  width: 18px;
  min-height: 18px;
  margin-top: 2px;
}

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

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

  .case-form {
    grid-template-columns: 1fr;
  }

  .actions {
    display: grid;
  }
}
