/* ==========================================================================
   MyStoreDesk 商业化控制台 —— 对齐旧版 storedesk
   浅色优先；明暗两套 token 由 <html data-theme> 切换（JS 解析 system）。
   纯静态 CSS，无框架、无外部字体/CDN。
   ========================================================================== */

:root {
  /* spacing scale: 4 / 8 / 12 / 16 / 20 / 24 / 28 / 32 */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-7: 28px;
  --sp-8: 32px;

  /* radius & shadow */
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 12px;
  --radius-sm: var(--r-sm);
  --radius-md: var(--r-md);
  --radius-lg: var(--r-lg);
  --radius-pill: 999px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-md: 0 6px 16px rgba(16, 24, 40, 0.08);
  --shadow-lg: 0 16px 48px rgba(16, 24, 40, 0.14);

  /* type & layout */
  --fs-body: 14px;
  --fs-aux: 12.5px;
  --fs-h1: 22px;
  --fs-h2: 16px;
  --fs-h3: 15px;
  --fs-sm: 13px;
  --fs-xs: 12px;
  --lh: 1.6;
  --sidebar-w: 228px;
  --content-max: 1320px;
  --control-h: 38px;

  font-family: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: var(--fs-body);
  line-height: var(--lh);
}

/* ---- 浅色主题 ---- */
:root,
:root[data-theme="light"] {
  color-scheme: light;
  --canvas: #f7f8fa;
  --surface: #ffffff;
  --surface-sunken: #f2f4f7;
  --line: #e6e8ec;
  --line-strong: #d5d8de;
  --text: #16191d;
  --text-muted: #5f6774;
  --text-subtle: #6b7280;

  --accent: #1d4ed8;
  --accent-hover: #1a45c0;
  --accent-soft: #eef2ff;
  --accent-fill: #1d4ed8;
  --accent-fill-hover: #1a45c0;
  --on-accent: #ffffff;
  --accent-ring: rgba(29, 78, 216, 0.18);

  --ok: #137a3f;
  --ok-soft: #e9f6ee;
  --warn: #9a5b00;
  --warn-soft: #fdf3e2;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --neutral-soft: #f1f3f6;
  --danger-line: #f3c3bd;
  --warn-line: #e0a94a;

  --skeleton-base: #f1f3f6;
  --skeleton-shine: #e9ecf1;
  --overlay: rgba(16, 24, 40, 0.45);
  --log-bg: rgba(15, 17, 21, 0.85);
  --log-fg: #e7e9ee;
  --player-bg: #000000;

  /* 兼容旧组件命名 */
  --success: var(--ok);
  --success-soft: var(--ok-soft);
  --warning: var(--warn);
  --warning-soft: var(--warn-soft);
  --brand: var(--accent);
  --brand-soft: var(--accent-soft);
  --muted: var(--text-muted);
  --card: var(--surface);
  --card-2: var(--surface-sunken);
  --bg: var(--canvas);
}

/* ---- 深色主题（只覆盖同名语义 token） ---- */
:root[data-theme="dark"] {
  color-scheme: dark;
  --canvas: #0f1115;
  --surface: #171a1f;
  --surface-sunken: #1e2228;
  --line: #2a2f37;
  --line-strong: #3a414b;
  --text: #e7e9ee;
  --text-muted: #a8b0bd;
  --text-subtle: #8b93a1;

  --accent: #6ea0ff;
  --accent-hover: #2563eb;
  --accent-soft: #1b2740;
  --accent-fill: #2563eb;
  --accent-fill-hover: #1d4ed8;
  --on-accent: #ffffff;
  --accent-ring: rgba(110, 160, 255, 0.25);

  --ok: #4ade80;
  --ok-soft: #123021;
  --warn: #f0b64d;
  --warn-soft: #33260d;
  --danger: #f87171;
  --danger-soft: #3a1d1d;
  --neutral-soft: #232830;
  --danger-line: #5f2a2a;
  --warn-line: #5a4419;

  --skeleton-base: #232830;
  --skeleton-shine: #2c323b;
  --overlay: rgba(0, 0, 0, 0.65);
  --log-bg: rgba(0, 0, 0, 0.55);
  --log-fg: #e7e9ee;
  --player-bg: #000000;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.6);
  --shadow-md: 0 6px 16px rgba(0, 0, 0, 0.55);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.6);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  background: var(--canvas);
  color: var(--text);
  font-family: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: var(--fs-body);
  line-height: var(--lh);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, p { margin-top: 0; }
