/* 51.LA 简易统计系统 */
:root {
    --bg: #f3f6fb;
    --card: #ffffff;
    --text: #1f2a44;
    --muted: #8a94a6;
    --line: #edf1f7;
    --primary: #1677ff;
    --primary-weak: #eaf2ff;
    --green: #18a058;
    --orange: #ff8a3d;
    --radius: 10px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 14px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: #0e66e8; }

/* ---------------- 布局 ---------------- */

.sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    width: 216px;
    background: #fff;
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    padding: 18px 14px;
    z-index: 20;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 16px;
    padding: 4px 10px 20px;
    color: var(--text);
}
.brand:hover { color: var(--text); }

.brand-mark {
    width: 34px; height: 34px;
    border-radius: 9px;
    background: linear-gradient(135deg, #1677ff, #69b1ff);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    font-weight: 800;
    letter-spacing: -.5px;
    box-shadow: 0 6px 14px rgba(22, 119, 255, .25);
}

.nav { display: flex; flex-direction: column; gap: 3px; }
.nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    color: #455066;
    font-weight: 500;
    font-size: 13.5px;
}
.nav a svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.7; flex: 0 0 18px; }
.nav a:hover { background: #f5f8ff; color: var(--primary); }
.nav a.active { background: var(--primary-weak); color: var(--primary); }
.nav-sep { margin: 12px 6px; border-top: 1px solid var(--line); }

.sidebar-foot {
    margin-top: auto;
    padding: 14px 10px 0;
    border-top: 1px solid var(--line);
    font-size: 12px;
    color: var(--muted);
}
.sidebar-foot .who { color: #46506a; font-weight: 600; margin-bottom: 6px; }
.sidebar-foot a { color: var(--muted); }
.sidebar-foot a:hover { color: var(--primary); }

.main { margin-left: 216px; min-height: 100vh; }

.topbar {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    padding: 20px 24px 0;
    flex-wrap: wrap;
}
.page-title { font-size: 20px; font-weight: 700; letter-spacing: -.2px; }
.page-desc { font-size: 12px; color: var(--muted); margin-top: 3px; }
.top-actions { display: flex; align-items: center; gap: 10px; }

.site-select {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 12.5px;
    color: var(--muted);
}
.site-select select {
    border: 0;
    background: transparent;
    font: inherit;
    color: var(--text);
    outline: none;
    max-width: 220px;
    cursor: pointer;
}

.content { padding: 16px 24px 34px; max-width: 1680px; }

/* ---------------- 卡片 ---------------- */

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 1px 2px rgba(20, 35, 70, .03);
    min-width: 0;
}

.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 15px 18px;
    border-bottom: 1px solid #f3f6fa;
    flex-wrap: wrap;
}
.card-title { font-size: 15px; font-weight: 650; display: flex; align-items: center; gap: 8px; }
.card-title .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); }
.card-title .dot.green { background: #18a058; }
.card-title .dot.orange { background: #ff8a3d; }
.card-actions { font-size: 12px; color: var(--muted); }
.card-body { padding: 16px 18px; }
.card-body.tight { padding: 8px 18px 14px; }

.grid-2 { display: grid; grid-template-columns: 2fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.section-gap { margin-top: 14px; }
.mt-14 { margin-top: 14px; }

/* ---------------- 概况 ---------------- */

.overview-top { display: grid; grid-template-columns: 270px minmax(0, 1fr); gap: 14px; margin-bottom: 14px; }

.realtime {
    background: linear-gradient(150deg, #eaf3ff, #dbe9ff);
    border: 0;
    min-height: 186px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 18px;
}
.realtime h3 { margin: 0; font-size: 13px; color: #3b5b8a; font-weight: 600; display: flex; gap: 6px; align-items: center; }
.realtime .big { font-size: 46px; font-weight: 800; color: #0b2a55; line-height: 1; letter-spacing: -1px; }
.realtime .hint { font-size: 12px; color: #5e7aa3; }
.realtime a { font-size: 12px; }

.ov-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.ov-table th {
    font-weight: 500;
    color: var(--muted);
    text-align: right;
    padding: 10px 12px;
    background: #f8fafd;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
.ov-table th:first-child { text-align: left; background: transparent; border-bottom: 0; }
.ov-table td { text-align: right; padding: 11px 12px; border-bottom: 1px dashed #eef2f7; white-space: nowrap; }
.ov-table td:first-child { text-align: left; color: #5a6477; width: 110px; }
.ov-table tr:last-child td { border-bottom: 0; }
.ov-table .num { font-size: 15px; font-weight: 600; color: #23314d; font-variant-numeric: tabular-nums; }
.delta { color: #ff4d4f; font-size: 11px; margin-left: 3px; }
.delta.down { color: #18a058; }

.legend-inline { display: flex; gap: 16px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.legend-inline i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 5px; }

/* ---------------- 标签 / 按钮 ---------------- */

.tabs { display: inline-flex; background: #f2f5fa; border-radius: 8px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.tab {
    padding: 6px 13px;
    border-radius: 6px;
    color: #66708a;
    font-size: 12px;
    border: 0;
    background: transparent;
    cursor: pointer;
    white-space: nowrap;
    font-family: inherit;
    line-height: 1.4;
}
.tab:hover { color: var(--primary); }
.tab.active { background: #fff; color: var(--primary); box-shadow: 0 1px 3px rgba(22, 35, 70, .08); font-weight: 600; }

.pills { display: flex; gap: 8px; flex-wrap: wrap; }
.pill {
    display: inline-flex;
    align-items: center;
    height: 30px;
    padding: 0 12px;
    border-radius: 6px;
    border: 1px solid #e3e9f2;
    background: #fff;
    color: #5d6880;
    font-size: 12px;
}
.pill:hover { border-color: #b9cdf0; color: var(--primary); }
.pill.active { background: var(--primary); border-color: var(--primary); color: #fff; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 34px;
    padding: 0 16px;
    border-radius: 7px;
    border: 1px solid #dfe5ee;
    background: #fff;
    color: #35405a;
    font: inherit;
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
}
.btn:hover { border-color: #b9c6da; color: #1f2a44; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: #0e66e8; border-color: #0e66e8; color: #fff; }
.btn-danger { color: #e5484d; border-color: #f2c4c5; background: #fff; }
.btn-danger:hover { background: #fff5f5; color: #d4380d; border-color: #ef9a9d; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn-block { width: 100%; height: 40px; font-size: 14px; }

/* ---------------- 表单 ---------------- */

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > span { font-size: 12px; color: #6b7488; }

input[type=text], input[type=password], input[type=date], input[type=search], select, textarea {
    height: 36px;
    border: 1px solid #dfe5ee;
    border-radius: 7px;
    padding: 0 10px;
    font: inherit;
    font-size: 13px;
    color: var(--text);
    background: #fff;
    outline: none;
}
input:focus, select:focus, textarea:focus {
    border-color: #7eb3ff;
    box-shadow: 0 0 0 3px rgba(22, 119, 255, .1);
}
textarea { height: auto; padding: 10px; resize: vertical; }

.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.filter-field { display: flex; flex-direction: column; gap: 6px; }
.filter-field > span { font-size: 12px; color: #8a94a6; }
.filter-field input, .filter-field select { width: 150px; height: 34px; }
.filter-field.wide input { width: 210px; }
.filter-actions { display: flex; gap: 8px; padding-bottom: 0; }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.toolbar-right { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ---------------- 表格 ---------------- */

.table-wrap { overflow: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 860px; }
.data-table th {
    text-align: left;
    color: #7b869b;
    font-weight: 500;
    background: #f8fafd;
    padding: 10px 12px;
    white-space: nowrap;
    border-bottom: 1px solid var(--line);
}
.data-table td { padding: 11px 12px; border-bottom: 1px solid #f1f4f9; vertical-align: middle; white-space: nowrap; }
.data-table tbody tr:hover { background: #fafcff; }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table .url { max-width: 380px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; vertical-align: middle; }
.data-table .strong { font-weight: 600; }
.data-table .total-row td { background: #fbfcfe; font-weight: 600; }
.data-table .sub { color: var(--muted); font-size: 12px; }

.badge { display: inline-block; padding: 2px 7px; border-radius: 4px; font-size: 11px; line-height: 1.5; background: #f1f4f9; color: #647089; }
.badge-new { background: #e8f7ef; color: #18a058; }
.badge-old { background: #f1f4f9; color: #7b869b; }
.badge-blue { background: var(--primary-weak); color: var(--primary); }
.badge-gray { background: #f1f4f9; color: #7b869b; }

.pager { display: flex; align-items: center; gap: 6px; justify-content: flex-end; padding: 14px 18px; flex-wrap: wrap; }
.pager-total, .pager-size { font-size: 12px; color: var(--muted); margin-right: 4px; }
.pager-btn {
    min-width: 30px; height: 30px;
    padding: 0 9px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #e3e9f2;
    border-radius: 6px;
    background: #fff;
    color: #5d6880;
    font-size: 12.5px;
}
.pager-btn:hover { border-color: #b9cdf0; color: var(--primary); }
.pager-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.pager-btn.disabled { color: #c3cad8; pointer-events: none; background: #fbfcfe; }
.pager-gap { color: #a5afc0; font-size: 12px; }

/* ---------------- 图表 / 环境 ---------------- */

.chart { width: 100%; }

.progress-list { padding: 4px 0; }
.progress-row {
    display: grid;
    grid-template-columns: 130px minmax(80px, 1fr) 96px;
    gap: 12px;
    align-items: center;
    padding: 8px 0;
    font-size: 12.5px;
}
.progress-label { color: #4a556d; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.progress-track { height: 9px; background: #f1f4f9; border-radius: 5px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 5px; background: linear-gradient(90deg, #9fcbff, #1677ff); min-width: 2px; }
.progress-fill.green { background: linear-gradient(90deg, #9be3bf, #18a058); }
.progress-value { text-align: right; color: #7b869b; font-variant-numeric: tabular-nums; }
.progress-value b { color: #2b3852; font-weight: 600; }

.rt-strip { display: grid; grid-template-columns: repeat(3, 190px); gap: 12px; padding: 16px 18px; }
.rt-item { border-radius: 8px; padding: 12px 14px; background: #f8fbff; border: 1px solid #edf3fb; }
.rt-item.blue { background: linear-gradient(150deg, #f0f6ff, #e8f1ff); }
.rt-item.green { background: linear-gradient(150deg, #eefaf4, #e4f7ed); }
.rt-item.orange { background: linear-gradient(150deg, #fff7ef, #fff1e3); }
.rt-label { font-size: 12px; color: #6d7890; }
.rt-value { font-size: 24px; font-weight: 700; margin-top: 6px; font-variant-numeric: tabular-nums; }

/* 地域分布 */
.map-wrap { height: 440px; width: 100%; }
.geo-table .row-toggle {
    width: 18px; height: 18px;
    margin-right: 7px;
    border: 0;
    border-radius: 4px;
    background: #f1f5fb;
    color: #7b869b;
    cursor: pointer;
    font-size: 11px;
    line-height: 1;
    padding: 0;
    transition: transform .15s ease, background .15s ease, color .15s ease;
    vertical-align: middle;
}
.geo-table .row-toggle.open { transform: rotate(90deg); background: #eaf2ff; color: #1677ff; }
.geo-table .row-spacer { display: inline-block; width: 25px; }
.geo-table .geo-child td { background: #fbfcfe; color: #5d6880; }
.geo-table .geo-child td:first-child { padding-left: 34px; }
.geo-table .geo-child.hidden { display: none; }
.geo-table .geo-sub { color: var(--muted); font-size: 11.5px; margin-left: 6px; }
.geo-note { font-size: 12px; color: var(--muted); padding: 0 18px 14px; }
.geo-loading { display: flex; align-items: center; justify-content: center; height: 440px; color: #98a2b3; font-size: 13px; }

/* ---------------- 其他 ---------------- */

.empty { text-align: center; color: #98a2b3; padding: 38px 12px; font-size: 13px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.text-right { text-align: right; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

.alert { padding: 10px 12px; border-radius: 7px; font-size: 12.5px; margin-bottom: 14px; }
.alert-error { background: #fff1f0; color: #d4380d; border: 1px solid #ffccc7; }
.alert-success { background: #f0faf4; color: #18a058; border: 1px solid #c6ebd6; }

.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.kpi { padding: 15px 18px; }
.kpi-label { font-size: 12px; color: var(--muted); }
.kpi-value { font-size: 24px; font-weight: 700; margin-top: 5px; letter-spacing: -.3px; font-variant-numeric: tabular-nums; }
.kpi-foot { font-size: 11.5px; color: var(--muted); margin-top: 3px; }

.stat-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 10px; }
.stat-box { padding: 14px 16px; border: 1px solid #eff3f9; border-radius: 8px; background: #fbfcfe; }
.stat-box .label { font-size: 12px; color: var(--muted); }
.stat-box .value { font-size: 21px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }

/* 登录 / 安装 */
.auth-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(1200px 600px at 20% 0%, #e8f1ff, #f4f7fc 60%);
    padding: 24px;
}
.auth-card {
    width: 380px;
    max-width: 100%;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: 0 20px 50px rgba(30, 60, 120, .12);
    padding: 30px;
}
.auth-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; margin-bottom: 22px; }
.auth-ok { background: #f0faf4; color: #159957; border: 1px solid #c6ebd6; border-radius: 7px; padding: 10px 12px; font-size: 13px; margin-bottom: 16px; }
.auth-foot { margin-top: 16px; font-size: 12px; color: var(--muted); text-align: center; }

/* 弹层 */
dialog.modal { border: 0; border-radius: 12px; padding: 22px; width: min(620px, 92vw); box-shadow: 0 24px 60px rgba(15, 30, 60, .25); }
dialog::backdrop { background: rgba(15, 25, 45, .45); }
.modal h3 { margin: 0 0 6px; font-size: 16px; }
.modal textarea { width: 100%; font-family: ui-monospace, Consolas, "Courier New", monospace; font-size: 12px; background: #f7f9fc; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }

.snippet-code {
    display: block;
    background: #f7f9fc;
    border: 1px solid #e8edf5;
    border-radius: 7px;
    padding: 10px 12px;
    font-family: ui-monospace, Consolas, "Courier New", monospace;
    font-size: 12px;
    color: #35405a;
    word-break: break-all;
}

/* 响应式 */
@media (max-width: 1280px) {
    .grid-3 { grid-template-columns: 1fr 1fr; }
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .stat-grid { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 980px) {
    .sidebar { position: static; width: 100%; height: auto; flex-direction: row; align-items: center; flex-wrap: wrap; padding: 10px 14px; }
    .brand { padding: 0 14px 0 0; flex: 0 0 auto; }
    .nav { flex-direction: row; gap: 2px; flex-wrap: wrap; }
    .nav a { padding: 8px 10px; white-space: nowrap; }
    .nav a svg { display: none; }
    .nav-sep, .sidebar-foot { display: none; }
    .main { margin-left: 0; }
    .topbar { padding: 16px 16px 0; }
    .content { padding: 14px 16px 28px; }
    .overview-top, .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .rt-strip { grid-template-columns: 1fr; }
    .stat-grid { grid-template-columns: 1fr 1fr; }
    .map-wrap, .geo-loading { height: 300px; }
    .ov-table th, .ov-table td { padding: 9px 7px; font-size: 12px; }
    .ov-table td:first-child { width: 66px; }
    .ov-table .num { font-size: 13px; }
}
