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

:root {
    --primary: #002336;
    --primary-light: #E6EDF1;
    --primary-hover: #003a57;
    --success-bg: #E8F5E9;
    --success-text: #2E7D32;
    --warning-bg: #FFF8E1;
    --warning-text: #F57F17;
    --danger-bg: #FFEBEE;
    --danger-text: #C62828;
    --neutral-bg: #F5F6F7;
    --neutral-text: #455A64;
    --border: #E0E4E8;
    --text-primary: #1A2B35;
    --text-secondary: #607D8B;
    --white: #FFFFFF;
    --sidebar-width: 220px;
    --topbar-height: 52px;
    --radius: 8px;
    --radius-lg: 12px;
}

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

/* ===== LAYOUT ===== */
.app-layout {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

.main-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

/* ===== TOPBAR (mobile) ===== */
.topbar {
    display: none;
    align-items: center;
    gap: 12px;
    padding: 0 16px;
    height: var(--topbar-height);
    background: var(--primary);
    flex-shrink: 0;
}

.topbar-logo {
    height: 32px;
    object-fit: contain;
}

.btn-hamburger {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    border-radius: 6px;
}

.btn-hamburger:hover { background: rgba(255,255,255,0.1); }

/* ===== SIDEBAR ===== */
.sidebar {
    width: var(--sidebar-width);
    background: #002336;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow-y: auto;
    transition: transform 0.25s ease;
}

.sidebar-overlay {
    display: none;
}

.sidebar-header {
    padding: 14px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-logo-img {
    width: 36px;
    height: 36px;
    object-fit: contain;
    flex-shrink: 0;
}

.sidebar-title {
    font-size: 11px;
    color: rgba(255,255,255,0.85);
    font-weight: 500;
    line-height: 1.3;
}

.sidebar-nav {
    padding: 10px 8px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius);
    color: rgba(255,255,255,0.65);
    text-decoration: none;
    font-size: 13px;
    transition: background 0.15s, color 0.15s;
}

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

.sidebar-nav a.active {
    background: rgba(255,255,255,0.15);
    color: white;
    font-weight: 500;
}

.sidebar-footer {
    padding: 12px 10px;
    border-top: 1px solid rgba(255,255,255,0.08);
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.user-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: rgba(255,255,255,0.15);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 500;
    flex-shrink: 0;
}

.user-info { display: flex; flex-direction: column; min-width: 0; }

.user-name {
    font-size: 12px;
    color: rgba(255,255,255,0.9);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role { font-size: 10px; color: rgba(255,255,255,0.5); }

.btn-logout {
    background: none;
    border: none;
    color: rgba(255,255,255,0.5);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.btn-logout:hover { color: white; }

.sidebar-brand {
    padding: 10px 14px;
    border-top: 1px solid rgba(255,255,255,0.06);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.brand-logo { width: 24px; height: 24px; object-fit: contain; opacity: 0.8; }
.brand-text { font-size: 11px; color: rgba(255,255,255,0.4); font-weight: 500; }

/* ===== MAIN CONTENT ===== */
.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

/* ===== FORMS ===== */
.form-group { display: flex; flex-direction: column; gap: 5px; }

.form-group label { font-size: 12px; font-weight: 500; color: var(--text-secondary); }

.form-group input, .form-group select, .form-group textarea {
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
    color: var(--text-primary);
    background: white;
    outline: none;
    transition: border 0.15s;
    width: 100%;
}

.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    border-color: var(--primary);
}

/* ===== BUTTONS ===== */
.btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: background 0.15s;
}

.btn-primary:hover { background: var(--primary-hover); }

.btn-secondary {
    background: white;
    color: var(--text-primary);
    border: 1px solid var(--border);
    padding: 8px 16px;
    border-radius: var(--radius);
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s;
}

.btn-secondary:hover { background: var(--neutral-bg); }

.btn-danger {
    background: var(--danger-bg);
    color: var(--danger-text);
    border: none;
    padding: 8px 16px;
    border-radius: var(--radius);
    font-size: 13px;
    cursor: pointer;
}

.btn-icon {
    background: var(--neutral-bg);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 5px 8px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.15s;
}

.btn-icon:hover { background: var(--primary-light); color: var(--primary); }

/* ===== PAGE HEADER ===== */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.page-header h1 { font-size: 20px; font-weight: 500; color: var(--text-primary); }

/* ===== SEARCH ===== */
.search-bar { margin-bottom: 16px; }

.search-bar input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
    background: white;
    outline: none;
}

.search-bar input:focus { border-color: var(--primary); }

/* ===== ALERTS ===== */
.alert-error {
    background: var(--danger-bg);
    color: var(--danger-text);
    padding: 8px 12px;
    border-radius: var(--radius);
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ===== LOADING / EMPTY ===== */
.loading, .empty {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
    font-size: 13px;
}

/* ===== DASHBOARD ===== */
.dashboard-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.stat-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
}

.stat-card .stat-label { font-size: 11px; color: var(--text-secondary); margin-bottom: 6px; }
.stat-card .stat-value { font-size: 26px; font-weight: 500; color: var(--text-primary); }
.stat-card .stat-value.highlight { color: var(--primary); }

.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.dashboard-panel {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
    height: 320px;
    overflow: hidden;
}

.dashboard-panel h2 { font-size: 13px; font-weight: 500; color: var(--text-secondary); margin-bottom: 14px; }

/* ===== INVENTARIO ===== */
.inventario-lista { display: flex; flex-direction: column; gap: 8px; }

.inventario-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 14px;
}

