/* ===================================================================
   FilamentRadar - Modern Design System
   =================================================================== */

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --primary-bg: #eef2ff;
    --primary-rgb: 99, 102, 241;
    --accent: #f59e0b;
    --accent-dark: #d97706;
    --surface: #ffffff;
    --surface-alt: #f8fafc;
    --surface-hover: #f1f5f9;
    --surface-translucent: rgba(255, 255, 255, 0.92);
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --text: #0f172a;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --danger: #ef4444;
    --danger-bg: #fef2f2;
    --success: #10b981;
    --success-bg: #ecfdf5;
    --warning-bg: #fffbeb;
    --radius: 10px;
    --radius-lg: 16px;
    --radius-sm: 6px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.08), 0 2px 4px -2px rgba(0,0,0,0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.05);
    --font: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
}

/* --- Dark theme overrides ---
   Applied when <html data-theme="dark"> is set (by the no-FOUC bootstrap script in _Layout).
   Keep variable names identical to light mode so component CSS works unchanged. */
[data-theme="dark"] {
    --primary: #818cf8;
    --primary-dark: #6366f1;
    --primary-light: #a5b4fc;
    --primary-bg: rgba(129, 140, 248, 0.12);
    --primary-rgb: 129, 140, 248;
    --accent: #fbbf24;
    --accent-dark: #f59e0b;
    --surface: #0f172a;
    --surface-alt: #020617;
    --surface-hover: #1e293b;
    --surface-translucent: rgba(15, 23, 42, 0.85);
    --border: #1e293b;
    --border-light: #0f172a;
    --text: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --danger: #f87171;
    --danger-bg: rgba(239, 68, 68, 0.15);
    --success: #34d399;
    --success-bg: rgba(16, 185, 129, 0.15);
    --warning-bg: rgba(245, 158, 11, 0.15);
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow: 0 1px 3px rgba(0,0,0,0.4), 0 1px 2px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.4), 0 2px 4px -2px rgba(0,0,0,0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.5), 0 4px 6px -4px rgba(0,0,0,0.4);
    color-scheme: dark;
}

/* --- Base --- */

html {
    font-size: 15px;
    min-height: 100%;
}

@media (min-width: 768px) {
    html { font-size: 16px; }
}

body {
    margin: 0;
    padding: 0;
    color: var(--text);
    font-family: var(--font);
    background: var(--surface-alt);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    /* Sticky footer pattern: body becomes a flex column so the footer sits at the bottom
       on short pages but doesn't steal viewport when content is long (the old fixed footer
       ate 70px of mobile real estate). */
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main[role="main"] { flex: 1; }

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

/* --- Navbar --- */

.site-navbar {
    border-bottom: 1px solid var(--border);
    padding: 0 1.5rem;
    height: 56px;
    display: flex;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
    background: var(--surface-translucent);
}

.nav-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 800;
    font-size: 1.1rem;
    color: var(--text);
    text-decoration: none;
    letter-spacing: -0.03em;
}

.nav-brand:hover { color: var(--primary); }

.nav-brand-icon {
    width: 30px;
    height: 30px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(var(--primary-rgb), 0.35);
}

.nav-brand-icon svg {
    width: 100%;
    height: 100%;
    display: block;
}

.nav-brand-sweep {
    transform-origin: 16px 16px;
    animation: radar-sweep 3.2s linear infinite;
}

@keyframes radar-sweep {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
    .nav-brand-sweep { animation: none; }
}

/* --- Theme toggle button (nav) --- */

.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.theme-toggle:hover {
    background: var(--surface-hover);
    color: var(--text);
    border-color: var(--border);
}

.theme-toggle:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.theme-icon {
    width: 18px;
    height: 18px;
}

/* Light mode: show moon (clicking will switch TO dark) */
.theme-icon-sun { display: none; }
.theme-icon-moon { display: block; }

/* Dark mode: show sun (clicking will switch TO light) */
[data-theme="dark"] .theme-icon-sun { display: block; }
[data-theme="dark"] .theme-icon-moon { display: none; }

/* --- Radar loader (used in place of spinners while data loads) --- */

.radar-loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.65rem;
    padding: 1.25rem 1rem;
    color: var(--text-muted);
}

.radar-loader-icon {
    position: relative;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background-image:
        radial-gradient(circle, transparent 0 20px, rgba(var(--primary-rgb),0.30) 20px 21px, transparent 21px),
        radial-gradient(circle, transparent 0 12px, rgba(var(--primary-rgb),0.40) 12px 13px, transparent 13px),
        radial-gradient(circle, transparent 0 5px,  rgba(var(--primary-rgb),0.55) 5px 6px,  transparent 6px);
    background-repeat: no-repeat;
    background-position: center;
}

.radar-loader-icon::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: conic-gradient(from 0deg,
        rgba(var(--primary-rgb),0)    0deg,
        rgba(var(--primary-rgb),0)    260deg,
        rgba(var(--primary-rgb),0.45) 350deg,
        rgba(var(--primary-rgb),0.85) 360deg);
    mask: radial-gradient(circle, #000 0 40%, transparent 41%);
    -webkit-mask: radial-gradient(circle, #000 0 40%, transparent 41%);
    animation: radar-loader-spin 1.4s linear infinite;
}

.radar-loader-icon::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 5px;
    height: 5px;
    background: var(--primary);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 6px rgba(var(--primary-rgb),0.6);
}

.radar-loader-text {
    font-size: 0.875rem;
    letter-spacing: 0.01em;
}

@keyframes radar-loader-spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
    .radar-loader-icon::before { animation: none; opacity: 0.5; }
}

/* --- Alternatives header (title + view toggle) --- */

.alternatives-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.alternatives-header .panel-heading {
    margin: 0;
}

.view-toggle {
    display: inline-flex;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 2px;
    gap: 2px;
}

