/* 通用组件 */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-head { display: flex; align-items: center; gap: 12px; padding: 15px 18px; border-bottom: 1px solid var(--line-soft); flex-wrap: wrap; }
.card-head h3 { font-size: 14.5px; }
.card-head .sub { font-size: 12px; color: var(--text-3); }
.card-head .spacer { flex: 1; }
.card-body { padding: 18px; }
.card-body.tight { padding: 8px 10px; }
.card-foot { padding: 12px 18px; border-top: 1px solid var(--line-soft); }

.grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.main-side { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
@media (max-width: 1180px) { .cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .main-side, .cols-3 { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 720px) { .cols-2, .cols-4 { grid-template-columns: minmax(0, 1fr); } .form-grid { grid-template-columns: minmax(0, 1fr); } .form-grid .span-2 { grid-column: span 1; } }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 14px; border-radius: 9px; border: 1px solid var(--line); background: #fff; color: var(--text-2); font-size: 13px; font-weight: 550; cursor: pointer; transition: all .16s; white-space: nowrap; }
.btn svg { width: 15px; height: 15px; }
.btn:hover { border-color: #cbd5e1; color: var(--text); background: #fafbff; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; }
.btn.success { background: var(--success); border-color: var(--success); color: #fff; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--line-soft); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.text-danger { color: var(--danger); }
.btn.ghost.text-danger:hover { background: rgba(239, 68, 68, .08); color: var(--danger); }

.icon-btn { width: 36px; height: 36px; border-radius: 9px; border: 1px solid var(--line); background: #fff; display: grid; place-items: center; cursor: pointer; color: var(--text-2); }
.icon-btn:hover { background: #fafbff; color: var(--text); }
.icon-btn svg { width: 17px; height: 17px; }

/* ---------------- 顶栏用户区 / 账号菜单 ---------------- */
.user-btn { width: auto; max-width: 220px; height: 36px; padding: 0 10px 0 6px; gap: 8px; display: flex; align-items: center; border-radius: 999px; }
.user-name { display: block; max-width: 118px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-menu { display: none; position: absolute; right: 0; top: 44px; width: 190px; max-width: calc(100vw - 24px); z-index: 60; padding: 6px; box-shadow: var(--shadow-lg); }
.user-menu .btn { width: 100%; height: 34px; justify-content: flex-start; }
.user-menu .divider { margin: 6px 0; }
.cycle-select { width: auto; min-width: 150px; max-width: 190px; }

.input, .select, .textarea { width: 100%; height: 36px; padding: 0 11px; border-radius: 9px; border: 1px solid var(--line); background: #fff; outline: none; transition: border-color .16s, box-shadow .16s; }
.textarea { height: auto; min-height: 84px; padding: 9px 11px; line-height: 1.6; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { border-color: #a5b4fc; box-shadow: 0 0 0 3px rgba(99, 102, 241, .14); }
.input::placeholder, .textarea::placeholder { color: #b6bdc9; }
.select { appearance: none; padding-right: 30px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 11px center; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: 12.5px; color: var(--text-2); font-weight: 550; }
.field .hint { font-size: 11.5px; color: var(--text-3); }
.field .err { font-size: 11.5px; color: var(--danger); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid .span-2 { grid-column: span 2; }
.form-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 18px; }

.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .spacer { flex: 1; }
.toolbar .select, .toolbar .input { width: auto; min-width: 130px; }
.search-box { position: relative; }
.search-box svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--text-3); }
.search-box .input { padding-left: 32px; width: 224px; }

.seg { display: inline-flex; padding: 3px; background: #eef0f6; border-radius: 10px; gap: 2px; }
.seg button { border: 0; background: transparent; height: 30px; padding: 0 12px; border-radius: 8px; font-size: 12.5px; color: var(--text-2); cursor: pointer; font-weight: 550; }
.seg button.active { background: #fff; color: var(--brand); box-shadow: var(--shadow-sm); }

.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.badge.gray { background: #f3f4f6; color: #4b5563; }
.badge.brand { background: var(--brand-soft); color: var(--brand-dark); }
.badge.green { background: var(--success-soft); color: #047857; }
.badge.amber { background: var(--warning-soft); color: #b45309; }
.badge.red { background: var(--danger-soft); color: #b91c1c; }
.badge.sky { background: #eff6ff; color: #0369a1; }
.badge.purple { background: #f5f3ff; color: #6d28d9; }

.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-dark); display: grid; place-items: center; font-weight: 650; font-size: 12.5px; flex: 0 0 auto; }
.avatar.sm { width: 28px; height: 28px; font-size: 11px; }
.avatar.lg { width: 44px; height: 44px; font-size: 15px; }
.user-cell { display: flex; align-items: center; gap: 9px; }

.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
table.table th { text-align: left; font-weight: 600; color: var(--text-3); font-size: 11.5px; letter-spacing: .04em; text-transform: uppercase; padding: 11px 14px; background: #fbfcfe; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.table td { padding: 12px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
table.table tbody tr:hover td { background: #fbfcff; }
table.table tbody tr:last-child td { border-bottom: 0; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-3); }
.strong { font-weight: 600; color: var(--text); }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.tiny { font-size: 12px; }

.progress { height: 7px; border-radius: 999px; background: #eef0f6; overflow: hidden; min-width: 60px; }
.progress > span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, #6366f1, #0ea5e9); transition: width .4s; }
.progress.green > span { background: linear-gradient(90deg, #10b981, #34d399); }
.progress.amber > span { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.progress.red > span { background: linear-gradient(90deg, #ef4444, #f87171); }
.progress-line { display: flex; align-items: center; gap: 9px; }
.progress-line .pct { font-size: 12px; color: var(--text-2); font-variant-numeric: tabular-nums; min-width: 36px; text-align: right; }

.stat { padding: 16px 18px; display: flex; flex-direction: column; gap: 9px; }
.stat-top { display: flex; align-items: center; gap: 9px; color: var(--text-2); font-size: 12.5px; }
.stat-icon { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; }
.stat-icon svg { width: 16px; height: 16px; }
.stat .value { font-size: 26px; font-weight: 680; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.15; }
.stat .value small { font-size: 13px; font-weight: 500; color: var(--text-3); margin-left: 4px; }
.stat .delta { font-size: 12px; color: var(--text-3); }

.empty { padding: 42px 16px; text-align: center; color: var(--text-3); }
.empty .empty-icon { width: 46px; height: 46px; border-radius: 14px; background: var(--line-soft); display: grid; place-items: center; margin: 0 auto 12px; color: #b6bdc9; }
.empty .empty-icon svg { width: 22px; height: 22px; }
.empty b { display: block; color: var(--text-2); font-size: 13.5px; margin-bottom: 4px; }
.empty p { font-size: 12.5px; }

.skeleton { background: linear-gradient(90deg, #f1f3f8 25%, #e9ecf3 37%, #f1f3f8 63%); background-size: 400% 100%; animation: shimmer 1.3s infinite; border-radius: 8px; }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.divider { height: 1px; background: var(--line-soft); margin: 14px 0; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); }
.tabs button { border: 0; background: transparent; padding: 10px 12px; font-size: 13px; color: var(--text-2); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 550; }
.tabs button.active { color: var(--brand); border-bottom-color: var(--brand); }

/* 弹窗 */
.modal-host { position: fixed; inset: 0; z-index: 100; pointer-events: none; }
.modal-host.open { pointer-events: auto; }
.modal-mask { position: absolute; inset: 0; background: rgba(15, 23, 42, .48); opacity: 0; transition: opacity .2s; }
.modal-host.open .modal-mask { opacity: 1; }
.modal { position: relative; margin: 6vh auto 0; width: min(640px, calc(100vw - 32px)); background: #fff; border-radius: 16px; box-shadow: var(--shadow-lg); transform: translateY(12px); opacity: 0; transition: all .22s; max-height: 86vh; display: flex; flex-direction: column; }
.modal-host.open .modal { transform: none; opacity: 1; }
.modal.wide { width: min(880px, calc(100vw - 32px)); }
.modal.narrow { width: min(460px, calc(100vw - 32px)); }
.modal-head { display: flex; align-items: flex-start; gap: 12px; padding: 18px 20px 14px; border-bottom: 1px solid var(--line-soft); }
.modal-head h3 { font-size: 16px; }
.modal-head .sub { font-size: 12.5px; color: var(--text-3); margin-top: 3px; }
.modal-head .close { margin-left: auto; }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line-soft); display: flex; justify-content: flex-end; gap: 9px; background: #fcfdff; border-radius: 0 0 16px 16px; }

/* 抽屉 */
.drawer-mask { position: fixed; inset: 0; background: rgba(15, 23, 42, .42); z-index: 90; opacity: 0; transition: opacity .2s; }
.drawer-mask.open { opacity: 1; }
.drawer { position: fixed; top: 0; right: 0; height: 100vh; width: min(620px, 100vw); background: #fff; z-index: 91; transform: translateX(100%); transition: transform .26s cubic-bezier(.2, .8, .3, 1); display: flex; flex-direction: column; }
.drawer.open { transform: none; }
.drawer-head { padding: 18px 22px; border-bottom: 1px solid var(--line-soft); display: flex; align-items: flex-start; gap: 12px; }
.drawer-body { padding: 20px 22px; overflow-y: auto; flex: 1; }
.drawer-foot { padding: 14px 22px; border-top: 1px solid var(--line-soft); display: flex; gap: 9px; justify-content: flex-end; flex-wrap: wrap; background: #fcfdff; }

/* 提示 */
.toast-host { position: fixed; top: 18px; right: 18px; z-index: 200; display: flex; flex-direction: column; gap: 9px; pointer-events: none; }
.toast { min-width: 230px; max-width: 360px; background: #111827; color: #f8fafc; padding: 11px 14px; border-radius: 11px; font-size: 13px; box-shadow: var(--shadow-lg); display: flex; gap: 9px; align-items: flex-start; transform: translateY(-8px); opacity: 0; transition: all .22s; }
.toast.show { transform: none; opacity: 1; }
.toast svg { width: 16px; height: 16px; flex: 0 0 auto; margin-top: 2px; }
.toast.success svg { color: #34d399; }
.toast.error svg { color: #f87171; }
.toast.info svg { color: #60a5fa; }
/* ---------------- 移动端紧凑布局 ---------------- */
@media (max-width: 720px) {
    .content { padding: 14px 12px 30px; }
    .topbar { height: 56px; gap: 10px; }
    .topbar h1 { font-size: 15px; }
    .topbar .crumb { display: none; }
    .topbar-actions { gap: 6px; }
    .topbar-actions .cycle-select { min-width: 0; max-width: 132px; }
    .user-name { display: none; }
    .user-btn { padding: 0 6px; max-width: none; }
    .card-head { padding: 12px 14px; gap: 8px; }
    .card-body { padding: 14px; }
    .card-foot { padding: 10px 14px; }
    .toolbar { gap: 8px; margin-bottom: 12px; }
    .toolbar .select, .toolbar .input { min-width: 0; flex: 1 1 140px; width: auto; }
    .search-box { flex: 1 1 100%; }
    .search-box .input { width: 100%; }
    .tabs { overflow-x: auto; scrollbar-width: none; }
    .tabs::-webkit-scrollbar { display: none; }
    .tabs button { padding: 9px 10px; white-space: nowrap; }
    table.table { min-width: 640px; }
    table.table th, table.table td { padding: 10px 12px; }
    .modal { margin: 12px auto 0; max-height: 92vh; }
    .modal-head, .modal-body, .modal-foot { padding-left: 14px; padding-right: 14px; }
    .drawer { width: 100vw; }
    .drawer-head, .drawer-body, .drawer-foot { padding-left: 14px; padding-right: 14px; }
    .big-num { font-size: 22px; }
}

@media (max-width: 480px) {
    .topbar h1 { font-size: 14px; }
    .topbar-actions .cycle-select { max-width: 104px; padding-right: 26px; font-size: 12.5px; }
    .btn { height: 34px; padding: 0 11px; font-size: 12.5px; }
    .btn.block { width: 100%; }
    .toast-host { left: 12px; right: 12px; }
    .toast { max-width: none; min-width: 0; width: 100%; }
    .cols-2, .cols-3, .cols-4 { gap: 12px; }
    .big-num { font-size: 20px; }
}

/* 分页条 */
.pager { display: flex; align-items: center; gap: 8px; margin-top: 16px; }
.pager .spacer { flex: 1; }
