/* Success button (verde) */
.btn-success {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: #fff;
    border: none;
    box-shadow: 0 4px 16px rgba(34,197,94,0.2);
    font-weight: 600;
    transition: background 0.2s;
}
/* Badges de bloqueo */
.status-blocked {
    background: #fee2e2 !important;
    color: #b91c1c !important;
    border: 1px solid #b91c1c !important;
}
.status-unblocked {
    background: #dcfce7 !important;
    color: #166534 !important;
    border: 1px solid #22c55e !important;
}
.btn-success:hover {
    background: linear-gradient(135deg, #16a34a, #15803d);
    color: #fff;
    box-shadow: 0 6px 20px rgba(34,197,94,0.3);
}
.search-section {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin-bottom: 18px;
}
.search-section h3 {
    width: 100%;
    text-align: center !important;
    font-size: 1.35rem;
    font-weight: 700;
    color: #6366f1;
    margin-bottom: 18px;
    letter-spacing: 0.2px;
    display: flex;
    justify-content: center;
    align-items: center;
}
/* --- CABECERAS DE SECCIÓN CENTRADAS --- */
.search-section {
    width: 100%;
    text-align: center;
    margin-bottom: 18px;
}
.search-section h3 {
    width: 100%;
    text-align: center;
    font-size: 1.35rem;
    font-weight: 700;
    color: #6366f1;
    margin-bottom: 18px;
    letter-spacing: 0.2px;
}
/* --- PAGINACIÓN BONITA --- */
.pagination {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 18px 0 0 0;
    justify-content: flex-end;
}
.pagination-btn {
    background: #f1f5f9;
    color: #6366f1;
    border: none;
    border-radius: 8px;
    padding: 7px 16px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.pagination-btn.active, .pagination-btn:focus {
    background: #6366f1;
    color: #fff;
    outline: none;
}
.pagination-btn:hover:not(.active) {
    background: #e0e7ff;
    color: #4338ca;
}
.page-info {
    color: #64748b;
    font-size: 14px;
    margin: 0 8px;
}

/* --- FILTROS BONITOS --- */
.search-row {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 10px;
    flex-wrap: wrap;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

@media (max-width: 768px) {
    .search-row {
        gap: 8px;
    }
}

/* Full-bleed utility for lists inside panels: use only under small screens to avoid layout shifts */
@media (max-width: 768px) {
    /* For users list (rendered as .users-list) */
    .users-section .users-list {
        margin-left: 0 !important;
        margin-right: 0 !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    /* For table-based lists inside categories (uses .users-table inside .categories-panel) */
    .categories-panel .table-wrapper {
        margin-left: 0 !important;
        margin-right: 0 !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
        overflow-x: hidden !important;
    }

    /* Prevent clipping of shadows */
    .categories-panel,
    .users-section {
        overflow: visible !important;
    }
}

@media (max-width: 480px) {
    .search-row {
        gap: 6px;
    }
}
.search-row input[type="text"] {
    border: 1.5px solid #e5e7eb;
    border-radius: 8px;
    padding: 8px 14px;
    font-size: 15px;
    background: #f8fafc;
    color: #334155;
    transition: border 0.15s;
}
.search-row input[type="text"]:focus {
    border-color: #6366f1;
    outline: none;
}
.search-row select {
    border: 1.5px solid #e5e7eb;
    border-radius: 8px;
    padding: 8px 14px;
    font-size: 15px;
    background: #f8fafc;
    color: #334155;
    transition: border 0.15s;
    appearance: none;
    min-width: 140px;
}
.search-row select:focus {
    border-color: #6366f1;
    outline: none;
}
.search-row button {
    border-radius: 8px;
    font-size: 15px;
    padding: 8px 18px;
    font-weight: 500;
    border: none;
    background: #6366f1;
    color: #fff;
    transition: background 0.15s;
    cursor: pointer;
}
.search-row button.btn-secondary {
    background: #f1f5f9;
    color: #6366f1;
    border: 1.5px solid #e5e7eb;
}
.search-row button:hover:not(.btn-secondary) {
    background: #4338ca;
}
.search-row button.btn-secondary:hover {
    background: #e0e7ff;
    color: #4338ca;
}
/* --- USUARIOS GRID BONITO --- */
/* Wrapper para scroll horizontal en móviles */
.table-wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-top: 18px;
}

.users-table {
    width: 100%;
    min-width: 100%; /* No forzar ancho mínimo, adaptarse al contenedor */
    border-collapse: separate;
    border-spacing: 0;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 4px 24px rgba(30,41,59,0.10);
    overflow: hidden;
    font-size: 15px;
}
.users-table thead tr {
    background: #f1f5f9;
}
.users-table th, .users-table td {
    padding: 14px 18px;
    text-align: left;
}
.users-table th {
    color: #334155;
    font-weight: 700;
    font-size: 15px;
    border-bottom: 1.5px solid #e5e7eb;
    letter-spacing: 0.2px;
}
.users-table tbody tr {
    border-bottom: 1px solid #f1f5f9;
    transition: background 0.13s;
}
.users-table tbody tr:last-child {
    border-bottom: none;
}
.users-table tbody tr:hover {
    background: #f3f4f6;
}
.users-table td {
    color: #475569;
    vertical-align: middle;
}
.users-table .btn-small {
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 14px;
    border: none;
    background: #6366f1;
    color: #fff;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
    margin-right: 4px;
}
.users-table .btn-small:hover {
    background: #4338ca;
}
.users-table .status-badge {
    font-size: 13px;
    padding: 4px 10px;
    border-radius: 12px;
    font-weight: 600;
    background: #e0f2fe;
    color: #0284c7;
    letter-spacing: 0.5px;
}
.users-table .status-inactive {
    background: #fee2e2;
    color: #dc2626;
}
.users-table .status-active {
    background: #d1fae5;
    color: #059669;
}
/* --- MODAL STYLES --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0,0,0,0.45) !important; /* fondo oscuro semitransparente */
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s;
    padding: 20px;
    box-sizing: border-box;
}

.modal-content {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(30,41,59,0.18);
    max-width: 500px;
    width: 95vw;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: modalIn 0.18s cubic-bezier(.4,0,.2,1);
    position: relative;
}

.modal-header {
    padding: 18px 24px 12px 24px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-shrink: 0;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.3rem;
    font-weight: 600;
    color: #1e293b;
    flex: 1;
    min-width: 0;
}

.modal-close {
    background: #f3f4f6;
    border: none;
    font-size: 1.75rem;
    color: #1f2937;
    cursor: pointer;
    padding: 8px;
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: all 0.2s;
    font-weight: 300;
    line-height: 1;
}
.modal-close:hover {
    background: #e5e7eb;
    transform: scale(1.05);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    background: #f8fafc;
    flex: 1;
    -webkit-overflow-scrolling: touch;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid #e5e7eb;
    background: #f1f5f9;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    flex-shrink: 0;
    flex-wrap: wrap;
}

@keyframes modalIn {
    from { transform: translateY(40px) scale(0.98); opacity: 0; }
    to { transform: none; opacity: 1; }
}

/* Responsive modal */
@media (max-width: 768px) {
    .modal-overlay {
        padding: 10px;
        align-items: flex-start;
        overflow-y: auto;
    }
    
    .modal-content {
        max-width: 100%;
        width: 100%;
        max-height: none;
        min-height: auto;
        margin: 10px 0;
    }
    
    .modal-header {
        padding: 14px 16px 10px 16px;
    }
    
    .modal-header h3 {
        font-size: 1.1rem;
    }
    
    .modal-body {
        padding: 16px;
        max-height: none;
    }
    
    .modal-footer {
        padding: 12px 16px;
        gap: 8px;
    }
    
    .modal-footer button {
        flex: 1;
        min-width: 100px;
    }
}

@media (max-width: 480px) {
    .modal-overlay {
        padding: 0;
    }
    
    .modal-content {
        border-radius: 0;
        width: 100vw;
        max-width: 100vw;
        min-height: 100vh;
        margin: 0;
    }
    
    .modal-footer {
        flex-direction: column;
    }
    
    .modal-footer button {
        width: 100%;
    }
}

/* Ensure modal content remains fully opaque and above the overlay */
.modal-content {
    position: relative;
    z-index: 10001;
    background: #fff !important;
}

/* Force fully opaque backgrounds for common components inside modals */
.modal-content .card,
.modal-content .device-info,
.modal-content .device-details,
.modal-content .detail-section,
.modal-content .kpi-card,
.modal-content .welcome-card {
    background: #fff !important;
    box-shadow: 0 8px 28px rgba(2,6,23,0.12) !important;
}

/* High-contrast text inside modals */
.modal-content,
.modal-content * {
    color: #1e293b !important;
}

/* Modern, elegant admin dashboard styles */
:root {
    --bg: #ffffff;
    --bg-overlay: #f8f9fa;
    --card: #fff;
    --card-hover: #f8f9fa;
    --glass: #fff;
    --glass-border: #e5e7eb;
    --primary: #6366f1; /* legacy var used in some components */
    --accent: #6366f1;
    --accent-2: #4338ca;
    --accent-hover: #4338ca;
    --text-primary: #111827;
    --text-secondary: #475569;
    --border-color: rgba(148, 163, 184, 0.2);
    --card-bg: #fff;
    --radius: 16px;
    --radius-sm: 12px;
    --radius-lg: 20px;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 12px 40px rgba(0, 0, 0, 0.15);
    --shadow-inner: inset 0 2px 4px rgba(0, 0, 0, 0.06);
    --border: rgba(148, 163, 184, 0.2);
    --border-hover: rgba(99, 102, 241, 0.3);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html, body {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
    position: relative;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    background-attachment: fixed;
    min-height: 100vh;
    color: #1e293b;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

#app {
    max-width: 1200px;
    margin: 32px auto;
    padding: 24px;
    position: relative;
    overflow-x: hidden; /* Evitar scroll horizontal */
}

@media (max-width: 768px) {
    #app {
        max-width: 100vw;
        width: 100%;
        margin: 0;
        padding: 12px;
        box-sizing: border-box;
    }
}

@media (max-width: 480px) {
    #app {
        padding: 8px;
    }
}

/* Glass morphism effect */
.card {
    background: var(--card) !important;
    border: 1px solid var(--glass-border) !important;
    box-shadow: var(--shadow) !important;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

@media (max-width: 768px) {
    .card {
        padding: 16px;
    }
}

@media (max-width: 480px) {
    .card {
        padding: 12px;
    }
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    border-radius: var(--radius) var(--radius) 0 0;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
    background: var(--card-hover);
}

/* Header styles */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.header h1 {
    margin: 0;
    font-size: 28px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header .actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

/* Button styles */
button {
    background: var(--card);
    border: 2px solid var(--border);
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    color: #475569;
}

button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

button:hover::before {
    left: 100%;
}

button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border-color: var(--border-hover);
    color: #334155;
}

button:active {
    transform: translateY(0);
}

button.primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    color: white;
    border: none;
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.3);
    text-shadow: 0 1px 0 rgba(0,0,0,0.18);
}

