/* ================= 后台样式 ================= */
:root {
    --bg: #0d1017;
    --bg-soft: #141824;
    --bg-card: #171c28;
    --line: #242a3a;
    --text: #e9ecf5;
    --text-dim: #98a0b6;
    --accent: #4f7cff;
    --accent-2: #6ea8ff;
    --danger: #ff5566;
    --ok: #35d07f;
    --radius: 12px;
}

* { box-sizing: border-box; }

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

a { color: inherit; text-decoration: none; }
h1, h2 { margin: 0; font-weight: 700; }
input, select, textarea, button { font-family: inherit; font-size: 14px; }

/* ---------------- 登录页 ---------------- */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: radial-gradient(1200px 600px at 50% -10%, #1d2743 0%, #0b0e15 60%);
    padding: 20px;
}
.login-box {
    width: 100%;
    max-width: 380px;
    background: var(--bg-card);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 28px 26px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .45);
}
.login-title { font-size: 22px; text-align: center; }
.login-sub { text-align: center; color: var(--text-dim); margin: 6px 0 20px; font-size: 13px; }
.login-tip { color: var(--text-dim); font-size: 12px; margin: 16px 0 0; line-height: 1.7; }
.login-tip code { background: #232a3c; padding: 1px 5px; border-radius: 4px; }

/* ---------------- 布局 ---------------- */
.admin-body { display: flex; min-height: 100vh; }

.sidebar {
    width: 210px;
    flex: 0 0 210px;
    background: #0f131c;
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    padding: 16px 12px;
    position: sticky;
    top: 0;
    height: 100vh;
}
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 16px;
    padding: 4px 8px 16px;
}
.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px; height: 26px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    font-size: 12px;
}
.sidebar-nav { display: flex; flex-direction: column; gap: 3px; }
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 9px 11px;
    border-radius: 9px;
    color: var(--text-dim);
    transition: .16s;
}
.sidebar-link:hover { background: #ffffff0d; color: #fff; }
.sidebar-link.is-active { background: linear-gradient(135deg, #2b3a63, #1e2740); color: #fff; }
.sidebar-icon { width: 18px; text-align: center; }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 3px; }
.sidebar-user { color: #5f687e; font-size: 12px; margin: 8px 0 0; padding: 0 11px; }

.admin-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.admin-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 24px;
    border-bottom: 1px solid var(--line);
    background: #10141d;
    position: sticky;
    top: 0;
    z-index: 20;
}
.admin-title { font-size: 19px; }
.admin-content { padding: 22px 24px 60px; }

/* ---------------- 通用控件 ---------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 38px;
    padding: 0 16px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #1b2130;
    color: var(--text);
    transition: .16s;
    white-space: nowrap;
    cursor: pointer;
}
.btn:hover { border-color: #37405a; background: #212839; }
.btn-primary {
    border: none;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #fff;
    font-weight: 600;
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-danger { border-color: #6b2733; background: #341a20; color: #ff9aa5; }
.btn-danger:hover { background: #46222b; }
.btn-ghost { background: transparent; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn-block { width: 100%; margin-top: 8px; }

.alert {
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: var(--bg-soft);
    margin-bottom: 16px;
}
.alert a { color: var(--accent-2); text-decoration: underline; }
.alert-success { border-color: #1e6b48; background: #10241b; color: #86efb6; }
.alert-error { border-color: #6b2733; background: #2b151a; color: #ff9aa5; }
.alert-warn { border-color: #6b5a1e; background: #262110; color: #f0d479; }
.error-list { margin: 0; padding-left: 18px; }

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}
.stat-card {
    background: linear-gradient(160deg, #1a2133, #141824);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.stat-value { font-size: 26px; font-weight: 800; }
.stat-label { color: var(--text-dim); font-size: 13px; }

.panel {
    background: var(--bg-card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px 20px;
    margin-bottom: 18px;
}
.panel-title {
    font-size: 16px;
    margin-bottom: 14px;
    padding-left: 10px;
    border-left: 3px solid var(--accent);
    line-height: 1.2;
}
.panel-hint { color: var(--text-dim); font-size: 12px; font-weight: 400; margin-left: 6px; }
.panel-row { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.quick-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------------- 表单 ---------------- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-full { grid-column: 1 / -1; }
.field-label { color: var(--text-dim); font-size: 13px; }
.req { color: var(--danger); font-style: normal; }
.field-help { color: #5f687e; font-size: 12px; }
.field input[type="text"],
.field input[type="password"],
.field input[type="number"],
.field input[type="search"],
.field input[type="file"],
.field select,
.field textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: #10141d;
    color: var(--text);
    outline: none;
    transition: .16s;
}
.field textarea { resize: vertical; line-height: 1.7; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); }
.field input[type="file"] { padding: 7px; }
.check { display: flex; align-items: center; gap: 6px; color: var(--text-dim); font-size: 13px; cursor: pointer; }
.check input { width: auto; }
.poster-preview {
    width: 150px;
    height: 214px;
    object-fit: cover;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: #10141d;
}
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; }

/* 播放线路编辑 */
.source-row {
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #10141d;
    padding: 12px;
    margin-bottom: 12px;
}
.source-row-head {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}
.source-row-no { color: var(--text-dim); font-size: 13px; white-space: nowrap; }
.source-row-head .source-label { flex: 1; min-width: 150px; }
.source-row-head input,
.source-row-head select {
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: #0d1017;
    color: var(--text);
    outline: none;
    transition: .16s;
}
.source-row-body input,
.source-row-body textarea {
    display: block;
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: #0d1017;
    color: var(--text);
    outline: none;
    resize: vertical;
    transition: .16s;
}
.source-row-head input:focus,
.source-row-head select:focus,
.source-row-body input:focus,
.source-row-body textarea:focus { border-color: var(--accent); }
.source-cell[hidden] { display: none; }
.source-parse { display: block; margin-top: 6px; word-break: break-all; }
.source-parse.is-ok { color: #7ee2ac; }
.source-parse.is-bad { color: #ff9aa5; }

/* ---------------- 表格 ---------------- */
.toolbar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 16px;
}
.toolbar input, .toolbar select {
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: #10141d;
    color: var(--text);
    outline: none;
}
.toolbar-input { flex: 1; min-width: 200px; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-card); }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; font-size: 13px; vertical-align: middle; }
.table th { background: #10141d; color: var(--text-dim); font-weight: 600; white-space: nowrap; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #ffffff06; }
.table a:hover { color: var(--accent-2); }
.ta-r { text-align: right; }
.ta-c { text-align: center; }
.thumb { width: 40px; height: 56px; object-fit: cover; border-radius: 6px; background: #10141d; }
.cell-title { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.cell-warn { color: #f0d479; font-size: 12px; }
.cell-actions { white-space: nowrap; display: flex; gap: 10px; justify-content: flex-end; align-items: center; flex-wrap: wrap; }
.inline-form { display: inline; }
.link { background: none; border: none; padding: 0; color: var(--accent-2); cursor: pointer; font-size: 13px; }
.link:hover { text-decoration: underline; }
.link-danger { color: #ff8b96; }
.bulk-bar { display: flex; align-items: center; gap: 12px; margin: 14px 0; }
.empty-box {
    padding: 40px 20px;
    text-align: center;
    border: 1px dashed var(--line);
    border-radius: var(--radius);
    background: var(--bg-soft);
}
.muted { color: var(--text-dim); }

.tag {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 10px;
    font-size: 12px;
    line-height: 18px;
    background: #ffffff12;
    color: var(--text-dim);
}
.tag-on { background: #123322; color: #7ee2ac; }
.tag-off { background: #33201f; color: #ffa8a0; }
.tag-rec { background: #2a2a12; color: #f0d479; }
.tag-slider { background: #1c2440; color: #9ec1ff; }
.tag-src { background: #232a3c; color: #cdd6ea; }

/* ---------------- 分页 ---------------- */
.pager { display: flex; align-items: center; justify-content: center; gap: 6px; flex-wrap: wrap; margin: 22px 0 8px; }
.pager-btn, .pager-num {
    min-width: 34px;
    height: 34px;
    padding: 0 11px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 9px;
    border: 1px solid var(--line);
    background: #161b27;
    color: var(--text-dim);
    font-size: 13px;
}
.pager-num.is-active { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border-color: transparent; color: #fff; font-weight: 700; }
.pager-btn.is-disabled { opacity: .4; }
.pager-gap { color: var(--text-dim); }

/* ---------------- 响应式 ---------------- */
@media (max-width: 900px) {
    .admin-body { flex-direction: column; }
    .sidebar { width: 100%; flex: none; height: auto; position: static; flex-direction: column; }
    .sidebar-nav { flex-direction: row; flex-wrap: wrap; }
    .sidebar-foot { flex-direction: row; flex-wrap: wrap; margin-top: 8px; }
    .grid-2, .grid-3, .panel-row { grid-template-columns: 1fr; }
    .admin-content { padding: 16px; }
}
