/* Inter font loaded via <link> in layout.html for faster render */

/* ===================== CSS VARIABLES ===================== */
[data-theme="default"], :root {
    --bg-primary: #0a0e17;
    --bg-secondary: #111827;
    --bg-card: #1a1f2e;
    --bg-card-hover: #222838;
    --bg-input: #151b2b;
    --bg-sidebar: #0d1220;
    --border-color: #2a3042;
    --border-light: #333a4f;
    --text-primary: #e8ecf4;
    --text-secondary: #8892a8;
    --text-muted: #5b6478;
    --accent: #00d4aa;
    --accent-hover: #00e8bb;
    --accent-glow: rgba(0, 212, 170, 0.15);
    --accent-glow-strong: rgba(0, 212, 170, 0.3);
    --danger: #ff4757;
    --danger-hover: #ff6b7a;
    --warning: #ffa726;
    --info: #42a5f5;
    --success: #66bb6a;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.5);
    --shadow-glow: 0 0 20px rgba(0, 212, 170, 0.1);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --sidebar-width: 260px;
    --header-height: 64px;
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --bg-input-disabled: #1c2233;
    --border-color-dim: #252b3b;
}

[data-theme="dark-neon"] {
    --bg-primary: #050505;
    --bg-secondary: #0a0a0a;
    --bg-card: #121212;
    --bg-card-hover: #1a1a1a;
    --bg-input: #0f0f0f;
    --bg-sidebar: #080808;
    --border-color: #222222;
    --border-light: #333333;
    --text-primary: #f0f0f0;
    --text-secondary: #a0a0a0;
    --text-muted: #666666;
    --accent: #bb86fc;
    --accent-hover: #d1a8ff;
    --accent-glow: rgba(187, 134, 252, 0.15);
    --accent-glow-strong: rgba(187, 134, 252, 0.3);
    --shadow-glow: 0 0 20px rgba(187, 134, 252, 0.1);
}

[data-theme="light-fresh"] {
    --bg-primary: #f5f7fa;
    --bg-secondary: #eef2f6;
    --bg-card: #ffffff;
    --bg-card-hover: #f9fafb;
    --bg-input: #ffffff;
    --bg-sidebar: #ffffff;
    --border-color: #e2e8f0;
    --border-light: #cbd5e1;
    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --accent: #10b981;
    --accent-hover: #059669;
    --accent-glow: rgba(16, 185, 129, 0.15);
    --accent-glow-strong: rgba(16, 185, 129, 0.3);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.1);
    --shadow-glow: 0 0 20px rgba(16, 185, 129, 0.15);
    --bg-input-disabled: #f1f5f9;
    --border-color-dim: #f1f5f9;
}

[data-theme="navy-gold"] {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-card: #1e293b;
    --bg-card-hover: #26334a;
    --bg-input: #151e32;
    --bg-sidebar: #0b1120;
    --border-color: #334155;
    --border-light: #475569;
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --accent: #f59e0b;
    --accent-hover: #fbbf24;
    --accent-glow: rgba(245, 158, 11, 0.15);
    --accent-glow-strong: rgba(245, 158, 11, 0.3);
    --shadow-glow: 0 0 20px rgba(245, 158, 11, 0.1);
}

[data-theme="monochrome"] {
    --bg-primary: #111111;
    --bg-secondary: #1a1a1a;
    --bg-card: #222222;
    --bg-card-hover: #2a2a2a;
    --bg-input: #181818;
    --bg-sidebar: #0f0f0f;
    --border-color: #333333;
    --border-light: #444444;
    --text-primary: #ffffff;
    --text-secondary: #b3b3b3;
    --text-muted: #808080;
    --accent: #ffffff;
    --accent-hover: #e0e0e0;
    --accent-glow: rgba(255, 255, 255, 0.15);
    --accent-glow-strong: rgba(255, 255, 255, 0.3);
    --shadow-glow: 0 0 20px rgba(255, 255, 255, 0.1);
}

