@font-face {
    font-family: "Darker Grotesque";
    src: url("/fonts/DarkerGrotesque-Regular.ttf") format("truetype");
    font-style: normal;
    font-weight: 400 600;
    font-display: swap;
}

@font-face {
    font-family: "Darker Grotesque";
    src: url("/fonts/DarkerGrotesque-Bold.ttf") format("truetype");
    font-style: normal;
    font-weight: 700 900;
    font-display: swap;
}

@font-face {
    font-family: "Figtree";
    src: url("/fonts/Figtree-Regular.ttf") format("truetype");
    font-style: normal;
    font-weight: 400 500;
    font-display: swap;
}

@font-face {
    font-family: "Figtree";
    src: url("/fonts/Figtree-SemiBold.ttf") format("truetype");
    font-style: normal;
    font-weight: 600;
    font-display: swap;
}

@font-face {
    font-family: "Figtree";
    src: url("/fonts/Figtree-Bold.ttf") format("truetype");
    font-style: normal;
    font-weight: 700 900;
    font-display: swap;
}

:root {
    color-scheme: light;
    --bg: #f7f4ef;
    --panel: #ffffff;
    --text: #232323;
    --muted: #656565;
    --line: #dbd2c5;
    --line-strong: #bab0a3;
    --accent: #232323;
    --accent-dark: #000000;
    --accent-soft: #ece3d6;
    --ok: #3a8d70;
    --ok-soft: #e0f5f3;
    --fail: #d04348;
    --fail-soft: #fff0f0;
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "Figtree", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
    color: inherit;
}

h1,
h2,
h3,
button,
.secondary-button,
.pager a,
.home-action-title,
.eyebrow,
.topbar nav,
.brand-context {
    font-family: "Darker Grotesque", ui-sans-serif, system-ui, sans-serif;
}

.home-shell {
    min-height: calc(100vh - 69px);
    display: grid;
    place-items: center;
    padding: 32px;
}

.home-panel {
    width: min(920px, 100%);
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--muted);
    font-size: 15px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
}

h1 {
    margin: 0 0 32px;
    font-size: 42px;
    line-height: 1.1;
}

.home-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 18px;
}

.home-action {
    min-height: 150px;
    padding: 24px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--panel);
    text-decoration: none;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.home-action:hover,
.home-action:focus-visible {
    border-color: var(--text);
    box-shadow: 0 8px 24px rgb(35 35 35 / 12%);
    transform: translateY(-2px);
}

.home-action-title {
    font-size: 24px;
    font-weight: 800;
}

.home-action-copy {
    color: var(--muted);
    line-height: 1.45;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    min-height: 69px;
    padding: 12px 24px;
    border-bottom: 1px solid #000;
    background: #000;
    color: #fff;
}

.brand-link {
    display: inline-flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
    font-weight: 800;
    text-decoration: none;
}

.brand-logo {
    display: block;
    width: 140px;
    height: auto;
}

.brand-context {
    border-left: 1px solid rgb(255 255 255 / 35%);
    color: var(--accent-soft);
    padding-left: 14px;
    font-size: 18px;
    font-weight: 700;
    line-height: 1;
    white-space: nowrap;
}

.topbar nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

.topbar nav a {
    padding: 8px 12px;
    border-radius: 6px;
    color: var(--accent-soft);
    text-decoration: none;
    font-weight: 700;
    font-size: 16px;
}

.topbar nav a.active,
.topbar nav a:hover {
    background: var(--accent-soft);
    color: var(--accent-dark);
}

.page {
    padding: 24px;
}

.audit-controls {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.aggregation-status {
    display: flex;
    justify-content: flex-end;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 10px;
    color: var(--muted);
    font-size: 12px;
}

.aggregation-status strong {
    color: var(--text);
    font-weight: 700;
}

.aggregation-runs-page {
    display: grid;
    gap: 18px;
}

.aggregation-runs-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 24px;
}

.aggregation-runs-heading h1 {
    margin-bottom: 6px;
}

.aggregation-runs-heading p {
    margin: 0;
    color: var(--muted);
}

