/* ============================================================
   LA TUERCA - Sistema de Gestión Profesional
   Tema oscuro premium
   ============================================================ */

:root {
    --bg-primary: #0a0a0b;
    --bg-secondary: #111113;
    --bg-card: #18181b;
    --bg-card-hover: #1f1f23;
    --bg-input: #1a1a1e;
    --border-color: #27272a;
    --border-light: #3f3f46;
    --text-primary: #f4f4f5;
    --text-secondary: #a1a1aa;
    --text-muted: #8b8b95;
    --accent: #dc2626;
    --accent-hover: #b91c1c;
    --accent-glow: rgba(220, 38, 38, 0.15);
    --success: #22c55e;
    --success-bg: rgba(34, 197, 94, 0.1);
    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.1);
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.1);
    --info: #3b82f6;
    --info-bg: rgba(59, 130, 246, 0.1);
    --sidebar-width: 260px;
    --sidebar-collapsed: 70px;
    --topbar-height: 64px;
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --safe-top: env(safe-area-inset-top);
    --safe-bottom: env(safe-area-inset-bottom);
    --safe-left: env(safe-area-inset-left);
    --safe-right: env(safe-area-inset-right);
}

* {
    scrollbar-width: thin;
    scrollbar-color: var(--border-light) transparent;
}

*::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
*::-webkit-scrollbar-track {
    background: transparent;
}
*::-webkit-scrollbar-thumb {
    background: var(--border-light);
    border-radius: 3px;
}
*::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

html {
    overflow-x: hidden;
}
body {
    font-family: var(--font-family);
    background: var(--bg-primary);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    width: 100%;
    overflow-x: hidden;
    max-width:100vw;
}

/* ============================================================
   LAYOUT
   ============================================================ */

.app-layout {
    display: flex;
    min-height: 100dvh;
    width: 100%;
    overflow: clip;
    overflow-x: hidden;
    overflow-y: visible;
}

.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: transform var(--transition), width var(--transition), min-width var(--transition);
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed);
    min-width: var(--sidebar-collapsed);
}

.sidebar.collapsed .sidebar-title-main,
.sidebar.collapsed .sidebar-title-sub,
.sidebar.collapsed .sidebar-link span,
.sidebar.collapsed .sidebar-user-info,
.sidebar.collapsed .sidebar-user-name,
.sidebar.collapsed .sidebar-user-role {
    opacity: 0;
    width: 0;
    overflow: hidden;
    white-space: nowrap;
}

