:root {
    --primary: #3498DB;
    --primary-dark: #2980B9;
    --primary-light: #5DADE2;
    --primary-50: rgba(52, 152, 219, 0.08);
    --primary-100: rgba(52, 152, 219, 0.15);
    --primary-glow: rgba(52, 152, 219, 0.25);

    --secondary: #2ECC71;
    --secondary-dark: #27AE60;

    --tertiary: #7D66D1;

    --bg-body: #F0F4F8;
    --bg-white: #FFFFFF;
    --bg-card: #FFFFFF;
    --bg-sidebar: #1B2A4A;
    --bg-sidebar-hover: rgba(255, 255, 255, 0.08);
    --bg-sidebar-active: rgba(52, 152, 219, 0.2);

    --border: #E2E8F0;
    --border-light: #EDF2F7;

    --text-dark: #1A202C;
    --text-body: #2D3748;
    --text-secondary: #718096;
    --text-muted: #A0AEC0;
    --text-sidebar: #CBD5E0;
    --text-sidebar-active: #FFFFFF;

    --danger: #E74C3C;
    --danger-light: rgba(231, 76, 60, 0.1);
    --warning: #F39C12;
    --warning-light: rgba(243, 156, 18, 0.1);
    --info: #3498DB;
    --info-light: rgba(52, 152, 219, 0.1);
    --success: #2ECC71;
    --success-light: rgba(46, 204, 113, 0.1);

    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.05), 0 2px 4px rgba(0, 0, 0, 0.03);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.08), 0 4px 10px rgba(0, 0, 0, 0.04);
    --shadow-xl: 0 20px 50px rgba(0, 0, 0, 0.1);

    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-body);
    color: var(--text-body);
    min-height: 100vh;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

/* ===== AUTH LAYOUT ===== */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: url('/assets/img/fundobk.jpg') center/cover no-repeat fixed;
    position: relative;
    overflow: hidden;
}

.auth-wrapper::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(10, 15, 30, 0.55);
    z-index: 0;
}

.auth-wrapper::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at 30% 50%, rgba(52, 152, 219, 0.12) 0%, transparent 60%);
    z-index: 0;
}

.auth-card {
    width: 100%;
    max-width: 440px;
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: var(--radius-xl);
    padding: 2.5rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.1);
    animation: fadeInUp 0.6s ease-out;
    position: relative;
    z-index: 1;
}

.auth-card .logo {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-card .logo h1 {
    font-size: 1.75rem;
    font-weight: 800;
    color: #FFFFFF;
    letter-spacing: -0.02em;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.auth-card .logo p {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

/* Glass form overrides */
.auth-card .form-group label {
    color: rgba(255, 255, 255, 0.85);
}

.auth-card .form-control {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #FFFFFF;
}

.auth-card .form-control::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.auth-card .form-control:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.3);
    background: rgba(255, 255, 255, 0.15);
}

.auth-card .text-sm {
    color: rgba(255, 255, 255, 0.6);
}

.auth-card a.text-link {
    color: var(--primary-light);
}

.auth-card a.text-link:hover {
    color: #FFFFFF;
}

/* ===== FORMS ===== */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-body);
    margin-bottom: 0.5rem;
}

.form-control {
    width: 100%;
    padding: 0.7rem 1rem;
    background: var(--bg-body);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-dark);
    font-size: 0.95rem;
    font-family: inherit;
    transition: var(--transition);
    outline: none;
}

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

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

textarea.form-control {
    resize: vertical;
    min-height: 100px;
}

select.form-control {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23718096' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    padding-right: 2.5rem;
}

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.7rem 1.5rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
    line-height: 1.4;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    box-shadow: 0 2px 8px var(--primary-glow);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px var(--primary-glow);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--bg-body);
    border: 1.5px solid var(--border);
    color: var(--text-body);
}

.btn-secondary:hover {
    background: var(--border-light);
    border-color: var(--text-muted);
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger), #C0392B);
    color: white;
}

.btn-success {
    background: linear-gradient(135deg, var(--secondary), var(--secondary-dark));
    color: white;
}

.btn-sm { padding: 0.45rem 0.9rem; font-size: 0.8rem; }
.btn-lg { padding: 0.85rem 2rem; font-size: 1rem; }
.btn-block { width: 100%; }

/* ===== ALERTS / FLASH ===== */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1.25rem;
    font-size: 0.9rem;
    border-left: 4px solid transparent;
    animation: fadeInDown 0.3s ease-out;
}

.alert-success {
    background: var(--success-light);
    border-left-color: var(--secondary);
    color: var(--secondary-dark);
}

.alert-error {
    background: var(--danger-light);
    border-left-color: var(--danger);
    color: var(--danger);
}

.alert-warning {
    background: var(--warning-light);
    border-left-color: var(--warning);
    color: #B7791F;
}

.alert-info {
    background: var(--info-light);
    border-left-color: var(--info);
    color: var(--primary-dark);
}

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

