:root {
    --bg: #0f1115;
    --panel: #171a21;
    --panel-2: #1d2330;
    --line: #2a3140;
    --text: #edf1f7;
    --muted: #98a3b3;
    --accent: #5aa8ff;
    --accent-2: #89d2ff;
    --success: #38d27a;
    --danger: #ff5c7a;
    --shadow: 0 10px 25px rgba(0, 0, 0, 0.35);
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    background: linear-gradient(180deg, #0c0f14 0%, #12161e 100%);
    color: var(--text);
    font-family: "Segoe UI", Arial, sans-serif;
    min-height: 100%;
}

body {
    min-height: 100vh;
}

.page-wrap {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 28px;
    background: rgba(19, 24, 33, 0.95);
    border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow);
}

.brand-title {
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: 0.2px;
}

.brand-signature {
    font-weight: 800;
    font-size: 1.2rem;
    color: #dbeeff;
    position: relative;
    text-shadow: 0 0 10px rgba(110, 190, 255, 0.35);
}

.shimmer {
    animation: waveGlow 5s ease-in-out infinite;
}

@keyframes waveGlow {
    0%, 100% {
        transform: translateY(0) scale(1);
        text-shadow:
            0 0 6px rgba(90, 168, 255, 0.15),
            0 0 16px rgba(90, 168, 255, 0.12);
        color: #dfeeff;
    }
    35% {
        transform: translateY(-1px) scale(1.02);
        text-shadow:
            0 0 8px rgba(90, 168, 255, 0.45),
            0 0 20px rgba(90, 168, 255, 0.35),
            0 0 34px rgba(137, 210, 255, 0.25);
        color: #ffffff;
    }
    55% {
        transform: translateY(0) scale(1.03);
        text-shadow:
            0 0 10px rgba(137, 210, 255, 0.75),
            0 0 24px rgba(90, 168, 255, 0.55),
            0 0 38px rgba(137, 210, 255, 0.4);
        color: #ffffff;
    }
}

.container {
    width: min(1450px, calc(100% - 30px));
    margin: 22px auto;
    flex: 1;
}

.grid {
    display: grid;
    gap: 18px;
    margin-bottom: 18px;
}

.kpi-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.info-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.map-status-grid {
    grid-template-columns: 2fr 1fr;
}

.panel {
    background: linear-gradient(180deg, rgba(27, 31, 40, 0.96) 0%, rgba(21, 25, 33, 0.96) 100%);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 18px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(8px);
}

.panel h3 {
    margin: 0 0 14px 0;
    font-size: 1.02rem;
}

.filters-form {
    display: flex;
    gap: 18px;
    flex-wrap: wrap;
    align-items: end;
}

.field {
    min-width: 220px;
}

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

select {
    width: 100%;
    background: #0f141c;
    color: var(--text);
    border: 1px solid #323a4b;
    border-radius: 10px;
    padding: 11px 12px;
    font-size: 0.95rem;
    outline: none;
}

.refresh-badge,
.range-badge {
    display: inline-flex;
    align-items: center;
    padding: 10px 14px;
    border-radius: 999px;
    background: rgba(90, 168, 255, 0.12);
    color: #cce7ff;
    border: 1px solid rgba(90, 168, 255, 0.25);
    font-weight: 600;
}

.metric {
    min-height: 132px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.metric-label {
    color: var(--muted);
    margin-bottom: 10px;
    font-size: 0.95rem;
}

.metric-value {
    font-size: 2rem;
    font-weight: 800;
    line-height: 1.1;
}

.metric-value span {
    font-size: 1rem;
    color: var(--muted);
    font-weight: 600;
}

.status-large,
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    font-weight: 700;
    border-radius: 999px;
    text-transform: uppercase;
}

.status-large {
    margin-top: 10px;
    padding: 10px 16px;
    font-size: 0.95rem;
    width: fit-content;
}

.status-pill {
    padding: 7px 12px;
    font-size: 0.85rem;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: currentColor;
    box-shadow: 0 0 12px currentColor;
}

.online {
    color: var(--success);
    background: rgba(56, 210, 122, 0.12);
    border: 1px solid rgba(56, 210, 122, 0.22);
}

.offline {
    color: var(--danger);
    background: rgba(255, 92, 122, 0.12);
    border: 1px solid rgba(255, 92, 122, 0.22);
}

.info-table {
    display: grid;
    gap: 10px;
}

.info-table div {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.info-table div:last-child {
    border-bottom: none;
}

.info-table span {
    color: var(--muted);
}

.info-table strong {
    text-align: right;
}

#map {
    width: 100%;
    height: 360px;
    border-radius: 12px;
    overflow: hidden;
}

.devices-status-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 360px;
    overflow: auto;
}

.device-status-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    padding: 12px;
    border-radius: 12px;
    background: rgba(255,255,255,0.025);
    border: 1px solid rgba(255,255,255,0.05);
}

.muted {
    color: var(--muted);
    font-size: 0.9rem;
    margin-top: 4px;
}

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

.chart-wrap {
    height: 280px;
    margin-bottom: 18px;
}

.chart-wrap:last-child {
    margin-bottom: 0;
}

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

table {
    width: 100%;
    border-collapse: collapse;
}

thead th {
    text-align: left;
    background: rgba(255,255,255,0.04);
    color: #d9e4ef;
    font-weight: 700;
    padding: 12px 10px;
    border-bottom: 1px solid var(--line);
}

tbody td {
    padding: 12px 10px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    color: #e7edf7;
}

tbody tr:hover {
    background: rgba(255,255,255,0.03);
}

.footer {
    margin-top: auto;
    padding: 16px 20px;
    text-align: center;
    color: #afbbca;
    border-top: 1px solid var(--line);
    background: rgba(17, 21, 28, 0.96);
}

