/* ============================================
   COLMAPP — Premium Style (Linear + Tremor)
   ============================================ */

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

/* === LIGHT THEME (Default) === */
:root, [data-theme="light"] {
    --bg-primary: #F8F9FC;
    --bg-secondary: #FFFFFF;
    --bg-tertiary: #F3F4F6;
    --border-color: #E5E7EB;
    --text-primary: #111827;
    --text-secondary: #4B5563;
    --text-muted: #9CA3AF;

    --green-500: #22C55E;
    --green-600: #16A34A;
    --blue-500: #3B82F6;
    --orange-500: #F97316;
    --red-500: #EF4444;
    --purple-500: #A855F7;
    --yellow-500: #EAB308;

    /* Acento primario configurable: por defecto verde */
    --accent: var(--green-500);
    --accent-strong: var(--green-600);
    --accent-soft: rgba(34,197,94,0.1);
    --accent-soft-2: rgba(34,197,94,0.18);

    --sidebar-bg: #FFFFFF;
    --topbar-bg: rgba(255,255,255,0.85);
    --shadow-lg: 0 4px 24px rgba(0,0,0,0.08);
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.04);
    --shadow-xl: 0 24px 64px rgba(0,0,0,0.18);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 22px;
    --radius-full: 9999px;
    --transition: all 0.2s ease;
}

/* Acentos alternativos */
[data-accent="blue"]   { --accent: #3B82F6; --accent-strong: #2563EB; --accent-soft: rgba(59,130,246,0.10); --accent-soft-2: rgba(59,130,246,0.18); }
[data-accent="orange"] { --accent: #F97316; --accent-strong: #EA580C; --accent-soft: rgba(249,115,22,0.10); --accent-soft-2: rgba(249,115,22,0.18); }
[data-accent="purple"] { --accent: #A855F7; --accent-strong: #9333EA; --accent-soft: rgba(168,85,247,0.10); --accent-soft-2: rgba(168,85,247,0.18); }
[data-accent="red"]    { --accent: #EF4444; --accent-strong: #DC2626; --accent-soft: rgba(239,68,68,0.10); --accent-soft-2: rgba(239,68,68,0.18); }

/* === DARK THEME === */
[data-theme="dark"] {
    --bg-primary: #0F1117;
    --bg-secondary: #1A1D27;
    --bg-tertiary: #232633;
    --border-color: #2A2D3E;
    --text-primary: #FFFFFF;
    --text-secondary: #A0A3B1;
    --text-muted: #6B7280;

    --sidebar-bg: #13151F;
    --topbar-bg: rgba(19,21,31,0.78);
    --shadow-lg: 0 4px 24px rgba(0,0,0,0.4);
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.3);
    --shadow-xl: 0 24px 64px rgba(0,0,0,0.55);
}

/* === RESET & BASE === */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    transition: background 0.3s ease, color 0.3s ease;
}

/* === APP LAYOUT === */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* === SIDEBAR === */
.sidebar {
    width: 260px;
    background: var(--sidebar-bg);
    color: var(--text-primary);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 1000;
    transition: var(--transition);
    overflow: hidden;
    border-right: 1px solid var(--border-color);
}

.sidebar,
.sidebar-nav,
.popover-list {
    scrollbar-width: thin;
    scrollbar-color: transparent transparent;
}

.sidebar:hover,
.sidebar-nav:hover,
.popover-list:hover {
    scrollbar-color: var(--border-color) transparent;
}

.sidebar::-webkit-scrollbar,
.sidebar-nav::-webkit-scrollbar,
.popover-list::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.sidebar::-webkit-scrollbar-track,
.sidebar-nav::-webkit-scrollbar-track,
.popover-list::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb,
.sidebar-nav::-webkit-scrollbar-thumb,
.popover-list::-webkit-scrollbar-thumb {
    background: transparent;
    border-radius: var(--radius-full);
}

.sidebar:hover::-webkit-scrollbar-thumb,
.sidebar-nav:hover::-webkit-scrollbar-thumb,
.popover-list:hover::-webkit-scrollbar-thumb {
    background: var(--border-color);
}

.sidebar-header {
    padding: 24px 20px 20px;
    border-bottom: 1px solid var(--border-color);
}

.logo {
    display: flex;
    align-items: center;
    gap: 14px;
}

.logo-icon {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--green-500), var(--green-600));
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.logo-text strong {
    display: block;
    font-size: 1.15rem;
    letter-spacing: 1.5px;
    font-weight: 700;
}

.logo-text small {
    font-size: 0.72rem;
    opacity: 0.6;
    letter-spacing: 0.3px;
}

.colmado-info {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.plan-badge {
    font-size: 0.65rem;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-weight: 600;
    letter-spacing: 0.5px;
    background: rgba(34,197,94,0.15);
    color: var(--green-500);
}

.sidebar-nav {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 12px 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 20px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: var(--transition);
    border-left: 3px solid transparent;
    margin: 2px 0;
    font-size: 0.88rem;
    font-weight: 500;
}

.nav-item:hover {
    background: rgba(34,197,94,0.05);
    color: var(--text-primary);
}

.nav-item.active {
    background: rgba(34,197,94,0.1);
    color: var(--green-500);
    border-left-color: var(--green-500);
}

.nav-icon {
    font-size: 1.25rem;
    width: 26px;
    text-align: center;
}

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

.sidebar-mobile-user,
.sidebar-mobile-quick {
    display: none;
}

.nav-count {
    background: var(--red-500);
    border-radius: var(--radius-full);
    color: #fff;
    font-size: 0.68rem;
    font-weight: 800;
    line-height: 1;
    margin-left: auto;
    min-width: 20px;
    padding: 4px 6px;
    text-align: center;
}

.logout-btn {
    color: var(--red-500) !important;
}

/* Theme Toggle Button */
.theme-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    margin: 8px 0;
    cursor: pointer;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-size: 0.82rem;
    font-weight: 500;
    transition: var(--transition);
    font-family: inherit;
    width: calc(100% - 40px);
}

.theme-toggle:hover {
    background: var(--border-color);
    color: var(--text-primary);
}

.theme-toggle .icon {
    font-size: 1.1rem;
}

/* === MAIN CONTENT === */
.main-content {
    margin-left: 260px;
    flex: 1;
    min-height: 100vh;
    transition: var(--transition);
}

.page-header {
    background: var(--bg-secondary);
    padding: 28px 36px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    transition: var(--transition);
}

.page-header h1 {
    color: var(--text-primary);
    font-size: 1.7rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.page-header p {
    color: var(--text-secondary);
    font-size: 0.92rem;
    margin-top: 4px;
}

.page-body {
    padding: 32px 36px;
}

/* === CARDS === */
.card {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 28px;
    margin-bottom: 24px;
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-lg);
    border-color: var(--green-500);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 22px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.card-header h2 {
    font-size: 1.05rem;
    font-weight: 650;
    color: var(--text-primary);
}

/* === STATS GRID === */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 26px;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 18px;
    transition: var(--transition);
    border: 1px solid var(--border-color);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--green-500);
    opacity: 0;
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    border-color: var(--green-500);
}

