:root {
    --bg: #eef2ff;
    --surface: rgba(255, 255, 255, 0.9);
    --surface-strong: #ffffff;
    --border: rgba(15, 23, 42, 0.08);
    --text: #0f172a;
    --muted: #64748b;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary: #e2e8f0;
    --success: #059669;
    --danger: #be123c;
    --amber: #d97706;
    --danger-soft: #fee2e2;
    --danger-strong: #991b1b;
    --overlay: rgba(0, 0, 0, 0.45);
    --surface-muted: #f3f4f6;
    --border-muted: #e5e7eb;
    --border-subtle: #eef0f2;
    --border-strong: rgba(148, 163, 184, 0.45);
    --shadow-dialog: 0 8px 32px rgba(0, 0, 0, 0.18);
    --z-modal: 999;
    --shadow: 0 28px 60px rgba(15, 23, 42, 0.14);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(37, 99, 235, 0.16), transparent 28%),
        radial-gradient(circle at bottom right, rgba(5, 150, 105, 0.14), transparent 24%),
        linear-gradient(180deg, #f8fafc 0%, #eef2ff 100%);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

code {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: rgba(15, 23, 42, 0.06);
    border-radius: 6px;
    padding: 0.1rem 0.35rem;
}

a {
    color: inherit;
    text-decoration: none;
}

.shell {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    min-height: 100vh;
    transition: grid-template-columns 220ms ease;
}

.sidebar {
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
    padding: 1.25rem;
    background: linear-gradient(180deg, #163B5C 0%, #176F73 100%);
    color: white;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    transition: left 240ms ease;
}

.brand,
.card-head {
    display: flex;
    align-items: center;
    gap: 0.9rem;
}

.brand-mark {
    width: 2.7rem;
    height: 2.7rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.9rem;
    background: #ffffff;
    overflow: hidden;
    flex-shrink: 0;
}

.brand-title,
.page-header h1,
.panel-head h2,
.stat-card strong,
.login-hero h1 {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

.brand-title {
    font-weight: 700;
    font-size: 1.08rem;
}

.brand-subtitle,
.muted,
.page-kicker,
.panel-head p,
.stat-note,
.helper-copy,
.definition-list dt {
    color: var(--muted);
}

.nav-list {
    display: grid;
    gap: 0.3rem;
}

.nav-link {
    padding: 0.78rem 1rem;
    border-radius: 1rem;
    color: rgba(255, 255, 255, 0.92);
    font-size: 1.05rem;
    transition: 160ms ease;
}

.nav-link:hover,
.nav-link.is-active {
    color: white;
    background: rgba(255, 255, 255, 0.08);
}

.nav-list > .nav-top-level {
    padding-top: 0.23rem;
    padding-bottom: 0.23rem;
    font-size: 0.82rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.nav-group {
    display: grid;
    gap: 0.3rem;
}

.nav-group-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    width: 100%;
    padding: 0.23rem 1rem;
    border: 0;
    background: transparent;
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    text-align: left;
    color: rgba(255, 255, 255, 0.78);
    transition: color 160ms ease;
}

.nav-group-label:hover,
.nav-group-label:focus-visible {
    color: rgba(255, 255, 255, 0.95);
}

.nav-group-label:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.5);
    outline-offset: 2px;
    border-radius: 0.5rem;
}

.nav-group-chevron {
    width: 0.85rem;
    height: 0.85rem;
    flex-shrink: 0;
    transition: transform 160ms ease;
}

.nav-group.is-collapsed .nav-group-chevron {
    transform: rotate(-90deg);
}

.nav-group-body {
    display: grid;
    gap: 0.2rem;
}

.nav-group-body .nav-link {
    padding-top: 0.62rem;
    padding-bottom: 0.62rem;
    font-size: 0.86rem;
}

.nav-group.is-collapsed .nav-group-body {
    display: none;
}

.nav-divider {
    height: 1px;
    margin: 0.1rem 0.6rem 0.3rem;
    background: rgba(255, 255, 255, 0.12);
}

.sidebar-footer {
    margin-top: auto;
    padding: 0.8rem;
    border-radius: 1.2rem;
    background: rgba(255, 255, 255, 0.05);
}

.sidebar .muted {
    color: #c8d5df;
}

.sidebar .session-user {
    color: #ffffff;
}

.session-user {
    margin: 10px 0 0;
    font-weight: 600;
    font-size: 1.08rem;
}

.sidebar-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    align-self: flex-end;
    flex-shrink: 0;
    width: 2.4rem;
    height: 2.4rem;
    border: 1px solid var(--border);
    border-radius: 0.9rem;
    background: var(--surface-strong);
    color: var(--text);
    cursor: pointer;
    transition: background 160ms ease;
}

