/* ================================================================
   GreenBay Pulse - Executive Greenhouse Design System
   ================================================================ */

/* Apple SF Pro - same font used on apple.com */
@font-face {
    font-family: 'SF Pro Display';
    src: url('https://applesocial.s3.amazonaws.com/assets/styles/fonts/sanfrancisco/sanfranciscodisplay-regular-webfont.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'SF Pro Display';
    src: url('https://applesocial.s3.amazonaws.com/assets/styles/fonts/sanfrancisco/sanfranciscodisplay-medium-webfont.woff2') format('woff2');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'SF Pro Display';
    src: url('https://applesocial.s3.amazonaws.com/assets/styles/fonts/sanfrancisco/sanfranciscodisplay-semibold-webfont.woff2') format('woff2');
    font-weight: 600;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'SF Pro Display';
    src: url('https://applesocial.s3.amazonaws.com/assets/styles/fonts/sanfrancisco/sanfranciscodisplay-bold-webfont.woff2') format('woff2');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

:root {
    --bg: #F5F8F6;
    --surface: rgba(255, 255, 255, 0.85);
    --surface-solid: #FFFFFF;
    --surface-alt: #EDF2EE;
    --border: rgba(200, 215, 205, 0.5);
    --border-hover: #AAC0B0;
    --green: #1DB954;
    --green-dark: #0B3D0B;
    --green-light: #E8F5EC;
    --green-mid: #158C3F;
    --text: #1A1F1C;
    --text-primary: #1A1F1C;
    --text-secondary: #5A6B60;
    --text-tertiary: #8A9B90;
    --positive: #1DB954;
    --negative: #DC3B2F;
    --warning: #E5A020;
    --info: #2E7FBF;
    --chart-1: #1DB954;
    --chart-2: #158C3F;
    --chart-3: #0F6B30;
    --chart-4: #094D22;
    --chart-5: #E5A020;
    --chart-6: #2E7FBF;
    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --shadow-sm: 0 1px 4px rgba(10, 30, 16, 0.05), 0 0 1px rgba(10, 30, 16, 0.08);
    --shadow-md: 0 4px 16px rgba(10, 30, 16, 0.08), 0 1px 3px rgba(10, 30, 16, 0.06);
    --shadow-lg: 0 12px 40px rgba(10, 30, 16, 0.12), 0 4px 12px rgba(10, 30, 16, 0.06);
    --glass-blur: 12px;
}

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
    background-image:
        radial-gradient(ellipse at 20% 0%, rgba(29, 185, 84, 0.04) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 100%, rgba(46, 127, 191, 0.03) 0%, transparent 50%);
    background-attachment: fixed;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

/* ---- Anime.js entrance animation helpers ---- */
.anim-enter {
    opacity: 0;
    transform: translateY(18px);
}

/* ---- Region Switcher ---- */
.region-switcher {
    display: flex;
    align-items: center;
    gap: 2px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    padding: 3px;
    position: relative;
    margin-left: 12px;
    flex-shrink: 0;
}

.region-btn {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: rgba(255, 255, 255, 0.6);
    font: 500 12px 'Inter', 'SF Pro Display', -apple-system, sans-serif;
    cursor: pointer;
    white-space: nowrap;
    transition: color .25s;
}

.region-btn:hover {
    color: rgba(255, 255, 255, 0.9);
}

.region-btn.active {
    color: #fff;
    font-weight: 600;
}

.region-flag {
    font-size: 14px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.region-flag img {
    display: block;
    border-radius: 2px;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.06);
    width: 22px;
    height: 16px;
    object-fit: cover;
}

.region-slider {
    position: absolute;
    z-index: 1;
    top: 3px;
    left: 3px;
    height: calc(100% - 6px);
    border-radius: 8px;
    background: linear-gradient(135deg, rgba(29,185,84,0.35) 0%, rgba(21,140,63,0.4) 100%);
    backdrop-filter: blur(4px);
    transition: left .35s cubic-bezier(.4,0,.2,1), width .35s cubic-bezier(.4,0,.2,1);
    pointer-events: none;
    box-shadow: 0 1px 6px rgba(29,185,84,0.2);
}

@media (max-width: 768px) {
    .region-label { display: none; }
    .region-btn { padding: 5px 8px; }
}

/* ---- Customer Summary Card ---- */
.customer-summary-card {
    background: var(--surface);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 14px 20px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow .3s ease, transform .3s ease;
}

.customer-summary-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.customer-tri-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.cust-stat {
    text-align: center;
    padding: 10px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    transition: transform .2s ease, box-shadow .2s ease;
    position: relative;
    overflow: hidden;
}

.cust-stat::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    border-radius: 2px 2px 0 0;
}

.cust-stat:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.cust-stat--total { background: rgba(29,185,84,0.04); }
.cust-stat--total::before { background: linear-gradient(90deg, #1DB954, #4ADE80); }
.cust-stat--new { background: rgba(46,127,191,0.04); }
.cust-stat--new::before { background: linear-gradient(90deg, #2E7FBF, #61AFEF); }
.cust-stat--returning { background: rgba(229,160,32,0.04); }
.cust-stat--returning::before { background: linear-gradient(90deg, #E5A020, #F0C040); }

.cust-stat-icon {
    font-size: 16px;
    margin-bottom: 4px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cust-stat-value {
    font-family: 'Inter', 'SF Pro Display', -apple-system, sans-serif;
    font-size: 22px;
    font-weight: 700;
    line-height: 1.1;
    margin-bottom: 2px;
}

.cust-stat--total .cust-stat-value { color: #1DB954; }
.cust-stat--new .cust-stat-value { color: #2E7FBF; }
.cust-stat--returning .cust-stat-value { color: #E5A020; }

.cust-stat-label {
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-secondary);
}

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


/* ---- Header / Top Bar ---- */
.top-bar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 16px;
    background: linear-gradient(135deg, #0B3D0B 0%, #0d4f12 40%, #11601a 70%, #157025 100%);
    border-bottom: none;
    padding: 0 28px;
    height: 60px;
    box-shadow: 0 4px 20px rgba(11, 61, 11, 0.25), 0 1px 3px rgba(0,0,0,0.1);
}

.logo {
    font-size: 20px;
    font-weight: 700;
    color: #FFFFFF;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.logo span {
    color: #4ADE80;
}

.logo-img {
    height: 30px;
    width: auto;
    object-fit: contain;
    vertical-align: middle;
}

/* ---- Tabs ---- */
.tabs {
    display: flex;
    gap: 2px;
    overflow-x: auto;
    scrollbar-width: none;
    margin-left: 24px;
    flex: 1;
}

.tabs::-webkit-scrollbar {
    display: none;
}

.tab-scroll-hint {
    position: sticky;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 100%;
    font-size: 22px;
    font-weight: 700;
    color: #4ADE80;
    background: linear-gradient(90deg, transparent, rgba(11, 61, 11, 0.9) 40%);
    cursor: pointer;
    user-select: none;
    padding-left: 16px;
    animation: pulse-hint 2s ease-in-out infinite;
    transition: opacity .3s;
}

.tab-scroll-hint.hidden {
    opacity: 0;
    pointer-events: none;
}

@keyframes pulse-hint {

    0%,
    100% {
        transform: translateX(0);
    }

    50% {
        transform: translateX(4px);
    }
}

.tab-btn {
    position: relative;
    overflow: hidden;
    background: none;
    border: none;
    /* Dynamic padding + font that scale with viewport so all 11 labels stay
       visible without clipping on common laptop widths (1024-1600px) and
       still look right on huge monitors. */
    padding: 16px clamp(6px, 1vw, 14px);
    cursor: pointer;
    font: 500 clamp(10.5px, 0.85vw, 13px) 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    color: rgba(255, 255, 255, 0.65);
    letter-spacing: 0.3px;
    text-transform: uppercase;
    white-space: nowrap;
    /* Critical: flex parent has `flex:1` and tab-btn has `overflow:hidden`
       (for the ripple), which together caused labels to be clipped. Locking
       flex-shrink to 0 lets each button keep its content width; if the
       full row is wider than the bar, the .tabs container scrolls instead. */
    flex-shrink: 0;
    min-width: max-content;
    border-bottom: 2px solid transparent;
    transition: color .25s, border-color .25s, background .25s;
}

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

.tab-btn.active {
    color: #4ADE80;
    border-bottom-color: #4ADE80;
    font-weight: 700;
}

/* Global region mode: hide all tabs except Overview, and pin Overview
   to the *viewport* horizontal center of the top bar (not the center
   of the .tabs flex slot, which sits asymmetrically between the
   logo+region-switcher on the left and the wider .controls block on
   the right - using flex justify-content there visibly drifts the
   label off-centre). .top-bar is position: sticky which establishes a
   positioning context for the absolute placement below. */
.tabs.global-mode {
    /* Let absolute positioning handle Overview; remaining tabs are
       collapsed to zero width by the rule further below, so the flex
       slot becomes empty and stays out of the way. */
    justify-content: flex-start;
    overflow: visible;
}

.tabs .tab-btn {
    transition: opacity .3s ease, transform .35s ease, max-width .35s ease, padding .35s ease;
    transform-origin: center;
}

.tabs.global-mode .tab-btn:not([data-tab="overview"]) {
    opacity: 0;
    max-width: 0;
    padding-left: 0;
    padding-right: 0;
    transform: scale(0.8);
    pointer-events: none;
    overflow: hidden;
}

.tabs.global-mode .tab-btn[data-tab="overview"] {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%) scale(1.15);
    font-size: 15px;
    letter-spacing: 0.5px;
    pointer-events: auto;
    z-index: 2;
}

.tabs.global-mode .tab-scroll-hint {
    display: none;
}

/* Ripple effect on tab buttons */
.tab-btn .ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(29, 185, 84, 0.18);
    transform: scale(0);
    pointer-events: none;
}

/* ---- Controls (right side of top bar) ---- */
.controls {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-left: auto;
}

.period-select {
    font: 500 13px 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    padding: 8px 14px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.1);
    color: #FFFFFF;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%23FFFFFF' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 28px;
    transition: border-color .2s, box-shadow .2s;
}

.period-select:hover {
    border-color: rgba(255, 255, 255, 0.5);
}

.period-select option {
    background: #1a3a1d;
    color: #FFFFFF;
}

/* Override for selects INSIDE cards (e.g. Compare Weeks) - need dark text on light bg */
.card .period-select,
.tab-content .period-select {
    border: 1px solid var(--border-hover);
    background: var(--surface-solid);
    color: var(--text);
    background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%235A6B60' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
}

.card .period-select:hover,
.tab-content .period-select:hover {
    border-color: var(--green);
}

.card .period-select option,
.tab-content .period-select option {
    background: var(--surface-solid);
    color: var(--text);
}

.pulse-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
}

.pulse-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #4ADE80;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: .5;
        transform: scale(1.4);
    }
}

.refresh-btn {
    background: none;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: var(--radius-sm);
    padding: 5px 10px;
    cursor: pointer;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.8);
    transition: border-color .2s, color .2s, background .2s;
}

.refresh-btn:hover {
    border-color: #4ADE80;
    color: #4ADE80;
    background: rgba(74, 222, 128, 0.08);
}

/* ---- Main Content ---- */
.main {
    padding: 24px 28px;
    max-width: 1600px;
    margin: 0 auto;
}

.tab-content {
    display: none;
    animation: fadeIn .15s ease-out;
}

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

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

/* ---- Section Titles ---- */
.section-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--green-dark);
    margin: 28px 0 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-title:first-child {
    margin-top: 0;
}

/* ---- KPI Cards Grid ---- */
.kpi-grid {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(5, 1fr);
}

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

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

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

.kpi-card {
    background: var(--surface);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--border);
    border-left: 3px solid transparent;
    border-image: linear-gradient(180deg, #1DB954, #0F6B30) 1;
    border-image-slice: 0 0 0 1;
    border-radius: var(--radius-md);
    padding: 18px 20px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow .3s ease, transform .3s ease;
    position: relative;
    overflow: hidden;
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #1DB954, #4ADE80, #1DB954);
    opacity: 0;
    transition: opacity .3s ease;
}

.kpi-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-3px);
}

