:root {
    --bg: #f1f5f9;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --sidebar: #ffffff;
    --sidebar-2: #eff6ff;
    --text: #0f172a;
    --muted: #64748b;
    --faint: #94a3b8;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-soft: #eff6ff;
    --accent: #f97316;
    --info: #0ea5e9;
    --warning: #d97706;
    --border: #e2e8f0;
    --border-soft: #f1f5f9;
    --danger: #dc2626;
    --success: #16a34a;
    --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 6px 16px rgba(15, 23, 42, 0.06);
}

* {
    box-sizing: border-box;
}

html {
    font-size: 14px;
}

body {
    margin: 0;
    font-family: Inter, "Segoe UI", Roboto, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.45;
}

a {
    color: inherit;
}

.shell {
    display: grid;
    grid-template-columns: 232px minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    position: sticky;
    top: 0;
    align-self: start;
    min-height: 100vh;
    background: var(--sidebar);
    border-right: 1px solid var(--border);
    padding: 18px 14px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.brand {
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    padding: 2px 4px 14px;
    border-bottom: 1px solid var(--border);
}

.brand strong {
    display: block;
    color: var(--text);
    font-size: 1rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.brand span {
    display: block;
    color: var(--muted);
    font-size: 0.76rem;
    margin-top: 1px;
}

.brand-mark {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--primary), var(--info));
    color: white;
    display: grid;
    place-items: center;
    font-weight: 800;
    letter-spacing: 0;
}

.nav {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.nav a,
.logout {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    text-decoration: none;
    color: #475569;
    padding: 8px 10px;
    border-radius: 6px;
    border: 1px solid transparent;
    background: transparent;
    text-align: left;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
}

.nav-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.nav a:hover,
.logout:hover {
    background: var(--sidebar-2);
    border-color: var(--border);
    color: var(--primary-dark);
}

.sidebar form {
    margin-top: auto;
}

.logout {
    color: var(--danger);
}

.content {
    min-width: 0;
    padding: 22px 24px 32px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    align-items: end;
    margin-bottom: 18px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
}

.topbar h1 {
    margin: 0 0 3px;
    font-size: 1.42rem;
    line-height: 1.2;
    font-weight: 750;
    letter-spacing: 0;
}

.topbar p {
    margin: 0;
    color: var(--muted);
    font-size: 0.92rem;
}

.cards,
.grid {
    display: grid;
    gap: 14px;
}

.cards.four {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-bottom: 14px;
}

.cards.three {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-bottom: 14px;
}

.grid.two {
    grid-template-columns: minmax(320px, 0.85fr) minmax(0, 1.15fr);
    align-items: start;
}

.grid.two.balanced {
    grid-template-columns: minmax(320px, 1fr) minmax(320px, 1fr);
}

.card,
.panel,
.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow);
}

.card {
    padding: 14px 15px;
    min-height: 94px;
}

.panel,
.login-card {
    padding: 16px;
}

.card span {
    display: block;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.card strong {
    display: block;
    margin-top: 7px;
    font-size: 1.6rem;
    line-height: 1.08;
    font-weight: 760;
    color: var(--text);
    overflow-wrap: anywhere;
}

.card .delta {
    display: block;
    margin-top: 6px;
    font-size: 0.78rem;
    font-weight: 700;
}

.delta.trend-up {
    color: var(--success);
}

.delta.trend-down {
    color: var(--danger);
}

.delta.trend-flat {
    color: var(--muted);
}

.trend-up::before {
    content: "\25B2 ";
}

.trend-down::before {
    content: "\25BC ";
}

.trend-flat::before {
    content: "\25AC ";
}

.panel h2,
.panel h3 {
    margin: 0 0 10px;
    color: var(--text);
    font-size: 1rem;
    line-height: 1.25;
    font-weight: 740;
}

.panel p {
    margin: 0 0 12px;
}

.panel > p:last-child {
    margin-bottom: 0;
}

.muted {
    color: var(--muted);
    font-size: 0.9rem;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    overflow: hidden;
}

thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--surface-2);
    color: #475569;
    font-size: 0.74rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

th,
td {
    padding: 9px 10px;
    border-bottom: 1px solid var(--border-soft);
    text-align: left;
    font-size: 0.88rem;
    vertical-align: middle;
}