.inventario-imagen {
    width: 52px;
    height: 52px;
    border-radius: var(--radius);
    background: var(--primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}

.inventario-imagen img { width: 100%; height: 100%; object-fit: cover; }
.sin-imagen { font-size: 22px; }

.inventario-info { flex: 1; min-width: 0; }
.inventario-info h3 { font-size: 14px; font-weight: 500; color: var(--text-primary); margin-bottom: 2px; }
.inventario-info .codigo { font-size: 11px; color: var(--text-secondary); margin-bottom: 4px; }
.inventario-info .precio { font-size: 12px; color: var(--text-secondary); margin-bottom: 6px; }

.stock-info { display: flex; gap: 6px; flex-wrap: wrap; }
.stock-disponible { font-size: 11px; background: var(--success-bg); color: var(--success-text); padding: 2px 8px; border-radius: 20px; }
.stock-alquilado { font-size: 11px; background: var(--warning-bg); color: var(--warning-text); padding: 2px 8px; border-radius: 20px; }
.stock-total { font-size: 11px; background: var(--primary-light); color: var(--primary); padding: 2px 8px; border-radius: 20px; }
.inventario-acciones { display: flex; gap: 4px; flex-shrink: 0; }

/* ===== MODALS ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal {
    background: white;
    border-radius: var(--radius-lg);
    padding: 24px;
    width: 100%;
    max-width: 480px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-height: 90vh;
    overflow-y: auto;
    margin: 16px;
}

.modal-pequeno { max-width: 360px; }
.modal h2 { font-size: 15px; font-weight: 500; color: var(--text-primary); }
.modal-acciones { display: flex; gap: 8px; justify-content: flex-end; }
.error { font-size: 12px; color: var(--danger-text); }

/* ===== BADGES ===== */
.badge-activo { font-size: 11px; background: var(--success-bg); color: var(--success-text); padding: 2px 10px; border-radius: 20px; font-weight: 500; }
.badge-finalizado { font-size: 11px; background: var(--neutral-bg); color: var(--neutral-text); padding: 2px 10px; border-radius: 20px; font-weight: 500; }
.badge-cancelado { font-size: 11px; background: var(--danger-bg); color: var(--danger-text); padding: 2px 10px; border-radius: 20px; font-weight: 500; }
.badge-abierto { font-size: 11px; background: var(--success-bg); color: var(--success-text); padding: 2px 10px; border-radius: 20px; font-weight: 500; }
.badge-cerrado { font-size: 11px; background: var(--neutral-bg); color: var(--neutral-text); padding: 2px 10px; border-radius: 20px; font-weight: 500; }

/* ===== LISTAS GENERALES ===== */
.lista-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: 8px;
}

.lista-item-info h3 { font-size: 13px; font-weight: 500; color: var(--text-primary); }
.lista-item-info p { font-size: 11px; color: var(--text-secondary); margin-top: 2px; }
.lista-item-acciones { display: flex; align-items: center; gap: 6px; }

/* ===== LOGIN ===== */
.login-page { min-height: 100vh; display: flex; }

.login-left {
    flex: 1;
    background: #002336;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px 40px;
}

.login-left-content { max-width: 420px; width: 100%; text-align: left; }

.login-logo-grande { width: 180px; margin: 0 auto 20px; display: block; }

.login-left-content h2 { font-size: 22px; font-weight: 500; color: white; margin-bottom: 8px; line-height: 1.3; }

.login-subtitle { font-size: 13px; color: rgba(255,255,255,0.5); line-height: 1.6; margin-bottom: 32px; }

