:root {
    --bg: #f6f8fb;
    --panel: #ffffff;
    --panel-soft: #f9fbfd;
    --ink: #202938;
    --muted: #76839a;
    --line: #e1e7ef;
    --brand: #2a9d8f;
    --brand-strong: #21867b;
    --brand-soft: #e6f5f3;
    --blue: #457b9d;
    --danger: #b42318;
    --warn: #b54708;
    --shadow: 0 10px 28px rgba(31, 41, 55, .06);
    --ok-bg: #dcf7e8;
    --warn-bg: #fff1cf;
    --muted-bg: #e9eef4;
    color-scheme: light;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

[data-theme="dark"] {
    --bg: #111827;
    --panel: #182231;
    --panel-soft: #121c29;
    --ink: #eef3f8;
    --muted: #9aa8bb;
    --line: #2a3748;
    --brand: #4db6ac;
    --brand-strong: #68ccc1;
    --brand-soft: #123f3b;
    --blue: #6fa8dc;
    --danger: #ff938c;
    --warn: #f8bc64;
    --shadow: 0 18px 55px rgba(0, 0, 0, .28);
    --ok-bg: #123d2a;
    --warn-bg: #3d2d11;
    --muted-bg: #24313e;
    color-scheme: dark;
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--bg); font-size: 14px; line-height: 1.35; }
body.drawer-open { overflow: hidden; }
a { color: inherit; }
button, input, select { font: inherit; }
.app-shell { display: grid; grid-template-columns: 260px minmax(0, 1fr); min-height: 100vh; transition: grid-template-columns .22s ease; }
.app-shell.sidebar-collapsed { grid-template-columns: 84px minmax(0, 1fr); }
.sidebar {
    background: #14212b;
    color: #f8fafc;
    padding: 22px 18px;
    display: flex;
    flex-direction: column;
    gap: 28px;
    border-right: 1px solid rgba(255,255,255,.08);
}
[data-theme="dark"] .sidebar { background: #0b1118; }
.sidebar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
.brand { display: flex; align-items: center; gap: 11px; font-size: 16px; }
.brand span, .brand-mark {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: var(--brand);
    color: white;
    font-weight: 850;
}
.brand span svg,
.brand-mark svg {
    width: 22px;
    height: 22px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2.15;
    stroke-linecap: round;
    stroke-linejoin: round;
}
nav { display: grid; gap: 7px; }
nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    text-decoration: none;
    color: #c7d1dc;
    font-weight: 700;
}
nav a.active, nav a:hover { background: rgba(255,255,255,.1); color: white; }
.nav-icon {
    width: 22px;
    height: 22px;
    flex: 0 0 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    background: rgba(255,255,255,.08);
    color: #f8fafc;
    font-size: 11px;
    font-weight: 900;
}
.nav-icon svg {
    width: 14px;
    height: 14px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2.05;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.nav-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.sidebar-toggle {
    flex: 0 0 auto;
    color: #d6e0ea;
    background: rgba(255,255,255,.05);
    border-color: rgba(255,255,255,.12);
}
.sidebar-toggle:hover { background: rgba(255,255,255,.1); }
.sidebar-toggle svg { transition: transform .22s ease; }
.app-shell.sidebar-collapsed .sidebar-toggle svg { transform: rotate(180deg); }
.app-shell.sidebar-collapsed .sidebar {
    padding-inline: 12px;
}
.app-shell.sidebar-collapsed .brand {
    justify-content: center;
}
.app-shell.sidebar-collapsed .brand strong,
.app-shell.sidebar-collapsed .nav-label,
.app-shell.sidebar-collapsed .import-box {
    display: none;
}
.app-shell.sidebar-collapsed nav a {
    justify-content: center;
    padding-inline: 0;
}
.app-shell.sidebar-collapsed .sidebar-head {
    display: grid;
    justify-items: center;
}
.import-box {
    margin-top: auto;
    display: grid;
    gap: 10px;
    padding: 14px;
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 8px;
    background: rgba(255,255,255,.04);
}
.content { padding: 26px 28px; overflow-x: hidden; min-width: 0; }
.topbar {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    align-items: center;
    margin-bottom: 22px;
}
.eyebrow { margin: 0 0 5px; color: var(--brand); font-weight: 850; text-transform: uppercase; font-size: 12px; letter-spacing: 0; }
h1, h2, h3 { margin: 0; letter-spacing: 0; }
h1 { font-size: 26px; line-height: 1.12; }
h2 { font-size: 16px; }
.user-menu { display: flex; gap: 12px; align-items: center; color: var(--muted); flex-wrap: wrap; justify-content: flex-end; }
.user-menu a, .ghost { color: var(--blue); text-decoration: none; font-weight: 800; }
.source-logo-strip {
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    flex-wrap: nowrap;
    gap: 5px;
    max-width: min(100%, 640px);
    overflow-x: auto;
    scrollbar-width: none;
    padding: 4px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: var(--panel);
}
.source-logo-strip::-webkit-scrollbar { display: none; }
.source-logo {
    width: 46px;
    height: 28px;
    flex: 0 0 46px;
    display: grid;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 7px;
    overflow: hidden;
    background: #fff;
}
.source-logo img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 2px 3px;
    background: #fff;
}
.source-logo.source-asv img { padding: 3px 4px; }
.account-name { color: var(--ink); font-weight: 800; }
.role-badge {
    border: 1px solid var(--line);
    background: var(--panel);
    color: var(--muted);
    padding: 5px 8px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 850;
    text-transform: uppercase;
}
.segmented {
    display: inline-grid;
    grid-template-columns: repeat(3, 1fr);
    padding: 3px;
    gap: 3px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
}
.segmented a {
    min-width: 36px;
    text-align: center;
    padding: 6px 9px;
    border-radius: 6px;
    color: var(--muted);
}
.segmented a.active { background: var(--brand-soft); color: var(--brand-strong); }
.icon-toggle {
    width: 42px;
    height: 42px;
    padding: 0;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: var(--panel);
    color: var(--ink);
    display: inline-grid;
    place-items: center;
}
.icon-toggle .moon { display: none; }
[data-theme="dark"] .icon-toggle .sun { display: none; }
[data-theme="dark"] .icon-toggle .moon { display: inline; }
.filters {
    display: grid;
    grid-template-columns: repeat(6, minmax(140px, 1fr));
    gap: 10px;
    margin-bottom: 18px;
    align-items: center;
}
.custom-period {
    display: none;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}
