:root {
  --warm-white: #f7f3ed;
  --charcoal: #252a28;
  --ink: #1d1d1c;
  --gray: #4e4d4d;
  --terracotta: #c65d3b;
  --stone: #e7e0d5;
  --line: #d8d0c4;
  --surface: #fffaf4;
  --muted: #8b8278;
  --good: #4c7a5a;
  --warn: #a56a38;
  --risk: #9b4a43;
  --shadow: 0 14px 36px rgba(37, 42, 40, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 1120px;
  background: var(--warm-white);
  color: var(--ink);
  font-family:
    "Noto Sans SC",
    "Microsoft YaHei",
    Inter,
    system-ui,
    sans-serif;
}

body.login-body {
  display: grid;
  min-width: 0;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

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

button {
  cursor: pointer;
}

.login-shell {
  width: min(420px, 100%);
}

.login-panel {
  display: grid;
  gap: 18px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-panel h1 {
  margin: 0;
  font-size: 26px;
}

.login-panel label {
  display: grid;
  gap: 8px;
  color: var(--gray);
  font-size: 14px;
}

.login-panel input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 11px 12px;
  background: #fff;
  color: var(--ink);
}

.login-error {
  min-height: 20px;
  margin: 0;
  color: var(--risk);
  font-size: 14px;
}

.app-shell {
  display: grid;
  grid-template-columns: 264px 1fr;
  min-height: 100vh;
  align-items: start;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 22px;
  height: 100vh;
  overflow: auto;
  padding: 22px 18px;
  background: var(--charcoal);
  color: var(--warm-white);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(247, 243, 237, 0.16);
}

.brand strong,
.brand span {
  display: block;
}

.brand strong {
  font-size: 16px;
}

.brand span {
  margin-top: 4px;
  color: rgba(247, 243, 237, 0.66);
  font-size: 12px;
}

.nav {
  display: grid;
  gap: 6px;
}

.nav button {
  width: 100%;
  border: 0;
  border-left: 3px solid transparent;
  padding: 12px 12px;
  background: transparent;
  color: rgba(247, 243, 237, 0.72);
  text-align: left;
}

.nav button:hover,
.nav button.active {
  border-left-color: var(--terracotta);
  background: rgba(247, 243, 237, 0.08);
  color: var(--warm-white);
}

.sidebar-note {
  margin-top: auto;
  padding: 14px;
  border: 1px solid rgba(247, 243, 237, 0.15);
  background: rgba(247, 243, 237, 0.06);
}

.sidebar-note strong {
  display: block;
  margin-bottom: 8px;
}

.sidebar-note p {
  margin: 0;
  color: rgba(247, 243, 237, 0.7);
  font-size: 13px;
  line-height: 1.7;
}

.sidebar-actions {
  display: grid;
  gap: 8px;
}

.sidebar-actions .ghost-button {
  width: 100%;
  border-color: rgba(247, 243, 237, 0.18);
  background: rgba(247, 243, 237, 0.06);
  color: rgba(247, 243, 237, 0.82);
}

.sidebar-actions .danger-button {
  color: #f4d3cc;
}

.workspace {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 24px 30px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(247, 243, 237, 0.92);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(12px);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--terracotta);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
  color: var(--charcoal);
  letter-spacing: 0;
}

h1 {
  font-size: 28px;
}

h2 {
  font-size: 20px;
}

h3 {
  font-size: 16px;
}

.topbar-actions,
.section-actions,
.row-actions,
.filters,
.score-list,
.chips,
.tabs,
.inline-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.inline-actions {
  margin-top: 8px;
}

.inline-status {
  color: var(--gray);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.primary-button,
.ghost-button,
.text-button,
.icon-button {
  min-height: 36px;
  border: 1px solid transparent;
  padding: 0 14px;
  border-radius: 6px;
  font-weight: 700;
}

.primary-button {
  background: var(--terracotta);
  color: #fff;
}

.primary-button:hover {
  background: #ad4f33;
}

.ghost-button {
  border-color: var(--line);
  background: var(--surface);
  color: var(--charcoal);
}

.danger-button {
  border-color: rgba(155, 74, 67, 0.34);
  color: var(--risk);
}

.ghost-button:hover {
  border-color: var(--terracotta);
  color: var(--terracotta);
}

.primary-button:disabled,
.ghost-button:disabled,
.text-button:disabled,
.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.text-button {
  padding: 0;
  background: transparent;
  color: var(--terracotta);
}

.icon-button {
  width: 36px;
  padding: 0;
  border-color: var(--line);
  background: var(--surface);
  color: var(--charcoal);
  font-size: 22px;
  line-height: 1;
}

.view {
  padding: 24px 30px 34px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

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

.metric strong {
  display: block;
  margin-top: 8px;
  color: var(--charcoal);
  font-size: 28px;
}

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

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.panel-header p {
  margin: 6px 0 0;
  color: var(--gray);
  font-size: 13px;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) 390px;
  gap: 18px;
}

.table-wrap {
  overflow: auto;
  max-height: calc(100vh - 230px);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 940px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 11px 12px;
  vertical-align: middle;
  text-align: left;
  font-size: 13px;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f0e8dd;
  color: var(--charcoal);
  font-weight: 800;
}

tr:hover td {
  background: #fff5ec;
}

tr.selected td {
  background: #f4e6d8;
}

.workbench-row {
  cursor: pointer;
}

.workbench-row:hover td {
  background: rgba(198, 93, 59, 0.06);
}

.status,
.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--warm-white);
  color: var(--gray);
  white-space: nowrap;
  font-size: 12px;
  font-weight: 700;
}

