/*
 * Clauve Console CSS
 *
 * 视觉规范沿用 Roster 控制台（roster/docs/CONSOLE_DESIGN_SYSTEM.md）与 MemoryLake 官网设计规范：
 * - 颜色只用 roster-colors.css 的语义变量（--bg-* / --text-* / --border-* …），不写原始色值；
 *   黑白为主，品牌蓝只给「进行中」与焦点，状态一律「7px 实色圆点 + 中性文字」
 * - 层次靠材质：sunken 侧栏 → canvas 灰内容区 → 微浮起的白卡片（elev-1）→ 浮层（elev-3）
 * - 紧凑密度：正文 13px，控件 28px；字重只用 400 / 500 / 600；数字等宽
 * - 深色：<html class="dark">（base.html 首帧按系统外观打上），变量随 roster-colors.css 的 .dark 切换
 *
 * 类名与旧版保持一致（模板与 console.js 依赖它们），只换视觉。
 */
@import url("roster-colors.css");

:root {
    /* 派生量：只取设计稿变量的透明度，不新增颜色（混色用 oklab，oklch 会让浅色发粉） */
    --hair: color-mix(in oklab, var(--text-primary) 9%, transparent);
    --hair-strong: color-mix(in oklab, var(--text-primary) 15%, transparent);
    --fill-1: color-mix(in oklab, var(--text-primary) 5%, transparent);
    --fill-2: color-mix(in oklab, var(--text-primary) 8%, transparent);
    --ink: var(--gray-1000);
    --highlight: inset 0 1px 0 color-mix(in oklab, var(--gray-0) 70%, transparent);
    --elev-0: 0 0 0 0.5px var(--hair-strong), 0 1px 1px color-mix(in oklab, var(--ink) 4%, transparent);
    --elev-1: 0 0 0 0.5px var(--hair-strong), 0 1px 1px color-mix(in oklab, var(--ink) 3%, transparent),
              0 2px 5px -1px color-mix(in oklab, var(--ink) 5%, transparent), 0 12px 24px -14px color-mix(in oklab, var(--ink) 14%, transparent);
    --elev-2: 0 0 0 0.5px var(--hair-strong), 0 2px 4px color-mix(in oklab, var(--ink) 5%, transparent),
              0 10px 20px -6px color-mix(in oklab, var(--ink) 10%, transparent), 0 24px 40px -18px color-mix(in oklab, var(--ink) 20%, transparent);
    --elev-3: 0 0 0 0.5px var(--hair-strong), 0 12px 28px -6px color-mix(in oklab, var(--ink) 18%, transparent),
              0 32px 64px -24px color-mix(in oklab, var(--ink) 28%, transparent);
    --focus-halo: 0 0 0 3px color-mix(in oklab, var(--focus-ring) 28%, transparent);

    /* 字号六档 */
    --fs-caption: 11px;
    --fs-small: 12px;
    --fs-body: 13px;
    --fs-title: 14px;
    --fs-name: 17px;
    --fs-display: 26px;

    /* 圆角 */
    --r-badge: 4px;
    --r-control: 6px;
    --r-panel: 10px;
    --r-float: 12px;

    --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    --font-mono: "SF Mono", "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

    --sidebar-width: 232px;
    --topbar-height: 52px;
    --ease: cubic-bezier(0.2, 0, 0, 1);

    /* 旧变量名：模板里可能还有直接引用，保留为语义别名 */
    --text-color-secondary: var(--text-secondary);
    --border-color: var(--border-subtle);
    --bg-base: var(--bg-canvas);
    --bg-card: var(--bg-surface);
    --bg-secondary: var(--bg-sunken);
    --radius: var(--r-control);
}
.dark {
    --hair-strong: color-mix(in oklab, var(--text-primary) 13%, transparent);
    --highlight: inset 0 1px 0 color-mix(in oklab, var(--gray-0) 5%, transparent);
    --elev-1: 0 0 0 0.5px var(--hair-strong), 0 2px 6px -2px rgb(0 0 0 / 0.5), 0 14px 28px -16px rgb(0 0 0 / 0.7);
    --elev-2: 0 0 0 0.5px var(--hair-strong), 0 6px 14px -4px rgb(0 0 0 / 0.5), 0 24px 40px -18px rgb(0 0 0 / 0.8);
    --elev-3: 0 0 0 0.5px var(--hair-strong), 0 16px 40px -8px rgb(0 0 0 / 0.7);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
    font-family: var(--font-sans);
    font-size: var(--fs-body);
    line-height: 20px;
    color: var(--text-primary);
    background: var(--bg-canvas);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: "cv11", "ss01";
}
h1, h2, h3, h4 { font-weight: 600; color: var(--text-primary); }
h2 { font-size: var(--fs-name); line-height: 24px; letter-spacing: -0.015em; }
h3 { font-size: var(--fs-title); line-height: 20px; letter-spacing: -0.005em; }
h4 { font-size: var(--fs-small); line-height: 16px; color: var(--text-secondary); font-weight: 600; margin: 4px 0 8px; }
p { line-height: 20px; }
a { color: var(--text-link); }
strong, b { font-weight: 600; }
code, kbd, pre, samp { font-family: var(--font-mono); }
::selection { background: color-mix(in oklab, var(--accent) 22%, transparent); }
:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--primary); width: 14px; height: 14px; vertical-align: middle; cursor: pointer; }

.icon-svg { width: 16px; height: 16px; flex: 0 0 auto; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

/* ========== Layout ========== */
.layout { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sunken);
    box-shadow: inset -0.5px 0 0 var(--hair-strong);
    height: 100vh; position: fixed; left: 0; top: 0; z-index: 100;
    display: flex; flex-direction: column;
    transition: transform 240ms var(--ease);
}
.sidebar-header { height: var(--topbar-height); padding: 0 14px; display: flex; align-items: center; gap: 8px; }
.sidebar-header h1 { font-size: var(--fs-title); font-weight: 600; letter-spacing: -0.01em; color: var(--text-primary); line-height: 1; }
.sidebar-header .brand-sub { display: block; margin-top: 3px; font-size: var(--fs-caption); line-height: 1; font-weight: 500; color: var(--text-tertiary); }
/* 标识：单色线形，随字色适配深浅色，不带底框 */
.brand-mark { width: 30px; height: 30px; flex: 0 0 auto; color: var(--text-primary); display: grid; place-items: center; }
.brand-mark svg { width: 30px; height: 30px; }

.sidebar-nav { flex: 1; padding: 6px 10px 12px; overflow-y: auto; display: flex; flex-direction: column; gap: 1px; }
.sidebar-nav .nav-group { padding: 14px 8px 6px; font-size: var(--fs-caption); line-height: 16px; font-weight: 600; color: var(--text-tertiary); }
.sidebar-nav a {
    display: flex; align-items: center; gap: 9px;
    height: 30px; padding: 0 8px;
    color: var(--text-secondary); text-decoration: none;
    border-radius: var(--r-control);
    font-weight: 500;
    transition: background-color 120ms, color 120ms;
}
.sidebar-nav a:hover { background: var(--fill-1); color: var(--text-primary); }
.sidebar-nav a.active { background: var(--fill-2); color: var(--text-primary); }
.sidebar-nav .icon { width: 16px; height: 16px; display: grid; place-items: center; color: var(--text-tertiary); }
.sidebar-nav a.active .icon, .sidebar-nav a:hover .icon { color: var(--text-primary); }

