/* =========================================================================
   SMTP 群发系统 · 管理后台样式
   浅色主题 · 本地字体 · 零外部依赖
   -------------------------------------------------------------------------
   结构：
     1. 设计变量与基础样式
     2. 布局（侧栏 / 顶栏 / 内容区）
     3. 通用组件（卡片、统计、表格、按钮、表单、徽章、提示、进度）
     4. 业务组件（筛选、分页、通知列表、设置、自检、连接测试、模板编辑）
     5. 弹窗 / Toast / 公开页 / 错误页
     6. 工具类与响应式
   ========================================================================= */

/* ------------------------------------------------------------------ 1. 变量 */
:root {
    --bg: #f5f7fb;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --surface-3: #f1f4f9;
    --line: #e4e8f0;
    --line-strong: #cfd6e4;

    --text: #101828;
    --text-2: #344054;
    --muted: #667085;
    --muted-2: #98a2b3;

    --primary: #2563eb;
    --primary-600: #1d4ed8;
    --primary-50: #eff5ff;
    --primary-line: #d3e2fd;

    --success: #079455;
    --success-50: #ecfdf3;
    --success-line: #abefc6;

    --warning: #dc6803;
    --warning-50: #fffaeb;
    --warning-line: #fedf89;

    --danger: #d92d20;
    --danger-50: #fef3f2;
    --danger-line: #fecdca;

    --info: #026aa2;
    --info-50: #f0f9ff;
    --info-line: #b9e6fe;

    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;

    --shadow-xs: 0 1px 2px rgba(16, 24, 40, .04);
    --shadow-sm: 0 1px 3px rgba(16, 24, 40, .06), 0 8px 24px -16px rgba(16, 24, 40, .16);
    --shadow-md: 0 12px 32px -12px rgba(16, 24, 40, .24), 0 2px 6px rgba(16, 24, 40, .06);
    --shadow-lg: 0 24px 64px -16px rgba(16, 24, 40, .32);

    --sidebar-w: 244px;
    --topbar-h: 60px;

    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
    --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

/* author 样式里的 display 会覆盖 hidden 属性，这里强制生效 */
[hidden] { display: none !important; }

html, body { margin: 0; padding: 0; }

body {
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.55;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

body.modal-open { overflow: hidden; }

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-600); }

h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
p { margin: 0; }

button, input, select, textarea { font-family: inherit; font-size: inherit; }

::selection { background: rgba(37, 99, 235, .16); }

:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    border-radius: 4px;
}

.skip-link {
    position: absolute;
    left: 12px;
    top: -60px;
    z-index: 200;
    padding: 10px 16px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    font-size: 13px;
    transition: top .15s ease;
}
.skip-link:focus { top: 12px; }

.icon {
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
    display: inline-block;
    vertical-align: -3px;
}

/* ------------------------------------------------------------------ 2. 布局 */
.app-shell { min-height: 100vh; }

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    z-index: 40;
}

.brand {
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 0 18px;
    border-bottom: 1px solid var(--line);
    flex: 0 0 auto;
}

.brand-mark {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: linear-gradient(135deg, #2563eb, #5b93ff);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 14px -8px rgba(37, 99, 235, .8);
}
.brand-mark .icon { width: 18px; height: 18px; }

.brand-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.brand-text strong { font-size: 14.5px; letter-spacing: -.01em; }
.brand-text small { color: var(--muted-2); font-size: 11px; margin-top: 2px; }

.sidebar-nav {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 12px 10px 14px;
    scrollbar-width: thin;
}

.nav-group { margin-bottom: 12px; }
.nav-group:last-child { margin-bottom: 2px; }

.nav-label {
    font-size: 10.5px;
    font-weight: 650;
    letter-spacing: .1em;
    color: var(--muted-2);
    padding: 0 10px 6px;
    text-transform: uppercase;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 34px;
    padding: 0 10px;
    border-radius: var(--radius-sm);
    color: var(--text-2);
    font-size: 13.5px;
    font-weight: 500;
    margin-bottom: 1px;
    transition: background .15s ease, color .15s ease;
}
.nav-item:hover { background: var(--surface-3); color: var(--text); }
.nav-item.active {
    background: var(--primary-50);
    color: var(--primary-600);
    font-weight: 600;
    box-shadow: inset 0 0 0 1px var(--primary-line);
}
.nav-item .icon { color: var(--muted); width: 17px; height: 17px; flex-basis: 17px; }
.nav-item.active .icon { color: var(--primary); }

.nav-badge {
    margin-left: auto;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--danger);
    color: #fff;
    font-size: 10.5px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.sidebar-footer {
    flex: 0 0 auto;
    border-top: 1px solid var(--line);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.worker-pill {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 12px;
    font-weight: 550;
    color: var(--muted);
    min-width: 0;
}
.worker-pill span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.worker-pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted-2); }
.worker-pill.online .dot { background: var(--success); box-shadow: 0 0 0 3px rgba(7, 148, 85, .14); }
.worker-pill.offline .dot { background: var(--danger); box-shadow: 0 0 0 3px rgba(217, 45, 32, .14); }
.version { font-size: 11px; color: var(--muted-2); font-variant-numeric: tabular-nums; }

.main {
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    height: var(--topbar-h);
    position: sticky;
    top: 0;
    z-index: 30;
    background: rgba(255, 255, 255, .86);
    backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 0 24px;
}

.topbar-left { display: flex; align-items: center; gap: 8px; min-width: 0; }
.topbar-right { display: flex; align-items: center; gap: 8px; }

.crumbs {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 12.5px;
    color: var(--muted-2);
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
}
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--primary); }
.crumbs strong { color: var(--text-2); font-weight: 600; }
.crumb-sep { color: var(--line-strong); }

.status-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 30px;
    padding: 0 11px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 550;
    border: 1px solid transparent;
    white-space: nowrap;
}
.status-chip .icon { width: 14px; height: 14px; }
.status-chip.is-ok { background: var(--success-50); color: var(--success); border-color: var(--success-line); }
.status-chip.is-off { background: var(--danger-50); color: var(--danger); border-color: var(--danger-line); }

.icon-btn {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    padding: 0;
    transition: background .15s ease, color .15s ease;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }

.notification-btn .dot-badge {
    position: absolute;
    top: 1px;
    right: 0;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 999px;
    background: var(--danger);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
}

.user-menu { position: relative; }
.user-menu summary {
    list-style: none;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 3px 8px 3px 3px;
    border-radius: 999px;
    cursor: pointer;
    user-select: none;
}
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu summary:hover { background: var(--surface-3); }

.avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, #e0e7ff, #c7d7fe);
    color: var(--primary-600);
    font-weight: 700;
    font-size: 12.5px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.user-name { font-size: 13px; font-weight: 550; color: var(--text-2); }

.user-menu-panel {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    width: 184px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: var(--shadow-md);
    padding: 6px;
    z-index: 50;
}
.user-menu-panel a,
.user-menu-panel button {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 10px;
    border: 0;
    background: transparent;
    border-radius: 7px;
    color: var(--text-2);
    font-size: 13px;
    text-align: left;
    cursor: pointer;
}
.user-menu-panel a:hover,
.user-menu-panel button:hover { background: var(--surface-3); color: var(--text); }
.user-menu-panel .icon { width: 16px; height: 16px; }

.content {
    flex: 1 1 auto;
    padding: 26px 28px 36px;
    width: 100%;
    max-width: 1440px;
    margin: 0 auto;
}

/* ------------------------------------------------------------------ 3. 通用 */
.page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 22px;
    flex-wrap: wrap;
}
.page-head h2 { font-size: 22px; font-weight: 700; letter-spacing: -.02em; line-height: 1.3; word-break: break-word; }
.page-head p { color: var(--muted); font-size: 13px; margin-top: 5px; max-width: 820px; }
.page-head .page-sub { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.page-sub .sep { color: var(--line-strong); }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.page-actions form { display: inline-flex; margin: 0; }

.breadcrumb { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb .sep { color: var(--muted-2); }

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-xs);
    margin-bottom: 20px;
    overflow: hidden;
}
.card-header,
.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 15px 20px;
    border-bottom: 1px solid var(--line);
    flex-wrap: wrap;
}
.card-header h3,
.card-head h3 { font-size: 15px; font-weight: 650; }
.card-header .sub,
.card-head .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.card-body { padding: 20px; }
.card-body.tight { padding: 14px 20px; }
.card-footer,
.card-foot {
    padding: 13px 20px;
    border-top: 1px solid var(--line);
    background: var(--surface-2);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}
