/* ==========================================================================
   BDMS - Blood Donor Management System
   Design system: neutral canvas, white surfaces, disciplined crimson accent.
   Spacing follows an 8px scale (4px half-steps for tight UI).
   ========================================================================== */

:root {
    --bg: #f8fafc;
    --surface: #ffffff;
    --surface-muted: #f8fafc;
    --border: #e2e8f0;
    --border-strong: #cbd5e1;

    --text: #0f172a;
    --text-2: #334155;
    --text-3: #64748b;
    --text-4: #94a3b8;

    --brand: #b91c1c;
    --brand-600: #dc2626;
    --brand-800: #991b1b;
    --brand-50: #fef2f2;
    --brand-100: #fee2e2;
    --brand-ring: rgba(220, 38, 38, 0.16);

    --emerald-50: #ecfdf5; --emerald-200: #a7f3d0; --emerald-600: #059669; --emerald-700: #047857;
    --amber-50: #fffbeb;   --amber-200: #fde68a;   --amber-600: #d97706;   --amber-700: #b45309;
    --rose-50: #fff1f2;    --rose-200: #fecdd3;    --rose-600: #e11d48;    --rose-700: #be123c;
    --sky-50: #eff6ff;     --sky-200: #bfdbfe;     --sky-600: #2563eb;     --sky-700: #1d4ed8;
    --slate-50: #f8fafc;   --slate-100: #f1f5f9;   --slate-200: #e2e8f0;

    --radius-sm: 6px;
    --radius: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;

    --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 3px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.05);
    --shadow-lg: 0 24px 48px -12px rgba(15, 23, 42, 0.25);

    --sidebar-w: 264px;
    --topbar-h: 64px;

    --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.55;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4 { margin: 0; color: var(--text); font-weight: 600; letter-spacing: -0.01em; }
p { margin: 0; }

a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-800); }

button, input, select, textarea { font: inherit; color: inherit; }

:focus-visible { outline: 2px solid var(--brand-600); outline-offset: 2px; }

/* Form fields signal focus with a border colour change only: no outline, ring or glow. */
input:focus, select:focus, textarea:focus,
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; box-shadow: none; }

.icon { width: 18px; height: 18px; flex-shrink: 0; }
.icon-sm { width: 16px; height: 16px; }
.muted { color: var(--text-3); }
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }
.strong { font-weight: 600; color: var(--text); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.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;
}

/* ==========================================================================
   App shell
   ========================================================================== */

.app-shell { min-height: 100vh; }

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 40;
    transition: transform 0.2s ease;
}

.sidebar-brand {
    height: var(--topbar-h);
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 12px; color: var(--text); }
.brand:hover { color: var(--text); }

.brand-mark {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: linear-gradient(145deg, var(--brand-600), var(--brand-800));
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px -2px rgba(185, 28, 28, 0.35);
}
.brand-mark .icon { width: 18px; height: 18px; }

.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-name { font-weight: 700; font-size: 16px; letter-spacing: 0.02em; }
.brand-sub { font-size: 11.5px; color: var(--text-3); }

.sidebar-nav-wrap {
    position: relative;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.sidebar-nav {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 16px 12px 24px;
    scrollbar-width: none;
    -ms-overflow-style: none;
    scroll-behavior: smooth;
}
.sidebar-nav::-webkit-scrollbar { display: none; }

.sidebar-scroll-btn {
    position: absolute;
    left: 0;
    right: 0;
    z-index: 2;
    height: 26px;
    border: 0;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    color: var(--text-3);
    cursor: pointer;
    transition: color 0.15s ease, background 0.15s ease;
}
.sidebar-scroll-btn[hidden] { display: none; }
.sidebar-scroll-btn .icon { width: 16px; height: 16px; }
.sidebar-scroll-btn-up {
    top: 0;
    border-bottom: 1px solid var(--border);
    box-shadow: 0 4px 10px -4px rgba(15, 23, 42, 0.08);
}
.sidebar-scroll-btn-down {
    bottom: 0;
    border-top: 1px solid var(--border);
    box-shadow: 0 -4px 10px -4px rgba(15, 23, 42, 0.08);
}
.sidebar-scroll-btn:hover { background: var(--slate-50); color: var(--brand); }
.sidebar-scroll-btn:focus-visible { outline: none; background: var(--slate-50); color: var(--brand); }

.nav-section {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-4);
    padding: 16px 12px 8px;
}
.nav-group:first-child .nav-section { padding-top: 4px; }

.nav-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    height: 38px;
    padding: 0 12px;
    margin-bottom: 2px;
    border-radius: var(--radius);
    color: var(--text-2);
    font-size: 13.5px;
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
}
.nav-link .icon { color: var(--text-4); transition: color 0.15s; }
.nav-link:hover { background: var(--slate-100); color: var(--text); }
.nav-link:hover .icon { color: var(--text-3); }
.nav-link.active { background: var(--brand-50); color: var(--brand); }
.nav-link.active .icon { color: var(--brand); }
.nav-link.active::before {
    content: "";
    position: absolute;
    left: -12px;
    top: 9px;
    bottom: 9px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--brand);
}

.sidebar-foot {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-4);
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    z-index: 30;
}

.main-area {
    margin-left: var(--sidebar-w);
    min-width: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    height: var(--topbar-h);
    padding: 0 32px;
    display: flex;
    align-items: center;
    gap: 16px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: saturate(180%) blur(8px);
    border-bottom: 1px solid var(--border);
}

.topbar-title {
    flex: 1;
    min-width: 0;
    font-size: 17px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-user { display: flex; align-items: center; gap: 16px; }

.user-chip { display: flex; align-items: center; gap: 12px; }
.avatar {
    width: 34px;
    height: 34px;
    border-radius: 999px;
    background: var(--slate-100);
    border: 1px solid var(--border);
    color: var(--text-2);
    font-weight: 600;
    font-size: 13px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.user-meta { display: flex; flex-direction: column; line-height: 1.25; }
.user-name { font-weight: 600; font-size: 13px; color: var(--text); max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.role-badge { font-size: 11.5px; font-weight: 500; color: var(--brand); }

.topbar-divider { width: 1px; height: 28px; background: var(--border); }

.icon-btn {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-2);
    cursor: pointer;
}
.icon-btn:hover { background: var(--slate-100); }
.nav-toggle, .sidebar-close { display: none; }

.content-wrap {
    width: 100%;
    max-width: 1440px;
    margin: 0 auto;
    padding: 32px;
}

.content-wrap > section,
.stack { display: flex; flex-direction: column; gap: 24px; }

.content-wrap > .alert { margin-bottom: 24px; }

/* ==========================================================================
   Page header & layout helpers
   ========================================================================== */

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head h2 { font-size: 20px; }
.page-head p { color: var(--text-3); margin-top: 4px; font-size: 13.5px; }

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-3);
    font-size: 13px;
    font-weight: 500;
}
.back-link:hover { color: var(--text); }

.grid { display: grid; gap: 24px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.grid-2-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.grid-1-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }
.grid-3-2 { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
.grid > * { min-width: 0; }
.align-start { align-items: start; }

/* ==========================================================================
   Cards
   ========================================================================== */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
    padding: 24px;
    min-width: 0;
}
.card-flush { padding: 0; overflow: hidden; }
.card-flush > .card-head { padding: 20px 24px 16px; margin: 0; }

.card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}
.card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    margin: 0;
    line-height: 1.4;
}
.card-sub { font-size: 13px; color: var(--text-3); margin-top: 2px; }
.card-actions { display: flex; gap: 8px; flex-shrink: 0; align-items: center; }