.status.good {
  border-color: rgba(76, 122, 90, 0.36);
  color: var(--good);
}

.status.warn {
  border-color: rgba(165, 106, 56, 0.36);
  color: var(--warn);
}

.status.risk {
  border-color: rgba(155, 74, 67, 0.36);
  color: var(--risk);
}

.detail-panel {
  position: sticky;
  top: 112px;
  align-self: start;
  min-width: 0;
  max-width: 100%;
  padding: 18px;
  overflow: hidden;
}

.detail-panel dl {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 11px 12px;
  margin: 18px 0 0;
}

.detail-panel dt {
  color: var(--muted);
}

.detail-panel dd {
  margin: 0;
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: pre-wrap;
}

.detail-panel h2,
.detail-panel h3,
.detail-panel p,
.detail-panel li,
.detail-panel small,
.detail-panel span,
.detail-panel strong,
.draft-card p,
.draft-body,
.analysis-box p,
.layout-item span,
.layout-item small {
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.filters {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}

.filters input,
.filters select,
.form-grid input,
.form-grid select,
.form-grid textarea,
.generator-grid input,
.generator-grid select,
.generator-grid textarea {
  min-height: 38px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  background: #fffdf9;
  color: var(--ink);
  outline: none;
}

.filters input:focus,
.filters select:focus,
.form-grid input:focus,
.form-grid select:focus,
.form-grid textarea:focus,
.generator-grid input:focus,
.generator-grid select:focus,
.generator-grid textarea:focus {
  border-color: var(--terracotta);
  box-shadow: 0 0 0 3px rgba(198, 93, 59, 0.13);
}

.filters input {
  max-width: 300px;
}

.empty {
  padding: 36px;
  color: var(--gray);
  text-align: center;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(37, 42, 40, 0.36);
}

.hidden {
  display: none !important;
}

.modal {
  width: min(860px, 100%);
  max-height: 92vh;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 24px 80px rgba(37, 42, 40, 0.22);
}

.modal-header,
.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
}

.modal-header {
  border-bottom: 1px solid var(--line);
}

.modal-footer {
  border-top: 1px solid var(--line);
}

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

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

.field label {
  display: block;
  margin-bottom: 7px;
  color: var(--charcoal);
  font-size: 13px;
  font-weight: 800;
}

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

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

.generator-form,
.draft-preview,
.settings-grid {
  padding: 18px;
}

.generator-form {
  display: grid;
  gap: 14px;
}