.sidebar-toggle:hover {
    background: var(--secondary);
}

.sidebar-toggle svg {
    width: 1.35rem;
    height: 1.35rem;
}

.sidebar-toggle .icon-open {
    display: none;
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 999;
    background: rgba(15, 23, 42, 0.52);
    opacity: 0;
    pointer-events: none;
    transition: opacity 220ms ease;
}

.sidebar-backdrop.is-visible {
    opacity: 1;
    pointer-events: auto;
}

body.sidebar-locked {
    overflow: hidden;
}

.content {
    min-width: 0;
    padding: 2rem;
}

.page-header {
    margin-bottom: 1.5rem;
}

.page-header h1 {
    margin: 0.15rem 0;
    font-size: clamp(1.9rem, 2vw, 2.6rem);
}

.page-header p,
.page-kicker {
    margin: 0;
}

.page-kicker,
.eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.18em;
    font-size: 0.72rem;
}

.stats-grid,
.panel-grid,
.form-grid,
.health-grid {
    display: grid;
    gap: 1rem;
}

.stats-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-bottom: 1rem;
}

.panel-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-bottom: 1rem;
}

.panel-grid-charts {
    align-items: stretch;
}

.chart-container {
    position: relative;
    width: 100%;
}

.chart-container canvas {
    max-height: 100%;
}

.panel-span-2 {
    grid-column: span 2;
}

.panel,
.stat-card,
.login-card,
.hero-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    backdrop-filter: blur(12px);
    box-shadow: var(--shadow);
}

.panel,
.login-card {
    border-radius: 1.5rem;
    padding: 1.35rem;
}

.panel-head {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: start;
    margin-bottom: 1rem;
}

.panel-head h2,
.stat-card strong {
    margin: 0;
    font-size: 1.05rem;
}

.panel-head p,
.stat-card span,
.helper-copy,
.definition-list dd,
.plain-list {
    margin: 0;
    font-size: 0.95rem;
}

.stat-card {
    padding: 1.25rem;
    border-radius: 1.35rem;
    display: grid;
    gap: 0.3rem;
}

.stat-card strong {
    font-size: 2.4rem;
}

.stat-label {
    color: var(--muted);
    font-size: 0.84rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

.accent-blue { border-top: 4px solid #2563eb; }
.accent-green { border-top: 4px solid #059669; }
.accent-amber { border-top: 4px solid #d97706; }
.accent-rose { border-top: 4px solid #be123c; }

a.stat-card-link {
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
    display: grid;
}

a.stat-card-link:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.12);
    text-decoration: none;
    color: inherit;
}

a.stat-card-link:active {
    transform: translateY(-1px);
    opacity: 0.9;
}

.alert {
    padding: 0.9rem 1rem;
    border-radius: 1rem;
    margin-bottom: 1rem;
    border: 1px solid var(--border);
}

.alert-danger {
    background: rgba(244, 63, 94, 0.08);
    color: #9f1239;
}

.alert-success {
    background: rgba(5, 150, 105, 0.08);
    color: #065f46;
}

.alert-info {
    background: rgba(37, 99, 235, 0.08);
    color: #1e3a8a;
    border-color: rgba(37, 99, 235, 0.18);
}

.toolbar {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    margin-bottom: 1rem;
}

.toolbar-end {
    justify-content: flex-end;
}

.button {
    border: 0;
    border-radius: 0.5rem;
    padding: 0.38rem 0.75rem;
    cursor: pointer;
    font-weight: 600;
    font-family: inherit;
    font-size: 0.78rem;
    line-height: 1.2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.2rem;
}

.button-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
}

.button-secondary {
    background: #e7f1f8;
    border: 1px solid #c8dce9;
    color: #2f75ad;
}

.button-danger {
    background: #dc2626;
    color: #fff;
}

.button-danger:hover {
    background: #b91c1c;
}

.button-block {
    width: 100%;
}

/* Page-level calls to action remain slightly more prominent than row actions. */
.table-filter-bar > div > .button-primary,
.foc-toolbar > .button-primary {
    min-height: 2.35rem;
    padding: 0.42rem 0.85rem;
    font-size: 0.8rem;
}

.input,
select.input {
    width: 100%;
    border: 1px solid rgba(148, 163, 184, 0.45);
    border-radius: 0.95rem;
    padding: 0.9rem 1rem;
    background: rgba(255, 255, 255, 0.9);
    color: var(--text);
    font: inherit;
}

.input:focus,
select.input:focus {
    outline: 2px solid rgba(37, 99, 235, 0.18);
    border-color: rgba(37, 99, 235, 0.45);
}

.label {
    display: block;
    margin-bottom: 0.45rem;
    font-size: 0.92rem;
    font-weight: 600;
}

.required-mark {
    color: var(--danger);
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    text-align: left;
    padding: 0.95rem 0.8rem;
    border-bottom: 1px solid rgba(148, 163, 184, 0.18);
    vertical-align: top;
}

.table th {
    color: var(--muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.table th a {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.empty-cell {
    text-align: center;
    color: var(--muted);
}

.table-filter-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem 0.75rem;
}

.filter-input {
    flex: 1;
    max-width: 340px;
    padding: 0.45rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.875rem;
    font-family: inherit;
    background: var(--bg);
    color: var(--text);
    outline: none;
    transition: border-color 0.15s;
}

.filter-input:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.12);
}

.filter-select {
    padding: 0.38rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.78rem;
    font-family: inherit;
    background: var(--bg);
    color: var(--text);
    outline: none;
    cursor: pointer;
    transition: border-color 0.15s;
    min-height: 2.2rem;
}

.filter-select:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.12);
}

