:root {
    /* Paleta DistriGo - azul corporativo + verde + naranja */
    --primary: #1f4880;          /* Azul DistriGo (Distri) - exacto del logo */
    --primary-dark: #153663;
    --primary-light: #e6ecf5;
    --primary-50: #f1f4f9;
    --primary-100: #dbe4f0;
    --primary-600: #1f4880;
    --primary-700: #153663;

    --success: #3ba24f;          /* Verde DistriGo (Go) - exacto del logo */
    --success-light: #e5f3e8;
    --warning: #e88838;          /* Naranja DistriGo (punto i) - exacto del logo */
    --warning-light: #fdecd9;
    --danger: #dc2626;
    --danger-light: #fee2e2;
    --info: #1f4880;             /* Usa azul corporativo también */
    --info-light: #e6ecf5;
    --purple: #7c3aed;
    --purple-light: #ede9fe;
    --pink: #db2777;
    --pink-light: #fce7f3;

    /* Acento naranja (para destacados) */
    --accent: #e88838;
    --accent-dark: #cf6f22;
    --accent-light: #fdecd9;

    /* Grises - escala neutra moderna */
    --gray-50: #fafafa;
    --gray-100: #f4f4f5;
    --gray-150: #ececef;
    --gray-200: #e4e4e7;
    --gray-300: #d4d4d8;
    --gray-400: #a1a1aa;
    --gray-500: #71717a;
    --gray-600: #52525b;
    --gray-700: #3f3f46;
    --gray-800: #27272a;
    --gray-900: #18181b;

    /* Layout */
    --sidebar-width: 260px;
    --topbar-height: 64px;
    --radius: 10px;
    --radius-lg: 16px;
    --radius-xl: 22px;

    /* Sombras suaves modernas */
    --shadow-xs: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.07), 0 1px 2px -1px rgb(0 0 0 / 0.07);
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.08), 0 2px 4px -2px rgb(0 0 0 / 0.08);
    --shadow-md: 0 10px 15px -3px rgb(0 0 0 / 0.08), 0 4px 6px -4px rgb(0 0 0 / 0.08);
    --shadow-lg: 0 20px 25px -5px rgb(0 0 0 / 0.10), 0 8px 10px -6px rgb(0 0 0 / 0.10);

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

* { box-sizing: border-box; }

html, body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'SF Pro Display', 'Inter', 'Segoe UI', system-ui, sans-serif;
    background: var(--gray-50);
    color: var(--gray-900);
    margin: 0; padding: 0;
    font-size: 14px; line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

/* LOGIN */
.login-page {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(420px, 1fr) 1fr;
    background: white;
}
.login-card {
    padding: 4rem 3rem;
    display: flex; flex-direction: column; justify-content: center;
    max-width: 480px; width: 100%; margin: 0 auto;
}
.login-header { text-align: center; margin-bottom: 2.5rem; }
.login-logo {
    width: 64px; height: 64px;
    border-radius: var(--radius-xl);
    background: linear-gradient(135deg, var(--primary) 0%, var(--success) 100%);
    display: inline-flex; align-items: center; justify-content: center;
    color: white; font-size: 1.75rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 10px 30px -5px rgba(31, 72, 128, 0.4);
}
.login-header h1 {
    font-size: 1.75rem; font-weight: 700;
    color: var(--gray-900); margin: 0 0 .5rem;
    letter-spacing: -0.025em;
}
.login-header p { color: var(--gray-500); margin: 0; font-size: .95rem; }
.login-bg {
    background: linear-gradient(135deg, var(--primary) 0%, var(--success) 50%, var(--accent) 100%);
    position: relative;
    display: flex; align-items: center; justify-content: center;
    color: white; padding: 3rem; overflow: hidden;
}
.login-bg::before {
    content: ''; position: absolute; inset: 0;
    background: radial-gradient(circle at 20% 50%, rgba(255,255,255,0.1) 0%, transparent 50%),
                radial-gradient(circle at 80% 80%, rgba(255,255,255,0.05) 0%, transparent 50%);
}
.bg-overlay { max-width: 460px; position: relative; z-index: 1; }
.bg-overlay h2 {
    font-size: 2.5rem; font-weight: 700;
    margin-bottom: 1.5rem;
    letter-spacing: -0.025em; line-height: 1.2;
}
.bg-overlay .features { list-style: none; padding: 0; margin: 0; }
.bg-overlay .features li {
    padding: .75rem 0; font-size: 1rem;
    display: flex; align-items: center; gap: .75rem;
    opacity: 0.95;
}
.bg-overlay .features i { color: #bef264; font-size: 1.25rem; flex-shrink: 0; }
.input-icon-wrapper { position: relative; }
.input-icon {
    position: absolute; left: 14px; top: 50%;
    transform: translateY(-50%); color: var(--gray-400);
    font-size: 1.1rem; pointer-events: none;
}
.form-control.with-icon { padding-left: 42px; }
.btn-block { width: 100%; padding: .75rem; font-weight: 600; }
.login-footer {
    text-align: center; margin-top: 2.5rem;
    padding: 1.25rem;
    background: var(--gray-50);
    border-radius: var(--radius);
    border: 1px solid var(--gray-200);
}
.login-footer code {
    background: white; padding: 3px 8px;
    border-radius: 4px; color: var(--primary);
    font-family: 'JetBrains Mono', 'Courier New', monospace;
    font-size: .8rem; font-weight: 600;
    border: 1px solid var(--gray-200);
}
@media (max-width: 900px) {
    .login-page { grid-template-columns: 1fr; }
    .login-bg { display: none; }
}

/* SIDEBAR */
.sidebar {
    position: fixed; top: 0; left: 0;
    width: var(--sidebar-width); height: 100vh;
    background: white;
    border-right: 1px solid var(--gray-200);
    display: flex; flex-direction: column;
    z-index: 100;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.sidebar-header {
    padding: 1.5rem 1.5rem 1.25rem;
    border-bottom: 1px solid var(--gray-150);
    display: flex; align-items: center; justify-content: center;
}
.logo-img {
    max-width: 160px;
    height: auto;
    display: block;
}
.logo {
    width: 40px; height: 40px;
    border-radius: var(--radius);
    background: linear-gradient(135deg, var(--primary), var(--success));
    display: flex; align-items: center; justify-content: center;
    color: white; font-size: 1.15rem;
    box-shadow: 0 4px 12px -2px rgba(30, 70, 120, 0.4);
}
.sidebar-title {
    font-weight: 700; color: var(--gray-900);
    font-size: .95rem; line-height: 1.3;
    letter-spacing: -0.015em;
}
.sidebar-subtitle {
    font-size: .68rem; color: var(--gray-500);
    font-weight: 500; letter-spacing: 0.04em;
    text-transform: uppercase;
}
.sidebar-nav { flex: 1; overflow-y: auto; padding: 1rem .75rem; }
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 3px; }
.nav-section { margin-bottom: 1.5rem; }
.nav-section-title {
    padding: .25rem .75rem .5rem;
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--gray-400);
    font-weight: 600;
}
.nav-link {
    display: flex; align-items: center; gap: .75rem;
    padding: .55rem .75rem;
    color: var(--gray-700);
    text-decoration: none;
    font-size: .85rem; font-weight: 500;
    border-radius: var(--radius);
    transition: var(--transition);
    margin-bottom: 2px;
}
.nav-link i {
    font-size: 1.1rem; width: 20px; text-align: center;
    color: var(--gray-500); transition: var(--transition);
}
.nav-link:hover { background: var(--gray-100); color: var(--gray-900); }
.nav-link:hover i { color: var(--gray-700); }
.nav-link.active {
    background: var(--primary-light);
    color: var(--primary-dark);
    font-weight: 600;
}
.nav-link.active i { color: var(--primary); }
.nav-link .nav-badge {
    margin-left: auto;
    background: var(--danger); color: white;
    font-size: .65rem; padding: 2px 7px;
    border-radius: 10px; font-weight: 600;
}
.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--gray-150);
    display: flex; align-items: center; gap: .75rem;
}
.user-info { flex: 1; display: flex; align-items: center; gap: .75rem; min-width: 0; }
.user-avatar {
    width: 38px; height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--success));
    color: white;
    display: flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: .8rem;
    flex-shrink: 0;
}
.user-details { flex: 1; min-width: 0; }
.user-name {
    font-size: .82rem; font-weight: 600; color: var(--gray-900);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.user-role { font-size: .7rem; color: var(--gray-500); font-weight: 500; }
.logout-btn {
    width: 36px; height: 36px;
    border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center;
    color: var(--gray-500); text-decoration: none;
    background: var(--gray-100);
    transition: var(--transition); flex-shrink: 0;
}
.logout-btn:hover { background: var(--danger); color: white; }

/* MAIN CONTENT */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    background: var(--gray-50);
}
.topbar {
    height: var(--topbar-height);
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--gray-200);
    padding: 0 2rem;
    display: flex; align-items: center; gap: 1rem;
    position: sticky; top: 0; z-index: 50;
}
.btn-icon {
    width: 38px; height: 38px;
    border-radius: var(--radius);
    background: transparent; border: none;
    display: none; align-items: center; justify-content: center;
    color: var(--gray-700); font-size: 1.2rem;
    cursor: pointer; transition: var(--transition);
}
.btn-icon:hover { background: var(--gray-100); }
.topbar-title {
    font-weight: 600; color: var(--gray-900);
    flex: 1; font-size: .95rem;
}
.topbar-actions { display: flex; align-items: center; gap: 1rem; }
.content-wrapper { padding: 2rem; max-width: 1440px; margin: 0 auto; }