.stat-card:hover::before {
    opacity: 1;
}

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.stat-icon.green { 
    background: linear-gradient(135deg, rgba(34,197,94,0.15), rgba(34,197,94,0.05)); 
    color: var(--green-500);
}
.stat-icon.blue { 
    background: linear-gradient(135deg, rgba(59,130,246,0.15), rgba(59,130,246,0.05)); 
    color: var(--blue-500);
}
.stat-icon.orange { 
    background: linear-gradient(135deg, rgba(249,115,22,0.15), rgba(249,115,22,0.05)); 
    color: var(--orange-500);
}
.stat-icon.red { 
    background: linear-gradient(135deg, rgba(239,68,68,0.15), rgba(239,68,68,0.05)); 
    color: var(--red-500);
}

.stat-info h3 {
    font-size: 42px;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.2;
}

@media (max-width: 768px) {
    .stat-info h3 {
        font-size: 1.4rem;
    }
}

/* Smaller stats for caja page */
.page-body .stats-grid .stat-card .stat-info h3 {
    font-size: 1.1rem;
}

.stat-info p {
    font-size: 0.84rem;
    color: var(--text-secondary);
    font-weight: 500;
    margin-top: 4px;
}

/* === TABLES === */
.table-responsive {
    overflow-x: auto;
    border-radius: var(--radius-md);
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

table thead th {
    background: var(--bg-tertiary);
    padding: 14px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 0.78rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    border-bottom: 2px solid var(--border-color);
}

table tbody td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.88rem;
    color: var(--text-primary);
}

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

table tbody tr:hover {
    background: rgba(34,197,94,0.03);
}

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

/* === BUTTONS === */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 22px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, var(--green-500), var(--green-600));
    color: white;
    box-shadow: 0 2px 8px rgba(34,197,94,0.25);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--green-600), var(--green-500));
    box-shadow: 0 4px 14px rgba(34,197,94,0.35);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

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

.btn-outline:hover {
    background: rgba(34,197,94,0.05);
    border-color: var(--green-500);
    color: var(--text-primary);
}

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

.btn-sm {
    padding: 7px 14px;
    font-size: 0.82rem;
}

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

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

.form-control {
    width: 100%;
    padding: 11px 15px;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 16px;
    transition: var(--transition);
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.form-control:focus {
    outline: none;
    border-color: var(--green-500);
    box-shadow: 0 0 0 4px rgba(34,197,94,0.12);
}

select.form-control {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%234B5563' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
}

[data-theme="dark"] select.form-control {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23A0A3B1' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
}

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

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

/* === BADGES === */
.badge {
    display: inline-block;
    padding: 4px 11px;
    border-radius: var(--radius-full);
    font-size: 0.76rem;
    font-weight: 600;
}

.badge-success { background: rgba(34,197,94,0.15); color: var(--green-500); }
.badge-warning { background: rgba(249,115,22,0.15); color: var(--orange-500); }
.badge-danger { background: rgba(239,68,68,0.15); color: var(--red-500); }
.badge-info { background: rgba(59,130,246,0.15); color: var(--blue-500); }

/* === ALERTS === */
.alert {
    padding: 16px 22px;
    border-radius: var(--radius-md);
    margin-bottom: 22px;
    font-size: 0.9rem;
    font-weight: 500;
    animation: slideDown 0.3s ease;
}

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

.alert-success { background: rgba(34,197,94,0.1); color: var(--green-500); border-left: 4px solid var(--green-500); }
.alert-danger { background: rgba(239,68,68,0.1); color: var(--red-500); border-left: 4px solid var(--red-500); }
.alert-info { background: rgba(59,130,246,0.1); color: var(--blue-500); border-left: 4px solid var(--blue-500); }
.alert-warning { background: rgba(249,115,22,0.1); color: var(--orange-500); border-left: 4px solid var(--orange-500); }

/* === LOGIN PAGE === */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 50%, var(--sidebar-bg) 100%);
    padding: 20px;
    position: relative;
    overflow: hidden;
}