.filter-count {
    font-size: 0.8rem;
    color: var(--muted);
    white-space: nowrap;
}

.pagination-row {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: center;
    margin-top: 1rem;
}

.pagination {
    display: flex;
    gap: 0.12rem;
    flex-wrap: wrap;
}

.page-link {
    min-width: 1.5rem;
    min-height: 1.5rem;
    padding: 0.12rem 0.3rem;
    border-radius: 0.25rem;
    background: rgba(148, 163, 184, 0.15);
    font-size: 0.68rem;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.page-link.is-active {
    background: var(--primary);
    color: white;
}

.page-ellipsis {
    padding: 0.3rem;
    color: var(--muted);
    align-self: center;
}

.sort-indicator {
    color: var(--primary);
}

.definition-list,
.plain-list,
.stack-md,
.stack-lg {
    display: grid;
    gap: 0.9rem;
}

.definition-list dt {
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 0.2rem;
}

.definition-list dd {
    margin-left: 0;
}

.form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.health-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.health-tile {
    border-radius: 1rem;
    padding: 1rem;
    background: rgba(241, 245, 249, 0.72);
}

.health-tile strong {
    display: block;
    margin-top: 0.3rem;
    font-size: 1.7rem;
}

.login-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1.5rem;
    position: relative;
    overflow: hidden;
    background:
        radial-gradient(circle at 18% 20%, rgba(148, 163, 184, 0.2), transparent 30%),
        radial-gradient(circle at 82% 85%, rgba(59, 130, 246, 0.18), transparent 28%),
        linear-gradient(145deg, #0f1f3b 0%, #1f3f73 48%, #2c4f8f 100%);
}

.login-body::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='340' height='140'%3E%3Ctext x='170' y='70' font-family='Arial%2C sans-serif' font-size='19' font-weight='700' fill='rgba(255%2C255%2C255%2C0.07)' text-anchor='middle' dominant-baseline='middle' transform='rotate(-35%2C170%2C70)'%3EData Feeds Center%3C%2Ftext%3E%3C%2Fsvg%3E");
    background-repeat: repeat;
    background-size: 340px 140px;
    pointer-events: none;
    z-index: 0;
}

.login-body::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(8, 16, 32, 0.1) 0%, rgba(8, 16, 32, 0.22) 100%);
    pointer-events: none;
    z-index: 0;
}

.auth-page {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 860px;
    display: grid;
    place-items: center;
}

.auth-card {
    width: min(100%, 410px);
    background: rgba(255, 255, 255, 1);
    border: 1px solid rgba(255, 255, 255, 0.75);
    border-radius: 20px;
    box-shadow: 0 26px 50px rgba(31, 41, 55, 0.26);
    text-align: center;
    padding: 2rem 2rem 1.8rem;
    color: #111827;
    animation: login-card-enter 420ms ease-out both;
}