.card-foot {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.section-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-2);
    margin: 24px 0 12px;
}

/* ==========================================================================
   KPI stat cards
   ========================================================================== */

.kpi-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}
.kpi-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.kpi-label { font-size: 13px; font-weight: 500; color: var(--text-3); }
.kpi-value {
    font-size: 28px;
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.02em;
    line-height: 1.15;
    font-variant-numeric: tabular-nums;
}
.kpi-value.sm { font-size: 20px; }
.kpi-sub { font-size: 12.5px; color: var(--text-3); margin-top: 4px; }

.icon-chip {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.tone-brand   { background: var(--brand-50);   color: var(--brand); }
.tone-emerald { background: var(--emerald-50); color: var(--emerald-600); }
.tone-amber   { background: var(--amber-50);   color: var(--amber-600); }
.tone-sky     { background: var(--sky-50);     color: var(--sky-600); }
.tone-slate   { background: var(--slate-100);  color: var(--text-2); }

.progress-track {
    background: var(--slate-100);
    border-radius: 999px;
    height: 6px;
    overflow: hidden;
    margin-top: 12px;
}
.progress-fill {
    background: var(--brand-600);
    height: 100%;
    border-radius: 999px;
    transition: width 0.3s ease;
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 38px;
    padding: 0 16px;
    border-radius: var(--radius);
    border: 1px solid transparent;
    font-size: 13.5px;
    font-weight: 500;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
}
.btn .icon { width: 16px; height: 16px; }
.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 1px 2px rgba(185, 28, 28, 0.25); }
.btn-primary:hover { background: var(--brand-800); color: #fff; }
.btn-secondary { background: var(--surface); color: var(--text-2); border-color: var(--border-strong); box-shadow: var(--shadow-xs); }
.btn-secondary:hover { background: var(--slate-50); color: var(--text); border-color: #94a3b8; }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--slate-100); color: var(--text); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 12.5px; }
.btn-block { width: 100%; }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--brand-ring); }

.btn-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ==========================================================================
   Status badges
   ========================================================================== */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 22px;
    padding: 0 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    border: 1px solid transparent;
    background: var(--slate-100);
    color: var(--text-2);
    border-color: var(--slate-200);
}
.badge::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 999px;
    background: currentColor;
    opacity: 0.85;
}
.badge.no-dot::before { display: none; }
.badge-success { background: var(--emerald-50); color: var(--emerald-700); border-color: var(--emerald-200); }
.badge-warn    { background: var(--amber-50);   color: var(--amber-700);   border-color: var(--amber-200); }
.badge-danger  { background: var(--rose-50);    color: var(--rose-700);    border-color: var(--rose-200); }
.badge-info    { background: var(--sky-50);     color: var(--sky-700);     border-color: var(--sky-200); }
.badge-neutral { background: var(--slate-100);  color: var(--text-2);      border-color: var(--slate-200); }

.blood-type {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 24px;
    padding: 0 8px;
    border-radius: var(--radius-sm);
    background: var(--brand-50);
    color: var(--brand);
    font-weight: 600;
    font-size: 12.5px;
    border: 1px solid var(--brand-100);
}

/* ==========================================================================
   Alerts
   ========================================================================== */

.alert {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 13.5px;
    border: 1px solid transparent;
}
.alert .icon { margin-top: 1px; }
.alert-success { background: var(--emerald-50); color: var(--emerald-700); border-color: var(--emerald-200); }
.alert-danger  { background: var(--rose-50);    color: var(--rose-700);    border-color: var(--rose-200); }
.alert-info    { background: var(--sky-50);     color: var(--sky-700);     border-color: var(--sky-200); }
.alert-neutral { background: var(--surface);    color: var(--text-2);      border-color: var(--border); }
.alert-warning { background: var(--amber-50);   color: var(--amber-700);   border-color: var(--amber-200); }

/* ==========================================================================
   Forms
   ========================================================================== */

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px 20px;
}
.form-grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.form-grid .span-2 { grid-column: span 2; }
.form-grid .span-all { grid-column: 1 / -1; }

.form-group { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.form-group + .form-group { margin-top: 16px; }
.form-grid > .form-group + .form-group { margin-top: 0; }
.form-group > label,
.form-label { font-size: 13px; font-weight: 500; color: var(--text-2); }
.req { color: var(--brand-600); margin-left: 2px; }
.form-hint { font-size: 12px; color: var(--text-3); }
.form-error { font-size: 12px; color: var(--rose-700); }
.form-error:empty { display: none; }

.form-control {
    width: 100%;
    height: 40px;
    padding: 0 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font-size: 14px;
    box-shadow: var(--shadow-xs);
    transition: border-color 0.15s, box-shadow 0.15s;
}
.form-control::placeholder { color: var(--text-4); }
.form-control:hover { border-color: #94a3b8; }
.form-control:focus, .form-control:focus-visible { outline: none; border-color: var(--brand-600); box-shadow: none; }
.form-control:disabled { background-color: var(--slate-100); border-color: var(--border); color: var(--text-4); cursor: not-allowed; opacity: 0.75; }
.form-control:disabled:hover { border-color: var(--border); }
.form-group.is-disabled > label { color: var(--text-4); }
textarea.form-control { height: auto; min-height: 84px; padding: 10px 12px; line-height: 1.5; resize: vertical; }
select.form-control {
    appearance: none;
    -webkit-appearance: none;
    padding-right: 36px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    text-overflow: ellipsis;
}

.password-field, .input-action-field { position: relative; }
.password-field .form-control, .input-action-field .form-control { padding-right: 44px; }
.input-action-field.has-two-actions .form-control { padding-right: 84px; }
.input-actions {
    position: absolute;
    top: 50%;
    right: 4px;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    gap: 2px;
}
.password-toggle, .input-action-btn {
    position: absolute;
    top: 50%;
    right: 4px;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-3);
    cursor: pointer;
}
.input-actions .input-action-btn {
    position: static;
    top: auto;
    right: auto;
    transform: none;
}
.password-toggle:hover, .input-action-btn:hover:not(:disabled) { color: var(--text); }
.password-toggle:focus-visible, .input-action-btn:focus-visible { outline: none; box-shadow: none; color: var(--brand); }
.input-action-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.input-action-btn[aria-busy="true"] { opacity: 0.5; cursor: progress; }
.temp-password-input[readonly] {
    font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
    letter-spacing: 0.08em;
    background: var(--surface-subtle, #f8fafc);
    cursor: default;
}
.copy-btn span { display: inline-flex; }
.copy-btn .when-copied { display: none; }
.copy-btn[data-copied="true"] .when-idle { display: none; }
.copy-btn[data-copied="true"] .when-copied { display: inline-flex; color: #059669; }
.temp-password-banner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 14px 16px;
    margin-bottom: 18px;
    border: 1px solid #bfdbfe;
    border-radius: var(--radius-md);
    background: #eff6ff;
}
.temp-password-banner-code {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 4px 4px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: #ffffff;
    font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.08em;
}
.temp-password-banner-code .input-action-btn {
    position: static;
    transform: none;
}
.password-toggle span { display: inline-flex; }
.password-toggle .when-shown,
.password-toggle[aria-pressed="true"] .when-hidden { display: none; }
.password-toggle[aria-pressed="true"] .when-shown { display: inline-flex; }

.form-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}
.form-actions.split { justify-content: space-between; }

.check {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 13.5px;
    color: var(--text-2);
    cursor: pointer;
    line-height: 1.5;
}
.check input[type="checkbox"],
.check input[type="radio"] {
    width: 16px;
    height: 16px;
    margin: 2px 0 0;
    accent-color: var(--brand);
    flex-shrink: 0;
}
.check-list { display: flex; flex-direction: column; gap: 12px; }
.sms-recipient-role, .sms-reason { display: block; font-size: 12px; color: var(--text-3); margin-top: 2px; }
.booking-alerts-form { display: flex; justify-content: flex-start; }
.center-admin-list .check > span { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.center-admin-list .check strong { color: var(--text); font-weight: 600; }
.check-inline { display: flex; flex-wrap: wrap; gap: 12px 24px; }

/* Filter bar */
.filter-bar {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
    padding: 16px 20px;
}
.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px 16px;
    align-items: end;
}
.filter-grid .form-group > label { font-size: 12px; color: var(--text-3); }
.filter-grid .form-control { height: 38px; font-size: 13.5px; }
.filter-actions { display: flex; gap: 8px; }
.filter-actions .btn { flex: 1; }

/* Fieldset-like sub sections */
.boxed-group {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    overflow: hidden;
}
.boxed-group + .boxed-group { margin-top: 16px; }
.boxed-group-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 20px;
    background: var(--surface-muted);
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-2);
}
.boxed-group-body { padding: 20px; }
.boxed-group.accent { border-color: var(--brand-100); }
.boxed-group.accent .boxed-group-title { background: var(--brand-50); color: var(--brand); border-color: var(--brand-100); }