.kpi-card:hover::before {
    opacity: 1;
}

.kpi-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
}

.kpi-spark-wrap {
    flex-shrink: 0;
    width: 64px;
    height: 24px;
    opacity: 0.85;
    transition: opacity .2s;
}

.kpi-card:hover .kpi-spark-wrap {
    opacity: 1;
}

.kpi-spark {
    width: 100%;
    height: 100%;
    display: block;
}

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

.kpi-value {
    font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    font-size: 26px;
    font-weight: 700;
    color: var(--green-dark);
    line-height: 1.2;
}

.kpi-value.positive {
    color: var(--positive);
}

.kpi-value.negative {
    color: var(--negative);
}

.kpi-value.amber {
    color: var(--warning);
}

.kpi-sub {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.kpi-sub strong {
    color: var(--text-primary);
    font-weight: 700;
}

.kpi-arrow {
    display: inline-block;
    margin-right: 2px;
    font-size: 14px;
}

.kpi-arrow.up {
    color: var(--positive);
}

.kpi-arrow.down {
    color: var(--negative);
}

/* ---- Toggle Pills ---- */
.toggle-pill {
    padding: 4px 12px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all .2s;
}

.toggle-pill.active {
    background: var(--green);
    color: #fff;
    border-color: var(--green);
}

.toggle-pill:hover:not(.active) {
    background: var(--surface-hover);
}

/* ---- Cards ---- */
.card {
    background: var(--surface);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px 24px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow .3s ease, transform .3s ease;
}

.card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.card-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: var(--text-secondary);
    margin-bottom: 10px;
    font-weight: 500;
}