/* Sidebar */
.sidebar {
    width: 260px;
    background: linear-gradient(180deg, #1B2A4A 0%, #1E3A5F 100%);
    padding: 1.5rem 0;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 100;
    transition: var(--transition-slow);
    box-shadow: 2px 0 20px rgba(0, 0, 0, 0.1);
}

.sidebar-brand {
    padding: 0.5rem 1.5rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    margin-bottom: 0.75rem;
}

.sidebar-brand h2 {
    font-size: 1.15rem;
    font-weight: 700;
    color: #FFFFFF;
    letter-spacing: -0.01em;
}

.sidebar-brand small {
    color: rgba(255, 255, 255, 0.4);
    font-size: 0.75rem;
}

.sidebar-nav {
    flex: 1;
    padding: 0.25rem 0;
    overflow-y: auto;
}

.sidebar-nav .nav-section {
    padding: 1rem 1.5rem 0.5rem;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(255, 255, 255, 0.3);
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 1.5rem;
    color: var(--text-sidebar);
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 500;
    transition: var(--transition);
    border-left: 3px solid transparent;
    margin: 1px 0;
}

.sidebar-nav a:hover {
    color: #FFFFFF;
    background: var(--bg-sidebar-hover);
}

.sidebar-nav a.active {
    color: #FFFFFF;
    background: var(--bg-sidebar-active);
    border-left-color: var(--primary-light);
    font-weight: 600;
}

.sidebar-nav a .icon {
    width: 20px;
    text-align: center;
    font-size: 1rem;
}

.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-footer .user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

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

.sidebar-footer .user-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: #FFFFFF;
}

.sidebar-footer .user-role {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.4);
}

.sidebar-footer .btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: var(--text-sidebar);
    font-size: 0.8rem;
}

.sidebar-footer .btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #FFFFFF;
}

/* Main content */
.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 2rem 2.5rem;
    min-height: 100vh;
}

.page-header {
    margin-bottom: 1.75rem;
}

.page-header h1 {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-dark);
    letter-spacing: -0.02em;
}

.page-header p {
    color: var(--text-secondary);
    margin-top: 0.25rem;
    font-size: 0.9rem;
}

/* ===== CARDS ===== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-light);
}

.card-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-dark);
}

/* Stats Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.stat-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    border-radius: 0 4px 4px 0;
}

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

.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}

.stat-card .stat-icon.green  { background: var(--success-light); color: var(--secondary); }
.stat-card .stat-icon.blue   { background: var(--info-light);    color: var(--primary); }
.stat-card .stat-icon.yellow { background: var(--warning-light); color: var(--warning); }
.stat-card .stat-icon.red    { background: var(--danger-light);  color: var(--danger); }
.stat-card .stat-icon.purple { background: rgba(125, 102, 209, 0.1); color: var(--tertiary); }

.stat-card:nth-child(1)::after { background: var(--primary); }
.stat-card:nth-child(2)::after { background: var(--secondary); }
.stat-card:nth-child(3)::after { background: var(--warning); }
.stat-card:nth-child(4)::after { background: var(--tertiary); }

.stat-info .stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.2;
    color: var(--text-dark);
}

.stat-info .stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ===== TABLES ===== */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius);
}

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

table th,
table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.9rem;
}

table th {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--bg-body);
}

table tbody tr {
    transition: var(--transition);
}

table tbody tr:hover {
    background: var(--primary-50);
}

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

/* ===== BADGES ===== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.65rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-success { background: var(--success-light); color: var(--secondary-dark); }
.badge-danger  { background: var(--danger-light);  color: var(--danger); }
.badge-warning { background: var(--warning-light); color: #B7791F; }
.badge-info    { background: var(--info-light);    color: var(--primary-dark); }
.badge-purple  { background: rgba(125,102,209,0.1); color: var(--tertiary); }

/* ===== GRID HELPERS ===== */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.25rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.25rem; }

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

@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-10px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

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

.animate-fade-in { animation: fadeInUp 0.5s ease-out; }
.animate-pulse { animation: pulse 2s infinite; }

/* ===== TEXT LINK ===== */
a.text-link {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
}

a.text-link:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

/* ===== UTILS ===== */
.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-muted  { color: var(--text-muted); }
.text-sm     { font-size: 0.85rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.gap-1 { gap: 0.5rem; }
.d-flex { display: flex; }
.justify-between { justify-content: space-between; }
.align-center { align-items: center; }

code {
    background: var(--bg-body);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-size: 0.85em;
    color: var(--primary-dark);
    border: 1px solid var(--border);
}

/* ===== QR CODE ===== */
.qr-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2rem;
    gap: 1rem;
}

.qr-container img {
    max-width: 280px;
    border-radius: var(--radius);
    border: 2px solid var(--border);
    box-shadow: var(--shadow-md);
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 0.5rem;
}

.status-dot.connected    { background: var(--success); box-shadow: 0 0 8px rgba(46, 204, 113, 0.4); }
.status-dot.disconnected { background: var(--danger); }
.status-dot.connecting   { background: var(--warning); animation: pulse 1.5s infinite; }

/* ===== EMPTY STATE ===== */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

.empty-state .icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.4;
}

.empty-state h3 {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0;
        padding: 1.25rem;
    }
    .stats-grid {
        grid-template-columns: 1fr;
    }
    .grid-2, .grid-3 {
        grid-template-columns: 1fr;
    }
    .auth-card {
        padding: 1.5rem;
    }
}

/* ===== MOBILE TOGGLE ===== */
.mobile-toggle {
    display: none;
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 200;
    background: var(--bg-white);
    border: 1px solid var(--border);
    color: var(--text-dark);
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    box-shadow: var(--shadow-md);
}

@media (max-width: 768px) {
    .mobile-toggle { display: flex; }
}