.aggregation-limit-form label {
    display: grid;
    gap: 5px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.aggregation-limit-form select {
    min-width: 150px;
    min-height: 36px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    padding: 6px 8px;
    font: inherit;
}

.aggregation-history-warning {
    border: 1px solid #d59b35;
    border-radius: 8px;
    background: #fff7df;
    color: #6e4a0c;
    padding: 12px 14px;
}

.aggregation-run-summary {
    display: flex;
    justify-content: flex-end;
}

.aggregation-run-summary p {
    margin: 0;
    color: var(--muted);
    font-size: 12px;
}

.aggregation-run-list {
    display: grid;
    gap: 10px;
}

.aggregation-run-list > header {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 20px;
}

.aggregation-run-list h2,
.aggregation-run-list p {
    margin: 0;
}

.aggregation-run-list p {
    margin-top: 3px;
    color: var(--muted);
    font-size: 13px;
}

.aggregation-average {
    display: grid;
    justify-items: end;
    gap: 2px;
}

.aggregation-average span {
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
}

.aggregation-average strong {
    font-size: 18px;
}

.aggregation-legend-failed,
.aggregation-legend-slow {
    display: inline-block;
    width: 11px;
    height: 11px;
    margin: 0 4px 0 12px;
    border-radius: 3px;
    vertical-align: -1px;
}

.aggregation-legend-failed {
    background: var(--fail-soft);
    border: 1px solid var(--fail);
}

.aggregation-legend-slow {
    background: #fff4c2;
    border: 1px solid #c78c16;
}

.aggregation-runs-table tr.aggregation-run-failed td {
    background: var(--fail-soft);
}

.aggregation-runs-table tr.aggregation-run-slow td {
    background: #fff9df;
}

.aggregation-message {
    min-width: 240px;
    white-space: normal;
    overflow-wrap: anywhere;
}

@media (max-width: 760px) {
    .aggregation-runs-heading {
        align-items: stretch;
        flex-direction: column;
    }

    .aggregation-run-summary p {
        width: 100%;
        margin-left: 0;
    }

    .aggregation-run-list > header {
        align-items: start;
    }
}

.audit-controls label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.audit-controls select {
    min-height: 34px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    color: var(--text);
    padding: 5px 8px;
    font: inherit;
}

.filters {
    display: grid;
    gap: 12px;
    margin-bottom: 18px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
}

.audit-user-page .filters {
    gap: 18px;
}

.audit-user-identity {
    display: grid;
    gap: 16px;
}

.audit-user-identity h1,
.audit-user-filter-heading h2,
.audit-user-empty-state h2 {
    margin: 0;
}

.audit-user-identity p,
.audit-user-empty-state p {
    margin: 4px 0 0;
    color: var(--muted);
}

.audit-user-identity-fields {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) auto minmax(220px, 1fr) auto;
    gap: 12px;
    align-items: end;
}

.audit-user-or {
    align-self: end;
    padding-bottom: 9px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
}

.audit-user-validation {
    color: var(--fail) !important;
    font-weight: 700;
}

.audit-user-advanced {
    display: grid;
    gap: 12px;
    padding-top: 18px;
    border-top: 1px solid var(--line);
}

.audit-user-filter-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.audit-user-filter-actions {
    display: flex;
    justify-content: flex-end;
}

.audit-user-empty-state {
    padding: 48px 24px;
    border: 1px dashed var(--line-strong);
    border-radius: 8px;
    background: rgb(255 255 255 / 55%);
    text-align: center;
}

@media (max-width: 760px) {
    .audit-user-identity-fields {
        grid-template-columns: 1fr;
    }

    .audit-user-or {
        padding: 0;
    }

    .audit-user-filter-heading {
        align-items: flex-start;
        flex-direction: column;
    }
}

.filter-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    align-items: end;
}

.filters label {
    position: relative;
    display: grid;
    gap: 5px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.filters input,
.filters select {
    width: 100%;
    min-height: 36px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    color: var(--text);
    padding: 6px 8px;
    font: inherit;
}

.filters label.audit-filter-toggle {
    display: flex;
    min-height: 36px;
    flex-direction: row;
    align-items: center;
    align-self: end;
    gap: 8px;
    color: var(--text);
    font-size: 13px;
}

.filters label.audit-filter-toggle input[type="checkbox"] {
    width: 16px;
    min-height: 16px;
    margin: 0;
    padding: 0;
}

.filters label.has-filter-clear input,
.filters label.has-filter-clear select {
    padding-right: 38px;
}

.filters label.has-filter-clear input[type="date"],
.filters label.has-filter-clear input[type="datetime-local"],
.filters label.has-filter-clear input[type="month"],
.filters label.has-filter-clear input[type="number"],
.filters label.has-filter-clear select {
    padding-right: 58px;
}

.filters input[type="search"]::-webkit-search-cancel-button {
    appearance: none;
}

.filter-clear-button,
.filter-clear-button:hover,
.filter-clear-button:focus-visible {
    position: absolute;
    right: 5px;
    bottom: 5px;
    z-index: 4;
    display: inline-grid;
    place-items: center;
    width: 26px;
    height: 26px;
    min-height: 26px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--muted);
    padding: 0 0 2px;
    font-family: "Figtree", ui-sans-serif, system-ui, sans-serif;
    font-size: 20px;
    font-weight: 500;
    line-height: 1;
}

