:root {
  --bg: #f6f8fb;
  --panel: #ffffff;
  --ink: #152033;
  --muted: #64748b;
  --line: #dbe4f0;
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --green: #059669;
  --amber: #d97706;
  --red: #dc2626;
  --soft-blue: #eaf2ff;
  --soft-green: #e8f7f0;
  --soft-amber: #fff7e6;
  --soft-red: #fff0f0;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(37, 99, 235, 0.08), rgba(255, 255, 255, 0) 260px),
    var(--bg);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 28px 32px 18px;
  max-width: 1440px;
  margin: 0 auto;
}

.app-nav {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  max-width: 1180px;
  padding: 0 32px 18px;
  margin: 0 auto;
}

.advanced-tab,
.quiet-advanced,
.advanced-result {
  display: none !important;
}

.nav-tab {
  display: grid;
  gap: 5px;
  min-height: 68px;
  padding: 12px 14px;
  color: var(--ink);
  text-align: left;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(15, 23, 42, 0.09);
  border-radius: 8px;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.05);
}

.nav-tab:hover {
  border-color: rgba(37, 99, 235, 0.35);
  background: #fff;
}

.nav-tab.active {
  color: #fff;
  background: var(--blue);
  border-color: var(--blue);
  box-shadow: 0 14px 28px rgba(37, 99, 235, 0.18);
}

.nav-tab strong {
  font-size: 15px;
}

.nav-tab span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.nav-tab.active span {
  color: rgba(255, 255, 255, 0.82);
}

.page-hidden {
  display: none !important;
}

.quick-guide {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  max-width: 1180px;
  padding: 0 32px 18px;
  margin: 0 auto;
}

.quick-guide article {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 4px 10px;
  align-items: center;
  padding: 13px 14px;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 8px;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.05);
}

.quick-guide span {
  display: grid;
  grid-row: span 2;
  place-items: center;
  width: 28px;
  height: 28px;
  color: #fff;
  background: var(--blue);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
}

.quick-guide strong {
  font-size: 14px;
}

.quick-guide p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--blue);
  font-size: 13px;
  font-weight: 700;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 30px;
}

h2 {
  margin-bottom: 0;
  font-size: 18px;
}

h3 {
  margin-bottom: 10px;
  font-size: 15px;
}

.status-pill,
.guard-status {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
}

.status-pill {
  background: var(--soft-green);
  color: var(--green);
}

.guard-status.idle {
  color: var(--muted);
  background: #edf2f7;
}

.guard-status.pass {
  color: var(--green);
  background: var(--soft-green);
}

.guard-status.warn {
  color: var(--amber);
  background: var(--soft-amber);
}

.guard-status.block {
  color: var(--red);
  background: var(--soft-red);
}

.layout {
  display: grid;
  grid-template-columns: minmax(360px, 0.95fr) minmax(420px, 1.25fr);
  gap: 18px;
  max-width: 1180px;
  padding: 0 32px 18px;
  margin: 0 auto;
}

.panel {
  background: var(--panel);
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 8px;
  box-shadow: 0 16px 45px rgba(15, 23, 42, 0.07);
}

.input-panel,
.result-panel {
  min-height: 620px;
  padding: 20px;
}

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

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

.inline-head h3 {
  margin-bottom: 0;
}

.crm-workbench {
  max-width: 1180px;
  padding: 16px;
  margin: 0 auto 18px;
}

.config-panel {
  max-width: 1180px;
  padding: 20px;
  margin: 0 auto 18px;
}

.config-grid {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) minmax(360px, 0.9fr);
  gap: 16px;
  margin-bottom: 14px;
}

.config-grid article {
  min-width: 0;
  padding: 14px;
  background: #fbfdff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.toggle-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 9px;
  align-items: center;
  margin-bottom: 12px;
}

.toggle-row input {
  width: auto;
  margin: 0;
}

.config-hint {
  padding: 12px;
  margin-top: 10px;
  background: var(--soft-blue);
  border: 1px solid rgba(37, 99, 235, 0.16);
  border-radius: 8px;
}

.config-hint p {
  margin: 5px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.handoff-panel {
  max-width: 1440px;
  padding: 20px;
  margin: 0 auto 18px;
}

.handoff-grid {
  display: grid;
  grid-template-columns: minmax(360px, 0.9fr) minmax(480px, 1.1fr);
  gap: 16px;
}

.handoff-grid article {
  min-width: 0;
}

.tall-preview {
  max-height: 640px;
}

.crm-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.9fr) minmax(420px, 1.1fr);
  gap: 16px;
}