/* ==========================================================================
   Screening questionnaire (yes/no pill rows)
   ========================================================================== */

.q-list { display: flex; flex-direction: column; }
.q-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 24px;
    align-items: center;
    padding: 12px 20px;
    border-bottom: 1px solid var(--slate-100);
}
.q-row:last-child { border-bottom: 0; }
.q-row:hover { background: #fcfcfd; }
.q-text { font-size: 13.5px; color: var(--text); line-height: 1.5; }
.q-control { display: flex; justify-content: flex-end; }
.q-control .form-control { width: 240px; height: 36px; font-size: 13px; }
.q-control textarea.form-control { height: auto; }
.q-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 4px; font-size: 11.5px; color: var(--text-muted, #64748b); }
.q-control:has(.field-edit) { flex-wrap: wrap; gap: 8px; align-items: flex-start; }
.q-row:has(.field-edit[open]) { grid-template-columns: 1fr; }
.q-row:has(.field-edit[open]) .q-control { justify-content: flex-start; }
.field-edit > summary { list-style: none; cursor: pointer; }
.field-edit > summary::-webkit-details-marker { display: none; }
.field-edit[open] { flex-basis: 100%; padding: 14px; border: 1px solid var(--slate-200); border-radius: 10px; background: #fff; }
.field-edit[open] > summary { margin-bottom: 12px; }
.field-edit .form-control { width: 100%; }
.field-edit form + form { margin-top: 10px; }

.pill-group {
    display: inline-flex;
    padding: 3px;
    gap: 2px;
    background: var(--slate-100);
    border: 1px solid var(--border);
    border-radius: 999px;
}
.pill-option { position: relative; cursor: pointer; }
.pill-option input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.pill-option span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 56px;
    height: 28px;
    padding: 0 14px;
    border-radius: 999px;
    font-size: 12.5px;
    font-weight: 500;
    color: var(--text-3);
    transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
.pill-option:hover span { color: var(--text); }
.pill-option input:checked + span { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(15, 23, 42, 0.12), 0 0 0 1px var(--border); }
.pill-option input:focus-visible + span { color: var(--brand); }
.pill-option input:disabled + span { cursor: default; }

/* ==========================================================================
   Workflow stepper (Parts A-E)
   ========================================================================== */

.stepper {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
    padding: 20px 8px;
    list-style: none;
    margin: 0;
}
.step {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 8px;
    padding: 0 8px;
    color: var(--text-3);
}
.step::before {
    content: "";
    position: absolute;
    top: 15px;
    right: 50%;
    width: 100%;
    height: 2px;
    background: var(--slate-200);
    z-index: 0;
}
.step:first-child::before { display: none; }
.step.done::before, .step.active::before { background: var(--emerald-600); }
.step-dot {
    position: relative;
    z-index: 1;
    width: 32px;
    height: 32px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    background: var(--surface);
    border: 2px solid var(--slate-200);
    color: var(--text-3);
}
.step-dot .icon { width: 16px; height: 16px; }
.step.done .step-dot { background: var(--emerald-600); border-color: var(--emerald-600); color: #fff; }
.step.active .step-dot { border-color: var(--brand); color: var(--brand); box-shadow: 0 0 0 4px var(--brand-ring); }
.step-part { font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-4); }
.step-label { font-size: 13px; font-weight: 500; color: var(--text-2); line-height: 1.35; }
.step.active .step-label { color: var(--brand); }
.step a { color: inherit; display: contents; }

.part-head { display: flex; align-items: flex-start; gap: 16px; }
.part-tag {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--slate-100);
    color: var(--text-2);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
}
.part-tag.done { background: var(--emerald-50); color: var(--emerald-700); }

.visit-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}
.visit-summary .who { display: flex; align-items: center; gap: 12px; }
.visit-summary .who .name { font-weight: 600; font-size: 15px; }
.meta-list { display: flex; flex-wrap: wrap; gap: 8px 16px; color: var(--text-3); font-size: 13px; }

/* ==========================================================================
   Tables
   ========================================================================== */

.table-wrap {
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.card-flush .table-wrap { border: 0; border-top: 1px solid var(--border); border-radius: 0; }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--slate-100);
    white-space: nowrap;
    vertical-align: middle;
}
th {
    background: var(--surface-muted);
    color: var(--text-3);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.02em;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background 0.12s; }