.filter-clear-button.for-native-control {
    right: 24px;
}

.filter-clear-button:hover,
.filter-clear-button:focus-visible {
    background: var(--accent-soft);
    color: var(--accent-dark);
}

.filters label.lookup-loading::after {
    content: "";
    position: absolute;
    right: 28px;
    bottom: 10px;
    width: 14px;
    height: 14px;
    border: 2px solid var(--line);
    border-top-color: var(--accent);
    border-radius: 50%;
    pointer-events: none;
    animation: loading-spin .7s linear infinite;
}

.filters label.lookup-loading select {
    padding-right: 46px;
}

.user-suggestion-shell {
    position: relative;
    display: block;
    width: 100%;
}

.user-suggestion-list {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 4px);
    z-index: 20;
    display: none;
    max-height: 240px;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    box-shadow: 0 12px 28px rgb(35 35 35 / 14%);
}

.user-suggestion-list.open {
    display: block;
}

.user-suggestion-option {
    display: block;
    width: 100%;
    min-height: 34px;
    border: 0;
    border-radius: 0;
    background: #fff;
    color: var(--text);
    padding: 7px 10px;
    text-align: left;
    font: inherit;
    font-size: 13px;
    font-weight: 500;
}

.user-suggestion-option:hover,
.user-suggestion-option:focus {
    background: var(--accent-soft);
    color: var(--accent-dark);
}

.user-suggestion-option.disabled {
    color: var(--muted);
    cursor: default;
    font-style: italic;
}

button,
.pager a,
.secondary-button {
    min-height: 36px;
    border: 1px solid var(--accent);
    border-radius: 7px;
    background: var(--accent);
    color: white;
    padding: 6px 12px;
    font: inherit;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
}

button:hover,
.pager a:hover,
.secondary-button:hover {
    background: var(--accent-dark);
}

.secondary-button {
    display: inline-flex;
    align-items: center;
    background: #fff;
    color: var(--accent-dark);
    border-color: var(--line-strong);
}

.secondary-button:hover {
    color: #fff;
    border-color: var(--accent-dark);
}

.table-shell {
    position: relative;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
}

.table-loading-indicator {
    position: absolute;
    right: 12px;
    top: 48px;
    z-index: 4;
    display: none;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    background: #fff;
    color: var(--accent-dark);
    padding: 8px 12px;
    box-shadow: 0 12px 28px rgb(35 35 35 / 14%);
    font-size: 13px;
    font-weight: 750;
    pointer-events: none;
}

.table-shell.loading .table-loading-indicator {
    display: inline-flex;
}

.loading-spinner {
    width: 16px;
    height: 16px;
    flex: 0 0 auto;
    border: 2px solid var(--line);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: loading-spin .7s linear infinite;
}

@keyframes loading-spin {
    to {
        transform: rotate(360deg);
    }
}

@media (prefers-reduced-motion: reduce) {
    .loading-spinner,
    .filters label.lookup-loading::after {
        animation: none;
    }
}

.table-shell.compact {
    max-width: 760px;
}

.audit-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 13px;
    table-layout: auto;
}

.audit-table th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--accent-soft);
    text-align: left;
    white-space: nowrap;
    border-bottom: 1px solid var(--line);
    padding: 9px 10px;
}

.audit-table td {
    vertical-align: middle;
    border-bottom: 1px solid var(--line);
    max-width: 260px;
    height: 42px;
    padding: 7px 10px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.audit-table tr:last-child td {
    border-bottom: 0;
}

.nowrap {
    white-space: nowrap;
}

.copyable {
    user-select: text;
    cursor: text;
}

.country-code-with-name {
    position: relative;
    overflow: visible !important;
}

.country-code-with-name:hover::after {
    position: absolute;
    z-index: 20;
    top: calc(100% + 6px);
    left: 50%;
    padding: 6px 9px;
    transform: translateX(-50%);
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #2b2926;
    color: #fff;
    box-shadow: 0 4px 12px rgb(0 0 0 / 18%);
    content: attr(data-country-name);
    font-size: 12px;
    font-weight: 500;
    line-height: 1.2;
    pointer-events: none;
    white-space: nowrap;
}

.copyable.copied,
.copy-button.copied,
#decryptCopy.copied {
    outline: 2px solid var(--ok);
    outline-offset: 1px;
}