.auth-logo-wrap {
    display: grid;
    place-items: center;
    min-height: 66px;
    margin-bottom: 0.65rem;
}

.auth-logo {
    max-width: 142px;
    width: 100%;
    height: auto;
}

.auth-logo-fallback {
    display: none;
    min-height: 52px;
    border-radius: 14px;
    padding: 0.6rem 1.1rem;
    background: #ecf3ff;
    color: #29549a;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    font-weight: 700;
    letter-spacing: 0.01em;
}

.auth-kicker {
    margin: 0;
    color: #6b7280;
    font-size: 0.95rem;
}

.auth-title {
    margin: 0.95rem 0 1.2rem;
    font-size: 2.15rem;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.05;
}

.auth-social-stack {
    display: grid;
    gap: 0.85rem;
}

.oauth-btn {
    width: 100%;
    border-radius: 10px;
    border: 2px solid #d1d5db;
    background: #ffffff;
    color: #1f2937;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    font-size: 1.04rem;
    font-weight: 600;
    padding: 0.82rem 0.95rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.48rem;
    cursor: pointer;
    opacity: 1;
    transition: background 160ms ease, border-color 160ms ease;
}

.oauth-btn:hover {
    background: #f3f4f6;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.10);
}

.oauth-btn:active {
    transform: translateY(0);
    box-shadow: none;
    background: #e9eaec;
}

.oauth-unavailable {
    cursor: pointer;
}

.oauth-google {
    border-color: #d6454f;
}

.oauth-google:hover {
    border-color: #b91c1c;
    background: #fff5f5;
}

.oauth-microsoft {
    border-color: #2597cc;
}

.oauth-microsoft:hover {
    border-color: #1575a8;
    background: #f0f8ff;
}

.oauth-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 999px;
    background: #f3f4f6;
    color: #111827;
    font-size: 0.72rem;
    font-weight: 700;
    transition: background 160ms ease;
}

.oauth-btn:hover .oauth-mark {
    background: #e5e7eb;
}

.auth-divider {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 0.75rem;
    margin: 1.4rem 0 1.2rem;
    color: #8c9098;
    font-size: 0.94rem;
    font-weight: 500;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    border-top: 1px solid #e5e7eb;
}

.credentials-toggle {
    margin: 0 0 1rem;
    text-align: left;
}

.credentials-toggle summary {
    cursor: pointer;
    color: #374151;
    font-size: 0.92rem;
    font-weight: 600;
}

.credentials-form {
    margin-top: 0.85rem;
}

.auth-terms {
    margin: 0.3rem 0 0;
    color: #6b7280;
    line-height: 1.45;
    font-size: 0.92rem;
}

@keyframes login-card-enter {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.985);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@media (max-width: 1100px) {
    .stats-grid,
    .panel-grid,
    .form-grid,
    .health-grid {
        grid-template-columns: 1fr;
    }

    .panel-span-2 {
        grid-column: auto;
    }

    .login-card {
        margin: 0;
    }
}

/* ──────────────────────────────────────────────────────────────
   Responsive sidebar
   Desktop & tablet (≥768px): full 280px rail by default; the
   toggle icon in the rail collapses it to a compact icon rail
   (preference persisted).
   Mobile (<768px): sidebar is off-canvas; the floating toggle
   icon opens/closes it as an overlay above the backdrop.
────────────────────────────────────────────────────────────── */