.sidebar-brand {
    padding: 1.25rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sidebar-logo {
    width: 42px;
    height: 42px;
    min-width: 42px;
    background: var(--accent);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: #fff;
    flex-shrink: 0;
}

.sidebar-title {
    overflow: hidden;
}

.sidebar-title-main {
    font-size: 0.95rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    color: #fff;
    display: block;
    white-space: nowrap;
    transition: opacity var(--transition);
}

.sidebar-title-sub {
    font-size: 0.65rem;
    color: var(--text-muted);
    letter-spacing: 0.05em;
    white-space: nowrap;
    transition: opacity var(--transition);
}

.sidebar-nav {
    flex: 1;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 0.85rem;
    border-radius: 0.5rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all var(--transition);
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-link i {
    width: 20px;
    text-align: center;
    font-size: 0.95rem;
    flex-shrink: 0;
}

.sidebar-link:hover {
    background: var(--bg-card-hover);
    color: #fff;
}

.sidebar-link:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.sidebar-link.active {
    background: var(--accent-glow);
    color: var(--accent);
    font-weight: 600;
}

.sidebar-link.active i {
    color: var(--accent);
}

.sidebar-footer {
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border-color);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.5rem;
    border-radius: 0.5rem;
}

.sidebar-user-avatar {
    width: 34px;
    height: 34px;
    min-width: 34px;
    border-radius: 8px;
    background: var(--border-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.85rem;
    color: #fff;
    flex-shrink: 0;
}

.sidebar-user-info {
    overflow: hidden;
    transition: opacity var(--transition);
}

.sidebar-user-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    transition: opacity var(--transition);
}

.sidebar-user-role {
    font-size: 0.7rem;
    color: var(--text-muted);
    white-space: nowrap;
    transition: opacity var(--transition);
}

/* ============================================================
   MAIN CONTENT
   ============================================================ */

.main-wrapper {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    transition: margin-left var(--transition);
}

.sidebar.collapsed ~ .main-wrapper,
.main-wrapper.expanded {
    margin-left: var(--sidebar-collapsed);
}

.topbar {
    height: var(--topbar-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 50;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.topbar-toggle {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    padding: 0.4rem;
    border-radius: 0.4rem;
    cursor: pointer;
    transition: all var(--transition);
    line-height: 1;
}

.topbar-toggle:hover {
    color: #fff;
    background: var(--bg-card-hover);
}

.topbar-toggle:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.topbar-title {
    font-size: 1.1rem;
    font-weight: 600;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.topbar-user-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: none;
    border: none;
    color: var(--text-primary);
    padding: 0.35rem 0.6rem;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: background var(--transition);
}

.topbar-user-btn:hover {
    background: var(--bg-card-hover);
}

.topbar-avatar {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
}

.topbar-name {
    font-size: 0.85rem;
    font-weight: 500;
}

.main-content {
    flex: 1;
    padding: 1.5rem;
    animation: fadeIn 0.3s ease-out;
    min-width: 0;
}

/* ============================================================
   BOOTSTRAP OVERRIDES - DARK THEME
   ============================================================ */

[data-bs-theme="dark"] {
    --bs-body-bg: var(--bg-primary);
    --bs-body-color: var(--text-primary);
    --bs-border-color: var(--border-color);
    --bs-tertiary-bg: var(--bg-card);
    --bs-secondary-color: var(--text-secondary);
}

.form-control,
.form-select {
    background-color: var(--bg-input);
    border-color: var(--border-color);
    color: var(--text-primary);
    border-radius: 0.5rem;
    padding: 0.6rem 0.9rem;
    font-size: 0.9rem;
    transition: all var(--transition);
}

.form-control:focus,
.form-select:focus {
    background-color: var(--bg-input);
    border-color: var(--accent);
    box-shadow: 0 0 0 0.2rem var(--accent-glow);
    color: var(--text-primary);
}

.form-control::placeholder {
    color: var(--text-muted);
}

.form-label {
    font-weight: 500;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
}

.form-check-input:checked {
    background-color: var(--accent);
    border-color: var(--accent);
}

.form-check-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 0.2rem var(--accent-glow);
}

/* ============================================================
   BUTTONS
   ============================================================ */

.btn {
    border-radius: 0.5rem;
    font-weight: 500;
    font-size: 0.875rem;
    padding: 0.55rem 1.25rem;
    transition: all var(--transition);
}

.btn-accent {
    background: var(--accent);
    color: #fff;
    border: none;
    font-weight: 600;
}

.btn-accent:hover {
    background: var(--accent-hover);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(220, 38, 38, 0.3);
}

.btn-ghost {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.btn-ghost:hover {
    background: var(--bg-card-hover);
    color: #fff;
    border-color: var(--border-light);
}

.btn:focus-visible,
.btn-ghost:focus-visible,
.btn-accent:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.btn:disabled,
.btn.disabled,
.btn-accent:disabled,
.btn-ghost:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.form-control:disabled,
.form-select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-lg {
    padding: 0.7rem 1.5rem;
    font-size: 0.95rem;
}

.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
}

/* ============================================================
   CARDS
   ============================================================ */

.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    transition: all var(--transition);
}

.card:hover {
    border-color: var(--border-light);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 1.25rem;
    font-weight: 600;
}

.card-body {
    padding: 1.25rem;
}

/* ============================================================
   STATS CARDS
   ============================================================ */

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    padding: 1.25rem;
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    transition: all var(--transition);
    cursor: default;
    min-width: 0;
}

.stat-card:hover {
    border-color: var(--border-light);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.3);
}

