:root {
    --scgs-navy: #14213d;
    --scgs-slate: #334155;
    --scgs-muted: #64748b;
    --scgs-line: #dbe3ef;
    --scgs-bg: #f5f7fb;
    --scgs-green: #16a34a;
    --scgs-teal: #0f766e;
    --scgs-blue: #2563eb;
    --scgs-red: #dc2626;
    --scgs-orange: #ea580c;
    --scgs-sidebar-width: 280px;
}

* {
    box-sizing: border-box;
}

html {
    overflow-x: hidden;
    max-width: 100%;
}

body {
    background: var(--scgs-bg);
    color: #172033;
    font-size: 15px;
    letter-spacing: 0;
    overflow-x: clip;
    max-width: 100%;
}

a {
    text-decoration: none;
}

.app-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ===== Top navigation (replaces sidebar) ===== */
.top-nav {
    position: sticky;
    top: 0;
    z-index: 1030;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
}

.top-nav-inner {
    width: 100%;
    
    margin: 0 auto;
    min-height: 64px;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 10px clamp(14px, 2vw, 24px);
    min-width: 0;
}

.top-nav-brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    color: var(--text);
    flex: 0 0 auto;
}

.brand-mark {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--primary);
    color: #ffffff;
    font-weight: 800;
    flex: 0 0 auto;
}

.top-nav-brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}

.brand-title {
    font-weight: 800;
}

.brand-subtitle {
    margin-top: 2px;
    color: var(--muted);
    font-size: 12px;
}

.login-brand {
    display: flex;
    gap: 12px;
    align-items: center;
    color: var(--text);
}

.top-nav-menu {
    display: flex;
    align-items: center;
    gap: 2px;
    flex: 1 1 auto;
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
}

.top-nav-menu::-webkit-scrollbar {
    display: none;
}

.nav-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    min-height: 40px;
    border-radius: 9px;
    color: var(--muted);
    font-weight: 650;
    font-size: 14px;
    white-space: nowrap;
}

.nav-link .ti {
    font-size: 18px;
}

.nav-link:hover {
    background: var(--bg);
    color: var(--text);
}

.nav-link.active {
    background: var(--bg);
    color: var(--primary);
}

.nav-link.active .ti {
    color: var(--primary);
}

.top-nav-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
    flex: 0 0 auto;
}

.nav-toggle {
    display: none;
    align-items: center;
    gap: 8px;
    margin-left: auto;
    padding: 9px 14px;
    border-radius: 9px;
    border: 1px solid var(--border);
    background: var(--card-bg);
    color: var(--text);
    font-weight: 700;
    cursor: pointer;
}

.nav-drawer-extra {
    display: none;
}

.nav-backdrop {
    display: none;
}

.app-main {
    flex: 1;
    width: 100%;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.app-container {
    width: 100%;
    
    margin: 0 auto;
    padding: 24px clamp(14px, 2vw, 24px);
    flex: 1;
    min-width: 0;
}

.app-footer {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    width: 100%;
    
    margin: 0 auto;
    padding: 18px clamp(14px, 2vw, 24px);
    color: var(--muted);
    border-top: 1px solid var(--border);
}

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

.page-heading h2 {
    margin: 0;
    color: var(--scgs-navy);
    font-size: 26px;
}

.page-heading p {
    margin: 6px 0 0;
    color: var(--scgs-muted);
    max-width: 760px;
}

.card {
    border-color: var(--scgs-line);
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.04);
}

.metric-card {
    height: 100%;
}

.metric-card .card-body {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    min-height: 138px;
}

.metric-icon {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    flex: 0 0 auto;
}

.metric-icon .ti {
    font-size: 23px;
}

.metric-primary {
    background: var(--scgs-blue);
}

.metric-success,
.metric-teal {
    background: var(--scgs-green);
}

.metric-info {
    background: var(--scgs-teal);
}

.metric-warning {
    background: #ca8a04;
}

.metric-danger {
    background: var(--scgs-red);
}

.metric-secondary {
    background: var(--scgs-slate);
}

.metric-label {
    color: var(--scgs-muted);
    font-weight: 700;
    font-size: 13px;
}

.metric-value {
    color: var(--scgs-navy);
    font-size: 31px;
    font-weight: 800;
    line-height: 1.1;
    margin-top: 7px;
}

.metric-caption {
    color: var(--scgs-muted);
    margin-top: 6px;
    font-size: 13px;
}

.panel-card .card-header {
    background: #ffffff;
    border-bottom-color: var(--scgs-line);
}

