/* ==========================================================================
   ArchLens design system
   Dark glass surfaces with an indigo-to-emerald brand, and a matching light theme.
   Every colour is a token below; components never hard-code theme colours.
   ========================================================================== */

/* --- Tokens: dark (default) --- */
:root {
    color-scheme: dark;

    --bg:              #070a12;
    --bg-glow:         rgba(99, 102, 241, 0.16);
    --bg-glow-2:       rgba(56, 189, 248, 0.08);
    --surface:         rgba(14, 20, 34, 0.78);
    --surface-solid:   #0e1424;
    --surface-2:       #131b2d;
    --surface-3:       #1a2439;
    --overlay:         rgba(7, 10, 18, 0.82);
    --border:          rgba(148, 163, 184, 0.14);
    --border-strong:   rgba(148, 163, 184, 0.26);
    --border-accent:   rgba(129, 140, 248, 0.5);
    --card-sheen:      linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0) 40%);

    --text:            #f1f5f9;
    --text-2:          #aab7ca;
    --text-3:          #8494aa;
    --text-inverse:    #0b1020;

    --accent:          #818cf8;
    --accent-strong:   #4f46e5;
    --accent-hover:    #5b54ec;
    --accent-soft:     rgba(129, 140, 248, 0.14);
    --accent-ring:     rgba(129, 140, 248, 0.55);
    --brand-gradient:  linear-gradient(135deg, #818cf8 0%, #38bdf8 50%, #34d399 100%);
    /* Primary buttons: the brand's indigo-to-cyan run, dark enough for white text (AA) */
    --btn-gradient:    linear-gradient(120deg, #6366f1 0%, #4f46e5 45%, #0e7490 100%);

    /* Semantic colours: text-safe foreground, tinted background, border */
    --good:            #34d399;
    --good-bg:         rgba(52, 211, 153, 0.12);
    --good-border:     rgba(52, 211, 153, 0.32);
    --warn:            #fbbf24;
    --warn-bg:         rgba(251, 191, 36, 0.12);
    --warn-border:     rgba(251, 191, 36, 0.32);
    --bad:             #fb7185;
    --bad-bg:          rgba(251, 113, 133, 0.12);
    --bad-border:      rgba(251, 113, 133, 0.34);
    --info:            #38bdf8;
    --info-bg:         rgba(56, 189, 248, 0.12);
    --info-border:     rgba(56, 189, 248, 0.32);

    /* Bars and arcs (graphics, not text) */
    --fill-good:       #34d399;
    --fill-warn:       #fbbf24;
    --fill-bad:        #fb7185;
    --track:           rgba(148, 163, 184, 0.14);

    /* The seven dimensions, as in the original design */
    --dim-documentation:   #818cf8;
    --dim-activity:        #38bdf8;
    --dim-organization:    #a78bfa;
    --dim-community:       #fbbf24;
    --dim-maintainability: #34d399;
    --dim-security:        #fb7185;
    --dim-code_quality:    #e879f9;

    /* Compare page: repository A and B (marks, and text on tinted backgrounds) */
    --series-a:        #6f7af5;
    --series-b:        #dc6f24;
    --series-a-text:   #a5b4fc;
    --series-b-text:   #fdba74;

    --shadow-sm:       0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md:       0 8px 24px rgba(0, 0, 0, 0.35);
    --shadow-lg:       0 24px 60px rgba(0, 0, 0, 0.5);
    --shadow-glow:     0 8px 28px rgba(79, 70, 229, 0.35);

    /* Type */
    --font-heading: 'Plus Jakarta Sans', 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --font-base:    'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --font-mono:    'JetBrains Mono', ui-monospace, 'SFMono-Regular', Consolas, monospace;
    --fs-xs: 0.75rem;   /* 12 */
    --fs-sm: 0.8125rem; /* 13 */
    --fs-md: 0.875rem;  /* 14 */
    --fs-base: 0.9375rem; /* 15 */
    --fs-lg: 1.0625rem; /* 17 */
    --fs-xl: 1.25rem;   /* 20 */
    --fs-2xl: 1.5rem;   /* 24 */
    --fs-3xl: 1.875rem; /* 30 */
    --fs-4xl: 2.5rem;   /* 40 */
    --fs-5xl: 3.25rem;  /* 52 */

    /* Space, radius, motion */
    --space-1: 4px;  --space-2: 8px;  --space-3: 12px; --space-4: 16px;
    --space-5: 20px; --space-6: 24px; --space-8: 32px; --space-10: 40px;
    --space-12: 48px; --space-16: 64px;
    --radius-sm: 8px; --radius-md: 12px; --radius-lg: 16px; --radius-xl: 20px; --radius-full: 999px;
    --ease: cubic-bezier(0.16, 1, 0.3, 1);
    --dur-fast: 150ms; --dur: 220ms; --dur-slow: 300ms;
    --nav-height: 64px;
}

/* --- Tokens: light --- */
html[data-theme="light"] {
    color-scheme: light;

    --bg:              #f5f7fb;
    --bg-glow:         rgba(99, 102, 241, 0.10);
    --bg-glow-2:       rgba(56, 189, 248, 0.07);
    --surface:         rgba(255, 255, 255, 0.86);
    --surface-solid:   #ffffff;
    --surface-2:       #f1f4f9;
    --surface-3:       #e7ecf4;
    --overlay:         rgba(245, 247, 251, 0.86);
    --border:          rgba(15, 23, 42, 0.10);
    --border-strong:   rgba(15, 23, 42, 0.18);
    --border-accent:   rgba(79, 70, 229, 0.45);
    --card-sheen:      linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0) 40%);

    --text:            #0f172a;
    --text-2:          #3a4a60;
    --text-3:          #5b6b82;
    --text-inverse:    #ffffff;

    --accent:          #4f46e5;
    --accent-strong:   #4f46e5;
    --accent-hover:    #4338ca;
    --accent-soft:     rgba(79, 70, 229, 0.08);
    --accent-ring:     rgba(79, 70, 229, 0.45);

    --good:            #047857;
    --good-bg:         #ecfdf5;
    --good-border:     #a7f3d0;
    --warn:            #b45309;
    --warn-bg:         #fffbeb;
    --warn-border:     #fde68a;
    --bad:             #be123c;
    --bad-bg:          #fff1f2;
    --bad-border:      #fecdd3;
    --info:            #0369a1;
    --info-bg:         #f0f9ff;
    --info-border:     #bae6fd;

    --fill-good:       #059669;
    --fill-warn:       #d97706;
    --fill-bad:        #e11d48;
    --track:           rgba(15, 23, 42, 0.08);

    --dim-documentation:   #6366f1;
    --dim-activity:        #0284c7;
    --dim-organization:    #7c3aed;
    --dim-community:       #d97706;
    --dim-maintainability: #059669;
    --dim-security:        #e11d48;
    --dim-code_quality:    #c026d3;

    --series-a:        #4f46e5;
    --series-b:        #ea580c;
    --series-a-text:   #3730a3;
    --series-b-text:   #9a3412;

    --shadow-sm:       0 1px 2px rgba(15, 23, 42, 0.06);
    --shadow-md:       0 6px 20px rgba(15, 23, 42, 0.07);
    --shadow-lg:       0 20px 50px rgba(15, 23, 42, 0.12);
    --shadow-glow:     0 8px 24px rgba(79, 70, 229, 0.25);
}

