/**
 * PopsMM Dashboard Styles
 */

/* App variables — teal / slate palette */
:root {
    --primary: #0f766e;
    --primary-hover: #0d9488;
    --primary-soft: rgba(15, 118, 110, 0.12);
    --success: #059669;
    --danger: #e11d48;
    --warning: #d97706;
    --ink: #0f172a;
    --muted: #64748b;

    /* Bootstrap overrides (buttons, badges, links, focus rings) */
    --bs-primary: #0f766e;
    --bs-primary-rgb: 15, 118, 110;
    --bs-link-color: #0f766e;
    --bs-link-hover-color: #0d9488;
    --bs-focus-ring-color: rgba(15, 118, 110, 0.35);
    --bs-success: #059669;
    --bs-success-rgb: 5, 150, 105;
    --bs-danger: #e11d48;
    --bs-danger-rgb: 225, 29, 72;

    --sidebar-width: 248px;
    --sidebar-collapsed-width: 72px;
    --sidebar-bg: #0b1220;
    --sidebar-bg-mid: #111827;
    --sidebar-border: rgba(148, 163, 184, 0.12);
    --sidebar-accent: #2dd4bf;
    --content-bg: #eef2f6;
    --panel-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px rgba(15, 23, 42, 0.06);
}

/* CSS Reset */
*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--content-bg);
    color: var(--ink);
}

/* Bootstrap primary button polish */
.btn-primary {
    --bs-btn-bg: var(--primary);
    --bs-btn-border-color: var(--primary);
    --bs-btn-hover-bg: var(--primary-hover);
    --bs-btn-hover-border-color: var(--primary-hover);
    --bs-btn-active-bg: #0f766e;
    --bs-btn-active-border-color: #0f766e;
    --bs-btn-disabled-bg: var(--primary);
    --bs-btn-disabled-border-color: var(--primary);
    box-shadow: 0 1px 2px rgba(15, 118, 110, 0.2);
}

.btn-outline-primary {
    --bs-btn-color: var(--primary);
    --bs-btn-border-color: var(--primary);
    --bs-btn-hover-bg: var(--primary);
    --bs-btn-hover-border-color: var(--primary);
    --bs-btn-active-bg: var(--primary);
    --bs-btn-active-border-color: var(--primary);
    --bs-btn-disabled-color: var(--primary);
    --bs-btn-disabled-border-color: var(--primary);
}

.bg-primary {
    background-color: var(--primary) !important;
}

.text-primary {
    color: var(--primary) !important;
}

.form-control:focus,
.form-select:focus {
    border-color: rgba(15, 118, 110, 0.55);
    box-shadow: 0 0 0 0.2rem rgba(15, 118, 110, 0.18);
}

.form-check-input:checked {
    background-color: var(--primary);
    border-color: var(--primary);
}

.page-link {
    color: var(--primary);
}
.page-item.active .page-link {
    background-color: var(--primary);
    border-color: var(--primary);
}

/* Login Page */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(ellipse 70% 60% at 85% 15%, rgba(45, 212, 191, 0.22), transparent 55%),
        radial-gradient(ellipse 50% 50% at 10% 90%, rgba(56, 189, 248, 0.12), transparent 50%),
        linear-gradient(145deg, #0b1220 0%, #0f172a 45%, #134e4a 120%);
}

.login-box {
    background: #fff;
    padding: 2.5rem;
    border-radius: 1rem;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.28);
    width: 100%;
    max-width: 400px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.login-box .logo {
    text-align: center;
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--ink);
    margin-bottom: 2rem;
    letter-spacing: -0.02em;
}

.login-box .form-control {
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border-radius: 0.6rem;
}

.login-box .btn-primary {
    padding: 0.75rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 0.6rem;
}

/* Utility Classes */
.text-profit { color: var(--success); }
.text-loss { color: var(--danger); }
.text-neutral { color: var(--muted); }

.bg-profit { background-color: rgba(5, 150, 105, 0.1); }
.bg-loss { background-color: rgba(225, 29, 72, 0.1); }

/* Stats Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

/* Table Enhancements */
.table-hover tbody tr:hover {
    background-color: rgba(15, 118, 110, 0.04);
}

.table .profit-cell {
    background-color: rgba(5, 150, 105, 0.1);
    color: var(--success);
    font-weight: 600;
}

.table .loss-cell {
    background-color: rgba(225, 29, 72, 0.1);
    color: var(--danger);
    font-weight: 600;
}

/* Quick Filters */
.filter-bar {
    background: #fff;
    padding: 0.55rem 0.75rem;
    border-radius: 0.65rem;
    margin-bottom: 0.85rem;
    border: 1px solid rgba(15, 23, 42, 0.06);
    box-shadow: var(--panel-shadow);
}

