@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

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

:root {
    /* Paleta corporativa de Taller Con-Ford GR (tomada de confordr.com) */
    --primary: #2f6fa4;
    --primary-hover: #1c4568;
    --primary-light: #e8f1f8;
    --primary-glow: rgba(47, 111, 164, 0.22);
    --secondary: #0a0e14;
    --secondary-light: #121821;
    --accent: #4fc3e8;
    --accent-light: #e8f9fd;
    --success: #10b981;
    --success-light: #d1fae5;
    --danger: #e31e27;
    --danger-light: #fce8e8;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --info: #4fc3e8;
    --info-light: #e8f9fd;
    --purple: #8b5cf6;
    --purple-light: #ede9fe;
    --light: #f4f6f9;
    --border: #e7eaee;
    --border-hover: #cbd2d9;
    --dark: #0a0e14;
    --muted: #667085;
    --sidebar-width: 280px;
    --sidebar-collapsed: 74px;
    --header-height: 72px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.05);
    --shadow-md: 0 4px 14px rgba(15, 23, 42, 0.07);
    --shadow-lg: 0 12px 30px rgba(15, 23, 42, 0.1);
    --shadow-xl: 0 20px 45px rgba(15, 23, 42, 0.15);
    --transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

html, body {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
}

body {
    font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
    background: #f8fafc;
    color: var(--dark);
    line-height: 1.5;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* Sidebar (Light Theme Default) */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    background: #ffffff;
    border-right: 1px solid var(--border);
    position: fixed;
    left: 0;
    top: 0;
    overflow-y: auto;
    transition: var(--transition);
    z-index: 1000;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}

.sidebar::-webkit-scrollbar {
    width: 4px;
}
.sidebar::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.brand {
    height: var(--header-height);
    padding: 0 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    position: sticky;
    top: 0;
    background: #ffffff;
    z-index: 10;
    box-sizing: border-box;
}

.brand-icon {
    width: 42px;
    height: 42px;
    background: linear-gradient(135deg, var(--primary-hover), #2f6fa4);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: white;
    box-shadow: 0 4px 14px var(--primary-glow);
}

.brand-text h1 {
    font-size: 19px;
    font-weight: 800;
    letter-spacing: -0.5px;
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--dark);
}

.brand-text h1 .badge-pro {
    font-size: 10px;
    background: linear-gradient(135deg, var(--primary-hover), #2f6fa4);
    padding: 2px 6px;
    border-radius: 6px;
    text-transform: uppercase;
    font-weight: 700;
    color: white;
}

.brand-text span {
    font-size: 11px;
    color: var(--muted);
    display: block;
}

.menu-section {
    padding: 12px 0;
    border-bottom: 1px solid #f1f5f9;
}

.menu-title {
    padding: 4px 22px 8px;
    font-size: 10.5px;
    text-transform: uppercase;
    color: var(--muted);
    letter-spacing: 0.8px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    user-select: none;
    transition: var(--transition);
}

.menu-title:hover {
    color: var(--primary);
}

.menu-title .menu-title-chevron {
    font-size: 9px;
    transition: transform 0.2s ease;
}

.menu-section.collapsed .menu-title .menu-title-chevron {
    transform: rotate(-90deg);
}

.menu-section.collapsed .menu-item {
    display: none;
}

.menu-item {
    display: flex;
    align-items: center;
    padding: 10px 22px;
    color: #475569;
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    transition: var(--transition);
    cursor: pointer;
    border-left: 3px solid transparent;
    gap: 12px;
}

.menu-item i {
    width: 20px;
    font-size: 15px;
    text-align: center;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.menu-item:hover {
    background: #f8fafc;
    color: var(--primary);
}

.menu-item:hover i {
    transform: scale(1.15);
}

.menu-item.active {
    background: var(--primary-light);
    color: var(--primary);
    border-left-color: var(--primary);
    font-weight: 700;
}

.menu-item.active i {
    transform: scale(1.18);
}

.badge {
    margin-left: auto;
    background: var(--primary);
    color: white;
    font-size: 10px;
    padding: 2px 7px;
    border-radius: 20px;
    font-weight: 700;
}

.badge-new {
    background: linear-gradient(135deg, #10b981, #059669);
}

/* Main Content Area */
.main-content {
    min-height: 100vh;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    box-sizing: border-box;
}

@media (min-width: 1025px) {
    .main-content {
        margin-left: var(--sidebar-width);
        width: calc(100% - var(--sidebar-width));
        max-width: calc(100% - var(--sidebar-width));
    }
}

/* Top Header */
.top-header {
    height: var(--header-height);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 0 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
    box-sizing: border-box;
}

.search-box {
    position: relative;
    width: 360px;
    display: flex;
    align-items: center;
}

.search-box input {
    width: 100%;
    height: 40px;
    padding: 0 16px 0 40px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 13px;
    outline: none;
    transition: var(--transition);
    background: #f8fafc;
    font-family: inherit;
    box-sizing: border-box;
}

.search-box input:focus {
    background: white;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.search-box i {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    font-size: 14px;
}

.search-results {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    width: 100%;
    min-width: 380px;
    background: white;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border);
    max-height: 440px;
    overflow-y: auto;
    z-index: 200;
}

.search-results.open {
    display: block;
    animation: dropdownFade 0.15s ease-out;
}

@keyframes dropdownFade {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
}

.search-results .sr-group-title {
    padding: 10px 16px 4px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: #94a3b8;
    font-weight: 700;
    background: #f8fafc;
}

.search-results .sr-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 10px 16px;
    cursor: pointer;
    border-bottom: 1px solid #f1f5f9;
    transition: var(--transition);
}

.search-results .sr-item:hover {
    background: var(--primary-light);
}

.search-results .sr-item .sr-main {
    font-size: 13.5px;
    color: var(--dark);
    font-weight: 600;
}

.search-results .sr-item .sr-sub {
    font-size: 12px;
    color: var(--muted);
}

.search-results .sr-empty {
    padding: 20px 16px;
    font-size: 13px;
    color: var(--muted);
    text-align: center;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: white;
    color: var(--muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: var(--transition);
    box-sizing: border-box;
}

.hamburger-btn {
    display: none;
    font-size: 17px;
    color: var(--dark);
    margin-right: 6px;
    flex-shrink: 0;
}

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

.sidebar-close-btn {
    display: none;
    background: #f1f5f9;
    border: none;
    border-radius: 8px;
    width: 34px;
    height: 34px;
    align-items: center;
    justify-content: center;
    color: #64748b;
    cursor: pointer;
    font-size: 15px;
    transition: var(--transition);
    margin-left: 8px;
    flex-shrink: 0;
}

.sidebar-close-btn:hover {
    background: #fee2e2;
    color: #ef4444;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 2400;
    opacity: 0;
    transition: opacity 0.25s ease-in-out;
    pointer-events: none;
}

.sidebar-overlay.open {
    display: block;
    opacity: 1;
    pointer-events: auto;
}

/* Mobile Bottom Navigation Bar (< 768px) */
.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 62px;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
    z-index: 1900;
    padding: 0 4px;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    box-sizing: border-box;
    justify-content: space-around;
    align-items: center;
    box-shadow: 0 -4px 18px rgba(15, 23, 42, 0.08);
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    height: 100%;
    color: #64748b;
    text-decoration: none;
    font-size: 10.5px;
    font-weight: 700;
    gap: 3px;
    transition: var(--transition);
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.mobile-nav-item i {
    font-size: 18px;
    transition: var(--transition);
}

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

.mobile-nav-item.active i {
    transform: scale(1.15);
    color: var(--primary);
}

.mobile-nav-item:active {
    transform: scale(0.92);
}

.bcv-pill {
    height: 40px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(5, 150, 105, 0.12);
    color: #059669;
    padding: 0 14px;
    border-radius: var(--radius-md);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    border: 1px solid rgba(5, 150, 105, 0.3);
    user-select: none;
    transition: all 0.2s ease;
    box-sizing: border-box;
}

#btnSyncMobile {
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(37, 99, 235, 0.08);
    color: var(--primary);
    padding: 0;
    border-radius: var(--radius-md);
    font-size: 14px;
    cursor: pointer;
    border: 1px solid rgba(37, 99, 235, 0.25);
    user-select: none;
    transition: all 0.2s ease;
    box-sizing: border-box;
}

#btnSyncMobile:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

#btnSyncMobile.syncing i {
    animation: fa-spin 1s infinite linear;
}

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

.notification-dot {
    position: absolute;
    top: 7px;
    right: 7px;
    width: 8px;
    height: 8px;
    background: var(--danger);
    border-radius: 50%;
    box-shadow: 0 0 0 2px white;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: var(--radius-md);
    transition: var(--transition);
    border: 1px solid transparent;
    position: relative;
}

.user-profile:hover {
    background: var(--light);
    border-color: var(--border);
}

.user-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: white;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border);
    min-width: 200px;
    z-index: 200;
    overflow: hidden;
}

