/* ========================================================
   UG GROUP - ODOO ERP EXECUTIVE DASHBOARD CSS
   ======================================================== */

:root {
    /* Color Tokens - Dark Mode (Default) */
    --bg-main: #0a0f1d;
    --bg-surface: #111827;
    --bg-card: #151f32;
    --bg-card-hover: #1a2740;
    --border-subtle: rgba(255, 255, 255, 0.08);
    --border-strong: #2a374f;
    --border-focus: #3b82f6;

    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    /* Accent & Brand Colors */
    --primary: #3b82f6;
    --primary-glow: rgba(59, 130, 246, 0.25);
    --success: #10b981;
    --success-glow: rgba(16, 185, 129, 0.25);
    --danger: #ef4444;
    --danger-glow: rgba(239, 68, 68, 0.25);
    --warning: #f59e0b;
    --accent: #8b5cf6;
    --accent-glow: rgba(139, 92, 246, 0.25);

    /* Dropdown match user screenshot */
    --dropdown-bg: #0d1525;
    --dropdown-active-bg: #1d4ed8;
    --dropdown-hover-bg: rgba(37, 99, 235, 0.2);
    --dropdown-divider: rgba(255, 255, 255, 0.12);

    /* Typography & Radius */
    --font-main: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.2);
    --shadow-card: 0 10px 25px -5px rgba(0, 0, 0, 0.4), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
    --shadow-glow: 0 0 20px rgba(59, 130, 246, 0.15);
}

/* Light Theme Variables */
body.light-theme {
    --bg-main: #f1f5f9;
    --bg-surface: #ffffff;
    --bg-card: #ffffff;
    --bg-card-hover: #f8fafc;
    --border-subtle: #e2e8f0;
    --border-strong: #cbd5e1;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --dropdown-bg: #ffffff;
    --dropdown-active-bg: #2563eb;
    --dropdown-hover-bg: #e0e7ff;
    --dropdown-divider: #e2e8f0;
    --shadow-card: 0 10px 25px -5px rgba(0, 0, 0, 0.06), 0 8px 10px -6px rgba(0, 0, 0, 0.04);
}

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

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

.app-layout {
    max-width: 1600px;
    margin: 0 auto;
    padding: 1.25rem 1.5rem 3rem 1.5rem;
}

/* ========================================================
   HEADER & NAVIGATION CONTROLS
   ======================================================== */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1.25rem;
    padding: 1.25rem 1.5rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    margin-bottom: 1rem;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.brand-badge {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.brand-icon {
    font-size: 1.6rem;
    color: #3b82f6;
    background: linear-gradient(135deg, #1e40af, #3b82f6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 2px 8px var(--primary-glow));
}

.brand-text {
    display: flex;
    flex-direction: column;
}

.brand-name {
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: 0.5px;
    color: var(--text-primary);
    line-height: 1.2;
}

.brand-sub {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.erp-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.25);
    padding: 0.35rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
}

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

@keyframes pulse {
    0% { transform: scale(0.95); opacity: 0.8; }
    50% { transform: scale(1.15); opacity: 1; }
    100% { transform: scale(0.95); opacity: 0.8; }
}

.status-label {
    font-weight: 600;
    color: var(--success);
}

.status-db {
    background: rgba(255, 255, 255, 0.1);
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    font-family: var(--font-mono);
    color: var(--text-secondary);
}

/* Header Controls Area */
.header-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    position: relative;
}

.dropdown-wrapper {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

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

.custom-dropdown-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.55rem 1rem;
    min-width: 170px;
    background: var(--bg-card);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.custom-dropdown-btn:hover {
    border-color: var(--primary);
    background: var(--bg-card-hover);
}

.custom-dropdown-btn.active {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-glow);
}

.caret-icon {
    font-size: 0.75rem;
    color: var(--text-secondary);
    transition: transform 0.2s ease;
}

.custom-dropdown-btn.active .caret-icon {
    transform: rotate(180deg);
}

/* Custom Dropdown Menu (Screenshot Style) */
.custom-dropdown-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    z-index: 1000;
    min-width: 200px;
    background: var(--dropdown-bg);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.6);
    padding: 4px 0;
    display: none;
    max-height: 420px;
    overflow-y: auto;
}

.custom-dropdown-menu.show {
    display: block;
    animation: fadeInDropdown 0.15s ease-out;
}

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

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    color: var(--text-primary);
    cursor: pointer;
    transition: background-color 0.15s ease;
    user-select: none;
}

.dropdown-item:hover {
    background-color: var(--dropdown-hover-bg);
    color: #ffffff;
}

