:root {
    --bg: #080d18;
    --surface: #111827;
    --surface-hover: #172136;
    --surface-sunken: #0b1220;
    --border: #1f2a3d;

    --text: #e5eaf2;
    --text-dim: #94a3b8;
    --text-faint: #5b6b85;

    --accent-blue: #38bdf8;
    --accent-cyan: #22d3ee;
    --accent-lime: #a3e635;

    --sev-high: #f87171;
    --sev-medium: #fbbf24;
    --sev-low: #94a3b8;

    --cat-breaking: #fb7185;
    --cat-security: #fb923c;
    --cat-deprecation: #f97316;
    --cat-release: var(--accent-blue);
    --cat-feature: #c084fc;
    --cat-docs: #64748b;

    --radius: 10px;
    --radius-sm: 6px;
    --font-display: "Space Grotesk", var(--font-body);
    --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

    color-scheme: dark;
}

* {
    box-sizing: border-box;
}

body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text);
    margin: 0;
    min-height: 100vh;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    background:
        radial-gradient(640px circle at 12% -8%, rgba(56, 189, 248, 0.16), transparent 60%),
        radial-gradient(560px circle at 92% 8%, rgba(163, 230, 53, 0.09), transparent 60%),
        radial-gradient(720px circle at 50% 105%, rgba(34, 211, 238, 0.1), transparent 60%);
    pointer-events: none;
}

h1, h2 {
    font-family: var(--font-display);
    font-weight: 700;
}

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg);
}

::-webkit-scrollbar-thumb {
    background: var(--surface-hover);
    border-radius: 8px;
    border: 2px solid var(--bg);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border);
}

@keyframes fade-in-up {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 0 0 0 rgba(248, 113, 113, 0.45); }
    50% { box-shadow: 0 0 0 6px rgba(248, 113, 113, 0); }
}

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

/* Topbar */

.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}

.topbar-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 14px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.brand {
    display: flex;
    align-items: center;
    gap: 9px;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.05rem;
    text-decoration: none;
}

.brand-text {
    background: linear-gradient(90deg, var(--text) 0%, var(--accent-blue) 60%, var(--accent-cyan) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.brand-radar {
    display: inline-flex;
    width: 26px;
    height: 26px;
    filter: drop-shadow(0 0 6px rgba(56, 189, 248, 0.35));
}

.brand-radar-svg {
    width: 100%;
    height: 100%;
    overflow: visible;
}

.brand-radar-ring {
    fill: none;
    stroke: var(--border);
    stroke-width: 1;
}

.brand-radar-sweep {
    transform-origin: 16px 16px;
    animation: brand-radar-spin 3.4s linear infinite;
}

.brand-radar-blip {
    fill: var(--sev-medium);
}

.brand-radar-core {
    fill: var(--accent-cyan);
}

.main-nav {
    display: flex;
    gap: 4px;
}

.nav-item {
    position: relative;
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-dim);
    text-decoration: none;
    transition: color 0.15s ease, background 0.15s ease;
}

.nav-item::after {
    content: "";
    position: absolute;
    left: 14px;
    right: 14px;
    bottom: 1px;
    height: 2px;
    border-radius: 2px;
    background: linear-gradient(90deg, var(--accent-blue), var(--accent-cyan));
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.2s ease;
}

.nav-item:hover {
    color: var(--text);
    background: var(--surface-hover);
}

.nav-item.active {
    color: var(--accent-blue);
    background: rgba(56, 189, 248, 0.12);
}

.nav-item:hover::after,
.nav-item.active::after {
    transform: scaleX(1);
}

/* Page layout */

.page {
    max-width: 820px;
    margin: 0 auto;
    padding: 32px 24px 64px;
}

.page-wide {
    max-width: 1200px;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

h1 {
    margin: 0;
    font-size: 1.6rem;
}

/* Buttons */

#scan-all-btn,
.scan-tech-btn {
    padding: 8px 16px;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-cyan));
    color: var(--surface-sunken);
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: box-shadow 0.2s ease, transform 0.15s ease;
}

