/* ============================================================
   Design tokens — Holland College / CSK-inspired palette
   ------------------------------------------------------------
   This palette is INSPIRED by Holland College (the Holland
   Hurricanes) and Canada's Smartest Kitchen brand identity.

   The hex values below are tasteful, well-contrasted
   approximations chosen to harmonise with CSK's existing red
   identity and the documented Holland maroon. They are NOT
   official Holland College PMS values. Treat as
   "Holland/CSK-inspired" — not as authoritative brand
   guidelines — until verified against the official Holland
   College brand book.

   Palette summary:
     Primary     CSK red            #E31E24
     Secondary   Holland maroon     #6E1A2E  (deep burgundy)
     Charcoal    near-black         #2B2B2B
     Surfaces    neutral light grey #F3F4F6 (page)
                 white cards       #FFFFFF
                 pale rose         #FBEEEC (brand accent tint)
                 pale maroon       #F5EAEC (brand accent tint)
     Semantic    green/amber/blue used only for status meaning
   ============================================================ */
:root {
    /* ---- Brand ---- */
    --brand-red:        #E31E24;
    --brand-red-dark:   #B8151A;
    --brand-red-soft:   #FBEEEC;   /* pale rose for icon tints */
    --brand-red-ink:    #7A0F12;   /* deep red for text on light */

    --brand-maroon:     #6E1A2E;   /* Holland/CSK-inspired maroon */
    --brand-maroon-dark:#4D1020;
    --brand-maroon-soft:#F5EAEC;   /* pale maroon tint */
    --brand-maroon-ink: #3D0D1A;   /* deep maroon text on light */

    --brand-charcoal:   #2B2B2B;
    --brand-ink:        #1A1A1A;   /* near-black for body text */

    /* ---- Surfaces (neutral laboratory/grey, not warm beige) ---- */
    --surface-page:     #f3f4f6;   /* very light neutral grey page bg */
    --surface-card:     #FFFFFF;   /* white card on grey page */
    --surface-muted:    #ececec;   /* neutral grey for stripes */
    --surface-warm:     #ececec;   /* neutral grey for hover/subtle fills */
    --surface-sidebar:  #241F22;   /* near-black w/ warm undertone */
    --surface-topbar:   #FFFFFF;

    /* ---- Text ---- */
    --text-primary:     #1A1A1A;
    --text-secondary:   #565656;
    --text-muted:       #8c8c8c;
    --text-on-dark:     #F4F0EC;
    --text-on-dark-dim: #BFB6AC;

    /* ---- Borders (neutral grey) ---- */
    --border-soft:      #e0e0e0;   /* neutral hairline */
    --border-mid:       #c8c8c8;
    --border-strong:    #8f8f8f;

    /* ---- Semantic status ---- */
    --status-draft:     #5A6470;   /* slate */
    --status-draft-bg:  #E9ECF0;
    --status-ready:     #1F7A4D;   /* green = ready */
    --status-ready-bg:  #E1F1E8;
    --status-active:    #B8151A;   /* brand red (in-use) */
    --status-active-bg: #FBEEEC;
    --status-complete:  #1F7A4D;   /* green */
    --status-complete-bg:#E1F1E8;
    --status-archived:  #8A8278;   /* muted */
    --status-archived-bg:#EDE7DF;
    --status-error:     #B8151A;
    --status-error-bg:  #FBEEEC;
    --status-warning:   #B26A00;   /* amber */
    --status-warning-bg:#FBEFD9;
    --status-info:      #1F5B7A;   /* restrained blue */
    --status-info-bg:   #E2EEF4;

    /* ---- Semantic aliases for shared component styles ---- */
    --info:        var(--status-info);
    --info-soft:   var(--status-info-bg);
    --success:     var(--status-complete);
    --success-soft:var(--status-complete-bg);
    --warning:     var(--status-warning);
    --warning-soft:var(--status-warning-bg);
    --danger:      var(--status-error);
    --danger-soft: var(--status-error-bg);

    /* ---- Aliases preserved for legacy selectors ---- */
    --charcoal:    var(--brand-charcoal);
    --grey:        var(--text-muted);
    --grey-soft:   var(--surface-warm);
    --grey-light:  var(--surface-page);
    --grey-mid:    var(--border-mid);
    --white:       #FFFFFF;
}
* { box-sizing: border-box; margin: 0; }
body {
    font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--surface-page);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