/* --- Reset and base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

html {
    font-size: 16px;
    scroll-behavior: smooth;
    scroll-padding-top: calc(var(--nav-height) + 16px);
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-base);
    font-size: var(--fs-base);
    line-height: 1.6;
    background-color: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
    font-feature-settings: "cv11", "ss01";
}

/* One soft light source behind the top of the page, for depth behind the glass cards */
.ambient {
    position: absolute;
    inset: 0 0 auto 0;
    height: 720px;
    pointer-events: none;
    z-index: -1;
    background:
        radial-gradient(900px 420px at 18% -80px, var(--bg-glow), transparent 70%),
        radial-gradient(700px 380px at 85% 40px, var(--bg-glow-2), transparent 70%);
}

a { color: var(--accent); text-decoration: none; text-underline-offset: 3px; }
a:hover { text-decoration: underline; }
ul, ol { list-style: none; }
img, svg { display: block; max-width: 100%; }
svg.icon { flex-shrink: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
code, kbd, .mono { font-family: var(--font-mono); font-feature-settings: normal; }
.num { font-variant-numeric: tabular-nums; }
h1, h2, h3, h4 { font-family: var(--font-heading); color: var(--text); line-height: 1.2; letter-spacing: -0.02em; }
p { max-width: 72ch; }
strong { font-weight: 600; }

::selection { background: var(--accent-soft); color: var(--text); }

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 4px;
}

