/* ===== Reset / Normalize ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
        "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
    background: #f0f2f5;
    color: #333;
    font-size: 14px;
    line-height: 1.6;
    min-height: 100vh;
}
a { color: #1890ff; text-decoration: none; }
a:hover { color: #096dd9; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }
ul, ol { list-style: none; }

/* ===== Topbar (matches _Layout.cshtml) ===== */
.topbar {
    background: linear-gradient(120deg, var(--brand-1, #001f3d) 0%, var(--brand-2, #0d3a6b) 60%, var(--brand-3, #1252a0) 100%);
    color: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,.15);
    position: sticky;
    top: 0;
    z-index: 100;
}
.topbar-inner {
    max-width: 1400px;
    margin: 0 auto;
    height: 56px;
    display: flex;
    align-items: center;
    padding: 0 20px;
    gap: 16px;
}
.topbar .logo {
    color: #fff;
    font-size: 18px;
    font-weight: 600;
    white-space: nowrap;
    margin-right: 8px;
}
.topbar .logo:hover { color: #e6f2ff; }
/* logo 渐变发光点（方案C 渐变科技风） */
.topbar .nav-dot {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 4px;
    background: linear-gradient(135deg, #1890ff, #40a9ff);
    box-shadow: 0 0 8px rgba(64,169,255,.6);
    margin-right: 8px;
    vertical-align: -2px;
}
.topbar nav {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1;
}
.topbar nav a {
    color: rgba(255,255,255,.85);
    padding: 8px 14px;
    border-radius: 4px;
    transition: background .2s, color .2s;
    white-space: nowrap;
    font-size: 14px;
}
.topbar nav a:hover { color: #fff; background: rgba(255,255,255,.12); }
.topbar nav a.active {
    color: #fff;
    background: none;
    font-weight: 500;
    position: relative;
    text-shadow: 0 0 12px rgba(64,169,255,.9);
}
/* 选中项底部发光下划线（方案C） */
.topbar nav a.active::after {
    content: "";
    position: absolute;
    left: 14px;
    right: 14px;
    bottom: -10px;
    height: 3px;
    border-radius: 2px;
    background: #40a9ff;
    box-shadow: 0 0 10px rgba(64,169,255,.9);
}
.topbar .user {
    display: flex;
    align-items: center;
    gap: 12px;
    white-space: nowrap;
    color: rgba(255,255,255,.9);
    font-size: 13px;
}
.topbar .user-name { color: rgba(255,255,255,.95); }
.topbar .btn-logout {
    color: rgba(255,255,255,.85);
    padding: 4px 10px;
    border: 1px solid rgba(255,255,255,.3);
    border-radius: 4px;
    transition: all .2s;
}
.topbar .btn-logout:hover { color: #fff; border-color: #fff; background: rgba(255,255,255,.1); }
/* 顶栏返回按钮：仅手机端显示（PC 有完整导航） */
.topbar .btn-back { display: none; }

/* Hamburger toggle (mobile only, hidden on desktop) */
.nav-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 40px;
    height: 40px;
    padding: 8px;
    background: transparent;
    border: 1px solid rgba(255,255,255,.3);
    border-radius: 4px;
    cursor: pointer;
    margin-left: auto;
}
.nav-toggle-bar {
    display: block;
    height: 2px;
    width: 100%;
    background: #fff;
    border-radius: 1px;
    transition: transform .25s, opacity .25s;
}
.nav-toggle-active .nav-toggle-bar:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle-active .nav-toggle-bar:nth-child(2) { opacity: 0; }
.nav-toggle-active .nav-toggle-bar:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Role badge */
.role-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 500;
}

/* ===== Container & Footer ===== */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}
.footer {
    text-align: center;
    color: #8c8c8c;
    font-size: 12px;
    padding: 24px 20px;
    margin-top: 20px;
}

/* ===== Cards ===== */
.card {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,.08);
    padding: 20px;
    margin-bottom: 20px;
}
.card-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid #f0f0f0;
}

