:root {
    --background: #080f1d;
    --sidebar: #0d1626;
    --surface: #111d30;
    --border: #24334a;
    --primary: #38bdf8;
    --text: #f1f5f9;
    --muted: #94a3b8;
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #f59e0b;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

body {
    font-family: "Segoe UI", Arial, sans-serif;
    background: var(--background);
    color: var(--text);
    min-height: 100vh;
    color-scheme: dark;
}

button, input, select, textarea {
    font: inherit;
}

button {
    cursor: pointer;
    transition: 0.2s ease;
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

button:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 3px;
}

svg {
    flex-shrink: 0;
}

/* LOGIN */

.login-screen {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background:
        radial-gradient(
            ellipse at top,
            #173b59,
            #080f1d 70%
        );
}

.login-card {
    width: 100%;
    max-width: 440px;
    padding: 36px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 24px;
    box-shadow: 0 25px 70px #0008;
}

.brand {
    text-align: center;
    margin-bottom: 32px;
}

.brand svg {
    width: 70px;
    height: 70px;
    color: var(--primary);
    margin-bottom: 20px;
    filter: drop-shadow(0 0 18px #38bdf850);
}

.brand h1 {
    font-size: 24px;
    letter-spacing: 1px;
    margin-bottom: 12px;
}

.brand p {
    color: var(--muted);
    font-size: 14px;
    line-height: 1.6;
}

#login-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

label {
    font-size: 13px;
    color: var(--muted);
    font-weight: 600;
}

input, select, textarea {
    width: 100%;
    padding: 15px;
    background: var(--background);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 10px;
    outline: none;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px #38bdf815;
}

#login-button {
    padding: 16px;
    margin-top: 12px;
    border: none;
    border-radius: 10px;
    background: linear-gradient(
        135deg,
        #38bdf8,
        #0284c7
    );
    color: #061827;
    font-weight: 700;
    box-shadow: 0 8px 25px #0284c730;
}

#login-button:hover {
    filter: brightness(1.15);
}

#login-message {
    color: var(--danger);
    font-size: 13px;
    text-align: center;
}

.login-card footer {
    text-align: center;
    color: var(--muted);
    font-size: 12px;
    margin-top: 28px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

/* DASHBOARD */

#dashboard {
    min-height: 100vh;
}

/* MENU LATERAL */

.sidebar {
    width: 255px;
    height: 100vh;
    height: 100dvh;
    position: fixed;
    top: 0;
    left: 0;
    display: flex;
    flex-direction: column;
    background: var(--sidebar);
    border-right: 1px solid var(--border);
    padding: 20px 14px;
    z-index: 1100;
    overflow-y: auto;
}

.sidebar-brand {
    text-align: center;
    padding: 15px 0 28px;
}

.sidebar-brand svg {
    width: 44px;
    height: 44px;
    color: var(--primary);
    margin-bottom: 10px;
}

.sidebar-brand h2 {
    font-size: 25px;
    letter-spacing: 3px;
}

.sidebar-brand span {
    color: var(--primary);
    font-size: 11px;
    letter-spacing: 2px;
}

.navigation {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
}

.navigation button {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px 12px;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
    text-align: left;
    font-size: 13px;
}

.navigation button svg {
    width: 19px;
    height: 19px;
}

.navigation button:hover {
    background: #17263c;
    color: white;
}

.navigation button.active {
    background: #12334b;
    color: var(--primary);
    border-color: #1d4c66;
}

#logout-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 13px;
    margin-top: 20px;
    background: #ef444414;
    color: #f87171;
    border: 1px solid #ef444430;
    border-radius: 9px;
}

#logout-button:hover {
    background: #ef444430;
}

/* CONTEUDO PRINCIPAL */

.main-content {
    margin-left: 255px;
    min-height: 100vh;
    min-width: 0;
}

.topbar {
    min-height: 72px;
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 15px 25px;
    background: var(--sidebar);
    border-bottom: 1px solid var(--border);
}

.topbar h2 {
    font-size: 18px;
    flex: 1;
}

