/**
 * JuanSinag v2 — Unified Theme System
 * Borderless Design | Color Blocking | Spatial Separation
 * Light + Dark mode via [data-theme] attribute
 * Bento box layout with uniform 16px margins
 *
 * Layout: Header spans FULL width above everything.
 *         Sidebar is fixed BELOW the header.
 *         On mobile: bottom tab bar replaces sidebar.
 */

/* ============================================
   Dark Mode (default)
   ============================================ */
:root,
[data-theme="dark"] {
    --color-yellow: #FFD700;
    --color-orange: #FF6B35;
    --color-red: #E63946;
    --nav-bg: #1a1a1a;
    --nav-border: #2a2a2a;
    --sidebar-bg: #1e1e1e;
    --sidebar-border: #2a2a2a;
    --body-bg: #121212;
    --surface: #1e1e1e;
    --surface-raised: #252525;
    --surface-overlay: rgba(30, 30, 30, 0.95);
    --text-primary: #e4e4e7;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;
    --border: #2a2a2a;
    --border-subtle: #222222;
    --hover-bg: rgba(255, 107, 53, 0.1);
    --hover-text: #FF6B35;
    --active-bg: rgba(255, 215, 0, 0.08);
    --active-text: #d4b000;
    --active-border: #d4b000;
    --accent: #FF6B35;
    --accent-hover: #ff8555;
    --success: #4caf50;
    --warning: #ff9800;
    --error: #E63946;
    --info: #60a5fa;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.3);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.4);
    --gradient-brand: linear-gradient(135deg, #FFD700 0%, #FF6B35 50%, #E63946 100%);
    --header-h: 56px;
    --sidebar-w: 240px;
    --bottombar-h: 56px;
    --spacing: 16px;
    --radius: 12px;
    --radius-sm: 8px;
}

/* ============================================
   Light Mode
   ============================================ */
[data-theme="light"] {
    --nav-bg: #ffffff;
    --nav-border: #e5e5e5;
    --sidebar-bg: #fafafa;
    --sidebar-border: #e5e5e5;
    --body-bg: #f0f0f0;
    --surface: #ffffff;
    --surface-raised: #f5f5f5;
    --surface-overlay: rgba(255, 255, 255, 0.97);
    --text-primary: #18181b;
    --text-secondary: #52525b;
    --text-muted: #a1a1aa;
    --border: #e5e5e5;
    --border-subtle: #f0f0f0;
    --hover-bg: rgba(255, 107, 53, 0.06);
    --hover-text: #e55a25;
    --active-bg: rgba(255, 107, 53, 0.1);
    --active-text: #d44a15;
    --active-border: #FF6B35;
    --accent: #e55a25;
    --accent-hover: #d44a15;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.1);
}

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

/* ============================================
   Theme Toggle Button (login/public pages)
   ============================================ */
.theme-toggle {
    background: none;
    border: 1px solid var(--border, #2a2a2a);
    color: var(--text-primary);
    cursor: pointer;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    flex-shrink: 0;
}
.theme-toggle:hover {
    background: var(--hover-bg, rgba(255, 107, 53, 0.1));
    border-color: var(--accent, #FF6B35);
}
.theme-toggle .icon-sun,
.theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
[data-theme="light"] .theme-toggle .icon-moon { display: block; }
:root:not([data-theme]) .theme-toggle .icon-sun { display: block; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    background: var(--body-bg);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* Kill old glass-admin animated orbs */
body::before, body::after { display: none !important; }

/* ============================================
   TOP NAVBAR — TRUE FULL WIDTH, above everything
   ============================================ */
.header {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    height: var(--header-h) !important;
    background: var(--nav-bg) !important;
    z-index: 1100;
    display: flex;
    align-items: center;
    box-shadow: var(--shadow-sm) !important;
    border-bottom: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    padding: 0 !important;
    margin: 0 !important;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0 var(--spacing);
    height: 100%;
}

/* Logo — enlarged to fill navbar height with small margin */
.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    background: none !important;
    -webkit-background-clip: unset !important;
    -webkit-text-fill-color: unset !important;
    background-clip: unset !important;
}

.header-logo-img {
    height: calc(var(--header-h) - 12px);
    width: auto;
    object-fit: contain;
}

.v2-badge { display: none; }

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.user-welcome-text {
    color: var(--text-secondary);
    font-size: 0.82rem;
    white-space: nowrap;
}

/* Theme toggle */
.theme-toggle-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
    width: 36px;
    height: 36px;
}
.theme-toggle-btn:hover { background: var(--hover-bg); color: var(--hover-text); }
.theme-toggle-btn i, .theme-toggle-btn svg { width: 18px; height: 18px; }
.theme-icon-dark { display: none; }
[data-theme="light"] .theme-icon-light { display: none !important; }
[data-theme="light"] .theme-icon-dark { display: block !important; }

/* Notification bell */
.notification-bell-btn {
    position: relative;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
    width: 36px;
    height: 36px;
}
.notification-bell-btn:hover { background: var(--hover-bg); color: var(--hover-text); }
.notification-bell-btn i, .notification-bell-btn svg { width: 18px; height: 18px; }
.notification-badge {
    position: absolute;
    top: 2px; right: 2px;
    background: var(--error);
    color: #fff;
    border-radius: 50%;
    min-width: 16px; height: 16px;
    font-size: 0.6rem;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700;
    padding: 0 3px;
    border: 2px solid var(--nav-bg);
}

/* Hamburger — hidden on desktop, visible on mobile */
.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-sm);
    width: 40px; height: 40px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    flex-shrink: 0;
}
.mobile-menu-btn:hover { background: var(--hover-bg); }
.mobile-menu-btn span {
    display: block; width: 20px; height: 2px;
    background: var(--text-primary);
    border-radius: 1px;
    transition: all 0.25s ease;
}
.mobile-menu-btn.active span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.mobile-menu-btn.active span:nth-child(2) { opacity: 0; }
.mobile-menu-btn.active span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ============================================
   SIDEBAR — Fixed BELOW header, left column
   ============================================ */