@media (min-width: 768px) {
    /* Collapsed compact icon rail */
    .shell.sidebar-collapsed {
        grid-template-columns: 92px minmax(0, 1fr);
    }

    .shell.sidebar-collapsed .sidebar {
        align-items: center;
        padding: 1rem 0.75rem;
    }

    .shell.sidebar-collapsed .brand {
        justify-content: center;
    }

    .shell.sidebar-collapsed .brand > div:not(.brand-mark) {
        display: none;
    }

    .shell.sidebar-collapsed .nav-list {
        width: 100%;
    }

    .shell.sidebar-collapsed .nav-group-label,
    .shell.sidebar-collapsed .nav-divider {
        display: none;
    }

    /* Labels are hidden in the icon rail, so collapsed groups must not hide their links. */
    .shell.sidebar-collapsed .nav-group.is-collapsed .nav-group-body {
        display: grid;
    }

    .shell.sidebar-collapsed .nav-link {
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0.55rem 0;
        font-size: 0;
        background: transparent;
    }

    .shell.sidebar-collapsed .nav-link::before {
        content: attr(data-icon);
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 2.6rem;
        height: 2.6rem;
        border-radius: 0.85rem;
        font-size: 0.95rem;
        font-weight: 700;
        color: rgba(255, 255, 255, 0.75);
        background: rgba(255, 255, 255, 0.06);
        transition: 160ms ease;
    }

    .shell.sidebar-collapsed .nav-link:hover,
    .shell.sidebar-collapsed .nav-link.is-active {
        background: transparent;
    }

    .shell.sidebar-collapsed .nav-link:hover::before {
        color: white;
        background: rgba(255, 255, 255, 0.14);
    }

    .shell.sidebar-collapsed .nav-link.is-active::before {
        color: white;
        background: rgba(255, 255, 255, 0.2);
    }

    .shell.sidebar-collapsed .sidebar-footer {
        width: 100%;
        padding: 0.6rem;
        border-radius: 0.9rem;
    }

    .shell.sidebar-collapsed .sidebar-footer .muted,
    .shell.sidebar-collapsed .sidebar-footer .session-user {
        display: none;
    }

    .shell.sidebar-collapsed .sidebar-footer .button {
        font-size: 0;
        padding: 0.65rem 0;
    }

    .shell.sidebar-collapsed .sidebar-footer .button::after {
        content: "";
        display: inline-block;
        width: 1.15rem;
        height: 1.15rem;
        background: currentColor;
        -webkit-mask: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%3E%3Cpath%20fill='black'%20d='M17%207l-1.41%201.41L18.17%2011H8v2h10.17l-2.58%202.58L17%2017l5-5zM4%205h8V3H4c-1.1%200-2%20.9-2%202v14c0%201.1.9%202%202%202h8v-2H4V5z'/%3E%3C/svg%3E") center / contain no-repeat;
        mask: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%3E%3Cpath%20fill='black'%20d='M17%207l-1.41%201.41L18.17%2011H8v2h10.17l-2.58%202.58L17%2017l5-5zM4%205h8V3H4c-1.1%200-2%20.9-2%202v14c0%201.1.9%202%202%202h8v-2H4V5z'/%3E%3C/svg%3E") center / contain no-repeat;
    }

    .shell.sidebar-collapsed .sidebar-toggle {
        align-self: center;
    }

    .shell.sidebar-collapsed .sidebar-toggle .icon-close {
        display: none;
    }

    .shell.sidebar-collapsed .sidebar-toggle .icon-open {
        display: block;
    }
}

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

    .sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        left: -105%;
        width: min(300px, 86vw);
        height: 100dvh;
        z-index: 1001;
        padding: 1.25rem;
        box-shadow: 0 24px 60px rgba(15, 23, 42, 0.45);
    }

    .sidebar.is-open {
        left: 0;
    }

    /* The toggle lives at the bottom of the sidebar but stays reachable
       while the rail is off-canvas: fixed to the viewport edge when closed,
       settling back into the sidebar's own flow when open. */
    .sidebar-toggle {
        display: inline-flex;
        position: fixed;
        bottom: 0.75rem;
        left: 0.75rem;
        z-index: 1002;
        box-shadow: 0 10px 24px rgba(15, 23, 42, 0.28);
        transition: background 160ms ease;
    }

    .sidebar.is-open .sidebar-toggle {
        position: static;
        align-self: flex-end;
    }

    /* Icon follows the rail state: pointing right while off-canvas (open),
       pointing left once the sidebar is shown (close). */
    .sidebar:not(.is-open) .sidebar-toggle .icon-close {
        display: none;
    }

    .sidebar:not(.is-open) .sidebar-toggle .icon-open {
        display: block;
    }

    .sidebar-backdrop {
        display: block;
    }
}

@media (max-width: 720px) {
    .content,
    .auth-page {
        padding: 1rem;
    }

    .auth-card {
        padding: 1.5rem 1rem;
        border-radius: 16px;
    }

    .auth-title {
        font-size: 1.8rem;
    }

    .oauth-btn {
        font-size: 0.96rem;
    }

    .toolbar,
    .pagination-row {
        flex-direction: column;
        align-items: stretch;
    }

    .table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
}

/* Keep the floating sidebar toggle clear of the page header on mobile. */
@media (max-width: 767px) {
    .content {
        padding-top: 4.25rem;
    }
}

