body {
    margin: 0;
    font-family: Arial, sans-serif;
    background: #f4f6fa;
    color: #1e293b;
    overflow-x: hidden;
}

.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #1e88e5, #0d47a1);
}

.login-container {
    width: 100%;
    max-width: 420px;
    padding: 20px;
    box-sizing: border-box;
}

.login-card {
    background: #fff;
    border-radius: 18px;
    padding: 30px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    box-sizing: border-box;
}

.login-logo {
    width: 90px;
    margin-bottom: 10px;
}

.login-card h1 {
    margin: 10px 0 5px;
    color: #1e88e5;
}

.login-card p {
    color: #64748b;
    margin-bottom: 20px;
}

.login-card input {
    width: 100%;
    padding: 14px;
    margin-bottom: 12px;
    border: 1px solid #dbe2ea;
    border-radius: 12px;
    box-sizing: border-box;
}

.login-card button {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 12px;
    background: #1e88e5;
    color: #fff;
    font-weight: bold;
    cursor: pointer;
}

.error {
    margin-top: 12px;
    color: #c62828;
}

.layout {
    display: flex;
    min-height: 100vh;
    background: #f4f6fa;
    width: 100%;
}

.sidebar {
    width: 240px;
    background: #0f172a;
    color: white;
    padding: 20px;
    box-sizing: border-box;
}

.sidebar .brand {
    font-size: 20px;
    font-weight: bold;
    margin-bottom: 25px;
}

.sidebar a {
    display: block;
    color: #cbd5e1;
    text-decoration: none;
    padding: 12px 0;
}

.sidebar a:hover {
    color: white;
}

.main-content {
    margin-left: 280px;
    width: calc(100% - 280px);
    min-height: 100vh;
    padding: 24px;
    box-sizing: border-box;
    overflow-x: hidden;
}

.topbar {
    background: white;
    padding: 18px 24px;
    border-bottom: 1px solid #e2e8f0;
    box-sizing: border-box;
}

.dashboard {
    width: 100%;
    max-width: 100%;
    padding: 0;
    box-sizing: border-box;
}

.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-top: 20px;
    width: 100%;
}

.card {
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 6px 18px rgba(0,0,0,0.08);
    box-sizing: border-box;
}

.card h3 {
    margin: 0;
    font-size: 16px;
}

.card p {
    font-size: 32px;
    font-weight: bold;
    margin: 12px 0 0;
}

