/* ============================================
   珩宇统计 V1.5 现代化 Dashboard 样式
   ============================================ */

:root {
    --bg: #f5f7fa;
    --card-bg: #ffffff;
    --text: #1f2937;
    --text-muted: #6b7280;
    --border: #e5e7eb;
    --primary: #4f6ef7;
    --primary-light: #eef2ff;
    --green: #10b981;
    --red: #ef4444;
    --orange: #f59e0b;
    --purple: #8b5cf6;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,0.04), 0 4px 12px rgba(0,0,0,0.04);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
                 "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
}

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

/* ===== 顶部导航 ===== */
.topbar {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}

.logo {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
}
.logo span {
    font-size: 12px;
    color: var(--primary);
    background: var(--primary-light);
    padding: 2px 8px;
    border-radius: 10px;
    margin-left: 8px;
    font-weight: 500;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
    color: var(--text-muted);
    font-size: 13px;
}

/* ===== 布局 ===== */
.layout {
    display: flex;
    min-height: calc(100vh - 56px);
}

/* ===== 侧边栏 ===== */
.sidebar {
    width: 200px;
    background: var(--card-bg);
    border-right: 1px solid var(--border);
    padding: 16px 0;
    flex-shrink: 0;
}

.menu {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 14px;
    transition: all 0.15s;
    border-left: 3px solid transparent;
}
.menu:hover {
    background: var(--bg);
    color: var(--text);
    text-decoration: none;
}
.menu.active {
    color: var(--primary);
    background: var(--primary-light);
    border-left-color: var(--primary);
    font-weight: 500;
}

/* ===== 页面切换 ===== */
.page { display: none; }
.page.active { display: block; animation: fadeIn 0.2s ease; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== 主内容区 ===== */
.main {
    flex: 1;
    padding: 24px;
    overflow-x: hidden;
}

.page-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}
.page-title h1 {
    font-size: 22px;
    font-weight: 700;
}
.page-title p {
    color: var(--text-muted);
    font-size: 13px;
    margin-top: 2px;
}

select, input, button {
    font-family: inherit;
    font-size: 14px;
}

select {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--card-bg);
    color: var(--text);
    cursor: pointer;
    outline: none;
}
select:focus { border-color: var(--primary); }

/* ===== 卡片网格 ===== */
.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow);
    transition: transform 0.15s;
}
.card:hover { transform: translateY(-2px); }

.card small {
    color: var(--text-muted);
    font-size: 12px;
    display: block;
    margin-bottom: 6px;
}

.card .number {
    font-size: 28px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.2;
}

.card .desc {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

.card .trend {
    font-size: 12px;
    margin-top: 6px;
}
.trend.up { color: var(--green); }
.trend.down { color: var(--red); }

/* ===== 面板 ===== */
.panel {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    margin-bottom: 16px;
}

.panel-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    font-size: 15px;
    font-weight: 600;
}

.panel-title .live {
    font-size: 11px;
    color: var(--red);
    background: #fef2f2;
    padding: 3px 10px;
    border-radius: 10px;
    font-weight: 500;
}

/* ===== 两列布局 ===== */
.two-column {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

@media (max-width: 900px) {
    .two-column { grid-template-columns: 1fr; }
    .sidebar { display: none; }
    .main { padding: 16px; }
}

/* ===== 图表区 ===== */
.chart {
    position: relative;
    height: 220px;
    display: flex;
    align-items: flex-end;
    gap: 2px;
    padding-top: 10px;
}

.chart .bar {
    flex: 1;
    background: linear-gradient(180deg, var(--primary) 0%, #818cf8 100%);
    border-radius: 3px 3px 0 0;
    min-width: 4px;
    position: relative;
    transition: opacity 0.15s;
}
.chart .bar:hover { opacity: 0.8; }
.chart .bar span {
    position: absolute;
    bottom: -22px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 10px;
    color: var(--text-muted);
    white-space: nowrap;
}

/* 折线图（SVG） */
.line-chart {
    width: 100%;
    height: 220px;
}

/* ===== 列表 ===== */
.list-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}
.list-row:last-child { border-bottom: none; }
.list-row span {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-right: 12px;
}
.list-row b {
    color: var(--text);
    font-weight: 600;
}

/* 实时访客行 */
.visitor-row {
    display: grid;
    grid-template-columns: 50px 1fr 140px;
    gap: 8px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 12px;
    align-items: center;
}
.visitor-row:last-child { border-bottom: none; }
.visitor-row .url-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text);
}
.visitor-row .time-text {
    color: var(--text-muted);
    text-align: right;
}
.visitor-row .device-tag {
    background: var(--bg);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    color: var(--text-muted);
    text-align: center;
}

/* ===== 进度条 ===== */
.bar-row {
    margin-bottom: 12px;
}
.bar-row .bar-label {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    margin-bottom: 4px;
}
.bar-row .bar-label b { font-weight: 600; }
.bar-row .bar-track {
    height: 8px;
    background: var(--bg);
    border-radius: 4px;
    overflow: hidden;
}
.bar-row .bar-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 4px;
    transition: width 0.3s;
}

/* ===== 饼图（用 conic-gradient） ===== */
.pie-chart {
    width: 160px;
    height: 160px;
    border-radius: 50%;
    margin: 0 auto;
    position: relative;
}
.pie-legend {
    margin-top: 16px;
}
.pie-legend .legend-item {
    display: flex;
    align-items: center;
    font-size: 12px;
    margin-bottom: 6px;
}
.pie-legend .dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 8px;
}

/* ===== 按钮 ===== */
button {
    background: var(--primary);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: opacity 0.15s;
}
button:hover { opacity: 0.9; }
button.secondary {
    background: var(--bg);
    color: var(--text);
}

/* ===== 代码框 ===== */
.code-box {
    background: #1e293b;
    color: #e2e8f0;
    padding: 16px;
    border-radius: 8px;
    font-family: "Fira Code", Consolas, monospace;
    font-size: 12px;
    overflow-x: auto;
    margin: 12px 0;
}

/* ===== 登录页 ===== */
.center-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-box {
    background: white;
    padding: 40px;
    border-radius: 16px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.login-box h1 {
    font-size: 24px;
    margin-bottom: 8px;
}
.login-box h1 small {
    font-size: 12px;
    color: var(--primary);
    font-weight: 400;
}
.login-box h2 {
    font-size: 14px;
    color: var(--text-muted);
    font-weight: 400;
    margin-bottom: 24px;
}

.login-box label {
    display: block;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.login-box input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 16px;
    outline: none;
    transition: border-color 0.15s;
}
.login-box input:focus { border-color: var(--primary); }

.login-box button {
    width: 100%;
    padding: 12px;
    font-size: 15px;
    margin-top: 8px;
}

.error {
    background: #fef2f2;
    color: var(--red);
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 16px;
}

.notice {
    background: #ecfdf5;
    color: var(--green);
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 16px;
}

.muted {
    color: var(--text-muted);
    font-size: 13px;
}

/* ===== 网站行 ===== */
.site-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
}
.site-row code {
    background: var(--bg);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    color: var(--primary);
}

/* ===== 时间维度切换 ===== */
.dim-tabs {
    display: flex;
    gap: 4px;
    background: var(--bg);
    padding: 3px;
    border-radius: 8px;
}
.dim-tabs button {
    background: transparent;
    color: var(--text-muted);
    padding: 5px 14px;
    font-size: 12px;
    border-radius: 6px;
}
.dim-tabs button.active {
    background: white;
    color: var(--primary);
    box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}

/* ===== 空状态 ===== */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}
