/* ============================================================
   ALT/FINANCE Dashboard — styles.css
   Brand Kit aligned (2026-05)
   ============================================================ */

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

:root {
    /* Core Brand */
    --alt-blue:      #0049FF;
    --alt-blue-hover:#003ad9;
    --alt-navy:      #211f54;
    --alt-midnight:  #000043;
    --alt-teal:      #00d4aa;
    --alt-purple:    #4a3aff;
    --alt-soft-blue: #4d7fff;
    --alt-gold:      #f5a623;

    /* Semantic */
    --success:  #10b981;
    --warning:  #f59e0b;
    --error:    #ef4444;

    /* Light Theme */
    --bg-page:       #ffffff;
    --bg-section:    #f8f9fb;
    --bg-card:       #ffffff;
    --bg-code:       #f1f3f7;
    --text-primary:  #1a1a2e;
    --text-secondary:#5a5a7a;
    --text-muted:    #8a8aaa;
    --border:        #e2e4ea;
    --border-light:  #eef0f4;
    --shadow-sm:     0 1px 3px rgba(0,0,0,0.06);
    --shadow-md:     0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg:     0 8px 30px rgba(0,0,0,0.1);

    /* Typography */
    --font-body:    'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-heading: 'Manrope', 'Inter', sans-serif;

    /* Geometry */
    --radius:    8px;
    --radius-lg: 12px;
    --transition: 0.2s ease;
}

html { font-size: 14px; }
body {
    font-family: var(--font-body);
    background: var(--bg-section);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

::selection { background: var(--alt-blue); color: #fff; }

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

/* ============================================================
   AUTH SCREEN
   ============================================================ */
.auth-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--alt-navy);
    position: relative;
    overflow: hidden;
}
.auth-screen::before {
    content: '';
    position: absolute;
    top: -300px; left: 50%;
    transform: translateX(-50%);
    width: 900px; height: 900px;
    background: radial-gradient(circle, rgba(0,73,255,0.15) 0%, transparent 70%);
    pointer-events: none;
}

.auth-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    padding: 48px 40px;
    width: 400px;
    max-width: 90vw;
    box-shadow: var(--shadow-lg);
    text-align: center;
    position: relative;
    z-index: 1;
}

.auth-logo { margin-bottom: 32px; }

.logo-circle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border-radius: 14px;
    background: var(--alt-blue);
    color: #fff;
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: 20px;
    letter-spacing: 1px;
    margin-bottom: 12px;
}

.auth-title {
    font-family: var(--font-heading);
    font-size: 28px;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: 1px;
}
.auth-title .slash { color: var(--alt-blue); }

.auth-subtitle {
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 1px;
    margin-top: 4px;
}

.auth-form { text-align: left; }

.auth-label {
    display: block;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.auth-input {
    width: 100%;
    padding: 12px 16px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font-body);
    font-size: 14px;
    background: var(--bg-card);
    color: var(--text-primary);
    transition: border-color var(--transition);
    outline: none;
}
.auth-input:focus {
    border-color: var(--alt-blue);
    box-shadow: 0 0 0 3px rgba(0,73,255,0.12);
}
.auth-input::placeholder { color: var(--text-muted); }

.auth-error {
    color: var(--error);
    font-size: 13px;
    margin-top: 8px;
}

.auth-button {
    width: 100%;
    margin-top: 16px;
    padding: 12px;
    background: var(--alt-blue);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition);
}
.auth-button:hover { background: var(--alt-blue-hover); }
.auth-button:disabled { opacity: 0.6; cursor: not-allowed; }

.auth-footer {
    margin-top: 24px;
    font-size: 12px;
    color: var(--text-muted);
}

/* ============================================================
   DASHBOARD LAYOUT
   ============================================================ */
