:root {
    /* Sizes only. Colours are tokens in theme.css (light and dark); never write a colour here. */
    --ml-sidebar-width: 15rem;
    --ml-sidebar-collapsed-width: 4.25rem;
    --ml-topbar-height: 3.5rem;

    /* Montserrat matches the logo wordmark; Bootstrap components read the --bs-* variables. */
    --font-sans: "Montserrat", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    --bs-font-sans-serif: var(--font-sans);
    --bs-body-font-family: var(--font-sans);
}

html, body {
    font-family: var(--font-sans);
    font-weight: 400;
    color: var(--ml-text);
    background: var(--ml-bg);
}

input, button, select, textarea {
    font: inherit;
}

/* Heading weights follow the logo: page titles 700, section headings 600. */
:is(h2, h3, h4, .h2, .h3, .h4, .h5, .h6) {
    font-weight: 600;
}

:is(h1, .h1) {
    font-weight: 700;
}

.btn {
    --bs-btn-font-weight: 500;
}

.form-label, .form-check-label {
    font-weight: 500;
}

a, .btn-link {
    color: var(--ml-link);
}

.btn-primary {
    --bs-btn-color: var(--ml-on-primary);
    --bs-btn-bg: var(--ml-primary);
    --bs-btn-border-color: var(--ml-primary);
    --bs-btn-hover-color: var(--ml-on-primary);
    --bs-btn-hover-bg: var(--ml-primary-strong);
    --bs-btn-hover-border-color: var(--ml-primary-strong);
    --bs-btn-active-color: var(--ml-on-primary);
    --bs-btn-active-bg: var(--ml-primary-strong);
    --bs-btn-active-border-color: var(--ml-primary-strong);
    --bs-btn-disabled-color: var(--ml-on-primary);
    --bs-btn-disabled-bg: var(--ml-primary);
    --bs-btn-disabled-border-color: var(--ml-primary);
}

/* Bootstrap's default outline colours fall below 4.5:1 on dark surfaces; use the theme's text tokens. */
.btn-outline-primary {
    --bs-btn-color: var(--ml-link);
    --bs-btn-border-color: var(--ml-link);
    --bs-btn-hover-color: var(--ml-on-primary);
    --bs-btn-hover-bg: var(--ml-primary);
    --bs-btn-hover-border-color: var(--ml-primary);
    --bs-btn-active-color: var(--ml-on-primary);
    --bs-btn-active-bg: var(--ml-primary-strong);
    --bs-btn-active-border-color: var(--ml-primary-strong);
    --bs-btn-disabled-color: var(--ml-link);
    --bs-btn-disabled-border-color: var(--ml-link);
}

.btn-outline-secondary {
    --bs-btn-color: var(--ml-text-muted);
    --bs-btn-border-color: var(--ml-border-strong);
    --bs-btn-hover-color: var(--ml-text);
    --bs-btn-hover-bg: var(--ml-surface-2);
    --bs-btn-hover-border-color: var(--ml-border-strong);
    --bs-btn-active-color: var(--ml-on-pressed);
    --bs-btn-active-bg: var(--ml-pressed);
    --bs-btn-active-border-color: var(--ml-pressed);
    --bs-btn-disabled-color: var(--ml-text-muted);
    --bs-btn-disabled-border-color: var(--ml-border);
}

.btn-secondary {
    --bs-btn-color: var(--ml-on-pressed);
    --bs-btn-bg: var(--ml-pressed);
    --bs-btn-border-color: var(--ml-pressed);
    --bs-btn-hover-color: var(--ml-on-pressed);
    --bs-btn-hover-bg: var(--ml-pressed);
    --bs-btn-hover-border-color: var(--ml-pressed);
}

.btn-outline-danger {
    --bs-btn-color: var(--ml-danger-text);
    --bs-btn-border-color: var(--ml-danger-text);
    --bs-btn-hover-color: var(--ml-on-danger);
    --bs-btn-hover-bg: var(--ml-danger-solid);
    --bs-btn-hover-border-color: var(--ml-danger-solid);
    --bs-btn-active-color: var(--ml-on-danger);
    --bs-btn-active-bg: var(--ml-danger-solid);
    --bs-btn-active-border-color: var(--ml-danger-solid);
    --bs-btn-disabled-color: var(--ml-danger-text);
    --bs-btn-disabled-border-color: var(--ml-danger-text);
}