.sidebar-footer { padding: 10px; box-shadow: inset 0 0.5px 0 var(--hair); display: flex; align-items: center; gap: 8px; }
.sidebar-user { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; }
.avatar { width: 26px; height: 26px; flex: 0 0 auto; border-radius: 50%; background: var(--fill-2); color: var(--text-secondary); display: grid; place-items: center; font-size: var(--fs-small); font-weight: 600; text-transform: uppercase; }
.sidebar-user .who { min-width: 0; }
.sidebar-user .name { display: block; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user .role { display: block; font-size: var(--fs-caption); line-height: 14px; color: var(--text-tertiary); }

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

/* ========== Topbar ========== */
.topbar {
    height: var(--topbar-height);
    background: color-mix(in oklab, var(--bg-canvas) 86%, transparent);
    -webkit-backdrop-filter: saturate(1.8) blur(16px); backdrop-filter: saturate(1.8) blur(16px);
    box-shadow: inset 0 -0.5px 0 var(--hair);
    display: flex; align-items: center; gap: 12px;
    padding: 0 24px; position: sticky; top: 0; z-index: 50;
}
.topbar-left { display: flex; align-items: center; }
.menu-toggle { display: none; width: 28px; height: 28px; border: 0; border-radius: var(--r-control); background: transparent; color: var(--text-secondary); cursor: pointer; place-items: center; }
.menu-toggle:hover { background: var(--fill-2); color: var(--text-primary); }
.topbar-center { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; }
.org-badge, .team-badge {
    display: inline-flex; align-items: center; gap: 6px;
    height: 24px; padding: 0 9px;
    font-size: var(--fs-small); font-weight: 500; color: var(--text-secondary);
    border-radius: var(--r-control); background: var(--bg-surface); box-shadow: var(--elev-0);
    white-space: nowrap;
}
.org-badge::before, .team-badge::before { content: ""; width: 6px; height: 6px; border-radius: 2px; background: var(--text-tertiary); }
.team-badge::before { border-radius: 50%; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.user-info { color: var(--text-secondary); font-size: var(--fs-small); }

/* ========== Page ========== */
.page { width: 100%; max-width: 1280px; margin: 0 auto; padding: 24px 28px 48px; display: flex; flex-direction: column; gap: 16px; animation: rise 450ms var(--ease) both; }
.page-narrow { max-width: 860px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head .page-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.page-head .page-desc { margin-top: 2px; font-size: var(--fs-small); color: var(--text-tertiary); }
/* 页面标题行右侧的筛选：标签在左，下拉框限宽，组织名过长时由浏览器截断 */
.page-head-filter { display: flex; align-items: center; gap: 8px; }
.page-head-filter label { font-size: var(--fs-small); font-weight: 500; color: var(--text-secondary); white-space: nowrap; }
.page-head-filter select { height: 28px; max-width: 220px; padding: 0 10px; font-size: var(--fs-body); }
/* 工作台可刷新区块的外层容器，不参与布局，避免多出 .page 的间距 */
.dashboard-section { display: contents; }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
@keyframes rise { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ========== Buttons ========== */
/* white-space:nowrap + flex-shrink:0：height 是写死的，文字一旦在窄容器里
   折行（"续签 AT" 这类带空格的最容易中招）就会溢出按钮边框 */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    height: 28px; padding: 0 12px;
    font: inherit; font-size: var(--fs-body); font-weight: 500; line-height: 1;
    border-radius: var(--r-control); border: 0;
    cursor: pointer; text-decoration: none; white-space: nowrap; flex-shrink: 0;
    transition: background-color 120ms, box-shadow 120ms, color 120ms, opacity 120ms;
}
.btn:disabled, .btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: var(--text-on-primary); box-shadow: var(--highlight), 0 1px 2px color-mix(in oklab, var(--ink) 18%, transparent); }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-primary:active:not(:disabled) { background: var(--primary-pressed); }
.btn-default { background: var(--bg-surface); color: var(--text-primary); box-shadow: var(--elev-0); }
.btn-default:hover:not(:disabled) { background: var(--bg-hover); }
.btn-default:active:not(:disabled) { background: var(--bg-pressed); }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover:not(:disabled) { background: var(--fill-2); color: var(--text-primary); }
.btn-danger { background: var(--bg-surface); color: var(--danger-text); box-shadow: var(--elev-0); }
.btn-danger:hover:not(:disabled) { background: var(--danger-bg); }
/* 不可恢复的操作（永久删除）用实心危险色，和普通删除区分开 */
.btn-danger-solid { background: var(--danger-solid); color: #fff; box-shadow: var(--elev-0); }
.btn-danger-solid:hover:not(:disabled) { filter: brightness(0.92); }
.btn-sm { height: 24px; padding: 0 9px; font-size: var(--fs-small); border-radius: 5px; }
.btn-block { width: 100%; height: 34px; }
.btn:focus-visible { outline: none; box-shadow: var(--focus-halo), var(--elev-0); }
/* 请求较慢的按钮（如更新用量）：请求进行中在文字前显示转圈，配合 hx-disabled-elt 防止重复点击 */
.btn-async.htmx-request::before {
    content: ""; width: 10px; height: 10px; border-radius: 50%;
    border: 1.5px solid currentColor; border-right-color: transparent;
    animation: btn-spin 0.7s linear infinite;
}
@keyframes btn-spin { to { transform: rotate(360deg); } }

/* ========== Forms ========== */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; font-size: var(--fs-small); font-weight: 500; color: var(--text-secondary); }
.form-group > div:not(.form-hint) { font-size: var(--fs-body); color: var(--text-primary); }
input[type="text"], input[type="password"], input[type="email"], input[type="number"], input[type="search"], select, textarea {
    font: inherit; font-size: var(--fs-body); color: var(--text-primary);
    background: var(--bg-surface);
    border: 1px solid var(--border-default); border-radius: var(--r-control);
    transition: border-color 120ms, box-shadow 120ms;
}
input::placeholder, textarea::placeholder { color: var(--text-tertiary); }
input:hover, select:hover, textarea:hover { border-color: color-mix(in oklab, var(--border-control) 70%, var(--border-default)); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--focus-ring); box-shadow: var(--focus-halo); }
input[readonly] { background: var(--bg-sunken); color: var(--text-secondary); }
select:disabled, input:disabled { background: var(--bg-sunken); color: var(--text-disabled); cursor: not-allowed; }
select {
    -webkit-appearance: none; appearance: none; cursor: pointer;
    padding-right: 26px !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10' fill='none' stroke='%23666d7a' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 4l2-2 2 2M3 6l2 2 2-2'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 8px center;
}
.form-group input, .form-group select { width: 100%; height: 32px; padding: 0 10px; }
.form-group textarea { width: 100%; padding: 8px 10px; }
.form-hint { margin-top: 6px; font-size: var(--fs-small); line-height: 18px; color: var(--text-tertiary); }
.form-hint-error { color: var(--danger-text); }
.form-hint[hidden] { display: none; }
.form-hint-block { margin-bottom: 16px; padding: 10px 12px; background: var(--bg-sunken); border-radius: var(--r-control); color: var(--text-secondary); }
.form-hint-error { color: var(--danger-text); }
.required-mark { color: var(--danger-solid); }
input:user-invalid { border-color: var(--danger-solid); }
input[type="file"] { font: inherit; font-size: var(--fs-small); color: var(--text-secondary); }
input[type="file"]::file-selector-button {
    font: inherit; font-size: var(--fs-small); font-weight: 500; height: 26px; padding: 0 10px; margin-right: 10px;
    border: 0; border-radius: 5px; background: var(--bg-surface); color: var(--text-primary); box-shadow: var(--elev-0); cursor: pointer;
}

/* ========== Tables ========== */
.table-container { overflow-x: auto; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--fs-body); }
.table th, .table td { padding: 0 12px; height: 40px; text-align: left; vertical-align: middle; border-bottom: 0.5px solid var(--hair); }
.table th:first-child, .table td:first-child { padding-left: 16px; }
.table th:last-child, .table td:last-child { padding-right: 16px; }
.table thead th { height: 34px; background: transparent; font-size: var(--fs-small); font-weight: 500; color: var(--text-tertiary); white-space: nowrap; border-bottom: 0.5px solid var(--hair-strong); }
.table tbody tr { transition: background-color 120ms; }
.table tbody tr:hover { background: var(--fill-1); }
.table tbody tr:last-child td, .table tbody tr:last-child th { border-bottom: 0; }
.table td { color: var(--text-primary); font-variant-numeric: tabular-nums; }
/* 左侧表头的属性表（账号详情）：th 是标签列 */
.table tbody th { font-size: var(--fs-small); font-weight: 500; color: var(--text-secondary); white-space: nowrap; }
/* td 必须留在表格布局里：给它 display:flex 会让该单元格脱离 table-cell，
   行的下边框在这一列断开（凭据健康度页出现过）。这里只排按钮间距，
   按钮本身是 inline-flex，天然横向排布。 */
