/* ============================================================
   授权中心 · UI 设计系统 v2
   统一后台 / 代理端 / 弹层 / 表单 / 表格 视觉规范
   ============================================================ */

:root {
    --brand: #5b5bf0;
    --brand-600: #4f46e5;
    --brand-700: #4338ca;
    --brand-soft: #eef0ff;
    --violet: #8b5cf6;
    --cyan: #06b6d4;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;

    --bg: #f5f7fc;
    --bg-soft: #eef1f9;
    --surface: #ffffff;
    --surface-2: #fafbff;
    --sidebar: #0b1020;
    --sidebar-2: #121a30;

    --text: #0f172a;
    --text-2: #475569;
    --muted: #8490a8;
    --line: #e7ebf5;
    --line-strong: #d8dfee;

    --radius: 16px;
    --radius-sm: 10px;
    --radius-xs: 8px;
    --shadow-xs: 0 1px 2px rgba(15, 23, 42, .05);
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .04), 0 6px 18px -10px rgba(15, 23, 42, .14);
    --shadow-md: 0 2px 4px rgba(15, 23, 42, .04), 0 18px 40px -22px rgba(15, 23, 42, .28);
    --shadow-pop: 0 24px 60px -20px rgba(15, 23, 42, .35);

    --grad: linear-gradient(135deg, #6366f1 0%, #8b5cf6 55%, #22d3ee 130%);
    --sidebar-w: 252px;
    --topbar-h: 64px;

    --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC", sans-serif;
}

[data-theme="dark"] {
    --bg: #080c17;
    --bg-soft: #0d1324;
    --surface: #0f1626;
    --surface-2: #131c30;
    --sidebar: #070b14;
    --sidebar-2: #0d1526;
    --text: #e8edf9;
    --text-2: #a9b6cf;
    --muted: #7b89a4;
    --line: #1c2740;
    --line-strong: #26334f;
    --brand-soft: rgba(99, 102, 241, .16);
    --shadow-sm: 0 8px 24px -16px rgba(0, 0, 0, .8);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-600); }

::selection { background: rgba(99, 102, 241, .22); }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: rgba(100, 116, 139, .28); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: rgba(100, 116, 139, .5); }
::-webkit-scrollbar-track { background: transparent; }

.mono, .num { font-variant-numeric: tabular-nums; }

/* ============================================================
   1. 后台外壳 Shell
   ============================================================ */
.shell { min-height: 100vh; background: var(--bg); }

.sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--sidebar-w);
    background: radial-gradient(120% 60% at 0% 0%, rgba(99, 102, 241, .22) 0%, rgba(11, 16, 32, 0) 60%),
    linear-gradient(180deg, var(--sidebar) 0%, var(--sidebar-2) 100%);
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    z-index: 60;
    border-right: 1px solid rgba(148, 163, 184, .08);
    transition: transform .28s cubic-bezier(.4, 0, .2, 1);
}

.sidebar::after {
    content: "";
    position: absolute; inset: 0;
    background-image: radial-gradient(rgba(255, 255, 255, .045) 1px, transparent 1px);
    background-size: 18px 18px;
    pointer-events: none;
    mask-image: linear-gradient(180deg, rgba(0, 0, 0, .5), transparent 70%);
}

.brand {
    display: flex; align-items: center; gap: 12px;
    height: var(--topbar-h);
    padding: 0 20px;
    flex: none;
    position: relative;
    z-index: 1;
}

.brand-mark {
    width: 38px; height: 38px;
    border-radius: 12px;
    background: var(--grad);
    display: grid; place-items: center;
    color: #fff;
    box-shadow: 0 10px 22px -10px rgba(99, 102, 241, .9);
    flex: none;
}

.brand-mark svg { width: 21px; height: 21px; }