.custom-period.is-visible { display: grid; }
.period-note {
    grid-column: span 2;
    color: var(--muted);
    font-size: 12px;
    font-weight: 750;
    align-self: center;
}
.export-links {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    white-space: nowrap;
}
.export-links .ghost { display: inline-flex; align-items: center; }
input, select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 7px;
    padding: 9px 11px;
    background: var(--panel);
    color: var(--ink);
    min-height: 38px;
    outline: none;
}
input:focus, select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); }
button, .primary {
    border: 0;
    border-radius: 7px;
    padding: 9px 13px;
    background: var(--muted-bg);
    color: var(--ink);
    cursor: pointer;
    font-weight: 800;
    text-decoration: none;
    text-align: center;
    min-height: 38px;
}
.primary { background: var(--brand); color: white; }
.primary:hover { background: var(--brand-strong); }
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 16px 0; }
.kpi-grid article, .panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}
.kpi-grid article { padding: 14px 16px; position: relative; overflow: visible; }
.kpi-grid article::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 4px;
    background: var(--brand);
}
.kpi-grid span { display: block; color: var(--muted); margin-bottom: 6px; font-weight: 750; }
.kpi-grid strong { font-size: 23px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.source-counter-strip {
    display: block;
    margin: -4px 0 16px;
    padding: 12px 14px;
    border: 1px solid color-mix(in srgb, var(--brand) 28%, var(--line));
    border-radius: 8px;
    background: color-mix(in srgb, var(--brand) 8%, var(--panel));
}
.source-counter-strip dl {
    display: grid;
    grid-template-columns: repeat(3, minmax(120px, 1fr));
    gap: 10px;
    margin: 0;
}
.source-counter-strip dl div {
    border: 1px solid var(--line);
    border-radius: 7px;
    padding: 10px 12px;
    background: var(--panel);
}
.source-counter-strip dt {
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
}
.source-counter-strip dd {
    margin: 2px 0 0;
    font-weight: 900;
    font-variant-numeric: tabular-nums;
}
.source-counter-strip dd small {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    line-height: 1.25;
}
.compatibility-panel { padding-top: 12px; }
.source-coverage-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
}
.source-coverage-item {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel-soft);
    padding: 12px;
}
.source-coverage-item strong {
    display: block;
    margin-bottom: 8px;
    font-size: 13px;
}
.source-coverage-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.panel { padding: 14px; margin-bottom: 14px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 14px; margin-bottom: 14px; color: var(--muted); }
.panel-head h2 { color: var(--ink); }
.panel-head p { margin: 5px 0 0; color: var(--muted); }
.chart-panel { min-height: 0; }
.chart-wrap {
    width: 100%;
    height: 210px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: linear-gradient(180deg, var(--panel-soft), var(--panel));
    padding: 12px;
}
#trendChart { display: block; width: 100%; height: 100%; }
.chart-legend { display: flex; gap: 18px; align-items: center; margin-top: 11px; color: var(--muted); font-weight: 750; }
.chart-legend span::before { content: ""; display: inline-block; width: 9px; height: 9px; border-radius: 99px; margin-right: 7px; }
.legend-impressions::before { background: var(--brand); }
.legend-clicks::before { background: var(--blue); }
.dashboard-chart-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(260px, .82fr) minmax(260px, .82fr);
    gap: 12px;
    align-items: stretch;
    margin-bottom: 14px;
}
.dashboard-chart-grid .panel { margin-bottom: 0; min-width: 0; }
.dashboard-chart-grid .chart-wrap { height: 188px; }
.dashboard-card { display: grid; align-content: start; }
.dashboard-card.chart-card { padding: 14px; }
.dashboard-card .donut-layout { min-height: 190px; grid-template-columns: 116px minmax(0, 1fr); gap: 12px; }
.dashboard-card .donut { width: 104px; height: 104px; }
.dashboard-card .donut::after { width: 58px; height: 58px; }
.dashboard-card .bar-list { gap: 8px; }
.table-wrap {
    overflow-x: auto;
    overflow-y: visible;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
}
table { width: 100%; border-collapse: separate; border-spacing: 0; min-width: 1140px; background: var(--panel); }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--panel-soft);
    color: var(--muted);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0;
}
td { font-size: 13px; }
td small { display: block; color: var(--muted); margin-top: 2px; max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.campaign-cell {
    min-width: 0;
    max-width: 0;
    overflow: hidden;
}
.campaign-cell strong,
.campaign-cell small {
    display: block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.campaign-link {
    color: inherit;
    text-decoration: none;
    border-bottom: 1px solid transparent;
}
.campaign-link:hover,
.campaign-link:focus-visible {
    color: var(--brand);
    border-bottom-color: color-mix(in srgb, var(--brand) 40%, transparent);
    outline: none;
}
.date-cell { color: var(--muted); white-space: nowrap; font-size: 12px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.creative-cell {
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
}
.creative-inline {
    display: flex;
    align-items: center;
    gap: 9px;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
}
.creative-inline > div {
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
}
.creative-inline > div.banner-id-wrap {
    overflow: visible;
    flex: 0 0 auto;
    min-width: max-content;
    max-width: none;
}
.creative-inline strong,
.creative-inline small {
    display: block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.creative-inline strong {
    font-variant-numeric: tabular-nums;
    margin: 0;
    font-size: 12px;
}
.banner-id-label {
    display: block;
    overflow: visible;
    text-overflow: clip;
    white-space: nowrap;
    letter-spacing: 0;
}
.banner-id-label.is-compact {
    font-size: 10px;
    letter-spacing: .01em;
}
.thumb {
    width: 56px;
    height: 38px;
    padding: 0;
    overflow: hidden;
    background: var(--panel-soft);
    border: 1px solid var(--line);
    flex: 0 0 auto;
}
.thumb img { width: 100%; height: 100%; object-fit: contain; display: block; }
.compact-creative-table { min-width: 1240px; table-layout: fixed; }
.compact-creative-table th,
.compact-creative-table td { padding-top: 7px; padding-bottom: 7px; }
.compact-creative-table th:nth-child(1), .compact-creative-table td:nth-child(1) { width: 156px; }
.compact-creative-table th:nth-child(2), .compact-creative-table td:nth-child(2) { width: 28%; }
.compact-creative-table th:nth-child(3), .compact-creative-table td:nth-child(3) { width: 106px; }
.compact-creative-table th:nth-child(4), .compact-creative-table td:nth-child(4) { width: 130px; }
.compact-creative-table th:nth-child(5), .compact-creative-table td:nth-child(5) { width: 92px; }
.compact-creative-table th:nth-child(6), .compact-creative-table td:nth-child(6) { width: 120px; }
.compact-creative-table th:nth-child(7), .compact-creative-table td:nth-child(7) { width: 92px; }
.compact-creative-table th:nth-child(8), .compact-creative-table td:nth-child(8) { width: 106px; }
.compact-creative-table th:nth-child(9), .compact-creative-table td:nth-child(9) { width: 110px; }
.compact-creative-table th:nth-child(10), .compact-creative-table td:nth-child(10) { width: 92px; }
.compact-creative-table th:nth-child(11), .compact-creative-table td:nth-child(11) { width: 64px; }
.compact-creative-table td:nth-child(3),
.compact-creative-table td:nth-child(5),
.compact-creative-table td:nth-child(6),
.compact-creative-table td:nth-child(10),
.compact-creative-table td:nth-child(11) { white-space: nowrap; }
.compact-creative-table tbody tr:hover td { background: color-mix(in srgb, var(--panel-soft) 72%, transparent); }
.compact-creative-table tbody tr:last-child td { border-bottom: 0; }
.row-details-cell { text-align: right; }
.detail-trigger {
    width: 34px;
    height: 34px;
}
.row-details { position: relative; display: inline-block; }
.row-details summary,
.row-action-menu summary {
    list-style: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 30px;
    border: 1px solid var(--line);
    border-radius: 7px;
    padding: 5px 9px;
    background: var(--panel-soft);
    color: var(--ink);
    cursor: pointer;
    font-size: 12px;
    font-weight: 850;
    white-space: nowrap;
}
.row-details summary::-webkit-details-marker,
.row-action-menu summary::-webkit-details-marker { display: none; }
.row-details-panel,
.row-action-form {
    position: absolute;
    z-index: 60;
    right: 0;
    top: calc(100% + 6px);
    width: min(520px, calc(100vw - 36px));
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
    text-align: left;
}
.panel-close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--panel-soft);
    color: var(--muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
}
.panel-close:hover {
    color: var(--ink);
    border-color: color-mix(in srgb, var(--brand) 35%, var(--line));
}
.row-details-panel dl {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin: 22px 0 10px;
}
.row-details-panel dt,
.row-action-form label {
    color: var(--muted);
    font-size: 11px;
    font-weight: 850;
}
.row-details-panel dd {
    margin: 3px 0 0;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 750;
}
.row-details-panel .wide { grid-column: 1 / -1; }
.report-grid-breakdown {
    grid-template-columns: minmax(280px, .9fr) minmax(0, 1.35fr) minmax(320px, .9fr);
}
.report-grid-breakdown-secondary {
    grid-template-columns: minmax(280px, 1fr) minmax(320px, 1.2fr);
}
.campaign-chart-panel {
    min-height: 320px;
}
.compact-chart-wrap {
    min-height: 240px;
}
.zone-breakdown-wide {
    margin-bottom: 18px;
}
.hour-breakdown table {
    min-width: 0;
}
.hour-breakdown th,
.hour-breakdown td {
    white-space: nowrap;
}
.hour-breakdown td:last-child,
.hour-breakdown th:last-child {
    white-space: normal;
}
.zone-breakdown-wide .table-wrap {
    overflow-x: auto;
}
.zone-breakdown-wide table {
    min-width: 640px;
}
.table-link {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    border: 1px solid var(--line);
    border-radius: 7px;
    padding: 4px 8px;
    background: var(--panel-soft);
    color: var(--ink);
    text-decoration: none;
    font-size: 12px;
    font-weight: 800;
}
.table-link:hover,
.table-link:focus-visible,
.table-link.active {
    background: var(--brand-soft);
    color: var(--brand-strong);
    border-color: color-mix(in srgb, var(--brand) 32%, var(--line));
    outline: none;
}
.pill { display: inline-flex; min-width: 66px; justify-content: center; border-radius: 999px; padding: 4px 8px; font-size: 11px; font-weight: 850; }
.pill.ok { background: var(--ok-bg); color: #087443; }
[data-theme="dark"] .pill.ok { color: #77e0ad; }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.muted { background: var(--muted-bg); color: var(--muted); }
.format-pill {
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
    border: 1px solid color-mix(in srgb, var(--brand) 28%, var(--line));
    background: var(--brand-soft);
    color: var(--brand-strong);
    border-radius: 999px;
    padding: 3px 8px;
    font-size: 11px;
    font-weight: 850;
}
.info-tip {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 17px;
    height: 17px;
    margin-left: 6px;
    border-radius: 50%;
    border: 1px solid color-mix(in srgb, var(--brand) 35%, var(--line));
    background: color-mix(in srgb, var(--brand-soft) 55%, transparent);
    color: var(--brand-strong);
    cursor: help;
    vertical-align: middle;
    isolation: isolate;
    transform: translateY(-1px);
}
.info-tip svg {
    width: 13px;
    height: 13px;
    display: block;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.info-tip:hover,
.info-tip:focus {
    border-color: var(--brand);
    background: var(--brand);
    color: #fff;
    outline: none;
}
.tooltip-pop {
    position: fixed;
    z-index: 9999;
    width: max-content;
    max-width: min(360px, calc(100vw - 32px));
    padding: 10px 12px;
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: 8px;
    background: #0f1724;
    color: #f8fafc;
    box-shadow: 0 18px 46px rgba(0, 0, 0, .34);
    font-size: 12px;
    font-weight: 650;
    line-height: 1.35;
    text-align: left;
    pointer-events: none;
    opacity: 0;
    transform: translateY(4px);
    transition: opacity .12s ease, transform .12s ease;
}
.tooltip-pop.is-visible { opacity: 1; transform: translateY(0); }
.tooltip-pop.chart-tooltip {
    white-space: pre-line;
    min-width: 190px;
    font-variant-numeric: tabular-nums;
}
.tooltip-pop::before {
    content: "";
    position: absolute;
    left: var(--arrow-x, 50%);
    top: -5px;
    width: 9px;
    height: 9px;
    background: #0f1724;
    border-left: 1px solid rgba(255, 255, 255, .08);
    border-top: 1px solid rgba(255, 255, 255, .08);
    transform: translateX(-50%) rotate(45deg);
}
.tooltip-pop.above::before {
    top: auto;
    bottom: -5px;
    border: 0;
    border-right: 1px solid rgba(255, 255, 255, .08);
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.tooltip-pop.side::before {
    left: -5px;
    top: var(--arrow-y, 50%);
    bottom: auto;
    border: 0;
    border-left: 1px solid rgba(255, 255, 255, .08);
    border-bottom: 1px solid rgba(255, 255, 255, .08);
    transform: translateY(-50%) rotate(45deg);
}
.table-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin: 0 0 10px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 750;
    flex-wrap: wrap;
}
.table-toolbar + .table-wrap { margin-top: 6px; }
.table-wrap + .table-toolbar { margin: 10px 0 0; }
.pager {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: flex-end;
}
.pager a,
.pager strong {
    min-height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--line);
    border-radius: 7px;
    padding: 5px 8px;
    background: var(--panel-soft);
    color: var(--ink);
    text-decoration: none;
    font-size: 12px;
}
.pager a.active {
    background: var(--brand-soft);
    color: var(--brand-strong);
    border-color: color-mix(in srgb, var(--brand) 38%, var(--line));
}
.pager a.disabled {
    opacity: .45;
    pointer-events: none;
}
.pager strong {
    color: var(--muted);
    font-weight: 850;
}
.log-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.log-grid div { border: 1px solid var(--line); border-radius: 8px; padding: 12px; background: var(--panel-soft); }
.log-grid span { display: block; color: var(--muted); margin-top: 4px; }
.report-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(430px, 100%), 1fr)); gap: 12px; }
.report-stack { display: grid; grid-template-columns: 1fr; gap: 12px; }
.report-stack .mini-report table { table-layout: fixed; width: 100%; }
.insights-stack { max-width: none; }
.mini-report { min-width: 0; overflow: visible; }
.mini-report table { min-width: 0; table-layout: fixed; }
.mini-report th, .mini-report td { padding: 8px 9px; font-size: 12px; }
.mini-report th { font-size: 10px; }
.mini-report th,
.mini-report td { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-report th:first-child,
.mini-report td:first-child { width: 48%; }
.mini-report th:not(:first-child),
.mini-report td:not(:first-child) { width: 17.33%; }
.mini-report .num { white-space: nowrap; font-size: 12px; }
.insight-table th:first-child,
.insight-table td:first-child { width: 34%; }
.insight-table th:nth-child(2),
.insight-table td:nth-child(2) { width: 13%; }
.insight-table th:nth-child(n+3),
.insight-table td:nth-child(n+3) { width: 10.6%; }
.insight-table th:nth-child(4),
.insight-table td:nth-child(4) { width: 13%; }
.insight-summary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.insight-summary .panel { margin: 0; padding: 14px 16px; }
.insight-summary span { display: block; color: var(--muted); font-weight: 750; margin-bottom: 6px; }
.insight-summary strong { font-size: 22px; }
.insight-chart-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.insight-visual-grid { margin-bottom: 14px; }
.insight-visual-card { margin-bottom: 0; }
.insight-chart-wrap { height: 240px; }
.insightChart { display: block; width: 100%; height: 100%; }
.chart-card {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel-soft);
    padding: 12px;
    min-width: 0;
    overflow: hidden;
}
.chart-card h3 { font-size: 14px; margin-bottom: 10px; }
.bar-list { display: grid; gap: 9px; min-width: 0; }
.bar-row { display: grid; gap: 5px; min-width: 0; }
.chart-hover,
.donut.chart-hover,
.donut-legend .chart-hover,
.bar-row.chart-hover { cursor: crosshair; }
.chart-hover:focus {
    outline: 2px solid color-mix(in srgb, var(--brand) 42%, transparent);
    outline-offset: 2px;
}
.bar-row.chart-hover {
    border-radius: 7px;
    padding: 2px 0;
}
.bar-row.chart-hover:hover .bar-track {
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--brand) 42%, transparent);
}
.donut.chart-hover:hover {
    box-shadow: inset 0 0 0 1px var(--line), 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent);
}
.donut-legend .chart-hover {
    border-radius: 6px;
    padding: 2px 4px;
    margin: -2px -4px;
}
.donut-legend .chart-hover:hover {
    background: color-mix(in srgb, var(--brand-soft) 52%, transparent);
}
.bar-meta {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    font-size: 12px;
    min-width: 0;
}
.bar-meta span {
    display: block;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--ink);
}
.bar-meta strong { flex: 0 0 auto; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.bar-track { height: 8px; border-radius: 999px; background: var(--muted-bg); overflow: hidden; }
.bar-track i {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--brand), #6bbfb5);
    transform-origin: left center;
    animation: bar-grow .72s cubic-bezier(.2, .8, .2, 1) both;
}
.donut-layout { display: grid; grid-template-columns: 130px minmax(0, 1fr); align-items: center; gap: 14px; min-height: 176px; }
.donut {
    width: 116px;
    height: 116px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    position: relative;
    box-shadow: inset 0 0 0 1px var(--line);
    animation: chart-rise .58s cubic-bezier(.2, .8, .2, 1) both;
}
.donut.empty { background: var(--muted-bg); }
.donut::after { content: ""; position: absolute; width: 66px; height: 66px; border-radius: 50%; background: var(--panel-soft); box-shadow: inset 0 0 0 1px var(--line); }
.donut span { position: relative; z-index: 1; font-weight: 850; font-size: 13px; }
.donut-legend { display: grid; gap: 7px; min-width: 0; }
.donut-legend div { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; align-items: center; gap: 8px; font-size: 12px; min-width: 0; }
.donut-legend i { width: 9px; height: 9px; border-radius: 3px; }
.donut-legend span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); }
.donut-legend strong { color: var(--muted); font-size: 12px; }
.chart-wrap canvas { cursor: crosshair; }
.insight-table td:first-child { max-width: 260px; }
.metric-ctr { color: var(--brand); font-weight: 850; }
.alert { background: var(--brand-soft); border: 1px solid color-mix(in srgb, var(--brand) 35%, transparent); padding: 12px 14px; border-radius: 8px; margin-bottom: 14px; }
.alert-error { background: #fff0f0; border-color: #f5b5b5; color: var(--danger); }
[data-theme="dark"] .alert-error { background: #3a1717; border-color: #733131; }
.login-page { min-height: 100vh; display: grid; place-items: center; background: #101820; padding: 18px; }
.login-shell { width: min(420px, 100%); }
.login-panel { background: var(--panel); padding: 28px; border-radius: 8px; display: grid; gap: 18px; box-shadow: var(--shadow); }
.login-tools { display: flex; justify-content: flex-end; gap: 10px; align-items: center; }
.stack { display: grid; gap: 12px; }
.stack label { display: grid; gap: 6px; color: var(--muted); font-weight: 750; }
.source-checks {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 12px;
    display: grid;
    gap: 8px;
    background: var(--panel-soft);
}
.source-checks legend { color: var(--muted); font-weight: 850; padding: 0 4px; }
.source-checks label { display: flex; align-items: center; gap: 7px; color: var(--ink); font-weight: 750; }
.source-checks input { width: auto; min-height: 0; }
.source-checks.inline { border: 0; padding: 0; background: transparent; grid-template-columns: repeat(2, max-content); gap: 7px 12px; }
.source-access-form { display: grid; gap: 8px; align-items: start; }
.source-access-form button { width: max-content; min-height: 30px; padding: 5px 9px; font-size: 12px; }
.source-access-menu {
    position: relative;
    width: 100%;
    max-width: 100%;
}
.source-access-menu[open] { width: 100%; }
.source-access-menu summary {
    list-style: none;
    min-height: 34px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--panel-soft);
    color: var(--ink);
    padding: 7px 10px;
    cursor: pointer;
    font-weight: 800;
    font-size: 12px;
}
.source-access-menu summary {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.source-access-menu summary::-webkit-details-marker { display: none; }
.source-access-menu summary::after {
    content: "";
    width: 7px;
    height: 7px;
    border-right: 2px solid var(--muted);
    border-bottom: 2px solid var(--muted);
    transform: rotate(45deg) translateY(-2px);
    flex: 0 0 auto;
}
.source-access-menu[open] summary::after { transform: rotate(225deg) translateY(-2px); }
.source-access-menu .source-access-form {
    position: absolute;
    z-index: 40;
    right: 0;
    top: calc(100% + 6px);
    min-width: 300px;
    max-width: min(360px, calc(100vw - 32px));
    margin-top: 0;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
}
.user-table-wrap { overflow: visible; }
.user-table { min-width: 1120px; table-layout: fixed; }
.user-table th, .user-table td { vertical-align: top; }
.user-table th:nth-child(1), .user-table td:nth-child(1) { width: 18%; }
.user-table th:nth-child(2), .user-table td:nth-child(2) { width: 10%; }
.user-table th:nth-child(3), .user-table td:nth-child(3) { width: 10%; }
.user-table th:nth-child(4), .user-table td:nth-child(4) { width: 24%; }
.user-table th:nth-child(5), .user-table td:nth-child(5) { width: 14%; }
.user-table th:nth-child(6), .user-table td:nth-child(6) { width: 24%; }
.user-table td:nth-child(1),
.user-table td:nth-child(2),
.user-table td:nth-child(5) { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-table td:nth-child(4),
.user-table td:nth-child(6) { overflow: visible; }
.muted-text { color: var(--muted); font-weight: 750; }
.chip-list { display: flex; align-items: center; gap: 5px; flex-wrap: nowrap; min-width: 0; margin-bottom: 8px; overflow: hidden; }
.chip {
    display: inline-flex;
    align-items: center;
    max-width: 86px;
    min-height: 24px;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 3px 8px;
    background: var(--panel-soft);
    font-size: 11px;
    font-weight: 850;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.chip.muted { color: var(--muted); }
.user-source-cell {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: start;
    min-width: 0;
}
.row-action-menu { position: relative; display: inline-block; }
.row-action-form {
    display: grid;
    gap: 9px;
    width: 260px;
}
.row-action-form label { display: grid; gap: 5px; }
.danger-button { color: var(--danger); }
.split { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 18px; align-items: start; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.actions form { margin: 0; }
.user-actions {
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    flex-wrap: nowrap;
    white-space: nowrap;
}
.user-actions form,
.user-actions details { flex: 0 0 auto; margin: 0; }
.icon-button {
    width: 34px;
    height: 34px;
    min-height: 34px;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel-soft);
    color: var(--ink);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.icon-button:hover { border-color: color-mix(in srgb, var(--brand) 45%, var(--line)); background: color-mix(in srgb, var(--brand-soft) 55%, var(--panel-soft)); }
.icon-button svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.icon-button.danger { color: var(--danger); }
.icon-button.success { color: var(--brand-strong); }
.icon-button.warn { color: var(--warn); }
.detail-drawer {
    position: fixed;
    inset: 0;
    z-index: 140;
    pointer-events: none;
}
.detail-drawer.is-open {
    pointer-events: auto;
}
.detail-drawer-backdrop {
    position: absolute;
    inset: 0;
    border: 0;
    background: rgba(11, 17, 24, .46);
    opacity: 0;
    transition: opacity .2s ease;
}
.detail-drawer-panel {
    position: absolute;
    top: 0;
    right: 0;
    width: min(440px, calc(100vw - 20px));
    height: 100%;
    display: grid;
    align-content: start;
    gap: 14px;
    padding: 20px;
    background: var(--panel);
    border-left: 1px solid var(--line);
    box-shadow: var(--shadow);
    transform: translateX(100%);
    transition: transform .24s ease;
    overflow-y: auto;
}
.detail-drawer.is-open .detail-drawer-backdrop { opacity: 1; }
.detail-drawer.is-open .detail-drawer-panel { transform: translateX(0); }
.detail-drawer-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}
.detail-drawer-head .eyebrow { margin-bottom: 6px; }
.detail-drawer-sub {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 12px;
}
.detail-drawer-preview {
    min-height: 180px;
    display: grid;
    place-items: center;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: linear-gradient(180deg, var(--panel-soft), var(--panel));
}
.detail-drawer-preview img {
    max-width: 100%;
    max-height: 220px;
    object-fit: contain;
    display: block;
}
.detail-drawer-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin: 0;
}
.detail-drawer-grid dt {
    color: var(--muted);
    font-size: 11px;
    font-weight: 850;
}
.detail-drawer-grid dd {
    margin: 4px 0 0;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 800;
}
.detail-drawer-grid .wide { grid-column: 1 / -1; }
.detail-drawer-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.detail-drawer-link {
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 7px;
    padding: 9px 13px;
    background: var(--panel-soft);
}
.source-access-menu .icon-button { width: 34px; }
.source-access-menu summary.icon-button {
    min-height: 34px;
    padding: 0;
    justify-content: center;
    gap: 0;
    background: var(--panel-soft);
}
.source-access-menu summary.icon-button::after { display: none; }
.row-action-menu summary.icon-button {
    min-height: 34px;
    padding: 0;
    background: var(--panel-soft);
}
.inline-reset { display: flex; gap: 6px; }
.inline-reset input { width: 180px; }
dialog { border: 0; border-radius: 8px; padding: 18px; width: min(900px, calc(100vw - 28px)); box-shadow: 0 20px 70px rgba(16,24,32,.32); background: var(--panel); color: var(--ink); }
dialog::backdrop { background: rgba(16, 24, 32, .62); }
.close { float: right; width: 34px; height: 34px; padding: 0; font-size: 24px; }
.creative-stage { margin: 16px 0; min-height: 240px; display: grid; place-items: center; background: var(--panel-soft); border-radius: 8px; border: 1px solid var(--line); }
.creative-stage img { max-width: 100%; max-height: 70vh; object-fit: contain; }
code { background: var(--muted-bg); padding: 2px 5px; border-radius: 4px; }
@keyframes bar-grow {
    from { transform: scaleX(0); opacity: .45; }
    to { transform: scaleX(1); opacity: 1; }
}
@keyframes chart-rise {
    from { transform: scale(.94); opacity: .35; }
    to { transform: scale(1); opacity: 1; }
}
@media (max-width: 1180px) {
    .filters { grid-template-columns: repeat(3, minmax(145px, 1fr)); }
    .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .source-counter-strip dl { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .log-grid, .insight-chart-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .dashboard-chart-grid { grid-template-columns: 1fr 1fr; }
    .dashboard-trend { grid-column: 1 / -1; }
}
@media (max-width: 820px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar { position: static; }
    .sidebar-head { grid-template-columns: 1fr auto; justify-items: stretch; }
    .app-shell.sidebar-collapsed { grid-template-columns: 1fr; }
    .app-shell.sidebar-collapsed .brand strong,
    .app-shell.sidebar-collapsed .nav-label { display: initial; }
    .app-shell.sidebar-collapsed .import-box { display: grid; }
    .app-shell.sidebar-collapsed nav a { justify-content: flex-start; padding-inline: 12px; }
    .filters, .kpi-grid, .log-grid, .split, .report-grid, .insight-summary, .insight-chart-grid, .dashboard-chart-grid { grid-template-columns: 1fr; }
    .source-counter-strip dl { grid-template-columns: 1fr; }
    .topbar { align-items: flex-start; flex-direction: column; }
    .content { padding: 18px; }
    h1 { font-size: 24px; }
    .donut-layout { grid-template-columns: 1fr; justify-items: start; }
    .dashboard-card .donut-layout { grid-template-columns: 1fr; }
    .table-toolbar { align-items: flex-start; }
    .pager { justify-content: flex-start; }
    .period-note { grid-column: auto; }
    .custom-period { grid-template-columns: 1fr; }
    .detail-drawer-panel { width: min(100vw, 100%); }
    .detail-drawer-grid { grid-template-columns: 1fr; }
    .table-wrap::after {
        content: "Scroll";
        position: sticky;
        right: 8px;
        bottom: 8px;
        display: inline-flex;
        margin: 8px;
        padding: 4px 8px;
        border-radius: 999px;
        background: var(--muted-bg);
        color: var(--muted);
        font-size: 10px;
        font-weight: 850;
        text-transform: uppercase;
    }
}
