/* ========== 通用隐藏 ========== */
.hidden { display: none !important; }

/* ========== 手机模拟器框架 ========== */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
    --primary: #1677ff;
    --primary-light: #e6f4ff;
    --primary-dark: #0958d9;
    --success: #52c41a;
    --success-light: #f6ffed;
    --warning: #faad14;
    --warning-light: #fffbe6;
    --danger: #ff4d4f;
    --danger-light: #fff2f0;
    --text-primary: #1f1f1f;
    --text-secondary: #666;
    --text-muted: #999;
    --bg-page: #f5f6f8;
    --bg-card: #ffffff;
    --border: #ebebeb;
    --radius: 12px;
    --radius-sm: 8px;
}

html, body {
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
    background: #1a1a2e;
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
}

/* 桌面端展示手机模拟器 */
.phone-stage {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    position: relative;
}

.phone-stage::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 30% 20%, rgba(22,119,255,0.15), transparent 50%),
                radial-gradient(circle at 70% 80%, rgba(82,196,26,0.1), transparent 50%);
}

.phone-frame {
    position: relative;
    width: 390px;
    height: 844px;
    background: #000;
    border-radius: 55px;
    padding: 12px;
    box-shadow: 0 0 0 2px #2a2a3e, 0 20px 60px rgba(0,0,0,0.5), 0 0 80px rgba(22,119,255,0.2);
    flex-shrink: 0;
}

/* 侧边按钮 */
.phone-frame::before {
    content: '';
    position: absolute;
    left: -3px;
    top: 180px;
    width: 3px;
    height: 60px;
    background: #2a2a3e;
    border-radius: 2px;
}
.phone-frame::after {
    content: '';
    position: absolute;
    right: -3px;
    top: 200px;
    width: 3px;
    height: 100px;
    background: #2a2a3e;
    border-radius: 2px;
}

.phone-screen {
    width: 100%;
    height: 100%;
    background: var(--bg-page);
    border-radius: 43px;
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
}

/* 灵动岛 */
.dynamic-island {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    width: 120px;
    height: 32px;
    background: #000;
    border-radius: 20px;
    z-index: 1000;
}

/* 状态栏 */
.status-bar {
    height: 50px;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    padding: 0 28px 4px;
    font-size: 14px;
    font-weight: 600;
    background: var(--bg-page);
    flex-shrink: 0;
    z-index: 999;
}
.status-bar .time { font-size: 15px; }
.status-bar .icons { display: flex; align-items: center; gap: 5px; font-size: 12px; }

/* 页面容器 */
.m-page { display: none; flex: 1; flex-direction: column; overflow: hidden; }
.m-page.active { display: flex; }

/* 滚动内容区 */
.m-content { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 8px 16px 80px; }
.m-content::-webkit-scrollbar { width: 0; }

/* ========== 登录页 ========== */
.m-login { display: flex; flex-direction: column; align-items: center; justify-content: center; flex: 1; padding: 40px 28px; }
.m-login-logo { text-align: center; margin-bottom: 32px; }
.m-login-logo .icon { font-size: 48px; margin-bottom: 12px; }
.m-login-logo h1 { font-size: 22px; color: var(--primary-dark); }
.m-login-logo p { font-size: 13px; color: var(--text-muted); margin-top: 6px; }

