/* ============================================================
   SAN VISTO - Estilos Principales
   Diseño moderno con degradados 3D y colores amigables
   ============================================================ */

:root {
    --primary: #6366F1;
    --primary-dark: #4F46E5;
    --primary-light: #818CF8;
    --primary-gradient: linear-gradient(135deg, #6366F1, #8B5CF6);

    --secondary: #F59E0B;
    --secondary-dark: #D97706;
    --secondary-light: #FBBF24;
    --secondary-gradient: linear-gradient(135deg, #F59E0B, #F97316);

    --accent: #06B6D4;
    --accent-dark: #0891B2;
    --accent-light: #22D3EE;
    --accent-gradient: linear-gradient(135deg, #06B6D4, #14B8A6);

    --success: #10B981;
    --success-gradient: linear-gradient(135deg, #10B981, #34D399);
    --danger: #EF4444;
    --danger-gradient: linear-gradient(135deg, #EF4444, #F87171);
    --warning: #F59E0B;
    --warning-gradient: linear-gradient(135deg, #F59E0B, #FBBF24);
    --info: #3B82F6;
    --info-gradient: linear-gradient(135deg, #3B82F6, #60A5FA);

    --bg-body: #F0F2F8;
    --bg-card: #FFFFFF;
    --bg-sidebar: linear-gradient(180deg, #1E1B4B, #312E81);

    --text-primary: #1E293B;
    --text-secondary: #64748B;
    --text-light: #94A3B8;
    --text-white: #FFFFFF;

    --border: #E2E8F0;
    --border-light: #F1F5F9;

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow: 0 4px 12px rgba(0,0,0,0.1);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);
    --shadow-xl: 0 15px 40px rgba(0,0,0,0.15);
    --shadow-3d: 0 8px 20px -4px rgba(99, 102, 241, 0.3);
    --shadow-3d-hover: 0 12px 28px -4px rgba(99, 102, 241, 0.4);

    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 50px;

    --sidebar-width: 260px;
    --header-height: 70px;

    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---- Reset & Base ---- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--primary-dark);
}

/* ---- Login Page ---- */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1E1B4B 0%, #312E81 40%, #6366F1 100%);
    padding: 20px;
    position: relative;
    overflow: hidden;
}

.login-container::before {
    content: '';
    position: absolute;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(245,158,11,0.3), transparent 70%);
    top: -100px;
    right: -100px;
    border-radius: 50%;
}

.login-container::after {
    content: '';
    position: absolute;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(6,182,212,0.2), transparent 70%);
    bottom: -80px;
    left: -80px;
    border-radius: 50%;
}

.login-card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-radius: var(--radius-xl);
    padding: 48px 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-xl);
    position: relative;
    z-index: 1;
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo h1 {
    font-size: 2.2rem;
    font-weight: 800;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 4px;
}

.login-logo p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.login-card .form-group {
    margin-bottom: 20px;
}

.login-card .form-group label {
    display: block;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.login-card .form-control {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.95rem;
    transition: var(--transition);
    background: var(--bg-body);
}

.login-card .form-control:focus {
    outline: none;
    border-color: var(--primary);
    background: #fff;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

.login-card .btn-login {
    width: 100%;
    padding: 14px;
    background: var(--primary-gradient);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-3d);
    margin-top: 8px;
}

.login-card .btn-login:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-3d-hover);
}

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

.login-error {
    background: #FEF2F2;
    border: 1px solid #FECACA;
    color: var(--danger);
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    font-size: 0.9rem;
    text-align: center;
}

/* ---- Layout Principal ---- */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 100;
    transition: var(--transition);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.sidebar-logo {
    padding: 24px 20px;
    text-align: center;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-logo h2 {
    color: white;
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: 1px;
}

.sidebar-logo small {
    color: rgba(255,255,255,0.5);
    font-size: 0.75rem;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
}

.sidebar-nav .nav-section {
    margin-bottom: 24px;
}

.sidebar-nav .nav-section-title {
    color: rgba(255,255,255,0.4);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    padding: 0 12px;
    margin-bottom: 8px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 16px;
    border-radius: var(--radius);
    color: rgba(255,255,255,0.7);
    font-size: 0.9rem;
    font-weight: 500;
    transition: var(--transition);
    margin-bottom: 4px;
}

.nav-link:hover {
    background: rgba(255,255,255,0.1);
    color: white;
}

.nav-link.active {
    background: var(--primary-gradient);
    color: white;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.nav-link .nav-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}

.nav-link .nav-badge {
    margin-left: auto;
    background: var(--danger);
    color: white;
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-weight: 600;
}

.sidebar-user {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 1rem;
}

.sidebar-user-info {
    flex: 1;
}

.sidebar-user-info .user-name {
    color: white;
    font-size: 0.85rem;
    font-weight: 600;
}

.sidebar-user-info .user-role {
    color: rgba(255,255,255,0.5);
    font-size: 0.75rem;
}

/* ---- Main Content ---- */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-height: 100vh;
}

/* ---- Header ---- */
.header {
    height: var(--header-height);
    background: white;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: var(--shadow-sm);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-left h1 {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary);
}

.header-left .breadcrumb {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.btn-menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.4rem;
    cursor: pointer;
    color: var(--text-primary);
    padding: 8px;
}

.header-notification {
    position: relative;
    padding: 8px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    font-size: 1.2rem;
}

.header-notification:hover {
    background: var(--bg-body);
}

.header-notification .notif-count {
    position: absolute;
    top: 2px;
    right: 2px;
    background: var(--danger);
    color: white;
    font-size: 0.65rem;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.header-user {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: var(--radius);
    transition: var(--transition);
}

.header-user:hover {
    background: var(--bg-body);
}

/* ---- Page Content ---- */
.page-content {
    padding: 28px 32px;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
    flex-wrap: wrap;
    gap: 16px;
}

.page-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
}

/* ---- Stat Cards (Dashboard) ---- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}

.stat-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 24px;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: var(--transition);
}

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

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
}

.stat-card.card-primary::before { background: var(--primary-gradient); }
.stat-card.card-success::before { background: var(--success-gradient); }
.stat-card.card-warning::before { background: var(--warning-gradient); }
.stat-card.card-danger::before { background: var(--danger-gradient); }
.stat-card.card-info::before { background: var(--info-gradient); }
.stat-card.card-accent::before { background: var(--accent-gradient); }
.stat-card.card-secondary::before { background: var(--secondary-gradient); }

.stat-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.stat-card-title {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.stat-card-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    color: white;
    box-shadow: var(--shadow);
}

.stat-card-icon.icon-primary { background: var(--primary-gradient); }
.stat-card-icon.icon-success { background: var(--success-gradient); }
.stat-card-icon.icon-warning { background: var(--warning-gradient); }
.stat-card-icon.icon-danger { background: var(--danger-gradient); }
.stat-card-icon.icon-info { background: var(--info-gradient); }
.stat-card-icon.icon-accent { background: var(--accent-gradient); }
.stat-card-icon.icon-secondary { background: var(--secondary-gradient); }

.stat-card-value {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.2;
}

.stat-card-detail {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-top: 4px;
}

/* ---- Cards ---- */
.card {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
    margin-bottom: 24px;
}

.card-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-header h3 {
    font-size: 1.1rem;
    font-weight: 700;
}

.card-body {
    padding: 24px;
}

.card-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-light);
    background: #FAFBFC;
}

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