/* ── Feed-Out Config: portal-based view ─────────────────────────────────────── */
.foc-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.foc-tab {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.75rem;
    border-radius: 0.5rem;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-size: 0.78rem;
    font-weight: 600;
    transition: background 160ms ease, border-color 160ms ease, color 160ms ease;
    min-height: 2.2rem;
}

.foc-tab:hover {
    background: var(--surface-strong);
    border-color: rgba(37, 99, 235, 0.35);
}

.foc-tab.is-active {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-color: transparent;
    color: white;
}

.foc-tab-count {
    min-width: 1.4rem;
    padding: 0.1rem 0.45rem;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.08);
    font-size: 0.75rem;
    text-align: center;
}

.foc-tab.is-active .foc-tab-count {
    background: rgba(255, 255, 255, 0.22);
}

.foc-panel {
    padding: 1.15rem 1.35rem;
}

.foc-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.foc-filter-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.foc-clear {
    font-size: 0.85rem;
    text-decoration: none;
}

.foc-summary {
    margin-left: auto;
    font-size: 0.82rem;
    color: var(--muted);
    white-space: nowrap;
}

.foc-portal-head {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin: 1.1rem 0 0.9rem;
}

.foc-portal-head h2 {
    margin: 0;
    font-size: 1.2rem;
}

.foc-method {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding: 0.15rem 0.45rem;
    border-radius: 999px;
    background: rgba(37, 99, 235, 0.1);
    color: var(--primary-dark);
}

.foc-customers {
    display: grid;
    gap: 0.9rem;
}

.foc-customer {
    background: var(--surface-strong);
    border: 1px solid var(--border);
    border-radius: 1rem;
    overflow: hidden;
}

.foc-customer-head {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    width: 100%;
    padding: 0.85rem 1.1rem;
    border: 0;
    background: transparent;
    font: inherit;
    text-align: left;
    cursor: pointer;
    transition: background 150ms ease;
}

.foc-customer-head:hover {
    background: rgba(15, 23, 42, 0.03);
}

.foc-caret {
    color: var(--muted);
    font-size: 0.8rem;
    transition: transform 150ms ease;
}

.foc-customer.is-collapsed .foc-caret {
    transform: rotate(-90deg);
}

.foc-customer-name {
    font-weight: 700;
    font-size: 1rem;
}

.foc-customer-meta {
    margin-left: auto;
    color: var(--muted);
    font-size: 0.8rem;
    text-align: right;
}

.foc-customer-body {
    border-top: 1px solid var(--border);
}

.foc-customer.is-collapsed .foc-customer-body {
    display: none;
}

.foc-config-row {
    display: grid;
    grid-template-columns: minmax(4.5rem, 0.8fr) minmax(5.5rem, 0.9fr) minmax(9rem, 1.5fr) minmax(7rem, 1fr) minmax(11rem, 1.4fr);
    gap: 1rem;
    align-items: center;
    padding: 0.55rem 1.1rem;
    font-size: 0.875rem;
    border-top: 1px solid rgba(148, 163, 184, 0.12);
    transition: background 120ms ease;
}

.foc-config-row:first-child {
    border-top: 0;
}

.foc-config-row:not(.foc-config-head):hover {
    background: rgba(241, 245, 249, 0.5);
}

.foc-config-head {
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    background: rgba(241, 245, 249, 0.55);
    padding-top: 0.45rem;
    padding-bottom: 0.45rem;
}

/* Keep the Action heading aligned with the left edge of its buttons. */
.foc-config-head .foc-col:last-child {
    text-align: left;
}

.foc-id {
    display: inline-block;
    padding: 0.14rem 0.55rem;
    border-radius: 0.5rem;
    background: rgba(15, 23, 42, 0.06);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.foc-updated-heading,
.foc-updated {
    grid-column: 4;
}

.foc-action-heading,
.foc-col-actions {
    grid-column: 5;
}

.foc-col-actions {
    display: flex;
    justify-content: flex-start;
    gap: 0.45rem;
    align-items: center;
    justify-self: start;
}

.foc-updated {
    white-space: nowrap;
    justify-self: start;
}

@media (min-width: 721px) {
    .foc-config-row {
        grid-template-areas: "config method activity updated action";
    }

    .foc-config-row > .foc-col:nth-child(1) { grid-area: config; }
    .foc-config-row > .foc-col:nth-child(2) { grid-area: method; }
    .foc-config-row > .foc-col:nth-child(3) { grid-area: activity; }
    .foc-config-row > .foc-updated { grid-area: updated; }
    .foc-config-row > .foc-col-actions { grid-area: action; }
}

.foc-push,
.foc-edit {
    padding: 0.34rem 0.85rem;
    font-size: 0.8125rem;
    border-radius: 0.7rem;
    white-space: nowrap;
    /* Keep the compact visual size; extend the hit area to a 44px target
       via a pseudo-element that covers the row's own padding (T1). */
    position: relative;
    min-height: 0;
}

.foc-push::after,
.foc-edit::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: -0.55rem;
    bottom: -0.55rem;
}

