:root {
    --bg-dark: #1a1a1a;
    --bg-darker: #0f0f0f;
    --bg-deepest: #050505;
    --brand-red: #dc2626;
    --brand-red-hover: #b91c1c;
    --brand-red-soft: rgba(220, 38, 38, 0.12);
    --brand-red-line: rgba(220, 38, 38, 0.45);
    --text-light: #f5f5f5;
    --text-muted: #9ca3af;
    --text-dark: #1f2937;
    --border-soft: rgba(255, 255, 255, 0.08);
    --content-bg: #f5f7fa;
    --c-success: #10b981;
    --c-warn: #f59e0b;
    --c-info: #3b82f6;
    --c-purple: #8b5cf6;
    --c-pink: #ec4899;
    --c-teal: #06b6d4;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
    color: var(--text-dark);
    background: var(--content-bg);
}

a { text-decoration: none; }

/* ========== 登录/注册公共布局 ========== */
.auth-shell {
    min-height: 100vh;
    display: flex;
}

.auth-side {
    flex: 1.1;
    background:
        radial-gradient(1200px 600px at 0% 0%, rgba(220,38,38,0.45), transparent 60%),
        radial-gradient(1000px 600px at 100% 100%, rgba(220,38,38,0.25), transparent 60%),
        linear-gradient(135deg, #0a0a0a 0%, #1a1a1a 60%, #2a0707 100%);
    color: var(--text-light);
    padding: 56px 64px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.auth-side::before {
    content: "";
    position: absolute; inset: 0;
    background-image:
        linear-gradient(rgba(255,255,255,0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.04) 1px, transparent 1px);
    background-size: 36px 36px;
    pointer-events: none;
}

.auth-brand {
    display: flex; align-items: center; gap: 14px;
    margin-bottom: 24px;
}
.auth-brand-icon {
    width: 56px; height: 56px;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--brand-red), #7f1d1d);
    display: flex; align-items: center; justify-content: center;
    color: white; font-size: 28px;
    box-shadow: 0 10px 30px rgba(220,38,38,0.4);
}
.auth-brand-name { font-size: 28px; font-weight: 700; letter-spacing: 1px; }
.auth-brand-sub { color: var(--text-muted); font-size: 14px; margin-top: 2px; }

.auth-tagline {
    font-size: 32px;
    line-height: 1.4;
    font-weight: 600;
    margin: 18px 0 12px;
    background: linear-gradient(90deg, #fff, #fca5a5);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.auth-desc {
    color: var(--text-muted);
    font-size: 15px;
    line-height: 1.8;
    max-width: 540px;
    margin-bottom: 32px;
}

.auth-features {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    max-width: 580px;
}
.auth-feature {
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border-soft);
    border-radius: 14px;
    padding: 16px 18px;
    backdrop-filter: blur(6px);
    transition: transform .2s, border-color .2s;
}
.auth-feature:hover { transform: translateY(-3px); border-color: var(--brand-red-line); }
.auth-feature-icon {
    width: 40px; height: 40px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px; color: white;
    margin-bottom: 10px;
}
.auth-feature-title { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.auth-feature-desc { color: var(--text-muted); font-size: 12px; line-height: 1.6; }

.auth-form-area {
    flex: 0.9;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fafafa;
    padding: 40px 30px;
}
.auth-card {
    width: 100%;
    max-width: 420px;
    background: white;
    border-radius: 16px;
    padding: 40px 36px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.08);
}
.auth-card h2 {
    margin: 0 0 6px;
    font-size: 26px;
    color: var(--text-dark);
}
.auth-card .auth-sub { color: #6b7280; font-size: 14px; margin-bottom: 28px; }

.form-control:focus {
    border-color: var(--brand-red);
    box-shadow: 0 0 0 0.2rem rgba(220,38,38,0.12);
}
.btn-brand {
    background: linear-gradient(135deg, var(--brand-red), #991b1b);
    color: #fff;
    border: 0;
    font-weight: 600;
    letter-spacing: 1px;
    padding: 10px 20px;
    transition: filter .2s, transform .2s;
}
.btn-brand:hover { color: #fff; filter: brightness(1.05); transform: translateY(-1px); }
.btn-brand:disabled { filter: grayscale(0.3) brightness(0.9); }
.text-brand { color: var(--brand-red); }
.text-brand:hover { color: var(--brand-red-hover); }

/* ========== 后台布局 ========== */
.layout {
    min-height: 100vh;
}
.app-topbar {
    position: fixed; top: 0; left: 0; right: 0;
    height: 56px; z-index: 1030;
    background: var(--bg-dark);
    border-bottom: 1px solid var(--border-soft);
    display: flex; align-items: center;
    padding: 0 20px;
    color: var(--text-light);
}
.app-topbar .brand {
    display: flex; align-items: center; gap: 10px;
    font-size: 18px; font-weight: 700;
    margin-right: 30px;
}
.app-topbar .brand-icon {
    width: 32px; height: 32px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--brand-red), #7f1d1d);
    display: flex; align-items: center; justify-content: center;
    color: #fff;
}
.app-topbar .brand-name {
    background: linear-gradient(90deg, #fff, #fecaca);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.app-topbar .toggle-side {
    background: transparent; border: 0; color: var(--text-light);
    font-size: 18px; cursor: pointer; margin-right: 12px;
}
.app-topbar .topbar-right {
    margin-left: auto;
    display: flex; align-items: center; gap: 14px;
}
.app-topbar .user-chip {
    display: flex; align-items: center; gap: 8px;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: 20px;
    background: rgba(255,255,255,0.05);
    transition: background .2s;
}
.app-topbar .user-chip:hover { background: rgba(220,38,38,0.18); }
.app-topbar .user-avatar {
    width: 28px; height: 28px; border-radius: 50%;
    background: linear-gradient(135deg, var(--brand-red), #7f1d1d);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 13px;
}
.app-topbar .user-meta { font-size: 13px; line-height: 1.2; }
.app-topbar .user-meta .nm { color: #fff; }
.app-topbar .user-meta .mh { color: var(--text-muted); font-size: 12px; }

.app-side {
    position: fixed; top: 56px; bottom: 0; left: 0;
    width: 240px; z-index: 1020;
    background: var(--bg-darker);
    border-right: 1px solid var(--border-soft);
    overflow-y: auto;
    transition: width .2s;
}
.app-side.collapsed { width: 64px; }
.app-side .menu-group {
    padding: 8px 12px 4px; font-size: 11px;
    color: var(--text-muted); letter-spacing: 1px;
    text-transform: uppercase;
    display: flex; align-items: center; gap: 8px;
}
.app-side.collapsed .menu-group { display: none; }
.app-side .menu-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px; margin: 2px 8px;
    color: #d1d5db; font-size: 14px;
    border-radius: 8px;
    cursor: pointer; user-select: none;
    position: relative;
    transition: background .15s, color .15s;
}
.app-side .menu-item .menu-ico {
    width: 22px; text-align: center;
    font-size: 16px;
    flex-shrink: 0;
}
.app-side .menu-item .menu-text { flex: 1; }
.app-side .menu-item:hover { background: rgba(255,255,255,0.05); color: #fff; }
.app-side .menu-item.active {
    background: var(--brand-red-soft);
    color: #fff;
}
.app-side .menu-item.active::before {
    content: ""; position: absolute; left: 0; top: 6px; bottom: 6px;
    width: 4px; border-radius: 4px;
    background: var(--brand-red);
}
.app-side.collapsed .menu-item .menu-text { display: none; }

.app-main {
    margin-left: 240px;
    margin-top: 56px;
    padding: 0;
    transition: margin-left .2s;
    min-height: calc(100vh - 56px);
    background: var(--content-bg);
}
.app-main.collapsed { margin-left: 64px; }

.tab-bar {
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    padding: 6px 12px 0;
    display: flex; align-items: end; gap: 4px;
    overflow-x: auto;
    position: sticky; top: 0; z-index: 10;
}
.tab-item {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 14px;
    background: #f3f4f6; color: #374151;
    border-radius: 6px 6px 0 0;
    font-size: 13px;
    cursor: pointer;
    border: 1px solid transparent;
    border-bottom: 0;
    flex-shrink: 0;
    transition: background .15s;
}
.tab-item:hover { background: #e5e7eb; }
.tab-item.active {
    background: #fff; color: var(--brand-red);
    border-color: #e5e7eb;
    font-weight: 600;
}
.tab-item .tab-close {
    margin-left: 4px;
    color: #9ca3af; font-size: 14px;
    line-height: 1;
    border-radius: 50%;
    width: 18px; height: 18px;
    display: inline-flex; align-items: center; justify-content: center;
}
.tab-item .tab-close:hover { background: #fecaca; color: var(--brand-red); }

.tab-content-wrap {
    padding: 0;
    background: #fff;
}
.tab-pane {
    display: none;
    padding: 24px;
    min-height: calc(100vh - 56px - 44px);
}
.tab-pane.active { display: block; }
.tab-pane .page-title {
    text-align: center;
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--brand-red-soft);
}

/* ========== 仪表盘卡片 ========== */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.kpi-card {
    background: #fff;
    border-radius: 12px;
    padding: 20px 22px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.04);
    border: 1px solid #f1f5f9;
    display: flex; gap: 16px;
    align-items: center;
    transition: transform .2s, box-shadow .2s;
}
.kpi-card:hover { transform: translateY(-3px); box-shadow: 0 8px 24px rgba(0,0,0,0.08); }
.kpi-icon {
    width: 56px; height: 56px;
    border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 26px;
}
.kpi-label { color: #6b7280; font-size: 13px; }
.kpi-value { color: var(--text-dark); font-size: 24px; font-weight: 700; line-height: 1.2; }

/* ========== 通用 ========== */
.section-card {
    background: #fff;
    border-radius: 12px;
    padding: 20px 22px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.04);
    border: 1px solid #f1f5f9;
    margin-bottom: 16px;
}
.section-card-title {
    font-size: 15px; font-weight: 600;
    margin-bottom: 14px;
    display: flex; align-items: center; gap: 8px;
}

table.table.brand thead th {
    background: #1a1a1a; color: #fff;
    border-color: #1a1a1a;
    font-weight: 500;
    font-size: 13px;
}
table.table.brand tbody td { font-size: 13px; vertical-align: middle; }

.btn-outline-brand {
    border: 1px solid var(--brand-red);
    color: var(--brand-red);
    background: transparent;
}
.btn-outline-brand:hover { background: var(--brand-red); color: #fff; }

/* ========== Toast ========== */
.toast-stack {
    position: fixed; top: 76px; right: 20px;
    z-index: 1080; display: flex; flex-direction: column; gap: 8px;
}
.toast-msg {
    display: flex; align-items: center; gap: 10px;
    background: #fff;
    padding: 12px 16px;
    border-radius: 10px;
    box-shadow: 0 6px 24px rgba(0,0,0,0.12);
    border-left: 4px solid var(--c-info);
    font-size: 13px;
    min-width: 240px;
    animation: toast-in .2s ease-out;
}
.toast-msg.success { border-color: var(--c-success); }
.toast-msg.error { border-color: var(--c-warn); }
.toast-msg.warn { border-color: var(--c-warn); }
.toast-msg .ico { font-size: 18px; }
.toast-msg.info .ico { color: var(--c-info); }
.toast-msg.success .ico { color: var(--c-success); }
.toast-msg.error .ico { color: var(--brand-red); }
.toast-msg.warn .ico { color: var(--c-warn); }
@keyframes toast-in {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

/* 滚动条 */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.18); border-radius: 4px; }
.app-side::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.18); }
