:root {
  --bg: #f4ecdf;
  --panel: rgba(255, 252, 247, 0.96);
  --line: rgba(83, 62, 30, 0.08);
  --deep: #203338;
  --gold: #b9883f;
  --text: #211d17;
  --muted: #7c6e5c;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(197, 95, 58, 0.14), transparent 28%),
    radial-gradient(circle at 86% 12%, rgba(208, 168, 83, 0.16), transparent 22%),
    linear-gradient(180deg, #f6efe4 0%, #f1e7d8 100%);
  color: var(--text);
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
}

.shell {
  display: grid;
  grid-template-columns: 300px 1fr;
  min-height: 100vh;
}

.sidebar {
  padding: 28px;
  background: linear-gradient(180deg, #1b2a2f 0%, #23383d 100%);
  color: #fff7e9;
}

.brand h1 {
  margin: 14px 0 10px;
  font-size: 32px;
}

.brand p,
.side-text,
.side-list {
  color: rgba(255, 247, 233, 0.8);
  line-height: 1.8;
}

.brand-badge {
  display: inline-flex;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(255, 247, 233, 0.12);
  border: 1px solid rgba(255, 247, 233, 0.16);
  font-size: 12px;
  letter-spacing: 1px;
}

.side-card {
  margin-top: 22px;
  padding: 20px;
  border-radius: 24px;
  background: rgba(255, 247, 233, 0.08);
  border: 1px solid rgba(255, 247, 233, 0.08);
}

.side-title {
  margin-bottom: 10px;
  font-size: 15px;
  font-weight: 700;
}

.side-field {
  display: block;
  margin-top: 14px;
}

.side-field span {
  display: block;
  margin-bottom: 8px;
  font-size: 12px;
  color: rgba(255, 247, 233, 0.72);
}

.side-input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid rgba(255, 247, 233, 0.14);
  border-radius: 16px;
  background: rgba(255, 247, 233, 0.08);
  color: #fff8eb;
}

.side-input::placeholder {
  color: rgba(255, 247, 233, 0.44);
}

.side-list {
  margin: 0;
  padding-left: 18px;
}

.side-inline-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.side-inline-actions.stacked {
  flex-direction: column;
}

.side-btn {
  width: 100%;
}

.case-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
  max-height: 320px;
  overflow: auto;
}

.case-item,
.case-empty {
  width: 100%;
  padding: 14px;
  text-align: left;
  border-radius: 18px;
  border: 1px solid rgba(255, 247, 233, 0.08);
  background: rgba(255, 247, 233, 0.06);
  color: #fff8eb;
}

.case-item {
  cursor: pointer;
}

.case-item.active {
  background: linear-gradient(135deg, rgba(39, 66, 71, 0.9) 0%, rgba(179, 138, 68, 0.88) 100%);
  border-color: rgba(255, 247, 233, 0.18);
  box-shadow: 0 14px 30px rgba(11, 23, 27, 0.24);
}

.case-name {
  font-size: 15px;
  font-weight: 700;
}

.case-meta,
.case-applicants,
.case-empty,
.side-text.small {
  margin-top: 6px;
  font-size: 12px;
  line-height: 1.6;
  color: rgba(255, 247, 233, 0.74);
}

.case-item.active .case-meta,
.case-item.active .case-applicants {
  color: rgba(255, 248, 235, 0.86);
}

.side-card code {
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(255, 247, 233, 0.08);
}

.content {
  padding: 26px;
}

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

.eyebrow {
  font-size: 12px;
  letter-spacing: 1.4px;
  color: var(--muted);
}

.toolbar h2 {
  margin: 8px 0 0;
  font-size: 30px;
}

