/* 聚美康全站手机端适配。此文件必须在主题样式之后加载。 */
.mobile-bottom-nav,
.mobile-admin-home,
.mobile-student-tools,
.mobile-user-list { display: none; }

@media (max-width: 768px) {
    html { width: 100%; overflow-x: hidden; -webkit-text-size-adjust: 100%; }
    body.h-theme { width: 100%; min-width: 0; overflow-x: hidden; padding-left: 0; }

    .h-theme .navbar {
        width: 100%; min-height: 60px; padding: max(9px, env(safe-area-inset-top)) 12px 9px;
        position: sticky; top: 0; z-index: 1000;
    }

    .h-theme .nav-brand { min-width: 0; gap: 9px; }
    .h-theme .brand-copy { min-width: 0; }
    .h-theme .brand-copy strong { max-width: 210px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
    .h-theme .brand-copy small { display: none; }
    .h-theme .nav-toggle {
        display: grid; place-items: center; flex: none; width: 44px; height: 44px; padding: 0;
        border-radius: 12px; color: #fff; background: rgba(255,255,255,.12); font-size: 23px;
    }
    .h-theme .nav-links {
        display: none; position: absolute; top: 100%; left: 0; right: 0; width: 100%;
        padding: 10px 12px 14px; gap: 5px; flex-direction: column; align-items: stretch;
        z-index: 999; max-height: calc(100svh - 60px); overflow-y: auto;
    }
    .h-theme .nav-links.show { display: flex; }
    .h-theme .nav-link,
    .h-theme.admin-portal .nav-links > .nav-settings-icon {
        display: flex; width: 100%; min-height: 46px; padding: 11px 14px;
        align-items: center; border-radius: 10px; font-size: 14px;
    }
    .h-theme.admin-portal .nav-links > .nav-settings-icon svg { width: 19px; height: 19px; margin-right: 7px; }
    .h-theme.admin-portal .nav-links > .nav-settings-icon .settings-label { display: inline; }
    .h-theme.admin-portal .nav-links > .nav-link:last-child { margin-top: 4px; }

    .h-theme .main-content,
    .h-theme.admin-portal .main-content,
    .h-theme.user-portal .main-content {
        width: 100%; max-width: 100%; min-width: 0; margin: 0;
        padding: 16px 10px calc(36px + env(safe-area-inset-bottom));
    }
    .h-theme .main-content::before { display: none; }
    .h-theme .page-header,
    .h-theme .dt-page-header,
    .h-theme .lb-header { margin-bottom: 14px; gap: 10px; }
    .h-theme .page-header { min-height: 0; flex-direction: column; align-items: stretch; }
    .h-theme .page-header h2,
    .h-theme .dt-page-header h2,
    .h-theme .lb-header h1 { font-size: 20px; line-height: 1.35; }

    .h-theme .card,
    .h-theme .stat-card,
    .h-theme .podium-card,
    .h-theme .rest-item { border-radius: 14px; }
    .h-theme .card { margin-bottom: 12px; }
    .h-theme .card-header { min-height: 50px; padding: 12px 14px; }
    .h-theme .card-header h3 { font-size: 15px; }
    .h-theme .card-body { padding: 14px; }

    .h-theme .btn { min-height: 44px; justify-content: center; }
    .h-theme .page-header > .btn { width: 100%; }
    .h-theme .btn-group { width: 100%; }
    .h-theme .btn-group > .btn { flex: 1 1 140px; }
    .h-theme input.form-input,
    .h-theme select.form-select,
    .h-theme textarea.form-input { min-height: 44px; max-width: none !important; font-size: 16px; }
    .h-theme textarea.form-input { min-height: 96px; }
    .h-theme .checkbox-label { align-items: flex-start; line-height: 1.5; }

    .h-theme .table-wrapper,
    .h-theme.admin-portal .table-wrapper,
    .h-theme.admin-portal .exports-page .card-body {
        width: 100%; max-width: 100%; overflow-x: auto !important;
        -webkit-overflow-scrolling: touch; overscroll-behavior-inline: contain;
    }
    .h-theme .ranking-table { min-width: 680px; font-size: 12px; }
    .h-theme.admin-portal .ranking-table { min-width: 760px; }
    .h-theme .ranking-table th,
    .h-theme .ranking-table td,
    .h-theme.admin-portal .ranking-table th,
    .h-theme.admin-portal .ranking-table td { height: auto; padding: 10px 9px; white-space: nowrap; }

    .h-theme .header-controls { width: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
    .h-theme .header-controls > * { width: 100%; min-width: 0; }
    .h-theme .header-controls > .btn { grid-column: 1 / -1; }
    .h-theme .stats-row { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px; margin-bottom: 12px; }
    .h-theme .stat-card { min-width: 0; padding: 13px 8px; }
    .h-theme .stat-value { font-size: 22px; overflow-wrap: anywhere; }
    .h-theme .stat-label { font-size: 11px; }

    .h-theme .podium { grid-template-columns: 1fr; gap: 10px; }
    .h-theme .podium-card { padding: 18px 12px; }
    .h-theme .podium-medal { font-size: 38px; }
    .h-theme .podium-name { font-size: 19px; }
    .h-theme .podium-rate { font-size: 24px; }
    .h-theme .rest-item { grid-template-columns: 32px minmax(0,1fr) auto; gap: 8px; padding: 11px 10px; }
    .h-theme .rest-weight { grid-column: 2 / -1; grid-row: 2; }
    .h-theme .rest-rate { grid-column: 3; grid-row: 1; }

    .h-theme.user-portal .weigh-container { display: grid; grid-template-columns: 1fr; gap: 12px; }
    .h-theme.user-portal .camera-section { padding: 7px; }
    .h-theme.user-portal .camera-wrapper { width: 100%; min-height: 0; aspect-ratio: 4 / 3; }
    .h-theme.user-portal .face-oval { width: min(48vw, 180px); height: min(62vw, 230px); }
    .h-theme.user-portal .camera-status,
    .h-theme.user-portal .liveness-status { max-width: calc(50% - 14px); padding: 5px 8px; line-height: 1.25; }
    .h-theme.user-portal .camera-switch-wrapper { display: grid !important; grid-template-columns: 1fr; gap: 8px !important; }
    .h-theme.user-portal .camera-switch-wrapper > * { width: 100%; max-width: none !important; min-height: 44px; }
    .h-theme.user-portal .scale-control { align-items: stretch; }
    .h-theme.user-portal .scale-control .btn { width: 100%; }
    .h-theme.user-portal .scale-baudrate { width: 100%; justify-content: space-between; }
    .h-theme.user-portal .scale-baudrate .form-select { width: auto; min-width: 120px; }
    .h-theme.user-portal .weight-realtime { font-size: clamp(38px, 15vw, 58px); }
    .h-theme.user-portal .weight-input { min-width: 0; font-size: 24px; }
    .h-theme.user-portal .today-item { gap: 8px; flex-wrap: wrap; }
    .h-theme.user-portal .voice-toggle { min-height: 38px; }

    .h-theme.admin-portal .admin-tabs { width: 100%; display: grid; grid-template-columns: 1fr 1fr; padding-top: 0; }
    .h-theme.admin-portal .admin-tabs .tab { text-align: center; min-width: 0; padding: 12px 8px; }
    .h-theme.admin-portal .settings-container { display: grid; grid-template-columns: minmax(0,1fr); gap: 12px; }
    .h-theme.admin-portal .settings-container > * { min-width: 0; grid-column: auto; }
    .h-theme.admin-portal .settings-container > .btn-group .btn { width: 100%; }
    .h-theme.admin-portal .exports-page .card-body > div[style*="display:flex"] { align-items: stretch !important; }
    .h-theme.admin-portal .exports-page .card-body .btn { width: 100%; min-width: 0 !important; }

    .h-theme .modal { padding: 8px; align-items: flex-end; z-index: 1400; }
    .h-theme .modal-content { width: 100%; max-width: none; max-height: calc(100svh - 16px); border-radius: 18px 18px 10px 10px; }
    .h-theme .modal-header { position: sticky; top: 0; z-index: 3; padding: 14px 16px; background: inherit; }
    .h-theme .modal-body { padding: 15px; }
    .h-theme .modal-footer { position: sticky; bottom: 0; z-index: 3; padding: 12px 15px; background: inherit; flex-wrap: wrap; }
    .h-theme .modal-footer .btn { flex: 1 1 120px; }
    .h-theme .face-enroll-actions { flex-wrap: wrap; }
    .h-theme .face-enroll-actions .btn { flex: 1 1 130px; }
    .h-theme .preview-img { max-width: min(100%, 220px); height: auto; }
    .h-theme .info-table { table-layout: fixed; }
    .h-theme .info-table td:first-child { width: 82px; }
    .h-theme .info-table code { overflow-wrap: anywhere; word-break: break-all; }

    /* 管理端移动首页与固定底栏 */
    .h-theme.admin-portal { padding-bottom: calc(70px + env(safe-area-inset-bottom)); }
    .h-theme.admin-portal .main-content { padding-bottom: 26px; }
    .h-theme.admin-portal .navbar { min-height: 56px; padding-top: max(7px, env(safe-area-inset-top)); padding-bottom: 7px; }
    .h-theme.admin-portal .brand-copy strong { font-size: 15px; }
    .h-theme.admin-portal .nav-toggle { width: 40px; height: 40px; }
    .h-theme.admin-portal .nav-links {
        top: 100%; padding: 8px 10px 14px; border-radius: 0 0 18px 18px;
        box-shadow: 0 18px 35px rgba(3,25,21,.28);
    }

    .mobile-bottom-nav {
        position: fixed; z-index: 1100; left: 8px; right: 8px; bottom: max(7px, env(safe-area-inset-bottom));
        height: 64px; display: grid; grid-template-columns: repeat(5, minmax(0,1fr));
        padding: 6px 5px; border: 1px solid rgba(205,180,112,.25); border-radius: 18px;
        background: rgba(16,47,41,.97); box-shadow: 0 10px 30px rgba(2,20,17,.32);
        backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
    }
    .mobile-bottom-item {
        appearance: none; border: 0; background: transparent; color: rgba(255,255,255,.66);
        display: flex; min-width: 0; align-items: center; justify-content: center; flex-direction: column;
        gap: 2px; padding: 3px 1px; border-radius: 12px; font: inherit; font-size: 10px; text-decoration: none;
    }
    .mobile-bottom-item.active { color: #f4d98f; background: rgba(255,255,255,.08); }
    .mobile-bottom-item:active { transform: scale(.96); }
    .mobile-bottom-icon { height: 25px; display: grid; place-items: center; font-size: 21px; line-height: 1; font-weight: 700; }

    .mobile-admin-home { display: block; margin: -2px 0 20px; }
    .mobile-home-welcome {
        position: relative; overflow: hidden; display: flex; align-items: flex-start; justify-content: space-between;
        min-height: 142px; padding: 22px 20px; border-radius: 20px; color: #fff;
        background: linear-gradient(135deg, #123f35 0%, #1e6654 70%, #b99a55 150%);
        box-shadow: 0 14px 28px rgba(10,53,44,.2);
    }
    .mobile-home-welcome::after {
        content: ''; position: absolute; right: -50px; bottom: -72px; width: 180px; height: 180px;
        border: 1px solid rgba(245,220,153,.24); border-radius: 50%; box-shadow: 0 0 0 30px rgba(255,255,255,.025);
    }
    .mobile-home-date { margin: 0 0 8px; color: #f2d88e; font-size: 12px; letter-spacing: .06em; }
    .mobile-home-welcome h1 { position: relative; z-index: 1; margin: 0; font-size: 24px; line-height: 1.25; }
    .mobile-home-welcome h1 + p { position: relative; z-index: 1; margin: 8px 0 0; color: rgba(255,255,255,.72); font-size: 12px; }
    .mobile-home-refresh {
        position: relative; z-index: 2; display: grid; place-items: center; width: 38px; height: 38px;
        border: 1px solid rgba(255,255,255,.18); border-radius: 12px; color: #f6dda0;
        background: rgba(255,255,255,.08); text-decoration: none; font-size: 22px;
    }

    .mobile-stat-grid { position: relative; z-index: 3; display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin: -33px 10px 0; }
    .mobile-stat-card {
        min-width: 0; min-height: 106px; padding: 14px; border: 1px solid rgba(21,80,66,.09); border-radius: 16px;
        color: #173b33; background: #fff; box-shadow: 0 9px 22px rgba(10,48,41,.1); text-decoration: none;
    }
    .mobile-stat-card::before { content: ''; display: block; width: 28px; height: 3px; margin-bottom: 9px; border-radius: 3px; background: var(--stat-color); }
    .mobile-stat-card .mobile-stat-label { display: block; color: #61756f; font-size: 11px; }
    .mobile-stat-card strong { display: block; margin: 2px 0 1px; color: #173b33; font-size: 27px; line-height: 1.15; }
    .mobile-stat-card small { color: #91a09c; font-size: 10px; }
    .mobile-stat-green { --stat-color: #2f8b70; }
    .mobile-stat-blue { --stat-color: #4a81a4; }
    .mobile-stat-gold { --stat-color: #d4a63f; }
    .mobile-stat-rose { --stat-color: #c86a70; }

    .mobile-home-section { margin-top: 22px; }
    .mobile-section-heading { display: flex; align-items: baseline; justify-content: space-between; margin: 0 4px 10px; }
    .mobile-section-heading h2 { margin: 0; color: #173b33; font-size: 17px; }
    .mobile-section-heading span { color: #93a39e; font-size: 11px; }
    .mobile-quick-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 8px; }
    .mobile-quick-action {
        min-width: 0; min-height: 105px; padding: 13px 7px 10px; border: 1px solid rgba(22,75,63,.08); border-radius: 15px;
        color: #173b33; background: rgba(255,255,255,.92); box-shadow: 0 5px 15px rgba(10,48,41,.06);
        text-align: center; text-decoration: none;
    }
    .mobile-quick-action:active { transform: translateY(1px); background: #f8f6ef; }
    .mobile-quick-icon {
        width: 36px; height: 36px; margin: 0 auto 7px; display: grid; place-items: center;
        border-radius: 12px; color: #1e6755; background: #eaf4f0; font-size: 20px; font-weight: 700;
    }
    .mobile-quick-action strong { display: block; font-size: 12px; }
    .mobile-quick-action small { display: block; margin-top: 3px; color: #95a29f; font-size: 9px; line-height: 1.25; }

    .h-theme.admin-portal .admin-tabs { margin-top: 0 !important; margin-bottom: 12px !important; }
    .h-theme.admin-portal #studentSection .page-header { margin-bottom: 10px; }
    .h-theme.admin-portal #studentSection .page-header .btn { display: none; }
    .h-theme.admin-portal #studentSection > .card { display: none; }
    .mobile-student-tools { display: block; margin-bottom: 10px; }
    .mobile-search-box {
        display: grid; grid-template-columns: 24px minmax(0,1fr) 34px; align-items: center; gap: 4px;
        height: 48px; padding: 0 7px 0 12px; border: 1px solid rgba(20,76,63,.13); border-radius: 14px;
        color: #66827a; background: #fff; box-shadow: 0 5px 15px rgba(10,48,41,.06);
    }
    .mobile-search-box > span { font-size: 20px; }
    .mobile-search-box input { min-width: 0; height: 44px; border: 0; outline: 0; color: #173b33; background: transparent; font-size: 16px; }
    .mobile-search-box input::placeholder { color: #9aa9a5; }
    .mobile-search-box button { width: 32px; height: 32px; border: 0; border-radius: 10px; color: #789089; background: #eef4f1; font-size: 19px; }
    .mobile-list-summary { display: flex; justify-content: space-between; padding: 9px 3px 0; color: #80938d; font-size: 11px; }
    .mobile-list-summary a { color: #26715d; text-decoration: none; font-weight: 600; }
    .mobile-user-list { display: grid; gap: 10px; }
    .mobile-user-card {
        padding: 14px; border: 1px solid rgba(17,71,59,.1); border-radius: 17px;
        background: #fff; box-shadow: 0 6px 18px rgba(10,48,41,.07);
    }
    .mobile-user-main { display: flex; align-items: center; gap: 11px; }
    .mobile-user-avatar {
        flex: none; width: 43px; height: 43px; display: grid; place-items: center; border-radius: 14px;
        color: #fff; background: linear-gradient(145deg, #245f50, #39846f); font-size: 17px; font-weight: 700;
    }
    .mobile-user-copy { min-width: 0; flex: 1; }
    .mobile-user-copy > div { display: flex; align-items: center; justify-content: space-between; gap: 7px; }
    .mobile-user-copy strong { min-width: 0; overflow: hidden; color: #173b33; font-size: 15px; text-overflow: ellipsis; white-space: nowrap; }
    .mobile-user-copy p { margin: 4px 0 0; color: #7b908a; font-size: 11px; }
    .mobile-face-pill { flex: none; padding: 4px 7px; border-radius: 999px; font-size: 9px; }
    .mobile-face-pill.is-ready { color: #247158; background: #e6f4ee; }
    .mobile-face-pill.is-missing { color: #a46622; background: #fff1dc; }
    .mobile-user-metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0; }
    .mobile-user-metrics span { padding: 9px 10px; border-radius: 11px; background: #f4f7f5; }
    .mobile-user-metrics small { display: block; color: #8b9b96; font-size: 9px; }
    .mobile-user-metrics strong { display: block; margin-top: 2px; color: #24473e; font-size: 12px; }
    .mobile-user-actions { display: grid; grid-template-columns: 1fr 1.2fr 1fr; gap: 6px; }
    .mobile-user-actions a,
    .mobile-user-actions button {
        min-width: 0; min-height: 38px; display: grid; place-items: center; padding: 7px 4px;
        border: 1px solid #dbe8e3; border-radius: 10px; color: #286c5a; background: #f8fbfa;
        font: inherit; font-size: 10px; text-decoration: none;
    }
    .mobile-user-actions .danger { color: #a9575c; border-color: #f0d9da; background: #fffafa; }
    .mobile-empty-state { padding: 30px 15px; border-radius: 16px; color: #8b9d98; background: #fff; text-align: center; font-size: 13px; }
}

@media (max-width: 390px) {
    .h-theme .main-content,
    .h-theme.admin-portal .main-content,
    .h-theme.user-portal .main-content { padding-right: 8px; padding-left: 8px; }
    .h-theme .brand-copy strong { max-width: 176px; font-size: 13px; }
    .h-theme .header-controls { grid-template-columns: 1fr; }
    .h-theme .header-controls > .btn { grid-column: auto; }
}

/* 管理端首页在窄屏设备上减少首屏占用，优先显示常用操作和学员列表。 */
@media (max-width: 768px) {
    .h-theme.admin-portal .main-content {
        padding-top: 10px;
    }

    .mobile-home-welcome {
        min-height: 126px;
        padding: 18px 18px;
        border-radius: 18px;
    }

    .mobile-home-date {
        margin-bottom: 5px;
        font-size: 11px;
    }

    .mobile-home-welcome h1 { font-size: 22px; }
    .mobile-home-welcome h1 + p {
        margin-top: 5px;
        font-size: 11px;
    }

    .mobile-stat-grid {
        gap: 8px;
        margin: -24px 6px 0;
    }

    .mobile-stat-card {
        min-height: 94px;
        padding: 12px;
        border-radius: 14px;
    }

    .mobile-stat-card::before { margin-bottom: 6px; }
    .mobile-stat-card strong { font-size: 25px; }
    .mobile-home-section { margin-top: 16px; }
    .mobile-section-heading { margin-bottom: 8px; }
    .mobile-quick-grid { gap: 7px; }

    .mobile-quick-action {
        min-height: 96px;
        padding: 10px 5px 8px;
        border-radius: 13px;
    }

    .mobile-quick-icon {
        width: 32px;
        height: 32px;
        margin-bottom: 5px;
        border-radius: 10px;
        font-size: 18px;
    }

    .mobile-quick-action strong { font-size: 11px; }
    .mobile-quick-action small { font-size: 8px; }
}
