/*
 * PatagoniaWeb - Sistema de Gestión
 * Stylesheet centralizado con soporte Dark/Light Theme
 */

/* ============================================
   TEMA CLARO (default)
   ============================================ */
:root,
[data-theme="light"] {
    /* Brand */
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-darker: #4338ca;
    --primary-light: #e0e7ff;
    
    --success: #10b981;
    --success-dark: #059669;

    --danger: #ef4444;
    --danger-dark: #dc2626;

    --warning: #f59e0b;
    --warning-dark: #d97706;

    --info: #3b82f6;
    --info-dark: #2563eb;

    --secondary: #64748b;
    --secondary-dark: #475569;

    --accent: #8b5cf6;
    --accent-dark: #7c3aed;

    /* Sidebar */
    --sidebar-bg: #0f172a;
    --sidebar-text: #94a3b8;
    --sidebar-text-hover: #e2e8f0;
    --sidebar-text-active: #ffffff;
    --sidebar-active-bg: rgba(99, 102, 241, 0.15);
    --sidebar-active-border: #6366f1;
    --sidebar-hover-bg: rgba(255, 255, 255, 0.05);
    --sidebar-border: rgba(255, 255, 255, 0.08);
    --sidebar-icon: #818cf8;

    /* Topbar */
    --topbar-bg: #ffffff;
    --topbar-border: #e2e8f0;
    --topbar-text: #1e293b;

    /* Page */
    --page-bg: #f0f4ff;
    --surface: #ffffff;
    --surface-hover: #f8fafc;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --text: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --text-disabled: #cbd5e1;

    /* Inputs */
    --input-bg: #ffffff;
    --input-border: #d8dff0;
    --input-focus-border: #6366f1;
    --input-focus-ring: rgba(99, 102, 241, 0.20);
    --input-text: #0f172a;
    --input-placeholder: #94a3b8;

    /* Shadows */
    --shadow-xs: 0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.09), 0 1px 3px rgba(15, 23, 42, 0.05);
    --shadow: 0 4px 18px rgba(15, 23, 42, 0.10), 0 2px 6px rgba(15, 23, 42, 0.05);
    --shadow-md: 0 8px 30px rgba(15, 23, 42, 0.12), 0 3px 10px rgba(15, 23, 42, 0.06);
    --shadow-lg: 0 20px 52px rgba(15, 23, 42, 0.14), 0 6px 18px rgba(15, 23, 42, 0.07);
    --shadow-inner: inset 0 2px 4px rgba(15, 23, 42, 0.05);
    --shadow-primary: 0 4px 20px rgba(99, 102, 241, 0.28);
    --shadow-accent: 0 4px 20px rgba(139, 92, 246, 0.28);

    /* Radii */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    /* Table */
    --table-header-bg: #f8fafc;
    --table-row-hover: #f1f5f9;
    --table-border: #e2e8f0;
}

/* ============================================
   TEMA OSCURO
   ============================================ */
[data-theme="dark"] {
    /* Brand - más vibrante sobre fondo oscuro */
    --primary: #818cf8;
    --primary-dark: #6366f1;
    --primary-darker: #4f46e5;
    --primary-light: rgba(99, 102, 241, 0.15);

    --success: #34d399;
    --success-dark: #10b981;

    --danger: #f87171;
    --danger-dark: #ef4444;

    --warning: #fbbf24;
    --warning-dark: #f59e0b;

    --info: #60a5fa;
    --info-dark: #3b82f6;

    --secondary: #94a3b8;
    --secondary-dark: #64748b;

    --accent: #a78bfa;
    --accent-dark: #8b5cf6;

    /* Sidebar */
    --sidebar-bg: #020617;
    --sidebar-text: #94a3b8;
    --sidebar-text-hover: #cbd5e1;
    --sidebar-text-active: #f1f5f9;
    --sidebar-active-bg: rgba(129, 140, 248, 0.12);
    --sidebar-active-border: #818cf8;
    --sidebar-hover-bg: rgba(255, 255, 255, 0.04);
    --sidebar-border: rgba(255, 255, 255, 0.06);
    --sidebar-icon: #818cf8;

    /* Topbar */
    --topbar-bg: #0f172a;
    --topbar-border: #1e293b;
    --topbar-text: #f1f5f9;

    /* Page */
    --page-bg: #020617;
    --surface: #0f172a;
    --surface-hover: #1e293b;
    --border: #1e293b;
    --border-light: #0f172a;
    --text: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --text-disabled: #475569;

    /* Inputs */
    --input-bg: #1e293b;
    --input-border: #334155;
    --input-focus-border: #818cf8;
    --input-focus-ring: rgba(129, 140, 248, 0.20);
    --input-text: #f1f5f9;
    --input-placeholder: #475569;

    /* Shadows */
    --shadow-xs: 0 1px 3px rgba(0, 0, 0, 0.24), 0 1px 2px rgba(0, 0, 0, 0.14);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.30), 0 1px 3px rgba(0, 0, 0, 0.18);
    --shadow: 0 4px 18px rgba(0, 0, 0, 0.32), 0 2px 6px rgba(0, 0, 0, 0.18);
    --shadow-md: 0 8px 30px rgba(0, 0, 0, 0.38), 0 3px 10px rgba(0, 0, 0, 0.22);
    --shadow-lg: 0 20px 52px rgba(0, 0, 0, 0.45), 0 6px 18px rgba(0, 0, 0, 0.26);
    --shadow-inner: inset 0 2px 4px rgba(0, 0, 0, 0.14);
    --shadow-primary: 0 4px 20px rgba(129, 140, 248, 0.22);
    --shadow-accent: 0 4px 20px rgba(167, 139, 250, 0.22);

    /* Radii */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    /* Table */
    --table-header-bg: #1e293b;
    --table-row-hover: #1e293b;
    --table-border: #1e293b;
}

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