.sidebar {
    position: fixed;
    top: var(--header-h);
    left: 0;
    bottom: 0;
    width: var(--sidebar-w);
    background: var(--sidebar-bg) !important;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    overflow-y: auto;
    transition: transform 0.25s ease;
    border-right: none !important;
    box-shadow: var(--shadow-sm) !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}

.sidebar-header { display: none; }

.sidebar-nav {
    flex: 1;
    padding: 8px 0;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 16px;
    margin: 1px 8px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.82rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    transition: all 0.15s ease;
    white-space: nowrap;
    border: none;
}
.sidebar-link:hover { background: var(--hover-bg); color: var(--hover-text); }
.sidebar-link.active {
    background: var(--active-bg);
    color: var(--active-text);
    font-weight: 600;
    box-shadow: inset 3px 0 0 var(--active-border);
}
.sidebar-link i, .sidebar-link svg { width: 18px; height: 18px; flex-shrink: 0; }

.sidebar-divider { height: 1px; background: var(--border-subtle); margin: 8px 16px; }
.sidebar-section-title {
    padding: 12px 16px 4px;
    font-size: 0.65rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.08em;
    color: var(--text-muted);
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.sidebar-v2-footer {
    padding: 12px 16px !important;
    border-top: 1px solid var(--border-subtle) !important;
    text-align: center;
    font-size: 0.7rem !important;
    color: var(--text-muted) !important;
}

.sidebar-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    opacity: 0; pointer-events: none;
    transition: opacity 0.25s ease;
    z-index: 999;
}
.sidebar-overlay.active { opacity: 1; pointer-events: all; }

/* ============================================
   DESKTOP LAYOUT (≥769px)
   Header: full width. Sidebar: below header. Content: offset by sidebar.
   ============================================ */
@media (min-width: 769px) {
    .sidebar { transform: translateX(0) !important; }
    .mobile-menu-btn { display: none !important; }
    .sidebar-overlay { display: none !important; }
    .sidebar-close-btn { display: none; }

    /* Content offset by sidebar only — header stays full width */
    .container,
    .dashboard-container {
        margin-left: var(--sidebar-w) !important;
        width: calc(100% - var(--sidebar-w)) !important;
    }

    /* Bottom bar hidden on desktop */
    .mobile-bottom-bar { display: none !important; }
}

/* Tablet tweak */
@media (max-width: 1024px) and (min-width: 769px) {
    :root, [data-theme="dark"], [data-theme="light"] { --sidebar-w: 200px; }
    .sidebar-link span { font-size: 0.78rem; }
}

/* ============================================
   MAIN CONTENT
   ============================================ */