.view-toggle-btn {
    background: transparent;
    border: 0;
    padding: 0.3rem 0.75rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.view-toggle-btn:hover {
    color: var(--text);
}

.view-toggle-btn.active {
    background: var(--surface);
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

/* --- Radar view for closest alternatives --- */

.similar-radar {
    padding: 0.5rem 0 0;
}

.radar-svg {
    width: 100%;
    max-width: 360px;
    height: auto;
    display: block;
    margin: 0 auto;
}

.radar-rings circle {
    fill: none;
    stroke: rgba(var(--primary-rgb), 0.18);
    stroke-width: 1;
}

.radar-rings circle:last-child {
    stroke: rgba(var(--primary-rgb), 0.32);
}

.radar-axes line {
    stroke: rgba(var(--primary-rgb), 0.10);
    stroke-width: 1;
    stroke-dasharray: 2 3;
}

.radar-ring-labels text {
    fill: var(--text-muted);
    font-size: 9px;
    font-family: var(--font-mono);
    user-select: none;
}

.radar-center {
    stroke: #fff;
    stroke-width: 2;
    filter: drop-shadow(0 1px 3px rgba(0,0,0,0.25));
    fill: var(--primary);
}

.radar-dot circle {
    stroke: #fff;
    stroke-width: 1.5;
    cursor: pointer;
    transition: transform 0.15s ease, stroke-width 0.15s ease;
    transform-box: fill-box;
    transform-origin: center;
}

.radar-dot:hover circle,
.radar-dot:focus circle {
    transform: scale(1.45);
    stroke-width: 2.5;
}

.radar-dot:focus {
    outline: none;
}

.radar-hint {
    margin: 0.75rem 0 0;
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    letter-spacing: 0.01em;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    list-style: none;
    margin: 0;
    padding: 0;
}

/* Hamburger — hidden on desktop, becomes the menu toggle below 768px. */
.nav-hamburger {
    display: none;
    width: 40px;
    height: 40px;
    padding: 0;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 4px;
    color: var(--text-secondary);
}

.nav-hamburger span {
    display: block;
    width: 20px;
    height: 2px;
    background: currentColor;
    border-radius: 2px;
    transition: transform 0.2s, opacity 0.15s;
}

.nav-hamburger:hover {
    background: var(--surface-hover);
    color: var(--text);
}

/* Open state: top span tilts down, middle fades, bottom tilts up (classic X). */
.nav-open .nav-hamburger span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.nav-open .nav-hamburger span:nth-child(2) { opacity: 0; }
.nav-open .nav-hamburger span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

@media (max-width: 767px) {
    .nav-hamburger { display: flex; }

    /* Hide the menu by default on mobile; the hamburger toggles .nav-open on the nav element
       which switches display back on (absolute-positioned dropdown below the bar). */
    .nav-links {
        display: none;
        position: absolute;
        top: 56px;
        left: 0;
        right: 0;
        flex-direction: column;
        align-items: stretch;
        background: var(--surface);
        border-bottom: 1px solid var(--border);
        padding: 0.5rem 1rem 0.75rem;
        gap: 0.25rem;
        box-shadow: var(--shadow-md);
    }

    .nav-open .nav-links { display: flex; }

    .nav-links li { width: 100%; }
    .nav-links a,
    .nav-links .nav-logout-btn {
        display: block;
        width: 100%;
        padding: 0.6rem 0.85rem;
        text-align: left;
    }

    /* Lang switcher: drop the left divider on mobile (it sits below a wrap, not beside text). */
    .lang-switcher {
        margin-left: 0;
        padding-left: 0;
        border-left: 0;
        padding-top: 0.5rem;
        border-top: 1px solid var(--border);
        justify-content: flex-start;
    }
}

.nav-links a {
    padding: 0.4rem 0.85rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    transition: all 0.15s;
    text-decoration: none;
}

.nav-logout-btn {
    background: none;
    border: 1px solid var(--border);
    padding: 0.35rem 0.85rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: var(--font);
    transition: all 0.15s;
}

.nav-logout-btn:hover {
    color: var(--danger);
    border-color: var(--danger);
    background: var(--danger-bg);
}

.nav-links a:hover,
.nav-links a.active {
    color: var(--primary);
    background: var(--primary-bg);
}

/* --- Language switcher --- */

.lang-switcher {
    display: inline-flex;
    align-items: center;
    gap: 0.15rem;
    margin-left: 0.5rem;
    padding-left: 0.75rem;
    border-left: 1px solid var(--border);
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.04em;
}

.lang-switcher a,
.lang-switcher .lang-active {
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    text-decoration: none;
    transition: all 0.15s;
}

.lang-switcher a {
    color: var(--text-muted);
}

.lang-switcher a:hover {
    color: var(--primary);
    background: var(--primary-bg);
}

.lang-switcher .lang-active {
    color: var(--primary);
    background: var(--primary-bg);
    cursor: default;
}

/* --- Footer --- */

.site-footer {
    padding: 1rem 1.5rem;
    font-size: 0.8rem;
    background: var(--surface);
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    margin-top: 2rem;
}

.footer-inner {
    display: flex;
    justify-content: space-between;
    max-width: 1400px;
    margin: 0 auto;
}

/* --- Buttons --- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.5rem 1.1rem;
    font-size: 0.875rem;
    font-weight: 600;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s;
    line-height: 1.4;
    white-space: nowrap;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }

.btn-ghost { background: transparent; color: var(--text-secondary); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-hover); color: var(--text); }

.btn-danger-ghost { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn-danger-ghost:hover { background: var(--danger); color: #fff; }

.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-dark); color: #fff; }

.btn-outline-primary { border-color: var(--primary); color: var(--primary); background: transparent; }
.btn-outline-primary:hover { background: var(--primary); color: #fff; }

.btn-outline-secondary { border-color: var(--border); color: var(--text-secondary); background: transparent; }
.btn-outline-secondary:hover { background: var(--surface-hover); }

.btn-outline-danger { border-color: var(--danger); color: var(--danger); background: transparent; }
.btn-outline-danger:hover { background: var(--danger); color: #fff; }

.btn-sm { padding: 0.3rem 0.7rem; font-size: 0.78rem; }
.btn-lg { padding: 0.7rem 1.8rem; font-size: 1rem; }
.btn-warning { background: var(--accent); color: #fff; }
.btn-warning:hover { background: var(--accent-dark); }
.w-100 { width: 100%; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1.5rem; }
.mb-3 { margin-bottom: 1rem; }
.pb-3 { padding-bottom: 1rem; }

/* --- Brand Logos --- */

.brand-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 6px;
    overflow: hidden;
    flex-shrink: 0;
    background: var(--surface-alt);
    border: 1px solid var(--border-light);
}

.brand-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 2px;
}

