/* ============================================================
   dealer-cdk 管理端 / 分销端共享样式 · DeepSleep AI · Penguin 设计语言
   v0.7.0：门户风格（品牌蓝 + 近黑主按钮 + 纯黑深色主题）
   主题切换：<html class="dark"> + localStorage "cdk-theme"（与门户一致）
   类名与旧版完全兼容（KeyFlow → DeepSleep AI 仅为文案与配色变化）
   ============================================================ */

:root {
  color-scheme: light;
  /* 品牌蓝——唯一的 accent 色系，克制使用 */
  --brand-50: #e8f0fe; --brand-100: #d2e3fc; --brand-300: #8ab4f8;
  --brand-500: #4285f4; --brand-600: #1a73e8; --brand-700: #0b57d0;
  /* 中性灰（Tailwind gray） */
  --gray-50: #f9fafb; --gray-100: #f3f4f6; --gray-200: #e5e7eb; --gray-300: #d1d5db;
  --gray-400: #9ca3af; --gray-500: #6b7280; --gray-600: #4b5563; --gray-900: #111827;
  --bg: #ffffff; --surface: #ffffff; --canvas: #f9fafb; --surface-soft: #f9fafb;
  --border: var(--gray-200); --control-border: var(--gray-300);
  --fg: var(--gray-900); --fg-muted: var(--gray-600); --fg-faint: var(--gray-500);
  /* 主按钮近黑非蓝 */
  --accent-bg: #111827; --accent-fg: #ffffff;
  --radius-control: 6px; --radius-card: 12px; --ease: cubic-bezier(0.2, 0.7, 0.3, 1);
  /* 状态色：绿仅用于「有效 / 成功」，红用于错误 */
  --ok: #16a34a; --ok-bg: #f0fdf4; --ok-border: #bbf7d0;
  --err: #b91c1c; --err-bg: #fef2f2; --err-border: #fecaca;
  --warning: #b45309; --warning-soft: #fffbeb; --warning-border: #fde68a;
  --info: #0b57d0; --info-soft: #e8f0fe;
  /* 旧变量名 → 新值（兼容旧内联用法） */
  --ink: var(--fg); --ink-soft: var(--fg-muted); --muted: var(--fg-faint);
  --line: var(--gray-200); --line-strong: var(--gray-300);
  --primary: var(--brand-600); --primary-hover: var(--brand-700); --primary-soft: var(--brand-50);
  --success: var(--ok); --success-soft: var(--ok-bg);
  --danger: var(--err); --danger-soft: var(--err-bg);
  --nav: #ffffff; --nav-soft: var(--gray-100);
  --shadow: 0 1px 3px rgb(0 0 0 / .05), 0 12px 32px rgb(17 24 39 / .08);
  --radius: var(--radius-card);
  --primary-metric-muted: rgba(255, 255, 255, .78);
}

.dark {
  color-scheme: dark; /* 纯黑，不带蓝调 */
  --bg: #000000; --surface: #0d0d0d; --canvas: #000000; --surface-soft: #0d0d0d;
  --gray-50: #111111; --gray-100: #1c1c1c; --gray-200: #1f1f1f; --gray-300: #303030;
  --gray-400: #4b5563; --gray-500: #6b7280; --gray-600: #9ca3af; --gray-900: #f3f4f6;
  --border: var(--gray-200); --control-border: var(--gray-300);
  --fg: var(--gray-900); --fg-muted: var(--gray-600); --fg-faint: var(--gray-500);
  --accent-bg: #f3f4f6; --accent-fg: #111827; /* 主按钮反转为浅色 */
  --brand-600: #8ab4f8; --brand-700: #8ab4f8;
  --ok: #4ade80; --ok-bg: #052e16; --ok-border: #166534;
  --err: #f87171; --err-bg: #450a0a; --err-border: #7f1d1d;
  --warning: #fbbf24; --warning-soft: #451a03; --warning-border: #78350f;
  --info: #8ab4f8; --info-soft: #172554;
  --ink: var(--fg); --ink-soft: var(--fg-muted); --muted: var(--fg-faint);
  --line: var(--gray-200); --line-strong: var(--gray-300);
  --primary: #8ab4f8; --primary-hover: #a5c8fd; --primary-soft: #172554;
  --success: var(--ok); --success-soft: var(--ok-bg);
  --danger: var(--err); --danger-soft: var(--err-bg);
  --nav: #0d0d0d; --nav-soft: var(--gray-100);
  --shadow: 0 1px 3px rgb(0 0 0 / .4), 0 12px 32px rgb(0 0 0 / .5);
  --primary-metric-muted: rgba(17, 24, 39, .68);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--canvas); }
