/* =========================================================
   宁佳CRM 设计系统
   - 基于 CSS 变量，统一配色 / 间距 / 圆角 / 阴影
   - 深色侧边栏 + 浅色内容区，现代后台观感
   - 响应式：窄屏侧边栏转为顶部横向导航
   ========================================================= */
:root {
    --primary: #2563eb;
    --primary-d: #1d4ed8;
    --primary-l: #eff4ff;
    --bg: #f1f5f9;
    --surface: #ffffff;
    --side-bg: #0f172a;
    --side-bg2: #111827;
    --side-text: #cbd5e1;
    --side-muted: #64748b;
    --side-active: #2563eb;
    --top-bg: #0f172a;
    --text: #1e293b;
    --muted: #64748b;
    --border: #e2e8f0;
    --radius: 10px;
    --radius-sm: 7px;
    --shadow: 0 1px 2px rgba(15,23,42,.06), 0 6px 18px rgba(15,23,42,.06);
    --shadow-sm: 0 1px 2px rgba(15,23,42,.05);
    --ok: #16a34a;
    --warn: #d97706;
    --danger: #dc2626;
    --info: #2563eb;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
    margin: 0; background: var(--bg); color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
    font-size: 14px; line-height: 1.5;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- 图标 ---------- */
.icon { width: 18px; height: 18px; display: inline-block; vertical-align: -4px; flex: none; }
.who .icon, .quit .icon { width: 18px; height: 18px; }

/* ---------- 应用骨架 ---------- */
.app { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
    height: 56px; background: var(--top-bg); color: #fff;
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 20px; position: sticky; top: 0; z-index: 30;
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 600; font-size: 16px; }
.brand .logo { color: var(--primary); display: inline-flex; }
.brand .logo .icon { width: 22px; height: 22px; }
.brand .ver { font-size: 11px; color: #94a3b8; font-weight: 400; }
.top-right { display: flex; align-items: center; gap: 14px; }
.who { display: flex; align-items: center; gap: 8px; font-size: 13px; color: #e2e8f0; }
.who .avatar {
    width: 28px; height: 28px; border-radius: 50%; background: var(--primary);
    color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600;
}
.who .role { font-style: normal; background: #334155; color: #cbd5e1; padding: 1px 8px; border-radius: 10px; font-size: 11px; }
.quit { color: #94a3b8; display: inline-flex; padding: 6px; border-radius: 6px; }
.quit:hover { background: #1e293b; color: #fff; text-decoration: none; }

.app-body { flex: 1; display: flex; align-items: stretch; }

/* ---------- 侧边栏 ---------- */
.side {
    width: 232px; flex: 0 0 232px; background: var(--side-bg);
    border-right: 1px solid #1f2937; padding: 14px 12px;
}
.side nav ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.side li a {
    display: flex; align-items: center; gap: 11px;
    padding: 11px 14px; border-radius: var(--radius-sm);
    color: var(--side-text); border-left: 3px solid transparent;
}
.side li a .ic { color: var(--side-muted); display: inline-flex; }
.side li a:hover { background: var(--side-bg2); color: #fff; text-decoration: none; }
.side li a:hover .ic { color: #cbd5e1; }
.side li.active a { background: rgba(37,99,235,.16); color: #fff; border-left-color: var(--side-active); font-weight: 600; }
.side li.active a .ic { color: #93b4fb; }

/* ---------- 内容区 ---------- */
.content { flex: 1; min-width: 0; padding: 22px 26px 40px; }

/* ---------- 面包屑 ---------- */
.breadcrumb { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; margin-bottom: 14px; flex-wrap: wrap; }
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb .sep { color: #cbd5e1; display: inline-flex; }
.breadcrumb .sep .icon { width: 14px; height: 14px; }
.breadcrumb .cur { color: var(--text); font-weight: 600; }

/* ---------- 页面头部 ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .ph-title { margin: 0; font-size: 20px; font-weight: 700; color: var(--text); }
.page-head .ph-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ---------- 卡片 ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); margin-bottom: 18px; overflow: hidden; }
.card-head { padding: 14px 18px; font-size: 15px; font-weight: 600; border-bottom: 1px solid var(--border); background: #fafbfc; }
.card-body { padding: 18px; }

/* ---------- 区块标题 ---------- */
.section-title { margin: 22px 0 12px; font-size: 15px; font-weight: 600; border-left: 3px solid var(--primary); padding-left: 10px; color: var(--text); }

/* ---------- 统计卡 ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-sm); }
.stat .num { font-size: 28px; font-weight: 800; color: var(--primary); line-height: 1.1; }
.stat .lbl { color: var(--muted); margin-top: 6px; font-size: 13px; }
.stat:hover { text-decoration: none; border-color: #c7d6f0; }
.stat-warn .num { color: var(--warn); }
.stat-ok .num { color: var(--ok); }

/* ---------- 表格 ---------- */
.tbl { width: 100%; border-collapse: collapse; background: var(--surface); font-size: 13.5px; border-radius: var(--radius); overflow: hidden; }
.tbl th, .tbl td { padding: 11px 14px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.tbl th { background: #f8fafc; color: var(--muted); font-weight: 600; white-space: nowrap; }
.tbl tbody tr:hover { background: #f8fafd; }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl .op a { margin-right: 12px; }
.tbl .op a:last-child { margin-right: 0; }
.tbl .empty { text-align: center; color: #9aa3b2; padding: 28px 0; }

/* ---------- 表单 ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px 22px; max-width: 900px; }
.field { display: flex; flex-direction: column; min-width: 0; }
.field.full { grid-column: 1 / -1; }
.field label { margin-bottom: 6px; color: #475569; font-size: 13px; font-weight: 500; }
.field input, .field select, .field textarea {
    padding: 9px 12px; border: 1px solid #cbd5e1; border-radius: var(--radius-sm);
    font-size: 14px; background: #fff; color: var(--text); width: 100%; transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
    outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.field textarea { min-height: 84px; resize: vertical; }
.form-actions { margin-top: 20px; display: flex; gap: 10px; }

/* ---------- 按钮 ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: var(--radius-sm);
    border: 1px solid var(--primary); background: var(--primary); color: #fff; cursor: pointer;
    font-size: 14px; font-weight: 500; line-height: 1.2; transition: background .15s, box-shadow .15s; }
.btn:hover { background: var(--primary-d); text-decoration: none; color: #fff; }
.btn .icon { width: 16px; height: 16px; }
.btn-ghost { background: #fff; color: var(--primary); }
.btn-ghost:hover { background: var(--primary-l); }
.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn-danger { background: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: #b91c1c; }
.btn-success { background: var(--ok); border-color: var(--ok); }
.btn-success:hover { background: #15803d; }
.btn-row { margin-bottom: 14px; display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- 徽章 ---------- */
.badge { display: inline-flex; align-items: center; padding: 2px 10px; border-radius: 11px; font-size: 12px; background: #eef2f7; color: #475569; }
.badge-vip { background: #fde7f3; color: #c2185b; }
.badge-key { background: var(--primary-l); color: var(--primary-d); }
.badge-strategy { background: #fff3e0; color: var(--warn); }
.badge-ok { background: #dcfce7; color: #15803d; }
.badge-warn { background: #fef3c7; color: #b45309; }
.badge-danger { background: #fee2e2; color: #b91c1c; }
.badge-muted { background: #f1f5f9; color: #64748b; }

/* ---------- 提示条 ---------- */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 14px; border: 1px solid transparent; }
.alert-success { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }
.alert-error { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }
.alert-info { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }

/* ---------- 筛选栏 ---------- */
.filters { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; box-shadow: var(--shadow-sm); }
.filters form { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; }
.filters .field { min-width: 170px; }
.filters .field input, .filters .field select { padding: 8px 11px; }

/* ---------- 分页 ---------- */
.pager { margin-top: 16px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.pager a, .pager span { display: inline-flex; align-items: center; gap: 4px; padding: 7px 13px; border: 1px solid var(--border); border-radius: var(--radius-sm); color: #475569; font-size: 13px; }
.pager a:hover { text-decoration: none; border-color: var(--primary); color: var(--primary); }
.pager .cur { background: var(--primary); color: #fff; border-color: var(--primary); }
.pager .disabled { color: #b8bfca; }
.pager .total { border: none; color: var(--muted); }

/* ---------- 进度条 ---------- */
.progress { height: 8px; background: #e2e8f0; border-radius: 99px; overflow: hidden; width: 120px; display: inline-block; vertical-align: middle; }
.progress span { display: block; height: 100%; background: var(--primary); border-radius: 99px; }
.progress-warn span { background: var(--warn); }
.progress-ok span { background: var(--ok); }
.progress-num { margin-left: 8px; color: var(--muted); font-size: 12px; }

/* ---------- 详情 ---------- */
.detail-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px 30px; }
.detail-grid .row { display: flex; padding: 9px 0; border-bottom: 1px dashed var(--border); }
.detail-grid .row .k { width: 96px; color: var(--muted); flex: none; }
.detail-grid .row .v { color: var(--text); }

/* ---------- 登录页 ---------- */
/* ========== 登录页（左右两栏，对齐老版本 crm/public/css/auth.css） ========== */
*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
.auth-body { min-height:100vh; background:linear-gradient(135deg,#1a3a6e 0%,#2563a8 60%,#3b82d0 100%); display:flex; align-items:center; justify-content:center; padding:24px; font-family:"Microsoft YaHei","PingFang SC",-apple-system,"Segoe UI",sans-serif; color:#333; position:relative; overflow:hidden; }
.auth-body::before { content:''; position:absolute; top:-50%; left:-50%; width:200%; height:200%; background:radial-gradient(circle,rgba(255,255,255,0.1) 0%,transparent 60%); animation:bgFloat 15s ease-in-out infinite; pointer-events:none; }
@keyframes bgFloat { 0%,100%{transform:translate(0,0) rotate(0deg)} 33%{transform:translate(2%,1%) rotate(1deg)} 66%{transform:translate(-1%,2%) rotate(-1deg)} }

.auth-wrap { display:flex; border-radius:16px; overflow:hidden; box-shadow:0 25px 80px rgba(0,0,0,.4); width:900px; max-width:100%; min-height:540px; position:relative; z-index:1; animation:slideUp .5s ease-out; background:#fff; }
@keyframes slideUp { from{opacity:0;transform:translateY(30px)} to{opacity:1;transform:translateY(0)} }

.auth-banner { width:360px; flex:0 0 360px; background:linear-gradient(160deg,#1e4fd8 0%,#0e2a72 100%); color:#fff; display:flex; flex-direction:column; align-items:center; justify-content:center; padding:50px 35px; text-align:center; position:relative; overflow:hidden; }
.auth-banner::before { content:''; position:absolute; top:-50%; left:-50%; width:200%; height:200%; background:radial-gradient(circle,rgba(255,255,255,0.08) 0%,transparent 50%); animation:bannerFloat 8s ease-in-out infinite; pointer-events:none; }
@keyframes bannerFloat { 0%,100%{transform:translate(0,0)} 50%{transform:translate(5%,5%)} }
.auth-banner::after { content:''; position:absolute; bottom:-30px; right:-30px; width:120px; height:120px; border:3px solid rgba(255,255,255,0.1); border-radius:50%; pointer-events:none; }
.auth-banner h1 { font-size:24px; margin-bottom:10px; font-weight:700; letter-spacing:1px; position:relative; z-index:1; font-family:"KaiTi","STKaiti","FangSong","STFangsong","SimSun","宋体",serif; }
.auth-banner p  { font-size:15px; opacity:.85; position:relative; z-index:1; margin:0; }

.auth-card { flex:1; background:#fff; padding:50px 45px; display:flex; flex-direction:column; justify-content:center; }
.auth-card h2 { font-size:26px; color:#1a2a4e; margin-bottom:30px; font-weight:700; }
.auth-card .form-group { margin-bottom:20px; }
.auth-card .form-group label { display:block; font-size:13px; color:#555; margin-bottom:8px; font-weight:500; }
.auth-card .form-control { width:100%; padding:11px 14px; border:1.5px solid #d0d7e8; border-radius:8px; font-size:14px; color:#333; outline:none; transition:all .25s; background:#f8faff; }
.auth-card .form-control:focus { border-color:#2563a8; background:#fff; box-shadow:0 0 0 3px rgba(37,99,168,0.1); }

.captcha-row { display:flex; gap:12px; align-items:center; }
.captcha-row .captcha-input { flex:1; }
.captcha-row .captcha-img { height:42px; cursor:pointer; border-radius:6px; border:1.5px solid #d0d7e8; transition:transform .2s; }
.captcha-row .captcha-img:hover { transform:scale(1.02); }

.remember-row label { display:flex; align-items:center; gap:8px; font-size:13px; cursor:pointer; color:#666; }

.btn { display:inline-flex; align-items:center; justify-content:center; padding:12px 24px; border:none; border-radius:8px; cursor:pointer; font-size:15px; font-weight:600; transition:all .25s; }
.btn-primary { background:linear-gradient(135deg,#2563a8 0%,#1a4a8e 100%); color:#fff; box-shadow:0 4px 15px rgba(37,99,168,0.3); }
.btn-primary:hover { background:linear-gradient(135deg,#1a4a8e 0%,#153a75 100%); box-shadow:0 6px 20px rgba(37,99,168,0.4); transform:translateY(-1px); }
.btn-primary:active { transform:translateY(0); }
.btn-block { width:100%; margin-top:10px; }

.auth-alert { padding:12px 16px; border-radius:8px; font-size:13px; margin-bottom:18px; }
.auth-alert-danger { background:#fef0f0; border-left:4px solid #e74c3c; color:#c0392b; }
.auth-alert-info { background:#eef6ff; border-left:4px solid #3498db; color:#2471a3; }
.auth-alert-success { background:#edfbf0; border-left:4px solid #27ae60; color:#1e8449; }

.auth-links { margin-top:24px; display:flex; justify-content:space-between; font-size:13px; }
.auth-links a { color:#2563a8; text-decoration:none; transition:color .2s; }
.auth-links a:hover { color:#1a4a8e; text-decoration:underline; }

/* 窄屏：左右转上下 */
@media (max-width:760px) {
    .auth-body { padding:0; }
    .auth-wrap { flex-direction:column; width:100%; min-height:100vh; border-radius:0; animation:none; }
    .auth-banner { width:100%; flex:0 0 auto; padding:30px 24px; }
    .auth-banner::after { display:none; }
    .auth-card { padding:32px 24px; }
}
.auth-wrap-single { width:480px; max-width:100%; }
.auth-card-wide { flex:1 1 100%; padding:40px 36px; }

/* 兼容老 class（被替换前的过渡保留） */
.login-page { background: linear-gradient(135deg, #0f172a, #1e3a8a); display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-box { width: 360px; max-width: 92vw; background: #fff; border-radius: 14px; padding: 36px 32px; box-shadow: 0 18px 50px rgba(0,0,0,.35); }
.login-box h1 { margin: 0 0 4px; color: var(--primary); text-align: center; font-size: 22px; }
.login-box .sub { text-align: center; color: var(--muted); margin: 0 0 24px; font-size: 13px; }
.login-box label { display: block; margin: 14px 0 6px; font-size: 13px; color: #475569; }
.login-box input { width: 100%; padding: 11px 12px; border: 1px solid #cbd5e1; border-radius: var(--radius-sm); font-size: 14px; }
.login-box input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.login-box button { margin-top: 22px; width: 100%; padding: 12px; background: var(--primary); color: #fff; border: none; border-radius: var(--radius-sm); font-size: 15px; cursor: pointer; }
.login-box button:hover { background: var(--primary-d); }
.login-box .err { background: #fef2f2; color: #b91c1c; padding: 10px 12px; border-radius: var(--radius-sm); margin-bottom: 14px; font-size: 13px; }

/* ---------- 响应式 ---------- */
@media (max-width: 880px) {
    .app-body { display: block; }
    .side { width: auto; flex: none; padding: 0; border-right: none; border-bottom: 1px solid #1f2937; }
    .side nav ul { flex-direction: row; overflow-x: auto; padding: 6px 10px; gap: 2px; }
    .side li a { padding: 10px 14px; border-left: none; border-bottom: 3px solid transparent; white-space: nowrap; }
    .side li.active a { border-left: none; border-bottom-color: var(--side-active); }
    .content { padding: 16px; }
    .form-grid { grid-template-columns: 1fr; }
    .detail-grid { grid-template-columns: 1fr; }
}
