:root {
  --bg: #eef4f1;
  --surface: #ffffff;
  --surface-soft: #f6f9f7;
  --surface-strong: #f0f7f5;
  --ink: #17211f;
  --muted: #62706b;
  --line: #d7e1dd;
  --deep: #193d39;
  --deep-2: #24504b;
  --accent: #0f8b8d;
  --gold: #c38b34;
  --success: #167c61;
  --warning: #b56d18;
  --danger: #a13a3a;
  --shadow: 0 18px 40px rgba(23, 33, 31, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(15, 139, 141, 0.1), transparent 28%),
    radial-gradient(circle at bottom right, rgba(195, 139, 52, 0.08), transparent 26%),
    var(--bg);
  font:
    15px/1.6 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
}

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

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  min-height: 100vh;
}

.app-sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 24px;
  height: 100vh;
  padding: 28px;
  color: #f6fbf9;
  background:
    radial-gradient(circle at top, rgba(15, 139, 141, 0.22), transparent 36%),
    linear-gradient(rgba(25, 61, 57, 0.97), rgba(25, 61, 57, 0.99));
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 10px;
  color: var(--deep);
  background: #fff;
  font-weight: 800;
}

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

.brand-block span {
  color: rgba(246, 251, 249, 0.78);
  font-size: 13px;
}

.eyebrow {
  margin: 0;
  color: #9bddda;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

.sidebar-copy h1 {
  margin: 8px 0 10px;
  font-size: 32px;
  line-height: 1.14;
}

.sidebar-copy p:last-child {
  color: rgba(246, 251, 249, 0.82);
}

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

.nav-link {
  padding: 11px 12px;
  color: rgba(246, 251, 249, 0.78);
  text-align: left;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
}

.nav-link.active {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.16);
}

.sidebar-card {
  margin-top: auto;
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
}

.sidebar-card h2 {
  margin: 0 0 8px;
  font-size: 20px;
}

.sidebar-card ul {
  margin: 0;
  padding-left: 18px;
  color: rgba(246, 251, 249, 0.82);
}

.app-main {
  display: grid;
  gap: 22px;
  width: min(1400px, 100%);
  padding: 28px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.topbar h2 {
  margin: 6px 0 0;
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1.1;
}

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

.system-banner {
  padding: 14px 16px;
  border-left: 5px solid var(--gold);
  color: #4d4538;
  background: #fffaf0;
  box-shadow: 0 8px 22px rgba(195, 139, 52, 0.12);
}

.view-mount {
  min-height: 500px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.panel-header {
  padding: 20px 22px 0;
}

.panel-header h3 {
  margin: 6px 0 0;
  font-size: 24px;
}

.subtle {
  color: var(--muted);
}

.panel-body {
  padding: 20px 22px 24px;
}

.prose-block h4,
.summary-section h4,
.layer-panel h4,
.decision-card h4,
.result-card h4,
.readonly-block h4,
.consent-inline h4 {
  margin: 0 0 12px;
  font-size: 19px;
}

.prose-block h5,
.consent-inline h5 {
  margin: 18px 0 8px;
  font-size: 16px;
}

.prose-block ul,
.prose-block ol,
.summary-section ul,
.result-card ul {
  margin: 0 0 14px;
  padding-left: 20px;
}

.prose-block p,
.prose-block li,
.summary-section p,
.summary-section li,
.consent-inline p,
.consent-inline li,
.readonly-block pre,
.result-card p {
  margin-top: 0;
}

.consent-org-block {
  display: grid;
  gap: 4px;
  padding: 16px;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(15, 139, 141, 0.1), rgba(35, 80, 75, 0.08));
}

.warning-block {
  margin: 16px 0;
  padding: 16px;
  border: 1px solid rgba(195, 139, 52, 0.35);
  border-radius: 10px;
  color: #5a4729;
  background: #fffaf0;
}

.checkbox-stack,
.checkbox-grid {
  display: grid;
  gap: 10px;
}

.checkbox-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.checkbox-row.plain,
.inline-check {
  padding: 0;
  border: none;
  background: transparent;
}

.checkbox-row input {
  width: auto;
  margin: 3px 0 0;
}

.checkbox-row.compact {
  padding: 8px 10px;
}

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

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

label,
.field-label {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  margin-top: 8px;
  padding: 0 12px;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
}

input,
select {
  height: 44px;
}

textarea {
  min-height: 104px;
  padding: 12px;
  resize: vertical;
}

.quality-card,
.summary-card,
.status-card,
.upload-card,
.readonly-block,
.repeat-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-soft);
}