tbody tr:hover {
    background: var(--surface-2);
}

tbody tr:last-child td {
    border-bottom: 0;
}

td strong {
    font-weight: 720;
}

.stack-form {
    display: grid;
    gap: 10px;
}

label {
    display: grid;
    gap: 5px;
    color: #475569;
    font-size: 0.82rem;
    font-weight: 700;
}

input,
select,
button {
    font: inherit;
}

input,
select {
    min-height: 36px;
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 10px;
    background: white;
    color: var(--text);
    outline: none;
}

input:focus,
select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.13);
}

input[readonly] {
    background: var(--surface-2);
    color: var(--muted);
}

button,
.button-link {
    min-height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: 1px solid transparent;
    border-radius: 6px;
    padding: 7px 11px;
    background: var(--primary);
    color: white;
    text-decoration: none;
    font-size: 0.84rem;
    font-weight: 750;
    cursor: pointer;
    white-space: nowrap;
}

button:hover,
.button-link:hover {
    background: var(--primary-dark);
}

button.secondary {
    background: var(--danger);
}

button.secondary:hover {
    background: #b91c1c;
}

.button-link {
    background: var(--info);
}

.button-link:hover {
    background: #0284c7;
}

.button-link.small,
button.small {
    min-height: 28px;
    padding: 4px 9px;
    font-size: 0.78rem;
}

.button-link.outline {
    background: transparent;
    color: var(--primary);
    border: 1px solid var(--border);
}

.button-link.outline:hover {
    background: var(--sidebar-2);
}

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

.panel-head.compact {
    display: block;
    margin-bottom: 10px;
}

.panel-head h2,
.panel-head h3,
.panel-head p {
    margin: 0;
}

.panel-head p {
    margin-top: 3px;
}

.actions {
    display: flex;
    gap: 7px;
    flex-wrap: wrap;
    align-items: center;
}

.actions form {
    margin: 0;
}

.feed {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 8px;
}

.feed li {
    padding: 10px 11px;
    border: 1px solid var(--border-soft);
    border-radius: 7px;
    background: var(--surface-2);
}

.feed li strong,
.feed li span,
.feed li small {
    display: block;
}

.feed li span,
.feed li small {
    color: var(--muted);
    font-size: 0.82rem;
}

.live-map {
    min-height: 410px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border);
    background: var(--surface-2);
}

.map-panel {
    padding: 14px;
}

.service-line-map {
    min-height: 340px;
}

.map-preview-block {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--border-soft);
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 3px 8px;
    border-radius: 999px;
    background: var(--surface-2);
    color: #334155;
    font-size: 0.74rem;
    font-weight: 800;
    letter-spacing: 0.02em;
}

.badge.ready {
    background: #dcfce7;
    color: #15803d;
}

.badge.failed {
    background: #fee2e2;
    color: #b91c1c;
}

.badge.missing {
    background: #fef3c7;
    color: var(--warning);
}

.badge.severity-high {
    background: #fee2e2;
    color: #b91c1c;
}

.badge.severity-medium {
    background: #fef3c7;
    color: #b45309;
}

.badge.severity-low {
    background: #dbeafe;
    color: #1d4ed8;
}

.table-note {
    margin-top: 4px;
    color: var(--faint);
    font-size: 0.78rem;
}

/* Rank badges for ranking tables */
.rank-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 999px;
    background: var(--surface-2);
    color: #475569;
    font-size: 0.78rem;
    font-weight: 800;
}

.rank-badge.rank-1 {
    background: #fef3c7;
    color: #b45309;
}

.rank-badge.rank-2 {
    background: #e2e8f0;
    color: #475569;
}

.rank-badge.rank-3 {
    background: #fed7aa;
    color: #c2410c;
}

/* Inline coverage progress bar used inside table cells */
.mini-bar {
    display: flex;
    align-items: center;
    gap: 8px;
}

.mini-bar .track {
    flex: 1;
    height: 6px;
    min-width: 60px;
    background: var(--border);
    border-radius: 999px;
    overflow: hidden;
}

.mini-bar .fill {
    display: block;
    height: 100%;
    border-radius: 999px;
    background: var(--primary);
}

.mini-bar .fill.good {
    background: var(--success);
}

.mini-bar .fill.warn {
    background: var(--warning);
}