/* ---- Card label row with optional trailing controls (e.g. currency
   toggle on the Agent Revenue Leaderboard). Keeps the title left-aligned
   and the toggle right-aligned without affecting cards that still use a
   plain .card-label. ---- */
.card-label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}
.card-label-row .card-label {
    margin-bottom: 0;
}

/* Currency toggle - 4 small pills, visually consistent with the
   region-switcher pills in the top bar but scoped to the card so the
   greens are themable. Hidden by default via the [hidden] attribute;
   JS removes the attribute when the Global region is active. */
.ccy-toggle {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    background: rgba(11, 61, 11, 0.06);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 2px;
}
.ccy-toggle[hidden] { display: none; }
.ccy-btn {
    appearance: none;
    background: transparent;
    border: 0;
    color: var(--text-secondary);
    font: 600 11px/1 'Inter', system-ui, sans-serif;
    letter-spacing: .04em;
    padding: 5px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: background .18s ease, color .18s ease, transform .12s ease;
}
.ccy-btn:hover { color: var(--text-primary); background: rgba(29, 185, 84, 0.08); }
.ccy-btn:active { transform: scale(0.96); }
.ccy-btn.active {
    background: linear-gradient(135deg, #1DB954 0%, #16933e 100%);
    color: #ffffff;
    box-shadow: 0 1px 3px rgba(29, 185, 84, 0.25);
}
.ccy-btn:focus-visible {
    outline: 2px solid #1DB954;
    outline-offset: 2px;
}

/* ---- Chart Grid ---- */
.chart-grid {
    display: grid;
    gap: 18px;
    grid-template-columns: repeat(2, 1fr);
    margin-top: 14px;
}

.chart-grid.three {
    grid-template-columns: repeat(3, 1fr);
}

.chart-grid.full {
    grid-template-columns: 1fr;
}

@media (max-width: 900px) {

    .chart-grid,
    .chart-grid.three {
        grid-template-columns: 1fr;
    }
}

.chart-container {
    position: relative;
    width: 100%;
    height: 300px;
    min-height: 280px;
}

.chart-container canvas {
    display: block;
}

/* ---- Tables ---- */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table th {
    text-align: left;
    padding: 10px 12px;
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border);
    cursor: pointer;
    user-select: none;
    position: relative;
}