.btn-danger {
    --bs-btn-color: var(--ml-on-danger);
    --bs-btn-bg: var(--ml-danger-solid);
    --bs-btn-border-color: var(--ml-danger-solid);
    --bs-btn-hover-color: var(--ml-on-danger);
    --bs-btn-hover-bg: var(--ml-danger-solid);
    --bs-btn-hover-border-color: var(--ml-danger-solid);
}

/* Bootstrap's text utilities use fixed colours; these keep AA contrast in both themes. */
.text-secondary, .text-muted, .text-body-secondary { color: var(--ml-text-muted) !important; }
.text-danger { color: var(--ml-danger-text) !important; }
.text-success { color: var(--ml-success-text) !important; }
.text-info { color: var(--ml-info-text) !important; }

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem var(--ml-surface), 0 0 0 0.25rem var(--ml-focus);
}

h1:focus {
    outline: none;
}

/* Keyboard focus on links and toggles (buttons and fields have Bootstrap's ring above). tabindex="-1"
   marks focus set by code, such as the page heading after navigation, which needs no ring. */
:is(a, summary, [tabindex]):not(.btn, [tabindex="-1"]):focus-visible {
    outline: 2px solid var(--ml-focus);
    outline-offset: 2px;
    border-radius: 0.25rem;
}

summary {
    cursor: pointer;
}

/* Hover feedback eases in instead of snapping. */
.notification-bell,
.location-chip,
.location-tab,
.filter-chip-remove,
.sort-link {
    transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid var(--ml-success-text);
}

.invalid {
    outline: 1px solid var(--ml-danger-text);
}

.validation-message {
    color: var(--ml-danger-text);
}

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, var(--ml-danger-solid);
    padding: 1rem 1rem 1rem 3.7rem;
    color: var(--ml-on-danger);
}

    .blazor-error-boundary::after {
        content: "An error has occurred."
    }

.darker-border-checkbox.form-check-input {
    border-color: var(--ml-border-strong);
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
    color: var(--bs-secondary-color);
    text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
    text-align: start;
}
/* ---------- Page building blocks ---------- */
.page-header {
    margin-bottom: 1.5rem;
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.page-subtitle {
    color: var(--ml-text-muted);
    margin: 0;
}

.empty-state {
    background: var(--ml-surface);
    border: 1px dashed var(--ml-border);
    border-radius: 0.75rem;
    padding: 2rem;
    max-width: 44rem;
    color: var(--ml-text-muted);
}

.empty-state :is(h1, h2) {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--ml-text);
}

/* ---------- Account settings (Account/Manage): side navigation and the page in a panel ---------- */
.manage-layout {
    display: grid;
    grid-template-columns: 13rem minmax(0, 1fr);
    gap: 1rem;
    align-items: start;
}

.manage-nav {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.manage-nav-link {
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
    color: var(--ml-text-muted);
    text-decoration: none;
    transition: background-color 0.15s, color 0.15s;
}

.manage-nav-link:hover {
    background: var(--ml-surface-2);
    color: var(--ml-text);
}

/* The current page is bold and marked with a bar, not only tinted. */
.manage-nav-link.active {
    background: var(--ml-accent-soft);
    color: var(--ml-accent-soft-text);
    font-weight: 600;
    box-shadow: inset 3px 0 0 var(--ml-primary);
}

.manage-body {
    min-width: 0;
    margin-bottom: 0;
}

.manage-body h3 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
}

.manage-body h4 {
    font-size: 1rem;
    margin-top: 1.25rem;
}