.brand-logo-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    font-size: 0.6rem;
    font-weight: 800;
    color: var(--text-secondary);
    background: var(--surface-alt);
    letter-spacing: -0.02em;
}

/* --- Color Swatches --- */

.color-swatch {
    display: inline-block;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    border: 2px solid rgba(0,0,0,0.08);
    box-shadow: var(--shadow-sm);
    vertical-align: middle;
    flex-shrink: 0;
}

.color-swatch-inline {
    display: inline-block;
    width: 16px;
    height: 16px;
    border-radius: 4px;
    border: 1px solid rgba(0,0,0,0.1);
    vertical-align: middle;
    margin-right: 0.3rem;
}

.color-swatch-lg {
    display: inline-block;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: 2px solid rgba(0,0,0,0.08);
    box-shadow: var(--shadow-sm);
    vertical-align: middle;
}

/* --- Delta E Badges --- */

.delta-e-badge {
    display: inline-block;
    padding: 0.2em 0.65em;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 700;
    font-family: var(--font-mono);
    white-space: nowrap;
}

.delta-e-excellent { background: #dcfce7; color: #166534; }
.delta-e-good { background: #dbeafe; color: #1e40af; }
.delta-e-moderate { background: #fef3c7; color: #92400e; }
.delta-e-poor { background: #fee2e2; color: #991b1b; }

[data-theme="dark"] .delta-e-excellent { background: rgba(34, 197, 94, 0.18);  color: #86efac; }
[data-theme="dark"] .delta-e-good      { background: rgba(59, 130, 246, 0.20); color: #93c5fd; }
[data-theme="dark"] .delta-e-moderate  { background: rgba(245, 158, 11, 0.20); color: #fcd34d; }
[data-theme="dark"] .delta-e-poor      { background: rgba(239, 68, 68, 0.20);  color: #fca5a5; }

/* --- Alerts --- */

.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    font-size: 0.875rem;
    font-weight: 500;
}

.alert-success { background: var(--success-bg); color: #065f46; border: 1px solid #a7f3d0; }
.alert-danger { background: var(--danger-bg); color: #991b1b; border: 1px solid #fecaca; }

[data-theme="dark"] .alert-success { color: #86efac; border-color: rgba(34, 197, 94, 0.35); }
[data-theme="dark"] .alert-danger  { color: #fca5a5; border-color: rgba(239, 68, 68, 0.35); }

/* --- Bootstrap utility class overrides (Bootstrap 5.1 has no dark mode) --- */
/* text-muted ships with hard #6c757d in Bootstrap; route through our token instead. */
.text-muted { color: var(--text-muted) !important; }
.text-danger { color: var(--danger) !important; }
.text-success { color: var(--success) !important; }

/* Tables: Bootstrap hardcodes #212529 text + #dee2e6 borders. Reroute via tokens
   so detail/admin/similar tables read correctly in dark mode. */
.table {
    color: var(--text);
    border-color: var(--border);
    --bs-table-color: var(--text);
    --bs-table-bg: transparent;
    --bs-table-border-color: var(--border);
    --bs-table-striped-color: var(--text);
    --bs-table-striped-bg: rgba(var(--primary-rgb), 0.04);
    --bs-table-hover-color: var(--text);
    --bs-table-hover-bg: rgba(var(--primary-rgb), 0.08);
    --bs-table-active-color: var(--text);
    --bs-table-active-bg: rgba(var(--primary-rgb), 0.10);
}

.table > :not(caption) > * > * {
    color: var(--text);
    border-bottom-color: var(--border);
    background-color: transparent;
}

/* Breadcrumb: Bootstrap hardcodes the active-page text and "/" divider to #6c757d. */
.breadcrumb-item.active { color: var(--text-secondary); }
.breadcrumb-item + .breadcrumb-item::before { color: var(--text-muted); }

/* Color picker — browsers render the native chrome in a fixed light style.
   color-scheme: dark on <html> tells modern browsers to render native form widgets dark. */
input[type="color"] {
    background: var(--surface);
    border-color: var(--border);
}

/* --- Forms --- */

.form-control,
.form-select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    background: var(--surface);
    color: var(--text);
    transition: all 0.15s;
}

.form-control:focus,
.form-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.12);
}

.form-range { width: 100%; accent-color: var(--primary); }

/* Larger range thumb on touch devices so the Max ΔE slider is grabbable with a finger.
   `pointer: coarse` matches touch screens — desktop mouse users get the default thin thumb. */
@media (pointer: coarse) {
    input[type="range"].form-range {
        height: 28px;
    }
    input[type="range"].form-range::-webkit-slider-thumb {
        width: 24px;
        height: 24px;
    }
    input[type="range"].form-range::-moz-range-thumb {
        width: 24px;
        height: 24px;
    }
}

/* --- Badge --- */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.15em 0.55em;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 20px;
}

.bg-secondary { background: var(--border); color: var(--text-secondary); }

/* ===================================================================
   Home Page
   =================================================================== */

.hero-section {
    padding: 5rem 2rem;
    text-align: center;
    background: linear-gradient(135deg, #eef2ff 0%, #e0e7ff 30%, #faf5ff 70%, #fdf2f8 100%);
    border-radius: var(--radius-lg);
    margin: 1.5rem;
    position: relative;
    overflow: hidden;
}

.hero-section::before {
    content: '';
    position: absolute;
    top: -40%;
    right: -20%;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(var(--primary-rgb),0.08) 0%, transparent 70%);
    pointer-events: none;
}

.hero-title {
    font-size: 2.8rem;
    font-weight: 900;
    margin-bottom: 1rem;
    color: var(--text);
    letter-spacing: -0.04em;
    line-height: 1.15;
}

.hero-subtitle {
    font-size: 1.15rem;
    color: var(--text-secondary);
    max-width: 560px;
    margin: 0 auto 2.5rem;
    line-height: 1.7;
}

.hero-actions .btn {
    padding: 0.8rem 2.2rem;
    font-size: 1.05rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
}

.features-section {
    padding: 2.5rem 1.5rem;
    max-width: 1100px;
    margin: 0 auto;
}

.feature-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2rem;
    height: 100%;
    text-align: center;
    transition: all 0.2s;
    box-shadow: var(--shadow-sm);
}

.feature-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
    border-color: var(--primary-light);
}

.feature-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin: 0 auto 1.2rem;
    background: var(--primary-bg);
}

.feature-card h3 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 0.6rem;
    color: var(--text);
}

.feature-card p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.65;
    margin: 0;
}

.cta-section {
    padding: 3.5rem 1.5rem;
    text-align: center;
    max-width: 600px;
    margin: 0 auto;
}

.cta-section h2 {
    font-size: 1.7rem;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.03em;
    margin-bottom: 0.5rem;
}

.cta-section p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

/* ===================================================================
   Category landing pages (/brand/{slug}, /material/{slug})
   =================================================================== */

.category-page {
    max-width: 1100px;
    margin: 1rem auto;
    padding: 0 1.5rem;
}

/* Hero card with eyebrow, title, subtitle, stats and a palette strip */
.category-hero {
    margin-top: 1rem;
    padding: 1.75rem 1.75rem 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.category-hero-main {
    padding-bottom: 1.25rem;
}

.category-eyebrow {
    text-transform: uppercase;
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    font-weight: 600;
    color: var(--text-muted);
    margin: 0 0 0.35rem;
}

.category-eyebrow-divider {
    margin: 0 0.45em;
    color: var(--border);
}

.category-eyebrow-parent {
    color: var(--primary);
    text-decoration: none;
    transition: color 0.15s;
}

.category-eyebrow-parent:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

.category-title {
    font-size: clamp(1.6rem, 3.2vw, 2.2rem);
    font-weight: 800;
    letter-spacing: -0.025em;
    color: var(--text);
    margin: 0 0 0.5rem;
    line-height: 1.15;
}

.category-subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.5;
    margin: 0 0 1.25rem;
    max-width: 720px;
}

.category-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.75rem;
    max-width: 460px;
}

.category-stat {
    background: var(--surface-alt);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 0.7rem 0.85rem;
    text-align: center;
}

.category-stat-number {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--primary);
    letter-spacing: -0.02em;
    line-height: 1;
    margin-bottom: 0.2rem;
}