.leaflet-container {
    background: #0e131a;
}

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

    .info-grid,
    .map-status-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 720px) {
    .topbar {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

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

    .container {
        width: calc(100% - 16px);
        margin: 10px auto;
    }

    .panel {
        padding: 14px;
    }

    .brand-title {
        font-size: 1.05rem;
    }
}

.page-title {
    margin: 0 0 6px 0;
    font-size: 1.45rem;
    font-weight: 700;
}

.devices-header-panel {
    margin-bottom: 18px;
}

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

.header-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.nav-button,
.tile-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid rgba(90, 168, 255, 0.22);
    background: rgba(90, 168, 255, 0.1);
    color: #d8ecff;
    text-decoration: none;
    font-weight: 600;
    transition: 0.2s ease;
}

.nav-button:hover,
.tile-button:hover {
    transform: translateY(-1px);
    background: rgba(90, 168, 255, 0.16);
    border-color: rgba(90, 168, 255, 0.35);
}

.tile-button.primary {
    background: linear-gradient(180deg, rgba(90, 168, 255, 0.22) 0%, rgba(90, 168, 255, 0.12) 100%);
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.summary-box {
    padding: 16px;
    border-radius: 14px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.06);
}

.summary-label {
    color: var(--muted);
    margin-bottom: 8px;
    font-size: 0.95rem;
}

.summary-value {
    font-size: 2rem;
    font-weight: 800;
    line-height: 1;
}

.online-text {
    color: var(--success);
}

.offline-text {
    color: var(--danger);
}

.devices-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: 18px;
}

.device-tile {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.device-tile-top {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
}

.device-title {
    margin: 0 0 6px 0;
    font-size: 1.15rem;
    line-height: 1.2;
}

.device-type-line {
    color: #c9d6e5;
    font-size: 0.95rem;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.tile-metrics {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.tile-metric {
    background: rgba(255,255,255,0.025);
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: 12px;
    padding: 12px;
}

.tile-metric span {
    display: block;
    color: var(--muted);
    font-size: 0.84rem;
    margin-bottom: 8px;
}

.tile-metric strong {
    font-size: 1.05rem;
    line-height: 1.2;
}

.device-meta {
    display: grid;
    gap: 8px;
}

.device-meta div {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.device-meta div:last-child {
    border-bottom: none;
}

.device-meta span {
    color: var(--muted);
}

.device-meta strong {
    text-align: right;
}

.tile-actions {
    display: flex;
    gap: 10px;
    margin-top: 4px;
}

@media (max-width: 900px) {
    .devices-header-top {
        flex-direction: column;
    }

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

@media (max-width: 640px) {
    .devices-grid {
        grid-template-columns: 1fr;
    }

    .tile-metrics {
        grid-template-columns: 1fr;
    }

    .tile-actions {
        flex-direction: column;
    }
}

.filters-panel {
    margin-bottom: 28px;
}

.filters-form {
    display: flex;
    justify-content: space-between;
    align-items: end;
    gap: 18px;
    flex-wrap: wrap;
}

.filters-left {
    display: flex;
    gap: 18px;
    flex-wrap: wrap;
    align-items: end;
    flex: 1 1 auto;
}

.filters-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 7px;
    flex: 0 0 auto;
}

.actions-label {
    color: var(--muted);
    font-size: 0.9rem;
    text-align: right;
}

.refresh-info {
    min-width: 180px;
}

.top-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.nav-button {
    white-space: nowrap;
    min-width: 190px;
}

.kpi-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-top: 10px;
    margin-bottom: 22px;
}

@media (max-width: 1100px) {
    .filters-form {
        flex-direction: column;
        align-items: stretch;
    }

    .filters-left {
        width: 100%;
    }

    .filters-right {
        width: 100%;
        align-items: flex-start;
    }

    .actions-label {
        text-align: left;
    }

    .top-actions {
        justify-content: flex-start;
    }
}

@media (max-width: 640px) {
    .top-actions {
        flex-direction: column;
        width: 100%;
    }

    .nav-button {
        width: 100%;
        min-width: 0;
    }
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="datetime-local"],
input[type="date"],
textarea {
    width: 100%;
    background: #0f141c;
    color: var(--text);
    border: 1px solid #323a4b;
    border-radius: 10px;
    padding: 11px 12px;
    font-size: 0.95rem;
    outline: none;
}

textarea {
    min-height: 120px;
    resize: vertical;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.form-actions {
    margin-top: 20px;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

@media (max-width: 800px) {
    .form-grid {
        grid-template-columns: 1fr;
    }
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.login-actions {
    margin-top: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.login-btn {
    width: 160px;
    min-width: 160px;
    text-align: center;
    justify-content: center;
}

.login-actions .nav-button:last-child {
    margin-left: auto;
}

button.login-btn {
    appearance: none;
    -webkit-appearance: none;
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
}

.marker {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid #ffffff;
    box-shadow: 0 0 10px rgba(0,0,0,0.5);
}

.marker-online {
    background: #38d27a;
    animation: pulseMarker 2s infinite;
    box-shadow:
        0 0 8px rgba(56,210,122,0.9),
        0 0 16px rgba(56,210,122,0.6);
}

.marker-offline {
    background: #ff5c7a;
    box-shadow:
        0 0 8px rgba(255,92,122,0.9),
        0 0 16px rgba(255,92,122,0.6);
}

@keyframes pulseMarker {
    0% {
        box-shadow: 0 0 0 0 rgba(56,210,122,0.8);
    }
    70% {
        box-shadow: 0 0 0 12px rgba(56,210,122,0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(56,210,122,0);
    }
}

