/* ===================================================================
   NGNet v3 — Design System (Full Overhaul)
   =================================================================== */

:root {
    --primary: #0066cc;
    --primary-hover: #0052a3;
    --primary-light: #e8f0fe;
    --sidebar-bg: #1a1f2e;
    --sidebar-hover: #252b3b;
    --sidebar-text: #8892a0;
    --sidebar-active: #ffffff;
    --sidebar-width: 270px;
    --sidebar-compact-width: 60px;
    --topbar-height: 56px;
    --impersonation-height: 40px;
    --bg: #f5f7fa;
    --card-bg: #ffffff;
    --text: #1a1a2e;
    --text-muted: #6b7280;
    --success: #10b981;
    --success-light: #ecfdf5;
    --warning: #f59e0b;
    --warning-light: #fffbeb;
    --danger: #ef4444;
    --danger-light: #fef2f2;
    --info: #3b82f6;
    --info-light: #eff6ff;
    --border: #e5e7eb;
    --radius: 8px;
    --radius-sm: 4px;
    --radius-lg: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-lg: 0 4px 6px rgba(0,0,0,0.07), 0 10px 15px rgba(0,0,0,0.1);
    --transition: 0.2s ease;
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    --debugbar-height: 0px;
    --font-mono: 'SF Mono', SFMono-Regular, Menlo, Consolas, monospace;
}

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; -webkit-font-smoothing: antialiased; }
body { font-family: var(--font); color: var(--text); background: var(--bg); line-height: 1.6; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
table { border-collapse: collapse; width: 100%; }

/* --- App Layout --- */
.app-wrapper { display: flex; min-height: 100vh; }
.app-main { flex: 1; display: flex; flex-direction: column; min-width: 0; margin-left: var(--sidebar-width); transition: margin-left var(--transition); padding-bottom: var(--debugbar-height); }
.app-content { flex: 1; padding: 24px; max-width: 1400px; width: 100%; margin: 0 auto; }
.app-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; justify-content: space-between; color: var(--text-muted); font-size: 0.85rem; }

/* Compact sidebar mode */
.sidebar-compact .sidebar { width: var(--sidebar-compact-width); }
.sidebar-compact .sidebar .sidebar-brand,
.sidebar-compact .sidebar .nav-label,
.sidebar-compact .sidebar .nav-chevron,
.sidebar-compact .sidebar .badge { display: none; }
.sidebar-compact .sidebar .sidebar-logo { display: none; }
.sidebar-compact .sidebar .sidebar-toggle-compact { margin: 0 auto; padding: 8px; }
.sidebar-compact .sidebar .nav-submenu { display: none !important; }
.sidebar-compact .sidebar .sidebar-header { justify-content: center; padding: 16px 8px; flex-wrap: wrap; gap: 0; }
.sidebar-compact .sidebar .nav-link,
.sidebar-compact .sidebar .nav-category-header { justify-content: center; padding: 10px 0; }
.sidebar-compact .sidebar .nav-icon { margin: 0; }
.sidebar-compact .app-main { margin-left: var(--sidebar-compact-width); }

/* Toggle button icon switching: collapse (<<) visible by default, expand (>>) in compact mode */
.sidebar-toggle-compact .icon-expand { display: none; }
.sidebar-compact .sidebar .sidebar-toggle-compact .icon-collapse { display: none; }
.sidebar-compact .sidebar .sidebar-toggle-compact .icon-expand { display: inline-flex; }