.user-dropdown.open {
    display: block;
    animation: dropdownFade 0.15s ease-out;
}

.user-dropdown button {
    width: 100%;
    text-align: left;
    padding: 12px 18px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 13.5px;
    color: var(--dark);
    font-family: inherit;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: var(--transition);
}

.user-dropdown button:hover {
    background: #f8fafc;
    color: var(--danger);
}

.header-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border);
    width: 340px;
    max-height: 420px;
    overflow-y: auto;
    z-index: 300;
}

.header-dropdown.open {
    display: block;
    animation: dropdownFade 0.15s ease-out;
}

.header-dropdown .hd-title {
    padding: 14px 18px;
    font-size: 13.5px;
    font-weight: 700;
    color: var(--dark);
    border-bottom: 1px solid #f1f5f9;
    background: #fafafa;
}

.header-dropdown .hd-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 18px;
    font-size: 13px;
    color: var(--dark);
    border-bottom: 1px solid #f8fafc;
}

.header-dropdown .hd-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 18px;
    font-size: 13px;
    color: var(--dark);
    cursor: pointer;
    font-weight: 500;
}

.header-dropdown .hd-link:hover {
    background: #f8fafc;
    color: var(--primary);
}

.header-dropdown .hd-empty {
    padding: 24px 18px;
    font-size: 13px;
    color: var(--muted);
    text-align: center;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 14px;
    box-shadow: 0 2px 8px var(--primary-glow);
}

.user-info {
    line-height: 1.3;
}

.user-info .name {
    font-size: 13.5px;
    font-weight: 700;
    color: var(--dark);
}

.user-info .role {
    font-size: 11px;
    color: var(--muted);
}

/* Dashboard & Page Layout */
.dashboard-content {
    padding: 28px 32px;
    max-width: 1600px;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
}

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

.page-title-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-left: auto;
    flex-wrap: wrap;
}

.page-title-text h2 {
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -0.5px;
    color: var(--dark);
    margin-bottom: 4px;
}

.page-title-text p {
    color: var(--muted);
    font-size: 14px;
}

.breadcrumb {
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.breadcrumb a {
    color: var(--muted);
    cursor: pointer;
    text-decoration: none;
    transition: var(--transition);
}

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

/* Stats Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 28px;
}

/* Usado cuando se oculta una tarjeta del Panel Principal (ej: Ingresos del
   Mes para roles sin permiso de ver ingresos), para que las 3 restantes
   ocupen el ancho completo en vez de dejar un hueco en blanco. */
.stats-grid.cols-3 {
    grid-template-columns: repeat(3, 1fr);
}

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

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--border-hover);
}

.stat-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 14px;
}

