/**
 * Zib 数据统计 - 前台样式
 * 商务/官方风格：海军蓝主色、细边框卡片、规整数据表；跟随 Zibll 明暗模式
 */
.zs-page,
.zs-widget-root {
    --zs-primary: #1f4e79;
    --zs-primary-2: #3f7ca8;
    --zs-primary-soft: #eaf1f7;
    --zs-gold: #b08d57;
    --zs-ink: var(--key-color, #1f2a37);
    --zs-muted: var(--muted-color, #6b7a8c);
    --zs-line: var(--main-border-color, rgba(31, 42, 55, .12));
    --zs-bg: var(--main-bg, #fff);
    --zs-bg-soft: rgba(31, 78, 121, .045);
}

.zs-page {
    padding: 10px 0 30px;
    color: var(--zs-ink);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

.zs-page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    padding-bottom: 16px;
    margin-bottom: 18px;
    border-bottom: 1px solid var(--zs-line);
}

.zs-page-head-main {
    min-width: 0;
}

.zs-page-head-side {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.zs-eyebrow {
    margin-bottom: 4px;
    color: var(--zs-primary);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .12em;
    line-height: 1.4;
}

.zs-page-title {
    margin: 0;
    color: var(--zs-ink);
    font-size: 26px;
    font-weight: 600;
    letter-spacing: -.01em;
    line-height: 1.3;
}

.zs-page-sub {
    margin: 6px 0 0;
    color: var(--zs-muted);
    font-size: 13px;
    line-height: 1.6;
}

.zs-shortcode-title {
    margin: 0 0 16px;
    color: var(--zs-ink);
    font-size: 20px;
    font-weight: 600;
}

.zs-range-tabs {
    display: inline-flex;
    overflow: hidden;
    border: 1px solid var(--zs-line);
    border-radius: 6px;
    background: var(--zs-bg);
}

.zs-page-tabs .but {
    border: 0;
    border-right: 1px solid var(--zs-line);
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    padding: 7px 14px;
    color: var(--zs-muted);
    font-size: 13px;
    line-height: 1.4;
    cursor: pointer;
}

.zs-page-tabs .but:last-child {
    border-right: 0;
}

.zs-page-tabs .but:hover {
    background: var(--zs-bg-soft);
    color: var(--zs-ink);
}

.zs-page-tabs .but.active {
    background: var(--zs-primary);
    color: #fff;
    font-weight: 600;
    box-shadow: none;
}

.zs-page-grid {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 16px;
}

.zs-page-col {
    min-width: 0;
}

.zs-span-12 { grid-column: span 12; }
.zs-span-6  { grid-column: span 6; }
.zs-span-4  { grid-column: span 4; }

.zib-widget.zs-page-card {
    padding: 0;
    overflow: hidden;
    border: 1px solid var(--zs-line);
    border-radius: 8px;
    background: var(--zs-bg);
    box-shadow: 0 1px 2px rgba(16, 24, 40, .03);
}

.zs-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--zs-line);
    background: var(--zs-bg-soft);
}

.zs-card-title {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--zs-ink);
    font-size: 14px;
    font-weight: 600;
    line-height: 1.4;
}

.zs-card-title::before {
    content: '';
    display: inline-block;
    width: 3px;
    height: 13px;
    background: var(--zs-primary);
}

.zs-card-body {
    padding: 16px;
}

.zs-widget-root {
    position: relative;
}

.zs-widget-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin: 6px 0 12px;
}

.zs-widget-tabs .zs-tab {
    border: 1px solid var(--zs-line);
    border-radius: 4px;
    background: transparent;
    color: var(--zs-muted);
    padding: 3px 10px;
    font-size: 12px;
    line-height: 1.5;
    cursor: pointer;
}

.zs-widget-tabs .zs-tab:hover {
    border-color: var(--zs-primary-2);
    color: var(--zs-ink);
}

.zs-widget-tabs .zs-tab.active {
    border-color: var(--zs-primary);
    background: var(--zs-primary);
    color: #fff;
}

.zs-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
}

.zs-stat {
    position: relative;
    overflow: hidden;
    padding: 14px 16px 13px;
    border: 1px solid var(--zs-line);
    border-radius: 8px;
    background: var(--zs-bg);
}

.zs-page-card .zs-stat,
.zs-widget-root .zs-stat {
    background: var(--zs-bg-soft);
    box-shadow: none;
}

.zs-stat::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: var(--zs-primary);
}