.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-name { font-size: 15px; font-weight: 650; color: #fff; letter-spacing: .2px; white-space: nowrap; }
.brand-sub { font-size: 10.5px; letter-spacing: .16em; text-transform: uppercase; color: #7c8ab0; }

.sidebar-scroll { flex: 1; overflow-y: auto; padding: 8px 12px 18px; position: relative; z-index: 1; }

.nav-section { margin-bottom: 6px; }

.nav-section-title {
    font-size: 10.5px;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: #5f6c8c;
    padding: 14px 12px 8px;
    font-weight: 600;
}

.nav-link {
    display: flex; align-items: center; gap: 11px;
    padding: 10px 12px;
    border-radius: 11px;
    color: #a7b3cd;
    font-size: 13.5px;
    font-weight: 500;
    cursor: pointer;
    position: relative;
    transition: background .18s, color .18s, transform .18s;
    user-select: none;
}

.nav-link:hover { background: rgba(148, 163, 184, .1); color: #fff; }
.nav-link:active { transform: scale(.99); }

.nav-link.active {
    color: #fff;
    background: linear-gradient(90deg, rgba(99, 102, 241, .3), rgba(99, 102, 241, .06));
    box-shadow: inset 0 0 0 1px rgba(129, 140, 248, .28);
}

.nav-link.active::before {
    content: "";
    position: absolute; left: -12px; top: 50%; transform: translateY(-50%);
    width: 3px; height: 18px; border-radius: 0 4px 4px 0;
    background: linear-gradient(180deg, #818cf8, #22d3ee);
}

.nav-icon { width: 18px; height: 18px; flex: none; opacity: .92; }
.nav-icon svg { width: 18px; height: 18px; display: block; }
.nav-text { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.nav-badge {
    font-size: 10.5px; font-weight: 600; padding: 1px 7px; border-radius: 99px;
    background: rgba(34, 211, 238, .14); color: #67e8f9;
}

.sidebar-foot {
    flex: none; padding: 14px 18px 16px;
    border-top: 1px solid rgba(148, 163, 184, .1);
    position: relative; z-index: 1;
}

.sidebar-foot-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sidebar-foot .ver { font-size: 11px; color: #6d7a99; }
.dot-live { width: 7px; height: 7px; border-radius: 50%; background: #34d399; box-shadow: 0 0 0 4px rgba(52, 211, 153, .14); display: inline-block; margin-right: 6px; }

.main {
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    display: flex; flex-direction: column;
    min-width: 0;
}

.topbar {
    height: var(--topbar-h);
    position: sticky; top: 0; z-index: 40;
    display: flex; align-items: center; gap: 14px;
    padding: 0 22px;
    background: color-mix(in srgb, var(--surface) 82%, transparent);
    backdrop-filter: blur(14px) saturate(180%);
    -webkit-backdrop-filter: blur(14px) saturate(180%);
    border-bottom: 1px solid var(--line);
}

.icon-btn {
    width: 36px; height: 36px; border-radius: 10px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-2);
    display: inline-grid; place-items: center;
    cursor: pointer;
    transition: background .16s, color .16s, border-color .16s;
    flex: none;
}
.icon-btn:hover { background: var(--bg-soft); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn.is-mobile { display: none; }

.topbar-context { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.topbar-context .eyebrow { font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.topbar-context .page-now { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.topbar-spacer { flex: 1; }

.search-pill {
    display: flex; align-items: center; gap: 8px;
    height: 36px; padding: 0 12px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 10px;
    color: var(--muted);
    font-size: 12.5px;
    min-width: 200px;
    cursor: pointer;
    transition: border-color .16s, box-shadow .16s;
}
.search-pill:hover { border-color: var(--line-strong); box-shadow: var(--shadow-xs); }
.search-pill svg { width: 15px; height: 15px; }
.search-pill kbd {
    margin-left: auto; font-family: var(--font); font-size: 10.5px;
    border: 1px solid var(--line); background: var(--surface);
    border-radius: 5px; padding: 0 5px; color: var(--muted);
}

.user-chip {
    display: flex; align-items: center; gap: 10px;
    padding: 4px 10px 4px 4px;
    border-radius: 99px;
    border: 1px solid var(--line);
    background: var(--surface);
    cursor: pointer;
    transition: box-shadow .16s, border-color .16s;
    position: relative;
}
.user-chip:hover { box-shadow: var(--shadow-sm); border-color: var(--line-strong); }
.user-chip img, .user-chip .avatar {
    width: 30px; height: 30px; border-radius: 50%; object-fit: cover; flex: none;
    background: var(--grad); color: #fff; display: grid; place-items: center;
    font-size: 12px; font-weight: 600;
}
.user-meta { display: flex; flex-direction: column; line-height: 1.2; }
.user-meta .u-name { font-size: 12.5px; font-weight: 600; color: var(--text); max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-meta .u-role { font-size: 10.5px; color: var(--muted); }

.dropdown {
    position: absolute; right: 0; top: calc(100% + 10px);
    min-width: 190px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: var(--shadow-pop);
    padding: 6px;
    display: none;
    z-index: 80;
}
.dropdown.open { display: block; animation: pop .16s ease-out; }
.dropdown a {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 10px; border-radius: 9px;
    font-size: 13px; color: var(--text-2);
}
.dropdown a:hover { background: var(--bg-soft); color: var(--text); }
.dropdown .sep { height: 1px; background: var(--line); margin: 6px 4px; }
.dropdown a.danger { color: var(--danger); }
.dropdown svg { width: 15px; height: 15px; opacity: .8; }

@keyframes pop { from { opacity: 0; transform: translateY(-6px) scale(.98); } to { opacity: 1; transform: none; } }

/* 标签栏 */
.tabbar {
    display: flex; align-items: center; gap: 6px;
    height: 48px; padding: 0 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    flex: none;
    position: sticky; top: var(--topbar-h); z-index: 35;
}
.tabbar::-webkit-scrollbar { display: none; }

.tab {
    display: inline-flex; align-items: center; gap: 7px;
    height: 32px; padding: 0 10px 0 12px;
    border-radius: 9px;
    font-size: 12.5px; font-weight: 500;
    color: var(--text-2);
    background: transparent;
    border: 1px solid transparent;
    cursor: pointer;
    white-space: nowrap;
    flex: none;
    transition: background .16s, color .16s, border-color .16s;
}
.tab:hover { background: var(--bg-soft); }
.tab.active {
    background: var(--brand-soft);
    color: var(--brand-600);
    border-color: rgba(99, 102, 241, .18);
}
.tab .tab-close {
    width: 16px; height: 16px; border-radius: 5px;
    display: grid; place-items: center; opacity: .45;
    font-size: 14px; line-height: 1;
}
.tab .tab-close:hover { background: rgba(15, 23, 42, .08); opacity: 1; }
.tab .tab-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--brand); display: none; }
.tab.active .tab-dot { display: inline-block; }

.tabbar-tools { margin-left: auto; display: flex; gap: 4px; padding-left: 10px; background: var(--surface); position: sticky; right: 0; }

/* 工作区 */
.workspace { flex: 1; position: relative; min-height: 0; background: var(--bg); }
.tab-pane { position: absolute; inset: 0; display: none; }
.tab-pane.active { display: block; }
.tab-pane iframe { width: 100%; height: 100%; border: 0; display: block; background: var(--bg); }

.scrim {
    position: fixed; inset: 0; background: rgba(8, 12, 24, .5);
    backdrop-filter: blur(2px);
    opacity: 0; pointer-events: none; transition: opacity .25s; z-index: 55;
}
.scrim.show { opacity: 1; pointer-events: auto; }

/* ============================================================
   2. 页面骨架（iframe 内页）
   ============================================================ */
.ui-page { padding: 22px 24px 32px; max-width: 1720px; }

.page-head {
    display: flex; align-items: flex-end; justify-content: space-between;
    gap: 16px; margin-bottom: 18px; flex-wrap: wrap;
}
.page-head h1 {
    margin: 0; font-size: 20px; font-weight: 680; letter-spacing: -.02em;
    color: var(--text); display: flex; align-items: center; gap: 10px;
}
.page-head .sub { margin: 4px 0 0; font-size: 12.5px; color: var(--muted); }
.page-head > div { min-width: 0; }
.page-head .actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; min-width: 0; max-width: 100%; }

.eyebrow {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase;
    color: var(--muted); font-weight: 600;
}

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.card-pad { padding: 18px 20px; }

.card-head {
    display: flex; align-items: center; gap: 10px;
    padding: 15px 18px;
    border-bottom: 1px solid var(--line);
}
.card-head h3 { margin: 0; font-size: 14px; font-weight: 650; }
.card-head .hint { font-size: 12px; color: var(--muted); margin-left: auto; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* 统计卡 */
.stat {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: transform .2s, box-shadow .2s, border-color .2s;
}
.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--line-strong); }
.stat::after {
    content: ""; position: absolute; right: -40px; top: -40px;
    width: 120px; height: 120px; border-radius: 50%;
    background: radial-gradient(circle, rgba(99, 102, 241, .12), transparent 70%);
}
.stat-top { display: flex; align-items: center; justify-content: space-between; }
.stat-ico {
    width: 38px; height: 38px; border-radius: 11px;
    display: grid; place-items: center; color: #fff;
    background: var(--grad);
    box-shadow: 0 8px 16px -10px rgba(99, 102, 241, .9);
}
.stat-ico svg { width: 19px; height: 19px; }
.stat-ico.c-cyan { background: linear-gradient(135deg, #06b6d4, #3b82f6); box-shadow: 0 8px 16px -10px rgba(6, 182, 212, .9); }
.stat-ico.c-amber { background: linear-gradient(135deg, #f59e0b, #f97316); box-shadow: 0 8px 16px -10px rgba(245, 158, 11, .9); }
.stat-ico.c-green { background: linear-gradient(135deg, #10b981, #22c55e); box-shadow: 0 8px 16px -10px rgba(16, 185, 129, .9); }
.stat-ico.c-pink { background: linear-gradient(135deg, #ec4899, #f43f5e); box-shadow: 0 8px 16px -10px rgba(236, 72, 153, .9); }
.stat-ico.c-slate { background: linear-gradient(135deg, #475569, #0f172a); box-shadow: 0 8px 16px -10px rgba(15, 23, 42, .8); }

.stat-label { font-size: 12.5px; color: var(--text-2); font-weight: 500; }
.stat-value { font-size: 28px; font-weight: 700; letter-spacing: -.03em; margin-top: 10px; line-height: 1; font-variant-numeric: tabular-nums; }
.stat-foot { display: flex; align-items: center; gap: 6px; margin-top: 10px; font-size: 11.5px; color: var(--muted); }
.trend-up { color: var(--success); font-weight: 600; }
.trend-down { color: var(--danger); font-weight: 600; }

/* 快捷入口 */
.quick {
    display: flex; align-items: center; gap: 12px;
    padding: 13px 14px;
    border-radius: 13px;
    border: 1px solid var(--line);
    background: var(--surface);
    cursor: pointer;
    transition: transform .18s, border-color .18s, box-shadow .18s;
}
.quick:hover { transform: translateY(-2px); border-color: rgba(99, 102, 241, .35); box-shadow: var(--shadow-sm); }
.quick .qi {
    width: 34px; height: 34px; border-radius: 10px; flex: none;
    display: grid; place-items: center;
    background: var(--brand-soft); color: var(--brand-600);
}
.quick .qi svg { width: 17px; height: 17px; }
.quick .qt { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.quick .qt b { font-size: 13px; font-weight: 600; color: var(--text); }
.quick .qt span { font-size: 11.5px; color: var(--muted); }

/* 列表/说明文字 */
.prose { font-size: 13.5px; color: var(--text-2); line-height: 1.85; }
.prose p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.tiny { font-size: 11.5px; }
.hr { height: 1px; background: var(--line); border: 0; margin: 16px 0; }

.empty {
    display: flex; flex-direction: column; align-items: center; gap: 8px;
    padding: 46px 20px; color: var(--muted); font-size: 13px;
}
.empty svg { width: 40px; height: 40px; opacity: .5; }

/* ============================================================
   3. 覆盖 layui 组件
   ============================================================ */
.layui-btn {
    height: 36px; line-height: 36px;
    padding: 0 14px;
    border-radius: 10px;
    font-size: 13px; font-weight: 550;
    background: var(--brand-600);
    border: 1px solid transparent;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .08);
    transition: filter .16s, transform .1s, box-shadow .16s;
}
.layui-btn:hover { filter: brightness(1.06); color: #fff; box-shadow: 0 6px 14px -8px rgba(79, 70, 229, .8); }
.layui-btn:active { transform: translateY(1px); }
.layui-btn + .layui-btn { margin-left: 6px; }

.layui-btn-normal { background: linear-gradient(135deg, var(--brand), var(--violet)); box-shadow: 0 8px 18px -12px rgba(99, 102, 241, .95); }
.layui-btn-warm { background: linear-gradient(135deg, #f59e0b, #f97316); }
.layui-btn-danger { background: #fef2f2; color: #dc2626; border-color: #fecaca; box-shadow: none; }
.layui-btn-danger:hover { background: #fee2e2; color: #b91c1c; }
.layui-btn-primary { background: var(--surface); border-color: var(--line-strong); color: var(--text-2); box-shadow: none; }
.layui-btn-primary:hover { border-color: var(--brand); color: var(--brand-600); }
.layui-btn-disabled, .layui-btn-disabled:hover { background: var(--bg-soft) !important; color: var(--muted) !important; border-color: var(--line) !important; box-shadow: none; }

.layui-btn-xs { height: 28px; line-height: 28px; padding: 0 10px; font-size: 12px; border-radius: 8px; }
.layui-btn-sm { height: 32px; line-height: 32px; padding: 0 12px; font-size: 12.5px; border-radius: 9px; }
.layui-btn-lg { height: 44px; line-height: 44px; padding: 0 22px; font-size: 14px; border-radius: 12px; }
.layui-btn-fluid { border-radius: 12px; }

.layui-input, .layui-textarea, .layui-select {
    height: 40px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line-strong);
    background: var(--surface);
    color: var(--text);
    font-size: 13.5px;
    padding-left: 12px;
    transition: border-color .16s, box-shadow .16s, background .16s;
}
.layui-textarea { height: auto; padding: 10px 12px; line-height: 1.7; }
.layui-input:hover, .layui-textarea:hover { border-color: #b9c3d9 !important; }
.layui-input:focus, .layui-textarea:focus, .layui-select:focus {
    border-color: var(--brand) !important;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, .12);
    background: var(--surface);
}
.layui-input::placeholder, .layui-textarea::placeholder { color: #a3aec2; }

.layui-form-label { width: 108px; padding: 9px 14px 9px 0; font-size: 13px; color: var(--text-2); font-weight: 500; text-align: right; }
.layui-input-block { margin-left: 138px; min-height: 40px; }
.layui-input-inline { margin-right: 10px; }
.layui-form-item { margin-bottom: 18px; }
.layui-form-mid { line-height: 40px; color: var(--muted); font-size: 12.5px; }
.layui-elem-quote { border-left: 3px solid var(--brand); background: var(--brand-soft); border-radius: 0 10px 10px 0; color: var(--text-2); font-size: 13px; padding: 12px 16px; }

.layui-form-select dl {
    border-radius: 12px; border-color: var(--line); box-shadow: var(--shadow-pop); padding: 6px; top: 44px;
}
.layui-form-select dl dd { border-radius: 8px; font-size: 13px; line-height: 34px; }
.layui-form-select dl dd.layui-this { background: var(--brand-soft); color: var(--brand-600); font-weight: 600; }
.layui-form-select .layui-edge { border-top-color: var(--muted); }
.layui-form-select dl dd:hover { background: var(--bg-soft); }

.layui-form-radio, .layui-form-checkbox { margin-right: 14px; color: var(--text-2); font-size: 13px; }
.layui-form-radio > i { font-size: 17px; color: #b6c0d4; }
.layui-form-radioed > i, .layui-form-radio > i:hover { color: var(--brand); }
.layui-form-checkbox[lay-skin="primary"] > i { border-radius: 6px; }
.layui-form-checked[lay-skin="primary"] > i { border-color: var(--brand) !important; background: var(--brand); }

.layui-form-switch { height: 22px; min-width: 44px; border-radius: 99px; margin-top: 9px; border-color: var(--line-strong); background: #e2e8f4; }
.layui-form-switch > i { width: 18px; height: 18px; top: 1px; left: 2px; }
.layui-form-onswitch { background: var(--brand); border-color: var(--brand); }
.layui-form-onswitch > i { right: 2px; }

.layui-table-view {
    border: 1px solid var(--line);
    border-radius: 14px;
    overflow: hidden;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    margin: 0;
}
.layui-table-view .layui-table { background: transparent; }
.layui-table-header { background: var(--surface-2); }
.layui-table th {
    font-size: 11.5px; font-weight: 650; color: var(--text-2);
    letter-spacing: .04em; text-transform: uppercase;
    height: 42px; border-color: var(--line) !important;
    background: var(--surface-2);
}
.layui-table td {
    font-size: 13px; color: var(--text);
    height: 46px; border-color: var(--line) !important;
    border-bottom: 1px solid var(--line) !important;
}
.layui-table tbody tr:hover, .layui-table-hover { background: #f7f8ff !important; }
.layui-table[lay-even] tbody tr:nth-child(even) { background: transparent; }
.layui-table-cell { height: 46px; line-height: 46px; padding: 0 14px; }
.layui-table-page { border-top: 1px solid var(--line); padding: 12px 12px; background: var(--surface); }
.layui-table-tool { background: var(--surface); border-bottom: 1px solid var(--line); }
.layui-table-tool-temp { padding-right: 0; }
.layui-table-view .layui-table-tool { border-radius: 14px 14px 0 0; }
.layui-table-tips-main { border-radius: 10px; font-size: 12.5px; }

.layui-laypage a, .layui-laypage span {
    border-radius: 8px; border-color: var(--line); background: var(--surface);
    color: var(--text-2); font-size: 12.5px; margin-right: 4px;
}
.layui-laypage .layui-laypage-curr .layui-laypage-em { background: var(--brand); border-radius: 8px; }
.layui-laypage a:hover { color: var(--brand); }

.layui-tab { margin: 0; }
.layui-tab-title { background: transparent; border-color: var(--line); }
.layui-tab-title li { font-size: 13px; color: var(--text-2); }
.layui-tab-title .layui-this { color: var(--brand-600); font-weight: 600; }
.layui-tab-brief > .layui-tab-title .layui-this:after { border-bottom: 2px solid var(--brand); }
.layui-tab-card { border-radius: 14px; box-shadow: var(--shadow-sm); border-color: var(--line); background: var(--surface); }

.layui-colla-item { border-color: var(--line); border-radius: 12px; overflow: hidden; background: var(--surface); }
.layui-colla-title { background: var(--surface-2); font-size: 13px; font-weight: 600; color: var(--text); height: 46px; line-height: 46px; }
.layui-colla-content { padding: 16px; font-size: 13px; color: var(--text-2); }

.layui-layer { border-radius: 16px !important; box-shadow: var(--shadow-pop) !important; overflow: hidden; }
.layui-layer-title {
    height: 52px; line-height: 52px; padding: 0 20px;
    background: var(--surface); border-bottom: 1px solid var(--line);
    font-size: 14px; font-weight: 650; color: var(--text);
}
.layui-layer-content { color: var(--text-2); font-size: 13.5px; }
.layui-layer-btn { padding: 12px 18px 18px; }
.layui-layer-btn a { height: 34px; line-height: 34px; border-radius: 9px; font-size: 12.5px; }
.layui-layer-btn .layui-layer-btn0 { background: var(--brand-600); border-color: var(--brand-600); }
.layui-layer-page .layui-layer-content { background: var(--surface); }
.layui-layer-iframe iframe { background: var(--bg); }
.layui-layer-close { color: var(--muted); opacity: .7; }
.layui-layer-setwin .layui-layer-close1 { background-size: 12px; }

.layui-badge, .layui-badge-rim { border-radius: 99px; font-size: 11px; padding: 0 8px; }
.layui-bg-green { background: var(--success) !important; }
.layui-bg-red { background: var(--danger) !important; }
.layui-bg-blue { background: var(--brand) !important; }
.layui-bg-orange { background: var(--warning) !important; }

.layui-elem-field legend { font-size: 13px; font-weight: 650; color: var(--text); }

/* 表格工具栏 */
.layui-table-tool-self { top: 8px; right: 8px; }
.layui-table-tool .layui-inline { margin-bottom: 0; }
.layui-table-tool .layui-btn { height: 30px; line-height: 30px; }

/* 内页通用布局修正 */
.my-index-main { padding: 22px 24px 30px; margin: 0 !important; }
.layui-row.layui-col-space10 { margin: -8px; }
.layui-row.layui-col-space10 > * { padding: 8px; }

body.body { background: var(--bg); }

/* 让旧页面里的 inline 深色按钮也回归体系 */
button.layui-btn { font-family: var(--font); }

/* 响应式 */
@media (max-width: 1180px) {
    .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* 栅格子项不因内容（表格 / 长文本）撑破容器 */
.grid > *, .dash-main > * { min-width: 0; }
.card { min-width: 0; }

@media (max-width: 960px) {
    .sidebar { transform: translateX(-100%); box-shadow: none; }
    .sidebar.open { transform: none; box-shadow: 0 30px 80px rgba(0, 0, 0, .45); }
    .main { margin-left: 0; }
    .icon-btn.is-mobile { display: inline-grid; }
    .search-pill { display: none; }
    .topbar { padding: 0 14px; }
    .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); }
    .ui-page { padding: 16px 14px 26px; }
    .my-index-main { padding: 16px 14px 24px; }
    .page-head h1 { font-size: 18px; }
    .user-meta { display: none; }
    .user-chip { padding: 4px; }
    .tabbar { padding: 0 10px; }
}

@media (max-width: 680px) {
    .stat-value { font-size: 24px; }
    .layui-form-label { width: 84px; padding-right: 10px; }
    .layui-input-block { margin-left: 108px; }
    /* 页头改成上下两段，操作按钮整行均分，避免右侧按钮被挤出屏幕 */
    .page-head { flex-direction: column; align-items: stretch; gap: 12px; }
    .page-head .actions { width: 100%; gap: 8px; flex-wrap: nowrap; }
    .page-head .actions > .btn {
        flex: 1 1 0; min-width: 0; padding: 0 8px;
        overflow: hidden; text-overflow: ellipsis;
    }
    .page-head .actions > .btn svg { flex: none; }
}

/* ============================================================
   4. 折叠侧栏 / 命令面板 / 轻提示
   ============================================================ */
body.sidebar-collapsed .sidebar { width: 76px; }
body.sidebar-collapsed .main { margin-left: 76px; }
body.sidebar-collapsed .brand { padding: 0; justify-content: center; }
body.sidebar-collapsed .brand-text,
body.sidebar-collapsed .nav-text,
body.sidebar-collapsed .nav-badge,
body.sidebar-collapsed .nav-section-title,
body.sidebar-collapsed .sidebar-foot .link-text { display: none; }
body.sidebar-collapsed .nav-link { justify-content: center; padding: 11px 0; }
body.sidebar-collapsed .nav-link.active::before { display: none; }
body.sidebar-collapsed .nav-section { margin-bottom: 2px; }
body.sidebar-collapsed .sidebar-scroll { padding: 10px 12px 18px; }
body.sidebar-collapsed .sidebar-foot { padding: 12px 8px; }
body.sidebar-collapsed .sidebar-foot-row { justify-content: center; }

.palette {
    position: fixed; inset: 0; z-index: 200;
    display: flex; align-items: flex-start; justify-content: center;
    padding-top: 12vh;
    background: rgba(8, 12, 24, .55);
    backdrop-filter: blur(4px);
    opacity: 0; pointer-events: none;
    transition: opacity .18s;
}
.palette.show { opacity: 1; pointer-events: auto; }
.palette-panel {
    width: min(560px, 92vw);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: var(--shadow-pop);
    overflow: hidden;
    transform: translateY(-8px) scale(.985);
    transition: transform .18s;
}
.palette.show .palette-panel { transform: none; }
.palette-search { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.palette-search svg { width: 18px; height: 18px; color: var(--muted); flex: none; }
.palette-search input {
    flex: 1; border: 0; outline: 0; background: transparent;
    font-family: var(--font); font-size: 14.5px; color: var(--text);
}
.palette-search kbd { font-size: 10.5px; color: var(--muted); border: 1px solid var(--line); border-radius: 5px; padding: 1px 6px; }
.palette-list { max-height: 46vh; overflow-y: auto; padding: 8px; }
.palette-item {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 12px; border-radius: 10px; cursor: pointer; font-size: 13.5px;
    color: var(--text-2);
}
.palette-item .pi-group { font-size: 11px; color: var(--muted); }
.palette-item:hover, .palette-item.focus { background: var(--brand-soft); color: var(--brand-700); }
.palette-empty { padding: 22px; text-align: center; color: var(--muted); font-size: 13px; }

.ui-toast-box {
    position: fixed; top: 18px; left: 50%; transform: translateX(-50%);
    z-index: 9999; display: flex; flex-direction: column; gap: 8px; align-items: center;
    pointer-events: none;
}
.ui-toast {
    padding: 9px 16px; border-radius: 10px;
    background: rgba(15, 23, 42, .92); color: #fff;
    font-size: 13px; box-shadow: var(--shadow-pop);
    animation: toastIn .22s ease-out;
}
.ui-toast.ok { background: rgba(5, 150, 105, .96); }
.ui-toast.err { background: rgba(220, 38, 38, .96); }
.ui-toast.out { opacity: 0; transform: translateY(-6px); transition: all .24s; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* 独立表单卡片化 */
.my-index-main > .card.card-pad > .layui-form { padding: 4px 4px 0; }
.my-index-main > .card.card-pad { margin-bottom: 16px; }
.page-head + .card { margin-top: 0; }

/* 旧版页面里偶发的写死底色/白字修正 */
.body .layui-elem-quote a { color: var(--brand-600); }

/* ============================================================
   5. 通用表格 / 弹窗 / 按钮（新页面使用）
   ============================================================ */
.table-ui { width: 100%; border-collapse: collapse; font-size: 13px; }
.table-ui thead th {
    text-align: left; font-size: 11px; letter-spacing: .06em; text-transform: uppercase;
    color: var(--muted); font-weight: 650; padding: 12px 14px;
    background: var(--surface-2); border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
.table-ui tbody td { padding: 13px 14px; border-bottom: 1px solid var(--line); color: var(--text-2); }
.table-ui tbody tr:last-child td { border-bottom: 0; }
.table-ui tbody tr:hover td { background: var(--surface-2); }
.table-ui .strong { color: var(--text); font-weight: 600; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    height: 36px; padding: 0 14px; border-radius: 10px;
    border: 1px solid var(--line-strong); background: var(--surface); color: var(--text-2);
    font-family: var(--font); font-size: 13px; font-weight: 550; cursor: pointer;
    white-space: nowrap;
    transition: all .16s;
}
.btn:hover { border-color: var(--brand); color: var(--brand-600); }
.btn svg { width: 15px; height: 15px; }
.btn.primary { background: var(--grad); border-color: transparent; color: #fff; box-shadow: 0 10px 22px -14px rgba(99,102,241,.95); }
.btn.primary:hover { filter: brightness(1.05); color: #fff; }
.btn.danger { color: #dc2626; border-color: #fecaca; background: #fef2f2; }
.btn.danger:hover { background: #fee2e2; color: #b91c1c; border-color: #fca5a5; }
.btn.ghost { background: transparent; }
.btn.sm { height: 30px; padding: 0 10px; font-size: 12px; border-radius: 8px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

.badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 2px 9px; border-radius: 99px; font-size: 11px; font-weight: 600;
    background: var(--brand-soft); color: var(--brand-600);
}
.badge.green { background: #ecfdf5; color: #047857; }
.badge.amber { background: #fffbeb; color: #b45309; }
.badge.red { background: #fef2f2; color: #b91c1c; }
.badge.slate { background: var(--bg-soft); color: var(--text-2); }

.modal {
    position: fixed; inset: 0; z-index: 300;
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
    background: rgba(8, 12, 24, .55);
    backdrop-filter: blur(3px);
    opacity: 0; pointer-events: none; transition: opacity .18s;
    overflow: hidden;
}
.modal.show { opacity: 1; pointer-events: auto; }
.modal-panel {
    width: min(430px, 100%);
    max-height: calc(100vh - 40px);
    max-height: calc(100dvh - 40px);
    display: flex; flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: var(--shadow-pop);
    transform: translateY(10px) scale(.985);
    transition: transform .2s;
    overflow: hidden;
}
.modal.show .modal-panel { transform: none; }
.modal-head { padding: 18px 20px 0; flex: none; }
.modal-head h3 { margin: 0 0 4px; font-size: 16px; font-weight: 680; color: var(--text); }
.modal-head p { margin: 0; font-size: 12.5px; color: var(--muted); }
.modal-body { padding: 18px 20px 6px; flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px 18px; flex: none; background: var(--surface); border-top: 1px solid var(--line); }

/* 手机端：弹窗改为底部抽屉，整层由遮罩容器滚动（避免嵌套滚动在部分浏览器里滑不动） */
@media (max-width: 640px) {
    .modal {
        flex-direction: column; align-items: stretch; justify-content: flex-start;
        padding: 0;
        overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y;
        /* 关掉模糊：backdrop-filter 会让内部 fixed 按钮定位失效，手机端也更快 */
        backdrop-filter: none; -webkit-backdrop-filter: none;
        background: rgba(8, 12, 24, .58);
    }
    .modal-panel {
        width: 100% !important;
        max-height: none;
        margin-top: auto;              /* 内容不足时贴底，超出时从顶部开始可整层滚动 */
        border-radius: 18px 18px 0 0;
        border-bottom: 0;
        overflow: visible;
        transform: translateY(24px);
    }
    .modal.show .modal-panel { transform: none; }
    .modal-head {
        padding: 16px 16px 10px;
        background: var(--surface);
        border-radius: 18px 18px 0 0;
    }
    .modal-head h3 { font-size: 15.5px; }
    .modal-body { padding: 14px 16px 6px; flex: 0 0 auto; overflow: visible; }
    .modal-panel { padding-bottom: calc(74px + env(safe-area-inset-bottom)); }
    .modal-foot {
        position: fixed; left: 0; right: 0; bottom: 0; z-index: 4;
        padding: 10px 16px calc(12px + env(safe-area-inset-bottom));
    }
    .modal-foot .btn { flex: 1; height: 42px; }
    .modal-foot .btn:only-child { flex: 0 0 auto; min-width: 104px; }
    /* 弹窗内表单保持两列，避免手机端纵向过长 */
    .modal .field-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 10px; }
}
@media (max-width: 360px) {
    .modal .field-grid { grid-template-columns: minmax(0, 1fr); }
}

.form-row { margin-bottom: 14px; }
.form-row label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-2); margin-bottom: 7px; }
.form-row input {
    width: 100%; height: 42px; padding: 0 12px;
    border: 1px solid var(--line-strong); border-radius: 10px;
    background: var(--surface); color: var(--text);
    font-family: var(--font); font-size: 13.5px; outline: 0;
    transition: border-color .16s, box-shadow .16s;
}
.form-row input:focus { border-color: var(--brand); box-shadow: 0 0 0 4px rgba(99,102,241,.12); }
.form-row .hint { margin-top: 6px; font-size: 11.5px; color: var(--muted); }
.form-error {
    display: none; margin-bottom: 12px; padding: 9px 12px;
    border-radius: 9px; background: #fef2f2; border: 1px solid #fecaca;
    color: #b91c1c; font-size: 12.5px;
}
.form-error.show { display: block; }

.section-title { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; font-size: 14px; font-weight: 650; color: var(--text); }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }

/* ============================================================
   内页表单：卡片内横向排列（label 左、控件右）
   ============================================================ */
.card .layui-form-item {
    display: flex; align-items: center; gap: 14px;
    margin-bottom: 14px; clear: none;
}
.card .layui-form-item:last-child { margin-bottom: 0; }
.card .layui-form-label {
    flex: 0 0 auto; width: auto; min-width: 84px;
    padding: 0; text-align: left;
    font-size: 13px; font-weight: 600; color: var(--text-2); line-height: 40px;
}
.card .layui-input-block,
.card .layui-input-inline { flex: 1 1 auto; margin: 0 !important; min-width: 0; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.card .layui-input-block > .layui-input,
.card .layui-input-inline > .layui-input { flex: 1 1 220px; }
.card .layui-form-item .layui-btn { margin: 0; }
.card .layui-form-mid { padding: 0 !important; line-height: 40px; }

/* 表格内原生复选框：缩小、配色统一 */
.layui-table-cell input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--brand); vertical-align: -2px; cursor: pointer; }
.layui-table-cell { color: var(--text); }

/* 搜索工具条：输入框 + 按钮同一行 */
.card .layui-input-block > input.layui-input { height: 40px; }

/* 表单内下拉框与输入框等宽 */
.card .layui-input-block > .layui-form-select,
.card .layui-input-inline > .layui-form-select { flex: 1 1 260px; min-width: 200px; }
.card .layui-form-select .layui-input { height: 40px; }

/* ============================================================
   5. 弹窗内容（代理记录 / 日志列表）与移动端细化
   ============================================================ */
.layer-pad { padding: 16px 20px 6px; background: var(--surface); color: var(--text); }
.layui-layer-page .layui-layer-content { max-height: 66vh; overflow: auto; -webkit-overflow-scrolling: touch; }

.log-list { display: flex; flex-direction: column; }
.log-item {
    display: flex; gap: 14px; align-items: flex-start;
    padding: 11px 0; border-bottom: 1px solid var(--line); font-size: 13px;
}
.log-item:last-child { border-bottom: 0; }
.log-time { flex: 0 0 auto; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.log-msg { margin: 0; color: var(--text-2); line-height: 1.7; word-break: break-word; }
.log-foot { margin: 14px 0 10px; font-size: 11.5px; color: var(--muted); line-height: 1.8; }

.log-empty { text-align: center; padding: 36px 18px 30px; color: var(--muted); }
.log-empty svg { width: 42px; height: 42px; opacity: .4; margin-bottom: 12px; }
.log-empty p { margin: 0 0 6px; font-size: 14px; color: var(--text-2); font-weight: 650; }
.log-empty span { font-size: 12px; line-height: 1.7; }

@media (max-width: 720px) {
    .log-item { flex-direction: column; gap: 4px; }
    .layer-pad { padding: 12px 14px 4px; }
    .layui-layer-title { font-size: 14px; }
    .layui-layer-btn { padding-bottom: 6px; }
    .layui-table-cell { font-size: 12.5px; }
}

/* ============================================================
   6. 工作台 / 内页：平板与手机布局
   ============================================================ */
.dash-main { grid-template-columns: 1.75fr 1fr; }
@media (max-width: 1180px) {
    .dash-main { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
    .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
    .dash-main { gap: 12px; }
    .grid { gap: 12px; }
    .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .grid-3, .grid-2 { grid-template-columns: minmax(0, 1fr); }
    .stat { padding: 13px 14px; border-radius: 14px; }
    .stat-value { font-size: 22px; }
    .stat-label { font-size: 11.5px; }
    .stat-foot { font-size: 11px; }
    .stat-ico { width: 32px; height: 32px; border-radius: 10px; }
    .card-head { padding: 14px 16px 0; }
    #trendChart { height: 210px; }
    .recent { min-width: 460px; }
    .chart-legend { gap: 10px; font-size: 11px; }
    .page-head { margin-bottom: 14px; }
    .page-head h1 { font-size: 17px; }
    .sys-row { font-size: 12.5px; }
}

/* 快捷操作宫格 */
.quick-grid { display: grid; gap: 10px; grid-template-columns: 1fr; }
@media (max-width: 720px) {
    .quick-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; padding: 12px !important; }
    .quick-grid .quick { padding: 12px; gap: 10px; }
    .quick-grid .quick .qt span { font-size: 11px; line-height: 1.5; }
    .quick-grid .quick .qt b { font-size: 12.5px; }
    .quick-grid .qi { width: 32px; height: 32px; border-radius: 10px; }
}

/* layui 弹窗按钮统一品牌色 */
.layui-layer-btn a { height: 34px; line-height: 34px; border-radius: 9px; font-size: 13px; padding: 0 18px; }
.layui-layer-btn .layui-layer-btn0 { background: var(--brand) !important; border-color: var(--brand) !important; color: #fff !important; }
.layui-layer-btn .layui-layer-btn1 { border-color: var(--line-strong) !important; color: var(--text-2) !important; background: var(--surface) !important; }

/* 表格横向滚动：可见滚动条 + 手机提示 */
.layui-table-main::-webkit-scrollbar { height: 6px; }
.layui-table-main::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 3px; }
.layui-table-main::-webkit-scrollbar-track { background: transparent; }
.table-scroll-hint {
    margin: 0 0 8px; padding: 6px 12px;
    font-size: 11.5px; color: var(--muted);
    background: var(--surface-2); border: 1px dashed var(--line-strong);
    border-radius: 9px; text-align: center;
}
@media (min-width: 721px) { .table-scroll-hint { display: none; } }

/* 工作台最近订单：移动端不换行 */
@media (max-width: 720px) {
    .recent { min-width: 520px; }
    .recent th, .recent td, .recent td div { white-space: nowrap; }
    .recent td div[style] { font-size: 11px !important; }
}

/* ---------- 手机端表单：标签上置，输入框全宽 ---------- */
@media (max-width: 640px) {
    .card .layui-form-item,
    .layui-collapse .layui-form-item { flex-direction: column; align-items: stretch; gap: 6px; margin-bottom: 16px; }
    .card .layui-form-label,
    .layui-collapse .layui-form-label {
        width: auto !important; min-width: 0; line-height: 1.5;
        padding: 0; font-size: 12.5px; text-align: left;
    }
    .card .layui-input-block, .card .layui-input-inline,
    .layui-collapse .layui-input-block, .layui-collapse .layui-input-inline { margin-left: 0 !important; width: 100%; }
    .card .layui-input-block > .layui-input,
    .layui-collapse .layui-input-block > .layui-input { flex: 1 1 100%; }
    .card .layui-form-mid, .layui-collapse .layui-form-mid { line-height: 1.6; }
    .card .layui-input-block > button.layui-btn,
    .layui-collapse .layui-input-block > button.layui-btn { margin: 4px 6px 0 0; }
    .layui-elem-quote { font-size: 12px; padding: 10px 12px; }

    /* 折叠面板 */
    .layui-collapse { border: 0; border-radius: 14px; background: var(--surface); overflow: hidden; }
    .layui-colla-item { border-color: var(--line); }
    .layui-colla-title { height: auto; line-height: 1.5; padding: 13px 16px; font-size: 13.5px; background: var(--surface-2); }
    .layui-colla-title .layui-colla-icon { left: auto; right: 14px; }
    .layui-colla-content { padding: 14px 16px 4px; }
}

/* 表单内按钮不被 flex 压缩换行 */
.card .layui-input-block > .layui-btn,
.card .layui-input-block > button,
.layui-collapse .layui-input-block > .layui-btn,
.layui-collapse .layui-input-block > button {
    flex: 0 0 auto; white-space: nowrap;
}

/* ============================================================
   7. 抽奖管理 / 通用开关
   ============================================================ */
.switch { position: relative; display: inline-flex; width: 44px; height: 24px; flex: none; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch span {
    position: absolute; inset: 0; border-radius: 99px;
    background: var(--line-strong); transition: background .18s;
}
.switch span::after {
    content: ""; position: absolute; left: 3px; top: 3px;
    width: 18px; height: 18px; border-radius: 50%;
    background: #fff; box-shadow: 0 1px 3px rgba(15, 23, 42, .28);
    transition: transform .18s;
}
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:disabled + span { opacity: .55; cursor: not-allowed; }

.prize-cell { display: flex; align-items: center; gap: 10px; min-width: 0; }
.prize-ico {
    width: 34px; height: 34px; border-radius: 10px; flex: none;
    display: grid; place-items: center; font-size: 17px; line-height: 1;
    background: var(--brand-soft); color: var(--brand-600);
}
.prize-cell b { display: block; font-size: 13px; color: var(--text); font-weight: 600; white-space: nowrap; }
.prize-cell div span { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; }

.prob { display: flex; align-items: center; gap: 8px; min-width: 104px; }
.prob-bar { flex: 1; height: 6px; border-radius: 99px; background: var(--bg-soft); overflow: hidden; }
.prob-bar i { display: block; height: 100%; border-radius: 99px; background: var(--grad); }
.prob b { font-size: 12px; color: var(--text-2); font-weight: 600; font-variant-numeric: tabular-nums; }

.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 12px; }
.field-grid .full { grid-column: 1 / -1; }
@media (max-width: 640px) { .field-grid { grid-template-columns: minmax(0, 1fr); } }

.form-row select,
.form-row textarea {
    width: 100%; border: 1px solid var(--line-strong); border-radius: 10px;
    background: var(--surface); color: var(--text);
    font-family: var(--font); font-size: 13.5px; outline: 0;
    transition: border-color .16s, box-shadow .16s;
}
.form-row select { height: 42px; padding: 0 10px; }
.form-row textarea { min-height: 84px; padding: 10px 12px; line-height: 1.7; resize: vertical; }
.form-row select:focus, .form-row textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 4px rgba(99,102,241,.12); }

.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.pager .info { font-size: 12px; color: var(--muted); }
.pager .btns { display: flex; gap: 6px; }
.pager .btns button { min-width: 32px; }

.record-code { font-family: ui-monospace, Menlo, monospace; font-size: 11.5px; color: var(--text-2); word-break: break-all; }

/* 抽奖管理：双列在窄屏自动改单列（内联 grid 无法响应，用类控制） */
.lot-admin-grid { grid-template-columns: 1.7fr 1fr; align-items: start; }
@media (max-width: 1320px) {
    .lot-admin-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 720px) {
    .lot-admin-grid { gap: 12px; }
}

/* ---------- 响应式表格：窄屏自动转卡片（给 table 加 .rt 即生效） ---------- */
@media (max-width: 760px) {
    .table-ui.rt { min-width: 0 !important; display: block; border: 0; }
    .table-ui.rt thead { display: none; }
    .table-ui.rt tbody { display: block; }
    .table-ui.rt tbody tr {
        display: block;
        padding: 10px 0 12px;
        border-bottom: 1px solid var(--line);
    }
    .table-ui.rt tbody tr:last-child { border-bottom: 0; }
    .table-ui.rt tbody td {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 14px;
        padding: 5px 14px;
        border: 0;
        white-space: normal;
        text-align: right;
    }
    .table-ui.rt tbody td::before {
        content: attr(data-label);
        flex: none;
        color: var(--muted);
        font-size: 12px;
        font-weight: 500;
        letter-spacing: .02em;
        white-space: nowrap;
    }
    .table-ui.rt tbody td[data-label="奖品"],
    .table-ui.rt tbody td[data-label="发放内容"] { align-items: flex-start; }
    .table-ui.rt .prize-cell { justify-content: flex-end; text-align: right; }
    .table-ui.rt .prize-cell b { white-space: normal; }
    .table-ui.rt .prob { width: 128px; flex: none; }
    .table-ui.rt thead th { display: none; }
    .table-ui.rt tbody td[data-label="操作"],
    .table-ui.rt tbody td[data-label="启用"] { justify-content: flex-end; gap: 8px; }
    .table-ui.rt tbody td[data-label="操作"]::before,
    .table-ui.rt tbody td[data-label="启用"]::before { margin-right: auto; }
    .table-ui.rt tbody td[colspan] { display: block; text-align: center; padding: 26px 0; }
    .table-ui.rt tbody td[colspan]::before { content: none; }
}

/* 管理员页两栏布局：窄屏塌成单栏，避免内容被压缩溢出 */
.admins-layout { grid-template-columns: 1.6fr 1fr; }
@media (max-width: 960px) {
    .admins-layout { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- 卡片头部行内筛选 ---------- */
.fld-inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-left: auto; }
.fld-inline input, .fld-inline select {
    height: 32px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: 9px;
    background: var(--surface); color: var(--text); font-size: 12.5px; font-family: var(--font); outline: 0;
}
.fld-inline select { padding: 0 8px; color: var(--text-2); }
.fld-inline input { width: 190px; }
.fld-inline select { width: 118px; }
.fld-inline input:focus, .fld-inline select:focus { border-color: var(--brand-400); }
@media (max-width: 760px) {
    .fld-inline {
        width: 100%; margin-left: 0;
        display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px;
    }
    .fld-inline input { grid-column: 1 / -1; }
    .fld-inline input, .fld-inline select, .fld-inline .btn { width: 100%; min-width: 0; }
    /* 两个下拉 + 两个按钮的筛选栏：两列更紧凑 */
    .fld-inline.fld-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .table-ui.rt tbody td[data-label="操作"] { flex-wrap: wrap; }
    /* 窄屏卡片里需要竖排的多行值（如注册 / 最近登录） */
    .table-ui.rt .td-stack { display: flex; flex-direction: column; align-items: flex-end; gap: 1px; min-width: 0; }
}

/* ---------- 详情键值网格 ---------- */
.field-grid > div { padding: 8px 0; border-bottom: 1px dashed var(--line); min-width: 0; }
.field-grid > div > span { display: block; font-size: 11.5px; color: var(--muted); margin-bottom: 3px; }
.field-grid > div > b { display: block; font-size: 13px; font-weight: 600; word-break: break-all; }

/* ---------- 详情信息行 ---------- */
.info-row { display: flex; justify-content: space-between; gap: 14px; padding: 9px 0; border-bottom: 1px dashed var(--line); }
.info-row:last-child { border-bottom: 0; }
.info-row .l { min-width: 0; }
.info-row .l b { display: block; font-size: 13px; font-weight: 600; }
.info-row .l span { display: block; font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.info-row .r { flex: none; text-align: right; font-size: 12.5px; color: var(--text-2); white-space: nowrap; }

@media (max-width: 760px) {
    .card-head { flex-wrap: wrap; row-gap: 10px; }
    .card-head > h3 { width: 100%; }
    .card-head .fld-inline { margin-left: 0; }
}

/* 数字输入框去掉浏览器原生步进器，避免手机端出现多余控件 */
.form-row input[type="number"]::-webkit-outer-spin-button,
.form-row input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.form-row input[type="number"] { -moz-appearance: textfield; appearance: textfield; }

body.modal-open { overflow: hidden; }

/* ---------- 工单管理 ---------- */
.tk-cell { display: flex; align-items: flex-start; gap: 10px; min-width: 0; }
.tk-cell-main { min-width: 0; width: 100%; }
.tk-title-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tk-title-row b {
    flex: 0 1 auto; min-width: 0; font-size: 13px; font-weight: 600; color: var(--text); line-height: 1.5;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.tk-title-row .tk-cat { flex: none; margin-left: 0; }
.tk-excerpt {
    margin-top: 3px; font-size: 11.5px; color: var(--muted); line-height: 1.6;
    max-width: 430px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tk-cat {
    flex: none; margin-left: auto; padding: 2px 8px; border-radius: 7px;
    background: var(--bg-soft); color: var(--text-2); font-size: 11px; white-space: nowrap;
}
.tk-user-cell b { display: block; font-size: 12.5px; font-weight: 600; }
.tk-user-cell span { display: block; margin-top: 2px; font-size: 11px; color: var(--muted); }
.tk-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #ef4444; margin-left: 6px; vertical-align: middle; }
.tk-status-cell { display: inline-flex; align-items: center; gap: 7px; min-width: 0; }
.tk-status-cell .tk-dot { margin-left: 0; margin-right: 0; flex: none; }
.tk-id { display: none; font-size: 11.5px; font-weight: 600; color: var(--muted); }
.tk-card-time { display: none; font-style: normal; font-size: 11.5px; color: var(--muted); white-space: nowrap; }

/* --- 工单详情弹窗 --- */
.tk-modal .tk-panel {
    width: min(720px, 100%);
    height: min(760px, calc(100vh - 48px));
    height: min(760px, calc(100dvh - 48px));
    max-height: none;
    padding: 0;
    overflow: hidden;
}
.tk-head {
    flex: none; display: flex; align-items: flex-start; gap: 12px;
    padding: 16px 20px 12px; border-bottom: 1px solid var(--line); background: var(--surface);
}
.tk-head-main { flex: 1 1 auto; min-width: 0; }
.tk-head-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tk-head-title h3 {
    margin: 0; font-size: 16px; font-weight: 680; line-height: 1.45; color: var(--text);
    word-break: break-word;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.tk-head-title .badge { flex: none; }
.tk-head p { margin: 5px 0 0; font-size: 12px; color: var(--muted); }
.tk-x {
    flex: none; width: 32px; height: 32px; border: 0; border-radius: 9px;
    background: var(--bg-soft); color: var(--text-2); font-size: 19px; line-height: 1; cursor: pointer;
}
.tk-x:hover { background: var(--line); color: var(--text); }

/* 用户信息：四宫格 */
.tk-user {
    flex: none; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1px; background: var(--line); border-bottom: 1px solid var(--line);
}
.tk-u { min-width: 0; padding: 9px 14px; background: var(--surface-2); }
.tk-u > span { display: block; font-size: 11px; color: var(--muted); line-height: 1.4; }
.tk-u > b {
    display: block; margin-top: 3px; font-size: 13px; font-weight: 600; color: var(--text);
    line-height: 1.4; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tk-u-wide { grid-column: span 3; }
.tk-u > b.tk-u-muted { color: var(--muted); font-weight: 500; }

/* 对话区 */
.tk-reply, .tk-body { background: var(--surface); }
.tk-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 16px 20px; -webkit-overflow-scrolling: touch; }
.tk-thread { display: flex; flex-direction: column; gap: 16px; }
.tk-msg { display: flex; gap: 9px; align-items: flex-start; }
.tk-avatar {
    flex: none; width: 30px; height: 30px; border-radius: 9px;
    display: grid; place-items: center; font-size: 11.5px;
    background: var(--bg-soft); color: var(--text-2);
}
.tk-msg.is-admin .tk-avatar { background: var(--brand-soft); color: var(--brand-600); }
.tk-msg-main { max-width: 76%; min-width: 0; }
.tk-bubble {
    padding: 10px 13px; border-radius: 12px; font-size: 13px; line-height: 1.72;
    background: var(--bg-soft); color: var(--text); word-break: break-word; white-space: pre-wrap;
    border-top-left-radius: 4px;
}
.tk-msg.is-admin { flex-direction: row-reverse; }
.tk-msg.is-admin .tk-msg-main { text-align: right; }
.tk-msg.is-admin .tk-bubble {
    background: var(--brand-soft); color: var(--brand-700, #4338ca);
    text-align: left; border-top-left-radius: 12px; border-top-right-radius: 4px;
}
.tk-msg-time { display: block; margin-top: 5px; font-size: 10.5px; color: var(--muted); }
.tk-empty { padding: 26px 0; text-align: center; font-size: 12.5px; color: var(--muted); }

/* 回复区 */
.tk-reply { flex: none; padding: 12px 20px 14px; border-top: 1px solid var(--line); background: var(--surface-2); }
.tk-reply textarea {
    display: block; width: 100%; min-height: 74px; max-height: 150px; padding: 10px 12px;
    border: 1px solid var(--line-strong); border-radius: 10px;
    font-family: var(--font); font-size: 13px; line-height: 1.7; color: var(--text);
    background: var(--surface); resize: none; outline: 0;
}
.tk-reply textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 4px rgba(99, 102, 241, .12); }
.tk-reply textarea::placeholder { color: var(--muted); }
.tk-reply-bar { display: flex; gap: 8px; margin-top: 9px; align-items: center; }
.tk-reply-bar select {
    height: 38px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: 9px;
    background: var(--surface); color: var(--text-2); font-family: var(--font); font-size: 12.5px;
    flex: 1 1 auto; min-width: 0;
}
.tk-reply-bar .btn { flex: none; height: 38px; }
.tk-reply .form-error { margin-top: 9px; }

/* 底部操作 */
.tk-foot {
    flex: none; display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 10px 20px 14px; background: var(--surface); border-top: 1px solid var(--line);
}
.tk-foot-main { display: flex; gap: 8px; }
.tk-foot .tk-del { flex: none; }

@keyframes tkIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.tk-msg { animation: tkIn .18s ease-out; }

@media (max-width: 720px) {
    /* 卡片模式下「工单」整行纵向排列，标题左对齐 */
    .table-ui.rt tbody td[data-label="工单"] { flex-direction: column; align-items: stretch; gap: 5px; text-align: left; }
    .table-ui.rt tbody td[data-label="工单"]::before { content: none; }
    .table-ui.rt tbody td[data-label="编号"] { display: none; }
    .table-ui.rt tbody td[data-label="状态"] { justify-content: flex-end; }
    .table-ui.rt tbody td[data-label="更新时间"] { display: none; }
    .table-ui.rt td .tk-cell { flex: 1 1 auto; width: 100%; min-width: 0; }
    .table-ui.rt td .tk-cell .tk-cell-main { flex: 1 1 auto; min-width: 0; text-align: left; }
    .table-ui.rt td .tk-cell .tk-cell-main b,
    .table-ui.rt td .tk-cell .tk-excerpt { text-align: left; }
    .tk-id { display: inline; margin-right: 2px; }
    .tk-card-time { display: inline; }
    .tk-excerpt { max-width: 100%; white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
    .tk-cell { align-items: flex-start; }
}

/* 手机端：满屏抽屉，头部/回复区/操作区固定，只有对话区滚动 */
@media (max-width: 640px) {
    .tk-modal { padding: 0; }
    .tk-modal .tk-panel {
        width: 100% !important;
        height: 92vh; height: 92dvh; max-height: 92dvh;
        padding-bottom: 0;
        border-radius: 18px 18px 0 0;
        overflow: hidden;
    }
    .tk-head { padding: 14px 14px 10px; }
    .tk-head-title h3 { font-size: 15.5px; }
    .tk-user { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .tk-u { padding: 8px 12px; }
    .tk-u-wide { grid-column: span 1; }
    .tk-body { padding: 14px; }
    .tk-msg-main { max-width: 82%; }
    .tk-reply { padding: 10px 14px 12px; }
    .tk-reply textarea { min-height: 66px; font-size: 13.5px; }
    .tk-reply-bar { gap: 7px; }
    .tk-reply-bar select { flex: 1 1 0; font-size: 12px; padding: 0 6px; }
    .tk-reply-bar .btn { flex: 0 0 auto; min-width: 92px; padding: 0 12px; }
    .tk-foot {
        position: static;
        padding: 8px 14px calc(10px + env(safe-area-inset-bottom));
        gap: 8px;
    }
    .tk-foot .btn, .tk-foot .tk-del { flex: 1 1 0; min-width: 0; padding: 0 6px; font-size: 12.5px; height: 40px; }
    .tk-foot-main { flex: 1 1 auto; gap: 7px; }
}