.data-table th:hover {
    color: var(--green);
}

.data-table th.num,
.data-table td.num {
    text-align: right;
    font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

.data-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--surface-alt);
}

.data-table tbody tr:nth-child(even) {
    background: var(--bg);
}

.data-table tbody tr:hover {
    background: var(--surface-alt);
}

.data-table .positive {
    color: var(--positive);
}

.data-table .negative {
    color: var(--negative);
}

/* Sort arrows */
.data-table th .sort-arrow {
    font-size: 10px;
    margin-left: 4px;
    opacity: .4;
}

.data-table th.sorted .sort-arrow {
    opacity: 1;
    color: var(--green);
}

/* ---- Status Badges ---- */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .03em;
}

.badge.sale,
.badge.done,
.badge.paid,
.badge.full {
    background: var(--green-light);
    color: var(--green-mid);
}

.badge.cancel,
.badge.not_paid {
    background: #fde8e6;
    color: var(--negative);
}

.badge.draft,
.badge.sent,
.badge.partial {
    background: #fff5e0;
    color: var(--warning);
}

/* ---- Condition Cards ---- */
.condition-cards {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    margin-top: 14px;
}

.condition-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px;
    text-align: center;
}

.condition-card .name {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 8px;
}

.condition-card .val {
    font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    font-size: 20px;
    font-weight: 600;
    color: var(--green-dark);
}

.condition-card .sub {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: 4px;
}

/* ---- Rank badges (agent leaderboard) ---- */
.rank-badge {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 6px;
}

.rank-badge.gold {
    background: #FFD700;
}

.rank-badge.silver {
    background: #C0C0C0;
}

.rank-badge.standard {
    background: var(--border);
}