.draft-card {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf9;
}

.draft-card + .draft-card {
  margin-top: 12px;
}

.draft-card p {
  margin: 0;
  color: var(--gray);
  line-height: 1.7;
}

.progress-steps {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.progress-steps span {
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
  text-align: center;
  font-size: 13px;
  font-weight: 700;
}

.progress-steps span.active {
  border-color: rgba(198, 93, 59, 0.4);
  background: rgba(198, 93, 59, 0.09);
  color: var(--terracotta);
}

.review-preview {
  display: grid;
  gap: 16px;
}

.review-preview section {
  display: grid;
  gap: 8px;
}

.draft-body {
  white-space: pre-wrap;
}

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

.asset-strip figure {
  margin: 0;
}

.case-photo-card {
  display: grid;
  gap: 8px;
}

.asset-strip img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--stone);
}

.asset-strip figcaption {
  display: grid;
  gap: 4px;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.asset-strip figcaption small {
  color: var(--gray);
}

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

.photo-toolbar {
  display: grid;
  grid-template-columns: repeat(3, 28px);
  gap: 5px;
}

.photo-toolbar .icon-button {
  width: 28px;
  min-height: 26px;
  padding: 0;
  border-color: var(--line);
  border-radius: 5px;
  background: #fffdf9;
  color: var(--charcoal);
  font-size: 17px;
  font-weight: 600;
  line-height: 1;
}

.photo-toolbar .danger-icon {
  color: var(--risk);
  font-size: 20px;
  font-weight: 500;
}

.photo-actions .text-button {
  min-height: 28px;
  padding: 0 8px;
}

.photo-actions .danger-text {
  color: var(--risk);
}

.layout-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.layout-item {
  display: grid;
  gap: 3px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fffdf9;
}

.layout-item span {
  color: var(--charcoal);
  font-weight: 800;
}

.layout-item small {
  color: var(--gray);
}

.link-recognizer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}

.link-recognizer.compact {
  padding-top: 0;
}

.token-panel {
  display: grid;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf9;
}

.backup-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.75fr);
  gap: 18px;
}

.backup-panel {
  align-self: start;
}

.backup-body {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.panel-header.compact {
  padding: 0;
  border: 0;
}

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

.token-metric {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
}

.token-metric span,
.token-metric strong {
  display: block;
}

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

.token-metric strong {
  margin-top: 4px;
  color: var(--charcoal);
  font-size: 20px;
}

.score {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: 2px solid var(--terracotta);
  color: var(--terracotta);
  font-size: 19px;
  font-weight: 800;
}

.score-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
}

.progress {
  height: 8px;
  border-radius: 999px;
  background: var(--stone);
  overflow: hidden;
}

.progress span {
  display: block;
  height: 100%;
  background: var(--terracotta);
}

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

.notice {
  padding: 12px 14px;
  border-left: 3px solid var(--terracotta);
  background: #fff4ec;
  color: var(--gray);
  line-height: 1.7;
}

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

.danger-list li {
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fffdf9;
}

.thumb {
  display: block;
  width: 56px;
  height: 42px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--stone);
}

.asset-preview {
  display: block;
  width: 100%;
  max-height: 260px;
  margin: 14px 0;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--stone);
}

.analysis-box {
  display: grid;
  gap: 10px;
  margin-top: 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf9;
}

.analysis-box.nested {
  margin-top: 10px;
  padding: 12px;
  background: var(--surface);
}

.analysis-box p {
  margin: 0;
  color: var(--gray);
  line-height: 1.7;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 50;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--terracotta);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--charcoal);
  font-weight: 700;
}

@media (max-width: 900px) {
  body {
    min-width: 0;
  }

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

  .sidebar {
    position: static;
    height: auto;
    overflow: visible;
  }

  .split,
  .generator-grid,
  .settings-grid,
  .backup-grid,
  .metric-grid {
    grid-template-columns: 1fr;
  }

  .topbar,
  .panel-header,
  .filters {
    align-items: flex-start;
    flex-direction: column;
  }

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