.visually-hidden {
    position: absolute !important;
    width: 1px; height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.skip-link {
    position: absolute;
    left: 16px; top: -48px;
    z-index: 100;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    background: var(--accent-strong);
    color: #fff;
    font-weight: 600;
    transition: top var(--dur) var(--ease);
}
.skip-link:focus { top: 12px; }

/* --- Layout --- */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--space-6);
}

.main-content {
    flex: 1;
    padding: var(--space-10) 0 var(--space-16);
}
.main-content:focus { outline: none; }

/* --- Navigation --- */
.navbar {
    position: sticky;
    top: 0;
    z-index: 50;
    height: var(--nav-height);
    background: var(--overlay);
    backdrop-filter: blur(14px) saturate(140%);
    -webkit-backdrop-filter: blur(14px) saturate(140%);
    border-bottom: 1px solid var(--border);
}

.nav-inner {
    height: 100%;
    display: flex;
    align-items: center;
    gap: var(--space-4);
}

.nav-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-right: auto;
    color: var(--text);
    font-family: var(--font-heading);
    font-size: 1.2rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}
.nav-brand:hover { text-decoration: none; }
.brand-svg { width: 28px; height: 28px; filter: drop-shadow(0 0 8px rgba(99, 102, 241, 0.35)); }
.brand-accent { color: var(--info); }
html[data-theme="light"] .brand-accent { color: #0284c7; }

.nav-links { display: flex; align-items: center; gap: 2px; }

.nav-link {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 38px;
    padding: 0 12px;
    border-radius: var(--radius-sm);
    color: var(--text-2);
    font-size: var(--fs-md);
    font-weight: 500;
    transition: color var(--dur-fast), background var(--dur-fast);
}
.nav-link:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.nav-link[aria-current="page"] {
    color: var(--text);
    background: var(--accent-soft);
    box-shadow: inset 0 0 0 1px var(--border-accent);
}
.nav-icon { width: 16px; height: 16px; color: var(--text-3); }
.nav-link[aria-current="page"] .nav-icon { color: var(--accent); }

.nav-actions { display: flex; align-items: center; gap: 4px; }

.icon-btn {
    position: relative;
    display: inline-grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-2);
    transition: color var(--dur-fast), background var(--dur-fast), border-color var(--dur-fast);
}
.icon-btn:hover { color: var(--text); background: var(--surface-2); border-color: var(--border); text-decoration: none; }
.icon-btn .icon { width: 18px; height: 18px; }

/* Show the icon for the theme you would switch to */
html[data-theme="dark"] #theme-toggle .icon-moon,
html[data-theme="light"] #theme-toggle .icon-sun { display: none; }

.nav-menu-btn { display: none; }
html:not(.js) #theme-toggle { display: none; }
.nav-menu-btn .icon-close { display: none; }
.nav-menu-btn[aria-expanded="true"] .icon-open { display: none; }
.nav-menu-btn[aria-expanded="true"] .icon-close { display: block; }