.category-stat-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

/* Color palette strip — a 6-12 swatch ribbon below the stats */
.category-palette {
    display: flex;
    height: 12px;
    margin: 0 -1.75rem;
    /* Edge-to-edge inside the hero card */
}

.palette-swatch {
    flex: 1;
}

/* Breakdown chips */
.category-section-heading {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 700;
    color: var(--text-muted);
    margin: 1.75rem 0 0.85rem;
}

.category-breakdown { margin-bottom: 0.5rem; }

.breakdown-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.breakdown-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0.85rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
    text-decoration: none;
    color: var(--text);
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.15s;
}

.breakdown-chip:hover {
    border-color: var(--primary-light);
    background: var(--primary-bg);
    color: var(--primary-dark);
    transform: translateY(-1px);
}

.breakdown-chip-name { font-weight: 600; }

.breakdown-chip-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 20px;
    padding: 0 0.4rem;
    background: var(--surface-alt);
    border-radius: 10px;
    font-size: 0.72rem;
    color: var(--text-muted);
    font-weight: 600;
}

.breakdown-chip:hover .breakdown-chip-count {
    background: white;
    color: var(--primary-dark);
}

/* Filament grid */
.category-filament-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 0.85rem;
}

.category-card {
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    text-decoration: none;
    color: var(--text);
    transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}

.category-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary-light);
}

.category-card-swatch {
    position: relative;
    display: block;
    width: 100%;
    aspect-ratio: 4 / 3;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.category-card-unmeasured-pin {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.92);
    color: var(--accent-dark);
    border: 1px solid var(--accent);
    border-radius: 50%;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: help;
}

.category-card--unmeasured .category-card-swatch {
    border: 2px dashed var(--accent);
    border-bottom-width: 2px;
}

.category-card-match-badge {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px 3px 7px;
    background: rgba(255, 255, 255, 0.94);
    color: var(--primary-dark);
    border: 1px solid rgba(var(--primary-rgb), 0.35);
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.12);
    backdrop-filter: blur(4px);
    cursor: help;
}

.category-card-match-badge::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--primary);
    box-shadow: 0 0 0 2px rgba(var(--primary-rgb), 0.25);
}

