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

html, body {
    height: 100%;
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 16px;
    color: #020817;
    background: #f8fafc;
    -webkit-font-smoothing: antialiased;
}

/* ===== App Layout ===== */
.app-layout {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ===== Sidebar ===== */
.sidebar {
    width: 16rem;
    min-width: 16rem;
    background: #ffffff;
    border-right: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.sidebar-brand {
    padding: 24px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid #e2e8f0;
}

.brand-icon {
    font-size: 20px;
    color: #7525f9;
}

.brand-text {
    font-size: 18px;
    font-weight: 700;
    color: #020817;
    letter-spacing: 0.3px;
}

.sidebar-nav {
    padding: 12px 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: #3f3f46;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.15s ease;
    border-left: 3px solid transparent;
}

.nav-link:hover {
    color: #020817;
    background: #f1f5f9;
}

.nav-link.active {
    color: #7525f9;
    background: #ebe5fd;
    border-left-color: #7525f9;
    font-weight: 600;
}

.nav-icon {
    font-size: 8px;
    color: #64748b;
    opacity: 0.7;
}

.nav-link.active .nav-icon {
    opacity: 1;
    color: #7525f9;
}

/* ===== Main Content ===== */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.top-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 32px;
    background: #ffffff;
    border-bottom: 1px solid #e2e8f0;
    min-height: 64px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.page-title {
    font-size: 20px;
    font-weight: 700;
    color: #6b21a8;
}

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

.user-name {
    font-size: 14px;
    color: #64748b;
    font-weight: 500;
}

.logout-btn {
    font-size: 14px;
    color: #64748b;
    text-decoration: none;
    padding: 6px 14px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-weight: 500;
    transition: all 0.15s ease;
    background: #ffffff;
}

.logout-btn:hover {
    color: #dc2626;
    border-color: #dc2626;
    background: #fef2f2;
}

.content-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px 32px;
}

/* ===== Date Picker ===== */
.date-picker {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
    background: #ffffff;
    padding: 14px 20px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.date-presets {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.preset-btn {
    padding: 6px 14px;
    border: 1px solid #e2e8f0;
    background: #ffffff;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    color: #64748b;
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: 'Inter', system-ui, sans-serif;
}

.preset-btn:hover {
    background: #f1f5f9;
    color: #020817;
    border-color: #cbd5e1;
}

.preset-btn.active {
    background: #8000ff;
    color: #ffffff;
    border-color: #8000ff;
    font-weight: 600;
}

.date-custom {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
}

.date-custom label {
    font-size: 12px;
    font-weight: 500;
    color: #64748b;
    display: flex;
    align-items: center;
    gap: 6px;
}

.date-custom input[type="date"] {
    padding: 6px 10px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 14px;
    font-family: 'Inter', system-ui, sans-serif;
    color: #020817;
    background: #ffffff;
    transition: border-color 0.15s ease;
}

.date-custom input[type="date"]:focus {
    outline: none;
    border-color: #8000ff;
    box-shadow: 0 0 0 3px rgba(128, 0, 255, 0.1);
}

.apply-btn {
    padding: 6px 18px;
    background: #8000ff;
    color: #ffffff;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease;
    font-family: 'Inter', system-ui, sans-serif;
}

.apply-btn:hover {
    background: #5b1cc7;
}

/* ===== Metric Cards ===== */
.metric-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.metric-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 20px 24px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.metric-label {
    font-size: 12px;
    font-weight: 500;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.metric-value {
    font-size: 24px;
    font-weight: 700;
    color: #020817;
}

/* ===== Chart ===== */
.chart-container {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 24px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.chart-box {
    width: 100%;
    height: 350px;
}

/* ===== Data Table ===== */
.table-wrapper,
.data-table-container {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    overflow: auto;
    max-height: 600px;
    position: relative;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.data-table thead {
    position: sticky;
    top: 0;
    z-index: 10;
}

.data-table thead th {
    background: #6b21a8;
    color: #ffffff;
    padding: 12px 16px;
    text-align: right;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    white-space: nowrap;
    user-select: none;
    border-bottom: 2px solid #7525f9;
}

.data-table thead th:first-child {
    text-align: left;
}

.data-table thead th:hover {
    background: #7525f9;
}

.sort-arrow {
    font-size: 10px;
    margin-left: 4px;
    opacity: 0.6;
}

.sort-arrow.asc::after { content: " \25B2"; }
.sort-arrow.desc::after { content: " \25BC"; }

.data-table tbody td {
    padding: 10px 16px;
    text-align: right;
    border-bottom: 1px solid #f1f5f9;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    color: #020817;
}

.data-table tbody td:first-child {
    text-align: left;
    font-weight: 500;
    color: #020817;
}

.data-table tbody tr:hover td {
    background: #f8fafc;
}

.data-table tfoot {
    position: sticky;
    bottom: 0;
    z-index: 10;
}

.data-table tfoot td {
    background: #f1f5f9;
    padding: 12px 16px;
    text-align: right;
    font-weight: 700;
    font-size: 14px;
    border-top: 2px solid #e2e8f0;
    white-space: nowrap;
    color: #020817;
}

.data-table tfoot td:first-child {
    text-align: left;
}

/* ===== Login Page ===== */
.login-page {
    background: #f8fafc;
}

.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.login-card {
    background: #ffffff;
    padding: 40px;
    border-radius: 8px;
    width: 100%;
    max-width: 400px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 24px;
}

.login-brand .brand-icon {
    color: #7525f9;
}

.login-brand .brand-text {
    color: #020817;
}

.login-card h2 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 24px;
    color: #6b21a8;
}

.login-error {
    background: #fef2f2;
    color: #dc2626;
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 14px;
    margin-bottom: 16px;
    border: 1px solid #fee2e2;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: #64748b;
    margin-bottom: 6px;
}

.form-group input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 14px;
    font-family: 'Inter', system-ui, sans-serif;
    color: #020817;
    background: #ffffff;
    transition: border-color 0.15s ease;
}

.form-group input:focus {
    outline: none;
    border-color: #8000ff;
    box-shadow: 0 0 0 3px rgba(128, 0, 255, 0.1);
}

.login-submit {
    width: 100%;
    padding: 12px;
    background: #8000ff;
    color: #ffffff;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    font-family: 'Inter', system-ui, sans-serif;
    transition: background 0.2s ease;
    margin-top: 8px;
}

.login-submit:hover {
    background: #5b1cc7;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .sidebar {
        display: none;
    }

    .content-body {
        padding: 16px;
    }

    .top-header {
        padding: 12px 16px;
    }

    .date-picker {
        flex-direction: column;
        align-items: stretch;
    }

    .date-custom {
        margin-left: 0;
        flex-wrap: wrap;
    }

    .metric-cards {
        grid-template-columns: 1fr;
    }

    .table-wrapper,
    .data-table-container {
        max-height: 400px;
    }
}