/* ---- Revenue Target Gauge ---- */
.gauge-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    flex-direction: column;
}

.gauge-ring {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: conic-gradient(var(--green) var(--pct, 0%), var(--surface-alt) 0%);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.gauge-ring::after {
    content: '';
    position: absolute;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--surface);
}

.gauge-label {
    position: relative;
    z-index: 1;
    font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    font-size: 20px;
    font-weight: 600;
    color: var(--green-dark);
}

/* ---- Skeleton loading ---- */
.skeleton {
    background: linear-gradient(90deg, var(--surface-alt) 25%, var(--border) 50%, var(--surface-alt) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

.skeleton-card {
    height: 100px;
}

.skeleton-chart {
    height: 280px;
    margin-top: 14px;
}

/* ---- Error & empty states ---- */
.error-banner {
    background: #fde8e6;
    color: var(--negative);
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 16px;
    display: none;
}

.error-banner.show {
    display: block;
}

.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-tertiary);
    font-size: 15px;
}

/* ---- Scrollable table wrapper ---- */
.table-wrap {
    overflow-x: auto;
    margin-top: 14px;
}

/* ---- Leaderboard row highlight ---- */
.lb-gold {
    background: #fffbe6 !important;
}

.lb-silver {
    background: #f8f9fa !important;
}

/* ---- KPI Row (for sub-tab KPIs) ---- */
.kpi-row {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.kpi-row .kpi-card {
    flex: 1;
    min-width: 160px;
}

/* ---- Custom date inputs ---- */
.custom-range {
    display: none;
    align-items: center;
    gap: 8px;
    margin-left: 10px;
}

.custom-range.show {
    display: flex;
}

.custom-range input[type="date"] {
    font: 500 13px 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    padding: 5px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

/* ---- Toggle Mini (inside KPI labels) ---- */
.toggle-mini {
    display: inline-block;
    font-size: 10px;
    text-transform: none;
    letter-spacing: 0;
    color: var(--green);
    cursor: pointer;
    margin-left: 4px;
    font-weight: 600;
    vertical-align: middle;
}

.toggle-mini:hover {
    color: var(--green-dark);
    text-decoration: underline;
}

.toggle-mini b {
    text-decoration: underline;
    color: var(--green-dark);
}

/* ---- Week Comparison Panel ---- */
.week-compare-panel {
    padding: 20px 24px;
}

.week-compare-row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    align-items: flex-end;
    margin-bottom: 12px;
}

.week-compare-group {
    display: flex;
    gap: 8px;
    align-items: center;
}

.week-compare-group label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
}

.week-compare-group input[type="month"] {
    font: 500 13px 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    padding: 5px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    width: 140px;
    cursor: pointer;
}

/* ---- Pie Chart with External Legend ---- */
.pie-container {
    display: flex;
    align-items: center;
    gap: 16px;
}

.pie-container canvas {
    max-width: 55%;
    flex-shrink: 0;
}

.pie-legend {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 280px;
    overflow-y: auto;
    flex: 1;
    min-width: 120px;
}

.pie-legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text);
}

.pie-legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.pie-legend-text {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pie-legend-pct {
    font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    font-weight: 600;
    font-size: 12px;
    color: var(--green-dark);
    white-space: nowrap;
}

/* ---- BCG Matrix Legend ---- */
.bcg-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}

.bcg-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--text-secondary);
}

.bcg-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}
/* ===== Global Loader Overlay ===== */
.gb-loader {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(245, 248, 246, 0.55);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease-out;
}
.gb-loader.show {
    opacity: 1;
    pointer-events: auto;
}
.gb-loader-spinner {
    width: 56px;
    height: 56px;
    border: 4px solid rgba(29, 185, 84, 0.18);
    border-top-color: #1DB954;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    box-shadow: 0 4px 18px rgba(11, 61, 11, 0.12);
}
.gb-loader-text {
    font: 500 13px/1.4 'SF Pro Display', -apple-system, sans-serif;
    color: #0B3D0B;
    letter-spacing: 0.02em;
}
/* Region pill flag - keep crisp at any size */
.region-flag { font-size: 14px; line-height: 1; display: inline-block; }
@media (min-width: 1280px) {
    .region-flag { font-size: 16px; }
}