.data-card .card-header {
    background: #ffffff;
    border-bottom-color: var(--scgs-line);
}

.table {
    color: #172033;
}

.table thead th {
    color: var(--scgs-muted);
    font-size: 12px;
    text-transform: uppercase;
    font-weight: 800;
    border-bottom-color: var(--scgs-line);
}

.table td {
    vertical-align: middle;
    overflow-wrap: anywhere;
}

.url-wrap {
    word-break: break-word;
    overflow-wrap: anywhere;
    white-space: normal;
}

.btn-list form {
    display: inline-flex;
    margin: 0;
}

.empty-state {
    min-height: 190px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: var(--scgs-muted);
    padding: 28px;
}

.empty-state .ti {
    font-size: 42px;
    color: var(--scgs-green);
    margin-bottom: 12px;
}

.empty-state h4 {
    margin: 0 0 6px;
    color: var(--scgs-navy);
}

.empty-state p {
    margin: 0;
}

.empty-inline {
    border: 1px dashed var(--scgs-line);
    border-radius: 8px;
    padding: 16px;
    color: var(--scgs-muted);
    background: #fbfdff;
}

.detail-list {
    display: grid;
    gap: 13px;
}

.detail-list > div {
    display: grid;
    grid-template-columns: minmax(90px, 130px) 1fr;
    gap: 12px;
}

.detail-list span {
    color: var(--scgs-muted);
}

.detail-list strong {
    color: var(--scgs-navy);
    overflow-wrap: anywhere;
}

.detail-tile {
    height: 100%;
    border: 1px solid var(--scgs-line);
    border-radius: 8px;
    background: #fbfdff;
    padding: 14px;
}

.detail-tile span,
.detail-tile strong {
    display: block;
}

.detail-tile span {
    color: var(--scgs-muted);
    font-size: 12px;
    text-transform: uppercase;
}

.detail-tile strong {
    color: var(--scgs-navy);
    margin-top: 6px;
    overflow-wrap: anywhere;
}

.note-list {
    display: grid;
    gap: 12px;
    max-height: 380px;
    overflow-y: auto;
}

.note-item {
    border: 1px solid var(--scgs-line);
    border-radius: 8px;
    background: #fbfdff;
    padding: 14px;
}

.note-date {
    color: var(--scgs-muted);
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 6px;
}

.mini-record {
    border-bottom: 1px solid var(--scgs-line);
    padding: 12px 0;
}

.mini-record:first-child {
    padding-top: 0;
}

.mini-record:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}

.mini-record strong,
.mini-record span {
    display: block;
}

.mini-record span {
    color: var(--scgs-muted);
    margin-top: 3px;
}

.workflow-steps {
    display: grid;
    gap: 18px;
}

.quick-actions-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.quick-actions-grid a {
    display: grid;
    gap: 8px;
    min-height: 142px;
    border: 1px solid var(--scgs-line);
    border-radius: 8px;
    padding: 16px;
    color: var(--scgs-slate);
    background: #fbfdff;
}

.quick-actions-grid a:hover {
    border-color: rgba(22, 163, 74, 0.45);
    background: #f0fdf4;
}

.quick-actions-grid .ti {
    color: var(--scgs-green);
    font-size: 26px;
}

.quick-actions-grid strong {
    color: var(--scgs-navy);
    font-size: 16px;
}

.quick-actions-grid span {
    color: var(--scgs-muted);
    font-size: 13px;
}

.workflow-step {
    display: grid;
    grid-template-columns: 42px 1fr;
    gap: 14px;
}

.workflow-number {
    width: 42px;
    height: 42px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #eef6f0;
    color: var(--scgs-green);
    font-weight: 800;
}

.workflow-step h4 {
    margin: 0 0 5px;
    color: var(--scgs-navy);
    font-size: 17px;
}

.workflow-step p {
    margin: 0;
    color: var(--scgs-muted);
}

.cron-status {
    display: flex;
    align-items: center;
    gap: 12px;
}

.cron-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--scgs-green);
    box-shadow: 0 0 0 6px rgba(22, 163, 74, 0.12);
}

.cron-dot.is-danger {
    background: var(--scgs-red);
    box-shadow: 0 0 0 6px rgba(220, 38, 38, 0.12);
}

.queue-summary {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 20px;
}

.queue-summary-wide {
    grid-template-columns: repeat(5, minmax(90px, 1fr));
}

