:root {
  color-scheme: light;
  --ink: #17202a;
  --muted: #667085;
  --line: #d8dee8;
  --panel: #ffffff;
  --band: #f4f7fb;
  --blue: #1f5eff;
  --green: #16825d;
  --red: #c24132;
  --amber: #a15c00;
  --teal: #0f766e;
  font-family: Inter, "Microsoft YaHei", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--band);
  color: var(--ink);
}

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

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

button {
  border: 0;
  border-radius: 6px;
  background: var(--blue);
  color: #fff;
  min-height: 36px;
  padding: 0 14px;
  cursor: pointer;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

button.ghost {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

button.ghost.danger {
  border-color: rgba(194, 65, 50, 0.4);
  background: #fff;
  color: var(--red);
}

button.ghost.danger:hover,
button.ghost.danger:focus-visible {
  background: var(--red);
  color: #fff;
}

button.danger {
  background: var(--red);
  color: #fff;
}

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

button.primary-block {
  width: 100%;
  background: var(--blue);
  color: #fff;
  min-height: 40px;
}

button.link-button {
  min-height: auto;
  padding: 0;
  border-radius: 0;
  background: transparent;
  color: var(--blue);
  text-decoration: underline;
}

.prototype-workflow {
  display: grid;
  gap: 12px;
  padding: 16px 20px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.prototype-head,
.prototype-tabs,
.prototype-filters,
.prototype-form,
.prototype-drawer {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.prototype-head h3,
.prototype-head p {
  margin: 0;
}

.prototype-head p,
.prototype-filters,
.prototype-drawer span {
  color: var(--muted);
  font-size: 13px;
}

.prototype-filters span {
  padding-right: 10px;
  border-right: 1px solid var(--line);
}

.prototype-workflow details {
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.prototype-workflow summary {
  color: var(--blue);
  cursor: pointer;
  font-weight: 600;
}

.prototype-form {
  padding-top: 12px;
}

.prototype-form label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}

.prototype-form input,
.prototype-form select {
  min-width: 150px;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  background: #fff;
  color: var(--ink);
}

.prototype-drawer {
  justify-content: space-between;
  padding: 10px 0 0;
  border-top: 1px dashed var(--line);
}

/* ---------------------------------------------------------------------------
 * 应用外壳：侧栏 + 工作区
 * ------------------------------------------------------------------------- */

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

.app-shell[hidden] {
  display: none;
}

.sidebar {
  background: #101828;
  color: #fff;
  padding: 20px 14px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 4px 8px 18px;
}

.brand > div {
  display: grid;
  gap: 2px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: #2f6fed;
  font-weight: 800;
}

.brand small,
.eyebrow {
  color: var(--muted);
  font-size: 12px;
}

.brand small {
  color: #b8c4d8;
}

.nav-list {
  display: grid;
  gap: 4px;
}

.nav-item {
  width: 100%;
  display: grid;
  grid-template-columns: 28px 1fr;
  align-items: center;
  text-align: left;
  background: transparent;
  color: #d8dee8;
  border-radius: 6px;
  min-height: 40px;
}

.nav-item.active,
.nav-item:hover {
  background: #253043;
  color: #fff;
}

.nav-icon {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: #36445c;
  font-size: 11px;
  font-weight: 700;
}

.workspace {
  min-width: 0;
  padding: 22px;
}

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

.topbar h1 {
  margin: 4px 0 0;
  font-size: 24px;
  letter-spacing: 0;
}

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

.current-user {
  color: var(--muted);
  font-size: 13px;
}

.current-user[hidden] {
  display: none;
}

input,
select,
textarea {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 0 10px;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
}

/* ---------------------------------------------------------------------------
 * 登录/注册全屏页
 * ------------------------------------------------------------------------- */

.auth-screen {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  overflow: auto;
  background: #eef2f9;
}

.auth-screen[hidden] {
  display: none;
}

.auth-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.risk-map {
  position: absolute;
  inset: 10% 8%;
  border: 1px solid #c9d4e4;
  border-radius: 14px;
  background:
    linear-gradient(90deg, rgba(20, 31, 48, 0.05) 1px, transparent 1px),
    linear-gradient(0deg, rgba(20, 31, 48, 0.05) 1px, transparent 1px),
    rgba(255, 255, 255, 0.5);
  background-size: 42px 42px;
  overflow: hidden;
}

.node,
.route {
  position: absolute;
  display: block;
}

.node {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 0 8px rgba(194, 65, 50, 0.16);
}

.n1 {
  left: 18%;
  top: 26%;
}

.n2 {
  right: 22%;
  top: 42%;
  background: var(--amber);
}

.n3 {
  left: 46%;
  bottom: 24%;
  background: var(--green);
}

.route {
  height: 2px;
  background: #2f6fed;
  transform-origin: left center;
}

.r1 {
  left: 22%;
  top: 30%;
  width: 48%;
  transform: rotate(14deg);
}

.r2 {
  left: 48%;
  top: 58%;
  width: 28%;
  transform: rotate(-24deg);
}

.auth-root {
  position: relative;
  z-index: 1;
  width: min(420px, 100%);
}

.auth-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 18px 60px rgba(16, 24, 40, 0.16);
  padding: 28px 26px;
  display: grid;
  gap: 14px;
}

.auth-head h2 {
  margin: 4px 0 0;
  font-size: 22px;
}

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

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

.auth-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.auth-form input {
  width: 100%;
}

.required-mark {
  margin-right: 3px;
  color: #c24132;
  font-weight: 700;
}

.sms-code-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 132px;
  gap: 8px;
}

.sms-code-row .sms-send-button {
  width: 132px;
  min-height: 42px;
  padding: 0 8px;
  white-space: nowrap;
}

@media (max-width: 440px) {
  .sms-code-row {
    grid-template-columns: 1fr;
  }

  .sms-code-row .sms-send-button {
    width: 100%;
  }
}

.auth-switch {
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

/* ---------------------------------------------------------------------------
 * CMS 列表：工具栏 + 汇总 + 筛选 + 表格 + 分页
 * ------------------------------------------------------------------------- */

.cms-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 2px;
}

.cms-toolbar h2 {
  margin: 0;
  font-size: 18px;
}

.cms-toolbar-actions {
  display: flex;
  gap: 8px;
}

.cms-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}

.cms-summary .metric {
  display: grid;
  gap: 4px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.cms-summary .metric strong {
  font-size: 22px;
  color: var(--ink);
}

.cms-filter {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)) auto;
  gap: 12px;
  align-items: end;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcff;
}

