:root {
  --bg: #f5f6fa; --surface: #fff; --surface-2: #f0f2f8; --border: #e4e7f0;
  --text: #1d2333; --muted: #7c8498; --accent: #4f63e8; --accent-dark: #3d50d0;
  --accent-soft: #eef1ff; --success: #1ba87a; --danger: #e05260;
  --radius: 14px; --shadow: 0 4px 20px rgba(30,40,80,.06);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif; }
button, input, select { font-family: inherit; }
button { cursor: pointer; }
.svg-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
svg { width: 18px; height: 18px; }

/* 通用按钮 */
.btn { border: 0; border-radius: 9px; padding: 9px 16px; display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13px; transition: .15s; }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 5px 14px rgba(79,99,232,.22); }
.btn-primary:hover { background: var(--accent-dark); }
.btn-secondary { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: #c8cfdf; }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-sm { height: 36px; padding: 0 12px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; }
.btn-danger { background: #fff; color: var(--danger); border: 1px solid #f3cbd0; }
.btn-danger:hover { background: #fff5f6; }
.icon-btn { width: 34px; height: 34px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); display: grid; place-items: center; }
.icon-btn:hover, .icon-btn.active { background: var(--accent-soft); color: var(--accent); }
.link-btn { border: 0; background: transparent; color: var(--accent); font-weight: 600; font-size: 12px; padding: 2px 4px; }
.link-btn:hover { text-decoration: underline; }

/* 登录 */
.login-overlay { position: fixed; inset: 0; z-index: 150; display: grid; place-items: center; padding: 20px; }
.login-backdrop { position: absolute; inset: 0; background: radial-gradient(1200px 600px at 50% -10%, #dfe5ff 0%, #eef0f8 45%, #f5f6fa 100%); }
.login-card { position: relative; width: min(440px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: 0 20px 60px rgba(30,40,80,.14); padding: 30px 32px; }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.login-brand > div { display: flex; flex-direction: column; }
.login-brand strong { font-size: 18px; }
.login-brand span:not(.brand-mark) { color: var(--muted); font-size: 12px; }
.brand-mark { width: 38px; height: 38px; border-radius: 11px; background: var(--accent); color: #fff; display: grid; place-items: center; flex: none; }
.brand-mark svg { width: 20px; height: 20px; }
.login-card h2 { margin: 0 0 8px; font-size: 22px; }
.login-sub { margin: 0; color: var(--muted); font-size: 13px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; margin: 20px 0 6px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.field-wide { grid-column: 1 / -1; }
.field > span { font-size: 12px; font-weight: 600; color: #596279; }
.field input { height: 40px; border-radius: 9px; border: 1px solid var(--border); padding: 0 12px; background: #fff; color: var(--text); outline: none; }
.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79,99,232,.1); }
.field small { color: #a3aabd; font-size: 11px; }
.setup-actions { display: flex; align-items: center; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.setup-msg { font-size: 12px; color: var(--muted); }
.setup-msg.ok { color: var(--success); }
.setup-msg.err { color: var(--danger); }
.login-foot { margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--border); color: var(--muted); font-size: 12px; text-align: center; }

/* 用户端布局 */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: 236px; flex: none; background: var(--surface); border-right: 1px solid var(--border); padding: 22px 14px; display: flex; flex-direction: column; }
.side-item { width: 100%; border: 0; background: transparent; border-radius: 9px; padding: 10px 12px; display: flex; align-items: center; gap: 10px; color: var(--text); font-size: 13px; font-weight: 600; text-align: left; }
.side-item:hover { background: var(--surface-2); }
.side-item.active { background: var(--accent-soft); color: var(--accent); }
.side-icon { display: grid; place-items: center; }
.side-divider { height: 1px; background: var(--border); margin: 16px 4px; }
.side-title { font-size: 11px; font-weight: 700; color: #a3aabd; letter-spacing: 1px; padding: 0 10px 8px; }
.folder-list { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; max-height: 55vh; }
.folder-item { border: 0; background: transparent; border-radius: 8px; padding: 8px 10px; display: flex; align-items: center; gap: 8px; color: #596279; font-size: 12.5px; text-align: left; width: 100%; }
.folder-item svg { width: 15px; height: 15px; flex: none; color: #a3aabd; }
.folder-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-item:hover { background: var(--surface-2); color: var(--text); }
.folder-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.side-footer { margin-top: auto; padding: 16px 6px 0; border-top: 1px solid var(--border); }
.side-user { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; margin-bottom: 12px; color: #596279; }
.side-user svg { width: 16px; height: 16px; }
.content { flex: 1; min-width: 0; padding: 28px 32px 50px; }
.content-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; flex-wrap: wrap; }
.head-title h1 { margin: 0; font-size: 25px; letter-spacing: -.4px; }
.breadcrumbs { display: flex; align-items: center; gap: 5px; margin-top: 8px; flex-wrap: wrap; }
.breadcrumbs button { border: 0; background: transparent; padding: 2px 4px; color: var(--muted); font-size: 12px; }
.breadcrumbs button:hover { color: var(--accent); }
.head-tools { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.head-account { display: flex; align-items: center; gap: 6px; margin-left: 4px; padding-left: 12px; border-left: 1px solid var(--border); }
@media (max-width: 1100px) { .head-account { margin-left: 0; padding-left: 0; border-left: 0; } }
.search-box { height: 38px; width: 230px; border: 1px solid var(--border); border-radius: 9px; background: #fff; display: flex; align-items: center; gap: 8px; padding: 0 11px; color: var(--muted); }
.search-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79,99,232,.1); }
.search-box svg { width: 16px; height: 16px; flex: none; }
.search-box input { border: 0; outline: 0; background: transparent; width: 100%; color: var(--text); font-size: 13px; }
.view-switch { display: flex; background: var(--surface-2); border-radius: 9px; padding: 2px; }

/* 筛选栏 */
.filter-bar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin-top: 18px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.filter-item { display: flex; flex-direction: column; gap: 6px; }
.filter-item > span { font-size: 11px; font-weight: 700; color: #a3aabd; letter-spacing: .5px; }
.filter-item select { height: 34px; min-width: 112px; border-radius: 8px; border: 1px solid var(--border); padding: 0 10px; background: #fff; color: var(--text); font-size: 12.5px; outline: none; cursor: pointer; max-width: 180px; }
.filter-item select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79,99,232,.1); }
.filter-active { color: var(--accent); font-weight: 700; }
#clearFilters { margin-left: auto; }
.meta-line { color: var(--muted); font-size: 12px; margin: 18px 0 14px; }
.loading-wrap { display: flex; align-items: center; gap: 12px; color: var(--muted); padding: 60px 0; justify-content: center; }
.spinner { width: 22px; height: 22px; border: 2.5px solid #dfe3ef; border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* 视频卡片 */
.video-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px,1fr)); gap: 18px; }
.video-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; cursor: pointer; transition: .16s; outline: none; }
.video-card:hover, .video-card:focus { transform: translateY(-3px); box-shadow: 0 12px 28px rgba(30,40,80,.12); border-color: #cfd6ee; }
.thumb { position: relative; aspect-ratio: 16/10; background: linear-gradient(135deg,#e8ebf5,#f3f4fa); display: grid; place-items: center; overflow: hidden; }
.thumb svg { width: 34px; height: 34px; color: #bcc4d8; }
.thumb img { width: 100%; height: 100%; object-fit: cover; position: absolute; inset: 0; }
.play-hint { position: absolute; width: 40px; height: 40px; border-radius: 50%; background: rgba(255,255,255,.92); color: #1d2333; display: grid; place-items: center; opacity: 0; transition: .16s; }
.video-card:hover .play-hint { opacity: 1; }
.play-hint svg { width: 18px; height: 18px; color: inherit; }
.badge { position: absolute; top: 8px; right: 8px; background: rgba(25,30,50,.72); color: #fff; font-size: 10px; font-weight: 700; padding: 3px 7px; border-radius: 5px; letter-spacing: .5px; }
.ep-badge { position: absolute; bottom: 8px; left: 8px; background: rgba(79,99,232,.9); color: #fff; font-size: 10px; font-weight: 700; padding: 3px 7px; border-radius: 5px; }
.video-card.playing { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(79,99,232,.22); }
.card-body { padding: 11px 12px 13px; }
.card-name { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-meta { display: flex; justify-content: space-between; margin-top: 6px; color: var(--muted); font-size: 11px; }
.list-mode { grid-template-columns: repeat(auto-fill,minmax(420px,1fr)); }
.list-mode .video-card { display: flex; align-items: center; }
.list-mode .thumb { width: 148px; aspect-ratio: 16/9; flex: none; }
.list-mode .play-hint { display: none; }
.list-mode .card-body { flex: 1; min-width: 0; }
.cache-status { margin-left: 12px; padding: 2px 8px; border-radius: 6px; font-size: 11px; background: #e8f6f0; color: #147a58; }
.cache-status.stale { background: #fff4e5; color: #b97616; }
.empty-state { padding: 80px 20px; text-align: center; color: var(--muted); }
.empty-icon { display: inline-grid; place-items: center; width: 64px; height: 64px; border-radius: 50%; background: var(--surface-2); color: #b6bdcd; }
.empty-icon svg { width: 30px; height: 30px; }
.empty-state h3 { margin: 16px 0 6px; color: var(--text); font-size: 17px; }
.empty-state p { margin: 0; font-size: 13px; }

/* 播放器 */
.player { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 24px; }
.player-backdrop { position: absolute; inset: 0; background: rgba(12,15,28,.86); }
.player-shell { position: relative; width: min(1080px,100%); background: #151a2a; border-radius: 16px; overflow: hidden; box-shadow: 0 30px 80px rgba(0,0,0,.5); }
.player-top { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; color: #fff; }
.player-top > div { display: flex; flex-direction: column; min-width: 0; }
.player-top strong { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-top span { color: #9aa5c0; font-size: 11px; margin-top: 3px; }
.player-top .icon-btn { color: #aab3c8; }
.player-top .icon-btn:hover { background: rgba(255,255,255,.1); color: #fff; }
.player-top > div.player-top-tools { display: flex; flex-direction: row; align-items: center; gap: 12px; flex: none; min-width: auto; }
.player-top-tools { flex-wrap: nowrap; }
.player-order { display: flex; align-items: center; gap: 2px; background: #222a3d; border-radius: 8px; padding: 2px 6px; }
.player-order .ctrl-btn { width: 28px; height: 28px; color: #aab3c8; }
.player-order .ctrl-btn:hover:not(:disabled) { color: #fff; }
.player-order .ctrl-btn:disabled { opacity: .3; cursor: not-allowed; }
.player-order .ctrl-btn svg { width: 16px; height: 16px; }
.player-order #prevFileBtn svg { transform: rotate(180deg); }
.player-order .order-btn { border-radius: 6px; }
.player-order .order-btn.active { background: var(--accent); color: #fff; }
.ctrl-btn.auto-next { border: 1px solid #3b4258; border-radius: 6px; }
.ctrl-btn.auto-next.active { color: #7ee0b5; border-color: #2f8f6a; }
.ctrl-label { font-size: 11px; color: #aab3c8; white-space: nowrap; }
.video-stage { position: relative; background: #000; aspect-ratio: 16/9; display: grid; place-items: center; }
.video-stage video { width: 100%; height: 100%; max-height: 72vh; object-fit: contain; display: block; }
.big-play { position: absolute; width: 66px; height: 66px; border: 0; border-radius: 50%; background: rgba(255,255,255,.92); color: #1d2333; display: grid; place-items: center; box-shadow: 0 10px 30px rgba(0,0,0,.4); }
.big-play svg { width: 28px; height: 28px; }
.player-controls { display: flex; align-items: center; gap: 12px; padding: 14px 18px; color: #fff; }
.ctrl-btn { border: 0; background: transparent; color: #dfe4f2; width: 30px; height: 30px; display: grid; place-items: center; }
.ctrl-btn:hover { color: #fff; }
.time-label { font-size: 12px; color: #b8c1d8; font-variant-numeric: tabular-nums; min-width: 38px; }
.seek-bar, .volume-bar { -webkit-appearance: none; appearance: none; background: transparent; cursor: pointer; }
.seek-bar { flex: 1; height: 5px; border-radius: 4px; background: linear-gradient(to right, var(--accent) var(--p,0%), #3b4258 var(--p,0%)); }
.volume-bar { width: 84px; height: 4px; border-radius: 3px; background: #3b4258; }
.seek-bar::-webkit-slider-thumb, .volume-bar::-webkit-slider-thumb { -webkit-appearance: none; width: 13px; height: 13px; border-radius: 50%; background: #fff; border: 0; }
.speed-select { background: #2b3245; color: #fff; border: 0; border-radius: 6px; padding: 5px 6px; font-size: 12px; outline: none; }

/* 管控后台 */
.admin-app { min-height: 100vh; }
.admin-topbar { height: 62px; background: var(--surface); border-bottom: 1px solid var(--border); padding: 0 26px; display: flex; align-items: center; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 11px; }
.brand-text { display: flex; flex-direction: column; }
.brand-text strong { font-size: 15px; }
.brand-text span { font-size: 9px; color: var(--muted); letter-spacing: 1px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.status-pill { display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px; border-radius: 999px; font-size: 12px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.status-pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #b6bdcd; }
.status-pill.ok { background: #e9f7f1; color: var(--success); }
.status-pill.ok::before { background: var(--success); }
.status-pill.warn { background: #fff4e5; color: #b97616; }
.admin-layout { display: flex; min-height: calc(100vh - 62px); }
.admin-nav { width: 220px; flex: none; background: var(--surface); border-right: 1px solid var(--border); padding: 20px 12px; }
.admin-nav-item { width: 100%; border: 0; background: transparent; border-radius: 9px; padding: 11px 13px; display: flex; align-items: center; gap: 10px; color: #596279; font-size: 13px; font-weight: 600; text-align: left; margin-bottom: 4px; }
.admin-nav-item:hover { background: var(--surface-2); }
.admin-nav-item.active { background: var(--accent-soft); color: var(--accent); }
.admin-main { flex: 1; min-width: 0; padding: 30px 34px 60px; }
.admin-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; flex-wrap: wrap; margin-bottom: 22px; }
.admin-head h2 { margin: 0 0 6px; font-size: 21px; }
.admin-head p { margin: 0; color: var(--muted); font-size: 13px; }
.user-list { display: flex; flex-direction: column; gap: 12px; }
.user-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; box-shadow: var(--shadow); }
.user-row { display: flex; align-items: center; gap: 12px; }
.user-avatar { width: 38px; height: 38px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; flex: none; }
.user-info { flex: 1; min-width: 0; }
.user-info strong { font-size: 14px; }
.user-info span { display: block; color: var(--muted); font-size: 11px; }
.user-actions { display: flex; gap: 6px; }
.tag { display: inline-block; font-size: 10px; padding: 2px 7px; border-radius: 5px; background: var(--surface-2); color: var(--muted); margin-left: 6px; }
.tag.off { background: #fff0f1; color: var(--danger); }
.user-folders { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); display: flex; flex-wrap: wrap; gap: 6px; }
.folder-chip { font-size: 11px; padding: 4px 9px; border-radius: 6px; background: var(--accent-soft); color: var(--accent); }
.folder-chip.group { background: #e8f6f0; color: #147a58; }
.folder-chip.none { background: #fff4e5; color: #b97616; }
.group-list { display: grid; grid-template-columns: repeat(auto-fill,minmax(320px,1fr)); gap: 14px; }
.group-card { border-left: 3px solid #1ba87a; }
.folder-stats { display: grid; grid-template-columns: repeat(auto-fill,minmax(240px,1fr)); gap: 12px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; box-shadow: var(--shadow); }
.stat-card h3 { margin: 0 0 4px; font-size: 14px; }
.stat-card p { margin: 0; color: var(--muted); font-size: 12px; }
.stat-num { font-size: 22px; font-weight: 700; color: var(--accent); margin-top: 8px; }
.admin-form { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 20px 22px; margin-bottom: 18px; box-shadow: var(--shadow); max-width: 720px; }
.admin-form h3 { margin: 0; font-size: 15px; }
.form-tip { margin: 6px 0 14px; color: var(--muted); font-size: 12px; }
.pass-form .form-grid { max-width: 480px; }
.check-line { display: flex; align-items: center; gap: 8px; margin-top: 14px; font-size: 12.5px; color: #596279; }

/* 弹窗 */
.modal { position: fixed; inset: 0; z-index: 300; display: grid; place-items: center; padding: 20px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(18,22,40,.55); }
.modal-card { position: relative; width: min(620px,100%); max-height: 88vh; overflow-y: auto; background: var(--surface); border-radius: 16px; padding: 24px 26px; box-shadow: 0 24px 70px rgba(0,0,0,.25); }
.modal-card-sm { width: min(420px,100%); }
.modal-head { display: flex; justify-content: space-between; align-items: center; }
.modal-head h2 { margin: 0; font-size: 19px; }
.auth-block { margin-top: 18px; border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; }
.auth-head { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.auth-head strong { font-size: 13px; margin-right: auto; }
.folder-checks { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; max-height: 240px; overflow-y: auto; }
.folder-check { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 12px; cursor: pointer; }
.folder-check:hover { background: var(--surface-2); }
.folder-check input { accent-color: var(--accent); }
.folder-check span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-check small { color: var(--muted); }
/* 按项目分组的授权列表 */
.folder-projects { display: flex !important; flex-direction: column; gap: 8px; max-height: 320px; overflow-y: auto; }
.dir-loading { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 60px 0; color: var(--muted); font-size: 13px; }
.folder-project { border: 1px solid var(--border); border-radius: 9px; overflow: hidden; flex: none; flex-shrink: 0; }
.project-head { display: flex; align-items: center; gap: 10px; padding: 9px 12px; background: var(--surface-2); }
.project-toggle { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; cursor: pointer; }
.project-toggle input { accent-color: var(--accent); }
.project-toggle strong { font-size: 13px; }
.project-toggle small { color: var(--muted); font-size: 11px; }
.project-children { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 6px; padding: 10px; }
.project-children .folder-check { padding: 6px 9px; }
@media (max-width: 720px) { .project-children { grid-template-columns: 1fr; } }
/* 权限分组勾选列表 */
.user-group-checks { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; max-height: 180px; overflow-y: auto; }
.group-check { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px; font-size: 12.5px; cursor: pointer; }
.group-check:hover { background: var(--surface-2); }
.group-check input { accent-color: var(--accent); }
.group-check span { font-weight: 600; }
.group-check small { flex-basis: 100%; padding-left: 22px; color: var(--muted); font-size: 11px; }
.group-check.off { opacity: .6; }
@media (max-width: 720px) { .user-group-checks { grid-template-columns: 1fr; } }

.toast { position: fixed; right: 24px; bottom: 24px; z-index: 500; background: #1d2333; color: #fff; padding: 12px 18px; border-radius: 10px; font-size: 13px; box-shadow: 0 12px 30px rgba(0,0,0,.25); }
.toast.ok { background: var(--success); }
.toast.err { background: var(--danger); }

@media (max-width: 860px) {
  .sidebar { width: 190px; }
  .content { padding: 20px 18px 40px; }
  .head-tools { width: 100%; }
  .search-box { flex: 1; width: auto; }
  .admin-nav { width: 170px; }
  .admin-main { padding: 22px 18px 40px; }
  .folder-checks { grid-template-columns: 1fr; }
  #clearFilters { margin-left: 0; }
}