.login-container {
    background: var(--bg-secondary);
    backdrop-filter: blur(10px);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    padding: 52px 48px;
    width: 100%;
    max-width: 440px;
    position: relative;
    z-index: 1;
    border: 1px solid var(--border-color);
}

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

.login-logo .logo-icon {
    font-size: 3.2rem;
    display: block;
    margin-bottom: 14px;
}

.login-logo h1 {
    font-size: 2rem;
    color: var(--text-primary);
    font-weight: 800;
    letter-spacing: 1.5px;
}

.login-logo p {
    color: var(--text-secondary);
    font-size: 0.92rem;
    margin-top: 6px;
    font-style: italic;
}

.login-form .btn {
    width: 100%;
    padding: 14px;
    font-size: 1rem;
    margin-top: 8px;
}

.login-error {
    background: rgba(239,68,68,0.1);
    color: var(--red-500);
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-size: 0.9rem;
    border-left: 3px solid var(--red-500);
}

/* === MODAL === */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(6px);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--bg-secondary);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    width: 92%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalIn 0.3s ease;
    border: 1px solid var(--border-color);
}

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

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

.modal-close {
    background: var(--bg-tertiary);
    border: none;
    font-size: 1.4rem;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

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

.modal-body {
    padding: 26px;
}

.modal-footer {
    padding: 18px 26px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* === ACTIONS === */
.action-btns {
    display: flex;
    gap: 6px;
}

.action-btn {
    width: 34px;
    height: 34px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: var(--transition);
}

.action-btn.edit { background: rgba(59,130,246,0.15); color: var(--blue-500); }
.action-btn.delete { background: rgba(239,68,68,0.15); color: var(--red-500); }

.action-btn:hover {
    transform: scale(1.12);
}

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

.empty-state .icon {
    font-size: 3.5rem;
    margin-bottom: 16px;
    display: block;
}

.empty-state h3 {
    margin-bottom: 8px;
    color: var(--text-primary);
    font-size: 1.1rem;
    font-weight: 600;
}

/* === SEARCH BAR === */
.search-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.search-input {
    flex: 1;
    min-width: 220px;
    padding: 11px 16px;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.9rem;
    transition: var(--transition);
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

/* === PAGINATION === */
.pagination {
    display: flex;
    justify-content: center;
    gap: 4px;
    margin-top: 28px;
}

.pagination a, .pagination span {
    padding: 9px 14px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 0.88rem;
    font-weight: 500;
    transition: var(--transition);
}

.pagination a:hover {
    background: rgba(34,197,94,0.05);
}

.pagination .active {
    background: var(--green-500);
    color: white;
}

/* === ANIMATIONS === */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fadeIn 0.4s ease;
}

/* === TOAST NOTIFICATIONS === */
.toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.toast {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px 20px;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 320px;
    max-width: 420px;
    animation: toastIn 0.3s ease;
    transition: var(--transition);
}

.toast.removing {
    animation: toastOut 0.3s ease forwards;
}

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

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

.toast-icon {
    font-size: 1.3rem;
    flex-shrink: 0;
}

.toast-content {
    flex: 1;
}

.toast-title {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.toast-message {
    font-size: 0.82rem;
    color: var(--text-secondary);
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.2rem;
    padding: 4px;
    transition: var(--transition);
}

.toast-close:hover {
    color: var(--text-primary);
}

.toast.success { border-left: 4px solid var(--green-500); }
.toast.error { border-left: 4px solid var(--red-500); }
.toast.info { border-left: 4px solid var(--blue-500); }
.toast.warning { border-left: 4px solid var(--orange-500); }

/* === CHART CONTAINERS === */
.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
    margin: 20px 0;
}

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

@media (max-width: 768px) {
    .chart-grid {
        grid-template-columns: 1fr;
    }
    
    .toast-container {
        top: 16px;
        right: 16px;
        left: 16px;
    }
    
    .toast {
        min-width: auto;
        max-width: none;
    }
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        width: 240px;
        box-shadow: 4px 0 25px rgba(0,0,0,0.2);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .page-header {
        padding: 20px 24px;
    }
    
    .page-header h1 {
        font-size: 1.35rem;
    }
    
    .page-body {
        padding: 24px;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    
    .stat-card {
        padding: 16px;
    }
    
    .stat-info h3 {
        font-size: 1.4rem;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
}

/* === ICON CIRCLES (Premium) === */
.icon-circle {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
}

.icon-circle.green {
    background: radial-gradient(circle at 30% 30%, rgba(34,197,94,0.2), rgba(34,197,94,0.05));
    color: var(--green-500);
    box-shadow: 0 2px 12px rgba(34,197,94,0.15);
}

.icon-circle.blue {
    background: radial-gradient(circle at 30% 30%, rgba(59,130,246,0.2), rgba(59,130,246,0.05));
    color: var(--blue-500);
    box-shadow: 0 2px 12px rgba(59,130,246,0.15);
}

.icon-circle.orange {
    background: radial-gradient(circle at 30% 30%, rgba(249,115,22,0.2), rgba(249,115,22,0.05));
    color: var(--orange-500);
    box-shadow: 0 2px 12px rgba(249,115,22,0.15);
}

.icon-circle.red {
    background: radial-gradient(circle at 30% 30%, rgba(239,68,68,0.2), rgba(239,68,68,0.05));
    color: var(--red-500);
    box-shadow: 0 2px 12px rgba(239,68,68,0.15);
}

/* === LOADING SPINNER === */
.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--green-500);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 40px auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* === SKELETON LOADING === */
.skeleton {
    background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--border-color) 50%, var(--bg-tertiary) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: var(--radius-sm);
    color: transparent !important;
    pointer-events: none;
    user-select: none;
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ============================================================
   ✨ MEJORAS UI 2026 — Utilidades, Topbar, CmdK, POS, Mobile Nav
   ============================================================ */

/* ========== ICON BASE (SVG Lucide) ========== */
.icon { display: inline-block; vertical-align: -3px; flex-shrink: 0; stroke: currentColor; }
.icon-lg { width: 28px; height: 28px; }
.icon-xl { width: 36px; height: 36px; }

/* ========== UTILIDADES TIPO TAILWIND LIGHT ========== */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-start { display: flex; align-items: center; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.justify-end { justify-content: flex-end; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; }
.gap-xs { gap: 4px; } .gap-sm { gap: 8px; } .gap-md { gap: 12px; } .gap-lg { gap: 20px; } .gap-xl { gap: 28px; }
.grid { display: grid; }
.w-full { width: 100%; } .h-full { height: 100%; }
.text-center { text-align: center; } .text-right { text-align: right; }
.text-xs { font-size: 0.72rem; } .text-sm { font-size: 0.82rem; } .text-md { font-size: 0.92rem; }
.text-lg { font-size: 1.05rem; } .text-xl { font-size: 1.4rem; } .text-2xl { font-size: 1.8rem; }
.font-medium { font-weight: 500; } .font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; } .font-extrabold { font-weight: 800; }
.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.text-green { color: var(--green-500); }
.text-blue { color: var(--blue-500); }
.text-orange { color: var(--orange-500); }
.text-red { color: var(--red-500); }
.text-accent { color: var(--accent); }
.uppercase { text-transform: uppercase; letter-spacing: 0.6px; }
.rounded-sm { border-radius: var(--radius-sm); }
.rounded-md { border-radius: var(--radius-md); }
.rounded-lg { border-radius: var(--radius-lg); }
.rounded-full { border-radius: var(--radius-full); }
.bg-tertiary { background: var(--bg-tertiary); }
.bg-secondary { background: var(--bg-secondary); }
.border { border: 1px solid var(--border-color); }
.shadow-sm { box-shadow: var(--shadow-sm); }
.shadow-lg { box-shadow: var(--shadow-lg); }
.mt-0 { margin-top: 0; } .mt-xs { margin-top: 4px; } .mt-sm { margin-top: 8px; } .mt-md { margin-top: 14px; } .mt-lg { margin-top: 22px; }
.mb-0 { margin-bottom: 0; } .mb-xs { margin-bottom: 4px; } .mb-sm { margin-bottom: 8px; } .mb-md { margin-bottom: 14px; } .mb-lg { margin-bottom: 22px; }
.p-sm { padding: 10px; } .p-md { padding: 16px; } .p-lg { padding: 24px; }
.cursor-pointer { cursor: pointer; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

/* ========== TRANSICIÓN DE TEMA SUAVE ========== */
html { transition: background-color 0.25s ease, color 0.25s ease; }

/* ========== TOPBAR GLOBAL ========== */
.topbar {
    position: sticky;
    top: 0;
    z-index: 900;
    background: var(--topbar-bg);
    backdrop-filter: saturate(180%) blur(18px);
    -webkit-backdrop-filter: saturate(180%) blur(18px);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 28px;
    min-height: 60px;
}
.topbar .topbar-left { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.topbar .topbar-search { flex: 1; max-width: 560px; }
.topbar .topbar-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.topbar-desktop-only { display: block; }
.topbar .breadcrumbs { display: flex; align-items: center; gap: 8px; color: var(--text-muted); font-size: 0.84rem; }
.topbar .breadcrumbs .icon { width: 14px; height: 14px; opacity: 0.7; }
.topbar .breadcrumbs .crumb-current { color: var(--text-primary); font-weight: 600; }

.cmdk-trigger {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 9px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.86rem;
    transition: var(--transition);
    font-family: inherit;
}
.cmdk-trigger:hover { border-color: var(--accent); color: var(--text-primary); }
.cmdk-trigger .kbd-hint { margin-left: auto; display: inline-flex; gap: 3px; }
.kbd {
    font-family: 'SF Mono', ui-monospace, monospace;
    font-size: 0.7rem;
    padding: 2px 6px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-bottom-width: 2px;
    border-radius: 5px;
    color: var(--text-secondary);
    line-height: 1;
}

.icon-btn {
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    flex-shrink: 0;
}
.icon-btn:hover { background: var(--bg-tertiary); color: var(--text-primary); border-color: var(--border-color); }
.icon-btn .badge-dot {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--red-500);
    border: 2px solid var(--bg-secondary);
}

/* ========== AVATAR ========== */
.avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    color: white;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.92rem;
    cursor: pointer;
    border: 2px solid transparent;
    transition: var(--transition);
}
.avatar:hover { border-color: var(--accent); }
.avatar-sm { width: 30px; height: 30px; font-size: 0.78rem; }

/* ========== POPOVER ========== */
.popover {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    min-width: 320px;
    max-width: 380px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-xl);
    padding: 8px;
    z-index: 1000;
    opacity: 0;
    transform: translateY(-6px);
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease;
}
.popover.open { opacity: 1; transform: translateY(0); pointer-events: auto; }
.popover-header { padding: 10px 12px; border-bottom: 1px solid var(--border-color); margin-bottom: 4px; }
.popover-header h4 { font-size: 0.86rem; font-weight: 700; color: var(--text-primary); }
.popover-list { max-height: 320px; overflow-y: auto; }
.popover-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.85rem;
    transition: var(--transition);
    cursor: pointer;
}
.popover-item:hover { background: var(--bg-tertiary); }
.popover-item .item-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--accent-soft);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.popover-item .item-title { font-weight: 600; }
.popover-item .item-meta { font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; }
.popover-footer { padding: 8px 12px; border-top: 1px solid var(--border-color); margin-top: 4px; text-align: center; }
.popover-footer a { color: var(--accent); font-size: 0.8rem; font-weight: 600; text-decoration: none; }