.stat-icon {
    width: 46px;
    height: 46px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.stat-icon.blue { background: var(--primary-light); color: var(--primary); }
.stat-icon.green { background: var(--success-light); color: var(--success); }
.stat-icon.orange { background: var(--warning-light); color: var(--warning); }
.stat-icon.purple { background: var(--purple-light); color: var(--purple); }
.stat-icon.red { background: var(--danger-light); color: var(--danger); }

.stat-trend {
    font-size: 12px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 20px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.trend-up {
    background: var(--success-light);
    color: #065f46;
}

.trend-down {
    background: var(--danger-light);
    color: #991b1b;
}

.stat-value {
    font-size: 30px;
    font-weight: 800;
    letter-spacing: -0.5px;
    color: var(--dark);
    margin-bottom: 4px;
}

.stat-label {
    font-size: 13px;
    color: var(--muted);
    font-weight: 500;
}

/* Stats Cards - fila secundaria (3 columnas, ej. financiero/alertas del Panel Principal) */
.stats-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 28px;
}

/* Usado cuando se ocultan las tarjetas de Cuentas por Cobrar/Pagar (roles sin
   permiso) y solo queda "Repuestos con Stock Crítico" en esta fila, para que
   esa tarjeta ocupe el ancho completo en vez de dejar dos huecos en blanco. */
.stats-grid-3.cols-1 {
    grid-template-columns: 1fr;
}

/* Panel Principal: Centro de Alertas + Órdenes Recientes lado a lado */
.dashboard-split {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 20px;
    align-items: start;
}

/* Quick Actions */
.quick-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.quick-action {
    background: white;
    border-radius: var(--radius-lg);
    padding: 18px 14px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.quick-action:hover {
    border-color: var(--primary);
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.quick-action i {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 10px;
    font-size: 20px;
    transition: var(--transition);
}

.quick-action.blue i { background: var(--primary-light); color: var(--primary); }
.quick-action.green i { background: var(--success-light); color: var(--success); }
.quick-action.orange i { background: var(--warning-light); color: var(--warning); }
.quick-action.purple i { background: var(--purple-light); color: var(--purple); }
.quick-action.red i { background: var(--danger-light); color: var(--danger); }
.quick-action.teal i { background: #ccfbf1; color: #0f766e; }

.quick-action h4 {
    font-size: 13.5px;
    font-weight: 700;
    margin-bottom: 2px;
    color: var(--dark);
}

.quick-action p {
    font-size: 11.5px;
    color: var(--muted);
}

/* Grid & Cards */
.two-columns {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
    gap: 24px;
    margin-bottom: 28px;
    min-width: 0;
    max-width: 100%;
}

/* Variante de .two-columns con ambas columnas del mismo ancho (50/50) */
.two-columns-equal {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.three-columns {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 24px;
    margin-bottom: 28px;
    min-width: 0;
    max-width: 100%;
}

.card {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    overflow: hidden;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
}

.card-header {
    padding: 18px 24px;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
}

.card-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--dark);
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-action {
    font-size: 13px;
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.card-action:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

.card-body {
    padding: 0;
}

/* Tables */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

.data-table th {
    text-align: left;
    padding: 12px 20px;
    font-size: 11px;
    text-transform: uppercase;
    color: var(--muted);
    font-weight: 700;
    letter-spacing: 0.6px;
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
}

.data-table td {
    padding: 14px 20px;
    border-bottom: 1px solid #f1f5f9;
    color: var(--dark);
    vertical-align: middle;
}

.data-table tr:hover td {
    background: #f8fafc;
}

.status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11.5px;
    font-weight: 700;
}

.status::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.status-completed { background: var(--success-light); color: #065f46; }
.status-completed::before { background: var(--success); }

.status-pending { background: var(--warning-light); color: #92400e; }
.status-pending::before { background: var(--warning); }

.status-progress { background: var(--primary-light); color: #1e40af; }
.status-progress::before { background: var(--primary); }

.status-danger { background: var(--danger-light); color: #991b1b; }
.status-danger::before { background: var(--danger); }

.customer-cell {
    display: flex;
    align-items: center;
    gap: 12px;
}

.customer-avatar {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: var(--primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    color: var(--primary);
    flex-shrink: 0;
}

/* Activity Items */
.activity-list {
    padding: 6px 0;
}

.activity-item {
    display: flex;
    gap: 14px;
    padding: 14px 24px;
    border-bottom: 1px solid #f1f5f9;
    transition: var(--transition);
}

.activity-item:last-child {
    border-bottom: none;
}

.activity-item:hover {
    background: #f8fafc;
}

.activity-icon {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    flex-shrink: 0;
}

.activity-icon.blue { background: var(--primary-light); color: var(--primary); }
.activity-icon.green { background: var(--success-light); color: var(--success); }
.activity-icon.orange { background: var(--warning-light); color: var(--warning); }
.activity-icon.red { background: var(--danger-light); color: var(--danger); }

.activity-content {
    flex: 1;
}

.activity-text {
    font-size: 13.5px;
    line-height: 1.4;
    color: var(--dark);
}

.activity-text strong {
    font-weight: 700;
}

.activity-time {
    font-size: 11px;
    color: var(--muted);
    margin-top: 2px;
}

/* Form Styles */
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    padding: 0;
    width: 100%;
    box-sizing: border-box;
}

.form-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
    width: 100%;
    box-sizing: border-box;
}

.form-group.full,
.form-group.full-width {
    grid-column: 1 / -1;
    width: 100%;
}

.form-group label {
    font-size: 12px;
    font-weight: 600;
    color: #475569;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    outline: none;
    transition: var(--transition);
    font-family: inherit;
    background: white;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.form-group textarea {
    resize: vertical;
    min-height: 75px;
}

.btn {
    padding: 9px 18px;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: inherit;
    user-select: none;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 2px 8px var(--primary-glow);
}

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

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    background: #059669;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-outline {
    background: white;
    border-color: var(--border);
    color: var(--dark);
}

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

.btn-outline.danger,
.btn-outline-danger {
    background: #fff5f5;
    border-color: #fecaca;
    color: #ef4444;
}

.btn-outline.danger:hover,
.btn-outline-danger:hover {
    background: #ef4444;
    border-color: #ef4444;
    color: #ffffff;
}

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

.form-actions {
    padding: 16px 24px 24px;
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    border-top: 1px solid #f1f5f9;
}

.filters-bar {
    display: flex;
    gap: 12px;
    padding: 16px 24px;
    border-bottom: 1px solid #f1f5f9;
    flex-wrap: wrap;
    align-items: center;
    background: #fafafa;
}

.filter-input {
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    outline: none;
    font-family: inherit;
    background: white;
    transition: var(--transition);
}

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

/* Modals */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    z-index: 2000;
    align-items: flex-start;
    justify-content: center;
    padding: 40px 20px;
    overflow-y: auto;
}

.modal-overlay.open {
    display: flex;
    animation: modalIn 0.2s ease-out;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.96); }
    to { opacity: 1; transform: scale(1); }
}

.modal-box {
    background: white;
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 680px;
    box-shadow: var(--shadow-xl);
    overflow: hidden;
    margin: auto 0;
}

.modal-box.modal-lg { max-width: 960px; }
.modal-box.modal-xl { max-width: 1200px; }

.modal-header {
    padding: 20px 26px;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 800;
    color: var(--dark);
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-close {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: var(--muted);
    padding: 4px;
    border-radius: 6px;
    transition: var(--transition);
}

.modal-close:hover {
    color: var(--danger);
    background: var(--danger-light);
}

.modal-body {
    padding: 22px 26px;
    max-height: 75vh;
    overflow-y: auto;
    overflow-x: hidden;
}

.modal-footer {
    padding: 16px 26px;
    border-top: 1px solid #f1f5f9;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    background: #f8fafc;
}

.row-actions {
    display: flex;
    gap: 6px;
}

.row-actions button {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #475569;
    font-size: 13px;
    transition: var(--transition);
}

.row-actions button:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.row-actions button.danger:hover {
    background: var(--danger);
    border-color: var(--danger);
    color: white;
}

.row-actions button.success:hover {
    background: var(--success);
    border-color: var(--success);
    color: white;
}

/* Switches & Toggles */
.toggle-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 0;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 42px;
    height: 24px;
    flex-shrink: 0;
}

.toggle-switch input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: #cbd5e1;
    transition: var(--transition);
    border-radius: 24px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background: white;
    transition: var(--transition);
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--primary);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(18px);
}

/* Toast */
.toast {
    position: fixed;
    bottom: 28px;
    right: 28px;
    background: var(--secondary);
    color: white;
    padding: 14px 22px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    z-index: 9999;
    box-shadow: var(--shadow-xl);
    display: flex;
    align-items: center;
    gap: 10px;
    animation: toastSlide 0.25s ease-out;
}

@keyframes toastSlide {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.section-page { 
    display: none; 
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}
.section-page.active { 
    display: block; 
    animation: pageFade 0.18s ease-out; 
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

@keyframes pageFade {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

.app-hidden { display: none !important; }

/* Login Modal Compact & Centered */
.login-overlay {
    position: fixed;
    inset: 0;
    background: radial-gradient(circle at center, rgba(15, 23, 42, 0.75), rgba(15, 23, 42, 0.95));
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    padding: 16px;
    animation: loginFade 0.25s ease-out;
}

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

.login-box {
    background: #ffffff;
    border-radius: 18px;
    box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(226, 232, 240, 0.8);
    width: 100%;
    max-width: 360px;
    padding: 28px 24px;
    text-align: center;
    position: relative;
    animation: loginModalPop 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes loginModalPop {
    from { opacity: 0; transform: scale(0.92) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.login-box .brand-icon {
    width: 50px;
    height: 50px;
    font-size: 22px;
    margin: 0 auto 12px;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--primary), #1d4ed8);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 16px rgba(37, 99, 235, 0.3);
}

.login-box h2 {
    font-size: 20px;
    font-weight: 800;
    color: #0f172a;
    margin-bottom: 2px;
    letter-spacing: -0.4px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.login-box .sub {
    font-size: 12px;
    color: #64748b;
    margin-bottom: 20px;
    font-weight: 500;
}

.login-box .form-group {
    text-align: left;
    margin-bottom: 18px;
}

.login-box .form-group label {
    font-size: 12px;
    font-weight: 700;
    color: #475569;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.login-box select {
    width: 100%;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1.5px solid #cbd5e1;
    font-size: 12.5px;
    color: #1e293b;
    font-weight: 600;
    background: #f8fafc;
    outline: none;
    transition: all 0.2s ease;
}

.login-box select:focus {
    border-color: var(--primary);
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.login-box .login-btn {
    width: 100%;
    padding: 11px 16px;
    border-radius: 10px;
    font-size: 13.5px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-hover), #2f6fa4);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 6px 16px rgba(47, 111, 164, 0.35);
    transition: all 0.15s ease;
}

.login-box .login-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 20px rgba(47, 111, 164, 0.45);
}

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

/* Premium Receipt / Payment Modal Components */
.segmented-control {
    display: flex;
    background: #f1f5f9;
    padding: 4px;
    border-radius: 12px;
    gap: 6px;
    width: 100%;
    box-sizing: border-box;
}

.segmented-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 14px;
    border: none;
    background: transparent;
    font-size: 13px;
    font-weight: 600;
    color: #64748b;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.segmented-btn.active {
    background: white;
    color: var(--primary);
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    font-weight: 700;
}

.receipt-summary-box {
    background: linear-gradient(135deg, #f8fafc, #f1f5f9);
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 14px 18px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
}

.receipt-summary-item {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.receipt-summary-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #64748b;
}

.receipt-summary-val {
    font-size: 14px;
    font-weight: 700;
    color: #1e293b;
}

.money-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.money-input-wrap .currency-prefix {
    position: absolute;
    left: 14px;
    font-size: 16px;
    font-weight: 700;
    color: #059669;
}

.money-input-wrap input {
    padding-left: 32px !important;
    font-size: 16px !important;
    font-weight: 700 !important;
    color: #059669 !important;
    letter-spacing: 0.5px;
}

.quick-amounts {
    display: flex;
    gap: 8px;
    margin-top: 6px;
    flex-wrap: wrap;
}

.quick-amount-btn {
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    color: #065f46;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.quick-amount-btn:hover {
    background: #d1fae5;
    border-color: #6ee7b7;
    transform: translateY(-1px);
}

.balance-preview-box {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 10px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
    color: #1e40af;
}

/* ==========================================================================
   RESPONSIVE DESIGN SYSTEM (TABLET & MOBILE ERGONOMICS)
   ========================================================================== */

/* 1. TABLETS & DISPOSITIVOS TÁCTILES (<= 1024px)
   Abarca iPads (768px, 810px, 820px, 834px, 1024px), Galaxy Tabs (800px-1024px), Surface y pantallas táctiles */
@media (max-width: 1024px) {
    :root {
        --sidebar-width: 0px !important;
    }

    /* Layout & Navegación Drawer para Tablets */
    .sidebar {
        transform: translateX(-100%);
        position: fixed;
        left: 0;
        top: 0;
        height: 100vh;
        width: 320px;
        max-width: 82vw;
        z-index: 2500;
        box-shadow: none;
        transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
        display: block !important;
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: 8px 0 35px rgba(15, 23, 42, 0.35);
    }

    .sidebar-close-btn {
        display: inline-flex;
    }

    .main-content {
        margin-left: 0 !important;
        padding-bottom: 84px !important; /* Espacio ergonómico para dock/barra inferior */
        width: 100% !important;
        max-width: 100% !important;
        overflow-x: hidden;
    }

    .dashboard-content {
        padding: 16px 16px 28px 16px;
    }

    .hamburger-btn {
        display: inline-flex;
    }

    .mobile-bottom-nav {
        display: flex;
    }

    /* Cabecera Superior en Tablet */
    .top-header {
        height: 64px;
        padding: 0 14px;
        gap: 10px;
    }

    .search-box {
        flex: 1;
        width: auto;
        min-width: 180px;
        max-width: 420px;
    }

    .search-box input {
        height: 40px;
        font-size: 13.5px;
        padding-left: 34px;
        padding-right: 10px;
    }

    .search-box i {
        left: 11px;
        font-size: 13.5px;
    }

    .search-results {
        position: fixed;
        top: 66px;
        left: 12px;
        right: 12px;
        width: auto;
        min-width: 0;
        max-height: 70vh;
    }

    /* Acciones de Cabecera en Tablet */
    .header-actions {
        gap: 8px;
        align-items: center;
    }

    .header-btn {
        width: 38px;
        height: 38px;
    }

    .bcv-pill {
        height: 38px;
        padding: 0 10px;
        font-size: 12px;
        display: inline-flex;
        align-items: center;
    }

    .bcv-pill span {
        display: inline; /* En tablet el texto de tasa BCV es completamente visible */
    }

    #btnSyncMobile {
        height: 38px;
        width: 38px;
        padding: 0;
        justify-content: center;
    }

    #btnSyncMobile .btn-sync-label {
        display: none;
    }

    #headerClockText {
        display: none !important;
    }

    .user-profile {
        padding: 2px 6px;
        gap: 8px;
    }

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

    .user-name {
        font-size: 12.5px;
        font-weight: 700;
    }

    .user-role {
        font-size: 10.5px;
    }

    .user-avatar {
        width: 38px;
        height: 38px;
        font-size: 14px;
    }

    /* Estadísticas y Accesos Rápidos en Tablet */
    .stats-grid, .stats-grid-3 {
        grid-template-columns: repeat(2, 1fr);
        gap: 14px;
        margin-bottom: 18px;
    }

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

    .stat-card {
        padding: 16px;
    }

    .quick-actions {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: 12px;
        margin-bottom: 20px;
    }

    .quick-action {
        padding: 14px 10px;
    }

    .quick-action i {
        width: 42px;
        height: 42px;
        font-size: 18px;
        margin-bottom: 6px;
    }

    .quick-action h4 {
        font-size: 12px;
    }

    .quick-action span {
        font-size: 10.5px;
    }

    .two-columns, .three-columns {
        grid-template-columns: minmax(0, 1fr) !important;
        gap: 16px;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
    }

    .card {
        min-width: 0 !important;
        max-width: 100% !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
    }

    /* Cabeceras de Páginas en Tablet */
    .page-title {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        margin-bottom: 18px;
        flex-wrap: wrap;
    }

    .page-title-actions {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }

    .page-title-actions .btn {
        min-height: 42px;
        padding: 8px 16px;
    }

    .page-title-text h2 {
        font-size: 20px;
    }

    /* Formularios Ergonómicos para Tablet (2 columnas fluidas) */
    .form-grid, .form-grid-2, .form-grid-3, .form-grid-4 {
        grid-template-columns: repeat(2, 1fr);
        gap: 14px;
    }

    input[type="text"],
    input[type="number"],
    input[type="email"],
    input[type="password"],
    input[type="date"],
    input[type="time"],
    select,
    textarea {
        font-size: 16px !important; /* Previene auto-zoom molesto en iPadOS Safari */
        min-height: 44px;
        border-radius: 8px;
    }

    .btn {
        min-height: 42px;
        padding: 8px 16px;
        font-size: 13.5px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    /* Tablas con desplazamiento táctil suave */
    .table-responsive,
    .card-body,
    .data-table-container {
        width: 100%;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
    }

    .data-table {
        min-width: 580px;
        font-size: 12.5px;
    }

    .data-table th, .data-table td {
        padding: 11px 12px;
        white-space: nowrap;
    }

    /* Pestañas de Reportes y Navegación Horizontal */
    .tabs-header, .reportes-tabs-bar {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap !important;
        scrollbar-width: none;
        padding-bottom: 4px;
    }

    .tabs-header::-webkit-scrollbar, .reportes-tabs-bar::-webkit-scrollbar {
        display: none;
    }

    .tab-btn {
        white-space: nowrap;
        flex-shrink: 0;
        font-size: 12.5px;
        padding: 8px 14px;
    }

    /* Menús desplegables adaptados en Tablet */
    .user-dropdown, .header-dropdown {
        max-width: 360px;
    }
}

/* 2. DOCK FLOTANTE & MODALES FLOTANTES PARA TABLETS (601px a 1024px) */
@media (min-width: 601px) and (max-width: 1024px) {
    /* Dock inferior flotante tipo iPadOS / Material 3 */
    .mobile-bottom-nav {
        max-width: 640px;
        left: 50%;
        transform: translateX(-50%);
        bottom: 12px;
        border-radius: 20px;
        border: 1px solid rgba(226, 232, 240, 0.9);
        box-shadow: 0 8px 32px rgba(15, 23, 42, 0.16);
        height: 64px;
        padding: 0 16px;
        background: rgba(255, 255, 255, 0.96);
        backdrop-filter: blur(14px);
    }

    .mobile-nav-item i {
        font-size: 19px;
    }

    .mobile-nav-item span {
        font-size: 11px;
    }

    /* Modales flotantes centrados y amplios para Tablet */
    .modal-overlay {
        padding: 24px;
        align-items: center;
        justify-content: center;
    }

    .modal-box {
        width: 100% !important;
        max-width: min(740px, 92vw) !important;
        max-height: 88vh;
        border-radius: 18px !important;
        margin: 0 auto;
        display: flex;
        flex-direction: column;
        box-shadow: 0 20px 50px rgba(15, 23, 42, 0.22);
    }

    .modal-box.modal-lg, .modal-box.modal-xl {
        max-width: min(920px, 95vw) !important;
    }

    .modal-header {
        padding: 16px 22px;
        flex-shrink: 0;
    }

    .modal-header h3 {
        font-size: 17px;
    }

    .modal-body {
        padding: 18px 22px;
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        max-height: calc(88vh - 135px);
    }

    .modal-footer {
        padding: 14px 22px;
        flex-shrink: 0;
        display: flex;
        flex-direction: row !important;
        justify-content: flex-end;
        gap: 10px;
    }

    .modal-footer .btn {
        width: auto !important;
        min-width: 130px;
        min-height: 42px;
    }
}

/* 2.5. TABLETS VERTICALES Y SMARTPHONES GRANDES (<= 768px) */
@media (max-width: 768px) {
    :root {
        --sidebar-width: 0px !important;
    }

    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
    }
}

/* 3. CELULARES Y TELÉFONOS COMPACTOS (<= 600px) */
@media (max-width: 600px) {
    :root {
        --sidebar-width: 0px !important;
    }

    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    /* Barra inferior de celular de borde a borde */
    .mobile-bottom-nav {
        left: 0;
        right: 0;
        bottom: 0;
        border-radius: 0;
        height: 66px;
    }

    .sidebar {
        width: 290px;
        max-width: 86vw;
    }

    .dashboard-content {
        padding: 12px 10px 24px 10px;
    }

    .top-header {
        height: 60px;
        padding: 0 10px;
        gap: 8px;
    }

    /* El buscador heredaba min-width:180px de la regla de tablet (768px), lo que
       sumado a los botones de acciones desbordaba el encabezado en celulares
       angostos (los iconos de la derecha quedaban cortados / fuera de pantalla).
       Se reduce aquí para que el encabezado completo entre en el ancho disponible. */
    .search-box {
        min-width: 70px;
    }

    .bcv-pill span {
        display: none; /* En celular pequeño mostramos solo el ícono para dar espacio al buscador */
    }

    .user-info {
        display: none;
    }

    /* En smartphones los formularios colapsan a 1 sola columna */
    .form-grid, .form-grid-2, .form-grid-3, .form-grid-4 {
        grid-template-columns: minmax(0, 1fr) !important;
        gap: 12px;
    }

    .stats-grid, .stats-grid-3 {
        grid-template-columns: minmax(0, 1fr) !important;
        gap: 10px;
    }

    .dashboard-split {
        grid-template-columns: minmax(0, 1fr) !important;
    }

    .quick-actions {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 8px;
    }

    .data-table-container,
    .table-responsive {
        width: 100% !important;
        max-width: 100% !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        display: block !important;
    }

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

    .page-title-actions {
        margin-left: 0;
        width: 100%;
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }

    .page-title-actions .btn {
        flex: 1;
        justify-content: center;
        min-height: 42px;
    }

    /* Modales tipo Bottom-Sheet en Celulares */
    .modal-overlay {
        padding: 0;
        align-items: flex-end;
    }

    .modal-box {
        width: 100% !important;
        max-width: 100% !important;
        max-height: 92vh;
        border-radius: 20px 20px 0 0 !important;
        margin: 0;
    }

    .modal-footer {
        flex-direction: column-reverse !important;
        gap: 8px;
    }

    .modal-footer .btn {
        width: 100% !important;
        min-height: 44px;
    }

    .user-dropdown, .header-dropdown {
        position: fixed !important;
        top: 64px !important;
        right: 8px !important;
        left: 8px !important;
        width: auto !important;
        max-width: none !important;
    }
}

/* 4. PANTALLAS ULTRA-PEQUEÑAS (<= 480px) */
@media (max-width: 480px) {
    .brand img {
        max-height: 28px;
    }
    .top-header {
        padding: 0 6px;
        gap: 6px;
    }
    /* En teléfonos muy angostos (<=480px, p.ej. 320px) incluso el min-width:70px
       del buscador sumado a los botones de acción desborda el encabezado. */
    .search-box {
        min-width: 34px;
    }
    .header-actions {
        gap: 6px;
    }
    .dashboard-content {
        padding: 10px 6px 20px 6px;
    }
    .stat-card {
        padding: 12px;
    }
    .bcv-pill {
        display: none; /* En teléfonos muy estrechos se oculta para dar prioridad a búsqueda */
    }
    #db-sync-status span {
        display: none; /* Mostrar solo ícono de base de datos */
    }
}

/* 5. TABLETS EN ORIENTACIÓN HORIZONTAL / LANDSCAPE (1025px - 1280px y pantallas táctiles) */
@media (min-width: 1025px) and (max-width: 1280px) {
    .dashboard-content {
        padding: 20px 22px;
    }
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 16px;
    }
    .stats-grid-3 {
        grid-template-columns: repeat(3, 1fr);
        gap: 16px;
    }
    .quick-actions {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
        gap: 12px;
    }
    .form-grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }
    .modal-box.modal-lg, .modal-box.modal-xl {
        max-width: 90vw;
    }
}

/* Optimización para punteros táctiles gruesos (Touchscreens, Tablets & Stylus) */
@media (pointer: coarse) {
    .btn, button, .menu-item, .mobile-nav-item, .tab-btn {
        -webkit-tap-highlight-color: transparent;
    }
    .btn:active, button:active, .mobile-nav-item:active {
        transform: scale(0.98);
    }
}

/* ==========================================================================
   DARK THEME PALETTE & SYSTEM OVERRIDES
   ========================================================================== */
body.dark-theme {
    --light: #0b0f19;
    --dark: #f8fafc;
    --muted: #94a3b8;
    --border: #24324f;
    --border-hover: #3b4d71;
    --secondary: #080c14;
    --secondary-light: #151e32;
    background: #0b0f19;
    color: #f8fafc;
}

body.dark-theme .top-header {
    background: rgba(19, 27, 46, 0.95);
    border-bottom-color: #24324f;
}

body.dark-theme .card,
body.dark-theme .stat-card,
body.dark-theme .modal-box,
body.dark-theme .quick-action,
body.dark-theme .user-dropdown,
body.dark-theme .header-dropdown,
body.dark-theme .search-results {
    background: #151e32 !important;
    border-color: #24324f !important;
    color: #f8fafc;
}

body.dark-theme .card-header {
    background: #151e32 !important;
    border-bottom: 1px solid #24324f !important;
    color: #f8fafc !important;
}

body.dark-theme .card-body {
    background: #151e32 !important;
    color: #f8fafc;
}

body.dark-theme .card-title,
body.dark-theme .card-title i,
body.dark-theme .page-title h2,
body.dark-theme .page-title-text h2,
body.dark-theme .stat-value,
body.dark-theme .modal-title,
body.dark-theme #modalTitle,
body.dark-theme h2,
body.dark-theme h3,
body.dark-theme h4,
body.dark-theme h5 {
    color: #f8fafc !important;
}

body.dark-theme .card-action {
    color: #60a5fa !important;
}

body.dark-theme .card-action:hover {
    color: #93c5fd !important;
}

body.dark-theme .activity-list {
    background: #151e32;
}

body.dark-theme .activity-item {
    border-bottom: 1px solid #1a253d !important;
    color: #e2e8f0;
}

body.dark-theme .activity-item:hover {
    background: #1c2842 !important;
}

body.dark-theme .activity-title {
    color: #f8fafc !important;
}

body.dark-theme .activity-time {
    color: #94a3b8 !important;
}

body.dark-theme .stat-label,
body.dark-theme .page-title-text p,
body.dark-theme .text-muted {
    color: #94a3b8 !important;
}

body.dark-theme .data-table th {
    background: #0d1424 !important;
    color: #94a3b8 !important;
    border-bottom: 1px solid #24324f !important;
}

body.dark-theme .data-table td {
    border-bottom: 1px solid #1a253d !important;
    color: #e2e8f0 !important;
}

body.dark-theme .data-table tbody tr:hover {
    background: #1c2842 !important;
}

body.dark-theme input,
body.dark-theme select,
body.dark-theme textarea,
body.dark-theme .filter-input,
body.dark-theme .search-box input {
    background: #0d1424 !important;
    color: #f8fafc !important;
    border-color: #24324f !important;
}

body.dark-theme input:focus,
body.dark-theme select:focus,
body.dark-theme textarea:focus,
body.dark-theme .search-box input:focus {
    border-color: var(--primary) !important;
    background: #0d1424 !important;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.25) !important;
}

body.dark-theme input::placeholder,
body.dark-theme textarea::placeholder {
    color: #64748b;
}

body.dark-theme #branchSelectorContainer > div {
    background: #151e32 !important;
    border-color: #24324f !important;
    color: #f8fafc !important;
}