/* ===== Page header ===== */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 12px;
}
.page-header h2 { font-size: 20px; font-weight: 600; }

/* ===== Stat cards ===== */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}
.stat-card {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,.08);
    padding: 24px 20px;
    text-align: center;
    transition: transform .15s, box-shadow .15s;
    border-top: 3px solid #1890ff;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,.12); }
.stat-num { font-size: 28px; font-weight: 700; color: #1890ff; margin-bottom: 8px; }
.stat-label { font-size: 13px; color: #8c8c8c; }

/* ===== Tables (used as .tab in spec but views use .data-table) ===== */
.tab,
.data-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 8px;
}
.tab th, .tab td,
.data-table th, .data-table td {
    padding: 10px 12px;
    border: 1px solid #e0e0e0;
    text-align: left;
    vertical-align: middle;
    font-size: 14px;
    white-space: nowrap;
}
/* 备注等长文本列：允许换行 */
.data-table td.cell-wrap,
.tab td.cell-wrap {
    white-space: normal;
    word-break: break-word;
    min-width: 100px;
}
.tab th,
.data-table th {
    background: #fafafa;
    font-weight: 600;
    white-space: nowrap;
    color: #595959;
}
.tab tbody tr:nth-child(even),
.data-table tbody tr:nth-child(even) { background: #fafafa; }
.tab tbody tr:hover,
.data-table tbody tr:hover { background: #f0f7ff; }
.tab .empty-row,
.data-table .empty-row { text-align: center; color: #999; padding: 24px; }
.mono { font-family: "Consolas", "Courier New", monospace; white-space: nowrap; }
.text-muted { color: #999; font-size: 12px; }

.table-summary { color: #666; font-size: 13px; margin-bottom: 8px; }
.info-table th { width: 140px; }

/* ===== Action cell ===== */
.action-cell { white-space: nowrap; display: flex; gap: 6px; flex-wrap: nowrap; }

/* ===== Wide table horizontal scroll wrapper ===== */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ===== Forms ===== */
.form-stack { max-width: 520px; }
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: #333;
}
.form-control {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #d9d9d9;
    border-radius: 4px;
    background: #fff;
    color: #333;
    transition: border-color .2s, box-shadow .2s;
}
.form-control:focus {
    border-color: #1890ff;
    box-shadow: 0 0 0 2px rgba(24,144,255,.2);
    outline: none;
}
.form-control[readonly] { background: #f5f5f5; color: #666; }
.form-control-sm {
    padding: 5px 8px;
    border: 1px solid #d9d9d9;
    border-radius: 4px;
    width: 100%;
    max-width: 140px;
}
textarea.form-control { resize: vertical; }

.form-actions { display: flex; gap: 10px; margin-top: 20px; }

/* Inline / filter / search forms */
.filter-form, .search-form, .cardtype-add-form {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    flex-wrap: wrap;
}
.filter-form .form-group, .cardtype-add-form .form-group {
    margin-bottom: 0;
}
.search-form .form-control { flex: 1; max-width: 420px; }
.filter-form .form-control { min-width: 130px; }

.checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: normal;
    cursor: pointer;
}

/* ===== Buttons ===== */
.btn {
    display: inline-block;
    padding: 6px 16px;
    border: 1px solid transparent;
    border-radius: 4px;
    background: #fff;
    color: #333;
    cursor: pointer;
    font-size: 14px;
    line-height: 1.5;
    transition: all .2s;
    text-align: center;
    white-space: nowrap;
    text-decoration: none;
}
.btn:hover { opacity: .85; }
.btn-primary { background: #1890ff; border-color: #1890ff; color: #fff; }
.btn-primary:hover { background: #40a9ff; border-color: #40a9ff; opacity: 1; }
.btn-danger { background: #ff4d4f; border-color: #ff4d4f; color: #fff; }
.btn-danger:hover { background: #ff7875; border-color: #ff7875; opacity: 1; }
.btn-success { background: #52c41a; border-color: #52c41a; color: #fff; }
.btn-success:hover { background: #73d13d; border-color: #73d13d; opacity: 1; }
.btn-warning { background: #faad14; border-color: #faad14; color: #fff; }
.btn-warning:hover { background: #ffc53d; border-color: #ffc53d; opacity: 1; }
.btn-default { background: #fff; border-color: #d9d9d9; color: #333; }
.btn-default:hover { background: #f5f5f5; color: #333; opacity: 1; }
.btn-block { width: 100%; }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* ===== Status badges ===== */
.status-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    line-height: 1.5;
    font-weight: 500;
}
.status-active { background: #f6ffed; color: #52c41a; border: 1px solid #b7eb8f; }
.status-expired { background: #fff1f0; color: #ff4d4f; border: 1px solid #ffa39e; }
.status-expiring { background: #fffbe6; color: #faad14; border: 1px solid #ffe58f; }
.status-disabled { background: #fff1f0; color: #ff4d4f; border: 1px solid #ffa39e; }

/* ===== APP 账号版本 ===== */
.ver-badge {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 10px;
    font-size: 12px;
    line-height: 1.7;
    font-weight: 600;
    white-space: nowrap;
}
.ver-normal { background: #eef1f5; color: #6b7683; border: 1px solid #d8dee6; }
.ver-premium { background: #fff4e0; color: #b3701a; border: 1px solid #f5d59a; }

/* ===== Custom confirm modal ===== */
.confirm-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,.45);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.confirm-overlay.active { display: flex; }
.confirm-dialog {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,.18);
    max-width: 400px;
    width: 100%;
    overflow: hidden;
    animation: confirmPop .2s ease-out;
}
@keyframes confirmPop {
    from { transform: scale(.92); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}
.confirm-dialog .confirm-body {
    padding: 24px 24px 16px;
    white-space: pre-line;
    font-size: 15px;
    line-height: 1.7;
    color: #333;
}
.confirm-dialog .confirm-actions {
    display: flex;
    gap: 12px;
    padding: 0 24px 20px;
    justify-content: flex-end;
}
.confirm-dialog .confirm-btn {
    padding: 10px 24px;
    border-radius: 8px;
    border: none;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    min-height: 44px;
    transition: all .15s;
}
.confirm-dialog .confirm-cancel {
    background: #f5f5f5;
    color: #666;
}
.confirm-dialog .confirm-cancel:hover { background: #e8e8e8; }
.confirm-dialog .confirm-ok {
    background: #1890ff;
    color: #fff;
}
.confirm-dialog .confirm-ok:hover { background: #096dd9; }

/* ===== Alerts ===== */
.alert {
    padding: 10px 16px;
    border-radius: 4px;
    margin-bottom: 16px;
    border: 1px solid transparent;
    line-height: 1.6;
}
.alert-success { background: #f6ffed; color: #389e0d; border-color: #b7eb8f; }
.alert-error { background: #fff1f0; color: #cf1322; border-color: #ffa39e; }
.alert-info { background: #e6f7ff; color: #096dd9; border-color: #91d5ff; }
.alert-warning { background: #fffbe6; color: #ad6800; border-color: #ffe58f; }

/* ===== Pagination ===== */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    margin-top: 20px;
    flex-wrap: wrap;
}
.page-link {
    padding: 6px 12px;
    border: 1px solid #d9d9d9;
    border-radius: 4px;
    background: #fff;
    color: #333;
    cursor: pointer;
    transition: all .2s;
    text-decoration: none;
}
.page-link:hover { border-color: #1890ff; color: #1890ff; }
.page-link.disabled,
.page-link.disabled:hover { color: #ccc; cursor: not-allowed; background: #f5f5f5; border-color: #d9d9d9; pointer-events: none; }
.page-current {
    padding: 6px 12px;
    background: #1890ff;
    color: #fff;
    border-radius: 4px;
    border: 1px solid #1890ff;
}

/* ===== Quick links ===== */
.quick-links { display: flex; gap: 10px; flex-wrap: wrap; }

/* ===== Card type grid ===== */
.cardtype-grid { width: 100%; }
.cardtype-row {
    display: grid;
    grid-template-columns: 50px 1.2fr 0.8fr 1fr 70px 70px 1fr 70px 1.4fr 110px;
    gap: 8px;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #f0f0f0;
}
.cardtype-header {
    font-weight: 600;
    color: #595959;
    background: #fafafa;
    padding: 10px 8px;
    border-bottom: 1px solid #e0e0e0;
    border-radius: 4px 4px 0 0;
}
.cardtype-header > div { padding: 2px; }
.cardtype-row > div { padding: 0 2px; }
.cardtype-empty { text-align: center; color: #999; padding: 24px; }
.cardtype-row .action-cell { justify-content: flex-end; }

/* ===== Login ===== */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #001529 0%, #003a70 100%);
    padding: 20px;
}
.login-card {
    width: 360px;
    max-width: 100%;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,.25);
    padding: 40px 32px;
}
.login-title {
    text-align: center;
    font-size: 22px;
    font-weight: 600;
    margin-bottom: 24px;
    color: #001529;
}
.login-form .form-group { margin-bottom: 16px; }
.login-form .form-control { padding: 10px 12px; }
.login-form .btn { padding: 10px 16px; font-size: 16px; }

/* ===== Responsive ===== */

/* ---- Tablet (iPad portrait & landscape, 768px-1024px) ---- */
@media (max-width: 1024px) {
    .topbar-inner { max-width: 100%; padding: 0 16px; gap: 10px; }
    .topbar nav a { padding: 6px 10px; font-size: 13px; }
    .container { padding: 16px; }
    .card { padding: 16px; }
    .stat-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
    .stat-card { padding: 18px 14px; }
    .stat-num { font-size: 24px; }
    .login-card { width: 340px; padding: 32px 24px; }
    .cardtype-row {
        grid-template-columns: 50px 1fr 0.8fr 1fr 70px 70px 1fr 70px 1fr 100px;
    }
}

/* ---- Mobile (phones & small tablets, ≤768px) ---- */
@media (max-width: 768px) {
    /* Topbar: hamburger menu */
    .nav-toggle { display: flex; }
    .topbar-inner { flex-wrap: wrap; height: auto; min-height: 48px; padding: 8px 12px; gap: 8px; }
    .topbar .logo { font-size: 16px; margin-right: 4px; }
    #mainNav {
        display: none;
        order: 3;
        width: 100%;
        flex-direction: column;
        gap: 0;
        background: #001f3d;
        border-radius: 6px;
        margin-top: 4px;
        padding: 4px 0;
    }
    #mainNav.nav-open { display: flex; }
    #mainNav a {
        padding: 12px 16px;
        font-size: 15px;
        border-radius: 0;
        border-bottom: 1px solid rgba(255,255,255,.08);
    }
    #mainNav a:last-child { border-bottom: none; }
    #mainNav a:hover, #mainNav a.active { background: #1890ff; }

    .topbar .user {
        order: 2;
        margin-left: auto;
        gap: 8px;
        font-size: 12px;
    }
    .topbar .user-name { font-size: 12px; max-width: 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .role-badge { font-size: 11px; padding: 1px 6px; }

    /* Container */
    .container { padding: 10px; }

    /* Cards */
    .card { padding: 12px; margin-bottom: 12px; border-radius: 6px; }
    .card-title { font-size: 15px; margin-bottom: 12px; padding-bottom: 8px; }

    /* Page header */
    .page-header { margin-bottom: 12px; gap: 8px; }
    .page-header h2 { font-size: 18px; }

    /* Stat grid: 2 columns on phones */
    .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 12px; }
    .stat-card { padding: 14px 10px; border-radius: 6px; }
    .stat-num { font-size: 20px; }
    .stat-label { font-size: 12px; }

    /* Tables: compact for mobile, card mode (no horizontal scroll) */
    .table-scroll { overflow-x: hidden; }
    .table-scroll .data-table thead,
    .table-scroll .tab thead { display: none; }
    .table-scroll .data-table tbody tr,
    .table-scroll .tab tbody tr {
        display: block;
        margin-bottom: 10px;
        border: 1px solid #e0e0e0;
        border-radius: 6px;
        background: #fff;
        padding: 4px 0;
    }
    .table-scroll .data-table tbody tr:nth-child(even),
    .table-scroll .tab tbody tr:nth-child(even) { background: #fff; }
    .table-scroll .data-table tbody tr:hover,
    .table-scroll .tab tbody tr:hover { background: #fff; }
    .table-scroll .data-table tbody tr td,
    .table-scroll .tab tbody tr td {
        display: flex;
        flex-wrap: wrap;
        align-items: baseline;
        gap: 4px 8px;
        border: none;
        border-bottom: 1px solid #f0f0f0;
        padding: 5px 10px;
        white-space: normal;
        word-break: break-word;
        font-size: 13px;
    }
    .table-scroll .data-table tbody tr td:last-child,
    .table-scroll .tab tbody tr td:last-child { border-bottom: none; }
    /* 紧凑化：缩小卡片内行距，隐藏次要"序号"列（手机价值低，腾空间） */
    .table-scroll .data-table tbody tr td[data-label="序号"],
    .table-scroll .tab tbody tr td[data-label="序号"] { display: none; }
    /* Quick-renew row: use block instead of flex so panel expands fully */
    .table-scroll .data-table tbody tr.quick-renew-row td {
        display: block;
        padding: 6px 10px 10px;
    }
    .table-scroll .data-table tbody tr td[data-label]::before,
    .table-scroll .tab tbody tr td[data-label]::before {
        content: attr(data-label);
        font-weight: 600;
        color: #595959;
        font-size: 12px;
        flex-shrink: 0;
        min-width: 60px;
    }
    /* Keep info-table (SyncTime etc.) as regular table, not card */
    .table-scroll .info-table tbody tr,
    .info-table tbody tr { display: table-row; }
    .table-scroll .info-table tbody tr td,
    .info-table tbody tr td { display: table-cell; }
    .table-scroll .info-table thead,
    .info-table thead { display: table-header-group; }
    /* Empty row in card mode */
    .table-scroll .data-table .empty-row {
        text-align: center;
        color: #999;
        padding: 16px;
        display: block;
    }
    /* tfoot in card mode */
    .table-scroll .data-table tfoot tr {
        display: block;
        border: 1px solid #d9d9d9;
        border-radius: 6px;
        background: #fafafa;
        padding: 4px 0;
        margin-bottom: 10px;
    }
    .table-scroll .data-table tfoot tr td {
        display: flex;
        flex-wrap: wrap;
        gap: 4px 8px;
        border: none;
        border-bottom: 1px solid #f0f0f0;
        padding: 5px 10px;
        white-space: normal;
        word-break: break-word;
    }
    .table-scroll .data-table tfoot tr td:last-child { border-bottom: none; }
    .table-scroll .data-table tfoot tr td[data-label]::before {
        content: attr(data-label);
        font-weight: 700;
        color: #333;
        font-size: 12px;
        flex-shrink: 0;
        min-width: 60px;
    }
    .mono { font-size: 12px; word-break: break-all; }

    /* Forms: stack vertically, full width */
    .filter-form, .search-form, .cardtype-add-form {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }
    .filter-form .form-group, .cardtype-add-form .form-group { width: 100%; }
    .search-form .form-control, .filter-form .form-control { max-width: none; min-width: 0; width: 100%; }
    .form-control { padding: 10px 12px; font-size: 16px; } /* 16px prevents iOS zoom */
    /* Flex containers: form-control should not force 100% width */
    div[style*="display:flex"] .form-control { width: auto; flex: 1; min-width: 0; }
    /* Buttons inside flex containers: compact to fit on one line */
    div[style*="display:flex"] .btn { font-size: 13px; padding: 8px 10px; min-height: 40px; white-space: nowrap; }
    .form-actions { flex-direction: column; gap: 8px; }
    .form-actions .btn { width: 100%; }

    /* Buttons: larger touch targets on mobile */
    .btn { padding: 10px 18px; font-size: 15px; min-height: 44px; }
    .btn-sm { padding: 8px 12px; font-size: 13px; min-height: 36px; }
    .btn-block { width: 100%; }
    .page-header .btn { width: auto; min-height: 40px; padding: 8px 14px; }

    /* Action cell: wrap buttons */
    .action-cell { flex-wrap: wrap; gap: 4px; }

    /* Pagination: larger touch targets */
    .pagination { gap: 4px; }
    .page-link, .page-current { padding: 8px 12px; font-size: 14px; }

    /* Quick links */
    .quick-links { gap: 8px; }
    .quick-links .btn { flex: 1 1 calc(50% - 8px); min-width: 0; text-align: center; }

    /* Card type grid: 2 columns */
    .cardtype-row {
        grid-template-columns: 1fr 1fr;
        gap: 6px;
        padding: 8px 0;
    }
    .cardtype-header { display: none; }

    /* Login */
    .login-card { width: 100%; max-width: 360px; padding: 28px 20px; border-radius: 6px; }
    .login-title { font-size: 20px; }

    /* Alerts */
    .alert { padding: 10px 12px; font-size: 13px; }

    /* Footer */
    .footer { padding: 16px 12px; font-size: 11px; }

    /* Revenue report (page-specific) */
    .rev-day-nav { gap: 6px; }
    .rev-day-nav .rev-date { font-size: 14px; min-width: 100px; }
    .rev-day-nav .btn { padding: 8px 10px; font-size: 13px; min-height: 36px; }

    /* Info table (SyncTime etc.): auto width on mobile */
    .info-table th { width: auto; min-width: 80px; }

    /* Copy buttons: smaller on mobile to avoid overflow */
    .data-table .auto-copy { padding: 4px 6px; font-size: 11px; }
}

/* ---- Small phones (≤480px, iPhone SE etc.) ---- */
@media (max-width: 480px) {
    .topbar .logo { font-size: 15px; }
    .container { padding: 8px; }
    .card { padding: 10px; }
    .stat-grid { grid-template-columns: 1fr; gap: 8px; }
    .stat-card { padding: 12px 8px; }
    .stat-num { font-size: 18px; }
    .page-header h2 { font-size: 16px; }
    .data-table, .tab { font-size: 12px; }
    .table-scroll .data-table tbody tr td,
    .table-scroll .tab tbody tr td { font-size: 12px; padding: 4px 8px; }
    .btn { padding: 8px 14px; font-size: 14px; min-height: 40px; }
    .btn-sm { padding: 6px 10px; font-size: 12px; min-height: 32px; }
    .topbar .user-name { display: none; }
    .role-badge { display: none; }
    .pagination { gap: 2px; }
    .page-link, .page-current { padding: 6px 10px; font-size: 13px; }
}

/* ---- Landscape phones (481px-768px landscape, taller buttons) ---- */
@media (max-width: 768px) and (orientation: landscape) and (max-height: 500px) {
    #mainNav {
        max-height: 60vh;
        overflow-y: auto;
    }
    .stat-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ---- 底部标签栏（移动端导航，方案B） ---- */
.bottom-tabs { display: none; }
.bt-sheet-overlay { display: none; }

@media (max-width: 768px) {
    /* 底部标签栏替代汉堡菜单：隐藏顶栏汉堡和下拉菜单 */
    .nav-toggle { display: none !important; }
    #mainNav { display: none !important; }

    /* 手机端隐藏顶栏退出按钮（退出入口在「更多」抽屉里） */
    .topbar .btn-logout { display: none; }

    /* 手机端顶栏显示返回按钮 */
    .topbar .btn-back {
        display: inline-block;
        background: none;
        color: rgba(255,255,255,.9);
        padding: 5px 10px;
        border: 1px solid rgba(255,255,255,.35);
        border-radius: 4px;
        font-size: 13px;
        line-height: 1;
        cursor: pointer;
        white-space: nowrap;
    }
    .topbar .btn-back:active { color: #fff; border-color: #fff; background: rgba(255,255,255,.1); }

    /* 内容区留出底部栏高度，避免遮挡 footer/按钮 */
    body { padding-bottom: calc(58px + env(safe-area-inset-bottom, 0px)); }

    .bottom-tabs {
        display: flex;
        position: fixed;
        left: 0; right: 0; bottom: 0;
        height: calc(56px + env(safe-area-inset-bottom, 0px));
        padding-bottom: env(safe-area-inset-bottom, 0px);
        background: #001f3d;
        border-top: 1px solid rgba(255,255,255,.08);
        z-index: 900;
        box-shadow: 0 -2px 8px rgba(0,0,0,.15);
    }
    .bt-item {
        flex: 1;
        position: relative;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        background: none;
        border: none;
        color: rgba(255,255,255,.65);
        text-decoration: none;
        font-size: 11px;
        line-height: 1;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }
    .bt-icon { display: block; font-size: 20px; line-height: 1; }
    .bt-icon svg {
        width: 22px; height: 22px; display: block;
        fill: none; stroke: currentColor; stroke-width: 2;
        stroke-linecap: round; stroke-linejoin: round;
    }
    .bt-cell .bt-icon svg { width: 20px; height: 20px; }
    .bt-text { font-size: 11px; }
    .bt-item.bt-active { color: #40a9ff; }
    /* 选中项顶部蓝色指示条（方案D） */
    .bt-item.bt-active::before {
        content: "";
        position: absolute;
        top: 0; left: 50%;
        transform: translateX(-50%);
        width: 22px; height: 3px;
        border-radius: 0 0 3px 3px;
        background: #1890ff;
    }
    .bt-item:active { color: #fff; }

    /* 「更多」底部抽屉 */
    .bt-sheet-overlay {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,.45);
        opacity: 0;
        pointer-events: none;
        transition: opacity .2s ease;
        z-index: 1000;
    }
    .bt-sheet-overlay.bt-open { opacity: 1; pointer-events: auto; }
    .bt-sheet {
        position: absolute;
        left: 0; right: 0; bottom: 0;
        background: #fff;
        border-radius: 16px 16px 0 0;
        padding: 14px 14px calc(14px + env(safe-area-inset-bottom, 0px));
        transform: translateY(100%);
        transition: transform .25s ease;
    }
    .bt-sheet-overlay.bt-open .bt-sheet { transform: translateY(0); }
    .bt-sheet-title { text-align: center; font-size: 13px; color: #999; margin-bottom: 12px; }
    .bt-sheet-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
    .bt-cell {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 6px;
        padding: 12px 4px;
        background: #f5f7fa;
        border-radius: 10px;
        font-size: 12px;
        color: #333;
        text-decoration: none;
        -webkit-tap-highlight-color: transparent;
    }
    .bt-cell:active { background: #e8e8e8; }
    .bt-cell.bt-cell-active { background: #e6f4ff; color: #1890ff; }
    .bt-sheet-cancel {
        margin-top: 12px;
        width: 100%;
        padding: 12px;
        border: none;
        border-radius: 10px;
        background: #f0f0f0;
        color: #333;
        font-size: 15px;
        cursor: pointer;
    }
}
