/* RoomMon — 设计令牌 + 组件。仅深色主题。 */

:root {
    --bg: #0a0e1a;
    --bg-2: #141a2c;
    --surface: rgba(255, 255, 255, 0.04);
    --surface-2: rgba(255, 255, 255, 0.07);
    --border: rgba(255, 255, 255, 0.09);
    --border-strong: rgba(255, 255, 255, 0.18);

    --text: #e8edf7;
    --text-dim: #94a3b8;
    --text-faint: #64748b;

    --accent: #60a5fa;
    --accent-soft: rgba(96, 165, 250, 0.14);
    --ok: #22c55e;
    --warn: #f59e0b;
    --err: #ef4444;

    --stage-absent: #8aa0be;
    --stage-awake: #ff6b6b;
    --stage-light: #29B6F6;
    --stage-deep: #5E35B1;

    --radius: 14px;
    --radius-sm: 9px;
    --topbar-h: 58px;
    --tabbar-h: 58px;
    --pad: 16px;
}

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

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

body {
    background: linear-gradient(160deg, var(--bg), var(--bg-2));
    background-attachment: fixed;
    color: var(--text);
    font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    min-height: 100vh;
    min-height: 100dvh;
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ===================== 顶栏 ===================== */

.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 var(--pad);
    background: rgba(10, 14, 26, 0.86);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 9px; font-weight: 600; font-size: 15px; }
.brand img { width: 26px; height: 26px; border-radius: 7px; }

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.conn { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-dim); }
.conn-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--err); transition: background .3s; }
.conn-dot.connected { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.conn-dot.connecting { background: var(--warn); }

/* ===================== 导航 ===================== */

.tabs {
    display: flex;
    gap: 2px;
    padding: 0 var(--pad);
    border-bottom: 1px solid var(--border);
    background: rgba(10, 14, 26, 0.6);
    overflow-x: auto;
    scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
    padding: 11px 15px;
    font-size: 13px;
    color: var(--text-dim);
    border-bottom: 2px solid transparent;
    white-space: nowrap;
    min-height: 42px;
    transition: color .15s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ===================== 主区 ===================== */

.main { max-width: 880px; margin: 0 auto; padding: var(--pad); }
.view { display: none; }
.view.active { display: block; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--pad);
    margin-bottom: 12px;
}

.section-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-faint);
    text-transform: uppercase;
    letter-spacing: .07em;
    margin: 22px 0 10px;
}
.section-title:first-child { margin-top: 0; }

/* ===================== 通用元件 ===================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 13px;
    min-height: 36px;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    border: 1px solid var(--border);
    font-size: 13px;
    transition: background .15s, border-color .15s;
}
.btn:hover:not(:disabled) { background: rgba(255, 255, 255, 0.12); border-color: var(--border-strong); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--accent-soft); border-color: rgba(96, 165, 250, .4); color: #cfe4ff; }
.btn-primary:hover:not(:disabled) { background: rgba(96, 165, 250, .24); }
.btn-danger { color: #ffb4b4; border-color: rgba(239, 68, 68, .35); background: rgba(239, 68, 68, .12); }
.btn-danger:hover:not(:disabled) { background: rgba(239, 68, 68, .22); }
.btn-sm { min-height: 30px; padding: 5px 10px; font-size: 12px; }

.pill {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 11px;
    background: var(--surface-2);
    color: var(--text-dim);
}

.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-faint); flex: none; }
.dot.online { background: var(--ok); box-shadow: 0 0 7px rgba(34, 197, 94, .7); }
.dot.offline { background: var(--text-faint); }

.muted { color: var(--text-dim); }
.faint { color: var(--text-faint); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

.empty {
    text-align: center;
    padding: 44px 20px;
    color: var(--text-faint);
    font-size: 13px;
    line-height: 1.9;
}
.empty strong { display: block; color: var(--text-dim); font-size: 14px; margin-bottom: 4px; }

.spinner {
    width: 15px; height: 15px;
    border: 2px solid var(--border-strong);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .7s linear infinite;
    display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===================== 监控视图 ===================== */

