:root {
    --bg: #07080a;
    --panel: #0d0f12;
    --panel-2: #101318;
    --panel-3: #151920;
    --line: #252932;
    --line-soft: rgba(255, 255, 255, .065);
    --text: #f2f3f5;
    --muted: #9197a3;
    --lime: #a9b6d3;
    --lime-soft: rgba(169, 182, 211, .12);
    --green: #7fb69f;
    --orange: #c9a373;
    --red: #c98590;
    --violet: #a899c8;
    --blue: #819dc8;
    --radius: 12px;
    --shadow: 0 18px 46px rgba(0, 0, 0, .22);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--bg); color-scheme: dark; }
body {
    margin: 0;
    min-width: 320px;
    background:
        radial-gradient(circle at 18% -8%, rgba(129, 157, 200, .09), transparent 28%),
        radial-gradient(circle at 88% 22%, rgba(168, 153, 200, .055), transparent 24%),
        var(--bg);
    color: var(--text);
    font: 14px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-feature-settings: "calt", "kern", "liga", "ss03";
}
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
code { color: #c7d2eb; background: #090b0e; padding: 2px 5px; border-radius: 5px; }

.ambient { position: fixed; pointer-events: none; filter: blur(110px); opacity: .09; z-index: 0; }
.ambient-one { width: 320px; height: 320px; right: 4%; top: 10%; background: #748cb7; }
.ambient-two { width: 260px; height: 260px; left: -90px; bottom: 5%; background: #776a98; }
.shell { position: relative; z-index: 1; width: min(1760px, calc(100% - 42px)); margin: 0 auto; padding: 28px 0 60px; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 7px 0 25px; }
.brand-lockup, .topbar-actions, .user-menu, .view-switch, .panel-heading, .section-heading { display: flex; align-items: center; }
.brand-lockup { gap: 16px; }
.brand-mark {
    width: 48px; height: 48px; flex: 0 0 48px; display: grid; place-items: center;
    border: 1px solid #3b4352; border-radius: 10px; background: #d9deea; color: #11141a; font-weight: 850; letter-spacing: -.06em;
    box-shadow: 0 10px 28px rgba(0, 0, 0, .2);
}
.eyebrow { margin: 0 0 5px; color: #aab6ce; font-size: 10px; font-weight: 750; letter-spacing: .15em; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 3px; font-size: clamp(23px, 2.5vw, 34px); line-height: 1.1; letter-spacing: -.04em; }
h2 { margin-bottom: 0; font-size: 17px; letter-spacing: -.02em; }
.subtitle, .muted { margin-bottom: 0; color: var(--muted); }
.topbar-actions { gap: 14px; }
.view-switch { padding: 3px; border: 1px solid var(--line); border-radius: 9px; background: #0a0c0f; }
.view-link { padding: 8px 11px; border-radius: 8px; color: var(--muted); text-decoration: none; font-size: 12px; font-weight: 700; }
.view-link.active { color: var(--text); background: #242a34; box-shadow: inset 0 0 0 1px #353c48; }
.user-menu { gap: 9px; color: var(--muted); font-size: 12px; }
.user-menu form { margin: 0; }
.quiet-button { border: 0; background: transparent; color: var(--text); cursor: pointer; padding: 7px; }

.source-banner {
    display: flex; align-items: center; gap: 9px; margin-bottom: 18px; padding: 10px 14px;
    border: 1px solid var(--line); border-radius: 9px; color: var(--muted); background: rgba(13, 15, 18, .9); font-size: 12px;
}
.source-banner strong { color: var(--text); }
.source-banner.demo { border-color: rgba(240, 179, 106, .35); background: rgba(240, 179, 106, .07); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 5px rgba(99, 214, 157, .09); }
.source-banner.demo .status-dot { background: var(--orange); box-shadow: 0 0 0 5px rgba(240, 179, 106, .09); }

.tabs { display: flex; gap: 5px; padding: 4px; margin-bottom: 18px; border: 1px solid var(--line); border-radius: 10px; background: #0a0c0f; width: fit-content; }
.tab-button { border: 0; border-radius: 7px; padding: 10px 15px; background: transparent; color: var(--muted); cursor: pointer; font-weight: 700; }
.tab-button span { margin-right: 8px; color: #5b6c67; font-size: 10px; }
.tab-button.active { background: var(--panel-3); color: var(--text); box-shadow: inset 0 0 0 1px #303641; }
.tab-button.active span { color: var(--lime); }
.tab-panel[hidden] { display: none; }

.panel, .filter-panel {
    border: 1px solid var(--line); border-radius: var(--radius); background: rgba(13, 15, 18, .94);
    box-shadow: var(--shadow);
}
.filter-panel { padding: 14px; margin-bottom: 29px; box-shadow: none; }
.filter-grid { display: grid; grid-template-columns: 130px minmax(165px, .72fr) minmax(180px, .85fr) minmax(240px, 1.2fr) minmax(155px, .7fr) auto; gap: 10px; align-items: end; }
label { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 11px; font-weight: 700; }
input, select {
    width: 100%; min-height: 40px; border: 1px solid #2b3039; border-radius: 8px; outline: 0;
    background: #0a0c0f; color: var(--text); padding: 9px 11px;
}
input:focus, select:focus { border-color: #657696; box-shadow: 0 0 0 3px rgba(129, 157, 200, .12); }
.reset-button, .primary-button {
    min-height: 40px; border: 1px solid #cbd2e0; border-radius: 8px; padding: 9px 15px; cursor: pointer; background: #d9deea; color: #11141a; font-weight: 800;
}
.filter-note { margin: 10px 2px 0; color: #6f807b; font-size: 11px; }
.section-heading { justify-content: space-between; margin-bottom: 13px; }
.live-pill { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 11px; }
.live-pill i { width: 6px; height: 6px; border-radius: 50%; background: var(--lime); }

.kpi-grid { display: grid; grid-template-columns: repeat(8, minmax(130px, 1fr)); gap: 10px; margin-bottom: 18px; }
.kpi-card { min-height: 120px; padding: 15px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); position: relative; overflow: hidden; }
.kpi-card::after { content: ""; position: absolute; left: 15px; right: 15px; bottom: 0; height: 1px; background: var(--accent, var(--lime)); opacity: .75; }
.kpi-label { min-height: 33px; color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .08em; }
.kpi-value { margin: 5px 0 3px; font-size: clamp(20px, 1.7vw, 28px); font-weight: 830; letter-spacing: -.04em; }
.kpi-detail { color: #71817c; font-size: 10px; }

.insight-grid { display: grid; grid-template-columns: 1.7fr .8fr; gap: 14px; margin-bottom: 14px; }
.insight-grid > *, .creative-layout > *, .technical-grid > * { min-width: 0; }
.panel { padding: 18px; }
.panel-heading { justify-content: space-between; gap: 20px; margin-bottom: 17px; }
.panel-heading > p, .metric-basis { margin: 0; color: var(--muted); font-size: 10px; }
.trend { width: 100%; min-height: 225px; display: flex; align-items: stretch; gap: 10px; overflow-x: auto; padding-bottom: 4px; }
.trend-empty, .empty-state { width: 100%; min-height: 180px; display: grid; place-items: center; color: var(--muted); text-align: center; }
.trend-item { flex: 1; min-width: 150px; display: flex; flex-direction: column; justify-content: end; gap: 8px; padding: 13px; border: 1px solid var(--line-soft); border-radius: 9px; background: #0a0c0f; }
.trend-bars { height: 135px; display: flex; gap: 6px; align-items: end; }
.trend-bar { flex: 1; min-height: 3px; border-radius: 5px 5px 2px 2px; background: var(--lime); }
.trend-bar.leads { background: var(--orange); }
.trend-bar.meetings { background: var(--blue); }
.trend-values { display: flex; justify-content: space-between; color: var(--muted); font-size: 9px; }
.trend-date { font-size: 11px; font-weight: 750; }
.quality-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 15px; }
.quality-list li { display: grid; grid-template-columns: 28px 1fr; gap: 10px; }
.quality-list p { margin: 2px 0 0; color: var(--muted); font-size: 11px; }
.quality-icon { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 9px; font-weight: 900; }
.quality-icon.good { color: var(--green); background: rgba(99, 214, 157, .1); }
.quality-icon.warn { color: var(--orange); background: rgba(240, 179, 106, .1); }
.quality-icon.neutral { color: var(--violet); background: rgba(170, 148, 255, .1); }

.funnel-panel, .table-panel { margin-bottom: 14px; }
.funnel { display: grid; grid-template-columns: repeat(9, minmax(120px, 1fr)); gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.funnel-stage { min-height: 160px; padding: 13px; position: relative; border: 1px solid var(--line); border-radius: 9px; background: #0a0c0f; overflow: hidden; }
.funnel-stage::before { content: ""; position: absolute; left: 0; bottom: 0; width: 100%; height: var(--fill); background: linear-gradient(0deg, rgba(129, 157, 200, .13), transparent); }
.funnel-stage > * { position: relative; }
.funnel-index { color: #596964; font-size: 9px; }
.funnel-label { min-height: 43px; margin: 8px 0; color: var(--muted); font-size: 10px; }
.funnel-value { font-size: 22px; font-weight: 850; letter-spacing: -.04em; }
.funnel-meta { margin-top: 8px; color: #75857f; font-size: 9px; }
.funnel-meta strong { color: var(--text); }

.table-scroll { max-height: 620px; overflow: auto; border: 1px solid var(--line); border-radius: 12px; }
table { width: 100%; min-width: 1350px; border-collapse: collapse; font-size: 11px; }
th { position: sticky; top: 0; z-index: 2; padding: 12px 10px; background: #171b21; color: #a2a7b1; text-align: right; white-space: nowrap; }
td { padding: 11px 10px; border-top: 1px solid var(--line-soft); text-align: right; white-space: nowrap; }
th:first-child, td:first-child { position: sticky; left: 0; z-index: 1; min-width: 260px; max-width: 320px; text-align: left; background: #101318; }
th:first-child { z-index: 3; background: #171b21; }
tbody tr { cursor: pointer; }
tbody tr:hover td { background: #171b21; }
tbody tr:hover td:first-child { background: #1a1f26; }
.banner-title { font-weight: 750; overflow: hidden; text-overflow: ellipsis; }
.banner-meta { color: var(--muted); font-size: 9px; overflow: hidden; text-overflow: ellipsis; }
.status-chip { display: inline-flex; align-items: center; padding: 4px 7px; border-radius: 7px; font-size: 9px; font-weight: 800; background: rgba(142, 157, 152, .11); }
.status-chip.winner, .status-chip.good { color: var(--green); background: rgba(99, 214, 157, .1); }
.status-chip.stop_candidate, .status-chip.weak { color: var(--orange); background: rgba(201, 163, 115, .1); }
.status-chip.insufficient_data, .status-chip.mixed, .status-chip.average { color: var(--violet); background: rgba(168, 153, 200, .1); }
.immature { margin-left: 4px; color: var(--orange); }
.table-footnote { margin: 12px 0 0; color: var(--muted); font-size: 10px; }

.technical-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 14px; }
.technical-card p:last-child, .technical-card dd { color: var(--muted); font-size: 12px; }
.technical-card dl { display: grid; grid-template-columns: 90px 1fr; gap: 8px; margin-bottom: 0; }
.technical-card dt { color: var(--lime); font-weight: 800; }
.technical-card dd { margin: 0; }

.creative-toolbar { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 14px; }
.combobox-field { width: min(680px, 100%); position: relative; }
.combobox-field > label { display: block; margin-bottom: 6px; }
.banner-combobox { position: relative; }
.banner-combobox input { padding-right: 38px; }
.banner-combobox::after {
    content: "⌕"; position: absolute; z-index: 2; top: 8px; right: 12px;
    color: var(--muted); font-size: 18px; pointer-events: none;
}
.banner-suggestions {
    position: absolute; z-index: 12; top: calc(100% + 6px); left: 0; right: 0; max-height: 340px; overflow-y: auto;
    padding: 6px; border: 1px solid #303641; border-radius: 10px; background: #101318;
    box-shadow: 0 22px 48px rgba(0, 0, 0, .42);
}
.banner-suggestion {
    width: 100%; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 14px;
    padding: 10px; border: 0; border-radius: 7px; color: var(--text); background: transparent; text-align: left; cursor: pointer;
}
.banner-suggestion:hover, .banner-suggestion.active { background: #202630; }
.banner-suggestion span { min-width: 0; }
.banner-suggestion strong { display: block; overflow: hidden; color: #e4e7ed; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.banner-suggestion small { display: block; margin-top: 2px; color: var(--muted); font-size: 9px; }
.banner-suggestion em { max-width: 210px; overflow: hidden; color: #9ca8be; text-overflow: ellipsis; white-space: nowrap; font-size: 10px; font-style: normal; }
.banner-suggestion-empty { padding: 16px 12px; color: var(--muted); text-align: center; font-size: 11px; }
.combobox-hint { margin: 6px 2px 0; color: var(--muted); font-size: 10px; font-weight: 500; }
.analysis-state { color: var(--orange); font-size: 10px; }
.analysis-state span { display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: var(--orange); }
.creative-layout { display: grid; grid-template-columns: minmax(300px, .8fr) minmax(0, 1.45fr); gap: 14px; margin-bottom: 14px; }
.creative-image-wrap { min-height: 520px; display: grid; place-items: center; overflow: hidden; border: 1px solid var(--line-soft); border-radius: 10px; background: #08090b; }
.creative-image-wrap img { display: block; width: 100%; max-height: 620px; object-fit: contain; }
.image-fallback { padding: 30px; color: var(--muted); text-align: center; }
.demo-warning { margin-top: 13px; padding: 11px; border: 1px solid rgba(240, 179, 106, .24); border-radius: 11px; background: rgba(240, 179, 106, .06); }
.demo-warning strong { color: var(--orange); font-size: 11px; }
.demo-warning p { margin: 3px 0 0; color: var(--muted); font-size: 10px; }
.demo-warning.verified { border-color: rgba(127, 182, 159, .25); background: rgba(127, 182, 159, .065); }
.demo-warning.verified strong { color: var(--green); }
.source-link { display: inline-block; margin-top: 11px; color: var(--lime); font-size: 11px; text-decoration: none; }
.selection-placeholder { min-height: 300px; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; color: var(--muted); }
.selection-placeholder h2 { color: var(--text); margin: 12px 0 5px; }
.placeholder-index { color: var(--lime); font-size: 42px; font-weight: 900; opacity: .25; }
.report-hero { display: flex; justify-content: space-between; gap: 15px; align-items: center; margin-bottom: 10px; }
.decision { padding: 9px 12px; border: 1px solid #3b4352; border-radius: 8px; color: #dce2ee; background: #202630; font-size: 11px; font-weight: 800; text-transform: uppercase; white-space: nowrap; }
.detail-metrics { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin-bottom: 10px; }
.detail-metric { padding: 12px; border: 1px solid var(--line); border-radius: 9px; background: #0d0f12; }
.detail-metric span { color: var(--muted); font-size: 9px; }
.detail-metric strong { display: block; margin-top: 5px; font-size: 18px; }
.report-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.report-card { box-shadow: none; }
.report-card.wide { grid-column: 1 / -1; }
.report-card ul, .report-card ol { margin: 10px 0 0; padding-left: 19px; }
.report-card li { margin: 8px 0; color: #cbd4d1; font-size: 12px; }
.limitations { border-color: rgba(240, 179, 106, .25); }
.limitations p { color: var(--muted); }
.visual-facts, .technical-method { margin-bottom: 14px; }
.observation-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.observation-grid p { margin: 0; padding: 13px; border: 1px solid var(--line); border-radius: 9px; color: #c9ccd3; background: #0a0c0f; }
.method-columns { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.method-columns > div { padding: 13px; border-left: 2px solid #6f7f9d; background: #0a0c0f; }
.method-columns p { margin: 5px 0 0; color: var(--muted); font-size: 11px; }

.toast { position: fixed; z-index: 20; right: 22px; bottom: 22px; max-width: 440px; padding: 13px 16px; border: 1px solid rgba(237, 125, 138, .4); border-radius: 11px; background: #2a1619; color: #ffd8dc; box-shadow: var(--shadow); }
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: min(420px, 100%); padding: 32px; border: 1px solid var(--line); border-radius: 22px; background: var(--panel); box-shadow: var(--shadow); }
.login-card .brand-mark { margin-bottom: 25px; }
.login-card h1 { margin-bottom: 8px; }
.login-card form { display: grid; gap: 15px; margin-top: 25px; }
.form-error { margin-top: 16px; padding: 10px; border-radius: 9px; color: #ffd7dc; background: rgba(237, 125, 138, .12); }

@media (max-width: 1380px) {
    .filter-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .search-field { grid-column: span 2; }
    .kpi-grid { grid-template-columns: repeat(4, 1fr); }
    .funnel { grid-template-columns: repeat(9, 130px); }
    .detail-metrics { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 1040px) {
    .filter-grid { grid-template-columns: repeat(2, 1fr); }
    .search-field { grid-column: span 2; }
    .reset-button { width: 100%; }
    .insight-grid, .creative-layout { grid-template-columns: 1fr; }
    .technical-grid { grid-template-columns: 1fr; }
    .creative-image-wrap { min-height: 360px; }
}
@media (max-width: 720px) {
    .shell { width: min(100% - 22px, 1760px); padding-top: 14px; }
    .topbar, .topbar-actions, .creative-toolbar { align-items: stretch; flex-direction: column; }
    .topbar-actions { gap: 8px; }
    .view-switch { align-self: flex-start; }
    .source-banner { align-items: flex-start; flex-wrap: wrap; }
    .tabs { width: 100%; }
    .tab-button { flex: 1; padding: 10px 8px; font-size: 11px; }
    .filter-grid { grid-template-columns: 1fr; }
    .search-field { grid-column: auto; }
    .banner-suggestion { grid-template-columns: 1fr; gap: 2px; }
    .banner-suggestion em { max-width: none; }
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .panel-heading, .section-heading, .report-hero { align-items: flex-start; flex-direction: column; }
    .observation-grid, .method-columns, .report-grid { grid-template-columns: 1fr; }
    .report-card.wide { grid-column: auto; }
    .detail-metrics { grid-template-columns: repeat(2, 1fr); }
}
