* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #111827;
  background: #f5f7f9;
  line-height: 1.5;
}
a { color: #0f8f8b; text-decoration: none; }
a:hover { text-decoration: underline; }

.container { max-width: 1180px; margin: 0 auto; padding: 18px; }
.main { min-height: calc(100vh - 92px); }

.topbar {
  background: rgba(255,255,255,.98);
  border-bottom: 1px solid #e5e7eb;
  box-shadow: 0 4px 18px rgba(17,24,39,.035);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-inner {
  max-width: 1480px;
  margin: 0 auto;
  min-height: 72px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 28px;
  padding: 10px 28px;
}
.brand { display: inline-flex; align-items: center; gap: 12px; color: #111827; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 13px;
  letter-spacing: 0;
  background: #078f89;
  box-shadow: 0 8px 18px rgba(8,145,139,.16);
}
.brand-text strong { display: block; font-size: 21px; letter-spacing: 0; }
.brand-text small { display: block; color: #64748b; font-size: 13px; margin-top: 2px; }
.topbar-notice {
  justify-self: center;
  color: #c2410c;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 8px;
  padding: 10px 18px;
  font-weight: 700;
  white-space: nowrap;
}
.topbar-notice::before { content: "⚠ "; color: #f59e0b; }
.topnav { margin-left: auto; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.topnav a { color: #374151; }
.nav-link, .admin-menu summary { padding: 8px 10px; border-radius: 6px; font-size: 14px; }
.nav-link:hover, .admin-menu summary:hover { color: #087f7a; background: #f0f9f8; text-decoration: none; }
.nav-link-active { color: #087f7a !important; font-weight: 700; }
.nav-link-quiet { color: #64748b !important; }
.admin-menu { position: relative; }
.admin-menu summary { list-style: none; color: #374151; cursor: pointer; }
.admin-menu summary::-webkit-details-marker { display: none; }
.admin-menu-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 30;
  min-width: 150px;
  padding: 6px;
  background: #fff;
  border: 1px solid #dfe5ec;
  border-radius: 8px;
  box-shadow: 0 18px 45px rgba(15,23,42,.14);
}
.admin-menu-panel a { display: block; padding: 9px 10px; border-radius: 5px; font-size: 13px; }
.admin-menu-panel a:hover { background: #f1f7f7; text-decoration: none; }
.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  margin-left: 6px;
  border-left: 1px solid #e5e7eb;
  border-right: 1px solid #e5e7eb;
}
.user-chip .avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #0f766e;
  background: #e6f7f5;
  border: 1px solid #c8ede9;
  font-weight: 800;
}
.user-chip strong { display: block; font-size: 14px; }
.user-chip small { display: block; color: #64748b; font-size: 12px; }
.footer { padding: 20px 0; text-align: center; background: #fff; border-top: 1px solid #e5e7eb; }

.workbench {
  max-width: 1480px;
  margin: 18px auto 28px;
  padding: 0 18px;
  display: grid;
  grid-template-columns: 340px 320px minmax(560px, 1fr);
  gap: 14px;
  align-items: start;
}
.panel, .card {
  background: #fff;
  border: 1px solid #e3e8ef;
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(15,23,42,.025);
}
.panel { padding: 18px; }
.selector-panel { padding: 0; overflow: hidden; }
.selector-section { padding: 18px 16px; border-bottom: 1px solid #edf1f5; }
.selector-section:last-child { border-bottom: 0; }
.section-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.section-head b { display: block; font-size: 17px; }
.section-head em { display: block; color: #8a94a6; font-style: normal; font-size: 13px; margin-top: 2px; }
.step-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  background: #079a95;
  font-weight: 800;
}
.option-grid { display: grid; gap: 10px; }
.channel-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.two-col { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.purpose-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.count-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.choice-card {
  min-height: 78px;
  border: 1px solid #dde4ee;
  border-radius: 8px;
  background: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  position: relative;
  cursor: pointer;
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}
.choice-card.horizontal { min-height: 64px; flex-direction: row; justify-content: flex-start; padding: 0 14px; }
.choice-card:hover { border-color: #0faaa4; box-shadow: 0 10px 22px rgba(15,170,164,.08); }
.choice-card input { position: absolute; opacity: 0; pointer-events: none; }
.choice-card i {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  display: none;
  place-items: center;
  background: #0faaa4;
  color: #fff;
  font-style: normal;
  font-size: 12px;
  font-weight: 800;
}
.choice-card:has(input:checked) {
  border-color: #079a95;
  background: #f2fbfa;
  box-shadow: inset 0 0 0 1px #079a95;
}
.choice-card:has(input:checked) i { display: grid; }
.choice-card .channel-name { font-size: 16px; font-weight: 700; color: #1f2937; }
.choice-card small { color: #8a94a6; font-size: 12px; }
.choice-copy { display: grid; gap: 2px; text-align: left; }
.choice-copy strong { color: #1f2937; font-size: 14px; }
.purpose-grid .choice-card { min-height: 68px; align-items: flex-start; padding: 0 14px; }
.choice-card:focus-within { outline: 3px solid rgba(15,170,164,.18); outline-offset: 2px; }
.count-card { min-height: 62px; font-size: 18px; }
.count-card b { color: #0f8f8b; font-size: 22px; }

.summary-panel { position: sticky; top: 90px; }
.summary-panel h2, .result-head h2, .history-panel h2 { margin: 0; font-size: 20px; }
.panel-heading, .history-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.panel-heading > span > small, .history-heading > span > small {
  display: block;
  margin-bottom: 2px;
  color: #8793a3;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
}
.status-dot, .history-count {
  padding: 5px 8px;
  border-radius: 6px;
  color: #0f766e;
  background: #e9f7f5;
  font-size: 11px;
  font-weight: 700;
}
.summary-list { margin-top: 18px; border: 1px solid #e8edf3; border-radius: 8px; overflow: hidden; }
.summary-list div {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border-bottom: 1px solid #edf1f5;
}
.summary-list div:last-child { border-bottom: 0; }
.summary-list span { color: #718096; font-size: 13px; }
.summary-list strong { color: #334155; font-weight: 600; }
.ai-card {
  margin: 12px 0;
  padding: 11px 12px;
  text-align: left;
  border-radius: 8px;
  color: #0f766e;
  border: 1px solid #dbeeea;
  background: #f1f8f7;
}
.ai-card b { font-size: 14px; }
.ai-card p { margin: 5px 0 0; color: #64748b; font-size: 12px; }
.compact-fields { display: grid; gap: 8px; margin-bottom: 12px; }
.compact-fields label { display: grid; gap: 6px; color: #475569; font-size: 13px; }
.form input, .form select, .form textarea,
.compact-fields input, .compact-fields textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #d9e1ea;
  border-radius: 8px;
  font: inherit;
  background: #fff;
}
.form input:focus, .form select:focus, .form textarea:focus,
.compact-fields input:focus, .compact-fields textarea:focus {
  outline: 2px solid rgba(15,170,164,.18);
  border-color: #0faaa4;
}
.generate-btn {
  width: 100%;
  min-height: 50px;
  font-size: 17px;
  font-weight: 800;
  border-radius: 8px;
  box-shadow: 0 10px 22px rgba(6,150,143,.18);
}
.wait-tip { margin: 9px 0 0; text-align: center; }

.rewrite-page {
  max-width: 1480px;
  margin: 18px auto 28px;
  padding: 0 18px;
  display: grid;
  grid-template-columns: minmax(360px, 520px) minmax(520px, 1fr);
  gap: 14px;
  align-items: start;
}
.rewrite-input-panel, .rewrite-output-panel { min-height: 520px; }
.rewrite-history-panel { grid-column: 1 / -1; overflow-x: auto; }
.rewrite-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}
.rewrite-head small {
  display: block;
  margin-bottom: 2px;
  color: #8793a3;
  font-size: 11px;
  font-weight: 700;
}
.rewrite-head h2 { margin: 0; font-size: 20px; }
.rewrite-input-panel textarea {
  width: 100%;
  min-height: 340px;
  padding: 14px;
  resize: vertical;
  border: 1px solid #d9e1ea;
  border-radius: 8px;
  font: inherit;
  line-height: 1.65;
  background: #fff;
}
.rewrite-input-panel textarea:focus {
  outline: 2px solid rgba(15,170,164,.18);
  border-color: #0faaa4;
}
.rewrite-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
}
.rewrite-progress {
  border: 1px solid #dbeeea;
  border-radius: 8px;
  background: #f1f8f7;
  padding: 14px;
  margin-bottom: 14px;
}
.progress-title {
  color: #0f766e;
  font-size: 14px;
  font-weight: 800;
  margin-bottom: 10px;
}
.rewrite-progress ol {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 7px;
}
.rewrite-progress li {
  position: relative;
  padding-left: 26px;
  color: #6b7280;
  font-size: 13px;
}
.rewrite-progress li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid #cbd5e1;
  background: #fff;
}
.rewrite-progress li.active {
  color: #075985;
  font-weight: 700;
}
.rewrite-progress li.active::before {
  border-color: #38bdf8;
  background: #e0f2fe;
  box-shadow: 0 0 0 4px rgba(56,189,248,.14);
}
.rewrite-progress li.done {
  color: #0f766e;
}
.rewrite-progress li.done::before {
  content: "✓";
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  border-color: #0faaa4;
  background: #0faaa4;
}
.rewrite-result.empty-result {
  min-height: 330px;
  display: grid;
  align-content: center;
  justify-items: center;
  text-align: center;
  border: 1px dashed #d7dee8;
  border-radius: 8px;
  background: #fbfcfd;
}
.rewrite-article dl {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  gap: 14px;
  margin: 0;
  padding: 14px 0;
  border-bottom: 1px solid #edf1f5;
}
.rewrite-article dt {
  color: #718096;
  font-size: 13px;
  font-weight: 700;
}
.rewrite-article dd {
  margin: 0;
  color: #1f2937;
  line-height: 1.8;
  overflow-wrap: anywhere;
}
.rewrite-article b { font-size: 18px; }
.rewrite-copy-row {
  display: flex;
  justify-content: flex-end;
  padding-top: 14px;
}
.compliance-note { color: #92400e !important; }

.gen-status {
  display: block;
  margin: 14px 0 0;
  padding: 10px 14px;
  text-align: center;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  transition: background .2s, color .2s;
}
.gen-status.state-loading {
  background: #e0f2fe;
  color: #075985;
  border: 1px solid #bae6fd;
}
.gen-status.state-success {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #bbf7d0;
}
.gen-status.state-warn {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
}
.gen-status.state-error {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

tr.row-new {
  animation: rowFlash 2.2s ease-out;
}
@keyframes rowFlash {
  0%   { background: #fef3c7; }
  60%  { background: #fef3c7; }
  100% { background: transparent; }
}

.result-panel { min-height: 680px; max-height: calc(100vh - 128px); overflow: auto; }
.result-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.result-head span { color: #64748b; font-size: 14px; }
.empty-result b { display: block; font-size: 22px; margin: 28px 0 8px; }
.empty-result p { color: #8a94a6; margin: 0 0 28px; }
.skeleton-card {
  height: 156px;
  border: 1px solid #e4e9ef;
  border-radius: 10px;
  display: grid;
  grid-template-columns: 116px 1fr 42px;
  align-items: center;
  gap: 22px;
  padding: 18px;
  margin-bottom: 14px;
}
.doc-icon {
  width: 92px;
  height: 92px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  color: #7c9a9a;
  background: linear-gradient(135deg, #edf7f6, #f6fbfa);
  font-size: 40px;
}
.skeleton-card i {
  display: block;
  height: 12px;
  border-radius: 10px;
  margin: 14px 0;
  background: linear-gradient(90deg, #d9dadd, #eeeeef);
}
.skeleton-card i:nth-child(1) { width: 52%; height: 16px; }
.skeleton-card i:nth-child(2) { width: 43%; }
.skeleton-card i:nth-child(3) { width: 68%; }
.skeleton-card i:nth-child(4) { width: 64%; }
.skeleton-card em { justify-self: end; align-self: start; padding: 4px 8px; border-radius: 8px; background: #e4f5f3; color: #0f8f8b; font-style: normal; }
.loading-card { border-radius: 10px; background: #edf8f6; color: #0f766e; padding: 36px; text-align: center; }
.article-card {
  border: 0;
  border-top: 1px solid #e0e7ef;
  border-radius: 0;
  padding: 22px 4px;
  margin-bottom: 0;
  display: grid;
  grid-template-columns: 44px 1fr 100px;
  gap: 14px;
  background: #fff;
}
.article-num { color: #64748b; font-size: 24px; font-weight: 600; }
.article-main dl { display: grid; grid-template-columns: 82px minmax(0, 1fr); gap: 14px; margin: 0 0 14px; }
.article-main dt { color: #718096; font-size: 13px; font-weight: 600; }
.article-main dd { margin: 0; color: #1f2937; line-height: 1.75; overflow-wrap: anywhere; }
.article-main b { font-size: 17px; }
.article-main .compliance {
  display: grid;
  gap: 3px;
  color: #92400e;
  font-size: 12px;
  margin: 14px 0 0;
  padding: 10px 12px;
  border-left: 3px solid #f59e0b;
  background: #fffbeb;
}
.article-main .compliance strong { color: #78350f; font-size: 12px; }
.article-actions { display: grid; align-content: start; gap: 10px; }

.history-panel { min-width: 0; overflow-x: auto; }
.history-heading { margin-bottom: 16px; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 11px 10px; border-bottom: 1px solid #eef0f3; font-size: 13px; text-align: left; vertical-align: middle; }
.table th { background: #f6f8fa; color: #5f6b7a; font-weight: 700; }
.table tr:hover { background: #fafbff; }
.log-detail-row:hover { background: transparent !important; }
.log-detail-row > td { padding: 0 10px 12px !important; background: #fff; }
.history-empty { padding: 34px 12px !important; color: #8793a3; text-align: center !important; }
.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  padding-top: 16px;
}
.pagination a, .pagination span {
  min-width: 34px;
  height: 34px;
  padding: 0 10px;
  border: 1px solid #dfe5ec;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #475569;
  background: #fff;
  font-size: 13px;
}
.pagination a:hover { border-color: #0faaa4; color: #087f7a; text-decoration: none; }
.pagination .current { border-color: #078f89; color: #fff; background: #078f89; font-weight: 700; }
.pagination .disabled { color: #a8b0bc; background: #f6f8fa; }
.pagination .ellipsis { min-width: 22px; padding: 0; border-color: transparent; background: transparent; }
.tag { display: inline-block; padding: 4px 9px; border-radius: 8px; font-size: 12px; background: #eef2f7; color: #334155; }
.tag-success, .tag-passed { background: #e5f6f3; color: #0f766e; }
.tag-failed, .tag-rejected, .tag-error { background: #fee2e2; color: #991b1b; }
.tag-raw_text, .tag-partial { background: #fff7ed; color: #c2410c; }
.tags .tag { margin-right: 6px; background: #eaf3ff; color: #1464c8; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 7px;
  border: 1px solid #d9e1ea;
  cursor: pointer;
  font: inherit;
  background: #fff;
  color: #111827;
}
.btn:hover { filter: brightness(.98); text-decoration: none; }
.btn-primary { background: #078f89; color: #fff; border-color: #078f89; }
.btn-danger { background: #dc2626; color: #fff; }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 12px; font-size: 13px; color: #0f8f8b; border-color: #0faaa4; background: #fff; }
.btn[disabled] { opacity: .6; cursor: not-allowed; }
.alert { padding: 12px 14px; border-radius: 8px; margin-bottom: 12px; }
.alert-error  { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-warn   { background: #fff7ed; color: #c2410c; border: 1px solid #fed7aa; }
.alert-success{ background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.muted { color: #6b7280; }
.small { font-size: 12px; }

.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(180deg,#eef8f6 0%,#d9f1ee 100%); }
.login-card { width: 360px; max-width: 92vw; padding: 22px; }
.card { padding: 16px; margin-bottom: 16px; }

@media (max-width: 1180px) {
  .workbench { grid-template-columns: 1fr; }
  .rewrite-page { grid-template-columns: 1fr; }
  .summary-panel { position: static; }
  .result-panel { max-height: none; }
  .topbar-inner { align-items: flex-start; flex-direction: column; gap: 10px; }
  .topbar-notice, .topnav { justify-self: start; }
  .topnav { margin-left: 0; }
}
@media (max-width: 680px) {
  .topbar { position: static; }
  .topbar-inner { padding: 12px 16px; }
  .brand-text strong { font-size: 20px; }
  .topbar-notice { width: 100%; white-space: normal; }
  .topnav { width: 100%; gap: 4px; flex-wrap: nowrap; }
  .nav-link { padding: 7px 6px; }
  .user-chip {
    width: auto;
    min-width: 0;
    margin-left: 0;
    padding: 0 7px;
    border-left: 1px solid #e5e7eb;
    border-right: 1px solid #e5e7eb;
  }
  .user-chip .avatar { width: 32px; height: 32px; flex: 0 0 auto; }
  .user-chip strong, .user-chip small { white-space: nowrap; }
  .workbench { padding: 0 10px; margin-top: 12px; }
  .rewrite-page { padding: 0 10px; margin-top: 12px; }
  .rewrite-actions { align-items: stretch; flex-direction: column; }
  .rewrite-actions .btn { width: 100%; min-height: 46px; }
  .rewrite-article dl { grid-template-columns: 1fr; gap: 6px; }
  .channel-grid, .two-col { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .purpose-grid { grid-template-columns: 1fr; }
  .history-panel { padding: 14px 10px; }
  .table th, .table td { padding: 9px 7px; }
  .pagination { justify-content: center; flex-wrap: wrap; }
  .pagination a, .pagination span { min-width: 32px; height: 32px; padding: 0 8px; }
  .article-card { grid-template-columns: 1fr; }
  .article-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .article-main dl { grid-template-columns: 1fr; gap: 4px; }
}
