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

:root {
    --primary:       #2563eb;
    --primary-dark:  #1d4ed8;
    --sidebar-w:     240px;
    --navbar-h:      52px;
    --bg:            #f1f5f9;
    --card:          #fff;
    --text:          #1e293b;
    --muted:         #64748b;
    --border:        #e2e8f0;
    --danger:        #ef4444;
    --success:       #22c55e;
    --warning:       #f59e0b;
}

body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }

/* Layout */
#app          { display: flex; height: 100vh; overflow: hidden; }
#sidebar-container { width: var(--sidebar-w); flex-shrink: 0; }
#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.25rem; }

/* Sidebar */
.sidebar { width: var(--sidebar-w); height: 100vh; background: #1e293b; color: #fff; display: flex; flex-direction: column; }
.sidebar-header { padding: 1.25rem 1rem; border-bottom: 1px solid #334155; }
.sidebar-header h2 { font-size: 0.95rem; font-weight: 700; }
.rol-badge { display: inline-block; margin-top: 4px; padding: 1px 8px; border-radius: 99px; font-size: 0.68rem; text-transform: uppercase; letter-spacing: .5px; }
.rol-badge.admin   { background: #2563eb; }
.rol-badge.auditor { background: #7c3aed; }
.rol-badge.usuario { background: #059669; }
.sidebar-menu { list-style: none; flex: 1; padding: 0.5rem 0; }
.sidebar-menu li a { display: block; padding: 0.7rem 1.25rem; color: #94a3b8; text-decoration: none; transition: all .15s; }
.sidebar-menu li a:hover, .sidebar-menu li a.active { background: #334155; color: #fff; }
.sidebar-footer { padding: 0.875rem 1rem; border-top: 1px solid #334155; display: flex; justify-content: space-between; align-items: center; font-size: 0.8rem; color: #94a3b8; }
.btn-logout { background: none; border: 1px solid #475569; color: #94a3b8; padding: 3px 9px; border-radius: 4px; cursor: pointer; font-size: 0.8rem; }
.btn-logout:hover { border-color: var(--danger); color: var(--danger); }

/* Navbar */
.navbar { height: var(--navbar-h); background: #fff; border-bottom: 1px solid var(--border); display: flex; align-items: center; padding: 0 1.25rem; gap: 1rem; }
.navbar-title { flex: 1; font-weight: 600; font-size: 0.95rem; }
.navbar-user  { color: var(--muted); font-size: 0.8rem; }

/* Cards */
.card { background: var(--card); border-radius: 8px; border: 1px solid var(--border); padding: 1rem; margin-bottom: 1rem; }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.875rem; }
.card-header h3 { font-size: 0.95rem; font-weight: 600; }
.page-heading { font-size: 1.1rem; font-weight: 700; margin-bottom: 1rem; }

/* KPIs */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.kpi-card { background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 1.25rem; text-align: center; }
.kpi-card.warning { border-color: var(--warning); }
.kpi-value { display: block; font-size: 2.25rem; font-weight: 700; color: var(--primary); }
.kpi-card.warning .kpi-value { color: var(--warning); }
.kpi-label { display: block; font-size: 0.78rem; color: var(--muted); margin-top: 3px; }
.dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

/* Tables */
.tabla { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.tabla th { background: #f8fafc; color: var(--muted); font-weight: 600; padding: 0.625rem 0.75rem; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
.tabla td { padding: 0.625rem 0.75rem; border-bottom: 1px solid var(--border); }
.tabla tr:last-child td { border-bottom: none; }
.tabla tr:hover td { background: #f8fafc; }

/* Badges */
.badge { display: inline-block; padding: 2px 7px; border-radius: 99px; font-size: 0.68rem; font-weight: 600; text-transform: uppercase; letter-spacing: .3px; white-space: nowrap; }
.estado-activo, .estado-en_uso, .estado-alta { background: #dcfce7; color: #166534; }
.estado-en_transferencia, .estado-transferido { background: #dbeafe; color: #1e40af; }
.estado-en_reparacion  { background: #fef9c3; color: #854d0e; }
.estado-almacenado     { background: #f1f5f9; color: #475569; }
.estado-dado_de_baja, .estado-cerrado { background: #fee2e2; color: #991b1b; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 4px; padding: 0.45rem 0.875rem; border-radius: 6px; border: none; font-size: 0.85rem; font-weight: 500; cursor: pointer; transition: all .15s; }
.btn-primary   { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: #f1f5f9; color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-sm   { padding: 0.2rem 0.55rem; font-size: 0.78rem; }
.btn-full { width: 100%; justify-content: center; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* Forms */
.form-group { margin-bottom: 0.875rem; }
.form-group label { display: block; font-size: 0.85rem; font-weight: 500; margin-bottom: 0.3rem; }
.form-group input,
.form-group select,
.form-group textarea { width: 100%; padding: 0.45rem 0.7rem; border: 1px solid var(--border); border-radius: 6px; font-size: 0.875rem; background: #fff; }
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px rgba(37,99,235,.1); }

/* Login */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card  { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 2rem; width: 100%; max-width: 360px; }
.login-card h1 { text-align: center; margin-bottom: 1.5rem; font-size: 1.4rem; }
.error-msg { color: var(--danger); font-size: 0.8rem; padding: 0.5rem 0.75rem; background: #fee2e2; border-radius: 4px; margin-bottom: 0.75rem; }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.modal         { background: #fff; border-radius: 10px; width: 92%; max-width: 640px; max-height: 86vh; display: flex; flex-direction: column; }
.modal-header  { padding: 0.875rem 1.125rem; 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; }
.modal-close   { background: none; border: none; font-size: 1.2rem; cursor: pointer; color: var(--muted); }
.modal-body    { padding: 1.125rem; overflow-y: auto; flex: 1; }
.modal-footer  { padding: 0.875rem 1.125rem; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 0.5rem; }

/* Toast */
.toast { position: fixed; bottom: 1.25rem; right: 1.25rem; padding: 0.7rem 1.125rem; border-radius: 8px; font-size: 0.85rem; font-weight: 500; z-index: 2000; animation: slideIn .2s ease; }
.toast-info    { background: var(--primary); color: #fff; }
.toast-success { background: var(--success);  color: #fff; }
.toast-error   { background: var(--danger);   color: #fff; }
@keyframes slideIn { from { transform: translateX(110%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* Utils */
.loading { text-align: center; padding: 3rem; color: var(--muted); }
.error   { text-align: center; padding: 3rem; color: var(--danger); }

/* Responsive */
@media (max-width: 720px) {
    .dashboard-grid { grid-template-columns: 1fr; }
    #sidebar-container { display: none; }
    #sidebar-container.open { display: block; position: fixed; z-index: 999; height: 100vh; }
}