.summary {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px var(--pad);
    border-radius: var(--radius);
    background: var(--surface);
    border: 1px solid var(--border);
    margin-bottom: 14px;
    font-size: 13px;
}

.room-card { padding: 0; overflow: hidden; }

.room-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px var(--pad);
    cursor: pointer;
    user-select: none;
}
.room-head:hover { background: var(--surface); }
.room-name { font-weight: 600; font-size: 15px; }
.room-caret { color: var(--text-faint); font-size: 11px; transition: transform .2s; }
.room-card.open .room-caret { transform: rotate(90deg); }

.room-glance { margin-left: auto; display: flex; align-items: center; gap: 14px; font-size: 13px; }
.glance-item { display: flex; align-items: center; gap: 5px; color: var(--text-dim); }
.glance-item b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }

.room-body { display: none; padding: 0 var(--pad) var(--pad); }
.room-card.open .room-body { display: block; }

.status-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 0 16px;
    border-top: 1px solid var(--border);
}
.status-icon {
    width: 52px; height: 52px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: 24px;
    background: var(--surface-2);
    flex: none;
}
.status-icon.occupied { background: rgba(34, 197, 94, .16); animation: pulse 2.4s ease-in-out infinite; }
@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, .34); }
    50% { box-shadow: 0 0 0 10px rgba(34, 197, 94, 0); }
}
.status-text { font-size: 19px; font-weight: 600; }
.status-sub { font-size: 12px; color: var(--text-dim); }

.metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.metric { background: var(--surface-2); border-radius: var(--radius-sm); padding: 10px 12px; }
.metric-value { font-size: 19px; font-weight: 600; font-variant-numeric: tabular-nums; }
.metric-label { font-size: 11px; color: var(--text-faint); margin-top: 2px; }

.conf-bar { height: 3px; background: rgba(255, 255, 255, .1); border-radius: 2px; margin-top: 7px; overflow: hidden; }
.conf-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--ok)); transition: width .3s; }

.breath-panel { background: var(--surface-2); border-radius: var(--radius-sm); padding: 12px; margin-bottom: 14px; }
.breath-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 8px; }
.breath-bpm { font-size: 21px; font-weight: 600; color: var(--accent); font-variant-numeric: tabular-nums; }
.breath-canvas { width: 100%; height: 80px; display: block; }

