:root {
  --navy: #0f172a;
  --navy-soft: #172033;
  --bg: #f4f6fb;
  --card: #ffffff;
  --text: #172033;
  --muted: #6b7280;
  --line: #e5e9f2;
  --accent: #f97316;
  --accent-soft: #fff1e6;
  --danger: #dc2626;
  --ok: #059669;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  line-height: 1.5;
}
a { color: #2563eb; text-decoration: none; }
a:hover { color: #1d4ed8; }
h1 { font-size: 26px; margin: 0 0 18px; letter-spacing: -.02em; }
h2 { font-size: 19px; margin: 26px 0 12px; }
.admin-shell { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 16px;
  background:
    radial-gradient(400px 220px at 0 0, rgba(249, 115, 22, .18), transparent 65%),
    var(--navy);
  color: #e5e7eb;
  display: flex;
  flex-direction: column;
  gap: 18px;
  overflow-y: auto;
}
.admin-brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 800; font-size: 17px; }
.admin-brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, #f97316, #fbbf24);
  color: #fff;
  font-size: 14px;
  font-weight: 900;
  flex: none;
}
.admin-brand img { width: auto; height: 34px; max-width: 130px; object-fit: contain; border-radius: 8px; }
.sidebar nav { display: grid; gap: 5px; }
.sidebar nav a {
  padding: 10px 12px;
  border-radius: 9px;
  color: #cbd5e1;
  font-size: 13px;
  font-weight: 600;
}
.sidebar nav a:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.sidebar nav a.active { background: rgba(249, 115, 22, .16); color: #fdba74; box-shadow: inset 3px 0 0 #f97316; }
.admin-nav { display: grid; gap: 14px; }
.nav-single { display: block; }
.nav-group { display: block; }
.nav-group summary { list-style: none; }
.nav-group summary::-webkit-details-marker { display: none; }
.nav-group summary::after {
  content: "›";
  float: right;
  color: #64748b;
  transition: transform .15s ease;
}
.nav-group[open] summary::after { transform: rotate(90deg); }
.nav-group a { display: block; }
.nav-label {
  padding: 8px 12px 5px;
  color: #94a3b8;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
}
.nav-group a { padding: 8px 12px 8px 22px !important; }
.sidebar .sidebar-foot { margin-top: auto; display: grid; gap: 8px; font-size: 12px; color: #94a3b8; }
.sidebar .sidebar-foot a { color: #fdba74; }
.sidebar-logout { justify-self: start; padding: 0; background: none; color: #94a3b8; font-size: 12px; font-weight: 500; box-shadow: none; }
.sidebar-logout:hover { color: #fff; }
.admin-content { min-width: 0; }
.admin-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 28px;
  background: rgba(255, 255, 255, .86);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}
.admin-topbar .crumb { color: var(--muted); font-size: 13px; }
.admin-topbar .who { font-size: 13px; color: var(--muted); }
.admin-search { display: flex; align-items: center; gap: 7px; flex: 1; max-width: 520px; }
.admin-search input {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #f8fafc;
  font: inherit;
  font-size: 13px;
}
.admin-search button { height: 38px; padding: 0 16px; border-radius: 9px; flex: none; white-space: nowrap; }
.admin-frame-wrap { height: calc(100vh - 103px); background: #f4f6fa; }
.admin-tab-frame { width: 100%; height: 100%; border: 0; display: none; background: #f4f6fa; }
.admin-embed-body { background: #f4f6fa; }
.admin-embed-body .admin-main { max-width: 1180px; margin: 0 auto; padding: 22px 26px 48px; }
.admin-tabs {
  padding: 0 28px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}
.admin-tabs-list { display: flex; align-items: center; gap: 4px; min-height: 40px; }
.admin-tab {
  display: inline-flex;
  align-items: center;
  height: 29px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: #475569;
  background: #f8fafc;
  font-size: 12px;
  white-space: nowrap;
}
.admin-tab:hover { color: #0f172a; background: #eef2f7; }
.admin-tab.active { color: #c2410c; border-color: #fdba74; background: #fff7ed; }
.btn-small { padding: 5px 9px; font-size: 12px; border-radius: 6px; }
.admin-tab-frame { width: 100%; height: 100%; border: 0; display: none; background: #f4f6fa; }
.tab-context {
  position: fixed;
  z-index: 300;
  display: grid;
  min-width: 150px;
  padding: 5px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 9px;
  box-shadow: 0 16px 40px rgba(15, 23, 42, .22);
}
.toast {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 400;
  max-width: min(520px, calc(100vw - 30px));
  padding: 10px 16px;
  border-radius: 9px;
  background: #0f172a;
  color: #fff;
  font-size: 13px;
  box-shadow: 0 14px 34px rgba(15, 23, 42, .28);
}
.toast.hidden { display: none; }
.tab-context.hidden { display: none; }
.admin-modal {
  width: min(460px, calc(100vw - 28px));
  padding: 0;
  border: 0;
  border-radius: 14px;
  box-shadow: 0 24px 80px rgba(15, 23, 42, .28);
}
.admin-modal::backdrop { background: rgba(15, 23, 42, .48); }
.admin-modal form { display: grid; gap: 12px; padding: 20px; margin: 0; }
.admin-modal h2 { margin: 0; font-size: 18px; }
.admin-modal p { margin: 0; }
.admin-modal label { display: grid; gap: 6px; font-size: 13px; color: #374151; }
.admin-modal input {
  width: 100%;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
}
.admin-modal .modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.tab-context button {
  padding: 8px 10px;
  border-radius: 6px;
  background: none;
  color: #334155;
  box-shadow: none;
  font-size: 12px;
  text-align: left;
}
.tab-context button:hover { background: #f1f5f9; }
.admin-main { max-width: 1180px; margin: 0 auto; padding: 26px 28px 60px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; }
.metric {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, .04);
}
.metric b { display: block; font-size: 30px; margin-top: 6px; letter-spacing: -.03em; }
.metric .muted { color: var(--muted); font-size: 12px; }
.admin-form {
  display: grid;
  gap: 11px;
  max-width: 700px;
  margin: 16px 0;
  padding: 18px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
}
.admin-form label { display: grid; gap: 6px; font-size: 13px; color: #374151; }
.admin-form input, .admin-form select, .admin-form textarea {
  width: 100%;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fbfcfe;
  color: var(--text);
  font: inherit;
}
.admin-form input[type="checkbox"] { width: auto; }
.admin-form textarea { min-height: 140px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }
.admin-form button { justify-self: start; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--card); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.table th, .table td { text-align: left; padding: 11px 13px; border-bottom: 1px solid var(--line); font-size: 13px; vertical-align: middle; }
.table th { background: #f8fafc; color: var(--muted); font-weight: 600; }
.table tr:last-child td { border-bottom: 0; }
.table tr:hover td { background: #fbfcff; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 8px; }
.page-head h1 { margin-bottom: 4px; }
.page-head p { margin: 0; }
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form-row label { min-width: 0; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.actions form { display: inline-flex; align-items: center; }
.actions a, .actions button.linklike {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 9px;
  border-radius: 6px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  color: #334155;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
}
.actions a:hover, .actions button.linklike:hover { background: #e2e8f0; color: #0f172a; }
.actions .danger, .actions button.danger { color: #b91c1c; background: #fef2f2; border-color: #fecaca; }
.danger { color: #dc2626 !important; }
.password-reset input {
  width: 110px;
  padding: 5px 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
  font-size: 12px;
}
.table input:not([type="checkbox"]) {
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
  font-size: 12px;
  min-width: 80px;
}
.table select {
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
  font-size: 12px;
}
.detail-grid { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(240px, .7fr); gap: 16px; align-items: start; }
.detail-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px 18px;
}
.detail-card h2 { margin-top: 0; }
.detail-list { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 8px 12px; margin: 0; font-size: 13px; }
.detail-list dt { color: var(--muted); }
.detail-list dd { margin: 0; font-weight: 600; }
.break { word-break: break-all; }
.settings-form { max-width: 900px; }
.settings-section {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px 18px;
  display: grid;
  gap: 12px;
}
.settings-section h2 { margin: 0; font-size: 17px; }
.settings-section p { margin: 0; }
.perm-checks { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 12px; }
.perm-checks .check { display: flex; align-items: center; gap: 7px; font-size: 13px; color: #374151; }
.perm-checks input[type="checkbox"] { width: auto; }
.detail-card.admin-form { max-width: none; }
.msg { padding: 11px 14px; border-radius: 10px; background: #ecfdf5; border: 1px solid #a7f3d0; color: #065f46; margin-bottom: 16px; font-size: 13px; }
.branding-grid { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 16px; align-items: start; }
.branding-preview {
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
}
.branding-preview img { max-width: 180px; max-height: 80px; object-fit: contain; }
@media (max-width: 800px) { .branding-grid { grid-template-columns: 1fr; } }
.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    radial-gradient(700px 360px at 20% 0%, rgba(249, 115, 22, .16), transparent 60%),
    radial-gradient(600px 300px at 100% 100%, rgba(37, 99, 235, .12), transparent 55%),
    #eef2f8;
}
.login-card {
  width: min(420px, 100%);
  display: grid;
  gap: 13px;
  padding: 30px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 24px 70px rgba(15, 23, 42, .16);
}
.login-brand { display: flex; align-items: center; gap: 10px; font-weight: 800; color: var(--navy); }
.login-brand img { width: auto; height: 34px; max-width: 120px; object-fit: contain; border-radius: 8px; }
.login-brand span {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, #f97316, #fbbf24);
  color: #fff;
  font-size: 12px;
  font-weight: 900;
}
.login-card h1 { margin: 4px 0 0; font-size: 24px; }
.login-card p { margin: 0 0 4px; font-size: 13px; }
.login-card label { display: grid; gap: 6px; font-size: 13px; color: #374151; }
.login-card input {
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fbfcfe;
  color: var(--text);
  font: inherit;
}
.login-card input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(249, 115, 22, .14); }
.login-card button { margin-top: 6px; }
.login-back { text-align: center; font-size: 12px; color: var(--muted); }
.error { color: var(--danger); font-size: 13px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.inline { display: inline; }
.linklike { background: none; border: 0; color: #2563eb; cursor: pointer; padding: 0; font: inherit; }
button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 14px;
  border: 0;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
button:hover { filter: brightness(1.05); }
button:disabled { background: #94a3b8; cursor: not-allowed; }
@media (max-width: 800px) {
  .admin-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; padding: 14px; }
  .sidebar nav { display: flex; flex-wrap: wrap; }
  .admin-nav { flex-direction: column; align-items: stretch; gap: 10px; }
  .nav-group { display: flex; flex-wrap: wrap; gap: 4px; }
  .nav-label { width: 100%; }
  .nav-group a { padding: 8px 10px !important; }
  .admin-search { max-width: none; flex: 1; }
  .sidebar .sidebar-foot { display: none; }
  .admin-main { padding: 18px 14px 40px; }
  .admin-topbar { padding: 12px 14px; }
  .table { display: block; overflow-x: auto; }
}

.admin-dialog {
  width: min(1040px, calc(100vw - 48px));
  height: min(860px, calc(100vh - 48px));
  padding: 0;
  border: 0;
  border-radius: 12px;
  box-shadow: 0 28px 80px rgba(15, 23, 42, .35);
  overflow: hidden;
}
.admin-dialog::backdrop { background: rgba(15, 23, 42, .52); }
.admin-dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 50px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}
.admin-dialog-title { font-size: 15px; color: #0f172a; }
.admin-dialog-close {
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 6px;
  background: #f1f5f9;
  color: #475569;
  box-shadow: none;
}
.admin-dialog-close:hover { background: #e2e8f0; filter: none; }
.admin-dialog-body { position: relative; height: calc(100% - 50px); }
.admin-dialog-frame { width: 100%; height: 100%; border: 0; display: block; }
.admin-dialog-loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #64748b;
  background: #f8fafc;
  z-index: 2;
}
.admin-dialog-loading.hidden { display: none; }

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 14px 0;
  padding: 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.filter-bar input, .filter-bar select {
  height: 34px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  font: inherit;
  font-size: 13px;
}
.filter-bar input[name="q"] { min-width: 220px; }
.filter-bar > button[type="submit"] {
  height: 34px;
  padding: 0 14px;
  border-radius: 7px;
  background: var(--accent);
  color: #fff;
  border: 0;
  font-weight: 700;
}
.pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 10px 0;
}
.pager-links { display: inline-flex; align-items: center; gap: 8px; }
.pager select { height: 30px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }

.error-text { color: #b91c1c; font-size: 12px; }
.table code { word-break: break-all; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin: 14px 0; }
.stat-card { background: #fff; border: 1px solid var(--line); border-radius: 9px; padding: 12px; display: flex; flex-direction: column; gap: 4px; }
.stat-card span { color: #64748b; font-size: 12px; }
.stat-card strong { color: #0f172a; font-size: 22px; }

.switch { border: 1px solid #cbd5e1; background: #f1f5f9; color: #64748b; border-radius: 999px; padding: 4px 10px; font-size: 12px; font-weight: 700; }
.switch.on { background: #dcfce7; border-color: #86efac; color: #15803d; }

.break-all { word-break: break-all; white-space: normal; }

.table td.actions { gap: 6px; vertical-align: middle; padding-top: 9px; padding-bottom: 9px; }
.table td.actions form { margin: 0; }

.admin-shell { transition: grid-template-columns .22s ease; }
.admin-shell.sidebar-collapsed { grid-template-columns: 0 minmax(0, 1fr); }
.admin-shell.sidebar-collapsed .sidebar { opacity: 0; pointer-events: none; overflow: hidden; }
.sidebar { transition: opacity .18s ease; min-width: 0; }
.topbar-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.sidebar-toggle {
  width: 34px; height: 34px; padding: 0; border-radius: 8px;
  background: #f1f5f9; color: #334155; font-size: 17px; box-shadow: none;
}
.sidebar-toggle:hover { background: #e2e8f0; filter: none; }
.admin-user-menu { position: relative; margin-left: auto; }
.admin-user-button {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 8px 5px 5px; border-radius: 999px;
  background: #f1f5f9; color: #0f172a; box-shadow: none;
}
.admin-user-button:hover { background: #e2e8f0; filter: none; }
.admin-user-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center;
  background: linear-gradient(135deg,#fb923c,#ea580c); color: #fff; font-size: 12px; font-weight: 800;
}
.admin-user-name { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; font-weight: 700; }
.admin-user-caret { color: #64748b; font-size: 11px; }
.admin-user-dropdown {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 50;
  width: 230px; padding: 7px; border: 1px solid var(--line); border-radius: 10px;
  background: #fff; box-shadow: 0 16px 40px rgba(15,23,42,.16);
}
.admin-user-dropdown.hidden { display: none; }
.admin-user-email { padding: 8px 10px; color: #64748b; font-size: 11px; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.admin-user-dropdown a, .admin-user-dropdown button {
  display: block; width: 100%; box-sizing: border-box;
  padding: 9px 10px; border-radius: 7px;
  color: #334155; background: transparent; text-align: left;
  font-size: 13px; box-shadow: none; border: 0; cursor: pointer;
}
.admin-user-dropdown a:hover, .admin-user-dropdown button:hover { background: #f1f5f9; color: #0f172a; filter: none; }
.admin-user-dropdown form { margin: 0; border-top: 1px solid var(--line); padding-top: 5px; }
@media (max-width: 800px) {
  .admin-shell.sidebar-collapsed { grid-template-columns: 1fr; }
  .admin-user-name { display: none; }
}

.table tbody tr { height: 52px; }
.table td { vertical-align: middle; }
.table td.actions {
  height: 52px;
  align-items: center;
  flex-wrap: wrap;
}
.table td.actions a, .table td.actions button { white-space: nowrap; }
.table td.actions .btn-small { height: 28px; box-sizing: border-box; }

.table td.actions {
  display: table-cell !important;
  height: 56px;
  vertical-align: middle !important;
  white-space: normal;
}
.table td.actions > * {
  display: inline-flex;
  vertical-align: middle;
  margin: 2px 6px 2px 0;
}
.table td.actions form { display: inline-flex; margin: 2px 6px 2px 0; }
.table td.actions .btn-small,
.table td.actions button,
.table td.actions a { height: 28px; box-sizing: border-box; align-items: center; }
.table tbody td { height: 56px; vertical-align: middle; }

.admin-tab { gap: 6px; }
.admin-tab-label { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-tab-close {
  display: inline-grid; place-items: center;
  width: 17px; height: 17px; padding: 0; border: 0; border-radius: 50%;
  background: transparent; color: #94a3b8; font-size: 13px; line-height: 1;
  opacity: 0; box-shadow: none; transition: opacity .12s, background .12s;
}
.admin-tab:hover .admin-tab-close, .admin-tab.active .admin-tab-close { opacity: 1; }
.admin-tab-close:hover { background: #e2e8f0; color: #b91c1c; filter: none; }

.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f0f9eb !important;
  border: 1px solid #e1f3d8 !important;
  color: #529b2e !important;
  font-weight: 700;
  box-shadow: 0 10px 30px rgba(15, 23, 42, .14) !important;
}
.toast::before {
  content: "✓";
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #67c23a;
  color: #fff;
  font-size: 12px;
  font-weight: 900;
}
.toast.hidden { display: none !important; }

.filter-bar > button[type="submit"],
.filter-bar > .btn,
.filter-bar > .btn-small {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 34px !important;
  min-width: 64px;
  padding: 0 14px !important;
  border-radius: 7px;
  box-sizing: border-box;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
}
.filter-bar > .btn,
.filter-bar > .btn-small {
  background: var(--accent);
  border: 1px solid var(--accent);
  color: #fff;
}
.filter-bar > .btn:hover,
.filter-bar > .btn-small:hover { background: #ea580c; color: #fff; }

.admin-frame-wrap { position: relative; }
.admin-frame-loading {
  position: absolute;
  inset: 0;
  z-index: 25;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: #f4f6fa;
  color: #64748b;
  font-size: 13px;
  font-weight: 700;
}
.admin-frame-loading.hidden { display: none; }
.admin-frame-spinner {
  width: 28px; height: 28px;
  border: 3px solid #dbe2ec;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: admin-frame-spin .8s linear infinite;
}
@keyframes admin-frame-spin { to { transform: rotate(360deg); } }

.admin-blocking {
  position: fixed;
  inset: 0;
  z-index: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, .42);
  backdrop-filter: blur(2px);
}
.admin-blocking.hidden { display: none; }
.admin-blocking-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 24px;
  border-radius: 12px;
  background: #fff;
  color: #334155;
  font-size: 14px;
  font-weight: 700;
  box-shadow: 0 20px 60px rgba(15, 23, 42, .24);
}
.admin-blocking-spinner {
  width: 24px; height: 24px;
  border: 3px solid #dbe2ec;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: admin-block-spin .8s linear infinite;
}
@keyframes admin-block-spin { to { transform: rotate(360deg); } }
.btn-spinner {
  display: inline-block;
  width: 13px;
  height: 13px;
  margin-right: 6px;
  vertical-align: -2px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: admin-block-spin .7s linear infinite;
}

.ss-wrap { position: relative; display: inline-block; min-width: 150px; vertical-align: middle; }
.ss-wrap .ss-native { position: absolute !important; width: 1px !important; height: 1px !important; opacity: 0; pointer-events: none; margin: 0; }
.ss-trigger {
  width: 100%; min-height: 34px; padding: 0 30px 0 10px;
  border: 1px solid var(--line); border-radius: 7px;
  background: #fff; color: var(--text); text-align: left;
  font: inherit; font-size: 13px; cursor: pointer;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ss-trigger::after {
  content: "▾"; position: absolute; right: 11px; top: 50%; transform: translateY(-50%);
  color: #94a3b8; font-size: 12px;
}
.ss-trigger:hover { border-color: #cbd5e1; }
.ss-trigger:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(249,115,22,.12); }
.ss-trigger.placeholder { color: #94a3b8; }
.ss-panel {
  position: absolute; z-index: 80; top: calc(100% + 5px); left: 0;
  width: max(100%, 190px); max-width: 320px;
  padding: 6px; border: 1px solid var(--line); border-radius: 9px;
  background: #fff; box-shadow: 0 16px 40px rgba(15,23,42,.16);
}
.ss-panel.hidden { display: none; }
.ss-search { width: 100%; height: 31px; padding: 0 8px; margin-bottom: 5px; border: 1px solid var(--line); border-radius: 6px; }
.ss-list { max-height: 230px; overflow-y: auto; display: grid; gap: 2px; }
.ss-option {
  display: block; width: 100%; padding: 7px 8px; border: 0; border-radius: 6px;
  background: transparent; color: var(--text); text-align: left; font-size: 13px; cursor: pointer;
}
.ss-option:hover, .ss-option.selected { background: #fff1e6; color: #c2410c; }
.ss-empty { padding: 9px; color: #94a3b8; font-size: 12px; text-align: center; }
.pager select {
  height: 31px; padding: 0 25px 0 9px; border: 1px solid var(--line);
  border-radius: 7px; background: #fff; color: #475569; font-size: 12px;
}

.admin-form .ss-wrap,
.settings-section .ss-wrap { width: 100%; }
.filter-bar .ss-wrap { width: auto; min-width: 150px; }
.ss-trigger { height: 34px; }
.page-actions {
  display: flex; align-items: center; flex-wrap: wrap; gap: 10px;
  margin: 12px 0; padding: 10px 12px;
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
}

.table { overflow: visible; }

.pager .ss-wrap { min-width: 118px; }
.pager .ss-trigger { height: 31px; font-size: 12px; }

.admin-topbar { position: relative; z-index: 100; }
.admin-user-dropdown { z-index: 110; }

.nav-group > summary.nav-label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 9px;
  color: #cbd5e1;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
  user-select: none;
}
.nav-group > summary.nav-label:hover,
.nav-group > summary.nav-label:focus-visible {
  background: rgba(255, 255, 255, .07);
  color: #fff;
  outline: none;
}
.nav-group[open] > summary.nav-label {
  background: rgba(255, 255, 255, .045);
  color: #f8fafc;
}
.nav-group summary::after {
  float: none;
  margin-left: auto;
  color: #94a3b8;
}
.nav-group > summary.nav-label:hover::after { color: #fdba74; }
.nav-group a { padding: 9px 12px 9px 22px !important; }

.nav-group > summary.nav-label {
  padding: 9px 12px 9px 22px;
  color: #93c5fd;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0;
}
.nav-group > summary.nav-label:hover,
.nav-group > summary.nav-label:focus-visible {
  background: rgba(96, 165, 250, .16);
  color: #dbeafe;
}
.nav-group[open] > summary.nav-label {
  background: rgba(96, 165, 250, .10);
  color: #bfdbfe;
}
.nav-group summary::after { color: #60a5fa; }
.nav-group > summary.nav-label:hover::after { color: #dbeafe; }

.perm-tree { display: grid; gap: 10px; }
.perm-module {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfcfe;
  padding: 10px 12px;
}
.perm-module-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  padding-bottom: 7px;
  border-bottom: 1px dashed var(--line);
}
.perm-module-head strong { font-size: 13px; color: #334155; }
.perm-all-label { font-size: 12px !important; color: #64748b !important; white-space: nowrap; }
.perm-module .perm-checks { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.perm-module .check code {
  margin-left: auto;
  padding: 1px 5px;
  border-radius: 4px;
  background: #eef2f7;
  color: #94a3b8;
  font-size: 10px;
}
@media (max-width: 900px) {
  .perm-module .perm-checks { grid-template-columns: 1fr; }
}

.permission-role-modal {
  width: min(940px, calc(100vw - 30px));
  max-height: calc(100vh - 36px);
}
.permission-role-modal form {
  max-height: calc(100vh - 36px);
  overflow-y: auto;
}
.perm-dialog-body {
  max-height: min(58vh, 560px);
  overflow-y: auto;
  padding-right: 4px;
}
.permission-role-modal .perm-module .perm-checks { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.permission-role-modal .modal-actions {
  position: sticky;
  bottom: -20px;
  padding: 12px 0 2px;
  background: #fff;
}

.image-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 150px;
  padding: 12px;
  border: 1px dashed #cbd5e1;
  border-radius: 10px;
  background: #f8fafc;
}
.image-preview img {
  display: block;
  max-width: 260px;
  max-height: 180px;
  border-radius: 8px;
  object-fit: contain;
}
.image-preview-empty { color: #94a3b8; font-size: 13px; }
.image-preview img[hidden], .image-preview-empty[hidden] { display: none; }

/* 二级菜单比一级菜单多缩进一个字 */
.nav-group a { padding-left: 35px !important; }

.nav-single {
  display: flex;
  align-items: center;
  gap: 10px;
}
.nav-icon {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  color: #60a5fa;
  opacity: .95;
}
.nav-group > summary.nav-label { gap: 10px; }
.nav-group > summary.nav-label .nav-icon { color: #60a5fa; }
.nav-single:hover .nav-icon,
.nav-group > summary.nav-label:hover .nav-icon,
.nav-group[open] > summary.nav-label .nav-icon { color: #dbeafe; }
.nav-single.active .nav-icon { color: #fdba74; }

/* 有首级图标后，二级文字仍比首级文字多缩进一个字 */
.nav-group a { padding-left: 63px !important; }

.product-crop-modal {
  width: min(540px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
}
.product-crop-card { padding: 20px; }
.product-crop-card h2 { margin: 0 0 6px; }
.product-crop-card > p { margin: 0 0 12px; }
.product-crop-stage {
  position: relative;
  width: 400px;
  height: 400px;
  max-width: 100%;
  margin: 0 auto;
  overflow: hidden;
  border-radius: 10px;
  background: #0f172a;
  cursor: grab;
  touch-action: none;
}
.product-crop-stage.dragging { cursor: grabbing; }
.product-crop-stage img {
  position: absolute;
  top: 0;
  left: 0;
  max-width: none;
  pointer-events: none;
  user-select: none;
}
.product-crop-frame {
  position: absolute;
  inset: 0;
  border: 2px solid rgba(255, 255, 255, .92);
  box-shadow: 0 0 0 9999px rgba(15, 23, 42, .18);
  pointer-events: none;
}
.product-crop-frame::before,
.product-crop-frame::after {
  content: "";
  position: absolute;
  pointer-events: none;
  background: rgba(255, 255, 255, .35);
}
.product-crop-frame::before { left: 33.333%; right: 33.333%; top: 0; bottom: 0; border-left: 1px solid rgba(255,255,255,.35); border-right: 1px solid rgba(255,255,255,.35); background: none; }
.product-crop-frame::after { top: 33.333%; bottom: 33.333%; left: 0; right: 0; border-top: 1px solid rgba(255,255,255,.35); border-bottom: 1px solid rgba(255,255,255,.35); background: none; }
.product-crop-frame span {
  position: absolute;
  right: 8px;
  bottom: 8px;
  padding: 2px 7px;
  border-radius: 5px;
  background: rgba(15, 23, 42, .62);
  color: #fff;
  font-size: 11px;
  letter-spacing: .08em;
}
.product-crop-controls {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 12px;
}
.product-crop-controls input[type="range"] { width: 180px; }
.product-crop-size { color: #64748b; font-size: 12px; }
.product-crop-modal .modal-actions { margin-top: 14px; }

.product-crop-modal {
  width: min(460px, calc(100vw - 20px));
  max-height: calc(100vh - 20px);
}
.product-crop-card {
  max-height: calc(100vh - 20px);
  overflow-y: auto;
  padding: 16px 18px;
}
.product-crop-stage {
  width: min(320px, 100%);
  height: auto;
  aspect-ratio: 1 / 1;
  margin: 0 auto;
}
.product-crop-modal .modal-actions {
  position: sticky;
  bottom: -16px;
  z-index: 2;
  margin-top: 10px;
  padding: 10px 0 2px;
  background: #fff;
}

.branding-crop-stage {
  width: min(360px, 100%);
  margin: 0 auto;
}
.branding-crop-stage .product-crop-frame span {
  font-size: 10px;
}
.branding-crop-ratio {
  justify-content: center;
  margin: 0 auto 8px;
}
.branding-crop-ratio select {
  min-width: 150px;
  padding: 6px 8px;
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  background: #fff;
  color: #0f172a;
}

/* online support */
.support-admin {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  min-height: 580px;
  height: calc(100vh - 230px);
  border: 1px solid #dbe3ef;
  border-radius: 14px;
  overflow: hidden;
  background: #fff;
}
.support-conversations {
  border-right: 1px solid #e2e8f0;
  background: #f8fafc;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.support-conversations-head {
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #e2e8f0;
}
.support-conversation-list { overflow-y: auto; min-height: 0; }
.support-conversation {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px;
  border: 0;
  border-bottom: 1px solid #edf1f7;
  border-radius: 0;
  background: transparent;
  color: #0f172a;
  text-align: left;
  box-shadow: none;
  cursor: pointer;
}
.support-conversation:hover { background: #eef4ff; filter: none; }
.support-conversation.active { background: #e8f0ff; }
.support-conversation-main { min-width: 0; display: grid; gap: 2px; }
.support-conversation-main strong,
.support-conversation-main small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.support-conversation-main small { color: #64748b; font-size: 11px; }
.support-conversation-meta { display: grid; justify-items: end; gap: 4px; flex: none; }
.support-conversation-meta small { color: #94a3b8; font-size: 10px; }
.support-unread {
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 10px;
}
.support-chat-pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.support-chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid #e2e8f0;
}
.support-chat-head .muted { font-size: 12px; margin-top: 2px; }
.support-online-pill {
  flex: none;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}
.support-online-pill.on { background: #dcfce7; color: #166534; }
.support-online-pill.off { background: #f1f5f9; color: #64748b; }
.support-online-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #94a3b8;
  display: inline-block;
}
.support-online-dot.on { background: #22c55e; box-shadow: 0 0 0 4px rgba(34, 197, 94, .12); }
.support-online-dot.off { background: #94a3b8; }
.support-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px;
  background: #f8fafc;
}
.support-message {
  max-width: 78%;
  margin: 0 0 12px;
  padding: 9px 11px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid #e2e8f0;
}
.support-message.admin { margin-left: auto; background: #e8f0ff; border-color: #c7d7f8; }
.support-message.auto { max-width: 88%; background: #f1f5f9; border-style: dashed; }
.support-message-head { font-size: 10px; font-weight: 700; color: #64748b; margin-bottom: 3px; }
.support-message-content { font-size: 13px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.support-message-time { margin-top: 4px; font-size: 10px; color: #94a3b8; }
.support-reply {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 14px;
  border-top: 1px solid #e2e8f0;
  background: #fff;
}
.support-reply textarea {
  flex: 1;
  resize: vertical;
  min-height: 40px;
  max-height: 120px;
  padding: 9px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font: inherit;
  font-size: 13px;
}
.support-reply button { flex: none; }
.support-empty { padding: 24px 16px; color: #94a3b8; font-size: 12px; text-align: center; }
@media (max-width: 900px) {
  .support-admin { grid-template-columns: 1fr; height: auto; min-height: 0; }
  .support-conversations { max-height: 220px; border-right: 0; border-bottom: 1px solid #e2e8f0; }
  .support-chat-pane { min-height: 520px; }
}

/* support page fills the admin tab without an outer scrollbar */
body.admin-embed-body:has(#support-admin) {
  height: 100vh;
  overflow: hidden;
}
body.admin-embed-body:has(#support-admin) .admin-main {
  height: 100vh;
  max-width: 1180px;
  padding: 18px 24px 16px;
  display: flex;
  flex-direction: column;
}
body.admin-embed-body:has(#support-admin) .page-head {
  flex: 0 0 auto;
  margin-bottom: 8px;
}
body.admin-embed-body:has(#support-admin) .page-head h1 { margin-bottom: 2px; }
body.admin-embed-body:has(#support-admin) #support-admin {
  flex: 1 1 auto;
  height: auto;
  min-height: 0;
}
@media (max-width: 900px) {
  body.admin-embed-body:has(#support-admin) {
    height: auto;
    overflow: auto;
  }
  body.admin-embed-body:has(#support-admin) .admin-main {
    height: auto;
    min-height: 100vh;
    display: block;
  }
}

/* support page: fill viewport and hide scrollbar chrome */
html:has(#support-admin) { height: 100%; overflow: hidden; }
body.admin-embed-body:has(#support-admin) { height: 100%; overflow: hidden; }
body.admin-embed-body:has(#support-admin) .admin-main { overflow: hidden; }
body.admin-embed-body:has(#support-admin) .support-admin,
body.admin-embed-body:has(#support-admin) .support-conversations,
body.admin-embed-body:has(#support-admin) .support-chat-pane,
body.admin-embed-body:has(#support-admin) .support-messages,
body.admin-embed-body:has(#support-admin) .support-conversation-list {
  scrollbar-width: none;
  -ms-overflow-style: none;
}
body.admin-embed-body:has(#support-admin) .support-conversations::-webkit-scrollbar,
body.admin-embed-body:has(#support-admin) .support-messages::-webkit-scrollbar,
body.admin-embed-body:has(#support-admin) .support-conversation-list::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}
@media (max-width: 900px) {
  html:has(#support-admin), body.admin-embed-body:has(#support-admin) { height: auto; overflow: auto; }
  body.admin-embed-body:has(#support-admin) .admin-main { overflow: visible; }
}

/* keep the admin shell itself fixed; only tab content scrolls */
html:has(.admin-shell),
body:has(.admin-shell) {
  height: 100vh;
  overflow: hidden;
}
.admin-shell {
  height: 100vh;
  min-height: 0;
  overflow: hidden;
}
.admin-content {
  height: 100vh;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.admin-topbar,
.admin-tabs {
  flex: 0 0 auto;
}
.admin-frame-wrap {
  flex: 1 1 auto;
  height: auto;
  min-height: 0;
}
@media (max-width: 900px) {
  html:has(.admin-shell),
  body:has(.admin-shell) {
    height: auto;
    overflow: auto;
  }
  .admin-shell,
  .admin-content {
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }
  .admin-frame-wrap {
    flex: 1 1 auto;
    height: calc(100vh - 150px);
  }
}

/* unread badge for the support menu */
.support-menu-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  margin-left: 7px;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
  vertical-align: middle;
}
.support-menu-badge.hidden { display: none; }

.support-reply[hidden] { display: none !important; }

.support-history-end {
  margin: 2px 0 14px;
  color: #94a3b8;
  font-size: 10px;
  text-align: center;
  user-select: none;
}

/* payment address state */
.address-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}
.address-status::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.address-status.on {
  color: #047857;
  background: #d1fae5;
  border: 1px solid #6ee7b7;
}
.address-status.off {
  color: #b91c1c;
  background: #fee2e2;
  border: 1px solid #fca5a5;
}
.sync-status-ok {
  color: #047857;
  font-size: 12px;
  font-weight: 700;
}
.sync-status-error {
  color: #b91c1c;
  font-size: 12px;
  font-weight: 700;
  overflow-wrap: anywhere;
}
