:root {
    --brand-ink: #0e0e10;
    --brand-ink-soft: #2a2a30;
    --brand-mute: #6b6b75;
    --brand-line: #e8e6ee;
    --brand-bg: #ffffff;
    --brand-bg-alt: #faf9fc;
    --brand-accent: #8b5cf6;
    --brand-accent-soft: #ede9fe;
    --brand-accent-deep: #6d28d9;
    --brand-success: #10b981;
    --brand-warn: #f59e0b;
    --brand-danger: #ef4444;
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 22px;
    --shadow-sm: 0 1px 2px rgba(14, 14, 16, 0.04), 0 2px 8px rgba(14, 14, 16, 0.04);
    --shadow-md: 0 6px 20px rgba(14, 14, 16, 0.06);
    --shadow-lg: 0 20px 50px rgba(109, 40, 217, 0.14);
}

* { box-sizing: border-box; }

html {
    scroll-behavior: smooth;
    scroll-padding-top: 88px; /* clear the sticky topbar (~72px) when jumping to anchors */
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
}

html, body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--brand-ink);
    background: var(--brand-bg);
    -webkit-font-smoothing: antialiased;
    line-height: 1.55;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

.container {
    width: 100%;
    max-width: 1180px;
    margin: 0 auto;
    padding: 0 24px;
}

/* ---------- Top bar ---------- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    backdrop-filter: saturate(140%) blur(14px);
    background: rgba(255, 255, 255, 0.78);
    border-bottom: 1px solid var(--brand-line);
}
.topbar__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 72px;
}
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    letter-spacing: -0.01em;
}
.brand img, .brand svg { height: 44px; width: auto; }

.nav {
    display: flex;
    align-items: center;
    gap: 28px;
}
.nav a {
    color: var(--brand-ink-soft);
    font-size: 14.5px;
    font-weight: 500;
    transition: color .15s ease;
}
.nav a:hover { color: var(--brand-accent-deep); }

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

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 20px;
    border-radius: 999px;
    font-weight: 600;
    font-size: 14.5px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: transform .12s ease, box-shadow .15s ease, background .15s ease, color .15s ease, border-color .15s ease;
    white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn--primary {
    background: var(--brand-ink);
    color: #fff;
}
.btn--primary:hover { background: var(--brand-accent-deep); box-shadow: var(--shadow-lg); }
.btn--accent {
    background: var(--brand-accent);
    color: #fff;
}
.btn--accent:hover { background: var(--brand-accent-deep); box-shadow: var(--shadow-lg); }
.btn--ghost {
    background: transparent;
    color: var(--brand-ink-soft);
    border-color: var(--brand-line);
}
.btn--ghost:hover { border-color: var(--brand-ink); color: var(--brand-ink); }
.btn--block { width: 100%; }
.btn--sm { padding: 8px 14px; font-size: 13.5px; }

/* ---------- Staff portal dropdown ---------- */
.dropdown { position: relative; }
.dropdown__btn {
    background: transparent;
    border: 1px solid var(--brand-line);
    border-radius: 999px;
    padding: 9px 16px;
    font-size: 14px;
    font-weight: 500;
    color: var(--brand-ink-soft);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.dropdown__btn:hover { border-color: var(--brand-ink); color: var(--brand-ink); }
.dropdown__btn .chev {
    width: 14px; height: 14px;
    transition: transform .18s ease;
}
.dropdown.is-open .dropdown__btn .chev { transform: rotate(180deg); }
.dropdown__menu {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    min-width: 240px;
    background: #fff;
    border: 1px solid var(--brand-line);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    padding: 8px;
    opacity: 0;
    transform: translateY(-6px);
    pointer-events: none;
    transition: opacity .15s ease, transform .15s ease;
}
.dropdown.is-open .dropdown__menu {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}
.dropdown__item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    color: var(--brand-ink);
    font-size: 14px;
    font-weight: 500;
}
.dropdown__item:hover { background: var(--brand-bg-alt); color: var(--brand-accent-deep); }
.dropdown__item-ico {
    width: 36px; height: 36px;
    border-radius: 10px;
    background: var(--brand-accent-soft);
    color: var(--brand-accent-deep);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
}
.dropdown__item-meta { line-height: 1.25; }
.dropdown__item-meta small {
    display: block;
    font-size: 12px;
    color: var(--brand-mute);
    font-weight: 400;
    margin-top: 2px;
}
.dropdown__divider {
    height: 1px;
    background: var(--brand-line);
    margin: 6px 4px;
}

/* ---------- Hero ---------- */
.hero {
    padding: 88px 0 72px;
    background:
        radial-gradient(900px 420px at 85% -10%, rgba(139, 92, 246, 0.18), transparent 60%),
        radial-gradient(700px 360px at -10% 30%, rgba(16, 185, 129, 0.10), transparent 60%);
}
.hero__grid {
    display: grid;
    grid-template-columns: 1.05fr 0.95fr;
    gap: 64px;
    align-items: center;
}
.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 999px;
    background: var(--brand-accent-soft);
    color: var(--brand-accent-deep);
    font-size: 12.5px;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}
.eyebrow::before {
    content: "";
    width: 7px; height: 7px;
    border-radius: 999px;
    background: var(--brand-accent);
}
.hero h1 {
    font-size: clamp(38px, 5vw, 60px);
    line-height: 1.05;
    letter-spacing: -0.025em;
    margin: 18px 0 18px;
    font-weight: 700;
}
.hero h1 .accent { color: var(--brand-accent-deep); }
.hero p.lead {
    font-size: 18px;
    color: var(--brand-mute);
    max-width: 540px;
    margin: 0 0 28px;
}
.hero__cta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 28px;
}
.hero__metrics {
    display: flex;
    gap: 36px;
    margin-top: 28px;
    border-top: 1px solid var(--brand-line);
    padding-top: 22px;
}
.metric strong {
    display: block;
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.02em;
}
.metric span {
    font-size: 13px;
    color: var(--brand-mute);
}