.category-card-body {
    padding: 0.65rem 0.75rem 0.7rem;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.category-card-name {
    font-weight: 600;
    font-size: 0.88rem;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.category-card-meta {
    font-size: 0.72rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.category-card-brand { font-weight: 500; }

.category-card-hex {
    font-size: 0.7rem;
    font-family: var(--font-mono);
    color: var(--text-muted);
    margin-top: 0.1rem;
}

/* Empty state + CTA */
.category-empty {
    padding: 2.5rem 1rem;
    text-align: center;
    color: var(--text-muted);
    background: var(--surface-alt);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    margin-top: 1.5rem;
}

.category-actions {
    margin-top: 2rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border-light);
}

@media (max-width: 600px) {
    .category-hero { padding: 1.25rem 1.25rem 0; }
    .category-palette { margin: 0 -1.25rem; }
    .category-stats { max-width: 100%; }
    .category-stat-number { font-size: 1.15rem; }
}

@media (max-width: 420px) {
    /* 3 stat cards on a 375px screen squeeze the "Measurements" label below readable width.
       Drop to a single column on the smallest phones. */
    .category-stats { grid-template-columns: 1fr; }
}

/* ===================================================================
   Color landing page
   =================================================================== */

.color-page {
    max-width: 1100px;
    margin: 1rem auto;
    padding: 0 1.5rem;
}

.color-lookup-form {
    margin-top: 1rem;
    padding: 0.85rem 1rem;
    background: var(--surface-alt);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
}

.color-lookup-label {
    display: block;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 0.4rem;
}

.color-lookup-row {
    display: flex;
    gap: 0.5rem;
    align-items: stretch;
    flex-wrap: wrap;
}

.color-lookup-row #color-lookup-picker {
    width: 56px;
    height: 42px;
    padding: 2px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    background: transparent;
    flex-shrink: 0;
}

.color-lookup-row #color-lookup-hex {
    flex: 1;
    min-width: 140px;
    font-family: var(--font-mono);
    text-transform: uppercase;
}

.color-header {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
    padding: 1.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    margin-top: 1rem;
}

.color-header-swatch {
    width: 140px;
    height: 140px;
    border-radius: var(--radius);
    flex-shrink: 0;
    border: 1px solid rgba(0, 0, 0, 0.08);
}

.color-header-info { flex: 1; min-width: 0; }

.color-eyebrow {
    text-transform: uppercase;
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    font-weight: 600;
    margin: 0 0 0.25rem;
}

.color-header-info h1 {
    font-size: clamp(1.5rem, 3vw, 2rem);
    font-weight: 800;
    letter-spacing: -0.02em;
    margin: 0 0 0.5rem;
}

.color-subtitle {
    color: var(--text-secondary);
    margin-bottom: 1rem;
    font-size: 0.95rem;
}

.color-values {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.5rem 1rem;
    margin: 0;
}

.color-values > div {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.color-values dt {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    font-weight: 600;
    margin: 0;
}

.color-values dd {
    margin: 0;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text);
}

@media (max-width: 600px) {
    .color-header { flex-direction: column; align-items: stretch; }
    .color-header-swatch { width: 100%; height: 120px; }
}

.color-exact-match {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    background: var(--success-bg);
    border: 1px solid var(--success);
    border-radius: var(--radius);
}

.exact-match-badge {
    background: var(--success);
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.2rem 0.5rem;
    border-radius: 999px;
    flex-shrink: 0;
}

.exact-match-link {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    text-decoration: none;
    color: var(--text);
    flex: 1;
}

.exact-match-link:hover strong { text-decoration: underline; }

.color-matches-section h2 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
}

.color-blurb {
    font-size: 0.9rem;
    line-height: 1.5;
}

/* --- Palette section (complementary / analogous / triadic) --- */

.palette-section {
    margin-top: 2rem;
}

.palette-section-header h2 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.palette-section-header p {
    font-size: 0.88rem;
    margin: 0 0 1rem;
}

.palette-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
}

.palette-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1rem 1.1rem;
}

.palette-card-header h3 {
    font-size: 1rem;
    margin: 0 0 0.15rem;
    font-weight: 700;
}

.palette-card-header small {
    font-size: 0.72rem;
    display: block;
    margin-bottom: 0.85rem;
}