.login-features { display: flex; flex-direction: column; gap: 16px; }

.login-feature { display: flex; align-items: flex-start; gap: 12px; }

.feature-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: rgba(255,255,255,0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: rgba(255,255,255,0.7);
}

.login-feature div strong { display: block; font-size: 13px; font-weight: 500; color: rgba(255,255,255,0.9); margin-bottom: 2px; }
.login-feature div span { display: block; font-size: 11px; color: rgba(255,255,255,0.45); line-height: 1.4; }

.login-right {
    flex: 1;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px 40px;
}

.login-form-container { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 16px; }

.login-form-header { text-align: center; margin-bottom: 8px; }
.login-logo-small { width: 80px; margin-bottom: 16px; }

.login-form-header h1 { font-size: 24px; font-weight: 500; color: #002336; margin-bottom: 4px; border: none; outline: none; box-shadow: none; }
.login-form-header p { font-size: 12px; color: var(--text-secondary); }

.input-with-icon { position: relative; display: flex; align-items: center; }
.input-with-icon svg { position: absolute; left: 10px; color: var(--text-secondary); pointer-events: none; flex-shrink: 0; }
.input-with-icon input { padding-left: 34px !important; width: 100%; }

.btn-login {
    background: var(--primary);
    color: white;
    border: none;
    padding: 10px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    width: 100%;
    transition: background 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-login:hover { background: var(--primary-hover); }
.btn-login:disabled { opacity: 0.6; cursor: not-allowed; }

.login-forgot { text-align: center; font-size: 11px; color: var(--text-secondary); line-height: 1.6; }

.login-brand { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 40px; }
.login-brand img { width: 28px; height: 28px; object-fit: contain; opacity: 0.7; }
.login-brand span { font-size: 11px; color: rgba(255,255,255,0.4); font-weight: 500; }

.login-brand-mobile { display: none; align-items: center; justify-content: center; gap: 8px; margin-top: 24px; }
.login-brand-mobile img { width: 22px; height: 22px; object-fit: contain; }
.login-brand-mobile span { font-size: 11px; color: rgba(0,0,0,0.35); font-weight: 500; }

.login-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    display: inline-block;
}

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

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .topbar { display: flex; }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        z-index: 200;
        transform: translateX(-100%);
    }

    .sidebar.sidebar-open { transform: translateX(0); }

    .sidebar-overlay {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.5);
        z-index: 199;
    }

    .main-content { padding: 16px; }

    .dashboard-cards { grid-template-columns: repeat(2, 1fr); }

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

    .dashboard-panel { height: 280px; }

    .login-left { display: none; }
    .login-right { width: 100%; min-height: 100vh; }
    .login-brand-mobile { display: flex; }

    .inventario-acciones { flex-wrap: wrap; }
}

@media (max-width: 480px) {
    .dashboard-cards { grid-template-columns: 1fr; }
    .page-header { flex-direction: column; align-items: flex-start; gap: 8px; }
    .inventario-card { flex-wrap: wrap; }
}

.topbar-title {
    font-size: 13px;
    font-weight: 500;
    color: rgba(255,255,255,0.85);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.empty-chart {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 240px;
    gap: 10px;
}

.empty-chart p {
    font-size: 12px;
    color: var(--text-secondary);
}

h1, h2, h3 {
    outline: none;
    border: none;
    box-shadow: none;
}

.alert-success {
    background: var(--success-bg);
    color: var(--success-text);
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 13px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-spinner {
    width: 13px;
    height: 13px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    display: inline-block;
    vertical-align: middle;
}

/* ===== FILTROS ===== */
.filtros-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    align-items: center;
    flex-wrap: wrap;
}

.filtros-bar input {
    flex: 1;
    min-width: 200px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
    background: white;
    outline: none;
}

.filtros-bar input:focus { border-color: var(--primary); }

.filtro-botones {
    display: flex;
    gap: 4px;
}

.btn-filtro {
    padding: 6px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: white;
    font-size: 12px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.15s;
}

.btn-filtro:hover { background: var(--neutral-bg); }

.btn-filtro.activo {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* ===== ALERT INFO ===== */
.alert-info {
    background: #E3F2FD;
    color: #1565C0;
    padding: 8px 12px;
    border-radius: var(--radius);
    font-size: 12px;
    margin-bottom: 4px;
}

.modal-corte {
    background: white;
    border-radius: var(--radius-lg);
    padding: 24px;
    width: 95vw;
    max-width: 1200px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-height: 90vh;
    overflow-y: auto;
    margin: 16px;
}