body.dark-theme #globalBranchSelect {
    color: #f8fafc !important;
}

body.dark-theme #globalBranchSelect option {
    background: #0d1424 !important;
    color: #f8fafc !important;
}

body.dark-theme #bcvPill {
    background: rgba(5, 150, 105, 0.2) !important;
    border-color: rgba(5, 150, 105, 0.4) !important;
    color: #34d399 !important;
}

body.dark-theme #btnSyncMobile {
    background: rgba(37, 99, 235, 0.2) !important;
    border-color: rgba(37, 99, 235, 0.4) !important;
    color: #60a5fa !important;
}

body.dark-theme #btnSyncMobile:hover {
    background: var(--primary) !important;
    color: white !important;
}

body.dark-theme .btn-tutorial-help {
    background: rgba(37, 99, 235, 0.15) !important;
    border-color: rgba(37, 99, 235, 0.4) !important;
    color: #60a5fa !important;
}

body.dark-theme .search-results .sr-group-title {
    background: #0d1424;
    color: #94a3b8;
}

body.dark-theme .search-results .sr-item {
    border-bottom-color: #1a253d;
}

body.dark-theme .search-results .sr-item:hover {
    background: rgba(37, 99, 235, 0.15);
}

body.dark-theme .search-results .sr-main {
    color: #f8fafc;
}

