:root {
    color-scheme: light;
    --bg-deep: #f6f7fb;
    --bg-mid: #eef2f7;
    --bg-soft: #e7edf6;
    --cobalt: #2563eb;
    --cobalt-soft: #6ea8ff;
    --mint: #12b981;
    --amber: #f59e0b;
    --rose: #ef4444;
    --text: #101828;
    --text-soft: #475467;
    --text-muted: #667085;
    --glass: rgba(255, 255, 255, 0.78);
    --glass-strong: rgba(255, 255, 255, 0.94);
    --glass-light: rgba(248, 250, 252, 0.9);
    --line: rgba(16, 24, 40, 0.11);
    --line-soft: rgba(16, 24, 40, 0.07);
    --shadow: 0 18px 50px rgba(16, 24, 40, 0.08);
    --app-bg: linear-gradient(140deg, #fbfcff 0%, #f5f8fc 48%, #eef3f9 100%);
    --side-link-bg: transparent;
    --side-link-text: #475467;
    --side-link-active-bg: rgba(37, 99, 235, 0.1);
    --side-link-active-border: rgba(37, 99, 235, 0.24);
    --side-link-active-text: #1d4ed8;
    --primary-btn-bg: linear-gradient(135deg, #2563eb, #1d4ed8);
    --primary-btn-shadow: 0 12px 24px rgba(37, 99, 235, 0.22);
    --ghost-btn-border: rgba(16, 24, 40, 0.12);
    --ghost-btn-bg: rgba(255, 255, 255, 0.7);
    --ghost-btn-color: #344054;
    --control-header-bg: rgba(255, 255, 255, 0.82);
    --control-header-border: rgba(16, 24, 40, 0.08);
    --field-bg: rgba(255, 255, 255, 0.95);
    --field-text: #101828;
    --card-muted-bg: rgba(248, 250, 252, 0.94);
    --empty-bg: rgba(248, 250, 252, 0.9);
    --radius-xl: 8px;
    --radius-lg: 8px;
    --radius-md: 8px;
    --radius-sm: 8px;
}

html {
    background: #f6f7fb;
}

body {
    background: var(--app-bg);
    letter-spacing: 0;
}

button,
input,
select,
textarea {
    letter-spacing: 0;
}

.app-shell {
    width: min(100%, 1680px);
    margin: 0 auto;
    padding: 16px;
}

.app-header.app-header-inline {
    position: sticky;
    top: 0;
    z-index: 80;
    display: grid;
    grid-template-columns: minmax(160px, 210px) minmax(430px, 1fr) auto;
    gap: 12px;
    align-items: center;
    min-height: 78px;
    margin: -16px -16px 18px;
    padding: 12px 16px;
    border: 0;
    border-bottom: 1px solid rgba(16, 24, 40, 0.08);
    border-radius: 0;
    background: rgba(248, 250, 252, 0.76);
    box-shadow: 0 10px 30px rgba(16, 24, 40, 0.05);
    backdrop-filter: blur(24px);
}

.app-brand-inline {
    display: grid;
    gap: 2px;
    min-width: 0;
    padding-left: 6px;
}

.app-title-inline {
    margin: 0;
    font-size: clamp(1.32rem, 1.8vw, 1.8rem);
    font-weight: 850;
    line-height: 1;
    letter-spacing: 0;
    color: var(--text);
}

.app-brand-inline span {
    color: var(--text-muted);
    font-size: 0.73rem;
    font-weight: 750;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    white-space: nowrap;
}

.control-card,
.panel-card,
.status-banner,
.loading-card,
.filter-badge {
    border: 1px solid var(--line-soft);
    border-radius: 8px;
    background: var(--glass-strong);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
}

.control-card--header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    min-width: 0;
    margin: 0;
    padding: 8px;
    overflow: visible;
    border-color: rgba(16, 24, 40, 0.08);
    background: rgba(255, 255, 255, 0.84);
    box-shadow:
        0 18px 42px rgba(16, 24, 40, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.control-grid-inline {
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
    min-width: 0;
    overflow: visible;
}

.control-meta-row {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    min-width: 0;
    margin: 0;
    padding: 0;
}

.control-card--header .range-summary {
    display: none;
}

.section-indicator {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    max-width: 190px;
    padding: 0 10px;
    border: 1px solid rgba(37, 99, 235, 0.14);
    border-radius: 8px;
    background: rgba(239, 246, 255, 0.82);
    color: #1d4ed8;
    font-size: 0.68rem;
    font-weight: 850;
    line-height: 1.05;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.section-indicator::before {
    content: "";
    width: 6px;
    height: 6px;
    flex: 0 0 auto;
    margin-right: 6px;
    border-radius: 999px;
    background: #12b981;
    box-shadow: 0 0 0 4px rgba(18, 185, 129, 0.12);
}

.header-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    min-width: 0;
}

.primary-btn,
.ghost-btn,
.side-toggle,
.lead-report-range-trigger,
.field select,
.field input {
    min-height: 38px;
    border-radius: 8px;
}

.field select,
.field input,
.prompt-box,
.json-box {
    background: var(--field-bg);
    border-color: var(--line-soft);
    color: var(--field-text);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.68);
}

.ghost-btn {
    background: var(--ghost-btn-bg);
    color: var(--ghost-btn-color);
    box-shadow: 0 8px 18px rgba(16, 24, 40, 0.05);
}

.ghost-btn:hover {
    transform: translateY(-1px);
    background: rgba(255, 255, 255, 0.92);
}

.primary-btn {
    color: #fff;
    box-shadow: var(--primary-btn-shadow);
}

.header-actions .primary-btn,
.header-actions .ghost-btn {
    width: auto;
    min-height: 42px;
    padding: 0 14px;
    white-space: nowrap;
}

.header-actions .primary-btn {
    padding-inline: 16px;
    font-weight: 850;
}

#theme-toggle-btn,
#sidebar-toggle-btn {
    min-width: 0;
}

.control-card--header .field-compact {
    flex: 1 1 132px;
    min-width: 92px;
    max-width: 168px;
}

.control-card--header .field-compact select,
.control-card--header .field-compact input {
    height: 40px;
    min-height: 40px;
    border: 1px solid rgba(16, 24, 40, 0.09);
    border-radius: 8px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 250, 252, 0.94));
    color: var(--text);
    font-size: 0.86rem;
    font-weight: 700;
    padding: 0 34px 0 12px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