.signal-panel { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.signal-item { background: var(--surface-2); border-radius: var(--radius-sm); padding: 8px 10px; }
.signal-value { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.signal-label { font-size: 10px; color: var(--text-faint); margin-top: 1px; }
.signal-bar { height: 3px; background: rgba(255, 255, 255, .1); border-radius: 2px; margin-top: 6px; overflow: hidden; }
.signal-fill { height: 100%; border-radius: 2px; transition: width .3s; }
.signal-fill.good { background: var(--ok); }
.signal-fill.ok { background: var(--warn); }
.signal-fill.bad { background: var(--err); }

.sleep-strip {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-top: 14px;
}
.sleep-stat { background: var(--surface-2); border-radius: var(--radius-sm); padding: 9px 10px; text-align: center; }
.sleep-stat-value { font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; }
.sleep-stat-label { font-size: 10px; color: var(--text-faint); margin-top: 1px; }
.v-deep { color: var(--stage-deep); }
.v-light { color: var(--stage-light); }
.v-awake { color: var(--stage-awake); }

.dev-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }

/* ===================== 设备视图 ===================== */

#devList { display: flex; flex-direction: column; gap: 18px; }
.dev-section { display: flex; flex-direction: column; }
.dev-section-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.dev-section-head .section-title { margin: 0; }
.dev-section-head .faint { margin-left: auto; font-size: 12px; }
.dev-section-head .btn-ghost { margin-left: 8px; }

/* 桌面：一行网格；手机：堆叠（见响应式段） */
.dev-row {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    padding: 12px var(--pad);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 8px;
}
.dev-main { display: flex; align-items: center; gap: 10px; min-width: 0; }
.dev-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dev-sub { font-size: 11px; color: var(--text-faint); }
.dev-meta { display: flex; flex-wrap: wrap; gap: 10px; font-size: 12px; color: var(--text-dim); }
.dev-stat { font-variant-numeric: tabular-nums; white-space: nowrap; }
.dev-ops { display: flex; gap: 6px; }

.dev-hero { display: flex; align-items: center; gap: 11px; padding-bottom: 14px; }
.dev-hero-name { font-size: 16px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dev-hero .faint { font-size: 11px; }

.row-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.btn-ghost { background: none; border-color: transparent; color: var(--text-dim); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); border-color: var(--border); color: var(--text); }

/* ===================== 查找设备 ===================== */

.find-body { text-align: center; padding: 8px 0 4px; }
.find-icon { font-size: 42px; line-height: 1; margin-bottom: 12px; }
.find-icon.rainbow { animation: hue 1.6s linear infinite; }
@keyframes hue { to { filter: hue-rotate(360deg); } }
.find-text { font-size: 15px; font-weight: 600; margin-bottom: 8px; }
.find-hint { font-size: 12.5px; color: var(--text-dim); line-height: 1.7; }
.find-hint code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.find-body .spinner { margin-bottom: 12px; }

/* ===================== 睡眠视图 ===================== */

.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.seg { display: flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.seg button { padding: 8px 14px; font-size: 12px; color: var(--text-dim); min-height: 38px; }
.seg button.active { background: var(--accent-soft); color: var(--text); }

.report-grid { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.report-main { text-align: center; min-width: 96px; }
.report-score-label { font-size: 11px; color: var(--text-faint); margin-top: 4px; }
.report-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; flex: 1; min-width: 220px; margin-top: 0; }

.hypno-wrap { }
.hypnogram { width: 100%; height: 96px; display: block; background: var(--surface-2); border-radius: var(--radius-sm); }
.hypno-legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 9px; font-size: 11px; color: var(--text-dim); }
.hypno-key { display: inline-flex; align-items: center; gap: 5px; }
.hypno-key i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }

.trend { display: flex; align-items: flex-end; gap: 6px; height: 130px; padding-top: 8px; }
.trend-col { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; min-width: 0; }
.trend-bar {
    width: 100%;
    max-width: 40px;
    background: var(--accent);
    border-radius: 4px 4px 0 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    overflow: hidden;
    margin-top: auto;
}
.trend-bar-deep { background: var(--stage-deep); width: 100%; }
.trend-label { font-size: 10px; color: var(--text-faint); margin-top: 6px; white-space: nowrap; }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-faint);
    text-transform: uppercase;
    letter-spacing: .06em;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.table td { padding: 10px; border-bottom: 1px solid var(--border); font-variant-numeric: tabular-nums; white-space: nowrap; }
.table tr:last-child td { border-bottom: none; }

/* ===================== 固件升级 ===================== */

.dropzone {
    border: 2px dashed var(--border-strong);
    border-radius: var(--radius);
    padding: 30px 18px;
    text-align: center;
    cursor: pointer;
    transition: border-color .15s, background .15s;
    line-height: 1.7;
}
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.drop-icon { font-size: 34px; margin-bottom: 10px; }

.file-card { display: flex; align-items: center; gap: 12px; padding: 13px; background: var(--surface-2); border-radius: var(--radius-sm); }
.file-icon { font-size: 24px; flex: none; }
.file-name { font-weight: 600; word-break: break-all; }

.pick-list { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; max-height: 260px; overflow-y: auto; }
.pick-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    min-height: 46px;
}
.pick-row:hover { background: var(--surface); }
.pick-row input { width: 17px; height: 17px; accent-color: var(--accent); flex: none; }
.pick-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }

.ota-status { font-variant-numeric: tabular-nums; }
.ota-row.ok .ota-status { color: var(--ok); }
.ota-row.warn .ota-status { color: var(--warn); }
.ota-row.busy .ota-status { color: var(--accent); }

.steps { margin: 0; padding-left: 20px; font-size: 13px; line-height: 2; color: var(--text-dim); }
.steps code { background: var(--surface-2); padding: 2px 6px; border-radius: 4px; color: var(--text); font-size: 12px; }

/* ===================== 睡眠视图 ===================== */

.picker { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.select {
    padding: 8px 11px;
    min-height: 38px;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text);
}

.report-score { font-size: 44px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.report-score.good { color: var(--ok); }
.report-score.ok { color: var(--warn); }
.report-score.bad { color: var(--err); }

.timeline-bar { display: flex; gap: 1px; height: 30px; border-radius: 5px; overflow: hidden; margin-top: 10px; }
.tl-seg { flex: 1; min-width: 1px; background: rgba(255, 255, 255, .07); }
.tl-seg.on { background: var(--ok); }
.timeline-labels { display: flex; justify-content: space-between; font-size: 10px; color: var(--text-faint); margin-top: 5px; }

.hist-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}
.hist-row:last-child { border-bottom: none; }
.hist-date { flex: 1; }
.hist-detail { font-size: 12px; color: var(--text-dim); }
.hist-dur { font-variant-numeric: tabular-nums; font-weight: 600; }

/* ===================== 设置视图 ===================== */

/* 每行一个 <div><span>键</span><b>值</b></div> */
.kv > div {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    padding: 9px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}
.kv > div:last-child { border-bottom: none; }
.kv span { color: var(--text-dim); flex: none; }
.kv b { font-weight: 600; text-align: right; word-break: break-all; }

/* ===================== 模态框 ===================== */

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .68);
    backdrop-filter: blur(3px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    animation: fade .14s ease-out;
}
@keyframes fade { from { opacity: 0; } }

.modal {
    background: #161c2e;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    width: 100%;
    max-width: 460px;
    max-height: calc(100dvh - 32px);
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 50px rgba(0, 0, 0, .5);
    animation: pop .16s ease-out;
}
@keyframes pop { from { transform: scale(.96); opacity: 0; } }

.modal-head { display: flex; align-items: center; gap: 10px; padding: 15px var(--pad); border-bottom: 1px solid var(--border); }
.modal-title { font-size: 15px; font-weight: 600; flex: 1; }
.modal-x { color: var(--text-dim); font-size: 16px; padding: 4px 8px; border-radius: 6px; }
.modal-x:hover { background: var(--surface-2); color: var(--text); }
.modal-body { padding: var(--pad); overflow-y: auto; font-size: 13px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 13px var(--pad); border-top: 1px solid var(--border); }
.modal-actions:empty { display: none; }

.field { margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
.field label { display: block; font-size: 12px; color: var(--text-dim); margin-bottom: 6px; }
.input {
    width: 100%;
    padding: 10px 12px;
    min-height: 42px;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text);
}
.input:focus { border-color: var(--accent); outline: none; }

/* select 用 .input 类时的原生外观重置 */
select.input {
    appearance: none;
    -webkit-appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, var(--text-dim) 50%),
                      linear-gradient(135deg, var(--text-dim) 50%, transparent 50%);
    background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
    padding-right: 32px;
}
select.input option { background: #161c2e; color: var(--text); }

input[type=range] { width: 100%; accent-color: var(--accent); height: 28px; }

.check-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    margin-bottom: 7px;
    cursor: pointer;
}
.check-row:hover { background: var(--surface); }
.check-row input { width: 17px; height: 17px; accent-color: var(--accent); flex: none; }
.check-row.disabled { opacity: .5; }

.progress { height: 6px; background: rgba(255, 255, 255, .1); border-radius: 3px; overflow: hidden; margin-top: 10px; }
.progress-fill { height: 100%; background: var(--accent); width: 0; transition: width .18s; }