.mini-bar .fill.bad {
    background: var(--danger);
}

.mini-bar span {
    font-size: 0.82rem;
    font-weight: 750;
    min-width: 46px;
    text-align: right;
}

/* Chart.js canvas containers */
.chart-wrap {
    position: relative;
    height: 260px;
}

.chart-wrap.tall {
    height: 340px;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    border-bottom: 1px solid var(--border);
    margin-bottom: 14px;
}

.tabs a {
    display: inline-block;
    padding: 8px 14px;
    margin-bottom: -1px;
    border: 1px solid transparent;
    border-radius: 6px 6px 0 0;
    font-size: 0.86rem;
    font-weight: 700;
    color: var(--muted);
    text-decoration: none;
}

.tabs a:hover {
    color: var(--primary);
}

.tabs a.active {
    color: var(--primary);
    background: var(--surface);
    border-color: var(--border);
    border-bottom-color: var(--surface);
}

/* Filter bar (date range, scope filters) */
.filter-bar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: end;
    margin-bottom: 14px;
}

.filter-bar label {
    min-width: 150px;
}

.filter-bar .filter-actions {
    display: flex;
    gap: 8px;
}

/* Toggle switch for report generation panel */
.toggle-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-soft);
}

.toggle-row:last-child {
    border-bottom: 0;
}

.toggle-row strong {
    display: block;
    font-size: 0.9rem;
}

.toggle-row span {
    display: block;
    color: var(--muted);
    font-size: 0.8rem;
    margin-top: 2px;
}

.switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
    flex-shrink: 0;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.switch .slider {
    position: absolute;
    inset: 0;
    background: #cbd5e1;
    transition: 0.15s;
    border-radius: 999px;
    cursor: pointer;
}

.switch .slider::before {
    content: "";
    position: absolute;
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background: white;
    transition: 0.15s;
    border-radius: 50%;
}

.switch input:checked + .slider {
    background: var(--primary);
}

.switch input:checked + .slider::before {
    transform: translateX(18px);
}

/* Exception category breakdown bars */
.category-list {
    display: grid;
    gap: 10px;
}

.category-row .category-head {
    display: flex;
    justify-content: space-between;
    font-size: 0.84rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.category-row .track {
    height: 8px;
    background: var(--border);
    border-radius: 999px;
    overflow: hidden;
}

.category-row .fill {
    display: block;
    height: 100%;
    border-radius: 999px;
    background: var(--primary);
}

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        linear-gradient(rgba(15, 23, 42, 0.78), rgba(15, 23, 42, 0.78)),
        url("https://images.unsplash.com/photo-1519750783826-e2420f4d687f?auto=format&fit=crop&w=1600&q=80") center/cover;
}

.login-card {
    width: min(390px, 100%);
    padding: 22px;
}

.login-card h1 {
    margin: 0;
    font-size: 1.35rem;
    line-height: 1.2;
}

.login-card p {
    margin: 8px 0 16px;
    color: var(--muted);
    font-size: 0.9rem;
}

.login-card form {
    display: grid;
    gap: 11px;
}

.login-card button {
    width: 100%;
    margin-top: 2px;
}

.credential-list {
    display: grid;
    gap: 6px;
    margin: 12px 0 16px;
}

.credential-list code {
    display: block;
    padding: 7px 9px;
    border: 1px solid var(--border-soft);
    border-radius: 6px;
    background: var(--surface-2);
    color: #334155;
    font-family: "Segoe UI Mono", Consolas, monospace;
    font-size: 0.8rem;
}

.error,
.success {
    margin-top: 12px;
    padding: 8px 10px;
    border-radius: 6px;
    font-weight: 700;
}

.error {
    background: #fee2e2;
    color: var(--danger);
}

.success {
    background: #dcfce7;
    color: #15803d;
}

.error-banner {
    margin-top: 12px;
    padding: 8px 10px;
    border-radius: 6px;
    font-weight: 700;
    background: #fee2e2;
    color: var(--danger);
}