.topnav {
    background: var(--charcoal);
    color: var(--white);
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
}
.brand { font-size: 1.15rem; font-weight: 600; display: flex; align-items: center; gap: 0.6rem; }
.brand-mark {
    width: 14px; height: 14px; border-radius: 50%;
    background: var(--brand-red); display: inline-block;
}
.container { flex: 1; max-width: 1100px; margin: 2rem auto; padding: 0 1rem; width: 100%; }
.card {
    background: var(--white);
    border-radius: 8px;
    padding: 2rem;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    border-top: 3px solid var(--brand-maroon);
}
h1 { margin-bottom: 0.75rem; }
p { color: #555; margin-bottom: 1.25rem; }
.btn {
    display: inline-block;
    padding: 0.6rem 1.4rem;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 600;
    border: none;
    cursor: pointer;
}
.btn-primary { background: var(--brand-red); color: var(--white); text-decoration: none; }
.btn-primary:hover { background: var(--brand-red-dark); color: var(--white); text-decoration: none; }
.btn-primary:active { background: var(--brand-red-dark); text-decoration: none; }
.btn-primary:visited { color: var(--white); text-decoration: none; }
.footer {
    background: var(--charcoal);
    color: var(--grey);
    text-align: center;
    padding: 0.75rem;
    font-size: 0.85rem;
}
/* --- Phase 1 part 2 additions --- */
.nav-links { margin-left: auto; display: flex; align-items: center; gap: 1.25rem; }
.nav-links a { color: var(--white); text-decoration: none; font-weight: 500; }
.nav-links a:hover { color: var(--brand-red); }
.nav-user { color: var(--grey); font-size: 0.9rem; }
.inline-form { display: inline; }
.btn-ghost {
    background: transparent; color: var(--grey);
    border: 1px solid var(--grey); padding: 0.35rem 0.9rem;
    border-radius: 6px; font-size: 0.85rem;
    text-decoration: none;
}
.btn-ghost:hover { color: var(--white); border-color: var(--white); text-decoration: none; }
.btn-ghost:active { color: var(--white); text-decoration: none; }
.btn-ghost:visited { color: var(--grey); text-decoration: none; }
.btn-sm { font-size: 0.85rem; padding: 0.3rem 0.6rem; }
.page-title { margin-bottom: 1.25rem; }
.stat-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem; margin-bottom: 1.5rem;
}
.stat-card {
    background: var(--white); border-radius: 8px; padding: 1.25rem;
    text-align: center; box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    border-top: 3px solid var(--brand-red);
}
.stat-number { font-size: 2rem; font-weight: 700; color: var(--charcoal); }
.stat-label { color: var(--grey); font-size: 0.85rem; margin-top: 0.25rem; }
.data-table { width: 100%; border-collapse: collapse; margin-top: 0.75rem; }
.data-table th {
    text-align: left; padding: 0.6rem;
    background: var(--surface-warm); color: var(--text-primary);
    font-size: 0.85rem;
}
.data-table td { padding: 0.6rem; border-bottom: 1px solid #e3e3e3; }
.data-table tr:nth-child(even) { background: var(--grey-light); }
.badge {
    padding: 0.2rem 0.6rem; border-radius: 10px;
    font-size: 0.75rem; font-weight: 600; color: var(--white);
}
.badge-draft { background: var(--status-draft); }
.badge-ready { background: var(--status-ready); }
.badge-active { background: var(--status-active); }
.badge-complete { background: var(--status-complete); }
.badge-archived { background: var(--status-archived); }

/* --- Brand mini-pass: shared component treatments --- */
.btn-maroon { background: var(--brand-maroon); color: var(--white); text-decoration: none; }
.btn-maroon:hover { background: var(--brand-maroon-dark); color: var(--white); text-decoration: none; }
.btn-maroon:active { background: var(--brand-maroon-dark); text-decoration: none; }
.btn-maroon:visited { color: var(--white); text-decoration: none; }

/* A subtle maroon underline on page titles for visual depth without
   changing layout or font sizing. Uses a thin left border on the
   .page-title or .page-header-text block. */
.page-title,
.page-header-text h1 {
    border-left: 3px solid var(--brand-maroon);
    padding-left: 0.7rem;
}

/* Data table: neutral light-grey header, subtle grey hover. */
.data-table thead th {
    background: var(--surface-warm);
    color: var(--charcoal);
    border-bottom: 1px solid var(--border-soft);
}
.data-table tbody tr:hover {
    background: #f5f5f5;
}

/* Empty state card-like treatment so they don't look like raw text. */
.empty-state,
.dashboard-empty {
    background: var(--surface-warm);
    border: 1px dashed var(--border-soft);
    border-radius: 8px;
    color: var(--text-secondary);
}

/* Alerts: match the new palette. */
.alert { border-radius: 8px; padding: 0.75rem 1rem; }
.alert-info     { background: var(--info-soft);    color: var(--info);    border-left: 3px solid var(--info); }
.alert-success  { background: var(--success-soft); color: var(--success); border-left: 3px solid var(--success); }
.alert-warning  { background: var(--warning-soft); color: var(--warning); border-left: 3px solid var(--warning); }
.alert-danger   { background: var(--danger-soft);  color: var(--danger);  border-left: 3px solid var(--danger); }

/* Wizard-ready progress element (already present, brand-touched) */
.progress,
.wizard-progress { background: var(--surface-warm); border-radius: 6px; overflow: hidden; }
.progress-bar,
.wizard-progress > .progress-bar { background: var(--brand-maroon); }
.login-wrap { display: flex; justify-content: center; padding-top: 3rem; }
.login-card { width: 100%; max-width: 400px; }
.login-card label {
    display: block; margin: 0.9rem 0 0.3rem; font-weight: 600; font-size: 0.9rem;
}
.login-card input {
    width: 100%; padding: 0.55rem; border: 1px solid #ccc;
    border-radius: 6px; font-size: 1rem;
}
.login-card input:focus { outline: 2px solid var(--brand-red); border-color: transparent; }
.btn-block { width: 100%; margin-top: 1.25rem; }
.form-error { color: var(--brand-red); font-size: 0.9rem; margin-bottom: 0.5rem; }
h2 { margin-bottom: 0.5rem; }
/* --- Phase 2 additions --- */
.form-card { max-width: 560px; }
.form-card p { margin-bottom: 0.9rem; }
.form-card label { display: block; font-weight: 600; font-size: 0.9rem; margin-bottom: 0.3rem; }
.form-card input[type="text"], .form-card input[type="email"],
.form-card input[type="date"], .form-card select, .form-card textarea {
    width: 100%; padding: 0.55rem; border: 1px solid #ccc;
    border-radius: 6px; font-size: 1rem; font-family: inherit;
}
.form-card input:focus, .form-card select:focus, .form-card textarea:focus {
    outline: 2px solid var(--brand-red); border-color: transparent;
}
.form-card ul { list-style: none; }
.form-card .helptext { color: var(--grey); font-size: 0.8rem; }
.form-card .errorlist { color: var(--brand-red); font-size: 0.85rem; }
.filter-bar { display: flex; gap: 0.75rem; margin-bottom: 1rem; }
.filter-bar select { padding: 0.45rem; border: 1px solid #ccc; border-radius: 6px; }
/* --- Phase 3 additions --- */
.flash { padding: 0.7rem 1rem; border-radius: 6px; margin-bottom: 1rem;
         font-weight: 600; }
.flash-success { background: var(--status-complete-bg); color: var(--status-complete); }
.flash-error { background: var(--status-error-bg); color: var(--status-error); }
.btn-row { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-top: 0.75rem; }
.btn-secondary { background: var(--brand-charcoal); color: var(--white); text-decoration: none; }
.btn-secondary:hover { background: #1A1A1A; color: var(--white); text-decoration: none; }
.btn-secondary:active { background: #1A1A1A; text-decoration: none; }
.btn-secondary:visited { color: var(--white); text-decoration: none; }
.code-chip { display: inline-block; background: var(--grey-light);
             border: 1px solid #ccc; border-radius: 4px;
             padding: 0.1rem 0.45rem; font-family: monospace;
             margin-right: 0.25rem; }
.code-ref { background: var(--charcoal); color: var(--white); }
.ws-warning { color: var(--brand-red-dark); font-weight: 700;
              margin: 0.5rem 0 1rem; }
.ws-code { font-family: monospace; font-weight: 700; }
@media print {
    .topnav, .footer, .no-print { display: none !important; }
    .container { margin: 0; max-width: none; }
    body { background: white; }
}
/* --- Ballot builder --- */
.ballot-q { margin-bottom: 1rem; }
.ballot-q-head { display: flex; align-items: center; gap: 0.5rem;
                 margin-bottom: 0.5rem; }
.ballot-q-num { font-weight: 700; color: var(--brand-red); }
.ballot-q-edit { margin-left: auto; font-size: 0.85rem; }
.ballot-q-text { font-weight: 600; color: var(--charcoal); }
.preview-radio { display: block; margin: 0.25rem 0; color: #444; }
.preview-note { color: var(--grey); font-size: 0.85rem; }
.line-scale { display: flex; align-items: center; gap: 0.75rem; }
.line-scale input[type="range"] { flex: 1; }
.ballot-q textarea { width: 100%; padding: 0.5rem; border: 1px solid #ccc;
                     border-radius: 6px; }
                     /* --- Phase 4: tasting interface --- */
.taste-card { max-width: 520px; }
.taste-code-input { width: 100%; padding: 0.8rem; font-size: 1.4rem;
    text-align: center; text-transform: uppercase; font-family: monospace;
    border: 2px solid #ccc; border-radius: 8px; margin-bottom: 1rem; }
.taste-name-btn { display: block; width: 100%; margin-bottom: 0.6rem;
    background: var(--grey-light); color: var(--charcoal);
    border: 1px solid #ccc; font-size: 1.1rem; padding: 0.9rem; }
.taste-name-btn:hover { border-color: var(--brand-red); }
.taste-code { font-family: monospace; font-weight: 700;
    background: var(--charcoal); color: var(--white);
    padding: 0.1rem 0.5rem; border-radius: 4px; }
.taste-progress { color: var(--grey); font-size: 0.85rem; }
.taste-q { margin: 1.25rem 0; }
.taste-opt { color: var(--grey); font-weight: 400; font-size: 0.85rem; }
.taste-pick { display: inline-block; margin: 0.4rem 0.6rem 0 0; }
.taste-pick input { position: absolute; opacity: 0; }
.taste-pick span { display: inline-block; padding: 0.8rem 1.4rem;
    border: 2px solid #ccc; border-radius: 8px; font-family: monospace;
    font-size: 1.2rem; font-weight: 700; cursor: pointer; }
.taste-pick input:checked + span { border-color: var(--brand-red);
    background: var(--brand-red-soft); }
.taste-rank { display: flex; align-items: center; gap: 0.75rem;
    margin: 0.4rem 0; }
.taste-rank select { padding: 0.4rem; border-radius: 6px; }
.taste-q textarea { width: 100%; padding: 0.5rem; border: 1px solid #ccc;
    border-radius: 6px; }
    /* --- Phase 5: results --- */
.stats-table th { width: 280px; background: var(--grey-light);
    color: var(--charcoal); }
.verdict { font-weight: 700; margin-top: 0.75rem; }
.verdict-yes { color: #1d6b3f; }
.verdict-no { color: var(--grey); }
.comment-list { padding-left: 1.25rem; }
.comment-list li { margin: 0.3rem 0; }
details summary { cursor: pointer; font-weight: 600; margin: 0.75rem 0; }
/* --- Power calculator & performance --- */
.power-form { display: flex; gap: 1rem; flex-wrap: wrap;
    align-items: flex-end; margin: 1rem 0; }
.power-form label { display: flex; flex-direction: column;
    font-weight: 600; font-size: 0.9rem; gap: 0.3rem; }
.power-form input, .power-form select { padding: 0.5rem;
    border: 1px solid #ccc; border-radius: 6px; }
.power-n { color: var(--brand-red); font-size: 1.6em; }
.perf-good { color: #1d6b3f; font-weight: 700; }
.perf-poor { color: var(--brand-red-dark); font-weight: 700; }
/* --- Branding --- */
.brand-logo { height: 40px; width: 40px; border-radius: 50%; }
/* Participant header overrides */
.taste-header .brand-logo {
    width: 40px; height: 40px; max-width: 40px; max-height: 40px;
    flex: 0 0 40px; object-fit: contain;
}
.brand-sub { color: var(--grey); font-weight: 400; font-size: 0.85em;
             margin-left: 0.4rem; }

/* ---- Standalone participant shell (taste_base.html) ----
   Intentionally minimal: no staff chrome, no sidebar, no topbar. */
body.is-participant {
    background: var(--surface-page);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
.participant-shell {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}
.participant-header {
    background: var(--white);
    border-bottom: 3px solid var(--brand-maroon);
    padding: 0.85rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
.participant-brand { display: inline-flex; align-items: center; gap: 0.6rem; }
.participant-brand .brand-logo { width: 36px; height: 36px; object-fit: contain; }
.participant-brand-text { font-weight: 700; color: var(--charcoal); }
.participant-brand-sub {
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.85em;
    margin-left: 0.3rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.participant-content {
    flex: 1;
    padding: 1.5rem 1.25rem;
    max-width: 720px;
    width: 100%;
    margin: 0 auto;
}
.participant-footer {
    background: var(--surface-warm);
    color: var(--text-muted);
    text-align: center;
    padding: 0.85rem;
    font-size: 0.8rem;
    border-top: 1px solid var(--border-soft);
}
.is-participant .skip-link {
    position: absolute; left: -1000px; top: 0;
    background: var(--brand-maroon); color: var(--white);
    padding: 0.5rem 0.9rem; z-index: 1000;
}
.is-participant .skip-link:focus { left: 1rem; top: 0.5rem; }



/* --- Tetrad grouping interface --- */
/* Self-contained Tetrad UI — no Rank dependencies */
.tetrad-preference { margin: 1rem 0; max-width: 900px; }
.tetrad-instructions { font-size: 0.9rem; color: var(--grey); margin-bottom: 0.5rem; }
/* Tetrad layout uses CSS Grid with explicit grid-template-areas so the
   Available / Group A / Group B zones have FIXED positions regardless of
   how many sample cards are inside each zone. The previous flex-based
   layout caused Group A and Group B to wrap or shift as Available
   shrank, which made the grouping targets feel unstable. */
.tetrad-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas:
        "available available"
        "group-a   group-b";
    gap: 1rem 1.5rem;
    align-items: start;
}
.tetrad-column { min-width: 0; }
.tetrad-column h4 { margin-bottom: 0.5rem; }
.tetrad-column-available {
    grid-area: available;
    min-width: 0;
}
.tetrad-available { min-width: 0; }
.tetrad-available h4 { margin-bottom: 0.5rem; }
.tetrad-cards { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 0; }
.tetrad-card {
    width: 70px; height: 50px;
    border: 2px solid var(--brand-red);
    border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    background: var(--white);
    cursor: grab;
    transition: box-shadow 0.15s, background 0.15s;
    user-select: none;
}
.tetrad-card:hover { box-shadow: 0 2px 6px rgba(0,0,0,0.15); }
.tetrad-card .tetrad-code { font-size: 1rem; font-weight: 700; }
.tetrad-card.tetrad-selected {
    background: var(--brand-red);
    color: var(--white);
    box-shadow: 0 0 0 3px var(--brand-red-dark);
}
.tetrad-card.tetrad-selected .tetrad-code { color: var(--white); }
.tetrad-card.tetrad-dragging { opacity: 0.4; }

.tetrad-slots { display: flex; flex-direction: column; gap: 0.5rem; }
.tetrad-slot {
    min-height: 50px;
    border: 2px dashed var(--grey);
    border-radius: 6px;
    padding: 0.5rem;
    display: flex; align-items: center; gap: 0.5rem;
    background: var(--grey-light);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}
.tetrad-slot:hover { border-color: var(--brand-red); }
.tetrad-slot.tetrad-dragover { border-color: var(--brand-red); background: #fff0f0; }
.tetrad-slot .tetrad-code { font-weight: 700; font-size: 1rem; }
.tetrad-column-group {
    grid-area: group-a;
    cursor: pointer;
    transition: background 0.15s;
    padding: 0.25rem;
    border-radius: 6px;
    min-width: 0;
}
#tetrad-group-b { grid-area: group-b; }
.tetrad-column-group:hover { background: #fafafa; }
.tetrad-column-group:focus { outline: 2px solid var(--brand-red); outline-offset: 2px; }

#tetrad-status {
    margin-top: 0.75rem;
    font-size: 0.9rem;
    color: var(--grey);
}
#tetrad-status.tetrad-status-ok { color: #2a7d2a; font-weight: 600; }

@media (max-width: 600px) {
    .tetrad-layout {
        grid-template-columns: minmax(0, 1fr);
        grid-template-areas:
            "available"
            "group-a"
            "group-b";
    }
}
/* --- Print styles --- */
@media print {
    .no-print, .topnav, .btn-row, .footer, .btn, button, form, .nav-links,
    .inline-form, .flash, .flash-* { display: none !important; }
    body { font-size: 11pt; color: #000; background: #fff; }
    .container { max-width: none; padding: 0; margin: 0; }
    .card { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
    .data-table { font-size: 9pt; }
    .data-table th { background: #eee !important; color: #000 !important; }
    .ws-table td, .ws-table th { padding: 4px 6px; }
    .page-title { font-size: 14pt; }
    h2 { font-size: 12pt; }
    a { color: #000; text-decoration: underline; }
    @page { margin: 0.75in; }
    .rank-preference { break-inside: avoid; }
    .rank-card, .rank-slot { border-color: #999; }
}
/* --- Label print styles --- */
.label-page { width: 8.5in; margin: 0 auto; padding: 0; }
.label-5167 { display: flex; flex-wrap: wrap; }
.label-cell { break-inside: avoid; }
.label-cell-5167 {
    width: 1.75in; height: 0.5in;
    display: flex; align-items: center; justify-content: center;
    border: 1px solid #ccc; font-size: 18pt; font-weight: 700;
    font-family: monospace;
}
.label-5160 { display: flex; flex-wrap: wrap; }
.label-cell-5160 {
    width: 2.625in; height: 1in;
    border: 1px solid #ccc; padding: 4px; box-sizing: border-box;
    break-inside: avoid; display: flex; align-items: center;
}
.tray-label-content { font-size: 10pt; width: 100%; }
.tray-label-study { font-weight: 700; font-size: 11pt; }
.tray-label-seat { font-size: 9pt; color: #444; }
.tray-label-codes { font-family: monospace; font-size: 14pt; font-weight: 700; margin-top: 2px; }
@media print {
    .label-cell { border: 1px solid #000; }
    .label-page { padding: 0; }
}
/* --- Batch 4A-1: staff application shell ------------------------------- */
/* New chrome added in 4A-1: app-shell grid, sidebar, topbar, content,
   coming-soon module list, dashboard polish, flash messages, skip-link.
   Implemented in the canonical source so collectstatic will distribute it
   to staticfiles/ automatically. */

body.is-staff-app {
    background: var(--grey-light);
    color: var(--charcoal);
}
body.is-anon {
    background: linear-gradient(135deg, #fafafa 0%, var(--grey-light) 100%);
}

/* ---- Skip link: visually hidden until keyboard focused ---- */
.skip-link {
    position: absolute;
    top: -100px;
    left: 1rem;
    background: var(--charcoal);
    color: var(--white);
    padding: 0.6rem 1rem;
    border-radius: 0 0 6px 6px;
    text-decoration: none;
    font-weight: 600;
    z-index: 1000;
    transition: top 0.15s ease-in-out;
}
.skip-link:focus,
.skip-link:focus-visible {
    top: 0;
    outline: 3px solid var(--brand-red);
    outline-offset: 0;
}

/* ---- App shell: CSS Grid sidebar + main ---- */
.app-shell {
    display: grid;
    grid-template-columns: 240px 1fr;
    grid-template-areas: "sidebar main";
    min-height: 100vh;
    width: 100%;
}
.app-shell-anon {
    display: block;
    min-height: 100vh;
}
.app-shell-anon .app-main { width: 100%; }

/* ---- Sidebar ---- */
.app-sidebar {
    grid-area: sidebar;
    background:
        linear-gradient(180deg, #2A2125 0%, #221B1E 100%);
    color: var(--text-on-dark);
    padding: 1.5rem 0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    position: sticky;
    top: 0;
    height: 100vh;
    border-top: 3px solid var(--brand-maroon);   /* Holland/CSK-inspired accent */
}
.app-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0 1.25rem 1.5rem;
    border-bottom: 1px solid #3a3a3a;
    margin-bottom: 1rem;
}
.app-sidebar .brand-logo {
    width: 36px; height: 36px;
    border-radius: 50%;
    object-fit: cover;
    flex: 0 0 36px;
    background: var(--white);
}
.app-brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
    min-width: 0;
}
.app-brand-name {
    font-size: 1rem;
    font-weight: 700;
    color: var(--white);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.app-brand-sub {
    font-size: 0.75rem;
    color: var(--grey);
    margin-top: 0.15rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-nav {
    display: flex;
    flex-direction: column;
    padding: 0 0.75rem;
    gap: 0.15rem;
    margin-bottom: 1.5rem;
}
.app-nav-section {
    display: block;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #C9C2BB;          /* dim warm white on dark sidebar */
    background: rgba(255, 255, 255, 0.06);
    padding: 0.5rem 0.6rem 0.35rem;
    border-radius: 4px;
    margin: 0.5rem 0.5rem 0.4rem;
}
.app-nav-link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.55rem 0.75rem;
    color: #d8d8d8;
    text-decoration: none;
    border-radius: 6px;
    font-size: 0.92rem;
    font-weight: 500;
    transition: background 0.12s, color 0.12s;
}
.app-nav-link:hover {
    background: #3a3a3a;
    color: var(--white);
}
.app-nav-link.is-active {
    background: var(--brand-red);
    color: var(--white);
    font-weight: 600;
    box-shadow: inset 3px 0 0 var(--brand-maroon);
}
.app-nav-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: #666;
    flex: 0 0 6px;
}
.app-nav-link:hover .app-nav-dot,
.app-nav-link.is-active .app-nav-dot { background: var(--white); }

/* ---- Sensory Quick Start section (replaces generic Coming Soon) ---- */
.app-quickstart {
    margin-top: auto;
    padding: 1rem 0.75rem 0.5rem;
    border-top: 1px solid #3A2A30;
}
.quickstart-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}
.quickstart-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0.7rem;
    border-radius: 6px;
    transition: background 0.12s ease;
    position: relative;
}
.quickstart-item:hover { background: rgba(255, 255, 255, 0.04); }
.quickstart-item.is-soon .quickstart-dot { background: #888; }
.quickstart-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--brand-maroon);
    flex: 0 0 6px;
}
.quickstart-link {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
    text-decoration: none;
    color: var(--white);
}
.quickstart-link:hover .quickstart-label { color: var(--brand-red); }
.quickstart-label {
    font-size: 0.86rem;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: color 0.12s ease;
}
.quickstart-sub {
    font-size: 0.7rem;
    color: #aaa;
    margin-top: 0.1rem;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.quickstatic {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
    color: #888;
    cursor: not-allowed;
    user-select: none;
}
.quickstatic .quickstart-label { color: #888; }
.quickstatic .quickstart-sub   { color: #6a6a6a; font-style: italic; }
.quickstart-badge {
    background: var(--brand-red);
    color: var(--white);
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    flex: 0 0 auto;
}

/* ---- Main column: topbar + content + footer ---- */
.app-main {
    grid-area: main;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--surface-page);
}

.app-topbar {
    background: var(--surface-topbar);
    border-bottom: 1px solid var(--border-soft);
    box-shadow: 0 1px 2px rgba(80, 40, 30, 0.04);
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-height: 56px;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}
.app-topbar-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
    min-width: 0;
}
.app-topbar-right {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    flex-shrink: 0;
}
.app-user {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    line-height: 1.2;
    border-left: 1px solid #e0e0e0;
    padding-left: 0.85rem;
}
.app-user-name {
    font-weight: 600;
    color: var(--charcoal);
    font-size: 0.9rem;
}
.app-user-role {
    font-size: 0.72rem;
    color: var(--grey);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-top: 0.1rem;
}
.app-logout-form { display: inline; margin: 0; }

/* Buttons used by topbar (compact ghost variant) */
.app-topbar .btn-ghost {
    color: var(--charcoal);
    border-color: #d0d0d0;
    background: transparent;
}
.app-topbar .btn-ghost:hover {
    color: var(--brand-red);
    border-color: var(--brand-red);
    background: #fff5f5;
}

/* ---- Content area ---- */
.app-content {
    flex: 1;
    padding: 2rem 2.25rem;
    max-width: 1600px;
    width: 100%;
    margin: 0 auto;
}
.app-shell-anon .app-content {
    max-width: 460px;
    padding: 4rem 1.5rem;
}

/* Page header (used by study_list, study_detail, panelist dir, etc.) */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}
.page-header-text { min-width: 0; }
.page-header h1,
.page-header .page-title {
    margin: 0 0 0.25rem;
    font-size: 1.6rem;
    color: var(--charcoal);
}
.page-subtitle {
    color: var(--grey);
    font-size: 0.95rem;
    margin: 0;
}
.page-header-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
}

/* Breadcrumb (rendered into topbar-left) */
.app-breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.88rem;
    color: var(--grey);
    flex-wrap: wrap;
}
.app-breadcrumb a {
    color: var(--charcoal);
    text-decoration: none;
    font-weight: 500;
}
.app-breadcrumb a:hover { color: var(--brand-red); }
.app-breadcrumb .crumb-sep { color: #c0c0c0; }
.app-breadcrumb .crumb-current { color: var(--charcoal); font-weight: 600; }

/* ---- Flash messages ---- */
.flash-container {
    margin-bottom: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.flash {
    padding: 0.75rem 1rem;
    border-radius: 6px;
    font-weight: 500;
    border-left: 4px solid;
}
.flash-success,
.flash-info {
    background: var(--status-complete-bg);
    color: var(--status-complete);
    border-left-color: var(--status-complete);
}
.flash-error,
.flash-danger {
    background: var(--status-error-bg);
    color: var(--status-error);
    border-left-color: var(--status-error);
}
.flash-warning {
    background: var(--status-warning-bg);
    color: var(--status-warning);
    border-left-color: var(--status-warning);
}

/* ---- Dashboard card variants ---- */
.dashboard-hero {
    background: linear-gradient(135deg, var(--charcoal) 0%, #1a1a1a 100%);
    color: var(--white);
    border-radius: 10px;
    padding: 1.75rem 2rem;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    flex-wrap: wrap;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.dashboard-hero-text { min-width: 0; }
.dashboard-hero h1 {
    color: var(--white);
    margin: 0 0 0.35rem;
    font-size: 1.6rem;
}
.dashboard-hero p {
    color: #c8c8c8;
    margin: 0;
    font-size: 0.95rem;
}
.dashboard-hero .btn-primary {
    background: var(--brand-red);
    color: var(--white);
    padding: 0.75rem 1.5rem;
    font-size: 0.95rem;
}
.dashboard-hero .btn-primary:hover { background: var(--brand-red-dark); }

.dashboard-section {
    margin-bottom: 1.75rem;
}
.dashboard-section h2 {
    font-size: 1.1rem;
    margin: 0 0 0.75rem;
    color: var(--charcoal);
    font-weight: 700;
}

.dashboard-empty {
    text-align: center;
    padding: 2.5rem 1rem;
    color: var(--grey);
}
.dashboard-empty p { color: var(--grey); margin-bottom: 0.75rem; }
.dashboard-empty .empty-icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    color: #c0c0c0;
}

/* Card variants */
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #eee;
}
.card-header h2,
.card-header h3 { margin: 0; font-size: 1.1rem; }
.card-header .card-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

/* Stat-card enhancement */
.stat-card {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    transition: transform 0.12s, box-shadow 0.12s;
}
.stat-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(0,0,0,0.1);
}

/* Status pills -- broader coverage for ad-hoc status strings */
.badge-soon {
    background: var(--status-archived);
    color: var(--white);
}

/* Invitation status badges (derived statuses on the staff page) */
.badge-status {
    border: 1px solid transparent;
    border-radius: 12px;
    padding: 0.2rem 0.7rem;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.4;
    display: inline-block;
    white-space: nowrap;
}
.badge-INVITED { background: var(--status-info-bg); color: var(--status-info); border-color: var(--status-info); }
.badge-OPENED  { background: var(--status-info-bg); color: var(--status-info); border-color: var(--status-info); }
.badge-STARTED { background: var(--status-warning-bg); color: var(--status-warning); border-color: var(--status-warning); }
.badge-COMPLETED { background: var(--status-complete-bg); color: var(--status-complete); border-color: var(--status-complete); }
.badge-REVOKED { background: var(--status-archived-bg); color: var(--status-archived); border-color: var(--status-archived); }
.badge-EXPIRED { background: var(--status-archived-bg); color: var(--status-archived); border-color: var(--status-archived); }

/* Staff invitation manager page */
.invitations-page-head { margin-bottom: 1rem; }
.invitations-guidance {
    background: var(--surface-warm);
    border-left: 3px solid var(--border-mid);
    border-radius: 6px;
    color: var(--text-secondary);
    padding: 0.7rem 1rem;
    margin: 0 0 1.25rem;
    font-size: 0.95rem;
}
.invitations-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.25rem;
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin: 0.25rem 0 1rem;
}
.invitations-meta span { white-space: nowrap; }
.invitations-meta .meta-label { color: var(--text-muted); margin-right: 0.25rem; }
.invitations-meta strong { color: var(--text-primary); font-weight: 600; }
.invitations-note {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 0.75rem;
}
.open-session-card {
    padding: 1rem 1.25rem;
    margin-bottom: 1.25rem;
}
.open-session-card .invitations-guidance {
    margin: 0 0 1rem;
}
.open-session-form { margin: 0; }
.open-session-form .btn-lg {
    padding: 0.65rem 1.4rem;
    font-size: 1.05rem;
}
.invitations-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}
.link-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0 0 0.6rem;
}
.link-row input.copy-link {
    flex: 1;
    min-width: 0;
    font-family: Consolas, "Courier New", monospace;
    font-size: 0.8rem;
    padding: 0.35rem 0.5rem;
    border: 1px solid var(--border-soft);
    border-radius: 6px;
    background: var(--surface-page);
    color: var(--text-primary);
}
.copy-btn { white-space: nowrap; }
.inv-detail { margin: 0; }
.inv-detail summary {
    cursor: pointer;
    color: var(--brand-red-dark);
    font-size: 0.9rem;
    font-weight: 600;
}
.inv-detail summary:hover { text-decoration: underline; }
.inv-detail .inv-actions {
    margin-top: 0.5rem;
    padding: 0.6rem;
    border: 1px solid var(--border-soft);
    border-radius: 6px;
    background: var(--surface-card);
}
.hidden-form { display: none; }
.hidden-form:not([hidden]) { display: none; }
.col-select {
    width: 1%;
    white-space: nowrap;
}
.select-all-label {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    user-select: none;
}
.select-all-label input {
    accent-color: var(--brand-red);
    width: 1rem;
    height: 1rem;
    cursor: pointer;
}
.panelist-select {
    accent-color: var(--brand-red);
    width: 1rem;
    height: 1rem;
    cursor: pointer;
    vertical-align: middle;
}
.invitations-table { margin-top: 0.5rem; }
.invitations-table th,
.invitations-table td {
    vertical-align: middle;
}
.invitations-table td { padding-top: 0.7rem; padding-bottom: 0.7rem; }
.participant-name { font-weight: 600; color: var(--text-primary); }
.participant-username {
    display: block;
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-top: 0.1rem;
}
.generate-card { margin-top: 1.5rem; }
.generate-card .form-row {
    max-width: 340px;
    margin-bottom: 1rem;
}
.generate-card select {
    padding: 0.45rem 0.6rem;
    border: 1px solid var(--border-mid);
    border-radius: 6px;
    background: var(--surface-card);
    font-family: inherit;
    font-size: 0.95rem;
    color: var(--text-primary);
}

/* Buttons: more consistent sizing */
.btn { font-family: inherit; }
/* Button-style links: never show the browser default underline, even
   after a visit. Kept at the shared .btn level so every button-like
   link (wizard Back/Continue, Save, Open links) inherits the same
   rule without per-template patches. */
.btn,
.btn:link,
.btn:visited,
.btn:hover,
.btn:active {
    text-decoration: none;
}
.btn:focus-visible {
    outline: 3px solid var(--brand-red);
    outline-offset: 2px;
}
.btn-primary:focus-visible,
.btn-secondary:focus-visible {
    outline-color: var(--brand-maroon-dark);
}

/* Form focus rings */
input:focus-visible, select:focus-visible, textarea:focus-visible,
button:focus-visible {
    outline: 2px solid var(--brand-red);
    outline-offset: 1px;
}

/* Table improvements */
.data-table th:first-child,
.data-table td:first-child { padding-left: 1rem; }
.data-table th:last-child,
.data-table td:last-child { padding-right: 1rem; }

/* ---- Footer ---- */
.app-footer {
    background: transparent;
    color: var(--grey);
    text-align: center;
    padding: 1rem 1.5rem;
    font-size: 0.82rem;
    border-top: 1px solid #e0e0e0;
    margin-top: 1rem;
}

/* ---- Responsive: tablet & mobile ---- */
@media (max-width: 900px) {
    .app-shell {
        grid-template-columns: 1fr;
        grid-template-areas: "main";
    }
    .app-sidebar {
        position: fixed;
        top: 0; left: 0; bottom: 0;
        width: 260px;
        z-index: 100;
        transform: translateX(-100%);
        transition: transform 0.2s ease-in-out;
        box-shadow: 2px 0 8px rgba(0,0,0,0.2);
    }
    .app-sidebar.is-open { transform: translateX(0); }
    .app-topbar { padding: 0.6rem 1rem; }
    .app-topbar-left::before {
        content: "\2630";
        display: inline-block;
        font-size: 1.4rem;
        color: var(--charcoal);
        margin-right: 0.5rem;
        cursor: pointer;
        padding: 0.25rem 0.5rem;
        border-radius: 4px;
    }
    .app-topbar-left::before:hover { background: var(--grey-light); }
    .app-user { display: none; }
    .app-content { padding: 1.25rem 1rem; }
    .dashboard-hero { padding: 1.25rem 1.25rem; }
    .dashboard-hero h1 { font-size: 1.3rem; }
}
@media (max-width: 600px) {
    .stat-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .stat-card { padding: 0.9rem; }
    .stat-number { font-size: 1.5rem; }
    .app-topbar-right .btn-ghost { padding: 0.25rem 0.5rem; font-size: 0.78rem; }
    .data-table { font-size: 0.85rem; }
    .data-table th, .data-table td { padding: 0.4rem 0.5rem; }
    .page-header h1, .page-header .page-title { font-size: 1.3rem; }
}

/* ---- Print: hide staff chrome ---- */
@media print {
    .app-sidebar, .app-topbar, .app-footer, .skip-link { display: none !important; }
    .app-shell { grid-template-columns: 1fr; grid-template-areas: "main"; }
    .app-content { padding: 0; max-width: none; }
}
/* --- Batch 4A-1: dashboard visual application launcher ----------------- */
/* (Legacy first-block removed: it conflicted with the modern layout
   below and forced the aside into the wrong grid track. The new
   `.dashboard` rule later in this stylesheet is the single source of
   truth. The orphaned `.dashboard-stats` rule was also removed because
   the template uses `.stat-strip` (4 tiles), not `.dashboard-stats`. */

.dashboard-welcome {
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-soft);
    position: relative;
}
.dashboard-welcome::before {
    content: "";
    position: absolute;
    left: 0;
    bottom: -1px;
    width: 56px;
    height: 3px;
    background: linear-gradient(90deg, var(--brand-red) 0%, var(--brand-maroon) 100%);
    border-radius: 2px;
}
.dashboard-welcome h1 {
    margin: 0 0 0.25rem 0;
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--charcoal);
    letter-spacing: -0.01em;
}
.dashboard-welcome p {
    margin: 0;
    color: var(--grey);
    font-size: 0.95rem;
}

.launcher-grid {
    display: grid;
    width: 100%;
    /* Wide desktop default: 4 columns. Responsive overrides below. */
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1rem;
}
.launcher-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.85rem;
    padding: 1.4rem 1.4rem 1.25rem;
    background: var(--white);
    border: 1px solid var(--grey-mid);
    border-radius: 12px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    text-decoration: none;
    color: inherit;
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
    min-height: 200px;
    position: relative;
    overflow: hidden;
}
.launcher-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
    border-color: var(--brand-red);
    color: inherit;
    text-decoration: none;
}
.launcher-card:focus-visible {
    outline: 3px solid var(--brand-red);
    outline-offset: 2px;
}


.launcher-card.is-soon {
    background: var(--surface-warm);
    color: var(--text-secondary);
    border-style: dashed;
    border-color: var(--border-mid);
    cursor: default;
    pointer-events: none;
}
.launcher-card.is-soon:hover {
    transform: none;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    border-color: var(--border-strong);
}
.launcher-card.is-soon .launcher-cta     { display: none; }

/* Normalized launcher icon: CSK red accent on a light neutral
   surface. Applied uniformly across every active launcher card
   (Create Sensory Study, Sensory Studies, Panelists, Sessions,
   Participant Entry, Results & Reports, Admin). The disabled
   At-Home card uses a neutral grey treatment via .is-soon below
   so it cannot be confused with an active launch. */
.launcher-icon-bg {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    background: var(--brand-red-soft);
    color: var(--brand-red);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.launcher-card.is-soon .launcher-icon-bg {
    background: var(--grey-soft);
    color: var(--grey);
}
.launcher-card.is-soon .launcher-icon {
    color: var(--grey);
    opacity: 0.7;
}
.launcher-icon { width: 32px; height: 32px; display: block; }
.launcher-icon svg {
    width: 100%; height: 100%;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.launcher-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: inherit;
    line-height: 1.2;
    margin: 0;
}
.dashboard-activity .activity-card {
    background: var(--white);
    border: 1px solid var(--grey-mid);
    border-radius: 10px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    margin-bottom: 1rem;
    overflow: hidden;
}
.activity-header {
    padding: 0.85rem 1.1rem;
    border-bottom: 1px solid var(--grey-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.activity-header h2 {
    margin: 0;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--grey);
}
.activity-header a {
    font-size: 0.75rem;
    color: var(--brand-red);
    text-decoration: none;
    font-weight: 600;
}
.activity-header a:hover { text-decoration: underline; }

.activity-list { list-style: none; margin: 0; padding: 0; }
.activity-item {
    padding: 0.75rem 1.1rem;
    border-bottom: 1px solid var(--grey-light);
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}
.activity-item:last-child { border-bottom: none; }
.activity-item-title {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--charcoal);
    text-decoration: none;
    line-height: 1.3;
}
.activity-item-title:hover { color: var(--brand-red); }
.activity-item-meta {
    font-size: 0.75rem;
    color: var(--grey);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.activity-item-meta .dot { color: var(--grey-mid); }
.activity-item-action {
    margin-top: 0.35rem;
    font-size: 0.75rem;
    color: var(--brand-red);
    text-decoration: none;
    font-weight: 600;
    align-self: flex-start;
}
.activity-item-action:hover { text-decoration: underline; }
.activity-empty {
    padding: 1.5rem 1.1rem;
    text-align: center;
    color: var(--grey);
    font-size: 0.85rem;
}

/* Orphaned `.dashboard-stats` / `.stat-pill` / `.dashboard-activity` rules
   from the legacy dashboard grid were removed: the modern template uses
   `.stat-strip` + `.stat-tile` and `.dashboard-aside`, which are styled
   in the launcher block below. */

.app-sidebar { overflow-y: auto; overflow-x: hidden; }
.app-nav, .coming-soon-list, .app-coming-soon { overflow: visible; }

.launcher-sub {
    font-size: 0.85rem;
    color: var(--grey);
    line-height: 1.4;
    margin: 0;
    flex-grow: 1;
}
.launcher-card.is-soon .launcher-sub    { color: var(--grey); }

.launcher-cta {
    margin-top: auto;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--brand-red);
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}
.launcher-cta-arrow { transition: transform 0.15s ease; }
.launcher-card:hover .launcher-cta-arrow { transform: translateX(3px); }

.launcher-soon-badge {
    position: absolute;
    top: 0.85rem;
    right: 0.85rem;
    background: var(--charcoal);
    color: var(--white);
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.18rem 0.5rem;
    border-radius: 3px;
}
.launcher-soon-badge.is-next { background: var(--brand-red); }

/* --- Batch 4A-1 GUI: dashboard visual application launcher ----------- */
/* Aliases and additions for the new dashboard.html class names. */
/* Activity panels (Upcoming Sessions + Recent Studies) sit BELOW the
   launcher as a 2-column grid on wide screens, stacked on smaller ones. */
.dashboard-activity {
    display: grid;
    width: 100%;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
    margin-top: 1.5rem;
}
.dashboard-activity .activity-card {
    background: var(--white);
    border: 1px solid var(--grey-mid);
    border-top: 3px solid var(--brand-red);
    border-radius: 10px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    overflow: hidden;
}
.activity-card-head {
    padding: 0.85rem 1.1rem;
    border-bottom: 1px solid var(--grey-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.activity-card-head h2 {
    margin: 0;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--brand-maroon);
}
.activity-card-link {
    font-size: 0.75rem;
    color: var(--brand-red);
    text-decoration: none;
    font-weight: 600;
}
.activity-card-link:hover { text-decoration: underline; }

.activity-list { list-style: none; margin: 0; padding: 0; }
/* Dashboard activity lists (Upcoming Sessions + Recent Studies) use a
   two-column card grid on desktop, collapsing to one column on narrow
   screens so each card stays readable. */
.activity-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 1rem;
}
.activity-item {
    padding: 0.75rem 1.1rem;
    border-bottom: 1px solid var(--grey-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}
.activity-item:last-child { border-bottom: none; }
.activity-main { min-width: 0; flex: 1 1 auto; }
.activity-title {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--charcoal);
    line-height: 1.35;
    overflow-wrap: break-word;
    white-space: normal;
}
.activity-meta {
    font-size: 0.75rem;
    color: var(--grey);
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-top: 0.1rem;
}
.dot-sep { color: var(--grey-mid); }
.activity-open {
    flex-shrink: 0;
    font-size: 0.72rem;
    color: var(--brand-red);
    text-decoration: none;
    font-weight: 600;
    padding: 0.25rem 0.55rem;
    border: 1px solid var(--brand-red);
    border-radius: 4px;
    background: transparent;
    transition: background 0.15s ease, color 0.15s ease;
}
.activity-open:hover {
    background: var(--brand-red);
    color: var(--white);
    text-decoration: none;
}
.activity-open:focus-visible {
    outline: 2px solid var(--brand-red);
    outline-offset: 2px;
}
.activity-empty {
    padding: 1.5rem 1.1rem;
    text-align: center;
    color: var(--grey);
    font-size: 0.85rem;
    margin: 0;
}

.stat-strip {
    margin-top: 1.5rem;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0;
    background: var(--white);
    border: 1px solid var(--grey-mid);
    border-top: 3px solid var(--brand-maroon);
    border-radius: 10px;
    padding: 0.75rem 1rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
.stat-tile {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 0.5rem 0.85rem;
    border-left: 1px solid var(--brand-maroon-soft);
}
.stat-tile:first-child { border-left: none; }
.stat-tile-num {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--brand-maroon);
    line-height: 1.1;
}
.stat-tile-label {
    font-size: 0.7rem;
    color: var(--grey);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-top: 0.2rem;
}

/* Full-width dashboard layout:
   .dashboard is a simple vertical flow (launcher -> activity -> stat-strip).
   No nested 70/30 grid, no named areas, no implicit tracks. Each section
   is a plain block-level child that fills the available .app-content width. */
.dashboard {
    display: block;
    width: 100%;
}
.dashboard-launcher {
    display: block;
    width: 100%;
}

/* Launcher responsive grid:
     >=1400px : 4 columns
     1000-1399: 3 columns
     650-999  : 2 columns
     <650     : 1 column
   The base rule above defaults to 4 columns on wide screens. */
@media (max-width: 1399px) {
    .launcher-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 999px) {
    .launcher-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 649px) {
    .launcher-grid { grid-template-columns: 1fr; }
    .launcher-card { min-height: 140px; padding: 1rem; }
    .dashboard-welcome h1 { font-size: 1.3rem; }
}

/* Activity panels: 2 columns on desktop, 1 column on small screens. */
@media (max-width: 820px) {
    .dashboard-activity { grid-template-columns: 1fr; }
    .activity-grid { grid-template-columns: 1fr; }
    .stat-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .stat-tile { border-left: none; }
    .stat-tile:nth-child(odd) { border-right: 1px solid var(--grey-light); }
    .stat-tile:nth-child(3),
    .stat-tile:nth-child(4) {
        border-top: 1px solid var(--grey-light);
        padding-top: 0.7rem;
        margin-top: 0.3rem;
    }
}
@media (max-width: 600px) {
    .stat-tile { padding: 0.4rem 0.5rem; }
    .stat-tile-num { font-size: 1.1rem; }
}
@media print {
    .launcher-card, .activity-card, .stat-strip { box-shadow: none; }
}

/* ============================================================
   Batch 4A-2A: Objective-first guided study wizard
   ============================================================ */

.wizard-step-header {
    margin-bottom: 1.25rem;
}
.wizard-step-eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--brand-red);
    margin: 0 0 0.35rem 0;
}
.wizard-step-header h1 {
    margin: 0 0 0.4rem 0;
    font-size: 1.65rem;
    color: var(--text-primary);
}
.wizard-step-lede {
    margin: 0;
    color: var(--text-secondary);
    max-width: 60ch;
    line-height: 1.5;
}

/* ---- Progress bar ---- */
.wizard-progress {
    margin: 1.25rem 0 1.5rem 0;
    border-bottom: 1px solid var(--border-soft);
    padding-bottom: 1rem;
}
.wizard-progress-list {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 0.5rem;
    margin: 0;
    padding: 0;
}
.wizard-progress-step {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.65rem;
    border-radius: 999px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    background: var(--surface-muted);
    border: 1px solid var(--border-soft);
}
.wizard-progress-index {
    display: inline-block;
    min-width: 1.4rem;
    height: 1.4rem;
    line-height: 1.4rem;
    border-radius: 50%;
    background: transparent;
    color: var(--text-secondary);
    text-align: center;
    font-weight: 600;
    font-size: 0.78rem;
}
.wizard-progress-step.is-current {
    color: #fff;
    background: var(--brand-red);
    border-color: var(--brand-red);
    font-weight: 600;
}
.wizard-progress-step.is-current .wizard-progress-index {
    background: rgba(255, 255, 255, 0.25);
    color: #fff;
}
.wizard-progress-step.is-complete {
    color: var(--brand-maroon-dark);
    background: var(--brand-maroon-soft);
    border-color: var(--brand-maroon-soft);
}
.wizard-progress-step.is-complete .wizard-progress-index {
    font-size: 0;
}
.wizard-progress-step.is-complete .wizard-progress-index::before {
    content: "OK";
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ---- Goal recap banner ---- */
.wizard-goal-recap {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
    margin: 0 0 1.25rem 0;
    padding: 0.6rem 0.9rem;
    background: var(--brand-maroon-soft);
    border-left: 3px solid var(--brand-maroon);
    border-radius: 4px;
    font-size: 0.92rem;
}
.wizard-goal-recap-eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.72rem;
    color: var(--brand-maroon-dark);
    font-weight: 600;
}
.wizard-goal-recap-label {
    color: var(--text-primary);
    font-weight: 600;
}
.wizard-goal-recap-change {
    margin-left: auto;
    color: var(--brand-red);
    font-size: 0.85rem;
    text-decoration: underline;
}

/* ---- Generic form layout ---- */
.wizard-form {
    margin-top: 1rem;
}
.form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    margin: 1rem 0;
}
@media (min-width: 720px) {
    .form-grid { grid-template-columns: 1fr 1fr; }
}
.form-row {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}
.form-row label {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.92rem;
}
.form-row input[type="text"],
.form-row input[type="number"],
.form-row input[type="date"],
.form-row input[type="tel"],
.form-row select,
.form-row textarea {
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--border-soft);
    border-radius: 4px;
    background: #fff;
    font: inherit;
    color: var(--text-primary);
}
.form-row input:focus,
.form-row select:focus,
.form-row textarea:focus {
    outline: 2px solid var(--brand-red);
    outline-offset: 1px;
    border-color: var(--brand-red);
}
.form-help {
    color: var(--text-secondary);
    font-size: 0.82rem;
    margin: 0;
}
.form-errors {
    list-style: none;
    margin: 0;
    padding: 0;
    color: var(--brand-red-dark);
    font-size: 0.85rem;
}
.form-errors li::before {
    content: "!  ";
}

.wizard-step-actions {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 0.75rem;
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border-soft);
    flex-wrap: wrap;
}
/* Wizard footer actions share one button treatment regardless of the
   underlying element (<a> or <button>). The shared .btn base class
   provides identical height, padding, radius, font, weight, border,
   hover, and focus-visible behavior for every wizard navigation
   control. */
.wizard-step-actions .btn,
.wizard-step-actions .btn-primary,
.wizard-step-actions .btn-ghost {
    min-width: 9rem;
    font-size: 0.95rem;
    padding: 0.6rem 1.4rem;
}
/* Back stays on the left; the final action (Continue / Save / Generate)
   is pushed to the right edge. */
.wizard-step-actions a:last-child,
.wizard-step-actions button:last-child {
    margin-left: auto;
}

/* ---- Alert box ---- */
.wizard-alerts {
    margin: 1rem 0;
}
.wizard-alert {
    padding: 0.7rem 0.9rem;
    border-radius: 4px;
    margin-bottom: 0.5rem;
    font-size: 0.92rem;
}
.wizard-alert-error {
    background: #fdecea;
    color: var(--brand-red-dark);
    border-left: 3px solid var(--brand-red);
}
.wizard-alert-info,
.wizard-alert-success {
    background: var(--brand-maroon-soft);
    color: var(--brand-maroon-dark);
    border-left: 3px solid var(--brand-maroon);
}
.wizard-alert-warning {
    background: #fff3cd;
    color: #856404;
    border-left: 3px solid #ffc107;
}

/* ---- Goal card grid ---- */
.goal-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.85rem;
    margin: 1rem 0;
}
@media (min-width: 640px) {
    .goal-grid { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 980px) {
    .goal-grid { grid-template-columns: 1fr 1fr 1fr; }
}
.goal-card {
    display: flex;
    align-items: stretch;
    gap: 0.5rem;
    padding: 1.1rem 1.1rem;
    background: #fff;
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    cursor: pointer;
    transition: border-color 120ms ease, box-shadow 120ms ease, background 120ms ease;
    position: relative;
}
.goal-card:hover {
    border-color: var(--brand-red);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}
.goal-card input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
.goal-card:has(input:checked) {
    border-color: var(--brand-red);
    background: var(--brand-red-soft);
    box-shadow: 0 0 0 1px var(--brand-red) inset;
}
.goal-card-body {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    flex: 1 1 auto;
}
.goal-card-title {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 1.02rem;
}
.goal-card-desc {
    color: var(--text-secondary);
    font-size: 0.88rem;
    line-height: 1.4;
}
.goal-card-arrow {
    align-self: center;
    color: var(--brand-red);
    font-size: 1.4rem;
    line-height: 1;
}

/* ---- Method card grid ---- */
.method-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
    margin: 1rem 0;
}
@media (min-width: 720px) {
    .method-grid { grid-template-columns: 1fr 1fr; }
}
.method-card {
    display: flex;
    align-items: stretch;
    gap: 0.5rem;
    padding: 0.9rem 1rem;
    background: #fff;
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    cursor: pointer;
    position: relative;
    transition: border-color 120ms ease, box-shadow 120ms ease, background 120ms ease;
}
.method-card:hover {
    border-color: var(--brand-red);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}
.method-card input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
.method-card:has(input:checked) {
    border-color: var(--brand-red);
    background: var(--brand-red-soft);
    box-shadow: 0 0 0 1px var(--brand-red) inset;
}
.method-card-body {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    flex: 1 1 auto;
}
.method-card-title {
    font-weight: 600;
    color: var(--text-primary);
}
.method-card-badge {
    align-self: flex-start;
    background: var(--brand-maroon);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
}

/* ---- Location card grid ---- */
.location-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.85rem;
    margin: 1rem 0;
}
@media (min-width: 720px) {
    .location-grid { grid-template-columns: 1fr 1fr; }
}
.location-card {
    display: flex;
    align-items: stretch;
    gap: 0.5rem;
    padding: 1.1rem 1.1rem;
    background: #fff;
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    cursor: pointer;
    position: relative;
    transition: border-color 120ms ease, box-shadow 120ms ease, background 120ms ease;
}
.location-card:hover {
    border-color: var(--brand-red);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}
/* Real radio kept in the markup for semantics, keyboard access, and
   form submission; visually hidden so no native circle shows. */
.location-card input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
/* Selected state: unmistakable brand-red treatment. */
.location-card:has(input:checked) {
    border-color: var(--brand-red);
    background: var(--brand-red-soft);
    box-shadow: 0 0 0 1px var(--brand-red) inset;
}
/* Keyboard focus: visible ring on the whole card. */
.location-card:has(input:focus-visible) {
    outline: 3px solid var(--brand-red);
    outline-offset: 2px;
}
.location-card-body {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    flex: 1 1 auto;
}
.location-card-title {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 1.02rem;
}
.location-card-desc {
    color: var(--text-secondary);
    font-size: 0.88rem;
    line-height: 1.4;
}
.location-card-arrow {
    align-self: center;
    color: var(--brand-red);
    font-size: 1.4rem;
    line-height: 1;
}
.method-reasons {
    margin: 0.5rem 0 1rem 0;
    padding: 0.6rem 0.9rem;
    background: var(--brand-maroon-soft);
    border-left: 3px solid var(--brand-maroon);
    border-radius: 4px;
    font-size: 0.88rem;
    color: var(--text-primary);
}
.method-reasons .method-reason {
    margin: 0.25rem 0;
    line-height: 1.4;
}

/* ---- Help block (method requirements) ---- */
.wizard-help-block {
    margin: 0 0 1rem 0;
    padding: 0.7rem 0.9rem;
    background: var(--surface-warm);
    border-left: 3px solid var(--brand-maroon);
    border-radius: 4px;
    color: var(--text-primary);
}
.wizard-help-block h2 {
    margin: 0 0 0.35rem 0;
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--brand-maroon-dark);
}
.wizard-help-block p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* ---- Review cards ---- */
.review-card {
    background: #fff;
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    padding: 1rem 1.1rem;
    margin: 0 0 1rem 0;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}
.review-card h2 {
    margin: 0 0 0.5rem 0;
    font-size: 1.05rem;
    color: var(--brand-maroon-dark);
    border-bottom: 1px solid var(--border-soft);
    padding-bottom: 0.4rem;
}
.review-card h3 {
    margin: 0.6rem 0 0.3rem 0;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
}
.review-card p {
    margin: 0.25rem 0;
    color: var(--text-primary);
    font-size: 0.92rem;
}
.review-list {
    list-style: disc;
    margin: 0.4rem 0 0.4rem 1.4rem;
    padding: 0;
    color: var(--text-primary);
}
.review-pre {
    background: var(--surface-muted);
    padding: 0.5rem 0.7rem;
    border-radius: 4px;
    font-size: 0.85rem;
    white-space: pre-wrap;
    margin: 0.25rem 0;
}

/* ---- Print ---- */
@media print {
    .wizard-progress,
    .wizard-step-actions,
    .wizard-goal-recap,
    .method-reasons,
    .wizard-help-block {
        display: none !important;
    }
}

/* ============================================================
   Recruitment / Qualifier Questionnaire polish
   (beta UI pass — recruitment journey)
   Shared layout & spacing only; no behavior changes.
   ============================================================ */

/* Light-context ghost button: outline stays visible on hover/focus
   instead of turning white-on-white on light cards. */
.btn-ghost {
    color: var(--text-secondary);
    border-color: var(--border-mid);
    background: transparent;
}
.btn-ghost:hover {
    color: var(--brand-red-dark);
    border-color: var(--brand-red);
    background: var(--brand-red-soft);
    text-decoration: none;
}
.btn-ghost:active { color: var(--brand-red-dark); border-color: var(--brand-red); }
.btn-ghost:visited { color: var(--text-secondary); }

/* Muted helper note text (matches the .form-help treatment). */
.field-hint {
    color: var(--text-secondary);
    font-size: 0.85rem;
    line-height: 1.45;
    margin: 0.2rem 0 0.5rem 0;
}

/* Inline checkbox option rows, grouped logically. */
.check-label {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9rem;
    cursor: pointer;
    user-select: none;
    margin: 0.25rem 1.25rem 0.25rem 0;
    white-space: nowrap;
}
.check-label input[type="checkbox"] {
    accent-color: var(--brand-red);
    width: 1rem;
    height: 1rem;
    cursor: pointer;
}

/* Vertical section within a card, separated by a hairline. */
.form-section {
    margin-top: 1.1rem;
}
.form-section + .form-section {
    border-top: 1px solid var(--border-soft);
    padding-top: 1.25rem;
}

/* Panelist edit: a field that spans the full form-grid width. */
.form-row--full {
    grid-column: 1 / -1;
}

/* Panelist edit: compact responsive checkbox grid for allergen choices. */
.allergen-grid {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
    gap: 0.35rem 1rem;
}
.allergen-grid label {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.9rem;
    cursor: pointer;
    white-space: normal;
}
.allergen-grid input[type="checkbox"] {
    accent-color: var(--brand-red);
    width: 1rem;
    height: 1rem;
    cursor: pointer;
}

/* ---- Questionnaire details ---- */
.qualifier-details .form-row textarea {
    min-height: 4.5rem;
    line-height: 1.4;
}
.qualifier-save-row {
    margin-top: 1.25rem;
}

/* ---- Qualifier question forms ---- */
.qualifier-prompt { grid-column: 1 / -1; }
.qualifier-type { align-self: end; }
.qualifier-options {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem 0.5rem;
    margin: 0.75rem 0 0.75rem 0;
}
.qualifier-actions {
    margin-top: 1rem;
}

/* ---- Existing question cards ---- */
.question-card {
    background: var(--surface-page);
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    padding: 1rem 1.1rem;
    margin-top: 1rem;
}
.question-head {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}
.question-head h3 { margin: 0; font-size: 1rem; color: var(--text-primary); }
.question-kind {
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* ---- Choices subsection ---- */
.question-choices {
    margin-top: 0.9rem;
    background: var(--surface-card);
    border: 1px solid var(--border-soft);
    border-radius: 6px;
    padding: 0.75rem 0.9rem;
}
.question-choices h4 {
    margin: 0 0 0.5rem 0;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
}
.choice-list { list-style: none; margin: 0 0 0.6rem 0; padding: 0; }
.choice-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    padding: 0.3rem 0;
    border-bottom: 1px dashed var(--border-soft);
}
.choice-item:last-child { border-bottom: none; }
.choice-item input[type="text"],
.choice-add input[type="text"] {
    flex: 1 1 220px;
    min-width: 0;
}
.choice-add {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* ---- Question action buttons (visible on hover / focus) ---- */
.question-actions {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
    margin-top: 0.85rem;
    opacity: 0;
    transition: opacity 0.15s ease;
}
.question-card:hover .question-actions,
.question-actions:focus-within { opacity: 1; }

/* ---- Rules ---- */
.rule-list { list-style: none; margin: 0.5rem 0 0.75rem 0; padding: 0; }
.rule-list li {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    padding: 0.5rem 0;
    border-bottom: 1px dashed var(--border-soft);
}
.rule-list li:last-child { border-bottom: none; }
.rule-summary {
    flex: 1 1 auto;
    color: var(--text-primary);
    font-size: 0.92rem;
}

/* Add-rule builder: a readable sentence broken into a grid. */
.rule-builder { max-width: 820px; }
.rule-builder .rule-sentence {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0.6rem 0.9rem;
    align-items: stretch;
    margin-top: 0.6rem;
}
@media (min-width: 720px) {
    .rule-builder .rule-sentence {
        grid-template-columns: auto minmax(0, 1fr) auto minmax(0, 1.4fr);
    }
}
.rule-builder .rule-field {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}
.rule-builder .rule-word {
    font-weight: 700;
    color: var(--brand-maroon);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.78rem;
    align-self: end;
    padding-bottom: 0.5rem;
}
.rule-builder label {
    font-weight: 600;
    font-size: 0.88rem;
    color: var(--text-primary);
}
.rule-builder select,
.rule-builder input[type="number"] {
    padding: 0.5rem 0.6rem;
    border: 1px solid var(--border-mid);
    border-radius: 4px;
    background: #fff;
    font: inherit;
    color: var(--text-primary);
    width: 100%;
}
.rule-builder .rule-actions { margin-top: 1rem; }

.no-questions-note {
    background: var(--surface-warm);
    border: 1px solid var(--border-soft);
    border-radius: 6px;
    padding: 0.9rem 1rem;
    color: var(--text-secondary);
    font-size: 0.92rem;
    margin: 0.5rem 0 0.5rem 0;
}

/* ---- Campaign monitor: horizontal, wrapping action row ---- */
.campaign-actions {
    margin-top: 1rem;
}
.campaign-actions .inline-form { display: inline-block; }

/* ---- Recruit Participants: read-only audience note ---- */
.info-note {
    color: var(--text-primary);
    font-size: 0.95rem;
    margin: 0.15rem 0 0.25rem 0;
    padding: 0.5rem 0.7rem;
    background: var(--surface-page);
    border: 1px solid var(--border-soft);
    border-radius: 6px;
}

/* Field label shown above a read-only value (no control). */
.field-label {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.92rem;
}

/* ---- Qualifier rule builder: clean vertical rows ---- */
.rule-row {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    margin: 0.9rem 0 0 0;
}
.rule-row--split {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0.9rem;
    align-items: start;
}
@media (min-width: 720px) {
    .rule-row--split {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    }
}
.rule-field {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}
.rule-step {
    font-weight: 700;
    color: var(--brand-maroon);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.76rem;
}
.rule-builder label {
    font-weight: 600;
    font-size: 0.88rem;
    color: var(--text-primary);
}
.rule-builder select,
.rule-builder input[type="number"] {
    width: 100%;
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--border-mid);
    border-radius: 4px;
    background: #fff;
    font: inherit;
    color: var(--text-primary);
}
.rule-builder #rule-choice-multi {
    min-height: 4.5rem;
}

/* Essential editing actions are always visible (no hover-only reveal). */
.question-actions { opacity: 1; }

/* The [hidden] attribute must win over display:flex for rule fields so the
   JS can hide the Condition selector for SINGLE questions. */
.rule-field[hidden],
#rule-target-wrap[hidden] { display: none !important; }

/* ============================================================
   Shared button system — beta consistency pass
   ------------------------------------------------------------
   Primary/secondary/tertiary (ghost) buttons share one set of
   typography + dimensions; only hierarchy color differs.
   .btn-sm is the compact table-row/action variant and keeps the
   same typography conventions. Higher-specificity contexts such as
   the topbar (.app-topbar .btn-ghost) and wizard actions
   (.wizard-step-actions .btn-ghost) override min-width/padding as
   they need, and are unaffected by these base rules.
   ============================================================ */

/* Standard button scale (all variants share these). */
.btn {
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.2;
    padding: 0.6rem 1.4rem;
    min-height: 2.5rem;
    border-radius: 6px;
}

/* Tertiary / outlined button: inherit the standard scale; the base
   .btn-ghost rule in this file forced a smaller size, so re-align it. */
.btn-ghost {
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.2;
    padding: 0.6rem 1.4rem;
    min-height: 2.5rem;
    border-radius: 6px;
}

/* Compact button for table rows / inline actions (e.g. Copy Signup
   Link, Monitor, Save/Delete on choice & rule rows). Same typography
   conventions as the standard button, reduced only in padding/size. */
.btn-sm {
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    line-height: 1.2;
    padding: 0.35rem 0.7rem;
    min-height: 2rem;
    border-radius: 6px;
}

/* Stable hover / focus: dimensions and typography never change,
   text/background never disappear, and keyboard focus stays visible. */
.btn,
.btn-primary,
.btn-secondary,
.btn-ghost,
.btn-sm {
    transition: background-color 0.15s ease, color 0.15s ease,
                border-color 0.15s ease;
}

/* ---- Panelist join consent group ---- */
.consent-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin: 1.1rem 0 0.3rem 0;
}
.consent-label {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9rem;
    margin-top: 0.4rem;
}
.consent-label:first-child { margin-top: 0; }
/* Checkbox aligned to the top of the label text, not centered. */
.check-label--top {
    align-items: flex-start;
    white-space: normal;
    margin: 0;
    max-width: 46rem;
}
.check-label--top input[type="checkbox"] {
    margin-top: 0.1rem;
    flex-shrink: 0;
}
.check-text {
    display: inline;
    color: var(--text-primary);
    font-weight: 500;
}
.consent-group .field-hint {
    margin: 0 0 0 1.45rem;
    color: var(--text-secondary);
}