[data-theme="hacker-green"] {
    --bg-primary: #000000;
    --bg-secondary: #050a05;
    --bg-card: #0a140a;
    --bg-card-hover: #101f10;
    --bg-input: #050a05;
    --bg-sidebar: #000000;
    --border-color: #1a331a;
    --border-light: #264d26;
    --text-primary: #33ff33;
    --text-secondary: #24b324;
    --text-muted: #146614;
    --accent: #00ff00;
    --accent-hover: #66ff66;
    --accent-glow: rgba(0, 255, 0, 0.15);
    --accent-glow-strong: rgba(0, 255, 0, 0.3);
    --shadow-glow: 0 0 20px rgba(0, 255, 0, 0.2);
}

[data-theme="cyberpunk"] {
    --bg-primary: #0a0a1a;
    --bg-secondary: #121026;
    --bg-card: #181433;
    --bg-card-hover: #231c4d;
    --bg-input: #141126;
    --bg-sidebar: #080814;
    --border-color: #331f4d;
    --border-light: #4d2e73;
    --text-primary: #f0f0f0;
    --text-secondary: #c2c2d6;
    --text-muted: #8585ad;
    --accent: #ff00ff;
    --accent-hover: #ff66ff;
    --accent-glow: rgba(255, 0, 255, 0.2);
    --accent-glow-strong: rgba(255, 0, 255, 0.4);
    --shadow-glow: 0 0 20px rgba(255, 0, 255, 0.2);
    --warning: #fcee0a;
    --info: #00ffff;
}

[data-theme="ocean-blue"] {
    --bg-primary: #0b132b;
    --bg-secondary: #111e3c;
    --bg-card: #1c2541;
    --bg-card-hover: #233054;
    --bg-input: #141b31;
    --bg-sidebar: #080e1f;
    --border-color: #3a506b;
    --border-light: #507194;
    --text-primary: #ffffff;
    --text-secondary: #aec1d6;
    --text-muted: #6f8ab0;
    --accent: #5bc0be;
    --accent-hover: #8aeceb;
    --accent-glow: rgba(91, 192, 190, 0.15);
    --accent-glow-strong: rgba(91, 192, 190, 0.3);
    --shadow-glow: 0 0 20px rgba(91, 192, 190, 0.1);
}

[data-theme="dracula"] {
    --bg-primary: #282a36;
    --bg-secondary: #303342;
    --bg-card: #383a59;
    --bg-card-hover: #44475a;
    --bg-input: #303247;
    --bg-sidebar: #21222c;
    --border-color: #44475a;
    --border-light: #6272a4;
    --text-primary: #f8f8f2;
    --text-secondary: #bfbfbf;
    --text-muted: #8b92b5;
    --accent: #ff79c6;
    --accent-hover: #ff92df;
    --accent-glow: rgba(255, 121, 198, 0.15);
    --accent-glow-strong: rgba(255, 121, 198, 0.3);
    --shadow-glow: 0 0 20px rgba(255, 121, 198, 0.1);
    --success: #50fa7b;
    --warning: #f1fa8c;
    --danger: #ff5555;
    --info: #8be9fd;
}

[data-theme="sepia"] {
    --bg-primary: #f4ecd8;
    --bg-secondary: #ebe0c6;
    --bg-card: #fdf6e3;
    --bg-card-hover: #ffffff;
    --bg-input: #fdf6e3;
    --bg-sidebar: #f4ecd8;
    --border-color: #d1c5a9;
    --border-light: #bbaa88;
    --text-primary: #433422;
    --text-secondary: #6e5c47;
    --text-muted: #968672;
    --accent: #c44536;
    --accent-hover: #d66456;
    --accent-glow: rgba(196, 69, 54, 0.15);
    --accent-glow-strong: rgba(196, 69, 54, 0.3);
    --shadow-sm: 0 1px 3px rgba(67, 52, 34, 0.05);
    --shadow-md: 0 4px 12px rgba(67, 52, 34, 0.08);
    --shadow-lg: 0 8px 32px rgba(67, 52, 34, 0.1);
    --shadow-glow: 0 0 20px rgba(196, 69, 54, 0.15);
    --bg-input-disabled: #e4d7bd;
    --border-color-dim: #e4d7bd;
}

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

