/* ============================================================
   PARKING MANAGER - CSS Responsive
   Mobile-first design
   ============================================================ */

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #dbeafe;
    --danger: #dc2626;
    --danger-light: #fee2e2;
    --success: #16a34a;
    --success-light: #dcfce7;
    --warning: #d97706;
    --warning-light: #fef3c7;
    --dark: #1e3a5f;
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --transition: all 0.2s ease;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--gray-100);
    color: var(--gray-800);
    line-height: 1.5;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* Splash */
.splash {
    position: fixed; inset: 0; z-index: 9999;
    background: var(--dark);
    display: flex; align-items: center; justify-content: center;
    animation: fadeOut 0.5s ease 1.2s forwards;
}
.splash-content { text-align: center; color: white; }
.splash-icon { font-size: 4rem; margin-bottom: 12px; animation: bounce 0.6s ease infinite alternate; }
.splash-content h1 { font-size: 1.6rem; font-weight: 700; margin-bottom: 4px; }
.splash-content p { font-size: 0.9rem; opacity: 0.7; }
@keyframes fadeOut { to { opacity: 0; visibility: hidden; } }
@keyframes bounce { from { transform: translateY(0); } to { transform: translateY(-10px); } }

/* Offline banner */
.offline-banner {
    position: fixed; top: 0; left: 0; right: 0; z-index: 2000;
    background: var(--warning); color: white;
    text-align: center; padding: 8px; font-size: 0.85rem; font-weight: 500;
}

/* Header */
.app-header {
    position: fixed; top: 0; left: 0; right: 0; z-index: 100;
    background: var(--dark); color: white;
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 16px; height: 56px;
    box-shadow: var(--shadow-md);
}
.header-brand { display: flex; align-items: center; gap: 8px; }
.header-icon { font-size: 1.4rem; }
.header-title { font-size: 1.1rem; font-weight: 600; }

.menu-toggle {
    background: none; border: none; cursor: pointer;
    width: 40px; height: 40px; display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 5px; padding: 8px;
}
.menu-toggle span {
    display: block; width: 22px; height: 2.5px;
    background: white; border-radius: 2px; transition: var(--transition);
}
.menu-toggle.active span:nth-child(1) { transform: rotate(45deg) translate(5px, 5px); }
.menu-toggle.active span:nth-child(2) { opacity: 0; }
.menu-toggle.active span:nth-child(3) { transform: rotate(-45deg) translate(5px, -5px); }

/* Navigation */
.app-nav { position: fixed; inset: 0; z-index: 90; pointer-events: none; }
.app-nav.open { pointer-events: all; }
.nav-overlay {
    position: absolute; inset: 0; background: rgba(0,0,0,0.5);
    opacity: 0; transition: opacity 0.3s ease; pointer-events: none;
}
.app-nav.open .nav-overlay { opacity: 1; pointer-events: all; }
.nav-panel {
    position: absolute; top: 0; left: 0; bottom: 0;
    width: 280px; max-width: 85vw;
    background: white;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex; flex-direction: column;
    box-shadow: var(--shadow-lg);
}
.app-nav.open .nav-panel { transform: translateX(0); }
.nav-header {
    background: var(--dark); color: white;
    padding: 20px 16px; display: flex; align-items: center; gap: 10px;
    font-size: 1.1rem; font-weight: 600;
}
.nav-header-icon { font-size: 1.4rem; }
.nav-item {
    display: flex; align-items: center; gap: 14px;
    padding: 14px 16px; color: var(--gray-700);
    text-decoration: none; font-size: 0.95rem; font-weight: 500;
    border-bottom: 1px solid var(--gray-100);
    transition: var(--transition);
}
.nav-item:hover, .nav-item.active {
    background: var(--primary-light); color: var(--primary-dark);
}
.nav-item.active { border-left: 3px solid var(--primary); padding-left: 13px; }
.nav-icon { font-size: 1.3rem; width: 28px; text-align: center; }
.nav-footer { margin-top: auto; padding: 16px; text-align: center; color: var(--gray-400); }