/* Panelist join: subdued explanatory note below DOB/Gender.
   Subdued informational text (not an error/warning). */
.form-note {
    color: var(--text-secondary);
    font-size: 0.86rem;
    line-height: 1.5;
    margin: 0.75rem 0 0.25rem 0;
    max-width: 46rem;
}

/* Join form: the "Why we ask" note spans the full form width beside the
   two-column grid (not squashed into one column next to City). */
.form-note--full {
    grid-column: 1 / -1;
    width: 100%;
}

/* Form field validation error text (used across the app; was missing a rule). */
.field-error {
    display: block;
    color: var(--status-error);
    font-size: 0.85rem;
    font-weight: 600;
    margin-top: 0.3rem;
}

/* A checkbox row that failed validation: distinct but keeps label readable. */
.check-label.is-invalid .check-text {
    color: var(--status-error);
}
.check-label.is-invalid input[type="checkbox"] {
    outline: 2px solid var(--status-error);
    outline-offset: 1px;
}

/* Inline consent validation error beneath the required-consent control. */
.consent-error {
    margin: 0.15rem 0 0 1.45rem;
}
.consent-error .field-error {
    margin-top: 0;
}

/* Rank-order participant ballot: status/hint text */
.rank-status {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin: 0.5rem 0;
}
.rank-status-ok { color: var(--status-complete); font-weight: 600; }
.rank-status-warn { color: var(--status-warning); font-weight: 600; }

