:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --primary: #5b5bd6;
  --primary-hover: #4b4bc4;
  --danger: #dc2626;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.6;
}

button, input { font-family: inherit; font-size: 14px; }
button { cursor: pointer; }

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.primary {
  border: 0; border-radius: 8px; padding: 10px 20px;
  background: var(--primary); color: #fff; font-weight: 600;
}
.primary:hover { background: var(--primary-hover); }
.primary:disabled { opacity: .55; cursor: not-allowed; }

.ghost {
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 14px;
  background: #fff; color: var(--text);
}
.ghost:hover { border-color: var(--primary); color: var(--primary); }

.danger {
  border: 1px solid #fecaca; border-radius: 8px; padding: 8px 14px;
  background: #fff5f5; color: var(--danger);
}
.danger:hover { background: #fee2e2; }

/* ---------- 登录 ---------- */
.login-wrap {
  min-height: 100vh; display: grid; place-items: center;
  background: linear-gradient(160deg, #eef1fa 0%, #f7f8fc 100%);
  padding: 24px;
}
.login-card {
  width: 100%; max-width: 440px; background: var(--card);
  border-radius: 16px; padding: 36px; box-shadow: 0 12px 40px rgba(31, 41, 55, .08);
}
.brand { display: flex; align-items: center; gap: 14px; margin-bottom: 28px; }
.brand-logo {
  width: 48px; height: 48px; border-radius: 12px; flex: none;
  display: grid; place-items: center;
  background: var(--primary); color: #fff; font-weight: 700; font-size: 18px;
}
.brand-logo.small { width: 30px; height: 30px; border-radius: 8px; font-size: 12px; }
.brand h1 { font-size: 20px; margin: 0; }
.brand p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }

.login-card label, .field label { display: block; font-weight: 600; margin: 16px 0 6px; }
.login-card input[type="text"], .login-card input[type="password"], .field input[type="text"] {
  width: 100%; padding: 11px 12px; border: 1px solid var(--border);
  border-radius: 8px; background: #fbfcfe; outline: none;
}
.login-card input:focus, .field input:focus { border-color: var(--primary); background: #fff; }
.login-card .primary { width: 100%; margin-top: 24px; }
.agreement-line { text-align: center; color: var(--muted); font-size: 12px; margin: 18px 0 0; }
.error { color: var(--danger); margin: 10px 0 0; min-height: 20px; font-size: 13px; }
.msg { min-height: 20px; margin: 10px 0 0; color: var(--muted); font-size: 13px; }
.hint { color: var(--muted); margin: -4px 0 18px; }
.warn { color: #b45309; background: #fffbeb; border: 1px solid #fde68a; border-radius: 8px; padding: 8px 10px; font-size: 12px; margin: 8px 0 0; }

/* ---------- 主界面 ---------- */
.topbar {
  height: 60px; background: #fff; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; padding: 0 28px;
}
.topbar-title { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; }
.topbar-right { display: flex; align-items: center; gap: 14px; color: var(--muted); font-size: 13px; }
.storage-info { padding: 4px 10px; border-radius: 999px; background: #f3f4f6; }
.storage-info.alert { background: #fee2e2; color: var(--danger); }

.container { max-width: 1180px; margin: 0 auto; padding: 24px; display: grid; gap: 20px; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; }
.card h2 { font-size: 16px; margin: 0 0 12px; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.field.span-2 { grid-column: 1 / -1; }
@media (max-width: 800px) { .form-grid, .settings-grid { grid-template-columns: 1fr; } }

.drop-zone {
  border: 1.5px dashed #cbd5e1; border-radius: 10px; padding: 22px;
  text-align: center; color: var(--muted); background: #fbfcfe; position: relative;
}
.drop-zone.dragover { border-color: var(--primary); background: #f2f2ff; }
.drop-zone input[type="file"] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.file-summary { font-size: 12px; color: var(--muted); min-height: 18px; margin: 8px 0 0; word-break: break-all; }

.table-wrap { overflow-x: auto; }
.case-table { width: 100%; border-collapse: collapse; }
.case-table th, .case-table td { text-align: left; padding: 11px 10px; border-bottom: 1px solid var(--border); font-size: 13px; vertical-align: middle; }
.case-table th { color: var(--muted); font-weight: 600; background: #fafbfd; }
.case-table tr:hover td { background: #fafbff; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; }
.badge.success { background: #dcfce7; color: #166534; }
.badge.processing, .badge.pending { background: #fef3c7; color: #92400e; }
.badge.failed { background: #fee2e2; color: #991b1b; }
.badge.enabled { background: #e0e7ff; color: #3730a3; }
.badge.disabled { background: #f3f4f6; color: #6b7280; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.row-actions button { padding: 5px 10px; font-size: 12px; }

.audit-list { max-height: 260px; overflow: auto; font-size: 12px; color: var(--muted); }
.audit-list div { padding: 5px 0; border-bottom: 1px dashed var(--border); font-family: ui-monospace, Consolas, monospace; }

/* ---------- 抽屉 / 弹窗 ---------- */
.mask {
  position: fixed; inset: 0; background: rgba(17, 24, 39, .45);
  display: grid; place-items: center; z-index: 20; padding: 20px;
}
.drawer {
  width: min(1040px, 100%); max-height: 92vh; overflow: auto;
  background: #fff; border-radius: 14px; padding: 22px;
}
.drawer-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.drawer-head h2 { margin: 0; font-size: 18px; }
.detail-top { display: grid; grid-template-columns: 320px 1fr; gap: 22px; }
@media (max-width: 800px) { .detail-top { grid-template-columns: 1fr; } }
.qr-box { border: 1px solid var(--border); border-radius: 10px; padding: 16px; text-align: center; }
.qr-box img { width: 180px; height: 180px; image-rendering: pixelated; }
.share-url { font-size: 11px; color: var(--muted); word-break: break-all; }
.state-line { font-size: 12px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 12px; }
.detail-meta h3 { font-size: 14px; margin: 0 0 8px; }
.detail-meta h3:not(:first-child) { margin-top: 20px; }
.model-list { margin: 0; padding-left: 18px; max-height: 180px; overflow: auto; font-size: 13px; }
.status-text { font-size: 13px; }
.preview-title { font-weight: 600; margin: 22px 0 10px; }
.preview-scope {
  height: 600px; border-radius: 10px; overflow: hidden;
  background: radial-gradient(ellipse 88% 78% at 50% 42%,
    var(--viewer-bg-center, #d0d0d0) 18%,
    var(--viewer-bg-edge, #525a63) 100%);
  border: 1px solid var(--border);
}
.preview-stage { position: absolute; inset: 0 0 20% 0; }
.preview-stage canvas { display: block; width: 100%; height: 100%; }
.viewer-loading {
  position: absolute; inset: 0; display: grid; place-items: center;
  color: var(--muted); font-size: 13px; pointer-events: none;
}
.viewer-scope[data-viewer-bg="gray"] .viewer-loading { color: #111827; }
.viewer-scope[data-viewer-bg="black"] .viewer-loading { color: #e5e7eb; }

.dialog { width: min(560px, 100%); background: #fff; border-radius: 14px; padding: 24px; }
.dialog h2 { margin: 0 0 10px; }
.purge-list { max-height: 220px; overflow: auto; padding-left: 18px; font-size: 13px; }

/* ---------- 协议页 ---------- */
.legal-page { padding: 32px 16px; }
.legal-card { max-width: 760px; margin: 0 auto; background: #fff; border: 1px solid var(--border); border-radius: 14px; padding: 36px; }
.legal-card h1 { font-size: 26px; margin: 18px 0 4px; }
.legal-card h2 { font-size: 16px; margin: 26px 0 8px; }
.legal-card p { color: #374151; }
.legal-version { color: var(--muted); font-size: 13px; }
.back-link { font-size: 13px; }

/* ---------- 二维码地址 / 存储设置 ---------- */
.settings-grid .field label { margin-top: 0; }
.settings-grid .field input[type="text"], .settings-grid .field input[type="number"],
.detail-meta input[type="text"] {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 8px; background: #fbfcfe; outline: none;
}
.settings-grid .field input:focus, .detail-meta input:focus { border-color: var(--primary); background: #fff; }
.btn-row.left { justify-content: flex-start; margin-top: 10px; }
.state-badge { display: inline-block; padding: 3px 12px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.state-badge.local { background: #fee2e2; color: #991b1b; }
.state-badge.lan { background: #fef3c7; color: #92400e; }
.state-badge.public { background: #dcfce7; color: #166534; }
.state-badge.invalid { background: #fee2e2; color: #991b1b; }
.notice { font-size: 13px; line-height: 1.6; border-radius: 8px; padding: 10px 12px; margin: 0 0 18px; }
.notice.local, .notice.invalid { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }
.notice.lan { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; }
.notice.public { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; }
.qr-box .notice { text-align: left; margin: 10px 0 0; font-size: 12px; }
.lan-list { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 10px; font-size: 12px; color: var(--muted); }
.lan-list button { padding: 4px 9px; font-size: 12px; }
.storage-info.alert { background: #fee2e2; color: var(--danger); }

/* ---------- 分类归档 ---------- */
.filter-row { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.filter-row select {
  padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px;
  background: #fff; color: var(--text); font-family: inherit; font-size: 13px;
}
.badge.category { background: #e0e7ff; color: #3730a3; }
.detail-meta .btn-row.left input { max-width: 220px; }

/* ---------- 页内确认弹窗与提示条 ---------- */
.confirm-mask { z-index: 30; }
.confirm-mask .dialog { max-width: 440px; }
.confirm-mask .dialog p { color: #374151; white-space: pre-line; }
.toast {
  position: fixed; left: 50%; bottom: 32px; transform: translateX(-50%);
  max-width: min(560px, 90vw); padding: 12px 20px; border-radius: 10px;
  background: #1f2937; color: #fff; font-size: 13px; line-height: 1.5;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .22); z-index: 50;
}