body { margin: 0; min-height: 100vh; color: var(--fg); background: var(--canvas); font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif; font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; transition: background-color 150ms var(--ease), color 150ms var(--ease); }
button, input, textarea, select { font: inherit; letter-spacing: 0; }
button { color: inherit; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 3px solid rgb(107 114 128 / .4); outline-offset: 2px; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 6px; font-size: 28px; line-height: 1.2; }
h2 { margin-bottom: 4px; font-size: 18px; line-height: 1.3; }
h3 { font-size: 16px; line-height: 1.35; }
.hidden { display: none !important; }
.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; }

/* 主题切换图标：默认都渲染，浅色显示月亮、深色显示太阳（与门户一致） */
.icon-moon, .icon-sun { display: block; }
html:not(.dark) .icon-moon { display: block; }
html:not(.dark) .icon-sun { display: none; }
html.dark .icon-moon { display: none; }
html.dark .icon-sun { display: block; }

/* ============ 品牌 / 加载 ============ */
.loading-screen { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 12px; color: var(--muted); }
.loading-mark, .brand-mark { display: grid; place-items: center; flex: 0 0 auto; width: 36px; height: 36px; border-radius: 8px; background: var(--accent-bg); color: var(--accent-fg); font-size: 15px; font-weight: 700; }
.loading-mark { width: 44px; height: 44px; font-size: 17px; }
.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.brand > span:last-child { display: flex; flex-direction: column; min-width: 0; }
.brand strong { color: var(--fg); font-size: 15px; line-height: 1.2; }
.brand small { margin-top: 3px; color: var(--muted); font-size: 11px; }
.brand-dark strong { color: var(--fg); font-size: 17px; }
.brand-dark small { color: var(--muted); }

/* ============ 登录（门户式居中卡片） ============ */
.auth-screen { min-height: 100vh; display: grid; place-items: center; padding: 40px 20px; background: var(--canvas); }
.auth-panel { width: min(460px, 100%); padding: 40px 38px; border: 1px solid var(--line); border-radius: var(--radius-card); background: var(--surface); box-shadow: 0 1px 3px rgb(0 0 0 / .05); }
.auth-heading { margin: 52px 0 24px; }
.auth-heading h1 { font-size: 30px; letter-spacing: -0.02em; }
.auth-heading > p:last-child { color: var(--muted); margin-bottom: 0; }
.eyebrow { margin-bottom: 8px; color: var(--brand-600); font-size: 12px; font-weight: 600; letter-spacing: .12em; }
.auth-aside { display: none; }
.auth-aside-content { display: none; }
.signal-dot, .connection-dot { display: inline-block; width: 8px; height: 8px; margin-right: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 4px rgb(22 163 74 / .12); }
.auth-preview { display: none; }
.preview-line { display: none; }
.success-text { color: var(--ok); }
.auth-tabs { margin-bottom: 20px; display: flex; }

.admin-auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--canvas); }
.token-panel { width: min(460px, 100%); padding: 36px 34px; border: 1px solid var(--line); border-radius: var(--radius-card); background: var(--surface); box-shadow: 0 1px 3px rgb(0 0 0 / .05); }
.token-panel .auth-heading { margin: 44px 0 24px; }
.token-panel .auth-heading h1 { font-size: 26px; }