.dropdown-item.active {
    background-color: var(--dropdown-active-bg) !important;
    color: #ffffff !important;
    font-weight: 600;
}

/* Screenshot style divider */
.dropdown-divider {
    height: 1px;
    background-color: var(--dropdown-divider);
    margin: 4px 8px;
    opacity: 0.8;
}

/* Action Buttons (Refresh, Theme) */
.action-buttons {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1.1rem;
}

.btn-icon {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-icon:hover {
    background: var(--bg-card-hover);
    color: var(--primary);
    border-color: var(--primary);
}

.btn-icon.spinning i {
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    100% { transform: rotate(360deg); }
}

/* Custom Range Popover */
.custom-range-modal {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 1050;
    background: var(--bg-card);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.6);
    padding: 1.25rem;
    display: none;
    width: 320px;
}

.custom-range-modal.show {
    display: block;
    animation: fadeInDropdown 0.2s ease;
}

.range-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.btn-close-modal {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.25rem;
    cursor: pointer;
}

.range-inputs {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    margin-bottom: 1.25rem;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.input-group label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.date-input {
    background: var(--bg-main);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    padding: 0.5rem 0.75rem;
    font-family: var(--font-mono);
    font-size: 0.85rem;
}

.range-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

.btn-modal-cancel, .btn-modal-apply {
    padding: 0.45rem 0.9rem;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font-main);
}

.btn-modal-cancel {
    background: transparent;
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
}

.btn-modal-apply {
    background: var(--primary);
    border: 1px solid var(--primary);
    color: #ffffff;
}

.btn-modal-apply:hover {
    background: #2563eb;
}

