/* ============================================================
   站点访问数据后台 —— 全局样式
   深色大屏风格 · 自适应手机 / 平板 / 桌面
   ============================================================ */

:root {
    --bg: #070d1a;
    --bg2: #0b1424;
    --card: #101b30;
    --card2: #0c1626;
    --border: rgba(148, 163, 184, 0.14);
    --border-strong: rgba(148, 163, 184, 0.28);
    --text: #e6edf7;
    --muted: #8aa0bd;
    --accent: #22d3ee;
    --accent2: #6366f1;
    --green: #34d399;
    --red: #fb7185;
    --orange: #fbbf24;
    --violet: #a78bfa;
    --radius: 14px;
    --shadow: 0 8px 28px rgba(2, 8, 23, 0.55);
}

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

html { -webkit-text-size-adjust: 100%; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei",
                 "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background:
        radial-gradient(1200px 500px at 15% -10%, rgba(34, 211, 238, 0.10), transparent 60%),
        radial-gradient(1000px 500px at 90% 0%, rgba(99, 102, 241, 0.12), transparent 60%),
        var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.55;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a { color: var(--accent); text-decoration: none; }
a:hover { filter: brightness(1.15); }

/* ===================== 顶部导航 ===================== */
.topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(7, 13, 26, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
}
.topbar-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 16px;
    height: 56px;
    display: flex;
    align-items: center;
    gap: 18px;
}
.brand {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
    background: linear-gradient(90deg, #67e8f9, #a5b4fc);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
.nav {
    display: flex;
    gap: 4px;
    flex: 1;
    overflow-x: auto;
    scrollbar-width: none;
}
.nav::-webkit-scrollbar { display: none; }
.nav a {
    color: var(--muted);
    padding: 7px 14px;
    border-radius: 10px;
    white-space: nowrap;
    font-size: 14px;
    transition: all .18s;
}
.nav a:hover { color: var(--text); background: rgba(148, 163, 184, 0.10); }
.nav a.active {
    color: #fff;
    background: linear-gradient(135deg, rgba(34, 211, 238, 0.22), rgba(99, 102, 241, 0.22));
    box-shadow: inset 0 0 0 1px rgba(34, 211, 238, 0.35);
}
.topbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--muted);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}
.topbar-right .sep { opacity: .4; }
.logout { color: var(--muted); }
.logout:hover { color: var(--red); }

/* ===================== 主体 ===================== */
.app {
    flex: 1;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px 16px 40px;
}
.footer {
    text-align: center;
    color: #55627a;
    font-size: 12px;
    padding: 18px 12px 26px;
}

.loading {
    text-align: center;
    padding: 80px 0;
    color: var(--muted);
}
.spinner {
    width: 34px; height: 34px;
    margin: 0 auto 14px;
    border: 3px solid rgba(34, 211, 238, 0.2);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===================== 页面标题 / 工具条 ===================== */
.page-head {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 16px;
}
.page-head h2 { font-size: 19px; font-weight: 700; }
.page-head .sub { color: var(--muted); font-size: 12px; }
.page-head .spacer { flex: 1; }

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-bottom: 16px;
}