body.dark-theme .header-btn {
    background: #151e32;
    color: #cbd5e1;
    border-color: #24324f;
}

body.dark-theme .header-btn:hover {
    background: #24324f;
    color: #ffffff;
}

body.dark-theme .user-profile {
    background: #151e32;
    border-color: #24324f;
}

body.dark-theme .user-profile:hover {
    background: #24324f;
}

body.dark-theme .user-profile .name {
    color: #f8fafc;
}

body.dark-theme .user-dropdown button,
body.dark-theme .header-dropdown .hd-link {
    color: #cbd5e1;
}

body.dark-theme .user-dropdown button:hover,
body.dark-theme .header-dropdown .hd-link:hover {
    background: #24324f;
    color: #ffffff;
}

body.dark-theme .btn-outline {
    border-color: #3b4d71;
    color: #e2e8f0;
    background: transparent;
}

body.dark-theme .btn-outline:hover {
    background: #24324f;
    border-color: #4b638f;
    color: #ffffff;
}

body.dark-theme .modal-header,
body.dark-theme .modal-footer {
    background: #151e32 !important;
    border-color: #24324f !important;
}

body.dark-theme .receipt-summary-box,
body.dark-theme .balance-preview-box,
body.dark-theme .timeline-item,
body.dark-theme .bay-card {
    background: #0d1424 !important;
    border-color: #24324f !important;
    color: #e2e8f0;
}