.dashboard {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ---- HEADER ---- */
.header {
    display: flex;
    align-items: center;
    gap: 20px;
    background: var(--alt-navy);
    padding: 0 24px;
    height: 60px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.logo-circle--small {
    width: 34px;
    height: 34px;
    font-size: 13px;
    border-radius: 10px;
}

.header-titles { line-height: 1.2; }

.header-title {
    font-family: var(--font-heading);
    font-size: 18px;
    font-weight: 800;
    color: #ffffff;
    letter-spacing: 1px;
}
.header-title .slash { color: var(--alt-blue); }

.header-subtitle {
    font-size: 10px;
    color: rgba(255,255,255,0.45);
    font-weight: 500;
    letter-spacing: 0.8px;
}

.category-tabs {
    display: flex;
    gap: 4px;
    margin-left: auto;
}

.cat-tab {
    padding: 8px 18px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: rgba(255,255,255,0.55);
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}
.cat-tab:hover { color: #ffffff; background: rgba(255,255,255,0.08); }
.cat-tab.active {
    background: var(--alt-blue);
    color: #ffffff;
}

.header-right-group {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: 16px;
    flex-shrink: 0;
}
.user-email {
    font-size: 0.78rem;
    color: rgba(255,255,255,0.55);
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.logout-btn {
    background: none;
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 6px;
    color: rgba(255,255,255,0.55);
    padding: 6px 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: all var(--transition);
}
.logout-btn:hover { color: #ffffff; border-color: rgba(255,255,255,0.35); }

/* ---- SUB-HEADER ---- */
.subheader {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-card);
    padding: 0 24px;
    height: 48px;
    border-bottom: 1px solid var(--border-light);
}

.page-tabs { display: flex; gap: 2px; }

.page-tab {
    padding: 6px 16px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-muted);
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}
.page-tab:hover { color: var(--text-primary); background: var(--bg-section); }
.page-tab.active { color: var(--alt-blue); background: rgba(0,73,255,0.06); }

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

.filter-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

.filter-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filter-select {
    padding: 5px 28px 5px 10px;
    border: 1.5px solid var(--border);
    border-radius: 6px;
    font-family: var(--font-body);
    font-size: 13px;
    color: var(--text-primary);
    background: var(--bg-card);
    cursor: pointer;
    outline: none;
    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='%238a8aaa' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
}
.filter-select:focus { border-color: var(--alt-blue); }

/* ---- LOADING BAR ---- */
.loading-bar {
    padding: 6px 24px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    gap: 12px;
}

.loading-bar-track {
    flex: 1;
    height: 4px;
    background: var(--bg-section);
    border-radius: 2px;
    overflow: hidden;
}

.loading-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--alt-blue), var(--alt-teal));
    border-radius: 2px;
    width: 0%;
    transition: width 0.3s ease;
}

.loading-text {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    min-width: 180px;
}

/* ---- ERROR BANNER ---- */
.error-banner {
    padding: 10px 24px;
    background: rgba(239,68,68,0.06);
    border-bottom: 1px solid rgba(239,68,68,0.15);
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--error);
    font-size: 13px;
    font-weight: 500;
}

.retry-btn {
    padding: 4px 14px;
    border: 1.5px solid var(--error);
    border-radius: 6px;
    background: transparent;
    color: var(--error);
    font-family: var(--font-body);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}
.retry-btn:hover { background: var(--error); color: #fff; }

.dismiss-btn {
    margin-left: auto;
    background: none;
    border: none;
    color: var(--error);
    font-size: 18px;
    cursor: pointer;
    padding: 0 4px;
}

/* ---- MAIN CONTENT ---- */
.main-content {
    flex: 1;
    padding: 20px 24px;
    overflow-y: auto;
}

.page { display: none; animation: fadeIn 0.25s ease; }
.page.active { display: block; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ---- EMPTY STATE ---- */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 24px;
    color: var(--text-muted);
    font-size: 15px;
    gap: 16px;
}

/* ============================================================
   OVERVIEW PAGE
   ============================================================ */
.overview-layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 20px;
    min-height: 0;
}

/* ---- KPI SIDEBAR ---- */
.kpi-sidebar {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.kpi-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 20px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    border-left: 4px solid var(--alt-blue);
}

.kpi-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--alt-blue);
    margin-bottom: 6px;
}

.kpi-value {
    font-family: var(--font-heading);
    font-size: 28px;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}

.kpi-sply {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
}

.kpi-sply-label {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 0.5px;
}

.kpi-sply-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}

.kpi-badge {
    display: inline-flex;
    align-items: center;
    margin-top: 8px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    width: fit-content;
}
.kpi-badge.positive { background: rgba(16,185,129,0.12); color: var(--success); }
.kpi-badge.negative { background: rgba(239,68,68,0.12); color: var(--error); }
.kpi-badge.neutral  { background: var(--bg-section); color: var(--text-muted); }

/* ---- CHARTS GRID ---- */
.charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 16px;
}

.chart-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 18px 20px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
}

.chart-title {
    font-family: var(--font-heading);
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 10px;
}

.chart-container {
    flex: 1;
    position: relative;
    min-height: 200px;
}

/* ============================================================
   ANALYSIS PAGE
   ============================================================ */
.analysis-layout {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 16px;
}

