/* 公共样式：设计变量 · 基础重置 · 通用组件（暖色调） */
:root {
  font-family: Inter, "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  font-size: 16px;
  color: #3a2a1b;
  background: #faf5ee;
  --brand: #b4530a;
  --brand-dark: #8f4108;
  --brand-soft: #fff4e6;
  --muted: #8d7a67;
  --line: #eee0d0;
  --ok: #2f8a52;
  --warn: #b3341f;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(120, 70, 20, .06), 0 10px 28px rgba(120, 70, 20, .08);
  --space: 18px;
}

* { box-sizing: border-box; }
body { margin: 0; }
body.modal-open { overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .5; }
button, a, input, select, textarea { outline-offset: 3px; }
a { color: var(--brand); text-decoration: none; }
p { line-height: 1.7; }
h1, h2, h3, p, dl, dd, dt { margin-top: 0; }
h1 { font-size: 26px; letter-spacing: -.4px; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
small, .muted { color: var(--muted); }
.mono { font-family: Consolas, ui-monospace, Menlo, monospace; }

/* 按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 38px; padding: 8px 14px; border-radius: 9px;
  border: 1px solid var(--line); background: #fff; color: #4a3826;
  font-size: 14px; font-weight: 600; white-space: nowrap;
}
.btn:hover:not(:disabled) { background: #fdf3e7; border-color: #e8d3ba; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn.ghost { background: #fdf7f0; border-color: var(--line); }
.btn.danger { background: #fff; border-color: #e3b1a5; color: #a52d1a; }
.btn.danger:hover:not(:disabled) { background: #fdf0ed; border-color: #d6907f; }
.btn.wide { width: 100%; min-height: 46px; }
/* 卡片内的小按钮（如「播报电量」）：与统计行同高，不抢视觉重心 */
.btn.tiny { min-height: 26px; padding: 2px 9px; font-size: 12px; border-radius: 7px; font-weight: 600; }
.text-button { border: 0; background: none; color: var(--brand); padding: 8px 0; font-size: 14px; }
.text-button:hover:not(:disabled) { text-decoration: underline; }

/* 表单 */
label { display: block; font-size: 13px; font-weight: 600; color: #5b4630; }
input, select, textarea {
  display: block; width: 100%; min-width: 0; padding: 10px 12px; margin-top: 6px;
  border: 1px solid #e0cfbb; border-radius: 8px; background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #f3c48f; border-color: var(--brand); }
textarea { resize: vertical; min-height: 92px; line-height: 1.6; }

/* 徽标 / 面板 */
.badge { font-size: 12px; padding: 4px 9px; background: #fbeee0; color: #8a4b16; border-radius: 999px; white-space: nowrap; }
.panel { border: 1px solid var(--line); background: #fff; border-radius: var(--radius); padding: 20px; margin-bottom: var(--space); }
.info { border: 1px solid #f4dcc0; background: #fff8ef; color: #7c4413; border-radius: 10px; padding: 12px 14px; font-size: 13px; line-height: 1.7; margin-bottom: var(--space); }
.info.error { border-color: #f0c9c2; background: #fff2ef; color: #8a2a1c; }

/* 启动自检：有 JS 文件没加载成功时，顶部直接说清楚，不留「点了没反应」 */
.boot-warning {
  border: 1px solid #efc0b9; border-left: 5px solid var(--warn);
  background: #fff8f7; color: #85251f; border-radius: 10px;
  padding: 12px 14px; font-size: 13.5px; line-height: 1.7;
  margin-bottom: var(--space); overflow-wrap: anywhere;
}
.boot-warning strong { display: block; margin-bottom: 4px; font-size: 14.5px; }

/* 设置弹窗顶部的「正在读取设备当前设置…」提示 */
#settings-progress { margin: 0 0 14px; color: var(--brand); font-weight: 600; }
#settings-progress.error { color: var(--warn); font-weight: 700; }

/* 通知（固定在视口上方，不阻塞操作） */#notice.notice-stack {
  position: fixed; top: max(24px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
  width: min(520px, calc(100vw - 32px)); z-index: 1000; display: flex; flex-direction: column;
  gap: 12px; max-height: calc(100dvh - 48px); overflow-y: auto; padding: 4px; margin: 0;
  border: 0; background: transparent; box-shadow: none; pointer-events: none;
}
.notice-popup {
  pointer-events: auto; display: flex; align-items: flex-start; gap: 12px; padding: 18px 14px 18px 18px;
  background: #fff; border: 1px solid #f2dcc0; border-left: 5px solid var(--brand); border-radius: 12px;
  box-shadow: 0 12px 40px #6b4a2030; color: #4a3826; font-size: 15px; line-height: 1.6;
  animation: notice-enter .18s ease-out;
}
.notice-popup.error { background: #fff8f7; border-color: #efc0b9; border-left-color: var(--warn); color: #85251f; }
.notice-icon { flex-shrink: 0; display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: #fdeedb; color: #a8550f; font-weight: 700; }
.notice-popup.error .notice-icon { background: #fce0db; color: #b02921; }
.notice-content { flex: 1; min-width: 0; }
.notice-content strong { font-size: 16px; }
.notice-content p { margin: 5px 0 0; overflow-wrap: anywhere; white-space: pre-wrap; }
.notice-close { flex-shrink: 0; border: 0; background: transparent; color: inherit; font-size: 26px; line-height: 1; min-width: 36px; min-height: 36px; padding: 4px; border-radius: 6px; }
.notice-close:hover { background: #6b4a2012; }
@keyframes notice-enter { from { opacity: 0; translate: 0 -8px; } to { opacity: 1; translate: 0 0; } }
@media (prefers-reduced-motion: reduce) { .notice-popup { animation: none; } }
@media (max-width: 640px) { #notice.notice-stack { top: max(12px, env(safe-area-inset-top)); } .notice-popup { padding: 14px 10px; gap: 9px; } }

/* 表格 */
.table-wrap { overflow-x: auto; max-width: 100%; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; letter-spacing: .04em; color: var(--muted); padding: 10px 12px; background: #fdf7f0; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 11px 12px; border-bottom: 1px solid #f5e9dd; vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
td.empty { text-align: center; color: var(--muted); padding: 26px 12px; }