html { scroll-behavior: smooth; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 0.875rem;
    background: var(--page-bg);
    color: var(--text);
    /* no transition on body — prevents "page refresh" flash on navigation */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

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

/* ============================================
   SIDEBAR
   ============================================ */
#main-sidebar {
    box-shadow: 2px 0 12px rgba(2, 6, 23, 0.08);
}

#main-sidebar nav a.nav-item {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.625rem 0.875rem;
    border-radius: 0.625rem;
    color: var(--sidebar-text);
    font-size: 0.875rem;
    font-weight: 500;
    transition: color 0.15s, background 0.15s, border-color 0.15s, box-shadow 0.15s;
    position: relative;
    border: 1px solid transparent;
    margin-bottom: 2px;
}

#main-sidebar nav a.nav-item:hover {
    color: var(--sidebar-text-hover);
    background: var(--sidebar-hover-bg);
}

#main-sidebar nav a.nav-item.active {
    color: var(--sidebar-text-active);
    background: rgba(99, 102, 241, 0.18);
    border-color: var(--sidebar-active-border);
    box-shadow: 0 2px 12px rgba(99, 102, 241, 0.22), inset 0 0 16px rgba(99, 102, 241, 0.06);
}

#main-sidebar nav a.nav-item .nav-icon {
    width: 1.5rem;
    height: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    color: var(--sidebar-icon);
    flex-shrink: 0;
    transition: color 0.15s;
}

#main-sidebar nav a.nav-item:hover .nav-icon,
#main-sidebar nav a.nav-item.active .nav-icon {
    color: var(--sidebar-text-active);
}

#main-sidebar .logo-text {
    font-size: 1.125rem;
    font-weight: 800;
    letter-spacing: 0.025em;
}

/* ============================================
   TOPBAR
   ============================================ */
header {
    padding: 0.625rem 1.25rem !important;
}