/* Wrapper para ancla relativa */
.has-popover { position: relative; }

/* ========== COMMAND PALETTE (Cmd+K) ========== */
.cmdk-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 3000;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding-top: 12vh;
}
.cmdk-overlay.active { display: flex; animation: cmdkFade 0.18s ease; }
@keyframes cmdkFade { from { opacity: 0; } to { opacity: 1; } }
.cmdk-panel {
    width: 92%;
    max-width: 620px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    overflow: hidden;
    animation: cmdkIn 0.22s ease;
}
@keyframes cmdkIn { from { opacity: 0; transform: scale(0.96) translateY(-8px); } to { opacity: 1; transform: scale(1) translateY(0); } }
.cmdk-input-wrap { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border-color); }
.cmdk-input-wrap .icon { color: var(--text-muted); }
.cmdk-input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: 1rem;
    color: var(--text-primary);
    font-family: inherit;
}
.cmdk-input::placeholder { color: var(--text-muted); }
.cmdk-results { max-height: 50vh; overflow-y: auto; padding: 6px; }
.cmdk-group-title { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.8px; color: var(--text-muted); padding: 10px 12px 6px; font-weight: 700; }
.cmdk-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.12s ease;
    text-decoration: none;
}
.cmdk-item.selected, .cmdk-item:hover { background: var(--accent-soft); color: var(--accent); }
.cmdk-item .item-meta { margin-left: auto; font-size: 0.75rem; color: var(--text-muted); }
.cmdk-item.selected .item-meta { color: var(--accent); }
.cmdk-empty { padding: 40px 20px; text-align: center; color: var(--text-muted); font-size: 0.9rem; }
.cmdk-footer {
    border-top: 1px solid var(--border-color);
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 0.74rem;
    color: var(--text-muted);
    background: var(--bg-tertiary);
}
.cmdk-footer span { display: inline-flex; align-items: center; gap: 6px; }