.card-foot .flex-between,
.card-footer .flex-between { margin-top: 0; }

/* 统计卡 */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}
.stat-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stat-grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat-grid-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.stat-grid-5 .stat-value { font-size: 26px; }

.stat-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow-xs);
    position: relative;
    overflow: hidden;
    min-width: 0;
}
.stat-card .stat-label { color: var(--muted); font-size: 12.5px; font-weight: 500; }
.stat-card .stat-value {
    font-size: 28px;
    font-weight: 750;
    letter-spacing: -.02em;
    margin-top: 5px;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
    word-break: keep-all;
}
.stat-card .stat-value.is-badge { display: flex; align-items: center; min-height: 34px; }
.stat-card .stat-value .badge { height: 26px; font-size: 12.5px; padding: 0 11px; }
.stat-card .stat-foot { color: var(--muted); font-size: 12px; margin-top: 5px; }
.stat-card .stat-icon {
    position: absolute;
    right: 16px;
    top: 16px;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--surface-3);
    color: var(--muted);
    display: flex;
    align-items: center;
    justify-content: center;
}
.stat-card .stat-icon .icon { width: 18px; height: 18px; }
.stat-card.accent .stat-icon { background: var(--primary-50); color: var(--primary); }
.stat-card.success .stat-icon { background: var(--success-50); color: var(--success); }
.stat-card.warning .stat-icon { background: var(--warning-50); color: var(--warning); }
.stat-card.danger .stat-icon { background: var(--danger-50); color: var(--danger); }

/* 表格 */
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.table { width: 100%; min-width: 880px; border-collapse: collapse; font-size: 13px; }
table.table th {
    text-align: left;
    font-weight: 600;
    font-size: 12px;
    color: var(--muted);
    letter-spacing: .01em;
    padding: 10px 16px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
table.table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
    color: var(--text-2);
}
table.table tbody tr:last-child td { border-bottom: 0; }
table.table tbody tr:hover { background: #fbfcff; }
table.table td.strong { color: var(--text); font-weight: 600; }
table.table td.right,
table.table th.right { text-align: right; font-variant-numeric: tabular-nums; }
table.table td.center,
table.table th.center { text-align: center; }
table.table .actions { display: flex; align-items: center; gap: 6px; flex-wrap: nowrap; justify-content: flex-end; }
table.table .actions .btn { white-space: nowrap; }
table.table td > form { display: inline-flex; margin: 0; }

.table-compact th { padding: 9px 13px; }
.table-compact td { padding: 9px 13px; font-size: 12.5px; }

.table-empty {
    text-align: center !important;
    color: var(--muted) !important;
    padding: 24px 16px !important;
    font-size: 12.5px;
}

.response-cell { max-width: 380px; }
.error-msg {
    display: block;
    margin-top: 2px;
    color: var(--muted);
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.error-hint {
    display: block;
    margin-top: 2px;
    color: var(--warning);
    font-size: 11px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cell-main { color: var(--text); font-weight: 550; }
.cell-main a { color: var(--text); }
.cell-main a:hover { color: var(--primary); }
.cell-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.mono { font-family: var(--mono); font-size: 12px; }
.nowrap { white-space: nowrap; }
.truncate { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 按钮 */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    height: 36px;
    padding: 0 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line-strong);
    background: var(--surface);
    color: var(--text-2);
    font-size: 13px;
    font-weight: 550;
    cursor: pointer;
    transition: background .15s ease, border-color .15s ease, color .15s ease, box-shadow .15s ease;
    white-space: nowrap;
    text-decoration: none;
    line-height: 1;
}
.btn:hover { background: var(--surface-2); color: var(--text); border-color: var(--line-strong); }
.btn:active { transform: translateY(.5px); }
.btn:disabled,
.btn.disabled,
.btn.is-busy { opacity: .6; cursor: not-allowed; }
.btn .icon { width: 15px; height: 15px; }

.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 1px 2px rgba(37, 99, 235, .28); }
.btn-primary:hover { background: var(--primary-600); border-color: var(--primary-600); color: #fff; }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-success:hover { background: #067647; border-color: #067647; color: #fff; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #b42318; border-color: #b42318; color: #fff; }
.btn-warning { background: var(--warning); border-color: var(--warning); color: #fff; }
.btn-warning:hover { background: #b54708; border-color: #b54708; color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); border-color: transparent; }
.btn-outline { background: transparent; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12px; border-radius: 7px; gap: 5px; }
.btn-sm .icon { width: 13px; height: 13px; }
.btn-lg { height: 42px; padding: 0 18px; font-size: 14px; }
.btn-block { width: 100%; }
.btn-link { border: 0; background: transparent; color: var(--primary); padding: 0; height: auto; }
.btn-link:hover { color: var(--primary-600); background: transparent; }

/* 表单 */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 20px; }
.form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.field-full { grid-column: 1 / -1; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label { font-size: 12.5px; font-weight: 600; color: var(--text-2); line-height: 1.4; }
.field .hint { font-size: 12px; color: var(--muted); line-height: 1.55; }
.field .error { font-size: 12px; color: var(--danger); }
.field.is-disabled { opacity: .55; }

.field-note {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-top: 14px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    border: 1px solid var(--line);
    color: var(--muted);
    font-size: 12.5px;
    line-height: 1.6;
}
.field-note .icon { width: 15px; height: 15px; flex: 0 0 15px; margin-top: 2px; color: var(--muted-2); }
.field-note .mono { color: var(--text-2); }

input[type="text"], input[type="password"], input[type="email"], input[type="number"],
input[type="datetime-local"], input[type="date"], input[type="time"],
input[type="url"], input[type="search"], input[type="file"],
select, textarea {
    width: 100%;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    padding: 8px 11px;
    height: 38px;
    outline: none;
    transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
textarea { height: auto; min-height: 120px; resize: vertical; line-height: 1.65; }
input:focus, select:focus, textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .13);
}
input::placeholder, textarea::placeholder { color: var(--muted-2); }
input:disabled, select:disabled, textarea:disabled { background: var(--surface-3); color: var(--muted); cursor: not-allowed; }
input[readonly] { background: var(--surface-3); color: var(--muted); }

select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 34px;
}

input[type="date"], input[type="time"], input[type="datetime-local"] { font-variant-numeric: tabular-nums; }
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator,
input[type="datetime-local"]::-webkit-calendar-picker-indicator {
    opacity: .5;
    cursor: pointer;
    padding: 2px;
    border-radius: 4px;
    transition: opacity .15s ease, background .15s ease;
}
input[type="date"]::-webkit-calendar-picker-indicator:hover,
input[type="time"]::-webkit-calendar-picker-indicator:hover,
input[type="datetime-local"]::-webkit-calendar-picker-indicator:hover { opacity: .9; background: var(--surface-3); }

.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); }
.checkbox-row input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--primary); }

.radio-row { display: flex; flex-wrap: wrap; gap: 8px 22px; margin-bottom: 18px; }
.radio { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); cursor: pointer; }
.radio input[type="radio"] { width: 15px; height: 15px; accent-color: var(--primary); margin: 0; flex: 0 0 auto; }

.form-card { padding: 4px 24px 22px; max-width: 1040px; }
.form-section { padding: 20px 0; border-bottom: 1px solid var(--line); }
.form-section:last-of-type { border-bottom: 0; }
.form-section > h3 {
    margin: 0 0 16px;
    font-size: 13px;
    font-weight: 650;
    color: var(--muted);
    letter-spacing: .04em;
    text-transform: uppercase;
}
.form-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 4px;
    padding-top: 18px;
    border-top: 1px solid var(--line);
}
.stack-form { display: flex; flex-direction: column; gap: 16px; }

