:root {
    /* Color Palette - Premium Dark Mode */
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-accent: #1e293b;
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --accent: #6366f1; /* Indigo */
    --accent-glow: rgba(99, 102, 241, 0.25);
    --accent-gradient: linear-gradient(135deg, #6366f1, #4f46e5);
    
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;
    
    --border: rgba(255, 255, 255, 0.08);
    --card-radius: 16px;
    --input-radius: 12px;
    --btn-radius: 12px;
    
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
}

/* Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    overflow-x: hidden;
    padding-bottom: calc(70px + var(--safe-area-bottom)); /* Space for bottom nav */
}

@media (min-width: 1025px) {
    body {
        padding-bottom: 0;
        padding-left: 260px; /* Space for sidebar */
    }
}

@media (max-width: 1024px) {
    body {
        padding-left: 0;
    }
}

/* Typography */
h1, h2, h3, h4 {
    font-family: 'Poppins', sans-serif;
    font-weight: 700;
}

.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-accent { color: var(--accent); }

/* Common Components */

/* Cards */
.card {
    background: var(--bg-secondary);
    border-radius: var(--card-radius);
    padding: 20px;
    border: 1px solid var(--border);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    margin-bottom: 20px;
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.card:active {
    transform: scale(0.98);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border-radius: var(--btn-radius);
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 14px;
    width: 100%;
    outline: none;
}

.btn-primary {
    background: var(--accent-gradient);
    color: white;
    box-shadow: 0 4px 15px var(--accent-glow);
}

.btn-primary:hover {
    box-shadow: 0 6px 20px var(--accent-glow);
    filter: brightness(1.1);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-primary);
}

.btn-outline:hover {
    background: rgba(255, 255, 255, 0.05);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

/* Inputs */
.input-group {
    margin-bottom: 16px;
}

.input-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

input, select, textarea {
    width: 100%;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border);
    border-radius: var(--input-radius);
    padding: 14px;
    color: white;
    font-size: 15px;
    transition: all 0.2s;
}

input:focus, select:focus {
    border-color: var(--accent);
    background: rgba(0, 0, 0, 0.3);
    box-shadow: 0 0 0 4px var(--accent-glow);
}

/* Stats Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

@media (max-width: 600px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

@media (min-width: 601px) {
    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    }
}

.stat-card {
    background: var(--bg-secondary);
    padding: 16px;
    border-radius: var(--card-radius);
    border: 1px solid var(--border);
}

.stat-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 20px;
    font-weight: 700;
    margin-top: 4px;
}

/* Animations */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: translateY(0); }
}

.animate-in {
    animation: fadeInUp 0.4s ease-out backwards;
}

/* Glassmorphism Classes */
.glass {
    background: rgba(30, 41, 59, 0.7);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

/* --- Premium Staff Suite Components --- */

/* Header & User Chip */
.premium-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding: 10px 0;
}

@media (max-width: 600px) {
    .premium-header {
        margin-bottom: 20px;
        padding: 5px 0;
    }
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.05);
    padding: 8px 16px 8px 8px;
    border-radius: 50px;
    border: 1px solid var(--border);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
}

.user-avatar-small {
    width: 40px;
    height: 40px;
    background: var(--accent-gradient);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    box-shadow: 0 0 15px var(--accent-glow);
    font-size: 16px;
    color: white;
}

.user-info-text {
    font-size: 14px;
    font-weight: 800;
}

.online-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 10px;
    font-weight: 800;
    color: var(--success);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-dot {
    width: 6px;
    height: 6px;
    background: var(--success);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--success);
    animation: status-pulse 2s infinite;
}

@keyframes status-pulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.4); opacity: 0.6; }
    100% { transform: scale(1); opacity: 1; }
}

/* Stats Row */
.stats-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

@media (max-width: 480px) {
    .stats-row {
        grid-template-columns: 1fr;
    }
}

.stat-glass {
    background: rgba(30, 41, 59, 0.7);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 16px;
    text-align: left;
    position: relative;
    overflow: hidden;
}

.stat-glass i {
    position: absolute;
    right: 12px;
    top: 12px;
    opacity: 0.15;
    width: 32px;
    height: 32px;
}

.stat-val {
    font-size: 24px;
    font-weight: 800;
    display: block;
}

.stat-lbl {
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: 600;
}

/* Bottom Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: rgba(15, 23, 42, 0.85);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    display: flex;
    padding: 12px 10px calc(12px + var(--safe-area-bottom));
    border-top: 1px solid var(--border);
    z-index: 1000;
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 700;
    text-decoration: none;
    transition: all 0.2s;
}

.nav-item.active {
    color: var(--accent);
}

.nav-item i {
    width: 24px;
    height: 24px;
}

/* Sign Out Button in Bottom Nav */
.nav-logout-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    color: var(--danger);
    font-size: 10px;
    font-weight: 700;
    background: none;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    padding: 0;
    font-family: inherit;
    opacity: 0.75;
}

.nav-logout-btn:hover,
.nav-logout-btn:active {
    opacity: 1;
    color: #ff6b6b;
}

.nav-logout-btn i {
    width: 24px;
    height: 24px;
}

/* Utility Classes */
.icon-20 { width: 20px !important; height: 20px !important; }
.icon-muted { color: var(--text-muted) !important; }
.icon-success { color: var(--success) !important; }
.icon-danger { color: var(--danger) !important; }
.icon-accent { color: var(--accent) !important; }
.icon-info { color: var(--info) !important; }
.flex-center { display: flex !important; align-items: center !important; gap: 8px !important; }
.hidden { display: none !important; }

/* Table Responsiveness */
.table-container {
    width: 100%;
    overflow-x: auto;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.2);
    margin-bottom: 20px;
}

table {
    min-width: 600px; /* Force scroll on small screens */
    width: 100%;
}

/* Form Grids */
.sale-form-grid, .service-form-grid, .expense-form-grid, .gift-form-grid, .finance-form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-bottom: 20px;
}

@media (max-width: 600px) {
    .sale-form-grid, .service-form-grid, .expense-form-grid, .gift-form-grid, .finance-form-grid {
        grid-template-columns: 1fr;
    }
    
    .grid-col-all {
        grid-column: span 1 !important;
    }
}

.grid-col-all {
    grid-column: span 2;
}

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

.show-mobile {
    @media (min-width: 769px) { display: none !important; }
}

/* Admin Sidebar Toggle Support */
.sidebar {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
        z-index: 2000;
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    .sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.5);
        -webkit-backdrop-filter: blur(4px);
        backdrop-filter: blur(4px);
        z-index: 1999;
        display: none;
    }
    
    .sidebar-overlay.active {
        display: block;
    }
}

/* Animations */
.spin { animation: spin-loader 1s infinite linear; }
@keyframes spin-loader { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

.topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.btn-danger-outline {
    color: var(--danger);
    border-color: var(--danger);
    background: rgba(239, 68, 68, 0.05);
    border: 1px solid var(--danger);
}
.btn-danger-outline:hover {
    background: rgba(239, 68, 68, 0.1);
}
