:root {
    --bg: #f4f5f9;
    --panel: #ffffff;
    --text: #16181f;
    --muted: #6b7280;
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --border: #e6e8ef;
    --danger: #dc2626;
    --success: #059669;
    --warning: #d97706;
    --radius: 12px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 8px 24px rgba(16, 24, 40, .05);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    font-size: 14px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------------------------------------------------------------- layout */
.topbar {
    background: var(--panel);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 20;
}

.topbar-inner {
    max-width: 1320px;
    margin: 0 auto;
    padding: 0 20px;
    height: 60px;
    display: flex;
    align-items: center;
    gap: 18px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 17px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: .5px;
    flex-shrink: 0;
    white-space: nowrap;
}
.brand:hover { text-decoration: none; }

.brand-mark {
    width: 30px;
    height: 30px;
    border-radius: 9px;
    background: linear-gradient(135deg, #6366f1, #a855f7);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    font-weight: 700;
}

.nav { display: flex; gap: 4px; flex: 1; }

.nav a {
    padding: 7px 11px;
    border-radius: 8px;
    color: var(--muted);
    font-weight: 500;
    white-space: nowrap;
}
.nav a:hover { background: #f1f2f7; color: var(--text); text-decoration: none; }
.nav a.active { background: #eef0ff; color: var(--primary); }

.topbar-right { display: flex; align-items: center; gap: 14px; flex-shrink: 0; }

.avatar {
    width: 30px; height: 30px; border-radius: 50%;
    background: #eef0ff; color: var(--primary);
    display: flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: 13px;
}

.who { font-size: 13px; color: var(--muted); white-space: nowrap; }
.who strong { color: var(--text); font-weight: 600; }

.container { max-width: 1320px; margin: 0 auto; padding: 28px 20px 60px; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.page-title { font-size: 22px; font-weight: 700; margin: 0; }
.page-sub { color: var(--muted); font-size: 13px; margin-top: 4px; }

/* ---------------------------------------------------------------- panels */
.card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.card + .card { margin-top: 20px; }

.card-head {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.card-title { font-weight: 600; font-size: 15px; margin: 0; }
.card-body { padding: 20px; }

.grid {
    display: grid;
    gap: 16px;
    margin-bottom: 20px;
}

/* 栅格里并排的卡片不参与「相邻卡片下移 20px」的规则，保证三张卡片等高 */
.grid > .card + .card { margin-top: 0; }

.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.stat { padding: 18px 20px; }
.stat-label { color: var(--muted); font-size: 13px; }
.stat-value { font-size: 28px; font-weight: 700; margin-top: 4px; letter-spacing: -.5px; }
.stat-value.muted { color: #b6bac7; font-size: 20px; }

/* ---------------------------------------------------------------- forms */
.form-row { margin-bottom: 16px; }
.label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }

.input, .select {
    width: 100%;
    height: 40px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: #fff;
    font-size: 14px;
    color: var(--text);
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, .12);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 38px;
    padding: 0 16px;
    border-radius: 9px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text);
    font-size: 13.5px;
    font-weight: 500;
    cursor: pointer;
    transition: background .15s, border-color .15s, opacity .15s;
    white-space: nowrap;
}
.btn:hover { background: #f7f8fb; text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }

.btn-danger { color: var(--danger); border-color: #f3c9c9; background: #fff7f7; }
.btn-danger:hover { background: #fdeeee; }

.btn-sm { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 7px; }
.btn-block { width: 100%; }

.inline-form { display: inline-flex; gap: 6px; align-items: center; }

/* ---------------------------------------------------------------- table */
.table { width: 100%; border-collapse: collapse; }
.table th {
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .3px;
    padding: 11px 20px;
    background: #fafbfd;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.table td { padding: 13px 20px; border-bottom: 1px solid #f1f2f6; vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: #fbfcfe; }

.table-compact th,
.table-compact td { padding-left: 12px; padding-right: 12px; }

.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }

/* ---------------------------------------------------------------- badge */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
    background: #f1f2f7;
    color: var(--muted);
    white-space: nowrap;
}
.badge-admin { background: #eef0ff; color: var(--primary); }
.badge-user { background: #f1f2f7; color: #4b5563; }
.badge-active { background: #e9f8f1; color: var(--success); }
.badge-disabled { background: #fdeeee; color: var(--danger); }
.badge-warn { background: #fff7ed; color: #c2410c; }

/* ---------------------------------------------------------------- health */
.bar {
    width: 80px;
    height: 6px;
    background: #eef0f5;
    border-radius: 999px;
    overflow: hidden;
    flex-shrink: 0;
}
.bar-inner { height: 100%; border-radius: 999px; background: var(--success); }
.bar-inner.warn { background: #f59e0b; }
.bar-inner.bad { background: var(--danger); }

/* ---------------------------------------------------------------- alerts */
.alert {
    padding: 11px 14px;
    border-radius: 9px;
    font-size: 13px;
    margin-bottom: 16px;
    border: 1px solid transparent;
}
.alert-success { background: #ecfdf5; color: #065f46; border-color: #b7ebd4; }
.alert-error { background: #fef2f2; color: #991b1b; border-color: #f6c6c6; }
.alert ul { margin: 0; padding-left: 18px; }

/* ---------------------------------------------------------------- auth */
.auth-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: radial-gradient(1200px 600px at 20% -10%, #e8e9ff 0%, var(--bg) 45%);
}

.auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(16, 24, 40, .09);
    padding: 32px;
}

.auth-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 19px;
    font-weight: 700;
    margin-bottom: 6px;
}

.auth-sub { color: var(--muted); font-size: 13px; margin-bottom: 24px; }

.auth-foot { text-align: center; font-size: 13px; color: var(--muted); margin-top: 20px; }

.checkbox { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }

/* ---------------------------------------------------------------- misc */
.pagination { display: flex; gap: 6px; align-items: center; padding: 14px 20px; }
.pagination a, .pagination span {
    min-width: 32px; height: 32px; padding: 0 8px;
    display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--border); border-radius: 8px;
    font-size: 13px; color: var(--muted); background: #fff;
}
.pagination .active { background: var(--primary); border-color: var(--primary); color: #fff; }
.pagination .disabled { opacity: .45; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }

.user-cell { display: flex; align-items: center; gap: 10px; }
.avatar-img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    background: #eef0ff;
    flex-shrink: 0;
}

/* ---------------------------------------------------------------- series */
.tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border);
}
.tab {
    padding: 8px 15px;
    border-radius: 8px 8px 0 0;
    color: var(--muted);
    font-size: 13.5px;
    font-weight: 500;
}
.tab:hover { background: #f1f2f7; text-decoration: none; color: var(--text); }
.tab.active { background: #eef0ff; color: var(--primary); font-weight: 600; }

.chart-legend {
    display: flex;
    gap: 16px;
    font-size: 12.5px;
    color: var(--muted);
    padding: 8px 0 0 62px;
}
.chart-legend i {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 2px;
    margin-right: 6px;
}

.chart-legend-center {
    justify-content: center;
    padding-left: 0;
}

.chart-scroll {
    overflow-x: auto;
    padding-bottom: 4px;
    max-width: 100%;
}

/* 账号详情：柱形图 + 底部缩放 */
.chart-zoom { width: 100%; }

.chart-svg {
    display: block;
    width: 100%;
    height: 250px;
}

.zoom-panel {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 0 2px;
}

.zoom-meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 12.5px;
    color: var(--muted);
    white-space: nowrap;
    min-width: 190px;
}

.zoom-track {
    position: relative;
    flex: 1;
    height: 26px;
    border-radius: 13px;
    background: #f2f5f9;
    border: 1px solid var(--border);
    cursor: pointer;
    touch-action: none;
    user-select: none;
}

.zoom-range {
    position: absolute;
    top: 0;
    bottom: 0;
    background: rgba(79, 70, 229, .14);
    border-radius: 13px;
    pointer-events: none;
}

.zoom-handle {
    position: absolute;
    top: 50%;
    width: 12px;
    height: 22px;
    margin-left: -6px;
    padding: 0;
    transform: translateY(-50%);
    background: #fff;
    border: 1px solid #c7c9f8;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(16, 24, 40, .18);
    cursor: ew-resize;
}

.zoom-handle:hover,
.zoom-handle.dragging {
    border-color: var(--primary);
    box-shadow: 0 1px 6px rgba(79, 70, 229, .35);
}

.table-scroll { overflow-x: auto; }
.table-scroll table { min-width: 920px; }
.rank {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 26px;
    height: 24px;
    padding: 0 6px;
    border-radius: 7px;
    background: #f1f2f7;
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
}
.rank-top { background: linear-gradient(135deg, #6366f1, #a855f7); color: #fff; }

/* 账号详情里的短剧表：固定列宽，标题列吃剩余空间，避免列被挤偏 */
.table-scroll .series-table {
    table-layout: fixed;
    min-width: 0;
}
.series-table th,
.series-table td {
    overflow: hidden;
    text-overflow: ellipsis;
}
.series-index {
    width: 26px;
    flex-shrink: 0;
    text-align: right;
    font-size: 12.5px;
    font-variant-numeric: tabular-nums;
    color: var(--muted);
}
.series-name {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-weight: 500;
    color: var(--text);
    line-height: 1.45;
}
.series-icp {
    font-size: 11.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.series-cell { display: flex; align-items: center; gap: 10px; }

/* 剧集标题：点标题直接跳抖音原始视频 */
.ep-link {
    color: inherit;
    text-decoration: none;
    border-bottom: 1px dashed var(--border);
    transition: color .15s ease, border-color .15s ease;
}

.ep-link:hover {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.ep-link-mark {
    font-size: 11px;
    color: var(--primary);
    margin-left: 2px;
}

.cover-thumb {
    width: 40px;
    height: 54px;
    border-radius: 6px;
    background: #eef0ff;
    overflow: hidden;
    flex-shrink: 0;
}
.cover-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cover-thumb-sm { width: 46px; height: 46px; border-radius: 6px; }

.cover-large {
    width: 100%;
    aspect-ratio: 2 / 3;
    border-radius: 10px;
    background: #f1f2f7;
    overflow: hidden;
}
.cover-large img { width: 100%; height: 100%; object-fit: contain; display: block; }
.cover-empty {
    width: 100%;
    aspect-ratio: 2 / 3;
    border-radius: 10px;
    background: #f1f2f7;
    color: var(--muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12.5px;
}

/* 封面卡片不要跟着右侧内容拉高，否则封面下方会留一大片空白 */
.detail-grid {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    align-items: start;
    gap: 18px;
    margin-bottom: 18px;
}

@media (max-width: 900px) {
    .detail-grid { grid-template-columns: 1fr; }
    .cover-large { max-width: 220px; }
}

.perm-group { margin-bottom: 18px; }
.perm-group-name { font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 8px; text-transform: uppercase; letter-spacing: .5px; }

.empty { padding: 40px 20px; text-align: center; color: var(--muted); font-size: 13px; }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }

@media (max-width: 1080px) {
    .who { display: none; }
    .nav { overflow-x: auto; scrollbar-width: none; }
    .nav::-webkit-scrollbar { display: none; }
}

@media (max-width: 820px) {
    .grid-3, .grid-2 { grid-template-columns: 1fr; }
    .nav { display: none; }
}

/* ---------------------------------------------------------------- 短剧标签 */
.filter-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.sort-inline {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--muted);
    white-space: nowrap;
}

.delta-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}

.tag-panel { width: 100%; }

.tag-panel > summary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 32px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    color: var(--muted);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    user-select: none;
    list-style: none;
    transition: background .15s, border-color .15s, color .15s;
}
.tag-panel > summary::-webkit-details-marker { display: none; }
.tag-panel > summary:hover { background: #f7f8fb; color: var(--text); }
.tag-panel[open] > summary {
    border-color: #c7c9f8;
    background: #eef0ff;
    color: var(--primary);
}

.tag-panel-label { font-weight: 600; }

.tag-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--primary);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    line-height: 1;
}

.tag-panel-caret { font-size: 10px; transition: transform .15s; }
.tag-panel[open] .tag-panel-caret { transform: rotate(180deg); }

.tag-panel-body {
    margin-top: 10px;
    padding: 4px 16px 2px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fafbfd;
}

.tag-panel-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 18px;
    padding: 10px 0;
    border-bottom: 1px dashed var(--border);
}

.tag-panel-hint { font-size: 12.5px; color: var(--muted); margin-right: auto; }

.tag-inline {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 12.5px;
    color: var(--muted);
    white-space: nowrap;
}
.tag-inline select { width: auto; }

.select-sm {
    height: 30px;
    padding: 0 8px;
    font-size: 12.5px;
    border-radius: 7px;
}

.tag-clear { font-size: 12.5px; color: var(--muted); }
.tag-clear:hover { color: var(--danger); }

.tag-row {
    display: flex;
    gap: 14px;
    padding: 9px 0;
    border-bottom: 1px dashed #eef0f5;
}
.tag-row:last-of-type { border-bottom: none; }

.tag-row-name {
    flex: 0 0 78px;
    padding-top: 4px;
    font-size: 12.5px;
    color: var(--muted);
    white-space: nowrap;
}

.tag-row-items {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.tag-pill {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 28px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: #fff;
    color: #4b5563;
    font-size: 12.5px;
    cursor: pointer;
    user-select: none;
    transition: background .15s, border-color .15s, color .15s;
}
.tag-pill:hover { border-color: #c7c9f8; color: var(--primary); }

.tag-pill input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}

.tag-pill input:checked + span { color: var(--primary); font-weight: 600; }

.tag-pill:has(input:checked) {
    background: #eef0ff;
    border-color: #c7c9f8;
    color: var(--primary);
}

.tag-pill:has(input:focus-visible) {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, .12);
}

.tag-panel-foot { padding: 12px 0; }

.tag-hot {
    background: #ef4444;
    color: #fff;
    font-size: 10px;
    line-height: 14px;
    padding: 0 4px;
    border-radius: 4px;
    font-style: normal;
}

.tag-chip {
    display: inline-block;
    background: #eef0ff;
    color: var(--primary);
    border-radius: 6px;
    padding: 1px 7px;
    font-size: 12px;
    margin: 0 4px 2px 0;
}