.compact-id {
    max-width: 120px;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
    font-size: 12px;
}

.message-col {
    min-width: 420px;
}

.message-cell {
    min-width: 420px;
    max-width: 560px;
}

.message-line {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    white-space: nowrap;
}

.table-view-toolbar {
    display: flex;
    justify-content: flex-end;
    margin: 0 0 8px;
}

.icon-button {
    flex: 0 0 auto;
    width: 30px;
    height: 28px;
    min-height: 28px;
    display: inline-grid;
    place-items: center;
    padding: 0;
    background: #fff;
    color: var(--accent-dark);
    border-color: var(--line-strong);
    font-size: 12px;
}

.icon-copy,
.icon-lock,
.icon-unlock,
.icon-view {
    position: relative;
    display: inline-block;
}

.icon-view {
    width: 16px;
    height: 10px;
    border: 1.7px solid currentColor;
    border-radius: 50%;
}

.icon-view::after {
    content: "";
    position: absolute;
    width: 4px;
    height: 4px;
    left: 4.3px;
    top: 1.3px;
    border: 1.5px solid currentColor;
    border-radius: 50%;
    background: currentColor;
}

.icon-copy {
    width: 12px;
    height: 14px;
    border: 1.7px solid currentColor;
    border-radius: 2px;
}

.icon-copy::before {
    content: "";
    position: absolute;
    width: 12px;
    height: 14px;
    left: -5px;
    top: 4px;
    border: 1.7px solid currentColor;
    border-radius: 2px;
    background: #fff;
    z-index: -1;
}

.icon-lock {
    width: 14px;
    height: 10px;
    border: 1.7px solid currentColor;
    border-radius: 2px;
    margin-top: 6px;
}

.icon-lock::before {
    content: "";
    position: absolute;
    width: 8px;
    height: 8px;
    left: 1.3px;
    top: -8px;
    border: 1.7px solid currentColor;
    border-bottom: 0;
    border-radius: 8px 8px 0 0;
}

.decrypt-button.decrypted .icon-lock {
    width: 14px;
    height: 10px;
    border: 1.7px solid currentColor;
    border-radius: 2px;
    margin-top: 6px;
}

.decrypt-button.decrypted .icon-lock::before {
    width: 8px;
    height: 8px;
    left: 7px;
    top: -8px;
    border: 1.7px solid currentColor;
    border-bottom: 0;
    border-left-color: transparent;
    border-radius: 8px 8px 0 0;
}

button:disabled {
    cursor: default;
    opacity: .55;
}

button:disabled:hover {
    background: var(--accent);
}

.secondary-button:disabled:hover {
    background: #fff;
    color: var(--accent-dark);
    border-color: var(--line-strong);
}

.message-preview {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    user-select: text;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

.load-message-button {
    min-height: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--accent-dark);
    text-align: left;
    font-weight: 700;
}

.load-message-button:hover,
.load-message-button:disabled:hover {
    background: transparent;
    color: var(--accent);
    text-decoration: underline;
}

.load-message-button:disabled {
    opacity: .75;
}

.decrypt-result {
    margin: 0;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    user-select: text;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
    line-height: 1.45;
}

.full-message-dialog {
    width: min(900px, calc(100vw - 32px));
}

.full-message-dialog .decrypt-result {
    min-height: 180px;
    max-height: min(60vh, 560px);
}

.status-pill {
    display: inline-block;
    min-width: 42px;
    text-align: center;
    padding: 2px 7px;
    border-radius: 999px;
    background: var(--bg);
    color: var(--muted);
}

.status-pill.ok {
    background: var(--ok-soft);
    color: var(--ok);
}

.status-pill.fail {
    background: var(--fail-soft);
    color: var(--fail);
}

.empty {
    color: var(--muted);
    text-align: center;
    padding: 36px;
}

.pager {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 18px;
}

.chart-panel {
    position: relative;
    width: 100%;
    margin-bottom: 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    padding: 12px 8px 8px;
}

.chart-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    padding: 4px 12px 0;
}