.queue-summary > div {
    border: 1px solid var(--scgs-line);
    border-radius: 8px;
    padding: 12px;
    background: #fbfdff;
}

.queue-summary span,
.queue-summary strong {
    display: block;
}

.queue-summary strong {
    margin-top: 4px;
    color: var(--scgs-navy);
    font-size: 24px;
}

.badge-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.progress-lg {
    height: 14px;
}

.login-page {
    min-height: 100vh;
    background:
        linear-gradient(180deg, rgba(20, 33, 61, 0.02), rgba(22, 163, 74, 0.04)),
        var(--scgs-bg);
}

.login-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.login-panel {
    width: 100%;
    max-width: 440px;
    background: #ffffff;
    border: 1px solid var(--scgs-line);
    border-radius: 8px;
    padding: 30px;
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.10);
}

.login-copy {
    margin: 28px 0 22px;
}

.login-copy h1 {
    color: var(--scgs-navy);
    font-size: 30px;
    margin: 0 0 8px;
}

.login-copy p,
.login-footnote {
    color: var(--scgs-muted);
}

.login-form .form-control {
    min-height: 44px;
}

.login-footnote {
    margin-top: 22px;
    text-align: center;
    font-size: 13px;
}

.btn {
    border-radius: 7px;
    font-weight: 700;
}

.btn-primary {
    background: var(--scgs-green);
    border-color: var(--scgs-green);
}

.btn-primary:hover {
    background: #15803d;
    border-color: #15803d;
}

.bg-teal {
    background-color: var(--scgs-teal) !important;
}

.bg-orange {
    background-color: var(--scgs-orange) !important;
}

body.sidebar-open .app-sidebar {
    transform: translateX(0);
}

@media (max-width: 991.98px) {
    .app-sidebar {
        transform: translateX(-100%);
        box-shadow: 20px 0 60px rgba(15, 23, 42, 0.16);
    }

    .app-main {
        margin-left: 0;
    }

    .app-topbar {
        padding: 12px 18px;
    }

    .app-content {
        padding: 20px 16px;
    }

    .page-heading,
    .app-footer {
        flex-direction: column;
        align-items: flex-start;
    }

    .queue-summary-wide {
        grid-template-columns: repeat(2, minmax(100px, 1fr));
    }

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

@media (max-width: 575.98px) {
    .topbar-actions {
        gap: 6px;
    }

    .topbar-title {
        font-size: 19px;
    }

    .metric-card .card-body {
        min-height: 118px;
    }

    .login-panel {
        padding: 24px;
    }

    .queue-summary,
    .queue-summary-wide {
        grid-template-columns: 1fr;
    }

    .quick-actions-grid {
        grid-template-columns: 1fr;
    }
}

/* Modern UI layer */
:root {
    --bg: #f4f7fb;
    --card-bg: #ffffff;
    --text: #172033;
    --muted: #64748b;
    --primary: #2563eb;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #d97706;
    --border: #dce5f2;
    --soft-border: rgba(15, 23, 42, 0.09);
    --shadow-sm: 0 8px 24px rgba(15, 23, 42, 0.05);
    --shadow-md: 0 18px 52px rgba(15, 23, 42, 0.08);
    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 18px;
    --space-1: 6px;
    --space-2: 10px;
    --space-3: 14px;
    --space-4: 20px;
    --space-5: 28px;
    --space-6: 36px;
    --scgs-bg: var(--bg);
    --scgs-line: var(--border);
    --scgs-muted: var(--muted);
    --scgs-navy: var(--text);
    --scgs-green: var(--success);
    --scgs-blue: var(--primary);
    --scgs-red: var(--danger);
    --scgs-orange: var(--warning);
}

body[data-theme="dark"],
body[data-resolved-theme="dark"] {
    --bg: #0f172a;
    --card-bg: #111c2f;
    --text: #e5eefc;
    --muted: #9fb0c7;
    --primary: #60a5fa;
    --success: #34d399;
    --danger: #fb7185;
    --warning: #fbbf24;
    --border: rgba(148, 163, 184, 0.22);
    --soft-border: rgba(226, 232, 240, 0.12);
    --shadow-sm: 0 8px 28px rgba(0, 0, 0, 0.24);
    --shadow-md: 0 22px 70px rgba(0, 0, 0, 0.34);
}

html {
    scrollbar-gutter: stable;
}

body {
    background:
        radial-gradient(circle at top left, rgba(37, 99, 235, 0.06), transparent 32rem),
        linear-gradient(180deg, rgba(22, 163, 74, 0.035), transparent 26rem),
        var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
}

body[data-resolved-theme="dark"] .text-secondary,
body[data-theme="dark"] .text-secondary {
    color: var(--muted) !important;
}

.app-shell {
    background: transparent;
}

.app-sidebar {
    background: color-mix(in srgb, var(--card-bg) 94%, transparent);
    border-right-color: var(--border);
    box-shadow: 10px 0 42px rgba(15, 23, 42, 0.035);
}

.app-sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1035;
    background: rgba(15, 23, 42, 0.42);
    backdrop-filter: blur(3px);
}