.pivot-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.pivot-title {
    font-family: var(--font-heading);
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
    padding: 14px 16px 10px;
    border-bottom: 1px solid var(--border-light);
}

.pivot-table-wrap {
    flex: 1;
    overflow: auto;
    max-height: calc(100vh - 220px);
}

table.pivot-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.pivot-table th {
    position: sticky;
    top: 0;
    background: var(--bg-section);
    color: var(--alt-blue);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 10px;
    letter-spacing: 1px;
    padding: 10px 10px;
    text-align: right;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    white-space: nowrap;
    user-select: none;
}
.pivot-table th:first-child { text-align: left; }
.pivot-table th:hover { color: var(--alt-blue-hover); }
.pivot-table th .sort-arrow { margin-left: 4px; font-size: 10px; }

.pivot-table td {
    padding: 7px 10px;
    border-bottom: 1px solid var(--border-light);
    text-align: right;
    white-space: nowrap;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}
.pivot-table td:first-child {
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pivot-table tr:hover td { background: rgba(0,73,255,0.03); }

.pivot-table tr.totals-row td {
    font-weight: 800;
    color: var(--text-primary);
    border-top: 2px solid var(--border);
    background: var(--bg-section);
}

.pivot-table tr.others-row td {
    font-style: italic;
    color: var(--text-muted);
}

/* ============================================================
   DETAILS PAGE
   ============================================================ */
.details-layout {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 20px;
}

.details-sidebar {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.slicer-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 14px 16px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.slicer-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--alt-blue);
    margin-bottom: 10px;
}

.slicer-search {
    width: 100%;
    padding: 8px 12px;
    border: 1.5px solid var(--border);
    border-radius: 6px;
    font-family: var(--font-body);
    font-size: 12px;
    background: var(--bg-card);
    color: var(--text-primary);
    margin-bottom: 8px;
    outline: none;
}
.slicer-search:focus {
    border-color: var(--alt-blue);
    box-shadow: 0 0 0 3px rgba(0,73,255,0.08);
}

.slicer-list { display: flex; flex-direction: column; gap: 2px; }
.slicer-list--scrollable { max-height: 280px; overflow-y: auto; }

.slicer-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 2px;
    font-size: 12px;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 4px;
    transition: background var(--transition);
}
.slicer-item:hover { background: var(--bg-section); }

.slicer-item input[type="checkbox"] {
    accent-color: var(--alt-blue);
    cursor: pointer;
}

.slicer-item label {
    cursor: pointer;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.apply-filters-btn {
    padding: 10px;
    background: var(--alt-blue);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition);
}
.apply-filters-btn:hover { background: var(--alt-blue-hover); }

.clear-filters-btn {
    padding: 8px;
    background: transparent;
    color: var(--text-secondary);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font-body);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}
.clear-filters-btn:hover { border-color: var(--text-secondary); color: var(--text-primary); }

/* ---- DETAILS TABLE ---- */
.details-main {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.details-table-wrap {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    overflow: auto;
    max-height: calc(100vh - 240px);
}

.details-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 12px;
}

.details-table th {
    position: sticky;
    top: 0;
    background: var(--bg-section);
    color: var(--alt-blue);
    font-weight: 700;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 12px 12px;
    text-align: left;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    z-index: 2;
    border-bottom: 1px solid var(--border);
}
.details-table th:hover { color: var(--alt-blue-hover); }
.details-table th .sort-arrow { margin-left: 4px; font-size: 10px; }

.details-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-secondary);
    white-space: nowrap;
}

.details-table tr:hover td { background: rgba(0,73,255,0.03); }

.details-table td img.thumb {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 6px;
    background: var(--bg-section);
    vertical-align: middle;
}

.details-table td.price-cell {
    font-weight: 700;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.details-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

.pagination-btn {
    padding: 7px 18px;
    border: 1.5px solid var(--border);
    border-radius: 6px;
    background: var(--bg-card);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}
.pagination-btn:hover:not(:disabled) { border-color: var(--alt-blue); color: var(--alt-blue); }
.pagination-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.pagination-info {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1200px) {
    .analysis-layout {
        grid-template-columns: 1fr;
    }
    .pivot-table-wrap { max-height: 400px; }
}

@media (max-width: 960px) {
    .overview-layout {
        grid-template-columns: 1fr;
    }
    .kpi-sidebar {
        flex-direction: row;
        flex-wrap: wrap;
    }
    .kpi-card { flex: 1; min-width: 200px; }
    .details-layout { grid-template-columns: 1fr; }
    .category-tabs { flex-wrap: wrap; }
}