/* Hero card */
.hero__card {
    background: #fff;
    border: 1px solid var(--brand-line);
    border-radius: var(--radius-lg);
    padding: 22px;
    box-shadow: var(--shadow-md);
    position: relative;
}
.hero__card::after {
    content: "";
    position: absolute;
    inset: -1px;
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, rgba(139,92,246,.18), transparent 40%);
    z-index: -1;
}
.verdict {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--brand-bg-alt);
    border: 1px solid var(--brand-line);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    margin-bottom: 14px;
}
.verdict__chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(16,185,129,.10);
    color: #047857;
    font-weight: 600;
    font-size: 13px;
    padding: 4px 10px;
    border-radius: 999px;
}
.verdict__score {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.02em;
}
.ingredient-row {
    display: grid;
    grid-template-columns: 1.4fr 1fr auto;
    gap: 12px;
    align-items: center;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid var(--brand-line);
    margin-bottom: 8px;
    font-size: 14px;
}
.ingredient-row .name { font-weight: 600; }
.ingredient-row .name small {
    display: block;
    font-weight: 400;
    color: var(--brand-mute);
    font-size: 12px;
}
.bar {
    height: 6px;
    border-radius: 999px;
    background: var(--brand-line);
    overflow: hidden;
    position: relative;
}
.bar > i {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, var(--brand-accent), var(--brand-accent-deep));
    border-radius: 999px;
}
.tag {
    font-size: 11.5px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 999px;
}
.tag--ok { background: rgba(16,185,129,.10); color: #047857; }
.tag--warn { background: rgba(245,158,11,.12); color: #b45309; }
.tag--bad  { background: rgba(239,68,68,.10);  color: #b91c1c; }

/* ---------- Section helpers ---------- */
section { padding: 84px 0; }
.section-head {
    text-align: center;
    max-width: 720px;
    margin: 0 auto 48px;
}
.section-head h2 {
    font-size: clamp(28px, 3.4vw, 40px);
    letter-spacing: -0.02em;
    margin: 12px 0 12px;
    line-height: 1.15;
}
.section-head p {
    color: var(--brand-mute);
    font-size: 17px;
    margin: 0;
}

/* Features */
.features {
    background: var(--brand-bg-alt);
    border-top: 1px solid var(--brand-line);
    border-bottom: 1px solid var(--brand-line);
}
.feature-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 22px;
}
.feature {
    background: #fff;
    border: 1px solid var(--brand-line);
    border-radius: var(--radius-md);
    padding: 28px;
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.feature:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    border-color: #d8d3e6;
}
.feature__ico {
    width: 44px; height: 44px;
    border-radius: 12px;
    background: var(--brand-accent-soft);
    color: var(--brand-accent-deep);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 18px;
}
.feature h3 {
    font-size: 18px;
    margin: 0 0 8px;
    letter-spacing: -0.01em;
}
.feature p {
    color: var(--brand-mute);
    font-size: 14.5px;
    margin: 0;
}

/* How it works */
.steps {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 22px;
    counter-reset: step;
}
.step {
    border: 1px solid var(--brand-line);
    border-radius: var(--radius-md);
    padding: 28px;
    position: relative;
    background: #fff;
}
.step::before {
    counter-increment: step;
    content: "0" counter(step);
    display: block;
    font-size: 13px;
    font-weight: 700;
    color: var(--brand-accent-deep);
    letter-spacing: 0.06em;
    margin-bottom: 12px;
}
.step h3 { font-size: 18px; margin: 0 0 8px; letter-spacing: -0.01em; }
.step p  { color: var(--brand-mute); margin: 0; font-size: 14.5px; }

/* Roles section */
.roles {
    background:
        radial-gradient(700px 320px at 85% 0%, rgba(139,92,246,.10), transparent 60%);
    border-top: 1px solid var(--brand-line);
}
.role-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 22px;
}
.role-card {
    border: 1px solid var(--brand-line);
    border-radius: var(--radius-md);
    padding: 28px;
    background: #fff;
    display: flex;
    flex-direction: column;
}
.role-card__badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--brand-mute);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    margin-bottom: 14px;
}
.role-card h3 {
    font-size: 22px;
    margin: 0 0 10px;
    letter-spacing: -0.015em;
}
.role-card p {
    color: var(--brand-mute);
    margin: 0 0 22px;
    font-size: 14.5px;
}
.role-card ul {
    margin: 0 0 24px;
    padding-left: 18px;
    color: var(--brand-ink-soft);
    font-size: 14px;
}
.role-card ul li { margin-bottom: 6px; }
.role-card .btn { margin-top: auto; }
.role-card.is-primary {
    background: linear-gradient(160deg, #1a1024 0%, #2a1140 60%, #4c1d95 100%);
    color: #fff;
    border-color: transparent;
}
.role-card.is-primary p { color: rgba(255,255,255,.7); }
.role-card.is-primary ul { color: rgba(255,255,255,.85); }
.role-card.is-primary .role-card__badge { color: rgba(255,255,255,.7); }
.role-card.is-primary .btn--primary { background: #fff; color: #1a1024; }
.role-card.is-primary .btn--primary:hover { background: var(--brand-accent); color: #fff; }

/* Footer */
footer {
    background: #0e0e10;
    color: rgba(255,255,255,.7);
    padding: 56px 0 28px;
}
footer .footer-grid {
    display: grid;
    grid-template-columns: 1.4fr repeat(3, 1fr);
    gap: 32px;
    margin-bottom: 36px;
}
footer h4 {
    color: #fff;
    font-size: 14px;
    margin: 0 0 14px;
    letter-spacing: 0.02em;
}
footer ul { list-style: none; padding: 0; margin: 0; }
footer ul li { margin-bottom: 8px; font-size: 14px; }
footer ul li a:hover { color: var(--brand-accent); }
footer .brand { color: #fff; }
footer .brand img, footer .brand svg { filter: brightness(0) invert(1); }
footer p.tagline {
    margin-top: 12px;
    font-size: 14px;
    max-width: 320px;
    color: rgba(255,255,255,.55);
}
footer .footer-bottom {
    border-top: 1px solid rgba(255,255,255,.08);
    padding-top: 24px;
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: rgba(255,255,255,.5);
}

/* ---------- Auth pages ---------- */
.auth-wrap {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1.05fr 1fr;
}
.auth-side {
    background: linear-gradient(160deg, #1a1024 0%, #2a1140 50%, #4c1d95 100%);
    color: #fff;
    padding: 56px 56px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    overflow: hidden;
}
.auth-side::before, .auth-side::after {
    content: "";
    position: absolute;
    border-radius: 50%;
    filter: blur(60px);
    opacity: .55;
}
.auth-side::before {
    width: 360px; height: 360px;
    background: rgba(139, 92, 246, .55);
    top: -100px; right: -120px;
}
.auth-side::after {
    width: 280px; height: 280px;
    background: rgba(16, 185, 129, .35);
    bottom: -80px; left: -80px;
}
.auth-side > * { position: relative; z-index: 2; }
.auth-side .brand img, .auth-side .brand svg { filter: brightness(0) invert(1); }
.auth-side h2 {
    font-size: 34px;
    line-height: 1.15;
    letter-spacing: -0.02em;
    margin: 32px 0 14px;
    max-width: 460px;
}
.auth-side p {
    color: rgba(255,255,255,.78);
    max-width: 460px;
    font-size: 15px;
    margin: 0 0 28px;
}
.auth-side .quote {
    border-left: 3px solid rgba(255,255,255,.35);
    padding: 4px 0 4px 16px;
    color: rgba(255,255,255,.85);
    font-style: italic;
    max-width: 460px;
}

.auth-main {
    padding: 48px 56px;
    display: flex;
    flex-direction: column;
}
.auth-main__top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: auto;
}
.auth-card {
    width: 100%;
    max-width: 420px;
    margin: 56px auto auto;
}
.auth-card h1 {
    font-size: 30px;
    letter-spacing: -0.02em;
    margin: 0 0 8px;
}
.auth-card .sub {
    color: var(--brand-mute);
    margin: 0 0 28px;
    font-size: 15px;
}
.role-tag {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 999px;
    background: var(--brand-accent-soft);
    color: var(--brand-accent-deep);
    font-size: 12.5px;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    margin-bottom: 18px;
}
.role-tag.is-admin { background: #fff5e6; color: #92400e; }
.role-tag.is-doctor { background: #ecfdf5; color: #065f46; }
.role-tag svg { width: 14px; height: 14px; }

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}
.field label {
    font-size: 13.5px;
    font-weight: 500;
    color: var(--brand-ink-soft);
}
.field input {
    height: 46px;
    border-radius: 12px;
    border: 1px solid var(--brand-line);
    padding: 0 14px;
    font-size: 15px;
    transition: border-color .15s ease, box-shadow .15s ease;
    background: #fff;
}
.field input:focus {
    outline: none;
    border-color: var(--brand-accent);
    box-shadow: 0 0 0 4px rgba(139,92,246,.15);
}
.field-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: -6px 0 18px;
    font-size: 13.5px;
}
.field-row a { color: var(--brand-accent-deep); font-weight: 500; }
.checkbox {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--brand-mute);
}
.checkbox input { accent-color: var(--brand-accent); }

.auth-footer-line {
    margin-top: 22px;
    text-align: center;
    color: var(--brand-mute);
    font-size: 14px;
}
.auth-footer-line a { color: var(--brand-accent-deep); font-weight: 600; }
.alt-actions {
    margin-top: 28px;
    padding-top: 22px;
    border-top: 1px dashed var(--brand-line);
    text-align: center;
    color: var(--brand-mute);
    font-size: 13.5px;
}
.alt-actions a { color: var(--brand-ink-soft); font-weight: 500; }

/* ---------- Staff portal selector ---------- */
.portal {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background:
        radial-gradient(900px 420px at 85% -20%, rgba(139, 92, 246, 0.18), transparent 60%),
        radial-gradient(700px 360px at -10% 30%, rgba(16, 185, 129, 0.10), transparent 60%),
        var(--brand-bg);
}
.portal__head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 32px;
}
.portal__main {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.portal__inner {
    max-width: 940px;
    width: 100%;
    text-align: center;
}
.portal__inner h1 {
    font-size: clamp(32px, 4vw, 44px);
    letter-spacing: -0.02em;
    margin: 14px 0 10px;
}
.portal__inner > p {
    color: var(--brand-mute);
    margin: 0 0 36px;
    font-size: 17px;
}
.portal-cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 22px;
    text-align: left;
}
.portal-card {
    background: #fff;
    border: 1px solid var(--brand-line);
    border-radius: var(--radius-lg);
    padding: 32px;
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
    display: flex;
    flex-direction: column;
}
.portal-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
    border-color: #d8d3e6;
}
.portal-card__ico {
    width: 56px; height: 56px;
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 22px;
}
.portal-card.admin .portal-card__ico { background: #fff5e6; color: #b45309; }
.portal-card.doctor .portal-card__ico { background: #ecfdf5; color: #047857; }
.portal-card h3 {
    font-size: 22px;
    margin: 0 0 8px;
    letter-spacing: -0.015em;
}
.portal-card p {
    color: var(--brand-mute);
    margin: 0 0 22px;
    font-size: 14.5px;
}
.portal-card ul {
    margin: 0 0 24px;
    padding: 0;
    list-style: none;
    font-size: 14px;
    color: var(--brand-ink-soft);
}
.portal-card ul li {
    padding: 6px 0;
    border-bottom: 1px solid var(--brand-line);
    display: flex; align-items: center; gap: 10px;
}
.portal-card ul li::before {
    content: "";
    width: 6px; height: 6px;
    border-radius: 999px;
    background: var(--brand-accent);
    flex: none;
}
.portal-card ul li:last-child { border-bottom: none; }
.portal-card .btn { margin-top: auto; }

/* ---------- Mobile ---------- */
@media (max-width: 920px) {
    .nav { display: none; }
    .hero__grid, .feature-grid, .steps, .role-grid, .portal-cards, footer .footer-grid { grid-template-columns: 1fr; }
    .auth-wrap { grid-template-columns: 1fr; }
    .auth-side { display: none; }
    .auth-main { padding: 32px 20px; }
    section { padding: 56px 0; }
    .hero { padding: 48px 0 36px; }
    .hero__metrics { gap: 22px; }
    footer .footer-bottom { flex-direction: column; gap: 8px; }
}

/* ---------------- App / Dashboard ---------------- */
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 260px 1fr; background: var(--brand-bg-alt); }
.sidebar { background: #0e0e10; color: rgba(255,255,255,.85); padding: 24px 16px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sidebar .brand img { filter: brightness(0) invert(1); height: 38px; }
.sidebar-section { margin-top: 26px; }
.sidebar-section h6 { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: rgba(255,255,255,.45); margin: 0 0 8px; padding: 0 10px; }
.sidebar-link { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; color: rgba(255,255,255,.85); font-size: 14px; }
.sidebar-link:hover, .sidebar-link.is-active { background: rgba(139,92,246,.18); color: #fff; }
.sidebar-link svg { width: 16px; height: 16px; opacity: .85; }
.sidebar .role-pill { display: inline-flex; align-items: center; gap: 8px; font-size: 11px; padding: 4px 10px; border-radius: 999px; background: rgba(255,255,255,.1); color: rgba(255,255,255,.8); margin-top: 8px; }

.app-main { padding: 28px 36px; min-width: 0; }
.app-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.app-header h1 { font-size: 24px; letter-spacing: -.015em; margin: 0; }
.app-header .crumbs { color: var(--brand-mute); font-size: 13px; margin-bottom: 4px; }

.flash { padding: 12px 16px; border-radius: 12px; margin-bottom: 16px; font-size: 14px; }
.flash--ok { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.flash--err { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

.card { background: #fff; border: 1px solid var(--brand-line); border-radius: var(--radius-md); padding: 22px; box-shadow: var(--shadow-sm); }
.card + .card { margin-top: 20px; }
.card-h { display: flex; justify-content: space-between; align-items: center; margin: 0 0 14px; }
.card-h h2 { font-size: 17px; margin: 0; letter-spacing: -.01em; }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.stat { background: #fff; border: 1px solid var(--brand-line); border-radius: var(--radius-md); padding: 18px; }
.stat strong { display: block; font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.stat span { color: var(--brand-mute); font-size: 13px; }

.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--brand-line); }
.table th { background: var(--brand-bg-alt); font-weight: 600; font-size: 12.5px; letter-spacing: .02em; text-transform: uppercase; color: var(--brand-mute); }
.table tr:hover td { background: #fafaff; }

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge--ok { background: #ecfdf5; color: #065f46; }
.badge--warn { background: #fffbeb; color: #92400e; }
.badge--bad { background: #fef2f2; color: #991b1b; }
.badge--mute { background: var(--brand-bg-alt); color: var(--brand-mute); border: 1px solid var(--brand-line); }
.badge--info { background: #eff6ff; color: #1d4ed8; }

.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.form-grid.cols-1 { grid-template-columns: 1fr; }
textarea.field-input, select.field-input, input.field-input { width: 100%; min-height: 44px; border-radius: 10px; border: 1px solid var(--brand-line); padding: 10px 14px; font: inherit; font-size: 14.5px; background: #fff; }
textarea.field-input { min-height: 110px; resize: vertical; }
.field-input:focus { outline: none; border-color: var(--brand-accent); box-shadow: 0 0 0 4px rgba(139,92,246,.12); }
.field-help { color: var(--brand-mute); font-size: 12.5px; margin-top: 4px; }
.error-msg { color: #b91c1c; font-size: 12.5px; margin-top: 4px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; background: var(--brand-bg-alt); border: 1px solid var(--brand-line); font-size: 13px; }

.kvs { display: grid; grid-template-columns: 160px 1fr; row-gap: 8px; column-gap: 16px; font-size: 14px; }
.kvs dt { color: var(--brand-mute); }
.kvs dd { margin: 0; color: var(--brand-ink); }

.empty { text-align: center; padding: 48px 24px; color: var(--brand-mute); }
.empty h3 { color: var(--brand-ink); margin: 0 0 8px; font-size: 18px; }

@media (max-width: 920px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar { position: static; height: auto; }
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .form-grid { grid-template-columns: 1fr; }
}

/* ---------------- Public catalog ---------------- */
.nav a.is-active { color: var(--brand-accent-deep); }

.catalog-hero {
    padding: 56px 0 28px;
    background:
        radial-gradient(700px 320px at 90% 0%, rgba(139, 92, 246, 0.16), transparent 60%),
        radial-gradient(540px 280px at -10% 30%, rgba(16, 185, 129, 0.08), transparent 60%);
}
.catalog-hero h1 {
    font-size: clamp(28px, 4vw, 42px);
    letter-spacing: -0.02em;
    margin: 12px 0 8px;
    line-height: 1.1;
}
.catalog-hero .lead {
    color: var(--brand-mute);
    font-size: 16.5px;
    margin: 0 0 24px;
    max-width: 640px;
}
.catalog-search {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    background: #fff;
    border: 1px solid var(--brand-line);
    border-radius: var(--radius-md);
    padding: 10px;
    box-shadow: var(--shadow-sm);
    width: 100%;
}
.catalog-search .field-input { flex: 1 1 200px; min-height: 42px; border: 1px solid var(--brand-line); }
.catalog-search .btn { white-space: nowrap; }

.catalog { padding: 36px 0 80px; }
.cat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}
.cat-card {
    display: block;
    background: #fff;
    border: 1px solid var(--brand-line);
    border-radius: var(--radius-md);
    padding: 18px;
    color: inherit;
    transition: transform .14s ease, box-shadow .18s ease, border-color .18s ease;
    height: 100%;
}
.cat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: #d8d3e6; }
.cat-card__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}
.cat-card h3 { font-size: 17px; margin: 0 0 4px; letter-spacing: -.01em; }
.cat-card__inci { font-size: 12.5px; color: var(--brand-mute); margin-bottom: 8px; }
.cat-card__desc { font-size: 13.5px; color: var(--brand-ink-soft); margin: 8px 0 12px; line-height: 1.55; }
.cat-card__flags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }

.chip--accent { background: var(--brand-accent-soft); border-color: transparent; color: var(--brand-accent-deep); font-weight: 600; font-size: 12px; }

.empty-card {
    text-align: center;
    padding: 56px 24px;
    background: #fff;
    border: 1px dashed var(--brand-line);
    border-radius: var(--radius-md);
}
.empty-card h3 { margin: 0 0 8px; font-size: 18px; }
.empty-card p { color: var(--brand-mute); margin: 0 0 16px; }

/* Detail pages */
.detail-hero {
    padding: 56px 0 28px;
    background: var(--brand-bg-alt);
    border-bottom: 1px solid var(--brand-line);
}
.detail-hero .crumbs { color: var(--brand-mute); font-size: 13px; margin-bottom: 8px; }
.detail-hero .crumbs a { color: var(--brand-accent-deep); }
.detail-hero h1 { font-size: clamp(28px, 4vw, 40px); letter-spacing: -0.02em; margin: 0 0 8px; line-height: 1.1; }
.detail-sub { color: var(--brand-mute); font-size: 15px; margin: 4px 0 0; }

.detail-body { padding: 36px 0 80px; }
.detail-grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 28px; align-items: start; }
.detail-grid aside .card + .card { margin-top: 16px; }
@media (max-width: 920px) {
    .detail-grid { grid-template-columns: 1fr; }
}

.pair-list, .thin-list {
    list-style: none;
    margin: 0; padding: 0;
}
.pair-list li, .thin-list li {
    padding: 10px 0;
    border-bottom: 1px solid var(--brand-line);
    display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
    font-size: 14.5px;
}
.pair-list li:last-child, .thin-list li:last-child { border-bottom: none; }
.pair-list li small, .thin-list li small {
    color: var(--brand-mute);
    font-size: 12.5px;
    flex-basis: 100%;
    margin-top: -4px;
}
.pair-list li a, .thin-list li a { color: var(--brand-ink); }
.pair-list li a:hover, .thin-list li a:hover { color: var(--brand-accent-deep); }

.ingredient-orderlist {
    counter-reset: ing;
    list-style: none;
    padding: 0;
    margin: 0;
}
.ingredient-orderlist li {
    counter-increment: ing;
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 14px 0;
    border-bottom: 1px solid var(--brand-line);
}
.ingredient-orderlist li:last-child { border-bottom: none; }
.ingredient-orderlist li::before {
    content: counter(ing);
    flex: 0 0 32px;
    width: 32px;
    height: 32px;
    border-radius: 999px;
    background: var(--brand-accent-soft);
    color: var(--brand-accent-deep);
    font-weight: 700;
    font-size: 13px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-top: 1px;
}
.ingredient-orderlist__main {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.ingredient-orderlist__main a {
    display: block;
    line-height: 1.35;
    word-break: break-word;
}
.ingredient-orderlist__main a strong { font-weight: 600; }
.ingredient-orderlist__main a:hover strong { color: var(--brand-accent-deep); }
.ingredient-orderlist__main small {
    display: block;
    color: var(--brand-mute);
    font-size: 12.5px;
    margin-top: 2px;
    word-break: break-word;
}
.ingredient-orderlist__flags { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------------- Pager (custom, replaces Tailwind default) ---------------- */
.pager {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 24px;
    font-size: 14px;
}
.pager__btn,
.pager__page {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 36px;
    min-width: 36px;
    padding: 0 14px;
    border-radius: 999px;
    border: 1px solid var(--brand-line);
    background: #fff;
    color: var(--brand-ink-soft);
    font-weight: 500;
    transition: border-color .15s ease, color .15s ease, background .15s ease;
}
.pager__btn:hover,
.pager__page:hover {
    border-color: var(--brand-ink);
    color: var(--brand-ink);
}
.pager__btn.is-disabled {
    opacity: .45;
    pointer-events: none;
    background: var(--brand-bg-alt);
}
.pager__page.is-current {
    background: var(--brand-ink);
    color: #fff;
    border-color: var(--brand-ink);
}
.pager__pages {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    gap: 6px;
}
.pager__ellipsis {
    color: var(--brand-mute);
    padding: 0 4px;
}
@media (max-width: 560px) {
    .pager__pages li:not(:has(.is-current)) { display: none; }
    .pager__pages li:has(.is-current) { display: block; }
}

/* ---------------- Catalog AJAX search ---------------- */
.is-hidden { display: none !important; }

.search-spinner {
    display: inline-block;
    width: 16px; height: 16px;
    border-radius: 50%;
    border: 2px solid var(--brand-line);
    border-top-color: var(--brand-accent);
    animation: spin .7s linear infinite;
    opacity: 0;
    transition: opacity .15s ease;
    margin-left: 4px;
}
.search-spinner.is-on { opacity: 1; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .search-spinner { animation: none; } }

/* ---------------- Mobile hamburger + drawer ---------------- */
.hamburger {
    display: none;
    background: transparent;
    border: 1px solid var(--brand-line);
    border-radius: 999px;
    width: 44px; height: 44px;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    flex-direction: column;
    gap: 4px;
}
.hamburger span {
    display: block;
    width: 18px; height: 2px;
    background: var(--brand-ink);
    border-radius: 2px;
    transition: transform .2s ease, opacity .2s ease;
}
.topbar.is-open .hamburger span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.topbar.is-open .hamburger span:nth-child(2) { opacity: 0; }
.topbar.is-open .hamburger span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

.mobile-drawer {
    display: none;
    flex-direction: column;
    gap: 4px;
    background: #fff;
    border-top: 1px solid var(--brand-line);
    padding: 16px 24px 22px;
    box-shadow: var(--shadow-md);
}
.topbar.is-open .mobile-drawer { display: flex; }

.mobile-drawer__link {
    padding: 14px 8px;
    border-radius: 10px;
    color: var(--brand-ink);
    font-size: 15.5px;
    font-weight: 500;
    border: 1px solid transparent;
}
.mobile-drawer__link:hover { background: var(--brand-bg-alt); }
.mobile-drawer__divider { height: 1px; background: var(--brand-line); margin: 8px 0; }

@media (max-width: 920px) {
    .hamburger { display: inline-flex; }
    .topbar .nav,
    .topbar .nav__actions { display: none; }
}

/* ---------------- Mobile sidebar (dashboard layout) ---------------- */
@media (max-width: 920px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar {
        position: static;
        height: auto;
        max-height: none;
        padding: 18px 16px;
        display: flex;
        flex-direction: column;
        gap: 12px;
    }
    .sidebar.is-collapsed .sidebar-section,
    .sidebar.is-collapsed .role-pill { display: none; }
    .sidebar-section { margin-top: 6px; }
    .app-main { padding: 20px 16px; }
    .app-header { flex-direction: column; align-items: flex-start; gap: 10px; }
}

.sidebar__toggle {
    display: none;
    background: rgba(255,255,255,.08);
    color: #fff;
    border: 1px solid rgba(255,255,255,.16);
    border-radius: 999px;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    align-self: flex-start;
}
.sidebar__toggle::before {
    content: "Menu";
}
.sidebar.is-collapsed .sidebar__toggle::before { content: "Menu"; }
.sidebar:not(.is-collapsed) .sidebar__toggle::before { content: "Hide menu"; }
@media (max-width: 920px) {
    .sidebar__toggle { display: inline-flex; align-items: center; gap: 6px; }
    .sidebar.is-collapsed { padding: 14px 16px; }
}

/* ---------------- Mobile touch targets ---------------- */
@media (max-width: 920px) {
    .btn--sm { padding: 11px 16px; font-size: 14px; }
    .pager__btn,
    .pager__page { height: 44px; min-width: 44px; }
    .dropdown__btn { padding: 11px 18px; }
    .field-input { min-height: 46px; }
}

/* ---------------- Sidebar top row (mobile) ---------------- */
.sidebar__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
@media (max-width: 920px) {
    .sidebar__top { padding-bottom: 4px; }
}

/* ---------------- 404 page ---------------- */
.error-page {
    padding: 96px 0 120px;
    text-align: center;
    background:
        radial-gradient(700px 320px at 90% -10%, rgba(139, 92, 246, 0.16), transparent 60%);
}
.error-page h1 {
    font-size: clamp(34px, 4.5vw, 50px);
    letter-spacing: -0.02em;
    margin: 14px 0 12px;
    line-height: 1.1;
}
.error-page .lead {
    color: var(--brand-mute);
    font-size: 17px;
    max-width: 520px;
    margin: 0 auto 28px;
}
.error-page__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
}

/* ---------------- Role tabs (admin users index) ---------------- */
.role-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: -4px 0 18px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--brand-line);
}
.role-tab {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 999px;
    background: transparent;
    color: var(--brand-ink-soft);
    font-size: 13.5px;
    font-weight: 500;
    border: 1px solid transparent;
    transition: background .15s ease, color .15s ease;
}
.role-tab:hover { background: var(--brand-bg-alt); color: var(--brand-ink); }
.role-tab.is-active {
    background: var(--brand-ink);
    color: #fff;
}
.role-tab__count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    border-radius: 999px;
    background: rgba(0,0,0,.07);
    font-size: 11.5px;
    font-weight: 600;
}
.role-tab.is-active .role-tab__count {
    background: rgba(255,255,255,.18);
    color: #fff;
}

/* ---------------- Skin Quiz ---------------- */
.quiz-intro__bullets {
    list-style: none;
    margin: 18px 0 0;
    padding: 0;
    color: var(--brand-ink-soft);
    font-size: 14.5px;
}
.quiz-intro__bullets li {
    padding: 10px 0;
    border-bottom: 1px solid var(--brand-line);
}
.quiz-intro__bullets li:last-child { border-bottom: none; }

.quiz-progress { margin: 0 0 22px; }
.quiz-progress__bar {
    height: 8px;
    background: var(--brand-line);
    border-radius: 999px;
    overflow: hidden;
}
.quiz-progress__bar > i {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, var(--brand-accent), var(--brand-accent-deep));
    border-radius: 999px;
    transition: width .25s ease;
}
.quiz-progress__label {
    margin-top: 6px;
    font-size: 12.5px;
    color: var(--brand-mute);
    letter-spacing: .04em;
    text-transform: uppercase;
}

.quiz-card { padding: 28px; }
.quiz-q {
    border: none;
    padding: 0 0 22px;
    margin: 0 0 22px;
    border-bottom: 1px solid var(--brand-line);
}
.quiz-q:last-of-type { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.quiz-q legend {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
    line-height: 1.4;
}
.quiz-q__help {
    font-size: 13px;
    color: var(--brand-mute);
    margin: 0 0 12px;
}

.quiz-options {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 8px;
}
.quiz-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border: 1px solid var(--brand-line);
    border-radius: 12px;
    cursor: pointer;
    background: #fff;
    font-size: 14.5px;
    transition: border-color .15s ease, background .15s ease;
}
.quiz-option:hover { border-color: var(--brand-ink); }
.quiz-option:has(input:checked) {
    border-color: var(--brand-accent);
    background: var(--brand-accent-soft);
}
.quiz-option input { accent-color: var(--brand-accent); }

.quiz-scale {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}
.quiz-scale__opt {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 1 1 60px;
    min-width: 60px;
    height: 56px;
    border: 1px solid var(--brand-line);
    border-radius: 12px;
    cursor: pointer;
    background: #fff;
    font-size: 18px;
    font-weight: 600;
    color: var(--brand-ink-soft);
    transition: border-color .15s ease, background .15s ease;
}
.quiz-scale__opt:hover { border-color: var(--brand-ink); }
.quiz-scale__opt:has(input:checked) {
    border-color: var(--brand-accent);
    background: var(--brand-accent-soft);
    color: var(--brand-accent-deep);
}
.quiz-scale__opt input { display: none; }

.quiz-actions {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin-top: 28px;
    padding-top: 18px;
    border-top: 1px solid var(--brand-line);
}

.review-step {
    padding: 18px 0;
    border-bottom: 1px solid var(--brand-line);
}
.review-step:last-of-type { border-bottom: none; }
.review-step__head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}
.review-step__head h3 {
    margin: 0;
    font-size: 15px;
    letter-spacing: -.005em;
}

@media (max-width: 720px) {
    .quiz-options { grid-template-columns: 1fr; }
    .quiz-actions { flex-direction: column-reverse; }
    .quiz-actions .btn { width: 100%; }
}

/* ---------------- AQI dashboard tile ---------------- */
.aqi-card { padding: 0; overflow: hidden; }
.aqi-empty {
    padding: 28px 32px;
    text-align: center;
}
.aqi-empty h2 { margin: 0 0 10px; font-size: 18px; letter-spacing: -0.01em; }
.aqi-empty p { color: var(--brand-mute); margin: 0 auto 18px; max-width: 520px; font-size: 14.5px; }
.aqi-empty .btn { gap: 8px; }
.aqi-empty__note { display: block; margin-top: 12px; color: var(--brand-mute); font-size: 12.5px; }
.aqi-empty__note a { color: var(--brand-accent-deep); }

.aqi-tile {
    padding: 26px 28px;
    color: #fff;
    position: relative;
    --aqi-bg: #6b7280;
    --aqi-bg-soft: #4b5563;
    background: linear-gradient(135deg, var(--aqi-bg) 0%, var(--aqi-bg-soft) 100%);
}
.aqi-tile.is-good            { --aqi-bg: #16a34a; --aqi-bg-soft: #047857; }
.aqi-tile.is-moderate        { --aqi-bg: #eab308; --aqi-bg-soft: #b45309; }
.aqi-tile.is-sensitive       { --aqi-bg: #f97316; --aqi-bg-soft: #c2410c; }
.aqi-tile.is-unhealthy       { --aqi-bg: #ef4444; --aqi-bg-soft: #b91c1c; }
.aqi-tile.is-very_unhealthy  { --aqi-bg: #8b5cf6; --aqi-bg-soft: #6d28d9; }
.aqi-tile.is-hazardous       { --aqi-bg: #7f1d1d; --aqi-bg-soft: #450a0a; }

.aqi-tile__head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 12px;
}
.aqi-tile__where {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    opacity: 0.85;
    margin-bottom: 4px;
}
.aqi-tile__label {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.01em;
}
.aqi-tile__score {
    text-align: right;
    line-height: 1;
}
.aqi-tile__score strong {
    font-size: 48px;
    font-weight: 800;
    letter-spacing: -0.025em;
    display: block;
}
.aqi-tile__score small {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    opacity: 0.85;
}
.aqi-tile__advice {
    margin: 14px 0 0;
    font-size: 14.5px;
    line-height: 1.55;
    background: rgba(255, 255, 255, 0.14);
    padding: 12px 14px;
    border-radius: 10px;
    backdrop-filter: blur(6px);
}
.aqi-tile__pollutants {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 8px;
    list-style: none;
    margin: 16px 0 0;
    padding: 0;
}
.aqi-tile__pollutants li {
    background: rgba(255, 255, 255, 0.16);
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 13px;
}
.aqi-tile__pollutants strong {
    display: block;
    font-size: 11px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    opacity: 0.85;
}
.aqi-tile__pollutants span {
    font-size: 16px;
    font-weight: 700;
}
.aqi-tile__foot {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid rgba(255, 255, 255, 0.18);
    font-size: 12.5px;
    opacity: 0.9;
}
.aqi-tile__foot .btn--ghost {
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.32);
}
.aqi-tile__foot .btn--ghost:hover {
    background: rgba(255, 255, 255, 0.26);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.6);
}

@media (max-width: 560px) {
    .aqi-tile__head { flex-direction: column; }
    .aqi-tile__score { text-align: left; }
    .aqi-tile__score strong { font-size: 38px; }
}

/* ---------------- Quiz flow (single-page, animated) ---------------- */
.quiz-body {
    background: linear-gradient(180deg, #faf9fc 0%, #fff 100%);
    min-height: 100vh;
    overflow-x: hidden;
}

.quiz-shell__head {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 24px;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: saturate(140%) blur(14px);
    border-bottom: 1px solid var(--brand-line);
}

.quiz-shell {
    max-width: 760px;
    margin: 0 auto;
    padding: 24px;
    min-height: calc(100vh - 60px);
    display: flex;
    flex-direction: column;
}

.quiz-shell__progress { margin-bottom: 24px; }
.quiz-shell__bar {
    height: 4px;
    background: var(--brand-line);
    border-radius: 999px;
    overflow: hidden;
}
.quiz-shell__bar > i {
    display: block;
    height: 100%;
    width: 4%;
    background: linear-gradient(90deg, var(--brand-accent), var(--brand-accent-deep));
    border-radius: 999px;
    transition: width .35s cubic-bezier(.2, .8, .2, 1);
}
.quiz-shell__counter {
    margin-top: 10px;
    font-size: 12px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--brand-mute);
}
.quiz-shell__counter small { font-weight: normal; }
.quiz-shell__counter [data-section-name] {
    font-weight: 600;
    color: var(--brand-ink-soft);
}

/* Viewport holds all cards stacked; only the active one shows */
.quiz-shell__viewport {
    flex: 1;
    position: relative;
    margin: 12px 0 28px;
    min-height: 480px;
}

#quiz-form { height: 100%; }

.quiz-card {
    position: absolute;
    inset: 0;
    opacity: 0;
    transform: translateX(40px);
    transition: opacity .35s cubic-bezier(.2, .8, .2, 1),
                transform .35s cubic-bezier(.2, .8, .2, 1);
    pointer-events: none;
}
.quiz-card.is-active {
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
    position: relative; /* let the card define viewport height when active */
}
.quiz-card.is-leaving-left { opacity: 0; transform: translateX(-40px); }
.quiz-card.is-leaving-right { opacity: 0; transform: translateX(40px); }
.quiz-card.is-entering-left { opacity: 0; transform: translateX(-40px); }
.quiz-card.is-entering-right { opacity: 0; transform: translateX(40px); }

@media (prefers-reduced-motion: reduce) {
    .quiz-card { transition: opacity .15s ease; transform: none !important; }
}

.quiz-card__inner {
    max-width: 640px;
    margin: 0 auto;
    padding: 8px 0;
}
.quiz-card__icon {
    width: 80px;
    height: 80px;
    border-radius: 22px;
    margin: 0 0 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--brand-accent-deep);
    background:
        radial-gradient(120% 120% at 30% 20%, rgba(139, 92, 246, 0.18), transparent 60%),
        linear-gradient(140deg, var(--brand-accent-soft) 0%, #fff 100%);
    border: 1px solid rgba(139, 92, 246, 0.16);
    box-shadow: 0 6px 18px rgba(109, 40, 217, 0.10);
}
.quiz-card__icon svg { display: block; }

.quiz-card__section {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--brand-accent-soft);
    color: var(--brand-accent-deep);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: 14px;
}
.quiz-card__q {
    font-size: clamp(20px, 3vw, 26px);
    line-height: 1.25;
    letter-spacing: -0.015em;
    margin: 0 0 8px;
    font-weight: 600;
}
.quiz-card__optional {
    color: var(--brand-mute);
    font-weight: 500;
    font-size: 0.7em;
}
.quiz-card__help {
    color: var(--brand-mute);
    font-size: 13.5px;
    margin: 0 0 18px;
    line-height: 1.5;
}
.quiz-card__hint {
    color: var(--brand-mute);
    font-size: 13px;
    margin: 12px 0 0;
}

/* Option cards — compact tiles you tap. Auto-fit to 2 columns when there's room. */
.quiz-card__options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 8px;
    margin-top: 8px;
}
.quiz-card__option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border: 1px solid var(--brand-line);
    border-radius: 10px;
    background: #fff;
    cursor: pointer;
    transition: border-color .15s ease, background .15s ease, transform .1s ease;
    font-size: 14px;
    line-height: 1.35;
}
.quiz-card__option:hover {
    border-color: var(--brand-ink-soft);
    background: var(--brand-bg-alt);
}
.quiz-card__option:active { transform: scale(.99); }
.quiz-card__option:has(input:checked) {
    border-color: var(--brand-accent);
    background: var(--brand-accent-soft);
    box-shadow: 0 0 0 3px rgba(139,92,246,.10);
}
.quiz-card__option input { display: none; }
.quiz-card__option-text { flex: 1; }
.quiz-card__option-check {
    width: 18px;
    height: 18px;
    border-radius: 999px;
    border: 1.5px solid var(--brand-line);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    color: transparent;
    background: #fff;
    flex: none;
    transition: all .15s ease;
}
.quiz-card__option:has(input:checked) .quiz-card__option-check {
    background: var(--brand-accent);
    color: #fff;
    border-color: var(--brand-accent);
}

/* Scale 1-5 — slimmer than perfectly square */
.quiz-card__scale {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    margin-top: 8px;
    max-width: 420px;
}
.quiz-card__scale-opt {
    height: 56px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1.5px solid var(--brand-line);
    border-radius: 12px;
    background: #fff;
    font-size: 18px;
    font-weight: 700;
    color: var(--brand-ink-soft);
    cursor: pointer;
    transition: all .15s ease;
}
.quiz-card__scale-opt:hover {
    border-color: var(--brand-ink-soft);
    background: var(--brand-bg-alt);
}
.quiz-card__scale-opt:has(input:checked) {
    border-color: var(--brand-accent);
    background: var(--brand-accent);
    color: #fff;
    box-shadow: 0 6px 16px rgba(109,40,217,.18);
}
.quiz-card__scale-opt input { display: none; }
.quiz-card__scale-legend {
    display: flex;
    justify-content: space-between;
    margin-top: 10px;
    font-size: 12.5px;
    color: var(--brand-mute);
}

/* Text input */
.quiz-card__text {
    width: 100%;
    margin-top: 8px;
    padding: 16px 20px;
    border: 1.5px solid var(--brand-line);
    border-radius: 14px;
    background: #fff;
    font-size: 16px;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.quiz-card__text:focus {
    outline: none;
    border-color: var(--brand-accent);
    box-shadow: 0 0 0 4px rgba(139,92,246,.12);
}

/* Footer nav */
.quiz-shell__nav {
    position: sticky;
    bottom: 0;
    background: linear-gradient(180deg, transparent, #fff 30%);
    padding: 18px 0 16px;
    display: flex;
    justify-content: space-between;
    gap: 12px;
}
.quiz-shell__nav .btn { padding: 14px 24px; font-size: 15px; }
.quiz-shell__nav .btn:disabled { opacity: .35; pointer-events: none; }

/* Review screen */
.quiz-card--review .quiz-card__submit {
    display: inline-flex;
    margin-top: 28px;
    padding: 16px 28px;
    font-size: 16px;
}
.quiz-review__section {
    border-top: 1px solid var(--brand-line);
    padding: 18px 0;
}
.quiz-review__section:first-child { border-top: none; padding-top: 4px; }
.quiz-review__section h3 {
    margin: 0 0 12px;
    font-size: 13px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--brand-mute);
}
.quiz-review__row {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    gap: 4px 12px;
    padding: 12px 14px;
    border-radius: 10px;
    cursor: pointer;
    transition: background .12s ease;
}
.quiz-review__row:hover { background: var(--brand-bg-alt); }
.quiz-review__row dt {
    grid-row: 1;
    font-size: 13px;
    color: var(--brand-mute);
}
.quiz-review__row dd {
    grid-row: 2;
    margin: 0;
    font-size: 15px;
    color: var(--brand-ink);
    font-weight: 500;
}
.quiz-review__edit {
    grid-row: 1 / span 2;
    align-self: center;
    color: var(--brand-accent-deep);
    font-size: 12.5px;
    font-weight: 600;
}

@media (max-width: 640px) {
    .quiz-shell { padding: 16px; }
    .quiz-shell__viewport { min-height: 380px; }
    .quiz-card__icon { width: 64px; height: 64px; border-radius: 18px; margin-bottom: 14px; }
    .quiz-card__icon svg { width: 44px; height: 44px; }
    .quiz-card__options { grid-template-columns: 1fr; }
    .quiz-card__option { padding: 11px 14px; }
    .quiz-card__scale-opt { height: 52px; font-size: 16px; }
    .quiz-shell__nav { flex-direction: row; }
    .quiz-shell__nav .btn { flex: 1; }
}

.quiz-card__guestnote {
    margin-top: 16px;
    font-size: 13.5px;
    color: var(--brand-mute);
}
.quiz-card__guestnote a {
    color: var(--brand-accent-deep);
    font-weight: 600;
}

/* ---------------- Quiz intro hero (public) ---------------- */
.quiz-intro-hero {
    padding: 72px 0 88px;
    background:
        radial-gradient(900px 420px at 80% -10%, rgba(139, 92, 246, 0.16), transparent 60%),
        radial-gradient(700px 360px at -10% 30%, rgba(16, 185, 129, 0.08), transparent 60%);
}
.quiz-intro-hero h1 {
    font-size: clamp(34px, 5vw, 54px);
    line-height: 1.05;
    letter-spacing: -0.025em;
    margin: 18px 0 18px;
    max-width: 740px;
    font-weight: 700;
}
.quiz-intro-hero .lead {
    font-size: 18px;
    color: var(--brand-mute);
    max-width: 620px;
    margin: 0 0 32px;
    line-height: 1.55;
}
.quiz-intro-hero__bullets {
    list-style: none;
    margin: 0 0 36px;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
    max-width: 920px;
}
.quiz-intro-hero__bullets li {
    background: #fff;
    border: 1px solid var(--brand-line);
    border-radius: var(--radius-md);
    padding: 18px 20px;
    box-shadow: var(--shadow-sm);
}
.quiz-intro-hero__bullets li strong {
    display: block;
    font-size: 15px;
    margin-bottom: 4px;
    letter-spacing: -0.01em;
}
.quiz-intro-hero__bullets li span {
    color: var(--brand-mute);
    font-size: 13.5px;
}
.quiz-intro-hero__cta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}
.quiz-intro-hero__cta .btn { padding: 14px 26px; font-size: 15px; }

/* ---------------- Saved quiz answers (results page) ---------------- */
.answers-card { padding-bottom: 16px; }

.answers-section + .answers-section {
    margin-top: 24px;
    padding-top: 22px;
    border-top: 1px solid var(--brand-line);
}
.answers-section__head {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0 0 14px;
    flex-wrap: wrap;
}
.answers-section__num {
    width: 24px;
    height: 24px;
    border-radius: 999px;
    background: var(--brand-accent-soft);
    color: var(--brand-accent-deep);
    font-size: 12px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
}
.answers-section__head h3 {
    margin: 0;
    font-size: 15px;
    letter-spacing: -.005em;
}
.answers-section__head small {
    color: var(--brand-mute);
    font-size: 13px;
    flex-basis: 100%;
    margin-left: 36px;
}

.answers-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 8px;
    margin: 0;
    padding: 0;
}
.answers-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid var(--brand-line);
    border-radius: 10px;
    background: #fff;
}
.answers-row__icon {
    flex: 0 0 36px;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background:
        radial-gradient(120% 120% at 30% 20%, rgba(139, 92, 246, 0.18), transparent 60%),
        linear-gradient(140deg, var(--brand-accent-soft) 0%, #fff 100%);
    color: var(--brand-accent-deep);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.answers-row__icon svg { width: 22px; height: 22px; }
.answers-row__main { flex: 1; min-width: 0; }
.answers-row dt {
    font-size: 12.5px;
    color: var(--brand-mute);
    margin: 0 0 2px;
    line-height: 1.3;
}
.answers-row dd {
    margin: 0;
    font-size: 14px;
    color: var(--brand-ink);
    font-weight: 500;
    word-break: break-word;
}

@media (max-width: 560px) {
    .answers-list { grid-template-columns: 1fr; }
}

/* ---------------- Scan a label (OCR) ---------------- */
.scan-card { padding: 24px; }

.scan-drop {
    display: block;
    border: 2px dashed var(--brand-line);
    border-radius: var(--radius-md);
    background: var(--brand-bg-alt);
    padding: 36px 24px;
    text-align: center;
    cursor: pointer;
    transition: border-color .15s ease, background .15s ease;
    margin-bottom: 22px;
}
.scan-drop:hover { border-color: var(--brand-accent); background: #fff; }
.scan-drop input[type="file"] { display: none; }
.scan-drop__icon {
    width: 80px; height: 80px;
    border-radius: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(120% 120% at 30% 20%, rgba(139, 92, 246, 0.18), transparent 60%),
        linear-gradient(140deg, var(--brand-accent-soft) 0%, #fff 100%);
    color: var(--brand-accent-deep);
    border: 1px solid rgba(139, 92, 246, 0.16);
    margin-bottom: 14px;
}
.scan-drop h2 { font-size: 18px; margin: 0 0 4px; letter-spacing: -0.01em; }
.scan-drop p { color: var(--brand-mute); font-size: 13.5px; margin: 0 0 16px; }

.scan-drop__preview img {
    max-width: 360px;
    max-height: 320px;
    width: auto; height: auto;
    margin: 0 auto 12px;
    border-radius: 12px;
    box-shadow: var(--shadow-md);
}
.scan-drop__filename {
    font-size: 12.5px;
    color: var(--brand-mute);
    margin-bottom: 12px;
}

.scan-tips {
    background: var(--brand-bg-alt);
    border-radius: var(--radius-md);
    padding: 16px 20px;
    margin-bottom: 18px;
}
.scan-tips h3 {
    font-size: 12.5px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin: 0 0 8px;
    color: var(--brand-mute);
}
.scan-tips ul {
    margin: 0;
    padding-left: 20px;
    font-size: 14px;
    color: var(--brand-ink-soft);
}
.scan-tips li { padding: 3px 0; }

/* Review screen: photo on the left, editable text on the right */
.scan-review-grid {
    display: grid;
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
    gap: 22px;
    align-items: start;
}
.scan-review__photo {
    width: 100%;
    border-radius: 10px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--brand-line);
}
@media (max-width: 880px) {
    .scan-review-grid { grid-template-columns: 1fr; }
}

/* ---------------- Analyze: mode picker ---------------- */
.analyze-modes { padding: 22px; }
.analyze-modes__grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
}
.analyze-mode {
    display: block;
    padding: 16px;
    border: 1px solid var(--brand-line);
    border-radius: 12px;
    background: #fff;
    color: var(--brand-ink);
    transition: border-color .15s ease, box-shadow .15s ease, transform .1s ease;
}
.analyze-mode:hover {
    border-color: var(--brand-accent);
    box-shadow: 0 0 0 4px rgba(139,92,246,.08);
}
.analyze-mode:active { transform: scale(.99); }
.analyze-mode__icon {
    width: 36px; height: 36px;
    border-radius: 10px;
    background: var(--brand-accent-soft);
    color: var(--brand-accent-deep);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 10px;
}
.analyze-mode strong { display: block; font-size: 14.5px; margin-bottom: 4px; letter-spacing: -0.005em; }
.analyze-mode small { color: var(--brand-mute); font-size: 12.5px; line-height: 1.45; display: block; }