/* =====================================================================
   MOBILE OPTIMISATION  (≤ 820px - phones & small tablets)
   Desktop view is untouched. Everything below only kicks in on small
   screens. Goals:
     • Top bar collapses to 2 stacked rows so logo, region & controls
       all remain accessible without overflow.
     • Tabs become a horizontally scrollable pill rail with snap points.
     • KPI cards reflow to 2 columns (then 1 on extra-small phones).
     • Charts auto-shrink height and tables become horizontally
       scrollable so wide content never breaks the layout.
     • Touch targets (buttons, pills, selects) are ≥ 40 px tall.
     • Sticky safe-area insets honoured for iPhone notch / home bar.
   ===================================================================== */
@media (max-width: 820px) {
    html, body {
        overflow-x: hidden;
        overflow-y: auto;
    }
    body {
        font-size: 13.5px;
        padding-bottom: env(safe-area-inset-bottom);
        -webkit-overflow-scrolling: touch;
    }
    .tab-content, .card, .glass-card, .panel {
        overflow: visible;
        -webkit-overflow-scrolling: touch;
    }

    /* ---- Top bar reflow ---- */
    .top-bar {
        flex-wrap: wrap;
        height: auto;
        min-height: 56px;
        padding: 8px 12px;
        gap: 8px;
        row-gap: 8px;
        padding-top: calc(8px + env(safe-area-inset-top));
    }
    .logo { font-size: 16px; gap: 6px; }
    .logo-img { height: 24px; }

    /* Region switcher: compact pills, no text labels (flag only) */
    .region-switcher {
        margin-left: auto;
        order: 2;
    }
    .region-btn { padding: 6px 10px; min-height: 36px; }
    .region-label { display: none; }

    /* Tabs become a horizontally scrollable rail under the top bar */
    .tabs {
        order: 4;
        width: 100%;
        flex: 0 0 100%;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        touch-action: pan-x;
        scroll-snap-type: x proximity;
        gap: 4px;
        padding: 2px 0 6px;
        margin: 0 -4px;
        scrollbar-width: none;
    }
    .tabs::-webkit-scrollbar { display: none; }
    .tab-btn {
        flex: 0 0 auto;
        scroll-snap-align: start;
        padding: 8px 14px;
        font-size: 13px;
        min-height: 38px;
        white-space: nowrap;
        border-radius: 999px;
        min-width: max-content;
    }
    .tab-scroll-hint { display: none; }

    /* Period + refresh controls: full width row, equal spacing */
    .controls {
        order: 3;
        flex: 1 1 auto;
        gap: 6px;
        flex-wrap: wrap;
        justify-content: flex-end;
    }
    .period-select {
        flex: 1 1 130px;
        min-height: 38px;
        font-size: 13px;
        padding: 6px 10px;
    }
    .refresh-btn {
        min-height: 38px;
        min-width: 38px;
        padding: 6px 12px;
        font-size: 14px;
    }

    /* ---- Main & tab content padding ---- */
    .main { padding: 10px; }
    .tab-content { padding: 0 !important; }
    .tab-content > * + * { margin-top: 12px; }

    /* ---- KPI grid → 2 cols on every phone size ---- */
    .kpi-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 10px;
    }
    .kpi-card {
        padding: 12px 14px;
    }
    .kpi-card .label, .kpi-card .kpi-label { font-size: 11px; }
    .kpi-card .value, .kpi-card .kpi-value { font-size: 18px; line-height: 1.15; }
    .kpi-card .sub, .kpi-card .kpi-sub { font-size: 11px; }

    /* ---- Cards / Sections ---- */
    .card, .glass-card, .panel, .card-block {
        padding: 12px !important;
        border-radius: 12px;
    }
    .card-label, .section-title, .panel-title {
        font-size: 12px;
        letter-spacing: .04em;
    }

    /* ---- Charts: 2-column grid on phones (instead of 1-col stack) ---- */
    .chart-grid,
    .chart-grid.three,
    .grid-2, .grid-3, .grid-4 {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 10px !important;
    }
    /* Full-width charts stay full-width even on phones */
    .chart-grid.full {
        grid-template-columns: 1fr !important;
    }
    .chart-container {
        height: 200px !important;
        min-height: 180px !important;
    }
    /* Slightly taller for tall stacked charts */
    .chart-container.tall { height: 280px !important; }

    /* Customer summary tri-grid → 3 across stays, compact font */
    .customer-tri-grid { gap: 8px; }
    .cust-stat { padding: 8px 6px; }
    .cust-stat-value { font-size: 18px; }
    .cust-stat-label { font-size: 10px; letter-spacing: .04em; }

    /* ---- Tables: horizontal scroll inside a wrapper, never break layout ---- */
    .data-table, table.data-table {
        font-size: 12px;
        min-width: 520px; /* triggers horizontal scroll on narrow phones */
    }
    .data-table th, .data-table td {
        padding: 8px 8px;
    }
    /* Wrap tables that aren't already in a scroll container */
    .table-wrap, .table-scroll {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    /* Hide low-priority columns (any th/td with .hide-mobile class) */
    .hide-mobile { display: none !important; }

    /* ---- Loader overlay: tighter ---- */
    .gb-loader-spinner { width: 44px; height: 44px; border-width: 3px; }
    .gb-loader-text { font-size: 12px; }

    /* ---- Top bar pill / status badges ---- */
    .top-bar .status-pill, .top-bar .gb-monitor-pill {
        height: 30px;
        min-width: 30px;
    }
}