/* ============ 应用框架（侧边栏门户化：浅色 + 右边框） ============ */
.app-shell { display: grid; grid-template-columns: 244px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; z-index: 20; display: flex; flex-direction: column; height: 100vh; padding: 24px 16px 18px; color: var(--fg-muted); background: var(--surface); border-right: 1px solid var(--line); }
.sidebar .brand { padding: 0 10px; }
.side-nav { display: flex; flex-direction: column; gap: 3px; margin-top: 34px; }
.nav-item { display: flex; align-items: center; gap: 11px; width: 100%; min-height: 40px; padding: 8px 11px; border: 0; border-radius: 8px; color: var(--fg-muted); background: transparent; cursor: pointer; font-weight: 600; text-align: left; white-space: nowrap; transition: background-color 150ms var(--ease), color 150ms var(--ease); }
.nav-item:hover { color: var(--fg); background: var(--nav-soft); }
.nav-item.active { color: var(--primary); background: var(--primary-soft); }
.nav-icon { display: grid; place-items: center; width: 20px; min-width: 20px; font-size: 17px; font-weight: 400; }
.sidebar-account { display: grid; grid-template-columns: 36px minmax(0, 1fr) 34px; align-items: center; gap: 9px; margin-top: auto; padding: 14px 10px 2px; border-top: 1px solid var(--line); }
.account-copy { display: flex; flex-direction: column; min-width: 0; }
.account-copy strong, .account-copy span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-copy strong { font-size: 13px; color: var(--fg); }
.account-actions { display: flex; align-items: center; gap: 6px; }
.account-actions .btn-small { padding: 5px 8px; font-size: 11px; white-space: nowrap; }
.account-copy span { font-size: 11px; color: var(--muted); }
.sidebar-footer { display: flex; align-items: center; gap: 8px; margin-top: auto; padding: 16px 10px 2px; border-top: 1px solid var(--line); }
.sidebar-footer > div { display: flex; flex-direction: column; }
.sidebar-footer strong { color: var(--fg); font-size: 12px; }
.sidebar-footer small { color: var(--muted); font-size: 11px; }
.avatar { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 8px; color: var(--gray-600); background: var(--gray-100); font-weight: 700; }
.avatar.small { width: 32px; height: 32px; font-size: 12px; }

.workspace { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 15; display: flex; align-items: center; justify-content: space-between; min-height: 64px; padding: 10px 30px; border-bottom: 1px solid var(--line); background: var(--surface); background: color-mix(in srgb, var(--surface) 85%, transparent); backdrop-filter: blur(8px); transition: border-color 150ms var(--ease), background-color 150ms var(--ease); }
.topbar > div:first-child { display: flex; flex-direction: column; }
.topbar-label { color: var(--muted); font-size: 11px; }
.topbar strong { font-size: 14px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.content-area { width: min(1180px, 100%); margin: 0 auto; padding: 34px 30px 70px; }
.admin-content { width: min(1320px, 100%); }
.view { display: none; }
.view.active { display: block; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 26px; }
.page-heading h1 { margin-bottom: 7px; }
.page-heading > div > p:last-child { margin-bottom: 0; color: var(--muted); }
.heading-with-action { align-items: center; }

/* ============ 按钮 ============ */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 38px; padding: 8px 14px; border: 1px solid transparent; border-radius: var(--radius-control); cursor: pointer; font-weight: 600; white-space: nowrap; transition: background-color 150ms var(--ease), border-color 150ms var(--ease), opacity 150ms var(--ease); }
.btn:hover:not(:disabled) { opacity: .92; }
.btn:disabled { cursor: not-allowed; opacity: .5; }
.btn-primary { color: var(--accent-fg); background: var(--accent-bg); border-color: var(--accent-bg); }
.btn-primary:hover:not(:disabled) { opacity: .9; }
.btn-secondary { color: var(--fg); border-color: var(--control-border); background: var(--surface); }
.btn-secondary:hover:not(:disabled) { border-color: var(--gray-400); background: var(--gray-100); opacity: 1; }
.btn-quiet { color: var(--muted); border-color: transparent; background: transparent; }
.btn-quiet:hover:not(:disabled) { color: var(--fg); background: var(--gray-100); opacity: 1; }
.btn-danger-quiet { color: var(--danger); border-color: transparent; background: transparent; }
.btn-danger-quiet:hover { background: var(--danger-soft); opacity: 1; }
.btn-small { min-height: 32px; padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; }
.icon-button, .icon-btn { display: grid; place-items: center; width: 34px; height: 34px; padding: 0; border: 0; border-radius: 6px; color: var(--fg-muted); background: transparent; cursor: pointer; font-size: 19px; line-height: 1; transition: color 150ms var(--ease), background-color 150ms var(--ease); }
.icon-button:hover, .icon-btn:hover { color: var(--fg); background: var(--gray-100); }
.icon-button svg, .icon-btn svg { width: 18px; height: 18px; }
.icon-btn { width: 40px; height: 40px; border-radius: 8px; }
.text-button { padding: 4px; border: 0; color: var(--brand-700); background: transparent; cursor: pointer; font-weight: 600; }