.filter-bar .form-control,
.filter-bar .form-select {
    font-size: 0.8125rem;
}

/* Network badges */
.badge-network {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
}

/* Layout */
.main-content {
    margin-left: var(--sidebar-width);
    padding: 0 0 1.15rem;
    min-height: 100vh;
    max-width: calc(100vw - var(--sidebar-width));
    overflow-x: hidden;
    transition: margin-left 0.2s ease;
}

.top-bar {
    position: sticky;
    top: 0;
    z-index: 40;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    padding: 0.22rem 1rem;
    margin: 0;
    min-height: 0;
    border-bottom: 1px solid rgba(15, 23, 42, 0.08);
    background: #fff;
    box-shadow: 0 1px 0 rgba(15, 23, 42, 0.04);
}

.top-bar h1,
.top-bar .h4,
.top-bar h4 {
    color: var(--ink);
    letter-spacing: -0.02em;
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.2;
}

.top-bar .user-info {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.top-bar .header-profile-link {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: #0f172a;
}

.top-bar a.header-profile-text {
    text-decoration: none !important;
    color: inherit !important;
    border-radius: 999px;
    padding: 0.1rem 0.4rem;
    transition: background 0.15s ease;
}

.top-bar a.header-profile-text:hover {
    background: rgba(15, 23, 42, 0.06);
}

.header-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid rgba(15, 23, 42, 0.12);
    flex-shrink: 0;
}

.header-avatar-fallback {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #e2e8f0;
    color: #64748b !important;
    font-size: 0.95rem;
}

.header-profile-text {
    display: inline-flex;
    align-items: center;
    line-height: 1.2;
}

.header-profile-hint {
    display: none;
}

.header-profile-name {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: inherit;
}

.header-profile-name strong {
    color: inherit;
    font-weight: 600;
}

.top-bar .user-info .small {
    font-size: 0.75rem;
    line-height: 1;
    white-space: nowrap;
}

.top-bar .badge {
    font-size: 0.65rem;
    padding: 0.15em 0.45em;
    vertical-align: middle;
}

.main-content:has(.dash-hero) .top-bar .header-profile-link,
.main-content:has(.dash-hero) .top-bar a.header-profile-text,
.main-content:has(.dash-hero) .top-bar a.header-profile-text:link,
.main-content:has(.dash-hero) .top-bar a.header-profile-text:visited,
.main-content:has(.dash-hero) .top-bar a.header-profile-text:hover,
.main-content:has(.dash-hero) .top-bar a.header-profile-text:active {
    color: #f8fafc !important;
}

.main-content:has(.dash-hero) .top-bar a.header-profile-text:hover {
    background: rgba(255, 255, 255, 0.12);
}

.main-content:has(.dash-hero) .header-avatar {
    border-color: rgba(255, 255, 255, 0.35);
}

.main-content:has(.dash-hero) .header-avatar-fallback {
    background: rgba(255, 255, 255, 0.18);
    color: #e2e8f0 !important;
}

.sidebar-toggle {
    border-radius: 0.5rem;
    border-color: rgba(15, 23, 42, 0.12);
    color: var(--ink);
    background: #fff;
}

.sidebar-toggle:hover {
    background: var(--primary-soft);
    border-color: rgba(15, 118, 110, 0.35);
    color: var(--primary);
}

.dash-home {
    padding: 0 1rem;
}

.main-content > .alert {
    margin: 0.65rem 1rem 0;
}

.main-content > .container-fluid {
    padding-top: 0.5rem;
}

/*
 * Sticky compact header. Hero sits flush underneath — no overlay, no gap above.
 */
.main-content:has(.dash-hero) .top-bar {
    background: #0f172a;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    color: #f8fafc;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.2);
}

.main-content:has(.dash-hero) .top-bar h4 {
    color: #f8fafc;
}

.main-content:has(.dash-hero) .top-bar .text-muted {
    color: rgba(226, 232, 240, 0.72) !important;
}

.main-content:has(.dash-hero) .top-bar .user-info {
    gap: 0.6rem;
    flex-wrap: nowrap;
    justify-content: flex-end;
    font-size: 0.8rem;
}

.main-content:has(.dash-hero) .top-bar .user-info strong {
    color: #fff;
}

.main-content:has(.dash-hero) .top-bar .badge.bg-primary {
    background: rgba(45, 212, 191, 0.25) !important;
    color: #99f6e4;
    border: 1px solid rgba(45, 212, 191, 0.35);
}

.main-content:has(.dash-hero) .sidebar-toggle {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.18);
    color: #f8fafc;
}

.main-content:has(.dash-hero) .sidebar-toggle:hover {
    background: rgba(45, 212, 191, 0.2);
    border-color: rgba(45, 212, 191, 0.45);
    color: #fff;
}

.main-content:has(.dash-hero) .dash-hero {
    margin: 0 -1rem 0.85rem;
    padding: 0.7rem 1rem 0.8rem;
    border-radius: 0;
    align-items: flex-end;
}

.main-content:has(.dash-hero) .dash-hero-eyebrow {
    margin-bottom: 0.1rem;
}

.main-content:has(.dash-hero) .dash-hero-title {
    font-size: clamp(1.1rem, 1.8vw, 1.35rem);
}

.main-content:has(.dash-hero) .dash-hero-sub {
    margin-top: 0.15rem;
    font-size: 0.8rem;
}

.main-content:has(.dash-hero) > .alert {
    position: relative;
    z-index: 3;
    margin: 0.5rem 1rem 0;
}

@media (max-width: 767.98px) {
    .dash-home {
        padding: 0 0.85rem;
    }

    .top-bar {
        padding: 0.2rem 0.85rem;
    }

    .main-content:has(.dash-hero) .dash-hero {
        margin: 0 -0.85rem 0.75rem;
        padding: 0.65rem 0.85rem 0.75rem;
    }
}

.stat-card {
    background: #fff;
    border-radius: 0.85rem;
    padding: 1.25rem;
    border: 1px solid rgba(15, 23, 42, 0.06);
    box-shadow: var(--panel-shadow);
}

.stat-card .value {
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--ink);
}

.stat-card .label {
    color: var(--muted);
    font-size: 0.875rem;
}

.profit { color: var(--success); }
.loss { color: var(--danger); }

.data-table {
    background: #fff;
    border-radius: 0.85rem;
    border: 1px solid rgba(15, 23, 42, 0.06);
    box-shadow: var(--panel-shadow);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.data-table th {
    background: #f8fafc;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--muted);
}

/* Quick date selector */
.date-pills {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.date-pills .btn {
    padding: 0.25rem 0.75rem;
    font-size: 0.875rem;
}

/* Sidebar */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background:
        radial-gradient(ellipse 120% 60% at 0% 0%, rgba(45, 212, 191, 0.14), transparent 55%),
        linear-gradient(180deg, var(--sidebar-bg) 0%, var(--sidebar-bg-mid) 100%);
    border-right: 1px solid var(--sidebar-border);
    overflow: hidden;
    z-index: 1045; /* slightly above content; offcanvas backdrop handles mobile */
    transition: width 0.2s ease;
}

/*
 * Bootstrap offcanvas-lg overrides (desktop)
 * Bootstrap applies background-color: transparent !important and width:auto !important
 * for .offcanvas-lg on large screens. We must explicitly override those so the
 * sidebar stays dark and fixed-width.
 */
@media (min-width: 992px) {
    .sidebar.offcanvas-lg {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        height: 100vh !important;
        width: var(--sidebar-width) !important;
        transform: none !important;
        visibility: visible !important;
        background:
            radial-gradient(ellipse 120% 60% at 0% 0%, rgba(45, 212, 191, 0.14), transparent 55%),
            linear-gradient(180deg, var(--sidebar-bg) 0%, var(--sidebar-bg-mid) 100%) !important;
        border-right: 1px solid var(--sidebar-border) !important;
        overflow: hidden !important;
        z-index: 1045 !important;
    }

    html.sidebar-collapsed .sidebar.offcanvas-lg {
        width: var(--sidebar-collapsed-width) !important;
    }
}

.sidebar-shell {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
}

.sidebar .offcanvas-header {
    border-bottom: 1px solid var(--sidebar-border);
    padding: 0.75rem 0.85rem;
}

.sidebar-brand {
    align-items: center;
    justify-content: space-between;
    gap: 0.4rem;
    flex-shrink: 0;
    padding: 0.7rem 0.7rem 0.65rem;
    border-bottom: 1px solid var(--sidebar-border);
}

.sidebar-collapse-btn {
    appearance: none;
    width: 28px;
    height: 28px;
    flex: 0 0 28px;
    border: 1px solid rgba(148, 163, 184, 0.22);
    background: rgba(255, 255, 255, 0.06);
    color: rgba(226, 232, 240, 0.88);
    border-radius: 0.4rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
    cursor: pointer;
}

.sidebar-collapse-btn:hover {
    background: rgba(45, 212, 191, 0.18);
    border-color: rgba(45, 212, 191, 0.45);
    color: #fff;
}

.sidebar .sidebar-inner {
    flex: 1 1 auto;
    min-height: 0;
    padding: 0.4rem 0.65rem 0.65rem;
    overflow-y: auto;
}

.sidebar .logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #fff;
    font-size: 1.05rem;
    font-weight: 700;
    padding: 0;
    margin: 0;
    border: 0;
    min-width: 0;
}

.sidebar .logo-mark {
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.5rem;
    background: linear-gradient(135deg, #14b8a6 0%, #0f766e 100%);
    color: #fff;
    font-weight: 800;
    letter-spacing: 0.5px;
    box-shadow: 0 4px 12px rgba(15, 118, 110, 0.35);
    flex-shrink: 0;
}

.sidebar .nav-link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    color: rgba(226, 232, 240, 0.72);
    padding: 0.42rem 0.65rem;
    border-radius: 0.5rem;
    margin-bottom: 0.12rem;
    transition: background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.sidebar .nav-link:hover {
    color: #fff;
    background: rgba(148, 163, 184, 0.12);
}

.sidebar .nav-link.active {
    color: #fff;
    background: linear-gradient(90deg, rgba(45, 212, 191, 0.22), rgba(15, 118, 110, 0.12));
    box-shadow: inset 3px 0 0 var(--sidebar-accent);
}

.sidebar .nav-link.active .nav-icon {
    color: var(--sidebar-accent);
}

.sidebar .nav-icon {
    font-size: 1.05rem;
    width: 1.25rem;
    text-align: center;
    flex: 0 0 auto;
    opacity: 0.95;
}

.sidebar .nav-text {
    white-space: nowrap;
}

.sidebar .nav-section {
    color: rgba(148, 163, 184, 0.65);
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    padding: 0.7rem 0.65rem 0.3rem;
}

/* Collapsible nav-section toggle */
.sidebar .nav-section-toggle {
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    user-select: none;
}
.sidebar .nav-section-toggle:hover {
    color: rgba(148, 163, 184, 0.9);
}
.sidebar .nav-section-chevron {
    font-size: 0.55rem;
    transition: transform 0.2s ease;
}
.sidebar .nav-section-toggle[aria-expanded="true"] .nav-section-chevron {
    transform: rotate(180deg);
}

/* Sub-links inside collapsible sections */
.sidebar .nav-link-sub {
    padding-left: 1.4rem;
    font-size: 0.82rem;
}

.sidebar .sidebar-inner > .nav-section:first-child {
    padding-top: 0.45rem;
}

.sidebar .sidebar-footer {
    flex-shrink: 0;
    padding: 0.45rem 0.65rem 0.65rem;
    border-top: 1px solid var(--sidebar-border);
}

.sidebar .sidebar-footer .btn-outline-light {
    border-color: rgba(148, 163, 184, 0.35);
    color: rgba(226, 232, 240, 0.85);
}

.sidebar .sidebar-footer .btn-outline-light:hover {
    background: rgba(45, 212, 191, 0.15);
    border-color: var(--sidebar-accent);
    color: #fff;
}

/* Desktop mini mode (icon-only) */
@media (min-width: 992px) {
    html.sidebar-collapsed .sidebar {
        width: var(--sidebar-collapsed-width);
    }

    html.sidebar-collapsed .main-content {
        margin-left: var(--sidebar-collapsed-width);
        max-width: calc(100vw - var(--sidebar-collapsed-width));
    }

    html.sidebar-collapsed .sidebar .nav-text,
    html.sidebar-collapsed .sidebar .nav-section,
    html.sidebar-collapsed .sidebar .logo-text,
    html.sidebar-collapsed .sidebar #sidebarUsefulLinks {
        display: none;
    }

    html.sidebar-collapsed .sidebar-brand {
        flex-direction: column;
        padding: 0.6rem 0.35rem 0.45rem;
        gap: 0.4rem;
    }

    html.sidebar-collapsed .sidebar .logo {
        justify-content: center;
    }

    html.sidebar-collapsed .sidebar .nav-link {
        justify-content: center;
        padding-left: 0.45rem;
        padding-right: 0.45rem;
    }

    html.sidebar-collapsed .sidebar .nav-icon {
        width: auto;
        font-size: 1.15rem;
    }

    html.sidebar-collapsed .sidebar-inner,
    html.sidebar-collapsed .sidebar-footer {
        padding-left: 0.4rem;
        padding-right: 0.4rem;
    }
}

/* Mobile: offcanvas behavior, no content left margin */
@media (max-width: 991.98px) {
    .main-content {
        margin-left: 0;
        max-width: 100vw;
        padding: 0 0 1rem;
    }

    html.sidebar-collapsed .main-content {
        margin-left: 0;
        max-width: 100vw;
    }
}

/* ==========================================================================
   Dashboard Home
   ========================================================================== */