/* Extra-small phones (≤ 480px) - keep 2 columns, just tighter */
@media (max-width: 480px) {
    body { font-size: 13px; }
    .top-bar { padding: 6px 10px; }
    .main { padding: 8px; }
    .logo { font-size: 15px; }
    .logo-img { height: 22px; }
    .region-btn { padding: 5px 8px; min-height: 34px; }

    /* Stay 2 cols even on tiny phones (user request) */
    .kpi-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 8px;
    }
    .kpi-card { padding: 10px 10px; }
    .kpi-card .value, .kpi-card .kpi-value { font-size: 16px; }
    .chart-container { height: 180px !important; min-height: 160px !important; }
    .tab-btn { padding: 7px 12px; font-size: 12.5px; }
    .period-select { flex-basis: 100%; }
    .controls { justify-content: stretch; }

    /* Marketing tab screenshots - 2 cols on phones (user request) */
    .marketing-grid, .platform-grid, .screenshot-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 8px;
    }

    /* Stop monstrously long table headers wrapping ugly */
    .data-table th { font-size: 10.5px; padding: 7px 6px; }
    .data-table td { font-size: 12px; padding: 7px 6px; }
}

/* ---- Very small screens (≤380px) - auto-scroll the active tab label
   so users on iPhone SE / folded phones still see the full word.
   The tabs row already scrolls horizontally; this animates the label of
   the currently-selected tab so its full text is visible without swiping. */
@media (max-width: 380px) {
    .tabs .tab-btn.active {
        max-width: 92px;
        position: relative;
    }
    .tabs .tab-btn.active::after {
        content: "";
        position: absolute;
        top: 0; right: 0; bottom: 0;
        width: 14px;
        background: linear-gradient(90deg, transparent, rgba(11, 61, 11, 0.95));
        pointer-events: none;
    }
    .tabs .tab-btn.active {
        animation: tab-marquee-scroll 5.5s linear infinite;
    }
}

@keyframes tab-marquee-scroll {
    0%, 18%   { text-indent: 0; }
    50%, 68%  { text-indent: -42px; }
    100%      { text-indent: 0; }
}

/* ---- Tablet portrait (821px–1024px) - 3-col KPIs, 2-col charts ---- */
@media (min-width: 821px) and (max-width: 1024px) {
    .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .chart-grid.three { grid-template-columns: repeat(2, 1fr); }
    .chart-container { height: 280px; }
}

/* ---- Touch device tweaks (no hover, larger hit areas) ---- */
@media (hover: none) and (pointer: coarse) {
    .tab-btn, .region-btn, .refresh-btn, .period-select {
        -webkit-tap-highlight-color: rgba(29, 185, 84, 0.18);
    }
    .kpi-card:hover, .cust-stat:hover, .customer-summary-card:hover {
        transform: none;  /* no lift on tap, prevents jitter */
    }
}

/* ---- Print: hide controls so PDF exports look clean (small win) ---- */
@media print {
    .top-bar .controls, .tab-scroll-hint, .gb-loader { display: none !important; }
    .tab-content { padding: 0 !important; }
}