#scan-all-btn:hover,
.scan-tech-btn:hover {
    box-shadow: 0 0 18px rgba(56, 189, 248, 0.45);
    transform: translateY(-1px);
}

#scan-all-btn:active,
.scan-tech-btn:active {
    transform: translateY(0);
}

#scan-all-btn:disabled,
.scan-tech-btn:disabled {
    opacity: 0.5;
    cursor: default;
    background: var(--surface-hover);
    color: var(--text-faint);
    box-shadow: none;
    transform: none;
}

.scan-tech-btn {
    padding: 4px 12px;
    font-size: 0.78rem;
}

/* Technology tabs */

.tabs-card {
    margin-top: 24px;
    background: rgba(17, 24, 39, 0.7);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    animation: fade-in-up 0.4s ease both;
}

.tabs {
    display: flex;
    gap: 4px;
    padding: 8px 16px 0;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
}

.tab-btn {
    position: relative;
    background: none;
    border: none;
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-dim);
    padding: 10px 16px;
    cursor: pointer;
    white-space: nowrap;
}

.tab-btn::after {
    content: "";
    position: absolute;
    left: 14px;
    right: 14px;
    bottom: -1px;
    height: 2px;
    border-radius: 2px;
    background: linear-gradient(90deg, var(--accent-blue), var(--accent-cyan));
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.2s ease;
}

.tab-btn:hover {
    color: var(--text);
}

.tab-btn.active {
    color: var(--accent-blue);
}

.tab-btn.active::after {
    transform: scaleX(1);
}

.tech-panel {
    display: none;
    padding: 18px 20px;
}

.tech-panel.active {
    display: block;
}

.source-rows {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 18px;
}

.source-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-sunken);
}

.source-row-main {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.source-row-name {
    font-weight: 600;
    font-size: 0.88rem;
    color: var(--text);
}

.source-row-status {
    display: block;
    font-size: 0.78rem;
    color: var(--text-faint);
    min-height: 1.1em;
}

.source-row-status.flash-success {
    animation: status-flash-success 3s ease forwards;
    font-weight: 600;
}

.source-row-status.flash-error {
    animation: status-flash-error 3s ease forwards;
    font-weight: 600;
}

.source-row-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.btn-ghost {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-dim);
    padding: 4px 12px;
    font-size: 0.78rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-weight: 600;
    cursor: pointer;
    transition: color 0.15s ease, border-color 0.15s ease;
}

.btn-ghost:hover {
    color: var(--text);
    border-color: var(--text-faint);
}

.btn-ghost:disabled {
    opacity: 0.5;
    cursor: default;
}

.btn-heal {
    background: linear-gradient(135deg, var(--sev-medium), #f97316);
    color: #241a03;
}

@keyframes status-flash-success {
    0% { color: var(--accent-lime); }
    70% { color: var(--accent-lime); }
    100% { color: var(--text-faint); }
}

@keyframes status-flash-error {
    0% { color: var(--sev-high); }
    70% { color: var(--sev-high); }
    100% { color: var(--text-faint); }
}

.events {
    list-style: none;
    padding: 0;
    margin: 0;
}

.events > li {
    padding: 16px 0;
    border-bottom: 1px solid var(--border);
}

.events > li:last-child {
    border-bottom: none;
}

.events > li.empty {
    color: var(--text-faint);
}

.empty {
    color: var(--text-faint);
}

.event-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.event-header a {
    font-weight: 600;
    color: var(--accent-blue);
    text-decoration: none;
}

.event-header a:hover {
    color: var(--accent-cyan);
    text-decoration: underline;
}

.badges {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.badge {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 10px;
    background: var(--surface-hover);
    color: var(--text-dim);
    white-space: nowrap;
}

.badge-release { background: rgba(56, 189, 248, 0.14); color: var(--cat-release); }
.badge-deprecation { background: rgba(249, 115, 22, 0.14); color: var(--cat-deprecation); }
.badge-breaking { background: rgba(251, 113, 133, 0.14); color: var(--cat-breaking); }
.badge-security { background: rgba(251, 146, 60, 0.14); color: var(--cat-security); }
.badge-feature { background: rgba(192, 132, 252, 0.14); color: var(--cat-feature); }
.badge-docs { background: rgba(100, 116, 139, 0.18); color: var(--cat-docs); }

/* Release notes / blog posts sub-tabs */

.sub-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 14px;
}

.sub-tab-btn {
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 5px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface-hover);
    color: var(--text-dim);
    cursor: pointer;
    transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.sub-tab-btn:hover {
    color: var(--text);
}

.sub-tab-btn.active {
    color: var(--accent-blue);
    border-color: rgba(56, 189, 248, 0.4);
    background: rgba(56, 189, 248, 0.1);
}

/* Filter chips reuse .badge/.badge-* for color; these rules add interactivity only */

.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 16px;
}

