/* ==========================================================================
   圆梦鸿途 · 管理后台  ·  控制台 Dashboard
   依赖 console/base.css 的 design token 与基础组件
   ========================================================================== */

/* 内联 SVG 图标（Feather 风格） */
svg.i {
    width: 16px;
    height: 16px;
    flex: none;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
    display: inline-block;
    vertical-align: middle;
}

.dash-page { max-width: none; width: 100%; }
/* 控制台内容容器：与设计稿一致，块间距 16px */
#dashConsole {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
#dashCustom { display: block; }

/* ==========================================================================
   A. KPI 条（单卡 4 等分）
   ========================================================================== */
.kpis {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
}
.kpi {
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    border-right: 1px solid var(--line-2);
    min-width: 0;
}
.kpi:last-child { border-right: 0; }
.kpi-t {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--ink-2);
    font-size: 13px;
    font-weight: 500;
    line-height: 1.4;
    white-space: nowrap;
}
.kpi-t .ico {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: var(--pri-2);
    color: var(--pri);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
}
.kpi-v {
    font-size: 28px;
    font-weight: 600;
    line-height: 1;
    color: var(--ink);
    overflow: hidden;
    text-overflow: ellipsis;
}
.kpi-f {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    font-size: 12px;
    line-height: 1.4;
    color: var(--ink-3);
}
.kpi-f b { color: var(--ink-2); font-weight: 500; }

/* ==========================================================================
   B. 第二行：注册趋势折线图 + 用户活跃 2×3
   ========================================================================== */
.row2 {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 380px;
    gap: 16px;
    align-items: stretch;
}
.chart-card {
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.chart-card .card-h { flex-wrap: nowrap; }
.dash-page .card-h h3 { line-height: 1.45; }
.chart-wrap {
    padding: 8px 18px 14px;
    flex: 1;
    min-width: 0;
}
#dashChart {
    width: 100%;
    height: 280px;
    display: block;
}
.legend {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 12px;
    color: var(--ink-2);
    white-space: nowrap;
    flex: none;
}
.legend > span { display: inline-flex; align-items: center; }
.legend i {
    display: inline-block;
    width: 10px;
    height: 2px;
    border-radius: 1px;
    background: var(--pri);
    margin-right: 6px;
}
.legend i.b {
    height: 0;
    border-radius: 0;
    background: transparent;
    border-top: 2px dashed #9DB5E6;
}