/* Main content */
.app-main {
    padding: 72px 12px 24px; min-height: 100vh;
    max-width: 1200px; margin: 0 auto;
}

/* Tab panels */
.tab-panel { display: none; animation: fadeIn 0.3s ease; }
.tab-panel.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* Page header */
.page-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 16px; position: relative;
}
.page-header h1 { font-size: 1.3rem; color: var(--dark); font-weight: 700; }

/* FAB (Floating Action Button) */
.fab {
    position: fixed; bottom: 24px; right: 24px; z-index: 50;
    width: 56px; height: 56px; border-radius: 50%;
    background: var(--primary); color: white; border: none;
    font-size: 1.6rem; font-weight: 300; cursor: pointer;
    box-shadow: var(--shadow-lg);
    display: flex; align-items: center; justify-content: center;
    transition: var(--transition);
}
.fab:active { transform: scale(0.95); }
.fab:hover { background: var(--primary-dark); }

/* Stats grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px; margin-bottom: 24px;
}
.stat-card {
    background: white; border-radius: var(--radius);
    padding: 14px; box-shadow: var(--shadow);
    display: flex; align-items: center; gap: 12px;
    transition: var(--transition); cursor: pointer;
}
.stat-card:hover { box-shadow: var(--shadow-md); }
.stat-card:active { transform: scale(0.98); }
.stat-card:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.stat-icon { font-size: 2rem; }
.stat-info { flex: 1; min-width: 0; }
.stat-value { font-size: 1.4rem; font-weight: 700; color: var(--dark); line-height: 1.2; }
.stat-label { font-size: 0.75rem; color: var(--gray-500); margin-top: 2px; }
.stat-bar {
    height: 4px; background: var(--gray-200); border-radius: 2px;
    margin-top: 8px; overflow: hidden;
}
.stat-fill { height: 100%; border-radius: 2px; transition: width 0.6s ease; }
.stat-cars .stat-fill { background: #3b82f6; }
.stat-motos .stat-fill { background: #f59e0b; }
.stat-clients .stat-icon { color: var(--primary); }
.stat-vehicles .stat-icon { color: var(--success); }

/* Section header */
.section-header {
    display: flex; align-items: center; justify-content: space-between;
    margin: 24px 0 12px;
}
.section-header h2 { font-size: 1.1rem; color: var(--dark); font-weight: 600; }