/* Active Filter Banner */
.filter-indicator-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 1.25rem;
    background: rgba(30, 41, 59, 0.4);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    margin-bottom: 1.5rem;
    font-size: 0.8rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.filter-tag {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.tag-title {
    color: var(--text-muted);
    font-weight: 600;
}

.tag-badge {
    padding: 0.2rem 0.6rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.company-badge {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.date-badge {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.last-sync {
    color: var(--text-muted);
    font-size: 0.75rem;
}

/* ========================================================
   TOP ROW: 3 KPI METRIC CARDS (NUMBERS)
   ======================================================== */
.kpi-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

.kpi-card {
    position: relative;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-card);
    overflow: hidden;
    transition: transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}

.kpi-card:hover {
    transform: translateY(-3px);
    border-color: var(--border-strong);
    box-shadow: 0 14px 28px rgba(0, 0, 0, 0.35);
}

.kpi-card.hero-kpi {
    border-color: rgba(16, 185, 129, 0.3);
    background: linear-gradient(145deg, #13222d, #141f32);
}

.kpi-card.hero-kpi:hover {
    border-color: var(--success);
    box-shadow: 0 0 25px var(--success-glow);
}

.kpi-card-glow {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
}

.gross-card .kpi-card-glow {
    background: linear-gradient(90deg, #2563eb, #60a5fa);
}

.net-card .kpi-card-glow {
    background: linear-gradient(90deg, #059669, #34d399);
}

.payment-card .kpi-card-glow {
    background: linear-gradient(90deg, #7c3aed, #a78bfa);
}

.kpi-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.kpi-info {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.kpi-label {
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-secondary);
}

.kpi-sub {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.kpi-icon-box {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.gross-icon {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
}

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

.payment-icon {
    background: rgba(139, 92, 246, 0.15);
    color: #c084fc;
}

.kpi-value-container {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.kpi-currency {
    font-family: var(--font-mono);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-muted);
}

.kpi-value {
    font-family: var(--font-mono);
    font-size: 2.1rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    color: var(--text-primary);
    line-height: 1;
}

.kpi-value.highlight {
    color: #34d399;
    text-shadow: 0 0 20px rgba(16, 185, 129, 0.2);
}

.kpi-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 0.85rem;
    border-top: 1px solid var(--border-subtle);
    font-size: 0.8rem;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.kpi-stat-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.2rem 0.5rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-weight: 500;
}

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

.payment-count-badge {
    background: rgba(139, 92, 246, 0.12);
    color: #c084fc;
}

.kpi-footnote {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* ========================================================
   MAIN ROW: 3 CHART CARDS IN A ROW
   ======================================================== */
.charts-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

.chart-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 1.4rem;
    box-shadow: var(--shadow-card);
    display: flex;
    flex-direction: column;
    min-height: 420px;
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.chart-card:hover {
    border-color: var(--border-strong);
}

.chart-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
    gap: 0.5rem;
}

.chart-title-area {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.chart-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    padding: 0.15rem 0.45rem;
    border-radius: 4px;
    width: fit-content;
}

.sales-badge { background: rgba(59, 130, 246, 0.15); color: #60a5fa; }
.team-badge { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }
.pay-badge { background: rgba(139, 92, 246, 0.15); color: #c084fc; }

.chart-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
}

.chart-subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.pill-metric {
    font-size: 0.75rem;
    font-family: var(--font-mono);
    font-weight: 600;
    padding: 0.25rem 0.6rem;
    border-radius: 9999px;
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-secondary);
    white-space: nowrap;
}

.chart-container {
    position: relative;
    flex: 1;
    min-height: 250px;
    max-height: 270px;
    width: 100%;
}

.chart-empty-state {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    gap: 0.5rem;
}

.chart-empty-state i {
    font-size: 2.2rem;
    opacity: 0.4;
}

.chart-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 1rem;
    margin-top: auto;
    border-top: 1px solid var(--border-subtle);
    font-size: 0.75rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.breakdown-stat {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.stat-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.dot-gross { background-color: #3b82f6; }
.dot-return { background-color: #ef4444; }
.dot-net { background-color: #10b981; }

.stat-name { color: var(--text-muted); }
.stat-val { font-family: var(--font-mono); font-weight: 600; color: var(--text-primary); }
.text-danger { color: #f87171 !important; }
.text-success { color: #34d399 !important; }
.text-primary { color: #60a5fa !important; }
.text-accent { color: #c084fc !important; }

.team-top-stat {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.8rem;
}

.trophy-icon { color: #f59e0b; }
.bank-icon { color: #8b5cf6; }

/* ========================================================
   BOTTOM SECTION: DRILL-DOWN DATA TABLES
   ======================================================== */
.drilldown-section {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    padding: 1.5rem;
}

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

.tab-buttons {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.tab-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 1rem;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-family: var(--font-main);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tab-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.tab-btn.active {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
    border-color: rgba(59, 130, 246, 0.3);
}

.tab-count-badge {
    background: rgba(255, 255, 255, 0.1);
    font-size: 0.7rem;
    padding: 0.1rem 0.45rem;
    border-radius: 9999px;
    font-family: var(--font-mono);
}

.table-search-box {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    padding: 0.4rem 0.8rem;
    min-width: 260px;
}

.table-search-box i {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.table-search-box input {
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 0.85rem;
    width: 100%;
}

.tab-pane {
    display: none;
}

.tab-pane.active {
    display: block;
    animation: fadeIn 0.2s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.data-table th {
    text-align: left;
    padding: 0.75rem 1rem;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid var(--border-strong);
}

.data-table td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-primary);
}

.data-table tbody tr:hover {
    background-color: var(--bg-card-hover);
}

.text-right {
    text-align: right !important;
}

.status-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.2rem 0.55rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

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

.status-not-paid {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
}

.status-in-process {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
}

.status-refund {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
}

/* ========================================================
   LOADING & TOAST NOTIFICATIONS
   ======================================================== */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 15, 29, 0.75);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.loading-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.loading-box {
    background: var(--bg-surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg);
    padding: 2rem 2.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(59, 130, 246, 0.2);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 1rem;
}

.loading-text {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.loading-sub {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.toast-notification {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--bg-card);
    border: 1px solid var(--border-strong);
    padding: 0.8rem 1.25rem;
    border-radius: var(--radius-md);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.85rem;
    color: var(--text-primary);
    z-index: 2500;
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ========================================================
   2-COLUMN SECTION: PROVINCIAL & PRODUCT TAG SALES
   ======================================================== */
.two-column-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

.geo-badge {
    background: rgba(14, 165, 233, 0.15);
    color: #38bdf8;
}

.prod-badge {
    background: rgba(236, 72, 153, 0.15);
    color: #f472b6;
}

.doughnut-container {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ========================================================
   SELECTED RANGE 4-YEAR COMPARISON CARD
   ======================================================== */
.selected-range-4y-section {
    width: 100%;
    margin-bottom: 1.5rem;
}

.compare-badge {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
}

/* ========================================================
   LONG CARD: MONTHLY NET SALES COMPARISON (4 YEARS)
   ======================================================== */
.long-card-section {
    width: 100%;
    margin-bottom: 1.5rem;
}

.long-chart-card {
    min-height: 480px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    position: relative;
    overflow: hidden;
}

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

.year-pills {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.year-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.3rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-family: var(--font-mono);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
    user-select: none;
}

.year-pill.y2026 {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border-color: rgba(16, 185, 129, 0.35);
}

.year-pill.y2025 {
    background: rgba(168, 85, 247, 0.15);
    color: #c084fc;
    border-color: rgba(168, 85, 247, 0.35);
}

.year-pill.y2024 {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
    border-color: rgba(245, 158, 11, 0.35);
}

.year-pill.y2023 {
    background: rgba(56, 189, 248, 0.15);
    color: #38bdf8;
    border-color: rgba(56, 189, 248, 0.35);
}

.year-pill:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.year-pill.muted {
    opacity: 0.35;
    text-decoration: line-through;
}

.year-pill-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.y2026 .year-pill-dot { background-color: #10b981; box-shadow: 0 0 6px #10b981; }
.y2025 .year-pill-dot { background-color: #a855f7; box-shadow: 0 0 6px #a855f7; }
.y2024 .year-pill-dot { background-color: #f59e0b; box-shadow: 0 0 6px #f59e0b; }
.y2023 .year-pill-dot { background-color: #38bdf8; box-shadow: 0 0 6px #38bdf8; }

.long-chart-container {
    position: relative;
    flex: 1;
    min-height: 330px;
    max-height: 360px;
    width: 100%;
}

.long-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 1rem;
    margin-top: auto;
    border-top: 1px solid var(--border-subtle);
    flex-wrap: wrap;
    gap: 1rem;
}

.long-footer-metrics {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.footer-metric-item {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.8rem;
}

.footer-metric-item .metric-label {
    color: var(--text-muted);
}

.footer-metric-item .metric-val {
    font-family: var(--font-mono);
    font-weight: 700;
}

.legend-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

/* ========================================================
   RESPONSIVE DESIGN BREAKPOINTS
   ======================================================== */
@media (max-width: 1200px) {
    .charts-row {
        grid-template-columns: repeat(2, 1fr);
    }
    .charts-row .chart-card:last-child {
        grid-column: span 2;
    }
}

@media (max-width: 900px) {
    .kpi-row {
        grid-template-columns: 1fr;
    }
    .charts-row {
        grid-template-columns: 1fr;
    }
    .charts-row .chart-card:last-child {
        grid-column: span 1;
    }
    .two-column-row {
        grid-template-columns: 1fr;
    }
    .long-footer-metrics {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.6rem;
    }
}

@media (max-width: 768px) {
    .app-layout {
        padding: 0.75rem 0.75rem 2.5rem 0.75rem;
    }

    .app-header {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
        padding: 1rem;
    }

    .header-left {
        justify-content: space-between;
        width: 100%;
    }

    .header-controls {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.6rem;
        width: 100%;
    }

    .dropdown-wrapper {
        width: 100%;
    }

    .custom-dropdown-btn {
        width: 100%;
        min-width: 0;
        padding: 0.5rem 0.75rem;
        font-size: 0.825rem;
    }

    .action-buttons {
        grid-column: span 2;
        display: flex;
        justify-content: flex-end;
        margin-top: 0.2rem;
    }

    .custom-range-modal {
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%) !important;
        width: calc(100vw - 32px);
        max-width: 360px;
        box-shadow: 0 25px 60px rgba(0, 0, 0, 0.8);
        z-index: 2200;
    }

    .custom-dropdown-menu {
        max-width: calc(100vw - 32px);
        min-width: 180px;
    }

    .kpi-value {
        font-size: clamp(1.5rem, 5.5vw, 1.9rem);
    }

    .drilldown-header {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }

    .tab-buttons {
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 0.35rem;
    }

    .tab-btn {
        flex-shrink: 0;
        white-space: nowrap;
        font-size: 0.8rem;
        padding: 0.45rem 0.75rem;
    }

    .table-search-box {
        width: 100%;
        min-width: 0;
    }
}

@media (max-width: 480px) {
    .brand-name {
        font-size: 1.1rem;
    }

    .brand-sub {
        font-size: 0.65rem;
    }

    .erp-status {
        padding: 0.25rem 0.5rem;
        font-size: 0.7rem;
    }

    .header-controls {
        grid-template-columns: 1fr;
    }

    .action-buttons {
        grid-column: span 1;
        justify-content: center;
        width: 100%;
    }

    .action-buttons .btn-icon {
        flex: 1;
        height: 42px;
    }

    .kpi-card {
        padding: 1.15rem;
    }

    .kpi-value {
        font-size: 1.55rem;
    }

    .chart-card {
        padding: 1.15rem;
        min-height: 380px;
    }

    .chart-container {
        min-height: 220px;
        max-height: 250px;
    }

    .long-chart-card {
        padding: 1.15rem;
        min-height: 420px;
    }

    .long-chart-container {
        min-height: 250px;
        max-height: 280px;
    }

    .year-pills {
        gap: 0.3rem;
    }

    .year-pill {
        font-size: 0.68rem;
        padding: 0.2rem 0.5rem;
    }

    .data-table th, .data-table td {
        padding: 0.6rem 0.65rem;
        font-size: 0.78rem;
    }
}

/* ========================================================
   PAGE NAVIGATION SWITCHER (Executive Sales vs CRM)
   ======================================================== */
.page-nav {
    display: inline-flex;
    align-items: center;
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 0.25rem;
    gap: 0.25rem;
}

body.light-theme .page-nav {
    background: #e2e8f0;
    border-color: #cbd5e1;
}

.nav-tab {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.45rem 0.95rem;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: calc(var(--radius-md) - 2px);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-tab:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.06);
}

.nav-tab.active {
    color: #ffffff;
    background: var(--primary);
    box-shadow: 0 2px 8px var(--primary-glow);
}

/* CRM Top Stats Grid (4 columns) */
.crm-kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

@media (max-width: 1200px) {
    .crm-kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 640px) {
    .crm-kpi-grid {
        grid-template-columns: 1fr;
    }
}

/* CRM Main Card & Controls */
.crm-controls-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1rem;
}

.crm-view-switch {
    display: inline-flex;
    align-items: center;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 0.2rem;
    gap: 0.25rem;
}

.view-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 0.4rem 0.85rem;
    font-size: 0.8rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.view-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.view-btn.active {
    color: #ffffff;
    background: var(--primary);
    box-shadow: 0 2px 6px var(--primary-glow);
}

.crm-search-box {
    position: relative;
    min-width: 240px;
}

.crm-search-box i {
    position: absolute;
    left: 0.85rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.85rem;
}

.crm-search-input {
    width: 100%;
    padding: 0.45rem 0.85rem 0.45rem 2.2rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.82rem;
    outline: none;
    transition: border-color 0.2s;
}

.crm-search-input:focus {
    border-color: var(--primary);
}

/* CRM Comparison Table */
.crm-table-container {
    overflow-x: auto;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    background: var(--bg-surface);
}

.crm-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    white-space: nowrap;
}

.crm-table th {
    background: rgba(11, 17, 32, 0.85);
    padding: 0.85rem 1rem;
    text-align: left;
    font-weight: 700;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border-strong);
    position: sticky;
    top: 0;
    z-index: 10;
}

body.light-theme .crm-table th {
    background: #f1f5f9;
}

.crm-table td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-primary);
    vertical-align: middle;
}

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

.crm-table tfoot td {
    background: rgba(15, 23, 42, 0.8);
    font-weight: 700;
    border-top: 2px solid var(--border-strong);
    border-bottom: none;
}

body.light-theme .crm-table tfoot td {
    background: #e2e8f0;
}

/* Year Header Colors */
.th-2023 { color: #38bdf8 !important; }
.th-2024 { color: #f59e0b !important; }
.th-2025 { color: #a855f7 !important; }
.th-2026 { color: #10b981 !important; }

/* Province Cell & Top Customers Badge */
.prov-name {
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.prov-cust-badge {
    display: inline-block;
    font-size: 0.72rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-top: 0.2rem;
}

/* Value & Pct Stack in table */
.val-pct-cell {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.val-num {
    font-family: var(--font-mono);
    font-weight: 600;
}

.pct-badge-wrapper {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.pct-badge {
    font-size: 0.73rem;
    font-weight: 700;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.06);
}

.pct-badge.y2023 { color: #38bdf8; background: rgba(56, 189, 248, 0.12); }
.pct-badge.y2024 { color: #f59e0b; background: rgba(245, 158, 11, 0.12); }
.pct-badge.y2025 { color: #a855f7; background: rgba(168, 85, 247, 0.12); }
.pct-badge.y2026 { color: #10b981; background: rgba(16, 185, 129, 0.14); }

.mini-bar-track {
    flex: 1;
    height: 4px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 2px;
    overflow: hidden;
    min-width: 36px;
    max-width: 60px;
}

.mini-bar-fill {
    height: 100%;
    border-radius: 2px;
}

.mini-bar-fill.y2023 { background: #38bdf8; }
.mini-bar-fill.y2024 { background: #f59e0b; }
.mini-bar-fill.y2025 { background: #a855f7; }
.mini-bar-fill.y2026 { background: #10b981; }

.crm-chart-card {
    min-height: 440px;
}