@media (max-width: 1180px) {
    .cards.four {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

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

    .grid.two,
    .grid.two.balanced {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 760px) {
    html {
        font-size: 13px;
    }

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

    .sidebar {
        position: static;
        min-height: auto;
        border-right: none;
        padding: 14px;
    }

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

    .content {
        padding: 16px;
    }

    .topbar {
        align-items: start;
    }

    .cards.four,
    .cards.three {
        grid-template-columns: 1fr;
    }

    .panel {
        overflow-x: auto;
    }

    table {
        min-width: 680px;
    }

    .filter-bar label {
        min-width: 0;
        flex: 1 1 140px;
    }
}

/* Topbar user chip */
.user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--info));
    color: white;
    display: grid;
    place-items: center;
    font-weight: 800;
    flex-shrink: 0;
}

.user-chip strong {
    display: block;
    font-size: 0.88rem;
    color: var(--text);
}

.role-badge {
    display: inline-block;
    margin-top: 2px;
    padding: 1px 8px;
    border-radius: 999px;
    background: var(--primary-soft);
    color: var(--primary-dark);
    font-size: 0.72rem;
    font-weight: 700;
}

/* Demo mode banner */
.demo-banner {
    margin-bottom: 14px;
    padding: 9px 14px;
    border-radius: 8px;
    background: #fffbeb;
    border: 1px solid #fde68a;
    color: var(--warning);
    font-size: 0.86rem;
    font-weight: 600;
}

/* Dashboard card icon badges */
.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.card-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    flex-shrink: 0;
}

.card-icon svg {
    width: 16px;
    height: 16px;
}

.card-icon.blue {
    background: var(--primary-soft);
    color: var(--primary);
}

.card-icon.green {
    background: #dcfce7;
    color: var(--success);
}

.card-icon.orange {
    background: #fff7ed;
    color: var(--accent);
}

.card-icon.red {
    background: #fee2e2;
    color: var(--danger);
}

/* AI insights panel */
.ai-panel {
    border-left: 3px solid var(--primary);
}

.ai-insight-text {
    margin: 8px 0 0;
    color: var(--text);
    font-size: 0.92rem;
    line-height: 1.6;
}

/* AI assistant chat widget */
.ai-chat {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 50;
}

.ai-chat-toggle {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    border: none;
    display: grid;
    place-items: center;
    box-shadow: var(--shadow);
    cursor: pointer;
}

.ai-chat-toggle:hover {
    background: var(--primary-dark);
}

.ai-chat-toggle svg {
    width: 24px;
    height: 24px;
}

.ai-chat-panel {
    position: absolute;
    right: 0;
    bottom: 64px;
    width: min(340px, 90vw);
    max-height: 70vh;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.ai-chat-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    font-size: 0.88rem;
}

.ai-chat-close {
    background: transparent;
    border: none;
    color: var(--muted);
    font-size: 1.1rem;
    line-height: 1;
    padding: 0 2px;
    min-height: auto;
}

.ai-chat-close:hover {
    background: transparent;
    color: var(--text);
}

.ai-chat-messages {
    flex: 1;
    min-height: 120px;
    max-height: 320px;
    overflow-y: auto;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ai-msg {
    padding: 7px 10px;
    border-radius: 8px;
    font-size: 0.84rem;
    line-height: 1.45;
    max-width: 90%;
}

.ai-msg-bot {
    background: var(--surface-2);
    color: var(--text);
    align-self: flex-start;
}

.ai-msg-user {
    background: var(--primary);
    color: white;
    align-self: flex-end;
}

.ai-chat-form {
    display: flex;
    gap: 6px;
    padding: 10px 12px;
    border-top: 1px solid var(--border);
}

.ai-chat-form input {
    flex: 1;
}

/* Error pages */
.error-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 10px;
    padding: 48px 24px;
}

.error-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: grid;
    place-items: center;
}

.error-icon svg {
    width: 32px;
    height: 32px;
}

.error-icon-warning {
    background: #fff7ed;
    color: var(--accent);
}

.error-icon-info {
    background: var(--primary-soft);
    color: var(--primary);
}

.error-icon-danger {
    background: #fee2e2;
    color: var(--danger);
}

.error-state h2 {
    margin: 4px 0 0;
    font-size: 1.25rem;
}

.error-state p {
    margin: 0;
    color: var(--muted);
    max-width: 480px;
}

.error-actions {
    display: flex;
    gap: 10px;
    margin-top: 8px;
}

/* ============================================================
   Sophisticated dashboard + live monitoring components
   ============================================================ */

