/* 私信助手发卡后台 — 深色侧边栏 + 浅色内容区 */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --primary: #2E6BE6;
    --primary-dark: #2058C7;
    --sidebar-bg: #1B2438;
    --sidebar-text: #9AA7BF;
    --bg: #F4F6FA;
    --card: #FFFFFF;
    --line: #E8ECF3;
    --text: #1C2536;
    --text2: #6B7A93;
    --green: #16A34A;
    --red: #DC2626;
    --orange: #D97706;
}

body {
    font-family: "Segoe UI", "Microsoft YaHei", -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
}

.layout { display: flex; min-height: 100vh; }

/* ===== 侧边栏 ===== */
.sidebar {
    width: 216px;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; bottom: 0; left: 0;
    z-index: 10;
}
.sidebar-brand {
    display: flex; align-items: center; gap: 10px;
    padding: 18px 16px;
    border-bottom: 1px solid rgba(255,255,255,.06);
}
.sidebar-brand img { width: 34px; height: 34px; border-radius: 8px; }
.brand-title { color: #fff; font-size: 16px; font-weight: 700; }
.brand-sub { font-size: 11px; margin-top: 2px; opacity: .7; }

.nav { flex: 1; padding: 12px 10px; }
.nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 11px 14px;
    border-radius: 9px;
    color: var(--sidebar-text);
    cursor: pointer;
    margin-bottom: 4px;
    font-size: 14px;
    user-select: none;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #E6ECF7; }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-item .ico { width: 18px; text-align: center; font-weight: 700; }
.sidebar-foot {
    padding: 14px 16px;
    font-size: 11px;
    opacity: .5;
    border-top: 1px solid rgba(255,255,255,.06);
}

/* ===== 主区 ===== */
.main { flex: 1; margin-left: 216px; display: flex; flex-direction: column; }
.topbar {
    background: var(--card);
    border-bottom: 1px solid var(--line);
    padding: 0 24px;
    height: 58px;
    display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; z-index: 5;
}
.topbar h1 { font-size: 17px; }
.pill {
    background: #EAF1FF; color: var(--primary);
    font-size: 12px; padding: 5px 12px; border-radius: 999px;
}
.content { padding: 20px 24px 40px; }

.view { display: none; }
.view.active { display: block; }

/* ===== 统计卡 ===== */
.stat-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 16px; }
.stat-card {
    background: var(--card); border: 1px solid var(--line); border-radius: 12px;
    padding: 16px; text-align: center;
}
.stat-num { font-size: 26px; font-weight: 800; color: var(--text); }
.stat-num.green { color: var(--green); }
.stat-num.blue { color: var(--primary); }
.stat-num.orange { color: var(--orange); }
.stat-num.red { color: var(--red); }
.stat-label { font-size: 12px; color: var(--text2); margin-top: 4px; }

/* ===== 卡片 ===== */
.card {
    background: var(--card); border: 1px solid var(--line); border-radius: 12px;
    padding: 16px 18px; margin-bottom: 16px;
}
.card-head {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 12px;
}
.card-head h3 { font-size: 15px; }
.muted { color: var(--text2); font-size: 13px; }
.link { color: var(--primary); cursor: pointer; font-size: 13px; text-decoration: none; }