.container {
    padding: calc(var(--header-h) + var(--spacing)) var(--spacing) var(--spacing);
    width: 100%;
    max-width: 100%;
    margin: 0;
    box-sizing: border-box;
}

/* main-content inside dashboard-container needs header offset */
.dashboard-container > .main-content,
.dashboard-container > main {
    padding: calc(var(--header-h) + var(--spacing)) var(--spacing) var(--spacing);
    width: 100%;
    box-sizing: border-box;
}

.container > h1 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: var(--spacing);
    color: var(--text-primary);
}

/* Dashboard layout — remove 680px constraint */
.sidebar ~ .container,
.sidebar ~ .dashboard-container {
    max-width: 100% !important;
    margin-right: 0 !important;
    padding: calc(var(--header-h) + var(--spacing)) var(--spacing) var(--spacing) !important;
}

/* ============================================
   CARDS — Borderless
   ============================================ */
.card {
    background: var(--surface) !important;
    border-radius: var(--radius) !important;
    padding: var(--spacing) !important;
    margin-bottom: var(--spacing) !important;
    box-shadow: var(--shadow-sm) !important;
    border: none !important;
    width: 100%;
    box-sizing: border-box;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}
.card::before, .stat-card::before, .table-container::before { display: none !important; }
.card-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: var(--spacing); padding-bottom: 12px;
    border-bottom: 1px solid var(--border-subtle);
}
.card-title { font-size: 1rem; font-weight: 600; color: var(--text-primary); }

/* ============================================
   STAT CARDS — Grid
   ============================================ */
.stats {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)) !important;
    gap: var(--spacing) !important;
    overflow-x: visible !important;
    margin-bottom: var(--spacing) !important;
}
.stat-card {
    background: var(--surface) !important;
    padding: var(--spacing) !important;
    border-radius: var(--radius) !important;
    text-align: center;
    box-shadow: var(--shadow-sm) !important;
    border: none !important;
    flex: unset !important;
    min-width: unset !important;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md) !important; }
.stat-number {
    font-size: 1.5rem !important;
    font-weight: 700;
    color: var(--accent) !important;
    background: none !important;
    -webkit-text-fill-color: var(--accent) !important;
    margin-bottom: 4px;
}
.stat-label { color: var(--text-secondary); font-size: 0.8rem; }

/* ============================================
   TABLES
   ============================================ */
.table-container {
    background: var(--surface) !important;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm) !important;
    border: none !important;
    width: 100%;
    backdrop-filter: none !important;
}
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 10px 14px; text-align: left; }
.table th {
    background: var(--surface-raised) !important;
    font-weight: 600; font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase; letter-spacing: 0.03em;
    border-bottom: 1px solid var(--border);
}
.table td { border-bottom: 1px solid var(--border-subtle); font-size: 0.85rem; color: var(--text-primary); }
.table tbody tr:hover { background: var(--hover-bg) !important; }
.table tbody tr:last-child td { border-bottom: none; }

/* ============================================
   BUTTONS
   ============================================ */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 8px 16px; border: none; border-radius: var(--radius-sm);
    font-size: 0.85rem; font-weight: 500; text-decoration: none;
    cursor: pointer; transition: all 0.15s ease; white-space: nowrap;
    color: var(--text-primary);
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); box-shadow: var(--shadow-md); }
.btn-secondary { background: var(--surface-raised); color: var(--text-primary); }
.btn-secondary:hover { background: var(--hover-bg); color: var(--hover-text); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { opacity: 0.9; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover { opacity: 0.9; }
.btn-danger { background: var(--error); color: #fff; }
.btn-danger:hover { opacity: 0.9; }
.btn-sm { padding: 5px 10px; font-size: 0.78rem; }

/* ============================================
   FORMS
   ============================================ */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; color: var(--text-primary); font-weight: 500; font-size: 0.85rem; }
.form-group input, .form-group select, .form-group textarea {
    width: 100%; padding: 10px 12px;
    background: var(--surface-raised) !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius-sm) !important;
    color: var(--text-primary) !important;
    font-size: 0.9rem;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none;
    border-color: var(--accent) !important;
    box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.12) !important;
    background: var(--surface-raised) !important;
}
.form-group input[type="file"] { padding: 8px; }
.form-group small { display: block; margin-top: 4px; color: var(--text-muted); font-size: 0.78rem; }

