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

/* ============================================================
   COFRADÍA PLATFORM – PREMIUM DESIGN SYSTEM v2.0
   ============================================================ */
:root {
    /* ── Brand Palette ── */
    --primary:      #1E2A4A;
    --primary-mid:  #2D3A6B;
    --primary-lite: #3D5088;
    --accent:       #D4A553;
    --accent-pale:  #F0D28B;
    --success:      #22C55E;
    --danger:       #EF4444;
    --warning:      #F59E0B;
    --info:         #3B82F6;

    /* ── Neutral Scale ── */
    --bg:           #F1F4F9;
    --surface:      #FFFFFF;
    --surface-2:    #F8FAFD;
    --border:       #E8EDF5;
    --text:         #111827;
    --text-muted:   #6B7280;
    --text-light:   #9CA3AF;

    /* ── Layout ── */
    --sidebar-w:    278px;
    --header-h:     76px;
    --radius:       14px;
    --radius-sm:    8px;
    --radius-lg:    20px;
    --shadow-sm:    0 1px 4px rgba(0,0,0,.06);
    --shadow:       0 4px 20px rgba(0,0,0,.07);
    --shadow-lg:    0 12px 40px rgba(0,0,0,.11);
    --speed:        0.3s;
}

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
    font-family: 'Outfit', sans-serif;
    background: var(--bg);
    color: var(--text);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,.18); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,.3); }

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
    width: var(--sidebar-w);
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    background: linear-gradient(170deg, var(--primary) 0%, var(--primary-mid) 60%, #22305A 100%);
    color: #fff;
    z-index: 1050;
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 28px rgba(0,0,0,.18);
    transition: transform var(--speed) cubic-bezier(.4,0,.2,1);
    overflow: hidden;
}

/* Decorative glow top-right */
.sidebar::before {
    content: '';
    position: absolute;
    top: -60px; right: -60px;
    width: 200px; height: 200px;
    background: radial-gradient(circle, rgba(212,165,83,.25) 0%, transparent 70%);
    pointer-events: none;
}

.sidebar-brand {
    padding: 28px 24px 22px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255,255,255,.07);
    flex-shrink: 0;
}

/* Brand logo styling */
.brand-logo-container {
    max-width: 100%;
    padding: 0 10px;
}
.sidebar-logo-img {
    max-height: 52px;
    max-width: 100%;
    object-fit: contain;
    transition: max-height var(--speed) cubic-bezier(.4,0,.2,1);
}

.sidebar-brand .brand-icon {
    width: 44px; height: 44px;
    background: linear-gradient(135deg, var(--accent), #B8882E);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
    box-shadow: 0 4px 14px rgba(212,165,83,.4);
}

.sidebar-brand .brand-text {
    font-size: 1.15rem;
    font-weight: 800;
    letter-spacing: .5px;
    color: #fff;
    line-height: 1.2;
}

.sidebar-brand .brand-sub {
    font-size: .68rem;
    font-weight: 500;
    color: rgba(255,255,255,.45);
    letter-spacing: 1.5px;
    text-transform: uppercase;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px 0 20px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,.1) transparent;
}

.sidebar-nav::-webkit-scrollbar { width: 3px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 10px; }

.nav-section-label {
    padding: 18px 24px 8px;
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: 1.8px;
    text-transform: uppercase;
    color: rgba(255,255,255,.3);
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 24px;
    color: rgba(255,255,255,.65);
    text-decoration: none;
    font-weight: 500;
    font-size: .9rem;
    position: relative;
    transition: color var(--speed), background var(--speed);
}

.sidebar-link i {
    font-size: 1.15rem;
    flex-shrink: 0;
    transition: transform var(--speed), color var(--speed);
    width: 20px;
    text-align: center;
}

.sidebar-link:hover {
    color: #fff;
    background: rgba(255,255,255,.06);
}

.sidebar-link:hover i {
    transform: translateX(2px);
    color: var(--accent);
}

