/* Tables — Excel-style grid */
.table-responsive { width: 100%; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; border: 2px solid #bfbfbf; }
.table th, .table td { text-align: left; padding: .5rem .75rem; border: 1px solid #d0d0d0; }
.table thead th { font-weight: 700; color: var(--text-dark); background: var(--table-header-bg); position: sticky; top: 0; border-color: rgba(0,0,0,0.2); }
.table tbody tr:nth-child(odd)  { background: #ffffff; }
.table tbody tr:nth-child(even) { background: #f2f2f2; }
.table tbody tr:hover { background: #fff3cd !important; }
.table tfoot td, .table tfoot th { background: #e8e8e8; border-top: 2px solid #bfbfbf; font-weight: 700; }
.table .num { text-align: right; }

/* Stacked table for mobile */
@media (max-width: 640px) {
  .table.stacked thead { display: none; }
  .table.stacked tbody tr { display: block; border: 1px solid var(--border-color); border-radius: .5rem; margin-bottom: .75rem; background: var(--card-bg); }
  .table.stacked tbody td { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border-color); padding: .625rem .75rem; }
  .table.stacked tbody td:last-child { border-bottom: none; }
  .table.stacked tbody td::before { content: attr(data-label); font-weight: 700; color: var(--muted-strong); margin-right: 1rem; }
}

/* Modals */
.modal-backdrop { 
    position: fixed; 
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, .6); 
    backdrop-filter: blur(4px);
    display: none; 
    align-items: center;
    justify-content: center;
    padding: 1rem;
    overflow-y: auto;
    opacity: 0;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 9999;
}
.modal-backdrop.active { 
    display: flex; 
    opacity: 1;
}
.modal-card { 
    background: var(--card-bg); 
    border-radius: 1rem; 
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25); 
    width: 100%; 
    max-width: 520px; 
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
    transform: translateY(-2rem);
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), 
                opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    margin: auto;
    position: relative;
}
.modal-backdrop.active .modal-card {
    transform: translateY(0);
    opacity: 1;
}
.modal-header { 
    display: flex; 
    align-items: center; 
    justify-content: space-between; 
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}
.modal-header h4 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-dark);
}
.modal-actions { 
    display: flex; 
    align-items: center; 
    gap: .75rem; 
    justify-content: flex-end; 
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

/* Confirmation Modal */
.confirm-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
}
.confirm-modal-backdrop.active {
    opacity: 1;
    visibility: visible;
}
.confirm-modal {
    background: var(--card-bg);
    border-radius: 1rem;
    padding: 1.5rem;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    transform: scale(0.9);
    transition: transform 0.2s ease;
}
.confirm-modal-backdrop.active .confirm-modal {
    transform: scale(1);
}
.confirm-modal-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
}
.confirm-modal-icon.danger { background: #fee2e2; }
.confirm-modal-icon.danger i { color: #dc2626; font-size: 1.75rem; }
.confirm-modal-icon.warning { background: #fef3c7; }
.confirm-modal-icon.warning i { color: #d97706; font-size: 1.75rem; }
.confirm-modal-icon.success { background: #dcfce7; }
.confirm-modal-icon.success i { color: #16a34a; font-size: 1.75rem; }
.confirm-modal-icon.info { background: #d4edda; }
.confirm-modal-icon.info i { color: #2E7D52; font-size: 1.75rem; }
.confirm-modal h3 {
    text-align: center;
    margin: 0 0 0.5rem;
    color: var(--text-dark);
    font-size: 1.25rem;
}
.confirm-modal p {
    text-align: center;
    color: var(--muted);
    margin: 0 0 1.25rem;
    font-size: 0.9rem;
    line-height: 1.5;
}
.confirm-modal-details {
    background: var(--bg-secondary);
    border-radius: 0.5rem;
    padding: 0.75rem;
    margin-bottom: 1.25rem;
}
.confirm-modal-details div {
    display: flex;
    justify-content: space-between;
    font-size: 0.875rem;
}
.confirm-modal-details div + div { margin-top: 0.25rem; }
.confirm-modal-details span:first-child { color: var(--muted); }
.confirm-modal-details span:last-child { font-weight: 600; color: var(--text-dark); }
.confirm-modal-actions {
    display: flex;
    gap: 0.75rem;
}
.confirm-modal-actions button {
    flex: 1;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}
.confirm-modal-actions .btn-cancel {
    background: var(--bg-secondary);
    color: var(--text-dark);
}
.confirm-modal-actions .btn-cancel:hover { background: var(--border-color); }
.confirm-modal-actions .btn-confirm-danger {
    background: #dc2626;
    color: white;
}
.confirm-modal-actions .btn-confirm-danger:hover { background: #b91c1c; }
.confirm-modal-actions .btn-confirm-danger:disabled { background: #f87171; cursor: not-allowed; }
.confirm-modal-actions .btn-confirm-warning {
    background: #d97706;
    color: white;
}
.confirm-modal-actions .btn-confirm-warning:hover { background: #b45309; }
.confirm-modal-actions .btn-confirm-primary {
    background: var(--primary-color);
    color: white;
}
.confirm-modal-actions .btn-confirm-primary:hover { background: var(--primary-dark); }
.confirm-modal-actions .btn-confirm-success {
    background: #16a34a;
    color: white;
}
.confirm-modal-actions .btn-confirm-success:hover { background: #15803d; }

/* Toast Notifications */
.toast-notification {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: #166534;
    color: white;
    padding: 0.875rem 1.25rem;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 10000;
}
.toast-notification.show {
    transform: translateY(0);
    opacity: 1;
}
.toast-notification.error { background: #dc2626; }
.toast-notification.warning { background: #d97706; }
.toast-notification.info { background: #1a2744; }
/* Modern, accessible theme overrides for SMS */
:root {
  --primary-color: #1a2744; /* navy */
  --primary-dark: #0f1a33;
  --primary-light: #2d3f6e;
  --secondary-color: #c0152a; /* crimson */
  --secondary-dark: #a01020;
  --accent-color: #F5A623; /* gold */
  --danger-color: #ef4444; /* red */
  --danger-dark: #dc2626;
  --text-dark: #111827; /* darker for contrast */
  --text: #1f2937;
  --muted: #6b7280;
  --muted-strong: #4b5563;
  --bg: #f9fafb;
  --bg-secondary: #f1f5f9;
  --white: #ffffff;
  --card-bg: #ffffff;
  --sidebar-bg: #ffffff;
  --border-color: #e5e7eb;
  --input-bg: #ffffff;
  --table-header-bg: #f8fafc;
  --table-hover: #fafafa;
  --radius: 0.75rem;
  --radius-lg: 1rem;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 6px 16px rgba(17,24,39,.08);
  --shadow-lg: 0 12px 28px rgba(17,24,39,.12);
  --transition: all .25s ease;
}

/* Dark Mode Variables */
[data-theme="dark"] {
  --primary-color: #2d3f6e;
  --primary-dark: #1a2744;
  --primary-light: #3d5490;
  --secondary-color: #c0152a;
  --secondary-dark: #a01020;
  --text-dark: #f1f5f9;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --muted-strong: #cbd5e1;
  --bg: #0f172a;
  --bg-secondary: #1e293b;
  --white: #1e293b;
  --card-bg: #1e293b;
  --sidebar-bg: #1e293b;
  --border-color: #334155;
  --input-bg: #0f172a;
  --table-header-bg: #1e293b;
  --table-hover: #334155;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.3);
  --shadow-md: 0 6px 16px rgba(0,0,0,.4);
  --shadow-lg: 0 12px 28px rgba(0,0,0,.5);
}

/* Typography utilities */
.text-muted { color: var(--muted); }
.text-gradient { background: linear-gradient(135deg, #2d3f6e 0%, #1a2744 50%, #c0152a 100%); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.text-primary { color: var(--primary-color); }
.text-secondary { color: var(--secondary-color); }
.text-accent { color: var(--accent-color); }
.heading-xl, .heading-lg, .heading-md, .heading-sm { color: var(--text-dark); }

/* Layout helpers */
.container { max-width: 1280px; margin: 0 auto; padding: 0 1rem; }
.section { padding: 3.5rem 0; }
.flex { display: flex; }
.flex-between { justify-content: space-between; }
.flex-center { justify-content: center; align-items: center; }
.gap-2 { gap: .5rem; }
.gap-3 { gap: .75rem; }
.gap-4 { gap: 1rem; }
.grid { display: grid; gap: 1.25rem; }
.grid-2 { grid-template-columns: repeat(1,minmax(0,1fr)); }
.grid-3 { grid-template-columns: repeat(1,minmax(0,1fr)); }
.grid-4 { grid-template-columns: repeat(1,minmax(0,1fr)); }
.grid-5 { grid-template-columns: repeat(1,minmax(0,1fr)); }
.grid-6 { grid-template-columns: repeat(1,minmax(0,1fr)); }
@media (min-width: 640px) {
  .grid-2 { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .grid-3 { grid-template-columns: repeat(3,minmax(0,1fr)); }
  .grid-4 { grid-template-columns: repeat(4,minmax(0,1fr)); }
  .grid-5 { grid-template-columns: repeat(5,minmax(0,1fr)); }
  .grid-6 { grid-template-columns: repeat(6,minmax(0,1fr)); }
}

/* Buttons - Standard sizes */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .375rem; padding: .5rem .875rem; border-radius: .5rem; border: 1px solid transparent; font-weight: 600; font-size: .875rem; cursor: pointer; transition: var(--transition); text-decoration: none; }
.btn-sm { padding: .375rem .625rem; font-size: .8125rem; }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(192,21,42,.25); }
.btn-primary { background: var(--primary-color); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--primary-dark); box-shadow: var(--shadow-md); }
.btn-secondary { background: var(--secondary-color); color: #fff; }
.btn-secondary:hover { background: var(--secondary-dark); }
.btn-outline { background: transparent; color: var(--primary-color); border-color: var(--border-color); }
.btn-outline:hover { background: var(--primary-color); color: #fff; border-color: var(--primary-color); }
.btn-lg { padding: .75rem 1.25rem; font-size: 1rem; }
.btn-white { background: var(--card-bg); color: var(--text-dark); border-color: var(--border-color); }
.btn-white:hover { background: var(--bg-secondary); }
.btn-ghost-white { background: transparent; color: #fff; border-color: rgba(255,255,255,.9); }
.btn-ghost-white:hover { background: rgba(255,255,255,.1); color: #fff; }
.btn-danger { background: var(--danger-color); color: #fff; border-color: var(--danger-color); }
.btn-danger:hover { background: var(--danger-dark); border-color: var(--danger-dark); }

/* Cards */
.card { background: var(--card-bg); border: 1px solid var(--border-color); border-radius: var(--radius-lg); padding: 1.5rem; box-shadow: var(--shadow-sm); transition: var(--transition); }
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.card-icon { width: 3rem; height: 3rem; border-radius: .75rem; display: inline-flex; align-items: center; justify-content: center; margin-bottom: .75rem; box-shadow: inset 0 0 0 2px rgba(0,0,0,.03); }
.card-icon.primary { background: rgba(46,125,82,.1); color: var(--primary-color); }
.card-icon.secondary { background: rgba(16,185,129,.12); color: var(--secondary-color); }
.card-icon.accent { background: rgba(245,158,11,.14); color: var(--accent-color); }
.stat-card { background: var(--card-bg); border: 1px dashed var(--border-color); border-radius: var(--radius); padding: 1.25rem; text-align: center; box-shadow: var(--shadow-sm); }
.stat-number { font-weight: 800; font-size: 1.5rem; color: var(--text-dark); }
.stat-label { color: var(--muted); font-size: .9rem; }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: .375rem; padding: .25rem .5rem; border-radius: .375rem; font-weight: 700; font-size: .85rem; border: 1px solid var(--border-color); background: var(--card-bg); color: var(--text-dark); }
.badge-secondary { background: rgba(16,185,129,.1); color: var(--secondary-color); border-color: rgba(16,185,129,.25); }

/* Auth */
.auth-card { border-radius: 1rem; box-shadow: var(--shadow-lg) !important; }
.auth-card .btn { width: 100%; }
.form-group { margin-bottom: 1rem; }
.form-label { display: block; color: var(--text-dark); font-weight: 600; font-size: 0.875rem; margin-bottom: 0.375rem; }
.form-input, .form-control { width: 100%; padding: .625rem .875rem; border: 1px solid var(--border-color); border-radius: .5rem; transition: var(--transition); background: var(--input-bg); color: var(--text-dark); font-size: 0.875rem; }
.form-input::placeholder, .form-control::placeholder { color: var(--muted); }
.form-input:focus, .form-control:focus { border-color: var(--primary-color); box-shadow: 0 0 0 3px rgba(26,39,68,.12); outline: none; }
select.form-control { cursor: pointer; appearance: none; background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e"); background-position: right 0.5rem center; background-repeat: no-repeat; background-size: 1.5em 1.5em; padding-right: 2.5rem; }
.form-checkbox input { accent-color: var(--primary-color); }

/* Navigation */
.app-nav { position: sticky; top: 0; z-index: 50; backdrop-filter: blur(8px); background: rgba(255,255,255,.85) !important; border-bottom: 1px solid var(--border-color) !important; }
[data-theme="dark"] .app-nav { background: rgba(30,41,59,.85) !important; }
.app-nav .btn.btn-outline { padding: .5rem 1rem; }

/* Hero */
.hero { position: relative; min-height: 92vh; display: grid; place-items: center; padding: 5rem 0 4rem; color: #fff; background-image: linear-gradient(135deg, #2E7D52 0%, #1B5E3B 35%, #4CAF78 70%, #F5A623 100%), radial-gradient(80rem 80rem at 20% 10%, rgba(255,255,255,.08), transparent 60%); background-size: 200% 200%, auto; background-position: 0% 50%, center; animation: heroGradient 18s ease infinite; }
.hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,0,0,.15), rgba(0,0,0,.3)); pointer-events: none; }
.hero .container { position: relative; z-index: 1; }
.hero-title { color: #fff; text-shadow: 0 1px 1px rgba(0,0,0,.25); }
.hero-lead { color: rgba(255,255,255,.95); font-size: 1.15rem; line-height: 1.8; max-width: 720px; margin: 0 auto; }
.hero .badge { display: inline-flex; align-items: center; gap: .5rem; padding: .375rem .75rem; border-radius: 999px; background: rgba(255,255,255,.92); color: #0f172a; border: 1px solid rgba(0,0,0,.04); font-weight: 700; letter-spacing: .02em; }

/* Subtle floating shapes */
.floating-shapes { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.floating-shapes .shape { position: absolute; border-radius: 50%; opacity: .26; background: radial-gradient(circle at 30% 30%, rgba(255,255,255,.35), rgba(255,255,255,.08) 60%, transparent 70%); animation: float 14s ease-in-out infinite; }
.shape-1 { width: 340px; height: 340px; top: 8%; left: 6%; }
.shape-2 { width: 180px; height: 180px; bottom: 18%; left: 15%; animation-delay: 1.5s; }
.shape-3 { width: 260px; height: 260px; right: 8%; bottom: 10%; animation-delay: 3s; }
@keyframes float { 0%, 100% { transform: translateY(0) } 50% { transform: translateY(-12px) } }
@keyframes heroGradient { 0% { background-position: 0% 50%, center; } 50% { background-position: 100% 50%, center; } 100% { background-position: 0% 50%, center; } }

/* Glowing CTA */
.btn-glow { box-shadow: 0 12px 28px rgba(192,21,42,.35); }
.btn-glow:hover { box-shadow: 0 18px 36px rgba(192,21,42,.45); }

/* Admin shell with sidebar */
.admin-shell { display: flex; height: 100vh; background: var(--bg); overflow: hidden; }
.sidebar { 
    width: 240px; 
    background: #1a2744;
    position: sticky; 
    top: 0; 
    height: 100vh; 
    padding: 0;
    display: flex; 
    flex-direction: column; 
    gap: 0;
    box-shadow: 4px 0 24px rgba(0,0,0,0.18);
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

/* Custom scrollbar for webkit browsers */
.sidebar::-webkit-scrollbar {
    width: 4px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background-color: rgba(255, 255, 255, 0.3);
}

/* Brand / Logo area */
.sidebar .brand { 
    display: flex; 
    align-items: center; 
    gap: 0.75rem; 
    font-weight: 800; 
    color: #ffffff; 
    padding: 1.25rem 1.25rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    margin-bottom: 0;
    text-decoration: none;
}
.sidebar .brand i { color: #ffffff; font-size: 1.5rem; }
.sidebar .brand span { color: #ffffff !important; font-size: 0.95rem; letter-spacing: -0.01em; }

/* Nav container */
.side-nav { 
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    padding: 0.75rem 0.75rem 0;
    flex: 1;
}

/* SVG icon sizing */
.side-nav a > svg,
.side-nav button > svg,
.nav-dropdown-toggle > svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    stroke-width: 2;
}

/* Icon pill background */
.side-nav a > svg:first-child,
.nav-dropdown-toggle > svg:first-child {
    background: rgba(255,255,255,0.08);
    border-radius: 6px;
    padding: 4px;
    transition: all 0.2s ease;
    box-sizing: content-box;
}

.side-nav a:hover > svg:first-child,
.nav-dropdown-toggle:hover > svg:first-child {
    background: rgba(255,255,255,0.15);
}

.side-nav a.active > svg:first-child,
.nav-dropdown-toggle.active > svg:first-child {
    background: rgba(192,21,42,0.85);
    box-shadow: 0 2px 8px rgba(192,21,42,0.4);
}

/* Nav links */
.side-nav a { 
    display: flex; 
    align-items: center; 
    gap: 0.65rem; 
    padding: 0.5rem 0.75rem; 
    color: rgba(255,255,255,0.65); 
    text-decoration: none; 
    border-radius: 8px; 
    border: 1px solid transparent; 
    transition: all 0.18s ease; 
    font-size: 0.825rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.side-nav a:hover { 
    background: rgba(255,255,255,0.07); 
    color: #ffffff;
}
.side-nav a.active { 
    background: rgba(255,255,255,0.1); 
    color: #ffffff; 
    border-color: rgba(255,255,255,0.1);
    font-weight: 600;
}
.side-nav a i {
    width: 18px;
    text-align: center;
    font-size: 0.8rem;
}

/* Dark mode */
[data-theme="dark"] .sidebar { background: #111827; }
[data-theme="dark"] .side-nav a.active { background: rgba(255,255,255,0.1); }

/* Dark mode sidebar buttons */
[data-theme="dark"] .sidebar .btn-primary {
    background: #c0152a;
    color: #ffffff;
    border: 2px solid #c0152a;
}
[data-theme="dark"] .sidebar .btn-primary:hover {
    background: #a01020;
    color: #ffffff;
    border-color: #a01020;
}
[data-theme="dark"] .sidebar .btn-primary i,
[data-theme="dark"] .sidebar .btn-primary span {
    color: #ffffff;
    opacity: 1;
}

/* Nav Dropdown */
.nav-dropdown { position: relative; }
.nav-dropdown-toggle { 
    display: flex; 
    align-items: center; 
    gap: 0.65rem; 
    padding: 0.5rem 0.75rem; 
    color: rgba(255,255,255,0.65); 
    background: none; 
    border: 1px solid transparent; 
    border-radius: 8px; 
    cursor: pointer; 
    width: 100%; 
    text-align: left; 
    font-size: 0.825rem; 
    font-weight: 500; 
    transition: all 0.18s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.nav-dropdown-toggle:hover { background: rgba(255,255,255,0.07); color: #ffffff; }
.nav-dropdown-toggle.active { background: rgba(255,255,255,0.1); color: #ffffff; border-color: rgba(255,255,255,0.1); font-weight: 600; }
.nav-dropdown-toggle .dropdown-arrow { margin-left: auto; font-size: 0.6rem; transition: transform 0.2s; opacity: 0.5; flex-shrink: 0; }
.nav-dropdown.open .dropdown-arrow { transform: rotate(180deg); }

/* Dropdown submenu */
.nav-dropdown-menu { 
    display: none; 
    padding-left: 0.5rem;
    margin-top: 0.125rem;
    border-left: 2px solid rgba(255,255,255,0.08);
    margin-left: 1.5rem;
}
.nav-dropdown.open .nav-dropdown-menu { display: flex; flex-direction: column; gap: 0.1rem; }
.nav-dropdown-menu a { 
    padding: 0.4rem 0.65rem; 
    font-size: 0.8rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border-radius: 6px;
    color: rgba(255,255,255,0.55);
}
.nav-dropdown-menu a:hover { color: #ffffff; background: rgba(255,255,255,0.07); }
.nav-dropdown-menu a.active { color: #ffffff; background: rgba(255,255,255,0.1); font-weight: 600; }
.nav-dropdown-menu a i { width: 1rem; font-size: 0.75rem; }

/* Nav Badge */
.nav-badge {
    background: #c0152a;
    color: white;
    font-size: 0.6rem;
    font-weight: 700;
    padding: 0.1rem 0.35rem;
    border-radius: 9999px;
    margin-left: auto;
    min-width: 1.1rem;
    text-align: center;
    flex-shrink: 0;
}

.sidebar .spacer { flex: 1; }

/* Bottom area */
.sidebar-bottom {
    padding: 0.75rem;
    border-top: 1px solid rgba(255,255,255,0.08);
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

/* Theme toggle */
.sidebar .theme-toggle {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.7);
    border-radius: 8px;
    font-size: 0.825rem;
    padding: 0.5rem 0.75rem;
    width: 100%;
    text-align: left;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    transition: all 0.18s ease;
}
.sidebar .theme-toggle:hover {
    background: rgba(255,255,255,0.1);
    color: #ffffff;
    border-color: rgba(255,255,255,0.2);
}
.sidebar .theme-toggle.active {
    background: rgba(255,255,255,0.12);
    border-color: rgba(255,255,255,0.2);
    color: #ffffff;
}

/* Tutorial / bottom dropdowns */
.sidebar .nav-dropdown {
    margin-top: 0;
}
.sidebar .nav-dropdown .nav-dropdown-toggle {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.7);
}
.sidebar .nav-dropdown .nav-dropdown-toggle:hover {
    background: rgba(255,255,255,0.1);
    color: #ffffff;
}
.sidebar .nav-dropdown .nav-dropdown-toggle.active {
    background: rgba(255,255,255,0.12);
    color: #ffffff;
}
.sidebar .nav-dropdown .nav-dropdown-menu a {
    color: rgba(255,255,255,0.6);
}
.sidebar .nav-dropdown .nav-dropdown-menu a:hover {
    background: rgba(255,255,255,0.07);
    color: #ffffff;
}
.sidebar .nav-dropdown .nav-dropdown-menu a.active {
    background: rgba(255,255,255,0.1);
    color: #ffffff;
    font-weight: 600;
}

/* Logout button */
.sidebar .btn-primary {
    background: #c0152a;
    color: #ffffff;
    border: none;
    font-weight: 600;
    border-radius: 8px;
    padding: 0.55rem 0.75rem;
    font-size: 0.825rem;
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    cursor: pointer;
    transition: all 0.18s ease;
    box-shadow: 0 2px 8px rgba(192,21,42,0.3);
}
.sidebar .btn-primary:hover {
    background: #a01020;
    box-shadow: 0 4px 12px rgba(192,21,42,0.4);
}
}
.sidebar .btn-primary i,
.sidebar .btn-primary span {
    color: #ffffff;
    opacity: 1;
}
.admin-content { flex: 1; min-width: 0; background: var(--bg); overflow-x: hidden; overflow-y: hidden; height: 100vh; display: flex; flex-direction: column; }
.admin-content main { background: var(--bg); min-height: 0; flex: 1; overflow-y: auto; overflow-x: hidden; }
.admin-topbar { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    padding: 0 1.5rem; 
    height: 56px;
    background: #ffffff;
    border-bottom: 1px solid #f0f0f0;
    box-shadow: 0 1px 8px rgba(0,0,0,0.06);
    position: sticky;
    top: 0;
    z-index: 50; 
    overflow: visible;
    flex-wrap: nowrap;
    gap: 0.75rem;
    max-width: 100%;
    box-sizing: border-box;
    flex-shrink: 0;
}
[data-theme="dark"] .admin-topbar {
    background: #1e2535;
    border-bottom-color: rgba(255,255,255,0.07);
    box-shadow: 0 1px 8px rgba(0,0,0,0.2);
}
.admin-topbar > div {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: nowrap;
}
.topbar-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
    min-width: 0;
}
.topbar-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: nowrap;
    flex-shrink: 0;
}

/* Topbar page title */
.topbar-left h1,
.topbar-left .page-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: #1a2744;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
[data-theme="dark"] .topbar-left h1,
[data-theme="dark"] .topbar-left .page-title { color: #f1f5f9; }

/* Topbar action buttons — override btn styles inside topbar */
.topbar-right .btn,
.topbar-right a.btn {
    height: 34px;
    padding: 0 0.85rem;
    font-size: 0.78rem;
    font-weight: 500;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    white-space: nowrap;
    transition: all 0.15s ease;
    border: 1px solid transparent;
    text-decoration: none;
    cursor: pointer;
}
.topbar-right .btn-primary,
.topbar-right a.btn-primary {
    background: #c0152a;
    color: #ffffff;
    border-color: #c0152a;
    box-shadow: 0 1px 4px rgba(192,21,42,0.25);
}
.topbar-right .btn-primary:hover,
.topbar-right a.btn-primary:hover {
    background: #a01020;
    border-color: #a01020;
    box-shadow: 0 2px 8px rgba(192,21,42,0.35);
}
.topbar-right .btn-outline,
.topbar-right a.btn-outline {
    background: transparent;
    color: #374151;
    border-color: #e5e7eb;
}
.topbar-right .btn-outline:hover,
.topbar-right a.btn-outline:hover {
    background: #f9fafb;
    border-color: #d1d5db;
    color: #1a2744;
}
[data-theme="dark"] .topbar-right .btn-outline,
[data-theme="dark"] .topbar-right a.btn-outline {
    color: #cbd5e1;
    border-color: rgba(255,255,255,0.12);
    background: rgba(255,255,255,0.05);
}
[data-theme="dark"] .topbar-right .btn-outline:hover,
[data-theme="dark"] .topbar-right a.btn-outline:hover {
    background: rgba(255,255,255,0.1);
    border-color: rgba(255,255,255,0.2);
    color: #ffffff;
}
.topbar-right .btn-sm,
.topbar-right a.btn-sm {
    height: 32px;
    padding: 0 0.75rem;
    font-size: 0.75rem;
}

/* Topbar divider */
.topbar-divider {
    width: 1px;
    height: 20px;
    background: #e5e7eb;
    flex-shrink: 0;
}
[data-theme="dark"] .topbar-divider { background: rgba(255,255,255,0.1); }

/* Topbar user avatar area */
.topbar-user {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: #374151;
    padding: 0.25rem 0.5rem;
    border-radius: 8px;
    transition: background 0.15s;
    font-size: 0.825rem;
    font-weight: 500;
}
.topbar-user:hover { background: #f3f4f6; }
[data-theme="dark"] .topbar-user { color: #cbd5e1; }
[data-theme="dark"] .topbar-user:hover { background: rgba(255,255,255,0.07); }
.topbar-user img {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #e5e7eb;
}
[data-theme="dark"] .topbar-user img { border-color: rgba(255,255,255,0.15); }
.topbar-user-avatar-placeholder {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #1a2744;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.75rem;
    font-weight: 700;
    flex-shrink: 0;
}
.admin-header { background: var(--card-bg); border-bottom: 1px solid var(--border-color); box-shadow: var(--shadow-sm); }
.admin-container { max-width: none; width: 100%; margin: 0; padding: 1.25rem; }

/* Footer */
footer a { color: rgba(255,255,255,.85); }
footer a:hover { color: #fff; }

/* Animations (lightweight) */
.fade-in-up { animation: fadeInUp .5s ease-out both; }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.scroll-reveal { transform: translateY(8px); opacity: 0; animation: reveal .6s ease-out .1s forwards; }
@keyframes reveal { to { transform: none; opacity: 1; } }

/* Accessibility tweaks */
:focus-visible { outline: 3px solid rgba(26,39,68,.45); outline-offset: 2px; }

/* Small helpers */
.mb-2 { margin-bottom: .5rem; }
.mb-3 { margin-bottom: .75rem; }
.mb-4 { margin-bottom: 1rem; }
.mt-2 { margin-top: .5rem; }
.hidden { display: none; }
.sm\:flex { display: none; }
@media (min-width: 640px) { .sm\:flex { display: flex; } }

/* Toasts */
.toast-container { position: fixed; right: 1rem; bottom: 1rem; z-index: 70; display: grid; gap: .5rem; }
.toast { display: flex; align-items: center; gap: .5rem; padding: .75rem 1rem; border-radius: .5rem; border: 1px solid var(--border-color); box-shadow: var(--shadow-md); background: var(--card-bg); color: var(--text-dark); }
.toast.toast-success { border-color: rgba(16,185,129,.25); background: rgba(16,185,129,.08); color: var(--secondary-color); }
.toast.toast-error { border-color: rgba(239,68,68,.25); background: rgba(239,68,68,.08); color: var(--danger-color); }
.toast .close { background: transparent; border: none; color: inherit; cursor: pointer; }

/* Dark Mode Toggle */
.theme-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    cursor: pointer;
    color: var(--text);
    font-size: 0.875rem;
    font-weight: 500;
    transition: var(--transition);
    width: 100%;
    justify-content: center;
}
.theme-toggle:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}
.theme-toggle i {
    font-size: 1rem;
}


/* ============================================
   MOBILE RESPONSIVE STYLES
   ============================================ */

/* Mobile Header - Hidden on desktop */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: linear-gradient(135deg, #2E7D52 0%, #1B5E3B 100%);
    border-bottom: none;
    padding: 0 1rem;
    align-items: center;
    justify-content: space-between;
    z-index: 100;
    box-shadow: 0 2px 10px rgba(46, 125, 82, 0.3);
}

.mobile-header .menu-toggle {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #ffffff;
    cursor: pointer;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    transition: background-color 0.2s ease;
}

.mobile-header .menu-toggle:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.mobile-header .menu-toggle:focus {
    outline: 2px solid rgba(255, 255, 255, 0.8);
    outline-offset: 2px;
}

.mobile-header .menu-toggle svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    fill: none;
}

.mobile-header .hamburger-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    color: #ffffff;
}

.mobile-header .hamburger-icon svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    fill: none;
    display: block;
}

/* Fallback for when SVG doesn't load */
.mobile-header .menu-toggle svg:not([viewBox]) + .hamburger-fallback,
.mobile-header .menu-toggle:not(:has(svg)) .hamburger-fallback {
    display: inline-block !important;
}

.mobile-header .mobile-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    color: #ffffff;
}

.mobile-header .mobile-brand i {
    color: #ffffff;
    font-size: 1.25rem;
}

.mobile-header .mobile-brand span {
    color: #ffffff !important;
}

.mobile-header .mobile-profile {
    font-size: 1.5rem;
    color: #ffffff;
    text-decoration: none;
}

/* Sidebar Overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 110;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    /* Show mobile header */
    .mobile-header {
        display: flex;
    }

    /* Hide sidebar by default, show as overlay */
    .sidebar {
        position: fixed;
        left: -240px;
        top: 0;
        height: 100vh;
        z-index: 120;
        transition: left 0.3s ease;
        box-shadow: var(--shadow-lg);
        overflow-y: auto;
        overflow-x: hidden;
        scrollbar-width: thin;
        scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
    }

    .sidebar.open {
        left: 0;
    }

    /* Adjust content area */
    .admin-shell {
        flex-direction: column;
        height: 100vh;
        overflow: hidden;
    }

    .admin-content {
        padding-top: 60px;
        width: 100%;
        height: calc(100vh - 60px);
        overflow-y: auto;
    }
    
    /* Topbar responsive */
    .admin-topbar {
        padding: 0 1rem;
        height: 52px;
        gap: 0.4rem;
    }
    
    .topbar-left,
    .topbar-right {
        gap: 0.4rem;
    }
    
    .topbar-right {
        flex-shrink: 0;
    }

    /* Prevent body scroll when sidebar open */
    body.sidebar-open {
        overflow: hidden;
    }

    /* Cards */
    .card {
        padding: 1rem;
    }

    /* Buttons */
    .btn {
        padding: 0.75rem 1rem;
        font-size: 0.875rem;
    }

    .btn-lg {
        padding: 0.875rem 1.25rem;
    }

    /* Forms */
    .form-input {
        padding: 0.75rem;
        font-size: 16px; /* Prevents zoom on iOS */
    }

    /* Tables */
    .table th, .table td {
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
    }

    /* Grids */
    .grid-2, .grid-3, .grid-4, .grid-5, .grid-6 {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    /* Stats */
    .stat-number {
        font-size: 1.25rem;
    }

    /* Headings */
    .heading-xl { font-size: 2rem; }
    .heading-lg { font-size: 1.5rem; }
    .heading-md { font-size: 1.25rem; }
    .heading-sm { font-size: 1rem; }

    /* Dashboard page header */
    .admin-header {
        padding: 0.75rem;
    }

    .admin-container {
        padding: 0.75rem;
    }

    /* Modal adjustments */
    .modal-backdrop {
        padding: 0.5rem;
    }
    .modal-card {
        margin: 0.5rem;
        max-height: calc(100vh - 1rem);
        max-width: calc(100% - 1rem);
    }

    /* Toast positioning */
    .toast-container {
        left: 1rem;
        right: 1rem;
        bottom: 1rem;
    }

    .toast {
        font-size: 0.875rem;
    }

    /* Flex wrap on mobile */
    .flex {
        flex-wrap: wrap;
    }

    /* Hide text on small buttons */
    .btn-sm span {
        display: none;
    }

    .btn-sm {
        padding: 0.5rem;
    }
}

/* Extra small devices */
@media (max-width: 480px) {
    .mobile-header .mobile-brand span {
        display: none;
    }

    .card {
        padding: 0.875rem;
        border-radius: 0.75rem;
    }

    .btn {
        padding: 0.625rem 0.875rem;
        font-size: 0.8125rem;
    }

    .grid {
        gap: 0.75rem;
    }

    /* Stack action buttons */
    .modal-actions {
        flex-direction: column;
    }

    .modal-actions .btn {
        width: 100%;
    }
}

/* Tablet landscape */
@media (min-width: 769px) and (max-width: 1024px) {
    .sidebar {
        width: 220px;
    }

    .grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }
}
/* Expense Summary Page Styles */
.expense-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.expense-summary-grid-secondary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.expense-summary-content-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.expense-form-flex {
    display: flex;
    gap: 1rem;
    align-items: end;
    flex-wrap: wrap;
}

.expense-form-flex .form-group {
    margin-bottom: 0;
    min-width: 150px;
}

.expense-card-hover {
    transition: transform 0.2s ease;
}

.expense-card-hover:hover {
    transform: translateY(-2px);
}

.expense-flex-center {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.expense-flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.expense-flex-column {
    display: flex;
    flex-direction: column;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .expense-summary-grid,
    .expense-summary-grid-secondary,
    .expense-summary-content-grid {
        grid-template-columns: 1fr;
    }
    
    .expense-form-flex {
        flex-direction: column;
        align-items: stretch;
    }
    
    .expense-form-flex .form-group {
        min-width: auto;
    }
}

/* Mobile Navigation Hamburger Icon */
.mobile-nav-hamburger {
  display: none; /* Hidden by default, shown on mobile via media query */
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 0.25rem;
  transition: background-color 0.2s ease;
  position: relative;
  width: 2.5rem;
  height: 2.5rem;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 0.25rem;
}

.mobile-nav-hamburger:hover {
  background-color: var(--hover-bg, rgba(0, 0, 0, 0.05));
}

.mobile-nav-hamburger:focus {
  outline: 2px solid var(--focus-color, #3b82f6);
  outline-offset: 2px;
}

/* Hamburger lines */
.mobile-nav-hamburger-line {
  display: block;
  width: 1.5rem;
  height: 2px;
  background-color: var(--text-color, #374151);
  border-radius: 1px;
  transition: all 0.3s ease;
  transform-origin: center;
}

/* Active state transformation (hamburger to X) */
.mobile-nav-hamburger--active .mobile-nav-hamburger-line:nth-child(1) {
  transform: translateY(6px) rotate(45deg);
}

.mobile-nav-hamburger--active .mobile-nav-hamburger-line:nth-child(2) {
  opacity: 0;
}

.mobile-nav-hamburger--active .mobile-nav-hamburger-line:nth-child(3) {
  transform: translateY(-6px) rotate(-45deg);
}

/* Mobile Menu Container */
.mobile-nav-menu {
  position: fixed;
  top: 0;
  left: 0;
  width: 80%;
  max-width: 320px;
  height: 100vh;
  background: var(--card-bg, #ffffff);
  box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
  z-index: 50;
  transform: translateX(-100%);
  transition: transform 0.3s ease;
  overflow-y: auto;
}

.mobile-nav-menu--open {
  transform: translateX(0);
}

.mobile-nav-menu--closed {
  transform: translateX(-100%);
}

/* Navigation Items */
.mobile-nav-item {
  border-bottom: 1px solid var(--border-color, #e5e7eb);
}

.mobile-nav-link {
  display: block;
  padding: 1rem 1.5rem;
  color: var(--text-color, #374151);
  text-decoration: none;
  transition: background-color 0.2s ease;
}

.mobile-nav-link:hover {
  background-color: var(--hover-bg, rgba(0, 0, 0, 0.05));
}

.mobile-nav-link:focus {
  outline: 2px solid var(--focus-color, #3b82f6);
  outline-offset: -2px;
}

/* Overlay for closing menu when clicking outside */
.mobile-nav-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 40;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.mobile-nav-overlay--active {
  opacity: 1;
  visibility: visible;
}

/* Show hamburger icon on mobile devices */
@media (max-width: 767px) {
  .mobile-nav-hamburger {
    display: flex;
  }
}

/* Hide hamburger icon on desktop */
@media (min-width: 768px) {
  .mobile-nav-hamburger {
    display: none;
  }
  
  .mobile-nav-menu {
    display: none;
  }
}

/* Respect user's reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
  .mobile-nav-hamburger-line {
    transition: none;
  }
  
  .mobile-nav-menu {
    transition: none;
  }
  
  .mobile-nav-overlay {
    transition: none;
  }
  
  .mobile-nav-hamburger {
    transition: none;
  }
  
  .mobile-nav-link {
    transition: none;
  }
}

/* Enhanced Mobile Navigation */
.mobile-header .menu-toggle {
    transition: transform 0.3s ease, background-color 0.2s ease;
    border-radius: 8px;
    padding: 8px;
}

.mobile-header .menu-toggle:hover {
    background-color: rgba(255, 255, 255, 0.1);
    transform: scale(1.05);
}

.mobile-header .menu-toggle:focus {
    outline: 2px solid rgba(255, 255, 255, 0.8);
    outline-offset: 2px;
}

.mobile-header .menu-toggle svg,
.mobile-header .menu-toggle i {
    transition: transform 0.3s ease;
}

/* Hamburger icon animation when menu is open */
.sidebar.open + * .mobile-header .menu-toggle svg,
.sidebar.open + * .mobile-header .menu-toggle i,
body.sidebar-open .mobile-header .menu-toggle svg,
body.sidebar-open .mobile-header .menu-toggle i {
    transform: rotate(90deg);
}

/* Enhanced sidebar animations */
.sidebar {
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform;
}

.sidebar.open {
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    z-index: 120; /* Ensure it's above mobile header */
}

/* Enhanced overlay */
.sidebar-overlay {
    transition: opacity 0.3s ease, visibility 0.3s ease;
    backdrop-filter: blur(4px);
    z-index: 110; /* Ensure it's above mobile header */
}

.sidebar-overlay.active {
    backdrop-filter: blur(8px);
}

/* Focus styles for navigation links */
.side-nav a:focus,
.side-nav button:focus {
    outline: 2px solid rgba(255, 255, 255, 0.8);
    outline-offset: 2px;
    background: rgba(255, 255, 255, 0.15);
}

/* Improved dropdown button focus */
.nav-dropdown-toggle:focus {
    outline: 2px solid rgba(255, 255, 255, 0.8);
    outline-offset: 2px;
    background: rgba(255, 255, 255, 0.25);
}

/* Screen reader only content */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
    .mobile-header .menu-toggle,
    .mobile-header .menu-toggle svg,
    .mobile-header .menu-toggle i,
    .sidebar,
    .sidebar-overlay {
        transition: none;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .mobile-header .menu-toggle:focus {
        outline: 3px solid white;
        outline-offset: 3px;
    }
    
    .side-nav a:focus,
    .side-nav button:focus {
        outline: 3px solid white;
        outline-offset: 3px;
        background: rgba(255, 255, 255, 0.3);
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .mobile-header .menu-toggle {
        min-height: 44px;
        min-width: 44px;
    }
    
    .side-nav a,
    .side-nav button {
        min-height: 44px;
        padding: 0.75rem 1rem;
    }
}

/* Landscape mobile optimizations */
@media (max-width: 768px) and (orientation: landscape) {
    .sidebar {
        width: 240px;
    }
    
    .sidebar.open {
        left: 0;
    }
}

/* Extra small devices - optimize for very small screens */
@media (max-width: 320px) {
    .sidebar {
        width: 100%;
        left: -100%;
    }
    
    .sidebar.open {
        left: 0;
    }
}
/* Ensure hamburger button is always clickable */
.mobile-header .menu-toggle {
    position: relative;
    z-index: 130; /* Higher than sidebar */
}

/* Mobile navigation z-index hierarchy */
/* 100: Mobile header */
/* 110: Sidebar overlay */
/* 120: Sidebar */
/* 130: Hamburger button */

/* Ensure proper stacking on mobile */
@media (max-width: 768px) {
    .mobile-header {
        z-index: 100;
    }
    
    .sidebar-overlay {
        z-index: 110;
    }
    
    .sidebar {
        z-index: 120;
    }
    
    .mobile-header .menu-toggle {
        z-index: 130;
    }
    
    /* Ensure sidebar appears above mobile header when open */
    .sidebar.open {
        z-index: 120;
    }
    
    /* But keep hamburger button accessible */
    body.sidebar-open .mobile-header .menu-toggle {
        z-index: 130;
        position: relative;
    }
}


/* ── Desktop sidebar toggle button ─────────────────────────── */
.desktop-nav-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    background: transparent;
    color: #374151;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    flex-shrink: 0;
    padding: 0;
}
.desktop-nav-toggle:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
    color: #1a2744;
}
[data-theme="dark"] .desktop-nav-toggle {
    border-color: rgba(255,255,255,0.12);
    color: #cbd5e1;
    background: rgba(255,255,255,0.04);
}
[data-theme="dark"] .desktop-nav-toggle:hover {
    background: rgba(255,255,255,0.1);
    border-color: rgba(255,255,255,0.2);
    color: #ffffff;
}

/* ── Collapsed sidebar (desktop only) ──────────────────────── */
@media (min-width: 769px) {
    .sidebar {
        transition: width 0.22s ease;
    }

    .sidebar.collapsed {
        width: 72px;
        overflow: visible;
    }

    /* Hide all text labels, arrows, badges, section dividers */
    .sidebar.collapsed .brand span,
    .sidebar.collapsed .side-nav > a span,
    .sidebar.collapsed .nav-dropdown-toggle span,
    .sidebar.collapsed .sidebar-bottom .theme-toggle span,
    .sidebar.collapsed .sidebar-bottom .btn-primary span,
    .sidebar.collapsed .nav-badge {
        display: none !important;
    }

    /* Center direct nav links */
    .sidebar.collapsed .brand,
    .sidebar.collapsed .side-nav > a,
    .sidebar.collapsed .sidebar-bottom .theme-toggle,
    .sidebar.collapsed .sidebar-bottom .btn-primary {
        justify-content: center;
        padding: 0.55rem 0;
        gap: 0;
    }

    /* Bigger icons on direct links */
    .sidebar.collapsed .side-nav > a > svg,
    .sidebar.collapsed .side-nav > a > i {
        width: 22px !important;
        height: 22px !important;
        font-size: 1.1rem !important;
        padding: 7px !important;
        border-radius: 10px !important;
        box-sizing: content-box !important;
        background: rgba(255,255,255,0.1) !important;
        flex-shrink: 0;
    }
    .sidebar.collapsed .side-nav > a:hover > svg,
    .sidebar.collapsed .side-nav > a:hover > i {
        background: rgba(255,255,255,0.2) !important;
    }
    .sidebar.collapsed .side-nav > a.active > svg,
    .sidebar.collapsed .side-nav > a.active > i {
        background: rgba(192,21,42,0.9) !important;
        box-shadow: 0 2px 8px rgba(192,21,42,0.4) !important;
    }

    /* ── Dropdown groups in collapsed mode ── */
    /* Hide the group toggle button */
    .sidebar.collapsed .nav-dropdown-toggle {
        display: none !important;
    }

    /* Always show the submenu, reset indentation */
    .sidebar.collapsed .nav-dropdown-menu {
        display: flex !important;
        flex-direction: column !important;
        gap: 0.1rem !important;
        padding-left: 0 !important;
        margin-left: 0 !important;
        border-left: none !important;
        margin-top: 0 !important;
    }

    /* Each submenu link: centered icon, full white */
    .sidebar.collapsed .nav-dropdown-menu a {
        display: flex !important;
        justify-content: center !important;
        align-items: center !important;
        padding: 0.55rem 0 !important;
        gap: 0 !important;
        overflow: visible !important;
        border-radius: 8px !important;
        color: #ffffff !important;
    }

    /* Force white on all icons in collapsed mode */
    .sidebar.collapsed .side-nav > a,
    .sidebar.collapsed .nav-dropdown-menu a {
        color: #ffffff !important;
    }
    .sidebar.collapsed .side-nav > a > svg,
    .sidebar.collapsed .nav-dropdown-menu a > svg {
        stroke: #ffffff !important;
        color: #ffffff !important;
    }
    .sidebar.collapsed .side-nav > a > i,
    .sidebar.collapsed .nav-dropdown-menu a > i {
        color: #ffffff !important;
    }

    /* Hide text inside submenu links */
    .sidebar.collapsed .nav-dropdown-menu a span,
    .sidebar.collapsed .nav-dropdown-menu a .nav-text-node {
        display: none !important;
    }

    /* Hide section label divs */
    .sidebar.collapsed .nav-dropdown-menu > div {
        display: none !important;
    }

    /* Bigger icons in submenu links */
    .sidebar.collapsed .nav-dropdown-menu a > svg,
    .sidebar.collapsed .nav-dropdown-menu a > i {
        width: 20px !important;
        height: 20px !important;
        font-size: 1rem !important;
        padding: 7px !important;
        border-radius: 10px !important;
        box-sizing: content-box !important;
        background: rgba(255,255,255,0.08) !important;
        flex-shrink: 0 !important;
        stroke-width: 2 !important;
    }
    .sidebar.collapsed .nav-dropdown-menu a:hover > svg,
    .sidebar.collapsed .nav-dropdown-menu a:hover > i {
        background: rgba(255,255,255,0.18) !important;
    }
    .sidebar.collapsed .nav-dropdown-menu a.active > svg,
    .sidebar.collapsed .nav-dropdown-menu a.active > i {
        background: rgba(192,21,42,0.9) !important;
        box-shadow: 0 2px 8px rgba(192,21,42,0.4) !important;
    }

    /* Tooltips on hover */
    .sidebar.collapsed .side-nav > a,
    .sidebar.collapsed .nav-dropdown-menu a {
        position: relative;
    }
    .sidebar.collapsed .side-nav > a::after,
    .sidebar.collapsed .nav-dropdown-menu a::after {
        content: attr(data-tooltip);
        position: absolute;
        left: calc(100% + 10px);
        top: 50%;
        transform: translateY(-50%);
        background: #1a2744;
        color: #fff;
        font-size: 0.78rem;
        font-weight: 500;
        padding: 0.35rem 0.75rem;
        border-radius: 6px;
        white-space: nowrap;
        pointer-events: none;
        opacity: 0;
        transition: opacity 0.15s ease;
        z-index: 9999;
        box-shadow: 0 4px 14px rgba(0,0,0,0.35);
    }
    .sidebar.collapsed .side-nav > a:hover::after,
    .sidebar.collapsed .nav-dropdown-menu a:hover::after {
        opacity: 1;
    }
}

/* ── Parent nav section labels ──────────────────────────────── */
.nav-section-label {
    padding: 0.6rem 0.75rem 0.2rem;
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(255,255,255,0.3);
    margin-top: 0.25rem;
}
/* Hide section labels when sidebar is collapsed */
.sidebar.collapsed .nav-section-label {
    display: none !important;
}