.chart-heading h1 {
    margin: 0;
    font-size: 19px;
    line-height: 1.25;
}

.chart-heading p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 12px;
}

.chart-heading-side {
    display: grid;
    justify-items: end;
    gap: 8px;
}

.compact-button {
    min-height: 30px;
    padding: 4px 9px;
    font-size: 11px;
}

.chart-options {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 8px 0 0;
    border: 0;
    padding: 0;
}

.chart-options legend {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
}

.chart-options label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--muted);
    cursor: pointer;
    font-size: 11px;
    font-weight: 700;
}

.chart-options label.disabled {
    cursor: default;
    opacity: .5;
}

.chart-options input {
    margin: 0;
}

.chart-options[hidden],
#statsChart[hidden],
.stats-summary[hidden],
#statsCopyChart[hidden] {
    display: none;
}

.chart-view-options > span {
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
}

#statsChart,
.stats-platform-chart,
#distinctUserChart {
    display: block;
    width: 100%;
    height: clamp(440px, 52vh, 760px);
}

.chart-selection-message {
    margin: 18px 14px 0;
    border: 1px dashed var(--line);
    border-radius: 6px;
    color: var(--muted);
    padding: 14px;
    text-align: center;
    font-size: 13px;
}

.distinct-user-filter-row {
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
}

.distinct-user-window-options {
    flex-wrap: wrap;
}

.distinct-user-window-options > span,
.chart-options > span {
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
}

.distinct-user-details {
    max-width: none;
}

.stats-platform-charts {
    display: grid;
    gap: 18px;
}

.stats-platform-charts[hidden] {
    display: none;
}

.stats-platform-card {
    margin-bottom: 0;
}

.stats-platform-card .chart-heading h2 {
    margin: 0;
    font-size: 18px;
    line-height: 1.25;
}