.stat-card > div:last-child {
    min-width: 0;
    flex: 1;
    width: 0;
}

.stat-card-icon {
    width: 48px;
    height: 48px;
    min-width: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.stat-card-icon.accent { background: var(--accent-glow); color: var(--accent); }
.stat-card-icon.info { background: var(--info-bg); color: var(--info); }
.stat-card-icon.success { background: var(--success-bg); color: var(--success); }
.stat-card-icon.warning { background: var(--warning-bg); color: var(--warning); }
.stat-card-icon.danger { background: var(--danger-bg); color: var(--danger); }

.stat-card-value {
    font-size: clamp(0.7rem, 2.5vw, 1.5rem);
    font-weight: 700;
    line-height: 1.2;
    white-space: nowrap;
}

.stat-card-value.stat-card-value-gs {
    display: flex;
    flex-direction: column;
    line-height: 1;
    white-space: normal;
}

.stat-card-currency {
    font-size: 0.6rem;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    line-height: 1;
    margin-bottom: 0.15rem;
    white-space: nowrap;
}

.stat-card-amount {
    font-weight: 700;
    font-size: clamp(0.6rem, 2.5vw, 1.5rem);
    line-height: 1.15;
    white-space: nowrap;
}

.stat-card-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
    line-height: 1.3;
    word-break: break-word;
}

/* ============================================================
   TABLES
   ============================================================ */

.table {
    color: var(--text-primary);
    margin-bottom: 0;
    font-size: 0.875rem;
}

.table > thead {
    border-bottom: 2px solid var(--border-color);
}

.table > thead th {
    background: var(--bg-card);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.75rem 1rem;
    border-bottom: none;
    white-space: nowrap;
}

.table > tbody td {
    padding: 0.7rem 1rem;
    border-color: var(--border-color);
    vertical-align: middle;
}

.table > tbody tr {
    transition: background var(--transition);
}

.table > tbody tr:hover {
    background: var(--bg-card-hover);
}

/* ============================================================
   BADGES
   ============================================================ */

.badge {
    font-weight: 500;
    font-size: 0.75rem;
    padding: 0.35em 0.7em;
    border-radius: 0.375rem;
}

.badge-pending {
    background: var(--warning-bg);
    color: var(--warning);
}

.badge-progress {
    background: var(--info-bg);
    color: var(--info);
}

.badge-completed {
    background: var(--success-bg);
    color: var(--success);
}

.badge-cancelled {
    background: var(--danger-bg);
    color: var(--danger);
}

.status-dropdown .badge {
    cursor: pointer;
    user-select: none;
}

.status-dropdown .dropdown-toggle::after {
    display: none;
}

/* ============================================================
   DROPDOWNS
   ============================================================ */

.dropdown-menu {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 0.4rem;
    box-shadow: 0 10px 40px rgba(0,0,0,0.4);
    min-width: 180px;
}

.dropdown-item {
    color: var(--text-primary);
    border-radius: 0.375rem;
    padding: 0.55rem 0.85rem;
    font-size: 0.85rem;
    transition: all var(--transition);
}

.dropdown-item:hover {
    background: var(--bg-card-hover);
    color: #fff;
}

.dropdown-item:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}

.dropdown-divider {
    border-color: var(--border-color);
    margin: 0.25rem 0;
}

/* ============================================================
   MODALS
   ============================================================ */

.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    box-shadow: 0 25px 80px rgba(0,0,0,0.5);
}

.modal-header {
    border-bottom: 1px solid var(--border-color);
    padding: 1.25rem;
}

.modal-footer {
    border-top: 1px solid var(--border-color);
    padding: 1rem 1.25rem;
}

.modal-body {
    padding: 1.25rem;
}

/* ============================================================
   CUSTOM MODAL OVERLAY (for Nuevo Cliente modal)
   ============================================================ */

.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
    padding: 1rem;
}

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

.modal-container {
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.9) translateY(20px);
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

.modal-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    box-shadow: 0 25px 80px rgba(0,0,0,0.5);
}