.foc-edit {
    background: #e7f1f8;
    border: 1px solid #c8dce9;
    color: #2f75ad;
}

.foc-edit:hover {
    background: #d9ebf5;
    border-color: #a9c9dc;
}

.foc-empty {
    padding: 2rem 1rem;
    text-align: center;
    color: var(--muted);
    display: grid;
    gap: 0.9rem;
    justify-items: center;
}

.foc-empty p {
    margin: 0;
    font-size: 0.95rem;
}

@media (max-width: 720px) {
    .foc-toolbar {
        display: grid;
        grid-template-columns: 1fr auto;
        align-items: center;
    }

    .foc-summary {
        grid-column: 1 / -1;
        grid-row: 2;
        margin-left: 0;
    }

    .foc-customer-meta {
        text-align: left;
    }

    .foc-config-row {
        grid-template-columns: 1fr 1fr;
        row-gap: 0.45rem;
        padding: 0.7rem 1rem;
    }

    .foc-config-head {
        display: none;
    }

    .foc-config-row .foc-col::before {
        content: attr(data-label);
        display: block;
        margin-bottom: 0.15rem;
        font-size: 0.66rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.07em;
        color: var(--muted);
    }

    .foc-col-actions {
        grid-column: 1 / -1;
        justify-content: flex-start;
        justify-self: stretch;
        padding-top: 0.2rem;
    }

    .foc-updated {
        grid-column: auto;
    }
}

/* ── Manual Push modal ─────────────────────────────────────────────────────── */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: absolute;
    top: -3rem;
    left: 1rem;
    z-index: 1100;
    padding: 0.75rem 1rem;
    background: var(--surface-strong);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
}

.skip-link:focus {
    top: 1rem;
}

/* Eliminate the 300ms tap delay on interactive controls (T4). */
.button,
.nav-link,
.nav-group-label,
.page-link,
.filter-input,
.filter-select,
.foc-tab,
.foc-push,
.foc-edit,
.foc-customer-head,
.sidebar-toggle,
.skip-link {
    touch-action: manipulation;
}

/* Stop all transitions/animations for reduced-motion users (A8). */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}

.modal-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 6px;
}

.modal-close-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 2.75rem;
    height: 2.75rem;
    padding: 0;
}

.modal-close-btn svg {
    width: 1.15rem;
    height: 1.15rem;
}

.step-indicator {
    margin: 0 0 16px;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--muted);
}

.modal-alert {
    display: none;
    background: var(--danger-soft);
    color: var(--danger-strong);
    padding: 10px 14px;
    border-radius: 6px;
    margin-bottom: 16px;
}

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--overlay);
    z-index: var(--z-modal);
    align-items: center;
    justify-content: center;
}

.modal-overlay.is-open {
    display: flex;
}

.modal-dialog {
    background: var(--surface-strong);
    border-radius: 10px;
    padding: 32px 28px;
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow: auto;
    box-shadow: var(--shadow-dialog);
}

.modal-title {
    margin: 0 0 6px;
    font-size: 1.2rem;
    font-weight: 700;
}

.modal-subtitle {
    margin: 0;
    color: var(--muted);
    font-size: 0.875rem;
}

.modal-footer {
    display: flex;
    justify-content: space-between;
    gap: 10px;
}

.modal-footer-actions {
    margin-left: auto;
    display: flex;
    gap: 10px;
}

.mp-step {
    display: none;
}

.mp-step.is-active {
    display: block;
}

.is-hidden {
    display: none !important;
}

.mp-choice {
    display: inline-flex;
    gap: 0.4rem;
    cursor: pointer;
    margin-right: 1.25rem;
}

.mp-dryrun {
    display: flex;
    gap: 0.4rem;
    align-items: center;
    cursor: pointer;
    margin-bottom: 24px;
}