.palette-card-entries {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.palette-entry-swatches {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.palette-swatch-block {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(0, 0, 0, 0.08);
    flex-shrink: 0;
}

.palette-arrow {
    color: var(--text-muted);
    font-size: 1rem;
}

.palette-entry-hex {
    margin: 0.35rem 0 0.45rem;
    font-size: 0.78rem;
}

.palette-entry-hex code {
    font-family: var(--font-mono);
    color: var(--text);
}

.palette-rotation {
    color: var(--text-muted);
    margin-left: 0.4rem;
    font-size: 0.7rem;
}

.palette-filament-link {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.45rem 0.6rem;
    background: var(--surface-alt);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--text);
    transition: all 0.12s;
}

.palette-filament-link:hover {
    border-color: var(--primary-light);
    background: var(--primary-bg);
}

.palette-swatch-mini {
    width: 22px;
    height: 22px;
    border-radius: 4px;
    flex-shrink: 0;
    border: 1px solid rgba(0, 0, 0, 0.08);
}

.palette-filament-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.palette-filament-info strong {
    font-size: 0.82rem;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.palette-filament-info small {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

/* ===================================================================
   Home dashboard
   =================================================================== */

.home-hero {
    max-width: 1100px;
    margin: 1.5rem auto 1rem;
    padding: 3rem 1.5rem 2.5rem;
    text-align: center;
    position: relative;
    overflow: hidden;
    isolation: isolate;
}

.home-hero::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: min(560px, 90vw);
    height: min(560px, 90vw);
    transform: translate(-50%, -50%);
    z-index: -1;
    background-image:
        radial-gradient(circle, transparent 0 39px, rgba(var(--primary-rgb),0.10) 39px 40px, transparent 40px),
        radial-gradient(circle, transparent 0 89px, rgba(var(--primary-rgb),0.09) 89px 90px, transparent 90px),
        radial-gradient(circle, transparent 0 149px, rgba(var(--primary-rgb),0.08) 149px 150px, transparent 150px),
        radial-gradient(circle, transparent 0 219px, rgba(var(--primary-rgb),0.07) 219px 220px, transparent 220px);
    background-repeat: no-repeat;
    background-position: center;
    opacity: 0.95;
    pointer-events: none;
}

.home-hero::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: min(440px, 80vw);
    height: min(440px, 80vw);
    transform: translate(-50%, -50%);
    z-index: -1;
    background: conic-gradient(from 0deg,
        rgba(var(--primary-rgb),0) 0deg,
        rgba(var(--primary-rgb),0) 270deg,
        rgba(var(--primary-rgb),0.18) 350deg,
        rgba(var(--primary-rgb),0.32) 360deg);
    border-radius: 50%;
    animation: hero-radar-sweep 5s linear infinite;
    pointer-events: none;
    mask: radial-gradient(circle, #000 0%, #000 95%, transparent 100%);
    -webkit-mask: radial-gradient(circle, #000 0%, #000 95%, transparent 100%);
}

@keyframes hero-radar-sweep {
    from { transform: translate(-50%, -50%) rotate(0deg); }
    to   { transform: translate(-50%, -50%) rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
    .home-hero::after { animation: none; opacity: 0.2; }
}

.home-hero-title {
    font-size: clamp(1.8rem, 4vw, 2.6rem);
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--text);
    margin-bottom: 0.75rem;
}

.home-hero-subtitle {
    font-size: 1.05rem;
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto 1.5rem;
    line-height: 1.5;
}

/* --- Stats row --- */

.home-stats {
    max-width: 1100px;
    margin: 0 auto 2rem;
    padding: 0 1.5rem;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
}

.home-stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    text-align: center;
    transition: transform 0.15s, box-shadow 0.15s;
}

.home-stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.home-stat-number {
    font-size: 2rem;
    font-weight: 800;
    color: var(--primary);
    letter-spacing: -0.02em;
    line-height: 1;
    margin-bottom: 0.3rem;
}

.home-stat-label {
    font-size: 0.78rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
}

@media (max-width: 768px) {
    .home-stats { grid-template-columns: repeat(2, 1fr); }
    .home-stat-number { font-size: 1.6rem; }
}

@media (max-width: 380px) {
    /* 2-col still works at 414px but the numbers + uppercase labels overlap on iPhone SE. */
    .home-stats { grid-template-columns: 1fr; }
}

/* --- Try a Color widget --- */

.home-color-match {
    max-width: 800px;
    margin: 0 auto 2.5rem;
    padding: 1.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.home-color-match h2 {
    margin: 0 0 0.3rem;
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text);
}

.home-section-subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.match-form { margin-bottom: 1rem; }

.match-input-group {
    display: flex;
    gap: 0.5rem;
    align-items: stretch;
    flex-wrap: wrap;
}

#match-color-picker {
    width: 56px;
    height: 42px;
    padding: 2px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    background: transparent;
}

#match-hex {
    flex: 1;
    min-width: 140px;
    font-family: var(--font-mono);
    text-transform: uppercase;
}

.match-error {
    margin-top: 0.5rem;
    color: var(--danger);
    font-size: 0.85rem;
    min-height: 1.2em;
}

.match-results-heading {
    font-size: 0.78rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
    margin: 0 0 0.5rem;
}

.match-results {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.match-result-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--text);
    transition: all 0.12s;
}

.match-result-item:hover {
    border-color: var(--primary-light);
    background: var(--surface-hover);
}

.match-swatch {
    width: 30px;
    height: 30px;
    border-radius: 6px;
    flex-shrink: 0;
    border: 1px solid rgba(0, 0, 0, 0.08);
}

.match-result-info { flex: 1; min-width: 0; }

.match-result-name {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
}

.match-result-meta {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* --- Latest filaments grid --- */

.home-latest {
    max-width: 1100px;
    margin: 0 auto 2.5rem;
    padding: 0 1.5rem;
}

.home-section-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 1rem;
}

.home-section-header h2 {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text);
    margin: 0;
}

.home-section-link {
    font-size: 0.85rem;
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.home-section-link:hover { text-decoration: underline; }

.home-latest-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 0.75rem;
}

.latest-card {
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    transition: transform 0.15s, box-shadow 0.15s;
}

.latest-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.latest-swatch {
    display: block;
    width: 100%;
    height: 70px;
}