.filter-chip {
    font-family: inherit;
    border: 1px solid transparent;
    cursor: pointer;
    transition: transform 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}

.filter-chip:hover:not(:disabled) {
    transform: translateY(-1px);
}

.filter-chip:disabled {
    opacity: 0.35;
    cursor: default;
}

.filter-chip.active {
    border-color: currentColor;
}

.badge-impact-high,
.badge-impact-medium,
.badge-impact-low {
    background: var(--surface-sunken);
    font-weight: 700;
    border-left: 3px solid transparent;
}

.badge-impact-high { color: var(--sev-high); border-left-color: var(--sev-high); animation: pulse-glow 2s ease-in-out infinite; }
.badge-impact-medium { color: var(--sev-medium); border-left-color: var(--sev-medium); }
.badge-impact-low { color: var(--sev-low); border-left-color: var(--sev-low); }

.events > li.high-impact {
    border-left: 3px solid var(--sev-high);
    padding-left: 14px;
    background: rgba(248, 113, 113, 0.05);
}

.events > li.focused-event {
    animation: focus-flash 1.8s ease;
}

@keyframes focus-flash {
    0% { background: rgba(56, 189, 248, 0.2); }
    100% { background: transparent; }
}

.impact-detail {
    margin-top: 10px;
    font-size: 0.85rem;
    color: var(--text-dim);
}

.impact-detail summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--text);
}

.impact-detail p {
    margin: 6px 0 0;
}

.impact-detail a {
    color: var(--accent-cyan);
}

.events p {
    margin: 8px 0 6px;
    color: var(--text-dim);
    font-size: 0.92rem;
}

/* Markdown-rendered event body (release notes / changelog text) */

.markdown-body {
    margin: 8px 0 6px;
    color: var(--text-dim);
    font-size: 0.92rem;
    line-height: 1.6;
    overflow-x: auto;
}

.markdown-body > :first-child {
    margin-top: 0;
}

.markdown-body > :last-child {
    margin-bottom: 0;
}

.markdown-body :is(h1, h2, h3, h4, h5, h6) {
    font-family: var(--font-body);
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text);
    margin: 14px 0 6px;
}

.markdown-body p {
    margin: 8px 0;
}

.markdown-body a {
    color: var(--accent-cyan);
}

.markdown-body strong {
    color: var(--text);
}

.markdown-body code {
    background: var(--surface-hover);
    color: var(--text);
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 0.85em;
}

.markdown-body pre {
    background: var(--surface-sunken);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    overflow-x: auto;
}

.markdown-body pre code {
    background: none;
    padding: 0;
}

.markdown-body ul,
.markdown-body ol {
    margin: 8px 0;
    padding-left: 22px;
}

.markdown-body li {
    padding: 2px 0;
    border-bottom: none;
}

.markdown-body blockquote {
    margin: 8px 0;
    padding-left: 12px;
    border-left: 3px solid var(--border);
    color: var(--text-faint);
}