#brand-select {
    width: 100%;
}

#project-field select {
    width: 100%;
}

.lead-report-range-field.field-compact {
    flex: 999 1 226px;
    width: auto;
    min-width: 188px;
    max-width: 340px;
    border: 1px solid rgba(37, 99, 235, 0.14);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 250, 252, 0.94));
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.82);
}

.lead-report-range-trigger {
    height: 40px;
    min-height: 40px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    box-shadow: none;
}

.lead-report-range-trigger::before {
    width: 50px;
    flex: 0 0 50px;
    border-radius: 8px 0 0 8px;
}

.lead-report-range-trigger strong {
    padding-left: 10px;
    font-size: 0.78rem;
    font-weight: 850;
    color: var(--text);
}

.lead-report-range-trigger::after {
    right: 12px;
}

.primary-btn:hover {
    transform: translateY(-1px);
}

.workspace-layout {
    display: grid;
    grid-template-columns: 248px minmax(0, 1fr);
    gap: 16px;
    align-items: start;
}

.workspace-content {
    min-width: 0;
}

.sidebar-nav {
    top: 92px;
    height: calc(100vh - 108px);
    padding: 14px;
    border: 1px solid var(--line-soft);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.66);
    box-shadow: 0 16px 44px rgba(16, 24, 40, 0.07);
    backdrop-filter: blur(22px);
}

.sidebar-head {
    padding: 8px 8px 12px;
    border-bottom: 1px solid var(--line-soft);
}

.sidebar-head h3 {
    font-size: 1rem;
}

.sidebar-section {
    gap: 6px;
}

.sidebar-section-title,
.kicker {
    color: var(--text-muted);
    letter-spacing: 0.08em;
}

.side-link {
    position: relative;
    min-height: 40px;
    justify-content: flex-start;
    border: 1px solid transparent;
    border-radius: 8px;
    color: var(--side-link-text);
    background: transparent;
    font-weight: 700;
}

.side-link::before {
    content: "";
    width: 3px;
    align-self: stretch;
    border-radius: 999px;
    background: transparent;
}

.side-link:hover {
    background: rgba(16, 24, 40, 0.04);
    color: var(--text);
}

.side-link.active {
    border-color: var(--side-link-active-border);
    background: var(--side-link-active-bg);
    color: var(--side-link-active-text);
    box-shadow: none;
}

.side-link.active::before {
    background: #2563eb;
}

