:root {
  --bg: #f3f6fb; --card: #ffffff; --line: #e3e8f0; --text: #1c2433; --text2: #6b7588;
  --primary: #1a6dff; --primary-soft: #e8f0ff; --ok: #10a36a; --ok-soft: #e4f6ee;
  --warn: #d98200; --warn-soft: #fff3df; --err: #e0413a; --err-soft: #fdeceb;
  --radius: 14px; --shadow: 0 1px 2px rgba(20, 40, 80, .06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11151c; --card: #1b212b; --line: #2a3240; --text: #e8ecf3; --text2: #98a2b3;
    --primary: #4b8dff; --primary-soft: #1d2b44; --ok: #35c48a; --ok-soft: #173327;
    --warn: #f0a33a; --warn-soft: #3a2c14; --err: #ff6b63; --err-soft: #3d1c1b; --shadow: none;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 15px/1.5 -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; -webkit-text-size-adjust: 100%; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
button:disabled { opacity: .45; cursor: default; }
input { font: inherit; }
h1 { font-size: 22px; margin: 12px 0 2px; }
.muted { color: var(--text2); }
.small { font-size: 13px; }
.strong { font-weight: 600; }
.center { text-align: center; }
.error { color: var(--err); font-size: 14px; margin: 4px 0 0; }
.boot { min-height: 100vh; display: flex; align-items: center; justify-content: center; color: var(--text2); }

/* 按钮 */
.primary { background: var(--primary); color: #fff; border-radius: 10px; padding: 9px 16px; font-weight: 600; }
.primary.big { padding: 12px 20px; font-size: 16px; border-radius: 12px; min-width: 112px; }
.primary.stop { background: var(--err); }
.wide { width: 100%; padding: 12px; margin-top: 8px; font-size: 16px; }
.ghost { color: var(--text2); padding: 9px 16px; border-radius: 10px; }
.outline { border: 1px solid var(--line); border-radius: 9px; padding: 6px 12px; font-size: 14px; background: var(--card); }
.outline.accent { color: var(--primary); border-color: var(--primary); }
.danger-outline { color: var(--err); border: 1px solid var(--err); border-radius: 9px; padding: 7px 14px; }
.link { color: var(--primary); padding: 8px 0 0; font-size: 14px; }

/* 登录 */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 360px; background: var(--card); border-radius: 18px; padding: 28px 22px; box-shadow: var(--shadow); text-align: center; }
.login-logo { width: 64px; height: 64px; border-radius: 16px; }
.login form { text-align: left; margin-top: 18px; }
.login label { display: block; font-size: 13px; color: var(--text2); margin-top: 12px; }
.login input { display: block; width: 100%; margin-top: 4px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); color: var(--text); font-size: 16px; }
.login input:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }

/* 框架 */
.app { min-height: 100vh; padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: var(--bg); }
.topbar-title { font-size: 20px; font-weight: 700; }
.topbar-state { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text2); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text2); }
.topbar-state.ok .dot { background: var(--ok); }
.topbar-state.err .dot { background: var(--err); }
main { padding: 0 16px 16px; }
.section { font-size: 14px; color: var(--text2); font-weight: 600; margin: 20px 2px 8px; }
.hint { margin: 0 2px 10px; }
.card { background: var(--card); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); margin-bottom: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.label { font-size: 13px; color: var(--text2); }