html {
    font-size: 14.5px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-feature-settings: 'tnum' 1, 'cv01' 1, 'cv02' 1, 'ss01' 1;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
    min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* ===================== SCROLLBAR ===================== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ===================== APP LAYOUT ===================== */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* ===================== POS MODE LAYOUT ===================== */
body.pos-mode, 
body.pos-mode .app-container,
body.pos-mode .main-content {
    height: 100vh;
    overflow: hidden;
    min-height: 0;
}
body.pos-mode #pageContent {
    padding: 0 !important;
    height: calc(100vh - var(--header-height));
    overflow: hidden;
    min-height: 0;
}
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
    overflow-y: auto;
}

.sidebar-brand {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-brand .brand-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--accent), #00b894);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    font-weight: 800;
    color: #0a0e17;
    box-shadow: 0 4px 15px rgba(0, 212, 170, 0.3);
}

.sidebar-brand h1 {
    font-size: 1.25rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent), #60dfcd);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
}

.nav-section {
    margin-bottom: 24px;
}

.nav-section-title {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--text-muted);
    padding: 0 12px 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    margin-bottom: 2px;
    font-weight: 500;
    font-size: 0.92rem;
    position: relative;
    user-select: none;
}

.nav-item:hover {
    background: var(--accent-glow);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--accent-glow);
    color: var(--accent);
    font-weight: 600;
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: var(--accent);
    border-radius: 0 3px 3px 0;
}

.nav-item .nav-icon {
    font-size: 1.15rem;
    width: 22px;
    text-align: center;
}

.nav-item .nav-badge {
    margin-left: auto;
    background: var(--danger);
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border-color);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--bg-card);
    border-radius: var(--radius-md);
}

.sidebar-user .user-avatar {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--accent), #00b894);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--bg-primary);
}

.sidebar-user .user-info { flex: 1; }
.sidebar-user .user-info .user-name { font-weight: 600; font-size: 0.85rem; }
.sidebar-user .user-info .user-role { font-size: 0.72rem; color: var(--text-muted); text-transform: capitalize; }

.btn-logout {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    border-radius: 6px;
}
.btn-logout:hover { 
    color: var(--danger);
    background: rgba(255, 71, 87, 0.1);
}

/* ===================== MAIN CONTENT ===================== */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-width: 0;
}

/* ===================== HEADER ===================== */
.header {
    height: var(--header-height);
    background: var(--bg-secondary);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    position: sticky;
    top: 0;
    z-index: 50;
}

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

.header-title {
    font-size: 1.2rem;
    font-weight: 700;
}

.btn-menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.5rem;
    cursor: pointer;
}

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

/* ===================== PAGE CONTENT ===================== */
.page-content {
    flex: 1;
    padding: 20px 24px;
    min-width: 0;
}

/* ===================== CARDS ===================== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    transition: var(--transition);
    position: relative;
    /* overflow: hidden; Removed to allow sticky child headers */
}

.card:hover {
    border-color: var(--border-light);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.card-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
}

/* ===================== KPI CARDS ===================== */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}

.kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 22px;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.kpi-card::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    opacity: 0.07;
    transform: translate(20px, -20px);
}

.kpi-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-glow);
    border-color: var(--accent);
}

.kpi-card.accent::after { background: var(--accent); }
.kpi-card.info::after { background: var(--info); }
.kpi-card.warning::after { background: var(--warning); }
.kpi-card.danger::after { background: var(--danger); }

.kpi-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    margin-bottom: 14px;
}