header, .topbar-gradient {
    background: var(--topbar-bg);
    border-bottom: 1px solid var(--topbar-border);
    color: var(--topbar-text);
    box-shadow: 0 1px 0 var(--border), 0 4px 20px rgba(15, 23, 42, 0.05);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.topbar-gradient h1 { color: var(--topbar-text); }

/* ============================================
   BOTONES — Modernos, sin 3D pesado
   ============================================ */
.btn-3d {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: background 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
    position: relative;
    text-decoration: none;
    white-space: nowrap;
    user-select: none;
    color: #fff;
    text-shadow: none;
    background: var(--btn-mid, #6366f1);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
    min-height: 2.25rem;
    letter-spacing: 0;
}

.btn-3d:hover {
    background: var(--btn-top, #818cf8);
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.1);
    transform: none;
    filter: brightness(1.05);
    color: #fff;
}

.btn-3d:active {
    transform: translateY(1px);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
    filter: brightness(0.95);
}

.btn-3d-sm {
    padding: 0.3rem 0.7rem;
    font-size: 0.8rem;
    border-radius: 0.4rem;
    min-height: 2rem;
}

.btn-3d-lg {
    padding: 0.625rem 1.25rem;
    font-size: 0.9375rem;
    border-radius: 0.5rem;
    min-height: 2.5rem;
}

/* Button color variants — flat bg, no gradients */
.btn-3d.btn-3d-primary {
    --btn-top: #818cf8; --btn-mid: #6366f1;
}
.btn-3d.btn-3d-success {
    --btn-top: #34d399; --btn-mid: #10b981;
}
.btn-3d.btn-3d-danger {
    --btn-top: #f87171; --btn-mid: #ef4444;
}
.btn-3d.btn-3d-warning {
    --btn-top: #fbbf24; --btn-mid: #f59e0b;
    color: #422006;
}
.btn-3d.btn-3d-secondary {
    --btn-top: #94a3b8; --btn-mid: #64748b;
}
.btn-3d.btn-3d-info {
    --btn-top: #60a5fa; --btn-mid: #3b82f6;
}
.btn-3d.btn-3d-accent {
    --btn-top: #a78bfa; --btn-mid: #8b5cf6;
}
.btn-3d.btn-3d-dark {
    --btn-top: #64748b; --btn-mid: #475569;
}

/* Outline variant */
.btn-3d-outline {
    background: transparent;
    box-shadow: none;
    text-shadow: none;
    border: 1.5px solid var(--btn-mid);
    color: var(--btn-mid);
}
.btn-3d-outline:hover {
    background: var(--btn-mid);
    color: #fff;
    filter: none;
    box-shadow: none;
}

/* ============================================
   CARDS — Limpias y profesionales
   ============================================ */
.card-3d {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
    transition: box-shadow 0.15s ease, border-color 0.15s ease;
    overflow: hidden;
}

.card-3d:hover {
    box-shadow: var(--shadow-sm);
    border-color: rgba(99, 102, 241, 0.15);
}

.card-3d-header {
    padding: 0.875rem 1.125rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    min-height: auto;
}

.card-3d-body {
    padding: 1.125rem;
}

.card-3d-footer {
    padding: 0.75rem 1.125rem;
    border-top: 1px solid var(--border);
    background: var(--surface-hover);
}

/* ============================================
   TABLAS — Compactas y profesionales
   ============================================ */
.table-3d {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
}

.table-3d thead tr {
    background: var(--table-header-bg);
}

.table-3d thead th {
    padding: 0.625rem 0.75rem;
}

/* ============================================
   TABLAS
   ============================================ */
.table-3d {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.table-3d thead tr {
    background: var(--table-header-bg);
}

.table-3d thead th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--table-border);
    white-space: nowrap;
}

.table-3d tbody tr {
    border-bottom: 1px solid var(--border-light);
    transition: background 0.1s;
}

.table-3d tbody tr:last-child { border-bottom: none; }

.table-3d tbody tr:hover {
    background: var(--table-row-hover);
}

.table-3d tbody td {
    padding: 0.875rem 1rem;
    color: var(--text);
    vertical-align: middle;
}

.table-3d .text-end { text-align: right; }
.table-3d .text-center { text-align: center; }

/* ============================================
   FORMULARIOS
   ============================================ */
.form-control-3d {
    display: block;
    width: 100%;
    padding: 0.625rem 0.875rem;
    background: var(--input-bg);
    border: 1.5px solid var(--input-border);
    border-radius: 0.5rem;
    color: var(--input-text);
    font-size: 0.875rem;
    font-family: inherit;
    transition: border-color 0.15s, box-shadow 0.15s, background 0.2s, color 0.2s;
    outline: none;
}

.form-control-3d::placeholder { color: var(--input-placeholder); }

.form-control-3d:focus {
    border-color: var(--input-focus-border);
    box-shadow: 0 0 0 3px var(--input-focus-ring);
}

.form-control-3d:focus-visible {
    outline: none;
}

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

.form-select-3d {
    display: block;
    width: 100%;
    padding: 0.625rem 2.25rem 0.625rem 0.875rem;
    background: var(--input-bg);
    border: 1.5px solid var(--input-border);
    border-radius: 0.5rem;
    color: var(--input-text);
    font-size: 0.875rem;
    font-family: inherit;
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s, background 0.2s, color 0.2s;
    outline: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2.25rem;
}

.form-select-3d:focus {
    border-color: var(--input-focus-border);
    box-shadow: 0 0 0 3px var(--input-focus-ring);
}

.form-label-3d {
    display: block;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.375rem;
    letter-spacing: 0.01em;
}

.input-group-3d {
    display: flex;
    align-items: stretch;
    width: 100%;
}

.input-prefix {
    display: flex;
    align-items: center;
    padding: 0 0.875rem;
    background: var(--surface-hover);
    border: 1.5px solid var(--input-border);
    border-right: none;
    border-radius: 0.5rem 0 0 0.5rem;
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: 600;
    white-space: nowrap;
}

.input-group-3d .form-control-3d,
.input-group-3d .form-input {
    border-radius: 0 0.5rem 0.5rem 0;
    flex: 1;
}

/* ============================================
   BADGES
   ============================================ */
.badge-3d {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.badge-primary-3d  { background: var(--primary-light);   color: var(--primary); }
.badge-success-3d  { background: rgba(16,185,129,0.12);  color: var(--success); }
.badge-danger-3d   { background: rgba(239,68,68,0.12);    color: var(--danger); }
.badge-warning-3d  { background: rgba(245,158,11,0.12);  color: var(--warning); }
.badge-secondary-3d { background: rgba(100,116,139,0.12); color: var(--secondary); }
.badge-info-3d     { background: rgba(59,130,246,0.12);   color: var(--info); }
.badge-accent-3d   { background: rgba(139,92,246,0.12);  color: var(--accent); }

/* ============================================
   ALERTS
   ============================================ */
.alert-3d {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-radius: 0.625rem;
    border: 1px solid;
    font-size: 0.875rem;
    line-height: 1.5;
}

.alert-3d-success {
    background: rgba(16, 185, 129, 0.08);
    border-color: rgba(16, 185, 129, 0.25);
    color: var(--success);
}
.alert-3d-danger {
    background: rgba(239, 68, 68, 0.08);
    border-color: rgba(239, 68, 68, 0.25);
    color: var(--danger);
}
.alert-3d-warning {
    background: rgba(245, 158, 11, 0.08);
    border-color: rgba(245, 158, 11, 0.25);
    color: var(--warning);
}
.alert-3d-info {
    background: rgba(59, 130, 246, 0.08);
    border-color: rgba(59, 130, 246, 0.25);
    color: var(--info);
}

/* ============================================
   PAGE HEADER & BREADCRUMB
   ============================================ */
.page-header-3d {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.75rem;
    flex-wrap: wrap;
}

.page-header-3d .title {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    font-size: 1.375rem;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.01em;
}

.page-header-3d .title .icon {
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.375rem;
    flex-shrink: 0;
}

.breadcrumb-3d {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.875rem;
    margin-bottom: 1.25rem;
}

.breadcrumb-3d a {
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.15s;
}

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

.breadcrumb-3d .separator {
    color: var(--text-disabled);
    font-size: 0.75rem;
}

.breadcrumb-3d .current {
    color: var(--text);
    font-weight: 500;
}

/* ============================================
   EMPTY STATE
   ============================================ */
.empty-state-3d {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1.5rem;
    text-align: center;
    color: var(--text-muted);
    gap: 0.5rem;
}

.empty-state-3d .icon {
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-hover);
    font-size: 1.5rem;
    color: var(--text-disabled);
    margin-bottom: 0.5rem;
}

.empty-state-3d p { font-size: 0.9375rem; margin: 0; }

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */
.toast-container-3d {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
}

.toast-3d {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1.125rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.625rem;
    box-shadow: var(--shadow-lg);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text);
    pointer-events: all;
    animation: toastIn 0.3s ease forwards;
    max-width: 360px;
    backdrop-filter: blur(12px);
}

