/* Google Fonts loaded via <link> in index.html for faster first paint */

/* HouseBets Design System */
:root {
    --hb-primary: #02F7ED;
    --hb-primary-dark: #00d4cc;
    --hb-dark-teal: #001719;
    --hb-dark-bean: #00171B;
    --hb-bg: #000d0f;

    --success: #10b981;
    --success-dark: #059669;
    --warning: #ff6b35;
    --info: #007bff;
    --muted: #6c757d;
    --danger: #ef4444;

    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --text-muted: rgba(255, 255, 255, 0.5);

    --border-color: rgba(2, 247, 237, 0.2);
    --border-color-hover: rgba(2, 247, 237, 0.4);

    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;

    --shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.4);

    /* Fonts */
    --font-heading: 'Oxanium', sans-serif;
    --font-body: 'Roboto', sans-serif;
    
    /* Compatibility aliases */
    --hb-surface: #00171B;
    --hb-surface-raised: #001f22;

    /* Card / panel backgrounds */
    --card-bg: #0a1e28;
    --card-border: rgba(2, 247, 237, 0.12);

    /* Negative / positive */
    --negative: #f87171;
}

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

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

/* App Container - Full width Bloomberg style */
.app-container {
    max-width: 100%;
    margin: 0;
    padding: 0;
}

.tab-content {
    padding: 20px 24px;
}

/* Header - Bloomberg Style */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 24px;
    background: var(--hb-bg);
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

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

.header-logo {
    height: 22px;
    width: auto;
}

.header-divider {
    width: 1px;
    height: 24px;
    background: var(--border-color);
}

.header-title {
    display: flex;
    flex-direction: column;
}

.title-main {
    font-family: var(--font-heading);
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: 1px;
}

.title-sub {
    font-family: var(--font-body);
    font-size: 11px;
    color: var(--text-muted);
}

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

.header-status {
    display: flex;
    align-items: center;
    gap: 6px;
}

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

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

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

.status-text {
    font-family: var(--font-heading);
    font-size: 11px;
    font-weight: 600;
    color: var(--success);
    letter-spacing: 0.5px;
}

.header-timestamp {
    font-family: var(--font-body);
    font-size: 11px;
    color: var(--text-muted);
}

/* User Authentication */
.user-auth {
    display: flex;
    align-items: center;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-info.hidden {
    display: none;
}

#googleSignIn.hidden {
    display: none;
}

.user-name {
    font-size: 12px;
    color: var(--text-primary);
    font-weight: 500;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sign-out-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 11px;
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sign-out-btn:hover {
    border-color: var(--hb-primary);
    color: var(--hb-primary);
}

.manage-users-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.manage-users-btn:hover {
    border-color: var(--hb-primary);
    color: var(--hb-primary);
}

.manage-users-btn svg {
    width: 14px;
    height: 14px;
}

.hidden {
    display: none !important;
}

/* Sign In Overlay */
.sign-in-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--hb-bg);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sign-in-overlay.hidden {
    display: none !important;
}

.sign-in-container {
    text-align: center;
    max-width: 420px;
    padding: 48px;
}

.sign-in-logo {
    margin-bottom: 48px;
}

.sign-in-logo img {
    height: 40px;
    width: auto;
}

.sign-in-title {
    font-family: var(--font-heading);
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 3px;
    margin: 0 0 8px 0;
}

.sign-in-subtitle {
    font-family: var(--font-body);
    font-size: 13px;
    color: var(--text-secondary);
    margin: 0 0 32px 0;
}

.sign-in-divider {
    width: 60px;
    height: 2px;
    background: var(--hb-primary);
    margin: 0 auto 32px auto;
}

.sign-in-prompt {
    font-family: var(--font-body);
    font-size: 11px;
    color: var(--text-muted);
    margin: 0 0 20px 0;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.sign-in-button-container {
    display: flex;
    justify-content: center;
    margin-bottom: 24px;
}

.sign-in-footer {
    font-family: var(--font-body);
    font-size: 10px;
    color: var(--text-muted);
    margin: 0;
    opacity: 0.6;
}

/* Buttons - Bloomberg muted style */
.btn {
    font-family: var(--font-heading);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border: none;
    border-radius: 2px;
    font-size: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.btn-primary {
    background: var(--hb-primary);
    color: var(--hb-bg);
}

.btn-primary:hover {
    background: var(--hb-primary);
}

.btn-secondary {
    background: var(--hb-surface-raised);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--hb-surface);
    border-color: var(--border-color-hover);
    color: var(--hb-primary);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    background: var(--success-dark);
}

.btn-icon {
    font-size: 16px;
}

.btn-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 24px;
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
}

.btn-close:hover {
    color: var(--text-primary);
}

/* Stats Cards - Bloomberg Style */
.stats-container {
    display: flex;
    gap: 0;
    background: var(--hb-bg);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    margin-bottom: 20px;
}

.stat-card {
    flex: 1;
    background: transparent;
    padding: 16px 20px;
    text-align: left;
    cursor: pointer;
    transition: all 0.15s ease;
    border-right: 1px solid var(--border-color);
}

.stat-card:last-child {
    border-right: none;
}

.stat-card:hover {
    background: rgba(2, 247, 237, 0.03);
}

.stat-card.active {
    background: rgba(2, 247, 237, 0.05);
}

.stat-label {
    font-family: var(--font-heading);
    font-size: 9px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 4px;
}

.stat-value {
    font-family: var(--font-heading);
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
}

.stat-value.stat-warning { color: var(--warning); }
.stat-value.stat-success { color: var(--success); }
.stat-value.stat-danger { color: var(--danger); }
.stat-value.stat-info { color: var(--hb-primary); }
.stat-value.stat-muted { color: var(--muted); }

/* Reusable text color classes for table cells */
.stat-success { color: var(--success); }
.stat-danger-text { color: var(--danger); }
.stat-warning-text { color: var(--warning); }

/* Trend arrows (period-over-period comparison) */
.trend-arrow {
    font-size: 8px;
    margin-left: 3px;
    vertical-align: middle;
    opacity: 0.85;
}
.trend-arrow.trend-up { color: var(--success); }
.trend-arrow.trend-down { color: var(--danger); }

/* Search - Bloomberg Style */
.deals-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    gap: 16px;
}

.search-container {
    flex: 1;
}

.search-input {
    font-family: var(--font-body);
    width: 100%;
    max-width: 320px;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: 2px;
    color: var(--text-primary);
    font-size: 12px;
}

.view-toggle {
    display: flex;
    gap: 0;
}

.view-btn {
    font-family: var(--font-heading);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    padding: 8px 16px;
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.view-btn:first-child {
    border-radius: 4px 0 0 4px;
}

.view-btn:last-child {
    border-radius: 0 4px 4px 0;
    border-left: none;
}

.view-btn:hover {
    color: var(--text-primary);
    border-color: var(--hb-primary);
}

.view-btn.active {
    background: var(--hb-primary);
    border-color: var(--hb-primary);
    color: var(--hb-bg);
}

/* expand-arrow for partner/bill rows */
.expand-arrow {
    font-size: 10px;
    color: var(--hb-primary);
    margin-right: 4px;
}

.campaign-count {
    color: var(--text-secondary);
    font-size: 11px;
}

.partner-total-fee {
    color: var(--hb-primary);
}

/* Payment badges */
.payment-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
}

.payment-complete {
    background: var(--success);
    color: white;
}

.payment-partial {
    background: #f59e0b;
    color: white;
}

.payment-pending {
    background: var(--warning);
    color: #000;
}

.payment-na {
    background: var(--muted);
    color: white;
}

.fee-agreed {
    font-weight: 600;
    color: var(--text-primary);
}

.fee-paid {
    color: var(--hb-primary);
}

/* Campaign Sub-table */
.campaign-table-container {
    margin-top: 24px;
    background: rgba(0, 212, 170, 0.03);
    border: 1px solid var(--hb-primary);
    border-radius: 4px;
    padding: 16px;
}

.campaign-table-container.hidden {
    display: none;
}