/* ============ 表单 ============ */
.form-stack { display: flex; flex-direction: column; gap: 15px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { color: var(--fg-muted); font-size: 12px; font-weight: 600; }
.field-span-2 { grid-column: span 2; }
.field-hint { color: var(--muted); font-size: 11px; line-height: 1.45; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
input, textarea, select { width: 100%; min-height: 42px; padding: 9px 11px; border: 1px solid var(--control-border); border-radius: var(--radius-control); color: var(--fg); background: var(--surface); transition: border-color 150ms var(--ease), box-shadow 150ms var(--ease); }
textarea { resize: vertical; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--gray-400); box-shadow: 0 0 0 2px rgb(156 163 175 / .3); }
input::placeholder, textarea::placeholder { color: var(--fg-faint); }
input:disabled { color: var(--muted); background: var(--gray-100); }
.form-message { min-height: 21px; margin: -2px 0 0; color: var(--muted); font-size: 12px; }
.form-message.error { color: var(--danger); }
.form-message.success { color: var(--success); }

.segmented { display: inline-flex; max-width: 100%; padding: 3px; border: 1px solid var(--line); border-radius: 8px; background: var(--gray-100); overflow-x: auto; }
.segment { min-height: 32px; padding: 5px 12px; border: 0; border-radius: 6px; color: var(--muted); background: transparent; cursor: pointer; font-size: 12px; font-weight: 600; white-space: nowrap; }
.segment.active { color: var(--fg); background: var(--surface); box-shadow: 0 1px 3px rgb(0 0 0 / .1); }
.auth-tabs .segment { flex: 1; }

/* ============ 指标卡 ============ */
.metric-grid { display: grid; gap: 12px; margin-bottom: 34px; }
.dealer-metrics { grid-template-columns: 1.25fr repeat(2, minmax(0, 1fr)); }
.admin-metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.metric { position: relative; display: flex; flex-direction: column; min-height: 128px; padding: 20px; border: 1px solid var(--line); border-radius: var(--radius-card); background: var(--surface); overflow: hidden; transition: border-color 150ms var(--ease); }
.metric::before { position: absolute; top: 0; right: 0; left: 0; height: 3px; content: ""; background: var(--gray-300); }
.metric-warning::before { background: #f59e0b; }
.metric-success::before { background: var(--ok); }
.metric-info::before { background: var(--brand-500); }
.metric > span { color: var(--muted); font-size: 12px; font-weight: 600; }
.metric > strong { margin: 12px 0 5px; font-size: 27px; line-height: 1.15; overflow-wrap: anywhere; }
.metric > small { margin-top: auto; color: var(--muted); }
.primary-metric { color: var(--accent-fg); border-color: var(--accent-bg); background: var(--accent-bg); }
.primary-metric::before { background: rgb(255 255 255 / .35); }
.primary-metric > span, .primary-metric > small { color: var(--primary-metric-muted); }

.notice { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 18px; padding: 14px 16px; border: 1px solid; border-radius: var(--radius-card); }
.notice > div { display: flex; flex-direction: column; }
.notice span { font-size: 12px; }
.notice-warning { border-color: var(--warning-border); background: var(--warning-soft); }
.notice-warning > div span { color: var(--warning); }

.badge { display: inline-flex; align-items: center; width: fit-content; min-height: 24px; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; white-space: nowrap; gap: 5px; }
.badge-success { color: var(--ok); background: var(--ok-bg); }
.badge-warning { color: var(--warning); background: var(--warning-soft); }
.badge-danger { color: var(--err); background: var(--err-bg); }
.badge-info { color: var(--primary); background: var(--primary-soft); }
.badge-neutral { color: var(--fg-muted); background: var(--gray-100); }

/* 小圆点（网关状态等） */
.dot { display: inline-block; flex: none; width: 8px; height: 8px; border-radius: 9999px; background: currentColor; }
.dot-ok { color: var(--ok); }
.dot-danger { color: var(--err); }
.dot-warning { color: #f59e0b; }
.dot-muted { color: var(--gray-400); }

/* ============ 区块 / 卡片 ============ */
.section-block { margin-top: 28px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 14px; }
.section-heading h2 { margin-bottom: 2px; }
.section-heading p { margin: 0; color: var(--muted); font-size: 12px; }
.count-label { color: var(--muted); font-size: 12px; }
.sku-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.sku-card, .admin-sku-card { display: flex; flex-direction: column; min-width: 0; padding: 20px; border: 1px solid var(--line); border-radius: var(--radius-card); background: var(--surface); transition: border-color 150ms var(--ease); }
.sku-card.featured { border-color: var(--brand-300); box-shadow: 0 8px 24px rgb(66 133 244 / .08); }
.sku-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 24px; }
.sku-code { max-width: 100%; overflow: hidden; color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Courier New", monospace; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.sku-card h3, .admin-sku-card h3 { margin: 18px 0 7px; font-size: 18px; }
.sku-card > p, .admin-sku-card > p { min-height: 42px; margin-bottom: 18px; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.sku-price { display: flex; align-items: baseline; gap: 5px; margin-bottom: 16px; }
.sku-price strong { font-size: 25px; }
.sku-price span { color: var(--muted); font-size: 12px; }
.tag-row { display: flex; flex-wrap: wrap; gap: 6px; min-height: 56px; margin-bottom: 17px; align-content: flex-start; }
.tag-row span { padding: 4px 8px; border-radius: 6px; color: var(--fg-muted); background: var(--gray-100); font-size: 11px; }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.search-field { width: min(380px, 100%); }
.search-field input { min-height: 38px; background: var(--surface); }
.select-control { width: auto; min-width: 150px; min-height: 38px; }
.data-list { display: flex; flex-direction: column; gap: 8px; }
.data-row { display: grid; grid-template-columns: minmax(210px, 1.4fr) minmax(140px, .8fr) 120px auto; align-items: center; gap: 16px; min-height: 76px; padding: 13px 15px; border: 1px solid var(--line); border-radius: var(--radius-card); background: var(--surface); }
.row-main { display: flex; align-items: center; gap: 12px; min-width: 0; }
.row-main > div:last-child, .row-amount { display: flex; flex-direction: column; min-width: 0; }
.row-main strong, .row-main span, .row-amount strong, .row-amount span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-main span, .row-amount span { color: var(--muted); font-size: 11px; }
.order-number { display: grid; place-items: center; flex: 0 0 auto; width: 44px; height: 38px; border-radius: 8px; color: var(--primary); background: var(--primary-soft); font-weight: 700; }
.row-actions, .card-actions, .table-actions { display: flex; justify-content: flex-end; gap: 6px; flex-wrap: wrap; }
.ledger-row { grid-template-columns: 42px minmax(240px, 1fr) minmax(150px, auto); }
.ledger-symbol { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; font-size: 18px; font-weight: 800; }
.ledger-symbol.positive { color: var(--ok); background: var(--ok-bg); }
.ledger-symbol.negative { color: var(--err); background: var(--err-bg); }
.amount-positive { color: var(--ok); }
.empty-state { display: grid; place-items: center; min-height: 150px; padding: 24px; color: var(--muted); text-align: center; }
.empty-state > span { font-size: 25px; }
.empty-state strong { margin-top: 8px; color: var(--fg-muted); }
.empty-state p { margin: 3px 0 0; font-size: 12px; }

.overview-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 28px; }
.overview-grid .section-block { margin-top: 0; }
.compact-list { border-top: 1px solid var(--line); }
.compact-row { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; align-items: center; gap: 10px; min-height: 64px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.clickable-row { cursor: pointer; }
.clickable-row:hover { background: var(--gray-50); }
.compact-row > div:nth-child(2) { display: flex; flex-direction: column; min-width: 0; }
.compact-row strong, .compact-row span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.compact-row span { color: var(--muted); font-size: 11px; }
.order-dot { width: 9px; height: 9px; margin-left: 10px; border-radius: 50%; background: var(--gray-400); }
.order-dot.success { background: var(--ok); }
.order-dot.refunded, .order-dot.pending { background: #f59e0b; }
.order-dot.failed { background: var(--err); }

/* ============ 表格 ============ */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-card); background: var(--surface); }
table { width: 100%; border-collapse: collapse; min-width: 820px; }
th, td { padding: 13px 15px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { color: var(--muted); background: var(--gray-50); font-size: 11px; font-weight: 700; text-transform: uppercase; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--gray-50); }
td { color: var(--fg-muted); font-size: 12px; }
.align-right { text-align: right; }
.entity-cell { display: flex; align-items: center; gap: 10px; min-width: 190px; }
.entity-cell > div:last-child { display: flex; flex-direction: column; min-width: 0; }
.entity-cell strong { color: var(--fg); }
.entity-cell span, .cell-sub { display: block; color: var(--muted); font-size: 11px; }
.money-cell { color: var(--fg); font-weight: 700; }
.mobile-data-list { display: none; }

/* ============ 管理端套餐 ============ */
.admin-sku-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.admin-sku-card.disabled-card { opacity: .72; background: var(--gray-50); }
.admin-sku-price { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 14px; font-size: 21px; font-weight: 700; }
.admin-sku-price span { color: var(--muted); font-size: 12px; font-weight: 600; }
.admin-sku-card dl { display: grid; gap: 7px; margin: 0 0 18px; padding-top: 13px; border-top: 1px solid var(--line); }
.admin-sku-card dl div { display: flex; justify-content: space-between; gap: 12px; }
.admin-sku-card dt { color: var(--muted); font-size: 11px; }
.admin-sku-card dd { margin: 0; max-width: 60%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.admin-sku-card .card-actions { margin-top: auto; }
.integration-status { display: flex; align-items: center; gap: 9px; min-height: 42px; margin: -10px 0 18px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; color: var(--muted); background: var(--surface); font-size: 12px; }
.integration-status.success { color: var(--ok); border-color: var(--ok-border); background: var(--ok-bg); }
.integration-status.danger { color: var(--err); border-color: var(--err-border); background: var(--err-bg); }
.group-detail { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-soft); }
.group-detail.empty { display: block; color: var(--muted); font-size: 12px; }
.group-detail div { display: flex; flex-direction: column; min-width: 0; }
.group-detail span { color: var(--muted); font-size: 10px; }
.group-detail strong { margin-top: 3px; overflow-wrap: anywhere; font-size: 12px; }
.group-detail .quota-detail { grid-column: span 2; }

/* 站点配置：三档套餐编辑行 */
.pricing-editor { display: flex; flex-direction: column; gap: 10px; }
.tier-row { display: grid; grid-template-columns: minmax(150px, 2fr) 110px 100px minmax(170px, 3fr) auto auto auto; gap: 10px; align-items: center; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.tier-row .field { gap: 3px; }
.tier-row input { min-height: 38px; }
.tier-check { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 600; white-space: nowrap; }
.tier-check input { width: auto; min-height: auto; }

/* ============ 弹窗 ============ */
.modal { width: min(560px, calc(100% - 28px)); max-height: calc(100vh - 28px); padding: 0; border: 0; border-radius: var(--radius-card); background: transparent; overflow: visible; }
.modal::backdrop { background: rgb(17 24 39 / .55); backdrop-filter: blur(2px); }
.modal-panel { max-height: calc(100vh - 28px); padding: 24px; border-radius: var(--radius-card); background: var(--surface); box-shadow: 0 24px 70px rgb(0 0 0 / .28); overflow-y: auto; }
.modal-wide { width: min(760px, calc(100vw - 28px)); }
.modal:has(.modal-wide) { width: min(760px, calc(100% - 28px)); }
.modal-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.modal-header h2 { margin: 0; font-size: 21px; }
.modal-header .eyebrow { margin-bottom: 5px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 22px; }
.modal-note { margin-top: 14px; padding: 10px 12px; border-radius: 8px; color: var(--warning); background: var(--warning-soft); font-size: 12px; }
.confirm-summary { border: 1px solid var(--line); border-radius: 8px; }
.confirm-product { display: flex; flex-direction: column; padding: 15px; border-bottom: 1px solid var(--line); background: var(--gray-50); }
.confirm-product span, .confirm-product small { color: var(--muted); font-size: 11px; }
.confirm-product strong { margin: 4px 0; font-size: 16px; }
.confirm-summary dl, .order-detail dl { display: grid; gap: 10px; margin: 0; padding: 15px; }
.confirm-summary dl div, .order-detail dl div { display: flex; justify-content: space-between; gap: 18px; }
.confirm-summary dt, .order-detail dt { color: var(--muted); }
.confirm-summary dd, .order-detail dd { margin: 0; font-weight: 700; text-align: right; overflow-wrap: anywhere; }
.success-callout { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; padding: 13px; border-radius: 8px; color: var(--ok); background: var(--ok-bg); }
.success-callout > span { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; color: var(--ok-bg); background: var(--ok); }
.success-callout > div { display: flex; flex-direction: column; }
.success-callout small { color: var(--ok); opacity: .8; }
.delivery-message { max-height: 280px; margin: 0; padding: 14px; border: 1px solid #303030; border-radius: 8px; color: #d1d5db; background: #111827; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Courier New", monospace; font-size: 12px; line-height: 1.65; white-space: pre-wrap; overflow: auto; overflow-wrap: anywhere; }
.selected-entity { display: flex; align-items: center; gap: 11px; margin-bottom: 18px; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--gray-50); }
.selected-entity > div:last-child { display: flex; flex-direction: column; min-width: 0; }
.selected-entity span { color: var(--muted); font-size: 11px; }
.quick-amounts { display: flex; gap: 7px; margin-top: 8px; }
.quick-amounts button { padding: 5px 9px; border: 1px solid var(--line); border-radius: 6px; color: var(--brand-700); background: var(--surface); cursor: pointer; font-size: 11px; }
.detail-status { display: flex; align-items: center; justify-content: space-between; margin-bottom: 5px; }
.detail-status > span:last-child { color: var(--muted); font-size: 11px; }
.error-callout { display: flex; flex-direction: column; gap: 3px; padding: 12px; border-radius: 8px; color: var(--err); background: var(--err-bg); }
.error-callout span { font-size: 12px; overflow-wrap: anywhere; }
.result-panel { display: flex; flex-direction: column; }
.result-panel .success-callout { justify-content: center; }

/* 对接信息（分销端工作台新增区块） */
.info-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.info-cell { display: flex; flex-direction: column; gap: 4px; min-width: 0; padding: 12px 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.info-cell span { color: var(--muted); font-size: 11px; }
.info-cell strong { overflow-wrap: anywhere; font-size: 13px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Courier New", monospace; }

/* ============ Toast ============ */
.toast-region { position: fixed; right: 22px; bottom: 22px; z-index: 100; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { min-width: 220px; max-width: min(360px, calc(100vw - 32px)); padding: 11px 14px; border-radius: 8px; color: var(--accent-fg); background: var(--accent-bg); box-shadow: var(--shadow); opacity: 0; transform: translateY(8px); transition: opacity .18s ease, transform .18s ease; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast-danger { background: var(--danger); }

/* ============ 响应式 ============ */
@media (max-width: 1080px) {
  .admin-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sku-grid, .admin-sku-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
  .app-shell { display: block; }
  .sidebar { position: sticky; height: auto; padding: 12px 16px 8px; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar > .brand { display: none; }
  .side-nav { flex-direction: row; gap: 4px; margin: 0; overflow-x: auto; }
  .nav-item { justify-content: center; min-width: max-content; }
  .sidebar-account, .sidebar-footer { display: none; }
  .topbar { top: 58px; padding: 10px 18px; }
  .content-area { padding: 26px 18px 60px; }
  .overview-grid { grid-template-columns: 1fr; }
  .table-wrap { display: none; }
  .mobile-data-list { display: flex; flex-direction: column; gap: 9px; }
  .mobile-data-card { padding: 14px; border: 1px solid var(--line); border-radius: var(--radius-card); background: var(--surface); }
  .mobile-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
  .mobile-card-head > div { display: flex; flex-direction: column; min-width: 0; }
  .mobile-card-head span { color: var(--muted); font-size: 11px; }
  .mobile-data-card dl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 14px 0; }
  .mobile-data-card dl div { display: flex; flex-direction: column; }
  .mobile-data-card dt { color: var(--muted); font-size: 11px; }
  .mobile-data-card dd { margin: 2px 0 0; font-weight: 700; }
}

@media (max-width: 640px) {
  h1 { font-size: 24px; }
  .auth-panel { padding: 30px 22px; }
  .auth-heading { margin: 40px 0 22px; }
  .auth-heading h1 { font-size: 26px; }
  .token-panel { padding: 25px 20px; }
  .nav-icon { display: none; }
  .nav-item { min-height: 38px; padding: 7px 10px; font-size: 12px; }
  .topbar { top: 54px; min-height: 60px; padding: 9px 14px; }
  .topbar-label { display: none; }
  .topbar-actions { gap: 5px; }
  .content-area { padding: 23px 14px 50px; }
  .page-heading { align-items: flex-start; flex-direction: column; margin-bottom: 20px; }
  .heading-with-action .btn { width: 100%; }
  .dealer-metrics, .admin-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .primary-metric { grid-column: span 2; }
  .metric { min-height: 116px; padding: 16px; }
  .metric > strong { font-size: 22px; }
  .sku-grid, .admin-sku-grid { grid-template-columns: 1fr; }
  .sku-card > p, .admin-sku-card > p { min-height: auto; }
  .toolbar { align-items: stretch; flex-direction: column; }
  .search-field, .select-control { width: 100%; }
  .segmented { width: 100%; }
  .toolbar .segment { flex: 1; }
  .data-row { grid-template-columns: minmax(0, 1fr) auto; gap: 12px; }
  .data-row > .row-amount { grid-column: 1; }
  .data-row > .row-actions { grid-column: 2; grid-row: 2; }
  .ledger-row { grid-template-columns: 36px minmax(0, 1fr); }
  .ledger-row .row-amount { grid-column: 2; }
  .form-grid { grid-template-columns: 1fr; }
  .field-span-2 { grid-column: auto; }
  .page-actions { width: 100%; }
  .page-actions .btn { width: auto; flex: 1; }
  .group-detail { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tier-row { grid-template-columns: 1fr 1fr; }
  .tier-row .tier-name { grid-column: span 2; }
  .tier-row .tier-desc { grid-column: span 2; }
  .modal-panel { padding: 19px; }
  .modal-actions .btn { flex: 1; }
  .toast-region { right: 16px; bottom: 16px; left: 16px; }
  .toast { width: 100%; max-width: none; }
  .info-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