@media (max-width: 767.98px) {
    .manage-layout {
        grid-template-columns: minmax(0, 1fr);
    }

    .manage-nav {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .manage-nav-link.active {
        box-shadow: inset 0 -2px 0 var(--ml-primary);
    }
}

/* Phones: slightly tighter cards so content keeps its width. */
@media (max-width: 575.98px) {
    .panel,
    .empty-state {
        padding: 1rem;
    }
}

/* ---------- Blazor error UI ---------- */
#blazor-error-ui {
    background: var(--ml-error-ui-bg);
    color: var(--ml-error-ui-text);
    bottom: 0;
    box-shadow: 0 -1px 2px var(--ml-shadow);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

/* ---------- Panels, details, badges ---------- */
.panel {
    background: var(--ml-surface);
    border: 1px solid var(--ml-border);
    border-radius: 0.75rem;
    padding: 1.25rem;
    margin-bottom: 1rem;
    box-shadow: 0 1px 2px var(--ml-shadow);
}

.panel .table {
    --bs-table-bg: transparent;
}

.details {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 0.35rem 1.25rem;
    margin-bottom: 1rem;
}

.details dt {
    font-weight: 500;
    color: var(--ml-text-muted);
}

.details dd {
    margin: 0;
}

.status-badge {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    border: 1px solid transparent;
    white-space: nowrap;
}

.status-ok { background: var(--ml-ok-bg); color: var(--ml-ok-text); border-color: var(--ml-ok-border); }
.status-warn { background: var(--ml-warn-bg); color: var(--ml-warn-text); border-color: var(--ml-warn-border); }
.status-bad { background: var(--ml-bad-bg); color: var(--ml-bad-text); border-color: var(--ml-bad-border); }
.status-neutral { background: var(--ml-neutral-bg); color: var(--ml-neutral-text); border-color: var(--ml-neutral-border); }

/* Private (this portal only) vs shared (visible to participating portals): a text label, never colour alone. */
.scope-badge {
    display: inline-block;
    font-size: 0.68rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    padding: 0.05rem 0.45rem;
    border-radius: 999px;
    border: 1px solid transparent;
    vertical-align: middle;
    white-space: nowrap;
}
.scope-private { background: var(--ml-private-bg); color: var(--ml-private-text); border-color: var(--ml-private-border); }
.scope-shared { background: var(--ml-accent-soft); color: var(--ml-accent-soft-text); border-color: var(--ml-border-strong); }

.role-badge {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    background: var(--ml-accent-soft);
    color: var(--ml-accent-soft-text);
    white-space: nowrap;
}

.audit-meta code {
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 0.75rem;
    color: var(--ml-text-muted);
}

/* ---------- Top-bar portal selector ---------- */
.portal-form {
    display: flex;
    gap: 0.5rem;
    max-width: 22rem;
}

.portal-current {
    display: inline-flex;
    align-items: baseline;
    gap: 0.5rem;
    min-width: 0;
}

.portal-name {
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.portal-role,
.portal-none {
    font-size: 0.8rem;
    color: var(--ml-text-muted);
}

@media (max-width: 575.98px) {
    .portal-form { max-width: 10rem; }
    .portal-role { display: none; }
}

/* ---------- Analytics ---------- */

/* Filter toolbar: period card (left) and the page's filters (right); one column on narrow screens. */
.filter-toolbar {
    display: grid;
    grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.filter-toolbar-single {
    grid-template-columns: minmax(0, 1fr);
}

@media (max-width: 991.98px) {
    .filter-toolbar {
        grid-template-columns: minmax(0, 1fr);
    }
}

.filter-card {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-width: 0;
    margin: 0;
    padding: 1rem 1.125rem;
    background: var(--ml-surface);
    border: 1px solid var(--ml-border);
    border-radius: 0.75rem;
    box-shadow: 0 1px 2px var(--ml-shadow);
}

.filter-card-title {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin: 0;
    padding: 0;
    font-size: 0.7rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--ml-text-muted);
}

.filter-icon {
    width: 0.95rem;
    height: 0.95rem;
    flex-shrink: 0;
    fill: currentColor;
}

/* Preset and toggle chips: real radio/checkbox inputs (Bootstrap .btn-check) with a pill label. */
.period-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
}

.period-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.3rem 0.75rem;
    font-size: 0.8rem;
    font-weight: 500;
    line-height: 1.2;
    color: var(--ml-text);
    background: var(--ml-surface);
    border: 1px solid var(--ml-border-strong);
    border-radius: 999px;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.15s, border-color 0.15s;
}

.period-chip:hover {
    background: var(--ml-surface-2);
}

/* The tick keeps the selection visible without relying on colour. */
.btn-check:checked + .period-chip {
    color: var(--ml-on-primary);
    background: var(--ml-primary);
    border-color: var(--ml-primary);
}

.btn-check:checked + .period-chip::before {
    content: "✓";
    font-weight: 700;
}

.btn-check:focus-visible + .period-chip {
    outline: 2px solid var(--ml-focus);
    outline-offset: 2px;
}

.period-custom {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
}

