:root {
  --bg:#f3f5f7; --panel:#fff; --line:#d7dde5; --text:#1f2933; --muted:#667085;
  --accent:#0b6bcb; --accent-soft:#e8f2ff; --ok:#0f8a45; --warn:#b54708; --bad:#b42318;
}
* { box-sizing:border-box; }
body { margin:0; font-family:system-ui,-apple-system,Segoe UI,sans-serif; background:var(--bg); color:var(--text); }
header { background:#17212b; color:#fff; padding:14px 20px; display:flex; align-items:center; justify-content:space-between; gap:14px; }
h1 { margin:0; font-size:19px; font-weight:650; }
h2 { margin:0; font-size:16px; }
h3 { margin:0 0 8px; font-size:14px; }
main { padding:16px 20px 28px; display:grid; gap:12px; }
button, input, select { font:inherit; }
button { border:1px solid var(--line); background:#fff; border-radius:6px; padding:7px 10px; cursor:pointer; color:var(--text); }
button.primary { background:var(--accent); border-color:var(--accent); color:#fff; }
button.text { border-color:transparent; background:transparent; color:var(--accent); padding:3px 4px; }
button.danger { color:var(--bad); }
input, select { border:1px solid var(--line); border-radius:6px; padding:7px 9px; background:#fff; min-width:120px; }
section { background:var(--panel); border:1px solid var(--line); border-radius:8px; padding:13px; }
.muted { color:var(--muted); }
.topline { display:flex; align-items:center; justify-content:space-between; gap:12px; flex-wrap:wrap; }
.userbar { display:flex; align-items:center; gap:8px; color:#d7dee8; font-size:13px; }
.tabs { display:flex; gap:6px; flex-wrap:wrap; }
.tabs button { border-color:transparent; background:transparent; }
.tabs button.active { background:var(--accent-soft); border-color:#b9d7ff; color:#064e99; }
.toolbar { display:flex; gap:8px; flex-wrap:wrap; align-items:center; }
.stats { display:grid; grid-template-columns:repeat(auto-fit, minmax(150px, 1fr)); gap:10px; }
.stat { background:#fff; border:1px solid var(--line); border-radius:8px; padding:11px; }
.stat strong { display:block; font-size:24px; margin-bottom:2px; }
.layout { display:grid; grid-template-columns:minmax(420px, 1.25fr) minmax(320px, .75fr); gap:12px; align-items:start; }
.hidden { display:none !important; }
.table-wrap { overflow:auto; border:1px solid var(--line); border-radius:8px; }
table { width:100%; border-collapse:collapse; font-size:13px; background:#fff; }
th, td { border-bottom:1px solid var(--line); padding:8px 7px; text-align:left; vertical-align:top; }
th { color:#475467; background:#f8fafc; font-weight:650; white-space:nowrap; }
tr:last-child td { border-bottom:none; }
.badge { display:inline-block; font-size:12px; line-height:18px; padding:0 7px; border-radius:999px; background:#eef2f7; color:#344054; white-space:nowrap; }
.badge.ok { background:#e8f7ee; color:var(--ok); }
.badge.warn { background:#fff5e6; color:var(--warn); }
.badge.bad { background:#fff0ed; color:var(--bad); }
.detail { display:grid; gap:10px; }
.kv { display:grid; grid-template-columns:96px 1fr; gap:5px 8px; font-size:13px; }
.kv .k { color:var(--muted); }
#mapFrame { width:100%; height:270px; border:1px solid var(--line); border-radius:8px; background:#eef2f7; }
.map-tools { display:flex; gap:8px; align-items:center; flex-wrap:wrap; margin:10px 0 8px; }
#trackCanvas { width:100%; aspect-ratio:16 / 9; display:block; border:1px solid var(--line); border-radius:8px; background:#eef2f7; cursor:pointer; }
.activity-timeline { display:grid; gap:8px; margin-top:8px; }
.activity-card { width:100%; border:1px solid var(--line); background:#fff; border-radius:8px; padding:9px 10px; display:grid; gap:6px; cursor:pointer; text-align:left; }
.activity-card:hover, .activity-card.active { border-color:#98c7ff; background:#f4f9ff; }
.activity-card-head { display:flex; align-items:center; justify-content:space-between; gap:8px; flex-wrap:wrap; font-size:13px; }
.activity-card-title { font-weight:650; }
.activity-card-meta { color:var(--muted); font-size:12px; line-height:1.45; }
.activity-bar { height:8px; border-radius:999px; background:#edf2f7; overflow:hidden; }
.activity-bar-fill { height:100%; border-radius:999px; background:var(--accent); min-width:2px; }
.history-legend { display:flex; gap:12px; align-items:center; flex-wrap:wrap; font-size:12px; color:var(--muted); }
.history-legend span { display:inline-flex; align-items:center; gap:5px; }
.history-dot { width:10px; height:10px; border-radius:999px; display:inline-block; background:#98a2b3; }
.history-dot.on { background:var(--ok); }
.history-dot.off { background:#98a2b3; }
pre { margin:0; overflow:auto; max-height:280px; background:#101828; color:#e6edf3; padding:10px; border-radius:8px; font-size:12px; }
.notice { padding:9px 10px; border:1px solid var(--line); border-radius:8px; background:#fbfcfe; font-size:13px; color:var(--muted); }
.modal-backdrop { position:fixed; inset:0; z-index:20; display:grid; place-items:center; padding:18px; background:rgba(15,23,42,.42); }
.modal-panel { width:min(680px, 100%); max-height:min(82vh, 760px); overflow:auto; background:var(--panel); border:1px solid var(--line); border-radius:8px; box-shadow:0 18px 45px rgba(15,23,42,.22); }
.modal-head { position:sticky; top:0; background:var(--panel); display:flex; align-items:center; justify-content:space-between; gap:12px; padding:14px 16px; border-bottom:1px solid var(--line); }
.icon-button { width:30px; height:30px; padding:0; font-size:20px; line-height:1; }
.modal-body { padding:14px 16px; display:grid; grid-template-columns:repeat(2, minmax(0, 1fr)); gap:12px; }
.form-field { display:grid; gap:6px; font-size:13px; color:#475467; }
.form-field.wide, .form-note { grid-column:1 / -1; }
.form-field input, .form-field select, .form-field textarea { width:100%; min-width:0; }
.form-field textarea { min-height:92px; resize:vertical; }
.form-field img.qr-img { width:180px; height:180px; border:1px solid var(--line); border-radius:8px; background:#fff; padding:8px; }
.form-field input[readonly] { color:#667085; background:#f8fafc; }
.form-field textarea[readonly] { color:#667085; background:#f8fafc; }
.form-help { color:var(--muted); font-size:12px; line-height:1.4; }
.form-note { padding:9px 10px; border:1px solid var(--line); border-radius:8px; background:#fbfcfe; color:var(--muted); font-size:13px; }
.modal-error { margin:0 16px 12px; padding:8px 10px; border:1px solid #fecdca; border-radius:8px; background:#fff0ed; color:var(--bad); font-size:13px; }
.modal-actions { position:sticky; bottom:0; background:var(--panel); display:flex; justify-content:flex-end; gap:8px; padding:12px 16px; border-top:1px solid var(--line); }
@media (max-width: 940px) { .layout { grid-template-columns:1fr; } header { align-items:flex-start; flex-direction:column; } }
@media (max-width: 640px) { .modal-body { grid-template-columns:1fr; } .modal-actions { justify-content:stretch; } .modal-actions button { flex:1; } }

body.login-page {
  margin: 0;
  min-height: 100vh;
  display: grid;
  place-items: center;
  font-family: system-ui, -apple-system, Segoe UI, sans-serif;
  background: var(--bg);
  color: var(--text);
}
.login-form {
  width: min(380px, calc(100vw - 32px));
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
  display: grid;
  gap: 13px;
}
.login-form h1 { margin: 0; font-size: 21px; }
.login-form p { margin: 0 0 6px; color: var(--muted); font-size: 13px; }
.login-form label { display: grid; gap: 6px; font-size: 13px; color: #475467; }
.login-form input,
.login-form button { font: inherit; border-radius: 6px; padding: 9px 10px; }
.login-form input { border: 1px solid var(--line); background: #fff; }
.login-form button { border: 1px solid var(--accent); background: var(--accent); color: #fff; cursor: pointer; }
.login-form #msg { min-height: 18px; color: var(--bad); font-size: 13px; }