.modal-card-header {
    padding: 1.25rem;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
}

.modal-card-body {
    padding: 1.25rem;
}

.modal-card-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border-color);
}

.btn-close-modal {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    line-height: 1;
    padding: 0.25rem;
    cursor: pointer;
    transition: color var(--transition);
    border-radius: 0.375rem;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-close-modal:hover {
    color: #fff;
    background: var(--bg-card-hover);
}

.modal-card .form-control.is-invalid,
.modal-card .form-select.is-invalid {
    border-color: var(--danger);
    box-shadow: 0 0 0 0.2rem var(--danger-bg);
}

.modal-card .invalid-feedback {
    display: none;
    font-size: 0.8rem;
    color: var(--danger);
    margin-top: 0.25rem;
}

.modal-card .form-control.is-invalid ~ .invalid-feedback,
.modal-card .form-select.is-invalid ~ .invalid-feedback {
    display: block;
}

@media (max-width: 576px) {
    .modal-overlay {
        align-items: flex-end;
        padding: 0;
    }
    .modal-container {
        max-width: 100%;
        max-height: 85vh;
        border-radius: 0.75rem 0.75rem 0 0;
    }
    .modal-card {
        border-radius: 0.75rem 0.75rem 0 0;
    }
}

/* ============================================================
   ALERTS / TOASTS
   ============================================================ */

.alert {
    border-radius: 0.5rem;
    border: 1px solid var(--border-color);
    font-size: 0.875rem;
    padding: 0.75rem 1rem;
}

.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: 400px;
    pointer-events: none;
}

.toast-container .toast-custom {
    pointer-events: auto;
}

.toast-custom {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    opacity: 0;
    animation: toastIn 0.35s ease-out forwards;
}

.toast-custom .toast-body {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    color: var(--text-primary);
    font-size: 0.875rem;
    line-height: 1.4;
}

.toast-custom .btn-close {
    flex-shrink: 0;
    margin-top: 2px;
}

.toast-icon {
    font-size: 1.1rem;
    flex-shrink: 0;
    margin-top: 2px;
}

.toast-icon-success { color: #22c55e; }
.toast-icon-error, .toast-icon-danger { color: var(--accent); }
.toast-icon-warning { color: #eab308; }
.toast-icon-info { color: #3b82f6; }

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ============================================================
   PAGINATION
   ============================================================ */

.pagination {
    gap: 0.25rem;
}

.page-link {
    background: var(--bg-card);
    border-color: var(--border-color);
    color: var(--text-secondary);
    border-radius: 0.375rem !important;
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
}

.page-link:hover {
    background: var(--bg-card-hover);
    color: #fff;
    border-color: var(--border-light);
}

.page-item.active .page-link {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    font-weight: 600;
}

.page-item.disabled .page-link {
    background: transparent;
    color: var(--text-muted);
    cursor: not-allowed;
}

.page-link:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ============================================================
   CALENDAR (Agenda)
   ============================================================ */

.calendar-day-header {
    text-align: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    padding: 0.5rem;
}

.calendar-day {
    aspect-ratio: 1;
    border-radius: 0.5rem;
    padding: 0.4rem;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all var(--transition);
    border: 1px solid transparent;
    position: relative;
}

.calendar-day:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-color);
}

/* ============================================================
   ANIMATIONS
   ============================================================ */

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

@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 0 5px rgba(220, 38, 38, 0.3); }
    50% { box-shadow: 0 0 25px rgba(220, 38, 38, 0.6); }
}

.pulse-glow {
    animation: pulse-glow 2s infinite;
}

/* ============================================================
   SERVICE FILTER
   ============================================================ */

.service-filter:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 0.2rem var(--accent-glow);
}

.service-select option[hidden] {
    display: none;
}

/* ============================================================
   COLLAPSE TRANSITION SMOOTH
   ============================================================ */

.stagger-item {
    animation: fadeIn 0.4s ease-out both;
}