.sidebar-link.active {
    color: #fff;
    background: rgba(255,255,255,.08);
    font-weight: 600;
}

.sidebar-link.active::before {
    content: '';
    position: absolute;
    left: 0; top: 0;
    height: 100%;
    width: 4px;
    background: linear-gradient(180deg, var(--accent), var(--accent-pale));
    border-radius: 0 4px 4px 0;
    box-shadow: 2px 0 12px rgba(212,165,83,.5);
}

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

/* ============================================================
   TOP HEADER
   ============================================================ */
.main-wrapper {
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left var(--speed);
}

.topbar {
    height: var(--header-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 36px;
    position: sticky;
    top: 0;
    z-index: 900;
    box-shadow: var(--shadow-sm);
}

.topbar-left { display: flex; align-items: center; gap: 16px; }

.sidebar-toggle-btn {
    width: 40px; height: 40px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.25rem;
    color: var(--text-muted);
    display: flex;
    transition: background var(--speed), color var(--speed);
}

.sidebar-toggle-btn:hover { background: var(--bg); color: var(--text); }

.breadcrumb-title {
    font-size: .85rem;
    font-weight: 600;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}

.breadcrumb-title .bc-sep { opacity: .4; }

.topbar-right { display: flex; align-items: center; gap: 12px; }

.topbar-date {
    font-size: .8rem;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--bg);
    padding: 6px 14px;
    border-radius: 20px;
    border: 1px solid var(--border);
}

.user-menu-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 14px 6px 6px;
    border: 1px solid var(--border);
    border-radius: 40px;
    background: var(--surface);
    cursor: pointer;
    text-decoration: none;
    color: var(--text);
    transition: border-color var(--speed), box-shadow var(--speed);
}

.user-menu-btn:hover {
    border-color: var(--primary-mid);
    box-shadow: var(--shadow-sm);
    color: var(--text);
}

.user-avatar {
    width: 36px; height: 36px;
    background: linear-gradient(135deg, var(--primary-mid), var(--primary));
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
    flex-shrink: 0;
}

.user-name { font-weight: 600; font-size: .88rem; }
.user-role { font-size: .72rem; color: var(--text-muted); }

/* ============================================================
   CONTENT AREA
   ============================================================ */
.page-content {
    padding: 36px 40px;
    flex-grow: 1;
}

.page-header {
    margin-bottom: 28px;
}

.page-title {
    font-size: 1.85rem;
    font-weight: 800;
    color: var(--text);
    line-height: 1.2;
    letter-spacing: -.3px;
}