button.primary:hover {
    background: linear-gradient(135deg, var(--accent-hover), #4338ca);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
    color: white;
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger), var(--danger-hover));
    color: white;
    border: none;
    box-shadow: 0 4px 16px rgba(239, 68, 68, 0.3);
    text-shadow: 0 1px 0 rgba(0,0,0,0.18);
}

.btn-danger:hover {
    background: linear-gradient(135deg, var(--danger-hover), #b91c1c);
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.4);
    color: white;
}

.btn-small {
    padding: 8px 16px;
    font-size: 13px;
    border-radius: var(--radius-sm);
}

/* KPI Cards */
.top-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-top: 24px;
}

@media (max-width: 480px) {
    .top-row {
        grid-template-columns: 1fr;
    }
}

.kpi {
    padding: 20px;
    border-radius: var(--radius);
    background: var(--card);
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.kpi::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.kpi:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-hover);
}

.kpi .label {
    font-size: 12px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    margin-bottom: 8px;
}

.kpi .value {
    font-size: 32px;
    font-weight: 800;
    color: var(--accent);
    margin-bottom: 4px;
}

.kpi .meta {
    font-size: 12px;
    color: var(--muted-light);
    font-weight: 500;
}

/* Main layout */
.main {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
    margin-top: 24px;
}