.cms-filter label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.cms-filter input,
.cms-filter select {
  width: 100%;
}

.cms-filter-actions {
  display: flex;
  gap: 8px;
}

.cms-table {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.table-scroll {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}

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

th {
  color: #475467;
  background: #f8fafc;
  font-weight: 700;
  white-space: nowrap;
}

tr:last-child td {
  border-bottom: 0;
}

.cms-row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.cms-row-actions button {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

.cms-empty {
  padding: 32px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

.cms-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 4px;
}

.cms-page-info {
  color: var(--muted);
  font-size: 13px;
}

.cms-page-actions {
  display: flex;
  gap: 8px;
}

/* ---------------------------------------------------------------------------
 * 状态徽标
 * ------------------------------------------------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  background: #e9f7f1;
  color: var(--green);
  font-size: 12px;
}

.badge.warn {
  background: #fff4df;
  color: var(--amber);
}

.badge.risk {
  background: #ffe8e2;
  color: var(--red);
}

.badge.muted {
  background: #eef0f4;
  color: var(--muted);
}

.badge.info {
  background: #e4ecff;
  color: var(--blue);
}

/* ---------------------------------------------------------------------------
 * 头像 / 人员卡片 / 详情网格
 * ------------------------------------------------------------------------- */

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  vertical-align: middle;
  background: #eef0f4;
}

.avatar-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #2f6fed;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  vertical-align: middle;
}

.person-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcff;
}

.person-info {
  display: grid;
  gap: 2px;
}

.person-info strong {
  font-size: 14px;
}

.detail-grid {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}

.detail-row {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 10px;
  align-items: baseline;
  padding: 6px 0;
  border-bottom: 1px dashed var(--line);
}

.detail-label {
  color: var(--muted);
  font-size: 12px;
}

.detail-value {
  font-size: 14px;
  word-break: break-word;
}

.detail-sub-title {
  margin: 16px 0 8px;
  font-size: 15px;
}

.detail-person-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px;
}

.detail-body {
  max-height: 60vh;
  overflow: auto;
}

.qr-preview {
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 14px 0 4px;
}

.qr-image-shell {
  display: grid;
  place-items: center;
  width: 220px;
  min-height: 220px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 13px;
}

.qr-image-shell img {
  width: 200px;
  height: 200px;
  object-fit: contain;
}

/* ---------------------------------------------------------------------------
 * 模态框（反馈 / 确认 / 表单 / 详情）
 * ------------------------------------------------------------------------- */

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

.modal[hidden] {
  display: none;
}

#confirmModal {
  z-index: 40;
}

#feedbackModal {
  z-index: 50;
}

.modal-panel {
  width: min(440px, 100%);
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 22px;
  box-shadow: 0 18px 60px rgba(16, 24, 40, 0.22);
}

.modal.confirm .modal-panel,
.modal.form .modal-panel,
.modal.detail .modal-panel {
  width: min(560px, 100%);
}

.modal.form .modal-panel {
  max-height: calc(100vh - 40px);
  overflow-y: auto;
}

.modal-panel strong {
  display: block;
  margin-bottom: 10px;
  font-size: 18px;
}

.modal-panel p {
  margin: 0 0 16px;
  color: var(--ink);
  white-space: pre-wrap;
  word-break: break-word;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 6px;
}

.modal.form .quick-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.modal.form .quick-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.modal.form .quick-form input,
.modal.form .quick-form select,
.modal.form .quick-form textarea {
  width: 100%;
}

.form-section-title {
  grid-column: 1 / -1;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding-top: 4px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
}

.form-section-title span {
  padding-bottom: 8px;
  font-size: 14px;
  font-weight: 700;
}

.form-section-title small {
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

/* ---------------------------------------------------------------------------
 * 杂项
 * ------------------------------------------------------------------------- */

.status-line {
  min-height: 18px;
  margin: 0;
  color: var(--muted);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

body.loading {
  cursor: progress;
}

body.loading button {
  pointer-events: none;
  opacity: 0.7;
}

/* ---------------------------------------------------------------------------
 * 响应式
 * ------------------------------------------------------------------------- */

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

  .sidebar {
    position: static;
    padding: 12px;
    overflow: hidden;
  }

  .nav-list {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: thin;
  }

  .nav-item {
    flex: 0 0 auto;
    width: auto;
    min-width: 112px;
    padding-inline: 10px;
  }

  .brand {
    padding-bottom: 10px;
  }

  .workspace {
    padding: 16px;
  }

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

  .cms-filter {
    grid-template-columns: 1fr;
  }

  .cms-filter-actions {
    justify-content: stretch;
  }

  .cms-filter-actions button {
    flex: 1;
  }

  .modal.confirm .modal-panel,
  .modal.form .modal-panel,
  .modal.detail .modal-panel {
    width: 100%;
  }

  .detail-row {
    grid-template-columns: 1fr;
  }
}
