/* 页面布局：外壳 · 设备卡片 · 弹窗 · 地图 · 登录页 · 响应式（暖色调） */

/* ---------- 外壳 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; height: 64px; padding: 0 22px;
  background: #fffdfa; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.brand { display: flex; align-items: center; gap: 10px; color: #4a2f16; font-weight: 700; font-size: 18px; }
.brand img { width: 32px; height: 32px; display: block; }
.topbar .crumb { color: var(--muted); font-size: 13px; font-weight: 400; }
#user-block { display: flex; align-items: center; gap: 12px; font-size: 14px; }
#user-block .connected { font-size: 12px; color: #5c7f66; }
#user-block .text-button { padding: 6px 0; }
main { width: 100%; max-width: 1440px; margin: 0 auto; padding: 22px; min-width: 0; }

/* ---------- 双视图外壳：左侧导航 + 主内容 ---------- */
.shell { display: flex; align-items: flex-start; gap: 0; min-height: calc(100vh - 64px); }
.sidenav {
  flex: 0 0 176px; position: sticky; top: 64px; align-self: flex-start;
  display: flex; flex-direction: column; gap: 6px;
  padding: 22px 0 22px 18px;
}
.sidenav-item {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px; border: 1px solid transparent; border-radius: 10px;
  background: transparent; color: #6b5640; font-size: 15px; font-weight: 600; text-align: left;
}
.sidenav-item:hover { background: #f8ede0; }
.sidenav-item.active { background: #fff; border-color: var(--line); color: var(--brand); box-shadow: var(--shadow); }
.sidenav-item.active::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--brand); }
.page-view[hidden] { display: none; }
.shell main { flex: 1 1 auto; min-width: 0; }

/* 项目选择 */
.project-label { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; }
.project-label select { width: auto; min-width: 170px; margin-top: 0; }