.table td.actions { white-space: nowrap; }
.table td.actions > * + * { margin-left: 6px; }
.table td.empty, .table td.text-center[colspan] { height: 96px; text-align: center; color: var(--text-tertiary); }
.table-compact th, .table-compact td { height: 34px; font-size: var(--fs-small); }
.table pre { margin: 0; font-size: var(--fs-caption); line-height: 16px; white-space: pre-wrap; word-break: break-all; color: var(--text-secondary); }
.cell-link { padding: 0; font: inherit; font-size: var(--fs-body); font-weight: 500; color: var(--text-primary); background: none; border: none; cursor: pointer; text-align: left; text-decoration: underline; text-decoration-color: var(--hair-strong); text-underline-offset: 3px; }
.cell-link:hover { color: var(--text-link); text-decoration-color: currentColor; }
.mono, .cell-id { font-family: var(--font-mono); font-size: var(--fs-small); color: var(--text-secondary); }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-tertiary); }
.text-warning { color: var(--warning-text); }
.text-danger { color: var(--danger-text); }
.text-success { color: var(--success-text); }
.text-tertiary { color: var(--text-tertiary); }

/* 客户端版本：补充发布页各平台各类型的状态 */
.release-slot { display: inline-block; margin: 2px 12px 2px 0; font-size: var(--fs-small); }
.release-slot-published, .release-slot-withdrawn { color: var(--text-tertiary); }
.release-slot-pending { color: var(--success-text); }
.release-slot-available, .release-slot-missing { color: var(--warning-text); font-weight: 500; }
.release-slot-selected { color: var(--text-link); font-weight: 500; }
.release-checklist { margin-top: 12px; }
.release-checklist-row { display: flex; flex-wrap: wrap; align-items: baseline; padding: 2px 0; }
.release-checklist-platform { width: 140px; flex: none; font-family: var(--font-mono); font-size: var(--fs-small); color: var(--text-secondary); }

/* 客户端版本：批量上传里检查不通过的行标红，只有提醒的行标黄 */
.table tbody tr.row-danger td, .table tbody tr.row-danger:hover td { background: var(--danger-bg); color: var(--danger-text); }
.table tbody tr.row-warning td, .table tbody tr.row-warning:hover td { background: var(--warning-bg); color: var(--warning-text); }

/* 客户端版本：列表里按平台分组的文件，已撤回的置灰划线 */
.release-platform + .release-platform { margin-top: 6px; }
.release-platform-head { display: flex; align-items: center; gap: 8px; }
.release-file { font-size: var(--fs-small); color: var(--text-secondary); }
.release-file.is-withdrawn { color: var(--text-tertiary); text-decoration: line-through; }
.release-file.is-withdrawn .badge { text-decoration: none; }
.release-notes { white-space: pre-wrap; padding: 10px 12px; background: var(--bg-sunken); border-radius: var(--r-control); color: var(--text-secondary); }

/* ========== Badges（状态：圆点 + 中性文字） ========== */
/* nowrap 同 .btn：窄列里「待分配」这类文字会被拆成两行 */
.badge {
    --dot: var(--text-tertiary);
    display: inline-flex; align-items: center; gap: 6px;
    height: 20px; padding: 0 7px 0 6px;
    font-size: var(--fs-small); font-weight: 500; line-height: 1; letter-spacing: 0;
    color: var(--text-secondary);
    border-radius: var(--r-badge); background: var(--fill-1);
    white-space: nowrap; vertical-align: middle;
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--dot); flex: 0 0 auto; }
.badge-success { --dot: var(--success-solid); color: var(--text-primary); }
.badge-warning { --dot: var(--warning-solid); color: var(--text-primary); }
.badge-error { --dot: var(--danger-solid); color: var(--danger-text); }
.badge-info { --dot: var(--accent); color: var(--text-primary); }
.badge-default { --dot: var(--text-disabled); }
/* 标题旁的范围标签（团队页的组织名）：中性胶囊，不带点 */
h2 .badge { height: 22px; padding: 0 8px; font-size: var(--fs-small); background: var(--bg-surface); box-shadow: var(--elev-0); }
h2 .badge::before { display: none; }