.btn:hover {
    transform: translateY(-2px);
}

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

.btn-primary {
    background: var(--primary-gradient);
    color: white;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.4);
    color: white;
}

.btn-success {
    background: var(--success-gradient);
    color: white;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.btn-success:hover {
    box-shadow: 0 6px 16px rgba(16, 185, 129, 0.4);
    color: white;
}

.btn-danger {
    background: var(--danger-gradient);
    color: white;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
    box-shadow: 0 6px 16px rgba(239, 68, 68, 0.4);
    color: white;
}

.btn-warning {
    background: var(--warning-gradient);
    color: white;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

.btn-warning:hover {
    box-shadow: 0 6px 16px rgba(245, 158, 11, 0.4);
    color: white;
}

.btn-info {
    background: var(--info-gradient);
    color: white;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.btn-accent {
    background: var(--accent-gradient);
    color: white;
    box-shadow: 0 4px 12px rgba(6, 182, 212, 0.3);
}

.btn-secondary {
    background: var(--secondary-gradient);
    color: white;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

.btn-outline {
    background: white;
    color: var(--text-primary);
    border: 2px solid var(--border);
    box-shadow: none;
}

.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.btn-sm {
    padding: 6px 14px;
    font-size: 0.8rem;
    border-radius: var(--radius-sm);
}

.btn-lg {
    padding: 14px 28px;
    font-size: 1rem;
    border-radius: var(--radius-lg);
}

.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: var(--radius);
}

.btn-icon.btn-sm {
    width: 32px;
    height: 32px;
}

/* ---- Tables ---- */
.table-container {
    overflow-x: auto;
}

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

.table th {
    background: var(--bg-body);
    padding: 12px 16px;
    text-align: left;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--border);
}

.table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.9rem;
}

.table tr:hover td {
    background: #F8FAFF;
}

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

/* ---- Badges ---- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-success {
    background: #D1FAE5;
    color: #065F46;
}

.badge-danger {
    background: #FEE2E2;
    color: #991B1B;
}

.badge-warning {
    background: #FEF3C7;
    color: #92400E;
}

.badge-info {
    background: #DBEAFE;
    color: #1E40AF;
}

.badge-secondary {
    background: #E2E8F0;
    color: #475569;
}

/* ---- Forms ---- */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    transition: var(--transition);
    background: white;
    font-family: inherit;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

textarea.form-control {
    resize: vertical;
    min-height: 80px;
}

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

.form-text {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-top: 4px;
}

.form-error {
    font-size: 0.8rem;
    color: var(--danger);
    margin-top: 4px;
}

/* ---- Modals ---- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: white;
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    transform: translateY(20px) scale(0.95);
    transition: var(--transition);
}

.modal-overlay.active .modal {
    transform: translateY(0) scale(1);
}

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

.modal-header h3 {
    font-size: 1.2rem;
    font-weight: 700;
}

.modal-close {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--bg-body);
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: var(--text-secondary);
    transition: var(--transition);
}

.modal-close:hover {
    background: var(--border);
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-light);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* ---- Alerts ---- */
.alert {
    padding: 14px 20px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 12px;
}

.alert-success {
    background: #D1FAE5;
    color: #065F46;
    border: 1px solid #A7F3D0;
}

.alert-danger {
    background: #FEE2E2;
    color: #991B1B;
    border: 1px solid #FECACA;
}

.alert-warning {
    background: #FEF3C7;
    color: #92400E;
    border: 1px solid #FDE68A;
}

.alert-info {
    background: #DBEAFE;
    color: #1E40AF;
    border: 1px solid #BFDBFE;
}

/* ---- Search & Filters ---- */
.search-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.search-input {
    flex: 1;
    min-width: 250px;
    position: relative;
}

.search-input input {
    width: 100%;
    padding: 10px 14px 10px 40px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    transition: var(--transition);
}

.search-input input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

.search-input .search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
}