/* ============================================================
   Rank Order ballot — two-column drag-and-drop layout
   Matches the DOM/JS contract in taste_step.html:
   .rank-layout (grid) -> .rank-source + .rank-slots
   .rank-samples > .rank-card[data-serving-pk] draggable chips
   .rank-slots-container > .rank-slot[data-rank] drop zones
   ============================================================ */
.rank-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    align-items: start;
}
@media (max-width: 640px) {
    .rank-layout { grid-template-columns: 1fr; }
}

/* Left column: available samples */
.rank-source {
    background: var(--surface-card);
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    padding: 1rem;
}
.rank-source h4,
.rank-slots h4 {
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    margin: 0 0 0.6rem 0;
}
.rank-samples {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    min-height: 3rem;
}

/* Draggable sample card/chip (only blind codes shown) */
.rank-card {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 3.2rem;
    min-height: 3rem;
    padding: 0.5rem 0.9rem;
    border: 1.5px solid var(--border-mid);
    border-radius: 8px;
    background: var(--surface-card);
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 700;
    cursor: grab;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    user-select: none;
}
.rank-card[aria-grabbed="true"],
.rank-card.dragging {
    cursor: grabbing;
    opacity: 0.6;
}
.rank-card.rank-selected {
    border-color: var(--brand-maroon);
    background: var(--brand-red-soft);
    box-shadow: 0 0 0 2px var(--brand-maroon);
}
.rank-card-code {
    color: #fff;
    font-weight: 700;
}