@media (max-width: 1024px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
    .main-content { margin-left: 0; }
    .btn-icon { display: flex; }
    .topbar { padding: 0 1rem; }
    .content-wrapper { padding: 1rem; }
}

/* PAGE HEADER */
.page-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 1.75rem; flex-wrap: wrap; gap: 1rem;
}
.page-title { display: flex; align-items: center; gap: 1rem; }
.page-title .icon {
    width: 48px; height: 48px;
    border-radius: var(--radius-lg);
    background: var(--primary-light);
    color: var(--primary);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.35rem;
    box-shadow: 0 4px 12px -2px rgba(31, 72, 128, 0.15);
}
.page-title h1 {
    margin: 0; font-size: 1.5rem; font-weight: 700;
    color: var(--gray-900);
    letter-spacing: -0.02em; line-height: 1.2;
}
.page-title p { margin: 0; color: var(--gray-500); font-size: .85rem; }
.page-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* STATS GRID */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem; margin-bottom: 1.75rem;
}
.stat-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    display: flex; align-items: center; gap: 1rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-150);
    transition: var(--transition);
    position: relative; overflow: hidden;
}
.stat-card::before {
    content: ''; position: absolute;
    top: 0; left: 0; right: 0; height: 3px;
    background: var(--primary);
}
.stat-card.success::before { background: var(--success); }
.stat-card.warning::before { background: var(--warning); }
.stat-card.danger::before { background: var(--danger); }
.stat-card.info::before { background: var(--info); }
.stat-card.purple::before { background: var(--purple); }
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-card .stat-icon {
    width: 44px; height: 44px;
    border-radius: var(--radius);
    background: var(--primary-light); color: var(--primary);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.4rem; flex-shrink: 0;
}
.stat-card.success .stat-icon { background: var(--success-light); color: var(--success); }
.stat-card.warning .stat-icon { background: var(--warning-light); color: var(--warning); }
.stat-card.danger .stat-icon { background: var(--danger-light); color: var(--danger); }
.stat-card.info .stat-icon { background: var(--info-light); color: var(--info); }
.stat-card.purple .stat-icon { background: var(--purple-light); color: var(--purple); }
.stat-value {
    font-size: 1.55rem; font-weight: 700;
    color: var(--gray-900); line-height: 1.1;
    letter-spacing: -0.02em;
}
.stat-label {
    font-size: .78rem; color: var(--gray-500);
    font-weight: 500; margin-top: 2px;
}
.stat-trend {
    font-size: .72rem; margin-top: .35rem;
    color: var(--gray-500);
    display: flex; align-items: center; gap: .25rem;
}
.stat-trend.up { color: var(--success); }
.stat-trend.down { color: var(--danger); }

/* CARDS */
.card {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
    border: 1px solid var(--gray-150);
    margin-bottom: 1rem;
    overflow: hidden;
}
.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--gray-150);
    display: flex; justify-content: space-between; align-items: center;
    background: white; gap: .75rem;
}
.card-title {
    margin: 0; font-size: .95rem; font-weight: 600;
    color: var(--gray-900);
    display: flex; align-items: center; gap: .5rem;
    letter-spacing: -0.01em;
}
.card-title i { color: var(--primary); font-size: 1.05rem; }
.card-body { padding: 1.25rem; }

/* FORMS */
.form-group { margin-bottom: 1rem; }
.form-label {
    display: block; margin-bottom: .375rem;
    font-size: .8rem; font-weight: 500;
    color: var(--gray-700);
}
.form-label .required { color: var(--danger); margin-left: 2px; }
.form-control, .form-select {
    width: 100%;
    padding: .55rem .85rem;
    font-size: .875rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    transition: var(--transition);
    background: white;
    color: var(--gray-900);
    font-family: inherit;
}
.form-control::placeholder { color: var(--gray-400); }
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(31, 72, 128, 0.1);
    outline: none;
}
.form-control:hover:not(:focus), .form-select:hover:not(:focus) { border-color: var(--gray-400); }
.form-control:disabled, .form-select:disabled {
    background: var(--gray-100); color: var(--gray-500); cursor: not-allowed;
}
textarea.form-control { min-height: 80px; resize: vertical; font-family: inherit; }
.form-check { display: flex; align-items: center; gap: .5rem; cursor: pointer; user-select: none; }
.form-check input[type="checkbox"], .form-check input[type="radio"] {
    width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer;
}