/* Compact filter/input bar — horizontal column layout */
.filter-bar,
.form-row-inline {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    align-items: end;
    margin-bottom: 16px;
}
.filter-bar .form-group,
.form-row-inline .form-group {
    margin-bottom: 0;
}
.filter-bar .full-width,
.form-row-inline .full-width {
    grid-column: 1 / -1;
}
@media (max-width: 480px) {
    .filter-bar,
    .form-row-inline {
        grid-template-columns: 1fr;
    }
}

/* Inline form row — for compact 2-3 column forms */
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    margin-bottom: 12px;
}
.form-row .form-group { margin-bottom: 0; }
.form-row .full-width { grid-column: 1 / -1; }

/* Compact form group — less padding, smaller labels */
.form-group--compact { margin-bottom: 8px; }
.form-group--compact label { font-size: 0.78rem; margin-bottom: 4px; }
.form-group--compact input,
.form-group--compact select,
.form-group--compact textarea {
    padding: 8px 10px;
    font-size: 0.85rem;
}

/* ============================================
   UNIVERSAL INPUT DARK/LIGHT MODE
   Ensures all inputs respect CSS variables
   ============================================ */
input[type="text"],
input[type="number"],
input[type="date"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="tel"],
input[type="url"],
select,
textarea {
    background: var(--surface-raised, #252525) !important;
    color: var(--text-primary, #e4e4e7) !important;
    border: 1px solid var(--border, #3E4042) !important;
    border-radius: var(--radius-sm, 8px);
}

input:focus, select:focus, textarea:focus {
    border-color: var(--accent, #FF6B35) !important;
    box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.15) !important;
    outline: none;
}

::placeholder {
    color: var(--text-muted, #71717a) !important;
    opacity: 1;
}

/* ============================================
   ALERTS
   ============================================ */
.alert {
    padding: 12px 16px; border-radius: var(--radius-sm);
    margin-bottom: var(--spacing); font-size: 0.85rem;
    border: none; border-left: 4px solid;
}
.alert-success { background: rgba(76,175,80,0.08); border-left-color: var(--success); color: var(--success); }
.alert-warning { background: rgba(255,152,0,0.08); border-left-color: var(--warning); color: var(--warning); }
.alert-error { background: rgba(230,57,70,0.08); border-left-color: var(--error); color: var(--error); }
.alert-info { background: rgba(96,165,250,0.08); border-left-color: var(--info); color: var(--info); }
.error {
    background: rgba(230,57,70,0.08);
    border: 1px solid rgba(230,57,70,0.2);
    color: var(--error); padding: 10px 14px;
    border-radius: var(--radius-sm); margin-bottom: var(--spacing);
}

/* ============================================
   MODALS
   ============================================ */
.modal {
    display: none; position: fixed; inset: 0; z-index: 10000;
    background: rgba(0,0,0,0.5); backdrop-filter: blur(4px);
    animation: fadeIn 0.15s ease;
}
.modal-content {
    background: var(--surface) !important; margin: 8vh auto; padding: 24px;
    border-radius: var(--radius); width: 90%; max-width: 560px;
    max-height: 84vh; overflow-y: auto;
    box-shadow: var(--shadow-lg); animation: slideUp 0.2s ease;
    backdrop-filter: none !important;
}
.modal-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 16px; padding-bottom: 12px;
    border-bottom: 1px solid var(--border-subtle);
}
.modal-title { font-size: 1.1rem; font-weight: 600; color: var(--text-primary); }
.close { color: var(--text-muted); font-size: 1.5rem; cursor: pointer; transition: color 0.15s; line-height: 1; }
.close:hover { color: var(--text-primary); }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ============================================
   STATUS BADGES
   ============================================ */
.status-badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.02em; }
.status-for_payment { background: rgba(255,152,0,0.12); color: var(--warning); }
.status-paid { background: rgba(76,175,80,0.12); color: var(--success); }
.status-unpaid { background: rgba(230,57,70,0.12); color: var(--error); }
.status-pending { background: rgba(255,152,0,0.12); color: var(--warning); }
.status-approved { background: rgba(76,175,80,0.12); color: var(--success); }
.status-rejected { background: rgba(230,57,70,0.12); color: var(--error); }

/* ============================================
   GRIDS
   ============================================ */
.grid { display: grid; gap: var(--spacing); }
.grid-2 { grid-template-columns: repeat(2, 1fr) !important; }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, 1fr) !important; }