/* Right column: ranking drop zones */
.rank-slots {
    background: var(--surface-card);
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    padding: 1rem;
}
.rank-slots-container {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}
.rank-slot {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 2.6rem;
    border: 1.5px dashed var(--border-mid);
    border-radius: 8px;
    background: var(--surface-warm);
    padding: 0.5rem 0.8rem;
    cursor: pointer;
}
.rank-slot.rank-slot-filled {
    border-style: solid;
    background: var(--surface-page);
}
.rank-slot.rank-drag-over {
    border-color: var(--brand-maroon);
    background: var(--brand-red-soft);
    box-shadow: 0 0 0 2px var(--brand-maroon);
}
.rank-slot-number {
    font-weight: 700;
    color: var(--text-primary);
    min-width: 1.2rem;
}
.rank-slot-label {
    color: var(--text-secondary);
    font-size: 0.85rem;
}
.rank-slot-code {
    color: #fff;
    font-weight: 700;
    background: var(--charcoal);
    font-family: monospace;
    padding: 0.1rem 0.5rem;
    border-radius: 4px;
}
.rank-slot .taste-rank-placeholder {
    color: var(--text-muted);
    font-size: 0.85rem;
}
/* Disabled button state (e.g. rank-ballot Finish before ranking is complete):
   muted, non-emphasised, no active hover. */