.latest-name {
    display: block;
    padding: 0.5rem 0.6rem 0.1rem;
    font-weight: 600;
    font-size: 0.82rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.latest-meta {
    display: block;
    padding: 0 0.6rem 0.55rem;
    font-size: 0.7rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (max-width: 900px) {
    .home-latest-grid { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 600px) {
    .home-latest-grid { grid-template-columns: repeat(2, 1fr); }
}

/* --- Compact features --- */

.home-features-compact {
    max-width: 1100px;
    margin: 0 auto 3rem;
    padding: 0 1.5rem;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
}

.feature-chip {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    padding: 0.85rem 1rem;
    background: var(--surface-alt);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
}

.feature-chip-icon {
    font-size: 1.5rem;
    line-height: 1;
    flex-shrink: 0;
}

.feature-chip strong {
    display: block;
    font-size: 0.9rem;
    margin-bottom: 0.15rem;
}

.feature-chip small {
    color: var(--text-muted);
    font-size: 0.75rem;
    line-height: 1.4;
}

@media (max-width: 768px) {
    .home-features-compact { grid-template-columns: 1fr; }
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ===================================================================
   Filament Picker
   =================================================================== */

.picker-title {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.03em;
    margin-bottom: 0.15rem;
}

.picker-subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 1.25rem;
}

.picker-layout {
    display: grid;
    grid-template-columns: 250px 1fr 380px;
    gap: 1rem;
    min-height: calc(100vh - 200px);
}

@media (max-width: 1100px) {
    .picker-layout { grid-template-columns: 230px 1fr; }
    .picker-detail { grid-column: 1 / -1; }
}

@media (max-width: 768px) {
    .picker-layout { grid-template-columns: 1fr; }
}

.panel-heading {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Filters */

.picker-filters {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    align-self: start;
    box-shadow: var(--shadow-sm);
}

/* Sticky filter panel only useful while filters live in a sidebar column. Below 768px
   everything stacks vertically and sticky would just glue the filter card to the top
   of the viewport, covering the list as the user scrolls. */
@media (min-width: 768px) {
    .picker-filters { position: sticky; top: 72px; }
}

/* Search stays visible at all sizes — it's the primary action. The little bottom margin
   creates breathing room before the collapsible toggle on mobile. */
.filter-search-group { margin-bottom: 0.5rem; }

/* "More filters" toggle button — only visible on phones. On desktop the filter body is
   always open and the toggle is hidden. */
.picker-filters-toggle {
    display: none;
    width: 100%;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 0.85rem;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    font-family: var(--font);
    text-align: left;
    transition: background 0.15s, color 0.15s;
}

.picker-filters-toggle:hover { background: var(--surface-hover); color: var(--text); }
.picker-filters-toggle:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.picker-filters-toggle-label { flex: 1; }

.picker-filters-toggle-badge {
    background: var(--primary);
    color: #fff;
    border-radius: 999px;
    padding: 1px 8px;
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1.4;
}

.picker-filters-toggle-icon {
    font-size: 0.85rem;
    transition: transform 0.15s;
}

.picker-filters.is-open .picker-filters-toggle-icon { transform: rotate(180deg); }

@media (max-width: 767px) {
    .picker-filters-toggle { display: flex; }
    .picker-filters-body { display: none; margin-top: 0.75rem; }
    .picker-filters.is-open .picker-filters-body { display: block; }
}

.filter-group {
    margin-bottom: 1rem;
}

.filter-group label {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.3rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.filter-group .form-control,
.filter-group .form-select {
    font-size: 0.85rem;
}

/* Filament List */

.picker-list {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    background: var(--surface);
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-sm);
}

.filament-list-container {
    flex: 1;
    overflow-y: auto;
    max-height: calc(100vh - 260px);
}

.filament-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.55rem 0.75rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.12s;
    border: 1.5px solid transparent;
    margin-bottom: 2px;
}

.filament-item:hover {
    background: var(--surface-hover);
}

.filament-item--selected {
    background: var(--primary-bg);
    border-color: var(--primary-light);
}

.filament-item-info { flex: 1; min-width: 0; }

.filament-item-name {
    display: block;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.filament-item-meta {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.filament-item-hex {
    font-size: 0.72rem;
    font-family: var(--font-mono);
    color: var(--text-muted);
}

/* Unmeasured filaments — soft visual de-emphasis + amber badge */

.filament-item--unmeasured .color-swatch {
    opacity: 0.6;
    border: 1.5px dashed var(--accent);
}

.filament-item--unmeasured .filament-item-hex {
    font-style: italic;
}

.detail-swatch-large--unmeasured {
    border: 2px dashed var(--accent);
    opacity: 0.85;
}

.unmeasured-badge {
    display: inline-block;
    margin-left: 0.4rem;
    padding: 0.05rem 0.4rem;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    color: var(--accent-dark);
    background: var(--warning-bg);
    border: 1px solid var(--accent);
    border-radius: 999px;
    vertical-align: middle;
    white-space: nowrap;
}

.unmeasured-notice {
    padding: 0.9rem 1rem;
    border-left: 3px solid var(--accent);
    background: var(--warning-bg);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 0.85rem;
    line-height: 1.45;
}

.unmeasured-notice strong {
    display: block;
    margin-bottom: 0.35rem;
    color: var(--accent-dark);
}

.unmeasured-notice p {
    margin: 0;
    color: var(--text-secondary);
}

/* Buy / Purchase links */

.buy-links,
.selected-buy-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.buy-link {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    text-decoration: none;
    white-space: nowrap;
}

.buy-link-icon {
    font-size: 0.85em;
    opacity: 0.8;
}

.detail-buy-section {
    padding: 1rem 1.25rem;
    background: var(--surface-alt);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.detail-buy-section h2 {
    margin-top: 0;
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
}

/* Pagination */

.pagination-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding-top: 0.75rem;
    margin-top: 0.75rem;
    border-top: 1px solid var(--border-light);
}

.page-info {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* Detail Panel */

.picker-detail {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    background: var(--surface);
    align-self: start;
    box-shadow: var(--shadow-sm);
}

/* Sticky detail panel only useful when it sits beside the list (3-column desktop). */
@media (min-width: 1100px) {
    .picker-detail { position: sticky; top: 72px; }
}

.placeholder-message {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    color: var(--text-muted);
    font-size: 0.9rem;
    text-align: center;
    padding: 2rem;
}

.selected-filament-card {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

.selected-swatch {
    width: 72px;
    height: 72px;
    border-radius: var(--radius);
    border: 2px solid rgba(0,0,0,0.06);
    box-shadow: var(--shadow);
    flex-shrink: 0;
}

.selected-info h3 {
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 0.2rem;
    color: var(--text);
}

.selected-meta { font-size: 0.8rem; color: var(--text-secondary); margin-bottom: 0.2rem; }
.selected-hex { font-family: var(--font-mono); font-size: 0.85rem; color: var(--text-muted); margin-bottom: 0.5rem; }

/* Similar Items */

.similar-list-container {
    max-height: calc(100vh - 440px);
    overflow-y: auto;
}

.similar-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.6rem;
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: inherit;
    transition: background 0.12s;
}

.similar-item:hover { background: var(--surface-hover); }

.similar-item-info { flex: 1; min-width: 0; }
.similar-item-name { display: block; font-weight: 600; font-size: 0.85rem; color: var(--text); }
.similar-item-meta { display: block; font-size: 0.72rem; color: var(--text-muted); }

/* ===================================================================
   Filament Detail Page
   =================================================================== */

.filament-detail-page {
    max-width: 960px;
    margin: 0 auto;
    padding: 1rem 1.5rem;
}

.breadcrumb {
    display: flex;
    gap: 0.4rem;
    list-style: none;
    padding: 0;
    margin-bottom: 1.5rem;
    font-size: 0.85rem;
}

.breadcrumb-item + .breadcrumb-item::before {
    content: '/';
    margin-right: 0.4rem;
    color: var(--text-muted);
}

.breadcrumb-item a { color: var(--text-secondary); }
.breadcrumb-item a:hover { color: var(--primary); }
.breadcrumb-item.active { color: var(--text-muted); }

.detail-header {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
    margin-bottom: 2rem;
}

.detail-swatch-large {
    width: 100px;
    height: 100px;
    border-radius: var(--radius-lg);
    border: 3px solid rgba(0,0,0,0.06);
    box-shadow: var(--shadow-md);
    flex-shrink: 0;
}

.detail-header-info h1 {
    font-size: 1.65rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    color: var(--text);
    letter-spacing: -0.03em;
}

.detail-meta {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
    margin-bottom: 0.5rem;
}

.detail-tag {
    display: inline-block;
    padding: 0.2em 0.7em;
    font-size: 0.78rem;
    font-weight: 600;
    background: var(--primary-bg);
    color: var(--primary-dark);
    border-radius: 20px;
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}

a.detail-tag:hover {
    background: var(--primary);
    color: #fff;
}

/* Family chip — visually distinct from the brand/material tags so it reads as the
   broader grouping ("this PolyLite PLA is part of the PLA family"). */
.detail-tag--family {
    background: rgba(245, 158, 11, 0.15);
    color: var(--accent-dark);
}

a.detail-tag--family:hover {
    background: var(--accent);
    color: #fff;
}

.detail-code { font-size: 0.85rem; color: var(--text-secondary); }

.detail-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    height: 100%;
    box-shadow: var(--shadow-sm);
}

.detail-card h2 {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--text);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 0.85rem;
}

.detail-table th {
    font-weight: 600;
    color: var(--text-secondary);
    width: 40%;
    font-size: 0.85rem;
}

.detail-table td { font-size: 0.85rem; }

/* Phone: the 40%/60% th/td layout squeezes both columns to unreadable widths under
   ~420px. Stack each row as label-over-value blocks so both stay legible. */
@media (max-width: 576px) {
    .detail-table thead { display: none; }
    .detail-table tbody, .detail-table tr { display: block; }
    .detail-table tr { padding: 0.5rem 0; border-bottom: 1px solid var(--border-light); }
    .detail-table tr:last-child { border-bottom: 0; }
    .detail-table th,
    .detail-table td {
        display: block;
        width: 100%;
        padding: 0.1rem 0;
        border: 0;
    }
    .detail-table th {
        text-transform: uppercase;
        font-size: 0.7rem;
        letter-spacing: 0.04em;
        color: var(--text-muted);
    }
    .detail-table td { font-size: 0.95rem; }
}

.detail-similar-section h2 {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 1rem;
}

.similar-table {
    /* Keep columns readable on small viewports — table-responsive wrapper will scroll
       horizontally when this exceeds the available width. */
    min-width: 540px;
}

.similar-table th {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.similar-table td { vertical-align: middle; font-size: 0.85rem; }

.detail-actions { padding-bottom: 2rem; }

@media (max-width: 576px) {
    .detail-header { flex-direction: column; align-items: center; text-align: center; }
    .detail-meta { justify-content: center; }
    .detail-swatch-large { width: 80px; height: 80px; }
    .hero-title { font-size: 2rem; }
    .hero-section { padding: 3rem 1rem; margin: 0.75rem; }
}

/* ===================================================================
   Admin
   =================================================================== */

.admin-page {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem;
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.admin-header h1 {
    font-size: 1.4rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    letter-spacing: -0.02em;
}

.admin-actions { display: flex; gap: 0.5rem; }

.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    text-align: center;
    box-shadow: var(--shadow-sm);
}

.stat-number {
    font-size: 2rem;
    font-weight: 800;
    color: var(--primary);
    letter-spacing: -0.03em;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 0.15rem;
}

.admin-filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.65rem 0.85rem;
    margin: 1rem 0 0.75rem;
}

.admin-filter-search { flex: 1 1 280px; min-width: 220px; }
.admin-filter-select { flex: 0 1 180px; min-width: 140px; }

.admin-filter-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.75rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    user-select: none;
}

.admin-filter-toggle:has(input:checked) {
    background: var(--primary-bg);
    color: var(--primary-dark);
    border-color: var(--primary);
}

.admin-filter-toggle input { accent-color: var(--primary); }

.admin-result-summary {
    margin: 0 0 0.5rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.admin-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin: 1rem 0 0;
    padding: 0.75rem 0;
}

.admin-page-info { font-size: 0.9rem; color: var(--text-secondary); }

.admin-table-wrapper { overflow-x: auto; }

.admin-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.admin-table th {
    background: var(--surface-alt);
    padding: 0.65rem 0.85rem;
    text-align: left;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-bottom: 1px solid var(--border);
}

.admin-table td {
    padding: 0.55rem 0.85rem;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.85rem;
    vertical-align: middle;
}

.admin-table tbody tr { transition: background 0.1s; }
.admin-table tbody tr:hover { background: var(--surface-hover); }
.admin-table .text-center { text-align: center; }
.admin-table .text-muted { color: var(--text-muted); }

.admin-table .lab-values {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.admin-form-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.admin-form-card h2 {
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text);
    margin-bottom: 1rem;
    padding-bottom: 0.6rem;
    border-bottom: 1px solid var(--border-light);
}

.admin-form-card h3 {
    font-size: 0.95rem;
    font-weight: 700;
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
    color: var(--text);
}

.form-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.form-group { flex: 1; min-width: 180px; }

.form-group label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.3rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.hex-input-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.hex-input-group input[type="color"] {
    width: 42px;
    height: 38px;
    padding: 2px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
}

.lab-aggregate-display {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
}

.lab-value {
    font-family: var(--font-mono);
    font-size: 1rem;
}

.lab-label {
    font-weight: 700;
    color: var(--primary);
    margin-right: 0.3rem;
}

/* --- Scrollbar --- */

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