.side-toggle {
    border: 1px solid var(--line-soft);
    background: rgba(255, 255, 255, 0.72);
    color: var(--text-soft);
}

.sidebar-section--utility {
    gap: 7px;
    margin-top: 2px;
    padding: 10px;
    border: 1px solid rgba(16, 24, 40, 0.06);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.46);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

.sidebar-section + .sidebar-section--utility {
    padding-top: 10px;
    border-top: 1px solid rgba(16, 24, 40, 0.06);
}

.sidebar-section--utility .sidebar-section-title {
    padding-inline: 2px;
    color: var(--text-muted);
    font-size: 0.64rem;
    line-height: 1;
}

.sidebar-section--utility .side-link,
.sidebar-section--utility .side-toggle {
    min-height: 36px;
    border-color: rgba(16, 24, 40, 0.08);
    background: rgba(255, 255, 255, 0.7);
    color: #344054;
    box-shadow: none;
}

.sidebar-section--utility .side-link:hover,
.sidebar-section--utility .side-toggle:hover {
    border-color: rgba(37, 99, 235, 0.18);
    background: rgba(239, 246, 255, 0.78);
    color: #1d4ed8;
}

.sidebar-section--utility .infra-group {
    gap: 6px;
    padding-top: 2px;
}

.sidebar-section--utility .infra-link {
    min-height: 34px;
    padding-left: 14px;
    font-size: 0.82rem;
}

.sidebar-section--utility .side-link.active {
    border-color: var(--side-link-active-border);
    background: var(--side-link-active-bg);
    color: var(--side-link-active-text);
}

.tab-content {
    animation: v3Fade 0.18s ease-out;
}

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

.panel-grid,
.report-grid-two,
.panel-grid-2 {
    gap: 16px;
}

.panel-card {
    padding: 18px;
}

.panel-card-compact {
    padding: 12px;
}

.panel-head {
    gap: 12px;
    padding-bottom: 12px;
}

.panel-head h3 {
    color: var(--text);
    font-weight: 800;
    letter-spacing: 0;
}

.kpi-grid {
    gap: 12px;
}

.kpi-card,
.summary-card,
.metric-card,
.entity-card,
.phase-card,
.creative-library-card,
.decision-card,
.alert-card {
    border-radius: 8px;
    border-color: var(--line-soft);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(248, 250, 252, 0.92));
    box-shadow: 0 10px 28px rgba(16, 24, 40, 0.06);
}

.kpi-card strong,
.summary-card strong,
.metric-card strong {
    color: var(--text);
    letter-spacing: 0;
}

.phase-selector {
    border-color: rgba(37, 99, 235, 0.14);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.78);
}

.phase-pill.active,
.phase-filter-btn.active {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: #fff;
    border-color: rgba(37, 99, 235, 0.32);
    box-shadow: 0 10px 22px rgba(37, 99, 235, 0.16);
}

.table-container {
    border-radius: 8px;
    border: 1px solid var(--line-soft);
    background: rgba(255, 255, 255, 0.86);
    overflow: auto;
}

table {
    border-collapse: collapse;
}

th {
    background: rgba(248, 250, 252, 0.96);
    color: var(--text-muted);
    letter-spacing: 0.06em;
}

td,
th {
    border-color: var(--line-soft);
}

.chart-box,
.gauge-wrap,
.funnel-grid,
.card-list,
.summary-grid {
    border-radius: 8px;
}

.lead-report-range-field {
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.96);
    border-color: var(--line-soft);
}

.lead-report-range-trigger::before {
    background: rgba(239, 246, 255, 0.92);
}

.lead-report-range-popover {
    border-radius: 8px;
    border-color: var(--line);
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 28px 70px rgba(16, 24, 40, 0.18);
}

.lead-report-range-presets button,
.lead-report-range-popover__head button,
.lead-report-range-popover__foot button,
.lead-report-range-day {
    border-radius: 8px;
}

.lead-report-range-day.is-inside {
    background: rgba(37, 99, 235, 0.1);
    color: #1d4ed8;
}

.lead-report-range-day.is-edge {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: #fff;
}

:root:not([data-theme]) .lead-report-range-field.field-compact,
:root[data-theme="light"] .lead-report-range-field.field-compact {
    border-color: rgba(37, 99, 235, 0.12);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 250, 252, 0.96));
}