/* --- Tooltips: <el data-tip="..."> on hover and keyboard focus --- */
[data-tip] { position: relative; }
[data-tip]::after {
    content: attr(data-tip);
    position: absolute;
    left: 50%;
    top: calc(100% + 8px);
    z-index: 60;
    padding: 5px 9px;
    border-radius: 6px;
    background: var(--text);
    color: var(--bg);
    font-size: var(--fs-xs);
    font-weight: 500;
    line-height: 1.3;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transform: translate(-50%, -3px);
    transition: opacity var(--dur-fast), transform var(--dur-fast);
}
[data-tip]:hover::after,
[data-tip]:focus-visible::after { opacity: 1; transform: translate(-50%, 0); }
[data-tip-align="end"]::after { left: auto; right: 0; transform: translateY(-3px); }
[data-tip-align="end"]:hover::after,
[data-tip-align="end"]:focus-visible::after { transform: none; }
@media (hover: none) { [data-tip]::after { display: none; } }

/* --- Cards: frosted glass surfaces --- */
.card {
    position: relative;
    background: var(--card-sheen), var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    box-shadow: var(--shadow-md);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    flex-wrap: wrap;
    padding-bottom: var(--space-4);
    margin-bottom: var(--space-5);
    border-bottom: 1px solid var(--border);
}
.card-title-wrap { display: flex; align-items: center; gap: 10px; min-width: 0; }
.card-title {
    font-family: var(--font-heading);
    font-size: var(--fs-lg);
    font-weight: 700;
    letter-spacing: -0.01em;
}
.card-icon {
    width: 32px; height: 32px;
    display: grid; place-items: center;
    flex-shrink: 0;
    border-radius: 9px;
    background: var(--accent-soft);
    color: var(--accent);
}
.card-icon .icon { width: 17px; height: 17px; }
.card-icon-good { background: var(--good-bg); color: var(--good); }
.card-icon-warn { background: var(--warn-bg); color: var(--warn); }
.card-icon-info { background: var(--info-bg); color: var(--info); }
.card-subtitle { color: var(--text-3); font-size: var(--fs-sm); }

.count-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 22px;
    padding: 0 7px;
    border-radius: var(--radius-full);
    background: var(--surface-3);
    color: var(--text-2);
    font-size: var(--fs-xs);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/* --- Page headers --- */
.page-header { margin-bottom: var(--space-8); }
.page-title-wrap { display: flex; align-items: center; gap: 14px; margin-bottom: var(--space-3); }
.page-title-icon {
    width: 44px; height: 44px;
    display: grid; place-items: center;
    flex-shrink: 0;
    border-radius: 12px;
    background: var(--accent-soft);
    border: 1px solid var(--border-accent);
    color: var(--accent);
}
.page-title-icon .icon { width: 22px; height: 22px; }
.page-header h1 { font-size: var(--fs-4xl); font-weight: 800; letter-spacing: -0.03em; }
.page-header p { color: var(--text-2); font-size: var(--fs-lg); }

.section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--space-4);
    flex-wrap: wrap;
    margin-bottom: var(--space-4);
}
.section-title { font-size: var(--fs-xl); font-weight: 700; }

/* --- Buttons --- */
.btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 40px;
    padding: 0 16px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--text);
    font-size: var(--fs-md);
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    transition: background var(--dur-fast), border-color var(--dur-fast), color var(--dur-fast),
        box-shadow var(--dur-fast), transform var(--dur-fast);
}
.btn:hover { background: var(--surface-3); border-color: var(--border-strong); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn .icon { width: 16px; height: 16px; flex-shrink: 0; }

.btn-primary {
    border-color: transparent;
    background: var(--btn-gradient);
    background-size: 140% 100%;
    background-position: 0 0;
    color: #fff;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), var(--shadow-glow);
    transition: background-position var(--dur) var(--ease), box-shadow var(--dur-fast), transform var(--dur-fast);
}
.btn-primary:hover {
    background: var(--btn-gradient);
    background-size: 140% 100%;
    background-position: 100% 0;
    border-color: transparent;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.24), 0 10px 30px rgba(79, 70, 229, 0.42);
}
.btn-primary:focus-visible { outline-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft), var(--shadow-glow); }

.btn-ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); border-color: var(--border); }

.btn-sm { height: 34px; padding: 0 12px; font-size: var(--fs-sm); }
.btn-lg { height: 48px; padding: 0 22px; font-size: var(--fs-base); border-radius: 10px; }