body.sidebar-open .app-sidebar-backdrop {
    display: block;
}

.sidebar-brand,
.sidebar-footer {
    border-color: var(--border);
}

.brand-mark {
    border-radius: 13px;
    background: linear-gradient(135deg, var(--primary), var(--success));
    box-shadow: 0 12px 30px rgba(37, 99, 235, 0.22);
}

.brand-title,
.topbar-title,
.page-heading h2,
.card-title,
.metric-value,
.detail-list strong,
.detail-tile strong,
.queue-summary strong,
.quick-actions-grid strong,
.workflow-step h4 {
    color: var(--text);
}

.brand-subtitle,
.topbar-kicker,
.page-heading p,
.metric-label,
.metric-caption,
.detail-list span,
.detail-tile span,
.quick-actions-grid span,
.workflow-step p,
.mini-record span {
    color: var(--muted);
}

.sidebar-link {
    border-radius: 12px;
    color: var(--muted);
    transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}

.sidebar-link:hover {
    transform: translateX(2px);
}

.sidebar-link:hover,
.sidebar-link.active {
    background: color-mix(in srgb, var(--primary) 10%, transparent);
    color: var(--primary);
}

.sidebar-link:hover .ti,
.sidebar-link.active .ti {
    color: var(--primary);
}

.app-topbar {
    min-height: 72px;
    background: color-mix(in srgb, var(--card-bg) 88%, transparent);
    border-bottom-color: var(--border);
    backdrop-filter: blur(18px);
    padding: 14px clamp(18px, 2vw, 32px);
}

.topbar-title {
    font-size: clamp(18px, 1.45vw, 23px);
}

.app-content {
    
    padding: clamp(20px, 2vw, 32px);
}

.app-footer {
    
    width: 100%;
    margin: 0 auto;
    border-top-color: var(--border);
    color: var(--muted);
}

.page-heading {
    align-items: center;
    gap: var(--space-4);
    margin-bottom: var(--space-5);
}

.page-heading h2 {
    font-size: clamp(24px, 2vw, 34px);
    line-height: 1.08;
}

.page-heading-actions,
.topbar-actions,
.btn-list {
    flex-wrap: wrap;
}

.card,
.panel-card,
.data-card {
    background: var(--card-bg);
    border: 1px solid var(--soft-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.card {
    overflow: clip;
}

.panel-card:hover,
.data-card:hover,
.metric-card:hover {
    box-shadow: var(--shadow-md);
}

.card-header,
.panel-card .card-header,
.data-card .card-header,
.card-footer {
    background: color-mix(in srgb, var(--card-bg) 96%, var(--bg));
    border-color: var(--border);
    padding: 16px 18px;
}

.card-body {
    padding: 18px;
}

.metric-grid,
.kpi-grid,
.dashboard-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: var(--space-3);
}

.metric-card .card-body {
    min-height: 118px;
    padding: 17px;
}

.metric-icon {
    width: 42px;
    height: 42px;
    border-radius: 13px;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.16);
}

.metric-value {
    font-size: clamp(24px, 2vw, 32px);
    overflow-wrap: anywhere;
}

.metric-label {
    text-transform: none;
    line-height: 1.25;
}

.filter-bar {
    display: grid;
    gap: var(--space-3);
}

.filter-bar .form-label {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

[data-audit-pages-root] {
    min-width: 0;
    max-width: 100%;
}

[data-audit-pages-root] .filter-bar {
    grid-template-columns: minmax(240px, 2fr) repeat(3, minmax(150px, 1fr));
}

[data-audit-pages-root] .audit-pages-table td,
[data-audit-pages-root] .audit-pages-table th {
    min-width: 0;
    max-width: 360px;
    overflow-wrap: anywhere;
    word-break: break-word;
    white-space: normal;
}

[data-audit-pages-root] .audit-pages-table {
    width: 100%;
    table-layout: fixed;
}

[data-audit-pages-root] .table-responsive {
    max-width: 100%;
}

.ai-search-root {
    min-width: 0;
    max-width: 100%;
}

.ai-search-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-3);
}