/* ========== KPI con tendencia ========== */
.stat-card {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
}
.stat-card .stat-row { display: flex; align-items: center; gap: 14px; }
.stat-trend {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.74rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: var(--radius-full);
    margin-top: 6px;
    width: fit-content;
}
.stat-trend.up   { background: rgba(34,197,94,0.13); color: var(--green-500); }
.stat-trend.down { background: rgba(239,68,68,0.13); color: var(--red-500); }
.stat-trend.flat { background: var(--bg-tertiary); color: var(--text-muted); }
.stat-trend .icon { width: 12px; height: 12px; }
.stat-spark { height: 32px; margin-top: -4px; }

/* Iconos de stat con SVG */
.stat-icon svg { width: 26px; height: 26px; }

/* ========== Page header polish ========== */
.page-header h1 { display: inline-flex; align-items: center; gap: 10px; }
.page-header h1 .icon { width: 28px; height: 28px; color: var(--accent); }

/* ========== Sidebar mejoras ========== */
.sidebar-nav .nav-item .icon { width: 20px; height: 20px; }
.sidebar-nav .nav-item.active { background: var(--accent-soft); color: var(--accent); border-left-color: var(--accent); }
.sidebar-nav .nav-item:hover { background: var(--accent-soft); }
.sidebar .nav-icon { display: inline-flex; align-items: center; justify-content: center; }

/* ========== EMPTY STATE rediseñado ========== */
.empty-state {
    text-align: center;
    padding: 56px 20px;
    color: var(--text-secondary);
}
.empty-state .icon-wrap {
    width: 72px;
    height: 72px;
    margin: 0 auto 18px;
    border-radius: 22px;
    background: linear-gradient(135deg, var(--accent-soft), var(--bg-tertiary));
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
}
.empty-state .icon-wrap .icon { width: 36px; height: 36px; }
.empty-state h3 { color: var(--text-primary); font-size: 1.1rem; font-weight: 700; margin-bottom: 6px; }
.empty-state p { font-size: 0.88rem; margin-bottom: 16px; }
.empty-state .empty-cta { display: inline-flex; align-items: center; gap: 8px; }

