:root {
    --bg: #f4f6fb;
    --panel: #ffffff;
    --line: #e5e9f2;
    --text: #172033;
    --muted: #7a8499;
    --primary: #e93b5a;
    --primary-dark: #c91e44;
    --blue: #2f6df6;
    --teal: #08a89d;
    --amber: #d69018;
    --bad: #d92d48;
    --ok: #168a52;
    --shadow: 0 18px 45px rgba(20, 32, 55, .08);
}
* { box-sizing: border-box; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "Inter", "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
    font-size: 14px;
}
a { color: inherit; text-decoration: none; }
input, select, textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    padding: 10px 12px;
    font: inherit;
    outline: none;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: rgba(233, 59, 90, .6); box-shadow: 0 0 0 3px rgba(233, 59, 90, .08); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: 12px; font-weight: 700; background: #fafbfe; }
td small { display: block; color: var(--muted); margin-top: 3px; max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 24px 18px;
    background: #111827;
    color: #d8deea;
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.brand { display: flex; gap: 12px; align-items: center; margin-bottom: 26px; }
.brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, #ff4164, #2f6df6);
    color: #fff;
    font-weight: 800;
}
.brand strong { display: block; color: #fff; font-size: 16px; }
.brand span { color: #95a0b8; font-size: 12px; }
.sidebar nav {
    display: grid;
    gap: 6px;
    min-height: 0;
    overflow-y: auto;
    padding-bottom: 12px;
}
.sidebar nav a {
    padding: 11px 12px;
    border-radius: 8px;
    color: #abb4c8;
}
.sidebar nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar nav a.active { background: #fff; color: #111827; box-shadow: var(--shadow); }
.sidebar-card {
    margin-top: auto;
    border: 1px solid rgba(255,255,255,.10);
    background: rgba(255,255,255,.06);
    border-radius: 12px;
    padding: 14px;
    flex: 0 0 auto;
}
.sidebar-card span, .sidebar-card small { color: #95a0b8; display: block; }
.sidebar-card strong { color: #fff; display: block; margin: 6px 0; }
.main { min-width: 0; padding: 24px; }
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}
.topbar h1 { margin: 0; font-size: 24px; }
.topbar p { margin: 6px 0 0; color: var(--muted); }
.top-actions { display: flex; gap: 10px; }
.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: var(--shadow);
    padding: 18px;
    margin-bottom: 18px;
    overflow: auto;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.panel-head h2 { margin: 0; font-size: 17px; }
.muted { color: var(--muted); }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 18px; }
.stat-card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 18px;
    box-shadow: var(--shadow);
}
.stat-card span { color: var(--muted); font-size: 12px; }
.stat-card strong { display: block; margin: 8px 0; font-size: 30px; line-height: 1; }
.stat-card small { color: var(--muted); }
.grid-2 { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 18px; }
.form-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; align-items: start; }
.form-grid.wide { grid-template-columns: 1.3fr 1fr 1fr 1fr .8fr .8fr auto; }
.filter-bar { display: grid; grid-template-columns: 260px 160px auto 1fr; gap: 10px; margin-bottom: 14px; align-items: center; }
.filter-bar.slots-filter { grid-template-columns: 240px 220px 150px auto auto 1fr; }
.batch-form { display: grid; gap: 10px; margin-bottom: 18px; padding: 14px; border: 1px solid var(--line); border-radius: 10px; background: #fafbfe; }
.batch-row { display: grid; grid-template-columns: 160px 160px 1fr auto; gap: 10px; align-items: center; }
.stack-form { display: grid; gap: 10px; }
.inline-form { display: grid; grid-template-columns: 120px 92px auto; gap: 6px; align-items: center; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; min-width: 260px; }
.actions form { margin: 0; }
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 10px 14px;
    background: #fff;
    color: var(--text);
    cursor: pointer;
    font-weight: 700;
    white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-light { background: #f7f9fc; border-color: var(--line); }
.btn-warn { background: #fff6e6; color: #9a6100; border-color: #f5d394; }
.btn-danger-outline { color: var(--bad); border-color: rgba(217,45,72,.35); background: #fff; }
.btn-sm { padding: 7px 10px; font-size: 12px; border-color: var(--line); background: #fff; }
.slot-renew-form { display: inline-flex; }
.btn-renew-month { background: #eef4ff; color: #1d4ed8; border-color: rgba(47, 109, 246, .28); }
.btn-renew-hour { background: #fff7e8; color: #a15c00; border-color: rgba(214, 144, 24, .35); }
.btn-block { width: 100%; }
.tag {
    display: inline-flex;
    border-radius: 999px;
    padding: 4px 9px;
    background: #eef1f6;
    color: #637083;
    font-size: 12px;
    font-weight: 700;
}
.tag.ok { background: #e8f7ef; color: var(--ok); }
.tag.bad { background: #fdecef; color: var(--bad); }
.tag.blue { background: #edf3ff; color: var(--blue); }
.tag.amber { background: #fff6e4; color: var(--amber); }
.alert {
    border-radius: 8px;
    padding: 12px 14px;
    margin-bottom: 16px;
    border: 1px solid var(--line);
}
.alert-success { background: #e8f7ef; color: var(--ok); border-color: #bfe8d2; }
.alert-error { background: #fdecef; color: var(--bad); border-color: #f8ccd5; }
.trend { height: 140px; display: grid; grid-template-columns: repeat(7, 1fr); gap: 18px; align-items: end; padding-top: 10px; }
.trend-day { height: 112px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; align-items: end; position: relative; padding-top: 20px; }
.trend-day span { position: absolute; left: 0; top: 0; font-size: 12px; color: var(--muted); }
.trend-day i { display: block; border-radius: 5px 5px 0 0; background: var(--blue); min-height: 6px; }
.trend-day i.teal { background: var(--teal); }
.trend-day i.amber { background: var(--amber); }
.config-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.config-grid label span { display: block; color: var(--muted); font-weight: 700; margin-bottom: 6px; }
.url-cell { max-width: 520px; word-break: break-all; color: #344054; }
.card-template-panel { overflow: visible; }
.card-template-uploader {
    display: grid;
    grid-template-columns: minmax(260px, 360px) 1fr;
    gap: 14px;
    margin-bottom: 18px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fafbfe;
}
.upload-box {
    display: grid;
    gap: 8px;
    align-content: center;
    min-height: 128px;
    padding: 18px;
    border: 1px dashed #cbd5e1;
    border-radius: 10px;
    background: #fff;
}
.upload-copy { display: grid; gap: 4px; }
.upload-box strong { font-size: 15px; }
.upload-box span { color: var(--muted); line-height: 1.6; }
.upload-picker {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 12px;
    background: #f8fafc;
}
.upload-picker input { display: none; }
.upload-picker b { display: block; color: var(--text); line-height: 1.2; }
.upload-picker small { display: block; color: var(--muted); margin-top: 3px; }
.upload-plus {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    border-radius: 9px;
    background: #edf3ff;
    color: var(--blue);
    font-size: 22px;
    font-weight: 800;
}
.template-form-fields {
    display: grid;
    grid-template-columns: minmax(160px, 1fr) minmax(260px, 1.6fr) 130px 120px auto;
    gap: 10px;
    align-items: center;
}
.template-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 14px;
}
.template-card {
    display: grid;
    grid-template-rows: auto 1fr auto;
    min-width: 0;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
}
.template-preview {
    aspect-ratio: 16 / 9;
    background: #111827;
    overflow: hidden;
}
.template-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.template-info {
    display: grid;
    gap: 7px;
    min-width: 0;
    padding: 12px;
}
.template-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-width: 0;
}
.template-title strong {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.template-url {
    display: block;
    min-width: 0;
    overflow: hidden;
    color: #344054;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.template-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 10px 12px 12px;
    border-top: 1px solid var(--line);
}
.template-actions form { margin: 0; }
.empty-state {
    display: grid;
    place-items: center;
    gap: 8px;
    min-height: 180px;
    border: 1px dashed #cbd5e1;
    border-radius: 10px;
    background: #fafbfe;
    color: var(--muted);
}
.empty-state strong { color: var(--text); font-size: 16px; }
.task-list { display: flex; gap: 10px; flex-wrap: wrap; }
.cookie-source { display: none; }
.modal-mask {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgba(17, 24, 39, .46);
}
.modal-mask[hidden] { display: none; }
.modal-card {
    width: min(760px, 100%);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: 0 28px 80px rgba(17, 24, 39, .22);
    padding: 18px;
}
.modal-head, .modal-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.modal-head { margin-bottom: 14px; }
.modal-head h3 { margin: 0; font-size: 17px; }
.modal-card textarea {
    min-height: 240px;
    font-family: Consolas, "Microsoft YaHei", monospace;
    word-break: break-all;
}
.modal-actions { margin-top: 12px; }
.login-body {
    min-height: 100vh;
    background: #f4f6fb;
}
.login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}
.login-panel {
    width: min(100%, 420px);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 30px;
    box-shadow: 0 18px 45px rgba(20, 32, 55, .10);
}
.login-brand {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 26px;
}
.login-brand .brand-mark {
    width: 40px;
    height: 40px;
    border-radius: 8px;
}
.login-brand h1 { margin: 0; font-size: 22px; line-height: 1.2; }
.login-brand p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.login-form { display: grid; gap: 10px; }
.login-form label { color: #667085; font-size: 13px; font-weight: 700; }
.login-form input { height: 44px; }
.login-form .btn { height: 46px; margin-top: 4px; }
.login-foot { color: var(--muted); font-size: 12px; margin: 16px 0 0; text-align: center; }
.login-side { display: none; }
.metric-glass { max-width: 520px; padding: 34px; border: 1px solid rgba(255,255,255,.18); border-radius: 18px; background: rgba(255,255,255,.08); }
.metric-glass span { color: #bac4d8; }
.metric-glass strong { display: block; margin: 12px 0; font-size: 44px; }
.metric-glass p { color: #d8deea; line-height: 1.7; }
@media (max-width: 1180px) {
    .app-shell { grid-template-columns: 210px 1fr; }
    .stats-grid, .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .form-grid, .form-grid.wide { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .card-template-uploader, .template-form-fields { grid-template-columns: 1fr; }
    .filter-bar.slots-filter { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
    .app-shell { display: block; }
    .sidebar { position: static; height: auto; }
    .sidebar-card { position: static; margin-top: 16px; }
    .main { padding: 16px; }
    .stats-grid, .grid-2, .config-grid, .login-shell { grid-template-columns: 1fr; }
    .filter-bar, .filter-bar.slots-filter { grid-template-columns: 1fr; }
    .template-gallery { grid-template-columns: 1fr; }
    .login-shell { min-height: 100vh; padding: 16px; }
    .login-panel { padding: 24px; }
}