/* Stats Grid - consistent across all pages */
.stats-grid {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)) !important;
    gap: var(--spacing) !important;
    margin-bottom: var(--spacing) !important;
}

/* Filter Grid - responsive based on content */
.filter-grid {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)) !important;
    gap: 12px !important;
    margin-bottom: 16px !important;
}

/* Cards Grid - for detail views */
.cards-grid {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)) !important;
    gap: var(--spacing) !important;
}

/* Vertical spacing utilities */
.gap-0 { gap: 0 !important; }
.gap-1 { gap: 8px !important; }
.gap-2 { gap: 16px !important; }
.gap-3 { gap: 24px !important; }
.gap-4 { gap: 32px !important; }
.mb-0 { margin-bottom: 0 !important; }
.mt-0 { margin-top: 0 !important; }

/* ============================================
   LOGIN — No sidebar pages
   ============================================ */
body.no-sidebar .container { margin-left: 0 !important; width: 100% !important; }
body.no-sidebar { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-form {
    max-width: 400px; width: 100%; margin: 0 auto;
    background: var(--surface) !important; padding: 32px;
    border-radius: var(--radius); box-shadow: var(--shadow-md) !important;
    border: none !important; backdrop-filter: none !important;
}
.login-form h1 { text-align: center; margin-bottom: 24px; color: var(--accent); font-size: 1.5rem; }

/* ============================================
   UTILITIES
   ============================================ */
.text-center { text-align: center; }
.text-right { text-align: right; }
.hidden { display: none; }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; } .mb-4 { margin-bottom: 32px; }
.mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; } .mt-4 { margin-top: 32px; }

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

/* ============================================
   MOBILE BOTTOM TAB BAR
   Replaces sidebar on mobile. SVG icons, favorites.
   ============================================ */
.mobile-bottom-bar {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottombar-h);
    background: var(--nav-bg);
    z-index: 1100;
    box-shadow: 0 -1px 4px rgba(0,0,0,0.15);
    padding: 0 4px;
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.bottom-bar-inner {
    display: flex;
    align-items: center;
    justify-content: space-around;
    height: 100%;
    max-width: 500px;
    margin: 0 auto;
}

.bottom-bar-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 0.6rem;
    font-weight: 500;
    padding: 4px 8px;
    border-radius: 8px;
    transition: color 0.15s, background 0.15s;
    min-width: 48px;
    -webkit-tap-highlight-color: transparent;
}

.bottom-bar-item svg {
    width: 22px;
    height: 22px;
    stroke-width: 1.8;
}

.bottom-bar-item:hover,
.bottom-bar-item:active {
    color: var(--hover-text);
    background: var(--hover-bg);
}

.bottom-bar-item.active {
    color: var(--active-text);
}

/* ============================================
   MOBILE (≤768px)
   ============================================ */
@media (max-width: 768px) {
    /* Header stays full width fixed */
    .header {
        position: fixed !important;
        height: var(--header-h) !important;
        padding: 0 !important;
        margin-bottom: 0 !important;
    }
    .header-content {
        flex-direction: row !important;
        gap: 8px !important;
        padding: 0 12px !important;
        height: 100%;
    }
    .header-right { display: flex !important; gap: 4px !important; margin-left: auto; }
    .user-welcome-text { display: none !important; }
    .header-logo-img { height: calc(var(--header-h) - 16px) !important; }

    /* Hide desktop sidebar */
    .sidebar {
        top: 0 !important;
        height: 100vh;
        width: 280px;
        max-width: 85vw;
        transform: translateX(-100%);
        z-index: 1200;
        box-shadow: none;
    }
    .sidebar.active {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0,0,0,0.4);
    }
    .sidebar.active .sidebar-header,
    .sidebar .sidebar-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 12px 16px;
        border-bottom: 1px solid var(--border-subtle);
        min-height: 56px;
    }

    /* Show hamburger for full sidebar access */
    .mobile-menu-btn { display: flex; }

    /* Show bottom bar */
    .mobile-bottom-bar { display: block; }

    /* Content: account for header top + bottom bar */
    .container,
    .dashboard-container {
        margin-left: 0 !important;
        width: 100% !important;
        padding: calc(var(--header-h) + 12px) 12px calc(var(--bottombar-h) + 12px) !important;
    }
    .sidebar ~ .container,
    .sidebar ~ .dashboard-container {
        margin-left: 0 !important;
        width: 100% !important;
        padding: calc(var(--header-h) + 12px) 12px calc(var(--bottombar-h) + 12px) !important;
    }

    /* Mobile grid adjustments */
    .stats { grid-template-columns: repeat(2, 1fr) !important; }
    .stats-grid { grid-template-columns: repeat(2, 1fr) !important; }
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr !important; }
    .filter-grid { grid-template-columns: 1fr !important; }
    .cards-grid { grid-template-columns: 1fr !important; }
    
    .table-container { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .modal-content { margin: 4vh 3vw; width: 94vw; max-height: 92vh; padding: 16px; }
    .card { padding: 12px !important; margin-bottom: 12px !important; }
    .sidebar-overlay { display: block; }
    
    /* Mobile card header adjustments */
    .card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    .card-header .btn {
        width: 100%;
    }
}