h1 { font-size: var(--fs-h1); font-weight: 600; letter-spacing: -0.01em; margin: 0 0 var(--sp-2); }
h2 { font-size: var(--fs-h2); font-weight: 600; margin: 0 0 var(--sp-2); }
h3 { font-size: var(--fs-h3); font-weight: 600; margin: 0 0 var(--sp-2); }
.subhead { margin: var(--sp-5) 0 var(--sp-2); color: var(--text-muted); font-size: var(--fs-aux); text-transform: uppercase; letter-spacing: 0.04em; }
a { color: var(--accent); text-decoration: none; }
.hidden { display: none !important; }
.muted { color: var(--text-muted); font-size: var(--fs-aux); }
.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;
}
.form-error { color: var(--danger); font-size: var(--fs-aux); min-height: 1.2em; margin: 6px 0 0; }
.form-note { color: var(--text-muted); font-size: var(--fs-aux); margin: 8px 0 0; }
.form-success { color: var(--ok); font-size: var(--fs-aux); margin: 8px 0 0; }
.error { color: var(--danger); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.icon {
  width: 17px;
  height: 17px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: middle;
}

/* ==========================================================================
   按钮 / 表单
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  height: var(--control-h);
  padding: 0 var(--sp-4);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 500;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.btn:hover:not(:disabled) { background: var(--surface-sunken); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.primary {
  background: var(--accent-fill);
  border-color: var(--accent-fill);
  color: var(--on-accent);
}
.btn.primary:hover:not(:disabled) {
  background: var(--accent-fill-hover);
  border-color: var(--accent-fill-hover);
}
.btn.secondary { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.btn.secondary:hover:not(:disabled) { border-color: var(--accent); background: var(--accent-soft); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text); }
.btn.ghost:hover:not(:disabled) { background: var(--surface-sunken); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger:hover:not(:disabled) { filter: brightness(0.94); }
.btn.danger-ghost { background: transparent; border-color: var(--danger-line); color: var(--danger); }
.btn.danger-ghost:hover:not(:disabled) { background: var(--danger-soft); }
.btn.sm { height: 28px; padding: 0 10px; font-size: var(--fs-aux); border-radius: var(--r-sm); }
.btn.block { width: 100%; }
.btn.loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.loading::after {
  content: "";
  position: absolute;
  width: 15px;
  height: 15px;
  border: 2px solid var(--accent-soft);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.btn.primary.loading::after { border-color: rgba(255, 255, 255, 0.45); border-top-color: #fff; }
@keyframes spin { to { transform: rotate(360deg); } }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span,
.field > label {
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--text-muted);
}
input, select, textarea {
  width: 100%;
  height: var(--control-h);
  padding: 0 var(--sp-3);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input::placeholder, textarea::placeholder { color: var(--text-subtle); }
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  outline: none;
}
input[type="file"] { height: auto; padding: 6px 8px; }
input[type="hidden"] { display: none; }
textarea { height: auto; padding: var(--sp-2) var(--sp-3); line-height: 1.55; resize: vertical; min-height: 88px; }

.form-grid {
  display: grid;
  gap: var(--sp-3) var(--sp-4);
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  align-items: end;
}
.form-grid .field-full { grid-column: 1 / -1; }
.form-actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center; }
.actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center; }
.actions select { width: auto; min-width: 170px; }
.stack { display: flex; flex-direction: column; gap: var(--sp-4); }
.inline-form { display: flex; gap: var(--sp-3); flex-wrap: wrap; align-items: end; margin-top: var(--sp-4); }
.inline-form .field { flex: 1; min-width: 180px; }

/* ==========================================================================
   卡片 / 面板 / 页面
   ========================================================================== */
.card, .panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}
.panel { padding: var(--sp-5); margin-top: var(--sp-5); }
.tab-panel > .panel:first-child { margin-top: var(--sp-5); }
.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-bottom: var(--sp-3);
}
.panel-head p { margin: 2px 0 0; }
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-4);
  margin-bottom: var(--sp-4);
}
.page-head h1 { margin: 0 0 var(--sp-1); }
.page-head p { margin: 0; max-width: 72ch; }
.two-col-grid {
  display: grid;
  gap: var(--sp-5);
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}
.two-col-grid > .panel { margin-top: var(--sp-5); }