/* --- Impersonation Banner --- */
.impersonation-banner {
    position: fixed; top: 0; left: 0; right: 0;
    height: var(--impersonation-height);
    background: linear-gradient(90deg, #e63946, #c5303c);
    color: #fff; display: flex; align-items: center; justify-content: center;
    font-size: 0.85rem; z-index: 200; gap: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
.has-impersonation .sidebar { top: var(--impersonation-height); }
.has-impersonation .app-main { padding-top: var(--impersonation-height); }

/* --- Sidebar --- */
.sidebar {
    position: fixed; top: 0; left: 0; bottom: var(--debugbar-height);
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex; flex-direction: column;
    z-index: 100;
    transition: width var(--transition), transform var(--transition);
    overflow-x: hidden;
}
.sidebar-header {
    padding: 20px; display: flex; align-items: center; gap: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0;
}
.sidebar-logo { width: 32px; height: 32px; border-radius: var(--radius-sm); flex-shrink: 0; }
.sidebar-brand { font-size: 1.1rem; font-weight: 600; color: #fff; white-space: nowrap; }
.sidebar-close { display: none; background: none; border: none; color: var(--sidebar-text); font-size: 1.5rem; cursor: pointer; margin-left: auto; }
.sidebar-toggle-compact {
    background: none; border: none; color: var(--sidebar-text); cursor: pointer;
    margin-left: auto; padding: 4px; border-radius: var(--radius-sm);
    display: inline-flex; align-items: center;
    transition: color var(--transition);
}
.sidebar-toggle-compact:hover { color: #fff; }
.sidebar-toggle-compact svg { width: 16px; height: 16px; }

.sidebar-nav { flex: 1; padding: 8px 0; overflow-y: auto; overflow-x: hidden; }
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

.nav-list { list-style: none; }

/* --- Menu Items --- */
.nav-item { margin: 1px 8px; }
.nav-link {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 12px; border-radius: var(--radius);
    color: var(--sidebar-text); transition: all var(--transition);
    font-size: 0.9rem; white-space: nowrap; text-decoration: none;
}
.nav-link:hover { background: var(--sidebar-hover); color: #fff; text-decoration: none; }
.nav-item.active > .nav-link { background: var(--primary); color: #fff; }
.nav-link.disabled { opacity: 0.5; cursor: default; }
.nav-link.disabled:hover { background: transparent; color: var(--sidebar-text); }

.nav-icon { width: 18px; height: 18px; flex-shrink: 0; display: inline-flex; align-items: center; }
.nav-icon svg { width: 18px; height: 18px; }
.nav-label { flex: 1; }

/* --- Menu Categories --- */
.nav-category { margin: 1px 8px; }
.nav-category-header {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 12px; border-radius: var(--radius);
    color: var(--sidebar-text); transition: all var(--transition);
    font-size: 0.9rem; cursor: pointer; user-select: none; white-space: nowrap;
}
.nav-category-header:hover { background: var(--sidebar-hover); color: #fff; }
.nav-category.active > .nav-category-header { color: #fff; }

.nav-chevron { margin-left: auto; display: inline-flex; transition: transform var(--transition); }
.nav-chevron svg { width: 14px; height: 14px; }
.nav-category.collapsed .nav-chevron { transform: rotate(-90deg); }

.nav-submenu {
    list-style: none;
    overflow: hidden;
    max-height: 500px;
    transition: max-height 0.3s ease;
}
.nav-category.collapsed .nav-submenu { max-height: 0; }

.nav-submenu .nav-item { margin-left: 12px; }
.nav-submenu .nav-link { font-size: 0.85rem; padding: 7px 12px; }
.nav-submenu .nav-icon { width: 16px; height: 16px; }
.nav-submenu .nav-icon svg { width: 16px; height: 16px; opacity: 0.7; }

/* --- Topbar --- */
.topbar {
    height: var(--topbar-height);
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 24px;
    position: sticky; top: 0; z-index: 50;
}
.has-impersonation .topbar { top: var(--impersonation-height); }
.topbar-left { display: flex; align-items: center; gap: 16px; }
.topbar-title { font-size: 1.1rem; font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 12px; }

.hamburger { display: none; background: none; border: none; cursor: pointer; padding: 4px; }
.hamburger svg { width: 24px; height: 24px; color: var(--text); }

.topbar-user { position: relative; display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 6px 8px; border-radius: var(--radius); transition: background var(--transition); }
.topbar-user:hover { background: var(--bg); }
.user-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 0.9rem; flex-shrink: 0; }
.user-name { font-weight: 500; }
.dropdown-arrow { width: 16px; height: 16px; color: var(--text-muted); transition: transform var(--transition); }

/* Dropdown */
.dropdown-menu {
    position: absolute; top: 100%; right: 0;
    background: var(--card-bg); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow-lg);
    min-width: 200px; padding: 4px 0;
    display: none; z-index: 200;
}
.dropdown-menu.open { display: block; }
.dropdown-item { display: block; padding: 8px 16px; color: var(--text); transition: background var(--transition); }
.dropdown-item:hover { background: var(--bg); text-decoration: none; }
.dropdown-item.disabled { opacity: 0.5; pointer-events: none; }
.dropdown-divider { height: 1px; background: var(--border); margin: 4px 0; }
.dropdown-info { padding: 8px 16px; }

/* --- Cards --- */
.card { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.card-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.card-header h3 { font-size: 1rem; font-weight: 600; }
.card-body { padding: 20px; }
.card-footer { padding: 12px 20px; border-top: 1px solid var(--border); }

/* --- Stats --- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; margin-bottom: 24px; }
.stat-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; display: flex; align-items: center; gap: 16px; box-shadow: var(--shadow); }
.stat-icon { width: 48px; height: 48px; border-radius: var(--radius); display: flex; align-items: center; justify-content: center; }
.stat-icon svg { width: 24px; height: 24px; }
.stat-primary .stat-icon { background: var(--primary-light); color: var(--primary); }
.stat-success .stat-icon { background: var(--success-light); color: var(--success); }
.stat-warning .stat-icon { background: var(--warning-light); color: var(--warning); }
.stat-info .stat-icon { background: var(--info-light); color: var(--info); }
.stat-danger .stat-icon { background: var(--danger-light); color: var(--danger); }
.stat-value { display: block; font-size: 1.5rem; font-weight: 700; line-height: 1.2; }
.stat-label { display: block; color: var(--text-muted); font-size: 0.85rem; }

/* --- Grids --- */
.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

/* --- Page Header --- */
.page-header { margin-bottom: 24px; }
.page-header h1 { font-size: 1.5rem; font-weight: 700; }
.page-header .text-muted { margin-top: 4px; }

/* --- Quick Links --- */
.quick-links { display: flex; flex-direction: column; gap: 8px; }
.quick-link { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius); transition: background var(--transition); color: var(--text); }
.quick-link:hover { background: var(--bg); text-decoration: none; }
.quick-link.disabled { opacity: 0.5; pointer-events: none; }
.quick-link-icon { width: 32px; height: 32px; border-radius: var(--radius); background: var(--primary-light); color: var(--primary); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 1.1rem; }

/* --- Buttons --- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 8px 16px; border: 1px solid transparent; border-radius: var(--radius);
    font-size: 0.85rem; font-weight: 500; cursor: pointer;
    transition: all var(--transition); text-decoration: none; line-height: 1.4;
    font-family: var(--font);
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #0da472; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-outline { background: transparent; border-color: var(--border); color: var(--text); }
.btn-outline:hover { background: var(--bg); }
.btn-sm { padding: 5px 10px; font-size: 0.78rem; }
.btn-lg { padding: 12px 24px; font-size: 1rem; }
.btn-block { width: 100%; }

/* --- Forms --- */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; font-weight: 500; font-size: 0.9rem; }
.form-control {
    width: 100%; padding: 10px 12px;
    border: 1px solid var(--border); border-radius: var(--radius);
    font-size: 0.95rem; font-family: var(--font);
    transition: border-color var(--transition), box-shadow var(--transition);
    background: var(--card-bg); color: var(--text);
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(0,102,204,0.15); }
.form-control.error { border-color: var(--danger); }
select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M6 8L1 3h10z' fill='%236b7280'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }
textarea.form-control { resize: vertical; min-height: 100px; }
.form-hint { font-size: 0.8rem; color: var(--text-muted); margin-top: 4px; }
.form-error { font-size: 0.8rem; color: var(--danger); margin-top: 4px; }
.form-row { display: flex; gap: 16px; }
.form-row .form-group { flex: 1; }

/* --- Tables --- */
.table-wrapper { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 10px 16px; text-align: left; border-bottom: 1px solid var(--border); }
.table th { font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); background: var(--bg); position: sticky; top: 0; }
.table tbody tr { transition: background var(--transition); }
.table tbody tr:hover { background: var(--bg); }

/* --- Badges --- */
.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 12px; font-size: 0.72rem; font-weight: 600; white-space: nowrap; }
.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-success { background: var(--success-light); color: var(--success); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-info { background: var(--info-light); color: var(--info); }
.badge-muted { background: #f3f4f6; color: var(--text-muted); }

/* --- Alerts --- */
.alert { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; font-size: 0.9rem; }
.alert-success { background: var(--success-light); color: #065f46; border: 1px solid #a7f3d0; }
.alert-error { background: var(--danger-light); color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: var(--warning-light); color: #92400e; border: 1px solid #fde68a; }
.alert-info { background: var(--info-light); color: #1e40af; border: 1px solid #bfdbfe; }

/* --- Toast --- */
.toast-container { position: fixed; top: 24px; right: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast {
    pointer-events: auto;
    display: flex; align-items: center; gap: 12px;
    padding: 14px 20px; border-radius: var(--radius);
    background: var(--card-bg); border: 1px solid var(--border);
    box-shadow: var(--shadow-lg); min-width: 300px; max-width: 480px;
    animation: toast-in 0.3s ease;
}
.toast-success { border-left: 4px solid var(--success); }
.toast-error { border-left: 4px solid var(--danger); }
.toast-warning { border-left: 4px solid var(--warning); }
.toast-info { border-left: 4px solid var(--info); }
.toast-content { flex: 1; }
.toast-message { font-size: 0.9rem; }
.toast-close { background: none; border: none; cursor: pointer; font-size: 1.2rem; color: var(--text-muted); padding: 0 4px; }
.toast.removing { animation: toast-out 0.3s ease forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateX(100%); } to { opacity: 1; transform: translateX(0); } }
@keyframes toast-out { from { opacity: 1; transform: translateX(0); } to { opacity: 0; transform: translateX(100%); } }

/* --- Modal --- */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.5);
    display: none; align-items: center; justify-content: center;
    z-index: 1000; padding: 24px;
}
.modal-overlay.open { display: flex; }
.modal {
    background: var(--card-bg); border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg); width: 100%; max-width: 560px; max-height: 90vh;
    display: flex; flex-direction: column; animation: modal-in 0.2s ease;
}
.modal-header { padding: 16px 24px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; }
.modal-header h3 { font-size: 1.1rem; font-weight: 600; margin: 0; }
.modal-header .modal-close { background: none; border: none; cursor: pointer; font-size: 1.5rem; color: var(--text-muted); padding: 0 4px; line-height: 1; }
.modal-header .modal-close:hover { color: var(--text); }
.modal-body { padding: 24px; overflow-y: auto; flex: 1; min-height: 0; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; flex-shrink: 0; }
@keyframes modal-in { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }

/* --- Login --- */
.login-body { background: var(--bg); display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-container { width: 100%; max-width: 400px; padding: 24px; }
.login-card { background: var(--card-bg); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: 40px 32px; }
.login-header { text-align: center; margin-bottom: 32px; }
.login-logo { width: 56px; height: 56px; margin-bottom: 16px; border-radius: var(--radius); }
.login-header h1 { font-size: 1.4rem; font-weight: 700; margin-bottom: 4px; }
.login-form { margin-top: 24px; }
.login-alt { text-align: center; margin-top: 16px; }
.login-footer { text-align: center; margin-top: 24px; font-size: 0.8rem; }

/* --- Error pages --- */
.error-page { text-align: center; padding: 80px 24px; }
.error-page h1 { font-size: 5rem; font-weight: 800; color: var(--primary); margin-bottom: 8px; }
.error-page p { color: var(--text-muted); margin-bottom: 24px; font-size: 1.1rem; }
.error-page-title { font-size: 4rem; margin: 0; color: var(--primary); font-weight: 800; }

/* --- Pagination --- */
.pagination { display: flex; gap: 4px; justify-content: center; margin-top: 8px; }
.pagination-btn, a.pagination-btn {
    padding: 6px 12px; border: 1px solid var(--border); border-radius: var(--radius);
    background: var(--card-bg); cursor: pointer; transition: all var(--transition);
    font-family: var(--font); font-size: 0.85rem; color: var(--text); text-decoration: none;
}
.pagination-btn:hover { background: var(--bg); }
.pagination-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* --- Filter bar --- */
.filter-bar { display: flex; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
.filter-bar .form-control { width: auto; min-width: 180px; padding: 7px 12px; font-size: 0.85rem; }
.filter-bar .form-control:first-child { flex: 1; min-width: 200px; }

/* --- Favorites --- */
.nav-favorite-star { color: #f59e0b; font-size: 0.75rem; margin-left: auto; padding-right: 4px; flex-shrink: 0; line-height: 1; }

.topbar-favorite {
    background: none; border: none; cursor: pointer; padding: 4px;
    display: inline-flex; align-items: center; border-radius: var(--radius-sm);
    transition: all var(--transition); position: relative;
}
.topbar-favorite svg { width: 20px; height: 20px; }
.topbar-favorite .star-filled { display: none; }
.topbar-favorite .star-outline { display: inline-flex; color: var(--text-muted); }
.topbar-favorite:hover .star-outline { color: #f59e0b; }
.topbar-favorite.is-favorite .star-filled { display: inline-flex; }
.topbar-favorite.is-favorite .star-outline { display: none; }
.topbar-favorite:hover { transform: scale(1.15); }
/* --- Topbar Action Buttons (Help, Bug Report) --- */
.topbar-action-btn {
    background: none; border: none; cursor: pointer; padding: 4px;
    display: inline-flex; align-items: center; border-radius: var(--radius-sm);
    transition: all var(--transition); color: var(--text-muted);
}
.topbar-action-btn svg { width: 18px; height: 18px; }
.topbar-action-btn:hover { color: var(--text); transform: scale(1.15); }
#topbar-help-btn:hover { color: var(--primary); }
#topbar-bug-btn:hover { color: var(--danger); }

/* === Debug Bar === */
.debugbar {
    position: fixed; bottom: 0; left: 0; right: 0;
    background: #1e1e2e; color: #cdd6f4;
    font-family: var(--font-mono); font-size: 12px;
    z-index: 10000; box-shadow: 0 -4px 12px rgba(0,0,0,0.3);
    height: 300px; display: flex; flex-direction: column;
}
.debugbar-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 6px 12px; background: #181825;
    border-bottom: 1px solid #313244; flex-shrink: 0;
}
.debugbar-tabs { display: flex; gap: 2px; }
.debugbar-tab {
    background: transparent; border: none; color: #6c7086;
    padding: 4px 10px; cursor: pointer; font-family: var(--font-mono);
    font-size: 11px; border-radius: 4px; transition: all 0.15s;
}
.debugbar-tab:hover { color: #cdd6f4; background: #313244; }
.debugbar-tab.active { color: #89b4fa; background: #313244; }
.debugbar-summary { display: flex; gap: 16px; color: #6c7086; font-size: 11px; }
.debugbar-summary span { display: inline-flex; align-items: center; }
.debugbar-close {
    background: none; border: none; color: #6c7086; cursor: pointer;
    font-size: 18px; padding: 0 6px; transition: color 0.15s;
}
.debugbar-close:hover { color: #f38ba8; }
.debugbar-body { overflow-y: auto; flex: 1; }
.debugbar-panel { display: none; padding: 10px 14px; }
.debugbar-panel.active { display: block; }
.debugbar-table { width: 100%; border-collapse: collapse; }
.debugbar-table th, .debugbar-table td {
    padding: 4px 10px; text-align: left; border-bottom: 1px solid #313244;
    font-size: 11px; vertical-align: top;
}
.debugbar-table th { color: #6c7086; font-weight: 600; }
.debugbar-table td:first-child { color: #89b4fa; white-space: nowrap; font-weight: 500; }
.debugbar-sql { word-break: break-all; color: #a6e3a1; }
.debugbar-pre {
    background: #11111b; padding: 10px; border-radius: 4px;
    overflow-x: auto; color: #cdd6f4; font-size: 11px;
    max-height: 300px; white-space: pre-wrap;
}
.debugbar h4 { color: #89b4fa; margin: 10px 0 6px; font-size: 12px; }

/* --- Utilities --- */
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-primary { color: var(--primary); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-sm { font-size: 0.85rem; }
.font-mono { font-family: var(--font-mono); }
.mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; }
.p-1 { padding: 8px; } .p-2 { padding: 16px; } .p-3 { padding: 24px; }
.d-flex { display: flex; } .align-center { align-items: center; } .justify-between { justify-content: space-between; }
.gap-1 { gap: 8px; } .gap-2 { gap: 16px; }
.hidden { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- Additional Utilities --- */
.card-body-flush { padding: 0; }
.d-inline { display: inline; }
.icon-sm { width: 16px; height: 16px; }
.columns-3 { columns: 3; gap: 20px; }
.truncate-inline { max-width: 200px; display: inline-block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-140 { width: 140px; }
.btn-impersonation-stop { color: #fff; border-color: rgba(255,255,255,.5); margin-left: 12px; }
.btn-impersonation-stop:hover { color: #fff; border-color: rgba(255,255,255,.8); }
/* --- Responsive --- */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-close { display: block; }
    .sidebar-toggle-compact { display: none !important; }
    .hamburger { display: flex; }
    .app-main { margin-left: 0 !important; }
    .app-content { padding: 16px; }
    .topbar { padding: 0 16px; }
    .stats-grid { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
    .stat-card { padding: 14px; }
    .stat-value { font-size: 1.2rem; }
    .form-row { flex-direction: column; gap: 0; }
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .toast-container { left: 16px; right: 16px; top: 16px; }
    .toast { min-width: unset; }
    .user-name { display: none; }
    .debugbar { font-size: 10px; }
    .sidebar-compact .app-main { margin-left: 0 !important; }
}

@media (max-width: 480px) {
    .login-card { padding: 28px 20px; }
}

/* --- Compact Sidebar Flyout --- */
.sidebar-compact .nav-category,
.sidebar-compact .nav-item { position: relative; }

.sidebar-compact .nav-category:hover > .nav-flyout,
.sidebar-compact .nav-item:hover > .nav-flyout { display: block; }

/* Extend hover zone to bridge gap between icon and flyout */
.sidebar-compact .nav-category > .nav-flyout::before,
.sidebar-compact .nav-item > .nav-flyout::before {
    content: '';
    position: absolute;
    left: -20px;
    top: 0;
    width: 20px;
    height: 100%;
}

.nav-flyout {
    display: none;
    position: fixed;
    left: var(--sidebar-compact-width);
    top: auto;
    min-width: 220px;
    background: var(--sidebar-bg);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 0 var(--radius) var(--radius) 0;
    box-shadow: var(--shadow-lg);
    padding: 8px 0;
    z-index: 150;
}
.nav-flyout-title {
    padding: 8px 16px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: rgba(255,255,255,0.4);
    border-bottom: 1px solid rgba(255,255,255,0.08);
    margin-bottom: 4px;
    white-space: nowrap;
}
.nav-flyout .nav-link {
    justify-content: flex-start;
    padding: 8px 16px;
    gap: 10px;
    white-space: nowrap;
}
.nav-flyout .nav-link:hover {
    background: var(--sidebar-hover);
    color: #fff;
}
.nav-flyout .nav-label { display: inline !important; }
.nav-flyout .nav-icon { display: inline-flex; width: 16px; height: 16px; }
.nav-flyout .nav-icon svg { width: 16px; height: 16px; opacity: 0.7; }
.nav-flyout .nav-favorite-star { display: inline !important; }

/* Sidebar footer with version */
.sidebar-footer {
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    padding: 12px 20px;
    border-top: 1px solid rgba(255,255,255,0.08);
    font-size: 0.75rem;
    color: rgba(255,255,255,0.25);
    flex-shrink: 0;
}

/* Form labels (alias) */
.form-label { display: block; margin-bottom: 6px; font-weight: 500; font-size: 0.9rem; }

/* Modal footer button spacing */
.modal-footer .btn { min-width: 100px; }
.modal-footer .btn-outline { border: 1px solid var(--border); background: var(--card-bg); }
.modal-footer .btn-outline:hover { background: var(--bg); border-color: var(--text-muted); }

/* --- Tooltip (lightweight, CSS-only) --- */
[data-tooltip] { position: relative; }
[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: #1a1a2e;
    color: #fff;
    padding: 5px 10px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
    z-index: 9999;
}
[data-tooltip]::before {
    content: '';
    position: absolute;
    bottom: calc(100% + 2px);
    left: 50%;
    transform: translateX(-50%);
    border: 4px solid transparent;
    border-top-color: #1a1a2e;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
    z-index: 9999;
}
[data-tooltip]:hover::after,
[data-tooltip]:hover::before { opacity: 1; }

/* Tooltip position variants */
[data-tooltip-pos=right]::after { bottom: auto; left: calc(100% + 6px); top: 50%; transform: translateY(-50%); }
[data-tooltip-pos=right]::before { bottom: auto; left: calc(100% + 2px); top: 50%; transform: translateY(-50%); border: 4px solid transparent; border-right-color: #1a1a2e; }
[data-tooltip-pos=bottom]::after { bottom: auto; top: calc(100% + 6px); }
[data-tooltip-pos=bottom]::before { bottom: auto; top: calc(100% + 2px); border: 4px solid transparent; border-bottom-color: #1a1a2e; }
[data-tooltip-pos=left]::after { bottom: auto; left: auto; right: calc(100% + 6px); top: 50%; transform: translateY(-50%); }
[data-tooltip-pos=left]::before { bottom: auto; left: auto; right: calc(100% + 2px); top: 50%; transform: translateY(-50%); border: 4px solid transparent; border-left-color: #1a1a2e; }

/* Sort indicators */
.table-sortable th[data-sort] { cursor: pointer; user-select: none; position: relative; padding-right: 24px; }
.table-sortable th[data-sort]:hover { color: var(--text); }
.table-sortable th[data-sort]::after { content: '⇅'; position: absolute; right: 8px; color: var(--border); font-size: 0.7rem; }
.table-sortable th.sort-asc::after { content: '↑'; color: var(--primary); }
.table-sortable th.sort-desc::after { content: '↓'; color: var(--primary); }

/* Pagination info */
.pagination-info { text-align: center; font-size: 0.8rem; color: var(--text-muted); margin-top: 12px; }