/* The custom range only matters for the Custom preset. */
.period-card:not(:has(#period-Custom:checked)) .period-custom {
    display: none;
}

.period-summary {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem 0.75rem;
    margin-top: auto;
    padding-top: 0.625rem;
    border-top: 1px solid var(--ml-border);
    font-size: 0.8rem;
}

.period-summary .filter-actions {
    margin: 0 0 0 auto;
}

.period-range {
    font-weight: 600;
}

.period-meta {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    color: var(--ml-text-muted);
}

.filter-fields {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
    gap: 0.75rem;
}

.filter-field {
    min-width: 0;
    margin: 0;
}

.filter-field-wide,
.filter-field-full {
    grid-column: 1 / -1;
}

.input-icon {
    position: relative;
}

.input-icon .filter-icon {
    position: absolute;
    top: 50%;
    left: 0.6rem;
    transform: translateY(-50%);
    color: var(--ml-text-muted);
    pointer-events: none;
}

.input-icon .form-control {
    padding-left: 2rem;
}

/* Compare: search over the portals outside the top 10. */
.portal-search-input { max-width: 20rem; }

.filter-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: auto;
}

/* Applied filters as removable chips. */
.active-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.375rem 0.5rem;
    margin-bottom: 0.75rem;
    font-size: 0.8rem;
}

.active-filters-label {
    color: var(--ml-text-muted);
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.15rem 0.25rem 0.15rem 0.65rem;
    color: var(--ml-accent-soft-text);
    background: var(--ml-accent-soft);
    border: 1px solid var(--ml-border-strong);
    border-radius: 999px;
}

.filter-chip-name {
    font-weight: 600;
}

.filter-chip-remove {
    display: inline-grid;
    place-items: center;
    width: 1.25rem;
    height: 1.25rem;
    border-radius: 999px;
    color: inherit;
    font-weight: 700;
    text-decoration: none;
}

.filter-chip-remove:hover,
.filter-chip-remove:focus-visible {
    background: var(--ml-surface);
}

.active-filters-clear {
    font-weight: 500;
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
    gap: 0.75rem;
}

.kpi-card {
    background: var(--ml-surface);
    border: 1px solid var(--ml-border);
    border-radius: 0.75rem;
    padding: 1rem;
    box-shadow: 0 1px 2px var(--ml-shadow);
}

.kpi-label {
    font-size: 0.8rem;
    color: var(--ml-text-muted);
    margin-bottom: 0.25rem;
}

.kpi-value {
    font-size: 1.5rem;
    font-weight: 600;
    line-height: 1.2;
    margin-bottom: 0.25rem;
}

.growth { font-size: 0.8rem; font-weight: 600; white-space: nowrap; }
.growth-up { color: var(--ml-up); }
.growth-down { color: var(--ml-down); }
.growth-flat { color: var(--ml-flat); }
.growth-none { color: var(--ml-none); font-weight: 400; }

.incomplete {
    display: inline-block;
    font-size: 0.72rem;
    color: var(--ml-warn-text);
    background: var(--ml-warn-bg);
    border: 1px solid var(--ml-warn-border);
    border-radius: 999px;
    padding: 0 0.45rem;
    margin-left: 0.25rem;
    white-space: nowrap;
}

.demo-badge {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--ml-demo-text);
    background: var(--ml-demo-bg);
    border: 1px solid var(--ml-demo-border);
    border-radius: 0.25rem;
    padding: 0 0.3rem;
    margin-left: 0.35rem;
    vertical-align: middle;
}

.data-status-stale { border-color: var(--ml-bad-border); background: var(--ml-stale-bg); }

/* ---------- Line chart (LineChart: shared by the trend and comparison charts) ----------
   Lines are a stretched SVG; numbers, dates, markers and tooltips are HTML positioned in % so the
   text keeps its size at any width. Hover or tap a day for its exact values. */
