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

:root {
    --primary:       #6366f1;
    --primary-light: #818cf8;
    --primary-dark:  #4f46e5;
    --secondary:     #a78bfa;
    --accent:        #06b6d4;
    --sidebar-w:     250px;
    --navbar-h:      56px;

    --bg:            #f0f2f5;
    --bg-gradient:   linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --card:          #ffffff;
    --card-hover:    #f8f9ff;

    --text:          #1e293b;
    --text-secondary:#64748b;
    --muted:         #94a3b8;

    --border:        #e9edf4;
    --radius-sm:     8px;
    --radius-md:     12px;
    --radius-lg:     16px;
    --radius-xl:     20px;
    --shadow-sm:     0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md:     0 4px 6px -1px rgba(0,0,0,0.08), 0 2px 4px -1px rgba(0,0,0,0.04);
    --shadow-lg:     0 10px 25px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
    --shadow-xl:     0 20px 40px -5px rgba(0,0,0,0.15);

    --danger:        #ef4444;
    --danger-light:  #fee2e2;
    --success:       #10b981;
    --success-light: #d1fae5;
    --warning:       #f59e0b;
    --warning-light: #fef3c7;
    --info:          #3b82f6;
    --info-light:    #dbeafe;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

#app {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

#sidebar-container {
    width: var(--sidebar-w);
    flex-shrink: 0;
    z-index: 100;
}

#main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#navbar-container {
    flex-shrink: 0;
}

#page-container {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem 1.75rem;
    background: var(--bg);
}

#page-container::-webkit-scrollbar { width: 6px; }
#page-container::-webkit-scrollbar-track { background: transparent; }
#page-container::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 99px; }
#page-container::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

.sidebar {
    width: var(--sidebar-w);
    height: 100vh;
    background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
    color: #fff;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

.sidebar::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at 30% 10%, rgba(99,102,241,0.08) 0%, transparent 60%);
    pointer-events: none;
}

.sidebar-header {
    padding: 1.5rem 1.25rem 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    position: relative;
}

.sidebar-header h2 {
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: -0.3px;
    background: linear-gradient(135deg, #c7d2fe 0%, #a5b4fc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.sidebar-header .logo-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: var(--radius-sm);
    margin-right: 8px;
    font-size: 16px;
    vertical-align: middle;
}

.rol-badge {
    display: inline-block;
    margin-top: 6px;
    padding: 2px 10px;
    border-radius: 99px;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    backdrop-filter: blur(4px);
}

.rol-badge.admin   { background: rgba(99,102,241,0.25); color: #a5b4fc; }
.rol-badge.auditor { background: rgba(167,139,250,0.25); color: #c4b5fd; }
.rol-badge.usuario { background: rgba(16,185,129,0.25); color: #6ee7b7; }

.sidebar-menu {
    list-style: none;
    flex: 1;
    padding: 0.75rem 0.5rem;
    position: relative;
}

.sidebar-menu li {
    margin-bottom: 2px;
}

.sidebar-menu li a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0.7rem 1rem;
    color: rgba(255,255,255,0.6);
    text-decoration: none;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
    font-size: 0.88rem;
    font-weight: 450;
    position: relative;
}

.sidebar-menu li a:hover {
    background: rgba(255,255,255,0.08);
    color: rgba(255,255,255,0.9);
}

.sidebar-menu li a.active {
    background: linear-gradient(135deg, rgba(99,102,241,0.2), rgba(167,139,250,0.1));
    color: #e2e8f0;
    font-weight: 600;
}

.sidebar-menu li a.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: linear-gradient(180deg, var(--primary), var(--secondary));
    border-radius: 0 3px 3px 0;
}

.sidebar-menu .menu-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    font-size: 14px;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid rgba(255,255,255,0.06);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    color: rgba(255,255,255,0.5);
    position: relative;
}

.sidebar-footer .user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    overflow: hidden;
}