.crm-workbench #crmProfilePreview,
.crm-workbench #crmPatchPreview {
  display: none;
}

.crm-workbench h3 {
  margin-top: 4px;
}

.crm-grid article {
  min-width: 0;
}

.inline-input {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: end;
}

.crm-lead-results,
.crm-patch-list {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.crm-create-box {
  padding: 12px;
  margin-bottom: 14px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.crm-lead-card,
.crm-patch-item {
  display: grid;
  gap: 6px;
  width: 100%;
  padding: 11px 12px;
  color: var(--ink);
  text-align: left;
  background: #fbfdff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.crm-lead-card {
  cursor: pointer;
}

.crm-lead-card.active {
  border-color: rgba(37, 99, 235, 0.65);
  background: var(--soft-blue);
}

.crm-lead-card strong,
.crm-patch-item strong {
  font-size: 14px;
}

.crm-lead-card span,
.crm-patch-item span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.crm-patch-item {
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
}

.crm-patch-item input {
  width: auto;
  margin-top: 3px;
}

.crm-patch-body {
  display: grid;
  gap: 5px;
}

.crm-patch-meta {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.crm-patch-item.setup,
.crm-patch-item.blocked {
  background: #fff;
}

.crm-patch-item.setup {
  border-color: rgba(217, 119, 6, 0.35);
}

.crm-patch-item.blocked {
  border-color: rgba(220, 38, 38, 0.35);
}

label {
  display: block;
  margin-bottom: 14px;
  color: #334155;
  font-size: 13px;
  font-weight: 700;
}

.optional-context {
  margin: 0 0 14px;
  padding: 12px 12px 2px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.optional-context summary {
  margin-bottom: 10px;
  color: var(--blue);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

input,
textarea,
select {
  width: 100%;
  margin-top: 7px;
  padding: 11px 12px;
  color: var(--ink);
  background: #fbfdff;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
  font-size: 14px;
  line-height: 1.5;
  outline: none;
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  border-color: rgba(37, 99, 235, 0.55);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.11);
}

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

button {
  border: 0;
  border-radius: 6px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.primary-btn,
.secondary-btn,
.ghost-btn,
.feedback-btn {
  min-height: 40px;
  padding: 0 14px;
}

.primary-btn {
  color: #fff;
  background: var(--blue);
}

.primary-btn:hover {
  background: var(--blue-dark);
}

.secondary-btn {
  color: var(--blue);
  background: var(--soft-blue);
}

.ghost-btn {
  color: var(--muted);
  background: #edf2f7;
}

.actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 420px;
  padding: 24px;
  color: var(--muted);
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fbfdff;
}

.empty-state h3 {
  color: var(--ink);
  font-size: 20px;
}

.hidden {
  display: none;
}

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

.diagnosis-grid article {
  min-height: 88px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
}

.diagnosis-grid span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.diagnosis-grid strong {
  font-size: 16px;
  line-height: 1.4;
}

.result-block {
  padding: 14px 0;
  border-top: 1px solid var(--line);
}

ul {
  padding-left: 18px;
  margin: 0;
}

li {
  margin: 6px 0;
  line-height: 1.55;
}

.reply-list {
  display: grid;
  gap: 10px;
}

.packet-preview {
  max-height: 260px;
  padding: 12px;
  overflow: auto;
  color: #1f2937;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.reply {
  position: relative;
  padding: 14px 46px 14px 14px;
  border: 1px solid rgba(37, 99, 235, 0.16);
  border-radius: 8px;
  background: var(--soft-blue);
  line-height: 1.65;
  white-space: pre-wrap;
}

.copy-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  min-height: 30px;
  padding: 0 9px;
  color: var(--blue);
  background: #fff;
  border: 1px solid rgba(37, 99, 235, 0.2);
}

.guards li.pass {
  color: var(--green);
}

.guards li.warn {
  color: var(--amber);
}

.guards li.block {
  color: var(--red);
  font-weight: 700;
}

.feedback-card {
  padding: 16px;
  border-radius: 8px;
  background: #f8fafc;
  border: 1px solid var(--line);
}

.feedback-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.feedback-btn {
  color: #334155;
  background: #fff;
  border: 1px solid var(--line);
}

.feedback-btn.active {
  color: #fff;
  background: var(--blue);
  border-color: var(--blue);
}

.analytics-panel,
.agent-config-panel,
.feedback-log,
.sample-lab,
.eval-lab {
  max-width: 1440px;
  padding: 20px;
  margin: 0 auto 18px;
}

.analytics-summary {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.metric-card {
  min-height: 86px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
}

.metric-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.metric-card strong {
  display: block;
  margin-top: 8px;
  font-size: 22px;
}

.metric-card em {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-style: normal;
  font-size: 12px;
}

.analytics-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 12px;
}

.analytics-grid article {
  min-height: 180px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
}

.stat-list {
  display: grid;
  gap: 8px;
}

.stat-row {
  display: grid;
  grid-template-columns: minmax(96px, 1fr) minmax(90px, 1.2fr) 38px;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.bar {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e5edf7;
}

.bar > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--blue);
}

.stat-empty {
  color: var(--muted);
  line-height: 1.5;
}

.review-coach {
  max-width: 1440px;
  padding: 20px;
  margin: 0 auto 18px;
}

.panel-note {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.analysis-source-note {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.review-layout {
  display: grid;
  grid-template-columns: minmax(360px, 0.9fr) minmax(420px, 1.1fr);
  gap: 18px;
}

.sample-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.compact-input {
  width: 180px;
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.sample-layout {
  display: grid;
  grid-template-columns: minmax(360px, 0.9fr) minmax(420px, 1.1fr);
  gap: 18px;
}

.sample-test-result {
  min-height: 36px;
  margin: 14px 0;
  color: var(--muted);
  font-weight: 700;
}

.sample-test-result.pass {
  color: var(--green);
}

.sample-test-result.warn {
  color: var(--amber);
}

.sample-test-result.block {
  color: var(--red);
}

.sample-library {
  max-height: 520px;
  overflow: auto;
}

.sample-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  color: var(--blue);
  background: var(--soft-blue);
  font-size: 12px;
  font-weight: 800;
}

.sample-card-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.mini-btn {
  min-height: 30px;
  padding: 0 10px;
  color: #334155;
  background: #fff;
  border: 1px solid var(--line);
}

.review-result {
  min-height: 280px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
}

.empty-review {
  display: grid;
  place-items: center;
  color: var(--muted);
  text-align: center;
}

.review-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.review-summary article {
  padding: 12px;
  border-radius: 8px;
  background: #f8fafc;
  border: 1px solid var(--line);
}

.review-summary span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.review-summary strong {
  display: block;
  margin-top: 6px;
  font-size: 18px;
}

.finding {
  padding: 13px;
  margin-top: 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
}

.finding.high {
  border-color: rgba(220, 38, 38, 0.28);
  background: var(--soft-red);
}

.finding.medium {
  border-color: rgba(217, 119, 6, 0.28);
  background: var(--soft-amber);
}

.finding.low {
  border-color: rgba(37, 99, 235, 0.2);
  background: var(--soft-blue);
}

.finding h4 {
  margin: 0 0 6px;
  font-size: 14px;
}

.finding p {
  margin: 5px 0;
  color: #334155;
  line-height: 1.55;
}

.rewrite {
  margin-top: 8px;
  padding: 10px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.76);
  white-space: pre-wrap;
}

.log-list {
  display: grid;
  gap: 10px;
}

.log-item {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
}

.log-item strong {
  display: block;
  margin-bottom: 5px;
}

.log-item p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

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

  .quick-guide {
    grid-template-columns: 1fr;
    padding: 0 18px 18px;
  }

  .nav-tab {
    min-height: 78px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 22px 18px 14px;
  }

  .layout {
    grid-template-columns: 1fr;
    padding: 0 18px 18px;
  }

  .input-panel,
  .result-panel {
    min-height: auto;
  }

  .field-grid,
  .diagnosis-grid,
  .config-grid,
  .handoff-grid,
  .analytics-summary,
  .analytics-grid,
  .review-layout,
  .sample-layout,
  .review-summary {
    grid-template-columns: 1fr;
  }

  .feedback-log,
  .analytics-panel,
  .agent-config-panel,
  .crm-workbench,
  .handoff-panel,
  .review-coach,
  .sample-lab,
  .eval-lab {
    margin: 0 18px 24px;
  }
}
