:root {
    color-scheme: dark;
    --bg: #050711;
    --panel: #0f1726;
    --panel-2: #152033;
    --line: #26344f;
    --text: #eef5ff;
    --muted: #9eb0c8;
    --cyan: #34d3ff;
    --green: #35f2a0;
    --red: #ff5570;
    --yellow: #ffd166;
    --shadow: 0 24px 70px rgba(0,0,0,.34);
}
* { box-sizing: border-box; }
body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(circle at 12% 0%, rgba(52,211,255,.16), transparent 30%),
        radial-gradient(circle at 90% 10%, rgba(53,242,160,.10), transparent 26%),
        linear-gradient(180deg, #060916 0%, var(--bg) 100%);
    color: var(--text);
    font: 15px/1.5 system-ui, -apple-system, Segoe UI, sans-serif;
}
a { color: inherit; text-decoration: none; }
.shell { min-height: 100vh; display: flex; }
.sidebar {
    width: 272px;
    padding: 24px 18px;
    border-right: 1px solid var(--line);
    background: rgba(8, 12, 23, .92);
    backdrop-filter: blur(18px);
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}
.brand { display: grid; grid-template-columns: 18px 1fr; align-items: center; gap: 8px 10px; font-weight: 800; letter-spacing: 0; }
.brand span {
    width: 16px; height: 16px; border-radius: 50%;
    background: linear-gradient(135deg, var(--cyan), var(--green));
    box-shadow: 0 0 22px var(--cyan);
}
.brand small { grid-column: 2; color: var(--muted); font-size: 12px; font-weight: 700; margin-top: -8px; }
.brand.big { font-size: 28px; justify-content: center; margin-bottom: 18px; }
nav { display: grid; gap: 8px; margin-top: 28px; }
nav a, .ghost, .primary, .danger {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 11px 14px;
    background: rgba(255,255,255,.03);
    color: var(--text);
    transition: border-color .18s ease, transform .18s ease, background .18s ease, box-shadow .18s ease;
}
nav a:hover, nav a.active, .ghost:hover {
    border-color: rgba(52,211,255,.72);
    background: rgba(52,211,255,.08);
    box-shadow: inset 3px 0 0 var(--cyan);
}
.ghost:hover, .primary:hover, .danger:hover { transform: translateY(-1px); }
.content { flex: 1; padding: 34px; max-width: 1280px; margin: 0 auto; width: 100%; }
.auth-wrap { margin: auto; width: min(430px, calc(100% - 28px)); }
.auth-card, .panel, .cards article {
    border: 1px solid var(--line);
    background: linear-gradient(180deg, rgba(21,31,50,.94), rgba(12,18,32,.94));
    border-radius: 8px;
    box-shadow: var(--shadow);
}
.auth-card { padding: 28px; }
.auth-card h1 { text-align: center; margin: 0 0 24px; }
.stack, .inline-form { display: grid; gap: 14px; }
label { color: var(--muted); display: grid; gap: 7px; }
input, select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px 13px;
    background: #090f1c;
    color: var(--text);
    outline: none;
}
input:focus, select:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(52,211,255,.12); }
button { cursor: pointer; font: inherit; }
.primary {
    background: linear-gradient(135deg, var(--cyan), var(--green));
    color: #031018;
    border: 0;
    font-weight: 800;
    box-shadow: 0 12px 34px rgba(52,211,255,.18);
}
.danger { border-color: rgba(255,85,112,.45); color: #ffd3da; background: rgba(255,85,112,.08); }
.auth-links { display: flex; justify-content: center; gap: 14px; margin-top: 18px; color: var(--muted); font-size: 13px; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 18px; margin-bottom: 24px; }
.topbar p { margin: 0; color: var(--cyan); text-transform: uppercase; font-size: 12px; font-weight: 800; }
.topbar h1 { margin: 3px 0 0; font-size: clamp(28px, 4vw, 44px); }
.grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cards article { padding: 20px; position: relative; overflow: hidden; }
.cards article::after {
    content: "";
    position: absolute;
    inset: auto 16px 0 16px;
    height: 2px;
    background: linear-gradient(90deg, transparent, rgba(52,211,255,.75), transparent);
}
.cards span { color: var(--muted); display: block; }
.cards strong { font-size: 38px; display: block; margin-top: 8px; }
.panel { padding: 20px; margin-top: 18px; }
.panel h2 { margin: 0 0 14px; font-size: 18px; }
.chart { display: grid; gap: 12px; }
.chart div { display: grid; grid-template-columns: 120px 1fr 42px; gap: 12px; align-items: center; }
.chart span, .chart b { color: var(--muted); }
.chart i { height: 14px; border-radius: 999px; background: linear-gradient(90deg, var(--cyan), var(--green)); box-shadow: 0 0 20px rgba(52,211,255,.22); }
.inline-form { grid-template-columns: 1fr 1fr auto; align-items: end; }
.remote-form { grid-template-columns: repeat(4, minmax(140px, 1fr)); }
.remote-form button { align-self: end; }
.remote-help { display: grid; gap: 4px; color: var(--muted); }
.remote-help strong { color: var(--text); }
.is-hidden { display: none !important; }
.screens { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.screens a { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: rgba(255,255,255,.03); }
.screens img { width: 100%; aspect-ratio: 9 / 16; object-fit: cover; display: block; background: #050812; }
.screens span { display: block; padding: 10px; color: var(--muted); font-size: 13px; }
.remote-screen { display: grid; grid-template-columns: minmax(220px, 330px) 1fr; gap: 18px; align-items: center; }
.remote-screen img { width: 100%; max-height: 72vh; aspect-ratio: 9 / 16; object-fit: contain; border: 1px solid var(--line); border-radius: 8px; background: #02040a; }
.remote-screen img { cursor: crosshair; }
.remote-screen strong, .remote-screen span, .remote-screen small { display: block; }
.remote-screen span { color: var(--cyan); margin-top: 6px; }
.remote-screen small { color: var(--muted); margin-top: 10px; }
.remote-actions { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.camera-live { display: grid; grid-template-columns: minmax(220px, 360px) 1fr; gap: 18px; align-items: center; margin-bottom: 18px; }
.camera-live img { width: 100%; aspect-ratio: 4 / 3; object-fit: contain; border: 1px solid var(--line); border-radius: 8px; background: #02040a; }
.camera-live strong, .camera-live span, .camera-live small { display: block; }
.camera-live span { color: var(--green); margin-top: 6px; }
.camera-live small { color: var(--muted); margin-top: 10px; }
.gps-panel { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; }
#gps-map { min-height: 620px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #050812; }
.gps-side { min-width: 0; }
.gps-row { width: 100%; color: var(--text); text-align: left; cursor: pointer; }
.gps-marker { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; background: rgba(0,0,0,.82); border: 2px solid var(--green); box-shadow: 0 0 24px rgba(53,242,160,.45); font-size: 20px; }
.gps-marker.offline { border-color: var(--red); box-shadow: 0 0 18px rgba(255,85,112,.35); filter: grayscale(.35); }
.gps-marker-label { display: flex; flex-direction: column; align-items: center; gap: 5px; white-space: nowrap; }
.gps-marker-phone { width: 52px; height: 52px; display: grid; place-items: center; border-radius: 16px; background: linear-gradient(180deg, #111b2b, #050914); border: 3px solid var(--green); box-shadow: 0 0 28px rgba(53,242,160,.55), inset 0 0 0 3px rgba(255,255,255,.04); font-size: 31px; }
.gps-marker-phone.offline { border-color: var(--red); box-shadow: 0 0 22px rgba(255,85,112,.4); filter: grayscale(.25); }
.gps-marker-phone span { transform: translateY(1px); }
.gps-marker-name { background: rgba(2,6,15,.94); border: 1px solid var(--cyan); color: var(--text); border-radius: 8px; padding: 4px 8px; font-size: 12px; font-weight: 900; box-shadow: 0 8px 22px rgba(0,0,0,.35); }
.map-action { width: auto; margin: 8px 4px 4px 0; border: 1px solid var(--line); border-radius: 6px; padding: 6px 9px; background: #0f1726; color: var(--text); cursor: pointer; }
.small-strong { font-size: 18px !important; overflow-wrap: anywhere; }
.table { display: grid; gap: 10px; }
.row {
    min-height: 64px;
    display: grid;
    grid-template-columns: minmax(180px, 1fr) auto auto;
    gap: 12px;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 12px;
    background: rgba(255,255,255,.025);
}
.row span { font-weight: 700; overflow-wrap: anywhere; }
.row small { display: block; color: var(--muted); font-weight: 500; margin-top: 2px; }
.row em { color: var(--muted); font-style: normal; font-size: 13px; }
.actions { display: flex; gap: 8px; justify-content: flex-end; }
.on { color: var(--green); }
.off { color: var(--muted); }
.warn { color: var(--yellow); }
.danger-text { color: var(--red); }
.muted { color: var(--muted); }
.catalog-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; }
.catalog-group { border: 1px solid var(--line); border-radius: 8px; padding: 14px; background: rgba(255,255,255,.025); }
.catalog-group h3 { margin: 0 0 10px; font-size: 15px; color: var(--cyan); }
.catalog-item { width: 100%; text-align: left; border: 1px solid transparent; border-radius: 8px; padding: 9px 10px; margin-top: 7px; color: var(--text); background: rgba(255,255,255,.035); }
.catalog-item:hover { border-color: var(--cyan); }
.catalog-item strong, .catalog-item small { display: block; }
.catalog-item small { color: var(--muted); margin-top: 2px; overflow-wrap: anywhere; }
.quick-form { margin-top: 14px; }
.file-browser { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.file-tile { border: 1px solid var(--line); border-radius: 8px; padding: 12px; background: rgba(255,255,255,.03); min-height: 112px; display: grid; gap: 8px; align-content: start; }
.file-tile.folder { border-color: rgba(52,211,255,.35); }
.file-tile strong, .file-tile small { display: block; overflow-wrap: anywhere; }
.file-tile small { color: var(--muted); }
.flash { margin-bottom: 16px; padding: 12px 14px; border-radius: 8px; background: rgba(53,242,160,.12); border: 1px solid rgba(53,242,160,.28); }
.flash.err { background: rgba(255,85,112,.12); border-color: rgba(255,85,112,.35); }
@media (max-width: 860px) {
    .shell { display: block; }
    .sidebar { width: auto; height: auto; position: relative; }
    nav { grid-template-columns: repeat(2, 1fr); }
    .content { padding: 20px; }
    .grid, .grid.two, .inline-form, .remote-form { grid-template-columns: 1fr; }
    .remote-screen { grid-template-columns: 1fr; }
    .camera-live { grid-template-columns: 1fr; }
    .gps-panel { grid-template-columns: 1fr; }
    #gps-map { min-height: 460px; }
    .chart div { grid-template-columns: 86px 1fr 32px; }
    .row { grid-template-columns: 1fr; }
    .actions { justify-content: stretch; }
    .actions button { width: 100%; }
}