.stats-platform-share {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.stats-filters {
    gap: 8px;
    padding: 12px;
}

.saved-search-toolbar {
    display: flex;
    align-items: end;
    gap: 8px;
    margin-bottom: 10px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
}

.saved-search-toolbar label {
    display: grid;
    min-width: min(320px, 100%);
    gap: 5px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.saved-search-toolbar select {
    width: 100%;
    min-height: 36px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    color: var(--text);
    padding: 6px 8px;
    font: inherit;
}

.saved-search-status {
    align-self: center;
    margin-left: auto;
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
}

.stats-filters .filter-row {
    gap: 8px;
    grid-template-columns: repeat(auto-fit, minmax(126px, 1fr));
}

.stats-filters .stats-time-row {
    grid-template-columns: minmax(150px, .7fr) minmax(320px, 1.8fr) minmax(120px, .6fr);
}

.stats-range-fields {
    min-height: 36px;
    align-items: end;
}

.stats-range-fields[hidden] {
    display: none;
}

.stats-range-all {
    display: flex;
    align-items: center;
    border: 1px dashed var(--line);
    border-radius: 6px;
    color: var(--muted);
    padding: 6px 10px;
    font-size: 12px;
}

.stats-range-rolling {
    display: grid;
    grid-template-columns: minmax(90px, .45fr) minmax(130px, 1fr);
    gap: 8px;
}

.stats-range-calendar,
.stats-range-custom {
    display: grid;
    grid-template-columns: repeat(2, minmax(150px, 1fr));
    gap: 8px;
}

.stats-filter-actions {
    display: flex;
    align-items: end;
    gap: 8px;
}

.stats-filter-actions > * {
    flex: 1 1 auto;
    justify-content: center;
}

.stats-data-details {
    display: grid;
    gap: 12px;
    max-width: 760px;
}

.stats-data-details-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.stats-data-details-heading h2 {
    margin: 0;
    font-size: 22px;
}

.stats-detail-name {
    min-width: 0;
    overflow-wrap: anywhere;
}

.stats-details {
    max-width: 760px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
}

.stats-details summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 14px;
    color: var(--accent-dark);
    cursor: pointer;
    font-size: 13px;
    font-weight: 750;
}

.stats-details[open] summary {
    border-bottom: 1px solid var(--line);
}

.stats-details .table-shell {
    border: 0;
    border-radius: 0 0 8px 8px;
}

.stats-detail-count {
    color: var(--muted);
    font-weight: 600;
}

.stats-details-summary-actions {
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    gap: 10px;
}

.stats-summary {
    display: grid;
    gap: 4px;
    color: var(--muted);
    font-size: 11px;
}

.stats-summary-series {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 4px 10px;
}

.stats-summary-series strong {
    color: var(--series-color);
}

.stats-summary-rate {
    color: var(--muted);
    text-align: right;
}

.stats-summary-platforms {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 4px 10px;
    color: var(--muted);
    text-align: right;
}

.stats-summary-platforms strong {
    color: var(--ink);
}

.stats-summary-rate strong {
    color: var(--fail);
    font-size: 13px;
}

.chart-point {
    outline: none;
}

.stats-chart-interaction {
    cursor: crosshair;
    touch-action: pan-y;
}

.chart-zoom-controls {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    padding: 4px 0;
    font-size: 11px;
    color: var(--muted);
}

.chart-zoom-controls[hidden] {
    display: none;
}

.chart-zoom-controls button {
    min-height: 24px;
    padding: 3px 7px;
    font-size: 11px;
    line-height: 1.25;
}

.chart-zoom-status {
    font-variant-numeric: tabular-nums;
}

.chart-zoom-selection {
    fill: #2369a0;
    fill-opacity: .15;
    stroke: #2369a0;
    stroke-width: 1;
    pointer-events: none;
}

.stats-chart-guide {
    opacity: .85;
}

.chart-point:hover,
.chart-point:focus {
    stroke: var(--text);
    stroke-width: 3;
}

.chart-event-marker {
    vector-effect: non-scaling-stroke;
}

.chart-event-hit-area:focus {
    outline: none;
}

.chart-event-description {
    color: #fff !important;
    font-weight: 700;
}

.chart-tooltip {
    position: absolute;
    z-index: 5;
    display: grid;
    min-width: min(290px, calc(100vw - 48px));
    gap: 3px;
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    background: rgb(0 0 0 / 94%);
    color: #fff;
    padding: 8px 10px;
    box-shadow: 0 8px 22px rgb(35 35 35 / 22%);
    line-height: 1.35;
    pointer-events: none;
    font-size: 12px;
}

.chart-tooltip-group {
    display: grid;
    gap: 1px;
    margin-top: 4px;
    padding-top: 4px;
    border-top: 1px solid rgb(255 255 255 / 20%);
}

.chart-tooltip-group strong {
    display: flex;
    justify-content: space-between;
    gap: 14px;
}

.chart-tooltip-share {
    color: var(--accent-soft);
    font-size: 11px;
    font-weight: 600;
}

.distinct-user-tooltip-row {
    display: flex;
    justify-content: space-between;
    gap: 24px;
}

.distinct-user-tooltip-row:first-of-type {
    margin-top: 4px;
    padding-top: 4px;
    border-top: 1px solid rgb(255 255 255 / 20%);
}

.chart-tooltip small {
    margin-top: 4px;
    color: var(--accent-soft);
}

.chart-tooltip[hidden] {
    display: none;
}

.chart-tooltip span {
    color: var(--accent-soft);
}

.chart-axis,
.chart-legend {
    fill: var(--muted);
    font-family: inherit;
    font-size: 12px;
}

.chart-legend {
    fill: var(--text);
    font-weight: 700;
}

.chart-empty {
    fill: var(--muted);
    font-family: inherit;
    font-size: 16px;
    font-weight: 700;
}

.decrypt-dialog {
    width: min(720px, calc(100vw - 32px));
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0;
}

.decrypt-dialog form {
    display: grid;
    gap: 14px;
    padding: 18px;
}

.decrypt-dialog h2 {
    margin: 0;
}

.decrypt-dialog label {
    display: grid;
    gap: 6px;
    font-weight: 700;
}

.decrypt-dialog input {
    min-height: 38px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 6px 8px;
    font: inherit;
}

.decrypt-result {
    min-height: 92px;
    max-height: 320px;
    overflow: auto;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--bg);
}

.dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.workspace-dialog {
    width: min(520px, calc(100vw - 32px));
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0;
    color: var(--text);
}

.workspace-dialog::backdrop {
    background: rgb(0 0 0 / 45%);
}

.workspace-dialog form {
    display: grid;
    gap: 14px;
    padding: 20px;
}

.workspace-dialog h2,
.dashboard-empty h2 {
    margin: 0;
}

.workspace-dialog p {
    margin: 0;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.45;
}

.workspace-dialog label:not(.workspace-checkbox) {
    display: grid;
    gap: 6px;
    font-weight: 700;
}