.page-subtitle {
    font-size: 1rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ============================================================
   CARDS
   ============================================================ */
.card-premium {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    transition: transform var(--speed), box-shadow var(--speed);
    overflow: hidden;
}

.card-premium:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

.card-glass {
    background: rgba(255,255,255,.75);
    backdrop-filter: blur(16px);
    border: 1px solid rgba(255,255,255,.5);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

/* Stat Cards */
.stat-card {
    padding: 24px;
    position: relative;
    overflow: hidden;
}

.stat-card .stat-bg-icon {
    position: absolute;
    right: -8px;
    bottom: -8px;
    font-size: 5.5rem;
    opacity: .05;
    line-height: 1;
    pointer-events: none;
    color: var(--primary);
}

.stat-label {
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.stat-value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--text);
    line-height: 1;
    letter-spacing: -.5px;
}

.stat-trend {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: .78rem;
    font-weight: 600;
    padding: 3px 9px;
    border-radius: 20px;
    margin-top: 10px;
}

.stat-trend.up   { background: rgba(34,197,94,.1);  color: var(--success); }
.stat-trend.down { background: rgba(239,68,68,.1);  color: var(--danger); }
.stat-trend.flat { background: rgba(107,114,128,.1); color: var(--text-muted); }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn-primary-custom {
    background: linear-gradient(135deg, var(--primary-mid), var(--primary));
    color: #fff;
    border: none;
    padding: 11px 24px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: .9rem;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: filter var(--speed), transform var(--speed), box-shadow var(--speed);
    box-shadow: 0 4px 14px rgba(45,58,107,.3);
}

.btn-primary-custom:hover {
    filter: brightness(1.12);
    transform: translateY(-2px);
    box-shadow: 0 8px 22px rgba(45,58,107,.4);
    color: #fff;
}

.btn-accent {
    background: linear-gradient(135deg, var(--accent), #B8882E);
    color: #1a1a1a;
    border: none;
    padding: 11px 24px;
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: .9rem;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: filter var(--speed), transform var(--speed), box-shadow var(--speed);
    box-shadow: 0 4px 14px rgba(212,165,83,.35);
}

.btn-accent:hover {
    filter: brightness(1.08);
    transform: translateY(-2px);
    box-shadow: 0 8px 22px rgba(212,165,83,.5);
    color: #000;
}

/* Keep Bootstrap .btn-premium alias */
.btn-premium { composes: btn-accent; }

/* ============================================================
   TABLES
   ============================================================ */
.table-wrapper {
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.table-premium thead th {
    background: var(--surface-2);
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--text-muted);
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.table-premium tbody td {
    padding: 14px 18px;
    font-size: .88rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.table-premium tbody tr:last-child td { border-bottom: 0; }
.table-premium tbody tr { transition: background var(--speed); }
.table-premium tbody tr:hover { background: var(--surface-2); }

/* ============================================================
   BADGES
   ============================================================ */
.badge-premium {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: .75rem;
    font-weight: 700;
    letter-spacing: .3px;
}

.badge-success { background: rgba(34,197,94,.1);  color: #15803d; border: 1px solid rgba(34,197,94,.2); }
.badge-warning { background: rgba(245,158,11,.1); color: #b45309; border: 1px solid rgba(245,158,11,.2); }
.badge-danger  { background: rgba(239,68,68,.1);  color: #B91C1C; border: 1px solid rgba(239,68,68,.2); }
.badge-info    { background: rgba(59,130,246,.1); color: #1d4ed8; border: 1px solid rgba(59,130,246,.2); }
.badge-neutral { background: rgba(107,114,128,.1); color: #4b5563; border: 1px solid rgba(107,114,128,.2); }

/* ============================================================
   FORMS
   ============================================================ */
.form-control, .form-select {
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    border: 1.5px solid var(--border);
    font-weight: 500;
    font-size: .9rem;
    background: var(--surface);
    color: var(--text);
    transition: border-color var(--speed), box-shadow var(--speed);
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary-mid);
    box-shadow: 0 0 0 3px rgba(45,58,107,.12);
    outline: none;
}

.form-label {
    font-size: .82rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 6px;
    letter-spacing: .2px;
}

.input-group-text {
    background: var(--surface-2);
    border: 1.5px solid var(--border);
    color: var(--text-muted);
}

/* ============================================================
   ACTION BUTTON CARD (tesorería)
   ============================================================ */
.action-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-decoration: none;
    color: var(--text);
    background: var(--surface);
    transition: border-color var(--speed), background var(--speed), box-shadow var(--speed);
    margin-bottom: 10px;
}

.action-item:hover {
    border-color: var(--primary-mid);
    background: #f1f5ff;
    box-shadow: var(--shadow-sm);
    color: var(--text);
}

.action-item-icon {
    width: 44px; height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}

.action-item-title { font-weight: 600; font-size: .9rem; }
.action-item-desc  { font-size: .78rem; color: var(--text-muted); margin-top: 2px; }

/* ============================================================
   ALERTS / NOTIFICATIONS
   ============================================================ */
.alert-premium {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 16px 20px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-size: .9rem;
    font-weight: 500;
    border-left: 4px solid transparent;
}

.alert-premium.success { background: rgba(34,197,94,.08); border-color: var(--success); color: #166534; }
.alert-premium.error   { background: rgba(239,68,68,.08);  border-color: var(--danger);  color: #991b1b; }

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-body {
    background: linear-gradient(135deg, var(--primary) 0%, #0f172a 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

/* Animated background blobs */
.login-body::before {
    content: '';
    position: absolute;
    top: -200px; left: -200px;
    width: 600px; height: 600px;
    background: radial-gradient(circle, rgba(212,165,83,.2) 0%, transparent 65%);
    animation: blob-float 12s ease-in-out infinite alternate;
}

.login-body::after {
    content: '';
    position: absolute;
    bottom: -200px; right: -200px;
    width: 500px; height: 500px;
    background: radial-gradient(circle, rgba(61,80,136,.4) 0%, transparent 65%);
    animation: blob-float 16s ease-in-out infinite alternate-reverse;
}

@keyframes blob-float {
    from { transform: translate(0, 0) scale(1); }
    to   { transform: translate(40px, 30px) scale(1.1); }
}

.login-card {
    background: rgba(255,255,255,.07);
    backdrop-filter: blur(24px);
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 24px;
    padding: 48px 44px;
    width: 100%;
    max-width: 420px;
    position: relative;
    z-index: 2;
    box-shadow: 0 24px 60px rgba(0,0,0,.3);
    color: #fff;
    animation: login-appear .6s cubic-bezier(.22,1,.36,1);
}

@keyframes login-appear {
    from { opacity: 0; transform: translateY(30px) scale(.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.login-card .form-control {
    background: rgba(255,255,255,.08);
    border: 1.5px solid rgba(255,255,255,.15);
    color: #fff;
    border-radius: 10px;
}

.login-card .form-control::placeholder { color: rgba(255,255,255,.4); }
.login-card .form-control:focus { 
    background: rgba(255,255,255,.12);
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(212,165,83,.2);
}

.login-card .form-label { color: rgba(255,255,255,.8); }

/* ============================================================
   OVERLAY & RESPONSIVE
   ============================================================ */
.sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.45);
    backdrop-filter: blur(3px);
    z-index: 1040;
}

.sidebar-overlay.show { display: block; }

@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.show { transform: translateX(0); }
    .main-wrapper { margin-left: 0; }
    .sidebar-toggle-btn { display: flex; }
    .topbar { padding: 0 20px; }
    .page-content { padding: 24px 20px; }
}

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

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

@keyframes slideInLeft {
    from { opacity: 0; transform: translateX(-20px); }
    to   { opacity: 1; transform: translateX(0); }
}

.anim-fade-up  { animation: fadeInUp  .5s cubic-bezier(.22,1,.36,1) both; }
.anim-fade-in  { animation: fadeIn    .4s ease both; }
.anim-slide-in { animation: slideInLeft .5s cubic-bezier(.22,1,.36,1) both; }

.anim-delay-1 { animation-delay: .05s; }
.anim-delay-2 { animation-delay: .1s;  }
.anim-delay-3 { animation-delay: .15s; }
.anim-delay-4 { animation-delay: .2s;  }

/* Stagger helper */
.stagger-children > * {
    opacity: 0;
    animation: fadeInUp .5s cubic-bezier(.22,1,.36,1) both;
}
.stagger-children > *:nth-child(1) { animation-delay: .05s; }
.stagger-children > *:nth-child(2) { animation-delay: .1s;  }
.stagger-children > *:nth-child(3) { animation-delay: .15s; }
.stagger-children > *:nth-child(4) { animation-delay: .2s;  }
.stagger-children > *:nth-child(5) { animation-delay: .25s; }

/* ============================================================
   MISC UTILITIES
   ============================================================ */
.divider { height: 1px; background: var(--border); margin: 0; }
.text-accent { color: var(--accent); }
.bg-primary-gradient { background: linear-gradient(135deg, var(--primary-mid), var(--primary)); }

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}
.empty-state i { font-size: 3.5rem; opacity: .25; display: block; margin-bottom: 16px; }
.empty-state h5 { font-weight: 700; color: var(--text); }

/* ── Hover util ── */
.hover-lift { transition: transform var(--speed), box-shadow var(--speed); }
.hover-lift:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }

/* Bootstrap overrides */
.btn-premium {
    background: linear-gradient(135deg, var(--accent), #B8882E);
    color: #1a1a1a;
    border: none;
    padding: 11px 24px;
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: .9rem;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: filter var(--speed), transform var(--speed), box-shadow var(--speed);
    box-shadow: 0 4px 14px rgba(212,165,83,.35);
}

.btn-premium:hover {
    filter: brightness(1.08);
    transform: translateY(-2px);
    box-shadow: 0 8px 22px rgba(212,165,83,.5);
    color: #000;
}

.hover-primary:hover {
    background-color: var(--primary) !important;
    color: white !important;
}

/* DataTables overrides */
.datatable-wrapper .datatable-search input,
.datatable-wrapper .datatable-selector {
    border: 1.5px solid var(--border) !important;
    border-radius: var(--radius-sm) !important;
    padding: 8px 14px !important;
    font-family: 'Outfit', sans-serif !important;
    font-size: .85rem !important;
}

.datatable-wrapper .datatable-pagination-list-item-link {
    border-radius: var(--radius-sm) !important;
    font-weight: 600 !important;
}

.datatable-wrapper .datatable-pagination-list-item-link.datatable-active {
    background: var(--primary-mid) !important;
    color: #fff !important;
}

/* ============================================================
   LIST GROUP inside card
   ============================================================ */
.card-premium .list-group-item {
    background: transparent;
    border-bottom: 1px solid var(--border) !important;
    transition: background var(--speed);
}
.card-premium .list-group-item:hover { background: var(--surface-2); }
.card-premium .list-group-item:last-child { border-bottom: none !important; }

/* ============================================================
   PRESUPUESTOS / CONFIGURACION helpers
   ============================================================ */
.progress-custom {
    height: 8px;
    border-radius: 20px;
    background: var(--border);
}
.progress-custom .progress-fill {
    height: 100%;
    border-radius: 20px;
    background: linear-gradient(90deg, var(--primary-mid), var(--accent));
    transition: width .6s cubic-bezier(.4,0,.2,1);
}

/* ============================================================
   PORTAL (public) overrides
   ============================================================ */
.portal-nav {
    background: linear-gradient(135deg, var(--primary), var(--primary-mid));
    padding: 16px 40px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.portal-nav .brand { color: var(--accent); font-weight: 800; font-size: 1.1rem; }
.portal-nav a { color: rgba(255,255,255,.75); text-decoration: none; font-weight: 600; font-size:.88rem; }
.portal-nav a:hover { color: #fff; }

/* ============================================================
   PRINT STYLES
   ============================================================ */
@media print {
    .sidebar, .topbar, .sidebar-overlay { display: none !important; }
    .main-wrapper { margin-left: 0 !important; }
    .page-content { padding: 0 !important; }
    .card-premium { box-shadow: none !important; border: 1px solid #ddd !important; }
    .btn-primary-custom, .btn-accent, .btn-premium { display: none !important; }
}

/* ============================================================
   SCROLLBAR for main content area
   ============================================================ */
.main-wrapper { overflow-y: auto; }

/* ============================================================
   TOOLTIP-LIKE hover on stat trend
   ============================================================ */
.stat-card:hover .stat-trend { opacity: 1; }
.stat-trend { opacity: .85; transition: opacity var(--speed); }

/* ============================================================
   COLLAPSIBLE SIDEBAR (DESKTOP)
   ============================================================ */
@media (min-width: 992px) {
    /* Base transitions */
    .sidebar {
        transition: transform var(--speed) cubic-bezier(.4,0,.2,1), width var(--speed) cubic-bezier(.4,0,.2,1);
    }
    
    .main-wrapper {
        transition: margin-left var(--speed) cubic-bezier(.4,0,.2,1);
    }

    /* Redefine sidebar width variable when collapsed */
    body.sidebar-collapsed {
        --sidebar-w: 80px;
    }

    /* Brand Logo / fallback styling in collapsed state */
    body.sidebar-collapsed .sidebar-brand {
        padding: 20px 10px;
        justify-content: center;
    }

    body.sidebar-collapsed .sidebar-logo-img {
        max-height: 38px;
    }

    body.sidebar-collapsed .brand-icon {
        width: 38px;
        height: 38px;
        font-size: 1.1rem;
        margin: 0 auto;
    }

    body.sidebar-collapsed .brand-text-wrapper {
        display: none;
    }

    /* Navigation sections and links when collapsed */
    body.sidebar-collapsed .nav-section-label {
        opacity: 0;
        height: 0;
        padding: 0;
        margin: 0;
        overflow: hidden;
        transition: opacity 0.15s ease, height 0.15s ease;
    }

    body.sidebar-collapsed .sidebar-link {
        padding: 14px 0;
        justify-content: center;
        gap: 0;
    }

    body.sidebar-collapsed .sidebar-link span {
        display: none;
    }

    body.sidebar-collapsed .sidebar-link i {
        font-size: 1.35rem;
        transition: transform var(--speed) ease;
    }

    body.sidebar-collapsed .sidebar-link:hover i {
        transform: scale(1.15);
    }

    body.sidebar-collapsed .sidebar-link.active::before {
        width: 4px;
        height: 70%;
        top: 15%;
        border-radius: 0 4px 4px 0;
    }
}
/* ============================================================
   TOP NAVIGATION (replaces sidebar – added v3.0)
   ============================================================ */

/* Reset sidebar margin */
.main-wrapper { margin-left: 0 !important; }

/* ── Main Navbar ── */
.app-navbar {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-mid) 100%);
    border-bottom: 1px solid rgba(255,255,255,.08);
    box-shadow: 0 2px 20px rgba(0,0,0,.18);
    position: sticky;
    top: 0;
    z-index: 1050;
    padding: 0 24px;
    height: 62px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.app-navbar .navbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    flex-shrink: 0;
    padding: 0;
}

.navbar-brand-logo {
    max-height: 38px;
    max-width: 120px;
    object-fit: contain;
}

.navbar-brand-icon {
    width: 38px; height: 38px;
    background: linear-gradient(135deg, var(--accent), #B8882E);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem; color: #fff;
    box-shadow: 0 3px 10px rgba(212,165,83,.4);
    flex-shrink: 0;
}

.navbar-brand-text {
    font-size: .95rem;
    font-weight: 800;
    color: #fff;
    letter-spacing: .2px;
    line-height: 1.15;
    white-space: nowrap;
}

.navbar-brand-sub {
    font-size: .6rem;
    font-weight: 500;
    color: rgba(255,255,255,.45);
    letter-spacing: 1.5px;
    text-transform: uppercase;
    white-space: nowrap;
}

/* ── Nav menus ── */
.app-nav {
    display: flex;
    align-items: center;
    gap: 2px;
    flex: 1;
    justify-content: center;
}

.app-nav .nav-item { position: relative; }

.app-nav .nav-link-top {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    color: rgba(255,255,255,.72);
    font-size: .85rem;
    font-weight: 600;
    text-decoration: none;
    border-radius: 8px;
    transition: color var(--speed), background var(--speed);
    cursor: pointer;
    white-space: nowrap;
    border: none;
    background: none;
}

.app-nav .nav-link-top:hover,
.app-nav .nav-link-top.active,
.app-nav .nav-item:focus-within .nav-link-top {
    color: #fff;
    background: rgba(255,255,255,.1);
}

.app-nav .nav-link-top i { font-size: 1rem; }
.app-nav .nav-link-top .caret {
    font-size: .65rem;
    opacity: .6;
    margin-left: 2px;
    transition: transform var(--speed);
}

.app-nav .nav-item:hover .caret { transform: rotate(180deg); }

/* ── Dropdown ── */
.nav-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    min-width: 210px;
    padding: 6px;
    display: none;
    z-index: 2000;
    animation: fadeInUp .2s cubic-bezier(.22,1,.36,1);
}

.app-nav .nav-item:hover .nav-dropdown,
.app-nav .nav-item:focus-within .nav-dropdown { display: block; }

.nav-dropdown a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 14px;
    color: var(--text);
    text-decoration: none;
    font-size: .875rem;
    font-weight: 500;
    border-radius: 8px;
    transition: background var(--speed), color var(--speed);
}

.nav-dropdown a:hover { background: var(--surface-2); color: var(--primary); }
.nav-dropdown a.active { background: rgba(30,42,74,.07); color: var(--primary); font-weight: 600; }
.nav-dropdown a i { font-size: .95rem; color: var(--text-muted); width: 18px; text-align: center; }
.nav-dropdown a:hover i, .nav-dropdown a.active i { color: var(--accent); }

.nav-dropdown-divider {
    height: 1px;
    background: var(--border);
    margin: 4px 6px;
}

.nav-dropdown-section {
    padding: 8px 14px 4px;
    font-size: .65rem;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--text-muted);
}

/* ── Right zone ── */
.app-navbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    margin-left: auto;
}

/* Mobile hamburger */
.navbar-mobile-toggle {
    display: none;
    background: rgba(255,255,255,.1);
    border: 1px solid rgba(255,255,255,.15);
    border-radius: 8px;
    color: #fff;
    font-size: 1.3rem;
    padding: 6px 10px;
    cursor: pointer;
    margin-left: auto;
}

.navbar-mobile-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    height: calc(100vh - 62px);
    background: var(--primary);
    z-index: 1049;
    overflow-y: auto;
    padding: 8px 12px 40px;
}

.navbar-mobile-menu.show { display: block; }

.mobile-section-label {
    padding: 14px 8px 4px;
    font-size: .65rem;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: rgba(255,255,255,.35);
}

.mobile-nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 12px;
    color: rgba(255,255,255,.72);
    text-decoration: none;
    font-size: .9rem;
    font-weight: 500;
    border-radius: 8px;
    transition: background var(--speed), color var(--speed);
}

.mobile-nav-link:hover, .mobile-nav-link.active {
    background: rgba(255,255,255,.08);
    color: #fff;
}

.mobile-nav-link i { width: 20px; text-align: center; font-size: 1.05rem; }

/* ── Topbar (now only breadcrumb + user info strip) ── */
.topbar {
    height: 52px;
    padding: 0 28px;
}

/* Hide old sidebar toggle on desktop */
.sidebar-toggle-btn { display: none !important; }

/* ── Print update ── */
@media print {
    .app-navbar, .topbar { display: none !important; }
    .main-wrapper { margin-left: 0 !important; }
}

@media (max-width: 991.98px) {
    .app-nav { display: none; }
    .navbar-mobile-toggle { display: flex; align-items: center; }
    .topbar { padding: 0 16px; height: 48px; }
    .page-content { padding: 20px 16px; }
    .app-navbar { padding: 0 16px; }
}

/* Trumbowyg override to match design */
.trumbowyg-box, .trumbowyg-editor {
    border: 1.5px solid var(--border) !important;
    border-radius: var(--radius-sm) !important;
    font-family: 'Outfit', sans-serif !important;
    font-size: .9rem !important;
}
.trumbowyg-box { border-radius: var(--radius-sm) !important; overflow: hidden !important; }
.trumbowyg-button-pane { background: var(--surface-2) !important; border-bottom: 1px solid var(--border) !important; }
