:root {
  color: #111827;
  background: #f4f6f8;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  --border: #dbe1ea;
  --muted: #64748b;
  --brand: #1677ff;
  --brand-dark: #0958d9;
  --surface: #ffffff;
  --success: #15803d;
  --danger: #be123c;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: #f4f6f8;
}

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

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: .55;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #fff;
  color: #111827;
  outline: none;
}

input,
select {
  height: 40px;
  padding: 0 11px;
}

textarea {
  min-height: 180px;
  padding: 12px;
  resize: vertical;
  line-height: 1.7;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #1677ff;
  box-shadow: 0 0 0 3px #1677ff1a;
}

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

.topbar {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: #fff;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.25;
}

.topbar p,
.result-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.status-chip {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  padding: 0 11px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #475569;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.status-chip.ok {
  background: #dcfce7;
  color: var(--success);
}

.status-chip.warn {
  background: #fff1f2;
  color: var(--danger);
}

.workspace {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(360px, 520px) minmax(520px, 1fr);
  gap: 14px;
  padding: 14px;
}

.composer,
.result-panel {
  min-height: 0;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  overflow: hidden;
}

.composer {
  gap: 14px;
  padding: 16px;
}

.composer label {
  display: grid;
  gap: 7px;
  color: #334155;
  font-size: 13px;
  font-weight: 800;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.body-field textarea {
  min-height: 160px;
}

.confirm-row {
  grid-template-columns: 18px 1fr;
  align-items: center;
  gap: 9px;
  color: #475569;
}

.confirm-row input {
  width: 16px;
  height: 16px;
}

.form-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid #edf2f7;
  padding-top: 14px;
}

.form-message {
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.form-message.ok {
  color: var(--success);
}

.form-message.warn {
  color: var(--danger);
}

.form-actions button,
.result-header button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  border-radius: 7px;
  background: var(--brand);
  color: #fff;
  font-weight: 800;
  white-space: nowrap;
}

.form-actions button:hover,
.result-header button:hover {
  background: var(--brand-dark);
}

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

.result-header button.danger-button {
  background: #b91c1c;
}

.result-header button.danger-button:hover {
  background: #991b1b;
}