.empty-state {
    margin: 8px 0 2px;
    padding: 18px;
    border: 1px dashed var(--border);
    border-radius: 10px;
    background: var(--surface-2);
    color: var(--muted);
    font-size: 0.86rem;
    text-align: center;
}

/* Hero grid: coverage gauge + AI briefing */
.hero-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
    gap: 16px;
    margin-bottom: 16px;
}

.hero-grid .ai-panel {
    margin: 0;
}

.gauge-panel {
    margin: 0;
}

.gauge-wrap {
    display: grid;
    grid-template-columns: 200px minmax(0, 1fr);
    align-items: center;
    gap: 20px;
}

.gauge-chart {
    position: relative;
    width: 200px;
    height: 130px;
}

.gauge-center {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 4px;
    text-align: center;
}

.gauge-center strong {
    display: block;
    font-size: 2rem;
    font-weight: 800;
    line-height: 1;
    color: var(--text);
}

.gauge-center span {
    font-size: 0.74rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

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

.gauge-stat {
    background: var(--surface-2);
    border: 1px solid var(--border-soft);
    border-radius: 10px;
    padding: 10px 12px;
}

.gauge-stat span {
    display: block;
    font-size: 0.74rem;
    color: var(--muted);
}

.gauge-stat strong {
    font-size: 1.3rem;
    font-weight: 700;
}

.gauge-stat strong.is-warn {
    color: var(--warning);
}

.ai-spark {
    color: var(--accent);
    margin-right: 4px;
}

/* KPI accent bar */
.card.kpi {
    position: relative;
    overflow: hidden;
}

.card.kpi::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    border-radius: 4px 0 0 4px;
}

.card.kpi.accent-blue::before { background: var(--primary); }
.card.kpi.accent-green::before { background: var(--success); }
.card.kpi.accent-orange::before { background: var(--accent); }
.card.kpi.accent-red::before { background: var(--danger); }

/* Exception donut */
.donut-layout {
    display: grid;
    grid-template-columns: 170px minmax(0, 1fr);
    align-items: center;
    gap: 18px;
}

.donut-chart {
    position: relative;
    width: 170px;
    height: 170px;
}