.sidebar-footer .user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 600;
    color: #fff;
    flex-shrink: 0;
}

.sidebar-footer .user-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: rgba(255,255,255,0.7);
}

.btn-logout {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.08);
    color: rgba(255,255,255,0.5);
    padding: 4px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.75rem;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.btn-logout:hover {
    background: rgba(239,68,68,0.15);
    border-color: rgba(239,68,68,0.3);
    color: #fca5a5;
}

.navbar {
    height: var(--navbar-h);
    background: rgba(255,255,255,0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 50;
}

.navbar::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--primary-light), transparent);
    opacity: 0.3;
}

.navbar-title {
    flex: 1;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text);
}

.navbar-user {
    color: var(--text-secondary);
    font-size: 0.82rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

.navbar-user::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 6px rgba(16,185,129,0.4);
}

.card {
    background: var(--card);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    padding: 1.25rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow-sm);
    transition: all 0.25s ease;
}

.card:hover {
    box-shadow: var(--shadow-md);
    border-color: #e2e8f0;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.card-header h3 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
}

.page-heading {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 1.25rem;
    color: var(--text);
    letter-spacing: -0.3px;
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.kpi-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: all 0.3s ease;
}

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

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.kpi-card.warning::before {
    background: linear-gradient(90deg, var(--warning), #f97316);
}

.kpi-card .kpi-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, rgba(99,102,241,0.1), rgba(167,139,250,0.1));
    font-size: 18px;
    margin-bottom: 0.75rem;
}

.kpi-card.warning .kpi-icon {
    background: linear-gradient(135deg, rgba(245,158,11,0.1), rgba(249,115,22,0.1));
}

.kpi-value {
    display: block;
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1.2;
    letter-spacing: -1px;
}

.kpi-card.warning .kpi-value {
    color: var(--warning);
}

.kpi-label {
    display: block;
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-top: 4px;
    font-weight: 500;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
}

.tabla {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.85rem;
}

.tabla thead th {
    background: #f8fafc;
    color: var(--text-secondary);
    font-weight: 600;
    padding: 0.7rem 0.85rem;
    text-align: left;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.tabla thead th:first-child {
    border-radius: var(--radius-sm) 0 0 0;
}

.tabla thead th:last-child {
    border-radius: 0 var(--radius-sm) 0 0;
}

.tabla td {
    padding: 0.7rem 0.85rem;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    vertical-align: middle;
}

.tabla tbody tr {
    transition: background 0.15s ease;
}

.tabla tbody tr:last-child td {
    border-bottom: none;
}

.tabla tbody tr:hover td {
    background: #f8faff;
}

.tabla tbody tr:nth-child(even) td {
    background: #fafbfc;
}

.tabla tbody tr:nth-child(even):hover td {
    background: #f0f4ff;
}

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 99px;
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    backdrop-filter: blur(4px);
}

.estado-activo, .estado-en_uso, .estado-alta {
    background: var(--success-light);
    color: #065f46;
}

.estado-en_transferencia, .estado-transferido {
    background: var(--info-light);
    color: #1e40af;
}

.estado-en_reparacion {
    background: var(--warning-light);
    color: #92400e;
}

.estado-almacenado {
    background: #f1f5f9;
    color: #475569;
}

.estado-dado_de_baja, .estado-cerrado {
    background: var(--danger-light);
    color: #991b1b;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    border: none;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    line-height: 1.4;
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    box-shadow: 0 2px 8px rgba(99,102,241,0.25);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99,102,241,0.35);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: #fff;
    color: var(--text);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
    box-shadow: var(--shadow-md);
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger), #dc2626);
    color: #fff;
    box-shadow: 0 2px 8px rgba(239,68,68,0.25);
}

.btn-danger:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(239,68,68,0.35);
}

.btn-sm {
    padding: 0.3rem 0.65rem;
    font-size: 0.78rem;
}