/* Loading state: the label stays for screen readers, a spinner replaces the icon */
.btn .spinner { display: none; }
.btn[aria-busy="true"] .spinner { display: inline-block; }
.btn[aria-busy="true"] .btn-icon { display: none; }
.btn[aria-busy="true"], .btn[aria-busy="true"]:disabled { cursor: progress; opacity: 1; }

.spinner {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid currentColor;
    border-right-color: transparent;
    animation: spin 0.7s linear infinite;
    flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

.btn-row { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }

/* --- Form controls --- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-label {
    color: var(--text-2);
    font-size: var(--fs-sm);
    font-weight: 600;
}

.input-wrap { position: relative; }
.input-icon {
    position: absolute;
    left: 13px;
    top: 50%;
    width: 18px;
    height: 18px;
    transform: translateY(-50%);
    color: var(--text-3);
    pointer-events: none;
    transition: color var(--dur-fast);
}
.input-wrap:focus-within .input-icon { color: var(--accent); }

.input, .select {
    width: 100%;
    height: 44px;
    padding: 0 14px;
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    background: var(--surface-2);
    color: var(--text);
    font-size: var(--fs-base);
    transition: border-color var(--dur-fast), box-shadow var(--dur-fast), background var(--dur-fast);
}
.input-with-icon { padding-left: 40px; }
.input::placeholder { color: var(--text-3); }
.input:hover, .select:hover { border-color: var(--border-accent); }
.input:focus, .select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
    background: var(--surface-solid);
}
.input[aria-invalid="true"] { border-color: var(--bad); }
.input[aria-invalid="true"]:focus { box-shadow: 0 0 0 3px var(--bad-bg); }

.select {
    appearance: none;
    padding-right: 38px;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238494aa' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}
.select-with-icon { padding-left: 40px; }

.field-error {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--bad);
    font-size: var(--fs-sm);
    font-weight: 500;
}
.field-error .icon { width: 15px; height: 15px; flex-shrink: 0; }
.field-error[hidden] { display: none; }

kbd {
    display: inline-block;
    min-width: 20px;
    padding: 1px 6px;
    border: 1px solid var(--border-strong);
    border-bottom-width: 2px;
    border-radius: 5px;
    background: var(--surface-2);
    color: var(--text-2);
    font-size: 11px;
    line-height: 1.5;
    text-align: center;
}

/* --- Chips (one-click examples) --- */
.chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.chips-label { color: var(--text-3); font-size: var(--fs-sm); margin-right: 2px; }
.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 30px;
    padding: 0 11px;
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    background: var(--surface-2);
    color: var(--text-2);
    font-family: var(--font-mono);
    font-size: var(--fs-sm);
    transition: color var(--dur-fast), border-color var(--dur-fast), background var(--dur-fast);
}
.chip:hover { color: var(--text); border-color: var(--border-accent); background: var(--accent-soft); text-decoration: none; }

/* --- Badges --- */
.grade-badge {
    display: inline-grid;
    place-items: center;
    min-width: 40px;
    height: 32px;
    padding: 0 8px;
    border: 1px solid;
    border-radius: 9px;
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: 1rem;
    letter-spacing: -0.01em;
}
.grade-badge-sm { min-width: 32px; height: 24px; font-size: var(--fs-sm); border-radius: 7px; padding: 0 6px; }
.grade-badge-lg { min-width: 64px; height: 52px; font-size: 1.6rem; border-radius: 13px; }
.grade-aplus, .grade-a { background: var(--good-bg); color: var(--good); border-color: var(--good-border); }
.grade-bplus, .grade-b { background: var(--info-bg); color: var(--info); border-color: var(--info-border); }
.grade-c { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-border); }
.grade-d, .grade-f { background: var(--bad-bg); color: var(--bad); border-color: var(--bad-border); }

.tier-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 26px;
    padding: 0 10px;
    border: 1px solid;
    border-radius: var(--radius-full);
    font-size: var(--fs-xs);
    font-weight: 600;
    letter-spacing: 0.01em;
    white-space: nowrap;
}
.icon-xs { width: 14px; height: 14px; }
.tier-high { background: var(--good-bg); color: var(--good); border-color: var(--good-border); }
.tier-mid { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-border); }
.tier-low { background: var(--bad-bg); color: var(--bad); border-color: var(--bad-border); }