/* ========== Cards ========== */
.card { background: var(--bg-surface); border-radius: var(--r-panel); box-shadow: var(--elev-1), var(--highlight); }
.card-header { min-height: 48px; padding: 12px 16px; box-shadow: inset 0 -0.5px 0 var(--hair); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-header h3, .card-header strong { font-size: var(--fs-title); font-weight: 600; }
.card-header .card-sub { font-size: var(--fs-small); color: var(--text-tertiary); font-weight: 400; }
.card-body { padding: 16px; }
.card-flush { overflow: hidden; }
.card-flush > .table-container { margin: 0; }
.card-foot { min-height: 44px; padding: 8px 16px; box-shadow: inset 0 0.5px 0 var(--hair); display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
/* 抽屉里的卡片：浮层上不再叠阴影，只留细线 */
.drawer .card { box-shadow: var(--elev-0); }
/* 抽屉正文本身就是一张浮层，最外层卡片不再画框（账号详情） */
.drawer-body > .card { background: transparent; box-shadow: none; border-radius: 0; }
.drawer-body > .card > .card-header { min-height: 0; padding: 0 0 14px; margin-bottom: 4px; }
.drawer-body > .card > .card-body { padding: 0; }

/* 分区：页面内的一个大块（导入导出页） */
.section { padding: 20px; }
.section + .section { box-shadow: inset 0 0.5px 0 var(--hair); }
.section h3 { margin-bottom: 4px; }
.section .section-desc { margin-bottom: 14px; font-size: var(--fs-small); color: var(--text-tertiary); }
.check-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.check-chip { display: inline-flex; align-items: center; gap: 7px; height: 28px; padding: 0 10px; border-radius: var(--r-control); background: var(--bg-surface); box-shadow: var(--elev-0); font-size: var(--fs-body); cursor: pointer; }
.check-chip:has(input:checked) { box-shadow: 0 0 0 1px var(--border-strong); }
.form-group label.check-inline { display: inline-flex; align-items: center; gap: 7px; margin-bottom: 0; font-size: var(--fs-body); color: var(--text-primary); cursor: pointer; }
.form-group .check-inline input { width: auto; height: auto; padding: 0; margin: 0; }
.field-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin-bottom: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: var(--fs-small); font-weight: 500; color: var(--text-secondary); }
.field select { height: 28px; padding: 0 10px; min-width: 160px; }
.btn-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.btn-row .divider { width: 0.5px; height: 18px; background: var(--hair-strong); margin: 0 4px; }

/* ========== Alerts（页面级提示条） ========== */
.alert { display: block; padding: 10px 12px; border-radius: var(--r-panel); font-size: var(--fs-body); line-height: 20px; margin-bottom: 16px; box-shadow: inset 0 0 0 0.5px var(--alert-border, var(--hair-strong)); background: var(--alert-bg, var(--bg-sunken)); color: var(--alert-text, var(--text-primary)); }
.alert-error { --alert-bg: var(--danger-bg); --alert-border: var(--danger-border); --alert-text: var(--danger-text); }
.alert-success { --alert-bg: var(--success-bg); --alert-border: var(--success-border); --alert-text: var(--success-text); }
.alert-warning { --alert-bg: var(--warning-bg); --alert-border: var(--warning-border); --alert-text: var(--warning-text); }
.alert-info { --alert-bg: var(--accent-subtle); --alert-border: color-mix(in oklab, var(--accent) 22%, transparent); --alert-text: var(--accent-text); }
.alert strong { font-weight: 600; }
.page > .alert { margin-bottom: 0; }

/* ========== 订阅定价卡片 ========== */
/* ---------- 订阅页、确认订单页 ---------- */
.buy-steps { list-style: none; display: grid; grid-template-columns: repeat(4, 1fr); margin: 4px 0 8px; }
.buy-step { position: relative; display: flex; flex-direction: column; align-items: center; gap: 8px; font-size: var(--fs-body); color: var(--text-tertiary); }
.buy-step:not(:last-child)::after { content: ""; position: absolute; top: 9px; left: calc(50% + 16px); right: calc(-50% + 16px); height: 1.5px; background: var(--border-subtle); }
.buy-step.is-done:not(:last-child)::after { background: var(--accent); }
.buy-step-dot { width: 20px; height: 20px; display: grid; place-items: center; border-radius: 50%; color: var(--accent); }
.buy-step-dot::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--text-disabled); }
.buy-step.is-current .buy-step-dot::before { background: var(--accent); box-shadow: 0 0 0 4px var(--accent-subtle); }
.buy-step.is-done .buy-step-dot::before { display: none; }
.buy-step-dot svg { width: 16px; height: 16px; }
.buy-step.is-current, .buy-step.is-done { color: var(--text-primary); font-weight: 500; }
.buy-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 24px; align-items: start; }
.buy-main { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.buy-side { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.buy-hero h1 { font-size: 28px; line-height: 36px; font-weight: 650; letter-spacing: -0.02em; color: var(--text-primary); }
.buy-hero p { margin-top: 6px; font-size: var(--fs-title); line-height: 22px; color: var(--text-secondary); }
.buy-group-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: var(--fs-small); }
.buy-group-head h3 { font-size: var(--fs-small); color: var(--text-secondary); }
.buy-link { font-size: var(--fs-small); font-weight: 500; color: var(--text-primary); text-decoration: none; }
.buy-link:hover { text-decoration: underline; }
.pricing-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.pricing-card .card-body { display: flex; flex-direction: column; gap: 12px; padding: 20px; height: 100%; }
.pricing-card-highlight { box-shadow: 0 0 0 1.5px var(--accent), var(--elev-1); }
.pricing-head { display: flex; align-items: flex-start; gap: 12px; }
.pricing-icon { width: 40px; height: 40px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 10px; background: var(--accent-subtle); color: var(--accent-text); }
.pricing-icon svg { width: 20px; height: 20px; }
.pricing-title { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.pricing-name { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pricing-name h3 { font-size: var(--fs-name); line-height: 24px; }
.pricing-amount { margin-top: 4px; font-size: 32px; line-height: 40px; font-weight: 650; letter-spacing: -0.02em; color: var(--text-primary); }
.pricing-period { margin-left: 6px; font-size: var(--fs-body); font-weight: 400; letter-spacing: 0; color: var(--text-tertiary); }
.pricing-hint { margin-top: -6px; font-size: var(--fs-small); }
.pricing-body { margin-top: 4px; padding-top: 16px; box-shadow: inset 0 0.5px 0 var(--hair); display: flex; flex-direction: column; gap: 12px; }
.pricing-headline { font-size: var(--fs-body); font-weight: 600; color: var(--text-primary); }
.pricing-features { list-style: none; display: flex; flex-direction: column; gap: 10px; font-size: var(--fs-body); line-height: 20px; color: var(--text-secondary); }
.pricing-features li { padding-left: 24px; position: relative; }
.pricing-features li::before { content: ""; position: absolute; left: 0; top: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--success-solid) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4.5 8.2l2.3 2.3 4.7-5' fill='none' stroke='white' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 12px no-repeat; }
.recent-orders { list-style: none; }
.recent-orders li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; box-shadow: inset 0 -0.5px 0 var(--hair); }
.recent-order-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; font-size: var(--fs-small); }
.recent-order-main .cell-link { font-family: var(--font-mono); font-size: var(--fs-small); overflow: hidden; text-overflow: ellipsis; }
.recent-order-side { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; font-size: var(--fs-body); }
.confirm-body { display: flex; flex-direction: column; gap: 16px; }
.confirm-body .alert { margin-bottom: 0; }
.confirm-body .form-group { margin-bottom: 0; }
.confirm-body input[type="number"] { width: 120px; }
.confirm-owner { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: var(--r-panel); box-shadow: inset 0 0 0 0.5px var(--hair-strong); }
.confirm-owner strong { font-size: var(--fs-title); font-weight: 600; }
.confirm-owner p { margin-top: 2px; font-size: var(--fs-small); }
.confirm-body .form-hint { display: block; }
.confirm-form [hidden] { display: none !important; }
.confirm-renew input[type="checkbox"] { width: 16px; height: 16px; padding: 0; flex: 0 0 auto; }
.form-group label.confirm-renew { display: inline-flex; align-items: center; gap: 8px; margin-bottom: 0; font-size: var(--fs-body); font-weight: 500; color: var(--text-primary); cursor: pointer; }
.confirm-summary { padding: 8px 16px; box-shadow: inset 0 -0.5px 0 var(--hair); }
.confirm-summary > div { display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 12px; padding: 8px 0; font-size: var(--fs-body); }
.confirm-summary dt { color: var(--text-tertiary); }
.confirm-summary dd { color: var(--text-primary); text-align: right; overflow-wrap: anywhere; }
.confirm-due > div { font-size: var(--fs-title); font-weight: 600; }
.confirm-due dt { color: var(--text-primary); }
.confirm-notes { padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.confirm-notes h4 { margin: 0; }
.confirm-notes ul { list-style: disc; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; font-size: var(--fs-small); line-height: 18px; color: var(--text-secondary); }
.confirm-notes .btn { margin-top: 6px; height: 38px; }

/* ========== 套餐编辑页 ========== */
.plan-editor-back { display: inline-block; margin-bottom: 4px; font-size: var(--fs-small); font-weight: 500; color: var(--text-tertiary); text-decoration: none; }
.plan-editor-back:hover { color: var(--text-primary); }
.plan-editor-page .page-title { flex-direction: column; align-items: flex-start; gap: 0; }
.plan-editor { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 24px; align-items: start; }
.plan-editor-form .section h3 { margin-bottom: 14px; }
.plan-editor-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.plan-editor-section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 4px; }
.plan-editor-form .plan-editor-section-head h3 { margin-bottom: 0; }
.plan-lang-tabs { display: inline-flex; gap: 2px; padding: 2px; border-radius: var(--r-control); background: var(--fill-2); }
.plan-lang-tab { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 12px; border: 0; border-radius: 5px; background: transparent; font: inherit; font-size: var(--fs-small); font-weight: 500; color: var(--text-secondary); cursor: pointer; }
.plan-lang-tab:hover { color: var(--text-primary); }
.plan-lang-tab.is-active { background: var(--bg-surface); color: var(--text-primary); box-shadow: var(--elev-0); }
.plan-lang-dot { width: 6px; height: 6px; border-radius: 50%; box-shadow: inset 0 0 0 1px var(--text-disabled); }
.plan-lang-tab.is-filled .plan-lang-dot { background: var(--success-solid); box-shadow: none; }
.plan-lang-panel[hidden] { display: none; }
.plan-editor-form textarea { resize: vertical; line-height: 20px; }
.plan-editor-actions { position: sticky; bottom: 0; display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-radius: 0 0 var(--r-panel) var(--r-panel); background: var(--bg-surface); box-shadow: inset 0 0.5px 0 var(--hair); }
.plan-editor-preview { position: sticky; top: 72px; max-height: calc(100vh - 88px); overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.plan-editor-preview-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; font-size: var(--fs-small); }
.plan-editor-preview-head h4 { margin: 0; }
.plan-editor-preview .pricing-card [hidden] { display: none; }
.plan-editor-preview .pricing-name h3.is-placeholder { color: var(--text-disabled); }
.plan-editor-preview [data-pv="buy"] { pointer-events: none; }
@media (max-width: 1023px) {
    .buy-layout { grid-template-columns: minmax(0, 1fr); }
    .plan-editor { grid-template-columns: minmax(0, 1fr); }
    .plan-editor-preview { position: static; max-height: none; overflow: visible; }
}
@media (max-width: 768px) {
    .buy-step-label { display: none; }
    .buy-step.is-current .buy-step-label { display: block; }
    .buy-hero h1 { font-size: 22px; line-height: 30px; }
    .pricing-grid { grid-template-columns: minmax(0, 1fr); }
    .plan-editor-grid { grid-template-columns: minmax(0, 1fr); }
}

/* ========== Toast ========== */
.toast-container { position: fixed; top: 12px; left: 50%; transform: translateX(-50%); z-index: 1100; display: flex; flex-direction: column; align-items: center; gap: 8px; max-width: calc(100vw - 32px); pointer-events: none; }
.toast {
    --toast-bg: var(--bg-raised); --toast-text: var(--text-primary);
    display: flex; justify-content: center; text-align: center;
    min-width: 280px; max-width: 400px; padding: 12px 16px;
    border-radius: var(--r-float); background: var(--toast-bg); color: var(--toast-text);
    font-weight: 500; line-height: 20px;
    box-shadow: 0 1px 2px color-mix(in oklab, var(--ink) 6%, transparent), 0 14px 34px -10px color-mix(in oklab, var(--ink) 24%, transparent);
    animation: toastIn 240ms var(--ease);
    pointer-events: auto;
}
.dark .toast { box-shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 16px 40px -10px rgb(0 0 0 / 0.75); }
.toast.success { --toast-bg: var(--success-bg); --toast-text: var(--success-text); }
.toast.error { --toast-bg: var(--danger-bg); --toast-text: var(--danger-text); }
.toast.warning { --toast-bg: var(--warning-bg); --toast-text: var(--warning-text); }
@keyframes toastIn { from { transform: translateY(-6px) scale(0.98); opacity: 0; } to { transform: none; opacity: 1; } }
/* console.js 收起时用 slideIn reverse，保留这个名字 */
@keyframes slideIn { from { transform: translateY(-6px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ========== Login Page（风格参照产品主页 clauve.cc：固定浅色、品牌蓝配青绿、白卡片、淡晕染背景） ========== */
.lp {
    --lp-canvas: #f5fafc; --lp-surface: #ffffff; --lp-paper: #f0f6fa;
    --lp-line: #e1e9f0; --lp-line-soft: #edf2f6;
    --lp-ink: #0f1d33; --lp-ink-2: #2b3a52; --lp-ink-3: #4a5970; --lp-ink-4: #5d6a7e; --lp-ink-5: #9aa6b6;
    --lp-brand-50: #eff5ff; --lp-brand-100: #dce8fe; --lp-brand-200: #bfd5fd;
    --lp-brand-400: #6b9bf7; --lp-brand-500: #3d7bf2; --lp-brand-600: #2f68e0;
    --lp-mint-50: #ecfdf8; --lp-aqua-500: #06b6d4;
    --lp-shadow-card: 0 1px 2px rgba(15, 29, 51, 0.04), 0 12px 32px -12px rgba(30, 72, 140, 0.18);
    /* 页面固定浅色，提示框颜色不跟随系统深色外观 */
    --danger-bg: #fdf2f1; --danger-border: #f3d6d3; --danger-text: #9f2525;
    --success-bg: #f1f8f4; --success-border: #dcebe2; --success-text: #12663a;
    min-height: 100vh; display: flex; flex-direction: column; color: var(--lp-ink); color-scheme: light; -webkit-font-smoothing: antialiased;
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
    background:
        radial-gradient(60% 50% at 0% 0%, rgba(167, 243, 220, 0.35), transparent 70%),
        radial-gradient(55% 45% at 100% 0%, rgba(191, 213, 253, 0.45), transparent 70%),
        radial-gradient(50% 40% at 50% 100%, rgba(165, 240, 252, 0.25), transparent 70%),
        var(--lp-canvas);
}
.lp-frame { max-width: 1200px; margin: 0 auto; padding: 0 16px; }
.lp-top { position: sticky; top: 0; z-index: 5; height: 60px; border-bottom: 1px solid rgba(255, 255, 255, 0.6); background: rgba(255, 255, 255, 0.85); box-shadow: 0 1px 0 rgba(15, 29, 51, 0.04); backdrop-filter: blur(24px); }
.lp-top-inner { height: 100%; display: flex; align-items: center; justify-content: space-between; }
.lp-logo { display: inline-flex; align-items: center; gap: 8px; color: var(--lp-ink); font-size: 17px; font-weight: 700; letter-spacing: -0.025em; text-decoration: none; }
.lp-logo .brand-mark { color: var(--lp-ink); }
.lp-logo .brand-mark, .lp-logo .brand-mark svg { width: 26px; height: 26px; display: block; }
.lp-top-right { display: flex; align-items: center; gap: 16px; }
.lp-top-link { font-size: 14px; font-weight: 500; color: var(--lp-ink-3); text-decoration: none; transition: color 150ms; }
.lp-top-link:hover { color: var(--lp-brand-600); }
.lp .lang-switch select { background: rgba(255, 255, 255, 0.8); color: var(--lp-ink-2); border: 1px solid var(--lp-line); border-radius: 9999px; padding: 0 10px; }
.lp-main { flex: 1; width: 100%; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 420px); gap: 72px; align-items: center; align-content: center; padding-top: 48px; padding-bottom: 48px; }
.lp-foot { border-top: 1px solid var(--lp-line); background: rgba(255, 255, 255, 0.5); }
.lp-foot-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; height: 56px; font-size: 12.5px; color: var(--lp-ink-5); }
.lp-foot-links { display: flex; gap: 20px; }
.lp-foot-links a { color: var(--lp-ink-4); text-decoration: none; transition: color 150ms; }
.lp-foot-links a:hover { color: var(--lp-brand-600); }
/* 和主页分区标签一样的胶囊：半透明白底、品牌色细边 */
.lp-badge { display: inline-block; padding: 4px 14px; border: 1px solid var(--lp-brand-100); border-radius: 9999px; background: rgba(255, 255, 255, 0.8); font-size: 13.5px; font-weight: 600; color: var(--lp-ink-2); box-shadow: 0 4px 16px -8px rgba(61, 123, 242, 0.35); }
.lp-brand h1 { margin: 24px 0 16px; font-size: 40px; line-height: 1.15; font-weight: 800; letter-spacing: -0.025em; color: var(--lp-ink); }
.lp-lead { font-size: 15px; line-height: 1.625; color: var(--lp-ink-3); max-width: 460px; }
.lp-highlights { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 28px; max-width: 620px; }
.lp-highlight { display: flex; gap: 12px; padding: 16px; border-radius: 16px; border: 1px solid var(--lp-line); background: var(--lp-surface); }
.lp-hl-icon { flex: 0 0 auto; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: linear-gradient(to bottom right, var(--lp-brand-50), var(--lp-mint-50)); color: var(--lp-brand-600); box-shadow: inset 0 0 0 1px var(--lp-brand-100); }
.lp-hl-icon svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.lp-hl-title { font-size: 15px; font-weight: 600; color: var(--lp-ink); }
.lp-hl-desc { margin-top: 4px; font-size: 13px; line-height: 1.625; color: var(--lp-ink-4); }
.lp-side { display: grid; gap: 16px; width: 100%; max-width: 420px; justify-self: end; }
.lp-card-note { margin: 16px 0 0; font-size: 12.5px; color: var(--lp-ink-4); text-align: center; }
.lp-card { background: var(--lp-surface); border: 1px solid var(--lp-line); border-radius: 16px; padding: 28px; box-shadow: var(--lp-shadow-card); }
.lp-card h2 { font-size: 20px; font-weight: 700; color: var(--lp-ink); margin: 0 0 4px; }
.lp-card-sub { font-size: 13px; color: var(--lp-ink-4); margin: 0 0 20px; }
.lp-form { display: flex; flex-direction: column; }
.lp-form label { font-size: 13px; font-weight: 500; color: var(--lp-ink-3); margin: 0 0 6px; }
.lp-form input { height: 40px; margin-bottom: 14px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--lp-line); background: var(--lp-surface); color: var(--lp-ink); font-size: 14px; outline: none; }
.lp-form input:focus { border-color: var(--lp-brand-400); box-shadow: 0 0 0 3px rgba(61, 123, 242, 0.15); }
/* 主页 btn-primary 同款：品牌蓝到青色渐变的圆角按钮 */
.lp-btn-primary { height: 42px; margin-top: 6px; border: 0; border-radius: 9999px; background: linear-gradient(to right, var(--lp-brand-500), var(--lp-brand-500), var(--lp-aqua-500)); color: #fff; font-size: 15px; font-weight: 600; cursor: pointer; box-shadow: 0 8px 24px -8px rgba(61, 123, 242, 0.65); transition: transform 200ms, box-shadow 200ms; }
.lp-btn-primary:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 14px 32px -10px rgba(61, 123, 242, 0.7); }
/* 请求进行中按钮被 hx-disabled-elt 禁用，防止重复提交 */
.lp-btn-primary:disabled { opacity: 0.6; cursor: wait; }
.lp .alert { margin-bottom: 16px; }
.lp-main-single { grid-template-columns: minmax(0, 420px); justify-content: center; }
.lp-card-note a { color: var(--lp-brand-600); text-decoration: none; }
.lp-card-note a:hover { text-decoration: underline; }
.lp-forgot { align-self: flex-end; margin: -6px 0 8px; font-size: 12.5px; color: var(--lp-brand-600); text-decoration: none; }
.lp-forgot:hover { text-decoration: underline; }
.lp-hint { margin: -8px 0 14px; font-size: 12px; color: var(--lp-ink-4); }
.lp-hint-error { color: var(--danger-text); }
.lp-hint[hidden] { display: none; }
.lp-code-row { display: flex; gap: 8px; }
.lp-code-row input { flex: 1; min-width: 0; }
.lp-btn-secondary { height: 40px; padding: 0 16px; border-radius: 9999px; border: 1px solid var(--lp-line); background: rgba(255, 255, 255, 0.8); color: var(--lp-ink); font-size: 13px; font-weight: 500; white-space: nowrap; cursor: pointer; transition: border-color 150ms, color 150ms; }
.lp-btn-secondary:hover:not(:disabled) { color: var(--lp-brand-600); border-color: var(--lp-brand-200); }
.lp-btn-secondary:disabled { opacity: 0.6; cursor: default; }
.lp-btn-secondary.htmx-request { cursor: wait; }
@media (max-width: 1023px) {
    .lp-main { grid-template-columns: minmax(0, 1fr); gap: 24px; padding-top: 32px; }
    .lp-side { max-width: none; justify-self: stretch; }
    .lp-card { padding: 20px; }
    .lp-brand h1 { font-size: 30px; margin-top: 16px; }
    .lp-highlights { display: none; }
}
.lang-switch { display: inline; margin: 0; }
.lang-switch select { height: 26px; padding: 0 8px; font-size: var(--fs-small); font-weight: 500; color: var(--text-secondary); border: 0; border-radius: var(--r-control); background-color: var(--bg-surface); box-shadow: var(--elev-0); }
.lang-switch select:hover { color: var(--text-primary); }
.lang-switch select:focus { box-shadow: var(--focus-halo), var(--elev-0); }

/* Auth Tabs（分段控件） */
.auth-tabs { display: flex; gap: 2px; margin-bottom: 24px; padding: 2px; background: var(--fill-2); border-radius: 7px; }
.auth-tab { flex: 1; height: 26px; border: 0; background: transparent; border-radius: 5px; font: inherit; font-size: var(--fs-body); font-weight: 500; color: var(--text-secondary); cursor: pointer; transition: background-color 120ms, color 120ms; }
.auth-tab:hover { color: var(--text-primary); }
.auth-tab.active { background: var(--bg-surface); color: var(--text-primary); box-shadow: var(--elev-0); }
.auth-switch { text-align: center; font-size: var(--fs-body); color: var(--text-secondary); margin-top: 16px; }
.auth-switch a { color: var(--text-primary); font-weight: 500; cursor: pointer; }
.auth-error { font-size: var(--fs-small); color: var(--danger-text); margin-top: -8px; }

/* ========== Dashboard KPI 条 ========== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); background: var(--bg-surface); border-radius: var(--r-panel); box-shadow: var(--elev-1), var(--highlight); overflow: hidden; }
.stat-card { position: relative; padding: 16px 18px 18px; min-height: 116px; display: flex; flex-direction: column; box-shadow: -0.5px 0 0 var(--hair), 0 -0.5px 0 var(--hair); }
.stat-card .label { font-size: var(--fs-small); font-weight: 500; color: var(--text-secondary); margin-bottom: 10px; display: flex; align-items: center; gap: 6px; }
.stat-card .value { font-size: var(--fs-display); line-height: 30px; font-weight: 600; letter-spacing: -0.025em; color: var(--text-primary); font-variant-numeric: tabular-nums; }
.stat-card .value .unit { font-size: var(--fs-title); font-weight: 500; letter-spacing: 0; color: var(--text-tertiary); margin-left: 2px; }
.stat-card .value .of { font-size: var(--fs-name); font-weight: 500; letter-spacing: -0.01em; color: var(--text-tertiary); }
.stat-card .sub { font-size: var(--fs-small); color: var(--text-tertiary); margin-top: auto; padding-top: 8px; }
.stat-card .meter { margin-top: 10px; }
.stat-card.is-alert .value { color: var(--danger-text); }
.meter { height: 4px; border-radius: 2px; background: var(--fill-2); overflow: hidden; }
.meter > i { display: block; height: 100%; border-radius: 2px; background: color-mix(in oklab, var(--text-primary) 78%, transparent); }
.usage-rows { display: flex; flex-direction: column; gap: 8px; }
.usage-row { display: grid; grid-template-columns: 22px 1fr auto; align-items: center; gap: 10px; }
.usage-row .k { font-size: var(--fs-small); font-weight: 500; color: var(--text-tertiary); font-family: var(--font-mono); }
.usage-row .v { font-size: var(--fs-name); font-weight: 600; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; min-width: 52px; text-align: right; }
.usage-row .v small { font-size: var(--fs-small); font-weight: 500; color: var(--text-tertiary); margin-left: 1px; }
/* 趋势图时间选择器：触发按钮 + 弹出面板（左侧绝对时间、右侧快速选择、底部时区） */
.chart-range-bar { display: flex; align-items: center; gap: 8px; }
.time-picker { position: relative; }
.time-picker-trigger { display: inline-flex; align-items: center; gap: 6px; }
.time-picker-trigger svg { width: 15px; height: 15px; flex: none; }
.time-picker-trigger .time-picker-chevron { width: 13px; height: 13px; color: var(--text-tertiary); transition: transform 120ms; }
.time-picker-trigger[aria-expanded="true"] .time-picker-chevron { transform: rotate(180deg); }
/* 刷新按钮只放图标；自动刷新关闭时下拉按钮只显示箭头 */
.refresh-picker { position: relative; display: flex; align-items: center; gap: 2px; }
.refresh-btn { display: inline-grid; place-items: center; padding-left: 8px; padding-right: 8px; }
.refresh-btn svg { width: 15px; height: 15px; }
.refresh-btn.is-loading svg { animation: btn-spin 0.8s linear infinite; }
.refresh-interval-label:empty { display: none; }
.refresh-menu { position: absolute; top: calc(100% + 6px); right: 0; z-index: 60; min-width: 96px; background: var(--bg-raised, var(--bg-surface)); border-radius: var(--r-float); box-shadow: var(--elev-3); }
.refresh-menu[hidden] { display: none; }
.time-picker-panel { position: absolute; top: calc(100% + 6px); right: 0; z-index: 60; display: grid; grid-template-columns: 300px 200px; background: var(--bg-raised, var(--bg-surface)); border-radius: var(--r-float); box-shadow: var(--elev-3); }
.time-picker-panel[hidden] { display: none; }
.time-picker-panel { scroll-margin: 16px; }
.time-picker-abs { display: flex; flex-direction: column; gap: 6px; padding: 16px; box-shadow: inset -0.5px 0 0 var(--hair); }
.time-picker-title { margin-bottom: 4px; font-size: var(--fs-name); font-weight: 600; color: var(--text-primary); }
.time-picker-abs label { margin-top: 4px; font-size: var(--fs-caption); font-weight: 500; color: var(--text-secondary); }
.time-picker-field { position: relative; display: flex; }
.time-picker-field input[type="text"] { flex: 1; min-width: 0; height: 32px; padding: 0 10px; border-radius: var(--r-control) 0 0 var(--r-control); font-family: var(--font-mono); font-size: var(--fs-small); }
.time-picker-field input.is-invalid { border-color: var(--danger-border); }
.time-picker-cal { display: grid; place-items: center; width: 34px; margin-left: -1px; border: 1px solid var(--border-default); border-radius: 0 var(--r-control) var(--r-control) 0; background: var(--fill-1); color: var(--text-secondary); cursor: pointer; }
.time-picker-cal:hover { background: var(--fill-2); color: var(--text-primary); }
.time-picker-cal svg { width: 15px; height: 15px; }
.time-picker-error { font-size: var(--fs-caption); color: var(--danger-text); }
.time-picker-abs .btn { margin-top: 8px; }
.time-picker-help { margin: 8px 0 0; font-size: var(--fs-small); line-height: 1.6; color: var(--text-tertiary); }
.time-picker-quick { margin: 0; padding: 6px 0; list-style: none; max-height: 340px; overflow-y: auto; }
.time-picker-quick button { display: block; width: 100%; padding: 8px 16px; border: 0; background: none; text-align: left; font: inherit; font-size: var(--fs-body); color: var(--text-primary); cursor: pointer; }
.time-picker-quick button:hover { background: var(--bg-hover); }
.time-picker-quick button.is-active { background: var(--bg-selected); color: var(--accent-text); font-weight: 500; }
.time-picker-footer { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; padding: 10px 16px; box-shadow: inset 0 0.5px 0 var(--hair); font-size: var(--fs-small); color: var(--text-secondary); }
.time-picker-footer > span:first-child { font-weight: 500; color: var(--text-primary); }
.time-picker-tz { margin-left: auto; padding: 2px 8px; border-radius: var(--r-badge); background: var(--fill-2); font-family: var(--font-mono); }
.time-picker-tz-editor { grid-column: 1 / -1; padding: 0 16px 14px; }
.time-picker-tz-editor[hidden] { display: none; }
.time-picker-tz-combo { position: relative; }
.time-picker-tz-combo input { width: 100%; height: 32px; padding: 0 10px 0 30px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238e95a2' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: 10px center; }
/* 时区列表展开在面板底部时区行的下面，面板随之变高 */
.time-picker-tz-list { margin: 6px 0 0; padding: 0; list-style: none; max-height: 240px; overflow-y: auto; }
.time-picker-tz-list[hidden] { display: none; }
.time-picker-tz-group { padding: 10px 8px 4px; font-size: var(--fs-caption); font-weight: 500; color: var(--text-tertiary); }
.time-picker-tz-option { display: flex; align-items: baseline; gap: 8px; padding: 7px 8px; border-radius: var(--r-control); cursor: pointer; }
.time-picker-tz-option:hover, .time-picker-tz-option.is-active { background: var(--bg-hover); }
.time-picker-tz-option.is-current { background: var(--bg-selected); }
.time-picker-tz-option-name { font-size: var(--fs-body); color: var(--text-primary); white-space: nowrap; }
.time-picker-tz-option-detail { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs-small); color: var(--text-tertiary); }
.time-picker-tz-option .time-picker-tz { margin-left: 0; flex: none; align-self: center; }
/* 日历弹层：显示在时间选择面板左侧 */
.time-picker-calendar { position: absolute; top: calc(100% + 6px); right: calc(500px + 8px); z-index: 60; width: 260px; padding: 12px; background: var(--bg-raised, var(--bg-surface)); border-radius: var(--r-float); box-shadow: var(--elev-3); }
.time-picker-calendar[hidden] { display: none; }
.time-picker-calendar.is-inside { right: 200px; width: 300px; z-index: 61; box-shadow: var(--elev-3), 0 0 0 0.5px var(--hair); }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cal-title { font-weight: 600; color: var(--text-primary); }
.cal-nav { display: grid; place-items: center; width: 28px; height: 28px; border: 0; border-radius: var(--r-control); background: transparent; color: var(--text-secondary); cursor: pointer; }
.cal-nav:hover { background: var(--fill-2); color: var(--text-primary); }
.cal-nav svg { width: 16px; height: 16px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-weekday { padding: 4px 0; text-align: center; font-size: var(--fs-caption); color: var(--text-tertiary); }
.cal-day { height: 30px; border: 0; border-radius: var(--r-control); background: transparent; font: inherit; font-size: var(--fs-small); font-variant-numeric: tabular-nums; color: var(--text-primary); cursor: pointer; }
.cal-day:hover:not(:disabled) { background: var(--bg-hover); }
.cal-day.is-today { font-weight: 600; color: var(--accent-text); }
.cal-day.is-selected { background: var(--primary); color: var(--text-on-primary); }
.cal-day:disabled { color: var(--text-disabled); cursor: default; }
.cal-time { display: flex; align-items: center; gap: 8px; margin-top: 10px; padding-top: 10px; box-shadow: inset 0 0.5px 0 var(--hair); }
.cal-time label { font-size: var(--fs-caption); color: var(--text-secondary); }
.cal-time input { flex: 1; height: 30px; padding: 0 8px; font: inherit; font-size: var(--fs-body); color: var(--text-primary); background: var(--bg-surface); border: 1px solid var(--border-default); border-radius: var(--r-control); }
.cal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.time-picker-tz-error { grid-column: 1 / -1; padding: 0 16px 12px; margin-top: -4px; }
.time-picker-tz-error[hidden] { display: none; }
/* 图表框选放大：选区按 Chart.js 绘图区的像素位置绝对定位 */
.chart-zoom-area { position: relative; cursor: crosshair; user-select: none; }
.chart-selection { position: absolute; display: none; pointer-events: none; background: rgba(37,99,235,0.12); border-left: 1px solid rgba(37,99,235,0.5); border-right: 1px solid rgba(37,99,235,0.5); }
/* 工作台两张卡片并排，窄屏时上下排列 */
.dashboard-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: stretch; }
@media (max-width: 900px) { .dashboard-pair { grid-template-columns: minmax(0, 1fr); } }
/* 用户多时列表在卡片内滚动，大约显示 10 行 */
#usage-cost-summary-body .usage-rows { max-height: 300px; overflow-y: auto; padding-right: 4px; }
#usage-cost-summary-body .usage-row { grid-template-columns: 96px 1fr auto; }
#usage-cost-summary-body .usage-row .k { font-family: inherit; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 32px 16px; text-align: center; color: var(--text-tertiary); }
.empty-state .empty-icon { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--success-bg); color: var(--success-solid); margin-bottom: 4px; }
.empty-state .empty-title { color: var(--text-primary); font-weight: 500; }