.donut-legend {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.donut-legend li {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.86rem;
}

.donut-legend .legend-dot {
    width: 11px;
    height: 11px;
    border-radius: 3px;
    flex: 0 0 auto;
    background: var(--muted);
}

.donut-legend li:nth-child(1) .legend-dot { background: #2563eb; }
.donut-legend li:nth-child(2) .legend-dot { background: #f97316; }
.donut-legend li:nth-child(3) .legend-dot { background: #16a34a; }
.donut-legend li:nth-child(4) .legend-dot { background: #dc2626; }
.donut-legend li:nth-child(5) .legend-dot { background: #0ea5e9; }
.donut-legend li:nth-child(6) .legend-dot { background: #a855f7; }

.donut-legend .legend-label {
    flex: 1 1 auto;
    color: var(--text);
}

.donut-legend .legend-value {
    color: var(--muted);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/* Evidence strip */
.evidence-strip {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
}

.evidence-card {
    margin: 0;
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    background: #0f172a;
}

.evidence-card video {
    display: block;
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    background: #0f172a;
}

.evidence-card figcaption {
    padding: 8px 10px;
    background: var(--surface);
    display: grid;
    gap: 2px;
}

.evidence-card figcaption strong {
    font-size: 0.84rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.evidence-card figcaption span {
    font-size: 0.72rem;
    color: var(--muted);
}

.evidence-card .evidence-meta {
    display: flex;
    align-items: center;
    gap: 6px;
}

@media (max-width: 1100px) {
    .hero-grid,
    .gauge-wrap,
    .donut-layout {
        grid-template-columns: minmax(0, 1fr);
    }
    .gauge-chart {
        margin: 0 auto;
    }
}

/* ---- Live monitoring ---- */
.live-toolbar {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.live-pill {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    background: #fef2f2;
    color: var(--danger);
    border: 1px solid #fecaca;
    padding: 5px 12px;
    border-radius: 999px;
    font-size: 0.74rem;
    font-weight: 800;
    letter-spacing: 0.08em;
}

.pulse-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--danger);
    box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.6);
    animation: pulse 1.6s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.5); }
    70% { box-shadow: 0 0 0 8px rgba(220, 38, 38, 0); }
    100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0); }
}

.live-clock {
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    font-size: 1rem;
    color: var(--text);
}

.live-refresh {
    color: var(--muted);
    font-size: 0.82rem;
}

.live-refresh strong {
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

.stat-strip {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 16px;
}

.stat-pill {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 14px;
    box-shadow: var(--shadow);
}

.stat-pill-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
}

.stat-pill-icon svg { width: 19px; height: 19px; }
.stat-pill-icon.blue { background: var(--primary-soft); color: var(--primary); }
.stat-pill-icon.green { background: #dcfce7; color: var(--success); }
.stat-pill-icon.orange { background: #fff7ed; color: var(--accent); }

.stat-pill div span {
    display: block;
    font-size: 0.74rem;
    color: var(--muted);
}

.stat-pill div strong {
    font-size: 1.4rem;
    font-weight: 800;
    line-height: 1.1;
}

.live-grid {
    grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr);
}

.map-shell {
    position: relative;
}

.live-map {
    height: 460px;
    border-radius: 12px;
    border: 1px solid var(--border);
    z-index: 1;
}

.map-legend {
    position: absolute;
    left: 12px;
    bottom: 12px;
    z-index: 500;
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px 11px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    font-size: 0.74rem;
    color: var(--text);
    box-shadow: var(--shadow);
}

.map-legend span { display: flex; align-items: center; gap: 7px; }
.map-legend .lg-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.map-legend .lg-line { width: 16px; height: 3px; border-radius: 3px; background: var(--primary); display: inline-block; }

.feed-panel .live-feed {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 460px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.feed-row {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 10px 4px;
    border-bottom: 1px solid var(--border-soft);
}

.feed-row:last-child { border-bottom: none; }

.feed-badge {
    flex: 0 0 auto;
    font-size: 0.64rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    padding: 4px 8px;
    border-radius: 6px;
    min-width: 48px;
    text-align: center;
}

.feed-badge.scan-start { background: #dcfce7; color: #15803d; }
.feed-badge.scan-end { background: #fff7ed; color: #b45309; }

.feed-main { flex: 1 1 auto; min-width: 0; }
.feed-main strong { display: block; font-size: 0.9rem; font-weight: 700; }
.feed-main .feed-sub { font-size: 0.74rem; color: var(--muted); }

.feed-side { text-align: right; display: flex; flex-direction: column; gap: 3px; align-items: flex-end; }
.feed-side small { color: var(--muted); font-variant-numeric: tabular-nums; }

.conf-chip {
    font-size: 0.66rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 5px;
}

.conf-chip.ok { background: #ecfdf5; color: #047857; }
.conf-chip.low { background: #fef2f2; color: var(--danger); }

.feed-empty {
    color: var(--muted);
    font-size: 0.86rem;
    padding: 14px 4px;
}

@media (max-width: 1100px) {
    .live-grid { grid-template-columns: minmax(0, 1fr); }
    .stat-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* 3D route-performance towers (dashboard) */
.route3d-wrap {
    position: relative;
    width: 100%;
    height: 380px;
    border-radius: 14px;
    overflow: hidden;
    background: radial-gradient(120% 120% at 50% 0%, #f8fafc 0%, #eef2f7 60%, #e2e8f0 100%);
    border: 1px solid var(--border, #e2e8f0);
    touch-action: none;
}
.route3d-wrap canvas { display: block; }
.route3d-fallback {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    text-align: center;
    color: #64748b;
    font-size: 13px;
}
.route3d-tip {
    position: absolute;
    z-index: 6;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-width: 200px;
    padding: 8px 11px;
    border-radius: 10px;
    background: rgba(15, 23, 42, 0.94);
    color: #fff;
    font-size: 12px;
    line-height: 1.35;
    box-shadow: 0 10px 30px rgba(2, 6, 23, 0.35);
}
.route3d-tip strong { font-size: 13px; font-weight: 700; }
.route3d-tip span { color: #cbd5e1; }
.route3d-legend {
    display: flex;
    gap: 18px;
    margin-top: 12px;
    font-size: 12px;
    color: #64748b;
}
.route3d-legend .dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 3px;
    margin-right: 6px;
    vertical-align: middle;
}
.route3d-legend .dot.good { background: #16a34a; }
.route3d-legend .dot.warn { background: #f59e0b; }
.route3d-legend .dot.bad { background: #dc2626; }

/* Topbar actions: notifications bell + profile chip */
.topbar-actions { display: flex; align-items: center; gap: 14px; }
.user-chip { text-decoration: none; color: inherit; }
.bell { position: relative; display: inline-flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; border-radius: 12px; color: #475569; background: #f1f5f9;
    border: 1px solid var(--border, #e2e8f0); transition: background .15s ease; }
.bell:hover { background: #e2e8f0; }
.bell svg { width: 20px; height: 20px; }
.bell-badge { position: absolute; top: -5px; right: -5px; min-width: 18px; height: 18px; padding: 0 5px;
    border-radius: 9px; background: #dc2626; color: #fff; font-size: 11px; font-weight: 700;
    display: flex; align-items: center; justify-content: center; box-shadow: 0 0 0 2px #fff; }

/* AI quick tags */
.ai-tags { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 14px; }
.ai-tag { border: 1px solid var(--border, #e2e8f0); background: var(--primary-soft, #eff6ff);
    color: var(--primary-dark, #1d4ed8); border-radius: 999px; padding: 6px 12px; font-size: 12.5px;
    font-weight: 600; cursor: pointer; transition: background .15s ease, transform .1s ease; }
.ai-tag:hover { background: #dbeafe; transform: translateY(-1px); }

/* Inline AI assistant on the AI Analytics page */
.ai-page-messages { display: flex; flex-direction: column; gap: 10px; max-height: 360px; overflow-y: auto;
    padding: 6px; margin-bottom: 12px; }
.ai-page-form { display: flex; gap: 10px; }
.ai-page-form input { flex: 1; padding: 11px 14px; border: 1px solid var(--border, #e2e8f0); border-radius: 12px; font-size: 14px; }
.ai-page-form button { padding: 11px 20px; border: none; border-radius: 12px; background: var(--primary, #2563eb);
    color: #fff; font-weight: 600; cursor: pointer; }

/* Profile */
.profile-list { list-style: none; margin: 0; padding: 0; }
.profile-list li { display: flex; justify-content: space-between; gap: 16px; padding: 11px 0;
    border-bottom: 1px solid #f1f5f9; }
.profile-list li:last-child { border-bottom: none; }
.profile-list li span { color: #64748b; font-size: 13px; }
.profile-list li strong { text-align: right; }
.profile-list .badge { margin-left: 4px; }
tr.row-unread { background: #f8fbff; }
tr.row-unread td:first-child { box-shadow: inset 3px 0 0 var(--primary, #2563eb); }

/* Inline form hint (e.g. "configured per route in Service Lines"). */
.form-hint {
    margin: 0;
    font-size: 0.82rem;
    color: var(--muted);
}
.form-hint a { color: var(--primary); }

/* Service-line manual route drawing toolbar (above the preview map). */
.draw-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 0.75rem;
    margin: 0.5rem 0 0.65rem;
}
.draw-toolbar .form-hint {
    flex-basis: 100%;
}

/* Payment Gateways settings page. */
.back-link {
    margin: 0 0 0.5rem;
    font-size: 0.9rem;
}
.gateway-card-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.gateway-fields {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 0.75rem 1rem;
    margin-top: 0.75rem;
}
.gateway-fields label {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    font-size: 0.85rem;
    color: var(--muted);
}
.gateway-fields input {
    width: 100%;
}

/* Dispatcher manual assignment: compact inline route picker per taxi row. */
.inline-assign {
    display: flex;
    gap: 0.4rem;
    align-items: center;
    margin: 0;
}
.inline-assign select {
    max-width: 180px;
    padding: 0.3rem 0.4rem;
}
.inline-assign button.small {
    padding: 0.3rem 0.6rem;
    font-size: 0.8rem;
}
td.capacity-full {
    color: var(--danger);
    font-weight: 600;
}

/* Global table pagination controls (10 rows per page, see paginate.js). */
.table-pagination {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 0.75rem;
}
.table-pagination-label {
    font-size: 0.85rem;
    color: var(--muted);
}
.table-pagination button[disabled] {
    opacity: 0.4;
    cursor: default;
}