.score-badge {
    display: inline-grid;
    place-items: center;
    min-width: 42px;
    height: 28px;
    padding: 0 8px;
    border: 1px solid;
    border-radius: 8px;
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: var(--fs-md);
    font-variant-numeric: tabular-nums;
}
.score-high { background: var(--good-bg); color: var(--good); border-color: var(--good-border); }
.score-mid { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-border); }
.score-low { background: var(--bad-bg); color: var(--bad); border-color: var(--bad-border); }

.tag {
    display: inline-flex;
    align-items: center;
    height: 20px;
    padding: 0 7px;
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    color: var(--text-2);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    white-space: nowrap;
}
.tag-example { color: var(--info); border-color: var(--info-border); background: var(--info-bg); }
.tag-profile { color: var(--accent); border-color: var(--border-accent); background: var(--accent-soft); }

/* --- Bars (scores out of a maximum) --- */
.bar {
    position: relative;
    display: block;
    height: 8px;
    border-radius: var(--radius-full);
    background: var(--track);
    overflow: hidden;
}
.bar-fill {
    display: block;
    height: 100%;
    width: var(--w, 0%);
    border-radius: inherit;
    background: var(--accent);
    transition: width var(--dur-slow) var(--ease);
}
.bar-high { background: var(--fill-good); }
.bar-mid { background: var(--fill-warn); }
.bar-low { background: var(--fill-bad); }

/* How the 100 points split across the dimensions (home and scoring pages) */
.points-bar {
    display: flex;
    gap: 3px;
    height: 12px;
    border-radius: var(--radius-full);
    overflow: hidden;
}
.points-seg { background: var(--dot); transition: filter var(--dur-fast); }
.points-seg:hover { filter: brightness(1.15); }
.dim-legend { display: flex; flex-wrap: wrap; gap: 8px; margin-top: var(--space-4); }
.dim-tag {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 34px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    background: var(--surface);
    color: var(--text-2);
    font-size: var(--fs-sm);
    font-weight: 500;
    transition: color var(--dur-fast), border-color var(--dur-fast), transform var(--dur-fast);
}
.dim-tag:hover { color: var(--text); border-color: var(--border-accent); text-decoration: none; transform: translateY(-1px); }
.dim-tag-points { color: var(--text-3); font-size: var(--fs-xs); }

.dim-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    background: var(--dot, var(--text-3));
}
.dim-documentation { --dot: var(--dim-documentation); }
.dim-activity { --dot: var(--dim-activity); }
.dim-organization { --dot: var(--dim-organization); }
.dim-community { --dot: var(--dim-community); }
.dim-maintainability { --dot: var(--dim-maintainability); }
.dim-security { --dot: var(--dim-security); }
.dim-code_quality { --dot: var(--dim-code_quality); }

/* --- Score gauge --- */
.gauge {
    display: block;
    position: relative;
    width: var(--gauge-size, 168px);
    aspect-ratio: 1;
    flex-shrink: 0;
}
.gauge-md { --gauge-size: 120px; }
.gauge-svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.gauge-track { fill: none; stroke: var(--track); stroke-width: 9; }
.gauge-fill {
    fill: none;
    stroke-width: 9;
    stroke-linecap: round;
    stroke-dasharray: var(--score) 100;
    animation: gauge-in var(--dur-slow) var(--ease) both;
}
.gauge-fill.gauge-high { stroke: var(--fill-good); filter: drop-shadow(0 0 6px rgba(52, 211, 153, 0.35)); }
.gauge-fill.gauge-mid { stroke: var(--fill-warn); filter: drop-shadow(0 0 6px rgba(251, 191, 36, 0.3)); }
.gauge-fill.gauge-low { stroke: var(--fill-bad); filter: drop-shadow(0 0 6px rgba(251, 113, 133, 0.3)); }
html[data-theme="light"] .gauge-fill { filter: none; }
@keyframes gauge-in { from { stroke-dasharray: 0 100; } }