.series-current { --series: var(--ml-chart-current); }
.series-previous { --series: var(--ml-chart-previous); }
.line-chart { --chart-axis: 3.25rem; font-size: 0.72rem; color: var(--ml-text-muted); font-variant-numeric: tabular-nums; }
.line-chart .chart-body { position: relative; height: var(--chart-height); margin: 1.25rem 0 0 var(--chart-axis); }
.line-chart .chart-y-axis span {
    position: absolute;
    left: calc(-1 * var(--chart-axis));
    width: calc(var(--chart-axis) - 0.5rem);
    text-align: right;
    line-height: 1;
    transform: translateY(-50%);
}
.line-chart .chart-plot { position: absolute; inset: 0; }
.line-chart .chart-grid { position: absolute; left: 0; right: 0; border-top: 1px solid var(--ml-chart-grid); }
.line-chart .chart-baseline { border-top-color: var(--ml-border-strong); }
.line-chart svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.line-chart .chart-line {
    fill: none;
    stroke: var(--series);
    stroke-width: 2.5;
    stroke-linejoin: round;
    stroke-linecap: round;
    vector-effect: non-scaling-stroke;
}
.line-chart .chart-line-dashed { stroke-width: 1.5; stroke-dasharray: 5 4; }
.line-chart .chart-marker {
    position: absolute;
    width: 9px;
    height: 9px;
    background: var(--series);
    transform: translate(-50%, -50%);
    pointer-events: none;
}
.line-chart .marker-circle { border-radius: 50%; box-shadow: 0 0 0 2px var(--ml-surface); }
.line-chart .marker-square { width: 8px; height: 8px; box-shadow: 0 0 0 2px var(--ml-surface); }
.line-chart .marker-triangle { width: 11px; height: 10px; clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.line-chart .marker-diamond { width: 11px; height: 11px; clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); }
.line-chart .marker-cross {
    width: 10px;
    height: 10px;
    clip-path: polygon(20% 0, 50% 30%, 80% 0, 100% 20%, 70% 50%, 100% 80%, 80% 100%, 50% 70%, 20% 100%, 0 80%, 30% 50%, 0 20%);
}
.line-chart .chart-value {
    position: absolute;
    color: var(--ml-text);
    font-weight: 600;
    white-space: nowrap;
    transform: translate(-50%, calc(-100% - 7px));
    pointer-events: none;
}
.line-chart .chart-band { position: absolute; top: 0; bottom: 0; outline: none; }
.line-chart .chart-guide { position: absolute; top: 0; bottom: 0; border-left: 1px dashed var(--ml-border-strong); display: none; }
.line-chart .chart-tip {
    position: absolute;
    top: 0;
    z-index: 3;
    display: none;
    width: max-content;
    max-width: 17rem;
    margin-left: 10px;
    padding: 0.4rem 0.6rem;
    font-size: 0.78rem;
    color: var(--ml-text);
    background: var(--ml-surface);
    border: 1px solid var(--ml-border-strong);
    border-radius: 0.375rem;
    box-shadow: 0 4px 14px var(--ml-shadow);
    pointer-events: none;
}
.line-chart .chart-tip-start { margin-left: -10px; transform: translateX(-100%); }
.line-chart .chart-band:hover .chart-guide,
.line-chart .chart-band:focus .chart-guide,
.line-chart .chart-band:hover .chart-tip,
.line-chart .chart-band:focus .chart-tip { display: block; }
.line-chart .chart-tip-date { font-weight: 600; margin-bottom: 0.2rem; }
.line-chart .chart-tip-row { display: flex; align-items: baseline; gap: 0.1rem; }
.line-chart .chart-tip-name { flex: 1; }
.line-chart .chart-tip-value { margin-left: 0.9rem; white-space: nowrap; }
.line-chart .chart-x-axis { position: relative; height: 1.5rem; margin-left: var(--chart-axis); }
.line-chart .chart-x-axis span { position: absolute; top: 0.4rem; white-space: nowrap; transform: translateX(-50%); }
.legend { font-size: 0.75rem; margin-left: 0.75rem; }
/* Legend text stays in text colours; the line style (solid / dashed) carries the identity. */
.legend-current { color: var(--ml-text); }
.legend-previous { color: var(--ml-text-muted); }

.live-panel { border-left: 4px solid var(--ml-live); }
.live-dot {
    display: inline-block;
    width: 0.55rem;
    height: 0.55rem;
    border-radius: 50%;
    background: var(--ml-live);
    margin-right: 0.25rem;
}

/* ---------- Comparison chart (categorical slots; light and dark steps validated, see theme.css) ---------- */
.comparison-chart .series-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.comparison-chart .series-marker { stroke: var(--ml-surface); stroke-width: 1.5; }
.comparison-chart path.series-marker { fill: none; stroke-width: 2; }
.comparison-chart .legend { color: var(--ml-text); white-space: nowrap; }
.comparison-chart .legend-swatch { vertical-align: middle; margin-right: 0.15rem; }
.series-0 { --series: var(--ml-series-1); }
.series-1 { --series: var(--ml-series-2); }
.series-2 { --series: var(--ml-series-3); }
.series-3 { --series: var(--ml-series-4); }
.series-4 { --series: var(--ml-series-5); }