/* ---- Empty State ---- */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.4;
}

.empty-state h3 {
    font-size: 1.1rem;
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 0.9rem;
    color: var(--text-light);
}

/* ---- Toast Notifications ---- */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    padding: 14px 20px;
    border-radius: var(--radius);
    color: white;
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 300px;
    animation: slideInRight 0.4s ease;
}

.toast-success { background: var(--success); }
.toast-danger { background: var(--danger); }
.toast-warning { background: var(--warning); }
.toast-info { background: var(--info); }

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

/* ---- Pagination ---- */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 20px 0;
}

.pagination a, .pagination span {
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    transition: var(--transition);
}

.pagination a {
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.pagination a:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.pagination .active {
    background: var(--primary-gradient);
    color: white;
    border: none;
}

/* ---- Loading Spinner ---- */
.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255,255,255,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9998;
}

/* ---- Grid Layout Helpers ---- */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 24px;
}

.grid-1-2 {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 24px;
}

.grid-info {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px;
    text-align: center;
}

.grid-info-item {
    background: var(--bg-body);
    border-radius: var(--radius-sm);
    padding: 10px;
}

.grid-info-item small {
    color: var(--text-secondary);
    display: block;
    font-size: 0.75rem;
}

.grid-info-item .info-value {
    font-weight: 700;
    font-size: 0.9rem;
}

.grid-actions-visit {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 24px;
}

/* ---- Collection Card (Operator Mobile) ---- */
.collection-card {
    background: white;
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 16px;
    transition: var(--transition);
}

.collection-card:hover {
    border-color: var(--primary-light);
    box-shadow: var(--shadow);
}

.collection-card-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 12px;
}

.collection-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.collection-amount {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--primary);
    margin-left: 8px;
}