.m-tabs { display: flex; margin-bottom: 20px; border-radius: var(--radius-sm); overflow: hidden; border: 1.5px solid var(--primary); width: 100%; }
.m-tab { flex: 1; padding: 10px; background: #fff; color: var(--primary); font-size: 14px; border: none; font-weight: 500; }
.m-tab.active { background: var(--primary); color: #fff; }

.m-form { width: 100%; display: flex; flex-direction: column; gap: 14px; }
.m-field { display: flex; flex-direction: column; gap: 5px; }
.m-field label { font-size: 13px; color: var(--text-secondary); font-weight: 500; }
.m-field input, .m-field select, .m-field textarea {
    padding: 12px 14px; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
    font-size: 15px; outline: none; transition: border-color 0.2s; background: #fff;
}
.m-field input:focus { border-color: var(--primary); }
.m-field .auto-val { background: #f5f5f5; color: var(--text-secondary); }
.m-field .auto-val.has-val { background: var(--primary-light); color: var(--primary-dark); font-weight: 600; }

.m-btn { padding: 13px; border: none; border-radius: var(--radius-sm); font-size: 15px; font-weight: 600; cursor: pointer; transition: opacity 0.2s; }
.m-btn-primary { background: var(--primary); color: #fff; }
.m-btn-primary:active { opacity: 0.85; }
.m-btn-secondary { background: #f0f0f0; color: var(--text-secondary); }
.m-btn-success { background: var(--success); color: #fff; }

.required { color: var(--danger); }

/* ========== 顶部导航栏 ========== */
.m-nav-bar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 16px 12px; background: var(--primary); color: #fff; flex-shrink: 0;
}
.m-nav-bar .title { font-size: 17px; font-weight: 600; }
.m-nav-bar .sub { font-size: 11px; opacity: 0.85; margin-top: 2px; }
.m-nav-bar .right-actions { display: flex; gap: 8px; }
.m-nav-btn-sm { padding: 6px 12px; border-radius: 6px; font-size: 12px; border: 1px solid rgba(255,255,255,0.3); background: rgba(255,255,255,0.15); color: #fff; }

/* ========== 底部Tab栏 ========== */
.m-tab-bar {
    position: absolute; bottom: 0; left: 0; right: 0;
    height: 64px; background: #fff; border-top: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-around;
    padding-bottom: 4px; z-index: 100;
}
.m-tab-item { display: flex; flex-direction: column; align-items: center; gap: 3px; cursor: pointer; padding: 6px; flex: 1; }
.m-tab-item .tab-icon { font-size: 20px; line-height: 1; }
.m-tab-item .tab-label { font-size: 10px; color: var(--text-muted); }
.m-tab-item.active .tab-label { color: var(--primary); font-weight: 600; }
.m-tab-item.active .tab-icon { color: var(--primary); }

/* ========== 卡片 ========== */
.m-card { background: #fff; border-radius: var(--radius); padding: 16px; margin-bottom: 12px; box-shadow: 0 1px 3px rgba(0,0,0,0.04); }
.m-card-title { font-size: 14px; font-weight: 600; margin-bottom: 10px; color: var(--text-primary); }

/* 指标卡片网格 */
.m-stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.m-stat-card { background: #fff; border-radius: var(--radius); padding: 14px; box-shadow: 0 1px 3px rgba(0,0,0,0.04); }
.m-stat-card .label { font-size: 11px; color: var(--text-muted); }
.m-stat-card .value { font-size: 22px; font-weight: 700; margin-top: 4px; }
.m-stat-card .unit { font-size: 11px; color: var(--text-secondary); }
.m-stat-card .change { font-size: 11px; margin-top: 2px; }
.m-stat-card .change.up { color: var(--success); }
.m-stat-card .change.down { color: var(--danger); }
.m-stat-card .icon { font-size: 20px; margin-bottom: 4px; }

/* 横向滚动指标 */
.m-stat-scroll { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 12px; -webkit-overflow-scrolling: touch; }
.m-stat-scroll::-webkit-scrollbar { display: none; }
.m-stat-scroll .m-stat-card { min-width: 140px; flex-shrink: 0; }

/* 图表容器 */
.m-chart-box { background: #fff; border-radius: var(--radius); padding: 14px; margin-bottom: 12px; box-shadow: 0 1px 3px rgba(0,0,0,0.04); }
.m-chart-box h3 { font-size: 13px; margin-bottom: 10px; color: var(--text-secondary); }
.m-chart-box canvas { max-height: 200px; }

/* ========== 店长填报表单 ========== */
.m-form-card { background: #fff; border-radius: var(--radius); padding: 16px; margin-bottom: 12px; box-shadow: 0 1px 3px rgba(0,0,0,0.04); }
.m-form-row { display: flex; gap: 10px; margin-bottom: 12px; }
.m-form-row .m-field { flex: 1; }
.m-form-actions { display: flex; gap: 10px; margin-top: 8px; }
.m-form-actions .m-btn { flex: 1; }

/* ========== 历史数据列表 ========== */
.m-list { display: flex; flex-direction: column; gap: 8px; }
.m-list-item { background: #fff; border-radius: var(--radius-sm); padding: 12px 14px; box-shadow: 0 1px 2px rgba(0,0,0,0.03); display: flex; align-items: center; justify-content: space-between; }
.m-list-item .main { flex: 1; }
.m-list-item .date { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.m-list-item .stats { font-size: 11px; color: var(--text-muted); margin-top: 3px; }
.m-list-item .stats span { margin-right: 8px; }
.m-list-item .action { padding: 6px 12px; border-radius: 6px; border: 1px solid var(--border); font-size: 12px; color: var(--primary); background: #fff; }
.m-list-item.unreported { border-left: 3px solid var(--danger); }

/* ========== 时间筛选 ========== */
.m-filter-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.m-filter-bar select, .m-filter-bar input {
    padding: 8px 10px; border: 1.5px solid var(--border); border-radius: 6px;
    font-size: 13px; background: #fff; outline: none;
}
.m-filter-bar .m-btn { padding: 8px 14px; font-size: 13px; }
.m-custom-range { display: none; flex-direction: column; gap: 6px; width: 100%; }
.m-custom-range.visible { display: flex; }

/* ========== 店铺列表 ========== */
.m-store-card { background: #fff; border-radius: var(--radius); padding: 14px; margin-bottom: 10px; box-shadow: 0 1px 3px rgba(0,0,0,0.04); border-left: 3px solid var(--primary); }
.m-store-card .header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.m-store-card .name { font-size: 15px; font-weight: 600; }
.m-store-card .cat-tag { font-size: 11px; padding: 2px 8px; border-radius: 4px; }
.m-store-card .info { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; }
.m-store-card .stats { display: flex; gap: 12px; }
.m-store-card .stat { font-size: 11px; }
.m-store-card .stat .label { color: var(--text-muted); display: block; }
.m-store-card .stat .val { font-weight: 600; font-size: 14px; }
.m-store-card.unreported { border-left-color: var(--danger); }

/* ========== 异常预警 ========== */
.m-alert-item { background: #fff; border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 8px; box-shadow: 0 1px 2px rgba(0,0,0,0.03); border-left: 3px solid var(--warning); }
.m-alert-item.high { border-left-color: var(--danger); }
.m-alert-item.medium { border-left-color: var(--warning); }
.m-alert-item.low { border-left-color: var(--primary); }
.m-alert-badge { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 10px; font-weight: 600; margin-bottom: 6px; }
.m-alert-badge.high { background: var(--danger-light); color: var(--danger); }
.m-alert-badge.medium { background: var(--warning-light); color: #d48806; }
.m-alert-badge.low { background: var(--primary-light); color: var(--primary); }
.m-alert-item .store-name { font-size: 14px; font-weight: 600; }
.m-alert-item .desc { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }
.m-alert-item .metric { font-size: 12px; color: var(--danger); font-weight: 600; margin-top: 4px; }

/* 未上报 */
.m-unreported-item { background: #fff2f0; border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 8px; border-left: 3px solid var(--danger); }
.m-unreported-item .name { font-size: 14px; font-weight: 600; color: var(--danger); }
.m-unreported-item .missing { font-size: 11px; color: var(--danger); margin-top: 4px; }
.m-unreported-item .contact { font-size: 11px; color: var(--text-muted); margin-top: 3px; }

/* ========== 弹窗 ========== */
.m-modal { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 2000; display: none; align-items: flex-end; justify-content: center; }
.m-modal.show { display: flex; }
.m-modal-card { background: #fff; border-radius: 20px 20px 0 0; width: 390px; max-height: 80%; overflow-y: auto; padding: 20px; animation: slideUp 0.3s ease; }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.m-modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.m-modal-header h3 { font-size: 16px; }
.m-modal-close { font-size: 22px; color: var(--text-muted); background: none; border: none; cursor: pointer; }
.m-modal-footer { display: flex; gap: 10px; margin-top: 16px; }
.m-modal-footer .m-btn { flex: 1; }

/* ========== Toast ========== */
.m-toast-container { position: fixed; top: 60px; left: 50%; transform: translateX(-50%); z-index: 9999; display: flex; flex-direction: column; gap: 8px; width: 320px; }
.m-toast { background: rgba(0,0,0,0.8); color: #fff; border-radius: 8px; padding: 10px 16px; font-size: 13px; text-align: center; animation: fadeIn 0.3s; }
.m-toast.success { background: var(--success); }
.m-toast.error { background: var(--danger); }
@keyframes fadeIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }

/* ========== 空状态 ========== */
.m-empty { text-align: center; padding: 40px 20px; color: var(--text-muted); font-size: 14px; }
.m-empty .icon { font-size: 36px; margin-bottom: 8px; }

/* ========== 段标题 ========== */
.m-section-title { font-size: 14px; font-weight: 600; color: var(--text-primary); margin: 16px 0 10px; display: flex; align-items: center; justify-content: space-between; }
.m-section-title .more { font-size: 12px; color: var(--primary); font-weight: 400; }

/* ========== 数据表格（移动端横向滚动） ========== */
.m-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius-sm); }
.m-table-wrap::-webkit-scrollbar { height: 3px; }
.m-table { width: 100%; border-collapse: collapse; font-size: 12px; white-space: nowrap; }
.m-table th { background: var(--bg-page); padding: 8px 10px; text-align: left; color: var(--text-secondary); font-weight: 500; }
.m-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); }
.m-table tr.row-unreported { background: #fff2f0; }
.m-table tr.row-unreported td { color: var(--danger); }

/* ========== 分段控件 ========== */
.m-seg { display: flex; background: #f0f0f0; border-radius: 8px; padding: 3px; margin-bottom: 12px; }
.m-seg-item { flex: 1; text-align: center; padding: 8px; font-size: 13px; color: var(--text-secondary); border-radius: 6px; cursor: pointer; transition: all 0.2s; }
.m-seg-item.active { background: #fff; color: var(--primary); font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }

/* ========== 反馈列表 ========== */
.m-feedback-item { background: #fff; border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 8px; box-shadow: 0 1px 2px rgba(0,0,0,0.03); }
.m-feedback-item .top { display: flex; justify-content: space-between; margin-bottom: 4px; }
.m-feedback-item .store { font-size: 13px; font-weight: 600; }
.m-feedback-item .date { font-size: 11px; color: var(--text-muted); }
.m-feedback-item .note { font-size: 12px; color: var(--text-secondary); margin-top: 4px; padding: 8px; background: var(--bg-page); border-radius: 6px; }

/* ========== 提示信息 ========== */
.m-tip { font-size: 12px; color: var(--text-muted); padding: 8px 0; }
.m-summary-bar { display: flex; gap: 16px; padding: 10px 14px; background: var(--primary-light); border-radius: var(--radius-sm); margin-bottom: 12px; flex-wrap: wrap; }
.m-summary-bar .item { font-size: 12px; }
.m-summary-bar .item .label { color: var(--text-muted); }
.m-summary-bar .item .val { font-weight: 700; font-size: 15px; color: var(--primary-dark); }
.m-summary-bar .item .val.danger { color: var(--danger); }

/* ========== 真机全屏模式（去除手机模拟器框架，修复高度链+滚动） ========== */
html.real-mobile { height: 100%; }
html.real-mobile body {
    background: var(--bg-page);
    overflow: hidden;
    height: 100%;
    height: 100dvh;
    margin: 0; padding: 0;
}
html.real-mobile .phone-stage {
    display: flex;
    flex-direction: column;
    height: 100%;
    height: 100dvh;
    background: var(--bg-page);
}
html.real-mobile .phone-stage::before { display: none; }
html.real-mobile .phone-frame {
    width: 100%;
    height: 100%;
    background: var(--bg-page);
    border-radius: 0; border: none;
    box-shadow: none; padding: 0;
    display: flex;
    flex-direction: column;
}
html.real-mobile .phone-frame::before,
html.real-mobile .phone-frame::after { display: none; }
html.real-mobile .phone-screen {
    border-radius: 0;
    height: 100%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
}
html.real-mobile .dynamic-island { display: none; }
html.real-mobile .status-bar { display: none; }

/* m-page 必须填满 phone-screen 剩余空间，内部才能滚动 */
html.real-mobile .m-page.active {
    display: flex !important;
    flex-direction: column;
    flex: 1;
    min-height: 0;   /* 关键：允许flex子项收缩，否则overflow:auto不生效 */
    overflow: hidden;
    position: relative;
}

/* 内容区可滚动 */
html.real-mobile .m-content {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

/* 底部Tab栏：从 absolute 改为文档流内固定定位（相对 m-page） */
html.real-mobile .m-tab-bar {
    position: relative;
    flex-shrink: 0;
    padding-bottom: env(safe-area-inset-bottom, 4px);
    z-index: 100;
}

html.real-mobile .m-nav-bar {
    padding-top: env(safe-area-inset-top, 8px);
    flex-shrink: 0;
}
html.real-mobile .m-modal-card { width: 100vw; }

/* ===== PWA 状态条 / 提醒 / 安装引导 ===== */
.m-pwa-bar { padding: 8px 12px 0; display: flex; flex-direction: column; gap: 8px; }
.m-sync-badge { background: #fff7e6; color: #d46b08; border: 1px solid #ffd591; border-radius: 8px; padding: 8px 10px; font-size: 12px; font-weight: 600; text-align: center; }
.m-reminder { background: #fff1f0; color: #cf1322; border: 1px solid #ffa39e; border-radius: 8px; padding: 8px 10px; font-size: 12px; font-weight: 600; text-align: center; }
.m-install-btn { background: #1677ff; color: #fff; border: none; border-radius: 8px; padding: 9px 12px; font-size: 13px; font-weight: 600; }
.m-install-btn:active { opacity: .85; }
.m-ios-tip { background: #e6f4ff; color: #0958d9; border: 1px solid #91caff; border-radius: 8px; padding: 8px 10px; font-size: 12px; text-align: center; }
.m-toast.warn { background: #faad14; color: #fff; }