/* ---------- SOS 选项卡 ---------- */
.sos-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 4px 0 14px; border-bottom: 1px solid var(--line); padding-bottom: 0; }
.sos-tab {
  padding: 9px 16px 10px; border: 1px solid transparent; border-bottom: 0;
  border-radius: 10px 10px 0 0; background: transparent; color: #6b5640;
  font-size: 13.5px; font-weight: 600;
}
.sos-tab:hover { background: #f8ede0; }
.sos-tab.active { background: #fff; border-color: var(--line); color: var(--brand); position: relative; top: 1px; }
.sos-panel[hidden] { display: none; }
/* SOS 生效模式提示条：三组互斥，随时能看到当前哪一组在生效 */
.sos-mode-bar {
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  margin: -6px 0 14px; padding: 9px 12px; border-radius: 9px;
  border: 1px solid #cfe0d8; background: #f2f8f5;
}
.sos-mode-chip { font-size: 13px; color: #47584f; white-space: nowrap; }
.sos-mode-chip strong { font-size: 14px; color: #1d6b4f; margin-left: 2px; }
.sos-mode-hint { font-size: 12.5px; color: #6b7a72; line-height: 1.55; flex: 1 1 260px; }
.sos-mode-hint.error { color: #a3361f; }
/* SIP_CC / CC 的实名卡提醒 */
.warn-line {
  margin: 0 0 10px; padding: 10px 12px; border-radius: 9px;
  border: 1px solid #f2d3a4; background: #fff7e8; color: #8a4b16;
  font-size: 13px; font-weight: 600;
}

/* ---------- 分组管理：树状图 ---------- */
.group-tree { display: grid; gap: 6px; }
.group-tree > p { margin: 0; }
.group-node { border: 1px solid var(--line); border-radius: 10px; background: #fff; overflow: hidden; }
.group-row {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 12px; min-height: 44px; border-bottom: 1px dashed var(--line);
}
.group-row.unassigned { background: #fdf8f1; }
.group-expander {
  width: 26px; height: 26px; flex-shrink: 0; border: 1px solid var(--line); border-radius: 7px;
  background: #fdf7f0; color: #6b5640; font-size: 12px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
}
.group-expander:disabled { opacity: .35; }
.group-name { font-weight: 700; color: #4a3826; }
.group-level { font-size: 11.5px; color: #8a4b16; background: #fbeee0; padding: 2px 8px; border-radius: 999px; font-weight: 600; }
.group-sips { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.group-count { font-size: 12px; color: var(--muted); }
.group-actions { margin-left: auto; display: inline-flex; gap: 12px; flex-wrap: wrap; }
.group-actions .text-button { padding: 4px 0; font-size: 13px; }
.group-device {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 8px 12px; min-height: 40px; border-bottom: 1px dashed var(--line);
  background: #fffdf9; cursor: context-menu;
}
.group-device:last-child { border-bottom: 0; }
.group-device:hover { background: #fdf3e7; }
.group-device-imei { font-size: 13.5px; font-weight: 600; }
.group-device-state { font-size: 12px; color: var(--muted); }
.group-device .group-more { margin-left: auto; }

/* ---------- 右键菜单 ---------- */
.ctx-menu {
  position: fixed; z-index: 300; min-width: 168px;
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 14px 34px #3d2a1830; padding: 6px; display: flex; flex-direction: column;
}
.ctx-menu[hidden] { display: none; }
.ctx-menu button {
  border: 0; background: transparent; text-align: left; padding: 10px 12px;
  border-radius: 7px; font-size: 13.5px; font-weight: 600; color: #4a3826;
}
.ctx-menu button:hover { background: #f8ede0; color: var(--brand); }

/* ---------- 拨号弹窗 ---------- */
#dial-duration { color: var(--brand); font-weight: 700; }
.heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; flex-wrap: wrap; margin-bottom: 18px; }
.heading p { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.toolbar .search { position: relative; }
.toolbar input[type="search"] { width: min(260px, 60vw); margin: 0; }

/* ---------- SIP 在线状态刷新条 ----------
 * 一行放三样：自动刷新开关、立即刷新、当前状态摘要（账号数 / 上次查询时刻 / 下次倒计时）。
 * 摘要用等宽感的小字，不放标题里——它是运行状态，不是页面说明。 */
.presence-bar {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px;
  margin: 10px 0 6px; padding: 8px 12px;
  border: 1px solid var(--line); border-radius: 10px; background: #fffdfa;
  font-size: 12.5px; color: var(--muted);
}
.presence-toggle {
  display: inline-flex; align-items: center; gap: 7px; margin: 0;
  font-weight: 600; color: #5d4a38; cursor: pointer;
}
.presence-toggle input { width: 15px; height: 15px; margin: 0; accent-color: var(--brand); }
.presence-note { min-width: 0; overflow-wrap: anywhere; }
.presence-note.error { color: var(--warn); font-weight: 600; }
.site-footer { display: flex; justify-content: space-between; gap: 14px; padding: 26px 0 6px; font-size: 12px; color: #a08b74; flex-wrap: wrap; }

/* ---------- 设备卡片 ---------- */
.device-grid { display: grid; gap: var(--space); grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); }
.device-card {
  display: flex; flex-direction: column; gap: 14px; min-width: 0;
  background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 18px;
  box-shadow: var(--shadow);
}
.device-card:hover { border-color: #e8c9a4; }
.device-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-width: 0; }
.device-title { display: flex; align-items: center; gap: 9px; min-width: 0; }
.device-imei { margin: 0; font-family: Consolas, ui-monospace, Menlo, monospace; font-size: 17px; letter-spacing: .3px; overflow-wrap: anywhere; }
.state-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; background: #ddccb9; }
.state-dot.ok { background: var(--ok); box-shadow: 0 0 0 3px #2f8a5222; }
.state-dot.warn { background: #e8a33d; box-shadow: 0 0 0 3px #e8a33d22; }
.state-dot.loading { background: #e0a860; animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }

/* 状态区：三行两列（左标签 / 右数值），每行一个字段 */
.device-stats { display: grid; gap: 0; margin: 0; padding: 10px 14px; background: #fdf7f0; border-radius: 10px; }
.stat { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; padding: 7px 0; border-bottom: 1px dashed var(--line); }
.stat:last-child { border-bottom: 0; }
.stat-label { flex: 0 0 auto; font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.stat-value { flex: 1 1 auto; min-width: 0; margin: 0; text-align: right; font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.stat-value[data-level=""] { color: var(--muted); font-weight: 500; }

.device-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.device-actions .btn { width: 100%; padding-left: 8px; padding-right: 8px; }

.device-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-top: 4px; border-top: 1px dashed var(--line); min-width: 0; }
.sip-chip { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 600; color: var(--muted); min-width: 0; }
.sip-chip .sip-dot { width: 8px; height: 8px; border-radius: 50%; background: #ddccb9; flex-shrink: 0; }
.sip-chip.on { color: #1f7a4d; }
.sip-chip.on .sip-dot { background: var(--ok); }
.sip-chip.pending { color: #96601c; }
.sip-chip.pending .sip-dot { background: #e8a33d; }
.sip-chip.off { color: #a04a2a; }
.sip-chip.off .sip-dot { background: #cf6a3a; }
/* 拨号中 / 收到来电：蓝色 */
.sip-chip.call { color: #1b5fbf; }
.sip-chip.call .sip-dot { background: #2f7de1; box-shadow: 0 0 0 3px #2f7de126; }
/* 通话中：亮橙色，加一圈光晕以示进行中 */
.sip-chip.talk { color: #b4530a; }
.sip-chip.talk .sip-dot { background: #ff8a1f; box-shadow: 0 0 0 4px #ff8a1f33; }
.sip-chip.unknown { color: var(--muted); }
.sip-chip.unknown .sip-dot { background: #ddccb9; }
.device-status { font-size: 12px; color: var(--muted); text-align: right; overflow-wrap: anywhere; }

#empty { text-align: center; color: var(--muted); font-size: 14px; padding: 48px 18px; border: 1px dashed var(--line); border-radius: 14px; background: #fffdfa; }

/* ---------- 弹窗 ---------- */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 22px; background: #3d2a1873; }
.modal[hidden] { display: none; }
.modal-box { width: 100%; max-width: 720px; max-height: 90vh; display: flex; flex-direction: column; background: #fff; border-radius: 16px; box-shadow: 0 24px 60px #3d2a1840; overflow: hidden; }
.modal-box.narrow { max-width: 520px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 17px; }
.modal-head .sub { margin: 4px 0 0; font-size: 12.5px; color: var(--muted); }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 18px; border-top: 1px solid var(--line); background: #fdf8f2; }
.close-x { border: 0; background: transparent; font-size: 22px; line-height: 1; color: var(--muted); width: 34px; height: 34px; border-radius: 8px; }
.close-x:hover { background: #f7ede2; color: #3a2a1b; }

/* 定位弹窗 */
.loc-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.loc-cell { background: #fdf7f0; border-radius: 10px; padding: 10px 12px; min-width: 0; }
.loc-cell .k { font-size: 11.5px; color: var(--muted); }
.loc-cell .v { margin: 4px 0 0; font-weight: 600; font-size: 15px; overflow-wrap: anywhere; }
.loc-address { margin: 0 0 14px; font-size: 13px; color: #5b4630; }
/* 定位弹窗里的说明行：原始上报值、间隔来源 */
#modal-location .section-note { margin: 0 0 10px; font-size: 12.5px; line-height: 1.5; color: var(--muted); }
#modal-location .section-note[id$="-source"] { padding-left: 9px; border-left: 3px solid #e2c9a8; color: #7a6449; }
.map-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.map-toolbar .hint { font-size: 12px; color: var(--muted); }
#loc-crs.error, #loc-status.error { color: var(--warn); }
#loc-status { margin: 0 0 8px; }

.loc-diag { margin: 0 0 14px; padding: 10px 12px; border: 1px dashed #e2c9a8; border-radius: 10px; background: #fdf8f1; }
.loc-diag p { margin: 0 0 4px; font-size: 12px; line-height: 1.55; color: #6b5640; word-break: break-all; }
.loc-diag p:last-child { margin-bottom: 0; }
#map-fallback { display: flex; flex-direction: column; align-items: center; gap: 10px; }
#location-map { width: 100%; height: 360px; border-radius: 12px; border: 1px solid var(--line); background: #f5ece0; }
#map-fallback { margin: 0; padding: 26px 16px; text-align: center; color: var(--muted); font-size: 14px; background: #fdf7f0; border: 1px dashed var(--line); border-radius: 12px; }
.map-info { font: 13px/1.7 Inter, "Microsoft YaHei", sans-serif; color: #3a2a1b; padding: 2px 4px; min-width: 130px; }
.map-info b { display: block; font-size: 13.5px; margin-bottom: 3px; }
.map-info span { display: block; overflow-wrap: anywhere; }
.loc-stage { margin: 12px 0 0; font-size: 13px; color: var(--muted); min-height: 20px; }
.loc-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }

/* 设备设置弹窗 */
.settings-section { border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin-bottom: 16px; }
.settings-section:last-of-type { margin-bottom: 0; }
.settings-section h3 { display: flex; align-items: center; gap: 9px; margin: 0 0 4px; font-size: 15px; }
.settings-section .section-note { margin: 0 0 12px; font-size: 12.5px; color: var(--muted); }
.settings-section code { font-family: Consolas, ui-monospace, Menlo, monospace; font-size: 12px; color: #7a4a12; background: #f6ead9; border-radius: 4px; padding: 1px 5px; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
/* 勾选项（自动接听）：占一格，与输入框同高，说明文字跟在下方 */
.check-field { display: flex; flex-direction: column; justify-content: center; gap: 4px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px; background: #fdfaf5; }
.check-line { display: flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 600; color: #4a3826; cursor: pointer; }
.check-line input[type="checkbox"] { width: 17px; height: 17px; margin: 0; accent-color: var(--brand); cursor: pointer; }
.check-hint { margin: 0; font-size: 11.5px; line-height: 1.45; color: var(--muted); }
/* 定位弹窗：主动上报间隔一行 */
.interval-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0 0 6px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fdf7f0; }
.interval-row label { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: #4a3826; }
.inline-field { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.interval-row input[type="number"] { width: 82px; margin: 0; text-align: right; }
.interval-row .section-status { flex: 1 1 100%; }
.section-actions { display: flex; align-items: center; gap: 12px; margin-top: 14px; flex-wrap: wrap; }
.section-status { margin: 0; font-size: 12.5px; color: var(--muted); overflow-wrap: anywhere; }
.section-status.error { color: var(--warn); }
.sos-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
/* 分组管理面板里「设备归属」与「sos_numbers 号码」是两件事，用细线分开 */
.sos-divider { border: 0; border-top: 1px dashed rgba(0, 0, 0, .12); margin: 18px 0 12px; }
.sos-row { display: flex; align-items: center; gap: 10px; }
.sos-row input { margin: 0; }
.sos-index { width: 22px; height: 22px; flex-shrink: 0; border-radius: 50%; background: var(--brand); color: #fff; font-size: 12px; font-weight: 700; display: grid; place-items: center; }
.sos-row .text-button { color: var(--muted); }

/* SIP_CC：一行 = 对端 SIP 账号 + 手机号。
   用 grid 固定三列，保证多行之间「账号」「号码」严格对齐——用户要对着看配对关系，
   参差不齐会直接影响判断。1fr 1.1fr 分别给账号和号码，号码长一点所以略宽。 */
.sos-head,
.sos-row-dual {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) minmax(0, 1.1fr) auto;
  align-items: center;
  gap: 8px;
}
.sos-head { margin: 2px 0 6px; font-size: 12px; color: var(--muted); }
.sos-head-index { text-align: center; }
.sos-head-cell { font-weight: 600; letter-spacing: .2px; }
.sos-head-tail { width: 40px; }
.sos-row-dual .sos-peer { min-width: 0; }
.sos-row-dual .sos-phone { min-width: 0; }
/* 箭头只做视觉引导，很窄；小屏下隐藏，避免挤压输入框 */
.sos-arrow { display: none; color: #a9b6ae; font-size: 12px; text-align: center; }
@media (max-width: 560px) {
  .sos-head { display: none; }
  .sos-row-dual { grid-template-columns: 22px minmax(0, 1fr) auto; row-gap: 6px; }
  .sos-row-dual .sos-peer { grid-column: 2 / 4; }
  .sos-row-dual .sos-phone { grid-column: 2 / 3; }
  .sos-row-dual .text-button { grid-column: 3 / 4; }
}

/* 「按设备回填」的来源说明：与普通说明区分开，用左侧色条提示这是本机/设备数据来源 */
.settings-section .section-note[id$="-source"] { padding-left: 9px; border-left: 3px solid #e2c9a8; color: #7a6449; }

/* 设备上报记录（诊断） */
.diag-list { display: grid; gap: 8px; margin-top: 12px; max-height: 320px; overflow: auto; }
.diag-list > p { margin: 0; font-size: 12.5px; color: var(--muted); }
.diag-item { border: 1px solid var(--line); border-radius: 10px; background: #fffaf3; padding: 9px 11px; }
.diag-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 12px; }
.diag-ct { color: var(--muted); }
.diag-tag { background: #f6ead9; color: #7a4a12; border-radius: 999px; padding: 1px 8px; font-size: 11.5px; font-weight: 600; }
.diag-cmd { font-family: Consolas, ui-monospace, Menlo, monospace; font-size: 12px; font-weight: 700; color: var(--brand); }
.diag-raw {
  margin: 7px 0 0; padding: 0; white-space: pre-wrap; overflow-wrap: anywhere;
  font-family: Consolas, ui-monospace, Menlo, monospace; font-size: 11.5px; line-height: 1.5; color: #5b4630;
}
/* 分包上报的分片标记与分片内容（分片本身读不出 cmd，单独标出来便于核对） */
.diag-part { background: #e3edf7; color: #1d4e7a; border-radius: 999px; padding: 1px 8px; font-size: 11.5px; font-weight: 600; }
.diag-raw.frag { margin-top: 4px; padding-left: 8px; border-left: 2px solid #e8d6bd; color: #6b5334; }

/* 音量调节：名称 + 进度条 + 数值 */
.volume-grid { display: grid; gap: 14px; }
.volume-row { display: grid; grid-template-columns: 74px minmax(0, 1fr) 46px; align-items: center; gap: 12px; font-weight: 600; }
.volume-name { font-size: 13px; color: #5b4630; }
.volume-value { font-family: Consolas, ui-monospace, Menlo, monospace; font-size: 15px; font-weight: 700; color: var(--brand); text-align: right; }
input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 24px; min-height: 24px; margin: 0; padding: 0;
  background: transparent; border: 0; border-radius: 0; cursor: pointer;
}
input[type="range"]:focus { outline: 2px solid #f3c48f; outline-offset: 4px; }
input[type="range"]::-webkit-slider-runnable-track {
  height: 10px; border-radius: 999px; background-color: #f1e0cb;
  background-image: linear-gradient(var(--brand), var(--brand));
  background-repeat: no-repeat; background-size: var(--fill, 0%) 100%;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 22px; height: 22px; margin-top: -6px; border-radius: 50%;
  background: #fff; border: 3px solid var(--brand); box-shadow: 0 1px 4px rgba(120, 70, 20, .35);
}
input[type="range"]::-moz-range-track { height: 10px; border-radius: 999px; background: #f1e0cb; }
input[type="range"]::-moz-range-progress { height: 10px; border-radius: 999px; background: var(--brand); }
input[type="range"]::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%; background: #fff;
  border: 3px solid var(--brand); box-shadow: 0 1px 4px rgba(120, 70, 20, .35);
}

/* 登录页 */
.login { min-height: 100vh; display: grid; grid-template-columns: 1.05fr .95fr; background: #fffdfa; }
.login-story { padding: 48px 7%; color: #fff; background: #4a2f17; display: flex; flex-direction: column; justify-content: space-between; gap: 30px; }
.login-story .brand { color: #fff; }
.login-story h1 { font-size: clamp(30px, 4vw, 48px); line-height: 1.25; margin: 18px 0; }
.login-story p { color: #e6d3bb; }
.login-story .eyebrow { font-size: 12px; letter-spacing: 1.8px; font-weight: 700; color: #f0b978; margin-bottom: 8px; }
.login-story small { color: #c8ae90; }
.login-flow { display: flex; gap: 14px; align-items: center; font-size: 14px; color: #ecdcc4; flex-wrap: wrap; }
.login-form { display: flex; align-items: center; justify-content: center; padding: 40px 7%; }
.login-box { width: 100%; max-width: 380px; }
.login-icon { width: 46px; height: 46px; border-radius: 13px; background: #fbeee0; color: var(--brand); display: grid; place-items: center; font-size: 22px; margin-bottom: 14px; }
.login-box p { color: var(--muted); font-size: 14px; }
.login-box .notice { margin: 16px 0; }
.login-note { font-size: 12.5px; color: var(--muted); margin-top: 16px; }

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
  .login { grid-template-columns: 1fr; }
  .login-story { min-height: auto; padding: 30px 8%; }
  .login-story h1 { font-size: 30px; }
  .login-form { padding: 30px 8% 48px; }
  /* 窄屏：左侧导航折叠为顶部横向标签 */
  .shell { flex-direction: column; }
  .sidenav {
    position: static; flex: none; flex-direction: row; width: 100%;
    padding: 12px 14px 0; gap: 8px; overflow-x: auto;
  }
  .sidenav-item { white-space: nowrap; }
}
@media (max-width: 640px) {
  h1 { font-size: 22px; }
  .topbar { height: auto; padding: 10px 14px; flex-wrap: wrap; }
  main { padding: 16px 14px; }
  .device-grid { grid-template-columns: 1fr; }
  .device-actions { grid-template-columns: 1fr; }
  .device-foot { flex-direction: column; align-items: flex-start; }
  .device-status { text-align: left; }
  .modal { padding: 10px; align-items: flex-end; }
  .modal-box { max-height: 93vh; border-radius: 16px 16px 6px 6px; }
  .loc-grid { grid-template-columns: 1fr 1fr; }
  .field-grid { grid-template-columns: 1fr; }
  .volume-row { grid-template-columns: 62px minmax(0, 1fr) 40px; gap: 9px; }
  #location-map { height: 52vh; min-height: 260px; }
  .toolbar input[type="search"] { width: 100%; }
  .toolbar { width: 100%; }
  .project-label select { min-width: 0; flex: 1; }
  .group-actions { margin-left: 0; flex-basis: 100%; }
  .group-device .group-more { margin-left: 0; }
  .ctx-menu { min-width: 148px; }
}
@media (max-width: 380px) {
  .loc-grid { grid-template-columns: 1fr; }
  .stat { gap: 10px; }
  .stat-label { font-size: 12px; }
}

/* ================= 通话记录弹窗 =================
 * 8 列（时间/方向/主叫/被叫/客户名/状态/时长/录音），默认 720px 会挤成一团，
 * 所以这个弹窗单独放宽；表格仍包在 .table-wrap 里，窄屏横向滚动而不是溢出页面。
 */
.modal-box.wide { max-width: 1040px; }

.calls-filter {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 12px;
  margin-bottom: 12px;
}
.calls-field {
  display: flex; flex-direction: column; gap: 4px; margin: 0;
  font-size: 12px; color: var(--muted); letter-spacing: .02em;
}
.calls-field input, .calls-field select { width: auto; min-width: 128px; margin: 0; }
.calls-field input#calls-ext { min-width: 158px; font-family: Consolas, ui-monospace, Menlo, monospace; }

/* 快捷区间：小圆角胶囊，选中态用品牌色实心 */
.calls-quick { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.calls-quick button {
  min-height: 34px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--line); background: #fff; color: #5d4a38;
  font-size: 13px; font-weight: 600;
}
.calls-quick button:hover { background: #fdf3e7; }
.calls-quick button[aria-pressed="true"] {
  background: var(--brand); border-color: var(--brand); color: #fff;
}

/* 翻页条：数据不满一页时整体隐藏。
 * 注意必须显式写 [hidden]：下面的 display:flex 优先级高于浏览器对 hidden 的
 * display:none 兜底，不写这条的话 hidden 属性会失效（截图实测踩过）。 */
.calls-pager { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 14px; }
.calls-pager[hidden] { display: none; }
.calls-pager #calls-page-info { font-size: 13px; color: var(--muted); }

/* 方向标识：呼入偏蓝、呼出偏绿，与「状态」列的颜色语义区分开 */
.call-dir { white-space: nowrap; font-weight: 600; }
.call-dir.in { color: #2a5f97; }
.call-dir.out { color: #2f7d4f; }

/* 状态：已接通绿、未接通用告警色；中文原因是主文案，英文枚举放 title */
.call-state { white-space: nowrap; font-weight: 600; }
.call-state.ok { color: var(--ok); }
.call-state.miss { color: var(--warn); }

/* 录音展开行：整行是一条浅底容器，内部按条竖排播放器 */
.calls-rec-row > td { background: #fffaf3; padding: 0; border-bottom: 1px solid var(--line); }
.calls-rec { padding: 12px 14px; display: grid; gap: 10px; }
.calls-rec-item { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.calls-rec-item audio { height: 34px; max-width: 100%; }
.calls-rec-item .calls-rec-meta { margin: 0; font-size: 12px; color: var(--muted); }
.calls-rec .calls-rec-hint { margin: 0; font-size: 12px; color: var(--muted); }

#calls-table td { white-space: nowrap; }
#calls-table td.calls-name { white-space: normal; min-width: 96px; }

@media (max-width: 640px) {
  .calls-filter { gap: 8px 10px; }
  .calls-field { flex: 1 1 132px; }
  .calls-field input, .calls-field select { width: 100%; min-width: 0; }
  .calls-filter > .btn { flex: 1 1 100%; }
  .calls-rec-item audio { width: 100%; }
}