#menu-button {
    display: none;
    background: transparent;
    color: var(--text);
    border: none;
}

.system-status {
    display: flex;
    align-items: center;
    gap: 7px;
    color: var(--muted);
    font-size: 12px;
}

.system-status::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--muted);
}

.system-status.connected::before {
    background: var(--success);
    box-shadow: 0 0 10px #22c55e80;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 9px;
    color: var(--muted);
    font-size: 13px;
}

#page-content {
    padding: 25px;
}

.welcome {
    margin-bottom: 25px;
}

.welcome h1 {
    font-size: 27px;
    margin-bottom: 7px;
}

.welcome p {
    color: var(--muted);
    font-size: 14px;
}

/* INDICADORES */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 25px;
}

.stat-card {
    padding: 22px;
    background: linear-gradient(
        145deg,
        #14243a,
        #111d30
    );
    border: 1px solid var(--border);
    border-radius: 14px;
    display: flex;
    flex-direction: column;
    gap: 13px;
    transition: 0.2s;
}

.stat-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
}

.stat-card svg {
    width: 28px;
    height: 28px;
    color: var(--primary);
}

.stat-card span {
    color: var(--muted);
    font-size: 13px;
}

.stat-card h2 {
    font-size: 34px;
    font-weight: 700;
}

#total-online {
    color: var(--success);
}

#total-offline {
    color: var(--muted);
}

#total-alertas {
    color: var(--danger);
}

/* PAINEIS */

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 20px;
    margin-bottom: 24px;
    min-width: 0;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
}

.panel-header h2 {
    font-size: 17px;
}

.panel-header svg {
    color: var(--primary);
}

#add-device {
    background: #12334b;
    color: var(--primary);
    border: 1px solid #1d4c66;
    padding: 11px 15px;
    border-radius: 8px;
    font-size: 13px;
}

#add-device:hover {
    background: #194964;
}

/* MAPA */

#map {
    height: 360px;
    width: 100%;
    background: #17263c;
    border-radius: 10px;
    overflow: hidden;
    z-index: 1;
}

.leaflet-container {
    color-scheme: light;
}

/* TABELAS */

.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    white-space: nowrap;
    font-size: 13px;
}

th {
    color: var(--muted);
    font-weight: 600;
    text-align: left;
    padding: 14px 12px;
    border-bottom: 1px solid var(--border);
}

td {
    padding: 16px 12px;
    border-bottom: 1px solid var(--border);
}

tbody tr:hover {
    background: #ffffff05;
}

.status-online {
    color: var(--success);
    background: #22c55e15;
    padding: 5px 10px;
    border-radius: 20px;
}

.status-offline {
    color: var(--muted);
    background: #94a3b815;
    padding: 5px 10px;
    border-radius: 20px;
}

.status-alerta {
    color: var(--danger);
    background: #ef444415;
    padding: 5px 10px;
    border-radius: 20px;
}

.main-footer {
    text-align: center;
    color: var(--muted);
    font-size: 12px;
    padding: 20px;
}

/* TABLETS */

@media (max-width: 1000px) {
    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* CELULARES */

@media (max-width: 768px) {

    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.25s ease;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    #menu-button {
        display: block;
    }

    .topbar {
        padding: 15px;
        gap: 10px;
    }

    .topbar h2 {
        font-size: 15px;
    }

    .user-profile span {
        display: none;
    }

    .system-status {
        font-size: 10px;
    }

    #page-content {
        padding: 15px;
    }

    .welcome h1 {
        font-size: 21px;
    }

    .stats-grid {
        gap: 10px;
    }

    .stat-card {
        padding: 15px;
    }

    .stat-card h2 {
        font-size: 27px;
    }

    .stat-card span {
        font-size: 11px;
    }

    .panel {
        padding: 14px;
    }

    #map {
        height: 280px;
    }

    .login-card {
        padding: 25px;
    }

    .brand h1 {
        font-size: 21px;
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
    }
}

/* FIM DO ARQUIVO */