/* 总览 */
.monitor-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.monitor-state { font-size: 24px; font-weight: 700; margin-top: 2px; }
.monitor-state.ok { color: var(--ok); }
.monitor-state.warn { color: var(--warn); }
.monitor-state.err { color: var(--err); }
.offline-note { margin-top: 10px; padding: 8px 10px; border-radius: 10px; background: var(--err-soft); color: var(--err); font-size: 14px; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile { background: var(--card); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); text-align: left; min-width: 0; }
.tile .value { font-size: 18px; font-weight: 700; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile .small-value { font-size: 14px; font-weight: 600; white-space: normal; }
.value.ok { color: var(--ok); } .value.warn { color: var(--warn); } .value.err { color: var(--err); }
.tile-link { position: relative; }
.tile-link::after { content: "›"; position: absolute; right: 12px; top: 10px; color: var(--text2); font-size: 18px; }

.list { display: flex; flex-direction: column; gap: 10px; }
.empty { text-align: center; color: var(--text2); font-size: 14px; padding: 18px 0; }
.alert { display: flex; gap: 10px; background: var(--err-soft); border-radius: 12px; padding: 10px 12px; }
.alert .alert-title { font-weight: 600; color: var(--err); }
.alert .alert-body { font-size: 13px; color: var(--text); }
.command { display: flex; justify-content: space-between; gap: 10px; background: var(--card); border-radius: 12px; padding: 10px 12px; box-shadow: var(--shadow); }
.command .command-text { min-width: 0; }
.command .command-label { font-weight: 600; overflow-wrap: anywhere; }
.command .command-message { font-size: 13px; color: var(--text2); overflow-wrap: anywhere; }

/* 记录 */
.segmented { display: flex; background: var(--line); border-radius: 10px; padding: 3px; margin-bottom: 12px; }
.segmented button { flex: 1; padding: 7px 0; border-radius: 8px; font-size: 14px; color: var(--text2); }
.segmented button.on { background: var(--card); color: var(--text); font-weight: 600; box-shadow: var(--shadow); }
.record { background: var(--card); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); }
.record.problem { box-shadow: inset 3px 0 0 var(--err), var(--shadow); }
.record-head { display: flex; justify-content: space-between; gap: 8px; }
.record-title { font-weight: 600; overflow-wrap: anywhere; }
.record-time { font-size: 13px; color: var(--text2); white-space: nowrap; }
.record-meta { font-size: 13px; color: var(--text2); margin-top: 2px; overflow-wrap: anywhere; }
.record-content { margin-top: 8px; font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; display: -webkit-box;
  -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.record-content.open { display: block; }
.more { color: var(--primary); font-size: 13px; padding: 2px 0 0; }
.task { border-top: 1px solid var(--line); margin-top: 10px; padding-top: 10px; }
.task-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.task-label { font-size: 14px; min-width: 0; overflow-wrap: anywhere; }
.task-detail { font-size: 12px; color: var(--text2); margin-top: 4px; white-space: pre-wrap; overflow-wrap: anywhere; }
.task-actions { display: flex; gap: 8px; margin-top: 8px; }
.chip { flex: none; font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--line); color: var(--text2); white-space: nowrap; }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.err { background: var(--err-soft); color: var(--err); }

/* 定时 */
.schedule { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--card);
  border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); }
.schedule-name { font-weight: 600; overflow-wrap: anywhere; }
.schedule-when { font-size: 13px; color: var(--text2); overflow-wrap: anywhere; }
.switch { flex: none; width: 50px; height: 30px; border-radius: 15px; background: var(--line); position: relative; transition: background .2s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .2s; }
.switch.on { background: var(--ok); }
.switch.on::after { transform: translateX(20px); }
.switch.waiting { opacity: .6; }

/* 底部导航 */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: flex; background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom); }
.tabbar button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 7px 0 6px; font-size: 11px;
  color: var(--text2); position: relative; }
.tabbar button.on { color: var(--primary); }
.badge { display: inline-block; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--err); color: #fff;
  font-size: 11px; line-height: 18px; text-align: center; margin-left: 4px; }
.tabbar .badge { position: absolute; top: 3px; left: calc(50% + 6px); margin: 0; }
.ico { width: 24px; height: 24px; background: currentColor; -webkit-mask: var(--m) center / 24px no-repeat; mask: var(--m) center / 24px no-repeat; }
.ico-home { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4 10.5 12 4l8 6.5V20a1 1 0 0 1-1 1h-5v-6h-4v6H5a1 1 0 0 1-1-1z'/%3E%3C/svg%3E"); }
.ico-list { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4 5h16v2H4zm0 6h16v2H4zm0 6h10v2H4z'/%3E%3C/svg%3E"); }
.ico-clock { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20zm1 10.4 3.5 2.1-1 1.7L11 13V7h2z'/%3E%3C/svg%3E"); }
.ico-gear { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M19.4 13a7.6 7.6 0 0 0 0-2l2.1-1.6-2-3.4-2.5 1a7 7 0 0 0-1.7-1L15 3h-4l-.4 2.6a7 7 0 0 0-1.7 1l-2.5-1-2 3.4L6.6 11a7.6 7.6 0 0 0 0 2l-2.1 1.6 2 3.4 2.5-1a7 7 0 0 0 1.7 1L11 21h4l.4-2.6a7 7 0 0 0 1.7-1l2.5 1 2-3.4zM13 15.5a3.5 3.5 0 1 1 0-7 3.5 3.5 0 0 1 0 7z'/%3E%3C/svg%3E"); }

/* 确认框、提示 */
.sheet { position: fixed; inset: 0; z-index: 20; background: rgba(10, 20, 40, .4); display: flex; align-items: flex-end; justify-content: center; }
.sheet-card { width: 100%; max-width: 480px; background: var(--card); border-radius: 18px 18px 0 0; padding: 20px 18px calc(16px + env(safe-area-inset-bottom)); }
.sheet-title { font-size: 17px; font-weight: 700; }
.sheet-text { margin-top: 8px; color: var(--text2); font-size: 14px; white-space: pre-wrap; }
.sheet-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.sheet-actions .primary.danger { background: var(--err); }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 30;
  max-width: calc(100% - 32px); background: rgba(28, 36, 51, .92); color: #fff; padding: 10px 14px; border-radius: 12px; font-size: 14px; }