/* BUTTONS */
.btn {
    padding: .55rem 1rem;
    font-size: .85rem; font-weight: 500;
    border-radius: var(--radius);
    border: 1px solid transparent;
    cursor: pointer;
    display: inline-flex; align-items: center; gap: .375rem;
    transition: var(--transition); text-decoration: none;
    font-family: inherit; line-height: 1.25;
    white-space: nowrap;
}
.btn i { font-size: 1rem; }
.btn:active { transform: translateY(1px); }
.btn-primary {
    background: var(--primary); color: white;
    box-shadow: 0 1px 2px rgba(31, 72, 128, 0.1);
}
.btn-primary:hover {
    background: var(--primary-dark); color: white;
    box-shadow: 0 4px 12px -2px rgba(31, 72, 128, 0.3);
}
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #047857; color: white; box-shadow: 0 4px 12px -2px rgba(5, 150, 105, 0.3); }
.btn-warning { background: var(--warning); color: white; }
.btn-warning:hover { background: #b45309; color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #b91c1c; color: white; }
.btn-outline-primary {
    background: white; color: var(--primary);
    border-color: var(--gray-300);
}
.btn-outline-primary:hover {
    background: var(--primary-light);
    color: var(--primary-dark);
    border-color: var(--primary);
}
.btn-outline-secondary {
    background: white; color: var(--gray-700);
    border-color: var(--gray-300);
}
.btn-outline-secondary:hover { background: var(--gray-100); color: var(--gray-900); }
.btn-outline-danger {
    background: white; color: var(--danger);
    border-color: var(--gray-300);
}
.btn-outline-danger:hover { background: var(--danger); color: white; border-color: var(--danger); }
.btn-sm { padding: .35rem .75rem; font-size: .78rem; border-radius: 6px; }
.btn-sm i { font-size: .9rem; }
.btn-lg { padding: .75rem 1.25rem; font-size: .95rem; }
.btn-ghost { background: transparent; color: var(--gray-600); }
.btn-ghost:hover { background: var(--gray-100); color: var(--gray-900); }

/* TABLES */
.table { width: 100%; background: white; border-collapse: collapse; }
.table th {
    background: var(--gray-50);
    padding: .65rem 1rem;
    text-align: left; font-size: .7rem; font-weight: 600;
    color: var(--gray-600); text-transform: uppercase;
    letter-spacing: .04em;
    border-bottom: 1px solid var(--gray-200);
    white-space: nowrap;
}
.table td {
    padding: .75rem 1rem; font-size: .85rem;
    border-bottom: 1px solid var(--gray-100);
    vertical-align: middle; color: var(--gray-700);
}
.table td.fw-semibold, .table td .fw-semibold { color: var(--gray-900); }
.table tbody tr { transition: var(--transition); }
.table tbody tr:hover { background: var(--gray-50); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tfoot td {
    padding: .65rem 1rem; font-size: .85rem;
    border-top: 1px solid var(--gray-200);
    background: var(--gray-50);
}
.table-responsive { overflow-x: auto; border-radius: var(--radius-lg); }

/* BADGES */
.badge {
    display: inline-flex; align-items: center; gap: .25rem;
    padding: .2rem .55rem; font-size: .7rem; font-weight: 600;
    border-radius: 6px; line-height: 1.4; white-space: nowrap;
}
.badge i { font-size: .85rem; }
.badge-primary { background: var(--primary-light); color: var(--primary-dark); }
.badge-success { background: var(--success-light); color: #047857; }
.badge-warning { background: var(--warning-light); color: #b45309; }
.badge-danger { background: var(--danger-light); color: #b91c1c; }
.badge-info { background: var(--info-light); color: #0369a1; }
.badge-secondary { background: var(--gray-150); color: var(--gray-700); }
.badge-purple { background: var(--purple-light); color: #6d28d9; }
.badge-pink { background: var(--pink-light); color: #be185d; }

/* ALERTS */
.alert {
    padding: .85rem 1.1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    border: 1px solid transparent;
    display: flex; align-items: flex-start; gap: .65rem;
    font-size: .85rem;
}
.alert i { font-size: 1.1rem; margin-top: 1px; flex-shrink: 0; }
.alert-success { background: var(--success-light); color: #065f46; border-color: #6ee7b7; }
.alert-danger { background: var(--danger-light); color: #991b1b; border-color: #fca5a5; }
.alert-warning { background: var(--warning-light); color: #92400e; border-color: #fcd34d; }
.alert-info { background: var(--info-light); color: #075985; border-color: #7dd3fc; }

/* UTILITIES */
.text-muted { color: var(--gray-500); }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-info { color: var(--info); }
.text-end { text-align: right; }
.text-center { text-align: center; }
.fw-bold { font-weight: 700; }
.fw-semibold { font-weight: 600; }
.fw-medium { font-weight: 500; }
.small { font-size: .78rem; }
.tiny { font-size: .7rem; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: .25rem; }
.mb-2 { margin-bottom: .5rem; }
.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 1.5rem; }
.mt-1 { margin-top: .25rem; }
.mt-2 { margin-top: .5rem; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }
.gap-1 { gap: .25rem; }
.gap-2 { gap: .5rem; }
.gap-3 { gap: 1rem; }
.d-flex { display: flex; }
.d-inline-flex { display: inline-flex; }
.align-items-center { align-items: center; }
.justify-content-between { justify-content: space-between; }
.justify-content-end { justify-content: flex-end; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; }

/* GRID */
.row { display: flex; flex-wrap: wrap; margin: -.5rem; }
.col, [class^="col-"] { padding: .5rem; }
.col { flex: 1; }
.col-12 { flex: 0 0 100%; max-width: 100%; }
.col-md-6 { flex: 0 0 50%; max-width: 50%; }
.col-md-4 { flex: 0 0 33.333%; max-width: 33.333%; }
.col-md-3 { flex: 0 0 25%; max-width: 25%; }
.col-md-2 { flex: 0 0 16.666%; max-width: 16.666%; }
.col-md-8 { flex: 0 0 66.666%; max-width: 66.666%; }
.col-lg-8 { flex: 0 0 66.666%; max-width: 66.666%; }
.col-lg-4 { flex: 0 0 33.333%; max-width: 33.333%; }
.col-lg-6 { flex: 0 0 50%; max-width: 50%; }
.col-lg-3 { flex: 0 0 25%; max-width: 25%; }
@media (max-width: 768px) {
    .col-md-6, .col-md-4, .col-md-3, .col-md-2, .col-md-8,
    .col-lg-8, .col-lg-4, .col-lg-6, .col-lg-3 {
        flex: 0 0 100%; max-width: 100%;
    }
}

/* CHART */
.chart-bars {
    display: flex; align-items: flex-end; gap: .65rem;
    height: 220px; padding: 1rem 0;
}
.chart-bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; min-width: 0; }
.chart-bar-fill {
    width: 100%;
    background: linear-gradient(180deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-radius: 8px 8px 0 0;
    min-height: 4px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 -2px 8px -2px rgba(31, 72, 128, 0.3);
}
.chart-bar-fill:hover { background: linear-gradient(180deg, var(--primary-dark) 0%, #6d28d9 100%); }
.chart-bar-label { font-size: .7rem; color: var(--gray-500); margin-top: .5rem; font-weight: 500; }
.chart-bar-value { font-size: .7rem; color: var(--gray-700); margin-bottom: .35rem; font-weight: 600; }

/* EMPTY STATE */
.empty-state { padding: 3rem 1rem; text-align: center; color: var(--gray-400); }
.empty-state i { font-size: 3rem; display: block; margin-bottom: 1rem; opacity: .4; color: var(--gray-400); }
.empty-state p { color: var(--gray-500); margin: 0; font-size: .9rem; }

/* LIST ITEMS */
.list-item {
    padding: .85rem 1.25rem;
    border-bottom: 1px solid var(--gray-100);
    display: flex; justify-content: space-between; align-items: center;
    transition: var(--transition);
}
.list-item:last-child { border-bottom: 0; }
.list-item:hover { background: var(--gray-50); }

/* STEPS / TIMELINE */
.steps { display: flex; align-items: center; gap: .5rem; margin: 1rem 0; flex-wrap: wrap; }
.step {
    flex: 1; min-width: 130px;
    display: flex; align-items: center; gap: .5rem;
    padding: .65rem .85rem;
    background: var(--gray-100);
    border-radius: var(--radius);
    font-size: .8rem;
    color: var(--gray-600);
}
.step.active { background: var(--primary-light); color: var(--primary-dark); font-weight: 600; }
.step.done { background: var(--success-light); color: #047857; }
.step-icon {
    width: 24px; height: 24px;
    border-radius: 50%; background: white;
    display: flex; align-items: center; justify-content: center;
    font-size: .75rem; font-weight: 700;
    flex-shrink: 0;
}
.step.active .step-icon { background: var(--primary); color: white; }
.step.done .step-icon { background: var(--success); color: white; }

/* FILTER CHIPS */
.filter-chips { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.filter-chip {
    padding: .35rem .85rem;
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: 20px;
    font-size: .8rem;
    color: var(--gray-700);
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}
.filter-chip:hover { background: var(--gray-50); color: var(--gray-900); border-color: var(--gray-300); }
.filter-chip.active { background: var(--primary); color: white; border-color: var(--primary); font-weight: 600; }

/* SCROLLBAR */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }

/* ANIMACIONES */
@keyframes fadeIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }
.alert, .stat-card, .card { animation: fadeIn 0.3s ease-out; }

/* PRINT */
@media print {
    .sidebar, .topbar, .page-actions, .btn { display: none !important; }
    .main-content { margin-left: 0 !important; }
    .card { box-shadow: none !important; border: 1px solid var(--gray-300) !important; }
}

/* =====================================================
   SISTEMA DE ALERTAS - Campanita y dropdown
   ===================================================== */

.alertas-wrapper {
    position: relative;
    display: inline-flex;
}

.alertas-btn {
    background: var(--gray-100);
    border: none;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    color: var(--gray-700);
    transition: all .15s;
    font-size: 1.15rem;
}
.alertas-btn:hover {
    background: var(--gray-200);
    color: var(--primary);
}
.alertas-btn.tiene-criticas i {
    color: var(--danger);
    animation: bell-shake 2s ease-in-out infinite;
}
@keyframes bell-shake {
    0%, 50%, 100% { transform: rotate(0); }
    10%, 30% { transform: rotate(-12deg); }
    20%, 40% { transform: rotate(12deg); }
}

.alertas-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    background: var(--warning);
    color: white;
    border-radius: 999px;
    font-size: .68rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0,0,0,.15);
    animation: badge-pop .3s ease;
}
.alertas-badge.critica {
    background: var(--danger);
    animation: badge-pulse 1.5s ease-in-out infinite;
}
@keyframes badge-pop {
    0% { transform: scale(0); }
    60% { transform: scale(1.2); }
    100% { transform: scale(1); }
}
@keyframes badge-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, .5); }
    50% { box-shadow: 0 0 0 6px rgba(220, 38, 38, 0); }
}

.alertas-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 420px;
    max-width: 90vw;
    background: white;
    border-radius: 14px;
    box-shadow: 0 20px 50px rgba(0,0,0,.18), 0 4px 12px rgba(0,0,0,.06);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px) scale(.96);
    transition: all .2s cubic-bezier(.16,1,.3,1);
    z-index: 1050;
    overflow: hidden;
    max-height: calc(100vh - 80px);
    display: flex;
    flex-direction: column;
}
.alertas-dropdown.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.alertas-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.15rem .85rem;
    border-bottom: 1px solid var(--gray-100);
}
.alertas-header h5 i {
    color: var(--primary);
}

.btn-ghost-icon {
    background: transparent;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    color: var(--gray-500);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all .15s;
}
.btn-ghost-icon:hover {
    background: var(--gray-100);
    color: var(--primary);
}

.alertas-tabs {
    display: flex;
    gap: .25rem;
    padding: .5rem .85rem;
    border-bottom: 1px solid var(--gray-100);
    overflow-x: auto;
    scrollbar-width: none;
}
.alertas-tabs::-webkit-scrollbar { display: none; }

.alertas-tab {
    flex-shrink: 0;
    background: transparent;
    border: none;
    padding: .4rem .75rem;
    border-radius: 8px;
    cursor: pointer;
    color: var(--gray-600);
    font-size: .8rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    transition: all .15s;
    white-space: nowrap;
}
.alertas-tab:hover {
    background: var(--gray-100);
}
.alertas-tab.active {
    background: var(--primary);
    color: white;
}

.tab-count {
    background: rgba(0,0,0,.08);
    color: inherit;
    padding: 1px 7px;
    border-radius: 99px;
    font-size: .7rem;
    font-weight: 600;
    min-width: 18px;
    text-align: center;
}
.alertas-tab.active .tab-count {
    background: rgba(255,255,255,.25);
}
.tab-count.danger { background: rgba(220, 38, 38, .15); color: var(--danger); }
.tab-count.warning { background: rgba(245, 158, 11, .15); color: var(--warning); }
.tab-count.info { background: rgba(14, 165, 233, .15); color: var(--info); }
.alertas-tab.active .tab-count.danger,
.alertas-tab.active .tab-count.warning,
.alertas-tab.active .tab-count.info {
    background: rgba(255,255,255,.25);
    color: white;
}

.alertas-lista {
    flex: 1;
    overflow-y: auto;
    max-height: 480px;
}

.alerta-item {
    display: flex;
    gap: .75rem;
    padding: .85rem 1rem;
    border-bottom: 1px solid var(--gray-50);
    transition: background .15s;
    align-items: flex-start;
    position: relative;
}
.alerta-item:hover {
    background: var(--gray-50);
}
.alerta-item:last-child {
    border-bottom: none;
}

.alerta-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1.05rem;
}

.alerta-content {
    flex: 1;
    min-width: 0;
    text-decoration: none;
    color: inherit;
    display: block;
}
.alerta-content:hover {
    color: inherit;
}

.alerta-titulo {
    font-size: .75rem;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: .03em;
    font-weight: 600;
    margin-bottom: .15rem;
}
.alerta-mensaje {
    font-weight: 600;
    font-size: .9rem;
    color: var(--gray-800);
    margin-bottom: .15rem;
    line-height: 1.3;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
}
.alerta-detalle {
    font-size: .78rem;
    color: var(--gray-500);
    line-height: 1.3;
}

.alerta-cerrar {
    background: transparent;
    border: none;
    width: 26px;
    height: 26px;
    border-radius: 6px;
    cursor: pointer;
    color: var(--gray-400);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all .15s;
    opacity: 0;
}
.alerta-item:hover .alerta-cerrar {
    opacity: 1;
}
.alerta-cerrar:hover {
    background: var(--gray-200);
    color: var(--danger);
}

.alertas-empty {
    padding: 3rem 1.5rem;
    text-align: center;
    color: var(--gray-500);
}
.alertas-empty i {
    font-size: 3rem;
    margin-bottom: .5rem;
    display: block;
}
.alertas-empty p {
    margin: .5rem 0 .25rem;
    color: var(--gray-700);
}

.alertas-skeleton {
    padding: 1rem;
}
.skeleton-row {
    height: 64px;
    background: linear-gradient(90deg, var(--gray-100) 0%, var(--gray-50) 50%, var(--gray-100) 100%);
    background-size: 200% 100%;
    border-radius: 10px;
    margin-bottom: .5rem;
    animation: skeleton-shimmer 1.5s ease-in-out infinite;
}
@keyframes skeleton-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.alertas-more {
    text-align: center;
    padding: .75rem;
    border-top: 1px solid var(--gray-100);
}
.alertas-more a {
    color: var(--primary);
    text-decoration: none;
    font-size: .85rem;
    font-weight: 500;
}

.alertas-footer {
    display: flex;
    justify-content: space-between;
    padding: .75rem 1rem;
    background: var(--gray-50);
    border-top: 1px solid var(--gray-100);
    gap: .5rem;
}
.alertas-footer-link {
    color: var(--primary);
    text-decoration: none;
    font-size: .82rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: .35rem;
}
.alertas-footer-link:hover {
    text-decoration: underline;
}
.alertas-footer-btn {
    background: transparent;
    border: none;
    color: var(--gray-600);
    font-size: .82rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: 0;
}
.alertas-footer-btn:hover {
    color: var(--danger);
}

/* Responsive */
@media (max-width: 576px) {
    .alertas-dropdown {
        width: calc(100vw - 24px);
        right: -8px;
    }
}

/* =====================================================
   MODAL DE CONFIRMACIÓN MODERNO (dg-modal)
   Reemplaza los confirm() nativos del navegador.
   ===================================================== */
.dg-modal-overlay {
    position: fixed; inset: 0; z-index: 1000;
    display: flex; align-items: center; justify-content: center;
    padding: 1rem;
    background: rgba(15, 23, 42, .45);
    backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
    opacity: 0; visibility: hidden;
    transition: opacity .2s ease, visibility .2s ease;
}
.dg-modal-overlay.open { opacity: 1; visibility: visible; }
body.dg-modal-open { overflow: hidden; }

.dg-modal {
    width: 100%; max-width: 420px;
    background: #fff;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    padding: 1.75rem 1.5rem 1.25rem;
    text-align: center;
    transform: translateY(14px) scale(.96);
    opacity: 0;
    transition: transform .24s cubic-bezier(.34, 1.3, .5, 1), opacity .2s ease;
}
.dg-modal-overlay.open .dg-modal { transform: translateY(0) scale(1); opacity: 1; }

.dg-modal-icon {
    width: 56px; height: 56px; border-radius: 50%;
    margin: 0 auto 1rem;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.6rem;
    background: var(--primary-light); color: var(--primary);
}
.dg-modal.dg-danger .dg-modal-icon { background: var(--danger-light); color: var(--danger); }

.dg-modal-title { font-size: 1.15rem; font-weight: 700; color: var(--gray-900); margin: 0 0 .4rem; }
.dg-modal-text  { font-size: .92rem; line-height: 1.55; color: var(--gray-600); margin: 0; }

.dg-modal-actions { display: flex; gap: .6rem; margin-top: 1.5rem; }
.dg-btn {
    flex: 1; padding: .62rem 1rem;
    border-radius: var(--radius);
    font-size: .9rem; font-weight: 600; cursor: pointer;
    border: 1px solid transparent;
    transition: var(--transition);
}
.dg-btn-cancel { background: var(--gray-100); color: var(--gray-700); border-color: var(--gray-200); }
.dg-btn-cancel:hover { background: var(--gray-200); }
.dg-btn-confirm { background: var(--primary); color: #fff; }
.dg-btn-confirm:hover { background: var(--primary-dark); }
.dg-modal.dg-danger .dg-btn-confirm { background: var(--danger); }
.dg-modal.dg-danger .dg-btn-confirm:hover { filter: brightness(.93); }
.dg-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

@media (max-width: 480px) { .dg-modal-actions { flex-direction: column-reverse; } }

/* =====================================================
   SIDEBAR — TEMA CLARO AZULADO (opción F)
   Fondo gris azulado claro con texto azul oscuro.
   Contraste verificado: enlaces 8.6:1 (AAA), activo 11.9:1 (AAA),
   acento azul 8.5:1 (AAA). Bloque final para sobreescribir.
   ===================================================== */
:root {
    --sidebar-bg:     #eef2f7;            /* gris azulado claro */
    --sidebar-hover:  rgba(30,70,120,.06);
    --sidebar-active: rgba(30,70,120,.10);
    --sidebar-text:   #34465b;            /* enlaces (8.6:1 AAA) */
    --sidebar-strong: #14304e;            /* activo/usuario (11.9:1 AAA) */
    --sidebar-muted:  #7488a0;            /* títulos de sección / rol */
    --sidebar-border: #dbe2ec;            /* separadores suaves */
    --sidebar-accent: #1f4880;            /* azul de marca (ítem activo) */
}

.sidebar {
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
}

.sidebar-header {
    border-bottom: 1px solid var(--sidebar-border);
    padding: 1.25rem 1.25rem;
}
/* Fondo claro: el logo se ve bien directamente (sin tarjeta) */
.sidebar-header .logo-img {
    background: transparent;
    padding: 0;
    max-width: 160px;
}
.sidebar-title    { color: var(--sidebar-strong); }
.sidebar-subtitle { color: var(--sidebar-muted); }

.sidebar-nav::-webkit-scrollbar-thumb { background: #cdd7e3; }

.nav-section-title { color: var(--sidebar-muted); }

.nav-link        { color: var(--sidebar-text); }
.nav-link i      { color: #7488a0; }
.nav-link:hover  { background: var(--sidebar-hover); color: var(--sidebar-strong); }
.nav-link:hover i{ color: var(--sidebar-strong); }
.nav-link.active {
    background: var(--sidebar-active);
    color: var(--sidebar-strong);
    box-shadow: inset 3px 0 0 var(--sidebar-accent);
}
.nav-link.active i { color: var(--sidebar-accent); }

.sidebar-footer { border-top: 1px solid var(--sidebar-border); }
.user-name { color: var(--sidebar-strong); }
.user-role { color: var(--sidebar-muted); }
.logout-btn {
    background: #e3e9f1;
    color: var(--sidebar-text);
}
.logout-btn:hover { background: var(--danger); color: #fff; }

/* ============================================================
   CAPA DE REFINAMIENTO "APPLE"  ·  DistriGo ERP
   Añadida al final: sobrescribe con misma especificidad para
   dar el mismo lenguaje visual que la landing pública.
   ============================================================ */
body{ letter-spacing:-.003em; }

/* --- Botones tipo píldora --- */
.btn{
  border-radius:980px; font-weight:500; padding:.6rem 1.15rem;
  transition:all .25s cubic-bezier(.2,.7,.2,1);
}
.btn:active{ transform:scale(.97); }
.btn-primary{ box-shadow:0 1px 2px rgba(31,72,128,.18); }
.btn-primary:hover{ background:var(--primary-dark); transform:scale(1.015); box-shadow:0 6px 16px -4px rgba(31,72,128,.35); }
.btn-success:hover{ background:#2f8340; box-shadow:0 6px 16px -4px rgba(59,162,79,.32); }
.btn-warning:hover{ background:var(--accent-dark); box-shadow:0 6px 16px -4px rgba(232,136,56,.32); }
.btn-sm{ border-radius:980px; padding:.4rem .85rem; }
.btn-lg{ border-radius:980px; padding:.8rem 1.5rem; }
.btn-outline-primary,.btn-outline-secondary,.btn-outline-danger{ border-radius:980px; }

/* --- Inputs: foco navy, radios suaves --- */
.form-control, .form-select{ border-radius:12px; border-color:var(--gray-200); padding:.62rem .9rem; }
.form-control:focus, .form-select:focus{ border-color:var(--primary); box-shadow:0 0 0 4px rgba(31,72,128,.13); }
textarea.form-control{ border-radius:14px; }

/* --- Tarjetas: más redondeadas y sombra muy suave --- */
.card{ border-radius:18px; border-color:rgba(0,0,0,.05); box-shadow:0 2px 14px rgba(0,0,0,.05); }
.card-header{ padding:1.1rem 1.35rem; border-bottom-color:var(--gray-100); }
.card-body{ padding:1.35rem; }

/* --- Stat cards: sin barra superior, más limpias --- */
.stat-card{ border-radius:18px; border-color:rgba(0,0,0,.05); box-shadow:0 2px 14px rgba(0,0,0,.05); padding:1.4rem; }
.stat-card::before{ height:0; }
.stat-card .stat-icon{ border-radius:14px; }
.stat-value{ font-size:1.7rem; letter-spacing:-.03em; }

/* --- Topbar más esmerilado --- */
.topbar{
  background:rgba(255,255,255,.72);
  backdrop-filter:saturate(180%) blur(20px);
  -webkit-backdrop-filter:saturate(180%) blur(20px);
}
.topbar-title{ font-size:1rem; letter-spacing:-.02em; }

/* --- Sidebar: ítem activo tipo píldora rellena (Apple) --- */
.sidebar-nav{ padding:1rem .6rem; }
.nav-link{ border-radius:11px; padding:.58rem .8rem; }
.nav-link.active{
  background:var(--primary); color:#fff;
  box-shadow:0 4px 12px -3px rgba(31,72,128,.42);
}
.nav-link.active i{ color:#fff; }
.nav-link.active .nav-badge{ background:rgba(255,255,255,.25); color:#fff; }
.nav-badge{ border-radius:980px; }

/* --- Badges tipo píldora --- */
.badge{ border-radius:980px; padding:.25rem .65rem; }

/* --- Íconos de encabezado / avatar con sombra de marca --- */
.page-title .icon{ border-radius:14px; box-shadow:0 6px 16px -5px rgba(31,72,128,.3); }
.page-title h1{ font-size:1.6rem; letter-spacing:-.03em; }
.user-avatar{ box-shadow:0 4px 12px -4px rgba(31,72,128,.35); }

/* --- Login estilo Apple --- */
.login-card{ max-width:420px; }
.login-header img{ max-width:190px; }
.login-footer{ border-radius:16px; }
.login-bg{
  background:
    radial-gradient(120% 120% at 15% 15%,rgba(232,136,56,.35),transparent 55%),
    radial-gradient(120% 120% at 85% 85%,rgba(59,162,79,.30),transparent 55%),
    linear-gradient(150deg,#1c3f73,var(--primary-dark));
}
.login-bg .features i{ color:#8fe3a0; }

/* --- Filtros y pasos ya redondeados; suavizar --- */
.filter-chip{ border-radius:980px; }
.step{ border-radius:12px; }

/* =====================================================
   RESPONSIVE GLOBAL — adaptación a móvil, tablet y laptop
   Bloque aditivo: refuerza el comportamiento en pantallas
   pequeñas sin alterar el diseño de escritorio.
   ===================================================== */

/* Nada debe desbordar horizontalmente la pantalla */
html, body { max-width: 100%; overflow-x: hidden; }
img, svg, video, canvas, iframe { max-width: 100%; height: auto; }

/* Tablet (≤1024px): el sidebar ya es off-canvas; holgura */
@media (max-width: 1024px) {
    .content-wrapper { padding: 1.25rem; }
    .page-title h1 { font-size: 1.35rem; }
}

/* Móvil grande / tablet vertical (≤768px) */
@media (max-width: 768px) {
    .page-header { margin-bottom: 1.25rem; }
    .page-title h1 { font-size: 1.2rem; }
    .page-title .icon { width: 42px; height: 42px; font-size: 1.15rem; }
    .page-actions { display: flex; flex-wrap: wrap; gap: .5rem; width: 100%; }
    .page-actions .btn { flex: 1 1 auto; justify-content: center; }
    .card-body { padding: 1.1rem; }
    /* Grupos de botones/acciones en fila -> se acomodan */
    .btn-group, .d-flex.gap-2, .d-flex.gap-3 { flex-wrap: wrap; }
    /* Modales cómodos en móvil */
    .modal-dialog { max-width: 94vw; margin: 1rem auto; }
    .dg-modal { max-width: 92vw; }
}

/* Móvil pequeño (≤576px) */
@media (max-width: 576px) {
    .content-wrapper { padding: .85rem; }
    .page-title h1 { font-size: 1.1rem; }
    .page-title { gap: .7rem; }
    .btn { padding: .55rem .9rem; }
    .card { border-radius: var(--radius); }
    /* Filtros/acciones en barras -> a ancho completo y apilados */
    form .d-flex.gap-2 > .form-control,
    form .d-flex.gap-2 > .form-select { width: 100%; }
    /* Tarjeta de usuario y textos del sidebar sin recortes */
    .user-details { min-width: 0; }
}

/* ===== Menú lateral colapsable por secciones (acordeón) ===== */
.nav-section-title {
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    user-select: none;
}
.nav-section-title .nav-chevron {
    font-size: .68rem;
    transition: transform .2s ease;
    opacity: .5;
    margin-left: auto;
}
.nav-section.collapsed .nav-section-title .nav-chevron { transform: rotate(-90deg); }
.nav-section.collapsed .nav-link { display: none !important; }

/* =====================================================
   MAYOR CONTRASTE — fondo tintado de marca + tarjetas nítidas
   (usa la paleta de la web; las tarjetas blancas ahora resaltan)
   ===================================================== */
:root { --page-bg: #e3eaf3; } /* gris azulado claro derivado del azul DistriGo */

html, body { background: var(--page-bg); }
.content-wrapper, main { background: var(--page-bg); }

/* Tarjetas: blancas, con borde y sombra de tinte azul para que "floten" */
.card {
    background: #ffffff;
    border: 1px solid #d3deec;
    box-shadow: 0 2px 12px rgba(31, 72, 128, .07), 0 1px 3px rgba(0, 0, 0, .04);
}
.card-header {
    background: #ffffff;
    border-bottom: 1px solid #eaeff6;
}

/* Barra superior y tablas con el mismo criterio de contraste */
.topbar { background: #ffffff; border-bottom: 1px solid #d3deec; }
.table-responsive { border: 1px solid #d3deec; background: #fff; }

/* =====================================================
   Aprovechar todo el ancho de la pantalla
   (el contenido ya no se limita a 1440px centrado)
   ===================================================== */
.content-wrapper { max-width: none; margin: 0; }

/* =====================================================
   El área de contenido también llena el ALTO de la pantalla
   (sin franja clara abajo cuando el contenido es corto)
   ===================================================== */
.main-content { background: var(--page-bg); display: flex; flex-direction: column; }
.content-wrapper { flex: 1 0 auto; }

/* =====================================================
   Ícono del título de página: azul sólido con ícono blanco
   (antes usaba un fondo claro que se confundía con el fondo
   tintado de la página y perdía contraste)
   ===================================================== */
.page-title .icon {
    background: var(--primary);
    color: #ffffff;
}

/* =====================================================
   Tarjetas de KPI más compactas y nítidas (estilo moderno,
   inspirado en el tablero de referencia): menos alto, borde
   izquierdo de color, etiquetas en mayúsculas y más por fila.
   Aplica a todas las páginas que usan .stat-card.
   ===================================================== */
.stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(185px, 1fr));
    gap: .7rem;
    margin-bottom: 1.25rem;
}
.stat-card {
    padding: .8rem .9rem;
    gap: .7rem;
    border-radius: 10px;
    border: 1px solid #d9e2ee;
    border-left: 3px solid var(--primary);
}
.stat-card::before { display: none; }         /* quita la barra superior; usamos borde izquierdo */
.stat-card.success { border-left-color: var(--success); }
.stat-card.warning { border-left-color: var(--warning); }
.stat-card.danger  { border-left-color: var(--danger); }
.stat-card.info    { border-left-color: var(--info); }
.stat-card.purple  { border-left-color: var(--purple); }
.stat-card:hover   { transform: none; box-shadow: var(--shadow); }
.stat-card .stat-icon {
    width: 34px; height: 34px;
    font-size: 1.05rem;
    border-radius: 8px;
}
.stat-value { font-size: 1.2rem; }
.stat-label {
    font-size: .66rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .3px;
    color: var(--gray-500);
    margin-top: 1px;
}
.stat-trend { font-size: .66rem; margin-top: .15rem; }

/* =====================================================
   PAQUETE BASE UI — moderno y nítido (aplica a todo el sistema)
   ===================================================== */

/* 1) Tipografía nítida + suavizado */
html, body { font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }

/* 2) Números tabulares: montos y cifras alineados en columna */
.table .text-end, .table .text-right, .table td.num, .stat-value,
.amount, .money, .table tfoot td { font-variant-numeric: tabular-nums; font-feature-settings: 'tnum' 1; }

/* 3) Tablas más compactas y legibles */
.table td { padding: .55rem 1rem; }
.table th { padding: .55rem 1rem; }
.table tbody tr:hover { background: var(--primary-50); }
.table tbody tr { border-left: 2px solid transparent; }
.table tbody tr:hover { border-left-color: var(--primary); }

/* 4) Estados como "pills" de color (badges redondeados y nítidos) */
.badge {
    border-radius: 999px;
    padding: .22rem .6rem;
    font-size: .68rem;
    font-weight: 600;
    letter-spacing: .02em;
    text-transform: uppercase;
}

/* 5) Feedback: spinner de botón + barra de progreso superior */
.dg-spinner {
    display: inline-block; width: .8em; height: .8em;
    border: 2px solid currentColor; border-right-color: transparent;
    border-radius: 50%; animation: dg-spin .6s linear infinite;
    vertical-align: -1px; margin-right: .35em;
}
@keyframes dg-spin { to { transform: rotate(360deg); } }
#dg-progress {
    position: fixed; top: 0; left: 0; height: 3px; width: 0;
    background: linear-gradient(90deg, var(--primary), var(--success));
    z-index: 9999; box-shadow: 0 0 8px rgba(31, 72, 128, .5);
    transition: width .3s ease, opacity .4s ease; opacity: 0;
}

/* 6) Micro-interacción: foco claro en inputs */
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(31, 72, 128, .12);
}

/* =====================================================
   PAQUETE UI (continuación): toasts, micro-interacciones, estados vacíos
   ===================================================== */

/* 7-A) Toasts (avisos que aparecen arriba a la derecha y se ocultan solos) */
.dg-toast-wrap { position: fixed; top: 72px; right: 18px; z-index: 9998; display: flex; flex-direction: column; gap: .6rem; max-width: 360px; }
.dg-toast {
    display: flex; align-items: flex-start; gap: .6rem;
    background: #fff; border: 1px solid #d9e2ee; border-left: 4px solid var(--primary);
    border-radius: 10px; padding: .7rem .85rem; font-size: .85rem; color: var(--gray-800);
    box-shadow: 0 8px 24px rgba(31, 72, 128, .16);
    animation: dg-toast-in .3s cubic-bezier(.2,.8,.2,1);
}
.dg-toast.oculto { animation: dg-toast-out .35s ease forwards; }
.dg-toast i { font-size: 1.05rem; line-height: 1.3; }
.dg-toast-success { border-left-color: var(--success); } .dg-toast-success i { color: var(--success); }
.dg-toast-danger  { border-left-color: var(--danger); }  .dg-toast-danger i  { color: var(--danger); }
.dg-toast-warning { border-left-color: var(--warning); } .dg-toast-warning i { color: var(--warning); }
.dg-toast-info    { border-left-color: var(--info); }    .dg-toast-info i    { color: var(--info); }
.dg-toast span { flex: 1; }
.dg-toast-x { background: none; border: 0; color: var(--gray-400); font-size: 1.1rem; line-height: 1; cursor: pointer; padding: 0 .1rem; }
.dg-toast-x:hover { color: var(--gray-700); }
@keyframes dg-toast-in  { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: none; } }
@keyframes dg-toast-out { to { opacity: 0; transform: translateX(40px); height: 0; padding-top: 0; padding-bottom: 0; margin: 0; } }

/* 7-B) Micro-interacciones sutiles (sin exagerar) */
.card { transition: box-shadow .2s ease, transform .2s ease; }
.btn { transition: background .15s ease, box-shadow .15s ease, transform .05s ease; }
.btn:active { transform: translateY(1px); }
.nav-link { transition: background .15s ease, color .15s ease; }

/* 8) Estados vacíos con más intención */
.empty-state { padding: 2.6rem 1rem; }
.empty-state i {
    font-size: 2rem; width: 68px; height: 68px; margin: 0 auto 1rem;
    display: flex; align-items: center; justify-content: center;
    background: var(--primary-50); color: var(--primary); border-radius: 50%; opacity: 1;
}
.empty-state p { color: var(--gray-600); font-size: .92rem; }
.empty-state .btn { margin-top: .9rem; }

/* =====================================================
   BUSCADOR RÁPIDO (command palette, Ctrl/⌘+K) — arriba a la izquierda
   ===================================================== */
.topbar-search {
    display: inline-flex; align-items: center; gap: .5rem;
    background: var(--gray-100); border: 1px solid var(--gray-200);
    border-radius: 10px; padding: .45rem .7rem; cursor: pointer;
    color: var(--gray-500); font-size: .85rem; min-width: 210px;
    transition: border-color .15s ease, background .15s ease;
}
.topbar-search:hover { border-color: var(--primary); background: #fff; }
.topbar-search i { font-size: .95rem; }
.topbar-search span { flex: 1; text-align: left; }
.topbar-search kbd {
    font-size: .68rem; background: #fff; border: 1px solid var(--gray-200);
    border-radius: 5px; padding: 1px 6px; color: var(--gray-500); font-family: inherit;
}
@media (max-width: 820px) { .topbar-search span, .topbar-search kbd { display: none; } .topbar-search { min-width: 0; } }

.dg-buscador { position: fixed; inset: 0; z-index: 10000; }
.dg-buscador[hidden] { display: none; }
.dg-buscador-bg { position: absolute; inset: 0; background: rgba(15, 25, 45, .45); }
.dg-buscador-panel {
    position: relative; max-width: 560px; margin: 10vh auto 0; background: #fff;
    border-radius: 14px; box-shadow: 0 20px 60px rgba(0, 0, 0, .3); overflow: hidden;
    animation: dg-buscador-in .18s ease;
}
@keyframes dg-buscador-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
.dg-buscador-top { display: flex; align-items: center; gap: .6rem; padding: .9rem 1rem; border-bottom: 1px solid var(--gray-150); }
.dg-buscador-top > i { color: var(--gray-400); font-size: 1.1rem; }
.dg-buscador-top input { flex: 1; border: 0; outline: 0; font-size: 1rem; color: var(--gray-900); background: transparent; }
.dg-buscador-top kbd { font-size: .7rem; background: var(--gray-100); border: 1px solid var(--gray-200); border-radius: 5px; padding: 2px 7px; color: var(--gray-500); font-family: inherit; }
.dg-buscador-lista { max-height: 56vh; overflow-y: auto; padding: .4rem; }
.dg-buscador-item { display: flex; align-items: center; gap: .7rem; padding: .55rem .7rem; border-radius: 8px; color: var(--gray-800); text-decoration: none; }
.dg-buscador-item .t { flex: 1; font-size: .9rem; }
.dg-buscador-item .s { font-size: .66rem; text-transform: uppercase; letter-spacing: .03em; color: var(--gray-400); }
.dg-buscador-item > i { color: var(--primary); width: 1.15rem; text-align: center; }
.dg-buscador-item.activo { background: var(--primary-50); }
.dg-buscador-vacio { padding: 1.5rem; text-align: center; color: var(--gray-400); font-size: .9rem; }

/* Buscador: encabezados de grupo (Acciones / Módulos / Registros) */
.dg-buscador-grupo {
    font-size: .64rem; text-transform: uppercase; letter-spacing: .06em;
    color: var(--gray-400); font-weight: 700;
    padding: .5rem .7rem .25rem;
}
.dg-buscador-item .s { margin-left: auto; }

/* =====================================================
   BUSCADOR estilo desplegable (input en la barra + resultados debajo,
   sin modal) — inspirado en CICOM
   ===================================================== */
.topbar-search {
    display: inline-flex; align-items: center; gap: .5rem;
    background: var(--gray-100); border: 1px solid var(--gray-200);
    border-radius: 10px; padding: .45rem .7rem; cursor: text;
    color: var(--gray-500); width: 340px; max-width: 42vw;
    transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
}
.topbar-search:focus-within { border-color: var(--primary); background: #fff; box-shadow: 0 0 0 3px rgba(31, 72, 128, .1); }
.topbar-search > i { font-size: .95rem; flex-shrink: 0; }
.topbar-search input { border: 0; outline: 0; background: transparent; font-size: .88rem; color: var(--gray-900); width: 100%; font-family: inherit; }
.topbar-search input::placeholder { color: var(--gray-400); }

.search-dropdown {
    position: absolute; top: calc(100% + 6px); left: 0; right: 0;
    background: #fff; border: 1px solid #d9e2ee; border-radius: 12px;
    box-shadow: 0 16px 40px rgba(31, 72, 128, .18);
    max-height: 62vh; overflow: auto; z-index: 300; display: none; padding: .35rem;
}
.search-dropdown.show { display: block; }
.search-grupo { font-size: .62rem; text-transform: uppercase; letter-spacing: .06em; color: var(--gray-400); font-weight: 700; padding: .5rem .6rem .25rem; }
.search-item { display: flex; align-items: center; gap: .7rem; padding: .5rem .6rem; border-radius: 8px; color: var(--gray-800); text-decoration: none; cursor: pointer; }
.search-item .t { flex: 1; font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-item .s { font-size: .66rem; color: var(--gray-400); text-transform: uppercase; letter-spacing: .02em; margin-left: auto; flex-shrink: 0; }
.search-item > i { color: var(--primary); width: 1.1rem; text-align: center; flex-shrink: 0; }
.search-item.activo, .search-item:hover { background: var(--primary-50); }
.search-vacio { padding: 1.1rem; text-align: center; color: var(--gray-400); font-size: .85rem; }
@media (max-width: 820px) { .topbar-search { width: auto; flex: 1; } }

/* =====================================================
   NORMALIZACIÓN DE TARJETAS (todas las páginas)
   - Igual alto y alineadas en la misma fila
   - Borde más suave y radio más contenido
   - Más compactas y menos separadas
   ===================================================== */

/* Igual alto: la columna estira la tarjeta para que todas midan lo mismo */
.row > .col,
.row > [class^="col-"],
.row > [class*=" col-"] { display: flex; flex-direction: column; }
.row > .col > .card,
.row > [class^="col-"] > .card,
.row > [class*=" col-"] > .card { flex: 1 1 auto; margin-bottom: 0; }

/* Borde suave, radio contenido, sombra sutil */
.card {
    border: 1px solid #e6edf5;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(31, 72, 128, .05), 0 6px 16px rgba(31, 72, 128, .05);
}
.card-header { border-radius: 12px 12px 0 0; }

/* Compactas y con menos separación entre ellas */
.row { margin: -.4rem; }
.col, [class^="col-"] { padding: .4rem; }
.card-body { padding: 1.05rem 1.15rem; }
.card-header { padding: .8rem 1.15rem; }