/* 分段控件 */
.segmented {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 3px;
    background: var(--surface-3);
    border: 1px solid var(--line);
    border-radius: 10px;
    flex-wrap: wrap;
}
.segment {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 32px;
    padding: 0 14px;
    border-radius: 7px;
    font-size: 13px;
    font-weight: 550;
    color: var(--muted);
    cursor: pointer;
    user-select: none;
    transition: background .15s ease, color .15s ease, box-shadow .15s ease;
    white-space: nowrap;
}
.segment:hover { color: var(--text); }
.segment input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}
.segment:has(input:checked),
.segment.is-checked {
    background: var(--surface);
    color: var(--primary-600);
    box-shadow: 0 1px 2px rgba(16, 24, 40, .08), inset 0 0 0 1px var(--primary-line);
}
.segment:has(input:focus-visible) { outline: 2px solid var(--primary); outline-offset: 1px; }
.segment.is-active {
    background: var(--surface);
    color: var(--primary-600);
    box-shadow: 0 1px 2px rgba(16, 24, 40, .08), inset 0 0 0 1px var(--primary-line);
}
.segmented-sm .segment { height: 28px; padding: 0 11px; font-size: 12.5px; }

/* 徽章 */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 22px;
    padding: 0 8px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 600;
    white-space: nowrap;
    border: 1px solid transparent;
}
.badge-primary { background: var(--primary-50); color: var(--primary-600); border-color: var(--primary-line); }
.badge-success { background: var(--success-50); color: var(--success); border-color: var(--success-line); }
.badge-warning { background: var(--warning-50); color: var(--warning); border-color: var(--warning-line); }
.badge-danger { background: var(--danger-50); color: var(--danger); border-color: var(--danger-line); }
.badge-info { background: var(--info-50); color: var(--info); border-color: var(--info-line); }
.badge-muted { background: var(--surface-3); color: var(--muted); border-color: var(--line); }