.gauge-label {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
}
.gauge-total { align-self: center; margin-top: calc(var(--gauge-size, 168px) * 0.1); }
.gauge-number {
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: calc(var(--gauge-size, 168px) * 0.3);
    line-height: 1;
    letter-spacing: -0.04em;
    font-variant-numeric: tabular-nums;
}
.gauge-total { color: var(--text-3); font-family: var(--font-mono); font-size: calc(var(--gauge-size, 168px) * 0.085); }

/* --- Alerts and notes --- */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    border: 1px solid var(--bad-border);
    border-radius: var(--radius-md);
    background: var(--bad-bg);
    color: var(--text);
    font-size: var(--fs-md);
}
.alert > .icon { width: 18px; height: 18px; color: var(--bad); flex-shrink: 0; margin-top: 2px; }
.alert-body { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.alert-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.alert-info { border-color: var(--info-border); background: var(--info-bg); }
.alert-info > .icon { color: var(--info); }

/* --- Tables --- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-md); }
.table th, .table td { padding: 11px 14px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--border); }
.table thead th {
    background: var(--surface-2);
    color: var(--text-3);
    font-size: var(--fs-xs);
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}
/* Sticky header for long tables that are not inside a scrolling wrapper */
.table-sticky thead th { position: sticky; top: var(--nav-height); z-index: 2; }
.table tbody tr { transition: background var(--dur-fast); }
.table tbody tr:hover { background: var(--accent-soft); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* --- Tabs --- */
.tabs { display: flex; gap: 4px; padding: 4px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); width: fit-content; max-width: 100%; overflow-x: auto; }
.tab {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 32px;
    padding: 0 12px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--text-2);
    font-size: var(--fs-sm);
    font-weight: 600;
    white-space: nowrap;
    transition: background var(--dur-fast), color var(--dur-fast);
}
.tab:hover { color: var(--text); text-decoration: none; }
.tab[aria-selected="true"], .tab[aria-current="page"] { background: var(--surface-solid); color: var(--text); box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--border); }
.tab .count-pill { height: 18px; min-width: 20px; font-size: 11px; }
.tab-panel[hidden] { display: none; }

/* --- Copyable snippets --- */
.snippet {
    display: flex;
    align-items: stretch;
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    background: var(--surface-2);
    overflow: hidden;
}
.snippet pre {
    flex: 1;
    min-width: 0;
    margin: 0;
    padding: 11px 14px;
    overflow-x: auto;
    color: var(--text-2);
    font-family: var(--font-mono);
    font-size: var(--fs-sm);
    line-height: 1.5;
    white-space: pre;
}
.snippet .btn { height: auto; border-radius: 0; border: 0; border-left: 1px solid var(--border-strong); }

/* --- Menus (details-based dropdown) --- */
.menu { position: relative; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu[open] > summary .icon-chevron { transform: rotate(180deg); }
.icon-chevron { transition: transform var(--dur-fast); }
.menu-panel {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    z-index: 30;
    min-width: 220px;
    padding: 6px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    background: var(--surface-solid);
    box-shadow: var(--shadow-lg);
    animation: pop-in var(--dur-fast) var(--ease);
}
.menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 9px 10px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--text);
    font-size: var(--fs-md);
    text-align: left;
}
.menu-item:hover, .menu-item:focus-visible { background: var(--surface-2); text-decoration: none; outline: none; }
.menu-item .icon { width: 16px; height: 16px; color: var(--text-3); }
.menu-item small { display: block; color: var(--text-3); font-size: var(--fs-xs); }
@keyframes pop-in { from { opacity: 0; transform: translateY(-4px); } }