.stagger-item:nth-child(1) { animation-delay: 0.05s; }
.stagger-item:nth-child(2) { animation-delay: 0.1s; }
.stagger-item:nth-child(3) { animation-delay: 0.15s; }
.stagger-item:nth-child(4) { animation-delay: 0.2s; }
.stagger-item:nth-child(5) { animation-delay: 0.25s; }
.stagger-item:nth-child(6) { animation-delay: 0.3s; }
.stagger-item:nth-child(7) { animation-delay: 0.35s; }
.stagger-item:nth-child(8) { animation-delay: 0.4s; }

/* ============================================================
   IMAGE GALLERY
   ============================================================ */

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.5rem;
}

.gallery-item {
    aspect-ratio: 4/3;
    border-radius: 0.5rem;
    overflow: hidden;
    cursor: pointer;
    position: relative;
    border: 2px solid transparent;
    transition: all var(--transition);
}

.gallery-item:hover {
    border-color: var(--accent);
    transform: scale(1.02);
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.gallery-item-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 0.5rem;
    background: linear-gradient(transparent, rgba(0,0,0,0.8));
    font-size: 0.7rem;
    color: #fff;
}

/* ============================================================
   SKIP LINK
   ============================================================ */

.skip-link {
    position: absolute;
    top: -100%;
    left: 0;
    z-index: 10000;
    padding: 0.5rem 1rem;
    background: var(--accent);
    color: #fff;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.875rem;
    border-radius: 0 0 0.5rem 0;
}

.skip-link:focus {
    top: 0;
}

/* ============================================================
   ERROR PAGES
   ============================================================ */

.error-code {
    font-size: 5rem;
    font-weight: 800;
    color: var(--text-muted);
    opacity: 0.3;
}

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

.sidebar-overlay {
    display: none;
}

.table-responsive{
    border-radius:.75rem;
    overflow-x:auto;
    overflow-y:hidden;
    -webkit-overflow-scrolling:touch;
}

/* Prevent any element inside .main-content from causing overflow */
.main-content {
    max-width: 100%;
    overflow-x:hidden;
}

/* Contain Bootstrap row negative margins on mobile */
@media (max-width: 767.98px) {
    .row.g-2,
    .row.g-3 {
        overflow: visible;
    }
}

/* ============================================================
   MOBILE-FIRST LAYOUT OVERRIDES
   ============================================================ */

/* ≤ 991px — sidebar overlay (tablet portrait) */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
        visibility: hidden;
        pointer-events: none;
        transition: transform var(--transition), visibility var(--transition);
    }
    .sidebar.mobile-open {
        transform: translateX(0);
        visibility: visible;
        pointer-events: auto;
    }
    .main-wrapper {
        margin-left: 0 !important;
        min-width: 0;
        transition: none;
    }
    .sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.5);
        z-index: 99;
        display: none;
    }
    .sidebar-overlay.active {
        display: block;
    }
}

/* ≤ 768px — tablet vertical / landscape small phone */
@media (max-width: 767.98px) {
    .main-content {
        padding: 0.75rem;
    }

    .main-content .row.g-3 {
        --bs-gutter-x: 0.5rem;
        --bs-gutter-y: 0.5rem;
    }

    .main-content .page-header {
        margin-bottom: 0.5rem;
    }

    .main-content .page-header h4 {
        font-size: 1rem;
    }

    .main-content .page-header p {
        font-size: 0.75rem;
    }

    .main-content .row.mb-4 {
        margin-bottom: 0.75rem !important;
    }

    .stat-card {
        padding: 0.75rem;
        gap: 0.5rem;
    }
    .stat-card-icon {
        width: 36px;
        height: 36px;
        min-width: 36px;
        font-size: 0.9rem;
        border-radius: 10px;
    }
    .stat-card-value {
        font-size: clamp(0.8rem, 3.5vw, 1.15rem);
    }
    .stat-card-amount {
        font-size: clamp(0.7rem, 3vw, 1rem);
    }
    .stat-card-label {
        font-size: 0.7rem;
    }

    .card {
        border-radius: 0.5rem;
    }
    .card-header {
        padding: 0.7rem 0.75rem;
        font-size: 0.85rem;
    }
    .card-body {
        padding: 0.75rem;
    }

    .card-header .btn-sm {
        font-size: 0.7rem;
        padding: 0.3rem 0.5rem;
    }

    .card-header span,
    .card-header .d-flex.align-items-center span {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        min-width: 0;
    }

    .table > thead th {
        white-space: normal;
        font-size: 0.65rem;
        padding: 0.35rem 0.4rem;
    }
    .table > tbody td {
        padding: 0.35rem 0.4rem;
        font-size: 0.75rem;
    }

    .topbar {
        padding: 0 0.75rem;
        gap: 0.5rem;
        height: 56px;
    }
    .topbar-title {
        font-size: 0.9rem;
    }

    .btn {
        font-size: 0.8rem;
        padding: 0.35rem 0.75rem;
    }

    .toast-container {
        left: 0.5rem;
        right: 0.5rem;
        max-width: none;
    }

    .stagger-item {
        animation: none !important;
    }
}