.save-status-line {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.save-status-badge {
  display: inline-flex;
  align-items: center;
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.save-status-badge.saved {
  background: rgba(39, 66, 71, 0.1);
  color: #244247;
}

.save-status-badge.dirty {
  background: rgba(185, 136, 63, 0.12);
  color: #8b631f;
}

.save-status-text {
  font-size: 13px;
  color: var(--muted);
}

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

.primary-btn,
.ghost-btn {
  height: 46px;
  padding: 0 18px;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
}

.primary-btn {
  background: linear-gradient(135deg, #274247 0%, #b38a44 100%);
  color: #fff8eb;
}

.ghost-btn {
  background: rgba(255, 251, 245, 0.92);
  color: #3e3527;
  border: 1px solid rgba(62, 53, 39, 0.12);
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 22px;
}

.editor {
  display: grid;
  gap: 18px;
}

.table-card,
.form-card,
.summary-card,
.preview-card {
  padding: 22px;
  border-radius: 28px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 16px 40px rgba(90, 69, 38, 0.08);
}

.table-card {
  margin-bottom: 22px;
}

.card-title,
.summary-title {
  margin-bottom: 16px;
  font-size: 18px;
  font-weight: 700;
}

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

.table-title {
  margin: 8px 0 0;
  font-size: 26px;
}

.table-stat {
  font-size: 14px;
  color: var(--muted);
}

.table-wrap {
  overflow: auto;
  border-radius: 22px;
  border: 1px solid rgba(83, 62, 30, 0.08);
}

.case-table {
  width: 100%;
  min-width: 840px;
  border-collapse: collapse;
  background: rgba(255, 252, 247, 0.72);
}

.case-table th,
.case-table td {
  padding: 14px 16px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid rgba(83, 62, 30, 0.08);
}

.case-table th {
  font-size: 12px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--muted);
  background: rgba(249, 240, 226, 0.8);
}

.case-table tbody tr {
  transition: background 0.18s ease;
}

.case-table tbody tr:hover {
  background: rgba(185, 136, 63, 0.06);
}

.case-table tbody tr.active {
  background: rgba(39, 66, 71, 0.08);
}

.table-main {
  font-weight: 700;
  color: var(--text);
}

.table-sub {
  margin-top: 4px;
  font-size: 12px;
  line-height: 1.6;
  color: var(--muted);
}

.table-tag {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(39, 66, 71, 0.08);
  color: #294046;
  font-size: 12px;
  font-weight: 700;
}

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

.table-btn {
  height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid rgba(62, 53, 39, 0.12);
  background: rgba(255, 251, 245, 0.92);
  color: #3e3527;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.table-btn.primary {
  background: linear-gradient(135deg, #274247 0%, #b38a44 100%);
  color: #fff8eb;
  border-color: transparent;
}

.empty-row td {
  text-align: center;
  color: var(--muted);
}

.with-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.grid.two {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  align-items: start;
}

.field {
  display: grid;
  align-content: start;
  min-width: 0;
}

.field.full {
  grid-column: 1 / -1;
}

.field span {
  display: block;
  margin-bottom: 8px;
  min-height: 18px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.field-help {
  display: block;
  margin-top: 8px;
  font-size: 12px;
  line-height: 1.6;
  color: var(--muted);
}

.field-inline-actions {
  margin-top: 14px;
}

input,
textarea,
select {
  width: 100%;
  min-height: 52px;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid rgba(83, 62, 30, 0.12);
  background: linear-gradient(180deg, #fffaf3 0%, #f9f0e2 100%);
  color: var(--text);
  font: inherit;
}

textarea {
  min-height: 120px;
  resize: vertical;
}

textarea.tall {
  min-height: 220px;
}

.hint-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  grid-column: 1 / -1;
  margin-top: -4px;
  padding: 0 2px;
}

.geo-status {
  font-size: 13px;
  color: var(--muted);
}

.small-btn {
  height: 38px;
  padding: 0 14px;
  font-size: 13px;
}

.danger-btn {
  color: #8a3d28;
}

.applicant-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

.applicant-tab {
  height: 38px;
  padding: 0 16px;
  border: 1px solid rgba(62, 53, 39, 0.12);
  border-radius: 999px;
  background: rgba(255, 251, 245, 0.92);
  color: #3e3527;
  cursor: pointer;
}

.applicant-tab.active {
  background: linear-gradient(135deg, #274247 0%, #b38a44 100%);
  color: #fff8eb;
  border-color: transparent;
}

.preview-column {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.preview-card {
  background: linear-gradient(145deg, #203338 0%, #3f5c67 50%, #c7934b 100%);
  color: #fff8eb;
}

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

.preview-badge,
.preview-status,
.meta-chip {
  display: inline-flex;
  align-items: center;
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 12px;
  background: rgba(255, 247, 233, 0.12);
  border: 1px solid rgba(255, 247, 233, 0.14);
}

.preview-title {
  margin-top: 18px;
  font-size: 30px;
  font-weight: 800;
  line-height: 1.3;
}

.preview-subtitle {
  margin-top: 10px;
  color: rgba(255, 247, 233, 0.82);
}

.preview-meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 18px;
}

.preview-applicant-select-wrap {
  margin-bottom: 16px;
}

.preview-applicant-select-wrap.hidden {
  display: none;
}

.preview-applicant-select {
  width: 100%;
  min-height: 46px;
  border-radius: 18px;
  border: 1px solid rgba(83, 62, 30, 0.12);
  background: linear-gradient(180deg, #fffaf3 0%, #f9f0e2 100%);
  color: var(--text);
  font: inherit;
}

.summary-grid {
  display: grid;
  gap: 14px;
}

.summary-item span {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  color: var(--muted);
}

.summary-item strong {
  font-size: 16px;
  line-height: 1.6;
  word-break: break-word;
}

.json-preview {
  margin: 0;
  max-height: 420px;
  overflow: auto;
  padding: 16px;
  border-radius: 18px;
  background: #1f2527;
  color: #f8f2e8;
  font-size: 12px;
  line-height: 1.6;
}

.delivery-grid {
  display: grid;
  gap: 14px;
}

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

.delivery-actions .ghost-btn,
.delivery-actions .primary-btn {
  flex: 1 1 140px;
}

.delivery-qr-card {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 18px;
  border-radius: 22px;
  background: linear-gradient(180deg, #fffaf3 0%, #f7ecdc 100%);
  border: 1px solid rgba(83, 62, 30, 0.08);
}

.delivery-qr-image {
  width: 220px;
  height: 220px;
  object-fit: contain;
  border-radius: 18px;
  background: #fff;
  padding: 10px;
  box-shadow: inset 0 0 0 1px rgba(83, 62, 30, 0.08);
}

.delivery-qr-caption,
.delivery-note {
  font-size: 12px;
  line-height: 1.7;
  color: var(--muted);
  text-align: center;
}

@media (min-width: 1101px) {
  .preview-column {
    position: sticky;
    top: 24px;
    align-self: start;
  }
}

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

  .sidebar {
    padding-bottom: 20px;
  }

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

@media (max-width: 720px) {
  .content,
  .sidebar {
    padding: 18px;
  }

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

  .table-head,
  .delivery-actions {
    flex-direction: column;
    align-items: stretch;
  }

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