/* --- Toasts --- */
.toasts {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 90;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}
.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 360px;
    padding: 11px 14px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    background: var(--surface-solid);
    color: var(--text);
    box-shadow: var(--shadow-lg);
    font-size: var(--fs-md);
    font-weight: 500;
    animation: toast-in var(--dur) var(--ease);
}
.toast .icon { width: 17px; height: 17px; color: var(--good); flex-shrink: 0; }
.toast-error .icon { color: var(--bad); }
.toast.is-leaving { opacity: 0; transform: translateY(6px); transition: opacity var(--dur), transform var(--dur); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* --- Skeletons --- */
.skeleton {
    display: block;
    border-radius: 6px;
    background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.3s linear infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }
.skeleton-round { width: 120px; height: 120px; border-radius: 50%; flex-shrink: 0; }

/* --- Empty and error states --- */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: var(--space-12) var(--space-6);
    text-align: center;
}
.empty-icon {
    width: 56px; height: 56px;
    display: grid; place-items: center;
    margin-bottom: 6px;
    border-radius: 16px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text-3);
}
.empty-icon .icon { width: 26px; height: 26px; }
.empty-title { font-family: var(--font-heading); font-size: var(--fs-lg); font-weight: 700; }
.empty-state p { color: var(--text-2); font-size: var(--fs-md); }
.empty-state .btn-row { margin-top: 8px; justify-content: center; }

/* --- Text helpers --- */
.muted { color: var(--text-3); }
.text-2 { color: var(--text-2); }
.small { font-size: var(--fs-sm); }
.nowrap { white-space: nowrap; }

/* --- Footer --- */
.footer {
    border-top: 1px solid var(--border);
    background: var(--overlay);
    padding: var(--space-8) 0;
}
.footer-inner {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: var(--space-4) var(--space-8);
}
.footer-brand { display: flex; align-items: center; gap: 10px; max-width: none; color: var(--text-2); font-size: var(--fs-sm); }
.footer-brand strong { color: var(--text); }
.footer-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand-gradient); box-shadow: 0 0 10px rgba(52, 211, 153, 0.5); flex-shrink: 0; }
.footer-links { display: flex; flex-wrap: wrap; gap: 6px 20px; font-size: var(--fs-md); }
.footer-links a { color: var(--text-2); }
.footer-links a:hover { color: var(--text); }

/* --- Responsive --- */
@media (max-width: 920px) {
    html.js .nav-menu-btn { display: inline-grid; }
    html.js .nav-links {
        position: absolute;
        top: calc(var(--nav-height) - 1px);
        left: 0;
        right: 0;
        display: none;
        flex-direction: column;
        align-items: stretch;
        gap: 2px;
        padding: 8px 16px 16px;
        background: var(--surface-solid);
        border-bottom: 1px solid var(--border);
        box-shadow: var(--shadow-lg);
    }
    html.js .nav-links.is-open { display: flex; animation: pop-in var(--dur-fast) var(--ease); }
    html.js .nav-link { height: 44px; padding: 0 12px; font-size: var(--fs-base); }
    /* Without JavaScript the links wrap under the brand instead of hiding behind a menu */
    html:not(.js) .nav-inner { flex-wrap: wrap; height: auto; padding-top: 10px; padding-bottom: 10px; }
    html:not(.js) .navbar { height: auto; }
    html:not(.js) .nav-links { order: 3; width: 100%; flex-wrap: wrap; }
    html:not(.js) .nav-link { padding: 0 10px; }
}

@media (max-width: 640px) {
    .container { padding: 0 16px; }
    .main-content { padding: var(--space-6) 0 var(--space-12); }
    .card { padding: var(--space-5) var(--space-4); border-radius: 14px; }
    .page-header h1 { font-size: var(--fs-3xl); }
    .page-header p { font-size: var(--fs-base); }
    .page-title-icon { width: 38px; height: 38px; }
    .nav-source { display: none; }
    .toasts { left: 16px; right: 16px; bottom: 16px; }
    .toast { max-width: none; }
    .footer-inner { grid-template-columns: minmax(0, 1fr); }
    .btn { min-height: 40px; }
    .btn-sm { height: 40px; }
    .chip, .tab, .dim-tag { min-height: 40px; }
    .footer-links a, .card-header a, .section-head a:not(.btn), .nav-brand { display: inline-flex; align-items: center; min-height: 40px; }
    .footer-links { gap: 0 20px; }
}

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