:root {
    --bg: #0b1220;
    --panel: #111a2e;
    --text: #e7eefc;
    --muted: #a9b4cc;
    --border: rgba(255,255,255,0.12);
}

html, body {
    height: 100%;
    margin: 0;
}

body {
    font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
    background: linear-gradient(180deg, var(--bg), #050813);
    color: var(--text);
}

    /* Blazor injects a wrapper <div> between <body> and .app-shell -- it must also fill the viewport */
    body > div {
        height: 100%;
    }

a {
    color: #93c5fd;
}

h1 {
    outline: none;
}

code {
    background: rgba(255,255,255,0.08);
    padding: 2px 6px;
    border-radius: 8px;
}

.app-shell {
    display: block;
}

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 260px;
    height: 100vh;
    overflow-y: auto;
    border-right: 1px solid var(--border);
    background: rgba(17,26,46,0.95);
    backdrop-filter: blur(12px);
    padding: 18px;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    z-index: 100;
}

.brand-title {
    font-weight: 700;
    font-size: 18px;
}

.brand-sub {
    color: var(--muted);
    font-size: 12px;
    margin-top: 4px;
}

.nav {
    margin-top: 18px;
    display: grid;
    gap: 8px;
}

.nav-link {
    display: block;
    padding: 10px 12px;
    border-radius: 12px;
    text-decoration: none;
    color: var(--text);
    border: 1px solid transparent;
}

    .nav-link.active {
        border-color: var(--border);
        background: rgba(255,255,255,0.06);
    }

.content {
    margin-left: 260px;
    padding: 22px;
}