.kpi-icon.accent { background: var(--accent-glow); color: var(--accent); }
.kpi-icon.info { background: rgba(66, 165, 245, 0.15); color: var(--info); }
.kpi-icon.warning { background: rgba(255, 167, 38, 0.15); color: var(--warning); }
.kpi-icon.danger { background: rgba(255, 71, 87, 0.15); color: var(--danger); }
.kpi-icon.success { background: rgba(102, 187, 106, 0.15); color: var(--success); }

.kpi-value {
    font-size: 1.75rem;
    font-weight: 800;
    line-height: 1.2;
    margin-bottom: 4px;
}

.kpi-label {
    font-size: 0.82rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* ===================== BUTTONS ===================== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: 'Inter', sans-serif;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    user-select: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), #00b894);
    color: var(--bg-primary);
    box-shadow: 0 2px 10px rgba(0, 212, 170, 0.3);
}
.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 20px rgba(0, 212, 170, 0.4);
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}
.btn-secondary:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-light);
}

.btn-danger {
    background: var(--danger);
    color: white;
}
.btn-danger:hover {
    background: var(--danger-hover);
    transform: translateY(-1px);
}

.btn-sm {
    padding: 6px 14px;
    font-size: 0.8rem;
}

.btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}
.btn-icon:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

/* ===================== FORMS ===================== */
.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    color-scheme: dark;
    transition: var(--transition);
    outline: none;
}

.form-control:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-control::placeholder {
    color: var(--text-muted);
}

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 24 24' fill='none' stroke='%238892a8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

/* ===================== TOGGLE SWITCH ===================== */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 38px;
    height: 22px;
    flex-shrink: 0;
}
.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}
.toggle-switch .slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    transition: 0.3s;
    border-radius: 22px;
}
.toggle-switch .slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 2px;
    bottom: 2px;
    background-color: var(--text-muted);
    transition: 0.3s;
    border-radius: 50%;
}
.toggle-switch input:checked + .slider {
    background-color: rgba(0, 212, 170, 0.1);
    border-color: rgba(0, 212, 170, 0.4);
}
.toggle-switch input:checked + .slider:before {
    transform: translateX(16px);
    background-color: var(--accent);
}

/* ===================== TABLES ===================== */
.table-container {
    width: 100%;
    overflow: auto;
    max-height: calc(100vh - 240px); /* Leaves space for header, filters, pagination */
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}
.table-container::-webkit-scrollbar {
    height: 8px;
}
.table-container::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 10px;
}
.table-container::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead {
    background: var(--bg-input);
}

th {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--bg-input);
    padding: 10px 12px;
    text-align: left;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border-color);
}

td {
    padding: 10px 12px;
    font-size: 0.8rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-secondary);
}

tr:hover td {
    background: rgba(0, 212, 170, 0.03);
}

tr:last-child td {
    border-bottom: none;
}

/* Small tables for settings */
.table-sm th {
    padding: 6px 10px;
    font-size: 0.65rem;
}
.table-sm td {
    padding: 6px 10px;
    font-size: 0.75rem;
}


/* Responsive Table Adjustments */
@media (max-width: 1024px) {
    th, td {
        padding: 8px 10px;
        font-size: 0.78rem;
    }
}

@media (max-width: 768px) {
    .table-container {
        border: none;
        border-radius: 0;
        margin: 0 -16px; /* Bleed out on small screens */
        padding: 0 16px;
    }
    
    th, td {
        padding: 8px 10px;
        font-size: 0.78rem;
    }
    
    /* Make the action column a bit more obvious and sticky if requested */
    .sticky-action {
        position: sticky;
        right: 0;
        background: var(--bg-card);
        z-index: 2;
        box-shadow: -4px 0 8px rgba(0,0,0,0.1);
        text-align: center;
    }
    thead th.sticky-action {
        background: var(--bg-input);
    }
}

/* Responsive visibility utilities */
@media (max-width: 768px) {
    .hide-mobile { display: none !important; }
}

@media (max-width: 1024px) {
    .hide-tablet { display: none !important; }
}