.zs-stat.c-blue::before { background: #1f4e79; }
.zs-stat.c-cyan::before { background: #3f7ca8; }
.zs-stat.c-green::before { background: #2f6f6b; }
.zs-stat.c-yellow::before { background: #b08d57; }
.zs-stat.c-purple::before { background: #5b6b7c; }
.zs-stat.c-pink::before { background: #8a6d7d; }
.zs-stat.c-orange::before { background: #a86a3f; }

.zs-stat-label {
    margin-bottom: 8px;
    color: var(--zs-muted);
    font-size: 12px;
    letter-spacing: .03em;
    line-height: 1.4;
}

.zs-stat-value-row {
    display: flex;
    align-items: baseline;
    gap: 7px;
    flex-wrap: wrap;
}

.zs-stat-val {
    color: var(--zs-ink);
    font-size: 24px;
    font-weight: 600;
    letter-spacing: -.02em;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
}

.zs-compare {
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.4;
    white-space: nowrap;
}

.zs-compare.up {
    color: #b42318;
    background: rgba(180, 35, 24, .08);
}

.zs-compare.down {
    color: #067647;
    background: rgba(6, 118, 71, .08);
}

.zs-compare.flat {
    color: var(--zs-muted);
    background: rgba(107, 122, 140, .1);
}

.zs-chart-box,
.zs-echart {
    width: 100%;
}

.zs-echart {
    min-height: 160px;
}

.zs-rank-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.zs-rank-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--zs-line);
}

.zs-rank-item:last-child {
    border-bottom: 0;
}

.zs-rank-badge {
    flex: 0 0 22px;
    height: 22px;
    line-height: 22px;
    border-radius: 4px;
    background: var(--zs-bg-soft);
    color: var(--zs-muted);
    font-size: 11px;
    font-weight: 600;
    text-align: center;
}

.zs-rank-badge.top {
    background: var(--zs-primary-soft);
    color: var(--zs-primary);
}

.zs-rank-main {
    flex: 1 1 auto;
    min-width: 0;
}

.zs-rank-name {
    display: block;
    overflow: hidden;
    color: var(--zs-ink);
    font-size: 13px;
    text-decoration: none;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.zs-rank-name:hover {
    color: var(--zs-primary);
}

.zs-mini-bar-wrap {
    height: 4px;
    margin-top: 5px;
    overflow: hidden;
    border-radius: 2px;
    background: var(--zs-bg-soft);
}

.zs-mini-bar {
    height: 100%;
    border-radius: 2px;
    background: var(--zs-primary);
}

.zs-rank-meta {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

.zs-rank-val {
    min-width: 40px;
    color: var(--zs-ink);
    font-size: 13px;
    font-weight: 600;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.zs-table-wrap {
    width: 100%;
    overflow-x: auto;
}

.zs-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.zs-table th,
.zs-table td {
    padding: 9px 10px;
    border-bottom: 1px solid var(--zs-line);
    text-align: left;
    vertical-align: middle;
    white-space: nowrap;
}

.zs-table th {
    background: var(--zs-bg-soft);
    color: var(--zs-muted);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .04em;
}

.zs-page .zs-table td,
.zs-widget-root .zs-table td,
.zs-page .zs-table tbody td,
.zs-widget-root .zs-table tbody td {
    color: var(--zs-ink) !important;
}

.zs-page .zs-table code,
.zs-widget-root .zs-table code {
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--zs-ink) !important;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 11px;
}

.zs-table tbody tr:hover {
    background: var(--zs-bg-soft);
}

.zs-realtime-head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.zs-realtime-head strong {
    color: var(--zs-ink);
    font-size: 13px;
    font-weight: 600;
}

.zs-online-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #16794c;
    box-shadow: 0 0 0 3px rgba(22, 121, 76, .12);
}

.zs-ellipsis {
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.zs-sub {
    color: var(--zs-muted);
    font-size: 12px;
}

.zs-empty {
    padding: 26px 12px;
    color: var(--zs-muted);
    font-size: 13px;
    text-align: center;
}

.zs-loading {
    opacity: .5;
    pointer-events: none;
}

.zs-lazy {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 40px 12px;
    color: var(--zs-muted);
    font-size: 13px;
}

.zs-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--zs-line);
    border-top-color: var(--zs-primary);
    border-radius: 50%;
    animation: zs-spin .8s linear infinite;
}

@keyframes zs-spin {
    to { transform: rotate(360deg); }
}

.zs-footnote {
    margin: 18px 0 0;
    padding-top: 12px;
    border-top: 1px solid var(--zs-line);
    color: var(--zs-muted);
    font-size: 11px;
    line-height: 1.6;
}

.zs-widget-root .zs-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

body.dark-theme .zs-page,
body.dark-theme .zs-widget-root {
    --zs-ink: #e6edf5;
    --zs-muted: #93a4b8;
    --zs-line: rgba(255, 255, 255, .12);
    --zs-bg: #151f2b;
    --zs-bg-soft: rgba(127, 179, 217, .08);
    --zs-primary: #7fb3d9;
    --zs-primary-2: #a8c9e3;
    --zs-primary-soft: rgba(127, 179, 217, .14);
    --zs-gold: #d4b483;
}

body.dark-theme .zib-widget.zs-page-card {
    background: var(--zs-bg);
}

body.dark-theme .zs-page-tabs .but.active,
body.dark-theme .zs-widget-tabs .zs-tab.active {
    background: #2f6f9f;
    border-color: #2f6f9f;
    color: #fff;
}

body.dark-theme .zs-stat.c-blue::before { background: #7fb3d9; }
body.dark-theme .zs-stat.c-cyan::before { background: #a8c9e3; }
body.dark-theme .zs-stat.c-green::before { background: #7fbcb7; }
body.dark-theme .zs-stat.c-yellow::before { background: #d4b483; }
body.dark-theme .zs-stat.c-purple::before { background: #9fb0c2; }
body.dark-theme .zs-stat.c-pink::before { background: #b08f9d; }
body.dark-theme .zs-stat.c-orange::before { background: #c08a5f; }

body.dark-theme .zs-table th {
    background: rgba(255, 255, 255, .04);
}

@media (max-width: 996px) {
    .zs-page-head {
        align-items: flex-start;
        flex-direction: column;
    }
    .zs-page-head-side {
        width: 100%;
    }
    .zs-span-6,
    .zs-span-4 {
        grid-column: span 12;
    }
    .zs-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 600px) {
    .zs-page-title {
        font-size: 21px;
    }
    .zs-page-tabs {
        display: flex;
        width: 100%;
    }
    .zs-page-tabs .but {
        flex: 1 1 0;
        padding: 7px 6px;
        text-align: center;
    }
    .zs-stats,
    .zs-widget-root .zs-stats {
        grid-template-columns: 1fr;
    }
    .zs-stat-val {
        font-size: 22px;
    }
}