/* ---------- Overview: top-cities donut and weekday columns, side by side on wide screens ---------- */
.chart-pair { display: grid; gap: 0 1rem; }
/* minmax(0, 1fr): exactly half each; long article titles are cut with "…" instead of widening a column. */
@media (min-width: 992px) { .chart-pair { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.chart-pair > .panel { min-width: 0; }

.slice-0 { --slice: var(--ml-series-1); }
.slice-1 { --slice: var(--ml-series-2); }
.slice-2 { --slice: var(--ml-series-3); }
.slice-3 { --slice: var(--ml-series-4); }
.slice-4 { --slice: var(--ml-series-5); }
.slice-5 { --slice: var(--ml-series-6); }
.slice-6 { --slice: var(--ml-series-7); }
.slice-7 { --slice: var(--ml-series-8); }
.slice-8 { --slice: var(--ml-series-9); }
.slice-9 { --slice: var(--ml-series-10); }
/* "Other" (city donut): neutral, so it reads as the rest rather than one more city; named in the legend. */
.slice-other { --slice: var(--ml-chart-other); }

.donut-body { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem 1.5rem; }
.donut-graphic { position: relative; width: 11rem; height: 11rem; flex-shrink: 0; }
.donut-graphic svg { width: 100%; height: 100%; }
/* A surface-coloured edge separates neighbouring slices without relying on their colours. */
.donut-slice { fill: var(--slice); stroke: var(--ml-surface); stroke-width: 2; }
.donut-slice:hover { opacity: 0.85; }
.donut-center {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    pointer-events: none;
}
.donut-total { font-size: 1.15rem; font-weight: 700; color: var(--ml-text); font-variant-numeric: tabular-nums; }
.donut-total-label { max-width: 5.5rem; font-size: 0.68rem; line-height: 1.2; color: var(--ml-text-muted); }
.donut-legend { flex: 1; min-width: 12rem; list-style: none; margin: 0; padding: 0; font-size: 0.85rem; }
.donut-legend li { display: flex; align-items: center; gap: 0.5rem; padding: 0.2rem 0; border-bottom: 1px solid var(--ml-border); }
.donut-legend li:last-child { border-bottom: 0; }
.donut-swatch { width: 0.75rem; height: 0.75rem; border-radius: 0.2rem; background: var(--slice); flex-shrink: 0; }
.donut-legend-rank { min-width: 1.4rem; color: var(--ml-text-muted); font-variant-numeric: tabular-nums; }
.donut-legend-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ml-text); text-decoration: none; }
a.donut-legend-name:hover { text-decoration: underline; }
.donut-legend-share { font-weight: 600; color: var(--ml-text); font-variant-numeric: tabular-nums; }
.donut-legend-views { min-width: 4.5rem; text-align: right; color: var(--ml-text-muted); font-variant-numeric: tabular-nums; }

.column-chart { --chart-axis: 3.25rem; --chart-height: 11rem; }
.column-chart-body { position: relative; height: var(--chart-height); margin: 1.25rem 0 0 var(--chart-axis); }
.column-chart-axis { position: absolute; inset: 0; font-size: 0.72rem; color: var(--ml-text-muted); font-variant-numeric: tabular-nums; }
.column-chart-axis span {
    position: absolute;
    left: calc(-1 * var(--chart-axis));
    width: calc(var(--chart-axis) - 0.5rem);
    text-align: right;
    transform: translateY(50%);
}
.column-chart-grid { position: absolute; left: 0; right: 0; border-top: 1px solid var(--ml-chart-grid); }
.column-chart-plot { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(var(--chart-columns, 7), minmax(0, 1fr)); gap: 0.5rem; padding: 0 0.25rem; }
.column-chart-slot { position: relative; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; }
.column-chart-bar {
    width: 100%;
    max-width: 2.75rem;
    min-height: 2px;
    border-radius: 0.375rem 0.375rem 0 0;
    background: var(--ml-chart-current);
}
.column-chart-bar.column-chart-best { box-shadow: inset 0 0 0 2px var(--ml-text); }
.column-chart-value { margin-bottom: 0.2rem; font-size: 0.7rem; font-weight: 600; color: var(--ml-text); white-space: nowrap; font-variant-numeric: tabular-nums; }
/* minmax(0, 1fr) columns: bars and day labels stay aligned on narrow screens; "No data" wraps inside its column. */
.column-chart-missing { margin-bottom: 0.3rem; font-size: 0.68rem; font-style: italic; color: var(--ml-text-muted); text-align: center; overflow-wrap: anywhere; }
.column-chart-labels {
    display: grid;
    grid-template-columns: repeat(var(--chart-columns, 7), minmax(0, 1fr));
    gap: 0.5rem;
    margin-left: var(--chart-axis);
    padding: 0.4rem 0.25rem 0;
    font-size: 0.75rem;
    color: var(--ml-text-muted);
    text-align: center;
}
.series-line[class*="series-"] { stroke: var(--series); }
.series-marker[class*="series-"] { fill: var(--series); }
path.series-marker[class*="series-"] { stroke: var(--series); }
.series-dot {
    display: inline-block;
    width: 0.6rem;
    height: 0.6rem;
    border-radius: 50%;
    background: var(--series);
    margin-right: 0.3rem;
    vertical-align: baseline;
}