/* ========== BOTTOM NAV (móvil) ========== */
.bottom-nav {
    display: none;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--topbar-bg);
    backdrop-filter: saturate(180%) blur(18px);
    -webkit-backdrop-filter: saturate(180%) blur(18px);
    border-top: 1px solid var(--border-color);
    z-index: 950;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    justify-content: space-around;
}
.bottom-nav a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 8px 4px;
    border-radius: var(--radius-md);
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.66rem;
    font-weight: 600;
    transition: var(--transition);
    min-height: 50px;
}
.bottom-nav a.active { color: var(--accent); background: var(--accent-soft); }
.bottom-nav a:active { transform: scale(0.95); }
.bottom-nav .icon { width: 22px; height: 22px; }

@media (max-width: 768px) {
    .bottom-nav { display: flex; }
    body { padding-bottom: 64px; }
    .topbar { padding: 10px 14px; min-height: 56px; }
    .topbar .topbar-search { display: none; }
    .topbar .breadcrumbs { display: none; }
    .topbar-mobile-search-btn { display: inline-flex !important; }
    .page-header { padding: 18px 18px; }
    .page-body { padding: 18px 14px; }
    .card { padding: 18px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .stat-card { padding: 14px; }
    .stat-icon { width: 40px; height: 40px; }
    .stat-icon svg { width: 20px; height: 20px; }
    .stat-info h3 { font-size: 1.25rem; }
}
@media (min-width: 769px) {
    .topbar-mobile-search-btn { display: none !important; }
}

/* ========== POS LAYOUT ========== */
.pos-layout {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 18px;
    align-items: start;
}
@media (max-width: 1024px) {
    .pos-layout { grid-template-columns: 1fr; }
}
.pos-categories {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 4px 0 12px;
    margin-bottom: 14px;
    scrollbar-width: thin;
}
.pos-cat-pill {
    padding: 8px 16px;
    border-radius: var(--radius-full);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 0.84rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: var(--transition);
}
.pos-cat-pill.active { background: var(--accent); color: white; border-color: var(--accent); }
.pos-cat-pill:hover:not(.active) { border-color: var(--accent); color: var(--accent); }

.pos-product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
}
.pos-product-card {
    background: var(--bg-secondary);
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 14px 12px;
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
    position: relative;
    user-select: none;
    min-height: 130px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}
.pos-product-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.pos-product-card:active { transform: translateY(0); }
.pos-product-card .pos-thumb {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    margin: 0 auto 8px;
    background: var(--accent-soft);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.1rem;
}
.pos-product-card .pos-name { font-size: 0.84rem; font-weight: 600; color: var(--text-primary); line-height: 1.25; min-height: 32px; display: flex; align-items: center; justify-content: center; }
.pos-product-card .pos-price { color: var(--accent); font-weight: 800; font-size: 0.95rem; margin-top: 6px; }
.pos-product-card .pos-stock { font-size: 0.66rem; color: var(--text-muted); margin-top: 2px; }
.pos-product-card.low { border-color: var(--orange-500); }
.pos-product-card.out { opacity: 0.4; pointer-events: none; }

.pos-cart {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 18px;
    position: sticky;
    top: 78px;
    max-height: calc(100vh - 100px);
    display: flex;
    flex-direction: column;
}
.pos-cart-items { flex: 1; overflow-y: auto; margin: 12px 0; padding: 4px; }
.pos-cart-item {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    padding: 10px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}
.pos-cart-item:hover { background: var(--bg-tertiary); }
.pos-cart-item .ci-name { font-size: 0.84rem; font-weight: 600; color: var(--text-primary); margin-bottom: 4px; }
.pos-cart-item .ci-controls { display: flex; align-items: center; gap: 6px; }
.qty-btn {
    width: 28px;
    height: 28px;
    border: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    transition: var(--transition);
}
.qty-btn:hover { background: var(--accent); color: white; border-color: var(--accent); }
.qty-input {
    width: 44px;
    text-align: center;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 4px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.85rem;
    font-family: inherit;
}
.pos-cart-item .ci-line { text-align: right; font-weight: 700; color: var(--accent); font-size: 0.85rem; min-width: 80px; }
.pos-cart-empty { text-align: center; padding: 30px 16px; color: var(--text-muted); font-size: 0.86rem; }
.pos-cart-empty .icon { width: 36px; height: 36px; margin: 0 auto 8px; display: block; opacity: 0.5; }
.pos-cart-totals {
    border-top: 1px dashed var(--border-color);
    padding-top: 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.pos-cart-totals .row { display: flex; justify-content: space-between; font-size: 0.86rem; color: var(--text-secondary); }
.pos-cart-totals .row.grand { font-size: 1.3rem; font-weight: 800; color: var(--text-primary); margin-top: 6px; }
.pos-pay-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }

/* ========== KBD shortcut block en footer cmdk ========== */
.shortcuts-help {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 800;
}
.shortcuts-help .icon-btn { box-shadow: var(--shadow-sm); background: var(--bg-secondary); border: 1px solid var(--border-color); }

/* ========== SPARKLINE inline ========== */
.spark-bar {
    display: inline-flex;
    align-items: flex-end;
    gap: 2px;
    height: 28px;
}
.spark-bar span {
    width: 4px;
    background: var(--accent);
    border-radius: 2px;
    opacity: 0.5;
    transition: var(--transition);
}
.spark-bar:hover span { opacity: 1; }