.stat-grid {
  display: grid;
  gap: var(--sp-4);
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}
.stat {
  display: flex;
  gap: var(--sp-3);
  align-items: flex-start;
  padding: var(--sp-4) var(--sp-5);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}
.stat-icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: var(--r-md);
  background: var(--accent-soft);
  color: var(--accent);
}
.stat-label { color: var(--text-muted); font-size: var(--fs-aux); }
.stat-value {
  font-size: 24px;
  font-weight: 600;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}
.stat-trend { color: var(--text-subtle); font-size: var(--fs-xs); margin-top: 2px; }
.stat.tone-success .stat-icon { background: var(--ok-soft); color: var(--ok); }
.stat.tone-warning .stat-icon { background: var(--warn-soft); color: var(--warn); }
.stat.tone-danger .stat-icon { background: var(--danger-soft); color: var(--danger); }
.stat.tone-info .stat-icon { background: var(--accent-soft); color: var(--accent); }
.skeleton-stat { min-height: 82px; border-radius: var(--r-lg); }
.stat-grid > .usage-bars { grid-column: 1 / -1; }

/* 用量条 */
.usage-bars { display: flex; flex-direction: column; gap: var(--sp-3); margin-top: var(--sp-4); }
.usage-row { display: grid; grid-template-columns: 110px minmax(0, 1fr) 92px; gap: var(--sp-3); align-items: center; }
.usage-name { color: var(--text-muted); font-size: var(--fs-aux); }
.usage-track { height: 8px; border-radius: var(--radius-pill); background: var(--surface-sunken); border: 1px solid var(--line); overflow: hidden; }
.usage-fill { height: 100%; border-radius: var(--radius-pill); background: var(--accent); min-width: 2px; }
.usage-row:nth-child(2) .usage-fill { background: var(--ok); }
.usage-row:nth-child(3) .usage-fill { background: var(--warn); }
.usage-value { text-align: right; font-variant-numeric: tabular-nums; font-size: var(--fs-aux); }

/* ==========================================================================
   表格（通用）
   ========================================================================== */
.table-wrap { width: 100%; overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-md); }
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-body); }
.table th {
  padding: 10px var(--sp-3);
  text-align: left;
  background: var(--surface-sunken);
  color: var(--text-muted);
  font-size: var(--fs-aux);
  font-weight: 500;
  white-space: nowrap;
  border-bottom: 1px solid var(--line);
}
.table td { padding: 10px var(--sp-3); border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:hover { background: var(--surface-sunken); }
.table tbody tr:last-child td { border-bottom: none; }
.table .num { font-variant-numeric: tabular-nums; }
.table .actions { margin-top: 0; }

/* ==========================================================================
   徽章 / 胶囊 / 空状态 / 骨架
   ========================================================================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 9px;
  border-radius: var(--radius-pill);
  font-size: var(--fs-aux);
  font-weight: 500;
  line-height: 1.7;
  white-space: nowrap;
  border: 1px solid transparent;
}
.badge.neutral { background: var(--neutral-soft); color: var(--text-muted); }
.badge.success { background: var(--ok-soft); color: var(--ok); }
.badge.warning { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.info { background: var(--accent-soft); color: var(--accent); }
.badge.brand { background: var(--accent-soft); color: var(--accent); }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-aux);
  color: var(--text-muted);
  white-space: nowrap;
}
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--line-strong); }
.pill.on { color: var(--ok); }
.pill.on .dot { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.pill.warn { color: var(--warn); }
.pill.warn .dot { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }
.pill.off { color: var(--text-subtle); }
.pill.accent { color: var(--accent); }
.pill.accent .dot { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-8) var(--sp-5);
  text-align: center;
  color: var(--text-muted);
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-lg);
  background: var(--surface);
}
.empty h4 { margin: 0; font-size: var(--fs-h3); color: var(--text); }
.empty p { margin: 0; font-size: var(--fs-aux); max-width: 440px; }
.empty .btn { margin-top: 4px; }

.skeleton {
  height: 96px;
  border-radius: var(--r-lg);
  background: linear-gradient(90deg, var(--skeleton-base) 25%, var(--skeleton-shine) 37%, var(--skeleton-base) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
}
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

/* ==========================================================================
   Toast / Modal
   ========================================================================== */
.toast-root {
  position: fixed;
  right: var(--sp-5);
  bottom: var(--sp-5);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  width: min(380px, calc(100vw - 32px));
}
.toast {
  display: flex;
  gap: var(--sp-2);
  align-items: flex-start;
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-md);
  font-size: var(--fs-aux);
  animation: toast-in 0.18s ease-out;
}
.toast.success { border-left-color: var(--ok); }
.toast.error { border-left-color: var(--danger); }
.toast.info { border-left-color: var(--accent); }
.toast.leaving { opacity: 0; transform: translateY(6px); transition: opacity 0.18s ease, transform 0.18s ease; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: grid;
  place-items: center;
  padding: var(--sp-5);
  background: var(--overlay);
}
.modal {
  width: min(460px, 100%);
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  padding: var(--sp-5);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
}
.modal h3 { margin: 0 0 var(--sp-2); font-size: var(--fs-h2); }
.modal > p { margin: 0 0 var(--sp-4); color: var(--text-muted); font-size: var(--fs-aux); }
.modal-actions { display: flex; justify-content: flex-end; gap: var(--sp-2); flex-wrap: wrap; }
.modal-form { display: flex; flex-direction: column; gap: var(--sp-3); margin-bottom: var(--sp-4); }