.type-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; }
.type-cell { background: #F7F9FC; border: 1px solid var(--line); border-radius: 10px; padding: 10px; text-align: center; }
.type-cell b { display: block; font-size: 18px; }
.type-cell span { font-size: 12px; color: var(--text2); }

/* ===== 表格 ===== */
.table { width: 100%; border-collapse: collapse; }
.table th {
    text-align: left; font-size: 12px; color: var(--text2);
    padding: 8px 10px; border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
.table td { padding: 9px 10px; border-bottom: 1px solid #F1F4F9; font-size: 13px; vertical-align: middle; }
.table tr:hover td { background: #F8FAFE; }
.mono { font-family: Consolas, monospace; font-size: 12.5px; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; }
.badge.unused  { background: #E9F8F0; color: var(--green); }
.badge.sold    { background: #EAF1FF; color: var(--primary); }
.badge.renewed { background: #FFF4E0; color: var(--orange); }
.badge.void    { background: #FDECEC; color: var(--red); }

.empty { text-align: center; color: var(--text2); padding: 36px 0; }

/* ===== 表单 ===== */
.form-row { display: flex; gap: 14px; margin-bottom: 14px; flex-wrap: wrap; }
.form-item { display: flex; flex-direction: column; gap: 6px; min-width: 150px; }
.form-item.grow { flex: 1; }
.form-item label { font-size: 12px; color: var(--text2); }
input, select, textarea {
    border: 1px solid #D9DEE8; border-radius: 9px;
    padding: 9px 11px; font-size: 14px; outline: none;
    background: #fff; color: var(--text);
    font-family: inherit;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); }

.type-picker { display: flex; gap: 8px; flex-wrap: wrap; }
.type-opt {
    padding: 9px 18px; border: 1px solid #D9DEE8; border-radius: 9px;
    cursor: pointer; user-select: none; background: #fff; font-size: 14px;
}
.type-opt:hover { border-color: var(--primary); }
.type-opt.on { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }

.checkbox { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); cursor: pointer; }
.checkbox input { width: 16px; height: 16px; }

.tip-box {
    background: #F7F9FC; border: 1px dashed #C9D4E6;
    border-radius: 9px; padding: 10px 12px; font-size: 12.5px; color: var(--text2);
    align-self: flex-end;
}

/* ===== 按钮 ===== */
.btn {
    border: 1px solid #D9DEE8; background: #fff; color: var(--text);
    padding: 9px 18px; border-radius: 9px; cursor: pointer; font-size: 13.5px;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.small { padding: 5px 12px; font-size: 12.5px; }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.danger:hover { background: #B91C1C; }
.btn.link-btn { border: none; background: none; color: var(--primary); padding: 2px 6px; font-size: 12.5px; }
.btn.link-btn.red { color: var(--red); }
.btn-row { display: flex; gap: 10px; margin-top: 10px; }
.btn-row.right { justify-content: flex-end; }

.mono-box {
    width: 100%; font-family: Consolas, monospace; font-size: 13px;
    background: #FBFCFE; line-height: 1.9; resize: vertical;
}

.filter-bar { display: flex; gap: 10px; flex: 1; }
.filter-bar input { flex: 1; max-width: 320px; }

/* ===== 弹窗 ===== */
.modal-mask {
    position: fixed; inset: 0; background: rgba(15,23,42,.45);
    display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal {
    background: #fff; border-radius: 14px; padding: 22px;
    width: 400px; max-width: 92vw;
}
.modal h3 { margin-bottom: 8px; }
.modal .form-item { margin-bottom: 12px; width: 100%; }
.modal select { width: 100%; }
.modal-tip {
    background: #F7F9FC; border: 1px dashed #C9D4E6; border-radius: 9px;
    padding: 9px 12px; font-size: 12.5px; color: var(--text2); margin-bottom: 8px;
}

/* ===== Toast ===== */
.toast {
    position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%);
    background: rgba(28,37,54,.92); color: #fff;
    padding: 10px 22px; border-radius: 999px; font-size: 13.5px;
    opacity: 0; pointer-events: none; transition: opacity .25s;
    z-index: 200;
}
.toast.show { opacity: 1; }

.danger-zone { border-color: #F5C6C6; }

.help-text p { line-height: 1.9; margin-bottom: 10px; font-size: 13.5px; color: #3A4658; }
.help-text b { color: var(--text); }

@media (max-width: 760px) {
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .type-grid { grid-template-columns: repeat(3, 1fr); }
}

/* 侧边栏用户信息 */
.sidebar-user {
    display: flex; align-items: center; gap: 10px;
    padding: 14px 16px; margin-top: auto;
    border-top: 1px solid #2a2f4a;
}
/* 侧边栏品牌 logo */
.sidebar-brand .brand-logo {
    width: 34px; height: 34px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
}
.user-avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: linear-gradient(135deg, #4f6ef7, #7c5cfc);
    color: #fff; display: flex; align-items: center; justify-content: center;
    font-size: 14px; font-weight: 600; flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 13px; color: #e8eaf6; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: #8c92a4; }
.btn-logout {
    height: 30px; padding: 0 12px; border-radius: 6px;
    background: transparent; border: 1px solid #3a3f5a; color: #aab0c8;
    cursor: pointer; font-size: 12px; transition: all 0.2s;
    white-space: nowrap;
}
.btn-logout:hover { background: #3a3f5a; color: #fff; }

/* 实时刷新指示器 */
.live-dot {
    display: inline-block; width: 7px; height: 7px; border-radius: 50%;
    background: #4caf50; margin-right: 5px; animation: pulse 2s infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }
