:root {
    /* Palette Adasta */
    --bg-body: #121212;
    --bg-card: #1E1E1E;
    --bg-header: #2C2C2C;
    --bg-input: #2C2C2C;
    --border-color: #383838;
    --text-primary: #FFFFFF;
    --text-secondary: #A0A0A0;
    --accent-yellow: #F2A900;
    --accent-hover: #d49200;
    --status-green: #8BC34A;
    --status-blue: #3F51B5;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-body);
    color: var(--text-primary);
    font-family: 'Montserrat', sans-serif;
    font-size: 13px;
    line-height: 1.5;
    padding: 20px;
}

/* Layout */
.container {
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

.flex-row {
    display: flex;
    gap: 15px;
    align-items: center;
}

.flex-between {
    justify-content: space-between;
}

/* Grids */
.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
}

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

.grid-4-filter {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 15px;
    align-items: end;
}

/* Spacing & Utilities */
.w-40 {
    width: 40px;
}

.w-100 {
    width: 100%;
}

.max-w-100 {
    max-width: 100%;
}

.col-span-2 {
    grid-column: span 2;
}

.mr-8 {
    margin-right: 8px;
}

.mr-10 {
    margin-right: 10px;
}

.mr-15 {
    margin-right: 15px;
}

.mb-0 {
    margin-bottom: 0px !important;
}

.mb-10 {
    margin-bottom: 10px;
}

.mb-20 {
    margin-bottom: 20px;
}

.mt-20 {
    margin-top: 20px;
}

.mt-auto {
    margin-top: auto;
}

.gap-10 {
    gap: 10px;
}

.gap-20 {
    gap: 20px;
}

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

/* Typography & Buttons */
h1 {
    font-size: 24px;
    font-weight: 700;
    color: #fff;
}

h3 {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
}

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

.text-16 {
    font-size: 16px;
}

a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 12px;
    transition: 0.2s;
}

a:hover {
    color: var(--accent-yellow);
}

.btn {
    padding: 9px 16px;
    border-radius: 4px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    font-size: 13px;
    transition: 0.2s;
    white-space: nowrap;
}

.btn-block {
    width: 100%;
}

.btn-primary {
    background-color: var(--accent-yellow);
    color: #121212;
}

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

.btn-outline {
    background-color: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.btn-outline:hover {
    border-color: var(--text-secondary);
}

/* Clear Filters Button (Link Style) */
.btn-clear {
    color: var(--accent-yellow);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    background: none;
    border: none;
}

.btn-clear:hover {
    text-decoration: underline;
}

/* Inputs */
label {
    display: block;
    color: var(--text-secondary);
    font-size: 11px;
    margin-bottom: 5px;
    font-weight: 500;
}

input[type="text"],
input[type="number"],
select {
    width: 100%;
    padding: 10px 12px;
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 13px;
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--accent-yellow);
}

/* Cards */
.card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 20px;
    margin-bottom: 15px;
}

.card-transparent {
    padding: 0;
    overflow: hidden;
    border: none;
    background: transparent;
}

.user-avatar {
    background: #333;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}

/* Dividers */
.divider-dashed {
    border-top: 1px dashed var(--border-color);
    margin: 20px 0;
    opacity: 0.5;
}

.divider-solid {
    border-top: 1px solid var(--border-color);
    margin: 25px 0;
}

.divider-solid-sm {
    border-top: 1px solid var(--border-color);
    opacity: 0.3;
    margin: 15px 0;
}

/* Helpers Typography */
.section-title-sm {
    font-weight: 600;
    font-size: 13px;
}

.section-subtitle {
    font-weight: 600;
    font-size: 12px;
}

.ctv-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
}

.radio-label-inline {
    display: inline;
}

.radio-label-flex {
    margin-bottom: 0;
    display: flex;
    align-items: center;
}

.label-uppercase {
    text-transform: uppercase;
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 10px;
    display: block;
}

.label-sm {
    font-size: 12px;
    color: var(--text-secondary);
}

.video-targeting-title {
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #fff;
}

/* --- TABS SYSTEM --- */
.tabs-container {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 25px;
}

.tab-btn {
    padding: 12px 25px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    font-family: inherit;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.tab-btn:hover {
    color: #fff;
}

.tab-btn.active {
    color: var(--accent-yellow);
    border-bottom-color: var(--accent-yellow);
}

.tab-content {
    display: none;
}

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

/* --- TABLE STYLES (Audience Manager) --- */
.table-responsive {
    overflow-x: auto;
    overflow-y: auto;
    max-height: 50vh;
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

table#audience-table {
    width: 100%;
    border-collapse: collapse;
    background-color: var(--bg-card);
    min-width: 100%;
}

#audience-table th {
    text-align: left;
    padding: 8px;
    background-color: var(--bg-header);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

#audience-table th i {
    margin-left: 5px;
    color: var(--text-secondary);
    font-size: 10px;
    cursor: pointer;
}

#audience-table td {
    padding: 8px;
    border-bottom: 1px solid var(--border-color);
    font-size: 12px;
    vertical-align: middle;
}

#audience-table tr:hover td {
    background-color: rgba(255, 255, 255, 0.05);
}

#audience-table tr.selected td {
    background-color: rgba(242, 169, 0, 0.1);
}

#audience-table tr.selected:hover td {
    background-color: rgba(242, 169, 0, 0.15);
}

#audience-table tbody tr {
    cursor: pointer;
}

#audience-table th:nth-child(2),
#audience-table td:nth-child(2) {
    display: none;
}

#audience-table th:nth-child(3),
#audience-table td:nth-child(3) {
    display: none;
}

/* Other columns take only needed space */
#audience-table th:nth-child(1),
#audience-table td:nth-child(1),
#audience-table th:nth-child(5),
#audience-table td:nth-child(5),
#audience-table th:nth-child(6),
#audience-table td:nth-child(6),
#audience-table th:nth-child(7),
#audience-table td:nth-child(7) {
    width: 1%;
    white-space: nowrap;
}

/* Audience Name takes remaining space and truncates */
#audience-table th:nth-child(4),
#audience-table td:nth-child(4) {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    width: 100%;
    max-width: 0;
}

/* Standardize padding for numeric columns */
#audience-table th:nth-child(5),
#audience-table td:nth-child(5),
#audience-table th:nth-child(6),
#audience-table td:nth-child(6),
#audience-table th:nth-child(7),
#audience-table td:nth-child(7) {
    padding: 8px 12px;
    text-align: right;
}

#audience-table input[type="checkbox"],
#audience-table input[type="radio"] {
    margin-right: 0;
}

.badge-group {
    display: flex;
    gap: 5px;
}

.badge-circle {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 700;
    color: #fff;
}

.bg-green {
    background-color: var(--status-green);
    color: #121212;
}

.bg-blue {
    background-color: var(--status-blue);
}

/* --- PLANNER SPECIFIC --- */
input[type="checkbox"],
input[type="radio"] {
    accent-color: var(--accent-yellow);
    width: 14px;
    height: 14px;
    cursor: pointer;
    margin-right: 8px;
    vertical-align: middle;
}

.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
}

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

.checkbox-item {
    display: flex;
    align-items: center;
}

.checkbox-item i {
    width: 20px;
    text-align: center;
    margin-right: 8px;
    color: var(--text-secondary);
    font-size: 14px;
}

.checkbox-item label {
    margin-bottom: 0;
    color: var(--text-primary);
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
}

details {
    margin-bottom: 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    overflow: hidden;
    background-color: var(--bg-card);
}

summary {
    list-style: none;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    padding: 15px;
    background-color: var(--bg-header);
}

.summary-content {
    display: flex;
    align-items: center;
    width: 100%;
}

summary .summary-content::before {
    content: '\f078';
    font-family: 'Font Awesome 7 Free';
    font-weight: 900;
    margin-right: 15px;
    font-size: 12px;
    color: var(--text-secondary);
    transition: transform 0.2s;
}

details[open] {
    overflow: visible;
}

details[open] summary .summary-content::before {
    transform: rotate(180deg);
}

.selected-summary {
    color: var(--accent-yellow);
    font-size: 12px;
    margin-top: 5px;
    margin-left: 28px;
    font-weight: 500;
}

.accordion-body {
    padding: 20px;
    border-top: 1px solid var(--border-color);
}

.hidden {
    display: none !important;
}

.fixed-currency {
    font-weight: 700;
    padding: 12px 0;
}

/* Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 34px;
    height: 18px;
    margin-right: 8px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #444;
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 12px;
    width: 12px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: var(--accent-yellow);
}

input:checked+.slider:before {
    transform: translateX(16px);
    background-color: #121212;
}

/* Search Input Icon */
.search-wrapper {
    position: relative;
    width: 100%;
}

.search-wrapper i {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    font-size: 12px;
}

.search-wrapper input {
    padding-left: 30px;
}

.input-group-text {
    display: flex;
    align-items: center;
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 4px;
}

.input-group-text input {
    border: none;
    background: transparent;
    flex-grow: 1;
    box-shadow: none;
}

.input-group-text span {
    padding: 0 10px;
    color: var(--text-secondary);
    font-size: 11px;
    border-left: 1px solid var(--border-color);
}

/* Dropdown selector */
.dropdown-field {
    position: relative;
}

.dropdown-toggle {
    width: 100%;
    padding: 10px 12px;
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 13px;
    text-align: left;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
}

.dropdown-toggle:hover {
    border-color: var(--text-secondary);
}

.dropdown-toggle i {
    color: var(--text-secondary);
    font-size: 12px;
    margin-left: 10px;
}

.dropdown-panel {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    min-width: 100%;
    max-width: 350px;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.35);
    padding: 10px;
    z-index: 20;
    display: none;
}

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

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

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-primary);
}

.dropdown-item input {
    margin: 0;
    flex-shrink: 0;
}

.dropdown-caption {
    font-size: 11px;
    color: var(--text-secondary);
    margin-left: 24px;
}

/* Async dropdown — search + scrollable list */
.dropdown-search {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    padding: 6px 8px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--bg-input);
}

.dropdown-search i {
    color: var(--text-secondary);
    font-size: 12px;
}

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

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

.dropdown-field-async .dropdown-list {
    max-height: 220px;
    overflow-y: auto;
}

.dropdown-loading {
    text-align: center;
    padding: 8px 0;
    font-size: 12px;
    color: var(--text-secondary);
}

/* --- MOBILE RESPONSIVE --- */
@media (max-width: 768px) {
    header.flex-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

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

    .grid-3,
    .grid-4-filter {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .checkbox-grid {
        grid-template-columns: 1fr 1fr;
    }

    .tabs-container {
        overflow-x: auto;
        white-space: nowrap;
    }

    /* Manager Header Mobile */
    .manager-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .manager-header .btn-clear {
        margin-left: 0;
        margin-top: 5px;
    }

    /* Filtri audience compatti su mobile */
    .grid-4-filter select {
        font-size: 12px;
    }

    .grid-4-filter label {
        font-size: 10px;
    }

    /* Audience table: keep table layout, allow inner horizontal scroll */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: 6px;
        max-width: 100%;
    }

    .table-responsive table {
        min-width: 680px;
        width: 100%;
    }

    .table-responsive th,
    .table-responsive td {
        padding: 10px 12px;
        font-size: 12px;
    }
}

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

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

/* Layout Columns */
.main-wrapper {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

.content-area {
    flex: 1;
    min-width: 0;
    width: 100%
}

.sidebar-summary {
    width: 350px;
    flex-shrink: 0;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 20px;
    position: sticky;
    top: 20px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

/* Sidebar Styles */
.summary-section {
    margin-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 15px;
}

.summary-section:last-of-type {
    border-bottom: none;
}

.summary-title {
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
}

.summary-title i {
    margin-right: 8px;
    color: var(--accent-yellow);
    width: 16px;
    text-align: center;
}

.summary-item {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 4px;
    padding-left: 24px;
    line-height: 1.4;
}

.summary-item strong {
    color: var(--text-primary);
}

.empty-state {
    font-style: italic;
    color: var(--text-secondary);
    font-size: 12px;
    padding-left: 24px;
    opacity: 0.7;
}

/* Mobile responsive for sidebar */
@media (max-width: 900px) {
    .main-wrapper {
        flex-direction: column;
    }

    .sidebar-summary {
        width: 100%;
        position: static;
        max-height: none;
    }
}

/* ══════════════════════════════════════════════════════════
           INSIGHT DASHBOARD
           ══════════════════════════════════════════════════════════ */

.insight-dashboard {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 0;
    overflow: visible;
    min-width: 0;
    /* constrain within flex parent */
}

.insight-dash-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border-color);
}

.insight-dash-header h3 {
    font-size: 15px;
    font-weight: 600;
}

.insight-date-range {
    display: flex;
    align-items: center;
    gap: 8px;
}

.insight-date-range label {
    display: inline;
    margin: 0;
    font-size: 11px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.insight-date-range input[type="date"] {
    width: auto;
    padding: 6px 10px;
    font-size: 12px;
    border-radius: 4px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-family: inherit;
    cursor: pointer;
}

.insight-date-range input[type="date"]:focus {
    outline: none;
    border-color: var(--accent-yellow);
}

/* ── Grid layouts ── */
.insight-grid {
    display: grid;
    gap: 0;
}

.insight-grid--1 {
    grid-template-columns: 1fr;
}

.insight-grid--2 {
    grid-template-columns: 1fr 1fr;
}

.insight-grid--3 {
    grid-template-columns: 1fr 1fr 1fr;
}

.insight-panel {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    min-height: 120px;
    min-width: 0;
    /* prevent grid blowout */
    overflow: visible;
    /* allow tooltips to overflow */
    position: relative;
}

.insight-grid--2 .insight-panel:first-child {
    border-right: 1px solid var(--border-color);
}

.insight-grid--3 .insight-panel {
    border-right: 1px solid var(--border-color);
}

.insight-grid--3 .insight-panel:last-child {
    border-right: none;
}

.insight-panel-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    margin-bottom: 16px;
}

.insight-panel-title i {
    color: var(--text-secondary);
    font-size: 14px;
}

/* ── Donut panels ── */
.insight-panel--donut .insight-body {
    display: flex;
    align-items: center;
    gap: 16px;
}

.insight-body {
    display: flex;
    align-items: center;
    gap: 32px;
    min-width: 0;
    overflow: visible;
}

/* Donut chart */
.donut-ring {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    flex-shrink: 0;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.donut-hole {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--bg-card);
    position: absolute;
}

.donut-pulse {
    background: conic-gradient(#383838 0% 100%) !important;
    animation: donut-spin 1.2s linear infinite;
}

.donut-empty {
    background: conic-gradient(#383838 0% 100%) !important;
}

@keyframes donut-spin {
    0% {
        transform: rotate(0deg);
    }

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

.donut-legend {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
}

.legend-swatch {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    flex-shrink: 0;
}

.legend-label {
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── KPI headline (Avails, Bid Requests, CPM) ── */
.kpi-headline {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-bottom: 12px;
}

.kpi-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
}

.kpi-help {
    font-size: 10px;
    color: var(--text-secondary);
    cursor: help;
    margin-left: 4px;
}

.kpi-value {
    font-size: 22px;
    font-weight: 700;
    line-height: 1.2;
}

.kpi-value--orange {
    color: #E8751A;
}

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

.kpi-value--error {
    color: #e57373;
    font-size: 14px;
}

.kpi-sub {
    font-size: 11px;
    font-weight: 500;
}

.kpi-chart-wrap {
    height: 120px;
    position: relative;
    min-width: 0;
    /* let canvas shrink in flex/grid */
    overflow: hidden;
}

.kpi-chart-wrap--cpm {
    height: 120px;
}


.kpi-chart-loading {
    background: repeating-linear-gradient(90deg,
            rgba(255, 255, 255, 0.03) 0%, rgba(255, 255, 255, 0.06) 50%, rgba(255, 255, 255, 0.03) 100%);
    background-size: 200% 100%;
    animation: kpi-shimmer 1.5s ease-in-out infinite;
    border-radius: 4px;
}

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

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

.kpi-chart-empty,
.kpi-chart-error {
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 4px;
}

.kpi-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 10px;
    min-width: 0;
}

/* ── Creative Sizes widget ── */
.cs-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.cs-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: #fff;
}

.cs-title i {
    color: var(--text-secondary);
}

.cs-bar {
    display: flex;
    width: 100%;
    height: 22px;
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 14px;
}

.cs-bar--loading {
    background: #383838;
    animation: kpi-shimmer 1.5s ease-in-out infinite;
    background-size: 200% 100%;
}

.cs-bar--empty,
.cs-bar--error {
    background: #2a2a2a;
}

.cs-bar-seg {
    min-width: 2px;
    transition: width 0.4s ease;
}

.cs-legend {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 6px 24px;
}

.cs-legend-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
}

.cs-see-all {
    font-size: 11px;
    font-weight: 600;
    color: var(--accent-yellow);
    text-decoration: none;
    transition: color 0.2s;
}

.cs-see-all:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

/* Modal popup styles */
.cs-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: 10000;
    padding: 20px;
}

.cs-modal-content {
    background: #fff;
    color: #333;
    width: 100%;
    max-width: 700px;
    max-height: 90vh;
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
}

.cs-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 25px;
    border-bottom: 1px solid #eee;
}

.cs-modal-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

.cs-modal-close-btn {
    background: none;
    border: none;
    font-size: 24px;
    color: #999;
    cursor: pointer;
    line-height: 1;
}

.cs-modal-close-btn:hover {
    color: #333;
}

.cs-modal-body {
    padding: 25px;
    overflow-y: auto;
}

.cs-modal-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px 40px;
}

.cs-modal-row {
    display: flex;
    align-items: center;
    font-size: 13px;
    padding: 4px 0;
}

.cs-modal-label {
    font-weight: 600;
    width: 100px;
    flex-shrink: 0;
}

.cs-modal-pct {
    width: 70px;
    color: #666;
    text-align: right;
    margin-right: 15px;
}

.cs-modal-cpm {
    color: #999;
    font-size: 12px;
}

.cs-modal-footer {
    padding: 15px 25px;
    border-top: 1px solid #eee;
    display: flex;
    justify-content: flex-end;
}

.cs-modal-btn-close {
    min-width: 120px;
    padding: 12px 20px;
    font-size: 14px;
}

@media (max-width: 600px) {
    .cs-modal-grid {
        grid-template-columns: 1fr;
    }

    .cs-modal-content {
        max-width: 100%;
    }
}

.cs-legend-name {
    color: var(--text-primary);
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cs-legend-pct {
    color: var(--text-secondary);
    white-space: nowrap;
}

.cs-legend-cpm {
    color: var(--text-secondary);
    white-space: nowrap;
    font-size: 11px;
}

/* ── Insight state panels (loading / empty / error) ── */
.insight-state {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.insight-state-icon {
    font-size: 22px;
    margin-bottom: 2px;
}

.insight-state-icon--error {
    color: #e57373;
}

.insight-state-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.insight-state-text {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.insight-state-detail {
    font-size: 11px;
    color: #e57373;
    font-family: monospace;
    background: rgba(229, 115, 115, 0.08);
    border: 1px solid rgba(229, 115, 115, 0.2);
    border-radius: 4px;
    padding: 6px 8px;
    line-height: 1.5;
    word-break: break-word;
}

.donut-error {
    background: conic-gradient(rgba(229, 115, 115, 0.25) 0% 100%) !important;
}

/* ── Responsive — Tablet (≤ 900px) ── */
@media (max-width: 900px) {
    .insight-grid--2 {
        grid-template-columns: 1fr;
    }

    .insight-grid--3 {
        grid-template-columns: 1fr 1fr;
    }

    .insight-grid--2 .insight-panel:first-child {
        border-right: none;
    }

    .insight-grid--3 .insight-panel {
        border-right: none;
    }

    .insight-grid--3 .insight-panel:nth-child(odd) {
        border-right: 1px solid var(--border-color);
    }

    .insight-grid--3 .insight-panel:last-child {
        border-right: none;
    }

    .donut-ring {
        width: 90px;
        height: 90px;
    }

    .donut-hole {
        width: 54px;
        height: 54px;
    }

    .kpi-chart-wrap {
        height: 100px;
    }

    .cs-legend {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    }
}

/* ── Responsive — Mobile (≤ 600px) ── */
@media (max-width: 600px) {
    .insight-dash-header {
        flex-direction: column;
        align-items: flex-start;
        padding: 14px 16px;
    }

    .insight-date-range {
        width: 100%;
        flex-wrap: wrap;
        gap: 6px;
    }

    .insight-date-range input[type="date"] {
        flex: 1;
        min-width: 0;
    }

    .insight-grid--2 {
        grid-template-columns: 1fr;
    }

    .insight-grid--3 {
        grid-template-columns: 1fr;
    }

    .insight-grid--2 .insight-panel:first-child {
        border-right: none;
    }

    .insight-grid--3 .insight-panel {
        border-right: none;
    }

    .insight-grid--3 .insight-panel:nth-child(odd) {
        border-right: none;
    }

    .insight-panel {
        padding: 16px;
    }

    .insight-panel--donut .insight-body {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .donut-ring {
        width: 90px;
        height: 90px;
        align-self: center;
    }

    .donut-hole {
        width: 54px;
        height: 54px;
    }

    .donut-legend {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 6px 14px;
    }

    .kpi-value {
        font-size: 18px;
    }

    .kpi-chart-wrap {
        height: 90px;
    }

    .kpi-chart-wrap--cpm {
        height: 80px;
    }

    .kpi-legend {
        gap: 6px;
    }

    .cs-bar {
        height: 18px;
    }

    .cs-legend {
        grid-template-columns: 1fr;
        gap: 4px;
    }
}

/* ══════════════════════════════════════════════════════════
   INVENTORY TABLE WIDGET (Domains, Apps, Publishers)
   ══════════════════════════════════════════════════════════ */
.inv-table-wrapper {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.inv-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    padding: 0 10px;
    background-color: var(--bg-card);
}

.inv-tab-btn {
    padding: 12px 20px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.inv-tab-btn:hover {
    color: #fff;
}

.inv-tab-btn.active {
    color: var(--accent-yellow);
    border-bottom-color: var(--accent-yellow);
}

.inv-table-container {
    max-height: 400px;
    overflow-y: auto;
    border: none;
    border-radius: 0;
}

.inv-table {
    width: 100%;
    border-collapse: collapse;
    background-color: transparent;
    font-size: 12px;
}

.inv-table th {
    position: sticky;
    top: 0;
    background-color: var(--bg-header);
    color: var(--text-secondary);
    font-weight: 600;
    padding: 10px 15px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    z-index: 10;
}

.inv-table th.sortable {
    cursor: pointer;
}

.inv-table th.sortable:hover {
    color: #fff;
}

.inv-table th i {
    margin-left: 5px;
    opacity: 0.3;
}

.inv-table th.sorted-asc i,
.inv-table th.sorted-desc i {
    opacity: 1;
    color: var(--accent-yellow);
}

.inv-table th.sorted-asc i::before {
    content: "\f0de"; /* fa-sort-up */
}

.inv-table th.sorted-desc i::before {
    content: "\f0dd"; /* fa-sort-down */
}

.inv-table td {
    padding: 8px 15px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    vertical-align: middle;
}

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

.inv-table tr.selected td {
    background-color: rgba(242, 169, 0, 0.08);
}

.inv-table tr.selected:hover td {
    background-color: rgba(242, 169, 0, 0.12);
}

.inv-table .w-40 {
    width: 40px;
    text-align: center;
    padding: 8px;
}

.inv-table input[type="checkbox"] {
    margin: 0;
}

/* Limit column widths and ensure truncation for long domains */
.inv-table th:nth-child(2),
.inv-table td:nth-child(2) {
    max-width: 250px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.inv-table th:nth-child(3),
.inv-table td:nth-child(3) {
    white-space: nowrap;
    text-align: end;
}

.inv-footer {
    padding: 15px;
    background-color: var(--bg-card);
    border-top: 1px solid var(--border-color);
    text-align: center;
}

.load-more-btn {
    display: block;
    width: auto;
    margin: 0 auto;
    padding: 8px 30px;
}

    .inv-shimmer {
        height: 16px;
        border-radius: 2px;
        background: repeating-linear-gradient(90deg, rgba(255,255,255,0.03) 0%, rgba(255,255,255,0.06) 50%, rgba(255,255,255,0.03) 100%);
        background-size: 200% 100%;
        animation: kpi-shimmer 1.5s ease-in-out infinite;
    }