.toast-3d.success { border-left: 4px solid var(--success); }
.toast-3d.error   { border-left: 4px solid var(--danger); }
.toast-3d.warning { border-left: 4px solid var(--warning); }
.toast-3d.info    { border-left: 4px solid var(--info); }

.toast-3d.fade-out {
    animation: toastOut 0.3s ease forwards;
}

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

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

/* ============================================
   THEME TOGGLE BUTTON
   ============================================ */
.theme-toggle {
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: color 0.2s, background 0.2s, transform 0.2s, box-shadow 0.2s;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 1.1rem;
}

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

/* ============================================
   STAT CARDS (Dashboard)
   ============================================ */
.stat-card-3d {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: 1.375rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.07), 0 1px 3px rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    gap: 1.125rem;
    transition: box-shadow 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
    position: relative;
    overflow: hidden;
}

/* subtle top accent stripe */
.stat-card-3d::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--stat-color-a, var(--primary)), var(--stat-color-b, var(--accent)));
    border-radius: 1rem 1rem 0 0;
}

.stat-card-3d:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.10), 0 3px 8px rgba(0, 0, 0, 0.06);
    transform: translateY(-2px);
    border-color: rgba(139, 92, 246, 0.2);
}

.stat-card-3d .stat-icon {
    width: 3.25rem;
    height: 3.25rem;
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
    /* default gradient — override per card with inline style */
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.15), rgba(139, 92, 246, 0.1));
    color: var(--accent);
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.18);
}

.stat-card-3d .stat-label {
    font-size: 0.8125rem;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 0.3rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.stat-card-3d .stat-value {
    font-size: 1.625rem;
    font-weight: 800;
    color: var(--text);
    line-height: 1.15;
    letter-spacing: -0.01em;
}

.stat-card-3d .stat-trend {
    font-size: 0.75rem;
    font-weight: 600;
    margin-top: 0.2rem;
}

.stat-card-3d .stat-trend.up   { color: var(--success); }
.stat-card-3d .stat-trend.down { color: var(--danger); }

/* ============================================
   MODAL — STRUCTURAL (Bootstrap CSS not loaded)
   ============================================ */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1055;
    overflow-x: hidden;
    overflow-y: auto;
}

.modal.show { display: block; }

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1050;
    background: #000;
    opacity: 0.5;
}

.modal-backdrop.fade { opacity: 0; }
.modal-backdrop.show { opacity: 0.5; }