/* ========== Botones primarios usan acento ========== */
.btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    color: white;
    box-shadow: 0 2px 8px var(--accent-soft-2);
}
.btn-primary:hover {
    background: linear-gradient(135deg, var(--accent-strong), var(--accent));
    box-shadow: 0 4px 16px var(--accent-soft-2);
    transform: translateY(-1px);
}
.btn-outline:hover { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.form-control:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.nav-item.active { color: var(--accent); border-left-color: var(--accent); }
.pagination .active { background: var(--accent); }
.btn .icon { width: 16px; height: 16px; }
.btn-sm .icon { width: 14px; height: 14px; }

/* ========== Confirm modal estilizado ========== */
.confirm-dialog .modal { max-width: 420px; }
.confirm-dialog .modal-body { text-align: center; padding: 30px 26px 22px; }
.confirm-dialog .icon-wrap {
    width: 64px; height: 64px; border-radius: 50%;
    background: rgba(239,68,68,0.12); color: var(--red-500);
    margin: 0 auto 16px;
    display: flex; align-items: center; justify-content: center;
}
.confirm-dialog .icon-wrap .icon { width: 32px; height: 32px; }
.confirm-dialog h3 { font-size: 1.15rem; font-weight: 700; color: var(--text-primary); margin-bottom: 8px; }
.confirm-dialog p { color: var(--text-secondary); font-size: 0.92rem; }
.confirm-dialog .modal-footer { justify-content: center; padding: 16px 26px 24px; }

/* ========== Toast con acción ========== */
.toast-action {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--accent);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.78rem;
    cursor: pointer;
    transition: var(--transition);
    margin-top: 6px;
}
.toast-action:hover { background: var(--accent-soft); }