/* Search box */
.search-box { margin-bottom: 12px; }
.search-box input {
    width: 100%; padding: 12px 16px; border: 1px solid var(--gray-200);
    border-radius: var(--radius); font-size: 0.95rem;
    background: white; box-shadow: var(--shadow-sm);
    transition: var(--transition);
}
.search-box input:focus {
    outline: none; border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

/* Cards list (mobile cards) */
.cards-list { display: flex; flex-direction: column; gap: 10px; }
.card {
    background: white; border-radius: var(--radius);
    padding: 14px; box-shadow: var(--shadow);
    display: flex; align-items: flex-start; gap: 12px;
    transition: var(--transition); position: relative;
}
.card:active { transform: scale(0.99); }
.card-avatar {
    width: 48px; height: 48px; border-radius: var(--radius);
    background: var(--gray-100); display: flex;
    align-items: center; justify-content: center;
    font-size: 1.5rem; flex-shrink: 0; overflow: hidden;
}
.card-avatar img { width: 100%; height: 100%; object-fit: cover; }
.card-body { flex: 1; min-width: 0; }
.card-title { font-size: 0.95rem; font-weight: 600; color: var(--gray-800); margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-subtitle { font-size: 0.8rem; color: var(--gray-500); }
.card-meta { display: flex; gap: 8px; margin-top: 6px; flex-wrap: wrap; }
.card-actions {
    display: flex; gap: 6px; margin-top: 10px;
    padding-top: 10px; border-top: 1px solid var(--gray-100);
}

/* Badges */
.badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 10px; border-radius: 20px;
    font-size: 0.75rem; font-weight: 600;
}
.badge-occupied { background: var(--danger-light); color: var(--danger); }
.badge-free { background: var(--success-light); color: var(--success); }
.badge-car { background: var(--primary-light); color: var(--primary-dark); }
.badge-moto { background: var(--warning-light); color: var(--warning); }

/* Parking map */
.parking-map {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: 8px;
}
.parking-spot {
    background: white; border-radius: var(--radius);
    padding: 12px 8px; text-align: center;
    box-shadow: var(--shadow); cursor: pointer;
    transition: var(--transition); border: 2px solid transparent;
    position: relative;
}
.parking-spot:active { transform: scale(0.95); }
.parking-spot.occupied { border-color: #fca5a5; background: #fef2f2; }
.parking-spot.free { border-color: #86efac; background: #f0fdf4; }
.spot-number { font-size: 1.1rem; font-weight: 700; color: var(--dark); }
.spot-type { font-size: 0.65rem; color: var(--gray-500); text-transform: uppercase; margin-top: 2px; letter-spacing: 0.5px; }
.spot-vehicle { font-size: 0.75rem; color: var(--gray-600); margin-top: 4px; font-weight: 500; line-height: 1.3; }
.spot-status-dot {
    position: absolute; top: 6px; right: 6px;
    width: 8px; height: 8px; border-radius: 50%;
}
.spot-status-dot.occupied { background: var(--danger); }
.spot-status-dot.free { background: var(--success); }

/* Spots grid (list view) */
.spots-grid { display: flex; flex-direction: column; gap: 8px; }
.spot-row {
    background: white; border-radius: var(--radius);
    padding: 12px 14px; box-shadow: var(--shadow);
    display: flex; align-items: center; gap: 12px;
}
.spot-row-info { flex: 1; min-width: 0; }
.spot-row-title { font-weight: 600; font-size: 0.95rem; }
.spot-row-sub { font-size: 0.8rem; color: var(--gray-500); margin-top: 2px; }

/* Filter tabs */
.filter-tabs {
    display: flex; gap: 6px; margin-bottom: 12px;
    overflow-x: auto; padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.filter-tabs::-webkit-scrollbar { display: none; }
.filter-tab {
    flex-shrink: 0; padding: 8px 16px;
    border: 1px solid var(--gray-200); border-radius: 20px;
    background: white; color: var(--gray-600);
    font-size: 0.85rem; font-weight: 500; cursor: pointer;
    transition: var(--transition); white-space: nowrap;
}
.filter-tab.active {
    background: var(--primary); color: white; border-color: var(--primary);
}

/* Filter selects (client/plaça/vehicle) */
.filter-selects {
    display: flex; flex-direction: column; gap: 8px;
    margin-bottom: 12px;
}
.filter-selects select {
    width: 100%; padding: 10px 34px 10px 14px;
    border: 1px solid var(--gray-200); border-radius: var(--radius);
    font-size: 0.85rem; font-weight: 500; color: var(--gray-700);
    background-color: white; box-shadow: var(--shadow-sm);
    appearance: none; -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%2364748b' viewBox='0 0 16 16'%3E%3Cpath d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 12px center;
    transition: var(--transition);
}
.filter-selects select:focus {
    outline: none; border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

/* Table responsive */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.data-table {
    width: 100%; border-collapse: collapse;
    background: white; border-radius: var(--radius);
    box-shadow: var(--shadow); font-size: 0.85rem;
    min-width: 500px;
}
.data-table th {
    background: var(--gray-50); color: var(--gray-600);
    font-weight: 600; text-align: left; padding: 12px 14px;
    border-bottom: 2px solid var(--gray-200); white-space: nowrap;
}
.data-table td { padding: 12px 14px; border-bottom: 1px solid var(--gray-100); color: var(--gray-700); }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover { background: var(--gray-50); }

/* Buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 10px 18px; border-radius: var(--radius-sm);
    border: none; cursor: pointer; font-size: 0.9rem; font-weight: 500;
    transition: var(--transition); white-space: nowrap;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover, .btn-primary:active { background: var(--primary-dark); }
.btn-secondary { background: var(--gray-100); color: var(--gray-700); }
.btn-secondary:hover { background: var(--gray-200); }
.btn-danger { background: var(--danger-light); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: white; }
.btn-small { padding: 6px 12px; font-size: 0.8rem; }
.btn-icon { padding: 8px; font-size: 1rem; }

/* Modal */
.modal {
    position: fixed; inset: 0; z-index: 500;
    display: none; align-items: flex-end;
    justify-content: center;
}
.modal.active { display: flex; }
.modal-backdrop {
    position: absolute; inset: 0; background: rgba(0,0,0,0.5);
    animation: fadeIn 0.2s ease;
}
.modal-content {
    position: relative; background: white;
    width: 100%; max-height: 90vh; overflow-y: auto;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-lg);
}
.modal-sm { max-width: 400px; border-radius: var(--radius-lg); margin: auto 16px; }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.modal-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 16px 20px; border-bottom: 1px solid var(--gray-100);
    position: sticky; top: 0; background: white; z-index: 1;
}
.modal-header h3 { margin: 0; font-size: 1.1rem; color: var(--dark); }
.modal-close {
    background: none; border: none; font-size: 1.6rem;
    color: var(--gray-400); cursor: pointer; line-height: 1;
    padding: 0; width: 32px; height: 32px; display: flex;
    align-items: center; justify-content: center;
}
.modal-close:hover { color: var(--gray-700); }
.modal form { padding: 16px 20px 20px; }
.modal-actions {
    display: flex; gap: 10px; margin-top: 20px;
    padding-top: 16px; border-top: 1px solid var(--gray-100);
}
.modal-actions .btn { flex: 1; }

/* Form elements */
.form-group { margin-bottom: 14px; }
.form-group label {
    display: block; margin-bottom: 5px;
    font-size: 0.85rem; font-weight: 500; color: var(--gray-700);
}
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%; padding: 12px 14px;
    border: 1px solid var(--gray-300); border-radius: var(--radius-sm);
    font-size: 1rem; background: white; color: var(--gray-800);
    transition: var(--transition); font-family: inherit;
    -webkit-appearance: none; appearance: none;
}
.form-group select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%2364748b' viewBox='0 0 16 16'%3E%3Cpath d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 12px center;
    padding-right: 36px;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none; border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* Readonly info box (dades fixes, no editables, dins d'un formulari) */
.readonly-box {
    padding: 12px 14px; background: var(--gray-50); border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm); font-size: 0.9rem; color: var(--gray-700); font-weight: 500;
}

/* Photo upload */
.photo-upload {
    border: 2px dashed var(--gray-300); border-radius: var(--radius);
    padding: 20px; text-align: center; cursor: pointer;
    transition: var(--transition); background: var(--gray-50);
}
.photo-upload:hover { border-color: var(--primary); background: var(--primary-light); }
.photo-placeholder { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.photo-icon { font-size: 2rem; }
.photo-placeholder span { font-size: 0.9rem; color: var(--gray-600); font-weight: 500; }
.photo-placeholder small { font-size: 0.75rem; color: var(--gray-400); }
.photo-preview-img {
    max-width: 100%; max-height: 200px; border-radius: var(--radius-sm);
    object-fit: contain;
}

/* Spot detail modal */
.spot-detail-body { padding: 16px 20px 20px; }
.spot-detail-row { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--gray-100); }
.spot-detail-row:last-child { border-bottom: none; }
.spot-detail-label { color: var(--gray-500); font-size: 0.9rem; }
.spot-detail-value { font-weight: 600; color: var(--gray-800); font-size: 0.9rem; text-align: right; }

/* Empty state */
.empty-state {
    text-align: center; padding: 48px 20px;
    color: var(--gray-500);
}
.empty-icon { font-size: 3rem; margin-bottom: 12px; }
.empty-state p { margin-bottom: 16px; font-size: 0.95rem; }

/* Toast notifications */
#toast-container {
    position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%);
    z-index: 3000; display: flex; flex-direction: column; gap: 8px;
    width: 90%; max-width: 400px; pointer-events: none;
}
.toast {
    background: var(--gray-800); color: white;
    padding: 12px 18px; border-radius: var(--radius);
    font-size: 0.9rem; box-shadow: var(--shadow-lg);
    animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
    display: flex; align-items: center; gap: 8px;
    pointer-events: all;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warning { background: var(--warning); }
@keyframes toastIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-20px); } }