.quality-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
}

.quality-bar {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #dde8e4;
}

.quality-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(135deg, var(--accent), var(--deep-2));
}

.layer-tabs {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 18px 0;
}

.layer-tab {
  height: 40px;
  padding: 0 14px;
  color: var(--deep);
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
}

.layer-tab.active {
  color: #fff;
  border-color: var(--deep);
  background: var(--deep);
}

.layer-panel {
  display: grid;
  gap: 16px;
}

.subsection-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
}

.repeat-grid {
  display: grid;
  gap: 10px;
}

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

.repeat-card .repeat-row {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.pending-files {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.pending-file {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.action-row {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 22px;
}

.action-row.split {
  justify-content: space-between;
  align-items: center;
}

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

.primary-button,
.ghost-button {
  height: 44px;
  padding: 0 16px;
  border-radius: 8px;
}

.primary-button {
  color: #fff;
  border: none;
  background: linear-gradient(135deg, var(--accent), var(--deep-2));
}

.primary-button:disabled,
.ghost-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.ghost-button {
  color: var(--deep);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.8);
}

.ghost-button.mini {
  width: auto;
  height: 34px;
  padding: 0 12px;
}

.small-note {
  color: var(--muted);
  font-size: 13px;
}

.generate-block {
  display: grid;
  gap: 8px;
  justify-items: end;
  margin-top: 22px;
}

.split-panel {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
  gap: 22px;
}

.scroll-body {
  max-height: 76vh;
  overflow: auto;
}

.readonly-block pre,
.summary-section pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-thread {
  display: grid;
  gap: 12px;
  min-height: 280px;
  margin: 14px 0;
}

.chat-bubble {
  max-width: 88%;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--surface-soft);
}

.chat-bubble.ai {
  justify-self: start;
  border-top-left-radius: 4px;
}

.chat-bubble.user {
  justify-self: end;
  color: #fff;
  background: linear-gradient(135deg, var(--deep-2), var(--accent));
  border-top-right-radius: 4px;
}

.chat-bubble span {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 800;
}

.chat-bubble p {
  margin: 0;
}

.chat-input {
  min-height: 120px;
}

.decision-grid,
.result-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.decision-card,
.result-card {
  display: grid;
  gap: 10px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-soft);
}

.result-card {
  cursor: pointer;
}

.result-card input[type="radio"] {
  width: auto;
  height: auto;
  margin: 0;
}

.result-card.static {
  cursor: default;
}

.consent-inline {
  margin-top: 24px;
  padding: 18px;
  border: 1px solid rgba(15, 139, 141, 0.2);
  border-radius: 10px;
  background: rgba(15, 139, 141, 0.04);
}

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

.queue-item {
  display: grid;
  gap: 4px;
  width: 100%;
  padding: 14px;
  color: inherit;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-soft);
}

.queue-item.active {
  border-color: rgba(15, 139, 141, 0.45);
  background: rgba(15, 139, 141, 0.08);
}

.queue-item small {
  color: var(--muted);
}

.status-card.warning {
  color: #684a1f;
  border-color: rgba(195, 139, 52, 0.35);
  background: #fff8ee;
}

@media (max-width: 1200px) {
  .split-panel,
  .admin-shell {
    grid-template-columns: 1fr;
  }
}

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

  .app-sidebar {
    position: static;
    height: auto;
  }
}

@media (max-width: 760px) {
  .app-main {
    padding: 18px;
  }

  .field-grid,
  .repeat-row,
  .repeat-card .repeat-row {
    grid-template-columns: 1fr;
  }

  .action-row,
  .action-row.split,
  .inline-actions {
    flex-direction: column;
    align-items: stretch;
  }
}
