:root {
    --bg-color: #0f1214;
    --sidebar-bg: #1A1F24;
    --card-bg: #22292F;
    --input-bg: #1A1F24;
    --accent: #0A8FDC;
    --accent-glow: rgba(10, 143, 220, 0.4);
    --text-primary: #ffffff;
    --text-secondary: #9ca3af;
    --border: rgba(255, 255, 255, 0.08);
    --radius: 16px;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
    --success: #10b981;
    --danger: #ef4444;
}

body {
    background-color: var(--bg-color);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    color: var(--text-primary);
    display: flex;
    height: 100vh;
    overflow: hidden;
    font-family: 'Be Vietnam Pro', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Be Vietnam Pro', sans-serif;
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.card,
.tab-content.active {
    animation: fadeInUp 0.4s ease-out;
}

/* Tab Logic */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Sidebar Styling */
.sidebar {
    width: 260px;
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    padding: 30px 20px;
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.1);
    z-index: 10;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 40px;
    color: white;
    display: flex;
    align-items: center;
}

.sidebar-logo {
    width: 40px;
    height: 40px;
    margin-right: 12px;
    object-fit: contain;
}

.nav-item {
    padding: 14px 18px;
    margin-bottom: 8px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: var(--text-secondary);
    font-weight: 500;
    border: 1px solid transparent;
}

.nav-item:hover {
    color: white;
    background-color: rgba(255, 255, 255, 0.03);
}

.nav-item.active {
    background-color: rgba(10, 143, 220, 0.15);
    color: var(--accent);
    border-color: rgba(10, 143, 220, 0.2);
    box-shadow: 0 4px 12px rgba(10, 143, 220, 0.1);
}

/* Main Content */
.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 40px;
    position: relative;
    padding-bottom: 100px;
    /* Space for mobile nav */
}

header {
    margin-bottom: 30px;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}

header h1 {
    font-size: 2rem;
    margin-bottom: 8px;
    font-weight: 700;
    background: linear-gradient(90deg, #fff, #b8c2cc);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

header p {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* Cards */
.card {
    background-color: var(--card-bg);
    border-radius: var(--radius);
    padding: 30px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    margin-bottom: 24px;
    position: relative;
    overflow: hidden;
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
}

/* Forms */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 24px;
    margin-bottom: 30px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
    margin-left: 2px;
}

input,
select {
    background-color: var(--input-bg);
    border: 1px solid var(--border);
    color: white;
    padding: 14px 16px;
    border-radius: 12px;
    outline: none;
    transition: all 0.2s;
    font-size: 0.95rem;
}

input:focus,
select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(10, 143, 220, 0.1);
}

select {
    cursor: pointer;
    background-repeat: no-repeat;
    background-position: right 16px center;
    padding-right: 40px;
}

/* Buttons */
.btn-primary {
    background: linear-gradient(135deg, #0A8FDC, #0077b6);
    color: white;
    border: none;
    padding: 14px 32px;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(10, 143, 220, 0.3);
    font-size: 1rem;
    letter-spacing: 0.3px;
}

.btn-primary:hover {
    box-shadow: 0 6px 16px rgba(10, 143, 220, 0.4);
    transform: translateY(-1px);
}

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

/* KPI Cards */
.kp-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.kpi {
    padding: 24px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    background: linear-gradient(145deg, #22292F, #1F2529);
}

.kpi-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.kpi-value {
    font-size: 2rem;
    font-weight: 700;
    color: white;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

/* Tables */
.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.data-table th {
    text-align: left;
    padding: 16px;
    border-bottom: 2px solid var(--border);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.data-table td {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    color: #e5e7eb;
    font-size: 0.95rem;
}

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

.data-table tr:hover td {
    background-color: rgba(255, 255, 255, 0.02);
}

/* Badges */
.badge {
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

.badge-success {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
}

.badge-danger {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
}

.badge-neutral {
    background: rgba(255, 255, 255, 0.08);
    color: #9ca3af;
}

/* Analytics */
.filter-bar {
    display: flex;
    gap: 12px;
    align-items: center;
}

.analytics-row {
    margin-bottom: 24px;
}

.full-width {
    width: 100%;
}

.chart-container {
    position: relative;
    /* Essential for Chart.js responsiveness */
    height: 350px;
    margin-top: 10px;
    width: 100%;
    max-width: 100%;
}

/* Login Screen */
#login-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    /* background: radial-gradient(circle at center, #1F2527 0%, #000 100%); */
    background: rgba(0, 0, 0, 0.4);
    /* Semi-transparent overlay */
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.login-card {
    width: 90%;
    max-width: 420px;
    background: rgba(30, 35, 40, 0.7);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 50px;
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    text-align: center;
}

.login-logo {
    width: 90px;
    height: 90px;
    margin-bottom: 30px;
    border-radius: 20px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.login-card h2 {
    color: white;
    font-weight: 700;
    margin-bottom: 30px;
    font-size: 1.6rem;
}

.logout-btn {
    position: absolute;
    bottom: 25px;
    left: 20px;
    padding: 10px 18px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.logout-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: white;
}

body.logged-out .sidebar,
body.logged-out .main-content,
body.logged-out .mobile-header,
body.logged-out .mobile-nav {
    display: none !important;
}

/* Mobile Header & Nav */
.mobile-header {
    display: none;
    padding: 15px;
    background: var(--sidebar-bg);
    border-bottom: 1px solid var(--border);
    text-align: center;
    font-weight: 700;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
}

.mobile-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--sidebar-bg);
    border-top: 1px solid var(--border);
    padding: 10px;
    z-index: 100;
    justify-content: space-around;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    color: var(--text-secondary);
    font-size: 0.75rem;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
}

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

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

@media (max-width: 768px) {
    body {
        flex-direction: column;
        overflow-y: auto;
    }

    .sidebar {
        display: none !important;
    }

    .main-content {
        padding: 20px;
        padding-top: 70px;
        /* Space for mobile header */
        padding-bottom: 90px;
    }

    .mobile-header {
        display: block;
    }

    .mobile-nav {
        display: flex;
    }

    header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .filter-bar {
        width: 100%;
        overflow-x: auto;
    }
}
/* Hide spin buttons for number inputs */
input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type=number] {
  -moz-appearance: textfield;
}

/* Responsive Table Wrapper */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Mobile Card View for Tables */
@media (max-width: 768px) {
    .data-table thead {
        display: none;
    }

    .data-table, .data-table tbody, .data-table tr, .data-table td {
        display: block;
        width: 100%;
        box-sizing: border-box; /* Fix width issues */
    }

    .data-table tr {
        margin-bottom: 20px;
        background: rgba(255, 255, 255, 0.03);
        border: 1px solid var(--border);
        border-radius: 12px;
        padding: 16px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    }

    .data-table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        text-align: right;
        padding: 10px 0;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    }
    
    .data-table td:last-child {
        border-bottom: none;
    }

    .data-table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-secondary);
        text-transform: uppercase;
        font-size: 0.85rem;
        text-align: left;
    }
}