.markdown-body hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 14px 0;
}

.markdown-body img {
    max-width: 100%;
}

.meta {
    font-size: 0.8rem;
    color: var(--text-faint);
}

/* Confidence badge (reused wherever impact_confidence is shown) */

.confidence-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 10px;
    background: var(--surface-hover);
    color: var(--text-dim);
    white-space: nowrap;
}

.confidence-badge strong {
    color: var(--text);
}

/* Chips used for affected-component display (event detail panel, dashboard attention list, upgrade simulation) */

.chain {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin: 8px 0;
}

.chain-chip {
    display: inline-flex;
    align-items: center;
    font-size: 0.78rem;
    font-weight: 600;
    padding: 4px 11px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface-hover);
    color: var(--text);
    white-space: nowrap;
}

.chain-chip-component {
    border-color: rgba(34, 211, 238, 0.35);
    color: var(--accent-cyan);
    background: rgba(34, 211, 238, 0.08);
}


/* Scraper health */

.health-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    margin-top: 20px;
    background: rgba(17, 24, 39, 0.7);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    animation: fade-in-up 0.4s ease both;
}

.health-table tbody tr {
    transition: background 0.15s ease;
}

.health-table tbody tr:hover {
    background: var(--surface-hover);
}

.health-table th {
    text-align: left;
    color: var(--text-faint);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}

.health-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
    color: var(--text);
}

.health-table tr:last-child td {
    border-bottom: none;
}

.health-badge {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 10px;
    white-space: nowrap;
}

.health-healthy { background: rgba(163, 230, 53, 0.14); color: var(--accent-lime); }
.health-degraded { background: rgba(251, 191, 36, 0.14); color: var(--sev-medium); }
.health-healing { background: rgba(34, 211, 238, 0.14); color: var(--accent-cyan); }
.health-healed { background: rgba(163, 230, 53, 0.14); color: var(--accent-lime); }
.health-failed { background: rgba(248, 113, 113, 0.14); color: var(--sev-high); }

.health-table th.actions-col,
.health-table td.actions-col {
    text-align: right;
    white-space: nowrap;
}

.health-detail-row td {
    padding: 0 16px 14px;
    border-bottom: 1px solid var(--border);
}

.health-detail {
    font-size: 0.8rem;
    color: var(--text-dim);
    background: var(--surface-sunken);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    line-height: 1.5;
}

.health-detail strong {
    color: var(--text);
}

@media (max-width: 640px) {
    .topbar-inner {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    .page {
        padding: 24px 16px 48px;
    }
}

/* Page loader */

.page-loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    min-height: calc(100vh - 180px);
    padding: 20px;
    color: var(--text-faint);
}

.page-loader-radar {
    display: inline-flex;
    width: 40px;
    height: 40px;
}

.page-loader-radar svg {
    width: 100%;
    height: 100%;
    overflow: visible;
}

.page-loader-ring {
    fill: none;
    stroke: var(--border);
    stroke-width: 1.2;
}

.page-loader-sweep {
    transform-origin: 16px 16px;
    animation: brand-radar-spin 1.1s linear infinite;
}

.page-loader-text {
    font-size: 0.85rem;
    letter-spacing: 0.02em;
}

.page-loader.is-error .page-loader-radar {
    display: none;
}

.page-loader.is-error .page-loader-text {
    color: var(--sev-high);
}

@media (prefers-reduced-motion: reduce) {
    .brand-radar-sweep,
    .page-loader-sweep,
    .badge-impact-high,
    .tabs-card,
    .health-table,
    .stat-card,
    .chart-card,
    .events > li.focused-event,
    .source-row-status.flash-success,
    .source-row-status.flash-error {
        animation: none;
    }
    #scan-all-btn,
    .scan-tech-btn,
    .tab-btn::after,
    .nav-item,
    .nav-item::after,
    .filter-chip,
    .sub-tab-btn {
        transition: none;
    }
}