/* Loading overlay */
.loading-overlay {
    position: fixed; inset: 0; z-index: 4000;
    background: rgba(255,255,255,0.8);
    display: flex; align-items: center; justify-content: center;
    backdrop-filter: blur(2px);
}
.spinner {
    width: 40px; height: 40px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   TABLET & DESKTOP (min-width: 768px)
   ============================================================ */
@media (min-width: 768px) {
    .app-header { display: none; }
    .app-nav {
        position: fixed; left: 0; top: 0; bottom: 0;
        width: 240px; pointer-events: all; z-index: 100;
    }
    .nav-overlay { display: none; }
    .nav-panel {
        transform: none; width: 100%; box-shadow: none;
        border-right: 1px solid var(--gray-200);
    }
    .app-main {
        margin-left: 240px; padding: 24px 32px;
        max-width: calc(100% - 240px);
    }
    .nav-item { padding: 12px 20px; }
    .nav-item.active { padding-left: 17px; }

    .stats-grid { grid-template-columns: repeat(4, 1fr); gap: 16px; }
    .stat-card { padding: 20px; }
    .stat-icon { font-size: 2.5rem; }
    .stat-value { font-size: 1.6rem; }

    .parking-map { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 12px; }
    .parking-spot { padding: 16px 10px; }
    .spot-number { font-size: 1.3rem; }

    .fab { position: static; width: auto; height: auto; border-radius: var(--radius-sm); font-size: 0.9rem; font-weight: 500; padding: 10px 18px; }
    .fab::before { content: '+ '; }

    .modal { align-items: center; }
    .modal-content { max-width: 520px; border-radius: var(--radius-lg); max-height: 85vh; }

    .cards-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }

    .filter-selects { flex-direction: row; }
    .filter-selects select { flex: 1; }

    .page-header h1 { font-size: 1.5rem; }
    .section-header h2 { font-size: 1.2rem; }
}