/* ========== Selector de acento (configuración) ========== */
.accent-picker { display: flex; gap: 10px; flex-wrap: wrap; }
.accent-swatch {
    width: 32px; height: 32px; border-radius: 50%;
    cursor: pointer;
    border: 3px solid transparent;
    transition: var(--transition);
}
.accent-swatch.active { border-color: var(--text-primary); transform: scale(1.1); }
.accent-swatch.green  { background: #22C55E; }
.accent-swatch.blue   { background: #3B82F6; }
.accent-swatch.orange { background: #F97316; }
.accent-swatch.purple { background: #A855F7; }
.accent-swatch.red    { background: #EF4444; }

/* Icon-circle override para SVG */
.icon-circle svg { width: 22px; height: 22px; }

/* Stat icon variantes con accent */
.stat-icon.accent {
    background: linear-gradient(135deg, var(--accent-soft-2), var(--accent-soft));
    color: var(--accent);
}

/* Page header refresh */
.main-content > .page-header { border-radius: 0; }
.page-header-compact { padding: 18px 28px; }

/* ========== ADAPTIVE APP SHELL (tablet, iOS, POS) ========== */
.mobile-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 17, 23, 0.46);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 940;
}
.mobile-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

@media (max-width: 1180px) {
    html,
    body {
        overflow-x: hidden;
    }

    .sidebar {
        transform: translateX(-100%);
        width: min(300px, 86vw);
        box-shadow: 8px 0 34px rgba(0,0,0,0.22);
        z-index: 1000;
        padding-bottom: env(safe-area-inset-bottom);
    }

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

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

    .topbar {
        padding-left: max(16px, env(safe-area-inset-left));
        padding-right: max(16px, env(safe-area-inset-right));
    }

    .page-header {
        padding-left: max(22px, env(safe-area-inset-left));
        padding-right: max(22px, env(safe-area-inset-right));
    }

    .page-body {
        padding-left: max(22px, env(safe-area-inset-left));
        padding-right: max(22px, env(safe-area-inset-right));
    }
}

@media (max-width: 1180px) {
    .sidebar-header {
        padding: 18px 18px 14px;
    }

    .colmado-info {
        padding: 12px 18px;
    }

    .sidebar-mobile-user {
        align-items: center;
        background: linear-gradient(135deg, var(--accent-soft), var(--bg-tertiary));
        border: 1px solid var(--border-color);
        border-radius: var(--radius-lg);
        display: flex;
        gap: 12px;
        margin: 14px 14px 10px;
        padding: 12px;
    }

    .sidebar-mobile-avatar {
        align-items: center;
        background: linear-gradient(135deg, var(--accent), var(--accent-strong));
        border-radius: var(--radius-md);
        color: #fff;
        display: flex;
        flex: 0 0 auto;
        font-weight: 900;
        height: 42px;
        justify-content: center;
        width: 42px;
    }

    .sidebar-mobile-user strong,
    .sidebar-mobile-user span {
        display: block;
    }

    .sidebar-mobile-user span {
        color: var(--text-muted);
        font-size: 0.76rem;
        text-transform: uppercase;
    }

    .sidebar-mobile-quick {
        display: grid;
        gap: 8px;
        grid-template-columns: repeat(3, 1fr);
        padding: 0 14px 12px;
    }

    .sidebar-mobile-quick a {
        align-items: center;
        background: var(--bg-tertiary);
        border: 1px solid var(--border-color);
        border-radius: var(--radius-md);
        color: var(--text-secondary);
        display: flex;
        flex-direction: column;
        font-size: 0.72rem;
        font-weight: 800;
        gap: 5px;
        min-height: 62px;
        justify-content: center;
        position: relative;
        text-decoration: none;
    }

    .sidebar-mobile-quick a em {
        background: var(--red-500);
        border-radius: var(--radius-full);
        color: #fff;
        font-size: 0.62rem;
        font-style: normal;
        line-height: 1;
        min-width: 18px;
        padding: 3px 5px;
        position: absolute;
        right: 7px;
        top: 7px;
    }

    .sidebar-sucursal {
        margin-top: 2px;
    }
}

@media (min-width: 769px) and (max-width: 1180px) {
    .bottom-nav {
        display: flex;
    }

    body {
        padding-bottom: 68px;
    }
}

@media (max-width: 640px) {
    .topbar-desktop-only {
        display: none !important;
    }

    .topbar .has-popover {
        position: static;
    }

    .popover {
        border-radius: var(--radius-lg);
        left: max(10px, env(safe-area-inset-left));
        max-height: calc(100dvh - 86px - env(safe-area-inset-bottom));
        max-width: none;
        min-width: 0;
        overflow: hidden;
        padding: 10px;
        position: fixed;
        right: max(10px, env(safe-area-inset-right));
        top: calc(58px + env(safe-area-inset-top));
        width: auto;
    }

    .topbar .avatar {
        width: 34px;
        height: 34px;
    }

    .popover-header {
        background: var(--bg-tertiary);
        border: 0;
        border-radius: var(--radius-md);
        margin-bottom: 8px;
        padding: 12px 14px;
    }

    .popover-list {
        display: flex;
        flex-direction: column;
        gap: 8px;
        max-height: calc(100dvh - 190px - env(safe-area-inset-bottom));
        overflow-y: auto;
        padding-right: 2px;
    }

    .popover-item {
        align-items: center;
        background: var(--bg-tertiary);
        border: 1px solid var(--border-color);
        border-radius: var(--radius-md);
        display: grid;
        grid-template-columns: 38px minmax(0, 1fr);
        gap: 10px;
        min-height: 58px;
        padding: 10px 12px;
    }

    .popover-item .item-icon {
        border-radius: var(--radius-md);
        height: 38px;
        width: 38px;
    }

    .popover-item .item-title,
    .popover-item .item-meta {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .popover-footer {
        background: var(--bg-tertiary);
        border: 0;
        border-radius: var(--radius-md);
        margin-top: 8px;
    }
}

@media (max-width: 768px) {
    .card:has(> table) {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .card > table {
        min-width: 640px;
    }

    .card-header {
        align-items: flex-start;
        flex-direction: column;
        gap: 12px;
    }

    .card-header .btn,
    .page-header .btn {
        justify-content: center;
    }

    .page-header > .flex,
    .page-header > .flex-between,
    .page-header > div:last-child {
        max-width: 100%;
    }

    .page-header > div:last-child .btn {
        min-height: 42px;
    }

    .modal {
        max-height: calc(100dvh - 24px - env(safe-area-inset-bottom));
    }

    .modal-footer {
        display: grid;
        grid-template-columns: 1fr;
        gap: 10px;
    }

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

    .mobile-card-table {
        min-width: 0 !important;
    }

    .mobile-card-table thead {
        display: none;
    }

    .mobile-card-table,
    .mobile-card-table tbody,
    .mobile-card-table tr,
    .mobile-card-table td {
        display: block;
        width: 100%;
    }

    .card:has(> .mobile-card-table),
    .card:has(.mobile-card-table) {
        overflow: visible;
    }

    .mobile-card-table tbody tr {
        background: var(--bg-tertiary);
        border: 1px solid var(--border-color);
        border-radius: var(--radius-md);
        margin-bottom: 10px;
        padding: 10px;
    }

    .mobile-card-table tbody td {
        align-items: center;
        border: 0;
        display: flex;
        gap: 14px;
        justify-content: space-between;
        min-height: 34px;
        padding: 6px 0;
        text-align: right !important;
    }

    .mobile-card-table tbody td::before {
        color: var(--text-muted);
        content: attr(data-label);
        flex: 0 0 auto;
        font-size: 0.7rem;
        font-weight: 800;
        letter-spacing: 0.06em;
        text-align: left;
        text-transform: uppercase;
    }

    .mobile-card-table tbody td > form {
        justify-content: flex-end;
        max-width: 100%;
    }

    .btn.is-submitting {
        opacity: 0.7;
        pointer-events: none;
    }
}

/* === Login mejorado: gradiente animado === */
.login-page::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 20% 30%, var(--accent-soft) 0%, transparent 50%),
                radial-gradient(circle at 80% 70%, rgba(59,130,246,0.08) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

/* Print: ocultar topbar y nav */
@media print {
    .topbar, .sidebar, .bottom-nav, .toast-container, .shortcuts-help, .mobile-overlay { display: none !important; }
    .main-content { margin-left: 0 !important; }
    .page-header { border: none; padding: 0 0 16px; }
    .card { box-shadow: none; border: 1px solid #ddd; }
}

/* Scrollbar fino consistente */
.popover-list::-webkit-scrollbar,
.cmdk-results::-webkit-scrollbar,
.pos-cart-items::-webkit-scrollbar { width: 6px; }
.popover-list::-webkit-scrollbar-thumb,
.cmdk-results::-webkit-scrollbar-thumb,
.pos-cart-items::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }
