:root {
    --bg: #0f172a;
    --card: #1e293b;
    --muted: #94a3b8;
    --text: #f1f5f9;
    --accent: #38bdf8;
    --accent2: #a78bfa;
    --ok: #34d399;
    --err: #f87171;
    --border: #334155;
}
* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, sans-serif;
    background: radial-gradient(1200px 600px at 10% -10%, #312e81 0%, transparent 50%), var(--bg);
    color: var(--text);
    min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.shell { max-width: 1100px; margin: 0 auto; padding: 16px 14px 48px; }
.topbar {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; flex-wrap: wrap;
    padding: 12px 16px; background: rgba(30,41,59,.85); backdrop-filter: blur(10px);
    border-radius: 14px; border: 1px solid var(--border); margin-bottom: 18px;
}
.topbar h1 { margin: 0; font-size: 1.1rem; font-weight: 800; letter-spacing: -0.02em; }
.nav { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.nav a.btn-link { padding: 8px 12px; border-radius: 10px; background: #334155; color: var(--text); font-weight: 600; font-size: 0.88rem; }
.nav a.btn-link:hover { background: #475569; text-decoration: none; }
.card {
    background: var(--card); border: 1px solid var(--border); border-radius: 16px;
    padding: 18px 20px; margin-bottom: 16px;
}
.card h2 { margin: 0 0 12px; font-size: 1rem; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 12px 18px; border-radius: 12px; border: none; font-weight: 700;
    cursor: pointer; font-size: 0.95rem;
}
.btn.primary { background: linear-gradient(135deg, var(--accent), #0284c7); color: #0f172a; }
.btn.secondary { background: #334155; color: var(--text); }
.btn.danger { background: #7f1d1d; color: #fff; }
.btn.ghost { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn.block { width: 100%; }
label { display: block; font-size: 0.8rem; font-weight: 700; color: var(--muted); margin-bottom: 6px; }
input, select, textarea {
    width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--border);
    background: #0f172a; color: var(--text); font-size: 1rem; margin-bottom: 14px;
}
textarea { min-height: 80px; resize: vertical; }
.table-wrap { overflow-x: auto; border-radius: 12px; border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); }
th { background: #0f172a; color: var(--muted); font-size: 0.72rem; text-transform: uppercase; letter-spacing: .05em; }
tr:last-child td { border-bottom: none; }
.muted { color: var(--muted); font-size: 0.88rem; }
.kpi {
    font-size: 1.8rem; font-weight: 900; background: linear-gradient(90deg, var(--accent), var(--accent2));
    -webkit-background-clip: text; background-clip: text; color: transparent;
}
.alert { padding: 12px 14px; border-radius: 12px; margin-bottom: 14px; font-weight: 600; }
.alert.err { background: rgba(248,113,113,.15); border: 1px solid var(--err); color: #fecaca; }
.alert.ok { background: rgba(52,211,153,.12); border: 1px solid var(--ok); color: #a7f3d0; }
.auth-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.auth-card {
    width: 100%; max-width: 420px; background: var(--card); border: 1px solid var(--border);
    border-radius: 20px; padding: 28px;
}
.auth-card h1 { margin: 0 0 8px; font-size: 1.5rem; }
.device-grid { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 560px) {
    .device-grid { grid-template-columns: repeat(2, 1fr); }
}
.device-tile {
    display: block; padding: 18px; border-radius: 14px; border: 1px solid var(--border);
    background: linear-gradient(145deg, #1e293b, #0f172a); color: var(--text);
    text-decoration: none; transition: transform .12s, border-color .12s;
}
.device-tile:hover { transform: translateY(-2px); border-color: var(--accent); text-decoration: none; }
.device-tile strong { display: block; font-size: 1.05rem; margin-bottom: 6px; }
.bar-fill {
    height: 10px; border-radius: 999px; background: #334155; overflow: hidden; margin-top: 8px;
}
.bar-fill > i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2)); border-radius: 999px; }
.pill { display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: 0.75rem; font-weight: 800; background: #334155; }

.tabs-bar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 14px;
}
.tab-btn {
    padding: 10px 16px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: #0f172a;
    color: var(--text);
    font-weight: 700;
    cursor: pointer;
    font-size: 0.88rem;
}
.tab-btn:hover {
    border-color: var(--accent);
}
.tab-btn.active {
    background: linear-gradient(135deg, var(--accent), #0284c7);
    color: #0f172a;
    border-color: transparent;
}
.tab-panel {
    display: none !important;
}
.tab-panel.is-visible {
    display: block !important;
}