.btn-full {
    width: 100%;
    justify-content: center;
    padding: 0.65rem 1rem;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

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

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 0.35rem;
    color: var(--text);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.55rem 0.75rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    background: #fff;
    color: var(--text);
    transition: all 0.2s ease;
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
}

.form-group input:hover,
.form-group select:hover,
.form-group textarea:hover {
    border-color: #cbd5e1;
}

.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #1e1b4b 100%);
    position: relative;
    overflow: hidden;
}

.login-page::before {
    content: '';
    position: absolute;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(99,102,241,0.12) 0%, transparent 70%);
    top: -200px;
    right: -200px;
}

.login-page::after {
    content: '';
    position: absolute;
    width: 400px;
    height: 400px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(167,139,250,0.1) 0%, transparent 70%);
    bottom: -150px;
    left: -150px;
}

.login-card {
    background: rgba(255,255,255,0.05);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: var(--radius-xl);
    padding: 2.5rem;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.5);
    position: relative;
    z-index: 1;
}

.login-card h1 {
    text-align: center;
    margin-bottom: 0.5rem;
    font-size: 1.5rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.5px;
}

.login-card .login-subtitle {
    text-align: center;
    color: rgba(255,255,255,0.4);
    font-size: 0.82rem;
    margin-bottom: 2rem;
}

.login-card .form-group label {
    color: rgba(255,255,255,0.7);
    font-size: 0.8rem;
}

.login-card .form-group input {
    background: rgba(255,255,255,0.06);
    border: 1.5px solid rgba(255,255,255,0.1);
    color: #fff;
    padding: 0.65rem 0.85rem;
}

.login-card .form-group input::placeholder {
    color: rgba(255,255,255,0.25);
}

.login-card .form-group input:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
    background: rgba(255,255,255,0.08);
}

.login-card .btn-primary {
    background: linear-gradient(135deg, #6366f1, #818cf8);
    padding: 0.7rem 1rem;
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

.login-card .btn-primary:hover {
    box-shadow: 0 4px 15px rgba(99,102,241,0.4);
}

.error-msg {
    color: #fca5a5;
    font-size: 0.8rem;
    padding: 0.6rem 0.85rem;
    background: rgba(239,68,68,0.1);
    border: 1px solid rgba(239,68,68,0.2);
    border-radius: var(--radius-sm);
    margin-bottom: 0.85rem;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease;
}

.modal {
    background: #fff;
    border-radius: var(--radius-lg);
    width: 92%;
    max-width: 640px;
    max-height: 86vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-xl);
    animation: slideUp 0.25s ease;
    border: 1px solid var(--border);
}

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

.modal-header h3 {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.4rem;
    cursor: pointer;
    color: var(--muted);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.15s ease;
}

.modal-close:hover {
    background: #f1f5f9;
    color: var(--text);
}

.modal-body {
    padding: 1.25rem;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

.toast {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    z-index: 2000;
    animation: slideInRight 0.3s ease;
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(8px);
}

.toast-info    { background: linear-gradient(135deg, #3b82f6, #6366f1); color: #fff; }
.toast-success { background: linear-gradient(135deg, #10b981, #059669); color: #fff; }
.toast-error   { background: linear-gradient(135deg, #ef4444, #dc2626); color: #fff; }

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes slideInRight {
    from { transform: translateX(110%); opacity: 0; }
    to   { transform: translateX(0); opacity: 1; }
}

.loading {
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.loading::before {
    content: '';
    display: block;
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    margin: 0 auto 0.75rem;
}

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

.error {
    text-align: center;
    padding: 3rem;
    color: var(--danger);
    font-size: 0.9rem;
}

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

    #sidebar-container {
        display: none;
        position: fixed;
        z-index: 999;
        height: 100vh;
    }
    #sidebar-container.open {
        display: block;
    }

    #page-container {
        padding: 1rem;
    }
}