.share-bar {
    height: 0.4rem;
    border-radius: 2px;
    background: var(--ml-chart-current);
    min-width: 2px;
}

.classification { font-size: 0.72rem; white-space: nowrap; }

/* Long titles and URLs wrap, but the column keeps a readable width; narrow screens scroll the table instead. */
.article-cell { min-width: 15rem; }

.export-buttons {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.4rem;
    margin: -0.5rem 0 0.75rem;
}

/* ---------- Notifications ---------- */
.notification-bell {
    position: relative;
    display: inline-flex;
    width: 2rem;
    height: 2rem;
    align-items: center;
    justify-content: center;
    color: var(--ml-text-muted);
    border-radius: 0.5rem;
}
.notification-bell:hover { background: var(--ml-accent-soft); color: var(--ml-accent-soft-text); }
.notification-bell svg { width: 1.15rem; height: 1.15rem; fill: currentColor; }
.notification-count {
    position: absolute;
    top: -0.2rem;
    right: -0.35rem;
    min-width: 1.1rem;
    padding: 0 0.25rem;
    font-size: 0.65rem;
    font-weight: 700;
    line-height: 1.1rem;
    text-align: center;
    color: var(--ml-on-danger);
    background: var(--ml-danger-solid);
    border-radius: 999px;
}
.notification-list li { padding: 0.6rem 0; border-bottom: 1px solid var(--ml-border); }
.notification-list li:last-child { border-bottom: 0; }
.notification-list li.is-read { opacity: 0.7; }

/* ---------- Theme switcher and other themed pieces ---------- */
.theme-option {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.45rem;
}
.theme-option svg { width: 1rem; height: 1rem; fill: currentColor; }
/* The chosen option is filled (a shape change, not only a colour change) and has aria-pressed. */
.theme-option[aria-pressed=true] {
    color: var(--ml-on-pressed);
    background: var(--ml-pressed);
    border-color: var(--ml-pressed);
}

/* Several buttons in one table cell (Blazor drops the whitespace between them). */
.row-actions > * + * {
    margin-left: 0.25rem;
}

/* Sync health: the portal column holds the name, property and verification badge. */
.sync-portal-cell {
    min-width: 12rem;
}

.runs-row,
.panel .table .runs-row { --bs-table-bg: var(--ml-surface-2); background: var(--ml-surface-2); }

/* Sortable column headers (SortHeader): the whole label is the link; ▲/▼ show the order in text. */
.sort-link {
    color: inherit;
    text-decoration: none;
    white-space: nowrap;
}
.sort-link:hover,
.sort-link:focus-visible {
    color: var(--ml-link);
    text-decoration: underline;
}
.sort-arrow {
    margin-left: 0.25rem;
    font-size: 0.75em;
}
.sort-arrow-idle {
    color: var(--ml-text-muted);
}
.share-col {
    width: 9rem;
}
button.sort-link {
    padding: 0;
    border: 0;
    background: none;
    font: inherit;
    font-weight: inherit;
    text-align: inherit;
}
.order-col {
    width: 7rem;
}

/* Audience location (Overview): tabs, place chips and the BiH map. */
.location-tabs {
    display: inline-flex;
    gap: 0.25rem;
    border-bottom: 1px solid var(--ml-border);
}
.location-tab {
    padding: 0.25rem 0.75rem;
    color: var(--ml-text-muted);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}