:root:not([data-theme]) .lead-report-range-trigger::before,
:root[data-theme="light"] .lead-report-range-trigger::before {
    border-right-color: rgba(37, 99, 235, 0.12);
    background: rgba(239, 246, 255, 0.94);
    color: #1d4ed8;
}

:root:not([data-theme]) .lead-report-range-trigger,
:root[data-theme="light"] .lead-report-range-trigger {
    color: #475467;
}

:root:not([data-theme]) .lead-report-range-trigger strong,
:root[data-theme="light"] .lead-report-range-trigger strong {
    color: #101828;
}

:root:not([data-theme]) .lead-report-range-field.is-open .lead-report-range-trigger,
:root[data-theme="light"] .lead-report-range-field.is-open .lead-report-range-trigger {
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.report-header-card {
    background:
        linear-gradient(135deg, rgba(37, 99, 235, 0.12), rgba(18, 185, 129, 0.08)),
        rgba(255, 255, 255, 0.94);
}

.report-main-title {
    color: var(--text);
}

.report-main-subtitle {
    color: var(--text-soft);
}

.capture-canvas-btn {
    border-radius: 8px;
    background: rgba(16, 24, 40, 0.82);
    color: #fff;
    box-shadow: 0 12px 26px rgba(16, 24, 40, 0.2);
}

.status-banner.info,
.status-banner.is-info {
    border-color: rgba(37, 99, 235, 0.24);
    background: rgba(239, 246, 255, 0.92);
    color: #1d4ed8;
}

.status-banner.success,
.status-banner.is-success {
    border-color: rgba(18, 185, 129, 0.24);
    background: rgba(236, 253, 245, 0.92);
    color: #047857;
}

.status-banner.error,
.status-banner.is-error {
    border-color: rgba(239, 68, 68, 0.24);
    background: rgba(254, 242, 242, 0.92);
    color: #991b1b;
}

.loading-overlay,
.filter-overlay {
    backdrop-filter: blur(18px);
}

.loading-card {
    background: rgba(255, 255, 255, 0.96);
}

.spinner {
    border-top-color: #2563eb;
}

body.capture-canvas-mode .app-shell,
body.canvas-capture-mode .app-shell {
    background: #f7f9fc;
}

@media (max-width: 1200px) {
    .app-header.app-header-inline {
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 8px;
        align-items: start;
        min-height: 0;
    }

    .app-brand-inline {
        align-self: center;
        min-height: 38px;
        padding-left: 2px;
    }

    .app-brand-inline span {
        display: none;
    }

    .app-title-inline {
        font-size: 1.12rem;
    }

    .control-card--header {
        grid-column: 1 / -1;
        grid-template-columns: minmax(0, 1fr) minmax(120px, auto);
        gap: 6px;
        padding: 6px;
    }

    .control-card--header .field-compact {
        flex-basis: 116px;
        min-width: 86px;
    }

    .lead-report-range-field.field-compact {
        min-width: 176px;
        max-width: none;
    }

    .lead-report-range-trigger::before {
        flex-basis: 44px;
        width: 44px;
        padding-inline: 7px;
        font-size: 0.62rem;
    }

    .lead-report-range-trigger strong {
        padding-left: 8px;
    }

    .section-indicator {
        max-width: 160px;
        min-height: 38px;
        padding-inline: 8px;
        font-size: 0.62rem;
    }

    .header-actions {
        align-self: center;
        gap: 6px;
    }

    .header-actions .primary-btn,
    .header-actions .ghost-btn {
        min-height: 38px;
        padding-inline: 10px;
        font-size: 0.82rem;
    }
}

@media (max-width: 980px) {
    .app-header.app-header-inline {
        grid-template-columns: 1fr;
    }

    .workspace-layout {
        grid-template-columns: 1fr;
    }

    .sidebar-nav {
        position: static;
        height: auto;
    }
}

@media (max-width: 720px) {
    .app-shell {
        padding: 10px;
    }

    .app-header.app-header-inline {
        margin: -10px -10px 12px;
        padding: 12px 10px;
    }

    .control-grid-inline,
    .header-actions {
        flex-wrap: wrap;
        width: 100%;
    }

    .control-card--header,
    .header-actions > * {
        width: 100%;
    }

    .header-actions .primary-btn,
    .header-actions .ghost-btn {
        width: 100%;
    }

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

    .control-card--header .field-compact {
        max-width: none;
    }

    #brand-select,
    #project-field select,
    .lead-report-range-field.field-compact {
        width: 100%;
        min-width: 0;
    }
}