.modal-dialog {
    position: relative;
    width: auto;
    margin: 1.75rem auto;
    max-width: 500px;
    pointer-events: none;
}

.modal-dialog-centered {
    display: flex;
    align-items: center;
    min-height: calc(100% - 3.5rem);
}

.modal-lg  { max-width: 800px; }
.modal-xl  { max-width: 1140px; }
.modal-sm  { max-width: 300px; }

.modal.fade .modal-dialog {
    transition: transform 0.3s ease-out;
    transform: translateY(-50px);
}

.modal.show .modal-dialog { transform: none; }

.modal-content {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    pointer-events: all;
    background: var(--surface) !important;
    border: 1px solid var(--border) !important;
    border-radius: 0.875rem !important;
    box-shadow: var(--shadow-lg) !important;
    color: var(--text) !important;
    outline: 0;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    background: var(--surface) !important;
    border-bottom: 1px solid var(--border) !important;
    border-top-left-radius: 0.875rem;
    border-top-right-radius: 0.875rem;
    color: var(--text) !important;
    gap: 0.75rem;
}

.modal-title {
    margin: 0;
    line-height: 1.5;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text) !important;
}

.modal-body {
    position: relative;
    flex: 1 1 auto;
    padding: 1.25rem;
}

.modal-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 0.875rem 1.25rem;
    background: var(--surface) !important;
    border-top: 1px solid var(--border) !important;
    border-bottom-left-radius: 0.875rem;
    border-bottom-right-radius: 0.875rem;
}

.btn-close {
    box-sizing: content-box;
    width: 1em;
    height: 1em;
    padding: 0.25em;
    background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M.293.293a1 1 0 011.414 0L8 6.586 14.293.293a1 1 0 111.414 1.414L9.414 8l6.293 6.293a1 1 0 01-1.414 1.414L8 9.414l-6.293 6.293A1 1 0 01.293 14.293L6.586 8 .293 1.707a1 1 0 010-1.414z'/%3E%3C/svg%3E") center/1em no-repeat;
    border: 0;
    border-radius: 0.375rem;
    opacity: 0.5;
    cursor: pointer;
    flex-shrink: 0;
    filter: var(--btn-close-filter, none);
    transition: opacity 0.15s;
}

.btn-close:hover { opacity: 0.75; }

[data-theme="dark"] .btn-close {
    --btn-close-filter: invert(1) grayscale(100%) brightness(200%);
}

/* Gestion panel dialog overlay */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1040;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.modal-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.875rem;
    box-shadow: var(--shadow-lg);
    width: 100%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Bootstrap layout utilities needed by caja/form templates */
.form-label {
    display: inline-block;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-control,
.form-select {
    display: block;
    width: 100%;
    padding: 0.625rem 0.875rem;
    background: var(--input-bg);
    border: 1.5px solid var(--input-border);
    border-radius: 0.5rem;
    color: var(--input-text);
    font-size: 0.875rem;
    font-family: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
    outline: none;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--input-focus-border);
    box-shadow: 0 0 0 3px var(--input-focus-ring);
}

.row {
    display: flex;
    flex-wrap: wrap;
    margin-right: -0.75rem;
    margin-left: -0.75rem;
}

[class*="col-"] {
    padding-right: 0.75rem;
    padding-left: 0.75rem;
    flex-shrink: 0;
    width: 100%;
    box-sizing: border-box;
}

.col-md-6  { width: 50%; }
.col-md-4  { width: 33.3333%; }
.col-md-3  { width: 25%; }
.col-md-8  { width: 66.6667%; }
.col-md-12 { width: 100%; }

@media (max-width: 767px) {
    .col-md-6,
    .col-md-4,
    .col-md-3,
    .col-md-8 { width: 100%; }
}

.g-3  { gap: 0.75rem; }
.g-2  { gap: 0.5rem; }
.g-4  { gap: 1rem; }

/* When gap is on .row, remove negative margins */
.row.g-3, .row.g-2, .row.g-4 {
    margin-right: 0;
    margin-left: 0;
}

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

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

.table-sm td,
.table-sm th {
    padding: 0.25rem 0.5rem;
    font-size: 0.85rem;
}

.d-none    { display: none !important; }
.d-block   { display: block !important; }
.d-flex    { display: flex !important; }
.d-inline  { display: inline !important; }
.d-inline-block { display: inline-block !important; }

.ms-1 { margin-left: 0.25rem !important; }
.ms-2 { margin-left: 0.5rem !important; }
.ms-4 { margin-left: 1rem !important; }
.me-1 { margin-right: 0.25rem !important; }
.me-3 { margin-right: 0.75rem !important; }
.mt-1 { margin-top: 0.25rem !important; }
.mt-2 { margin-top: 0.5rem !important; }