.btn:disabled,
.btn[disabled] {
    background: #e0e0e0;
    color: #8c8c8c;
    border-color: #e0e0e0;
    cursor: not-allowed;
    opacity: 1;
    pointer-events: none;
    box-shadow: none;
}
.btn:disabled:hover,
.btn:disabled:focus,
.btn[disabled]:hover,
.btn[disabled]:focus {
    background: #e0e0e0;
    color: #8c8c8c;
    box-shadow: none;
}
/* ===================================================================
   At-Home participant survey & Take-Home sheet (Batch 5)
   =================================================================== */

/* ---- At-Home start screen ---- */
.athome-start { text-align: center; max-width: 540px; margin: 0 auto; }
.athome-start-title { font-size: 1.5rem; margin: 0 0 0.5rem; }
.athome-instructions { background: var(--white); border: 1px solid var(--border-soft); border-radius: 8px; padding: 1rem; margin: 1rem 0; text-align: left; }
.athome-instructions p { margin: 0 0 0.5rem; }

/* ---- Sample heading ---- */
.athome-sample-head { text-align: center; margin-bottom: 1.25rem; }
.athome-code-badge { font-size: 2rem; font-weight: 800; letter-spacing: 0.1em; color: var(--charcoal); background: var(--white); border: 3px solid var(--charcoal); border-radius: 12px; display: inline-block; padding: 0.5rem 1.5rem; margin-bottom: 0.4rem; }
.athome-progress { font-size: 0.9rem; color: var(--text-muted); margin: 0; }