.dash-home {
    --dash-ink: #15202b;
    --dash-muted: #6b7785;
    --dash-teal: #0f766e;
    --dash-teal-soft: rgba(15, 118, 110, 0.12);
    --dash-slate: #334155;
    --dash-panel-border: rgba(15, 23, 42, 0.06);
    --dash-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px rgba(15, 23, 42, 0.06);
}

.dash-hero {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin: 0 0 0.85rem;
    padding: 0.7rem 1rem;
    border-radius: 1rem;
    color: #f8fafc;
    background:
        radial-gradient(ellipse 80% 120% at 100% 0%, rgba(45, 212, 191, 0.22), transparent 55%),
        radial-gradient(ellipse 60% 80% at 0% 100%, rgba(56, 189, 248, 0.12), transparent 50%),
        linear-gradient(135deg, #0f172a 0%, #1e293b 55%, #0f766e 140%);
    box-shadow: var(--dash-shadow);
    overflow: hidden;
    position: relative;
}

.dash-hero::after {
    content: "";
    position: absolute;
    inset: 0;
    background-image: linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
    background-size: 28px 28px;
    mask-image: linear-gradient(to bottom right, black, transparent 70%);
    pointer-events: none;
}

.dash-hero-copy,
.dash-hero-actions {
    position: relative;
    z-index: 1;
}

.dash-hero-eyebrow {
    margin: 0 0 0.35rem;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(226, 232, 240, 0.7);
}

.dash-hero-title {
    margin: 0;
    font-size: clamp(1.35rem, 2.2vw, 1.75rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    color: #fff;
}

.dash-hero-sub {
    margin: 0.4rem 0 0;
    font-size: 0.925rem;
    color: rgba(226, 232, 240, 0.82);
}

.dash-hero-sub strong {
    color: #fff;
    font-weight: 600;
}

.dash-hero-tz {
    opacity: 0.75;
}

.dash-hero-actions .btn-light {
    border: 0;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.dash-filter {
    border: 1px solid var(--dash-panel-border);
    box-shadow: var(--dash-shadow);
    border-radius: 0.65rem;
    margin-bottom: 0.85rem;
}

.dash-filter .form-label {
    color: var(--dash-muted);
    font-weight: 500;
}

.dash-kpi-grid {
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.dash-kpi {
    position: relative;
    border: 1px solid var(--dash-panel-border);
    box-shadow: var(--dash-shadow);
    overflow: hidden;
    opacity: 0;
    transform: translateY(8px);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.dash-kpi::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: #94a3b8;
}

.dash-kpi-cost::before { background: #64748b; }
.dash-kpi-revenue::before { background: #0284c7; }
.dash-kpi-profit::before { background: var(--dash-teal); }
.dash-kpi-roi::before { background: #0d9488; }
.dash-kpi-campaigns::before { background: #475569; }

.dash-kpi:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.1);
}

.dash-kpi-in {
    animation: dashKpiIn 0.45s ease forwards;
}

@keyframes dashKpiIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dash-kpi-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.35rem;
}

.dash-kpi .label {
    font-weight: 600;
    color: var(--dash-muted);
    letter-spacing: 0.01em;
}

.dash-kpi-icon {
    width: 2rem;
    height: 2rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.55rem;
    background: #f1f5f9;
    color: var(--dash-slate);
    font-size: 1rem;
}

.dash-kpi-profit .dash-kpi-icon,
.dash-kpi-roi .dash-kpi-icon {
    background: var(--dash-teal-soft);
    color: var(--dash-teal);
}

.dash-kpi .value {
    font-size: 1.65rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--dash-ink);
    line-height: 1.2;
}

.dash-kpi-meta {
    margin-top: 0.35rem;
    font-size: 0.75rem;
    color: var(--dash-muted);
}

.dash-panel {
    border: 1px solid var(--dash-panel-border);
    box-shadow: var(--dash-shadow);
    overflow: hidden;
}

.dash-panel-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 1rem 1.15rem 0.85rem;
    border-bottom: 1px solid #eef1f4;
    background: linear-gradient(180deg, #fff 0%, #fafbfc 100%);
}

.dash-panel-head h5 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--dash-ink);
    letter-spacing: -0.01em;
}

.dash-panel-head h5 .bi {
    color: var(--dash-teal);
}

.dash-panel-head-success h5 .bi { color: #198754; }
.dash-panel-head-danger h5 .bi { color: #dc3545; }

.dash-panel-sub {
    display: block;
    margin-top: 0.15rem;
    font-size: 0.78rem;
    color: var(--dash-muted);
}

.dash-panel-count {
    min-width: 1.75rem;
    height: 1.75rem;
    padding: 0 0.45rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: #f1f5f9;
    color: var(--dash-slate);
    font-size: 0.75rem;
    font-weight: 700;
}

.dash-panel-body {
    padding: 0.35rem 0.85rem 0.85rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.dash-chart-wrap {
    height: 220px;
    padding: 0.75rem 1rem 0.25rem;
}

.dash-table {
    --bs-table-hover-bg: rgba(15, 118, 110, 0.04);
}

.dash-table thead th {
    background: transparent !important;
    color: var(--dash-muted);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom-width: 1px;
    white-space: nowrap;
}

.dash-table tbody td {
    vertical-align: middle;
    font-size: 0.875rem;
    border-color: #f1f3f5;
}

/* Frozen thead / tfoot (public/js/sticky-table.js); .dash-table / .datatable tables get .sticky-table automatically. */
/* overflow-x: hidden makes .main-content a scroll container, which stops the sticky top bar; clip does not. */
.main-content:has(table.sticky-table) {
    overflow-x: clip;
}

/* No !important, so page-level header colours (e.g. activity analytics groups) still win. */
table.sticky-table > thead > tr > *,
table.sticky-table > tfoot > tr > * {
    position: relative;
    z-index: 3;
    background-color: #e8eef5;
    font-weight: 700;
}

table.sticky-table > thead > tr > * {
    color: #0f172a;
    border-bottom: 2px solid #cbd5e1;
}

table.sticky-table > tfoot > tr > * { border-top: 2px solid #cbd5e1; }

/* .dash-table thead th sets a transparent background with !important. */
.dash-table.sticky-table > thead > tr > * {
    background-color: #e8eef5 !important;
}

table.sticky-table.is-stuck-head > thead > tr > * {
    box-shadow: 0 3px 6px -2px rgba(15, 23, 42, 0.2);
}

table.sticky-table.is-stuck-foot > tfoot > tr > * {
    box-shadow: 0 -3px 6px -2px rgba(15, 23, 42, 0.2);
}

@media print {
    table.sticky-table > thead > tr > *,
    table.sticky-table > tfoot > tr > * {
        transform: none !important;
        box-shadow: none !important;
    }
}

.dash-link {
    color: var(--dash-ink);
    font-weight: 600;
    text-decoration: none;
}

.dash-link:hover {
    color: var(--dash-teal);
    text-decoration: underline;
}

.dash-chip {
    display: inline-block;
    padding: 0.12rem 0.45rem;
    border-radius: 0.35rem;
    background: #f1f5f9;
    color: var(--dash-slate);
    font-size: 0.75rem;
    font-weight: 600;
}

.dash-bar {
    height: 6px;
    border-radius: 999px;
    background: #eef2f6;
    overflow: hidden;
}

.dash-bar-fill {
    display: block;
    height: 100%;
    border-radius: inherit;
    transition: width 0.5s ease;
}

.dash-bar-fill.is-profit { background: linear-gradient(90deg, #14b8a6, #0f766e); }
.dash-bar-fill.is-loss { background: linear-gradient(90deg, #f87171, #dc3545); }

.dash-empty {
    text-align: center;
    color: var(--dash-muted) !important;
    padding: 2rem 1rem !important;
    font-size: 0.9rem;
}

@media (max-width: 575.98px) {
    .dash-hero {
        padding: 0.9rem 0.85rem;
    }

    .main-content:has(.dash-hero) .dash-hero {
        padding: 0.65rem 0.85rem 0.75rem;
    }

    .dash-kpi .value {
        font-size: 1.4rem;
    }

    .dash-panel-body {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
        overflow-x: auto;
    }
}

/* User × Date Matrix */
.matrix-table th,
.matrix-table td {
    white-space: nowrap;
    vertical-align: top;
    font-size: 0.8rem;
}
.matrix-table .v { font-weight: 600; }
.matrix-table .ug-even { background: #f6fbff; }
.matrix-table .ug-odd { background: #fffaf2; }
.matrix-table .ug-total { background: #f3f3f3; }
.matrix-table .ug-start { border-left: 3px solid #9a9a9a !important; }
.matrix-table tfoot td { font-weight: 700; }

.smart-section {
    padding: 1rem 1.15rem;
    background: #fafafa;
    border: 1px solid var(--dash-panel-border, #e5e7eb);
    border-radius: 0.85rem;
    box-shadow: var(--dash-shadow, 0 1px 3px rgba(0,0,0,0.06));
}
.smart-toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.smart-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 10px; }
.smart-card { background: #fff; border: 1px solid #ccc; border-radius: 4px; padding: 8px; }
.smart-card.total { border: 2px solid #555; background: #f0f4f8; }
.smart-card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; gap: 8px; }
.smart-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.smart-table th, .smart-table td { padding: 3px 5px; border-bottom: 1px solid #eee; text-align: right; }
.smart-table th:first-child, .smart-table td:first-child { text-align: left; }
.smart-table thead th { background: #f0f0f0; }
.pct-up { color: #007a00; font-weight: 700; }
.pct-down { color: #c00000; font-weight: 700; }
.pct-flat { color: #888; }
.smart-text { display: none; }
.copy-toast {
    position: fixed; bottom: 20px; right: 20px; background: #333; color: #fff;
    padding: 8px 14px; border-radius: 4px; opacity: 0; transition: opacity 0.2s; z-index: 9999; pointer-events: none;
}
.copy-toast.show { opacity: 1; }

.feedback-box { background: #fff; border: 1px solid #ccc; border-left: 4px solid #0f766e; border-radius: 4px; padding: 10px 12px; }
.feedback-head { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.feedback-overall { background: #f0f4f8; border: 1px solid #cfd8e3; padding: 6px 10px; border-radius: 4px; font-size: 13px; margin-bottom: 8px; }
.feedback-block { display: none; }
.feedback-block.active { display: block; }
.feedback-empty { color: #888; font-style: italic; padding: 6px 0; }
.feedback-cats { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 10px; margin-bottom: 10px; }
.feedback-cat { border: 1px solid #e3e3e3; border-radius: 4px; padding: 6px 8px; background: #fff; font-size: 12px; }
.feedback-cat h4 { margin: 0 0 4px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.4px; }
.feedback-cat ol, .feedback-cat ul { margin: 0; padding-left: 18px; }
.feedback-cat.top { border-left: 3px solid #007a00; }
.feedback-cat.top h4 { color: #007a00; }
.feedback-cat.down { border-left: 3px solid #c00000; }
.feedback-cat.down h4 { color: #c00000; }
.feedback-cat.stable { border-left: 3px solid #888; }
.feedback-cat.stable h4 { color: #555; }
.feedback-cat.inactive { border-left: 3px solid #d97706; }
.feedback-cat.inactive h4 { color: #b45309; }

/* User Dashboard tabs */
.ud-tabs .nav-link {
    color: #475569;
    font-weight: 600;
    font-size: 0.875rem;
    border-radius: 999px;
    padding: 0.4rem 0.9rem;
    margin-right: 0.25rem;
    margin-bottom: 0.35rem;
}
.ud-tabs .nav-link:hover { background: var(--primary-soft); color: var(--primary); }
.ud-tabs .nav-link.active {
    background: linear-gradient(135deg, #0f766e 0%, #0d9488 100%);
    color: #fff;
    box-shadow: 0 2px 8px rgba(15, 118, 110, 0.3);
}
.ud-loading {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.72);
    border-radius: 0.75rem;
}
.ud-dimmed { opacity: 0.45; pointer-events: none; }
.ud-kpi-strip { margin-bottom: 1rem; }
.ud-kpi-strip .dash-kpi { opacity: 1; transform: none; }

/* Quick Links */
.ql-group { display: inline-flex; flex-wrap: wrap; gap: 2px 0; align-items: center; font-size: 0.8rem; }
.ql-link { white-space: nowrap; color: var(--primary); text-decoration: none; padding: 1px 4px; border-radius: 3px; transition: background 0.15s; }
.ql-link:hover { background: var(--primary-soft); text-decoration: underline; }
.ql-sep { color: #bbb; margin: 0 1px; font-size: 0.7rem; }
.ql-ph-list { line-height: 1.9; }
.ql-ph {
    cursor: pointer;
    user-select: none;
    padding: 1px 5px;
    border-radius: 3px;
    background: #f1f5f9;
    color: #0f172a;
    font-size: 0.8em;
    white-space: nowrap;
}
.ql-ph:hover,
.ql-ph:focus {
    background: var(--primary-soft);
    color: var(--primary);
    outline: none;
}
.ql-ph.copied {
    background: #d1fae5;
    color: #059669;
}

/* DataTables (global DashDT) */
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter,
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate {
    font-size: 0.85rem;
    color: var(--muted, #64748b);
}
.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
    border: 1px solid rgba(15, 23, 42, 0.12);
    border-radius: 0.4rem;
    padding: 0.2rem 0.45rem;
}
.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: var(--primary-soft, #e0f2f1) !important;
    border-color: transparent !important;
}
.dash-panel .dataTables_wrapper,
.data-table .dataTables_wrapper {
    padding: 0 0.25rem 0.5rem;
}

/* Compact forms — dense labels, controls, filter bars, edit cards */
.main-content .form-label {
    margin-bottom: 0.15rem;
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--muted);
}

.main-content .form-control,
.modal-body .form-control {
    font-size: 0.8125rem;
    padding: 0.22rem 0.5rem;
    min-height: calc(1.5em + 0.44rem + 2px);
    border-radius: 0.375rem;
}

/* Keep extra right padding so the Bootstrap caret does not overlap the value */
.main-content .form-select,
.modal-body .form-select {
    font-size: 0.8125rem;
    padding: 0.22rem 1.85rem 0.22rem 0.5rem;
    min-height: calc(1.5em + 0.44rem + 2px);
    border-radius: 0.375rem;
    background-position: right 0.45rem center;
    background-size: 12px 10px;
}

.main-content textarea.form-control,
.modal-body textarea.form-control {
    min-height: 2.4rem;
    padding-top: 0.35rem;
}

.main-content form .mb-3 {
    margin-bottom: 0.55rem !important;
}

.main-content .form-text,
.modal-body .form-text {
    font-size: 0.72rem;
    margin-top: 0.15rem;
}

.modal-body .form-label {
    margin-bottom: 0.15rem;
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--muted);
}

.filter-bar .row,
.dash-filter .row {
    --bs-gutter-x: 0.5rem;
    --bs-gutter-y: 0.35rem;
}

.filter-bar.mb-3,
.dash-filter.mb-3,
.filter-bar.mb-4,
.dash-filter.mb-4 {
    margin-bottom: 0.75rem !important;
}

.filter-bar .col-auto > .form-control,
.filter-bar .col-auto > .form-select,
.dash-filter .col-auto > .form-control,
.dash-filter .col-auto > .form-select {
    width: auto;
    min-width: 7.5rem;
}

.filter-bar .col-auto > input[type="date"],
.dash-filter .col-auto > input[type="date"] {
    min-width: 9.25rem;
}

.filter-bar .col-auto > input[type="text"],
.filter-bar .col-auto > input[type="search"],
.dash-filter .col-auto > input[type="text"],
.dash-filter .col-auto > input[type="search"] {
    min-width: 9rem;
}

.filter-bar .form-check,
.dash-filter .form-check {
    min-height: calc(1.5em + 0.44rem + 2px);
    display: flex;
    align-items: center;
    margin: 0;
}

.user-card,
.edit-card,
.offer-form-card,
.profile-admin-card {
    padding: 0.85rem 1rem;
}

.offer-form-card h6,
.edit-card h6 {
    padding-bottom: 0.4rem;
    margin-bottom: 0.65rem;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #64748b;
}

[data-photo-preview] {
    cursor: zoom-in;
}

.photo-preview {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
    background: rgba(15, 23, 42, 0.84);
    cursor: zoom-out;
}
.photo-preview[hidden] {
    display: none !important;
}
.photo-preview img {
    max-width: min(92vw, 720px);
    max-height: 88vh;
    border-radius: 0.75rem;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
    object-fit: contain;
    background: #0f172a;
    cursor: default;
}
.photo-preview-close {
    position: absolute;
    top: 0.7rem;
    right: 0.85rem;
    width: 2rem;
    height: 2rem;
    border: 0;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
}
.photo-preview-close:hover {
    background: rgba(255, 255, 255, 0.28);
}
.profile-thumb {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid #e2e8f0;
    vertical-align: middle;
}

/* -- Realtime network boards ------------------------------------------- */
.realtime-table {
    font-size: 0.82rem;
}
.realtime-table th {
    white-space: nowrap;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    color: #64748b;
}
.realtime-table td {
    vertical-align: middle;
}
.realtime-thumb {
    max-width: 110px;
    max-height: 70px;
    object-fit: contain;
    border-radius: 0.25rem;
    border: 1px solid #e2e8f0;
    cursor: zoom-in;
    background: #fff;
}
.btn-xs {
    --bs-btn-padding-y: 0.05rem;
    --bs-btn-padding-x: 0.35rem;
    --bs-btn-font-size: 0.7rem;
}
.realtime-inline-edit .input-group {
    width: 10rem;
}
.realtime-inline-edit .realtime-value {
    font-variant-numeric: tabular-nums;
}
.realtime-toggle {
    --bs-btn-padding-y: 0.1rem;
    --bs-btn-padding-x: 0.4rem;
    --bs-btn-font-size: 0.72rem;
    white-space: nowrap;
}
.realtime-panels .accordion-button {
    font-weight: 600;
    padding-top: 0.6rem;
    padding-bottom: 0.6rem;
}
.realtime-summary .fs-5 {
    font-variant-numeric: tabular-nums;
}
.realtime-toast {
    position: fixed;
    bottom: 1.25rem;
    right: 1.25rem;
    z-index: 1080;
    max-width: 24rem;
    padding: 0.65rem 1rem;
    border-radius: 0.5rem;
    background: #0f172a;
    color: #fff;
    font-size: 0.85rem;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.3);
}
.realtime-toast.is-error {
    background: #b91c1c;
}
.realtime-toast[hidden] {
    display: none !important;
}