.toolbar {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.search {
    min-width: 260px;
    flex: 1;
    border-radius: 12px;
    border: 1px solid var(--border);
    padding: 10px 12px;
    background: rgba(255,255,255,0.06);
    color: var(--text);
}

    .search::placeholder {
        color: rgba(169,180,204,0.85);
    }

.sortbar {
    display: flex;
    gap: 10px;
    align-items: center;
}

.sortlabel {
    color: var(--muted);
    font-size: 12px;
}

.sortbtn {
    border-radius: 12px;
    border: 1px solid var(--border);
    background: rgba(255,255,255,0.06);
    color: var(--text);
    padding: 8px 12px;
    cursor: pointer;
}

    .sortbtn:hover {
        background: rgba(255,255,255,0.10);
    }

.count {
    color: var(--muted);
    font-size: 12px;
    margin-left: auto;
}

.device-list-simple {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1px;
    background: var(--border);
    border: 1px solid var(--border);
    border-radius: 16px;
    overflow: hidden;
}

.device-row {
    padding: 10px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    background: rgba(15,23,42,0.65);
}

    .device-row:hover {
        background: rgba(255,255,255,0.06);
    }

.simple-list {
    background: rgba(15,23,42,0.65);
    border: 1px solid var(--border);
    border-radius: 16px;
    overflow: hidden;
}

.simple-row {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

    .simple-row:last-child {
        border-bottom: none;
    }

    .simple-row:hover {
        background: rgba(255,255,255,0.04);
    }

.user-info {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.user-name {
    font-size: 15px;
    font-weight: 600;
}

.user-username {
    font-size: 12px;
    color: var(--muted);
    font-weight: 400;
    margin-left: 4px;
}

.user-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.user-customers {
    font-size: 12px;
    color: var(--muted);
}

.user-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 20px;
    border: 1px solid transparent;
}

.badge-superadmin {
    background: rgba(168,85,247,0.18);
    border-color: rgba(168,85,247,0.45);
    color: #d8b4fe;
}

.badge-admin {
    background: rgba(59,130,246,0.18);
    border-color: rgba(59,130,246,0.45);
    color: #93c5fd;
}

.badge-tech {
    background: rgba(34,197,94,0.18);
    border-color: rgba(34,197,94,0.45);
    color: #86efac;
}

.dot {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    display: inline-block;
    box-shadow: 0 0 0 2px rgba(0,0,0,0.25);
}

.dot-online {
    background: #22c55e;
}

.dot-warn {
    background: #f59e0b;
}

.dot-offline {
    background: #ef4444;
}

.devlink {
    text-decoration: none;
    color: var(--muted);
    font-size: 11px;
    font-style: italic;
}

    .devlink:hover {
        text-decoration: none;
    }

.customer {
    color: var(--text);
    font-size: 14px;
    font-weight: 500;
}

.notes {
    color: var(--muted);
    font-size: 12px;
}

.mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

.btn {
    border-radius: 12px;
    border: 1px solid var(--border);
    background: rgba(255,255,255,0.06);
    color: var(--text);
    padding: 8px 12px;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
}

    .btn:hover {
        background: rgba(255,255,255,0.10);
    }

.btn-primary {
    border-color: rgba(59,130,246,0.55);
    background: rgba(59,130,246,0.20);
}

    .btn-primary:hover {
        background: rgba(59,130,246,0.28);
    }

.btn-secondary {
    border-color: rgba(148,163,184,0.45);
    background: rgba(148,163,184,0.12);
}

    .btn-secondary:hover {
        background: rgba(148,163,184,0.22);
    }

.btn-danger {
    border-color: rgba(239,68,68,0.55);
    background: rgba(239,68,68,0.20);
}

    .btn-danger:hover {
        background: rgba(239,68,68,0.30);
    }

.btn-success {
    border-color: rgba(34,197,94,0.55);
    background: rgba(34,197,94,0.20);
}

    .btn-success:hover {
        background: rgba(34,197,94,0.30);
    }

.input-text {
    background: rgba(255,255,255,0.06);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    padding: 7px 10px;
    font-size: 13px;
    outline: none;
}

    .input-text:focus {
        border-color: rgba(59,130,246,0.6);
    }

.detail-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.detail-header-left {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.detail-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.detail-back {
    font-size: 12px;
    color: var(--muted);
    text-decoration: none;
    letter-spacing: 0.3px;
}

    .detail-back:hover {
        color: var(--text);
    }

.details-title {
    margin: 0;
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.details-sub {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.details-subtext {
    color: var(--muted);
    font-size: 12px;
}

    .details-subtext + .details-subtext::before {
        content: "?";
        margin-right: 8px;
        color: var(--border);
    }

.details-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.action-spacer {
    flex: 1;
}

.badge {
    display: inline-flex;
    align-items: center;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
    padding: 3px 10px;
    border-radius: 999px;
    border: 1px solid var(--border);
    white-space: nowrap;
}

.badge-online {
    background: rgba(34,197,94,0.18);
    border-color: rgba(34,197,94,0.45);
    color: #86efac;
}

.badge-warn {
    background: rgba(245,158,11,0.18);
    border-color: rgba(245,158,11,0.45);
    color: #fde68a;
}

.badge-offline {
    background: rgba(239,68,68,0.18);
    border-color: rgba(239,68,68,0.45);
    color: #fca5a5;
}

.details-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.card {
    background: rgba(15,23,42,0.65);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 16px 18px;
}

.card-title {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.kv {
    display: grid;
    grid-template-columns: 130px 1fr;
    gap: 8px;
    padding: 6px 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

    .kv:last-child {
        border-bottom: none;
    }

.k {
    color: var(--muted);
    font-size: 12px;
    padding-top: 1px;
}

.v {
    color: var(--text);
    font-size: 13px;
}

.mapthumb {
    width: 100%;
    height: auto;
    border-radius: 12px;
    border: 1px solid var(--border);
}

.device-meta {
    color: var(--muted);
    font-size: 12px;
    margin-top: 2px;
}

pre {
    margin: 0;
    background: rgba(0,0,0,0.25);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px;
    white-space: pre-wrap;
}

.error {
    margin-bottom: 12px;
    padding: 10px 12px;
    border: 1px solid rgba(239,68,68,0.45);
    border-radius: 12px;
    background: rgba(239,68,68,0.12);
    color: #fecaca;
}

.info {
    margin-bottom: 12px;
    padding: 10px 12px;
    border: 1px solid rgba(59,130,246,0.45);
    border-radius: 12px;
    background: rgba(59,130,246,0.12);
    color: #dbeafe;
}

.hint {
    margin-top: 10px;
    color: var(--muted);
    font-size: 12px;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
}

.modal {
    width: min(520px, 90vw);
    box-sizing: border-box;
    background: rgba(17,26,46,0.92);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 14px;
}

.modal-title {
    font-weight: 700;
    margin-bottom: 10px;
}

.modal-body {
    color: var(--text);
    box-sizing: border-box;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 14px;
}

@media (max-width: 900px) {
    .app-shell {
        display: block;
    }

    .sidebar {
        position: static;
        width: 100%;
        height: auto;
        overflow-y: visible;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    .content {
        margin-left: 0;
    }

    .details-grid {
        grid-template-columns: 1fr;
    }

    .kv {
        grid-template-columns: 120px 1fr;
    }

    .device-row {
        flex-wrap: wrap;
    }
}

/* -- Auth / Login ------------------------------------------------------------ */
.login-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.login-card {
    width: min(420px, 100%);
    background: rgba(17,26,46,0.92);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 32px;
}

.login-brand {
    font-weight: 700;
    font-size: 22px;
    margin-bottom: 4px;
}

.login-sub {
    color: var(--muted);
    font-size: 13px;
    margin-bottom: 24px;
}

.field {
    margin-bottom: 16px;
}

.field-label {
    display: block;
    color: var(--muted);
    font-size: 12px;
    margin-bottom: 6px;
}

.field-hint {
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 4px;
}

.field-input {
    width: 100%;
    box-sizing: border-box;
    border-radius: 12px;
    border: 1px solid var(--border);
    padding: 10px 12px;
    background: rgba(255,255,255,0.06);
    color: var(--text);
    font-size: 14px;
}

    .field-input:focus {
        outline: none;
        border-color: rgba(59,130,246,0.6);
        background: rgba(255,255,255,0.09);
    }

    .field-input option {
        background: #111a2e;
        color: var(--text);
    }

.toggle-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    cursor: pointer;
    padding: 2px 0;
}

    .toggle-row input[type="checkbox"] {
        accent-color: #3b82f6;
        width: 15px;
        height: 15px;
        cursor: pointer;
    }

.customer-checklist {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 220px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 10px;
    margin-top: 4px;
}

/* -- Sidebar footer ---------------------------------------------------------- */
.sidebar-footer {
    margin-top: auto;
    padding-top: 18px;
    border-top: 1px solid var(--border);
}

.sidebar-user {
    padding: 6px 0;
}

.sidebar-user-name {
    font-size: 13px;
    font-weight: 600;
}

.sidebar-user-role {
    font-size: 11px;
    color: var(--muted);
    margin-top: 2px;
}

.nav {
    flex: 1;
}


/* -- Telemetry range selector ----------------------------------------------- */
.rangebar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin: 10px 0 14px;
}

.rangebtn {
    border-radius: 999px;
    border: 1px solid var(--border);
    background: rgba(255,255,255,0.06);
    color: var(--text);
    padding: 6px 10px;
    font-size: 12px;
    cursor: pointer;
}

    .rangebtn:hover {
        background: rgba(255,255,255,0.10);
    }

    .rangebtn.active {
        border-color: rgba(59,130,246,0.65);
        background: rgba(59,130,246,0.22);
    }


/* -- ApexCharts tooltip --------------------------------------------------- */
.apex-tip {
    padding: 8px 10px;
    border-radius: 12px;
    background: rgba(17,26,46,0.95);
    border: 1px solid var(--border);
    color: var(--text);
}

.apex-tip-ts {
    font-size: 11px;
    color: var(--muted);
    margin-bottom: 4px;
}

.apex-tip-val {
    font-size: 13px;
    font-weight: 700;
}

.apex-tip-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 3px;
}

.apex-tip-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.apex-tip-label {
    font-size: 11px;
    color: var(--muted);
    flex: 1;
}

.apex-tip-row .apex-tip-val {
    font-size: 12px;
}

/* Sidebar nav cleanup */
.nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 16px;
}

/* Make links less "button-like" */
.nav-link {
    padding: 6px 10px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: var(--text);
    font-size: 14px;
    transition: background 0.15s ease;
}

    /* Hover effect */
    .nav-link:hover {
        background: rgba(255,255,255,0.06);
    }

    /* Active state (clean highlight instead of block button) */
    .nav-link.active {
        background: rgba(59,130,246,0.16);
        border-left: 3px solid #3b82f6;
        padding-left: 7px; /* compensate border */
    }

/* Section headers (Admin / System) */
.nav-section {
    margin-top: 14px;
    margin-bottom: 4px;
    font-size: 11px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

/* Indented sub-items */
.sub-link {
    padding-left: 16px;
    font-size: 13px;
    color: var(--muted);
}

    /* Slight hover emphasis for sub-links */
    .sub-link:hover {
        color: var(--text);
    }

/* -- Device Map ----------------------------------------- */
.map-page {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 44px);
}

.map-header {
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 12px;
    flex-shrink: 0;
}

.map-container {
    flex: 1;
    border-radius: 16px;
    border: 1px solid var(--border);
    overflow: hidden;
    min-height: 0;
}

/* Leaflet popup dark theme */
.device-popup .leaflet-popup-content-wrapper {
    background: rgba(17,26,46,0.97);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 12px;
    color: #e7eefc;
    box-shadow: 0 4px 24px rgba(0,0,0,0.5);
}

.device-popup .leaflet-popup-tip {
    background: rgba(17,26,46,0.97);
}

.device-popup .leaflet-popup-close-button {
    color: #a9b4cc;
}
