/* ==========================================================================
   销售查询系统 v2 —— 后台样式
   设计基调：深色导航 + 浅色内容区，卡片化布局，数字等宽对齐
   响应式：>=992px 固定侧栏；<992px 抽屉式侧栏（手机可用）
   ========================================================================== */

:root {
    --bg:            #f4f6fb;
    --card:          #ffffff;
    --line:          #e6e9f2;
    --line-soft:     #f0f2f8;
    --text:          #1c2333;
    --text-2:        #55607a;
    --muted:         #8b95ad;

    --primary:       #2c5ce6;
    --primary-dark:  #1e42b8;
    --primary-soft:  #eaf0ff;

    --sidebar:       #101a35;
    --sidebar-2:     #18234a;
    --sidebar-line:  rgba(255, 255, 255, .08);
    --sidebar-text:  #a9b4d0;

    /* 国内习惯：涨=红，跌=绿 */
    --up:            #e0324b;
    --down:          #12a071;
    --flat:          #8b95ad;

    --sidebar-w:     240px;
    --sidebar-w-min: 72px;
    --topbar-h:      60px;

    --radius:        14px;
    --radius-sm:     10px;
    --shadow:        0 1px 2px rgba(16, 26, 53, .04), 0 8px 24px -12px rgba(16, 26, 53, .14);
    --shadow-lg:     0 20px 50px -20px rgba(16, 26, 53, .28);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

/* ---------- 数字统一等宽，避免跳动 ---------- */
.num, .kpi-value, td.num, .rank-value {
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum";
}

/* ==========================================================================
   侧边导航
   ========================================================================== */
.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    background: linear-gradient(180deg, var(--sidebar) 0%, var(--sidebar-2) 100%);
    display: flex;
    flex-direction: column;
    z-index: 1045;
    transition: width .22s ease, transform .22s ease;
    overflow: hidden;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    height: var(--topbar-h);
    padding: 0 18px;
    border-bottom: 1px solid var(--sidebar-line);
    flex: 0 0 auto;
    white-space: nowrap;
}

.sidebar-brand .logo {
    width: 32px; height: 32px;
    flex: 0 0 32px;
    border-radius: 9px;
    background: linear-gradient(135deg, #4f7cff, #2c5ce6);
    display: grid; place-items: center;
    color: #fff; font-size: 16px;
    box-shadow: 0 4px 12px rgba(44, 92, 230, .45);
}

.sidebar-brand .brand-text { color: #fff; font-size: 15px; font-weight: 600; letter-spacing: .3px; }
.sidebar-brand .brand-sub  { display: block; color: var(--sidebar-text); font-size: 11px; font-weight: 400; letter-spacing: .6px; }

.sidebar-nav {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px 10px 20px;
}
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.14); border-radius: 3px; }

.nav-group-title {
    color: rgba(169, 180, 208, .55);
    font-size: 11px;
    letter-spacing: 1px;
    padding: 14px 12px 6px;
    white-space: nowrap;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 10px 12px;
    margin-bottom: 2px;
    border-radius: var(--radius-sm);
    color: var(--sidebar-text);
    font-size: 13.5px;
    white-space: nowrap;
    cursor: pointer;
    transition: background .15s, color .15s;
    position: relative;
}

.nav-item i { font-size: 16px; flex: 0 0 18px; text-align: center; }
.nav-item .nav-label { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; }
.nav-item .nav-arrow { font-size: 11px; transition: transform .2s; opacity: .7; }