.location-tab[aria-current="page"] {
    color: var(--ml-text);
    font-weight: 600;
    border-bottom-color: var(--ml-primary);
}
.location-filter {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
}
.location-chip {
    padding: 0.1rem 0.6rem;
    border: 1px solid var(--ml-border-strong);
    border-radius: 999px;
    color: var(--ml-text);
    font-size: 0.85rem;
    text-decoration: none;
}
.location-chip:hover {
    background: var(--ml-surface-2);
}
.location-tab:hover {
    color: var(--ml-text);
}
.location-chip[aria-current="page"] {
    background: var(--ml-pressed);
    border-color: var(--ml-pressed);
    color: var(--ml-on-pressed);
}
.audience-map svg {
    display: block;
    width: 100%;
    max-width: 40rem;
    height: auto;
}
.map-entity {
    stroke: var(--ml-map-border);
    stroke-width: 1.5;
}
.map-step-0 { fill: var(--ml-map-none); background: var(--ml-map-none); }
.map-step-1 { fill: var(--ml-map-1); background: var(--ml-map-1); }
.map-step-2 { fill: var(--ml-map-2); background: var(--ml-map-2); }
.map-step-3 { fill: var(--ml-map-3); background: var(--ml-map-3); }
.map-step-4 { fill: var(--ml-map-4); background: var(--ml-map-4); }
.map-step-5 { fill: var(--ml-map-5); background: var(--ml-map-5); }
.map-dim {
    opacity: 0.45;
}
.map-bubble {
    fill: var(--ml-map-bubble);
    fill-opacity: 0.75;
    stroke: var(--ml-map-bubble-border);
    stroke-width: 1;
}
.map-bubble-selected {
    fill-opacity: 0.95;
    stroke-width: 3;
}
.map-label {
    fill: var(--ml-text);
    font-size: 13px;
    font-weight: 600;
    paint-order: stroke;
    stroke: var(--ml-surface);
    stroke-width: 3px;
    stroke-linejoin: round;
}
.map-legend {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem 0.75rem;
    margin: 0.5rem 0;
}
.map-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}
.map-swatch {
    display: inline-block;
    width: 0.9rem;
    height: 0.9rem;
    border: 1px solid var(--ml-border-strong);
    border-radius: 2px;
}
.map-swatch-bubble {
    border-radius: 50%;
    background: var(--ml-map-bubble);
    border-color: var(--ml-map-bubble-border);
}
.map-entities {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 1rem;
}
.world-map svg {
    max-width: 56rem;
}
.world-map .map-entity {
    stroke-width: 0.4;
}
.map-home {
    fill: var(--ml-map-home);
    background: var(--ml-map-home);
}
.map-selected {
    stroke: var(--ml-text);
    stroke-width: 1.5;
}
.world-map .map-selected {
    stroke-width: 1;
}

/* ---------- Compare: share donut, new-articles and category columns, top articles ---------- */
/* Columns in a compared portal's series colour (the same colour as its line and dot). */
.column-chart-bar.series-bar { background: var(--series); }
/* Category chart: one group per category, one thin column per portal inside it. */
.column-chart-group { display: flex; align-items: flex-end; justify-content: center; gap: 2px; height: 100%; }
.column-chart-grouped .column-chart-slot { flex: 1; min-width: 0; }
.column-chart-grouped .column-chart-bar { max-width: 1.25rem; border-radius: 0.2rem 0.2rem 0 0; }
.column-chart-legend { display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; color: var(--ml-text); }
/* Top articles: one block per portal; bars share one scale across portals. */
.top-articles-grid { display: grid; gap: 1rem 1.5rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 16rem), 1fr)); }
.top-articles-portal { min-width: 0; }
.bar-list { list-style: none; margin: 0; padding: 0; font-size: 0.82rem; }
.bar-list li + li { margin-top: 0.5rem; }
.bar-list-text { display: flex; gap: 0.5rem; align-items: baseline; }
.bar-list-text a { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ml-text); }
.bar-list-value { font-weight: 600; color: var(--ml-text); font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar-list-track { display: block; height: 0.4rem; margin-top: 0.2rem; border-radius: 0.2rem; background: var(--ml-chart-grid); }
.bar-list-bar { display: block; height: 100%; min-width: 2px; border-radius: 0.2rem; background: var(--series); }

/* ---------- Privacy policy and terms ---------- */
/* Signed out, the pages sit in the sign-in card: widen it for reading. */
div.auth-card:has(.legal-document) { max-width: 48rem; }
.legal-document { max-width: 48rem; }
.legal-section { margin-bottom: 1.5rem; }
.legal-section p, .legal-section li { color: var(--ml-text); line-height: 1.6; }
.legal-links { margin-top: 2rem; }
.auth-legal { margin-top: 1.5rem; text-align: center; color: var(--ml-text-muted); }