/* 分段按钮组（周期切换 / 平台切换） */
.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; background: var(--card2); border: 1px solid var(--border); border-radius: 12px; padding: 4px; }
.seg button {
    border: 0;
    background: transparent;
    color: var(--muted);
    padding: 6px 13px;
    border-radius: 9px;
    cursor: pointer;
    font-size: 13px;
    white-space: nowrap;
    transition: all .15s;
}
.seg button:hover { color: var(--text); }
.seg button.active {
    background: linear-gradient(135deg, #22d3ee, #6366f1);
    color: #fff;
    font-weight: 600;
}

/* ===================== 卡片 ===================== */
.card {
    background: linear-gradient(180deg, var(--card), var(--card2));
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
}
.card h3 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.card h3 .badge { margin-left: 2px; }
.card .card-sub { color: var(--muted); font-size: 12px; font-weight: 400; margin-left: auto; }

/* 网格布局 */
.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-2-1 { grid-template-columns: 2fr 1fr; }
.grid-1-2 { grid-template-columns: 1fr 2fr; }
.grid-full { grid-template-columns: 1fr; }

/* ===================== 统计数字卡 ===================== */
.stat-card {
    position: relative;
    overflow: hidden;
    padding: 16px 18px;
}
.stat-card::after {
    content: "";
    position: absolute;
    right: -30px; top: -30px;
    width: 110px; height: 110px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(34, 211, 238, 0.14), transparent 70%);
    pointer-events: none;
}
.stat-card .label { color: var(--muted); font-size: 12.5px; margin-bottom: 6px; }
.stat-card .num {
    font-size: 30px;
    font-weight: 800;
    line-height: 1.15;
    font-variant-numeric: tabular-nums;
    background: linear-gradient(90deg, #e0f2fe, #67e8f9);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
.stat-card .extra { color: var(--muted); font-size: 12px; margin-top: 6px; }
.stat-card.iphone .num { background: linear-gradient(90deg, #fecdd3, #fda4af); -webkit-background-clip: text; background-clip: text; }
.stat-card.green .num { background: linear-gradient(90deg, #d1fae5, #6ee7b7); -webkit-background-clip: text; background-clip: text; }
.stat-card.violet .num { background: linear-gradient(90deg, #ede9fe, #c4b5fd); -webkit-background-clip: text; background-clip: text; }
.stat-card.orange .num { background: linear-gradient(90deg, #fef3c7, #fcd34d); -webkit-background-clip: text; background-clip: text; }

/* ===================== 图表 ===================== */
.chart { width: 100%; height: 280px; }
.chart-sm { height: 220px; }
.chart-lg { height: 340px; }

/* ===================== 表格 ===================== */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
table.data th {
    text-align: left;
    color: var(--muted);
    font-weight: 600;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border-strong);
    white-space: nowrap;
    position: sticky;
    top: 0;
    background: var(--card);
}
table.data td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
    word-break: break-all;
}
table.data tr:hover td { background: rgba(34, 211, 238, 0.045); }
.num-cell { font-variant-numeric: tabular-nums; text-align: right; }

/* 徽标 */
.badge {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 999px;
    font-size: 11.5px;
    line-height: 1.7;
    border: 1px solid var(--border-strong);
    color: var(--muted);
    white-space: nowrap;
}
.badge.ios     { color: #f9a8d4; border-color: rgba(249, 168, 212, .4); background: rgba(249, 168, 212, .08); }
.badge.android { color: #86efac; border-color: rgba(134, 239, 172, .4); background: rgba(134, 239, 172, .08); }
.badge.windows { color: #93c5fd; border-color: rgba(147, 197, 253, .4); background: rgba(147, 197, 253, .08); }
.badge.macos   { color: #c4b5fd; border-color: rgba(196, 181, 253, .4); background: rgba(196, 181, 253, .08); }
.badge.linux   { color: #fcd34d; border-color: rgba(252, 211, 77, .4); background: rgba(252, 211, 77, .08); }
.badge.bot     { color: #94a3b8; border-color: rgba(148, 163, 184, .4); background: rgba(148, 163, 184, .08); }
.badge.iphone  { color: #fda4af; border-color: rgba(253, 164, 175, .45); background: rgba(253, 164, 175, .10); }

.status-code { font-weight: 700; font-variant-numeric: tabular-nums; }
.st-2 { color: var(--green); }
.st-3 { color: var(--orange); }
.st-4 { color: var(--red); }
.st-5 { color: #f87171; }

/* 进度条 */
.pbar { height: 6px; background: rgba(148, 163, 184, .15); border-radius: 999px; overflow: hidden; min-width: 60px; }
.pbar i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--accent), var(--accent2)); }

/* ===================== 移动端卡片列表（替代表格） ===================== */
.mobile-list { display: none; flex-direction: column; gap: 10px; }
.m-item {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px;
}
.m-item .m-row { display: flex; gap: 8px; font-size: 12.5px; padding: 2.5px 0; }
.m-item .m-row .k { color: var(--muted); min-width: 62px; flex-shrink: 0; }
.m-item .m-row .v { word-break: break-all; flex: 1; }

/* ===================== 表单 ===================== */
.field { margin-bottom: 12px; }
.field label { display: block; color: var(--muted); font-size: 12.5px; margin-bottom: 5px; }
input[type=text], input[type=password], input[type=date], input[type=datetime-local], input[type=number], select {
    width: 100%;
    background: rgba(7, 13, 26, 0.6);
    border: 1px solid var(--border-strong);
    color: var(--text);
    border-radius: 10px;
    padding: 9px 12px;
    font-size: 14px;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
    -webkit-appearance: none;
    appearance: none;
}
input:focus, select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.15);
}
input::placeholder { color: #55627a; }
select {
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238aa0bd' stroke-width='2' fill='none'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 30px;
}
input[type=date]::-webkit-calendar-picker-indicator { filter: invert(0.7); }

.filter-form {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    align-items: end;
}
.filter-form .f-actions { display: flex; gap: 8px; grid-column: span 4; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: 1px solid var(--border-strong);
    background: rgba(148, 163, 184, 0.08);
    color: var(--text);
    border-radius: 10px;
    padding: 9px 16px;
    font-size: 13.5px;
    cursor: pointer;
    transition: all .15s;
    white-space: nowrap;
}
.btn:hover { border-color: var(--accent); color: #fff; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary {
    background: linear-gradient(135deg, #22d3ee, #6366f1);
    border: 0;
    color: #fff;
    font-weight: 600;
}
.btn-primary:hover { filter: brightness(1.12); color: #fff; }
.btn-danger { color: var(--red); border-color: rgba(251, 113, 133, .4); }
.btn-sm { padding: 6px 12px; font-size: 12.5px; border-radius: 8px; }
.btn-block { width: 100%; }

/* 分页 */
.pager { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.pager .info { color: var(--muted); font-size: 12.5px; margin-right: auto; }

/* ===================== 提示 / Toast ===================== */
.toast-wrap { position: fixed; top: 68px; right: 16px; z-index: 999; display: flex; flex-direction: column; gap: 8px; max-width: min(340px, 90vw); }
.toast {
    background: var(--card);
    border: 1px solid var(--border-strong);
    border-left: 3px solid var(--accent);
    border-radius: 10px;
    padding: 11px 14px;
    font-size: 13px;
    box-shadow: var(--shadow);
    animation: toastIn .25s ease;
}
.toast.ok    { border-left-color: var(--green); }
.toast.error { border-left-color: var(--red); }
@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }

.error-box {
    background: rgba(251, 113, 133, 0.10);
    border: 1px solid rgba(251, 113, 133, 0.35);
    color: #fda4af;
    border-radius: 10px;
    padding: 12px 14px;
    margin-bottom: 14px;
    font-size: 13px;
}
.empty { text-align: center; color: var(--muted); padding: 36px 0; font-size: 13px; }

/* 最近访问列表 */
.recent-list { display: flex; flex-direction: column; }
.recent-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 4px;
    border-bottom: 1px dashed var(--border);
    font-size: 12.5px;
}
.recent-item:last-child { border-bottom: 0; }
.recent-item .r-time { color: var(--muted); font-variant-numeric: tabular-nums; flex-shrink: 0; }
.recent-item .r-ip { color: #93c5fd; flex-shrink: 0; }
.recent-item .r-path { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.recent-item .r-badge { flex-shrink: 0; }

/* ===================== 登录页 ===================== */
.login-body { display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.login-wrap { width: 100%; max-width: 400px; }
.login-card {
    background: linear-gradient(180deg, var(--card), var(--card2));
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 36px 30px 28px;
    box-shadow: var(--shadow);
}
.login-logo { text-align: center; font-size: 46px; margin-bottom: 8px; }
.login-title { text-align: center; font-size: 20px; font-weight: 700; }
.login-sub { text-align: center; color: var(--muted); font-size: 13px; margin: 6px 0 26px; }
.login-error {
    background: rgba(251, 113, 133, 0.10);
    border: 1px solid rgba(251, 113, 133, 0.35);
    color: #fda4af;
    border-radius: 9px;
    padding: 9px 12px;
    font-size: 13px;
    margin-bottom: 12px;
}
.login-foot { text-align: center; color: #55627a; font-size: 11.5px; margin-top: 18px; }

/* ===================== 响应式 ===================== */
@media (max-width: 1100px) {
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
    .grid-3 { grid-template-columns: repeat(2, 1fr); }
    .filter-form { grid-template-columns: repeat(2, 1fr); }
    .filter-form .f-actions { grid-column: span 2; }
}

@media (max-width: 820px) {
    .grid-2, .grid-2-1, .grid-1-2 { grid-template-columns: 1fr; }
    .topbar-inner { height: auto; flex-wrap: wrap; padding: 8px 12px; gap: 8px; }
    .nav { order: 3; width: 100%; padding-bottom: 2px; }
    .chart { height: 240px; }
    .app { padding: 14px 10px 32px; }
}

@media (max-width: 640px) {
    .grid-4, .grid-3 { grid-template-columns: 1fr; }
    .stat-card .num { font-size: 26px; }
    .filter-form { grid-template-columns: 1fr; }
    .filter-form .f-actions { grid-column: span 1; }
    .page-head h2 { font-size: 17px; }
    .chart { height: 220px; }
    .chart-lg { height: 260px; }
    /* 表格 → 卡片列表 */
    .table-desktop { display: none; }
    .mobile-list { display: flex; }
    .card { padding: 13px; }
    .seg button { padding: 6px 10px; font-size: 12.5px; }
    .pager { justify-content: center; }
}

@media (min-width: 641px) {
    .mobile-list { display: none; }
}

/* 大屏全屏模式 */
#app:fullscreen {
    max-width: 100%;
    padding: 24px 28px;
}
#app:fullscreen .stat-card .num { font-size: 38px; }

/* 打印 / 减少动画 */
@media (prefers-reduced-motion: reduce) {
    * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