/* 提示条 */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 11px 14px;
    border-radius: 10px;
    font-size: 13px;
    line-height: 1.6;
    margin-bottom: 16px;
    border: 1px solid transparent;
}
.alert .icon { width: 17px; height: 17px; margin-top: 1px; flex: 0 0 17px; opacity: .9; }
.alert strong { font-weight: 650; }
.alert a { text-decoration: underline; }
.alert-info { background: var(--info-50); color: var(--info); border-color: var(--info-line); }
.alert-success { background: var(--success-50); color: var(--success); border-color: var(--success-line); }
.alert-warning { background: var(--warning-50); color: #b54708; border-color: var(--warning-line); }
.alert-danger { background: var(--danger-50); color: var(--danger); border-color: var(--danger-line); }

/* 进度 */
.progress {
    height: 8px;
    background: var(--surface-3);
    border-radius: 999px;
    overflow: hidden;
    width: 100%;
}
.progress-bar {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, #3b82f6, #2563eb);
    transition: width .4s ease;
}
.progress-bar.success { background: linear-gradient(90deg, #12b76a, #079455); }
.progress-bar.warning { background: linear-gradient(90deg, #f79009, #dc6803); }
.progress-bar.danger { background: linear-gradient(90deg, #f04438, #d92d20); }
.progress-lg { height: 12px; }
.progress-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 12px; color: var(--muted); margin-bottom: 7px; }

.mini-progress {
    height: 6px;
    width: 100%;
    min-width: 90px;
    background: var(--surface-3);
    border-radius: 999px;
    overflow: hidden;
}
.mini-progress > span {
    display: block;
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, #3b82f6, #2563eb);
    transition: width .4s ease;
}
.progress-cell { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; min-width: 116px; }
.progress-cell .mini-progress { width: 100%; }
.progress-cell .cell-sub { font-variant-numeric: tabular-nums; }

.progress-stack { display: flex; background: var(--surface-3); }
.progress-stack .seg {
    display: block;
    height: 100%;
    width: 0;
    transition: width .45s ease;
}
.progress-stack .seg-success { background: linear-gradient(90deg, #12b76a, #079455); }
.progress-stack .seg-danger { background: linear-gradient(90deg, #f97066, #d92d20); }
.progress-stack .seg-warning { background: linear-gradient(90deg, #fdb022, #dc6803); }
.progress-stack .seg-skip { background: #c7d2fe; }
.progress-stack .seg + .seg { box-shadow: inset 1px 0 0 rgba(255, 255, 255, .6); }

.progress-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 20px;
    margin-top: 14px;
    font-size: 12.5px;
    color: var(--muted);
}
.progress-legend > span { display: inline-flex; align-items: center; gap: 6px; }
.progress-legend .dot { width: 8px; height: 8px; flex: 0 0 8px; }

.dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 9px; }
.dot-success { background: var(--success); box-shadow: 0 0 0 3px rgba(7, 148, 85, .12); }
.dot-warning { background: var(--warning); box-shadow: 0 0 0 3px rgba(220, 104, 3, .12); }
.dot-danger { background: var(--danger); box-shadow: 0 0 0 3px rgba(217, 45, 32, .12); }
.dot-muted { background: var(--muted-2); box-shadow: 0 0 0 3px rgba(152, 162, 179, .15); }
.dot-pending { background: var(--surface-3); box-shadow: inset 0 0 0 1px var(--line-strong); }
.dot-skip { background: #c7d2fe; box-shadow: 0 0 0 3px rgba(199, 210, 254, .3); }

/* 空状态 */
.empty-state { padding: 44px 20px; text-align: center; color: var(--muted); }
.empty-state .empty-icon {
    width: 48px;
    height: 48px;
    border-radius: 13px;
    background: var(--surface-3);
    color: var(--muted-2);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
}
.empty-state .empty-icon .icon { width: 22px; height: 22px; }
.empty-state h3 { color: var(--text); font-size: 15px; margin-bottom: 5px; }
.empty-state p { font-size: 13px; margin-bottom: 16px; }

/* ------------------------------------------------------------------ 4. 业务组件 */
/* 标签页 */
.tabs {
    display: flex;
    align-items: center;
    gap: 2px;
    border-bottom: 1px solid var(--line);
    padding: 0 4px;
    margin-bottom: 0;
    overflow-x: auto;
    scrollbar-width: thin;
}
.tabs + .card { border-top-left-radius: 0; border-top-right-radius: 0; border-top: 0; }
.tab {
    padding: 11px 13px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 550;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 2px;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary-600); border-bottom-color: var(--primary); }
.tab-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    margin-left: 6px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1;
    color: var(--muted);
    background: var(--surface-3);
    border-radius: 9px;
}
.tab.active .tab-count { color: var(--primary-600); background: var(--primary-50); }

/* 筛选栏 */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 14px 16px;
    padding: 16px 20px;
    margin-bottom: 18px;
}
.card > .filter-bar { margin-bottom: 0; border-bottom: 1px solid var(--line); }
.filter-bar .field { gap: 5px; flex: 1 1 130px; min-width: 122px; }
.filter-bar .field > label { font-size: 11.5px; font-weight: 550; color: var(--muted); line-height: 16px; }
.filter-bar input,
.filter-bar select { height: 36px; font-size: 12.5px; }
.filter-bar .btn { height: 36px; }
.filter-bar .field-range { flex: 1 1 240px; min-width: 230px; }
.filter-bar .field-actions {
    flex: 0 0 auto;
    flex-direction: row;
    display: flex;
    gap: 8px;
    align-items: center;
    margin-left: auto;
}
.filter-bar > .btn { align-self: flex-end; }
.filter-bar > .btn + .btn { margin-left: -6px; }

.date-range { display: flex; align-items: center; gap: 8px; min-width: 0; }
.date-range input { flex: 1 1 0; min-width: 0; }
.date-range-sep { flex: 0 0 auto; font-size: 12px; color: var(--muted-2); }

/* 分页 */
.pagination { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.pagination a,
.pagination span {
    min-width: 30px;
    height: 30px;
    padding: 0 8px;
    border-radius: 7px;
    border: 1px solid var(--line);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12.5px;
    color: var(--text-2);
    background: var(--surface);
}
.pagination a:hover { border-color: var(--primary); color: var(--primary); }
.pagination .current { background: var(--primary); border-color: var(--primary); color: #fff; }
.pagination .disabled { color: var(--muted-2); background: var(--surface-2); }

/* 通知 */
.notice-list { list-style: none; margin: 0; padding: 0; }
.notice-item { padding: 15px 20px; border-bottom: 1px solid var(--line); }
.notice-item:last-child { border-bottom: 0; }
.notice-item.unread { background: #f8fbff; }
.notice-item.unread { box-shadow: inset 3px 0 0 var(--primary); }
.notice-head { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.notice-head strong { font-size: 13.5px; font-weight: 600; }
.notice-time { margin-left: auto; font-variant-numeric: tabular-nums; }
.notice-unread-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--primary); flex: 0 0 6px; }
.notice-body { margin-top: 7px; font-size: 13px; color: var(--text-2); line-height: 1.7; }
.notice-meta { display: flex; align-items: center; gap: 14px; margin-top: 7px; font-size: 11.5px; color: var(--muted); }
.notice-meta .meta-item { display: inline-flex; align-items: center; gap: 4px; }
.notice-meta .meta-item.is-ok { color: var(--success); }
.notice-meta .icon { width: 12px; height: 12px; }
.inline-form { display: inline; margin: 0; }

/* 简单列表 */
.list { display: flex; flex-direction: column; }
.list-item { display: flex; gap: 12px; padding: 13px 20px; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
.list-item.unread { background: #fbfdff; }
.list-item .item-icon {
    width: 32px;
    height: 32px;
    border-radius: 9px;
    background: var(--surface-3);
    color: var(--muted);
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 32px;
}
.list-item .item-body { flex: 1; min-width: 0; }
.list-item .item-title { font-weight: 600; color: var(--text); font-size: 13.5px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.list-item .item-text { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.list-item .item-time { color: var(--muted-2); font-size: 11.5px; white-space: nowrap; }

/* 详情栅格 */
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.detail-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 13px 20px;
    border-bottom: 1px solid var(--line);
    min-width: 0;
}
.detail-item:nth-child(odd) { border-right: 1px solid var(--line); }
.detail-item:nth-last-child(-n+2) { border-bottom: 0; }
.detail-item .k { color: var(--muted); font-size: 12px; flex: 0 0 auto; }
.detail-item .v {
    color: var(--text);
    font-size: 13px;
    font-weight: 550;
    text-align: right;
    word-break: break-all;
    min-width: 0;
}
.detail-grid-flush { margin: -20px; }

/* 代码 / 预览 */
.code-block {
    background: #0f172a;
    color: #e2e8f0;
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    font-family: var(--mono);
    font-size: 12px;
    line-height: 1.7;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-all;
}
.preview-frame {
    width: 100%;
    height: 560px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: #fff;
}
.code-pill {
    display: inline-block;
    padding: 2px 8px;
    font-family: var(--mono);
    font-size: 11.5px;
    color: var(--primary-600);
    background: var(--primary-50);
    border: 1px solid var(--primary-line);
    border-radius: 6px;
    white-space: nowrap;
}
.template-code {
    display: inline-flex;
    align-items: center;
    height: 24px;
    padding: 0 8px;
    border-radius: 6px;
    background: #eef2ff;
    color: #3730a3;
    border: 1px solid #c7d2fe;
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: .02em;
    white-space: nowrap;
}
.var-palette { display: flex; flex-wrap: wrap; gap: 6px; }
.var-chip {
    border: 1px solid var(--line);
    background: var(--surface-2);
    color: var(--muted);
    border-radius: 999px;
    padding: 3px 9px;
    font-size: 11.5px;
    font-family: var(--mono);
    cursor: pointer;
    transition: border-color .15s ease, color .15s ease, background .15s ease;
}
.var-chip:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-50); }
.code-editor {
    font-family: var(--mono);
    font-size: 12.5px;
    line-height: 1.65;
    background: #fbfcfe;
}

/* 仪表盘 */
.dash-overview {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-xs);
    margin-bottom: 20px;
    overflow: hidden;
}
.dash-metric { padding: 18px 22px; min-width: 0; }
.dash-metric + .dash-metric { border-left: 1px solid var(--line); }
.dash-metric-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.dash-metric-label { font-size: 12.5px; font-weight: 550; color: var(--muted); }
.dash-metric-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    flex: 0 0 30px;
    border-radius: 9px;
    background: var(--surface-3);
    color: var(--muted-2);
}
.dash-metric-icon .icon { width: 16px; height: 16px; }
.dash-metric-icon.is-success { background: var(--success-50); color: var(--success); }
.dash-metric-icon.is-danger { background: var(--danger-50); color: var(--danger); }
.dash-metric-icon.is-primary { background: var(--primary-50); color: var(--primary); }
.dash-metric-icon.is-info { background: var(--info-50); color: var(--info); }
.dash-metric-icon.is-muted { background: var(--surface-3); color: var(--muted-2); }
.dash-metric-value {
    margin-top: 4px;
    font-size: 30px;
    font-weight: 750;
    letter-spacing: -.025em;
    line-height: 1.15;
    font-variant-numeric: tabular-nums;
}
.dash-metric-foot {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    min-height: 18px;
    margin-top: 6px;
    font-size: 12px;
    color: var(--muted);
}
.dash-delta {
    display: inline-flex;
    align-items: center;
    height: 20px;
    padding: 0 6px;
    border-radius: 6px;
    font-size: 11.5px;
    font-weight: 650;
    font-variant-numeric: tabular-nums;
}
.dash-delta.is-up { background: var(--success-50); color: var(--success); }
.dash-delta.is-down { background: var(--danger-50); color: var(--danger); }
.dash-delta.is-flat { background: var(--surface-3); color: var(--muted); }
.dash-inline-value { color: var(--text); font-weight: 650; }
.dash-dot-sep { color: var(--muted-2); }
.dash-foot-ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }

.dash-main {
    display: grid;
    grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr);
    gap: 20px;
    margin-bottom: 20px;
}
.dash-pair {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}
.dash-main > .card,
.dash-pair > .card { margin-bottom: 0; }
.dash-pair > .card { display: flex; flex-direction: column; }
.dash-pair > .card > .card-body { display: flex; flex-direction: column; flex: 1 1 auto; }

.dash-task-head { margin-bottom: 18px; min-width: 0; }
.dash-task-title {
    font-size: 17px;
    font-weight: 650;
    letter-spacing: -.01em;
    line-height: 1.35;
    word-break: break-word;
}
.dash-task-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 7px;
    margin-top: 6px;
    font-size: 12px;
    color: var(--muted);
}

.dash-progress {
    padding: 14px 16px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 10px;
}
.dash-progress-top {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
    font-size: 12.5px;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}
.dash-progress-pct { font-size: 15px; font-weight: 700; color: var(--primary-600); }
.dash-progress-foot {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px 16px;
    margin-top: 9px;
    font-size: 12px;
    color: var(--muted);
}
.dash-progress-foot strong { color: var(--text-2); font-weight: 600; }

.dash-breakdown {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    margin-top: 14px;
}
.dash-break-item {
    padding: 11px 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    min-width: 0;
}
.dash-break-item .v {
    display: block;
    font-size: 19px;
    font-weight: 700;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
}
.dash-break-item .k { display: block; margin-top: 2px; font-size: 11.5px; color: var(--muted); }
.dash-break-item.is-success .v { color: var(--success); }
.dash-break-item.is-danger .v { color: var(--danger); }
.dash-break-item.is-warning .v { color: var(--warning); }
.dash-break-item.is-muted .v { color: var(--muted); }

.dash-idle { display: flex; align-items: flex-start; gap: 16px; padding: 8px 2px 4px; }
.dash-idle-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    flex: 0 0 46px;
    border-radius: 12px;
    background: var(--surface-3);
    color: var(--muted);
}
.dash-idle-icon .icon { width: 22px; height: 22px; }
.dash-idle-body { min-width: 0; }
.dash-idle-title { font-size: 15px; font-weight: 650; }
.dash-idle-body p { margin: 4px 0 14px; color: var(--muted); font-size: 13px; }
.dash-idle-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.dash-engine { display: flex; align-items: center; gap: 12px; padding: 2px 0 16px; }
.dash-engine-dot {
    width: 10px;
    height: 10px;
    flex: 0 0 10px;
    border-radius: 50%;
    background: var(--muted-2);
}
.dash-engine-dot.is-online { background: var(--success); box-shadow: 0 0 0 4px rgba(7, 148, 85, .14); }
.dash-engine-dot.is-offline { background: var(--danger); box-shadow: 0 0 0 4px rgba(217, 45, 32, .14); }
.dash-engine-body { min-width: 0; }
.dash-engine-state { font-size: 16px; font-weight: 650; line-height: 1.3; }
.dash-engine-sub { margin-top: 2px; font-size: 12px; color: var(--muted); }

.dash-kv { margin: 0; border-top: 1px solid var(--line); }
.dash-kv > div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
}
.dash-kv > div:last-child { border-bottom: 0; padding-bottom: 0; }
.dash-kv dt { color: var(--muted); font-size: 12.5px; flex: 0 0 auto; }
.dash-kv dd {
    margin: 0;
    min-width: 0;
    text-align: right;
    color: var(--text);
    font-size: 13px;
    font-weight: 550;
    word-break: break-all;
}

.dash-inline-note {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-top: 14px;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 12px;
    line-height: 1.55;
}
.dash-inline-note .icon { width: 15px; height: 15px; flex: 0 0 15px; margin-top: 2px; }
.dash-inline-note.is-warning { background: var(--warning-50); border: 1px solid var(--warning-line); color: #93370d; }
.dash-inline-note.is-success { background: var(--success-50); border: 1px solid var(--success-line); color: #05603a; }

.dash-quota-summary {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}
.dash-quota-used { font-size: 24px; font-weight: 750; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.dash-quota-limit { margin-left: 2px; font-size: 12.5px; color: var(--muted); }
.dash-quota-pct { font-size: 13px; font-weight: 650; font-variant-numeric: tabular-nums; }
.dash-quota-pct.is-primary { color: var(--primary-600); }
.dash-quota-pct.is-warning { color: var(--warning); }
.dash-quota-pct.is-danger { color: var(--danger); }
.dash-quota-side { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.dash-quota-left { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.dash-quota-list-head {
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
    font-size: 11px;
    font-weight: 650;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--muted-2);
}
.dash-quota-list { display: flex; flex-direction: column; gap: 12px; margin-top: 10px; }
.dash-quota-row { min-width: 0; }
.dash-quota-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 5px;
    font-size: 12px;
}
.dash-quota-name { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dash-quota-num { flex: 0 0 auto; color: var(--muted); font-variant-numeric: tabular-nums; }
.dash-quota-num strong { color: var(--text); font-weight: 600; }
.dash-quota-track { height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.dash-quota-track > span {
    display: block;
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, #60a5fa, #2563eb);
}
.dash-quota-track > span.is-warning { background: linear-gradient(90deg, #fdb022, #dc6803); }
.dash-quota-track > span.is-danger { background: linear-gradient(90deg, #f97066, #d92d20); }
.dash-quota-note {
    display: flex;
    align-items: flex-start;
    gap: 7px;
    margin-top: auto;
    padding-top: 16px;
    font-size: 11.5px;
    line-height: 1.6;
    color: var(--muted-2);
}
.dash-quota-note .icon { width: 14px; height: 14px; flex: 0 0 14px; margin-top: 2px; }

.dash-stack { display: flex; height: 12px; border-radius: 999px; overflow: hidden; background: var(--surface-3); }
.dash-stack > span { display: block; height: 100%; }
.dash-stack > span + span { box-shadow: inset 1px 0 0 rgba(255, 255, 255, .7); }
.dash-stack > .is-success { background: #12b76a; }
.dash-stack > .is-warning { background: #f79009; }
.dash-stack > .is-danger { background: #f04438; }
.dash-stack > .is-muted { background: #cfd6e4; }

.dash-legend {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-top: 16px;
}
.dash-legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-2);
    font-size: 12.5px;
    color: var(--muted);
    min-width: 0;
}
.dash-legend-item strong {
    margin-left: auto;
    color: var(--text);
    font-size: 14px;
    font-variant-numeric: tabular-nums;
}
.dash-legend-dot { width: 8px; height: 8px; flex: 0 0 8px; border-radius: 3px; }
.dash-legend-dot.is-success { background: #12b76a; }
.dash-legend-dot.is-warning { background: #f79009; }
.dash-legend-dot.is-danger { background: #f04438; }
.dash-legend-dot.is-muted { background: #cfd6e4; }

.dash-attention { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.dash-attention-title {
    margin-bottom: 8px;
    font-size: 11px;
    font-weight: 650;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--muted-2);
}
.dash-attention-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 0;
    border-bottom: 1px dashed var(--line);
    font-size: 12.5px;
    color: var(--text-2);
}
.dash-attention-item:last-child { border-bottom: 0; padding-bottom: 0; }
.dash-attention-item:hover { color: var(--primary); }
.dash-attention-mail { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.dash-attention-time { flex: 0 0 auto; margin-left: auto; font-size: 11.5px; color: var(--muted-2); }

.dash-actions { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; }
.dash-action {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    padding: 14px 16px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-xs);
    color: var(--text);
    transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.dash-action:hover {
    color: var(--text);
    border-color: var(--primary-line);
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}
.dash-action-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    border-radius: 9px;
    background: var(--surface-3);
    color: var(--muted);
}
.dash-action-icon .icon { width: 17px; height: 17px; }
.dash-action-icon.is-primary { background: var(--primary-50); color: var(--primary); }
.dash-action-icon.is-info { background: var(--info-50); color: var(--info); }
.dash-action-icon.is-success { background: var(--success-50); color: var(--success); }
.dash-action-icon.is-warning { background: var(--warning-50); color: var(--warning); }
.dash-action-icon.is-muted { background: var(--surface-3); color: var(--muted); }
.dash-action-body { min-width: 0; }
.dash-action-body strong { display: block; font-size: 13px; font-weight: 600; }
.dash-action-body span {
    display: block;
    margin-top: 1px;
    font-size: 11.5px;
    color: var(--muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.quota-row { padding: 10px 0; border-bottom: 1px solid var(--line); }
.quota-row:last-child { border-bottom: 0; padding-bottom: 0; }
.quota-row:first-child { padding-top: 0; }

.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.bar-row:last-child { margin-bottom: 0; }
.bar-label { flex: 0 0 100px; font-size: 12.5px; color: var(--text-2); }
.bar-track { flex: 1; height: 8px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.bar-track > span { display: block; height: 100%; background: linear-gradient(90deg, #f97066, #d92d20); border-radius: 999px; }
.bar-value { flex: 0 0 54px; text-align: right; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* 设置页 */
.settings-form { display: flex; flex-direction: column; gap: 20px; padding-bottom: 72px; }
.settings-section {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-xs);
    overflow: hidden;
}
.settings-section-spaced { margin-top: 20px; }
.settings-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 15px 20px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--line);
    flex-wrap: wrap;
}
.settings-section-head h3 { margin: 0; font-size: 14.5px; font-weight: 650; color: var(--text); }
.settings-section-desc { margin-top: 3px; font-size: 12px; color: var(--muted); }

.settings-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 22px 20px;
    padding: 20px;
    align-items: start;
}
.settings-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.settings-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.form-field { display: flex; flex-direction: column; min-width: 0; }
.form-field-label {
    display: flex;
    align-items: center;
    gap: 6px;
    min-height: 20px;
    margin-bottom: 7px;
    min-width: 0;
}
.form-field-title {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.form-field-key {
    font-family: var(--mono);
    font-size: 11px;
    color: var(--muted-2);
    white-space: nowrap;
    flex-shrink: 0;
    background: none;
    border: 0;
    padding: 0;
}
.form-field-control { display: flex; align-items: center; min-height: 38px; }
.form-field-control > input,
.form-field-control > select { width: 100%; height: 38px; }
.form-field-control .switch { height: 38px; display: inline-flex; align-items: center; gap: 10px; }
.form-field-desc { margin-top: 6px; font-size: 12px; color: var(--muted); line-height: 1.5; }
.form-field-hint { margin-top: 4px; font-size: 11.5px; color: var(--muted); line-height: 1.5; min-height: 16px; }
.form-field-full { grid-column: 1 / -1; }

.help-dot {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    padding: 0;
    flex: 0 0 auto;
    border: 1px solid var(--line-strong);
    border-radius: 50%;
    background: var(--surface);
    color: var(--muted);
    font-size: 10.5px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    transition: border-color .15s ease, color .15s ease, background .15s ease;
}
.help-dot:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-50); }
.help-dot-inline { vertical-align: -2px; cursor: default; }

.help-tip {
    position: absolute;
    z-index: 1200;
    max-width: 320px;
    padding: 10px 13px;
    background: #1d2939;
    color: #fff;
    font-size: 12.5px;
    line-height: 1.6;
    border-radius: 8px;
    box-shadow: 0 10px 28px -8px rgba(16, 24, 40, .4);
    pointer-events: none;
}
.help-tip::before {
    content: "";
    position: absolute;
    top: -5px;
    left: 16px;
    width: 10px;
    height: 10px;
    background: #1d2939;
    transform: rotate(45deg);
}

.toggle-list { border-top: 1px solid var(--line); }
.toggle-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    padding: 15px 20px;
    border-bottom: 1px solid var(--line);
    transition: background .15s ease;
}
.toggle-row:last-child { border-bottom: 0; }
.toggle-row:hover { background: var(--surface-2); }
.toggle-copy { min-width: 0; }
.toggle-title { display: flex; align-items: center; gap: 6px; font-size: 13.5px; font-weight: 550; color: var(--text); }
.toggle-desc { margin-top: 3px; font-size: 12.5px; color: var(--muted); line-height: 1.5; }
.toggle-impact { margin-top: 5px; font-size: 12px; line-height: 1.5; color: var(--success); }
.toggle-impact.is-off { color: var(--muted-2); }

.toggle {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 9px;
    flex: 0 0 auto;
    padding-top: 1px;
    cursor: pointer;
    user-select: none;
}
.toggle input[type="checkbox"] { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle-track {
    position: relative;
    width: 42px;
    height: 24px;
    border-radius: 999px;
    background: var(--line-strong);
    transition: background .18s ease;
    flex: 0 0 auto;
}
.toggle-track::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 2px rgba(16, 24, 40, .25);
    transition: transform .18s ease;
}
.toggle input:checked + .toggle-track { background: var(--primary); }
.toggle input:checked + .toggle-track::after { transform: translateX(18px); }
.toggle input:focus-visible + .toggle-track { outline: 3px solid rgba(37, 99, 235, .28); outline-offset: 2px; }
.toggle-state { font-size: 12.5px; color: var(--muted); min-width: 42px; }
.toggle input:checked ~ .toggle-state { color: var(--primary-600); font-weight: 600; }

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track {
    position: relative;
    width: 38px;
    height: 22px;
    border-radius: 999px;
    background: var(--line-strong);
    transition: background .18s ease;
    flex: 0 0 auto;
}
.switch-track::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    background: #fff;
    border-radius: 50%;
    transition: transform .18s ease;
    box-shadow: 0 1px 2px rgba(16, 24, 40, .2);
}
.switch input:checked + .switch-track { background: var(--primary); }
.switch input:checked + .switch-track::after { transform: translateX(16px); }
.switch-text { font-size: 12.5px; color: var(--muted); }

.settings-actions {
    position: sticky;
    bottom: 16px;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    padding: 12px 18px;
    background: rgba(255, 255, 255, .96);
    backdrop-filter: blur(8px);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
}
.settings-actions-hint { font-size: 12.5px; color: var(--muted); }
.settings-actions-btns { display: flex; gap: 10px; }
.settings-actions-sub {
    position: static;
    margin-top: 12px;
    padding: 12px 18px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    box-shadow: none;
}
.settings-actions-sub .settings-actions-hint { font-size: 12px; color: var(--muted); }

.about-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 20px;
    padding: 20px;
}
.about-item span { display: block; font-size: 11.5px; color: var(--muted); margin-bottom: 5px; }
.about-item strong {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text);
    font-family: var(--mono);
    word-break: break-all;
}
.kv-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.kv-grid .mono { margin-top: 4px; font-size: 13px; }

.worker-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 30px;
    padding: 0 11px;
    border-radius: 999px;
    font-size: 12.5px;
    font-weight: 600;
    white-space: nowrap;
    border: 1px solid transparent;
}
.worker-dot { width: 7px; height: 7px; border-radius: 50%; }
.worker-badge-on { background: var(--success-50); color: var(--success); border-color: var(--success-line); }
.worker-badge-on .worker-dot { background: var(--success); }
.worker-badge-off { background: var(--danger-50); color: var(--danger); border-color: var(--danger-line); }
.worker-badge-off .worker-dot { background: var(--danger); }

/* 连接测试 */
.conn-loading { padding: 28px 0; text-align: center; color: var(--muted); font-size: 13px; }
.conn-loading::before {
    content: "";
    display: block;
    width: 22px;
    height: 22px;
    margin: 0 auto 10px;
    border: 2px solid var(--line-strong);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.conn-verdict { display: flex; align-items: center; gap: 13px; padding: 13px 15px; border-radius: 10px; margin-bottom: 14px; }
.conn-verdict.ok { background: var(--success-50); border: 1px solid var(--success-line); }
.conn-verdict.fail { background: var(--danger-50); border: 1px solid var(--danger-line); }
.conn-verdict-icon {
    width: 32px;
    height: 32px;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 16px;
    font-weight: 700;
    background: #fff;
}
.conn-verdict.ok .conn-verdict-icon { color: var(--success); }
.conn-verdict.fail .conn-verdict-icon { color: var(--danger); }
.conn-verdict-title { font-size: 14.5px; font-weight: 650; color: var(--text); }
.conn-verdict-mail { font-size: 12px; color: var(--muted); margin-top: 2px; }
.conn-conclusion {
    padding: 11px 14px;
    margin-bottom: 14px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 9px;
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-2);
}
.conn-stages { list-style: none; margin: 0; padding: 0; }
.conn-stage { display: flex; gap: 12px; padding: 11px 0; border-bottom: 1px dashed var(--line); }
.conn-stage:last-child { border-bottom: 0; }
.conn-mark {
    width: 20px;
    height: 20px;
    flex: 0 0 auto;
    margin-top: 1px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 11px;
    font-weight: 700;
}
.conn-stage.ok .conn-mark { background: var(--success-50); color: var(--success); }
.conn-stage.fail .conn-mark { background: var(--danger-50); color: var(--danger); }
.conn-stage-main { flex: 1; min-width: 0; }
.conn-stage-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.conn-stage-head strong { font-size: 13px; font-weight: 600; color: var(--text); }
.conn-ms { font-size: 11.5px; color: var(--muted-2); font-variant-numeric: tabular-nums; }
.conn-detail { margin-top: 3px; font-size: 12px; color: var(--muted); line-height: 1.5; word-break: break-all; }
.conn-stage.fail .conn-detail { color: var(--danger); }

/* 发件箱批量测试 */
.check-col { width: 42px; text-align: center; padding-right: 0 !important; }
.check-col input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
    cursor: pointer;
    vertical-align: -2px;
}
.batch-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    padding: 10px 20px;
    background: var(--primary-50);
    border-bottom: 1px solid var(--primary-line);
}
.batch-count { font-size: 13px; color: var(--primary-600); }
.batch-count strong { font-size: 15px; font-weight: 700; }
.batch-hint { font-size: 12px; color: var(--muted); }
.batch-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

.modal.modal-wide { max-width: 720px; }
.batch-summary {
    margin-top: 14px;
    padding: 10px 12px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 8px;
    font-size: 12.5px;
    color: var(--text-2);
}
.batch-list {
    margin-top: 12px;
    max-height: 320px;
    overflow-y: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    overscroll-behavior: contain;
}
.batch-empty { padding: 22px 16px; text-align: center; color: var(--muted); font-size: 12.5px; }
.batch-item { padding: 10px 12px; border-bottom: 1px solid var(--line); }
.batch-item:last-child { border-bottom: 0; }
.batch-item.is-pending { background: #fbfdff; }
.batch-item-head { display: flex; align-items: center; gap: 8px; }
.batch-item-mail {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
    color: var(--text);
}
.batch-item-ms { flex: 0 0 auto; font-size: 11px; color: var(--muted-2); font-variant-numeric: tabular-nums; }
.batch-item-detail {
    margin-top: 3px;
    font-size: 12px;
    color: var(--muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.batch-item.is-fail .batch-item-detail { color: var(--danger); }

/* 登录锁定提示 */
.auth-alert { align-items: flex-start; }
.login-lock-timer { margin-top: 5px; font-size: 12px; color: var(--danger); }
.auth-hint {
    margin: 14px 0 0;
    font-size: 11.5px;
    line-height: 1.6;
    color: var(--muted);
    text-align: center;
}

/* 固定高度表格 */
.card-fixed { display: flex; flex-direction: column; min-height: 0; }.card-fixed .table-scroll {
    max-height: 336px;
    overflow-y: auto;
    overflow-x: auto;
    overscroll-behavior: contain;
}
.card-fixed .table-scroll thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--surface-2);
    box-shadow: inset 0 -1px 0 var(--line);
}
.card-fixed .table-scroll::-webkit-scrollbar { width: 8px; height: 8px; }
.card-fixed .table-scroll::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 999px; }
.card-fixed .table-scroll::-webkit-scrollbar-track { background: transparent; }

/* 系统自检 */
.sc-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
    gap: 20px;
    align-items: start;
}
.sc-deep { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); cursor: pointer; user-select: none; }
.sc-deep input { accent-color: var(--primary); width: 15px; height: 15px; }
.sc-card { margin-bottom: 0; }
.sc-results { padding: 4px 0 0; max-height: calc(100vh - 250px); overflow: auto; }
.sc-empty { padding: 44px 24px; text-align: center; color: var(--muted); }
.sc-empty strong { display: block; color: var(--text); margin-bottom: 6px; font-size: 14px; }
.sc-empty p { font-size: 12.5px; line-height: 1.7; }
.sc-legend { display: flex; gap: 12px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.sc-legend span { display: inline-flex; align-items: center; gap: 5px; }
.sc-legend .sc-dot { margin-top: 0; }
.sc-group { border-top: 1px solid var(--line); }
.sc-group:first-child { border-top: 0; }
.sc-group-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 20px 7px; }
.sc-group-head h3 { font-size: 12.5px; font-weight: 650; color: var(--muted); letter-spacing: .03em; }
.sc-item { display: flex; align-items: flex-start; gap: 10px; padding: 10px 20px 12px; border-top: 1px dashed var(--line); }
.sc-item:first-of-type { border-top: 0; }
.sc-item.is-fail { background: #fffbfa; }
.sc-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex: 0 0 auto; background: var(--muted-2); }
.sc-dot.is-ok { background: var(--success); }
.sc-dot.is-warn { background: var(--warning); }
.sc-dot.is-fail { background: var(--danger); }
.sc-dot.is-skip { background: var(--muted-2); }
.sc-body { min-width: 0; flex: 1; }
.sc-title { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--text); }
.sc-ms { font-size: 11px; font-weight: 400; color: var(--muted-2); font-variant-numeric: tabular-nums; }
.sc-detail { margin-top: 2px; font-size: 12.5px; color: var(--muted); line-height: 1.55; word-break: break-word; }
.sc-hint { margin-top: 4px; font-size: 12px; color: var(--warning); line-height: 1.5; }
.sc-badge { flex: 0 0 auto; margin-top: 1px; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.sc-badge.is-ok { background: var(--success-50); color: var(--success); }
.sc-badge.is-warn { background: var(--warning-50); color: var(--warning); }
.sc-badge.is-fail { background: var(--danger-50); color: var(--danger); }
.sc-badge.is-skip { background: var(--surface-3); color: var(--muted); }
.sc-left { min-width: 0; }
.sc-right { position: sticky; top: 80px; }
.sc-log-card { margin-bottom: 0; display: flex; flex-direction: column; }
.sc-log-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.sc-log-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--line);
    background: var(--surface-2);
    flex-wrap: wrap;
}
.sc-log-toolbar select,
.sc-log-toolbar input[type="search"] {
    width: auto;
    flex: 0 0 auto;
    height: 32px;
    min-height: 32px;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background-color: var(--surface);
    color: var(--text);
    font-size: 12.5px;
}
.sc-log-toolbar select { padding-right: 30px; }
.sc-log-toolbar input[type="search"] { flex: 1 1 120px; width: auto; min-width: 120px; }
.sc-auto { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); cursor: pointer; white-space: nowrap; }
.sc-auto input { accent-color: var(--primary); }

.log-pane {
    height: min(60vh, 540px);
    overflow: auto;
    padding: 8px 0;
    background: #0f172a;
    color: #cbd5e1;
    font-family: var(--mono);
    font-size: 12px;
    line-height: 1.65;
    scrollbar-width: thin;
}
.log-line { display: flex; gap: 10px; padding: 1px 14px; white-space: pre-wrap; word-break: break-word; }
.log-line:hover { background: rgba(255, 255, 255, .04); }
.log-line.is-live { background: rgba(37, 99, 235, .14); }
.log-ts { flex: 0 0 auto; color: #64748b; }
.log-lv { flex: 0 0 58px; font-weight: 600; color: #93c5fd; }
.lv-error, .lv-critical, .lv-fatal { color: #fca5a5; }
.lv-warning { color: #fcd34d; }
.lv-info { color: #93c5fd; }
.lv-debug { color: #94a3b8; }
.log-text { min-width: 0; color: #e2e8f0; }
.log-empty { padding: 28px 16px; text-align: center; color: #64748b; }
.sc-log-foot {
    padding: 8px 14px;
    border-top: 1px solid rgba(255, 255, 255, .06);
    background: #111c30;
    color: #7c8ba1;
    font-size: 11.5px;
    line-height: 1.5;
    word-break: break-all;
}

/* ------------------------------------------------------------------ 5. 弹窗 / Toast / 公开页 */
.modal-mask {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(16, 24, 40, .46);
    backdrop-filter: blur(2px);
    animation: fade-in .16s ease;
}
.modal-mask[hidden] { display: none; }

.modal {
    width: 100%;
    max-width: 560px;
    max-height: 86vh;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    animation: modal-in .18s ease;
}
.modal > form { display: flex; flex-direction: column; min-height: 0; max-height: inherit; }
.modal-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 17px 20px;
    border-bottom: 1px solid var(--line);
}
.modal-head h3 { margin: 0; font-size: 16px; font-weight: 650; }
.modal-close {
    width: 30px;
    height: 30px;
    flex: 0 0 auto;
    border: 0;
    border-radius: 8px;
    background: transparent;
    font-size: 21px;
    line-height: 1;
    color: var(--muted);
    cursor: pointer;
}
.modal-close:hover { background: var(--surface-3); color: var(--text); }
.modal-body { padding: 18px 20px 20px; overflow-y: auto; }
.modal-body > .field + .field { margin-top: 14px; }
.modal-body .radio + .radio { margin-top: 8px; }
.modal-foot {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    padding: 13px 20px;
    border-top: 1px solid var(--line);
    background: var(--surface-2);
    flex-wrap: wrap;
}
@media (max-width: 520px) {
    .modal-foot { flex-direction: column-reverse; align-items: stretch; }
    .modal-foot .btn { width: 100%; }
}

dialog.modal {
    border: 0;
    padding: 0;
    width: min(640px, calc(100vw - 32px));
}
dialog.modal::backdrop { background: rgba(16, 24, 40, .46); backdrop-filter: blur(2px); }

@keyframes modal-in {
    from { opacity: 0; transform: translateY(8px) scale(.99); }
    to { opacity: 1; transform: none; }
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* Toast */
.toast-stack {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 1100;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 380px;
}
.toast {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    background: #fff;
    border: 1px solid var(--line);
    border-left: 3px solid var(--muted);
    border-radius: 10px;
    box-shadow: 0 12px 32px -12px rgba(16, 24, 40, .3);
    padding: 11px 12px 11px 13px;
    font-size: 13px;
    color: var(--text-2);
    animation: toast-in .22s ease;
}
.toast-success { border-left-color: var(--success); }
.toast-error { border-left-color: var(--danger); }
.toast-warning { border-left-color: var(--warning); }
.toast-info { border-left-color: var(--info); }
.toast-icon { display: flex; margin-top: 1px; color: var(--muted); }
.toast-icon svg { width: 17px; height: 17px; }
.toast-success .toast-icon { color: var(--success); }
.toast-error .toast-icon { color: var(--danger); }
.toast-warning .toast-icon { color: var(--warning); }
.toast-text { flex: 1; line-height: 1.5; word-break: break-word; }
.toast-close {
    border: 0;
    background: transparent;
    color: var(--muted-2);
    cursor: pointer;
    padding: 0 2px;
    font-size: 17px;
    line-height: 1;
}
.toast-close:hover { color: var(--text); }
.toast.hide { opacity: 0; transform: translateY(6px); transition: opacity .2s ease, transform .2s ease; }

@keyframes toast-in {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: none; }
}

/* 登录 */
.auth-body {
    min-height: 100vh;
    background:
        radial-gradient(900px 500px at 12% -10%, rgba(37, 99, 235, .14), transparent 60%),
        radial-gradient(700px 420px at 100% 100%, rgba(79, 141, 253, .12), transparent 55%),
        #f4f6fa;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.auth-shell { width: 100%; max-width: 404px; }
.auth-panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: 0 24px 60px -24px rgba(16, 24, 40, .28);
    padding: 28px;
}
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.auth-brand strong { display: block; font-size: 16px; }
.auth-brand small { display: block; color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.auth-card h1 { font-size: 20px; margin-bottom: 4px; }
.auth-sub { color: var(--muted); font-size: 13px; margin-bottom: 20px; }
.auth-card .btn-block { height: 42px; font-size: 14px; }
.auth-footer { text-align: center; color: var(--muted-2); font-size: 11.5px; margin-top: 18px; }

/* 公开退订页 */
.public-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 20px;
    background: var(--bg);
}
.public-card {
    width: 100%;
    max-width: 440px;
    padding: 30px 26px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}
.public-brand { font-size: 12px; font-weight: 600; color: var(--primary); letter-spacing: .5px; margin-bottom: 10px; }
.public-card h1 { margin: 0 0 12px; font-size: 20px; }
.public-text { font-size: 13.5px; color: var(--text-2); line-height: 1.7; margin: 0 0 14px; }
.public-mail {
    display: block;
    padding: 10px 12px;
    margin: 0 0 18px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    font-size: 13px;
    word-break: break-all;
    color: var(--text);
}
.public-hint { margin: 14px 0 0; font-size: 12px; color: var(--muted-2); line-height: 1.6; }

/* 错误页 */
.empty-page { text-align: center; padding: 88px 20px; }
.empty-code { font-size: 64px; font-weight: 750; letter-spacing: -.04em; color: var(--line-strong); line-height: 1; }
.empty-page h1 { font-size: 22px; margin: 12px 0 6px; }
.empty-page p { color: var(--muted); margin-bottom: 20px; }

/* ------------------------------------------------------------------ 6. 工具类 */
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.split-2 { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 20px; }
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.flex-center { display: flex; align-items: center; gap: 8px; }
.flex-wrap { flex-wrap: wrap; }
.gap-6 { gap: 6px; }
.gap-10 { gap: 10px; }
.gap-16 { gap: 16px; }
.mt-0 { margin-top: 0; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.muted { color: var(--muted); }
.muted-sm { color: var(--muted); font-size: 12px; }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-muted { color: var(--muted-2); }
.text-right { text-align: right; }
.w-full { width: 100%; }
.hidden { display: none !important; }
.mobile-only { display: none; }
.req { color: var(--danger); }

.sidebar-overlay { position: fixed; inset: 0; background: rgba(16, 24, 40, .4); z-index: 35; display: none; }
.sidebar-overlay.show { display: block; }

/* 响应式 */
@media (max-width: 1280px) {
    .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .stat-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .stat-grid-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .settings-grid,
    .settings-grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .about-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .dash-overview { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .dash-metric:nth-child(odd) { border-left: 0; }
    .dash-metric:nth-child(n+3) { border-top: 1px solid var(--line); }
    .dash-actions { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 1100px) {
    .sc-grid { grid-template-columns: 1fr; }
    .sc-right { position: static; }
    .sc-results { max-height: none; }
    .log-pane { height: 340px; }
    .card-fixed .table-scroll { max-height: 300px; }
}

@media (max-width: 1024px) {
    .content { padding: 22px 20px 32px; }
    .form-grid,
    .form-grid.cols-3,
    .field-grid,
    .grid-2,
    .grid-3,
    .split-2,
    .dash-main,
    .dash-pair { grid-template-columns: 1fr; }
    .detail-grid { grid-template-columns: 1fr; }
    .detail-item:nth-child(odd) { border-right: 0; }
    .detail-item:nth-last-child(-n+2) { border-bottom: 1px solid var(--line); }
    .detail-item:last-child { border-bottom: 0; }
    .filter-bar .field-actions { margin-left: 0; }
}

@media (max-width: 900px) {
    .tabs { scrollbar-width: none; }
    .tabs::-webkit-scrollbar { display: none; }
    .sidebar {
        transform: translateX(-100%);
        transition: transform .2s ease;
        box-shadow: 0 20px 40px rgba(16, 24, 40, .18);
    }
    .sidebar.open { transform: translateX(0); }
    .main { margin-left: 0; }
    .mobile-only { display: inline-flex; }
    .topbar { padding: 0 16px; }
    .status-chip span { display: none; }
    .status-chip { padding: 0 9px; }
    .user-name { display: none; }
    .filter-bar .field-range { flex-basis: 100%; }
}

@media (max-width: 640px) {
    .batch-actions { margin-left: 0; width: 100%; }
    .batch-actions .btn { flex: 1 1 auto; }
    .content { padding: 18px 14px 28px; }
    .stat-grid,
    .stat-grid-3,
    .stat-grid-5 { grid-template-columns: 1fr; }
    .dash-overview { grid-template-columns: 1fr; }
    .dash-metric { padding: 15px 16px; }
    .dash-metric + .dash-metric,
    .dash-metric:nth-child(n+3) { border-left: 0; border-top: 1px solid var(--line); }
    .dash-metric-value { font-size: 26px; }
    .dash-breakdown { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .dash-actions { grid-template-columns: 1fr; }
    .dash-idle { gap: 12px; }
    .dash-idle-icon { width: 40px; height: 40px; flex-basis: 40px; }
    .page-head { flex-direction: column; align-items: stretch; gap: 12px; }
    .page-actions { justify-content: flex-start; }
    .card-header,
    .card-head { padding: 13px 16px; }
    .card-body { padding: 16px; }
    .form-card { padding: 2px 16px 18px; }
    .filter-bar { padding: 14px 16px; }
    .filter-bar .field,
    .filter-bar .field-range { flex: 1 1 100%; min-width: 0; }
    .filter-bar .field-actions { width: 100%; }
    .filter-bar .field-actions .btn { flex: 1 1 auto; }
    .toggle-row { flex-direction: column; gap: 12px; padding: 14px 16px; }
    .toggle { align-self: flex-start; }
    .settings-actions { position: static; flex-direction: column; align-items: stretch; }
    .settings-actions-btns { justify-content: flex-end; }
    .settings-grid,
    .settings-grid-3,
    .settings-grid-2,
    .about-grid { grid-template-columns: 1fr; padding: 16px; }
    .sc-item,
    .sc-group-head { padding-left: 16px; padding-right: 16px; }
    .sc-log-toolbar { padding: 10px 12px; }
    .log-lv { flex-basis: 52px; }
    table.table th,
    table.table td { padding: 10px 12px; }
    .toast-stack { left: 14px; right: 14px; bottom: 14px; max-width: none; }
    .modal-mask { padding: 12px; }
    .detail-item { padding: 12px 16px; }
    .bar-label { flex-basis: 78px; }
}

@media print {
    .sidebar, .topbar, .page-actions, .filter-bar, .toast-stack, .settings-actions { display: none !important; }
    .main { margin-left: 0; }
    .content { padding: 0; max-width: none; }
    .card { box-shadow: none; border-color: #ddd; break-inside: avoid; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}