.activity-card { display: flex; flex-direction: column; min-width: 0; }
.mini {
    display: grid;
    grid-template-columns: 1fr 1fr;
    height: 100%;
}
.mini .m {
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    border-bottom: 1px solid var(--line-2);
    border-right: 1px solid var(--line-2);
    min-width: 0;
}
.mini .m:nth-child(even) { border-right: 0; }
.mini .m:nth-last-child(-n+2) { border-bottom: 0; }
.m-l {
    color: var(--ink-3);
    font-size: 12px;
    line-height: 1.45;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.m-v {
    display: flex;
    align-items: baseline;
    gap: 8px;
    min-width: 0;
    flex-wrap: wrap;
}
.m-v b {
    font-size: 22px;
    font-weight: 600;
    line-height: 1.32;
    color: var(--ink);
}
.m-v .m-c { font-size: 11.5px; line-height: 1.3; white-space: nowrap; }
.m-v .m-c .up, .m-v .m-c .dn, .m-v .m-c .muted { font-size: 11.5px; }
.spark {
    height: 22px;
    width: 100%;
    display: block;
    margin-top: auto;
    overflow: visible;
}

/* ==========================================================================
   C. 系统统计 4 卡
   ========================================================================== */
.sys {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
}
.sys-card {
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-width: 0;
}
.sys-h {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    line-height: 1.45;
    font-weight: 600;
    color: var(--ink);
    white-space: nowrap;
}
.sys-h .ico { color: var(--pri); }
.live {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 500;
    color: var(--ok);
    white-space: nowrap;
}
.live::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--ok);
    box-shadow: 0 0 0 3px var(--ok-bg);
    flex: none;
}
.sys-b { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; min-width: 0; }
.sys-b.one { grid-template-columns: 1fr; }
.sys-b > div { min-width: 0; }
.sys-b b {
    display: block;
    font-size: 22px;
    font-weight: 600;
    line-height: 1.32;
    color: var(--ink);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.sys-b span {
    display: block;
    margin-top: 3px;
    font-size: 12px;
    line-height: 1.25;
    color: var(--ink-3);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.bar {
    height: 4px;
    border-radius: 2px;
    background: var(--line-2);
    overflow: hidden;
    flex: none;
}
.bar > i {
    display: block;
    height: 100%;
    border-radius: 2px;
    background: var(--pri);
    transition: width .3s ease;
}
.sys-f {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: 11.5px;
    line-height: 1.4;
    color: var(--ink-3);
    white-space: nowrap;
}
.sys-f .num { color: var(--ink-3); }

/* ==========================================================================
   D. 自定义视图占位
   ========================================================================== */
.dash-custom { display: block; }
.dash-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 72px 24px;
    text-align: center;
    background: #FAFBFC;
    border-style: dashed;
    border-color: #C9D1DD;
}
.dash-empty-ico {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: var(--pri-2);
    color: var(--pri);
    display: flex;
    align-items: center;
    justify-content: center;
}
.dash-empty-ico .i { width: 20px; height: 20px; }
.dash-empty h3 { font-size: 15px; font-weight: 600; color: var(--ink); }
.dash-empty p { margin: 0; max-width: 440px; font-size: 12.5px; line-height: 1.6; color: var(--ink-3); }

/* ==========================================================================
   E. 响应式
   ========================================================================== */
@media (max-width: 1280px) {
    .row2 { grid-template-columns: 1fr; }
    .mini { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .mini .m {
        border-right: 1px solid var(--line-2) !important;
        border-bottom: 1px solid var(--line-2) !important;
    }
    .mini .m:nth-child(3n) { border-right: 0 !important; }
    .mini .m:nth-last-child(-n+3) { border-bottom: 0 !important; }
    .sys { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1024px) {
    .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .kpi:nth-child(2) { border-right: 0; }
    .kpi:nth-child(-n+2) { border-bottom: 1px solid var(--line-2); }
}

@media (max-width: 640px) {
    .ph { align-items: flex-start; }
    .ph-actions { width: 100%; }
    .kpi { padding: 16px 14px; gap: 8px; }
    .kpi-v { font-size: 24px; }
    .kpi-t { font-size: 12.5px; }
    .card-h { padding: 12px 14px; gap: 8px; flex-wrap: wrap; }
    .chart-wrap { padding: 6px 10px 10px; }
    #dashChart { height: 220px; }
    .mini { grid-template-columns: 1fr 1fr; }
    .mini .m { padding: 14px; }
    .mini .m:nth-child(3n) { border-right: 1px solid var(--line-2) !important; }
    .mini .m:nth-child(even) { border-right: 0 !important; }
    .mini .m:nth-last-child(3) { border-bottom: 1px solid var(--line-2) !important; }
    .sys { grid-template-columns: 1fr; }
    .sys-card { padding: 14px; }
    .legend { gap: 12px; font-size: 11.5px; }
    .dash-empty { padding: 56px 18px; }
}

/* ==========================================================================
   F. iframe 场景适配
   后台内容页以 iframe 加载，iframe 宽度 = 窗口宽度 - 232px 侧栏，
   若直接使用 viewport 媒体查询，1440 窗口(iframe≈1208)会被误判为窄屏。
   dashboard.js 会按真实窗口宽度给 body 添加 vp-* class，这里按设计稿断点还原。
   ========================================================================== */
body.dash-in-frame.vp-gt-1280 .row2 { grid-template-columns: minmax(0, 1fr) 380px; }
body.dash-in-frame.vp-gt-1280 .mini { grid-template-columns: 1fr 1fr; }
body.dash-in-frame.vp-gt-1280 .mini .m {
    border-right: 1px solid var(--line-2) !important;
    border-bottom: 1px solid var(--line-2) !important;
}
body.dash-in-frame.vp-gt-1280 .mini .m:nth-child(even) { border-right: 0 !important; }
body.dash-in-frame.vp-gt-1280 .mini .m:nth-last-child(-n+2) { border-bottom: 0 !important; }
body.dash-in-frame.vp-gt-1280 .sys { grid-template-columns: repeat(4, minmax(0, 1fr)); }

body.dash-in-frame.vp-1025-1280 .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
body.dash-in-frame.vp-1025-1280 .kpi {
    border-right: 1px solid var(--line-2);
    border-bottom: 0;
}
body.dash-in-frame.vp-1025-1280 .kpi:nth-child(2) { border-right: 1px solid var(--line-2); }
body.dash-in-frame.vp-1025-1280 .kpi:last-child { border-right: 0; }
body.inside-header.dash-in-frame.vp-1025-1280 { padding: 20px; }