.mp-search-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    font-size: 0.9rem;
}

.mp-results {
    margin-top: 10px;
    max-height: 320px;
    overflow: auto;
}

.mp-branch-list {
    margin-bottom: 18px;
}

.mp-summary {
    margin-bottom: 18px;
    font-size: 0.875rem;
    color: var(--text);
}

/* Property picker rows (rendered by JS) */
.mp-branch-choice {
    display: block;
    margin-bottom: 6px;
    cursor: pointer;
}

.mp-muted {
    color: var(--muted);
}

.mp-selectall {
    display: inline-flex;
    gap: 0.4rem;
    align-items: center;
    cursor: pointer;
    margin-bottom: 8px;
    font-size: 0.8125rem;
}

.mp-group {
    margin-bottom: 12px;
    border: 1px solid var(--border-muted);
    border-radius: 6px;
    overflow: hidden;
}

.mp-group-head {
    background: var(--surface-muted);
    padding: 6px 10px;
    font-size: 0.8125rem;
    font-weight: 600;
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.mp-group-empty {
    padding: 10px;
    color: var(--muted);
    font-size: 0.8125rem;
}

.mp-property-row {
    display: flex;
    gap: 0.5rem;
    align-items: flex-start;
    padding: 8px 10px;
    border-top: 1px solid var(--border-subtle);
    font-size: 0.8125rem;
    cursor: pointer;
}

/* Two-line property picker row: full address + Property ID / price meta */
.mp-prop {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.mp-prop-address {
    font-weight: 600;
    color: var(--text);
}

.mp-prop-meta {
    color: var(--muted);
}

.mp-check-top {
    margin-top: 2px;
}

.mp-loadmore {
    padding: 8px 10px;
    text-align: center;
}

.mp-summary-line {
    margin-bottom: 4px;
}

/* ── Feed-Out Config form ───────────────────────────────────────────────── */
.focf-top {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
}

.focf-config {
    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: 1.25rem;
    padding: 1.25rem;
}

.focf-config-head {
    margin-bottom: 1.1rem;
}

.focf-config-head h2 {
    margin: 0;
    font-size: 1.05rem;
}

.focf-config-head p {
    margin: 0.2rem 0 0;
    font-size: 0.85rem;
    color: var(--muted);
}

/* Branch type segmented control */
.focf-branch-section {
    grid-column: 1 / -1;
    display: grid;
    gap: 0.9rem;
}

.focf-branch-toggle {
    display: grid;
    gap: 0.45rem;
    justify-items: start;
}

.focf-toggle-label {
    font-size: 0.92rem;
    font-weight: 600;
}

.focf-toggle {
    display: inline-flex;
    padding: 0.25rem;
    gap: 0.25rem;
    background: var(--secondary);
    border-radius: 0.95rem;
}

.focf-toggle-option {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 1rem;
    border-radius: 0.7rem;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--muted);
    transition: 160ms ease;
}

.focf-toggle-option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.focf-toggle-option:hover {
    color: var(--text);
}

.focf-toggle-option.is-active {
    background: var(--surface-strong);
    color: var(--text);
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12);
}

.focf-toggle-option:focus-within {
    outline: 2px solid rgba(37, 99, 235, 0.3);
    outline-offset: 2px;
}

/* Branch rows */
.focf-branch-list {
    display: grid;
    gap: 0.75rem;
}

.focf-branch-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.75rem;
    background: var(--surface-strong);
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: 0.9rem 1rem;
}

.focf-cell {
    flex: 1 1 10rem;
    min-width: 10rem;
}

.focf-cell-name {
    flex: 1.4 1 12rem;
}

.focf-remove {
    flex: 0 0 auto;
    background: transparent;
    border: 1px solid rgba(190, 18, 60, 0.35);
    color: var(--danger);
}

.focf-remove:hover {
    background: var(--danger-soft);
    border-color: rgba(190, 18, 60, 0.55);
}

.focf-add-branch {
    justify-self: start;
    background: transparent;
    border: 1px dashed rgba(37, 99, 235, 0.45);
    color: var(--primary);
}

.focf-add-branch:hover {
    background: rgba(37, 99, 235, 0.06);
}

/* Form actions */
.focf-actions {
    margin-top: 0.25rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-subtle);
}

@media (max-width: 1100px) {
    .focf-top {
        grid-template-columns: 1fr;
    }
}