.workspace-dialog input[type="text"],
.workspace-dialog select {
    width: 100%;
    min-height: 38px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    color: var(--text);
    padding: 6px 8px;
    font: inherit;
}

.workspace-checkbox {
    display: flex;
    align-items: center;
    gap: 7px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 650;
}

.column-picker-dialog {
    width: min(640px, calc(100vw - 32px));
}

.column-picker-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px 16px;
}

.column-picker-options label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-weight: 600;
}

.column-picker-options label:has(input:disabled) {
    color: var(--muted);
}

.dashboard-page-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 18px;
}

.dashboard-page-heading h1 {
    margin-bottom: 6px;
}

.dashboard-page-heading p:not(.eyebrow) {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
}

.dashboard-page-actions,
.dashboard-card-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 7px;
}

.workspace-message {
    min-height: 20px;
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 12px;
}

.dashboard-manager {
    display: flex;
    align-items: end;
    gap: 8px;
    margin-bottom: 10px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
}

.dashboard-manager label {
    display: grid;
    min-width: min(320px, 100%);
    gap: 5px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.dashboard-manager select {
    width: 100%;
    min-height: 36px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    color: var(--text);
    padding: 6px 8px;
    font: inherit;
}

.dashboard-manager > span {
    align-self: center;
    margin-left: auto;
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.dashboard-grid[hidden] {
    display: none;
}

.dashboard-card {
    position: relative;
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    padding: 12px 8px 8px;
    box-shadow: 0 3px 12px rgb(35 35 35 / 5%);
}

.dashboard-card-full {
    grid-column: 1 / -1;
}

.dashboard-card.dragging {
    opacity: .5;
}

.dashboard-card-error {
    border-color: var(--fail);
}

.dashboard-card-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    padding: 4px 10px 0;
}

.dashboard-card-heading h2 {
    margin: 0;
    font-size: 21px;
    line-height: 1.2;
}

.dashboard-card-heading p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 11px;
    line-height: 1.4;
}

.dashboard-move-handle {
    width: 32px;
    min-width: 32px;
    padding: 0;
    cursor: grab;
    font-family: inherit;
    font-size: 19px;
    line-height: 1;
    user-select: none;
}

.dashboard-move-handle:active {
    cursor: grabbing;
}

.dashboard-card.dashboard-drop-target {
    border-color: var(--text);
    box-shadow: 0 0 0 2px rgb(35 35 35 / 12%);
}

.dashboard-chart-options {
    padding: 0 10px;
}

.dashboard-card-meta {
    padding: 5px 10px 0;
    color: var(--muted);
    font-size: 11px;
}

.dashboard-card-summary {
    min-height: 34px;
    padding: 5px 10px 0;
}

.dashboard-card-summary .stats-summary-series,
.dashboard-card-summary .stats-summary-platforms {
    justify-content: flex-start;
    text-align: left;
}

.dashboard-card-summary .stats-summary-rate {
    text-align: left;
}

.dashboard-chart-shell {
    position: relative;
}

.dashboard-chart {
    display: block;
    width: 100%;
    height: clamp(310px, 38vh, 480px);
}

.dashboard-card .stats-platform-chart {
    height: clamp(300px, 35vh, 440px);
}

.dashboard-platform-charts {
    padding-top: 12px;
}

.dashboard-platform-charts .stats-platform-card {
    box-shadow: none;
}

.dashboard-empty {
    display: grid;
    justify-items: center;
    gap: 12px;
    min-height: 300px;
    place-content: center;
    border: 1px dashed var(--line-strong);
    border-radius: 8px;
    background: var(--panel);
    color: var(--muted);
    padding: 32px;
    text-align: center;
}

.dashboard-empty[hidden] {
    display: none;
}

.dashboard-empty p {
    max-width: 560px;
    margin: 0;
    line-height: 1.5;
}

@media (max-width: 1040px) {
    .saved-search-toolbar,
    .dashboard-manager {
        flex-wrap: wrap;
    }

    .saved-search-status,
    .dashboard-manager > span {
        width: 100%;
        margin-left: 0;
    }

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

    .dashboard-card-full {
        grid-column: auto;
    }
}