.nav-item:hover { background: rgba(255, 255, 255, .07); color: #fff; }

.nav-item.active,
.nav-sub .nav-item.active {
    background: linear-gradient(90deg, rgba(79, 124, 255, .30), rgba(79, 124, 255, .12));
    color: #fff;
    font-weight: 600;
}
.nav-item.active::before {
    content: "";
    position: absolute;
    left: 0; top: 50%;
    transform: translateY(-50%);
    width: 3px; height: 18px;
    border-radius: 0 3px 3px 0;
    background: #6b93ff;
}

.nav-sub { display: none; padding-left: 6px; }
.nav-sub.open { display: block; }
.nav-sub .nav-item { font-size: 13px; padding-left: 12px; }
.nav-group.open > .nav-item .nav-arrow { transform: rotate(90deg); }

.sidebar-foot {
    flex: 0 0 auto;
    padding: 12px 16px;
    border-top: 1px solid var(--sidebar-line);
    color: rgba(169, 180, 208, .6);
    font-size: 11px;
    white-space: nowrap;
}

/* 折叠态（仅桌面端） */
body.sidebar-mini .sidebar { width: var(--sidebar-w-min); }
body.sidebar-mini .sidebar-brand .brand-text,
body.sidebar-mini .nav-label,
body.sidebar-mini .nav-arrow,
body.sidebar-mini .nav-group-title,
body.sidebar-mini .sidebar-foot { display: none; }
body.sidebar-mini .nav-item { justify-content: center; padding: 11px 0; }
body.sidebar-mini .nav-sub { display: none !important; }
body.sidebar-mini .main { margin-left: var(--sidebar-w-min); }

/* ==========================================================================
   主区域
   ========================================================================== */
.main {
    margin-left: var(--sidebar-w);
    min-height: 100%;
    transition: margin-left .22s ease;
    display: flex;
    flex-direction: column;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 1030;
    height: var(--topbar-h);
    flex: 0 0 var(--topbar-h);
    background: rgba(255, 255, 255, .88);
    backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 20px;
}

.icon-btn {
    width: 36px; height: 36px;
    display: grid; place-items: center;
    border: 1px solid transparent;
    border-radius: 10px;
    background: transparent;
    color: var(--text-2);
    font-size: 17px;
    cursor: pointer;
    transition: background .15s, color .15s;
    flex: 0 0 auto;
}
.icon-btn:hover { background: var(--line-soft); color: var(--primary); }

.page-head { min-width: 0; }
.page-head h1 {
    margin: 0;
    font-size: 17px;
    font-weight: 650;
    letter-spacing: .2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.page-head .crumb { color: var(--muted); font-size: 12px; white-space: nowrap; }

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 30px;
    padding: 0 11px;
    border-radius: 999px;
    background: var(--line-soft);
    color: var(--text-2);
    font-size: 12px;
    white-space: nowrap;
}
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--flat); box-shadow: 0 0 0 3px rgba(139,149,173,.16); }
.chip .dot.ok   { background: var(--down); box-shadow: 0 0 0 3px rgba(18,160,113,.16); }
.chip .dot.bad  { background: var(--up);   box-shadow: 0 0 0 3px rgba(224,50,75,.16); }

.user-box {
    display: flex; align-items: center; gap: 9px;
    padding: 4px 10px 4px 4px;
    border-radius: 999px;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background .15s, border-color .15s;
}
.user-box:hover { background: var(--line-soft); border-color: var(--line); }
.avatar {
    width: 30px; height: 30px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4f7cff, #2c5ce6);
    color: #fff;
    display: grid; place-items: center;
    font-size: 13px; font-weight: 600;
}
.user-meta { line-height: 1.15; }
.user-meta .u-name { font-size: 13px; font-weight: 600; }
.user-meta .u-time { font-size: 11px; color: var(--muted); }

.content { padding: 20px; flex: 1 1 auto; }

/* ==========================================================================
   卡片
   ========================================================================== */
.card-x {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 18px;
    overflow: hidden;
}
.card-x > .hd {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--line-soft);
    flex-wrap: wrap;
}
.card-x > .hd h2 {
    margin: 0;
    font-size: 14.5px;
    font-weight: 650;
    display: flex; align-items: center; gap: 8px;
}
.card-x > .hd h2 i { color: var(--primary); font-size: 16px; }
.card-x > .hd .hd-right { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.card-x > .bd { padding: 16px 18px; }
.card-x > .bd.flush { padding: 0; }

/* ==========================================================================
   区块小标题（看板里分组，例如「本月经营」）
   ========================================================================== */
.sec-head {
    display: flex;
    align-items: baseline;
    gap: 10px;
    flex-wrap: wrap;
    margin: 4px 0 12px;
}
.sec-head h2 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    display: inline-flex;
    align-items: center;
    gap: 7px;
}
.sec-head h2 i { color: var(--primary); }
.sec-head .sec-sub { font-size: 12.5px; color: var(--muted); }

/* 目标完成进度条 */
.prog {
    height: 6px;
    margin: 10px 0 4px;
    border-radius: 999px;
    background: var(--line-soft);
    overflow: hidden;
}
.prog i {
    display: block;
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, #4f7cff, #7a5cff);
    transition: width .4s ease;
}

/* ==========================================================================
   KPI 卡片
   ========================================================================== */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 18px;
}