/* ===================== BADGES ===================== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.badge-success { background: rgba(102, 187, 106, 0.15); color: var(--success); }
.badge-warning { background: rgba(255, 167, 38, 0.15); color: var(--warning); }
.badge-danger { background: rgba(255, 71, 87, 0.15); color: var(--danger); }
.badge-info { background: rgba(66, 165, 245, 0.15); color: var(--info); }

/* ===================== LOADING OVERLAY ===================== */
.loading-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(10, 14, 23, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    z-index: 10000;
}
.loading-overlay.active { display: flex; }

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(0, 212, 170, 0.1);
    border-top: 4px solid var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 24px;
    box-shadow: 0 0 20px rgba(0, 212, 170, 0.2);
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===================== MODAL ===================== */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}
.modal-overlay.active { display: flex; }

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    width: 95%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalIn 0.3s ease;
    box-shadow: var(--shadow-lg);
    position: relative;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.3rem;
    cursor: pointer;
    padding: 4px;
    transition: var(--transition);
}
.modal-close:hover { color: var(--danger); }

.modal-body {
    padding: 24px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
}

/* ===================== TOAST NOTIFICATIONS ===================== */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 14px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 300px;
    max-width: 450px;
    box-shadow: var(--shadow-lg);
    animation: toastIn 0.4s ease;
    font-size: 0.88rem;
}

.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.warning { border-left: 3px solid var(--warning); }
.toast.info { border-left: 3px solid var(--info); }

@keyframes toastIn {
    from { opacity: 0; transform: translateX(100px); }
    to { opacity: 1; transform: translateX(0); }
}

/* ===================== EMPTY STATE ===================== */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}
.empty-state .empty-icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
    opacity: 0.5;
}
.empty-state p { font-size: 0.92rem; }

/* ===================== SEARCH BAR ===================== */
.search-bar {
    position: relative;
}
.search-bar input {
    padding-left: 40px;
}
.search-bar .search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* ===================== PAGE HEADER ===================== */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 16px;
    width: 100%;
}

.page-header-actions {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
}

/* ===================== GRID UTILITIES ===================== */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }

/* ===================== CHART CONTAINER ===================== */
.chart-container {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 20px;
}

.chart-bar-container {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    height: 180px;
    padding-top: 10px;
}

.chart-bar-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    height: 100%;
    justify-content: flex-end;
}

.chart-bar {
    width: 100%;
    max-width: 40px;
    background: linear-gradient(to top, var(--accent), rgba(0, 212, 170, 0.6));
    border-radius: 4px 4px 0 0;
    min-height: 4px;
    transition: height 0.5s ease;
}

.chart-bar-label {
    font-size: 0.68rem;
    color: var(--text-muted);
    text-align: center;
}

.chart-bar-value {
    font-size: 0.72rem;
    color: var(--text-secondary);
    font-weight: 600;
}

/* ===================== LOADING ===================== */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===================== RESPONSIVE ===================== */
@media (max-width: 1024px) {
    .sidebar { width: 240px; }
    .main-content { margin-left: 240px; }
    .kpi-grid { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-width);
    }
    .sidebar.open {
        transform: translateX(0);
        box-shadow: var(--shadow-lg);
    }
    .main-content {
        margin-left: 0;
    }
    .btn-menu-toggle {
        display: block;
    }
    .header {
        padding: 0 16px;
    }
    .page-content {
        padding: 12px;
    }
    .card {
        padding: 16px;
    }
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }
    .page-header-actions {
        width: 100%;
        justify-content: flex-start;
    }
    .page-header-actions .form-control {
        max-width: none !important;
        flex: 1;
    }
    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .grid-2, .grid-3 {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .kpi-grid {
        grid-template-columns: 1fr;
    }
    .header-right {
        display: none;
    }
    .modal {
        padding: 0;
        border-radius: var(--radius-lg);
    }
    .modal-header, .modal-body, .modal-footer {
        padding: 16px;
    }
    .btn {
        padding: 8px 16px;
        font-size: 0.82rem;
    }
    .page-header h1 {
        font-size: 1.25rem;
    }
}