@media (max-width: 720px) {
    .home-actions {
        grid-template-columns: 1fr;
    }

    .topbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .brand-link {
        gap: 10px;
    }

    .brand-logo {
        width: 120px;
    }

    .brand-context {
        padding-left: 10px;
        font-size: 15px;
    }

    .page {
        padding: 14px;
    }

    .saved-search-toolbar {
        align-items: stretch;
    }

    .saved-search-toolbar label,
    .saved-search-toolbar button,
    .dashboard-manager label,
    .dashboard-manager button {
        flex: 1 1 100%;
    }

    .dashboard-manager {
        align-items: stretch;
    }

    .dashboard-page-heading,
    .dashboard-card-heading {
        align-items: stretch;
        flex-direction: column;
    }

    .dashboard-page-actions,
    .dashboard-card-actions {
        justify-content: flex-start;
    }

    .stats-filters .stats-time-row {
        grid-template-columns: 1fr;
    }

    .chart-heading {
        display: grid;
    }

    .chart-heading-side {
        justify-items: start;
    }

    .stats-summary-series,
    .stats-summary-platforms {
        justify-content: flex-start;
        text-align: left;
    }

    .stats-summary-rate {
        text-align: left;
    }

    #statsChart,
    .stats-platform-chart,
    #distinctUserChart {
        height: 380px;
    }
}

@media (max-width: 520px) {
    .stats-range-rolling,
    .stats-range-calendar,
    .stats-range-custom {
        grid-template-columns: 1fr;
    }
}

/* Raw audit controls and page-scroll header; other tables keep their existing behavior. */
.filter-row.audit-date-row {
    grid-template-columns: repeat(2, minmax(220px, 1fr)) minmax(240px, 280px) minmax(180px, 240px);
}
.audit-timezone-control { display: grid; gap: 5px; min-width: 0; }
@media (max-width: 1100px) {
    .filter-row.audit-date-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 600px) {
    .filter-row.audit-date-row { grid-template-columns: minmax(0, 1fr); }
}
.audit-sticky-header {
    position: fixed;
    z-index: 9;
    overflow: hidden;
    background: var(--accent-soft);
    box-shadow: 0 2px 3px rgb(0 0 0 / 12%);
}
.audit-sticky-header .audit-table { table-layout: fixed; }
.audit-sticky-header th { position: static; box-sizing: border-box; }

/* Independent searches share the date controls above them. */
.stats-series-toolbar {
    display: flex;
    align-items: end;
    flex-wrap: wrap;
    gap: 12px;
    margin: 12px 0;
}
.stats-series-toolbar > span,
.stats-series-lookup-status {
    font-size: .85rem;
    color: #655f58;
}
.stats-series-group {
    border: 1px solid #d8d0c4;
    border-radius: 8px;
    padding: 12px;
    margin: 12px 0;
}
.stats-series-group summary {
    cursor: pointer;
    overflow-wrap: anywhere;
}
#statsVisibleSeries {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
}
#statsVisibleSeries label {
    color: var(--series-color);
}
#statsComparisonNotice {
    font-size: .85rem;
    color: #655f58;
}
.stats-series-group .stats-dimension-row {
    flex-wrap: wrap;
}

.stats-difference-controls {
    margin-top: 10px;
    flex-wrap: wrap;
}
.stats-difference-pair {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    min-width: 0;
    max-width: 100%;
}
.stats-difference-pair label {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    max-width: 100%;
}
.stats-difference-pair select {
    min-width: 0;
    max-width: min(260px, 65vw);
    padding: 4px 8px;
    border: 1px solid var(--line);
    border-radius: 5px;
    background: var(--panel);
    color: var(--text);
    font: inherit;
}
.stats-difference-panel {
    position: relative;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
    min-width: 0;
}
.stats-difference-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
}
.stats-difference-heading h3 {
    margin: 0;
    font-size: 19px;
    overflow-wrap: anywhere;
    min-width: 0;
}
.stats-difference-panel > p {
    color: var(--muted);
    font-size: 12px;
    margin: 6px 0;
}
.stats-difference-chart {
    display: block;
    width: 100%;
    height: 240px;
}
.stats-difference-chart:focus-visible {
    outline: 2px solid #2369a0;
    outline-offset: 2px;
}

.stats-difference-tooltip {
    max-width: min(400px, calc(100vw - 48px));
    overflow-wrap: anywhere;
}

.viewer-account { display: flex; align-items: center; gap: .75rem; font-size: .85rem; flex-shrink: 0; }
.viewer-account button { white-space: nowrap; }
.viewer-account > span { max-width: 10rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer-account form { margin: 0; }
.viewer-session-notice { position: fixed; z-index: 10000; inset: 0; display: grid; place-items: center; background: #fff; padding: 2rem; }