/* ---- At-Home step errors ---- */
.athome-error { background: #fff0f0; border: 1px solid var(--brand-red); color: var(--charcoal); border-radius: 8px; padding: 0.75rem 1rem; margin-bottom: 1rem; }

/* ---- At-Home question list ---- */
.athome-questions { list-style: none; padding: 0; margin: 0; }
.athome-question { background: var(--white); border: 1px solid var(--border-soft); border-radius: 10px; padding: 1.25rem; margin-bottom: 1rem; }
.athome-q-text { font-weight: 600; margin-bottom: 0.75rem; }
.athome-optional { font-weight: 400; color: var(--text-muted); font-size: 0.9rem; }
.athome-select { width: 100%; padding: 0.6rem; border: 1px solid var(--border-soft); border-radius: 6px; font-size: 1rem; }
/* ---- Hedonic radio-button scale ---- */
.athome-scale { border: none; padding: 0; margin: 0; }
.athome-scale .visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.athome-scale-options { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 0.2rem; align-items: start; width: 100%; margin-bottom: 0.25rem; }
.athome-scale-opt { display: flex; flex-direction: column; align-items: center; gap: 0.2rem; cursor: pointer; min-width: 0; }
.athome-scale-input { width: 1.75rem; height: 1.75rem; cursor: pointer; accent-color: var(--brand-red); }
.athome-scale-label { font-size: 0.65rem; color: var(--text-muted); text-align: center; width: 100%; max-width: none; overflow-wrap: break-word; word-break: normal; line-height: 1.2; }
.athome-scale-opt input:checked + .athome-scale-label { color: var(--charcoal); font-weight: 700; }
@media (max-width: 600px) {
    .athome-scale-options { overflow-x: auto; min-width: 500px; }
    .athome-scale { overflow-x: auto; }
}

/* ---- At-Home CATA ---- */
.athome-cata { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.athome-cata-opt { display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.4rem 0.7rem; border: 1px solid var(--border-soft); border-radius: 6px; background: var(--white); cursor: pointer; }
.athome-cata-opt:hover { border-color: var(--brand-red); }

/* ---- At-Home textarea ---- */
.athome-textarea { width: 100%; padding: 0.6rem; border: 1px solid var(--border-soft); border-radius: 6px; font-size: 1rem; resize: vertical; box-sizing: border-box; }
/* ---- At-Home submit ---- */
.athome-submit { margin-top: 1rem; }

/* ---- Completion screen ---- */
.athome-done { text-align: center; max-width: 480px; margin: 2rem auto; }
.athome-done-check { font-size: 3rem; color: #2a7d2a; margin-bottom: 0.5rem; }
.athome-done-title { font-size: 1.6rem; margin: 0 0 0.5rem; }
.athome-done-lede { font-size: 1.1rem; color: var(--charcoal); margin-bottom: 1rem; }
.athome-done-meta { color: var(--text-muted); font-size: 0.9rem; }
.athome-done-close { color: var(--text-muted); margin-top: 1rem; }

/* ---- Take-Home Sheet ---- */
.takehome-doc { max-width: 640px; margin: 0 auto; padding: 1.5rem; background: var(--white); border: 1px solid var(--border-soft); border-radius: 10px; }
.takehome-header { border-bottom: 3px solid var(--brand-maroon); padding-bottom: 0.75rem; margin-bottom: 1rem; }
.takehome-brand { font-size: 1.2rem; font-weight: 700; color: var(--charcoal); }
.takehome-brand-sub { font-size: 0.8rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.03em; }
.takehome-meta { display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem; margin-bottom: 1.25rem; }
.takehome-field { display: flex; flex-direction: column; gap: 0.15rem; }
.takehome-label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.03em; }
.takehome-value { font-weight: 600; color: var(--charcoal); }
.takehome-section-title { font-size: 1rem; margin: 0 0 0.75rem; border-bottom: 1px solid var(--border-soft); padding-bottom: 0.4rem; }
.takehome-order { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 0.5rem; }
.takehome-order-item { display: flex; align-items: center; gap: 0.75rem; padding: 0.5rem 0.75rem; background: var(--surface-warm); border: 2px solid var(--charcoal); border-radius: 8px; }
.takehome-order-num { width: 1.5rem; height: 1.5rem; border-radius: 50%; background: var(--charcoal); color: var(--white); display: flex; align-items: center; justify-content: center; font-size: 0.8rem; font-weight: 700; flex: 0 0 1.5rem; }
.takehome-code { font-size: 1.1rem; font-weight: 800; letter-spacing: 0.15em; }
.takehome-instruction { text-align: center; font-weight: 600; margin: 0.5rem 0 1rem; }
.takehome-notes { margin: 1rem 0; padding: 0.75rem; background: var(--surface-warm); border-radius: 6px; }
.takehome-notes h3 { margin: 0 0 0.3rem; font-size: 0.95rem; }
.takehome-start-box { text-align: center; margin: 1.25rem 0; }
.takehome-footer-info { border-top: 1px solid var(--border-soft); padding-top: 0.75rem; font-size: 0.85rem; color: var(--text-muted); }
.takehome-privacy { color: var(--brand-maroon); font-weight: 600; }
.takehome-url { word-break: break-all; margin-top: 0.5rem; }
.takehome-url-label { font-weight: 600; }
.takehome-url-value { font-family: monospace; font-size: 0.8rem; }

/* ---- Kit management table ---- */
.kit-header { margin-bottom: 1rem; }
.kit-meta { font-size: 0.9rem; color: var(--text-muted); margin: 0; }
.kit-table th { white-space: nowrap; }
.kit-status-ready { color: #1d6b3f; font-weight: 700; }
/* ---- Hedonic scale anchors ---- */
.athome-scale-anchors { display: flex; justify-content: space-between; font-size: 0.75rem; color: var(--text-muted); margin-top: 0.25rem; padding: 0 0.25rem; }
.athome-scale-left { text-align: left; max-width: 40%; }
.athome-scale-right { text-align: right; max-width: 40%; }
.kit-status-missing { color: var(--brand-red); font-weight: 600; }
.kit-status-pending { color: #b8860b; }

/* ---- Batch print for take-home sheets ---- */
@media print {
    body.batch-printing { background: #fff; }
    .batch-sheet { page-break-after: always; break-after: page; max-width: none; border: none; box-shadow: none; }
    .batch-sheet:last-child { page-break-after: avoid; }
    .batch-sheet .no-print { display: none !important; }
}