.campaign-table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.campaign-table-header h3 {
    font-family: var(--font-heading);
    font-size: 14px;
    font-weight: 600;
    color: var(--hb-primary);
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.campaign-table {
    width: 100%;
    border-collapse: collapse;
}

.campaign-table th {
    font-family: var(--font-heading);
    font-size: 10px;
    font-weight: 600;
    color: var(--hb-primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 8px 10px;
    text-align: left;
    border-bottom: 1px solid var(--hb-primary);
}

.campaign-table td {
    font-size: 12px;
    padding: 10px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

.campaign-table tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

.btn-sm {
    padding: 4px 10px;
    font-size: 10px;
}

.btn-xs {
    padding: 3px 8px;
    font-size: 9px;
}

/* Inline Campaign Table */
/* Partner row styling */
.partner-row {
    cursor: pointer;
    background: var(--hb-dark-teal);
}

.partner-row td {
    font-weight: 500;
    border-bottom: 1px solid var(--border-color);
}

.partner-row:hover {
    background: #002528;
}

.partner-row.expanded {
    background: #002025;
    border-left: 2px solid var(--hb-primary);
}

.partner-row .chevron {
    display: inline-block;
    transition: transform 0.2s ease;
    color: var(--text-muted);
    font-size: 10px;
    width: 20px;
}

.partner-row.expanded .chevron {
    transform: rotate(90deg);
    color: var(--hb-primary);
}

.partner-row.no-campaigns .chevron {
    visibility: hidden;
}

/* Legacy support for inline campaign table */
.campaign-header-row {
    background: rgba(0, 0, 0, 0.3);
}

.campaign-header-row > td {
    padding: 0 !important;
    border: none !important;
}

.inline-campaign-table {
    width: 100%;
    border-collapse: collapse;
    margin: 8px 0;
}

.inline-campaign-table th {
    font-family: var(--font-heading);
    font-size: 9px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 6px 8px;
    text-align: left;
    background: rgba(0, 212, 170, 0.1);
    border-bottom: 1px solid var(--border-color);
}

.inline-campaign-table td {
    font-size: 11px;
    padding: 8px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

/* Bills Tab Styles */
.bills-subtabs {
    display: flex;
    gap: 0;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border-color);
}

.subtab-btn {
    font-family: var(--font-heading);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    padding: 12px 24px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    position: relative;
    transition: color 0.2s ease;
}

.subtab-btn:hover {
    color: var(--text-primary);
}

.subtab-btn.active {
    color: var(--hb-primary);
}

.subtab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--hb-primary);
}

.bills-section {
    display: none;
}

.bills-section.active {
    display: block;
}

.bills-stats {
    margin-bottom: 20px;
}

.bills-note {
    margin-top: 16px;
    font-size: 11px;
    color: var(--text-muted);
    font-style: italic;
}

.bills-table table {
    min-width: 900px;
}

.bills-table .partner-row {
    cursor: pointer;
    background: var(--hb-dark-teal);
}

.bills-table .partner-row:hover {
    background: #002528;
}

.bills-table .partner-row.expanded {
    background: #002025;
    border-left: 2px solid var(--hb-primary);
}

.bills-table .partner-row .chevron {
    color: var(--hb-primary);
    font-size: 10px;
}

.bills-table .campaign-count-label {
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 400;
    margin-top: 2px;
}

.bills-table .inline-campaign-table {
    width: 100%;
    background: #000a0b;
    border-radius: var(--radius-sm);
}

.bills-table .inline-campaign-table th {
    background: rgba(2, 247, 237, 0.05);
    font-size: 11px;
    padding: 8px 12px;
}

.bills-table .inline-campaign-table td {
    padding: 8px 12px;
    font-size: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.bills-table .bill-row.canceled td {
    opacity: 0.5;
}

.bills-table .bill-row.pending td {
    background: rgba(255, 193, 7, 0.03);
}

.bills-table .bill-row.paid td {
    background: rgba(16, 185, 129, 0.03);
}

.bills-table .bill-row.month-row {
    cursor: pointer;
}

.bills-table .bill-row.month-row:hover td {
    background: rgba(0, 200, 170, 0.1);
}

.bills-table .bill-row.month-row td:first-child .chevron {
    color: var(--hb-primary);
    font-size: 10px;
}

.bills-table .campaign-detail-row td {
    padding-left: 20px;
    font-size: 11px;
    background: rgba(0, 50, 50, 0.08) !important;
    border: none !important;
    color: var(--text-muted);
}

.bills-table .campaign-detail-row td:first-child {
    border-left: 2px solid rgba(0, 200, 170, 0.3) !important;
}

.bills-table .campaign-detail-row:hover td {
    background: rgba(0, 50, 50, 0.12) !important;
}

.bills-table .campaign-detail-row td:first-child {
    padding-left: 8px;
}

.bills-table .campaign-detail-row .campaign-name {
    color: var(--text-primary);
    font-weight: 500;
}

.bills-table .campaign-detail-row .frequency-label {
    color: var(--text-muted);
    font-size: 10px;
    font-style: italic;
    margin-left: 8px;
}

.text-muted {
    color: var(--text-muted);
}

/* Bill action buttons */
.btn-small {
    padding: 4px 8px;
    font-size: 10px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    margin-right: 4px;
    font-weight: 600;
    transition: all 0.2s;
}

.btn-tiny {
    padding: 2px 6px;
    font-size: 10px;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    margin-right: 3px;
    font-weight: 600;
    transition: all 0.2s;
}

.btn-success {
    background: rgba(16, 185, 129, 0.2);
    color: #10b981;
}

.btn-success:hover {
    background: rgba(16, 185, 129, 0.4);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.4);
}

.action-cell {
    white-space: nowrap;
}

/* Warning row for campaign verification */
.bills-table .warning-row td {
    background: rgba(255, 193, 7, 0.05) !important;
    border: none !important;
    padding: 6px 20px;
}

.warning-text {
    font-size: 10px;
    color: #f59e0b;
    font-style: italic;
}

.warning-icon {
    font-size: 11px;
}

/* Clickable status badge */
.clickable-badge {
    cursor: pointer;
    transition: all 0.2s;
}

.clickable-badge:hover {
    filter: brightness(1.2);
    transform: scale(1.05);
}

/* Bill status editor popup */
.bill-status-editor {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.2s;
}

.bill-status-editor.visible {
    opacity: 1;
}

.bill-status-editor-content {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px;
    min-width: 200px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
}

.editor-header {
    font-size: 12px;
    font-weight: 600;
    color: var(--hb-primary);
    text-transform: uppercase;
    margin-bottom: 12px;
    text-align: center;
}

.editor-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}

.status-option {
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 8px 12px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.status-option:hover {
    background: rgba(0, 200, 170, 0.1);
    border-color: var(--hb-primary);
}

.status-option.current {
    background: rgba(0, 200, 170, 0.15);
    border-color: var(--hb-primary);
}

.editor-close {
    width: 100%;
    padding: 8px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 11px;
    transition: all 0.2s;
}

.editor-close:hover {
    background: rgba(255, 255, 255, 0.05);
}

.bills-table .amount-pending {
    color: var(--danger);
    font-weight: 600;
}

.bills-scroll-container {
    max-height: 400px;
    overflow-y: auto;
    border-radius: var(--radius-sm);
}

.bills-scroll-container::-webkit-scrollbar {
    width: 6px;
}

.bills-scroll-container::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
}

.bills-scroll-container::-webkit-scrollbar-thumb {
    background: var(--hb-primary);
    border-radius: 3px;
    opacity: 0.5;
}

.bills-table .inline-campaign-table th[data-sort] {
    cursor: pointer;
}

.bills-table .inline-campaign-table th[data-sort]:hover {
    color: var(--hb-primary);
}

.bills-table .inline-campaign-table .sort-icon {
    font-size: 10px;
    margin-left: 4px;
    opacity: 0.5;
}

.bills-table .inline-campaign-table .sort-icon.active {
    opacity: 1;
    color: var(--hb-primary);
}

.search-input:focus {
    outline: none;
    border-color: var(--hb-primary);
    background: rgba(0, 0, 0, 0.4);
}

.search-input::placeholder {
    color: var(--text-muted);
}

/* Main Content Layout */
.main-content {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 24px;
}