/* ≤ 599px — phones (landscape and portrait) */
@media (max-width: 599.98px) {
    .main-content {
        padding: 0.5rem;
    }

    .main-content .row.g-3 {
        --bs-gutter-x: 0.35rem;
        --bs-gutter-y: 0.35rem;
    }

    .main-content .row.mb-4 {
        margin-bottom: 0.5rem !important;
    }

    .main-content .card.mb-3 {
        margin-bottom: 0.5rem !important;
    }

    .main-content .page-header {
        margin-bottom: 0.35rem;
    }
    .main-content .page-header h4 {
        font-size: 0.9rem;
        margin-bottom: 0.1rem;
    }
    .main-content .page-header p {
        font-size: 0.7rem;
    }

    .stat-card {
        padding: 0.5rem;
        gap: 0.35rem;
        border-radius: 0.5rem;
    }
    .stat-card-icon {
        width: 30px;
        height: 30px;
        min-width: 30px;
        font-size: 0.8rem;
        border-radius: 8px;
    }
    .stat-card-value {
        font-size: clamp(0.7rem, 4vw, 1rem);
    }
    .stat-card-amount {
        font-size: clamp(0.6rem, 3.5vw, 0.9rem);
    }
    .stat-card-label {
        font-size: 0.65rem;
        margin-top: 0.1rem;
    }
    .stat-card-currency {
        font-size: 0.5rem;
        margin-bottom: 0.05rem;
    }

    .card {
        border-radius: 0.5rem;
    }
    .card-header {
        padding: 0.5rem 0.6rem;
        font-size: 0.8rem;
    }
    .card-header span,
    .card-header .d-flex.align-items-center span {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        min-width: 0;
    }
    .card-body {
        padding: 0.6rem;
    }
    .card-header .btn-sm {
        font-size: 0.65rem;
        padding: 0.2rem 0.4rem;
    }

    .table > thead th {
        font-size: 0.6rem;
        padding: 0.25rem 0.3rem;
    }
    .table > tbody td {
        padding: 0.3rem 0.35rem;
        font-size: 0.7rem;
    }

    .btn {
        font-size: 0.75rem;
        padding: 0.3rem 0.6rem;
    }

    .topbar {
        padding: 0 0.5rem;
        gap: 0.35rem;
        height: 52px;
    }
    .topbar-title {
        font-size: 0.85rem;
    }
    .topbar-avatar {
        width: 28px;
        height: 28px;
        font-size: 0.7rem;
    }
    .topbar-toggle {
        font-size: 1rem;
        padding: 0.3rem;
    }

    .d-grid.gap-2 .btn {
        font-size: 0.8rem;
        padding: 0.45rem 0.75rem;
    }

    .calendar-day {
        height: auto;
        min-height: 60px;
        padding: 3px;
    }
    .calendar-day-num {
        font-size: 0.7rem;
    }
    .calendar-job-dot .job-text {
        display: none;
    }
    .calendar-header-cell {
        font-size: 0.55rem;
        padding: 4px 2px;
    }

    .modal-container {
        margin: 0 0.35rem;
    }
    .modal-overlay {
        padding: 0.5rem;
    }

    .auth-page {
        padding: 0.75rem;
    }
    .input-icon-wrapper .form-control {
        padding-left: 2rem;
    }
    .btn-group-sm .btn {
        font-size: 0.65rem;
        padding: 0.15rem 0.35rem;
    }

    .stagger-item {
        animation: none !important;
    }

    .gallery-item-overlay {
        font-size: 0.6rem;
        padding: 0.3rem;
    }
}