/* ============================================
   PRINT
   ============================================ */
@media print {
    .sidebar, .sidebar-overlay, .header, .mobile-menu-btn, .mobile-bottom-bar { display: none !important; }
    .container { margin-left: 0 !important; width: 100% !important; padding: 0; }
}

/* ============================================
   OVERRIDE old sidebar conflicts
   ============================================ */
:root {
    --sidebar-width: var(--sidebar-w);
}

@media (min-width: 769px) {
    /* Header MUST be full width */
    .header {
        left: 0 !important;
        width: 100% !important;
    }

    /* Content: offset by sidebar, centered with equal padding L+R */
    .container,
    .dashboard-container,
    .sidebar ~ .container,
    .sidebar ~ .dashboard-container {
        margin-left: var(--sidebar-w) !important;
        width: calc(100% - var(--sidebar-w)) !important;
        padding-left: var(--spacing) !important;
        padding-right: var(--spacing) !important;
        max-width: 100% !important;
    }

    .sidebar {
        width: var(--sidebar-w) !important;
    }
}

@media (max-width: 768px) {
    .container,
    .dashboard-container,
    .sidebar ~ .container,
    .sidebar ~ .dashboard-container {
        margin-left: 0 !important;
        width: 100% !important;
        padding-left: 12px !important;
        padding-right: 12px !important;
    }
}

/* ============================================
   Light mode fixes for login-info and misc elements
   ============================================ */
.login-info {
    background: var(--surface-raised) !important;
    border-radius: var(--radius-sm);
    padding: 12px;
    margin-top: 16px;
    color: var(--text-secondary);
}

.login-info a {
    color: var(--accent) !important;
}

/* Ensure all text respects theme in light mode */
[data-theme="light"] body,
[data-theme="light"] .container,
[data-theme="light"] h1, [data-theme="light"] h2, [data-theme="light"] h3,
[data-theme="light"] p, [data-theme="light"] span, [data-theme="light"] label,
[data-theme="light"] td, [data-theme="light"] th {
    color: var(--text-primary);
}

[data-theme="light"] .text-secondary,
[data-theme="light"] small,
[data-theme="light"] .stat-label {
    color: var(--text-secondary) !important;
}

/* Fix inline style overrides that use old var names */
[data-theme="light"] [style*="color: var(--text-secondary)"] {
    color: var(--text-secondary) !important;
}

/* ============================================
   Login Page — True center, footer inside card
   ============================================ */
body.no-sidebar {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-height: 100vh !important;
    flex-direction: column;
}

body.no-sidebar .container {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex: 1;
    width: 100% !important;
    margin: 0 !important;
    padding: 16px !important;
}

.login-footer {
    text-align: center;
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border-subtle);
}

/* Remove old v2-footer */
.v2-footer { display: none !important; }

/* ============================================
   Facebook-style content margins
   Generous padding, breathing room, centered feel
   ============================================ */
@media (min-width: 769px) {
    .container,
    .sidebar ~ .container,
    .sidebar ~ .dashboard-container {
        padding: calc(var(--header-h) + 24px) 32px 32px !important;
    }
}

@media (min-width: 1200px) {
    .container,
    .sidebar ~ .container,
    .sidebar ~ .dashboard-container {
        padding: calc(var(--header-h) + 28px) 40px 40px !important;
    }
}

/* Bento box: cards, stats, grids all use consistent gap */
.card + .card,
.stats + .card,
.card + .stats,
.card + .table-container,
.table-container + .card {
    margin-top: 0;
}