/* ---- Bottom Nav (mobile only) ---- */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-top: 1px solid var(--border);
    z-index: 200;
    padding: 6px 0;
    padding-bottom: env(safe-area-inset-bottom, 6px);
    box-shadow: 0 -4px 16px rgba(0,0,0,0.08);
}

.bottom-nav-items {
    display: flex;
    justify-content: space-around;
    align-items: center;
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 12px;
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-size: 0.65rem;
    font-weight: 600;
    text-decoration: none;
    transition: var(--transition);
    position: relative;
}

.bottom-nav-item .nav-emoji {
    font-size: 1.3rem;
    line-height: 1;
}

.bottom-nav-item.active {
    color: var(--primary);
}

.bottom-nav-item .bottom-badge {
    position: absolute;
    top: 0;
    right: 4px;
    background: var(--danger);
    color: white;
    font-size: 0.55rem;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

/* ---- Mobile Table Cards ---- */
.mobile-cards {
    display: none;
}

.mobile-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
}

.mobile-card-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
}

.mobile-card-row:not(:last-child) {
    border-bottom: 1px solid var(--border-light);
}

.mobile-card-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
}

.mobile-card-value {
    font-size: 0.9rem;
    font-weight: 500;
    text-align: right;
}

.mobile-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--bg-body);
}

.mobile-card-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-light);
}

.mobile-card-actions .btn {
    flex: 1;
}

/* ============================================================
   RESPONSIVE DESIGN
   ============================================================ */

