:root {
    --bg: #f4f7fb;
    --panel: #ffffff;
    --line: #e5eaf1;
    --text: #0f172a;
    --muted: #64748b;
    --brand: #1d4ed8;
    --ok: #16a34a;
    --off: #64748b;
    --sidebar: #0f172a;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; color: var(--text); background: var(--bg); }

.app-shell { display: flex; min-height: 100%; }
.sidebar {
    width: 240px;
    background: var(--sidebar);
    color: #fff;
    display: flex;
    flex-direction: column;
    padding: 20px 16px;
    position: sticky;
    top: 0;
    height: 100vh;
}
.brand { display: flex; gap: 12px; align-items: center; margin-bottom: 28px; }
.brand-mark {
    width: 40px; height: 40px; border-radius: 12px;
    background: #2563eb; display: grid; place-items: center; font-weight: 700;
    font-size: 11px; letter-spacing: 0.02em;
}
.brand small { display: block; color: #94a3b8; font-size: 12px; }
.nav { display: flex; flex-direction: column; gap: 6px; flex: 1; }
.nav a {
    color: #cbd5e1; text-decoration: none; padding: 10px 12px; border-radius: 10px;
}
.nav a.active, .nav a:hover { background: #1e293b; color: #fff; }
.logout { border-top: 1px solid #1e293b; padding-top: 14px; }
.user-chip { color: #94a3b8; margin-bottom: 8px; font-size: 13px; }
.logout button, .toolbar button, form button, .ghost {
    border: 0; background: #2563eb; color: #fff; border-radius: 10px;
    padding: 10px 14px; cursor: pointer; font-size: 14px;
}
.logout button { width: 100%; background: #334155; }
.main { flex: 1; padding: 24px; min-width: 0; }
.page-head { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; margin-bottom: 18px; }
.page-head h1 { margin: 0 0 6px; font-size: 24px; }
.page-head p, .muted { color: var(--muted); margin: 0; font-size: 13px; }
.stat-row { display: flex; gap: 10px; flex-wrap: wrap; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; min-width: 110px; }
.stat b { display: block; font-size: 18px; }
.stat span { color: var(--muted); font-size: 12px; }
.stat.online b { color: var(--ok); }
.map-wrap { display: grid; grid-template-columns: 1fr 280px; gap: 12px; height: calc(100vh - 160px); }
#panorama-map, #device-map { height: 100%; min-height: 420px; border-radius: 16px; border: 1px solid var(--line); }
.map-side, .panel, .table-card, .login-card {
    background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
}
.map-side { overflow: auto; padding: 12px; }
.side-title { font-weight: 700; margin-bottom: 10px; }
.side-item { display: flex; gap: 10px; padding: 10px; border-radius: 10px; text-decoration: none; color: inherit; }
.side-item:hover { background: #f1f5f9; }
.side-item small { display: block; color: var(--muted); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--off); margin-top: 6px; flex: none; }
.dot.on { background: var(--ok); }
.toolbar { display: flex; gap: 8px; margin-bottom: 14px; }
.toolbar input, .toolbar select, form input, form select {
    border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: 14px;
}
.toolbar input { flex: 1; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); font-size: 14px; vertical-align: top; }
.mono { font-family: Consolas, monospace; font-size: 12px; }
.badge { display: inline-block; padding: 3px 8px; border-radius: 999px; font-size: 12px; background: #e2e8f0; }
.badge.ok { background: #dcfce7; color: #166534; }
.badge.off { background: #e2e8f0; color: #475569; }
.badge.warn { background: #fef3c7; color: #92400e; }
.actions a { color: var(--brand); }
.split { display: grid; grid-template-columns: 320px 1fr; gap: 16px; align-items: start; }
.panel { padding: 18px; }
.panel.grow { min-width: 0; }
.panel.narrow { max-width: 520px; }
.panel h2 { margin: 0 0 12px; font-size: 16px; }
form label { display: block; margin-bottom: 12px; font-size: 13px; color: var(--muted); }
form label input { width: 100%; margin-top: 6px; color: var(--text); }
.remember { display: flex; align-items: center; gap: 8px; }
.meta { display: grid; gap: 8px; margin-top: 16px; }
.meta dt { color: var(--muted); font-size: 12px; }
.meta dd { margin: 0; }
.track-bar { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.track-fields { display: flex; gap: 8px; flex-wrap: wrap; }
#device-map { height: calc(100vh - 280px); }
.flash { background: #dcfce7; color: #166534; padding: 10px 14px; border-radius: 10px; margin-bottom: 12px; }
.error { color: #b91c1c; margin: 8px 0; }
.danger, button.danger { background: #dc2626; }
.danger-form { margin-top: 12px; }
.ghost { background: #334155; }
.empty { color: var(--muted); padding: 24px; text-align: center; }
.user-pin { background: transparent; border: 0; }
.pin { width: 16px; height: 16px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 2px rgba(15,23,42,.2); }
.login-body { min-height: 100%; display: grid; place-items: center; background: linear-gradient(160deg, #0f172a, #1d4ed8); }
.login-card { width: 380px; padding: 32px; }
.login-card h1 { margin: 0 0 8px; }
.login-card p { color: var(--muted); margin: 0 0 20px; }
.pagination { margin-top: 16px; display: flex; gap: 12px; align-items: center; }
.pagination a { color: var(--brand); text-decoration: none; }

@media (max-width: 960px) {
    .app-shell { flex-direction: column; }
    .sidebar { width: 100%; height: auto; position: relative; }
    .nav { flex-direction: row; flex-wrap: wrap; }
    .map-wrap, .split { grid-template-columns: 1fr; height: auto; }
}