/* ── Accessibility (WCAG 2.1 AA) ─────────────────────────────────── */
.skip-link {
    position: absolute;
    top: -40px;
    left: 8px;
    z-index: 10000;
    padding: 8px 14px;
    background: #0B3D0B;
    color: #fff;
    text-decoration: none;
    border-radius: 0 0 6px 6px;
    font-weight: 600;
    transition: top 0.2s ease;
}
.skip-link:focus {
    top: 0;
    outline: 3px solid #FFD700;
    outline-offset: 2px;
}
:focus-visible {
    outline: 2px solid #2E7FBF;
    outline-offset: 2px;
    border-radius: 3px;
}
button:focus-visible,
a:focus-visible,
[role="tab"]:focus-visible {
    outline: 2px solid #2E7FBF;
    outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
@media (prefers-contrast: more) {
    .card { border-width: 2px; }
}

/* ===== Chart enhancements: top-right hover summary & value legend ===== */
.chart-month-summary {
    font: 500 12px/1.3 'SF Pro Display', -apple-system, sans-serif;
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
.chart-month-summary .cms-month {
    color: var(--text-primary);
    font-weight: 600;
}
.chart-month-summary .cms-dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    margin-right: 4px;
    vertical-align: middle;
}
.chart-month-summary .cms-sep {
    margin: 0 4px;
    color: var(--text-tertiary, #9aa3a0);
}
.chart-month-summary strong {
    color: var(--text-primary);
    font-weight: 600;
    margin-right: 2px;
}
.chart-value-legend {
    margin-top: 10px;
    padding: 8px 4px 2px;
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    font: 500 12px/1.4 'SF Pro Display', -apple-system, sans-serif;
    color: var(--text-secondary);
    border-top: 1px solid var(--border-color, #E2E8E4);
    align-items: center;
}
.chart-value-legend .cvl-mode {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-tertiary, #9aa3a0);
    margin-right: 4px;
    font-weight: 600;
}
.chart-value-legend .cvl-item {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
}
.chart-value-legend .cvl-dot {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    display: inline-block;
}
.chart-value-legend .cvl-label {
    color: var(--text-primary);
    font-weight: 500;
}
.chart-value-legend .cvl-value {
    color: var(--text-primary);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

/* ===== Marketing scrape progress bar (smooth animated) ===== */
.mkt-progress-bar {
    position: relative;
    width: 160px;
    height: 6px;
    background: rgba(29,185,84,0.15);
    border-radius: 999px;
    overflow: hidden;
    display: inline-block;
    vertical-align: middle;
    margin: 0 8px;
}
.mkt-progress-bar > .mkt-progress-fill {
    position: absolute;
    top: 0; left: 0; bottom: 0;
    width: 0%;
    background: linear-gradient(90deg, #1DB954, #2E7FBF);
    border-radius: 999px;
    transition: width 0.45s ease-out;
}
.mkt-progress-bar > .mkt-progress-shimmer {
    position: absolute;
    top: 0; bottom: 0;
    width: 40%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.55), transparent);
    animation: mkt-shimmer 1.4s linear infinite;
}
@keyframes mkt-shimmer {
    0%   { left: -40%; }
    100% { left: 100%; }
}
@media (prefers-reduced-motion: reduce) {
    .mkt-progress-bar > .mkt-progress-shimmer { animation: none; opacity: 0; }
    .mkt-progress-bar > .mkt-progress-fill    { transition: none; }
}

/* ===== Mobile scroll fix =====
   Safari iOS treats `background-attachment: fixed` on body as a blocking
   compositing layer that intermittently traps touch-scroll. Switch to
   `scroll` on small viewports so panning always works. */
@media (max-width: 900px) {
    html, body {
        -webkit-overflow-scrolling: touch;
        touch-action: manipulation;
    }
    body {
        background-attachment: scroll !important;
        min-height: 100vh;
        min-height: 100dvh;
    }
    .gb-loader:not(.show) {
        display: none !important;
        pointer-events: none !important;
    }
    .table-wrap, .table-scroll {
        touch-action: pan-x pan-y;
    }
}

/* ============================================================
   Analytics tab: visible ONLY in Global region.
   The existing .tabs.global-mode rule hides every non-Overview
   tab; this exception keeps the Analytics tab visible in Global
   mode, and hides it everywhere else.
   ============================================================ */

/* Hide the Analytics tab button by default (Kenya / Nigeria modes). */
.tabs .tab-btn[data-tab="analytics"] {
    display: none;
}

/* In Global mode, show the Analytics tab button. Override the
   non-overview hiding rule by re-asserting visibility. */
.tabs.global-mode .tab-btn[data-tab="analytics"] {
    display: inline-flex;
    opacity: 1;
    max-width: none;
    padding-left: 14px;
    padding-right: 14px;
    transform: none;
    pointer-events: auto;
    overflow: visible;
}

/* Iframe container fills the tab area; iframe fills the container. */
.analytics-embed-wrap {
    width: 100%;
    height: calc(100vh - 220px);
    min-height: 600px;
    background: #F0F5F2;
    border-radius: 8px;
    overflow: hidden;
}
.analytics-embed-frame {
    width: 100%;
    height: 100%;
    border: 0;
    display: block;
}