body.dark-theme .receipt-summary-item {
    border-color: #24324f;
}

body.dark-theme .segmented-control {
    background: #0d1424;
    border-color: #24324f;
}

body.dark-theme .segmented-btn {
    color: #94a3b8;
}

body.dark-theme .segmented-btn.active {
    background: var(--primary);
    color: white;
}

body.dark-theme .calendar-cell {
    background: #151e32;
    border-color: #24324f;
}

body.dark-theme .calendar-cell.other-month {
    background: #0b0f19;
    opacity: 0.35;
}

body.dark-theme .calendar-header-day {
    background: #0d1424;
    color: #94a3b8;
}

body.dark-theme .filters-bar {
    background: transparent;
}

body.dark-theme .sidebar {
    background: #080c14;
    border-right-color: #1a253d;
    scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

body.dark-theme .sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
}

body.dark-theme .brand {
    background: #080c14;
    border-bottom-color: #1a253d;
    color: white;
}

body.dark-theme .sidebar-logo-card {
    background: #ffffff !important;
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.4);
}

body.dark-theme .brand-text h1 {
    color: white;
}

body.dark-theme .brand-text span {
    color: #94a3b8;
}

body.dark-theme .menu-section {
    border-bottom-color: rgba(255, 255, 255, 0.04);
}