/* ============================================================
   LARGE DESKTOP (min-width: 1200px)
   ============================================================ */
@media (min-width: 1200px) {
    .app-main { max-width: 1000px; }
    .stats-grid { grid-template-columns: repeat(4, 1fr); }
}

/* ============================================================
   DARK MODE SUPPORT (optional)
   ============================================================ */
@media (prefers-color-scheme: dark) {
    :root {
        --gray-50: #0f172a;
        --gray-100: #1e293b;
        --gray-200: #334155;
        --gray-300: #475569;
        --gray-400: #64748b;
        --gray-500: #94a3b8;
        --gray-600: #cbd5e1;
        --gray-700: #e2e8f0;
        --gray-800: #f1f5f9;
        --gray-900: #f8fafc;
    }
    body { background: #0f172a; color: #e2e8f0; }
    .app-header { background: #0f172a; border-bottom: 1px solid #334155; }
    .stat-card, .card, .parking-spot, .spot-row, .data-table, .filter-tab { background: #1e293b; }
    .data-table th { background: #0f172a; }
    .search-box input { background: #1e293b; border-color: #334155; color: #e2e8f0; }
    .filter-selects select { background-color: #1e293b; border-color: #334155; color: #e2e8f0; }
    .readonly-box { background: #0f172a; border-color: #334155; color: #cbd5e1; }
    .form-group input, .form-group select, .form-group textarea { background: #1e293b; border-color: #334155; color: #e2e8f0; }
    .photo-upload { background: #0f172a; }
    .modal-content { background: #1e293b; }
    .modal-header { background: #1e293b; border-color: #334155; }
    .nav-panel { background: #1e293b; border-color: #334155; }
    .nav-item { border-color: #334155; color: #cbd5e1; }
    .loading-overlay { background: rgba(15,23,42,0.8); }
}


/* ============================================================
   LOGIN SCREEN
   ============================================================ */
.login-screen {
    position: fixed; inset: 0; z-index: 5000;
    background: linear-gradient(135deg, #1e3a5f 0%, #0f172a 100%);
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
}
.login-box {
    background: white; border-radius: var(--radius-lg);
    padding: 32px 24px; width: 100%; max-width: 360px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    animation: fadeIn 0.5s ease;
}
.login-brand { text-align: center; margin-bottom: 24px; }
.login-icon { font-size: 3.5rem; margin-bottom: 8px; }
.login-brand h1 { font-size: 1.4rem; color: var(--dark); margin-bottom: 4px; }
.login-brand p { color: var(--gray-500); font-size: 0.9rem; }
.login-footer { text-align: center; margin-top: 20px; color: var(--gray-400); }
.btn-block { width: 100%; }

/* User badge in header */
.user-badge {
    background: rgba(255,255,255,0.15); color: white;
    padding: 4px 10px; border-radius: 20px;
    font-size: 0.75rem; font-weight: 500;
    display: flex; align-items: center; gap: 4px;
}
.header-actions { display: flex; align-items: center; gap: 10px; }

/* Nav divider */
.nav-divider { height: 1px; background: var(--gray-200); margin: 8px 16px; }
.nav-logout { color: var(--danger) !important; }
.nav-logout:hover { background: var(--danger-light) !important; }

/* Admin-only elements hidden by default */
.admin-only-el { display: none !important; }
body.is-admin .admin-only-el { display: inline-flex !important; }
body.is-admin .admin-only { display: flex !important; }
body.is-admin .admin-only-inline { display: inline !important; }
body.is-admin .admin-only-block { display: block !important; }
body.is-admin .admin-only-table-cell { display: table-cell !important; }

/* Debt cards */
.debt-tabs {
    display: flex; gap: 8px; margin-bottom: 14px;
    background: white; padding: 6px; border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.debt-tab {
    flex: 1; padding: 10px; border-radius: var(--radius-sm);
    border: none; background: transparent; color: var(--gray-500);
    font-size: 0.85rem; font-weight: 600; cursor: pointer;
    transition: var(--transition); text-align: center;
}
.debt-tab.active { background: var(--primary); color: white; }
.debt-panel { display: none; }
.debt-panel.active { display: block; }

.debt-card {
    background: white; border-radius: var(--radius);
    padding: 14px; margin-bottom: 10px;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--danger);
    cursor: pointer; transition: var(--transition);
}
.debt-card:active { transform: scale(0.99); }
.debt-card.paid { border-left-color: var(--success); }
.debt-card-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 8px;
}
.debt-card-name { font-weight: 600; font-size: 0.95rem; color: var(--gray-800); }
.debt-card-amount { font-size: 1.2rem; font-weight: 700; color: var(--danger); }
.debt-card-amount.paid { color: var(--success); }
.debt-card-meta { font-size: 0.8rem; color: var(--gray-500); }
.debt-progress {
    height: 6px; background: var(--gray-200); border-radius: 3px;
    margin-top: 8px; overflow: hidden;
}
.debt-progress-fill {
    height: 100%; border-radius: 3px; background: var(--danger);
    transition: width 0.5s ease;
}
.debt-progress-fill.paid { background: var(--success); }

/* Payment cards */
.payment-card {
    background: white; border-radius: var(--radius);
    padding: 14px; margin-bottom: 10px;
    box-shadow: var(--shadow);
}
.payment-card-header {
    display: flex; justify-content: space-between; align-items: flex-start;
    margin-bottom: 8px;
}
.payment-card-amount { font-size: 1.1rem; font-weight: 700; }
.payment-card-amount.paid { color: var(--success); }
.payment-card-amount.partial { color: var(--warning); }
.payment-card-amount.unpaid { color: var(--danger); }
.payment-card-concept { font-weight: 600; color: var(--gray-800); margin-bottom: 4px; }
.payment-card-meta { font-size: 0.8rem; color: var(--gray-500); }
.payment-card-actions {
    display: flex; gap: 6px; margin-top: 10px;
    padding-top: 10px; border-top: 1px solid var(--gray-100);
}

/* Stats new colors */
.stat-debt .stat-icon { color: var(--danger); }
.stat-pending .stat-icon { color: var(--warning); }

/* User cards */
.user-card {
    background: white; border-radius: var(--radius);
    padding: 14px; margin-bottom: 10px;
    box-shadow: var(--shadow);
    display: flex; align-items: center; gap: 12px;
}
.user-card-avatar {
    width: 44px; height: 44px; border-radius: 50%;
    background: var(--primary-light); color: var(--primary-dark);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem; font-weight: 700; flex-shrink: 0;
}
.user-card-body { flex: 1; min-width: 0; }
.user-card-name { font-weight: 600; font-size: 0.95rem; }
.user-card-meta { font-size: 0.8rem; color: var(--gray-500); margin-top: 2px; }
.user-card-role {
    padding: 3px 10px; border-radius: 12px;
    font-size: 0.7rem; font-weight: 600; flex-shrink: 0;
}
.user-card-role.admin { background: #dbeafe; color: #1e40af; }
.user-card-role.gestor { background: #f3f4f6; color: #6b7280; }

/* Debt detail modal */
.debt-detail-list { display: flex; flex-direction: column; }
.debt-detail-item { padding: 10px 0; border-bottom: 1px solid var(--gray-100); }
.debt-detail-item:last-child { border-bottom: none; }
.debt-detail-item-header {
    display: flex; justify-content: space-between; align-items: center;
    font-weight: 600; color: var(--gray-800); font-size: 0.9rem; gap: 10px;
}
.debt-detail-item-amount { color: var(--danger); font-weight: 700; flex-shrink: 0; }
.debt-detail-item-sub { font-size: 0.78rem; color: var(--gray-500); margin-top: 2px; }
.debt-detail-total {
    display: flex; justify-content: space-between;
    padding-top: 14px; margin-top: 4px; border-top: 2px solid var(--gray-200);
    font-weight: 700; color: var(--dark); font-size: 1rem;
}

/* Spot detail mides */
.spot-detail-mides { background: var(--gray-50); padding: 8px 12px; border-radius: var(--radius-sm); margin-top: 8px; font-size: 0.85rem; color: var(--gray-600); }

/* Payment remaining indicator */
#payment-remaining { text-align: center; }

/* Dark mode additions */
@media (prefers-color-scheme: dark) {
    .login-box { background: #1e293b; }
    .login-brand h1 { color: #f1f5f9; }
    .debt-tabs { background: #1e293b; }
    .debt-card, .payment-card, .user-card { background: #1e293b; }
    .user-card-role.admin { background: #1e3a5f; color: #93c5fd; }
    .user-card-role.gestor { background: #334155; color: #94a3b8; }
    .spot-detail-mides { background: #0f172a; }
}