.panel {
    padding: 20px;
    border-radius: var(--radius);
    background: var(--card) !important;
    border: 1px solid var(--glass-border) !important;
    box-shadow: var(--shadow);
    transition: var(--transition);
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
}

@media (max-width: 768px) {
    .panel {
        padding: 16px;
    }
}

@media (max-width: 480px) {
    .panel {
        padding: 12px;
    }
}

.panel:hover {
    box-shadow: var(--shadow-hover);
}

.panel h2, .panel h3 {
    margin-bottom: 16px;
    color: #1e293b;
    font-weight: 600;
}

/* List items */
.list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: #fff;
    margin-bottom: 12px;
    transition: var(--transition);
}

.list-item:hover {
    border-color: var(--border-hover);
    background: #fff;
    transform: translateX(4px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

.list-item .meta {
    color: var(--muted);
    font-size: 13px;
    margin-top: 4px;
}

/* Search and form elements */
.search-row {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    align-items: center;
}

input[type="text"], input[type="date"], input[type="password"] {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    background: #fff;
    font-size: 14px;
    transition: var(--transition);
    color: #475569;
}

input[type="text"]:focus, input[type="date"]:focus, input[type="password"]:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
    background: white;
}

input[type="text"]::placeholder, input[type="date"]::placeholder, input[type="password"]::placeholder {
    color: var(--muted-light);
}

/* Tables */
.table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 16px;
}

.table th, .table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.table th {
    background: rgba(99, 102, 241, 0.05);
    font-weight: 600;
    color: #475569;
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 0.5px;
}

.table tr:hover {
    background: rgba(99, 102, 241, 0.02);
}

/* Notification items */
.notif-item {
    padding: 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: #fff;
    margin-bottom: 12px;
    transition: var(--transition);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.notif-item:hover {
    border-color: var(--border-hover);
    background: #fff;
}

/* Chart container */
.chart-wrap {
    padding: 16px;
    background: #fff;
    border-radius: var(--radius-sm);
    margin: 16px 0;
}

/* Utility classes */
.muted {
    color: var(--muted);
    font-size: 13px;
}

.small {
    font-size: 12px;
}

.footer {
    margin-top: 32px;
    text-align: center;
    color: var(--muted);
    font-size: 13px;
    padding: 20px;
}

/* Loading states */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

.loading::after {
    content: '';
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--accent);
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 1s linear infinite;
    margin-left: 8px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Status indicators */
.status-online {
    color: var(--success);
    font-weight: 600;
}

.status-offline {
    color: var(--muted);
    font-weight: 600;
}

.status-warning {
    color: var(--warning);
    font-weight: 600;
}

/* Responsive design */
@media (max-width: 1024px) {
    .main {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .top-row {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    }
}

@media (max-width: 768px) {
    #app {
        margin: 12px;
        padding: 12px;
    }

    .header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }

    .header h1 {
        font-size: 24px;
    }

    .card {
        padding: 16px;
    }

    .top-row {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .kpi {
        padding: 16px;
    }

    .kpi .value {
        font-size: 28px;
    }

    .search-row {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }
    
    .search-row input[type="text"],
    .search-row select {
        width: 100%;
        min-width: 100%;
    }

    .list-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .notif-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    /* Mejorar tablas en tablets */
    .users-table {
        font-size: 14px;
    }
    
    .users-table th,
    .users-table td {
        padding: 10px 12px;
    }
}

@media (max-width: 480px) {
    #app {
        margin: 4px;
        padding: 8px;
    }

    .header h1 {
        font-size: 20px;
    }

    .card {
        padding: 12px;
        border-radius: var(--radius-sm);
    }

    button {
        padding: 10px 16px;
        font-size: 13px;
        width: 100%;
    }

    .kpi {
        padding: 12px;
    }

    .kpi .value {
        font-size: 22px;
    }
    
    /* Mejorar tablas en móviles pequeños */
    .users-table {
        font-size: 11px;
        min-width: 100%; /* Eliminar min-width fijo */
        table-layout: auto; /* Permitir que las columnas se ajusten */
    }

    /* Make user rows visually full-bleed inside panels (compensate panel padding) */
    .users-table {
        width: 100%;
        box-sizing: border-box;
        padding-left: 0;
        padding-right: 0;
    }

    .users-table tr {
        width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        box-sizing: border-box !important;
        border-radius: 12px !important;
    }

    /* Ensure parent panels allow shadows and overflow so visuals aren't clipped */
    .panel, .overview-panel, .documentation-panel {
        overflow: visible !important;
    }
    
    .users-table th,
    .users-table td {
        padding: 6px 4px;
        word-break: break-word; /* Permitir que el texto se divida */
        max-width: none !important; /* permitir ancho completo */
        width: 100% !important; /* forzar que la celda ocupe todo el contenedor */
    }
    
    /* Hacer columnas de acciones más compactas */
    .users-table th:last-child,
    .users-table td:last-child {
        width: 60px;
        padding: 4px 2px;
    }
    
    .users-table .btn-small {
        padding: 4px 8px;
        font-size: 11px;
    }
    
    /* Ajustar paginación */
    .pagination {
        flex-wrap: wrap;
        gap: 6px;
        justify-content: center;
    }
    
    .pagination-btn {
        padding: 6px 12px;
        font-size: 13px;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #1e293b;
        --card: rgba(30, 41, 59, 0.95);
        --muted: #94a3b8;
        --border: rgba(71, 85, 105, 0.3);
    }

    body {
        color: #f1f5f9;
    }

    .card, .panel, .kpi {
        background: var(--card);
        border-color: var(--border);
    }

    input[type="text"], input[type="date"], input[type="password"] {
        background: rgba(30, 41, 59, 0.8);
        color: #f1f5f9;
        border-color: var(--border);
    }

    input[type="text"]::placeholder, input[type="date"]::placeholder, input[type="password"]::placeholder {
        color: var(--muted);
    }
}