.text-white   { color: #fff !important; }
.text-slate-500 { color: #64748b !important; }
.fw-bold   { font-weight: 700 !important; }
.fw-semibold { font-weight: 600 !important; }

.fs-4 { font-size: 1.5rem !important; }
.fs-5 { font-size: 1.25rem !important; }

.align-items-center { align-items: center !important; }
.justify-content-between { justify-content: space-between !important; }
.justify-content-end { justify-content: flex-end !important; }

.empty-hint {
    font-size: 0.8125rem;
    color: var(--text-disabled);
}

/* ============================================
   UTILITY
   ============================================ */
.text-success { color: var(--success) !important; }
.text-danger  { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.text-primary { color: var(--primary) !important; }
.text-info    { color: var(--info) !important; }
.text-accent  { color: var(--accent) !important; }
.text-muted   { color: var(--text-muted) !important; }
.text-secondary { color: var(--text-secondary) !important; }

.bg-success { background-color: rgba(16,185,129,0.1) !important; }
.bg-danger  { background-color: rgba(239,68,68,0.1) !important; }
.bg-warning { background-color: rgba(245,158,11,0.1) !important; }
.bg-primary { background-color: var(--primary-light) !important; }
.bg-info    { background-color: rgba(59,130,246,0.1) !important; }

.font-bold   { font-weight: 700; }
.font-semibold { font-weight: 600; }
.font-medium { font-weight: 500; }
.text-sm   { font-size: 0.875rem; }
.text-xs   { font-size: 0.75rem; }
.text-lg   { font-size: 1.125rem; }
.text-xl   { font-size: 1.25rem; }
.text-2xl  { font-size: 1.5rem; }
.text-center { text-align: center; }
.text-end   { text-align: right; }
.text-uppercase { text-transform: uppercase; letter-spacing: 0.05em; }

.flex    { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.items-start  { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center  { justify-content: center; }
.justify-end     { justify-content: flex-end; }
.flex-1  { flex: 1; }
.flex-wrap { flex-wrap: wrap; }
.gap-1  { gap: 0.25rem; }
.gap-2  { gap: 0.5rem; }
.gap-3  { gap: 0.75rem; }
.gap-4  { gap: 1rem; }
.gap-5  { gap: 1.25rem; }
.gap-6  { gap: 1.5rem; }

.w-full  { width: 100%; }
.h-full  { height: 100%; }
.min-w-0 { min-width: 0; }

.mb-0  { margin-bottom: 0; }
.mb-1  { margin-bottom: 0.25rem; }
.mb-2  { margin-bottom: 0.5rem; }
.mb-3  { margin-bottom: 0.75rem; }
.mb-4  { margin-bottom: 1rem; }
.mb-5  { margin-bottom: 1.25rem; }
.mb-6  { margin-bottom: 1.5rem; }
.mt-2  { margin-top: 0.5rem; }
.mt-3  { margin-top: 0.75rem; }
.mt-4  { margin-top: 1rem; }
.me-2  { margin-right: 0.5rem; }
.ms-3  { margin-left: 0.75rem; }
.py-3  { padding-top: 0.75rem; padding-bottom: 0.75rem; }
.px-4  { padding-left: 1rem; padding-right: 1rem; }
.py-2  { padding-top: 0.5rem; padding-bottom: 0.5rem; }
.ps-3  { padding-left: 0.75rem; }
.pt-0  { padding-top: 0; }
.pb-0  { padding-bottom: 0; }
.border-0 { border: none; }
.border { border: 1px solid var(--border); }
.rounded-xl { border-radius: 0.75rem; }
.rounded-2xl { border-radius: 1rem; }
.rounded-full { border-radius: 999px; }
.overflow-hidden { overflow: hidden; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.space-y-1 > * + * { margin-top: 0.25rem; }
.space-y-4 > * + * { margin-top: 1rem; }

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

.relative { position: relative; }
.absolute { position: absolute; }
.inset-y-0 { top: 0; bottom: 0; }
.left-3 { left: 0.75rem; }
.top-1\/2 { top: 50%; }
.-translate-y-1\/2 { transform: translateY(-50%); }

.inline-flex { display: inline-flex; }
.hidden { display: none; }
.block { display: block; }
.inline-block { display: inline-block; }

/* ============================================
   RESPONSIVE HELPERS
   ============================================ */
/* ── Tabs — pill-segment design ───────────────────────── */
.tabs-container {
    display: flex;
    gap: 0.25rem;
    background: var(--page-bg);
    border-radius: 0.75rem;
    padding: 0.25rem;
    border: 1px solid var(--border);
    width: fit-content;
    margin-bottom: 1.5rem;
}

.tab-btn {
    padding: 0.5rem 1.25rem;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    border-radius: 0.5rem;
    transition: color 0.2s, background 0.2s, transform 0.2s, box-shadow 0.2s;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    white-space: nowrap;
    line-height: 1.4;
}

.tab-btn i { font-size: 1rem; }

.tab-btn:hover {
    color: var(--accent);
    background: rgba(139, 92, 246, 0.08);
}

.tab-btn.active {
    background: var(--surface);
    color: var(--accent);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(139, 92, 246, 0.15);
    font-weight: 700;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.2s ease;
}

/* ── Row highlight ───────────────────────────────────── */
.row-success td {
    background: rgba(16, 185, 129, 0.06) !important;
}

/* ── Flex utilities ──────────────────────────────────── */
.flex { display: flex; }
.items-end { align-items: flex-end; }
.w-full { width: 100%; }
.gap-4 { gap: 1rem; }

/* ── Empty state icon size ───────────────────────────── */
.empty-state-3d .icon {
    font-size: 3rem !important;
}

/* ── Font utilities ───────────────────────────────────── */
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.fs-4 { font-size: 1.5rem; }

/* ── Margin/padding utilities ─────────────────────────── */
.mb-6 { margin-bottom: 1.5rem; }
.me-2 { margin-right: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.py-3 { padding-top: 0.75rem; padding-bottom: 0.75rem; }
.p-0 { padding: 0 !important; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 0.25rem; }

/* ── Text utilities ─────────────────────────────────── */
.text-center { text-align: center; }
.text-uppercase { text-transform: uppercase; }

/* ── Alert info variant ──────────────────────────────── */
.alert-3d-info {
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: #3b82f6;
}

/* ── Icon invert for close button in dark mode — canonical rule is in modal section ── */
:root, [data-theme="light"], [data-theme="dark"] {
    --icon-invert: none;
}

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

@media (max-width: 768px) {
    .grid-cols-2,
    .grid-cols-3,
    .grid-cols-4 {
        grid-template-columns: 1fr;
    }

    .btn-3d { padding: 0.5rem 0.875rem; font-size: 0.8125rem; }

    .tabs-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        width: 100%;
    }

    .tab-btn {
        padding: 0.4rem 0.875rem;
        font-size: 0.8rem;
        white-space: nowrap;
    }
}

/* Spinner para estado de carga */
@keyframes spin {
    to { transform: rotate(360deg); }
}
.spin {
    animation: spin 0.8s linear infinite;
}

/* ============================================
   MOBILE MENU BUTTON (hamburger topbar)
   ============================================ */
.mobile-menu-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 0.5rem;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    transition: background 0.15s;
}
.mobile-menu-btn:hover { background: var(--surface-hover); }
@media (max-width: 1023px) {
    .mobile-menu-btn { display: inline-flex; }
}

/* ============================================
   RESPONSIVE GLOBAL — mobile/tablet
   ============================================ */

/* Tablet (≤900px) */
@media (max-width: 900px) {
    .grid-responsive { grid-template-columns: 1fr !important; }

    /* Cards 2col en tablet */
    .stat-card-3d { min-width: 0; }
}

/* Mobile (≤520px) */
@media (max-width: 520px) {
    /* Reduce padding general */
    .main-content { padding: 0.875rem !important; }
    header { padding: 0.625rem 0.875rem !important; }

    /* Stat cards full width stacked */
    .stat-card-3d {
        padding: 0.875rem !important;
        flex-direction: row !important;
        gap: 0.625rem !important;
    }
    .stat-card-3d .stat-icon { width: 2.25rem !important; height: 2.25rem !important; font-size: 1rem !important; }
    .stat-card-3d .stat-label { font-size: 0.7rem !important; }
    .stat-card-3d .stat-value { font-size: 1rem !important; }

    /* Welcome banner reducido */
    h2 { font-size: 1.125rem !important; }

    /* Forms inputs full width touch */
    input, select, textarea, .form-control, .form-select {
        font-size: 16px !important; /* evita zoom iOS */
        min-height: 44px !important;
    }

    /* Buttons touch ≥44px */
    .btn-3d, .btn { min-height: 44px; padding: 0.625rem 0.875rem; }

    /* Sidebar links touch */
    .sidebar-link { min-height: 44px; }

    /* Cards body padding reducido */
    .card-3d-body { padding: 0.875rem !important; }
    .card-3d-header { padding: 0.75rem 0.875rem !important; }

    /* Modal full screen mobile */
    .modal-3d, .modal-content {
        margin: 0 !important;
        max-width: 100% !important;
        max-height: 100vh !important;
        border-radius: 0 !important;
    }
}

/* Tablas: scroll horizontal automático en parent (≤900px) */
@media (max-width: 900px) {
    .card-3d-body:has(.table-3d),
    .table-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .table-3d {
        font-size: 0.8125rem;
        min-width: 600px; /* fuerza scroll si no entra */
    }
    .table-3d thead th { padding: 0.5rem 0.625rem; }
    .table-3d tbody td { padding: 0.625rem 0.625rem; }
}

/* Sidebar overlay: solo mobile */
@media (min-width: 1024px) {
    #sidebar-overlay { display: none !important; }
}

/* ============================================
   DESKTOP CONTENT AREA PADDING OVERRIDE
   ============================================ */
@media (min-width: 769px) {
    .main-content { padding: 1.25rem 1.5rem !important; }
}

/* Tablet: slightly reduced */
@media (min-width: 521px) and (max-width: 768px) {
    .main-content { padding: 1.25rem 1.25rem !important; }
}

/* ============================================
   DESIGN SYSTEM — Componentes adicionales
   Añadidos 2026-05-08 para eliminar inline styles
   ============================================ */

/* Card header title (reemplaza style="font-size:0.9375rem; font-weight:700; color:var(--text); margin:0;") */
.ds-card-header__title {
    font-size: 0.9375rem;
    font-weight: 700;
    color: var(--text);
    margin: 0;
}

/* Action item para grids de acciones rápidas */
.ds-action-item {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 1rem;
    height: auto;
    text-align: center;
    align-items: center;
    justify-content: center;
}

/* Status dot (AFIP, conexiones, etc.) */
.ds-status-dot {
    width: 0.625rem;
    height: 0.625rem;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}
.ds-status-dot--success { background: var(--success); }
.ds-status-dot--warning { background: var(--warning); }
.ds-status-dot--danger  { background: var(--danger); }
.ds-status-dot--info    { background: var(--info); }

/* Small link para "Ver todos →" */
.ds-link-sm {
    font-size: 0.8125rem;
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}
.ds-link-sm:hover { text-decoration: underline; }

/* Table compacta usada en cards del dashboard */
.ds-table { width: 100%; border-collapse: collapse; margin: 0; }
.ds-table thead th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--table-border);
    white-space: nowrap;
}
.ds-table tbody td {
    padding: 0.75rem 1rem;
    color: var(--text);
    vertical-align: middle;
    font-size: 0.875rem;
}
.ds-table tbody tr { border-bottom: 1px solid var(--border-light); transition: background 0.1s; }
.ds-table tbody tr:last-child { border-bottom: none; }
.ds-table tbody tr:hover { background: var(--table-row-hover); }
.ds-table .ds-table__cell--center { text-align: center; }
.ds-table .ds-table__cell--right  { text-align: right; }
.ds-table .ds-table__cell--code   { font-family: monospace; font-size: 0.8rem; color: var(--text-muted); }
.ds-table .ds-table__cell--muted  { color: var(--text-muted); }
.ds-table .ds-table__cell--danger { font-weight: 700; color: var(--danger); }

/* Caja status card */
.ds-caja-status {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}
.ds-caja-status__icon {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.ds-caja-status__icon--open  { background: rgba(16, 185, 129, 0.12); color: var(--success); }
.ds-caja-status__icon--closed { background: var(--surface-hover); color: var(--text-muted); }
.ds-caja-status__title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text);
    margin: 0;
}
.ds-caja-status__subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin: 0.125rem 0 0;
}

/* AFIP status row */
.ds-afip-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.ds-afip-row__label {
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

/* Quick stat value inside card */
.ds-quick-stat {
    text-align: center;
    padding: 1.25rem;
}
.ds-quick-stat__label {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
}
.ds-quick-stat__value {
    font-size: 1.75rem;
    font-weight: 700;
}
.ds-quick-stat__sub {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Extra padding utilities que faltaban */
.py-2 { padding-top: 0.5rem; padding-bottom: 0.5rem; }

/* Extra margin utilities */
.mt-1 { margin-top: 0.25rem !important; }

/* Text utilities adicionales */
.no-underline { text-decoration: none; }
.text-foreground { color: var(--text) !important; }

/* Stat icon variants */
.ds-stat-icon--success { background: rgba(16,185,129,0.12) !important; color: var(--success) !important; }
.ds-stat-icon--primary  { background: var(--primary-light) !important; color: var(--primary) !important; }
.ds-stat-icon--info     { background: rgba(59,130,246,0.12) !important; color: var(--info) !important; }
.ds-stat-icon--warning  { background: rgba(245,158,11,0.12) !important; color: var(--warning) !important; }
.ds-stat-icon--danger   { background: rgba(239,68,68,0.12) !important; color: var(--danger) !important; }
.ds-stat-icon--accent   { background: rgba(139,92,246,0.12) !important; color: var(--accent) !important; }

/* Card danger variant (stock bajo alert) */
.ds-card--danger {
    border-left: 4px solid var(--danger) !important;
}
.ds-card--danger .card-3d-header {
    background: rgba(239,68,68,0.06);
}

/* Action item accent variant */
.ds-action-item--accent {
    background: rgba(139,92,246,0.08) !important;
    border-color: rgba(139,92,246,0.2) !important;
    color: var(--accent) !important;
}