.result-header {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.result-header h2 {
  margin: 0;
  font-size: 17px;
}

.command-summary,
.draft-info,
.publish-status {
  padding: 12px 16px;
  border-bottom: 1px solid #edf2f7;
}

.command-summary:empty,
.draft-info:empty,
.publish-status:empty {
  display: none;
}

.publish-status {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.publish-status.ok {
  color: var(--success);
}

.publish-status.warn {
  color: var(--danger);
}

.publish-status.pending {
  color: var(--brand-dark);
}

.command-summary dl,
.draft-info dl {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 14px;
  margin: 0;
}

.command-summary div,
.draft-info div {
  min-width: 0;
}

.command-summary dt,
.draft-info dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.command-summary dd,
.draft-info dd {
  margin: 3px 0 0;
  overflow: hidden;
  color: #111827;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tabs {
  display: flex;
  gap: 4px;
  padding: 10px 16px;
  border-bottom: 1px solid #edf2f7;
  background: #fbfcfd;
}

.tab {
  min-height: 32px;
  padding: 0 12px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.tab.active {
  background: #fff;
  color: var(--brand);
  box-shadow: inset 0 0 0 1px var(--border);
}

.preview-panel,
.html-panel {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.preview-panel {
  margin: 0 auto;
  width: min(760px, 100%);
  padding: 28px 28px 42px;
  background: #fff;
  line-height: 1.75;
}

.preview-panel img {
  max-width: 100%;
  height: auto;
}

.html-panel {
  min-height: 100%;
  border: 0;
  border-radius: 0;
  padding: 16px;
  font-family: "SF Mono", Consolas, monospace;
  font-size: 12px;
  line-height: 1.65;
}

.empty-state {
  min-height: 360px;
  display: grid;
  place-items: center;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 960px) {
  .app-shell {
    height: auto;
  }

  .topbar,
  .form-actions,
  .result-header {
    align-items: stretch;
    flex-direction: column;
  }

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

  .workspace {
    min-height: 0;
  }

  .preview-panel {
    padding: 22px 16px 34px;
  }
}

.stats-page {
  background: #eef3f8;
}

.stats-shell {
  min-height: 100vh;
  padding: 22px;
}

.stats-header {
  min-height: 112px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin: 0 auto 16px;
  max-width: 1680px;
  padding: 22px 26px;
  border: 1px solid rgba(203, 213, 225, .85);
  border-radius: 18px;
  background: rgba(255, 255, 255, .88);
  box-shadow: 0 18px 50px rgba(15, 23, 42, .08);
}

.stats-header h1 {
  margin: 3px 0 8px;
  font-size: 30px;
  line-height: 1.15;
}

.stats-header p {
  margin: 0;
  color: var(--muted);
}

.stats-header .eyebrow {
  color: var(--brand);
  font-size: 13px;
  font-weight: 900;
}

.stats-header-actions,
.stats-link {
  display: inline-flex;
  align-items: center;
}

.stats-header-actions {
  gap: 10px;
}

.stats-link {
  min-height: 40px;
  justify-content: center;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: #111827;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.stats-layout {
  max-width: 1680px;
  min-height: calc(100vh - 172px);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 16px;
}

.stats-sidebar,
.stats-main {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 16px;
}

.stats-card,
.stats-summary-card {
  border: 1px solid rgba(203, 213, 225, .86);
  border-radius: 14px;
  background: rgba(255, 255, 255, .92);
  box-shadow: 0 12px 36px rgba(15, 23, 42, .06);
}

.stats-card {
  padding: 18px;
}

.stats-card h2 {
  margin: 0 0 14px;
  font-size: 17px;
}

.stats-card label {
  display: grid;
  gap: 7px;
  margin-bottom: 12px;
  color: #334155;
  font-size: 13px;
  font-weight: 850;
}

.stats-checkset {
  display: grid;
  gap: 8px;
  margin: 0 0 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f8fafc;
}

.stats-checkset legend {
  padding: 0 4px;
  color: #334155;
  font-size: 13px;
  font-weight: 900;
}

.stats-checkset label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}

.stats-checkset input {
  width: 16px;
  height: 16px;
  accent-color: var(--brand);
}

.stats-help {
  margin: -4px 0 12px;
  color: #64748b;
  font-size: 13px;
  line-height: 1.6;
}

.stats-card button,
.stats-table-card button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  font-weight: 850;
}

.stats-button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.stats-card button:hover,
.stats-table-card button:hover {
  background: var(--brand-dark);
}

.stats-message {
  min-height: 22px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.stats-message.ok {
  color: var(--success);
}

.stats-message.warn {
  color: var(--danger);
}

.stats-message.pending {
  color: var(--brand-dark);
}

.stats-status-box {
  display: grid;
  gap: 10px;
}

.stats-status-list {
  display: grid;
  gap: 10px;
  margin: 0;
}

.stats-status-list div {
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #f8fafc;
}

.stats-status-list dt {
  color: #334155;
  font-size: 12px;
  font-weight: 900;
}

.stats-status-list dd {
  display: grid;
  gap: 4px;
  min-width: 0;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.stats-status-list a {
  overflow-wrap: anywhere;
  color: var(--brand);
  font-weight: 800;
  text-decoration: none;
}

.stats-account-list {
  display: grid;
  gap: 9px;
}

.stats-account-option {
  width: 100%;
  min-height: 68px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  color: #111827;
  text-align: left;
}

.stats-account-option.active {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(22, 119, 255, .14);
}

.stats-account-option img,
.stats-avatar-fallback {
  width: 42px;
  height: 42px;
  border-radius: 10px;
}

.stats-account-option img {
  object-fit: cover;
}

.stats-avatar-fallback {
  display: grid;
  place-items: center;
  background: #e0edff;
  color: var(--brand);
  font-weight: 900;
}

.stats-account-option strong,
.stats-account-option small {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stats-account-option small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.stats-account-option em {
  color: var(--brand);
  font-size: 12px;
  font-style: normal;
  font-weight: 900;
}

.stats-empty,
.stats-empty-cell {
  color: #94a3b8;
  text-align: center;
}

.zhizix-qr-box {
  display: grid;
  justify-items: center;
  gap: 10px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
}

.zhizix-qr-box:empty {
  display: none;
}

.zhizix-qr-box img {
  width: 180px;
  height: 180px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
}

.stats-fallback {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid #edf2f7;
}

.stats-fallback summary {
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
  cursor: pointer;
}

.stats-progress-card {
  display: grid;
  gap: 14px;
}

.stats-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.stats-section-title h2 {
  margin: 0;
}

.stats-section-title p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.stats-section-title span {
  color: var(--brand);
  font-weight: 900;
}

.stats-progress-track {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #e2e8f0;
}

.stats-progress-track span {
  width: 0%;
  height: 100%;
  display: block;
  border-radius: inherit;
  background: var(--brand);
  transition: width .2s ease;
}

.stats-steps {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.stats-steps span {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f8fafc;
  color: #64748b;
  font-size: 13px;
  font-weight: 850;
  text-align: center;
}

.stats-steps span.active {
  border-color: rgba(22, 119, 255, .36);
  background: #eaf3ff;
  color: var(--brand);
}

.stats-steps span.done {
  border-color: rgba(21, 128, 61, .28);
  background: #dcfce7;
  color: var(--success);
}

.stats-logs {
  min-height: 54px;
  margin: 0;
  padding: 10px 16px;
  border-radius: 10px;
  background: #f8fafc;
  color: #475569;
  font-size: 13px;
  line-height: 1.6;
}

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

.stats-summary-card {
  min-height: 86px;
  display: grid;
  align-content: center;
  gap: 5px;
  padding: 16px;
}

.stats-summary-card span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}

.stats-summary-card strong {
  font-size: 27px;
  line-height: 1;
}

.stats-table-card {
  min-height: 520px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 14px;
}

.stats-table-wrap {
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.stats-table {
  width: 100%;
  min-width: 1120px;
  border-collapse: collapse;
  background: #fff;
}

.stats-table th,
.stats-table td {
  border-bottom: 1px solid #e2e8f0;
  padding: 10px;
  text-align: left;
  vertical-align: top;
}

.stats-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fafc;
  color: #334155;
  font-size: 12px;
  font-weight: 900;
}

.stats-table td {
  color: #111827;
  font-size: 13px;
}

.stats-table td:nth-child(1),
.stats-table td:nth-child(2),
.stats-table td:nth-child(3),
.stats-table td:nth-child(6),
.stats-table td:nth-child(7),
.stats-table td:nth-child(8) {
  white-space: nowrap;
}

.stats-table td strong,
.stats-table td small {
  display: block;
  max-width: 360px;
}

.stats-table td small {
  margin-top: 4px;
  color: #64748b;
}

.stats-table a {
  color: var(--brand);
  font-weight: 800;
  text-decoration: none;
}

.stats-table input {
  width: 118px;
  height: 34px;
  border-radius: 7px;
}

.stats-table input[data-field="remark"] {
  width: 160px;
}

.stats-week-row td {
  background: #fff7ed;
  color: #9a3412;
  font-weight: 900;
}

.stats-empty-cell {
  height: 160px;
  vertical-align: middle;
}

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

.access-stat-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  background: #f8fafc;
}

.access-stat-card span {
  display: block;
  color: #64748b;
  font-size: 13px;
  font-weight: 800;
}

.access-stat-card strong {
  display: block;
  margin-top: 8px;
  color: #0f172a;
  font-size: 24px;
  line-height: 1.2;
}

.admin-shell {
  max-width: 920px;
  margin: 0 auto;
}

.admin-card {
  margin: 0 auto 16px;
  width: 100%;
}

.admin-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

@media (max-width: 1180px) {
  .stats-layout {
    grid-template-columns: 1fr;
  }

  .stats-sidebar {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .stats-summary-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .stats-shell {
    padding: 10px;
  }

  .stats-header,
  .stats-section-title {
    align-items: stretch;
    flex-direction: column;
  }

  .stats-sidebar,
  .stats-steps,
  .stats-summary-grid,
  .access-summary-grid,
  .admin-grid {
    grid-template-columns: 1fr;
  }
}