.ai-search-header > div:first-child {
    min-width: 0;
    max-width: 820px;
}

.ai-search-summary-grid,
.ai-search-section-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: var(--space-3);
}

.ai-search-section-card h4 {
    font-size: 14px;
    line-height: 1.35;
}

.ai-search-section-card .progress {
    height: 7px;
}

.ai-search-recommendation-list {
    display: grid;
    gap: 10px;
}

.ai-search-recommendation {
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr);
    align-items: start;
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: color-mix(in srgb, var(--card-bg) 96%, var(--bg));
}

.ai-search-filter-grid {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) 110px;
    gap: 10px;
    max-width: 720px;
}

.ai-search-page-table {
    width: 100%;
    table-layout: fixed;
}

.ai-search-page-table th,
.ai-search-page-table td {
    min-width: 0;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
}

@media (max-width: 767.98px) {
    .ai-search-header {
        display: grid;
    }

    .ai-search-header .btn-list {
        width: 100%;
    }

    .ai-search-header .btn {
        flex: 1 1 auto;
    }

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

@media (max-width: 991.98px) {
    [data-audit-pages-root] .filter-bar {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 575.98px) {
    [data-audit-pages-root] .filter-bar {
        grid-template-columns: minmax(0, 1fr);
    }
}

.form-control,
.form-select {
    border-radius: 12px;
    border-color: var(--border);
    background-color: var(--card-bg);
    color: var(--text);
}

.form-control:focus,
.form-select:focus,
.btn:focus-visible,
.sidebar-link:focus-visible,
.theme-option:focus-visible {
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 18%, transparent);
    border-color: var(--primary);
    outline: 0;
}

.btn {
    border-radius: 12px;
    min-height: 38px;
}

.btn-sm {
    min-height: 32px;
    border-radius: 10px;
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
}

.btn-primary:hover {
    background: color-mix(in srgb, var(--primary) 84%, #000);
    border-color: color-mix(in srgb, var(--primary) 84%, #000);
}

.alert,
.empty-inline,
.detail-tile,
.quick-actions-grid a,
.queue-summary > div,
.note-item,
.mini-record {
    border-color: var(--border);
    border-radius: var(--radius-md);
}

.empty-inline,
.detail-tile,
.quick-actions-grid a,
.queue-summary > div,
.note-item {
    background: color-mix(in srgb, var(--card-bg) 92%, var(--bg));
}

.empty-state {
    min-height: 220px;
    border: 1px dashed var(--border);
    border-radius: var(--radius-lg);
    background: color-mix(in srgb, var(--card-bg) 88%, var(--bg));
}

.empty-state .empty-icon,
.empty-state > .ti {
    width: 48px;
    height: 48px;
    border-radius: 15px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: color-mix(in srgb, var(--primary) 12%, transparent);
    color: var(--primary);
    margin-bottom: 12px;
}

.table-responsive {
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.table-toolbar {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    background: color-mix(in srgb, var(--card-bg) 94%, var(--bg));
}

.table-search {
    position: relative;
    width: min(100%, 340px);
}

.table-search .ti {
    position: absolute;
    left: 11px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    z-index: 2;
}

.table-search .form-control {
    padding-left: 34px;
}

.table {
    color: var(--text);
    margin-bottom: 0;
}

.table thead th {
    color: var(--muted);
    background: color-mix(in srgb, var(--card-bg) 90%, var(--bg));
    border-bottom-color: var(--border);
    white-space: nowrap;
}

.table td {
    border-color: var(--border);
}

.table tbody tr {
    transition: background 140ms ease;
}

.table tbody tr:hover {
    background: color-mix(in srgb, var(--primary) 5%, transparent);
}

.responsive-table-tools {
    display: inline-flex;
    gap: 4px;
    margin-left: 6px;
    vertical-align: middle;
}

.url-action {
    display: inline-flex;
    width: 24px;
    height: 24px;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--card-bg);
    color: var(--muted);
    cursor: pointer;
}

.url-action:hover {
    color: var(--primary);
    border-color: color-mix(in srgb, var(--primary) 45%, var(--border));
}

.url-wrap {
    color: var(--primary);
    word-break: break-word;
    overflow-wrap: anywhere;
    white-space: normal;
}

.audit-section-nav ~ [data-audit-section] .table {
    width: 100%;
    max-width: 100%;
}

.audit-section-nav ~ [data-audit-section] .table th,
.audit-section-nav ~ [data-audit-section] .table td,
.audit-section-nav ~ [data-audit-section] .table td > * {
    min-width: 0;
    max-width: 100%;
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.audit-section-nav ~ [data-audit-section] .table .badge {
    white-space: normal;
}

@media (max-width: 1199.98px) {
    .audit-section-nav ~ [data-audit-section] .responsive-table {
        overflow: visible;
    }

    .audit-section-nav ~ [data-audit-section] .responsive-table table,
    .audit-section-nav ~ [data-audit-section] .responsive-table thead,
    .audit-section-nav ~ [data-audit-section] .responsive-table tbody,
    .audit-section-nav ~ [data-audit-section] .responsive-table tr,
    .audit-section-nav ~ [data-audit-section] .responsive-table th,
    .audit-section-nav ~ [data-audit-section] .responsive-table td {
        display: block;
        width: 100%;
    }

    .audit-section-nav ~ [data-audit-section] .responsive-table thead {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
    }

    .audit-section-nav ~ [data-audit-section] .responsive-table tbody {
        display: grid;
        gap: 12px;
        padding: 12px;
    }

    .audit-section-nav ~ [data-audit-section] .responsive-table tr {
        border: 1px solid var(--border);
        border-radius: var(--radius-md);
        background: var(--card-bg);
        box-shadow: var(--shadow-sm);
        overflow: hidden;
    }

    .audit-section-nav ~ [data-audit-section] .responsive-table td {
        display: grid;
        grid-template-columns: minmax(120px, 28%) minmax(0, 1fr);
        gap: 10px;
        min-height: 42px;
        align-items: start;
        border-bottom: 1px solid var(--border);
        padding: 10px 12px;
    }

    .audit-section-nav ~ [data-audit-section] .responsive-table td:last-child {
        border-bottom: 0;
    }

    .audit-section-nav ~ [data-audit-section] .responsive-table td::before {
        content: attr(data-label);
        color: var(--muted);
        font-size: 11px;
        font-weight: 900;
        text-transform: uppercase;
    }
}

.theme-switcher {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    padding: 4px;
    margin-bottom: 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: color-mix(in srgb, var(--card-bg) 86%, var(--bg));
}

.theme-option {
    border: 0;
    border-radius: 9px;
    min-height: 30px;
    background: transparent;
    color: var(--muted);
}

.theme-option.active {
    background: var(--card-bg);
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.dashboard-hero,
.audit-hero {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(280px, .7fr);
    gap: var(--space-4);
    margin-bottom: var(--space-4);
}

.dashboard-kpi-grid > [class*="col-"],
.metric-grid > [class*="col-"],
.kpi-grid > [class*="col-"] {
    width: auto;
    max-width: none;
    padding: 0;
}

.hero-panel {
    border: 1px solid var(--soft-border);
    border-radius: var(--radius-lg);
    background:
        linear-gradient(135deg, color-mix(in srgb, var(--primary) 11%, transparent), transparent 46%),
        var(--card-bg);
    box-shadow: var(--shadow-sm);
    padding: clamp(20px, 2vw, 30px);
}

.hero-panel h2,
.hero-panel h3 {
    color: var(--text);
    margin: 0 0 8px;
}

.hero-panel p {
    color: var(--muted);
    margin: 0;
    max-width: 760px;
}

.quick-actions-grid {
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
}

.quick-actions-grid a {
    min-height: 126px;
    border-radius: var(--radius-md);
}

.workflow-step {
    align-items: start;
}

.workflow-number {
    border-radius: 14px;
    background: color-mix(in srgb, var(--primary) 12%, transparent);
    color: var(--primary);
}

.audit-section-nav {
    position: sticky;
    top: 78px;
    z-index: 999;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    max-width: 100%;
    min-width: 0;
    overflow: visible;
    padding: 10px;
    margin-bottom: var(--space-4);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: color-mix(in srgb, var(--card-bg) 92%, transparent);
    backdrop-filter: blur(14px);
    box-shadow: var(--shadow-sm);
}

.audit-section-tab {
    flex: 0 1 auto;
    max-width: 100%;
    min-width: 0;
    border: 1px solid transparent;
    border-radius: 999px;
    background: transparent;
    color: var(--muted);
    padding: 8px 13px;
    font-weight: 800;
    line-height: 1.25;
    white-space: normal;
    overflow-wrap: anywhere;
    text-align: center;
}

.audit-section-tab.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.audit-section-select {
    display: none;
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

@media (max-width: 767.98px) {
    .audit-section-nav {
        display: block;
        top: 68px;
        padding: 8px;
    }

    .audit-section-tab {
        display: none;
    }

    .audit-section-select {
        display: block;
    }
}

body.page-audits [data-audit-section].is-hidden {
    display: none !important;
}

.section-stack {
    display: grid;
    gap: var(--space-4);
}

.badge {
	color:#fff;
    border-radius: 999px;
}

body[data-resolved-theme="dark"] .bg-secondary,
body[data-theme="dark"] .bg-secondary {
    background-color: #475569 !important;
}

@media (max-width: 1366px) {
    .app-content {
        padding: 24px;
    }

    .metric-grid,
    .kpi-grid,
    .dashboard-kpi-grid {
        grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    }
}

@media (max-width: 1199.98px) {
    .dashboard-hero,
    .audit-hero {
        grid-template-columns: 1fr;
    }

    .table .priority-low,
    .table .hide-xl {
        display: none;
    }
}

@media (max-width: 991.98px) {
    .app-sidebar {
        transform: translateX(-100%);
        background: var(--card-bg);
    }

    body.sidebar-open {
        overflow: hidden;
    }

    .app-main {
        margin-left: 0;
    }

    .app-content {
        padding: 20px;
    }

    .page-heading {
        align-items: stretch;
    }

    .page-heading-actions .btn,
    .page-heading-actions form,
    .topbar-actions .btn,
    .topbar-actions form {
        width: auto;
    }
}

@media (max-width: 767.98px) {
    .app-content {
        padding: 16px 14px 84px;
    }

    .app-topbar {
        align-items: flex-start;
    }

    .topbar-actions {
        margin-left: 0;
        width: 100%;
        justify-content: flex-start;
    }

    .page-heading {
        margin-bottom: 18px;
    }

    .page-heading-actions {
        position: sticky;
        bottom: 10px;
        z-index: 1005;
        display: flex;
        padding: 10px;
        border: 1px solid var(--border);
        border-radius: var(--radius-lg);
        background: color-mix(in srgb, var(--card-bg) 94%, transparent);
        box-shadow: var(--shadow-md);
        backdrop-filter: blur(16px);
    }

    .page-heading-actions .btn,
    .page-heading-actions form,
    .page-heading-actions .workflow-controls {
        flex: 1 1 auto;
    }

    .page-heading-actions .btn {
        width: 100%;
        justify-content: center;
    }

    .card-header {
        align-items: flex-start;
        gap: 10px;
        flex-direction: column;
    }

    .card-actions {
        width: 100%;
    }

    .responsive-table {
        overflow: visible;
    }

    .responsive-table table,
    .responsive-table thead,
    .responsive-table tbody,
    .responsive-table tr,
    .responsive-table th,
    .responsive-table td {
        display: block;
        width: 100%;
    }

    .responsive-table thead {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
    }

    .responsive-table tbody {
        display: grid;
        gap: 12px;
        padding: 12px;
    }

    .responsive-table tr {
        border: 1px solid var(--border);
        border-radius: var(--radius-md);
        background: var(--card-bg);
        box-shadow: var(--shadow-sm);
        overflow: hidden;
    }

    .responsive-table td {
        display: grid;
        grid-template-columns: minmax(106px, 36%) minmax(0, 1fr);
        gap: 10px;
        min-height: 42px;
        align-items: start;
        border-bottom: 1px solid var(--border);
        padding: 10px 12px;
    }

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

    .responsive-table td::before {
        content: attr(data-label);
        color: var(--muted);
        font-size: 11px;
        font-weight: 900;
        text-transform: uppercase;
        letter-spacing: 0;
    }

    .responsive-table td[colspan] {
        display: block;
    }

    .responsive-table td[colspan]::before {
        display: none;
    }

    .table-responsive:not(.responsive-table) {
        overflow-x: auto;
    }
}

@media (max-width: 575.98px) {
    .app-topbar {
        flex-wrap: wrap;
        gap: 10px;
    }

    .topbar-title {
        font-size: 18px;
    }

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

    .metric-card .card-body {
        min-height: 104px;
    }

    .responsive-table td {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .btn-list,
    .card-actions .btn-list {
        width: 100%;
    }

    .btn-list .btn,
    .btn-list form {
        flex: 1 1 auto;
    }
}

@media (max-width: 420px) {
    .app-content {
        padding-inline: 12px;
    }

    .card-body,
    .card-header {
        padding: 14px;
    }
}

@media print {
    .responsive-table-tools,
    .url-action,
    .theme-switcher,
    .table-toolbar,
    .audit-section-nav {
        display: none !important;
    }
}

/* ============================================================
   Top-navigation redesign layer (authoritative, source-last)
   ============================================================ */

/* Legacy sidebar shell is fully replaced — neutralise any remnant. */
.app-sidebar,
.app-sidebar-backdrop,
.app-topbar {
    display: none !important;
}

.app-main {
    margin-left: 0 !important;
}

/* Column priority helpers for dense tables. */
@media (max-width: 1199.98px) {
    .hide-lg {
        display: none !important;
    }
}

@media (max-width: 991.98px) {
    .hide-md {
        display: none !important;
    }
}

/* Wrapping action button rows (replaces btn-list flex-nowrap). */
.action-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    min-width: 0;
}

/* Responsive form grid. */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr));
    gap: 16px;
}

.form-grid .form-control,
.form-grid .form-select,
.form-control,
.form-select,
textarea {
    max-width: 100%;
    min-width: 0;
}

/* Full-URL component (render_full_url()). */
.url-box {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: start;
    max-width: 100%;
    min-width: 0;
}

.url-box .url-wrap {
    display: block;
    min-width: 0;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.url-actions {
    display: inline-flex;
    gap: 6px;
    flex-wrap: wrap;
}

.btn-icon {
    display: inline-flex;
    width: 30px;
    height: 30px;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--card-bg);
    color: var(--muted);
    cursor: pointer;
}

.btn-icon:hover {
    color: var(--primary);
    border-color: color-mix(in srgb, var(--primary) 45%, var(--border));
}

@media (max-width: 575.98px) {
    .url-box {
        grid-template-columns: 1fr;
    }
}

/* Collapsible error details (PageSpeed etc.). */
.error-details summary {
    cursor: pointer;
    font-size: 12px;
    color: var(--muted);
}

.error-text {
    margin-top: 4px;
    overflow-wrap: anywhere;
    word-break: break-word;
    font-size: 12px;
}

/* ---------- Tablet / mobile: collapse top menu into a drawer ---------- */
@media (max-width: 991.98px) {
    .top-nav-inner {
        flex-wrap: wrap;
        gap: 10px;
    }

    .nav-toggle {
        display: inline-flex;
    }

    .top-nav-menu {
        position: fixed;
        inset: 64px 0 auto 0;
        flex-direction: column;
        align-items: stretch;
        gap: 4px;
        max-height: calc(100vh - 64px);
        overflow-y: auto;
        background: var(--card-bg);
        border-bottom: 1px solid var(--border);
        box-shadow: var(--shadow-md);
        padding: 12px;
        transform: translateY(-12px);
        opacity: 0;
        pointer-events: none;
        transition: opacity 160ms ease, transform 160ms ease;
        z-index: 1035;
    }

    body.nav-open .top-nav-menu {
        transform: translateY(0);
        opacity: 1;
        pointer-events: auto;
    }

    .nav-link {
        width: 100%;
        min-height: 46px;
        font-size: 15px;
    }

    .nav-drawer-extra {
        display: flex;
        flex-direction: column;
        gap: 12px;
        margin-top: 10px;
        padding-top: 14px;
        border-top: 1px solid var(--border);
    }

    .nav-drawer-user {
        line-height: 1.3;
    }

    .top-nav-actions .nav-action-cta span,
    .top-nav-actions .nav-action-logout {
        display: none;
    }

    body.nav-open .nav-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 1025;
        background: rgba(15, 23, 42, 0.4);
    }
}

@media (min-width: 992px) {
    .nav-drawer-extra {
        display: none !important;
    }
}

@media (max-width: 575.98px) {
    .app-container {
        padding: 14px;
    }

    .app-footer {
        flex-direction: column;
        gap: 6px;
        padding: 14px;
    }

    .top-nav-brand-text {
        display: none;
    }

    .action-bar {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .action-bar .btn {
        width: 100%;
        justify-content: center;
    }
}

/* Keep print/PDF clean — never render the app chrome. */
@media print {
    .top-nav,
    .nav-backdrop,
    .app-footer,
    .url-actions {
        display: none !important;
    }

    .app-container {
        padding: 0 !important;
        max-width: 100% !important;
    }
}