/* 一次性链接 / token 提示 */
.notice {
  display: flex;
  gap: var(--sp-2);
  flex-wrap: wrap;
  align-items: center;
  margin-top: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-sunken);
}
.notice-warning { border-color: var(--warn-line); background: var(--warn-soft); color: var(--warn); }
.notice .secret { flex: 1; min-width: 220px; word-break: break-all; font-size: var(--fs-xs); }
code.secret {
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
}

/* ==========================================================================
   登录 / 设置密码
   ========================================================================== */
.auth-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-5);
  padding: var(--sp-8) var(--sp-5);
  background: var(--canvas);
  position: relative;
}
.auth-theme { position: fixed; top: var(--sp-4); right: var(--sp-4); z-index: 50; }
.auth-card { width: min(390px, 100%); padding: var(--sp-8); }
.auth-brand { font-size: 20px; font-weight: 600; letter-spacing: -0.02em; }
.auth-title { margin: var(--sp-3) 0 var(--sp-1); font-size: 20px; }
.auth-sub { margin: 4px 0 var(--sp-6); }
.auth-form { gap: var(--sp-4); }
.auth-tip { margin: var(--sp-4) 0 0; line-height: 1.55; }
.security-note {
  margin-top: var(--sp-5);
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-sunken);
  color: var(--text-muted);
  font-size: var(--fs-xs);
}
.security-note strong { display: block; margin-bottom: 2px; color: var(--text); font-size: var(--fs-aux); }
.security-note p { margin: 0; }
.auth-foot { color: var(--text-subtle); font-size: var(--fs-xs); text-align: center; }

/* ==========================================================================
   应用外壳：228px 侧栏 + 内容
   ========================================================================== */
.app-shell { min-height: 100vh; }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  width: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  padding: var(--sp-6) var(--sp-3);
  background: var(--surface);
  border-right: 1px solid var(--line);
}
.brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  padding: 0 var(--sp-2) var(--sp-6) var(--sp-3);
}
.brand { font-weight: 600; letter-spacing: -0.02em; font-size: 15px; }
.theme-icon {
  flex: none;
  width: 28px;
  height: 28px;
  min-height: 28px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}