/* New Navigation Styles */
.dashboard-header {
    margin-bottom: 32px;
}

.header-main {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding: 20px;
    background: var(--card);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 16px;
}

.logo-icon {
    font-size: 32px;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo-text h1 {
    margin: 0;
    font-size: 24px;
    font-weight: 700;
    /* Two-tone title: left blue, right green (approx split) to match original design */
    background: linear-gradient(90deg, #6366f1 0%, #6366f1 55%, #10b981 55%, #10b981 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo-text .subtitle {
    font-size: 12px;
    color: var(--muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Mobile nav toggle button */
.nav-toggle {
    display: none;
    background: transparent;
    border: none;
    font-size: 22px;
    cursor: pointer;
    padding: 8px 10px;
    border-radius: 8px;
    color: var(--muted);
}

.nav-toggle:hover { background: rgba(99,102,241,0.06); color: var(--accent); }

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    font-size: 24px;
}

.user-name {
    font-weight: 600;
    color: #475569;
}

/* Main Navigation */
.main-navigation {
    background: var(--card);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.nav-tabs {
    display: flex;
    background: rgba(99, 102, 241, 0.05);
    border-bottom: 1px solid var(--border);
}

.nav-tab {
    flex: 1;
    padding: 16px 20px;
    background: none;
    border: none;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    position: relative;
    color: var(--muted);
    font-weight: 500;
}

.nav-tab:hover {
    background: rgba(99, 102, 241, 0.1);
    color: var(--accent);
}

.nav-tab.active {
    background: var(--accent);
    color: white;
}

.nav-tab.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 3px;
    background: white;
    border-radius: 2px;
}

.tab-icon {
    font-size: 20px;
}

.tab-text {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.nav-actions {
    padding: 16px 20px;
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

/* Action buttons in the nav (Actualizar / Cerrar sesión) to match screenshot */
.action-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: 12px;
    font-weight: 700;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.18s ease;
}
.action-btn .btn-icon { font-size: 16px; line-height: 1; }
.action-btn.secondary {
    background: #fff;
    color: var(--accent);
    border: 1px solid rgba(99,102,241,0.15);
    box-shadow: 0 6px 20px rgba(13,20,41,0.04);
}
.action-btn.secondary:hover { transform: translateY(-2px); box-shadow: 0 10px 30px rgba(13,20,41,0.06); }
.action-btn.primary {
    background: linear-gradient(135deg, #6366f1 0%, #4338ca 100%);
    color: #fff;
    border: none;
    box-shadow: 0 10px 30px rgba(67,56,202,0.18);
}
.action-btn.primary:hover { transform: translateY(-2px); box-shadow: 0 16px 40px rgba(67,56,202,0.2); }

/* Small-screen: collapsed by default (icons only). When .nav-expanded is present, show full menu.
   Scoping these rules to <=768px prevents desktop layout regressions. */
@media (max-width: 768px) {
    .main-navigation .nav-tabs { transition: all 0.18s ease; }

    /* Collapsed default: compact icons-only column for very small screens */
    .main-navigation:not(.nav-expanded) .nav-tabs {
        display: flex;
        flex-direction: column;
        gap: 6px;
        padding: 8px;
        align-items: center;
        max-height: calc(80vh);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    .main-navigation:not(.nav-expanded) .nav-tab {
        padding: 8px 6px;
        width: 56px;
        height: 56px;
        border-radius: 12px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        position: relative; /* allows hover label to position */
        transition: transform 0.12s ease, background 0.12s ease;
    }
    .main-navigation:not(.nav-expanded) .nav-tab:hover { transform: translateX(4px); }
    .main-navigation:not(.nav-expanded) .nav-tab .tab-text { display: none; }
    .main-navigation:not(.nav-expanded) .nav-tab .tab-icon { font-size: 18px; }
    .main-navigation:not(.nav-expanded) .nav-actions { display: none; }

    /* Show a compact popout label when hovering a collapsed tab (good for touch+mouse emulation)
       The .tab-text element is revealed and positioned to the right of the icon. */
    .main-navigation:not(.nav-expanded) .nav-tab:hover .tab-text {
        display: block;
        position: absolute;
        left: 68px;
        top: 50%;
        transform: translateY(-50%);
        background: var(--card);
        color: #1e293b;
        padding: 8px 12px;
        border-radius: 12px;
        box-shadow: 0 8px 24px rgba(13,20,41,0.12);
        white-space: nowrap;
        z-index: 40;
        font-size: 13px;
        text-transform: none;
        letter-spacing: normal;
    }

    /* Expanded: show full vertical menu (texts + actions) */
    .main-navigation.nav-expanded { padding: 12px; }
    .main-navigation.nav-expanded .nav-tabs {
        display: flex;
        flex-direction: column;
        gap: 12px;
        align-items: stretch;
    }
    .main-navigation.nav-expanded .nav-tab {
        padding: 12px 16px;
        width: 220px;
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 12px;
    }
    .main-navigation.nav-expanded .nav-tab .tab-text { display: inline-block; }
    .main-navigation.nav-expanded .nav-actions { display: flex; }

    /* Drawer-specific styles (for very small screens). When .nav-drawer is present,
       the navigation will slide in as an overlay panel from the left. */
    .main-navigation.nav-drawer {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: 260px;
        max-width: 80vw;
        transform: translateX(-110%);
        transition: transform 0.22s cubic-bezier(0.2, 0, 0, 1);
        z-index: 50;
        box-shadow: 0 24px 48px rgba(2,6,23,0.35);
    }
    .main-navigation.nav-drawer.nav-expanded { transform: translateX(0%); }

    /* overlay that darkens the rest of the page when drawer open */
    .nav-overlay {
        position: fixed;
        left: 0;
        top: 0;
        right: 0;
        bottom: 0;
        background: rgba(4, 6, 23, 0.45);
        z-index: 40;
        opacity: 1;
    }

    /* Popout-visible state: used by JS for tap-to-toggle popouts on collapsed tabs */
    .nav-tab.popout-visible { z-index: 60; }
    .nav-tab.popout-visible .tab-text {
        display: block;
        position: absolute;
        left: 68px;
        top: 50%;
        transform: translateY(-50%);
        background: var(--card);
        color: #1e293b;
        padding: 8px 12px;
        border-radius: 12px;
        box-shadow: 0 12px 32px rgba(2,6,23,0.18);
        white-space: nowrap;
        z-index: 80;
        font-size: 13px;
        text-transform: none;
        letter-spacing: normal;
    }
}

/* Content Area */
.content-area {
    min-height: 600px;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    box-sizing: border-box;
}

@media (max-width: 768px) {
    .content-area {
        min-height: auto;
        padding: 0;
    }
}

/* Overview Section */
.overview-section {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.welcome-card {
    text-align: center;
    padding: 32px;
    background: var(--card) !important;
    border: 1px solid var(--glass-border) !important;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.welcome-card h2 {
    margin-bottom: 8px;
    color: #1e293b;
}

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

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    width: 100%;
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
}

.kpi-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px;
    background: var(--card) !important;
    border: 1px solid var(--glass-border) !important;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    transition: var(--transition);
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

.kpi-icon {
    font-size: 32px;
    opacity: 0.8;
}

.kpi-content {
    flex: 1;
}

.kpi-value {
    font-size: 32px;
    font-weight: 800;
    color: #1e293b;
    margin-bottom: 4px;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    overflow-wrap: break-word;
    word-break: break-word;
}

.kpi-label {
    font-size: 14px;
    color: var(--muted);
    font-weight: 600;
    margin-bottom: 2px;
    overflow-wrap: break-word;
    word-break: break-word;
}

.kpi-meta {
    font-size: 12px;
    color: var(--muted-light);
    overflow-wrap: break-word;
    word-break: break-word;
}

.overview-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    width: 100%;
}

.overview-panel {
    background: var(--card);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    width: 100%;
    box-sizing: border-box;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.panel-header h3 {
    margin: 0;
    color: #1e293b;
    font-weight: 600;
}

.activity-feed {
    max-height: 300px;
    overflow-y: auto;
    padding-right: 8px;
}

.activity-feed::-webkit-scrollbar {
    width: 6px;
}

.activity-feed::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 3px;
}

.activity-feed::-webkit-scrollbar-thumb {
    background: var(--accent);
    border-radius: 3px;
}

/* Content Section */
.content-section {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.section-header {
    text-align: center;
    padding: 24px;
    background: var(--card);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.section-header h2 {
    margin-bottom: 8px;
    color: #1e293b;
}

.section-header p {
    color: var(--muted);
    font-size: 16px;
}

.content-tabs {
    display: flex;
    background: var(--card);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    overflow: hidden;
}

.content-tab {
    flex: 1;
    padding: 16px 24px;
    background: none;
    border: none;
    cursor: pointer;
    transition: var(--transition);
    font-weight: 600;
    color: var(--muted);
    position: relative;
}

.content-tab:hover {
    background: rgba(99, 102, 241, 0.1);
    color: var(--accent);
}

.content-tab.active {
    background: var(--accent);
    color: white;
}

.content-tab.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 30px;
    height: 3px;
    background: white;
    border-radius: 2px;
}

/* Analytics Section */
.analytics-section {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.analytics-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    width: 100%;
}

.analytics-panel {
    background: var(--card);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    width: 100%;
    box-sizing: border-box;
}

.analytics-panel h3 {
    margin-bottom: 16px;
    color: #1e293b;
    font-weight: 600;
}

/* Reports Section */
.reports-section {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Additional Responsive Design for New Navigation */
@media (max-width: 1024px) {
    .overview-grid,
    .analytics-grid {
        grid-template-columns: 1fr;
    }

    .nav-tabs {
        flex-wrap: wrap;
    }

    .nav-tab {
        flex: none;
        min-width: 120px;
    }
    
    /* Mejorar main layout en tablets */
    .main {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .header-main {
        flex-direction: column;
        gap: 16px;
        text-align: center;
    }

    .nav-toggle {
        display: inline-block;
        position: absolute;
        right: 20px;
        top: 18px;
        z-index: 30;
    }

    .nav-tabs {
        flex-direction: column;
    }

    .nav-tab {
        flex: none;
        width: 100%;
        padding: 12px 16px;
    }

    .nav-actions {
        justify-content: center;
        padding: 12px 16px;
    }

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

    .kpi-card {
        padding: 16px;
    }

    .kpi-value {
        font-size: 28px;
    }

    .overview-grid,
    .analytics-grid {
        gap: 16px;
    }

    .content-tabs {
        flex-direction: column;
    }

    .content-tab {
        padding: 12px 16px;
    }
    
    /* Mejorar action buttons en tablets */
    .action-btn {
        padding: 8px 12px;
        font-size: 14px;
    }
    
    /* Mejorar panel headers */
    .panel-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
}

@media (max-width: 480px) {
    .dashboard-header {
        margin-bottom: 16px;
    }

    /* By default on very small screens start collapsed to icons only */
    .main-navigation {
        position: relative;
    }
    .main-navigation .nav-tabs {
        display: flex;
        gap: 8px;
        justify-content: flex-start;
        overflow-x: auto;
        padding: 8px;
    }

    /* Nav behavior controlled by .nav-expanded (handled in larger small-screen block) */

    /* ensure toggle is visible */
    .nav-toggle { display: inline-block; }

    .header-main {
        padding: 16px;
    }

    .logo-section {
        flex-direction: column;
        gap: 8px;
    }

    .logo-text h1 {
        font-size: 20px;
    }

    .welcome-card {
        padding: 20px;
    }

    .welcome-card h2 {
        font-size: 20px;
    }

    .kpi-card {
        flex-direction: column;
        text-align: center;
        gap: 12px;
    }

    .kpi-icon {
        font-size: 28px;
    }

    .kpi-value {
        font-size: 24px;
    }
}

/* Users table zebra striping and hover highlight
   Applied to both .users-table-grid (legacy) and .users-table (used across pages)
   so tables that reuse the Users layout (including the Devices table) match visuals. */
.users-table-grid tbody tr:nth-child(odd),
.users-table tbody tr:nth-child(odd) {
    background: rgba(99, 102, 241, 0.08); /* slightly darker for odd rows */
}

.users-table-grid tbody tr:nth-child(even),
.users-table tbody tr:nth-child(even) {
    background: rgba(99, 102, 241, 0.02); /* slightly lighter for even rows */
}

.users-table-grid tbody tr:hover,
.users-table tbody tr:hover {
    background: #f3f4f6; /* match .users-table hover color for consistency */
    transition: background 0.15s ease-in-out;
}

.users-table-grid td,
.users-table td {
    padding: 12px 16px;
}

/* Documentation Section Styles */
.documentation-section {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.documentation-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
    width: 100%;
}

.documentation-panel {
    background: var(--card) !important;
    border: 1px solid var(--glass-border) !important;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    transition: var(--transition);
    width: 100%;
    box-sizing: border-box;
}

.documentation-panel:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

.documentation-panel h3 {
    margin: 0 0 12px 0;
    color: #1e293b;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.documentation-panel p {
    color: var(--muted);
    font-size: 14px;
    margin-bottom: 16px;
}

.documentation-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.documentation-actions button {
    flex: 1;
    min-width: 120px;
}

.version-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.version-info p {
    margin: 0;
    font-size: 14px;
    color: var(--muted);
}

.version-info strong {
    color: #1e293b;
}

.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-badge.active {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

/* Document Editor and Viewer */
.document-editor {
    width: 100%;
    min-height: 400px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 14px;
    line-height: 1.5;
    resize: vertical;
    background: var(--bg);
    color: #1e293b;
}

.document-editor:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.document-viewer {
    padding: 16px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    min-height: 400px;
    overflow-y: auto;
    line-height: 1.6;
}

.document-viewer h1,
.document-viewer h2,
.document-viewer h3,
.document-viewer h4,
.document-viewer h5,
.document-viewer h6 {
    margin-top: 24px;
    margin-bottom: 16px;
    color: #1e293b;
}

.document-viewer p {
    margin-bottom: 16px;
    color: #374151;
}

.document-viewer ul,
.document-viewer ol {
    margin-bottom: 16px;
    padding-left: 24px;
}

.document-viewer li {
    margin-bottom: 8px;
}

.document-viewer code {
    background: rgba(99, 102, 241, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 13px;
}

.document-viewer pre {
    background: #f8fafc;
    padding: 16px;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    border: 1px solid var(--border);
}

.document-viewer pre code {
    background: none;
    padding: 0;
}

.document-viewer blockquote {
    border-left: 4px solid var(--accent);
    padding-left: 16px;
    margin: 16px 0;
    color: var(--muted);
    font-style: italic;
}

/* Large Modal for Documents */
.large-modal .modal-content {
    max-width: 900px;
    width: 90vw;
    max-height: 80vh;
}

.large-modal .modal-body {
    max-height: 60vh;
    overflow-y: auto;
}

/* Responsive Documentation */
@media (max-width: 768px) {
    .documentation-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .documentation-panel {
        padding: 20px;
    }

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

    .documentation-actions button {
        width: 100%;
        max-width: none !important;
    }

    .document-editor,
    .document-viewer {
        min-height: 300px;
    }

    .large-modal .modal-content {
        width: 95vw;
        max-height: 85vh;
    }
    
    /* Mejorar modales en tablets */
    .modal-content {
        max-width: 90vw;
        width: 90vw;
    }
    
    .modal-body {
        max-height: 60vh;
    }
}

@media (max-width: 480px) {
    .documentation-panel {
        padding: 16px;
    }

    .document-editor,
    .document-viewer {
        padding: 12px;
        min-height: 250px;
    }
    
    /* Mejorar modales en móviles pequeños */
    .modal-content {
        max-width: 95vw;
        width: 95vw;
        max-height: 90vh;
        margin: 10px;
    }
    
    .modal-header {
        padding: 14px 16px 10px 16px;
    }
    
    .modal-header h3 {
        font-size: 1.1rem;
    }
    
    .modal-body {
        padding: 16px;
        max-height: 55vh;
    }
    
    .modal-footer {
        padding: 12px 16px;
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .modal-footer button {
        flex: 1 1 100%;
        min-width: 100%;
    }
}

/* Offensive content highlighting */
.offensive-row {
    background: rgba(239, 68, 68, 0.1) !important;
    border-left: 3px solid var(--danger) !important;
}

.offensive-row:hover {
    background: rgba(239, 68, 68, 0.15) !important;
}

.offensive-row td {
    color: var(--danger);
}

/* ============================================================================
   DEVICES PANEL - Estilos para gestión de dispositivos problemáticos
   ============================================================================ */

.devices-panel {
    padding: 2rem;
    max-width: 1400px;
    margin: 0 auto;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.section-description {
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

.header-actions {
    display: flex;
    gap: 1rem;
}

.stats-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
    width: 100%;
}

.stat-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 1.5rem;
    border-radius: 12px;
    color: white;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    width: 100%;
    box-sizing: border-box;
}

.stat-value {
    font-size: 2.5rem;
    font-weight: bold;
    margin-bottom: 0.5rem;
}

.stat-label {
    font-size: 0.9rem;
    opacity: 0.9;
}

.filters-container {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
    padding: 1.5rem;
    background: var(--card-bg);
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.filter-group label {
    font-weight: 600;
    color: var(--text-primary);
}

.filter-btn {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    background: var(--card-bg);
    color: var(--text-primary);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-btn:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.filter-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.filter-input,
.filter-select {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--card-bg);
    color: var(--text-primary);
    min-width: 200px;
}

.table-container {
    overflow-x: auto;
    background: var(--card-bg);
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

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

.devices-table thead {
    background: var(--primary);
    color: white;
}

.devices-table th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
}

.devices-table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
}

.devices-table tbody tr:hover {
    background: rgba(102, 126, 234, 0.05);
}

/* Make entire row clearly clickable and provide visible text action */
.clickable-row {
    cursor: pointer;
}
.clickable-row td {
    transition: background 0.12s ease;
}
.clickable-row:hover td {
    background: rgba(99,102,241,0.03);
}

.btn-text {
    padding: 6px 10px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: #ffffff;
    color: var(--primary);
    font-weight: 700;
    cursor: pointer;
    font-size: 0.9rem;
}
.btn-text:hover {
    background: var(--primary);
    color: #fff;
}

.device-info {
    display: flex;
    flex-direction: column;
}

.device-info strong {
    color: var(--text-primary);
    font-size: 1rem;
}

.device-info small {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-top: 0.25rem;
}

.severity-badge {
    display: inline-block;
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
}

.severity-low {
    background: #10b981;
    color: #fff;
}

.severity-medium {
    background: #f59e0b;
    color: #fff;
}

.severity-high {
    background: #ff7f50;
    color: #fff;
}

.severity-critical {
    background: #ef4444;
    color: #fff;
}

.status-badge {
    display: inline-block;
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
}

.status-active {
    background: #16a34a;
    color: #fff;
}

.status-inactive {
    background: #e2e8f0;
    color: #1e293b;
}

.actions {
    display: flex;
    gap: 0.5rem;
}

.btn-icon {
    padding: 0.5rem;
    border: 1px solid var(--border);
    background: #fbfdff; /* soft white to separate from row */
    color: var(--text-primary);
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 6px 18px rgba(99,102,241,0.12);
}

.btn-icon.btn-danger:hover {
    background: var(--danger);
    color: #fff;
}

.btn-icon:focus {
    outline: 3px solid rgba(99,102,241,0.16);
    outline-offset: 2px;
}

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin-top: 2rem;
}

.pagination button {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    background: var(--card-bg);
    color: var(--text-primary);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
}
.pagination button:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Modal para dispositivos */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--card-bg);
    border-radius: 12px;
    max-width: 800px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    margin: 0;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    font-size: 2rem;
    color: var(--text-secondary);
    cursor: pointer;
    line-height: 1;
}

.modal-close:hover {
    color: var(--danger);
}

.device-form {
    padding: 1.5rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--card-bg);
    color: var(--text-primary);
    font-family: inherit;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.checkbox-group {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.75rem;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.checkbox-group input[type="checkbox"] {
    width: auto;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    padding: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.device-details {
    padding: 1.5rem;
}

.detail-section {
    margin-bottom: 2rem;
}

.detail-section h3 {
    color: var(--primary);
    margin-bottom: 1rem;
    font-size: 1.2rem;
}

.detail-section p {
    margin: 0.5rem 0;
    color: var(--text-primary);
}

.detail-section ul {
    list-style: none;
    padding: 0;
}

.detail-section li {
    padding: 0.5rem 0;
    color: var(--text-primary);
}

.detail-section li:before {
    content: "✓ ";
    color: var(--success);
    font-weight: bold;
    margin-right: 0.5rem;
}

.loading-spinner {
    border: 4px solid rgba(0,0,0,0.1);
    border-left-color: var(--primary);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.error-state,
.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary);
}

/* Responsive */
@media (max-width: 768px) {
    .devices-panel {
        padding: 1rem;
    }

    .panel-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .header-actions {
        width: 100%;
        flex-direction: column;
    }

    .header-actions button {
        width: 100%;
        max-width: none !important;
    }

    .stats-container {
        grid-template-columns: 1fr;
    }

    .filters-container {
        flex-direction: column;
        gap: 1rem;
    }

    .filter-group {
        flex-direction: column;
        align-items: flex-start;
        width: 100%;
    }

    .filter-input,
    .filter-select {
        width: 100%;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .checkbox-group {
        grid-template-columns: 1fr;
    }

    .modal-content {
        width: 95%;
    }
}

/* Defensive: ensure modal content sits above overlays and is fully opaque */
.modal-overlay .modal-content {
    z-index: 10001 !important;
    position: relative !important;
    background: #fff !important;
    color: #1e293b !important;
}

/* Fix: User card should occupy 100% of grid line */
.user-card {
    width: 100% !important;
    box-sizing: border-box !important;
    margin: 0 !important;
    display: block !important;
    max-width: 100% !important;
}

/* Ensure user list items occupy full width and have consistent card appearance */
.users-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

.users-list .user-item,
.user-item {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    background: var(--card) !important;
    border: 1px solid var(--glass-border) !important;
    border-radius: 12px;
    padding: 12px 16px;
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    overflow: visible;
}

.user-item .user-info {
    display: flex;
    gap: 12px;
    align-items: center;
    flex: 1 1 auto;
    min-width: 0; /* allow truncation inside flex */
}

.user-item .user-avatar {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    flex: 0 0 48px;
}

.user-item .user-details {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
    width: 100%;
}

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

@media (max-width: 768px) {
    .user-item { flex-direction: column; align-items: stretch; }
    .user-item .user-actions { justify-content: flex-end; margin-top: 8px; }
}

/* Ensure user list fills available width and cards don't create horizontal scroll */
.users-section,
.users-list {
    width: 100%;
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

.users-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Remove any decorative left accent that can make cards look indented */
.user-item,
.users-list .user-item {
    border-left: none !important;
    box-shadow: 0 6px 18px rgba(2,6,23,0.06) !important;
    border-radius: 12px !important;
}

.user-item::before,
.users-list .user-item::before {
    display: none !important;
    content: none !important;
}

/* Defensive: if some inline or other CSS sets transform/translate affecting layout, reset it */
.user-item,
.users-list .user-item {
    transform: none !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
}

/* Make each user-item a full-width card inside its container */
.users-list .user-item,
.user-item {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    margin: 0 0 12px 0 !important;
    background: var(--card) !important;
    border: 1px solid var(--glass-border) !important;
    border-radius: 12px;
    padding: 12px 16px !important;
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

/* Ensure card shadows are not clipped by parent panels */
.panel, .overview-panel, .documentation-panel, .analytics-panel {
    overflow: visible !important;
}

@media (max-width: 480px) {
    /* Keep layout stacked and avoid additional negative margins */
    .user-item { flex-direction: column; align-items: flex-start; }
    .user-item .user-actions { width: 100%; display: flex; justify-content: flex-end; margin-top: 8px; }
}

/* Mobile: replace border-left on user rows with an internal accent (prevents visual cut and overflow) */
@media (max-width: 480px) {
    .users-table tr {
        border-left: none !important; /* remove external left border that causes indentation */
        position: relative !important;
        padding-left: 16px !important; /* smaller left padding so content fills more of the card */
    }

    .users-table tr::before {
        content: '';
        position: absolute;
        left: 8px; /* inside the card */
        top: 12px;
        bottom: 12px;
        width: 4px;
        background: var(--accent) !important;
        border-radius: 4px;
        pointer-events: none;
    }
}