.kpi {
    position: relative;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px 18px;
    overflow: hidden;
    transition: transform .18s, box-shadow .18s;
}
.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.kpi::after {
    content: "";
    position: absolute;
    right: -28px; top: -28px;
    width: 96px; height: 96px;
    border-radius: 50%;
    background: var(--primary-soft);
    opacity: .55;
}
.kpi-top { position: relative; display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.kpi-icon {
    width: 34px; height: 34px;
    border-radius: 10px;
    display: grid; place-items: center;
    font-size: 16px;
    color: #fff;
    flex: 0 0 34px;
}
.kpi-icon.blue   { background: linear-gradient(135deg, #4f7cff, #2c5ce6); box-shadow: 0 6px 16px -6px rgba(44,92,230,.6); }
.kpi-icon.rose   { background: linear-gradient(135deg, #ff7a90, #e0324b); box-shadow: 0 6px 16px -6px rgba(224,50,75,.55); }
.kpi-icon.green  { background: linear-gradient(135deg, #34d3a0, #12a071); box-shadow: 0 6px 16px -6px rgba(18,160,113,.55); }
.kpi-icon.amber  { background: linear-gradient(135deg, #ffc65c, #f09319); box-shadow: 0 6px 16px -6px rgba(240,147,25,.55); }
.kpi-icon.violet { background: linear-gradient(135deg, #a78bfa, #7c4dff); box-shadow: 0 6px 16px -6px rgba(124,77,255,.55); }
.kpi-icon.cyan   { background: linear-gradient(135deg, #4dd0e1, #0ea5c4); box-shadow: 0 6px 16px -6px rgba(14,165,196,.55); }

.kpi-label { font-size: 12.5px; color: var(--text-2); }
.kpi-value {
    position: relative;
    font-size: 25px;
    font-weight: 700;
    letter-spacing: -.5px;
    line-height: 1.2;
    white-space: nowrap;
}
.kpi-value .unit { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 3px; }
.kpi-foot { position: relative; margin-top: 8px; font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.delta {
    display: inline-flex; align-items: center; gap: 3px;
    padding: 1px 7px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 600;
}
.delta.up   { color: var(--up);   background: rgba(224, 50, 75, .10); }
.delta.down { color: var(--down); background: rgba(18, 160, 113, .10); }
.delta.flat { color: var(--flat); background: var(--line-soft); }

/* ==========================================================================
   表格
   ========================================================================== */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-scroll::-webkit-scrollbar { height: 8px; }
.table-scroll::-webkit-scrollbar-thumb { background: #d3d9e6; border-radius: 4px; }

table.grid {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 13.5px;
    min-width: 680px;
}
table.grid thead th {
    position: sticky; top: 0; z-index: 2;
    background: #f7f9fd;
    color: var(--text-2);
    font-weight: 600;
    font-size: 12.5px;
    letter-spacing: .3px;
    text-align: right;
    padding: 11px 14px;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
table.grid thead th:first-child,
table.grid thead th.l { text-align: left; }
table.grid thead th.c { text-align: center; }

table.grid tbody td,
table.grid tfoot td {
    padding: 11px 14px;
    text-align: right;
    border-bottom: 1px solid var(--line-soft);
    white-space: nowrap;
}
table.grid tbody td:first-child,
table.grid tbody td.l,
table.grid tfoot td:first-child,
table.grid tfoot td.l { text-align: left; }
table.grid tbody td.c,
table.grid tfoot td.c { text-align: center; }
table.grid tbody tr:hover td { background: #fafbff; }

table.grid tbody tr.total-row td,
table.grid tfoot tr.total-row td {
    background: var(--primary-soft);
    font-weight: 700;
    color: var(--primary-dark);
    border-bottom: none;
    border-top: 2px solid rgba(44, 92, 230, .22);
}
table.grid tbody tr.total-row:hover td { background: var(--primary-soft); }

.shop-name { max-width: 260px; overflow: hidden; text-overflow: ellipsis; display: inline-block; vertical-align: bottom; }
.badge-rank {
    display: inline-grid; place-items: center;
    width: 22px; height: 22px;
    border-radius: 7px;
    background: var(--line-soft);
    color: var(--text-2);
    font-size: 11.5px; font-weight: 600;
}
.badge-rank.top1 { background: linear-gradient(135deg, #ffb347, #f09319); color: #fff; }
.badge-rank.top2 { background: linear-gradient(135deg, #b9c4d8, #8e9bb5); color: #fff; }
.badge-rank.top3 { background: linear-gradient(135deg, #e2b07a, #c98b45); color: #fff; }

.val-up   { color: var(--up);   font-weight: 600; }
.val-down { color: var(--down); font-weight: 600; }

.empty {
    padding: 46px 20px;
    text-align: center;
    color: var(--muted);
}
.empty i { font-size: 34px; display: block; margin-bottom: 10px; opacity: .45; }

.swipe-hint { display: none; }

/* ==========================================================================
   表单 / 过滤条
   ========================================================================== */
.filter-bar {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    flex-wrap: wrap;
}
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label { font-size: 12px; color: var(--text-2); font-weight: 500; }
.field .ctl {
    height: 38px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 0 11px;
    font-size: 13.5px;
    color: var(--text);
    background: #fff;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
    min-width: 0;
    width: 100%;
}
.field .ctl:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(44,92,230,.13); }
.field select.ctl { padding-right: 30px; cursor: pointer; min-width: 190px; }
.field.date .ctl { width: 152px; }

.btn-x {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    height: 38px;
    padding: 0 16px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-size: 13.5px;
    font-weight: 500;
    cursor: pointer;
    transition: filter .15s, background .15s, border-color .15s, color .15s;
    white-space: nowrap;
}
.btn-x.primary { background: linear-gradient(135deg, #3b6bf0, var(--primary)); color: #fff; box-shadow: 0 6px 16px -8px rgba(44,92,230,.85); }
.btn-x.primary:hover { filter: brightness(1.06); color: #fff; }
.btn-x.ghost { background: #fff; border-color: var(--line); color: var(--text-2); }
.btn-x.ghost:hover { border-color: var(--primary); color: var(--primary); background: #fff; }
.btn-x.sm { height: 32px; padding: 0 12px; font-size: 12.5px; }
.btn-x.disabled { opacity: .45; pointer-events: none; }

/* 分页条 */
.pager {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding: 14px 18px;
    border-top: 1px solid var(--line-soft);
}
.pager-info { font-size: 12.5px; color: var(--muted); }
.pager-info b { color: var(--text-2); font-variant-numeric: tabular-nums; }
.pager-btns { display: flex; align-items: center; gap: 8px; }
.pager-btns .btn-x { text-decoration: none; }

/* 提示框里的补充说明（小字、灰色） */
.muted-note {
    margin-top: 6px;
    font-size: 12.5px;
    color: var(--muted);
}

.quick-ranges { display: flex; gap: 6px; flex-wrap: wrap; }
.quick-ranges .qr {
    height: 30px;
    padding: 0 11px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--text-2);
    font-size: 12.5px;
    cursor: pointer;
    transition: all .15s;
}
.quick-ranges .qr:hover { border-color: var(--primary); color: var(--primary); }
.quick-ranges .qr.active { background: var(--primary-soft); border-color: rgba(44,92,230,.35); color: var(--primary-dark); font-weight: 600; }

/* 分段切换 */
.seg {
    display: inline-flex;
    padding: 3px;
    border-radius: 999px;
    background: var(--line-soft);
    gap: 2px;
}
.seg a {
    padding: 6px 15px;
    border-radius: 999px;
    font-size: 13px;
    color: var(--text-2);
    transition: all .15s;
    white-space: nowrap;
}
.seg a.active { background: #fff; color: var(--primary-dark); font-weight: 600; box-shadow: 0 1px 4px rgba(16,26,53,.12); }

/* ==========================================================================
   查询条（Query Bar）
   ---------------------------------------------------------------------------
   目标：老板一眼知道「在看什么时间段、哪些店」，所以把筛选压成一行：
   [快捷区间] [开始 ~ 结束] [门店] [查询]
   下面一行小字回报当前口径，不需要再回头看输入框。
   ========================================================================== */
.qbar-card { margin-bottom: 16px; }
.qbar-card .bd { padding: 14px 18px; }

.qbar { display: flex; flex-direction: column; gap: 10px; }
.qbar-main {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

/* 快捷区间：平铺胶囊，选中态实心 */
.qseg { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.qseg button, .qseg a {
    display: inline-flex;
    align-items: center;
    height: 34px;
    padding: 0 14px;
    border-radius: 8px;
    border: 1px solid transparent;
    background: var(--line-soft);
    color: var(--text-2);
    font-size: 13px;
    cursor: pointer;
    transition: all .15s;
    white-space: nowrap;
}
.qseg button:hover, .qseg a:hover { background: #e8ecf8; color: var(--text); }
.qseg button.active, .qseg a.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 6px 14px -8px rgba(44,92,230,.9);
}

/* 日期区间 */
.qdates {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 34px;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}
.qdates input[type="date"] {
    border: 0;
    outline: none;
    background: transparent;
    font-size: 13px;
    color: var(--text);
    font-variant-numeric: tabular-nums;
    width: 128px;
    padding: 0;
}
.qdates .sep { color: var(--muted); font-size: 12.5px; }
.qdates:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(44,92,230,.12); }

/* 实时页的「今日实时」静态标签（不可选日期） */
.qdates .qtoday {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: #0f7b4f;
    font-variant-numeric: tabular-nums;
}
.qdates .qtoday i { font-size: 13px; }

/* 实时页的刷新按钮：靠右放，和左侧口径区分开 */
.qbar-main .qrefresh { margin-left: auto; }
.qbar-main .qrefresh i { font-size: 14px; }
.qmeta .qtime { font-variant-numeric: tabular-nums; color: var(--text); }

/* 门店下拉 */
.qsel { position: relative; }
.qsel select {
    height: 34px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    padding: 0 32px 0 12px;
    font-size: 13px;
    color: var(--text);
    min-width: 208px;
    max-width: 300px;
    cursor: pointer;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
}
.qsel select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(44,92,230,.12); }
.qsel:after {
    content: "";
    position: absolute;
    right: 12px; top: 50%;
    width: 6px; height: 6px;
    border-right: 1.6px solid var(--muted);
    border-bottom: 1.6px solid var(--muted);
    transform: translateY(-70%) rotate(45deg);
    pointer-events: none;
}
.qsel .go {
    height: 34px;
    padding: 0 15px;
    margin-left: 8px;
    border-radius: 8px;
    border: 1px solid transparent;
    background: linear-gradient(135deg, #3b6bf0, var(--primary));
    color: #fff;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
}
.qsel .go:hover { filter: brightness(1.06); }

/* 口径回报行 */
.qmeta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    font-size: 12.5px;
    color: var(--muted);
}
.qmeta b { color: var(--text-2); font-weight: 600; font-variant-numeric: tabular-nums; }
.qmeta .dot-sep { color: #cfd6e6; }

/* 取数方式标签：本地汇总库 / 生产库 */
.src-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 1px 8px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 600;
    cursor: default;
}
.src-tag.local  { background: #ecfdf5; color: #059669; }
.src-tag.remote { background: #eff6ff; color: #2563eb; }

/* ==========================================================================
   图表
   ========================================================================== */
.chart { width: 100%; height: 320px; }
.chart.sm { height: 260px; }
/* 门店多时图表纵向滚动，避免整页被一张图拉得很长 */
.chart-scroll { max-height: 560px; overflow-y: auto; overflow-x: hidden; }
.chart-scroll::-webkit-scrollbar { width: 6px; }
.chart-scroll::-webkit-scrollbar-thumb { background: #c9d3e6; border-radius: 3px; }
.chart-grid { display: grid; grid-template-columns: 1.55fr 1fr; gap: 18px; }

/* ==========================================================================
   连接状态 / 提示
   ========================================================================== */
.status-list { display: grid; gap: 10px; }
.status-row {
    display: flex; align-items: center; gap: 11px;
    padding: 11px 13px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: #fcfdff;
}
.status-row .ico {
    width: 30px; height: 30px; flex: 0 0 30px;
    border-radius: 9px; display: grid; place-items: center;
    font-size: 14px;
}
.status-row.ok .ico   { background: rgba(18,160,113,.12);  color: var(--down); }
.status-row.bad .ico  { background: rgba(224,50,75,.12);   color: var(--up); }
.status-row .txt { min-width: 0; flex: 1 1 auto; }
.status-row .t1 { font-size: 13px; font-weight: 600; }
.status-row .t2 { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-row .ms { font-size: 11.5px; color: var(--muted); white-space: nowrap; }

.alert-x {
    display: flex; gap: 10px;
    padding: 12px 15px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    border: 1px solid;
    margin-bottom: 16px;
}
.alert-x.warn { background: #fff8ec; border-color: #ffe0ac; color: #8a5a00; }
.alert-x.err  { background: #fff1f3; border-color: #ffd0d8; color: #a1122b; }
.alert-x.info { background: var(--primary-soft); border-color: rgba(44,92,230,.22); color: var(--primary-dark); }
.alert-x i { font-size: 16px; flex: 0 0 auto; margin-top: 2px; }

/* 命令预览 */
pre.cmd {
    background: #0f1730;
    color: #d7e3ff;
    border-radius: var(--radius-sm);
    padding: 16px 18px;
    font-family: "JetBrains Mono", Consolas, "Courier New", monospace;
    font-size: 12.5px;
    line-height: 1.85;
    overflow-x: auto;
    margin: 0;
    white-space: pre;
}
pre.cmd .c { color: #6b7ba8; }   /* 注释 */
pre.cmd .k { color: #7fd6ff; }   /* 命令 */
pre.cmd .a { color: #ffd479; }   /* 参数 */

/* ==========================================================================
   登录页
   ========================================================================== */
.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(1100px 600px at 12% 8%,  rgba(79,124,255,.30), transparent 60%),
        radial-gradient(900px 520px at 92% 92%, rgba(124,77,255,.24), transparent 60%),
        linear-gradient(160deg, #0d1630 0%, #16224a 48%, #1b2a5c 100%);
}
.login-card {
    width: 100%;
    max-width: 400px;
    background: rgba(255, 255, 255, .97);
    border-radius: 18px;
    box-shadow: 0 40px 90px -30px rgba(0, 0, 0, .55);
    padding: 34px 30px 28px;
}
.login-logo {
    width: 54px; height: 54px;
    border-radius: 15px;
    background: linear-gradient(135deg, #4f7cff, #2c5ce6);
    display: grid; place-items: center;
    color: #fff; font-size: 24px;
    margin: 0 auto 16px;
    box-shadow: 0 12px 30px -10px rgba(44,92,230,.85);
}
.login-card h1 { margin: 0 0 4px; font-size: 20px; font-weight: 700; text-align: center; letter-spacing: .5px; }
.login-card .sub { text-align: center; color: var(--muted); font-size: 12.5px; margin-bottom: 24px; }
.login-card .ctl {
    width: 100%;
    height: 46px;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 0 14px 0 42px;
    font-size: 14.5px;
    outline: none;
    letter-spacing: 2px;
    transition: border-color .15s, box-shadow .15s;
}
.login-card .ctl:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(44,92,230,.13); }
.input-wrap { position: relative; margin-bottom: 16px; }
.input-wrap > i {
    position: absolute; left: 15px; top: 50%;
    transform: translateY(-50%);
    color: var(--muted); font-size: 16px;
}
.login-btn {
    width: 100%;
    height: 46px;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, #3b6bf0, var(--primary));
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 3px;
    cursor: pointer;
    box-shadow: 0 12px 26px -12px rgba(44,92,230,.95);
    transition: filter .15s, transform .1s;
}
.login-btn:hover { filter: brightness(1.07); }
.login-btn:active { transform: scale(.99); }
.login-btn:disabled { opacity: .7; cursor: not-allowed; }
.login-msg { min-height: 20px; margin-top: 12px; text-align: center; font-size: 12.5px; color: var(--up); }
.login-foot { margin-top: 22px; text-align: center; color: var(--muted); font-size: 11.5px; line-height: 1.8; }
.login-foot .login-note { color: #a7b0c6; }
.login-foot .pick { display: inline-flex; align-items: center; gap: 4px; color: #3b6ef5; font-weight: 600; text-decoration: none; }
.login-foot .pick:hover { text-decoration: underline; }

/* ==========================================================================
   移动端抽屉
   ========================================================================== */
.backdrop {
    position: fixed; inset: 0;
    background: rgba(9, 15, 34, .5);
    backdrop-filter: blur(2px);
    z-index: 1040;
    opacity: 0;
    visibility: hidden;
    transition: opacity .22s, visibility .22s;
}
body.drawer-open .backdrop { opacity: 1; visibility: visible; }

@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); box-shadow: none; }
    body.drawer-open .sidebar { transform: translateX(0); box-shadow: 0 0 60px rgba(0,0,0,.4); }
    .main { margin-left: 0 !important; }
    body.sidebar-mini .sidebar { width: var(--sidebar-w); }
    body.sidebar-mini .sidebar-brand .brand-text,
    body.sidebar-mini .nav-label,
    body.sidebar-mini .nav-arrow,
    body.sidebar-mini .nav-group-title,
    body.sidebar-mini .sidebar-foot { display: block; }
    body.sidebar-mini .nav-item { justify-content: flex-start; padding: 10px 12px; }
    body.sidebar-mini .nav-group.open .nav-sub { display: block !important; }

    .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
    .kpi { padding: 13px 14px; }
    .kpi-value { font-size: 20px; }
    .kpi-icon { width: 30px; height: 30px; flex: 0 0 30px; font-size: 14px; }

    .chart-grid { grid-template-columns: 1fr; }
    .content { padding: 14px; }
    .topbar { padding: 0 14px; gap: 10px; }
    .page-head h1 { font-size: 15.5px; }
    .page-head .crumb { display: none; }
    .user-meta { display: none; }
    .chip .txt-hide { display: none; }
    .card-x > .bd { padding: 14px; }
    .card-x > .hd { padding: 12px 14px; }

    .field { flex: 1 1 140px; }
    .field select.ctl { min-width: 0; }
    .field.date .ctl { width: 100%; }
    .filter-bar { gap: 10px; }
    .filter-bar .btn-x { flex: 1 1 100%; }

    .chart { height: 260px; }
    .chart.sm { height: 240px; }

    .swipe-hint {
        display: flex; align-items: center; gap: 6px;
        padding: 8px 14px;
        font-size: 11.5px;
        color: var(--muted);
        background: #fafbff;
        border-bottom: 1px solid var(--line-soft);
    }
}

@media (max-width: 420px) {
    .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .kpi-value { font-size: 18px; }
    .login-card { padding: 28px 22px 22px; }
}

/* 打印 */
@media print {
    .sidebar, .topbar, .filter-bar, .backdrop, .btn-x { display: none !important; }
    .main { margin-left: 0 !important; }
    .card-x { box-shadow: none; border-color: #ccc; break-inside: avoid; }
    body { background: #fff; }
}

/* 旋转动画（刷新按钮） */
@keyframes jdl-spin { to { transform: rotate(360deg); } }
.bi.spin { display: inline-block; animation: jdl-spin .9s linear infinite; }

/* 全局等待遮罩（用于退货汇总这类需要几十秒的强制刷新） */
.loading-mask {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(15, 23, 42, .52);
    backdrop-filter: blur(3px);
}

.loading-mask.show { display: flex; }

.loading-box {
    width: 100%;
    max-width: 380px;
    padding: 26px 24px 22px;
    text-align: center;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 24px 60px rgba(15, 23, 42, .34);
}

.loading-ring {
    width: 44px;
    height: 44px;
    margin: 0 auto 16px;
    border: 3px solid var(--primary-soft);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: jdl-spin .8s linear infinite;
}

.loading-box h4 {
    margin: 0 0 8px;
    font-size: 15.5px;
    font-weight: 650;
    color: var(--ink);
}

.loading-box p {
    margin: 0;
    font-size: 12.5px;
    line-height: 1.7;
    color: var(--muted);
}

.loading-box b.countdown { color: var(--primary); font-variant-numeric: tabular-nums; }

/* ==========================================================================
   部类经营分析
   ---------------------------------------------------------------------------
   页面结构：筛选条 → KPI → 结构（排行 + 部门）→ 质量（四象限 + 走势）
             → 门店×部类强弱 → 明细表
   ========================================================================== */

/* 6 列 KPI */
.kpi-grid.x6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.kpi.compact { padding: 14px 15px; }
.kpi.compact .kpi-value { font-size: 22px; }
.kpi.compact .kpi-icon { width: 28px; height: 28px; flex: 0 0 28px; font-size: 14px; border-radius: 8px; }
.kpi.compact .kpi-top { margin-bottom: 8px; gap: 8px; }
.kpi.compact .kpi-label { font-size: 12px; }
.kpi.compact .kpi-foot { margin-top: 6px; font-size: 11.5px; }

@media (max-width: 1440px) {
    .kpi-grid.x6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
    .kpi-grid.x6 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* 3 列 KPI（今日实时） */
.kpi-grid.x3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 900px) {
    .kpi-grid.x3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
    .kpi-grid.x3 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
}

/* 表格里指标名后面的单位 */
.unit-x { font-size: 11px; color: var(--muted); margin-left: 4px; font-weight: 400; }

/* 看板底部口径说明 */
.note-block {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    margin: 4px 0 8px;
    padding: 12px 14px;
    border-radius: 10px;
    background: #f6f8fc;
    border: 1px solid var(--line);
    color: var(--text-2);
    font-size: 12.5px;
    line-height: 1.85;
}
.note-block i { color: #7d8aa5; margin-top: 2px; }

/* 筛选条里的内联说明文字 */
.qmeta-inline {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12.5px;
    color: var(--text-2);
}
.qmeta-inline b { color: var(--text); font-variant-numeric: tabular-nums; }
.qmeta-inline i { color: #97a3bb; }

/* 双栏栅格 */
.dept-grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 18px; align-items: start; }
.dept-grid > .card-x { margin-bottom: 18px; }
@media (max-width: 1180px) {
    .dept-grid { grid-template-columns: 1fr; }
}

/* 等宽双栏栅格（看板多维分析） */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.grid2 > .card-x { margin-bottom: 18px; }
@media (max-width: 1180px) {
    .grid2 { grid-template-columns: 1fr; }
}

/* ---------- 部门结构：堆叠条 ---------- */
.dstack {
    display: flex;
    height: 36px;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 16px;
    background: var(--line-soft);
}
.dstack > span {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: .2px;
    white-space: nowrap;
    overflow: hidden;
    transition: filter .15s;
    cursor: default;
}
.dstack > span:hover { filter: brightness(1.1); }

.dlist { display: grid; gap: 13px; }
.ditem-top { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.ditem-top .dot { width: 9px; height: 9px; border-radius: 3px; flex: 0 0 9px; }
.ditem-top b { font-weight: 600; }
.ditem-top .pct { margin-left: auto; font-weight: 700; font-variant-numeric: tabular-nums; }
.dbar { height: 6px; border-radius: 99px; background: var(--line-soft); margin: 7px 0 6px; overflow: hidden; }
.dbar i { display: block; height: 100%; border-radius: 99px; transition: width .4s ease; }
.dmeta { display: flex; gap: 12px; flex-wrap: wrap; font-size: 11.5px; color: var(--muted); }
.dmeta b { color: var(--text-2); font-weight: 600; }
.dkids { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 7px; }
.dkids span { font-size: 11px; padding: 2px 8px; border-radius: 6px; background: var(--line-soft); color: var(--text-2); }

/* ---------- 可排序表头 ---------- */
.grid th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
.grid th.sortable::after { content: "\2195"; opacity: .3; margin-left: 4px; font-size: 10px; }
.grid th.sort-asc::after { content: "\2191"; opacity: .85; }
.grid th.sort-desc::after { content: "\2193"; opacity: .85; }

/* ---------- 排名徽章 ---------- */
.rk {
    display: inline-grid;
    place-items: center;
    width: 20px;
    height: 20px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    background: var(--line-soft);
    color: var(--text-2);
    font-variant-numeric: tabular-nums;
}
.rk.t1 { background: linear-gradient(135deg, #ffb74d, #f09319); color: #fff; }
.rk.t2 { background: linear-gradient(135deg, #b0bec5, #8b95ad); color: #fff; }
.rk.t3 { background: linear-gradient(135deg, #d7a06a, #b07b47); color: #fff; }

/* 结构占比小条（表格内） */
.share-cell { display: flex; align-items: center; gap: 8px; min-width: 130px; }
.share-cell .bar { flex: 1 1 auto; height: 6px; border-radius: 99px; background: var(--line-soft); overflow: hidden; }
.share-cell .bar i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, #7ea2ff, #2c5ce6); }
.share-cell span { font-size: 11.5px; color: var(--text-2); font-variant-numeric: tabular-nums; min-width: 42px; text-align: right; }

/* 计划达成率（达标红 / 未达标绿 / 无计划灰） */
.rate-val { font-weight: 700; font-variant-numeric: tabular-nums; }
.rate-val.hit  { color: var(--up); }
.rate-val.miss { color: var(--down); }
.rate-val.na   { color: var(--muted); font-weight: 500; }
table.grid td.neg { color: var(--down); }

/* 口径/说明文字 */
.note-x { font-size: 12px; color: var(--muted); line-height: 1.8; }
.note-x b { color: var(--text-2); }

/* 空状态（本地库未初始化） */
.setup-box {
    max-width: 660px;
    margin: 60px auto;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 34px 36px;
    text-align: center;
}
.setup-box .ico {
    width: 60px; height: 60px;
    margin: 0 auto 18px;
    border-radius: 18px;
    display: grid; place-items: center;
    font-size: 26px;
    color: #fff;
    background: linear-gradient(135deg, #4f7cff, #2c5ce6);
    box-shadow: 0 14px 30px -12px rgba(44,92,230,.9);
}
.setup-box h2 { margin: 0 0 8px; font-size: 18px; }
.setup-box p { margin: 0 0 16px; color: var(--text-2); font-size: 13.5px; line-height: 1.8; }
.setup-box pre {
    text-align: left;
    background: #0f1730;
    color: #d7e3ff;
    border-radius: 10px;
    padding: 14px 16px;
    font-size: 12.5px;
    line-height: 1.9;
    overflow-x: auto;
}

/* 小号分段（筛选条第二行） */
.qseg.sm button, .qseg.sm a { height: 26px; padding: 0 10px; font-size: 11.5px; border-radius: 6px; }
.qbar-sep { width: 1px; height: 22px; background: var(--line); display: inline-block; margin: 0 2px; }

/* 登录页：本机设备标识（设备绑定辅助信息） */
.login-device {
    margin-top: -2px;
    margin-bottom: 12px;
    text-align: center;
    font-size: 11px;
    color: #9aa4b8;
    letter-spacing: 0;
}
.login-device b { color: #5b6884; font-weight: 600; letter-spacing: 1.5px; }
