/* ============================================================
   掌门银门店客情分析系统 — 后台设计系统
   掌门银绿(#018C89)主色 + Tailwind 工具类
   ============================================================ */

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    background: #f1f5f9;
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', 'Microsoft YaHei', sans-serif;
    color: #0f172a;
}

/* ---------- 侧边栏 ---------- */
.sidebar {
    background: #134e4a;
    width: 256px;
    min-height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 40;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s;
}
.sidebar .brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 24px 24px 18px;
}
.sidebar .brand .logo-box {
    width: 38px; height: 38px;
    border-radius: 8px;
    background: linear-gradient(135deg, #018C89, #134e4a);
    display: flex; align-items: center; justify-content: center;
    color: #fff; flex-shrink: 0;
    box-shadow: 0 6px 16px rgba(1,140,137,0.35);
}
.sidebar .brand .brand-name { color: #fff; font-weight: 700; font-size: 20px; line-height: 1.2; margin-top: 5px; }
.sidebar .brand .brand-sub { color: #94a3b8; font-size: 14px; margin-top: 3px; }

.nav { display: flex; flex-direction: column; gap: 4px; padding: 18px 14px 8px 46px; flex: 1; }
.nav-section { color: #475569; font-size: 11px; font-weight: 600; letter-spacing: .05em; padding: 14px 12px 6px; text-transform: uppercase; }
.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px 10px 14px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s;
    color: #94a3b8;
    font-size: 14px;
    font-weight: 500;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    text-decoration: none;
}
.nav-item:hover { background: rgba(255,255,255,0.06); color: #e2e8f0; }
.nav-item.active {
    background: rgba(1,140,137,0.15);
    color: #99f6e4;
    border-left: 3px solid #018C89;
    padding-left: 11px;
}
.nav-item i, .nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }

/* ---------- 侧边栏可折叠子菜单（父项 + 子项） ---------- */
.nav-group { display: block; }
.nav-parent { list-style: none; cursor: pointer; user-select: none; }
.nav-parent::-webkit-details-marker { display: none; }
.nav-parent .nav-chev { width: 16px; height: 16px; margin-left: auto; color: #64748b; transition: transform .15s; }
.nav-group[open] > .nav-parent .nav-chev { transform: rotate(90deg); }
.nav-group[open] > .nav-parent:not(.active) { color: #e2e8f0; }
.nav-children { display: flex; flex-direction: column; gap: 2px; padding: 2px 0 4px 30px; }
.nav-item.nav-sub { font-size: 13px; padding: 8px 12px; }

/* 侧边栏底部管理员信息 */
.sidebar-foot {
    margin-top: auto;
    padding: 16px;
    border-top: 1px solid rgba(255,255,255,0.07);
    display: flex;
    align-items: center;
    gap: 10px;
}
.sidebar-foot .avatar {
    width: 36px; height: 36px;
    border-radius: 8px;
    background: rgba(1,140,137,0.2);
    color: #99f6e4;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 14px;
    flex-shrink: 0;
}
.sidebar-foot .meta { flex: 1; min-width: 0; }
.sidebar-foot .meta .name { color: #e2e8f0; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-foot .meta .role { color: #64748b; font-size: 11px; }
.sidebar-foot .logout {
    color: #64748b; cursor: pointer; transition: color .15s;
    background: none; border: none; display: flex; padding: 6px; border-radius: 8px;
}
.sidebar-foot .logout:hover { color: #f87171; background: rgba(248,113,113,0.1); }

/* ---------- 主区域 ---------- */
.main-wrap { margin-left: 256px; min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    position: sticky;
    top: 0;
    z-index: 30;
}
.topbar .page-title { font-size: 18px; font-weight: 700; color: #0f172a; display: flex; align-items: center; gap: 10px; }
.topbar .page-title .crumb { color: #94a3b8; font-weight: 500; font-size: 13px; }
.topbar .topbar-right { display: flex; align-items: center; gap: 14px; }
.topbar .top-avatar {
    width: 34px; height: 34px; border-radius: 8px;
    background: rgba(1,140,137,0.1); color: #018C89;
    display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px;
}
#sidebar-toggle { display: none; color: #64748b; background: none; border: none; cursor: pointer; padding: 6px; border-radius: 8px; }
#sidebar-toggle:hover { background: #f1f5f9; }

.content { flex: 1; padding: 32px; }

/* ---------- 卡片 ---------- */
.stat-card {
    background: #fff;
    border-radius: 8px;
    padding: 22px 24px;
    border: 1px solid #f1f5f9;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.stat-card .stat-label { color: #94a3b8; font-size: 13px; font-weight: 500; }
.stat-card .stat-value { font-size: 30px; font-weight: 800; color: #0f172a; line-height: 1.1; }
.stat-card .stat-foot { display: flex; align-items: center; gap: 6px; color: #94a3b8; font-size: 12px; margin-top: 4px; }
.stat-card .stat-icon {
    position: absolute; top: 20px; right: 22px;
    width: 42px; height: 42px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
}
.stat-card { position: relative; }
.stat-icon.i-primary { background: rgba(1,140,137,0.12); color: #018C89; }
.stat-icon.i-success { background: rgba(16,185,129,0.12); color: #10b981; }
.stat-icon.i-warning { background: rgba(245,158,11,0.12); color: #f59e0b; }
.stat-icon.i-info    { background: rgba(59,130,246,0.12); color: #3b82f6; }

.panel {
    background: #fff;
    border-radius: 8px;
    border: 1px solid #f1f5f9;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
    padding: 24px;
    margin-bottom: 24px;
}
.panel-head {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 18px; gap: 12px; flex-wrap: wrap;
}
.panel-title { font-size: 16px; font-weight: 700; color: #0f172a; display: flex; align-items: center; gap: 8px; }
.panel-title i, .panel-title svg { color: #018C89; width: 18px; height: 18px; }
.panel-sub { font-size: 13px; color: #94a3b8; margin-top: 2px; }

/* ---------- 表格 ---------- */
.table-wrap { width: 100%; overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data-table thead th {
    background: #f8fafc;
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: #64748b;
    border-bottom: 1px solid #e2e8f0;
    font-size: 12px;
    white-space: nowrap;
}
table.data-table tbody td {
    padding: 13px 16px;
    border-bottom: 1px solid #f1f5f9;
    color: #334155;
}
table.data-table tbody tr { transition: background .15s; }
table.data-table tbody tr:hover { background: #f8fafc; }
table.data-table tbody tr:last-child td { border-bottom: none; }
.cell-mono { font-family: ui-monospace, 'SFMono-Regular', Menlo, monospace; color: #0f172a; font-weight: 600; }
.cell-time { font-size: 13px; white-space: nowrap; }

/* 操作列固定在右侧：表格横向溢出时始终可见（避免最右列被滚动条推出视口） */
table.data-table th.col-actions,
table.data-table td.col-actions {
    position: sticky;
    right: 0;
    z-index: 3;
}
table.data-table thead th.col-actions { background: #f8fafc; box-shadow: inset 1px 0 0 #e2e8f0; }
table.data-table tbody td.col-actions { background: #fff; box-shadow: inset 1px 0 0 rgba(226,232,240,.9); }
table.data-table tbody tr:hover td.col-actions { background: #f8fafc; }
/* 操作列固定宽度：按 4 个图标按钮（32px）预留，按钮左对齐（列宽固定，各行按钮起始位置一致） */
table.data-table th.col-actions,
table.data-table td.col-actions { width: 178px; min-width: 178px; }
table.data-table td.col-actions { text-align: left; }
.cell-remark { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #475569; }
.sel-code { -webkit-user-select: all; user-select: all; cursor: text; }

/* ---------- 徽章 ---------- */
.badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 10px; border-radius: 8px; font-size: 12px; font-weight: 600;
}
.badge-primary { background: #ccfbf1; color: #134e4a; }
.badge-success { background: #d1fae5; color: #065f46; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger  { background: #fee2e2; color: #991b1b; }
.badge-muted   { background: #f1f5f9; color: #475569; }

/* ---------- 表单 ---------- */
.form-label { display: block; font-size: 13px; font-weight: 500; color: #475569; margin-bottom: 6px; }
.form-input {
    width: 100%;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 9px 14px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
    background: #f8fafc;
    color: #0f172a;
}
.form-input:focus { border-color: #018C89; background: #fff; box-shadow: 0 0 0 3px rgba(1,140,137,0.1); }
.form-input::placeholder { color: #94a3b8; }
select.form-input { cursor: pointer; }
.form-hint { font-size: 12px; color: #94a3b8; margin-top: 6px; }

/* ---------- 按钮 ---------- */
.btn-primary { background: #018C89; color: #fff; border: none; border-radius: 8px; padding: 9px 18px; font-size: 14px; font-weight: 600; cursor: pointer; transition: all .15s; display: inline-flex; align-items: center; gap: 8px; text-decoration: none; }
.btn-primary:hover { background: #01706e; }
.btn-primary:active { transform: scale(.98); }
.btn-secondary { background: #f1f5f9; color: #475569; border: none; border-radius: 8px; padding: 9px 18px; font-size: 14px; font-weight: 500; cursor: pointer; transition: all .15s; display: inline-flex; align-items: center; gap: 8px; text-decoration: none; }
.btn-secondary:hover { background: #e2e8f0; }
.btn-danger { background: #fee2e2; color: #dc2626; border: none; border-radius: 8px; padding: 7px 14px; font-size: 13px; font-weight: 500; cursor: pointer; transition: all .15s; display: inline-flex; align-items: center; gap: 6px; text-decoration: none; }
.btn-danger:hover { background: #fecaca; }
.btn-ghost { background: none; border: 1px solid #e2e8f0; color: #475569; border-radius: 8px; padding: 8px 14px; font-size: 13px; cursor: pointer; transition: all .15s; display: inline-flex; align-items: center; gap: 6px; text-decoration: none; }
.btn-ghost:hover { background: #f8fafc; border-color: #cbd5e1; }
.btn-sm { padding: 6px 12px; font-size: 12px; border-radius: 8px; }
.icon-btn {
    width: 32px; height: 32px; border-radius: 8px;
    display: inline-flex; align-items: center; justify-content: center;
    border: none; cursor: pointer; transition: all .15s; background: #f1f5f9; color: #475569;
}
.icon-btn:hover { background: #e2e8f0; }
.icon-btn.danger:hover { background: #fee2e2; color: #dc2626; }
.icon-btn.edit:hover { background: #ccfbf1; color: #134e4a; }
.icon-btn.copy:hover { background: #ecfdf5; color: #059669; }
.icon-btn.warning { background: #fef3c7; color: #d97706; }
.icon-btn.warning:hover { background: #fde68a; }
.icon-btn.success { background: #d1fae5; color: #059669; }
.icon-btn.success:hover { background: #a7f3d0; }

/* ---------- 搜索框 ---------- */
.search-input {
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 9px 14px 9px 38px;
    font-size: 14px;
    outline: none;
    background: #f8fafc url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' viewBox='0 0 24 24'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.3-4.3'/%3E%3C/svg%3E") no-repeat 12px center;
    width: 260px;
    transition: all .15s;
    color: #0f172a;
}
.search-input:focus { border-color: #018C89; background-color: #fff; box-shadow: 0 0 0 3px rgba(1,140,137,0.1); }

/* ---------- 模态框 ---------- */
.modal-mask {
    position: fixed; inset: 0;
    background: rgba(15,23,42,0.55);
    backdrop-filter: blur(4px);
    z-index: 100;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal-mask.open { display: flex; }
.modal-box {
    background: #fff;
    border-radius: 8px;
    padding: 28px;
    width: 100%;
    max-width: 460px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
    animation: modalIn .2s ease;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-box h3 { font-size: 17px; font-weight: 700; color: #0f172a; margin: 0 0 18px; display: flex; align-items: center; gap: 8px; }
.modal-box h3 i, .modal-box h3 svg { color: #018C89; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px; }

/* ---------- Toast ---------- */
.toast {
    position: fixed; top: 24px; right: 24px; z-index: 999;
    padding: 12px 20px; border-radius: 8px; font-size: 14px; font-weight: 500;
    color: #fff; box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    transform: translateX(120%); opacity: 0;
    transition: transform .3s, opacity .3s;
    display: flex; align-items: center; gap: 8px;
}
.toast.show { transform: translateX(0); opacity: 1; }
.toast.success { background: #10b981; }
.toast.error { background: #ef4444; }
.toast.info { background: #018C89; }

/* ---------- 空状态 ---------- */
.empty-state { text-align: center; padding: 48px 16px; color: #94a3b8; }
.empty-state .empty-icon {
    width: 64px; height: 64px; border-radius: 8px; margin: 0 auto 16px;
    background: #f1f5f9; color: #cbd5e1; display: flex; align-items: center; justify-content: center;
}
.empty-state h3 { font-size: 16px; color: #475569; margin: 0 0 6px; }
.empty-state p { font-size: 13px; }

/* ---------- 提示条 ---------- */
.alert {
    padding: 13px 16px; border-radius: 8px; margin-bottom: 18px;
    display: flex; align-items: center; gap: 10px; font-size: 14px;
}
.alert-error { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }
.alert-success { background: #ecfdf5; color: #059669; border: 1px solid #a7f3d0; }

/* ---------- 进度条 ---------- */
.progress-track { height: 10px; background: #f1f5f9; border-radius: 8px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, #018C89, #134e4a); width: 0%; transition: width .3s; }

/* 模态框标题栏：固定不滚动，右侧含关闭 X */
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.modal-head h3 { margin-bottom: 0; }
/* 内部滚动容器：模态框滚动区、侧栏等 */
.modal-scroll {
    max-height: calc(100vh - 160px);
    overflow: auto;
    margin: 0;
    padding-right: 8px;
}
/* 滚动条统一标准：细条 6px / 滑块 #C3C3C3 / hover #A3A3A3 / 圆角 999px / 轨道透明
   页面主滚动条挂 html；内部滚动容器 .modal-scroll / .custom-scrollbar 同样套用 */
:is(html, .modal-scroll, .custom-scrollbar) {
    scrollbar-width: thin;
    scrollbar-color: #C3C3C3 transparent;
}
:is(html, .modal-scroll, .custom-scrollbar)::-webkit-scrollbar { width: 6px; height: 6px; }
:is(html, .modal-scroll, .custom-scrollbar)::-webkit-scrollbar-track { background: transparent; }
:is(html, .modal-scroll, .custom-scrollbar)::-webkit-scrollbar-thumb { background: #C3C3C3; border-radius: 999px; }
:is(html, .modal-scroll, .custom-scrollbar)::-webkit-scrollbar-thumb:hover { background: #A3A3A3; }

/* ---------- 响应式 ---------- */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-wrap { margin-left: 0; }
    #sidebar-toggle { display: inline-flex; }
    .content { padding: 20px 16px; }
    .topbar { padding: 0 16px; }
    .search-input { width: 160px; }
    .stat-card .stat-icon { display: none; }
    /* 添加客户表单：移动端“添加数据”按钮居右 */
    .add-btn-wrap { width: 100%; text-align: right; }
    /* 最近客户面板：移动端“查看全部客户”链接居右 */
    .view-all-link { margin-left: auto; }
    /* 客户列表工具栏：移动端“导出SHA1”紧贴“全部状态”右侧，搜索框另起一行 */
    .member-toolbar { flex-wrap: wrap; width: 100%; align-items: stretch; }
    .member-toolbar > form[method="get"] { display: contents; }
    .member-toolbar select[name="status"] { order: 1; flex: 0 0 50%; min-width: 0; height: 42px; }
    .member-toolbar > form[method="post"] { order: 2; flex: 1 1 0; min-width: 0; }
    .member-toolbar > form[method="post"] button { width: 100%; height: 42px; }
    .member-toolbar .member-search-wrap { order: 3; flex: 0 0 100%; }
    .member-toolbar .member-search-wrap .search-input { width: 100%; }
    /* 验证记录工具栏：移动端搜索框自适应整行宽度 */
    .logs-toolbar { width: 100%; }
    .logs-toolbar .logs-search-wrap { flex: 0 0 100%; }
    .logs-toolbar .logs-search-wrap .search-input { width: 100%; }
    /* 安装记录工具栏：移动端搜索框自适应整行宽度 */
    .ir-toolbar { width: 100%; }
    .ir-toolbar select[name="product"],
    .ir-toolbar select[name="bits"] { flex: 1 1 0; min-width: 0; }
    .ir-toolbar .ir-search-wrap { flex: 0 0 100%; }
    .ir-toolbar .ir-search-wrap .search-input { width: 100%; }
}
@media (min-width: 769px) {
    .sidebar.open { transform: translateX(0); }
}

/* ---------- SVG 折线图（参考 setup.ce.com 安装趋势图） ---------- */
.panel-body { padding: 16px 20px 20px; }
.chart-svg { width: 100%; height: auto; display: block; }
.chart-empty { padding: 48px 0; text-align: center; color: #94a3b8; font-size: 13px; }
.chart-legend { display: flex; gap: 18px; justify-content: center; margin-top: 8px; flex-wrap: wrap; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: #64748b; }
.chart-legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.line-chart { position: relative; }
.lc-dot { transition: r .12s ease; }
.chart-tip { position: absolute; display: none; transform: translate(-50%, -100%); background: #0f172a; color: #fff; padding: 7px 11px; border-radius: 8px; font-size: 12px; line-height: 1.55; white-space: nowrap; pointer-events: none; box-shadow: 0 6px 18px rgba(15,23,42,.25); z-index: 6; }
.chart-tip b { font-weight: 700; font-size: 12px; }
.chart-tip .tip-val { color: #99f6e4; font-weight: 700; }
.chart-tip .tip-row { display: flex; gap: 8px; align-items: center; }
.chart-tip .tip-dot { width: 8px; height: 8px; border-radius: 2px; flex-shrink: 0; }

/* ---------- 时间范围切换条 ---------- */
.range-bar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 20px; padding: 12px 18px; background: #fff; border: 1px solid #e2e8f0; border-radius: 12px; }
.range-label { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: #334155; }
.range-switcher { display: inline-flex; gap: 4px; background: #f1f5f9; border-radius: 8px; padding: 3px; }
.range-pill { padding: 6px 14px; font-size: 13px; color: #64748b; border-radius: 6px; text-decoration: none; transition: all .15s; }
.range-pill:hover { color: #018C89; }
.range-pill.active { background: #fff; color: #018C89; font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.range-note { margin-left: auto; font-size: 12px; color: #94a3b8; }

/* ---------- flatpickr 日期控件（airbnb 极简风 + 马尔斯绿品牌色微调） ---------- */
/* 容器沿用 airbnb 的轻量阴影/无边框，仅强制层级在弹窗之上 */
.flatpickr-calendar.open,
.flatpickr-calendar.inline { z-index: 100000 !important; }
.flatpickr-calendar { font-family: inherit; }

/* 选中日 / 今天 / 箭头 hover —— 统一套马尔斯绿，覆盖 airbnb 默认蓝红 */
.flatpickr-day.selected,
.flatpickr-day.startRange,
.flatpickr-day.endRange,
.flatpickr-day.selected:hover,
.flatpickr-day.selected:focus,
span.flatpickr-day.selected,
span.flatpickr-day.startRange,
span.flatpickr-day.endRange {
    background: #018C89 !important;
    border-color: #018C89 !important;
    color: #fff !important;
}
.flatpickr-day.today { border-color: #018C89 !important; color: #018C89 !important; }
.flatpickr-day.today:hover { background: #018C89 !important; color: #fff !important; }
.flatpickr-day:hover,
.flatpickr-day:focus { background: #ecfdf9 !important; border-color: #99f6e4 !important; }
.flatpickr-months .flatpickr-prev-month:hover,
.flatpickr-months .flatpickr-next-month:hover { color: #018C89 !important; }
.flatpickr-prev-month:hover svg,
.flatpickr-next-month:hover svg { fill: #018C89 !important; }