/* ---- Tablet landscape (1024px) ---- */
@media (max-width: 1024px) {
    .grid-3 {
        grid-template-columns: 1fr 1fr;
    }

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

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

/* ---- Tablet portrait / Large phone (768px) ---- */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        width: 280px;
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: var(--shadow-xl);
    }

    #sidebarOverlay {
        display: none !important;
    }

    .sidebar.open ~ #sidebarOverlay,
    #sidebarOverlay.active {
        display: block !important;
    }

    .main-content {
        margin-left: 0;
    }

    .btn-menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .page-content {
        padding: 16px;
        padding-bottom: 80px;
    }

    .header {
        padding: 0 16px;
        height: 60px;
    }

    .header-left h1 {
        font-size: 1.1rem;
    }

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

    .stat-card {
        padding: 16px;
    }

    .stat-card-value {
        font-size: 1.3rem;
    }

    .stat-card-icon {
        width: 38px;
        height: 38px;
        font-size: 1rem;
    }

    .stat-card-title {
        font-size: 0.75rem;
    }

    .stat-card-detail {
        font-size: 0.7rem;
    }

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

    .page-header {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .page-header .btn {
        width: 100%;
    }

    .card-header {
        padding: 16px;
        flex-direction: column;
        gap: 8px;
        align-items: stretch;
    }

    .card-header .btn {
        width: 100%;
        justify-content: center;
    }

    .card-body {
        padding: 16px;
    }

    .table th, .table td {
        padding: 10px 8px;
        font-size: 0.78rem;
    }

    .modal-overlay {
        padding: 8px;
        align-items: flex-end;
    }

    .modal {
        max-height: 92vh;
        border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    }

    .modal-header {
        padding: 20px 16px 14px;
    }

    .modal-body {
        padding: 16px;
    }

    .modal-footer {
        padding: 12px 16px;
        flex-direction: column;
    }

    .modal-footer .btn {
        width: 100%;
    }

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

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

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

    .grid-actions-visit {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .search-bar {
        flex-direction: column;
    }

    .search-input {
        min-width: 100%;
    }

    .search-bar select.form-control {
        width: 100% !important;
        min-width: 100% !important;
    }

    .alert {
        flex-direction: column;
        text-align: center;
        padding: 12px 16px;
        font-size: 0.85rem;
    }

    .toast-container {
        top: auto;
        bottom: 70px;
        right: 8px;
        left: 8px;
    }

    .toast {
        min-width: auto;
        width: 100%;
    }

    .bottom-nav {
        display: block;
    }

    .sidebar-user {
        display: none;
    }

    .collection-card-footer {
        flex-direction: column;
        gap: 12px;
        align-items: stretch;
    }

    .collection-card-footer .btn {
        width: 100%;
        justify-content: center;
        padding: 14px;
    }

    .collection-amount {
        font-size: 1.5rem;
        margin-left: 0;
        display: block;
    }
}

/* ---- Small phones (480px) ---- */
@media (max-width: 480px) {
    .login-card {
        padding: 28px 20px;
    }

    .login-logo h1 {
        font-size: 1.8rem;
    }

    .login-card .form-control {
        padding: 14px 16px;
        font-size: 16px; /* prevents iOS zoom */
    }

    .login-card .btn-login {
        padding: 16px;
        font-size: 1.05rem;
    }

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

    .stat-card {
        padding: 12px;
    }

    .stat-card-value {
        font-size: 1.15rem;
    }

    .stat-card-icon {
        width: 32px;
        height: 32px;
        font-size: 0.9rem;
    }

    .stat-card-title {
        font-size: 0.68rem;
    }

    .page-content {
        padding: 12px;
        padding-bottom: 80px;
    }

    .header {
        height: 54px;
    }

    .header-left h1 {
        font-size: 1rem;
    }

    .card {
        border-radius: var(--radius);
    }

    .grid-info {
        grid-template-columns: 1fr 1fr 1fr;
        gap: 6px;
    }

    .grid-info-item {
        padding: 8px 4px;
    }

    .grid-info-item small {
        font-size: 0.65rem;
    }

    .grid-info-item .info-value {
        font-size: 0.78rem;
    }

    .form-control {
        font-size: 16px; /* prevents iOS zoom */
        padding: 12px 14px;
    }

    select.form-control {
        font-size: 16px;
    }

    textarea.form-control {
        font-size: 16px;
    }

    .btn {
        padding: 12px 16px;
        font-size: 0.85rem;
    }

    .btn-lg {
        padding: 16px 20px;
        font-size: 1rem;
    }

    .btn-sm {
        padding: 8px 12px;
        font-size: 0.78rem;
    }

    .table th {
        font-size: 0.7rem;
        padding: 8px 6px;
    }

    .table td {
        font-size: 0.75rem;
        padding: 8px 6px;
    }

    .badge {
        font-size: 0.68rem;
        padding: 3px 8px;
    }

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

    .bottom-nav-item {
        font-size: 0.6rem;
        padding: 4px 6px;
    }

    .bottom-nav-item .nav-emoji {
        font-size: 1.15rem;
    }

    .collection-card {
        padding: 14px;
    }

    .collection-card h4 {
        font-size: 1rem;
    }
}

/* ---- Tiny phones (360px) ---- */
@media (max-width: 360px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .stat-card {
        padding: 14px;
    }

    .stat-card-header {
        flex-direction: row;
    }

    .stat-card-value {
        font-size: 1.4rem;
    }

    .grid-info {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .login-card {
        padding: 24px 16px;
    }

    .login-logo h1 {
        font-size: 1.6rem;
    }

    .page-content {
        padding: 8px;
        padding-bottom: 80px;
    }
}

/* ---- Desktop-only table, mobile cards ---- */
@media (max-width: 640px) {
    .desktop-table {
        display: none;
    }

    .mobile-cards {
        display: block;
    }
}

@media (min-width: 641px) {
    .mobile-cards {
        display: none;
    }
}

/* ---- Safe area for notched phones ---- */
@supports (padding: env(safe-area-inset-bottom)) {
    .bottom-nav {
        padding-bottom: calc(6px + env(safe-area-inset-bottom));
    }

    @media (max-width: 768px) {
        .page-content {
            padding-bottom: calc(80px + env(safe-area-inset-bottom));
        }
    }
}

/* ---- Landscape phone ---- */
@media (max-height: 500px) and (orientation: landscape) {
    .login-container {
        min-height: auto;
        padding: 16px;
    }

    .login-card {
        padding: 20px;
    }

    .login-logo {
        margin-bottom: 16px;
    }

    .login-logo h1 {
        font-size: 1.5rem;
    }

    .modal-overlay {
        align-items: center;
    }

    .modal {
        max-height: 90vh;
        border-radius: var(--radius-xl);
    }
}

/* ---- Print ---- */
@media print {
    .sidebar,
    .header,
    .bottom-nav,
    .btn,
    .search-bar,
    .modal-overlay {
        display: none !important;
    }

    .main-content {
        margin-left: 0;
    }

    .page-content {
        padding: 0;
    }

    .card {
        box-shadow: none;
        border: 1px solid #ddd;
    }

    .stat-card {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}

/* ---- Utilities ---- */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-secondary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.fw-bold { font-weight: 700; }
.fw-semibold { font-weight: 600; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.w-100 { width: 100%; }
.hidden { display: none !important; }