body.dark-theme .menu-title {
    color: #64748b;
}

body.dark-theme .menu-title:hover {
    color: #cbd5e1;
}

body.dark-theme .menu-item {
    color: #94a3b8;
}

body.dark-theme .menu-item i {
    color: #94a3b8;
}

body.dark-theme .menu-item:hover {
    background: rgba(255, 255, 255, 0.04);
    color: white;
}

body.dark-theme .menu-item:hover i {
    color: white;
}

body.dark-theme .menu-item.active {
    background: rgba(47, 111, 164, 0.18);
    color: #fb923c;
    border-left-color: var(--primary);
}

body.dark-theme .menu-item.active i {
    color: #fb923c;
}

body.dark-theme #selCambiarTutorial {
    background: #0d1424 !important;
    color: #f8fafc !important;
    border-color: #24324f !important;
}

body.dark-theme .modal-box div[style*="background:white"] {
    background: #0d1424 !important;
    border-color: #24324f !important;
    color: #f8fafc !important;
}

body.dark-theme .modal-box div[style*="color:#0f172a"] {
    color: #f8fafc !important;
}

body.dark-theme .modal-box div[style*="color:#475569"],
body.dark-theme .modal-box div[style*="color:#334155"] {
    color: #cbd5e1 !important;
}

body.dark-theme .modal-box div[style*="background:#f8fafc"] {
    background: #0d1424 !important;
    border-color: #24324f !important;
}

body.dark-theme .damage-type-btn {
    background: #0d1424;
    border-color: #24324f;
    color: #e2e8f0;
}

body.dark-theme .hamburger-btn {
    background: #151e32;
    border-color: #24324f;
    color: #f8fafc;
}

body.dark-theme .sidebar-close-btn {
    background: #1e293b;
    color: #94a3b8;
}

body.dark-theme .mobile-bottom-nav {
    background: rgba(15, 23, 42, 0.96);
    border-color: #24324f;
    border-top-color: #24324f;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
}

body.dark-theme .mobile-nav-item {
    color: #94a3b8;
}

body.dark-theme .mobile-nav-item.active {
    color: var(--primary);
}

/* Buscadores rápidos interactivos de Servicios y Repuestos */
.dropdown-buscador-catalogo {
    z-index: 1050 !important;
}
.item-resultado-busqueda:hover {
    background-color: #f1f5f9 !important;
}
.item-resultado-busqueda:active {
    background-color: #e2e8f0 !important;
}
.dropdown-buscador-catalogo::-webkit-scrollbar {
    width: 6px;
}
.dropdown-buscador-catalogo::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}