.ota-row {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 9px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}
.ota-row:last-child { border-bottom: none; }
.ota-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.notice {
    padding: 11px 13px;
    border-radius: var(--radius-sm);
    font-size: 12.5px;
    line-height: 1.65;
    border: 1px solid;
}
.notice-info { background: var(--accent-soft); border-color: rgba(96, 165, 250, .35); color: #cfe4ff; }
.notice-warn { background: rgba(245, 158, 11, .12); border-color: rgba(245, 158, 11, .35); color: #fde2b3; }
.notice-err { background: rgba(239, 68, 68, .12); border-color: rgba(239, 68, 68, .35); color: #ffc4c4; }

.countdown { font-size: 30px; font-weight: 700; text-align: center; font-variant-numeric: tabular-nums; color: var(--accent); }

/* ===================== Toast ===================== */

#toasts {
    position: fixed;
    right: 14px;
    bottom: calc(var(--tabbar-h) + 14px);
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: flex-end;
    pointer-events: none;
    max-width: min(340px, calc(100vw - 28px));
}

.toast {
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    background: #1e2740;
    border: 1px solid var(--border-strong);
    font-size: 13px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .4);
    animation: toast-in .2s ease-out;
    pointer-events: auto;
    word-break: break-word;
}
.toast-out { opacity: 0; transform: translateY(6px); transition: opacity .22s, transform .22s; }
.toast-success { border-color: rgba(34, 197, 94, .5); }
.toast-error { border-color: rgba(239, 68, 68, .55); }
.toast-info { border-color: rgba(96, 165, 250, .5); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ===================== 响应式 ===================== */

@media (max-width: 640px) {
    /* 手机：导航移到底部固定栏 */
    .tabs {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 40;
        padding: 0;
        border-bottom: none;
        border-top: 1px solid var(--border);
        background: rgba(10, 14, 26, .95);
        backdrop-filter: blur(12px);
        padding-bottom: env(safe-area-inset-bottom);
    }
    .tab {
        flex: 1;
        text-align: center;
        border-bottom: none;
        border-top: 2px solid transparent;
        padding: 9px 4px;
        font-size: 12px;
    }
    .tab.active { border-top-color: var(--accent); border-bottom: none; }

    .main { padding: 12px; padding-bottom: calc(var(--tabbar-h) + 20px); }
    .metrics { grid-template-columns: repeat(3, 1fr); gap: 7px; }
    .metric-value { font-size: 17px; }
    .signal-panel { grid-template-columns: repeat(2, 1fr); }
    .sleep-strip { grid-template-columns: repeat(2, 1fr); }
    .report-stats { grid-template-columns: repeat(3, 1fr); }
    .room-glance { gap: 10px; font-size: 12px; }

    /* 设备行：手机上从三列网格改成上下堆叠 */
    .dev-row { grid-template-columns: 1fr; gap: 10px; }
    .dev-meta { gap: 12px; }
    .dev-ops .btn { flex: 1; }
    .dev-ops { width: 100%; }

    .report-grid { gap: 14px; }
    .report-main { min-width: 78px; }
    .report-score { font-size: 38px; }
    .report-stats { grid-template-columns: repeat(2, 1fr); min-width: 100%; }
    .trend { height: 110px; gap: 3px; }
    .toolbar .seg { flex: 1; }
    .toolbar .seg button { flex: 1; }
    .toolbar select.input { max-width: none !important; flex: 1; }

    .modal { max-width: none; }
    .modal-backdrop { padding: 0; align-items: flex-end; }
    .modal { border-radius: var(--radius) var(--radius) 0 0; max-height: 92dvh; padding-bottom: env(safe-area-inset-bottom); }
    #toasts { left: 14px; right: 14px; align-items: stretch; max-width: none; }
}

@media (max-width: 360px) {
    .room-glance .glance-optional { display: none; }
}