/* Table Container - Bloomberg Style */
.table-container {
    background: var(--hb-bg);
    border: 1px solid var(--border-color);
    overflow: auto;
    max-height: calc(100vh - 280px);
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead {
    background: var(--hb-bg);
    position: sticky;
    top: 0;
    z-index: 10;
}

th {
    font-family: var(--font-heading);
    padding: 10px 12px;
    text-align: left;
    font-size: 9px;
    font-weight: 600;
    color: var(--hb-primary);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    background: var(--hb-surface);
    border-bottom: 1px solid var(--border-color);
}

th:hover {
    color: var(--hb-primary);
    background: var(--hb-surface-raised);
}


.sort-icon {
    margin-left: 4px;
    opacity: 0.4;
    font-size: 9px;
    transition: opacity 0.2s, color 0.2s;
}

.sort-icon.active {
    opacity: 1;
    color: var(--hb-primary);
}

td {
    padding: 8px 10px;
    font-size: 12px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    font-family: var(--font-body);
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    position: relative;
}

/* Tooltip for truncated text */
td[title]:hover::after {
    content: attr(title);
    position: absolute;
    left: 0;
    top: 100%;
    background: var(--hb-dark-bean);
    border: 1px solid var(--hb-primary);
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 12px;
    color: var(--text-primary);
    white-space: nowrap;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    max-width: 400px;
    overflow: hidden;
    text-overflow: ellipsis;
}

tbody tr {
    cursor: pointer;
    transition: background 0.1s ease;
}

tbody tr:hover {
    background: var(--hb-surface);
}

tbody tr.selected {
    background: var(--hb-surface-raised);
}

.loading-cell {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
    font-family: var(--font-body);
}

/* Status Badges - Bloomberg muted style */
.badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 2px;
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-live { background: rgba(45, 154, 110, 0.2); color: var(--success); border: 1px solid rgba(45, 154, 110, 0.3); }
.badge-in-process { background: rgba(74, 144, 164, 0.2); color: var(--info); border: 1px solid rgba(74, 144, 164, 0.3); }
.badge-inactive { background: rgba(74, 85, 104, 0.2); color: var(--text-muted); border: 1px solid rgba(74, 85, 104, 0.3); }
.badge-not-set { background: rgba(212, 131, 47, 0.2); color: var(--warning); border: 1px solid rgba(212, 131, 47, 0.3); }
.badge-future { background: rgba(120, 120, 180, 0.2); color: #9090d0; border: 1px solid rgba(120, 120, 180, 0.3); }
.badge-needs-setup { background: rgba(212, 131, 47, 0.2); color: var(--warning); border: 1px solid rgba(212, 131, 47, 0.3); }
.badge-missing-details { background: rgba(212, 131, 47, 0.15); color: var(--warning); border: 1px solid rgba(212, 131, 47, 0.25); }
.badge-ok { background: rgba(45, 154, 110, 0.2); color: var(--success); border: 1px solid rgba(45, 154, 110, 0.3); }

/* Strategic Recommendation Badges */
.badge-scale-up { background: rgba(34, 197, 94, 0.25); color: #22c55e; border: 1px solid rgba(34, 197, 94, 0.4); font-weight: 600; }
.badge-maintain { background: rgba(59, 130, 246, 0.2); color: #3b82f6; border: 1px solid rgba(59, 130, 246, 0.3); }
.badge-optimize { background: rgba(251, 191, 36, 0.2); color: #f59e0b; border: 1px solid rgba(251, 191, 36, 0.3); }
.badge-review { background: rgba(156, 163, 175, 0.2); color: #9ca3af; border: 1px solid rgba(156, 163, 175, 0.3); }
.badge-terminate { background: rgba(239, 68, 68, 0.25); color: #ef4444; border: 1px solid rgba(239, 68, 68, 0.4); font-weight: 600; }
.badge-reactivate { background: rgba(34, 211, 238, 0.2); color: #22d3ee; border: 1px solid rgba(34, 211, 238, 0.3); font-weight: 600; }
.badge-dormant { background: rgba(75, 85, 99, 0.3); color: #6b7280; border: 1px solid rgba(75, 85, 99, 0.4); }
.badge-extend { background: rgba(45, 154, 110, 0.2); color: var(--success); border: 1px solid rgba(45, 154, 110, 0.3); }

/* Deal Status Badges */
.badge-deal-active { background: rgba(34, 197, 94, 0.2); color: #22c55e; border: 1px solid rgba(34, 197, 94, 0.3); }
.badge-deal-inactive { background: rgba(75, 85, 99, 0.3); color: #6b7280; border: 1px solid rgba(75, 85, 99, 0.4); }
.badge-paused { background: rgba(251, 191, 36, 0.2); color: #f59e0b; border: 1px solid rgba(251, 191, 36, 0.3); }

/* Payback ratio colors */
.payback-excellent { color: #22c55e !important; font-weight: 600; }
.payback-good { color: #3b82f6 !important; }
.payback-warning { color: #f59e0b !important; }
.payback-poor { color: #ef4444 !important; }

/* Velocity colors */
.velocity-excellent { color: #22c55e !important; font-weight: 600; }
.velocity-good { color: #22c55e !important; }
.velocity-warning { color: #f59e0b !important; }
.velocity-poor { color: #ef4444 !important; }

/* Trend badges */
.badge-trend-up { background: rgba(34, 197, 94, 0.2); color: #22c55e; border: 1px solid rgba(34, 197, 94, 0.3); font-size: 10px; }
.badge-trend-stable { background: rgba(156, 163, 175, 0.2); color: #9ca3af; border: 1px solid rgba(156, 163, 175, 0.3); font-size: 10px; }
.badge-trend-down { background: rgba(239, 68, 68, 0.2); color: #ef4444; border: 1px solid rgba(239, 68, 68, 0.3); font-size: 10px; }

/* Text utility classes */
.text-success { color: #22c55e; }
.text-danger { color: #ef4444; }
.text-warning { color: #f59e0b; }
.text-muted { color: #6b7280; }

/* Form Panel */
.form-panel {
    background: var(--hb-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    height: fit-content;
    position: sticky;
    top: 24px;
}

.form-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 20px;
    background: var(--hb-surface-raised);
    border-bottom: 1px solid var(--border-color);
}

.form-header h2 {
    font-family: var(--font-heading);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-content {
    padding: 20px;
}

.form-placeholder {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

/* Form Elements */
.form-deal-info {
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.form-deal-info h3 {
    color: var(--hb-primary);
    font-size: 16px;
    margin-bottom: 4px;
}

.form-deal-info p {
    color: var(--text-secondary);
    font-size: 13px;
}

.form-deal-info .commission-title {
    color: var(--text-muted);
    font-size: 11px;
    margin-top: 4px;
}

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

.form-label {
    font-family: var(--font-heading);
    display: block;
    font-size: 10px;
    font-weight: 600;
    color: var(--hb-primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.form-hint {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
    font-style: italic;
}

.form-current {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}

.form-current.not-set {
    color: var(--warning);
}

.form-input,
.form-select {
    font-family: var(--font-body);
    width: 100%;
    padding: 10px 12px;
    background: rgba(2, 247, 237, 0.05);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
}

.form-input:focus,
.form-select:focus {
    outline: none;
    border-color: var(--hb-primary);
}

.form-select {
    cursor: pointer;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.form-actions {
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.form-actions .btn {
    width: 100%;
}

/* Toast Notifications */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 16px 24px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease;
    z-index: 1000;
    max-width: 400px;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast.success {
    background: var(--success);
    color: white;
}

.toast.error {
    background: var(--danger);
    color: white;
}

.toast.info {
    background: var(--info);
    color: white;
}

/* Responsive */
@media (max-width: 1200px) {
    .main-content {
        grid-template-columns: 1fr;
    }

    .form-panel {
        position: fixed;
        top: 0;
        right: -420px;
        width: 400px;
        height: 100vh;
        border-radius: 0;
        transition: right 0.3s ease;
        z-index: 100;
    }

    .form-panel.open {
        right: 0;
    }

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

@media (max-width: 768px) {
    .app-header {
        flex-direction: column;
        gap: 16px;
        text-align: center;
    }

    .stats-container {
        grid-template-columns: repeat(2, 1fr);
    }

    .form-panel {
        width: 100%;
        right: -100%;
    }
}

/* ============ TAB NAVIGATION - Bloomberg Style ============ */
.tab-nav {
    display: flex;
    gap: 0;
    background: var(--hb-dark-bean);
    border-bottom: 1px solid var(--border-color);
    padding: 0 24px;
}

.tab-btn {
    font-family: var(--font-heading);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 20px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: -1px;
}

.tab-btn:hover {
    color: var(--text-primary);
    background: rgba(2, 247, 237, 0.03);
}

.tab-btn.active {
    background: transparent;
    color: var(--hb-primary);
    border-bottom-color: var(--hb-primary);
}

.tab-content {
    display: none;
}

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

/* ============ LEADERBOARD STYLES ============ */
.leaderboard-stats {
    /* Uses default flex layout */
}

.leaderboard-controls {
    display: flex;
    align-items: center;
    margin-bottom: 16px;
    gap: 12px;
}

.leaderboard-controls .search-input {
    flex: 1;
    max-width: 320px;
}

.leaderboard-controls .month-picker {
    flex-shrink: 0;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    z-index: 20;
}

/* Make the controls row a positioning context */
.leaderboard-controls {
    position: relative;
}

.leaderboard-controls .btn-secondary {
    flex-shrink: 0;
    margin-left: auto;
}

/* ==================== Month Picker ==================== */
.month-picker {
    position: relative;
}

.month-picker-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: var(--hb-surface-raised);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 13px;
    font-family: 'Roboto', sans-serif;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.month-picker-toggle:hover {
    border-color: var(--border-color-hover);
    color: var(--hb-primary);
}

.month-picker-toggle.active {
    border-color: var(--hb-primary);
    color: var(--hb-primary);
}

.month-picker-caret {
    font-size: 10px;
    opacity: 0.6;
    transition: transform 0.2s ease;
}

.month-picker.open .month-picker-caret {
    transform: rotate(180deg);
}

.month-picker-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    width: 340px;
    background: var(--hb-surface-raised);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    z-index: 200;
    overflow: hidden;
}

.month-picker.open .month-picker-dropdown {
    display: block;
}

.month-picker-header {
    display: flex;
    gap: 6px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-color);
}

.month-picker-preset {
    padding: 5px 10px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 11px;
    font-family: 'Roboto', sans-serif;
    cursor: pointer;
    transition: all 0.15s ease;
}

.month-picker-preset:hover {
    border-color: var(--border-color-hover);
    color: var(--text-primary);
}

.month-picker-preset.active {
    background: rgba(2, 247, 237, 0.1);
    border-color: var(--hb-primary);
    color: var(--hb-primary);
}

.month-picker-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
    padding: 10px 12px;
    max-height: 260px;
    overflow-y: auto;
}

.month-picker-grid::-webkit-scrollbar {
    width: 4px;
}

.month-picker-grid::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 2px;
}

.month-btn {
    padding: 6px 4px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 11px;
    font-family: 'Roboto', sans-serif;
    cursor: pointer;
    transition: all 0.15s ease;
    text-align: center;
}

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

.month-btn.selected {
    background: rgba(2, 247, 237, 0.12);
    border-color: rgba(2, 247, 237, 0.3);
    color: var(--hb-primary);
}

.month-picker-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    border-top: 1px solid var(--border-color);
}

.month-picker-count {
    font-size: 11px;
    color: var(--text-muted);
}

.month-picker-apply {
    padding: 5px 16px !important;
    font-size: 11px !important;
    min-height: auto;
}

.leaderboard-table {
    overflow: auto;
    max-height: calc(100vh - 280px);
}

.leaderboard-table table {
    width: 100%;
    border-collapse: collapse;
}

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

.leaderboard-table thead th {
    background: var(--hb-surface);
    text-align: center;
}

.leaderboard-table th,
.leaderboard-table td {
    white-space: nowrap;
    text-align: right;
    padding: 10px 12px;
    font-size: 12px;
}

.leaderboard-table th:first-child,
.leaderboard-table td:first-child {
    text-align: center;
    width: 40px;
}

/* Location column (last) - constrain width with ellipsis */
.leaderboard-table th:last-child,
.leaderboard-table td:last-child {
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Location cell inner layout — name truncates, pct + chevron stay visible */
.leaderboard-table td:last-child .location-cell {
    display: block;
    max-width: 160px;
}

.leaderboard-table td:last-child .location-text {
    display: flex;
    align-items: center;
    gap: 4px;
    max-width: 160px;
    white-space: nowrap;
}

.leaderboard-table td:last-child .location-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
}

.leaderboard-table td:last-child .location-pct-inline {
    flex-shrink: 0;
    color: var(--hb-primary);
    font-size: 11px;
}

.leaderboard-table td:last-child .location-chevron {
    flex-shrink: 0;
}

/* Channel name column (2nd) - constrain with ellipsis */
.leaderboard-table th:nth-child(2),
.leaderboard-table td:nth-child(2) {
    text-align: left;
    max-width: 170px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.leaderboard-table td:nth-child(2) .channel-link {
    display: inline;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.col-expand {
    width: 40px;
    text-align: center !important;
}

/* Expandable rows */
.affiliate-row {
    cursor: pointer;
    background: var(--hb-dark-teal);
}

.affiliate-row td {
    font-weight: 500;
    border-bottom: 1px solid var(--border-color);
}

.affiliate-row:hover {
    background: #002528;
}

.affiliate-row.expanded {
    background: #002025;
    border-left: 2px solid var(--hb-primary);
}

.affiliate-row .chevron {
    display: inline-block;
    transition: transform 0.2s ease;
    color: var(--text-muted);
    font-size: 10px;
    width: 20px;
}

.affiliate-row.expanded .chevron {
    transform: rotate(90deg);
    color: var(--hb-primary);
}

.affiliate-row.no-campaigns .chevron {
    visibility: hidden;
}

/* Campaign row styles */
.campaign-row {
    display: none;
    cursor: pointer;
    background: #000a0b;
}

.campaign-row.visible {
    display: table-row;
}

.campaign-row:hover {
    background: #001214;
}

.campaign-row td {
    color: var(--text-secondary);
    font-size: 11px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.campaign-row td:nth-child(2) {
    padding-left: 32px;
}

.campaign-row td:nth-child(2)::before {
    content: '↳ ';
    color: var(--hb-primary);
    opacity: 0.6;
}

/* ============ EXPANDABLE DETAILS SECTION ============ */
.details-row,
.section-header-row,
.campaign-details-row {
    display: none;
    background: rgba(0, 20, 25, 0.95);
}

.details-row.visible,
.section-header-row.visible,
.campaign-details-row.visible {
    display: table-row;
}

.details-row td,
.section-header-row td,
.campaign-details-row td {
    padding: 0 !important;
    border-bottom: none;
}

/* Details Container - Compact Bloomberg-style single row */
.details-container {
    display: flex;
    align-items: stretch;
    gap: 0;
    padding: 0;
    background: rgba(0, 20, 24, 0.95);
    border-left: 2px solid var(--hb-primary);
    overflow: visible;
}

/* Tier 2 Expanded View */
.details-container.tier2-layout {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 12px 16px;
}

.tier2-sections {
    display: flex;
    gap: 0;
    flex-wrap: wrap;
}

.tier2-section {
    flex: 1;
    min-width: 180px;
    padding: 8px 12px;
    border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.tier2-section:last-child {
    border-right: none;
}

.tier2-section-title {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--hb-primary);
    margin-bottom: 6px;
    opacity: 0.7;
}

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

.tier2-metric {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.tier2-label {
    font-size: 9px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tier2-value {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-primary);
    font-family: 'Roboto', monospace;
}

/* Sparkline Rows (Line Chart Style) */
.tier2-sparklines {
    display: flex;
    gap: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    margin-top: 8px;
    padding: 8px 0;
    overflow-x: auto;
    justify-content: center;
}

.sparkline-row {
    flex: 1;
    min-width: 160px;
    padding: 4px 12px;
    border-right: 1px solid rgba(255, 255, 255, 0.04);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.sparkline-row:last-child {
    border-right: none;
}

.sparkline-header {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 2px;
}

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

.sparkline-trend-arrow {
    font-size: 8px;
    cursor: default;
}

.sparkline-trend-arrow.trend-up {
    color: #00C48C;
}

.sparkline-trend-arrow.trend-down {
    color: #FF6B6B;
}

.sparkline-chart-area {
    display: flex;
    flex-direction: column;
    align-items: stretch;
}

.sparkline-chart-area svg {
    display: block;
    width: 100%;
    max-width: 160px;
}

.sparkline-chart-area svg circle {
    cursor: pointer;
    transition: r 0.15s ease;
}

.sparkline-chart-area svg circle:hover {
    r: 5;
}

.sparkline-month-labels {
    display: flex;
    justify-content: space-between;
    font-size: 8px;
    color: var(--text-muted);
    opacity: 0.6;
    margin-top: 2px;
    max-width: 160px;
}

.sparkline-month-labels span {
    text-align: center;
    flex: 1;
}

.sparkline-values-row {
    display: flex;
    justify-content: space-between;
    font-size: 8px;
    opacity: 0.7;
    margin-top: 2px;
    max-width: 160px;
}

.sparkline-values-row span {
    text-align: center;
    flex: 1;
}

.sparkline-values-row .sv-positive {
    color: #00C48C;
}

.sparkline-values-row .sv-negative {
    color: #FF6B6B;
}

.sparkline-values-row .sv-projected {
    font-style: italic;
    opacity: 0.6;
}

.sparkline-month-labels .sv-projected {
    font-style: italic;
    opacity: 0.6;
}

.sparkline-dot-projected {
    cursor: pointer;
}

/* Lorenz Curve (mini concentration chart) */
.lorenz-row {
    min-width: 180px;
    max-width: 220px;
}

.lorenz-content {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 8px;
}

.lorenz-chart {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex-shrink: 0;
}

.lorenz-chart svg {
    display: block;
}

.lorenz-chart svg circle {
    cursor: pointer;
    transition: r 0.15s ease;
}

.lorenz-chart svg circle:hover {
    r: 4.5;
}

.lorenz-gini {
    font-size: 8px;
    font-weight: 600;
    opacity: 0.9;
}

.lorenz-info {
    font-size: 7px;
    color: var(--text-muted);
    opacity: 0.6;
    text-align: center;
    margin-top: 2px;
}

/* Top-down concentration labels next to chart */
.lorenz-labels {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding-top: 20px;
}

.lorenz-label-row {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 8px;
    cursor: default;
    white-space: nowrap;
}

.lorenz-label-key {
    color: var(--text-muted);
    opacity: 0.7;
    min-width: 32px;
}

.lorenz-label-val {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.lorenz-na {
    font-size: 9px;
    color: var(--text-muted);
    opacity: 0.5;
    padding: 8px 0;
}

.tier2-footer {
    display: flex;
    justify-content: flex-end;
    padding-top: 6px;
    border-top: 1px solid rgba(255, 255, 255, 0.04);
    margin-top: 6px;
}

/* Recommendation section - compact inline */
.recommendation-section {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    min-width: 200px;
}

.recommendation-label {
    font-family: var(--font-heading);
    font-size: 9px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.recommendation-reason {
    font-size: 11px;
    color: var(--text-secondary);
    white-space: nowrap;
}

/* Key Metrics - Bloomberg terminal style inline */
.key-metrics {
    display: flex;
    align-items: stretch;
    gap: 0;
    flex: 1;
    overflow: visible;
}

.key-metric {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    padding: 6px 12px;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    min-width: 85px;
    height: 56px;
    overflow: visible;
}

.key-metric:last-child {
    border-right: none;
}

.key-metric-label {
    font-family: var(--font-heading);
    font-size: 8px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    height: 12px;
    line-height: 12px;
}

.key-metric-value {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    height: 18px;
    line-height: 18px;
}

.key-metric-calc {
    font-size: 7px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    opacity: 0.6;
    height: 10px;
    line-height: 10px;
}

/* Player mix section - compact */
.player-mix-section {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    border-left: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 10px;
    color: var(--text-muted);
}

.player-mix-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.player-mix-label {
    color: var(--text-muted);
}

.player-mix-value {
    color: var(--text-secondary);
    font-weight: 500;
}

/* Hide old elements */
.recommendation-explanation { display: none; }
.additional-metrics { display: none; }

/* Section Header Row */
.section-header {
    padding: 8px 24px;
    background: rgba(2, 247, 237, 0.03);
    border-left: 3px solid var(--hb-primary);
    border-top: 1px solid rgba(2, 247, 237, 0.1);
}

.section-header-title {
    font-family: var(--font-heading);
    font-size: 10px;
    font-weight: 600;
    color: var(--hb-primary);
    letter-spacing: 0.8px;
}

/* Trend color classes */
.trend-positive {
    color: var(--success);
}

.trend-negative {
    color: var(--danger);
}

.trend-neutral {
    color: var(--text-muted);
}

/* NGR Sparkline Chart */
.ngr-trend-metric {
    min-width: 110px !important;
    height: 56px;
    display: flex;
    flex-direction: column;
    overflow: visible;
}

.ngr-trend-metric .key-metric-label {
    height: 12px;
    line-height: 12px;
    margin-bottom: 2px;
}

.ngr-trend-metric .ngr-sparkline-container {
    flex: 1;
    display: flex;
    align-items: flex-start;
}

.ngr-sparkline-container {
    display: flex;
    align-items: flex-start;
}

.ngr-sparkline-container .sparkline-with-values {
    width: 100%;
}

.ngr-sparkline {
    display: block;
}

.sparkline-line {
    fill: none;
    stroke: var(--hb-primary);
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.sparkline-line-projected {
    fill: none;
    stroke: var(--hb-primary);
    stroke-width: 1.5;
    stroke-dasharray: 3, 2;
    opacity: 0.6;
}

.zero-line {
    stroke: rgba(255, 255, 255, 0.15);
    stroke-width: 1;
    stroke-dasharray: 2, 2;
}

.sparkline-point {
    transition: r 0.15s ease;
    cursor: pointer;
}

.sparkline-point:hover {
    r: 5;
}

.sparkline-point.point-positive {
    fill: var(--success);
}

.sparkline-point.point-negative {
    fill: var(--danger);
}

.sparkline-point.point-projected {
    stroke: var(--hb-primary);
    stroke-width: 1.5;
    fill: var(--hb-bg);
}

.sparkline-point.point-projected.point-positive {
    stroke: var(--success);
}

.sparkline-point.point-projected.point-negative {
    stroke: var(--danger);
}

.sparkline-na {
    color: var(--text-muted);
    font-size: 11px;
}

/* FTD Sparkline - orange/amber color scheme */
.ftd-sparkline .ftd-line {
    stroke: #f59e0b;
}

.sparkline-point.point-ftd {
    fill: #f59e0b;
}

/* Profit Sparkline - uses green/red based on positive/negative */
.profit-sparkline .profit-line {
    stroke: #a855f7;
}

.profit-sparkline .profit-line-projected {
    stroke: #a855f7;
    stroke-dasharray: 3, 2;
    opacity: 0.6;
}

/* ROI Trend Sparkline - Gold/Yellow to differentiate from FTD (orange) */
.roi-sparkline .roi-line {
    stroke: #eab308;
    stroke-width: 2;
    fill: none;
}

/* Sparkline with values container */
.sparkline-with-values {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    width: 100%;
}

.sparkline-with-values svg {
    display: block;
}

/* Sparkline value labels - small values beneath aligned with dots */
.sparkline-values {
    display: flex;
    justify-content: space-between;
    font-size: 8px;
    color: #6B7280;
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
    padding: 2px 2px 0 2px;
    margin-top: 1px;
    line-height: 1;
}

.sparkline-values span {
    text-align: center;
    flex: 1;
}

.sparkline-values .sv-positive {
    color: #00C48C;
}

.sparkline-values .sv-negative {
    color: #FF6B6B;
}

/* Calculations Panel */
.calculations-toggle {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    padding: 4px 8px;
    margin-top: 6px;
    background: transparent;
    border: 1px solid rgba(100, 100, 100, 0.3);
    border-radius: 3px;
    font-size: 10px;
    color: #6B7280;
    width: fit-content;
    transition: all 0.2s ease;
}

.calculations-toggle:hover {
    background: rgba(100, 100, 100, 0.1);
    border-color: rgba(100, 100, 100, 0.5);
    color: #9CA3AF;
}

.calc-chevron {
    font-size: 10px;
    transition: transform 0.2s ease;
}

.calc-label {
    font-weight: 500;
}

/* Calculations Modal Overlay */
.calculations-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.calculations-modal-overlay.visible {
    opacity: 1;
    visibility: visible;
}

.calculations-modal {
    background: #0A1A1F;
    border: 1px solid rgba(2, 247, 237, 0.3);
    border-radius: 8px;
    padding: 20px;
    max-width: 900px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.calculations-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(2, 247, 237, 0.15);
}

.calculations-modal-title {
    color: #02F7ED;
    font-size: 14px;
    font-weight: 600;
}

.calculations-modal-close {
    background: transparent;
    border: 1px solid rgba(100, 100, 100, 0.3);
    color: #8E9196;
    cursor: pointer;
    font-size: 18px;
    width: 28px;
    height: 28px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.calculations-modal-close:hover {
    background: rgba(255, 107, 107, 0.2);
    border-color: rgba(255, 107, 107, 0.5);
    color: #FF6B6B;
}

/* Old calc grid (kept for backwards compat) */
.calc-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
}
.calc-section { background: rgba(2,247,237,0.03); padding: 12px; border-radius: 4px; border: 1px solid rgba(2,247,237,0.1); }
.calc-section-title { font-size: 11px; font-weight: 600; color: #02F7ED; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 10px; padding-bottom: 6px; border-bottom: 1px solid rgba(2,247,237,0.15); }
.calc-formula { font-size: 10px; color: #8E9196; font-style: italic; margin-bottom: 8px; padding: 4px 6px; background: rgba(0,0,0,0.3); border-radius: 3px; }
.calc-row { display: flex; justify-content: space-between; align-items: center; font-size: 11px; padding: 3px 0; border-bottom: 1px solid rgba(255,255,255,0.05); }
.calc-row:last-child { border-bottom: none; }
.calc-label-sm { color: #8E9196; font-weight: 400; }
.calc-value { color: #E8EAED; font-weight: 500; font-family: 'SF Mono','Monaco','Consolas',monospace; }

/* Shared positive / negative / warning */
.calc-positive { color: #34d399; }
.calc-negative { color: #f87171; }
.calc-warning  { color: #fbbf24; }
.calc-empty { color: #8E9196; font-size: 12px; text-align: center; padding: 20px; }

/* ===== V2 Calculations Panel ===== */
.calc-grid-v2 {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.calc-section-v2 {
    background: rgba(2, 247, 237, 0.03);
    border: 1px solid rgba(2, 247, 237, 0.10);
    border-radius: 6px;
    padding: 14px 16px;
}

.calc-section-title-v2 {
    font-size: 11px;
    font-weight: 700;
    color: #02F7ED;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(2, 247, 237, 0.15);
}

/* Raw data grid */
.calc-raw-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px 16px;
}

.calc-raw-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    padding: 3px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.calc-raw-label {
    color: #8E9196;
}

.calc-raw-val {
    color: #E8EAED;
    font-weight: 500;
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
    font-size: 11px;
}

/* Key metric block */
.calc-metric {
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.calc-metric:last-child {
    border-bottom: none;
}

.calc-metric-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2px;
}

.calc-metric-name {
    font-size: 12px;
    font-weight: 600;
    color: #E8EAED;
}

.calc-metric-result {
    font-size: 13px;
    font-weight: 700;
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
}

.calc-metric-formula {
    font-size: 10px;
    color: #02F7ED;
    opacity: 0.7;
    margin-bottom: 1px;
}

.calc-metric-detail {
    font-size: 10px;
    color: #8E9196;
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
}

/* Period ROI rows */
.calc-explanation {
    font-size: 10px;
    color: #8E9196;
    font-style: italic;
    margin-bottom: 8px;
}

.calc-row-sm {
    font-size: 11px;
    color: #8E9196;
}

.calc-row-sm strong {
    color: #E8EAED;
}

.calc-period-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    padding: 4px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.calc-period-label {
    color: #E8EAED;
    font-weight: 500;
    min-width: 80px;
}

.calc-period-val {
    color: #8E9196;
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
    font-size: 10px;
}

.calc-period-val.muted {
    opacity: 0.5;
    font-style: italic;
}

/* Break-even */
.calc-be-result {
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 10px;
}

.calc-step {
    font-size: 11px;
    color: #8E9196;
    padding: 3px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
}

.calc-step.calc-highlight {
    color: #02F7ED;
    font-weight: 600;
    border-bottom: none;
    margin-top: 4px;
}

/* Campaign Details Row - styled to match affiliate details but slightly smaller */
.campaign-details-row .details-container {
    margin-left: 40px;
    border-left: 2px solid rgba(2, 247, 237, 0.15);
    background: rgba(0, 12, 15, 0.9);
}

.campaign-details-row .details-container.campaign-details-style {
    padding: 0;
}

.campaign-details-row .recommendation-section {
    min-width: 160px;
    padding: 6px 12px;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
}

.campaign-details-row .recommendation-reason {
    font-size: 10px;
}

.campaign-details-row .key-metrics {
    gap: 0;
}

.campaign-details-row .key-metric {
    padding: 5px 10px;
    min-width: 80px;
    height: 48px;
}

.campaign-details-row .key-metric-label {
    font-size: 7px;
    height: 10px;
    line-height: 10px;
}

.campaign-details-row .key-metric-value {
    font-size: 11px;
    height: 14px;
    line-height: 14px;
}

.campaign-details-row .key-metric-calc {
    font-size: 6px;
    height: 8px;
    line-height: 8px;
}

.campaign-details-row .ngr-trend-metric {
    min-width: 100px;
    height: 48px;
}

.campaign-details-row .profit-sparkline {
    width: 90px;
    height: 24px;
}

.campaign-details-row .sparkline-values {
    font-size: 6px;
}

/* Old campaign-details styles - hidden, kept for compatibility */
.campaign-details { display: none; }
.campaign-recommendation { display: none; }
.recommendation-reason-inline { display: none; }
.campaign-metrics { display: none; }
.campaign-metric { display: none; }

/* Campaign row chevron */
.chevron-small {
    font-size: 8px;
    color: var(--text-muted);
    transition: transform 0.2s ease;
    display: inline-block;
}

.campaign-row.expanded .chevron-small {
    transform: rotate(90deg);
    color: var(--hb-primary);
}

/* NGR coloring */
.ngr-positive {
    color: var(--success) !important;
}

.ngr-negative {
    color: var(--danger) !important;
}

/* Profit coloring */
.profit-positive {
    color: var(--success) !important;
    font-weight: 600;
}

.profit-negative {
    color: var(--danger) !important;
    font-weight: 600;
}

/* ROI coloring */
.roi-excellent {
    color: #22c55e !important;
    font-weight: 700;
}

.roi-positive {
    color: var(--success) !important;
    font-weight: 600;
}

.roi-negative {
    color: var(--danger) !important;
    font-weight: 600;
}

.roi-neutral {
    color: var(--text-muted);
}

/* Row highlighting by profitability */
.row-profitable {
    border-left: 3px solid var(--success) !important;
}

.row-loss-making {
    border-left: 3px solid var(--danger) !important;
}

/* Status badges for leaderboard */
.badge-profitable {
    background: rgba(16, 185, 129, 0.2);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.4);
}

.badge-loss-making {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.4);
}

.badge-break-even {
    background: rgba(251, 191, 36, 0.2);
    color: #fbbf24;
    border: 1px solid rgba(251, 191, 36, 0.4);
}

.badge-neutral {
    background: rgba(107, 114, 128, 0.2);
    color: #9ca3af;
    border: 1px solid rgba(107, 114, 128, 0.3);
}

/* Recommendation badges */
.badge-extend {
    background: rgba(34, 197, 94, 0.25);
    color: #22c55e;
    border: 1px solid rgba(34, 197, 94, 0.5);
    font-weight: 700;
}

.badge-terminate {
    background: rgba(239, 68, 68, 0.25);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.5);
    font-weight: 700;
}

.badge-review {
    background: rgba(251, 191, 36, 0.2);
    color: #fbbf24;
    border: 1px solid rgba(251, 191, 36, 0.4);
}

/* Location dropdown */
.location-cell {
    position: relative;
    cursor: pointer;
}

.location-cell .location-text {
    display: flex;
    align-items: center;
    gap: 4px;
}

.location-cell .location-chevron {
    font-size: 8px;
    color: var(--text-muted);
    transition: transform 0.2s;
}

.location-cell.open .location-chevron {
    transform: rotate(180deg);
}

.location-dropdown {
    position: fixed;
    background: var(--hb-dark-bean);
    border: 1px solid var(--hb-primary);
    border-radius: var(--radius-sm);
    padding: 8px 0;
    min-width: 300px;
    width: auto;
    max-height: 250px;
    overflow-y: auto;
    z-index: 9999;
    display: none;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
}

.location-dropdown.open {
    display: block;
}

.location-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    font-size: 12px;
    gap: 16px;
}

.location-item:hover {
    background: rgba(2, 247, 237, 0.08);
}

.location-country {
    color: var(--text-primary);
    flex: 1;
    white-space: nowrap;
}

.location-pct {
    color: var(--hb-primary);
    font-weight: 500;
    white-space: nowrap;
}

/* ============ DEALS STYLES ============ */
.deals-stats {
    /* Uses default flex layout */
}

.deals-table {
    overflow: auto;
    max-height: calc(100vh - 300px);
}

.deals-table table {
    min-width: 1200px;
}

.deals-table .partner-summary {
    color: var(--text-muted);
    font-size: 11px;
}

.deals-table .campaign-count-label {
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 400;
    margin-top: 2px;
}

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

.deals-table thead::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 1px;
    background: var(--hb-primary);
}

.deals-table th,
.deals-table td {
    white-space: nowrap;
    padding: 12px 16px;
}

/* ============ MODAL STYLES ============ */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal-overlay.open {
    display: flex;
}

.modal-content {
    background: var(--hb-dark-bean);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    background: linear-gradient(135deg, var(--hb-dark-bean) 0%, var(--hb-dark-teal) 100%);
    border-bottom: 2px solid var(--hb-primary);
}

.modal-header h2 {
    font-family: var(--font-heading);
    color: var(--hb-primary);
    font-size: 18px;
    font-weight: 600;
    margin: 0;
}

.modal-body {
    padding: 24px;
}

.form-section-title {
    font-family: var(--font-heading);
    font-size: 11px;
    font-weight: 600;
    color: var(--hb-primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 20px 0 12px 0;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

.form-section-title:first-of-type {
    margin-top: 0;
}

.readonly-badge, .editable-badge {
    font-size: 9px;
    font-weight: 500;
    padding: 2px 6px;
    border-radius: 3px;
    margin-left: 8px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.readonly-badge {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
}

.editable-badge {
    background: rgba(0, 212, 170, 0.15);
    color: var(--hb-primary);
}

.readonly-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}

.readonly-item {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 10px 12px;
}

.readonly-label {
    display: block;
    font-size: 10px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 4px;
}

.readonly-value {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.attention-checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 12px;
    background: rgba(255, 193, 7, 0.1);
    border: 1px solid rgba(255, 193, 7, 0.3);
    border-radius: 4px;
}

.attention-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.attention-checkbox span {
    font-size: 13px;
    color: var(--text-primary);
}

.attention-reason {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 8px;
    font-style: italic;
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.form-actions .btn {
    flex: 1;
}

/* Responsive leaderboard */
@media (max-width: 1200px) {
    .leaderboard-stats {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .tab-nav {
        width: 100%;
    }
    
    .tab-btn {
        flex: 1;
        justify-content: center;
    }
    
    .leaderboard-stats {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .leaderboard-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .leaderboard-controls .search-input {
        max-width: none;
    }
    
    .modal-content {
        width: 95%;
        max-height: 95vh;
    }
}

/* ==================== Pending Changes Indicator ==================== */
.pending-changes-indicator {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--hb-dark-teal);
    border: 1px solid var(--hb-primary);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 4px 20px rgba(2, 247, 237, 0.2);
    z-index: 1000;
    animation: slideIn 0.3s ease;
}

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

.pending-changes-indicator .pending-count {
    background: var(--hb-primary);
    color: var(--hb-bg);
    font-weight: 700;
    font-size: 14px;
    padding: 4px 10px;
    border-radius: 20px;
    min-width: 24px;
    text-align: center;
}

.pending-changes-indicator .pending-text {
    color: var(--text-primary);
    font-size: 13px;
}

.pending-changes-indicator .sync-btn {
    background: var(--hb-primary);
    color: var(--hb-bg);
    border: none;
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.pending-changes-indicator .sync-btn:hover {
    background: var(--hb-primary-dark);
    transform: scale(1.02);
}

/* ============================================
   ANALYTICS TAB STYLES
   ============================================ */

/* Date Range Controls */
.analytics-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    margin-bottom: 20px;
}

.date-range-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.date-range-container label {
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
}

.date-input {
    background: var(--hb-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    padding: 8px 12px;
    font-size: 13px;
    font-family: inherit;
}

.date-input:focus {
    outline: none;
    border-color: var(--hb-primary);
}

.date-separator {
    color: var(--text-secondary);
    font-size: 14px;
}

.quick-filters {
    display: flex;
    gap: 8px;
}

.quick-filter-btn {
    background: transparent;
    border: 1px solid var(--card-border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    padding: 8px 16px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.quick-filter-btn:hover {
    border-color: var(--hb-primary);
    color: var(--hb-primary);
}

.quick-filter-btn.active {
    background: var(--hb-primary);
    border-color: var(--hb-primary);
    color: var(--hb-bg);
}

/* Analytics Summary Stats */
.analytics-stats {
    margin-bottom: 24px;
}

/* Analytics Grid */
.analytics-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.analytics-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    padding: 16px;
}

.chart-card-wide {
    grid-column: span 2;
}

.analytics-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--card-border);
}

.analytics-card-header h3 {
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 600;
    margin: 0;
}

.chart-subtitle {
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.chart-container {
    min-height: 280px;
    position: relative;
}

.no-data {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: var(--text-secondary);
    font-size: 13px;
}

.chart-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 300px;
    color: var(--text-secondary);
    font-size: 14px;
}

/* Performance Matrix Tooltip */
.matrix-tooltip {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: 12px;
    color: var(--text-primary);
    line-height: 1.5;
}

/* Top/Bottom Performers */
.performers-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.performers-column {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.performers-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0 0 8px 0;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--card-border);
}

.performers-title.top {
    color: var(--hb-primary);
}

.performers-title.bottom {
    color: var(--negative);
}

.performers-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.performer-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
}

.performer-item:hover {
    background: rgba(2, 247, 237, 0.1);
}

.performer-rank {
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 600;
    min-width: 18px;
}

.performer-name {
    flex: 1;
    color: var(--text-primary);
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.performer-roi {
    font-size: 12px;
    font-weight: 600;
}

.performer-roi.positive {
    color: var(--hb-primary);
}

.performer-roi.negative {
    color: var(--negative);
}

/* Drilldown Container */
.drilldown-container {
    margin-top: 20px;
}

.drilldown-header {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 20px;
}

.btn-back {
    background: transparent;
    border: 1px solid var(--card-border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    padding: 8px 16px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-back:hover {
    border-color: var(--hb-primary);
    color: var(--hb-primary);
}

.drilldown-header h2 {
    color: var(--text-primary);
    font-size: 18px;
    font-weight: 600;
    margin: 0;
}

/* Button Styles */
.btn-primary {
    background: var(--hb-primary);
    border: none;
    border-radius: var(--radius-sm);
    color: var(--hb-bg);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 12px;
}

.btn-primary:hover {
    background: var(--hb-primary-dark);
}

/* Stat Card Colors */
.stat-positive {
    color: var(--hb-primary) !important;
}

.stat-negative {
    color: var(--negative) !important;
}

/* ApexCharts Overrides */
.apexcharts-tooltip {
    background: #0a1e28 !important;
    border: 1px solid rgba(2, 247, 237, 0.2) !important;
    border-radius: 6px !important;
    box-shadow: 0 8px 24px rgba(0,0,0,0.5) !important;
}

.apexcharts-tooltip-title {
    background: #071a1a !important;
    border-bottom: 1px solid rgba(2, 247, 237, 0.12) !important;
    color: #E8EAED !important;
    font-size: 11px !important;
}

.apexcharts-tooltip-text-y-label {
    color: #8E9196 !important;
}

.apexcharts-tooltip-text-y-value {
    color: #E8EAED !important;
    font-weight: 600 !important;
}

/* Toolbar icons */
.apexcharts-toolbar {
    z-index: 5 !important;
}

.apexcharts-zoom-icon svg,
.apexcharts-zoomin-icon svg,
.apexcharts-zoomout-icon svg,
.apexcharts-pan-icon svg,
.apexcharts-reset-icon svg,
.apexcharts-selection-icon svg {
    fill: #6b7280 !important;
}

.apexcharts-zoom-icon.apexcharts-selected svg,
.apexcharts-selection-icon.apexcharts-selected svg,
.apexcharts-pan-icon.apexcharts-selected svg {
    fill: #02F7ED !important;
}

.apexcharts-zoom-icon:hover svg,
.apexcharts-zoomin-icon:hover svg,
.apexcharts-zoomout-icon:hover svg,
.apexcharts-pan-icon:hover svg,
.apexcharts-reset-icon:hover svg,
.apexcharts-selection-icon:hover svg {
    fill: #02F7ED !important;
}

/* Selection overlay */
.apexcharts-selection-rect {
    fill: rgba(2, 247, 237, 0.08) !important;
}

/* ============ ANALYTICS TAB - Charts ============ */

.analytics-charts-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-top: 20px;
    width: 100%;
}

.analytics-chart-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    padding: 16px 20px;
    min-width: 0;          /* allow grid items to shrink properly */
    overflow: hidden;
}

.analytics-chart-card .analytics-card-header {
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--card-border);
}

.analytics-chart-card .analytics-card-header h3 {
    font-size: 13px;
    font-weight: 600;
    color: var(--hb-primary);
    margin: 0;
    letter-spacing: 0.3px;
}

.analytics-chart-subtitle {
    font-size: 11px;
    color: var(--text-muted);
    opacity: 0.65;
}

.analytics-chart-body {
    min-height: 320px;
}

/* ============ Cohort Retention Heatmap ============ */

.cohort-heatmap-card {
    /* sits beside the Performance Trend card */
}

.cohort-heatmap-body {
    overflow-x: auto;
    overflow-y: auto;
    max-height: 420px;
    padding: 0 !important;
}

.cohort-heatmap-body .cohort-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 240px;
    color: var(--text-muted);
    font-size: 13px;
    animation: pulse-loading 1.5s ease-in-out infinite;
}

.cohort-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-family: var(--font-body);
    font-size: 12px;
}

.cohort-table thead {
    position: sticky;
    top: 0;
    z-index: 2;
}

.cohort-table thead th {
    background: var(--card-bg);
    color: var(--text-muted);
    font-weight: 500;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    padding: 8px 6px;
    text-align: center;
    white-space: nowrap;
    border-bottom: 1px solid var(--card-border);
}

.cohort-table thead th:first-child,
.cohort-table thead th:nth-child(2) {
    text-align: left;
    position: sticky;
    z-index: 3;
    background: var(--card-bg);
}
.cohort-table thead th:first-child { left: 0; min-width: 80px; }
.cohort-table thead th:nth-child(2) { left: 80px; min-width: 60px; }

.cohort-table tbody td {
    padding: 5px 6px;
    text-align: center;
    border-bottom: 1px solid rgba(2, 247, 237, 0.04);
    transition: transform 0.1s ease;
    position: relative;
}

.cohort-table tbody td:first-child,
.cohort-table tbody td:nth-child(2) {
    text-align: left;
    position: sticky;
    z-index: 1;
    background: var(--card-bg);
    font-weight: 500;
}
.cohort-table tbody td:first-child { left: 0; min-width: 80px; color: var(--hb-primary); }
.cohort-table tbody td:nth-child(2) { left: 80px; min-width: 60px; color: var(--text-secondary); }

.cohort-cell {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 28px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    color: #fff;
    cursor: default;
    transition: opacity 0.15s;
}

.cohort-cell:hover {
    opacity: 0.85;
    box-shadow: 0 0 0 1px rgba(255,255,255,0.2);
}

.cohort-cell-empty {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 28px;
    color: rgba(255,255,255,0.15);
    font-size: 10px;
}

/* Cohort tooltip */
.cohort-tooltip {
    position: fixed;
    z-index: 9999;
    background: #0b1e2a;
    border: 1px solid var(--card-border);
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 12px;
    color: var(--text-primary);
    pointer-events: none;
    box-shadow: var(--shadow-lg);
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.12s ease;
}

.cohort-tooltip.visible {
    opacity: 1;
}

.cohort-tooltip .ct-label {
    color: var(--text-muted);
    font-size: 11px;
    margin-bottom: 2px;
}

.cohort-tooltip .ct-value {
    color: var(--hb-primary);
    font-weight: 600;
}

/* Legend */
.cohort-legend {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-top: 1px solid var(--card-border);
}

.cohort-legend-label {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.cohort-legend-bar {
    display: flex;
    height: 10px;
    border-radius: 3px;
    overflow: hidden;
    flex: 1;
    max-width: 200px;
}

.cohort-legend-bar span {
    flex: 1;
}

.cohort-legend-range {
    font-size: 10px;
    color: var(--text-muted);
}

/* ============ Channel Effectiveness Matrix ============ */

.effectiveness-card {
    grid-column: 1 / -1;
}

.effectiveness-card .analytics-chart-body {
    min-height: 420px;
    position: relative;
    overflow: visible;
}

/* ---- Custom toolbar for effectiveness chart ---- */
.effectiveness-card .analytics-card-header {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    position: relative;
    padding-right: 180px; /* reserve space for toolbar */
}

.eff-toolbar {
    position: absolute;
    top: 50%;
    right: 0;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    gap: 2px;
    z-index: 10;
}

.eff-tb-btn {
    background: rgba(2, 247, 237, 0.06);
    border: 1px solid rgba(2, 247, 237, 0.12);
    color: rgba(255, 255, 255, 0.55);
    border-radius: 5px;
    width: 28px;
    height: 28px;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    line-height: 1;
}

.eff-tb-btn:hover {
    background: rgba(2, 247, 237, 0.12);
    color: var(--hb-primary);
}

.eff-tb-btn.eff-tb-active {
    background: rgba(2, 247, 237, 0.18);
    border-color: rgba(2, 247, 237, 0.35);
    color: var(--hb-primary);
}

.eff-tb-sep {
    width: 1px;
    height: 18px;
    background: rgba(255, 255, 255, 0.08);
    margin: 0 3px;
}

/* ---- Selection rectangle overlay ---- */
.eff-select-rect {
    position: absolute;
    border: 1px dashed rgba(2, 247, 237, 0.5);
    background: rgba(2, 247, 237, 0.06);
    border-radius: 3px;
    pointer-events: none;
    z-index: 20;
    display: none;
}

/* ApexCharts dark theme overrides for bubble */
.effectiveness-card .apexcharts-tooltip {
    background: #0b1e2a !important;
    border: 1px solid var(--card-border) !important;
    border-radius: 6px !important;
    box-shadow: var(--shadow-lg) !important;
    overflow: visible !important;
    /* Prevent tooltip from being clipped at chart top */
    z-index: 100 !important;
}

.effectiveness-card .apexcharts-canvas {
    overflow: visible !important;
}

.effectiveness-card svg {
    overflow: visible !important;
}

.effectiveness-card .apexcharts-tooltip .apexcharts-tooltip-title {
    background: rgba(2, 247, 237, 0.08) !important;
    border-bottom: 1px solid var(--card-border) !important;
    color: var(--hb-primary) !important;
    font-weight: 600 !important;
    font-size: 12px !important;
    padding: 6px 10px !important;
}

.effectiveness-card .apexcharts-tooltip-series-group {
    padding: 4px 10px !important;
}

.effectiveness-card .apexcharts-tooltip-text-y-label,
.effectiveness-card .apexcharts-tooltip-text-y-value {
    color: var(--text-primary) !important;
    font-size: 11px !important;
}

/* Effectiveness Key / Reference Table */
.eff-key {
    border-top: 1px solid rgba(2, 247, 237, 0.08);
    padding: 10px 14px;
}

.eff-key-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    flex-wrap: wrap;
    gap: 6px;
}

.eff-key-legend {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 10px;
    color: rgba(255,255,255,0.4);
}

.eff-key-legend-label {
    text-transform: uppercase;
    letter-spacing: 0.4px;
    font-weight: 600;
    color: rgba(255,255,255,0.3);
}

.eff-key-dot-label {
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.eff-key-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.eff-key-sep {
    color: rgba(255,255,255,0.1);
    margin: 0 2px;
}

.eff-key-note {
    color: rgba(255,255,255,0.25);
    font-size: 10px;
}

.eff-key-organic {
    font-size: 10px;
    color: rgba(255,255,255,0.2);
}

.eff-key-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 2px 20px;
    max-height: 160px;
    overflow-y: auto;
}

.eff-key-grid::-webkit-scrollbar { width: 4px; }
.eff-key-grid::-webkit-scrollbar-thumb { background: var(--card-border); border-radius: 2px; }

.eff-key-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 3px 4px;
    border-radius: 3px;
    transition: background 0.15s;
}

.eff-key-row {
    cursor: pointer;
}

.eff-key-row:hover {
    background: rgba(2, 247, 237, 0.06);
}

.eff-key-row-active {
    background: rgba(2, 247, 237, 0.1) !important;
    border-left: 2px solid var(--hb-primary);
    padding-left: 6px;
}

.eff-key-row-active .eff-key-name {
    color: var(--hb-primary);
}

.eff-key-name {
    flex: 1;
    min-width: 0;
    font-size: 11px;
    font-weight: 500;
    color: rgba(255,255,255,0.7);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.eff-key-metric {
    font-size: 10px;
    font-weight: 500;
    color: rgba(255,255,255,0.55);
    white-space: nowrap;
    min-width: 52px;
    text-align: right;
}

.eff-key-dim {
    font-size: 9px;
    font-weight: 400;
    color: rgba(255,255,255,0.25);
    margin-left: 2px;
}

.eff-key-prompt {
    text-align: center;
    padding: 12px 0;
    font-size: 11px;
    color: rgba(255,255,255,0.2);
}

.eff-key-selection-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 0;
    margin-bottom: 4px;
    font-size: 11px;
    color: var(--hb-primary);
    border-bottom: 1px solid rgba(2, 247, 237, 0.08);
}

.eff-clear-selection {
    background: rgba(2, 247, 237, 0.08);
    border: 1px solid rgba(2, 247, 237, 0.2);
    color: var(--hb-primary);
    font-size: 10px;
    padding: 3px 10px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.15s;
}

.eff-clear-selection:hover {
    background: rgba(2, 247, 237, 0.15);
}

/* Edge direction markers */
.eff-edge-markers {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 5;
}

.eff-edge {
    position: absolute;
    background: rgba(2, 247, 237, 0.1);
    border: 1px solid rgba(2, 247, 237, 0.2);
    color: var(--hb-primary);
    font-size: 10px;
    font-weight: 600;
    border-radius: 4px;
    padding: 3px 8px;
    white-space: nowrap;
    display: none;
    pointer-events: auto;
    cursor: default;
    backdrop-filter: blur(4px);
    opacity: 0.85;
}

.eff-edge-right {
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
}

.eff-edge-left {
    left: 50px;
    top: 50%;
    transform: translateY(-50%);
}

.eff-edge-top {
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
}

.eff-edge-bottom {
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
}

/* ============ ANALYTICS TAB - MoM ============ */

/* Controls Bar */
.analytics-controls-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    overflow: visible;
    position: relative;
    z-index: 100;
}

.a-controls-divider {
    width: 1px;
    height: 28px;
    background: var(--card-border);
    flex-shrink: 0;
}

/* ---- Generic Dropdown ---- */
.a-dropdown {
    position: relative;
}

.a-dropdown-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 12px;
    background: var(--hb-bg);
    border: 1px solid var(--card-border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s;
    white-space: nowrap;
    user-select: none;
}

.a-dropdown-trigger:hover {
    border-color: rgba(2, 247, 237, 0.4);
}

.a-dropdown-icon {
    opacity: 0.5;
    flex-shrink: 0;
}

.a-dropdown-chevron {
    opacity: 0.4;
    flex-shrink: 0;
    margin-left: 2px;
}

.a-dropdown-panel {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    z-index: 300;
    background: #0a1e28;
    border: 1px solid rgba(2, 247, 237, 0.15);
    border-radius: 8px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.7);
    min-width: 280px;
    backdrop-filter: none;
}

.a-dropdown-panel.open {
    display: block;
}

/* ---- Month Picker inside panel ---- */
.a-month-presets {
    display: flex;
    gap: 4px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--card-border);
}

.a-preset-btn {
    flex: 1;
    padding: 5px 0;
    background: transparent;
    border: 1px solid var(--card-border);
    border-radius: 4px;
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    text-align: center;
}

.a-preset-btn:hover {
    border-color: var(--hb-primary);
    color: var(--hb-primary);
}

.a-preset-btn.active {
    background: var(--hb-primary);
    border-color: var(--hb-primary);
    color: var(--hb-bg);
}

.a-month-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 3px;
    padding: 10px 12px;
    max-height: 280px;
    overflow-y: auto;
}

.a-month-btn {
    padding: 5px 6px;
    background: transparent;
    border: 1px solid var(--card-border);
    border-radius: 4px;
    color: var(--text-secondary);
    font-size: 11px;
    cursor: pointer;
    transition: all 0.12s;
    text-align: center;
}

.a-month-btn:hover {
    border-color: var(--hb-primary);
    color: var(--hb-primary);
    background: rgba(2, 247, 237, 0.05);
}

.a-month-btn.selected {
    background: rgba(2, 247, 237, 0.15);
    border-color: var(--hb-primary);
    color: var(--hb-primary);
    font-weight: 600;
}

/* ---- Searchable Dropdown Panel ---- */
.a-dropdown-searchable {
    min-width: 300px;
}

.a-dropdown-wide .a-dropdown-panel {
    min-width: 300px;
}

.a-search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--card-border);
    color: var(--text-secondary);
}

.a-search-box input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 12px;
    font-family: inherit;
}

.a-search-box input::placeholder {
    color: var(--text-secondary);
    opacity: 0.6;
}

.a-option-list {
    max-height: 240px;
    overflow-y: auto;
    padding: 4px 0;
}

.a-option-list::-webkit-scrollbar {
    width: 5px;
}

.a-option-list::-webkit-scrollbar-thumb {
    background: var(--card-border);
    border-radius: 3px;
}

.a-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 14px;
    cursor: pointer;
    font-size: 12px;
    color: var(--text-secondary);
    transition: background 0.1s;
}

.a-option:hover {
    background: rgba(2, 247, 237, 0.06);
    color: var(--text-primary);
}

.a-option.selected {
    color: var(--hb-primary);
}

.a-option-check {
    width: 16px;
    height: 16px;
    border: 1px solid var(--card-border);
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    flex-shrink: 0;
    line-height: 1;
}

.a-option.selected .a-option-check {
    background: var(--hb-primary);
    border-color: var(--hb-primary);
    color: var(--hb-bg);
}

.a-option-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.a-dropdown-actions {
    display: flex;
    justify-content: flex-end;
    padding: 6px 10px;
    border-top: 1px solid var(--card-border);
}

.a-action-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 11px;
    cursor: pointer;
    padding: 4px 10px;
    border-radius: 4px;
    transition: all 0.15s;
}

.a-action-btn:hover {
    color: var(--hb-primary);
    background: rgba(2, 247, 237, 0.08);
}

/* Channel name hyperlink */
.channel-link {
    cursor: pointer;
    transition: color 0.15s;
    border-bottom: 1px dotted transparent;
}

.channel-link:hover {
    color: var(--hb-primary);
    border-bottom-color: var(--hb-primary);
}

/* Filter context label */
.mom-filter-context {
    font-size: 11px;
    font-weight: 400;
    color: var(--text-secondary);
    opacity: 0.7;
    letter-spacing: 0.2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 500px;
}

/* MoM Table */
.analytics-table-wrapper {
    overflow-x: auto;
    max-height: 340px;
    overflow-y: auto;
}

.analytics-table-wrapper::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}

.analytics-table-wrapper::-webkit-scrollbar-thumb {
    background: var(--card-border);
    border-radius: 3px;
}

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

.analytics-mom-table thead th {
    background: var(--hb-dark-bean);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    padding: 10px 12px;
    text-align: center;
    white-space: nowrap;
    border-bottom: 2px solid var(--card-border);
    position: sticky;
    top: 0;
    z-index: 5;
}

.analytics-mom-table tbody td {
    padding: 10px 12px;
    text-align: center;
    color: var(--text-primary);
    border-bottom: 1px solid var(--card-border);
    white-space: nowrap;
}

.analytics-mom-table tbody tr:hover {
    background: rgba(2, 247, 237, 0.04);
}

.analytics-mom-table .mom-month {
    font-weight: 600;
    color: var(--hb-primary);
    text-align: left;
}

/* Sticky first column */
.analytics-mom-table .sticky-col {
    position: sticky;
    left: 0;
    z-index: 4;
    background: #0a1e28;
    box-shadow: 1px 0 0 0 rgba(2, 247, 237, 0.15);
}

.analytics-mom-table thead .sticky-col {
    z-index: 6;
    background: var(--hb-dark-bean);
    box-shadow: 1px 0 0 0 rgba(2, 247, 237, 0.15);
}

.analytics-mom-table tbody tr:hover .sticky-col {
    background: #0e2a36;
}

.analytics-mom-table tfoot td {
    padding: 12px;
    text-align: center;
    background: #0c2430;
    border-top: none;
    box-shadow: 0 -1px 0 0 rgba(2, 247, 237, 0.25);
    color: var(--text-primary);
    font-size: 12px;
    position: sticky;
    bottom: 0;
    z-index: 5;
}

.analytics-mom-table tfoot .sticky-col {
    z-index: 7;
    background: #0c2430;
    box-shadow: 1px 0 0 0 rgba(2, 247, 237, 0.15), 0 -1px 0 0 rgba(2, 247, 237, 0.25);
}

.analytics-mom-table .positive {
    color: #34d399;
}

.analytics-mom-table .negative {
    color: #f87171;
}

.analytics-mom-table .cost-col {
    color: var(--warning);
}

/* MoM Trend arrows */
.mom-trend {
    font-size: 9px;
    margin-left: 2px;
}

.mom-trend.trend-up {
    color: #34d399;
}

.mom-trend.trend-down {
    color: #f87171;
}

/* Retention color coding in table */
.analytics-mom-table .retention-good {
    color: #34d399;
    font-weight: 600;
}

.analytics-mom-table .retention-warning {
    color: var(--warning);
    font-weight: 600;
}

.analytics-mom-table .retention-danger {
    color: var(--negative);
    font-weight: 600;
}

.table-loading {
    text-align: center;
    color: var(--text-secondary);
    padding: 40px !important;
    font-size: 13px;
}

/* ============ FEE SCHEDULE ============ */

.fee-explainer {
    background: rgba(2, 247, 237, 0.04);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px 14px;
    margin-bottom: 14px;
}

.fee-explainer-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 8px;
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.fee-explainer-row:last-child { margin-bottom: 0; }

.fee-explainer-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(2, 247, 237, 0.12);
    color: var(--hb-primary);
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 1px;
}

.fee-explainer-row strong {
    color: var(--text-primary);
}

.fee-explainer-row em {
    color: var(--hb-primary);
    font-style: normal;
    font-weight: 500;
}

.fee-schedule-section {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px 14px;
    margin-top: 14px;
}

.fee-schedule-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
}

.fee-schedule-chevron {
    color: var(--text-muted);
    font-size: 12px;
    transition: transform 0.2s;
}

.fee-schedule-badge {
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 10px;
    margin-left: 8px;
    font-weight: 500;
    vertical-align: middle;
}

.fee-schedule-badge-empty {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-muted);
}

.fee-schedule-badge-active {
    background: rgba(2, 247, 237, 0.12);
    color: var(--hb-primary);
}

.fee-schedule-badge-loading {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-muted);
    animation: pulse-loading 1.2s ease-in-out infinite;
}

@keyframes pulse-loading {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

.fee-schedule-body {
    margin-top: 10px;
}

.fee-schedule-container {
    margin-bottom: 10px;
}

.fee-schedule-empty {
    color: var(--text-muted);
    font-size: 12px;
    padding: 8px 0;
    font-style: italic;
}

.fee-schedule-table {
    border: 1px solid var(--border-color);
    border-radius: 6px;
    overflow: hidden;
    font-size: 12px;
}

.fee-schedule-header {
    display: grid;
    grid-template-columns: 80px 80px 90px 70px 1fr 56px;
    gap: 6px;
    padding: 7px 10px;
    background: rgba(2, 247, 237, 0.05);
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-size: 10px;
    letter-spacing: 0.5px;
}

.fee-schedule-row {
    display: grid;
    grid-template-columns: 80px 80px 90px 70px 1fr 56px;
    gap: 6px;
    padding: 7px 10px;
    border-top: 1px solid var(--border-color);
    align-items: center;
    color: var(--text-primary);
}

.fee-schedule-row:hover {
    background: rgba(2, 247, 237, 0.03);
}

.fee-amount {
    color: var(--hb-primary);
    font-weight: 600;
}

.fee-ongoing-badge {
    font-size: 10px;
    color: var(--hb-primary);
    background: rgba(2, 247, 237, 0.1);
    padding: 1px 6px;
    border-radius: 8px;
}

.fee-schedule-notes {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-muted);
    font-size: 11px;
}

.fee-schedule-actions {
    display: flex;
    gap: 2px;
}

.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px 5px;
    font-size: 13px;
    opacity: 0.5;
    transition: opacity 0.15s;
}

.btn-icon:hover {
    opacity: 1;
}

.btn-icon-edit { color: var(--hb-primary); }
.btn-icon-del { color: #ef4444; }

.btn-sm {
    padding: 4px 12px;
    font-size: 12px;
}

.btn-add-period {
    background: rgba(2, 247, 237, 0.08);
    color: var(--hb-primary);
    border: 1px dashed var(--hb-primary);
    border-radius: 6px;
    padding: 5px 14px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s;
    margin-top: 6px;
    width: 100%;
}

.btn-add-period:hover {
    background: rgba(2, 247, 237, 0.15);
}

.form-hint-inline {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 400;
}

.fee-period-form {
    border: 1px solid var(--hb-primary);
    border-radius: 8px;
    padding: 14px;
    background: rgba(2, 247, 237, 0.03);
}

.fee-period-form-title {
    color: var(--text-primary);
    font-size: 14px;
    margin: 0 0 4px;
}

.fee-period-form-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.fee-schedule-loading {
    color: var(--text-muted);
    font-size: 12px;
    padding: 12px 0;
    animation: pulse-loading 1.2s ease-in-out infinite;
}


/* Responsive */
@media (max-width: 1200px) {
    .analytics-grid {
        grid-template-columns: 1fr;
    }
    
    .chart-card-wide {
        grid-column: span 1;
    }
    
    .analytics-controls {
        flex-direction: column;
        gap: 16px;
    }
}