.card.blue {
    background: linear-gradient(135deg, #1e88e5, #0d47a1);
    color: white;
}

.card.white {
    background: white;
    color: #0f172a;
}

.card.yellow {
    background: #fff4d6;
    color: #b26a00;
}

.alerta-resumen-card {
    background: linear-gradient(135deg, #fff4d6, #ffe8b3);
    color: #9a5b00;
    border-radius: 16px;
    padding: 16px 20px;
    min-width: 180px;
    box-shadow: 0 6px 18px rgba(0,0,0,0.08);
    text-align: center;
    box-sizing: border-box;
}

.alerta-resumen-label {
    font-size: 14px;
    font-weight: bold;
    margin-bottom: 6px;
}

.alerta-resumen-value {
    font-size: 30px;
    font-weight: bold;
}

.estado-revisar {
    display: inline-block;
    background: #fff7ed;
    color: #c2410c;
    padding: 6px 10px;
    border-radius: 999px;
    font-weight: bold;
    font-size: 12px;
}

.estado-critico {
    display: inline-block;
    background: #fee2e2;
    color: #b91c1c;
    padding: 6px 10px;
    border-radius: 999px;
    font-weight: bold;
    font-size: 12px;
}

.badge-ok {
    display: inline-block;
    background: #dcfce7;
    color: #166534;
    padding: 6px 10px;
    border-radius: 999px;
    font-weight: bold;
    font-size: 12px;
}

.badge-alerta {
    display: inline-block;
    background: #fee2e2;
    color: #b91c1c;
    padding: 6px 10px;
    border-radius: 999px;
    font-weight: bold;
    font-size: 12px;
}

.btn-primary {
    display: inline-block;
    background: #1e88e5;
    color: #fff;
    padding: 10px 16px;
    border-radius: 10px;
    text-decoration: none;
    border: none;
    cursor: pointer;
    font-weight: bold;
    box-sizing: border-box;
}

.btn-primary:hover {
    background: #1565c0;
}

.btn-secondary {
    display: inline-block;
    background: #e2e8f0;
    color: #1e293b;
    padding: 10px 16px;
    border-radius: 10px;
    text-decoration: none;
    margin-left: 8px;
    box-sizing: border-box;
}

.table-card,
.form-card {
    background: #fff;
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 6px 18px rgba(0,0,0,0.08);
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
}

.tabla {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.tabla thead {
    background: #f8fafc;
}

.tabla th,
.tabla td {
    padding: 12px;
    border-bottom: 1px solid #e2e8f0;
    text-align: left;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    width: 100%;
}

.form-card label {
    display: block;
    margin-bottom: 6px;
    font-weight: bold;
    color: #334155;
}

.form-card input,
.form-card select {
    width: 100%;
    padding: 12px;
    border: 1px solid #dbe2ea;
    border-radius: 10px;
    box-sizing: border-box;
    background: #fff;
}

.dashboard-header-pro {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 22px;
}

.dashboard-header-pro h2 {
    margin: 0;
    font-size: 28px;
    color: #0f172a;
}

.dashboard-header-pro p {
    margin: 6px 0 0;
    color: #64748b;
}

.dashboard-header-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 22px;
    width: 100%;
}

.kpi-card {
    border-radius: 18px;
    padding: 22px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.08);
    box-sizing: border-box;
    width: 100%;
}

.kpi-blue {
    background: linear-gradient(135deg, #1e88e5, #0d47a1);
    color: white;
}

.kpi-white {
    background: white;
    color: #0f172a;
}

.kpi-yellow {
    background: #fff4d6;
    color: #9a5b00;
}

.kpi-label {
    font-size: 14px;
    font-weight: bold;
    margin-bottom: 10px;
}

.kpi-value {
    font-size: 40px;
    font-weight: bold;
    line-height: 1;
    margin-bottom: 8px;
}

.kpi-sub {
    font-size: 13px;
    opacity: 0.9;
}

.dashboard-grid-2 {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
    width: 100%;
}

.panel-card {
    background: #fff;
    border-radius: 18px;
    padding: 20px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.08);
    box-sizing: border-box;
    width: 100%;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.panel-header h3 {
    margin: 0;
    color: #0f172a;
}

.panel-header a {
    color: #1e88e5;
    text-decoration: none;
    font-weight: bold;
}

.panel-note {
    color: #64748b;
    font-size: 13px;
}

.table-responsive {
    overflow-x: auto;
    width: 100%;
}

.alert-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.alert-item {
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 14px;
    background: #f8fafc;
    box-sizing: border-box;
}

.alert-item-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.alert-item-meta {
    color: #475569;
    font-size: 14px;
    margin-bottom: 4px;
}

.alert-item-date {
    color: #94a3b8;
    font-size: 12px;
    margin-top: 8px;
}

.rutas-resumen-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
    width: 100%;
}

.ruta-mini-card {
    border-radius: 16px;
    padding: 16px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    box-sizing: border-box;
}

.ruta-mini-title {
    font-weight: bold;
    color: #0f172a;
    margin-bottom: 10px;
}

.ruta-mini-value {
    font-size: 26px;
    font-weight: bold;
    color: #1e88e5;
    margin-bottom: 6px;
}

.ruta-mini-sub {
    font-size: 13px;
    color: #64748b;
}

.empty-box {
    padding: 20px;
    border: 1px dashed #cbd5e1;
    border-radius: 14px;
    color: #64748b;
    background: #f8fafc;
    box-sizing: border-box;
}

@media (max-width: 992px) {
    .dashboard-grid-2 {
        grid-template-columns: 1fr;
    }
}

.sidebar-pro {
    width: 280px;
    height: 100vh;
    background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
    color: #fff;
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    top: 0;
    z-index: 1000;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.12);
    overflow: hidden;
}

.sidebar-brand {
    padding: 24px 20px 10px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-brand-top {
    display: flex;
    align-items: center;
    gap: 14px;
}

.sidebar-logo-wrap {
    width: 58px;
    height: 58px;
    border-radius: 16px;
    background: rgba(255,255,255,0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.08);
}

.sidebar-logo {
    width: 42px;
    height: 42px;
    object-fit: contain;
}

.sidebar-title {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.4px;
}

.sidebar-subtitle {
    margin: 4px 0 0;
    font-size: 13px;
    color: rgba(255,255,255,0.70);
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    padding: 16px 12px 24px;
}

.sidebar-section-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255,255,255,0.45);
    margin: 18px 12px 8px;
}

