/* 统计豹 (tjb) 样式 - 移动端优先（Mobile First），向上增强 */
:root {
    --primary: #4f7cff;
    --primary-dark: #3a63d8;
    --bg: #f4f6fb;
    --card: #ffffff;
    --text: #1f2733;
    --muted: #8a94a6;
    --border: #e4e8f0;
    --green: #22b07d;
    --radius: 12px;
    --shadow: 0 2px 10px rgba(31, 39, 51, .06);
    --topbar-h: 54px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
    font-family: -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.6;
    -webkit-tap-highlight-color: transparent;
}

a { color: var(--primary); }

.wrap { max-width: 1400px; margin: 0 auto; padding: 0 14px; width: 100%; }
.wrap-narrow { max-width: 500px; }
.wrap-mid { max-width: 1200px; }

/* 安装向导：按钮放满整行 */
.btn-block { display: block; width: 100%; text-align: center; box-sizing: border-box; }
.install-foot { text-align: center; margin: 18px 0 6px; }
.install-time { color: var(--muted); font-size: 13px; }

.layout { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }

/* ===== 上部：顶栏（手机优先） ===== */
.topbar {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 100;
    padding-top: env(safe-area-inset-top);
}
.topbar-inner {
    position: relative;
    display: flex; align-items: center;
    height: var(--topbar-h);
}
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--text); min-width: 0; }
.brand-logo {
    width: 30px; height: 30px; border-radius: 8px; flex: none;
    background: linear-gradient(135deg, var(--primary), #7aa0ff);
    color: #fff; font-weight: 700; font-size: 15px;
    display: flex; align-items: center; justify-content: center;
}
.brand-text { font-size: 16px; font-weight: 700; white-space: nowrap; }
.brand-text small { color: var(--muted); font-weight: 500; margin-left: 4px; font-size: 11px; }

/* 菜单：单行靠右排列，每项带图标，手机端只显示图标 */
.nav {
    display: flex; flex-direction: row; align-items: center;
    gap: 2px; flex: none;
}
.nav a {
    display: flex; align-items: center; gap: 5px;
    text-decoration: none; color: var(--text);
    padding: 8px 9px; border-radius: 8px;
    font-weight: 500; font-size: 14px; white-space: nowrap;
}
.nav a svg { width: 17px; height: 17px; flex: none; }
.nav a:active { background: rgba(79, 124, 255, .1); }
.nav a.active { color: var(--primary); background: rgba(79, 124, 255, .12); font-weight: 600; }

/* 右侧菜单组靠右；用户徽标为展示项（不可点） */
.nav-right { margin-left: auto; }
.nav .user-chip {
    display: flex; align-items: center; gap: 5px;
    color: var(--muted); font-size: 13px;
    padding: 8px 4px; white-space: nowrap;
}
.nav .user-chip svg { width: 17px; height: 17px; flex: none; }

/* 手机端：隐藏菜单文字，只显示图标 */
.nav-label { display: none; }

/* ===== 中部：主内容（手机优先） ===== */
.main { flex: 1; padding: 16px 14px 36px; }

.page-head {
    display: flex; flex-direction: column; align-items: stretch;
    gap: 12px; margin-bottom: 16px;
}
.page-head h1 { font-size: 19px; }
.page-head p { color: var(--muted); margin-top: 2px; font-size: 13px; }
.page-head > div:last-child { display: flex; gap: 10px; }
.page-head .btn { flex: 1; text-align: center; padding: 10px 12px; }

.cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px; margin-bottom: 16px;
}
.card {
    background: var(--card); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 14px 14px;
}
.card .label { color: var(--muted); font-size: 12px; }
.card .value { font-size: 22px; font-weight: 700; margin-top: 2px; }
.card .value.green { color: var(--green); }
.card .value.blue { color: var(--primary); }

.panel {
    background: var(--card); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 14px 14px; margin-bottom: 16px;
}
.panel h2 { font-size: 15px; margin-bottom: 12px; }
.panel h2 .sub { font-weight: 400; font-size: 12px; color: var(--muted); margin-left: 6px; }

/* 表格：手机端横向滚动，避免挤压 */
.panel { overflow-x: auto; }
.panel table { width: 100%; border-collapse: collapse; min-width: 460px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); font-size: 13px; white-space: nowrap; }
th { color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: none; }
td.mono, .mono { font-family: Consolas, Menlo, monospace; font-size: 12px; }

.empty { text-align: center; color: var(--muted); padding: 28px 0; min-width: 240px; }