.theme-icon:hover { background: var(--surface-sunken); border-color: var(--line); color: var(--text); }
.nav { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.nav-label {
  margin: var(--sp-4) var(--sp-3) var(--sp-1);
  color: var(--text-subtle);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
}
.nav-label:first-child { margin-top: 0; }
.nav-item {
  padding: 9px var(--sp-3);
  border: 0;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-weight: 450;
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
}
.nav-item:hover { background: var(--surface-sunken); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 550; }
.nav-item:focus-visible { outline-color: var(--accent); }
.account {
  margin-top: auto;
  border-top: 1px solid var(--line);
  padding-top: var(--sp-3);
}
.account-name { font-size: var(--fs-aux); color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-meta { font-size: var(--fs-aux); color: var(--text-subtle); margin-bottom: var(--sp-2); }
.account > button { width: 100%; justify-content: flex-start; padding: 0 var(--sp-3); }
.org { margin-top: var(--sp-4); padding: var(--sp-3) var(--sp-3) 0; border-top: 1px solid var(--line); }
.org-name { font-size: 12px; color: var(--text-subtle); line-height: 1.4; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.org-ver { font-size: 12px; color: var(--text-subtle); opacity: 0.8; }

.app-main {
  min-height: 100vh;
  margin-left: var(--sidebar-w);
  padding: var(--sp-6) var(--sp-8) var(--sp-8);
}
.breadcrumb { color: var(--text-subtle); font-size: var(--fs-aux); margin-bottom: var(--sp-2); }
.content { width: 100%; max-width: var(--content-max); }
.mobile-bar { display: none; align-items: center; gap: var(--sp-2); margin-bottom: var(--sp-3); }
.mobile-title { font-weight: 600; font-size: var(--fs-h3); }

/* ==========================================================================
   店铺 / 账号明细表（storedesk 风格）
   ========================================================================== */
.ds-list {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.ds-toolbar {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  flex-wrap: wrap;
}
.ds-toolbar .grow { flex: 1 1 auto; }
.ds-toolbar .search { width: 300px; max-width: 100%; }
.ds-toolbar .count { color: var(--text-subtle); font-size: var(--fs-aux); white-space: nowrap; }
.ds-tabs {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  padding: 0 var(--sp-5);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}
.ds-tab {
  appearance: none;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  padding: var(--sp-3);
  color: var(--text-muted);
  font: inherit;
  font-size: var(--fs-body);
  cursor: pointer;
  white-space: nowrap;
}
.ds-tab:hover { color: var(--text); }
.ds-tab.on { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.ds-tab .n { margin-left: 4px; color: var(--text-subtle); font-variant-numeric: tabular-nums; }
.ds-tab.on .n { color: var(--accent); }
.ds-list .form-error { margin: var(--sp-3) var(--sp-5) 0; }
.ds-list .empty { margin: var(--sp-4); border-style: solid; }
.ds-table { width: 100%; border-collapse: collapse; font-size: var(--fs-body); }
.ds-table { table-layout: auto; }
.ds-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-sunken);
  color: var(--text-muted);
  font-size: var(--fs-aux);
  font-weight: 500;
  text-align: left;
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.ds-table tbody td {
  padding: 10px var(--sp-4);
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  text-align: left;
}
.ds-table tbody tr:hover td { background: var(--surface-sunken); }
.ds-table tbody tr:last-child td { border-bottom: 0; }
.ds-table .idx { text-align: center; color: var(--text-subtle); font-variant-numeric: tabular-nums; }
.ds-table .num { text-align: center; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.ds-table .act { text-align: right; white-space: nowrap; }
.ds-table .act .actions { justify-content: flex-end; }
.table-scroll { overflow-x: auto; }
.who-cell { display: flex; align-items: center; gap: var(--sp-3); min-width: 0; }
.who-cell .avatar {
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--neutral-soft);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}
.who-cell .avatar.amazon { background: var(--warn-soft); color: var(--warn); }
.who-cell .avatar.payment { background: var(--danger-soft); color: var(--danger); }
.who-cell .avatar.mailbox { background: var(--accent-soft); color: var(--accent); }
.who-cell .txt { min-width: 0; }
.who-cell .n1 {
  display: block;
  color: var(--text);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.who-cell .n2 {
  display: block;
  color: var(--text-subtle);
  font-size: var(--fs-aux);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cell-2l .l1 { display: block; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-2l .l2 {
  display: block;
  color: var(--text-subtle);
  font-size: var(--fs-aux);
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pager { padding: var(--sp-3) var(--sp-5); border-top: 1px solid var(--line); }
.pager-inner { display: flex; align-items: center; justify-content: flex-end; gap: var(--sp-3); }
.pager-inner .muted { font-size: var(--fs-aux); }

/* 快捷操作 / 套餐 / 摘要 */
.quick-grid { display: grid; gap: var(--sp-2); grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.quick-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: var(--sp-3);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-sunken);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.quick-card strong { font-size: var(--fs-sm); }
.quick-card span:not(.quick-icon) { color: var(--text-muted); font-size: var(--fs-xs); }
.quick-icon {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  margin-bottom: 4px;
  border-radius: var(--r-sm);
  background: var(--accent-soft);
  color: var(--accent);
}
.plan-grid { display: grid; gap: var(--sp-4); grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.plan-card {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding: var(--sp-4);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
}
.plan-card.is-inactive { opacity: 0.7; }
.plan-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); }
.plan-head h4 { margin: 0; font-size: var(--fs-h3); }
.plan-price { font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; }
.plan-price span { font-size: var(--fs-xs); font-weight: 400; color: var(--text-muted); }
.plan-meta { display: flex; flex-wrap: wrap; gap: var(--sp-3); margin: 0; }
.plan-meta div { display: flex; flex-direction: column; }
.plan-meta dt { color: var(--text-subtle); font-size: var(--fs-xs); }
.plan-meta dd { margin: 0; font-size: var(--fs-sm); font-weight: 600; font-variant-numeric: tabular-nums; }
.summary-grid { display: grid; gap: var(--sp-3); grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.summary-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: var(--sp-3);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-sunken);
}
.summary-item span { color: var(--text-subtle); font-size: var(--fs-xs); }
.summary-item strong { font-size: var(--fs-h3); font-variant-numeric: tabular-nums; }
.amount-summary {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: var(--sp-4);
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-sunken);
}
.amount-summary p { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }

/* 分段控件 */
.tabs {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-sunken);
}
.tabs .tab-segment {
  padding: 5px 12px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: var(--fs-aux);
  font-weight: 600;
  cursor: pointer;
}
.tabs .tab-segment.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* ==========================================================================
   响应式
   ========================================================================== */
.sidebar-backdrop { display: none; }
#menu-toggle { display: none; }

@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: none; }
  .app-main { margin-left: 0; padding: var(--sp-5) var(--sp-5) var(--sp-8); }
  .sidebar-backdrop.open {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 35;
    background: var(--overlay);
  }
  #menu-toggle { display: inline-flex; }
  .mobile-bar { display: flex; }
  .breadcrumb { display: none; }
}

@media (max-width: 768px) {
  .page-head { flex-direction: column; align-items: stretch; }
  .ds-toolbar .search { width: 100%; }
  .ds-toolbar .grow { display: none; }
  .form-grid { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two-col-grid { grid-template-columns: 1fr; }
  .ds-table { min-width: 760px; }
  .table-scroll, #stores, #accounts-list { overflow-x: auto; }
  .panel { padding: var(--sp-4); }
  .usage-row { grid-template-columns: 86px minmax(0, 1fr) 76px; }
}

@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr; }
  .app-main { padding: 12px; }
  .auth-card { padding: var(--sp-5); }
  .ds-toolbar, .ds-tabs { padding-left: var(--sp-3); padding-right: var(--sp-3); }
  .pager-inner { justify-content: center; flex-wrap: wrap; }
  .btn { padding: 0 12px; }
  .modal { padding: var(--sp-4); }
  .toast-root { right: 12px; bottom: 12px; }
}

/* ==========================================================================
   远程画面查看器（保持深色工具栏与浮层）
   ========================================================================== */
.viewer-body {
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: #05080f;
  color: #e7e9ee;
}
.viewer-body .top {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  height: 56px;
  padding: 0 var(--sp-4);
  background: #11161f;
  border-bottom: 1px solid #2a2f37;
  color: #e7e9ee;
}
.viewer-body .brand { font-size: 15px; font-weight: 700; color: #f8fafc; }
.viewer-body .sub { color: #9aa4b2; font-size: 12px; }
.viewer-body .btn.ghost,
.viewer-body .ghost {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.18);
  color: #e7e9ee;
}
.viewer-body .btn.ghost:hover,
.viewer-body .ghost:hover { background: rgba(255, 255, 255, 0.08); }
.viewer-body .btn.primary { background: #2563eb; border-color: #2563eb; color: #fff; }
.viewer-actions { margin-left: auto; display: flex; gap: var(--sp-2); }
.viewer-main { position: relative; flex: 1; min-height: 0; background: #000; }
.screen { position: absolute; inset: 0; outline: none; }
.screen canvas { width: 100% !important; height: 100% !important; }
.viewer-overlay {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-6);
  background: rgba(5, 8, 15, 0.84);
  color: #f3f4f6;
}
.viewer-card {
  width: min(460px, 100%);
  padding: var(--sp-6) var(--sp-7);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--r-lg);
  background: rgba(17, 22, 31, 0.97);
  box-shadow: var(--shadow-lg);
}
.viewer-card h2 { margin: 0 0 var(--sp-2); font-size: 19px; }
.viewer-card .muted { color: #9aa4b2; }
.viewer-card .actions { margin-top: var(--sp-4); display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.viewer-card .error { color: #fca5a5; }

/* 剪贴板浮层：可收起，默认不挡住画面；展开后只占左下角一块。 */
.clipboard-panel {
  position: absolute;
  left: 16px;
  bottom: 16px;
  /* 低于连接/结束 overlay，状态提示不会被剪贴板浮层挡住。 */
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  width: min(360px, calc(100% - 32px));
  padding: var(--sp-3);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--r-md);
  background: rgba(17, 22, 31, 0.96);
  color: #f3f4f6;
  box-shadow: var(--shadow-lg);
}
.clipboard-panel .clipboard-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); }
.clipboard-panel .clipboard-head-actions { display: flex; gap: 6px; }
.clipboard-remote { display: flex; flex-direction: column; gap: 6px; }
.clipboard-remote pre {
  max-height: 96px;
  margin: 0;
  padding: 8px 10px;
  overflow: auto;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--r-sm);
  background: rgba(0, 0, 0, 0.35);
  color: #f3f4f6;
  white-space: pre-wrap;
  word-break: break-all;
  font-size: 12px;
}
.clipboard-remote .ghost { align-self: flex-start; }
.clipboard-panel textarea {
  width: 100%;
  min-height: 96px;
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--r-sm);
  background: rgba(0, 0, 0, 0.35);
  color: #f3f4f6;
  resize: vertical;
}
.clipboard-panel .actions { margin-top: 0; display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.clipboard-panel .ghost { color: #f3f4f6; border-color: rgba(255, 255, 255, 0.24); }
.clipboard-panel .muted { color: #9aa4b2; margin: 0; font-size: 13px; }

/* 文件传输浮层：默认隐藏，展开后占右下角，放在连接/结束 overlay 之下。 */
.files-panel {
  position: absolute;
  right: 16px;
  bottom: 16px;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  width: min(420px, calc(100% - 32px));
  max-height: min(60vh, 520px);
  padding: var(--sp-3);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--r-md);
  background: rgba(17, 22, 31, 0.96);
  color: #f3f4f6;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.files-panel .files-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); }
.files-panel .files-head-actions { display: flex; gap: 6px; }
.files-panel .files-upload { display: flex; gap: var(--sp-2); align-items: center; }
.files-panel .files-upload input { flex: 1; min-width: 0; margin: 0; padding: 6px 8px; color: #f3f4f6; }
.files-panel .files-upload button { flex: none; }
.files-panel .files-list { margin: 0; padding: 0; list-style: none; overflow: auto; min-height: 0; }
.files-panel .files-list li {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 6px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 13px;
}
.files-panel .files-list li:last-child { border-bottom: none; }
.files-panel .files-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.files-panel .files-size { flex: none; color: #9aa4b2; font-size: 12px; }
.files-panel .files-list button { flex: none; padding: 4px 8px; font-size: 12px; }
.files-panel .ghost { color: #f3f4f6; border-color: rgba(255, 255, 255, 0.24); }
.files-panel .ghost.danger { color: #fca5a5; }
.files-panel .muted { color: #9aa4b2; margin: 0; font-size: 13px; }

#ticket {
  margin: var(--sp-3) 0 0;
  padding: var(--sp-3);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-sunken);
  overflow: auto;
  font-size: 12px;
}
#ticket:empty { display: none; }
#store-error:empty, #accounts-error:empty { display: none; }
[data-sessions-error] { min-height: 0; margin: 0 0 var(--sp-2); }

/* M6 P1：增值能力复选框与平台目录明细。 */
.check-field {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: 13px;
  color: var(--text);
}
.check-field input { width: auto; }
#platform-skus td,
#platform-node-products td,
#platform-addon-products td,
#platform-entitlements td,
#entitlements td {
  vertical-align: top;
}

@media (max-width: 768px) {
  .viewer-body .top { height: 52px; padding: 0 10px; gap: 8px; }
  .viewer-body .sub { display: none; }
  .clipboard-panel { left: 8px; bottom: 8px; width: calc(100% - 16px); }
  .files-panel { right: 8px; bottom: 8px; width: calc(100% - 16px); max-height: 56vh; }
}