.sidebar-link,
.sidebar-logout {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    margin: 6px 0;
    color: rgba(255,255,255,0.88);
    text-decoration: none;
    border-radius: 14px;
    transition: all 0.25s ease;
    font-size: 15px;
    font-weight: 500;
}

.sidebar-link:hover,
.sidebar-logout:hover {
    background: rgba(255,255,255,0.08);
    transform: translateX(3px);
}

.sidebar-link.active {
    background: linear-gradient(90deg, #16a34a, #22c55e);
    color: #fff;
    box-shadow: 0 8px 18px rgba(34, 197, 94, 0.30);
}

.sidebar-icon {
    width: 24px;
    text-align: center;
    font-size: 18px;
    flex-shrink: 0;
}

.sidebar-text {
    white-space: nowrap;
}

.sidebar-footer {
    padding: 12px 14px 16px;
    border-top: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0;
    background: #162235;
}

.sidebar-user-box {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: rgba(255,255,255,0.06);
    border-radius: 16px;
    margin-bottom: 12px;
}

.sidebar-user-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #22c55e, #16a34a);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: #fff;
    font-size: 16px;
    flex-shrink: 0;
}

.sidebar-user-info {
    overflow: hidden;
}

.sidebar-user-name {
    font-size: 14px;
    font-weight: 700;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    font-size: 12px;
    color: rgba(255,255,255,0.65);
    margin-top: 2px;
    text-transform: capitalize;
}

.sidebar-logout {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    margin-top: 10px;
    color: #fecaca;
    text-decoration: none;
    border-radius: 14px;
    background: rgba(239, 68, 68, 0.10);
}
.sidebar-logout:hover {
    background: rgba(239, 68, 68, 0.18);
}

.topbar-pro {
    background: #ffffff;
    padding: 18px 24px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.04);
    box-sizing: border-box;
    width: 100%;
}

.topbar-left {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar-title {
    font-size: 22px;
    font-weight: 800;
    color: #0f172a;
    line-height: 1.1;
}

.topbar-subtitle {
    margin-top: 4px;
    font-size: 13px;
    color: #64748b;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    min-width: 0;
}

.topbar-search {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 10px 14px;
    min-width: 240px;
    max-width: 100%;
    box-sizing: border-box;
}

.topbar-search-icon {
    color: #94a3b8;
    font-size: 14px;
}

.topbar-search input {
    border: none;
    background: transparent;
    outline: none;
    width: 100%;
    font-size: 14px;
    color: #0f172a;
    min-width: 0;
}

.topbar-alert-btn {
    position: relative;
    width: 44px;
    height: 44px;
    border-radius: 14px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    font-size: 18px;
    transition: all 0.2s ease;
    box-sizing: border-box;
}

.topbar-alert-btn:hover {
    background: #eef6ff;
    border-color: #bfdbfe;
    transform: translateY(-1px);
}

.topbar-alert-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 999px;
    background: #ef4444;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 8px 12px;
    box-sizing: border-box;
}

.topbar-user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1e88e5, #1565c0);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 15px;
}

.topbar-user-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar-user-name {
    font-size: 14px;
    font-weight: 700;
    color: #0f172a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-user-role {
    font-size: 12px;
    color: #64748b;
    text-transform: capitalize;
}

@media (max-width: 1200px) {
    .main-content {
        margin-left: 280px;
        width: calc(100% - 280px);
    }
}

@media (max-width: 992px) {
    .dashboard-grid-2 {
        grid-template-columns: 1fr;
    }

    .main-content {
        margin-left: 280px;
        width: calc(100% - 280px);
        padding: 20px;
    }
}

@media (max-width: 768px) {
    .topbar-pro {
        padding: 16px;
    }

    .topbar-right {
        width: 100%;
        justify-content: space-between;
    }

    .topbar-search {
        min-width: 100%;
        order: 3;
    }

    .sidebar-pro {
        position: relative;
        width: 100%;
        min-height: auto;
        height: auto;
    }

    .main-content {
        margin-left: 0;
        width: 100%;
        padding: 16px;
    }

    .layout {
        display: block;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .dashboard {
        padding: 0;
    }
}