/* ≤ 400px — small phones */
@media (max-width: 400px) {
    .main-content {
        padding: 0.35rem;
    }

    .main-content .row.g-3 {
        --bs-gutter-x: 0.25rem;
        --bs-gutter-y: 0.25rem;
    }

    .stat-card {
        padding: 0.4rem;
        gap: 0.3rem;
    }
    .stat-card-icon {
        width: 26px;
        height: 26px;
        min-width: 26px;
        font-size: 0.7rem;
        border-radius: 6px;
    }
    .stat-card-value {
        font-size: clamp(0.6rem, 4.5vw, 0.85rem);
    }
    .stat-card-amount {
        font-size: clamp(0.55rem, 4vw, 0.8rem);
    }
    .stat-card-label {
        font-size: 0.6rem;
    }

    .main-content .row.mb-4 {
        margin-bottom: 0.35rem !important;
    }

    .main-content .card.mb-3 {
        margin-bottom: 0.35rem !important;
    }

    .card-body {
        padding: 0.5rem;
    }
    .card-header {
        padding: 0.4rem 0.5rem;
        font-size: 0.75rem;
    }

    .table > thead th {
        font-size: 0.55rem;
        padding: 0.2rem 0.25rem;
    }
    .table > tbody td {
        padding: 0.25rem 0.3rem;
        font-size: 0.65rem;
    }

    .btn {
        font-size: 0.7rem;
        padding: 0.25rem 0.5rem;
    }

    .topbar-title {
        font-size: 0.8rem;
    }
    .page-header h4 {
        font-size: 0.85rem;
    }
}

/* ≤ 359px — very small phones */
@media (max-width: 359.98px) {
    .main-content .row.mb-4 {
        margin-bottom: 0.25rem !important;
    }

    .main-content .card.mb-3 {
        margin-bottom: 0.25rem !important;
    }

    .card-header span,
    .card-header .d-flex.align-items-center span {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .card-header .btn-sm {
        font-size: 0.55rem;
        padding: 0.15rem 0.3rem;
    }

    .main-content {
        padding: 0.25rem;
    }

    .main-content .row.g-3 {
        --bs-gutter-x: 0.15rem;
        --bs-gutter-y: 0.15rem;
    }

    .stat-card {
        padding: 0.3rem;
        gap: 0.25rem;
    }
    .stat-card-icon {
        width: 22px;
        height: 22px;
        min-width: 22px;
        font-size: 0.6rem;
        border-radius: 5px;
    }
    .stat-card-value {
        font-size: clamp(0.55rem, 5vw, 0.8rem);
    }
    .stat-card-amount {
        font-size: clamp(0.5rem, 4.5vw, 0.75rem);
    }
    .stat-card-label {
        font-size: 0.55rem;
    }

    .card-body {
        padding: 0.4rem;
    }
    .card-header {
        padding: 0.35rem 0.4rem;
        font-size: 0.7rem;
    }

    .btn {
        font-size: 0.65rem;
        padding: 0.2rem 0.4rem;
    }
    .table > thead th {
        font-size: 0.5rem;
        padding: 0.15rem 0.2rem;
    }
    .table > tbody td {
        padding: 0.2rem 0.25rem;
        font-size: 0.6rem;
    }

    .topbar-title {
        font-size: 0.75rem;
    }
    .page-header h4 {
        font-size: 0.8rem;
    }
}