/* ========== Pagination ========== */
.pagination { display: flex; align-items: center; justify-content: flex-end; gap: 12px; margin-top: 0; font-size: var(--fs-small); color: var(--text-tertiary); font-variant-numeric: tabular-nums; }
.pagination .page-total { white-space: nowrap; }
.pagination .page-numbers { display: flex; align-items: center; gap: 4px; }
/* 数字页码、省略号、上下页箭头共用的方块基础样式 */
.pagination .page-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 24px; height: 24px; padding: 0; border-radius: var(--r-control);
    border: 1px solid var(--hair); background: var(--bg-surface); color: var(--text-secondary);
    font-size: var(--fs-small); line-height: 1; cursor: pointer;
}
.pagination .page-btn:hover:not(:disabled):not(.is-ellipsis) { border-color: var(--primary); color: var(--primary); }
.pagination .page-btn:disabled { color: var(--text-tertiary); opacity: 0.4; cursor: not-allowed; }
.pagination .page-btn.is-current { background: var(--primary); border-color: var(--primary); color: var(--text-on-primary); cursor: default; }
.pagination .page-btn.is-ellipsis { border-color: transparent; background: transparent; cursor: default; }
.pagination .page-size-select { height: 24px; padding: 0 8px; font-size: var(--fs-small); border-radius: var(--r-control); }
.pagination .page-jump { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.pagination .page-jump input {
    width: 44px; height: 24px; padding: 0 6px; text-align: center;
    border-radius: var(--r-control); border: 1px solid var(--hair); font-size: var(--fs-small);
}

/* ========== Filter Bar（表格上方的筛选行） ========== */
.filter-bar { display: flex; flex-wrap: wrap; gap: 10px; padding: 12px 16px; background: transparent; box-shadow: inset 0 -0.5px 0 var(--hair); margin-bottom: 0; align-items: flex-end; }
.filter-item { display: flex; flex-direction: column; gap: 5px; min-width: 150px; }
.filter-item label { font-size: var(--fs-caption); line-height: 14px; font-weight: 500; color: var(--text-tertiary); }
.filter-item input, .filter-item select { height: 28px; padding: 0 10px; font-size: var(--fs-body); }
.filter-item input[name="keyword"] { min-width: 220px; padding-left: 28px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238e95a2' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: 9px center; }
/* 独立成卡片的筛选条（不在表格卡片内） */
.page > .filter-bar { background: var(--bg-surface); border-radius: var(--r-panel); box-shadow: var(--elev-1), var(--highlight); }
/* 批量操作条：选中计数 + 动作 */
.batch-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: var(--fs-small); color: var(--text-secondary); }
.batch-bar #selected-count { font-weight: 600; color: var(--text-primary); font-variant-numeric: tabular-nums; }
.batch-bar form { display: inline-flex; }

/* 表格卡片底栏里的批量操作：沿用 filter-bar 类名（见 accounts/list.html），这里去掉筛选条的外观 */
.filter-bar.batch-bar { padding: 0; box-shadow: none; align-items: center; gap: 6px; }
.card-foot .pagination { margin-left: auto; }
.usage-cell { display: inline-flex; align-items: center; gap: 8px; min-width: 92px; }
.usage-cell .num { min-width: 34px; }
.usage-cell .meter { width: 44px; height: 3px; }
.person { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; }
.avatar-sm { width: 22px; height: 22px; font-size: var(--fs-caption); }
.dry-run-result { margin-top: 16px; padding: 14px 16px; border-radius: var(--r-panel); background: var(--bg-sunken); }
.dry-run-result p { margin-bottom: 4px; }

/* ========== Drawer ========== */
.drawer-overlay { position: fixed; inset: 0; background: color-mix(in oklab, var(--ink) 28%, transparent); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); z-index: 1000; display: none; animation: fadeIn 160ms ease both; }
.drawer-overlay.open { display: block; }
.drawer {
    position: fixed; top: 8px; right: 8px; bottom: 8px; width: 560px; max-width: calc(100% - 16px);
    background: var(--bg-raised); z-index: 1001;
    border-radius: var(--r-float); box-shadow: var(--elev-3);
    display: none; flex-direction: column; overflow: hidden;
}
.drawer.open { display: flex; animation: drawerIn 260ms var(--ease) both; }
.drawer.drawer-wide { width: 760px; }
/* 坐席账号详情的租约表列多，设备一栏还要放设备名称，默认宽度放不下 */
.drawer:has(.account-detail) { width: 760px; }
.lease-device-name { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drawer-header { height: 52px; flex: 0 0 auto; padding: 0 12px 0 20px; box-shadow: inset 0 -0.5px 0 var(--hair); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.drawer-header h3 { font-size: var(--fs-title); font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drawer-close { width: 28px; height: 28px; flex: 0 0 auto; display: grid; place-items: center; background: none; border: none; border-radius: var(--r-control); font-size: 18px; line-height: 1; cursor: pointer; color: var(--text-tertiary); }
.drawer-close:hover { background: var(--fill-2); color: var(--text-primary); }
.drawer-body { flex: 1; overflow-y: auto; padding: 20px; }
/* 表单里的 drawer-footer 吸在抽屉底部 */
.drawer-footer { position: sticky; bottom: -20px; margin: 24px -20px -20px; padding: 12px 20px; background: color-mix(in oklab, var(--bg-raised) 92%, transparent); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); box-shadow: inset 0 0.5px 0 var(--hair); display: flex; justify-content: flex-end; gap: 8px; }
.drawer-body .card + h4, .drawer-body h4 + .table, .drawer-body form + h4 { margin-top: 16px; }
.drawer-body h4 { margin-top: 16px; }
.drawer-body .card-body > h4:first-child { margin-top: 0; }
.drawer-body .table { border-radius: var(--r-control); box-shadow: 0 0 0 0.5px var(--hair-strong); }
/* 抽屉里的宽表格会横向滚动，操作列固定在右侧，按钮始终可见 */
.table-sticky-actions .sticky-col { position: sticky; right: 0; background: var(--bg-raised); box-shadow: inset 0.5px 0 0 var(--hair); }
.drawer-body .table th:first-child, .drawer-body .table td:first-child { padding-left: 12px; }
.drawer-body .table select { height: 26px; padding: 0 8px; }
.secret-box { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border-radius: var(--r-control); background: var(--bg-sunken); font-family: var(--font-mono); font-size: var(--fs-title); letter-spacing: 0.02em; color: var(--text-primary); user-select: all; }
@keyframes drawerIn { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ========== Responsive ========== */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); box-shadow: var(--elev-3); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .menu-toggle { display: grid; }
    .topbar { padding: 0 12px; }
    .user-info { display: none; }
    .page { padding: 16px 12px 32px; }
    .drawer { top: 0; right: 0; bottom: 0; width: 100%; max-width: 100%; border-radius: 0; }
}

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

/* ========== Utility ========== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-secondary { color: var(--text-tertiary); }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.ml-8 { margin-left: 8px; }
.d-flex { display: flex; }
.justify-between { justify-content: space-between; }
.align-center { align-items: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
/* 粘贴 JSON 的输入框 */
.code-textarea {
    width: 100%;
    font-family: var(--font-mono);
    font-size: var(--fs-small);
    line-height: 18px;
    padding: 10px 12px;
    background: var(--bg-sunken);
    resize: vertical;
    white-space: pre;
    overflow-wrap: normal;
    overflow-x: auto;
}
.code-textarea:focus { background: var(--bg-surface); }
.code-textarea::placeholder {
    font-family: var(--font-sans);
    font-size: var(--fs-small);
    line-height: 1.6;
    color: var(--text-tertiary);
    white-space: pre-wrap;
}

/* 坐席账号按邮箱分组：折叠行可点击展开，明细子表的行可点击打开详情 */
.table th.sortable { cursor: pointer; user-select: none; }
.table th.sortable:hover, .table th.sortable.sorted { color: var(--text-primary); }
.sort-arrow { display: inline-block; min-width: 1em; margin-left: 2px; }
.group-row { cursor: pointer; }
.group-cell { display: inline-flex; align-items: center; gap: 8px; }
.group-caret { width: 0; height: 0; border-top: 4px solid transparent; border-bottom: 4px solid transparent; border-left: 5px solid var(--text-tertiary); transition: transform 120ms; }
.group-row.expanded .group-caret { transform: rotate(90deg); }
.group-email { font-weight: 500; margin-right: 6px; }
.table tbody tr.group-detail:hover { background: transparent; }
.group-detail > td { padding: 0 0 0 28px; background: var(--fill-1); }
.table.subtable thead th { height: 30px; }
.subtable .account-row { cursor: pointer; }
.table.subtable tbody tr.account-row:hover { background: var(--fill-2); }