.btn {
    display: inline-block; border: none; cursor: pointer;
    background: var(--primary); color: #fff;
    padding: 10px 16px; border-radius: 9px; font-size: 14px; font-weight: 600;
    text-decoration: none; transition: background .15s;
    -webkit-appearance: none; appearance: none;
}
.btn:active { background: var(--primary-dark); }
.btn.ghost { background: #eef1f8; color: var(--text); }
.btn.ghost:active { background: #e2e7f2; }
.btn.small { padding: 6px 10px; font-size: 12px; border-radius: 7px; }
.btn.danger { background: #fdecec; color: #c0392b; }
.btn.danger:active { background: #f9dcdc; }
.row-actions { display: flex; align-items: center; gap: 6px; }
.row-actions form { display: inline; }

.badge {
    display: inline-block; padding: 2px 9px; border-radius: 99px;
    font-size: 11px; font-weight: 600; vertical-align: 1px;
}
.badge.site { background: rgba(79,124,255,.12); color: var(--primary); }
.badge.soft { background: rgba(34,176,125,.12); color: var(--green); }

/* 表单：手机端输入框 16px 防止 iOS 聚焦自动放大 */
form .field { margin-bottom: 14px; }
form label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 14px; }
form input[type=text], form input[type=password], form input[type=url], form input[type=email], form select, textarea {
    width: 100%; padding: 10px 12px; font-size: 16px;
    border: 1px solid var(--border); border-radius: 9px;
    font-family: inherit; background: #fbfcfe;
}
form input:focus, textarea:focus { outline: 2px solid rgba(79,124,255,.35); border-color: var(--primary); }
.hint { color: var(--muted); font-size: 12px; margin-top: 6px; word-break: break-all; }
.form-actions { display: flex; gap: 10px; margin-top: 18px; }
.form-actions .btn { flex: 1; text-align: center; }

.code {
    background: #1f2733; color: #d6e2ff; border-radius: 10px;
    padding: 12px 14px; font-family: Consolas, Menlo, monospace;
    font-size: 12px; overflow-x: auto; line-height: 1.7;
}
.code .k { color: #7aa0ff; }
.code .s { color: #9ece6a; }

.key-box {
    display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px;
    background: #f0f4ff; border: 1px dashed var(--primary);
    border-radius: 10px; padding: 10px 12px; margin: 8px 0;
}
.key-box code { font-size: 13px; font-weight: 700; color: var(--primary-dark); letter-spacing: .5px; word-break: break-all; }

.alert { padding: 11px 14px; border-radius: 10px; margin-bottom: 14px; font-size: 13px; }
.alert.ok { background: rgba(34,176,125,.1); color: #157a56; border: 1px solid rgba(34,176,125,.3); }
.alert.err { background: rgba(245,80,80,.08); color: #c0392b; border: 1px solid rgba(245,80,80,.3); }

.chart-wrap { overflow-x: auto; }
.chart-wrap svg { display: block; min-width: 520px; }

.grid-2 { display: grid; grid-template-columns: 1fr; gap: 16px; }

.service-qr {
    display: block; width: 180px; max-width: 100%;
    border: 1px solid var(--border); border-radius: 12px;
}

/* ===== 下部：页脚 ===== */
.footer {
    background: var(--card); border-top: 1px solid var(--border);
    padding: 14px 0 calc(14px + env(safe-area-inset-bottom));
    color: var(--muted); font-size: 12px;
}
.footer-inner { display: flex; flex-direction: column; gap: 4px; }

/* ===== 平板 ≥640px ===== */
@media (min-width: 640px) {
    .wrap { padding: 0 20px; }

    .topbar-inner { height: 60px; }
    .brand-logo { width: 34px; height: 34px; font-size: 17px; border-radius: 9px; }
    .brand-text { font-size: 17px; }
    .brand-text small { font-size: 12px; }

    .nav { gap: 4px; }
    .nav a { padding: 7px 12px; font-size: 14px; }
    .nav a:hover { color: var(--primary); background: rgba(79, 124, 255, .08); }

    /* 平板及以上：显示菜单文字（图标 + 文字） */
    .nav-label { display: inline; }

    .main { padding: 24px 20px 44px; }

    .page-head { flex-direction: row; align-items: flex-end; justify-content: space-between; }
    .page-head h1 { font-size: 21px; }
    .page-head > div:last-child { flex: none; }
    .page-head .btn { flex: none; }

    .cards { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; }
    .card { padding: 16px 18px; }
    .card .value { font-size: 26px; }

    .panel { padding: 18px 22px; }
    .panel h2 { font-size: 16px; }
    .panel table { min-width: 0; }
    th, td { padding: 10px 12px; font-size: 13.5px; }

    form input[type=text], form input[type=url], form select, textarea { font-size: 14px; }
    .form-actions .btn { flex: none; }

    .grid-2 { grid-template-columns: 1fr 1fr; gap: 20px; }

    .footer { padding: 18px 0; }
    .footer-inner { flex-direction: row; justify-content: space-between; }
}

/* ===== 桌面 ≥960px ===== */
@media (min-width: 960px) {
    .main { padding: 28px 20px 48px; }
    .page-head h1 { font-size: 22px; }
    .card .value { font-size: 28px; }
    .chart-wrap svg { min-width: 0; }
}