tbody tr:hover td { background: #fbfcfe; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.wrap { white-space: normal; min-width: 280px; max-width: 520px; }
td.actions { text-align: right; width: 1%; }
td.actions .inline-form { display: inline-block; margin-left: 6px; }
td.actions:has(.inline-form) { white-space: nowrap; }
tr.row-muted td { color: var(--text-3); }
tr.row-muted td .strong { color: var(--text-2); }
.center-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.center-stats div { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.center-stats strong { display: block; font-size: 20px; color: var(--text); }
.center-stats span { font-size: 12px; color: var(--text-3); }
@media (max-width: 720px) { .center-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
td .sub { display: block; font-size: 12px; color: var(--text-3); }
.empty-row td { text-align: center; color: var(--text-3); padding: 32px 16px; white-space: normal; }

/* Clickable rows that open a detail dialog */
.table-interactive tbody tr.row-link { cursor: pointer; }
.table-interactive tbody tr.row-link:hover td { background: var(--brand-50); }
.table-interactive tbody tr.row-link:focus-visible { outline: none; }
.table-interactive tbody tr.row-link:focus-visible td { background: var(--brand-50); box-shadow: inset 0 1px 0 var(--brand-100), inset 0 -1px 0 var(--brand-100); }
.table-interactive tbody tr.row-link:focus-visible td:first-child { box-shadow: inset 3px 0 0 var(--brand), inset 0 1px 0 var(--brand-100), inset 0 -1px 0 var(--brand-100); }

/* Status dots & item cells */
.donor-cell, .status-item-cell { display: flex; align-items: center; gap: 12px; }
.status-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 999px;
    flex-shrink: 0;
    background: var(--text-4);
    box-shadow: 0 0 0 3px var(--slate-100);
}
.status-dot-lg { width: 14px; height: 14px; }
.status-dot-eligible, .status-dot-active { background: var(--emerald-600); box-shadow: 0 0 0 3px var(--emerald-50); }
.status-dot-deferred { background: var(--amber-600);   box-shadow: 0 0 0 3px var(--amber-50); }
.status-dot-blocked  { background: var(--rose-600);    box-shadow: 0 0 0 3px var(--rose-50); }
.status-dot-new, .status-dot-inactive { background: var(--text-4); box-shadow: 0 0 0 3px var(--slate-100); }

.status-legend {
    list-style: none;
    margin: 10px 0 0;
    padding: 0;
    display: flex;
    flex-wrap: nowrap;
    gap: 8px 20px;
    font-size: 12.5px;
    color: var(--text-3);
}
.status-legend li { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }

/* ==========================================================================
   Settings: roles, permissions & staff users
   ========================================================================== */

.btn-danger { background: var(--rose-600); color: #fff; box-shadow: 0 1px 2px rgba(225, 29, 72, 0.25); }
.btn-danger:hover { background: var(--rose-700); color: #fff; }

.btn-row.nowrap { flex-wrap: nowrap; justify-content: flex-end; }

/* Shared confirmation popup (fragments/ui :: confirm-modal) */
.tone-rose { background: var(--rose-50); color: var(--rose-600); }
.confirm-modal { z-index: 80; }
.confirm-modal .confirm-dialog { max-width: 460px; }
.confirm-main { display: flex; align-items: flex-start; gap: 16px; padding: 24px 24px 20px; }
.confirm-copy { min-width: 0; }
.confirm-copy .modal-title { margin-bottom: 8px; }
.confirm-text { margin: 0; color: var(--text-2); font-size: 14px; line-height: 1.5; overflow-wrap: anywhere; }
.confirm-name { color: var(--text); }
.confirm-note { margin: 10px 0 0; color: var(--text-3); font-size: 13px; line-height: 1.5; }
.confirm-modal .btn:focus,
.confirm-modal .btn:focus-visible { outline: none; box-shadow: none; }
.confirm-modal .btn-secondary:focus { border-color: var(--brand-600); }
.confirm-modal .btn-danger:focus,
.confirm-modal .btn-primary:focus { border-color: #0f172a; }
.confirm-modal .btn[aria-busy="true"] { opacity: 0.7; cursor: progress; }

.role-chip {
    display: inline-flex;
    align-items: center;
    height: 22px;
    padding: 0 9px;
    margin: 2px 6px 2px 0;
    border-radius: 999px;
    background: var(--brand-50);
    border: 1px solid var(--brand-100);
    color: var(--brand);
    font-size: 12px;
    font-weight: 500;
}

.permission-modules { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.permission-module {
    margin: 0;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface-muted);
    min-width: 0;
}
.permission-module-head { padding: 0 6px; margin-left: -6px; }
.permission-module-title { font-size: 13px; font-weight: 600; color: var(--text); }
.check-all { float: right; margin-top: -26px; font-size: 12.5px; color: var(--text-3); }
.permission-list { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.permission-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius);
    background: var(--surface);
    border: 1px solid transparent;
    cursor: pointer;
}
.permission-item:hover { border-color: var(--border); }
.permission-item input { margin-top: 3px; accent-color: var(--brand); width: 16px; height: 16px; flex-shrink: 0; }
.permission-item.locked { cursor: not-allowed; opacity: 0.75; }
.permission-implies { font-style: italic; }
.no-access-card { max-width: 560px; margin: 48px auto; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.no-access-card p { margin: 0; line-height: 1.6; }
.no-access-icon { display: inline-flex; align-items: center; justify-content: center; width: 56px; height: 56px; border-radius: 50%; background: var(--sky-50); color: var(--sky-700); }
.no-access-icon svg { width: 28px; height: 28px; }
.permission-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.permission-label { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; font-size: 13.5px; font-weight: 500; color: var(--text); }
.permission-code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 11.5px;
    color: var(--text-3);
    background: var(--slate-100);
    padding: 1px 6px;
    border-radius: 4px;
}
.permission-desc { font-size: 12.5px; color: var(--text-3); }

.role-picker { margin: 20px 0 0; padding: 0; border: 0; min-width: 0; }
.role-picker[hidden] { display: none; }
.card > .role-picker:first-child { margin-top: 0; }
.role-picker legend { font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 10px; padding: 0; }
.role-options { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.role-option {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}
.role-option:hover { border-color: var(--border-strong); }
.role-option:has(input:checked) { border-color: var(--brand-600); background: var(--brand-50); }
.role-option input { margin-top: 3px; accent-color: var(--brand); width: 16px; height: 16px; flex-shrink: 0; }
.role-option-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.role-option-name { font-weight: 600; font-size: 13.5px; color: var(--text); }
.role-option-desc { font-size: 12.5px; color: var(--text-3); }
.admin-note { margin-top: 16px; }
.fieldset-plain { border: 0; margin: 0; padding: 0; min-width: 0; }
.fieldset-plain:disabled .form-control,
.fieldset-plain:disabled .pill-option,
.fieldset-plain:disabled .check { opacity: 0.7; cursor: not-allowed; }
/* Multi-card forms: keep sections and the action bar apart instead of stacking flush. */
.form-stack { display: flex; flex-direction: column; gap: 24px; margin-bottom: 24px; }
.form-stack > .form-actions { margin-top: 4px; padding-bottom: 4px; }
/* ==========================================================================
   Donor registration form (NBTS guideline registration header)
   ========================================================================== */

.reg-section { border: 0; margin: 0; padding: 24px 0; min-width: 0; border-top: 1px solid var(--border); }
.reg-section:first-of-type { border-top: 0; padding-top: 4px; }
.reg-legend {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0;
    margin-bottom: 16px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}
.reg-step {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 999px;
    background: var(--brand-50, var(--rose-50));
    color: var(--brand-600);
    font-size: 12px;
    font-weight: 600;
}
.reg-consent .check-list { gap: 10px; }
.form-group > .label-like { margin-bottom: 0; }
.form-control.is-invalid { border-color: var(--rose-500, var(--rose-700)); }

.choice-group { display: flex; flex-wrap: wrap; gap: 8px; }
.choice { position: relative; cursor: pointer; }
.choice input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.choice span {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    padding: 6px 14px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface);
    font-size: 13px;
    color: var(--text-2);
    transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.choice:hover span { border-color: var(--text-3); color: var(--text); }
.choice input:checked + span { border-color: var(--brand-600); background: var(--rose-50); color: var(--text); font-weight: 500; }
.choice input:focus-visible + span { outline: 2px solid var(--brand-600); outline-offset: 2px; }
.choice input:disabled + span { opacity: 0.6; cursor: not-allowed; }

.member-banner { align-items: flex-start; }
.member-banner strong { display: block; margin-bottom: 2px; }

.signup-steps {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 8px 20px;
    margin: 0 0 24px;
    padding: 0;
    font-size: 12.5px;
    color: var(--text-3);
}
.signup-steps li { display: flex; align-items: center; gap: 8px; }
.signup-steps .step-no {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 999px;
    border: 1px solid var(--border-strong);
    font-weight: 600;
}
.signup-steps li.is-current { color: var(--text); font-weight: 500; }
.signup-steps li.is-current .step-no { background: var(--brand-600); border-color: var(--brand-600); color: #fff; }

@media (max-width: 639px) {
    .form-grid .span-2 { grid-column: 1 / -1; }
}

.readonly-note {
    margin-top: 20px;
    padding: 10px 14px;
    border-radius: var(--radius);
    background: var(--slate-100);
    color: var(--text-3);
    font-size: 13px;
}
.label-like { display: block; font-size: 13px; font-weight: 500; color: var(--text-2); margin-bottom: 6px; }
.switch-row { height: 40px; align-items: center; }

/* ==========================================================================
   Modal dialog
   ========================================================================== */

body.modal-open { overflow: hidden; }
.modal {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, 0.5); }
.modal-dialog {
    position: relative;
    width: 100%;
    max-width: 560px;
    max-height: calc(100vh - 48px);
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}
.modal-dialog:focus { outline: none; }
.modal-dialog.modal-lg { max-width: 860px; }
.modal-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}
.modal-title-wrap { display: flex; align-items: center; gap: 14px; min-width: 0; }
.modal-title { font-size: 18px; letter-spacing: -0.01em; margin-bottom: 4px; }
.modal-close { flex-shrink: 0; }
.modal-body { padding: 4px 24px 20px; overflow-y: auto; flex: 1; min-height: 0; }
.modal-foot {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 14px 24px;
    border-top: 1px solid var(--border);
    background: var(--surface-muted);
}
.modal-loading { padding: 48px 24px; text-align: center; color: var(--text-3); }
.modal-error { margin: 20px 24px; }
.modal [data-modal-state][hidden] { display: none; }
.modal [data-modal-state="ready"]:not([hidden]) { display: flex; flex-direction: column; min-height: 0; flex: 1; }

/* Center collection summary modal */
.range-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.range-bar .form-group { margin: 0; min-width: 150px; }
.range-quick { display: flex; flex-wrap: wrap; gap: 6px; margin-left: auto; }
.range-error { flex-basis: 100%; margin: 0; }
.range-caption { padding: 14px 24px 0; margin: 0; font-size: 13px; color: var(--text-3); }
.age-groups { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.age-groups li { display: grid; grid-template-columns: 72px 1fr 88px; align-items: center; gap: 12px; font-size: 13px; }
.age-label { font-weight: 600; color: var(--text); }
.age-track { height: 8px; border-radius: 999px; background: var(--surface-muted); border: 1px solid var(--border); overflow: hidden; }
.age-bar { display: block; height: 100%; background: var(--brand); border-radius: 999px; }
.age-count { text-align: right; color: var(--text-3); }

.profile-highlights {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    padding: 20px 24px 0;
    flex-shrink: 0;
}
.profile-highlights.target-highlights {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    padding-bottom: 16px;
}
.target-chart-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 6px 12px;
    margin-bottom: 12px;
}
.target-chart-head .section-title { margin-bottom: 0; }
.target-chart-caption { font-size: 12.5px; color: var(--text-3); }
.target-chart-box { height: 290px; }
.target-note { margin: 12px 0 0; font-size: 13px; color: var(--text-3); }
.modal-foot-split { justify-content: space-between; align-items: center; gap: 12px; }
.modal-foot-note { font-size: 12.5px; color: var(--text-3); }
.highlight {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 14px 16px;
    background: var(--surface-muted);
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}
.highlight-label { font-size: 12px; font-weight: 500; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.06em; }
.highlight-value { font-size: 17px; font-weight: 600; color: var(--text); letter-spacing: -0.01em; }
.highlight-sub { font-size: 12.5px; color: var(--text-3); min-height: 1em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Tabs */
.tabs {
    display: flex;
    gap: 4px;
    padding: 16px 24px 0;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    scrollbar-width: none;
    flex-shrink: 0;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
    position: relative;
    border: 0;
    background: transparent;
    padding: 10px 12px 12px;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--text-3);
    cursor: pointer;
    white-space: nowrap;
    border-radius: var(--radius) var(--radius) 0 0;
}
.tab:hover { color: var(--text); background: var(--slate-50); }
.tab[aria-selected="true"] { color: var(--brand); }
.tab[aria-selected="true"]::after {
    content: "";
    position: absolute;
    left: 10px;
    right: 10px;
    bottom: -1px;
    height: 2px;
    border-radius: 2px;
    background: var(--brand);
}
.tab:focus-visible { outline: none; color: var(--brand); background: var(--brand-50); }
.tab-panel { padding-top: 8px; }
.tab-panel:focus-visible { outline: none; }

/* Donor Check-In tabbed card */
.checkin-card > .card-head { padding-bottom: 12px; }
.checkin-tabs { padding-top: 0; }
.checkin-tabs .tab { display: inline-flex; align-items: center; gap: 8px; }
.checkin-tabs .tab .icon { width: 15px; height: 15px; }
.checkin-panel { padding: 24px; }
.checkin-card > .card-head + .checkin-panel { border-top: 1px solid var(--border); }
.checkin-panel .reg-section { padding: 20px 0; }
.checkin-panel .reg-section:first-of-type { padding-top: 0; }
.checkin-panel .card-foot { margin-top: 4px; padding-top: 20px; }
.checkin-hint { font-size: 12.5px; color: var(--text-3); }
.tab-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--slate-100);
    color: var(--text-3);
    font-size: 11.5px;
    font-weight: 600;
}
.tab[aria-selected="true"] .tab-count { background: var(--brand-50); color: var(--brand); }
.panel-caption {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px 16px;
    flex-wrap: wrap;
    padding: 14px 24px;
    background: var(--surface-muted);
    border-bottom: 1px solid var(--border);
}
.panel-caption-title { font-size: 13.5px; font-weight: 600; color: var(--text); }
.panel-caption-sub { font-size: 12.5px; color: var(--text-3); }
.tab-panel-flush .table-wrap { border-top: 0; }
.consent-box {
    padding: 16px 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface-muted);
}
.centers-grid {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px 16px;
}
.center-tile {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    font-size: 13.5px;
}
.center-tile-body { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.center-tile-body .strong, .center-tile-body .sub { overflow-wrap: anywhere; }
.center-tile-name { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.nearest-badge {
    display: inline-flex; align-items: center; height: 20px; padding: 0 8px;
    border-radius: 999px; background: var(--emerald-50); color: var(--emerald-700);
    font-size: 11.5px; font-weight: 600;
}
.nearest-badge[hidden] { display: none; }
.center-distance { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.center-distance.is-unknown { font-weight: 500; color: var(--text-3); }
.center-directions { flex-shrink: 0; align-self: center; }
.center-directions:focus, .center-directions:focus-visible,
.nearby-tools .btn:focus, .nearby-tools .btn:focus-visible { outline: none; box-shadow: none; border-color: var(--brand-600); }
.nearby-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-bottom: 14px; }
.nearby-status { margin: 0; flex: 1; min-width: 220px; font-size: 13px; color: var(--text-3); }
.nearby-status[data-tone="error"] { color: var(--rose-700); }
.nearby-status[data-tone="ok"] { color: var(--text-2); }
.nearby-note { margin: 12px 0 0; font-size: 12.5px; color: var(--text-3); }
.nearby-empty { margin: 0; }
@media (max-width: 639px) {
    .center-tile { flex-wrap: wrap; }
    .center-directions { flex-basis: 100%; justify-content: center; }
    .nearby-tools .btn { width: 100%; justify-content: center; }
}

/* Definition lists (profile details) */
.dl { display: grid; grid-template-columns: 170px minmax(0, 1fr); margin: 0; }
.dl dt, .dl dd { padding: 12px 0; border-bottom: 1px solid var(--slate-100); margin: 0; font-size: 13.5px; }
.dl dt { color: var(--text-3); }
.dl dd { color: var(--text); font-weight: 500; }
.dl dt:last-of-type, .dl dd:last-of-type { border-bottom: 0; }

/* Milestones */
.milestones { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 16px; }
.milestones[data-count="1"] { grid-template-columns: minmax(0, 1fr); }
.milestones[data-count="2"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.milestones[data-count="3"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.milestones[data-count="4"] { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.milestone {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
    background: var(--surface);
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.milestone.earned { border-color: var(--emerald-200); background: linear-gradient(180deg, var(--emerald-50), #fff 70%); }
.milestone-count { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; }
.milestone-count small { font-size: 12px; font-weight: 500; color: var(--text-3); margin-left: 4px; }
.milestone-title { font-size: 13px; font-weight: 600; color: var(--text); }
.milestone-desc { font-size: 12.5px; color: var(--text-3); line-height: 1.45; flex: 1; }

.list-plain { list-style: none; padding: 0; margin: 0; }
.list-plain li { display: flex; align-items: flex-start; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--slate-100); font-size: 13.5px; }
.list-plain li:last-child { border-bottom: 0; }

.divider { border: 0; border-top: 1px solid var(--border); margin: 24px 0; }

/* Charts */
.chart-box { position: relative; height: 300px; width: 100%; }
.chart-box.sm { height: 280px; }
.chart-box.chart-box-tall { height: 340px; }
.chart-box canvas { display: block; max-width: 100%; }

/* ==========================================================================
   Auth pages
   ========================================================================== */

.auth-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 24px;
    padding: 48px 24px;
    background:
        radial-gradient(1200px 600px at 50% -10%, #ffffff 0%, rgba(255, 255, 255, 0) 60%),
        linear-gradient(180deg, #f8fafc 0%, #eef2f6 100%);
}
.auth-foot { font-size: 12.5px; color: var(--text-3); text-align: center; }

/* Dark crimson sign-in card */
.auth-card-dark {
    position: relative;
    width: 100%;
    max-width: 440px;
    padding: 40px;
    border-radius: 20px;
    color: #e2e8f0;
    background:
        radial-gradient(420px 240px at 100% 0%, rgba(220, 38, 38, 0.28) 0%, rgba(220, 38, 38, 0) 70%),
        linear-gradient(150deg, #0f172a 0%, #1e1220 55%, #450a0a 100%);
    box-shadow: var(--shadow-lg), 0 0 0 1px rgba(15, 23, 42, 0.08);
    overflow: hidden;
}
.auth-card-dark .auth-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 12px;
    margin-bottom: 28px;
    padding-bottom: 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.auth-card-dark .auth-brand .brand-text { align-items: center; }
.auth-card-dark h1 { text-align: center; margin-bottom: 24px; }
.auth-card-dark .brand-mark { width: 40px; height: 40px; border-radius: 12px; box-shadow: 0 6px 18px -4px rgba(220, 38, 38, 0.6); }
.auth-card-dark .brand-name { color: #fff; font-size: 18px; }
.auth-card-dark .brand-sub { color: #94a3b8; font-size: 12px; }
.auth-card-dark h1 { color: #fff; font-size: 22px; font-weight: 600; letter-spacing: -0.02em; }
.auth-card-dark .auth-lead { color: #94a3b8; font-size: 13.5px; margin-top: 6px; margin-bottom: 24px; }
.auth-card-dark .form-group > label { color: #e2e8f0; }
.auth-card-dark .form-control {
    height: 44px;
    background: #ffffff;
    border-color: transparent;
    color: var(--text);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}
.auth-card-dark .form-control:hover { border-color: transparent; }
.auth-card-dark .form-control:focus,
.auth-card-dark .form-control:focus-visible { outline: none; border-color: var(--brand-600); box-shadow: none; }
.auth-card-dark .btn-primary {
    height: 44px;
    font-size: 14px;
    font-weight: 600;
    background: var(--brand-600);
    box-shadow: 0 8px 20px -6px rgba(220, 38, 38, 0.65);
}
.auth-card-dark .btn-primary:hover { background: #ef4444; }
.auth-card-dark .btn-primary:focus-visible { box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.55); }
.auth-card-dark a { color: #fca5a5; font-weight: 500; }
.auth-card-dark a:hover { color: #fecaca; }
.auth-card-dark .alert { margin-bottom: 20px; }
.auth-card-dark .alert-danger  { background: rgba(244, 63, 94, 0.14); border-color: rgba(251, 113, 133, 0.4); color: #fecdd3; }
.auth-card-dark .alert-info    { background: rgba(96, 165, 250, 0.12); border-color: rgba(147, 197, 253, 0.35); color: #dbeafe; }
.auth-card-dark .alert-success { background: rgba(16, 185, 129, 0.14); border-color: rgba(110, 231, 183, 0.4); color: #d1fae5; }
.auth-switch { margin-top: 20px; text-align: center; font-size: 13.5px; color: #94a3b8; }

/* Light card (registration, error) */
.auth-card {
    width: 100%;
    max-width: 460px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: var(--shadow-md);
    overflow: hidden;
}
.auth-card.wide { max-width: 860px; }
.auth-card-head {
    padding: 28px 40px;
    color: #e2e8f0;
    background:
        radial-gradient(420px 200px at 100% 0%, rgba(220, 38, 38, 0.28) 0%, rgba(220, 38, 38, 0) 70%),
        linear-gradient(150deg, #0f172a 0%, #1e1220 55%, #450a0a 100%);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}
.auth-card-head .brand-name { color: #fff; }
.auth-card-head .brand-sub { color: #94a3b8; }
.auth-card-head h1 { color: #fff; font-size: 20px; }
.auth-card-head p { color: #94a3b8; font-size: 13px; margin-top: 4px; }
.auth-card-body { padding: 32px 40px; }

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 1279px) {
    .grid-4, .grid-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .milestones { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .milestones[data-count="4"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-2-1, .grid-1-2, .grid-3-2 { grid-template-columns: minmax(0, 1fr); }
    .permission-modules { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 1023px) {
    .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
    body.nav-open .sidebar { transform: translateX(0); }
    body.nav-open .sidebar-backdrop { display: block; }
    .nav-toggle, .sidebar-close { display: inline-flex; }
    .main-area { margin-left: 0; }
    .topbar { padding: 0 16px; }
    .content-wrap { padding: 24px 16px; }
    .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
    .form-grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .profile-highlights.target-highlights { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .user-meta, .topbar-divider { display: none; }
    .stepper { grid-template-columns: repeat(5, minmax(120px, 1fr)); overflow-x: auto; }
}

@media (max-width: 639px) {
    .grid-4, .grid-5, .form-grid.cols-2, .form-grid.cols-3, .form-grid.cols-4 { grid-template-columns: minmax(0, 1fr); }
    .form-grid .span-2 { grid-column: auto; }
    .milestones, .milestones[data-count] { grid-template-columns: minmax(0, 1fr); }
    .q-row { grid-template-columns: minmax(0, 1fr); gap: 8px; }
    .q-control { justify-content: flex-start; }
    .auth-card-dark, .auth-card-body, .auth-card-head { padding: 28px 24px; }
    .dl { grid-template-columns: minmax(0, 1fr); }
    .status-legend { flex-wrap: wrap; }
    .profile-highlights, .profile-highlights.target-highlights { grid-template-columns: minmax(0, 1fr); }
    .modal-foot-split { flex-direction: column; align-items: stretch; }
    .modal { padding: 0; align-items: stretch; }
    .modal-dialog, .modal-dialog.modal-lg { max-height: 100vh; border-radius: 0; }
    .modal [data-modal-state="ready"]:not([hidden]) { overflow-y: auto; }
    .modal-body { overflow: visible; flex: none; }
    .profile-highlights { gap: 8px; padding: 16px 16px 0; }
    .highlight { flex-direction: row; flex-wrap: wrap; align-items: baseline; column-gap: 12px; padding: 10px 14px; }
    .highlight-label { flex-basis: 100%; }
    .highlight-value { font-size: 15px; }
    .modal-head, .modal-foot { padding-left: 16px; padding-right: 16px; }
    .tabs { padding: 12px 16px 0; }
    .checkin-tabs { padding-top: 0; }
    .checkin-panel { padding: 20px 16px; }
    .panel-caption { padding: 12px 16px; }
    .range-bar { padding: 12px 16px; }
    .range-bar .form-group { flex: 1 1 130px; }
    .range-quick { margin-left: 0; }
    .range-caption { padding: 12px 16px 0; }
    .modal-body { padding: 4px 16px 16px; }
    .dl dt { padding-bottom: 0; border-bottom: 0; }
    .btn-signout-label { display: none; }
}

/* Logs page */
.logs-table td.wrap { min-width: 200px; max-width: 420px; }
.recovery { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.recovery-days { font-size: 12.5px; font-weight: 600; color: var(--amber-700); }
.recovery .sub { max-width: 220px; white-space: normal; }
.pager {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    padding: 14px 20px;
    border-top: 1px solid var(--border);
}
.pager-info, .pager-page { font-size: 13px; color: var(--text-3); }
.restore-body { padding-top: 16px; }
.restore-body p + p { margin-top: 8px; }
/* Settings → Donor milestones */
#milestoneModal form { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.milestone-body { padding-top: 16px; }
.milestone-count-input { max-width: 200px; }
.milestone-count-cell { width: 96px; font-size: 15px; }
.milestones-empty { margin: 0; }

/* Settings → Donation eligibility */
.interval-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-top: 20px; }
.interval-field { padding: 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-muted); }
.interval-grid > .form-group + .form-group { margin-top: 0; }
.interval-field > label { font-weight: 600; color: var(--text); }
.input-with-suffix { position: relative; max-width: 180px; }
.input-with-suffix .form-control { padding-right: 68px; }
.input-with-suffix .input-suffix { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-size: 13px; color: var(--text-3); pointer-events: none; }
.interval-example { color: var(--text-2); }
.interval-changed { font-size: 12px; color: var(--text-3); }
.interval-notes { margin: 20px 0 0; padding-left: 18px; color: var(--text-2); font-size: 13px; display: grid; gap: 4px; }

/* Settings → Messaging */
.messaging-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.messaging-tab { padding: 8px 14px; font-size: 13.5px; color: var(--text-2); border-bottom: 2px solid transparent; margin-bottom: -1px; text-decoration: none; white-space: nowrap; }
.messaging-tab:hover { color: var(--text); }
.messaging-tab.active { color: var(--text); font-weight: 600; border-bottom-color: var(--brand-600); }
.messaging-tab:focus-visible { outline: none; border-bottom-color: var(--brand-600); color: var(--text); }
.messaging-enabled { margin-top: 16px; }
.messaging-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 16px; }
.messaging-grid > .form-group + .form-group { margin-top: 0; }
.messaging-grid .form-group { min-width: 0; }
.messaging-saved { display: block; font-weight: 600; color: var(--text-2); }
.messaging-clear { margin-top: 6px; font-size: 13px; }
.messaging-tools { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-end; }
.messaging-test { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.messaging-test .form-group { margin: 0; min-width: 220px; }
.messaging-save .form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
[data-provider-fields][hidden] { display: none; }
@media (max-width: 720px) {
    .messaging-grid { grid-template-columns: 1fr; }
    .messaging-test, .messaging-test .form-group { width: 100%; min-width: 0; }
}

/* Dashboard "Donors by age group" customizer */
.chart-empty {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 24px;
    text-align: center;
    font-size: 13px;
    color: var(--text-3);
    pointer-events: none;
}
.chart-empty[hidden] { display: none; }
.age-form { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.age-body { padding-top: 16px; display: flex; flex-direction: column; gap: 14px; }
.age-body > [hidden] { display: none; }
.age-body .modal-loading { padding: 32px 0; }
.alert-warning ul { margin: 0; padding-left: 18px; }
.alert-warning li + li { margin-top: 4px; }
.age-editor { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.age-editor:empty { display: none; }
.age-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 96px 96px 64px 36px;
    grid-template-areas:
        "label min max color remove"
        "swatches swatches swatches swatches swatches"
        "cerr cerr cerr cerr cerr";
    gap: 8px 12px;
    align-items: start;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
}
.age-row .form-group + .form-group { margin-top: 0; }
.age-row .form-group > label { font-size: 12px; }
.age-f-label { grid-area: label; }
.age-f-min { grid-area: min; }
.age-f-max { grid-area: max; }
.age-f-color { grid-area: color; }
.age-remove { grid-area: remove; margin-top: 24px; }
.age-remove:disabled { opacity: 0.4; cursor: not-allowed; }
.age-remove:disabled:hover { background: var(--surface); }
.age-remove:focus-visible { outline: none; border-color: var(--brand-600); }
.age-color-input {
    width: 100%;
    height: 40px;
    padding: 3px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface);
    cursor: pointer;
}
.age-color-input:focus, .age-color-input:focus-visible { outline: none; border-color: var(--brand-600); box-shadow: none; }
.age-swatches { grid-area: swatches; display: flex; flex-wrap: wrap; gap: 4px; }
.age-swatch {
    width: 26px;
    height: 26px;
    padding: 2px;
    border: 2px solid transparent;
    border-radius: 999px;
    background: var(--swatch, var(--slate-300)) content-box;
    cursor: pointer;
}
.age-swatch:hover { border-color: var(--border-strong); }
.age-swatch[aria-pressed="true"] { border-color: var(--text-2); }
.age-swatch:focus-visible { outline: none; border-color: var(--brand-600); }
.age-color-err { grid-area: cerr; }
.age-editor-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; }

@media (max-width: 639px) {
    .age-form { overflow-y: auto; }
    .age-row {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 56px;
        grid-template-areas:
            "label label remove"
            "min max color"
            "swatches swatches swatches"
            "cerr cerr cerr";
        padding: 12px;
    }
    .age-remove { justify-self: end; }
    .milestone-count-input { max-width: none; }
    .interval-grid { grid-template-columns: minmax(0, 1fr); }
    .input-with-suffix { max-width: none; }
    #milestoneModal form { overflow-y: auto; }
    [data-logs-filter] .filter-actions { grid-column: 1 / -1; }
    .pager { padding: 12px 16px; flex-direction: column; align-items: stretch; }
    .pager .btn-row { justify-content: space-between; }
    #restoreModal, .confirm-modal { align-items: center; padding: 16px; }
    #restoreModal .modal-dialog, .confirm-modal .modal-dialog { max-height: calc(100vh - 32px); border-radius: var(--radius-xl); }
    .confirm-main { padding: 20px 16px 16px; gap: 12px; }
    .confirm-modal .modal-foot .btn { flex: 1; }
}

/* Header messages bell, dropdown / drawer, inbox page and message modal */
.msg-bell { position: relative; }
.bell-btn { position: relative; width: 36px; height: 36px; }
.bell-btn svg { width: 18px; height: 18px; }
.bell-btn.has-unread { color: var(--text); }
.bell-count { position: absolute; top: -6px; right: -6px; pointer-events: none; }
.bell-badge {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
    background: var(--brand); color: #fff; font-size: 10.5px; font-weight: 700; line-height: 1;
    border: 2px solid var(--surface);
}
.bell-btn:focus, .bell-btn:focus-visible,
.msg-panel-close:focus-visible, .msg-remove:focus-visible { outline: none; box-shadow: none; border-color: var(--brand-600); }
.msg-panel {
    position: absolute; top: calc(100% + 8px); right: 0; z-index: 45;
    width: 360px; max-width: calc(100vw - 32px);
    display: flex; flex-direction: column;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg); overflow: hidden;
}
.msg-panel[hidden] { display: none; }
.msg-panel:focus { outline: none; }
.msg-panel-head { display: flex; align-items: center; gap: 8px; padding: 12px 12px 12px 16px; border-bottom: 1px solid var(--border); }
.msg-panel-title { flex: 1; font-size: 15px; font-weight: 600; margin: 0; }
.msg-panel-close { width: 32px; height: 32px; }
.msg-panel-body { max-height: 380px; overflow-y: auto; padding: 6px; display: flex; flex-direction: column; gap: 2px; }
.msg-panel-empty { padding: 28px 12px; text-align: center; color: var(--text-3); font-size: 13px; margin: 0; }
.msg-panel-foot {
    display: block; padding: 12px 16px; text-align: center; font-size: 13px; font-weight: 600;
    color: var(--brand); border-top: 1px solid var(--border); background: var(--surface-muted); text-decoration: none;
    border-left: 1px solid transparent; border-right: 1px solid transparent; border-bottom: 1px solid transparent;
}
.msg-panel-foot:hover { text-decoration: underline; }
.msg-panel-foot:focus-visible { outline: none; border-color: var(--brand-600); }
.msg-panel .btn:focus, .msg-panel .btn:focus-visible,
.message-modal .btn:focus, .message-modal .btn:focus-visible,
[data-messages-page] .btn:focus, [data-messages-page] .btn:focus-visible { outline: none; box-shadow: none; border-color: var(--brand-600); }
.message-modal .btn-primary:focus, .message-modal .btn-primary:focus-visible { border-color: #0f172a; }
.msg-item, .msg-open {
    display: flex; align-items: flex-start; gap: 10px; width: 100%; text-align: left;
    padding: 10px; border: 1px solid transparent; border-radius: var(--radius);
    background: transparent; color: inherit; font: inherit; cursor: pointer;
}
.msg-item:hover, .msg-open:hover { background: var(--surface-muted); }
.msg-item:focus, .msg-item:focus-visible, .msg-open:focus, .msg-open:focus-visible { outline: none; box-shadow: none; border-color: var(--brand-600); }
.msg-dot { flex-shrink: 0; width: 8px; height: 8px; margin-top: 6px; border-radius: 999px; background: transparent; }
.is-unread > .msg-dot, .is-unread .msg-open .msg-dot { background: var(--brand); }
.msg-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.msg-title-line { display: flex; gap: 6px; align-items: baseline; }
.msg-title { font-size: 13.5px; font-weight: 500; color: var(--text); }
.is-unread .msg-title { font-weight: 700; }
.msg-preview { font-size: 13px; color: var(--text-2); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.msg-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 12px; color: var(--text-3); }
.msg-meta .badge { font-size: 11px; }
.msg-backdrop { position: fixed; inset: 0; z-index: 65; background: rgba(15, 23, 42, 0.45); }
.msg-backdrop[hidden] { display: none; }
.msg-list { list-style: none; margin: 0; padding: 6px; display: flex; flex-direction: column; gap: 2px; }
.msg-row { display: flex; align-items: center; gap: 6px; border-bottom: 1px solid var(--border); padding-bottom: 2px; }
.msg-row:last-child { border-bottom: 0; }
.msg-row.is-unread .msg-open { background: var(--brand-50); }
.msg-row.is-unread .msg-open:hover { background: var(--brand-100); }
.msg-remove-form { margin: 0; flex-shrink: 0; }
.msg-remove { width: 32px; height: 32px; }
.msg-empty { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 40px 16px; text-align: center; color: var(--text-3); }
.msg-empty p { margin: 0; }
.msg-modal-meta { margin: 0; font-size: 12.5px; color: var(--text-3); }
.msg-body { margin: 12px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; line-height: 1.6; color: var(--text); }
.message-modal { z-index: 75; }
@media (max-width: 1023px) {
    .topbar-user { gap: 10px; }
}
@media (max-width: 639px) {
    body.msg-drawer-open { overflow: hidden; }
    body.msg-drawer-open .topbar { backdrop-filter: none; z-index: 70; }
    .msg-panel {
        position: fixed; top: 0; right: 0; bottom: 0; z-index: 70;
        width: min(100vw, 360px); max-width: 100vw; border-radius: 0; border-width: 0 0 0 1px;
    }
    .msg-panel-body { max-height: none; flex: 1; }
    .msg-panel-head { min-height: var(--topbar-h); }
    [data-messages-filter] .filter-actions { grid-column: 1 / -1; }
}

/* Page guide: header help button, highlighted stop and speech bubble */
.guide-btn svg { width: 18px; height: 18px; }
.guide-btn.is-active { color: var(--brand); background: var(--brand-50); border-color: var(--brand-600); }
.guide-btn:focus, .guide-btn:focus-visible { outline: none; box-shadow: none; border-color: var(--brand-600); }
.guide-target { border-color: var(--brand-600) !important; }
.guide-bubble {
    --guide-bg: rgba(9, 9, 11, 0.86);
    --guide-line: rgba(255, 255, 255, 0.14);
    position: fixed; top: 0; left: 0; z-index: 62;
    width: 320px; max-width: calc(100vw - 24px);
    padding: 16px 18px; background: var(--guide-bg); color: #fff;
    -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
    border: 1px solid var(--guide-line); border-radius: var(--radius-lg);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.28);
}
.guide-bubble[hidden] { display: none; }
.guide-bubble:focus { outline: none; }
/* The arrow is clipped to its outer half so the translucent fill doesn't double up over the bubble. */
.guide-arrow {
    position: absolute; width: 14px; height: 14px; background: var(--guide-bg);
    border: 1px solid var(--guide-line); transform: rotate(45deg);
}
.guide-arrow[hidden] { display: none; }
.guide-bubble[data-side="below"] .guide-arrow { top: -8px; border-right: 0; border-bottom: 0; clip-path: polygon(0 0, 100% 0, 0 100%); }
.guide-bubble[data-side="above"] .guide-arrow { bottom: -8px; border-left: 0; border-top: 0; clip-path: polygon(100% 0, 100% 100%, 0 100%); }
.guide-step { margin: 0 0 6px; font-size: 11.5px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: #fca5a5; }
.guide-title { margin: 0; font-size: 16px; font-weight: 700; line-height: 1.35; color: #fff; }
.guide-text { margin: 6px 0 16px; font-size: 13.5px; line-height: 1.6; color: rgba(255, 255, 255, 0.86); overflow-wrap: anywhere; }
.guide-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 12px; border-top: 1px solid var(--guide-line); }
.guide-bubble .btn { box-shadow: none; }
.guide-bubble .btn-secondary { background: transparent; color: #fff; border-color: rgba(255, 255, 255, 0.4); }
.guide-bubble .btn-secondary:hover { background: rgba(255, 255, 255, 0.12); color: #fff; border-color: rgba(255, 255, 255, 0.6); }
.guide-bubble .btn-primary { background: var(--brand-600); color: #fff; border-color: var(--brand-600); }
.guide-bubble .btn-primary:hover { background: var(--brand); color: #fff; border-color: var(--brand); }
.guide-bubble .btn:focus, .guide-bubble .btn:focus-visible { outline: none; box-shadow: none; border-color: #fff; }