/* =====================================================================
   iDisciple app screens on the web dashboard.
   Blends the dashboard shell (sidebar / topbar / tables) with the
   mobile app's look: Sky-blue brand, gradient headers, white cards on a
   cool canvas, recessed inputs, 14px-radius buttons.
   Colours mirror Mobile/Resources/Styles/Colors.xaml.
   ===================================================================== */
:root {
    --m-brand: #1E6FA8;
    --m-brand-dark: #0B3D5D;
    --m-brand-light: #5298CC;
    --m-brand-soft: #D6E7F2;
    --m-accent: #E8B86D;

    --m-canvas: #EEF3F9;
    --m-card: #FFFFFF;
    --m-subtle: #E2EAF2;
    --m-divider: #D9E1E9;

    --m-text-strong: #0F1419;
    --m-text: #2F3946;
    --m-muted: #5C6B80;
    --m-faint: #9AA5B5;

    --m-visitor-from: #6BB5E3; --m-visitor-to: #2C7DB5;
    --m-study-from: #95D8C8;   --m-study-to: #47A491;
    --m-board-from: #B6A7E3;   --m-board-to: #6B5BA7;
    --m-elders-from: #6EA3E3;  --m-elders-to: #3F6FB5;

    --m-success: #2F7D4F; --m-success-soft: #E0F0E7;
    --m-warning: #B67622; --m-warning-soft: #FAEDD4;
    --m-danger: #B3383A;  --m-danger-soft: #F8E0E0;
    --m-info: #1E6FA8;    --m-info-soft: #E0ECF5;
}

.m-page { position: relative; max-width: 1180px; }

/* ---------- Header ---------- */
.m-header {
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    padding: 22px 26px; margin-bottom: 20px; border-radius: 18px; color: #fff;
    background: linear-gradient(135deg, var(--m-brand-light), var(--m-brand-dark));
    box-shadow: 0 10px 24px rgba(11, 61, 93, 0.18);
}
.m-header.m-theme-visitor { background: linear-gradient(135deg, var(--m-visitor-from), var(--m-visitor-to)); }
.m-header.m-theme-study   { background: linear-gradient(135deg, var(--m-study-from), var(--m-study-to)); }
.m-header.m-theme-board   { background: linear-gradient(135deg, var(--m-board-from), var(--m-board-to)); }
.m-header.m-theme-elders  { background: linear-gradient(135deg, var(--m-elders-from), var(--m-elders-to)); }
.m-header-left { display: flex; align-items: center; gap: 14px; min-width: 0; }
.m-header h2 { font-size: 22px; font-weight: 800; letter-spacing: -0.3px; }
.m-header p { font-size: 13px; color: rgba(255,255,255,0.85); margin-top: 2px; }
.m-header-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.m-back {
    width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center;
    background: rgba(255,255,255,0.18); font-size: 18px; font-weight: 700; flex-shrink: 0;
}
.m-back:hover { background: rgba(255,255,255,0.3); }

/* ---------- Cards / sections ---------- */
.m-card { background: var(--m-card); border: 1px solid var(--m-divider); border-radius: 16px; }
.m-section { padding: 20px 22px; margin-bottom: 16px; }
.m-section-head { margin-bottom: 14px; }
.m-section-title {
    font-size: 11px; font-weight: 800; letter-spacing: 1.1px; text-transform: uppercase; color: var(--m-brand);
}
.m-section-sub { font-size: 12px; color: var(--m-muted); margin-top: 3px; }
.m-form { max-width: 860px; }
.m-two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.m-two-col-form { grid-template-columns: minmax(320px, 2fr) 3fr; }

/* ---------- Fields ---------- */
.m-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.m-grid-3 { grid-template-columns: repeat(3, 1fr); }
.m-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.m-grid .m-field { margin-bottom: 0; }
.m-field.wide { grid-column: 1 / -1; }
.m-field-label {
    font-size: 11px; font-weight: 700; letter-spacing: 0.8px; text-transform: uppercase; color: var(--m-muted);
}
.m-field-hint { font-size: 11px; color: var(--m-faint); }
.m-input {
    width: 100%; font: inherit; font-size: 14px; color: var(--m-text-strong);
    background: var(--m-subtle); border: 1.5px solid transparent; border-radius: 12px;
    padding: 12px 14px; outline: none; transition: border-color .15s, background .15s;
}
.m-input:focus { border-color: var(--m-brand); background: #fff; }
.m-input::placeholder { color: var(--m-faint); }
select.m-input { appearance: none; cursor: pointer;
    background-image: linear-gradient(45deg, transparent 50%, var(--m-muted) 50%), linear-gradient(135deg, var(--m-muted) 50%, transparent 50%);
    background-position: calc(100% - 18px) 52%, calc(100% - 13px) 52%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 34px; }
.m-textarea { min-height: 110px; resize: vertical; line-height: 1.5; }
.m-textarea-lg { min-height: 180px; }
.m-textarea-xl { min-height: 320px; }
.m-search { max-width: 360px; background: #fff; border-color: var(--m-divider); }

/* ---------- Toggle rows ---------- */
.m-toggle-row {
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    padding: 12px 0; border-bottom: 1px solid var(--m-divider); cursor: pointer; user-select: none;
}
.m-toggle-row:last-child { border-bottom: none; }
.m-toolbar .m-toggle-row { border: none; padding: 0; }
.m-toggle-title { font-weight: 600; color: var(--m-text-strong); }
.m-toggle-sub { font-size: 12px; color: var(--m-muted); margin-top: 2px; }
.m-switch { width: 46px; height: 26px; border-radius: 13px; background: var(--m-divider); position: relative; flex-shrink: 0; transition: background .2s; }
.m-switch span { position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s; }
.m-switch.on { background: var(--m-brand); }
.m-switch.on span { transform: translateX(20px); }

/* ---------- Buttons ---------- */
.m-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    font: inherit; font-weight: 700; font-size: 14px; border-radius: 14px; padding: 12px 20px;
    border: none; cursor: pointer; transition: filter .15s, background .15s; white-space: nowrap; text-decoration: none;
}
.m-btn:disabled { opacity: .6; cursor: default; }
.m-btn-primary { background: var(--m-brand); color: #fff; }
.m-btn-primary:hover:not(:disabled) { filter: brightness(1.08); }
.m-btn-subtle { background: var(--m-subtle); color: var(--m-text-strong); }
.m-btn-subtle:hover { background: var(--m-divider); }
.m-btn-success { background: var(--m-success); color: #fff; }
.m-btn-danger { background: var(--m-danger); color: #fff; }
.m-btn-danger-outline { background: transparent; color: var(--m-danger); border: 1.5px solid var(--m-danger-soft); }
.m-btn-danger-outline:hover { background: var(--m-danger-soft); }
.m-btn-ghost { background: rgba(255,255,255,0.18); color: #fff; padding: 9px 16px; border-radius: 12px; }
.m-btn-ghost:hover { background: rgba(255,255,255,0.3); }
.m-btn-sm { padding: 6px 12px; font-size: 12px; border-radius: 10px; }
.m-actions { display: flex; gap: 10px; justify-content: flex-end; align-items: center; margin-top: 14px; flex-wrap: wrap; }
.m-actions-split { justify-content: stretch; }
.m-actions-split .m-btn { flex: 1; }
.m-spacer { flex: 1; }
.m-file-btn { position: relative; overflow: hidden; }
.m-file-btn input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.m-icon-btn { border: none; background: var(--m-subtle); border-radius: 10px; width: 34px; height: 34px; cursor: pointer; font-size: 15px; }
.m-icon-btn:hover { background: var(--m-divider); }
.m-icon-btn.danger:hover { background: var(--m-danger-soft); }
.m-link { color: var(--m-brand); font-weight: 600; }

/* ---------- Toolbar / segmented ---------- */
.m-toolbar { display: flex; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 14px; flex-wrap: wrap; }
.m-segment { display: inline-flex; background: var(--m-subtle); border-radius: 12px; padding: 4px; gap: 2px; flex-wrap: wrap; }
.m-segment button { border: none; background: transparent; font: inherit; font-size: 13px; font-weight: 600; color: var(--m-muted); padding: 8px 14px; border-radius: 9px; cursor: pointer; }
.m-segment button.active { background: #fff; color: var(--m-brand); box-shadow: 0 1px 3px rgba(15,20,25,.1); }

/* ---------- Lists ---------- */
.m-list { display: flex; flex-direction: column; gap: 10px; }
.m-list-item { display: flex; align-items: center; gap: 14px; padding: 14px 18px; color: inherit; text-decoration: none; }
a.m-list-item, .m-list-item.clickable { cursor: pointer; transition: border-color .15s, transform .15s; }
a.m-list-item:hover, .m-list-item.clickable:hover { border-color: var(--m-brand-light); transform: translateY(-1px); }
.m-list-item.unread { border-left: 4px solid var(--m-brand); }
.m-list-plain { padding: 12px 0; border-bottom: 1px solid var(--m-divider); }
.m-list-plain:last-child { border-bottom: none; }
.m-list-main { flex: 1; min-width: 0; }
.m-list-title { font-weight: 700; color: var(--m-text-strong); }
.m-list-sub { font-size: 13px; color: var(--m-text); margin-top: 2px; }
.m-list-meta { font-size: 12px; color: var(--m-muted); margin-top: 4px; }
.m-list-quote { font-size: 13px; color: var(--m-muted); font-style: italic; margin-top: 4px; }
.m-list-icon { font-size: 22px; width: 42px; height: 42px; border-radius: 12px; background: var(--m-brand-soft); display: grid; place-items: center; flex-shrink: 0; }
.m-chevron { font-size: 22px; color: var(--m-faint); }
.m-admin-list { max-width: 640px; }
.m-table-card { padding: 6px 4px; overflow-x: auto; }
.m-row-link { cursor: pointer; }
.m-row-link:hover td { background: #F7FAFD; }
.m-right { text-align: right; }
.m-day-header { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: 1px; color: var(--m-brand); margin: 18px 0 8px; }
.m-event-time { width: 70px; font-weight: 800; color: var(--m-brand); font-size: 15px; flex-shrink: 0; }
.m-event-time small { display: block; font-weight: 600; color: var(--m-muted); font-size: 12px; }
.m-edit-mark { color: var(--m-faint); font-size: 18px; }

/* ---------- Chips / status / badges ---------- */
.m-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.m-chip { display: inline-block; font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: var(--m-subtle); color: var(--m-text); margin-right: 4px; }
.m-chip.info { background: var(--m-info-soft); color: var(--m-info); }
.m-chip.success { background: var(--m-success-soft); color: var(--m-success); }
.m-status { font-size: 11px; font-weight: 800; padding: 4px 10px; border-radius: 999px; background: var(--m-subtle); color: var(--m-muted); white-space: nowrap; }
.m-status-active, .m-status-approved, .m-status-confirmed, .m-status-completed, .m-status-reviewed { background: var(--m-success-soft); color: var(--m-success); }
.m-status-pending, .m-status-submitted, .m-status-paused, .m-status-tentative, .m-status-scheduled { background: var(--m-warning-soft); color: var(--m-warning); }
.m-status-rejected, .m-status-withdrew, .m-status-cancelled { background: var(--m-danger-soft); color: var(--m-danger); }
.m-status-baptised { background: var(--m-info-soft); color: var(--m-info); }
.m-badge { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--m-danger); color: #fff; font-size: 11px; font-weight: 800; }

/* ---------- Notice / busy / empty ---------- */
.m-notice { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 16px; border-radius: 12px; margin-bottom: 14px; font-weight: 600; position: sticky; top: 72px; z-index: 5; }
.m-notice-info { background: var(--m-info-soft); color: var(--m-info); }
.m-notice-success { background: var(--m-success-soft); color: var(--m-success); }
.m-notice-warning { background: var(--m-warning-soft); color: var(--m-warning); }
.m-notice-danger { background: var(--m-danger-soft); color: var(--m-danger); }
.m-notice-close { border: none; background: transparent; font-size: 20px; cursor: pointer; color: inherit; line-height: 1; }
.m-spinner { display: block; width: 26px; height: 26px; border: 3px solid var(--m-brand-soft); border-top-color: var(--m-brand); border-radius: 50%; animation: m-spin .8s linear infinite; }
@keyframes m-spin { to { transform: rotate(360deg); } }
.m-empty { padding: 28px 16px; text-align: center; color: var(--m-muted); font-size: 14px; }
.m-empty-state { padding: 40px; text-align: center; max-width: 560px; margin: 40px auto; }
.m-empty-state h3 { margin: 10px 0 8px; color: var(--m-text-strong); }
.m-empty-state p { color: var(--m-muted); margin-bottom: 18px; line-height: 1.5; }
.m-empty-icon { font-size: 38px; }
.m-banner { margin-top: 10px; padding: 10px 14px; border-radius: 10px; background: var(--m-info-soft); color: var(--m-info); font-weight: 600; font-size: 13px; }
.m-muted { color: var(--m-muted); font-size: 13px; }
.m-pre { white-space: pre-wrap; line-height: 1.55; }
.m-lead { font-size: 16px; color: var(--m-text-strong); margin-bottom: 12px; }
.m-quote { font-size: 15px; font-style: italic; color: var(--m-text); }

/* ---------- Detail lists ---------- */
.m-dl { display: grid; grid-template-columns: 170px 1fr; gap: 8px 16px; font-size: 14px; }
.m-dl dt { color: var(--m-muted); font-weight: 600; }
.m-dl dd { color: var(--m-text-strong); }
.m-check-list { list-style: none; display: flex; flex-direction: column; gap: 6px; color: var(--m-success); font-weight: 600; }
.m-timeline { list-style: none; display: flex; flex-direction: column; gap: 12px; }
.m-timeline li { padding: 12px 14px; border-left: 3px solid var(--m-brand); background: #F7FAFD; border-radius: 0 10px 10px 0; }
.m-timeline-meta { font-size: 12px; color: var(--m-muted); margin-bottom: 4px; }

/* ---------- Home tiles ---------- */
.m-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.m-tile {
    position: relative; display: flex; flex-direction: column; gap: 4px; padding: 20px; min-height: 140px;
    border-radius: 18px; color: #fff; text-decoration: none; transition: transform .15s, box-shadow .15s;
    background: linear-gradient(135deg, var(--m-brand-light), var(--m-brand));
}
.m-tile:hover { transform: translateY(-3px); box-shadow: 0 12px 24px rgba(15,20,25,.15); }
.m-tile.m-theme-visitor { background: linear-gradient(135deg, var(--m-visitor-from), var(--m-visitor-to)); }
.m-tile.m-theme-study   { background: linear-gradient(135deg, var(--m-study-from), var(--m-study-to)); }
.m-tile.m-theme-board   { background: linear-gradient(135deg, var(--m-board-from), var(--m-board-to)); }
.m-tile.m-theme-elders  { background: linear-gradient(135deg, var(--m-elders-from), var(--m-elders-to)); }
.m-tile-icon { font-size: 28px; width: 48px; height: 48px; border-radius: 14px; background: rgba(255,255,255,.22); display: grid; place-items: center; margin-bottom: auto; }
.m-tile-title { font-weight: 800; font-size: 16px; margin-top: 12px; }
.m-tile-sub { font-size: 12px; color: rgba(255,255,255,.85); }
.m-tile-badge { position: absolute; top: 14px; right: 14px; }

/* ---------- Folders / people / roster ---------- */
.m-folder-grid, .m-people-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.m-folder { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 18px; cursor: pointer; font: inherit; text-align: left; transition: border-color .15s, transform .15s; }
.m-folder:hover, .m-person:hover { border-color: var(--m-brand-light); transform: translateY(-2px); }
.m-folder-icon { font-size: 30px; }
.m-folder-name { font-weight: 700; color: var(--m-text-strong); }
.m-folder-meta { font-size: 12px; color: var(--m-muted); }
.m-person { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; padding: 20px; color: inherit; transition: border-color .15s, transform .15s; }
.m-avatar { width: 44px; height: 44px; border-radius: 50%; background: var(--m-brand-soft); color: var(--m-brand); font-weight: 800; display: inline-grid; place-items: center; object-fit: cover; flex-shrink: 0; }
.m-avatar.sm { width: 28px; height: 28px; font-size: 11px; vertical-align: middle; margin-right: 6px; }
.m-avatar.lg { width: 72px; height: 72px; font-size: 22px; margin-bottom: 8px; }
.m-avatar.xl { width: 140px; height: 140px; font-size: 42px; }
.m-photo { display: grid; place-items: center; padding: 10px 0; }
.m-photo img { width: 160px; height: 160px; border-radius: 50%; object-fit: cover; border: 4px solid var(--m-brand-soft); }
.m-roster { display: flex; flex-direction: column; gap: 10px; }
.m-roster-row { display: flex; align-items: center; gap: 14px; padding: 12px; border-radius: 14px; background: #F7FAFD; border: 1px solid transparent; }
.m-roster-row.editing { border-color: var(--m-brand); background: var(--m-info-soft); }
.m-date-badge { width: 54px; text-align: center; background: var(--m-brand); color: #fff; border-radius: 12px; padding: 6px 0; flex-shrink: 0; }
.m-date-badge strong { display: block; font-size: 20px; line-height: 1.1; }
.m-date-badge span { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; }
.m-row-actions { display: flex; gap: 6px; }

/* ---------- Checks ---------- */
.m-checks { display: grid; gap: 8px; }
.m-checks-2 { grid-template-columns: 1fr 1fr; }
.m-check { display: flex; align-items: center; gap: 10px; font-size: 14px; cursor: pointer; padding: 6px 8px; border-radius: 8px; }
.m-check:hover { background: #F7FAFD; }
.m-check input { width: 18px; height: 18px; accent-color: var(--m-brand); }

/* ---------- Elders: votes + chat ---------- */
.m-votes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.m-vote { border-radius: 14px; padding: 14px; text-align: center; background: var(--m-subtle); }
.m-vote strong { display: block; font-size: 28px; }
.m-vote span { font-size: 12px; font-weight: 700; color: var(--m-muted); text-transform: uppercase; }
.m-vote.yes { background: var(--m-success-soft); color: var(--m-success); }
.m-vote.no { background: var(--m-danger-soft); color: var(--m-danger); }
.m-chat { display: flex; flex-direction: column; gap: 8px; max-height: 460px; overflow-y: auto; padding: 4px; }
.m-bubble { max-width: 85%; padding: 10px 14px; border-radius: 14px 14px 14px 4px; background: var(--m-subtle); align-self: flex-start; }
.m-bubble.mine { background: var(--m-brand); color: #fff; border-radius: 14px 14px 4px 14px; align-self: flex-end; }
.m-bubble-meta { font-size: 11px; opacity: .8; margin-bottom: 3px; }
.m-chat-input { display: flex; gap: 8px; margin-top: 12px; }

/* ---------- App dashboard ---------- */
.m-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 16px; }
.m-kpi { padding: 18px; }
.m-kpi strong { display: block; font-size: 30px; font-weight: 800; color: var(--m-brand); letter-spacing: -0.5px; }
.m-kpi span { font-size: 12px; font-weight: 700; color: var(--m-muted); }
.m-columns { display: flex; align-items: flex-end; gap: 8px; height: 200px; padding-top: 18px; }
.m-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; }
.m-col-bar { width: 100%; max-width: 34px; border-radius: 8px 8px 3px 3px; min-height: 3px; }
.m-col-value { font-size: 11px; font-weight: 700; color: var(--m-muted); margin-bottom: 4px; }
.m-col-label { font-size: 10px; color: var(--m-muted); margin-top: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

/* ---------- Modal ---------- */
.m-modal-backdrop { position: fixed; inset: 0; background: rgba(15,20,25,.45); display: grid; place-items: center; z-index: 200; padding: 20px; }
.m-modal { background: #fff; border-radius: 20px; padding: 24px; width: 100%; max-width: 440px; box-shadow: 0 24px 60px rgba(0,0,0,.25); border-top: 6px solid var(--m-brand); }
.m-modal.danger { border-top-color: var(--m-danger); }
.m-modal h3 { font-size: 18px; color: var(--m-text-strong); margin-bottom: 6px; }
.m-modal p { color: var(--m-muted); margin-bottom: 14px; line-height: 1.5; }
.m-modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.m-choose { display: flex; flex-direction: column; gap: 6px; max-height: 340px; overflow-y: auto; }
.m-choose-item { text-align: left; font: inherit; font-weight: 600; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--m-divider); background: #fff; cursor: pointer; }
.m-choose-item:hover { border-color: var(--m-brand); background: var(--m-info-soft); color: var(--m-brand); }

/* ---------- Sidebar app items ---------- */
.nav-item .nav-emoji { width: 18px; text-align: center; font-size: 15px; flex-shrink: 0; }

/* =====================================================================
   START CHOOSER (after sign-in) — white page so the logo sits cleanly,
   colours taken from the logo: iDisciple blue #036BB5, slate grey #5F6064
   ===================================================================== */
.chooser-page {
    min-height: 100vh; min-height: 100dvh; display: grid; place-items: center;
    padding: 32px 20px calc(32px + env(safe-area-inset-bottom));
    background:
        radial-gradient(900px 420px at 50% -10%, #E6F0F9 0%, rgba(230,240,249,0) 70%),
        radial-gradient(600px 300px at 100% 110%, #EEF3F9 0%, rgba(238,243,249,0) 70%),
        #FFFFFF;
}
.chooser { width: 100%; max-width: 520px; text-align: center; }
.chooser-logo { width: 100%; max-width: 360px; height: auto; display: block; margin: 0 auto; }
.chooser-prompt {
    margin: 34px 0 18px; font-size: 13px; font-weight: 700; letter-spacing: 1.4px;
    text-transform: uppercase; color: #8A8D93;
}
.chooser-options { display: flex; flex-direction: column; gap: 14px; }
.chooser-card {
    display: flex; align-items: center; gap: 18px; text-align: left;
    padding: 22px 22px; border-radius: 20px; color: #fff; text-decoration: none;
    transition: transform .15s ease, box-shadow .15s ease;
}
.chooser-card.capture {
    background: linear-gradient(135deg, #1A82CC 0%, #036BB5 55%, #02508A 100%);
    box-shadow: 0 12px 28px rgba(3,107,181,.28);
}
.chooser-card.dashboard {
    background: linear-gradient(135deg, #74767B 0%, #5F6064 55%, #45464A 100%);
    box-shadow: 0 12px 28px rgba(69,70,74,.25);
}
.chooser-card:hover { transform: translateY(-3px); }
.chooser-card.capture:hover { box-shadow: 0 18px 36px rgba(3,107,181,.36); }
.chooser-card.dashboard:hover { box-shadow: 0 18px 36px rgba(69,70,74,.32); }
.chooser-card:active { transform: translateY(0); }
.chooser-icon {
    flex-shrink: 0; width: 56px; height: 56px; border-radius: 16px;
    display: grid; place-items: center; background: rgba(255,255,255,.16);
}
.chooser-icon svg { width: 28px; height: 28px; }
.chooser-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.chooser-title { font-size: 21px; font-weight: 800; letter-spacing: -0.2px; }
.chooser-desc { font-size: 13.5px; line-height: 1.4; color: rgba(255,255,255,.85); }
.chooser-arrow {
    flex-shrink: 0; width: 38px; height: 38px; border-radius: 50%;
    display: grid; place-items: center; background: rgba(255,255,255,.18);
    transition: transform .15s ease, background .15s ease;
}
.chooser-arrow svg { width: 18px; height: 18px; }
.chooser-card:hover .chooser-arrow { transform: translateX(3px); background: rgba(255,255,255,.28); }
.chooser-warn {
    margin-top: 16px; background: var(--m-warning-soft); color: var(--m-warning);
    border-radius: 12px; padding: 12px 16px; font-weight: 600; font-size: 13px;
}
.chooser-signout {
    display: inline-block; margin-top: 26px; padding: 10px 16px; border-radius: 10px;
    color: #8A8D93; font-weight: 600; font-size: 14px;
}
.chooser-signout:hover { color: #036BB5; background: #F1F6FB; }

/* =====================================================================
   CAPTURE SHELL (mobile-first)
   ===================================================================== */
.cap-shell { min-height: 100vh; min-height: 100dvh; background: var(--m-canvas); }
.cap-toggle { display: none; }

.cap-topbar {
    position: sticky; top: 0; z-index: 120; height: 60px;
    display: flex; align-items: center; gap: 10px; padding: 0 14px;
    padding-top: env(safe-area-inset-top);
    background: #fff; border-bottom: 1px solid var(--m-divider);
}
.cap-hamburger { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; cursor: pointer; color: var(--m-text-strong); }
.cap-hamburger:hover { background: var(--m-subtle); }
.cap-hamburger svg { width: 22px; height: 22px; }
.cap-brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 17px; color: var(--m-brand-dark); }
.cap-brand img { height: 30px; width: auto; }
.cap-topbar-spacer { flex: 1; }
.cap-church {
    max-width: 200px; font: inherit; font-size: 13px; font-weight: 700; color: var(--m-brand);
    background: var(--m-brand-soft); border: none; border-radius: 10px; padding: 8px 10px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cap-church-static { display: inline-block; }
.cap-top-icon { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; font-size: 18px; }
.cap-top-icon:hover { background: var(--m-subtle); }

.cap-backdrop { display: none; position: fixed; inset: 0; background: rgba(15,20,25,.45); z-index: 190; }
.cap-menu {
    position: fixed; top: 0; left: 0; bottom: 0; width: 280px; max-width: 86vw; z-index: 200;
    background: #fff; overflow-y: auto; padding: calc(16px + env(safe-area-inset-top)) 12px 24px;
    transform: translateX(-100%); transition: transform .25s ease; box-shadow: 8px 0 30px rgba(0,0,0,.12);
}
.cap-toggle:checked ~ .cap-menu { transform: translateX(0); }
.cap-toggle:checked ~ .cap-backdrop { display: block; }
.cap-menu-user { display: flex; align-items: center; gap: 12px; padding: 8px 10px 16px; border-bottom: 1px solid var(--m-divider); margin-bottom: 8px; }
.cap-menu-name { font-weight: 800; color: var(--m-text-strong); }
.cap-menu-church { font-size: 12px; color: var(--m-muted); }
.cap-menu-item {
    display: flex; align-items: center; gap: 12px; padding: 12px 12px; border-radius: 12px;
    font-weight: 600; color: var(--m-text); min-height: 46px;
}
.cap-menu-item span { width: 24px; text-align: center; font-size: 17px; }
.cap-menu-item:hover { background: var(--m-subtle); }
.cap-menu-item.active { background: var(--m-brand-soft); color: var(--m-brand); }
.cap-menu-sep { height: 1px; background: var(--m-divider); margin: 10px 4px; }

.cap-main { padding: 16px 14px calc(96px + env(safe-area-inset-bottom)); }
.cap-main .m-page { margin: 0 auto; }

.cap-tabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 110;
    display: grid; grid-template-columns: repeat(4, 1fr);
    background: #fff; border-top: 1px solid var(--m-divider);
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -4px 16px rgba(15,20,25,.06);
}
.cap-tab {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    height: 62px; font-size: 11px; font-weight: 700; color: var(--m-muted); cursor: pointer;
}
.cap-tab span { font-size: 20px; line-height: 1; }
.cap-tab.active { color: var(--m-brand); }

/* Desktop: permanent left menu, no bottom tabs */
@media (min-width: 1000px) {
    .cap-shell { display: grid; grid-template-columns: 260px 1fr; grid-template-rows: 60px 1fr; }
    .cap-topbar { grid-column: 1 / -1; padding-left: 20px; }
    .cap-hamburger, .cap-tabs, .cap-backdrop { display: none !important; }
    .cap-menu {
        position: sticky; top: 60px; height: calc(100vh - 60px); transform: none; box-shadow: none;
        border-right: 1px solid var(--m-divider); width: auto; max-width: none; padding-top: 16px; z-index: 1;
    }
    .cap-main { padding: 24px 32px 40px; min-width: 0; }
}

/* =====================================================================
   EVENTS / MENTORING / BIBLE STUDY SETTING
   ===================================================================== */
.m-past { opacity: .6; }
.m-mb { margin-bottom: 12px; }
.m-segment-wide { width: 100%; }
.m-segment-wide button { flex: 1; }
.m-spinner.sm { display: inline-block; width: 14px; height: 14px; border-width: 2px; vertical-align: -2px; margin-right: 6px; }

/* Type-ahead (mentee search) */
.m-typeahead { position: relative; }
.m-typeahead-list {
    margin-top: 6px; border: 1px solid var(--m-divider); border-radius: 14px; background: #fff;
    max-height: 320px; overflow-y: auto; box-shadow: 0 10px 24px rgba(15,20,25,.08);
}
.m-typeahead-item {
    display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; font: inherit;
    padding: 10px 12px; border: none; background: transparent; cursor: pointer; border-bottom: 1px solid var(--m-divider);
}
.m-typeahead-item:last-child { border-bottom: none; }
.m-typeahead-item:hover, .m-typeahead-item:focus { background: var(--m-info-soft); outline: none; }
.m-typeahead-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.m-typeahead-text strong { color: var(--m-text-strong); }
.m-typeahead-text small { color: var(--m-muted); font-size: 12px; }
.m-typeahead-empty { padding: 12px 14px; color: var(--m-muted); font-size: 13px; }
.m-picked {
    display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px;
    background: var(--m-info-soft); border: 1.5px solid var(--m-brand-light);
}

/* Blog-style feedback feed */
.m-blog { display: flex; flex-direction: column; gap: 14px; }
.m-post { padding: 18px 20px; border-left: 4px solid var(--m-study-to); }
.m-post.mine { border-left-color: var(--m-brand); }
.m-post-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.m-post-author { font-weight: 800; color: var(--m-text-strong); }
.m-post-date { font-size: 12px; color: var(--m-muted); }
.m-post-body { font-size: 15px; line-height: 1.65; color: var(--m-text); }

/* Bible study: Baptism Class checkbox card + summary cards */
.m-checkbox-card {
    display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: 14px; cursor: pointer;
    background: var(--m-subtle); border: 1.5px solid transparent; transition: background .15s, border-color .15s;
}
.m-checkbox-card input { width: 22px; height: 22px; accent-color: var(--m-study-to); flex-shrink: 0; }
.m-checkbox-card span { display: flex; flex-direction: column; }
.m-checkbox-card strong { color: var(--m-text-strong); }
.m-checkbox-card small { color: var(--m-muted); font-size: 12px; margin-top: 2px; }
.m-checkbox-card.on { background: #E3F4EF; border-color: var(--m-study-to); }
.m-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 14px; }
.m-summary-card {
    display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 14px 16px;
    font: inherit; text-align: left; cursor: pointer; transition: border-color .15s, box-shadow .15s;
}
.m-summary-card strong { font-size: 26px; font-weight: 800; color: var(--m-brand); line-height: 1.1; }
.m-summary-card.class strong { color: var(--m-study-to); }
.m-summary-card.private strong { color: var(--m-board-to); }
.m-summary-card span { font-size: 12px; font-weight: 700; color: var(--m-muted); }
.m-summary-card.active { border-color: var(--m-brand); box-shadow: 0 0 0 3px var(--m-brand-soft); }
.m-summary-card.class.active { border-color: var(--m-study-to); box-shadow: 0 0 0 3px #D4EFE7; }
.m-summary-card.private.active { border-color: var(--m-board-to); box-shadow: 0 0 0 3px #E7E2F5; }

@media (max-width: 700px) {
    .m-summary { gap: 8px; }
    .m-summary-card { padding: 12px; }
    .m-summary-card strong { font-size: 22px; }
    .m-summary-card span { font-size: 11px; }
    .m-post { padding: 16px; }
    .m-segment-wide button { padding: 10px 10px; font-size: 12.5px; }
}

/* =====================================================================
   LOADING FEEDBACK — top progress bar, busy bar, skeletons, button spinners
   ===================================================================== */
@keyframes m-progress-indet {
    0%   { transform: translateX(-100%) scaleX(.35); }
    50%  { transform: translateX(30%)   scaleX(.6); }
    100% { transform: translateX(110%)  scaleX(.35); }
}
@keyframes m-shimmer { 0% { background-position: -400px 0; } 100% { background-position: 400px 0; } }
@keyframes m-fade-in { from { opacity: 0; transform: translate(-50%, -6px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* Page-change bar (driven by js/progress.js) */
#nav-progress {
    position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 1000;
    pointer-events: none; opacity: 0; overflow: hidden; transition: opacity .3s ease;
}
#nav-progress::before {
    content: ""; position: absolute; inset: 0; transform-origin: left;
    background: linear-gradient(90deg, #5298CC, #036BB5, #E8B86D);
    box-shadow: 0 0 10px rgba(3,107,181,.6);
}
#nav-progress.active { opacity: 1; }
#nav-progress.active::before { animation: m-progress-indet 1.1s ease-in-out infinite; }
#nav-progress.done { opacity: 0; }
#nav-progress.done::before { transform: none; }

/* "Still working" hint (navigation: JS adds .show after 5s; busy: CSS delay) */
#nav-slow, .m-busy-slow {
    position: fixed; top: 74px; left: 50%; transform: translateX(-50%); z-index: 1001;
    background: var(--m-brand-dark, #0B3D5D); color: #fff; font-size: 13px; font-weight: 600;
    padding: 9px 16px; border-radius: 999px; box-shadow: 0 8px 24px rgba(0,0,0,.18);
    white-space: nowrap; pointer-events: none;
}
#nav-slow { display: none; }
#nav-slow.show { display: block; animation: m-fade-in .25s ease; }
.m-busy-slow { opacity: 0; animation: m-fade-in .25s ease 5s forwards; }

/* Busy bar inside capture screens (save / load in progress) */
.m-busy-bar {
    position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 999; overflow: hidden; pointer-events: none;
}
.m-busy-bar::before {
    content: ""; position: absolute; inset: 0; transform-origin: left;
    background: linear-gradient(90deg, #5298CC, #036BB5, #E8B86D);
    animation: m-progress-indet 1.1s ease-in-out infinite;
}

/* Spinner inside buttons while saving (buttons are disabled while Busy) */
.m-page .m-btn-primary:disabled, .m-page .m-btn-danger-outline:disabled { opacity: .85; }
.m-page .m-btn-primary:disabled::before, .m-page .m-btn-danger-outline:disabled::before,
.login-btn.is-loading::before {
    content: ""; width: 16px; height: 16px; border-radius: 50%;
    border: 2.5px solid rgba(255,255,255,.45); border-top-color: #fff;
    animation: m-spin .8s linear infinite; flex-shrink: 0;
}
.m-page .m-btn-danger-outline:disabled::before { border-color: var(--m-danger-soft); border-top-color: var(--m-danger); }
.login-btn { display: inline-flex; align-items: center; justify-content: center; gap: 10px; }
.login-btn.is-loading { opacity: .9; cursor: progress; }

/* Skeleton placeholder */
.sk {
    border-radius: 14px;
    background: linear-gradient(90deg, #E4EBF3 0px, #F3F7FB 160px, #E4EBF3 320px);
    background-size: 800px 100%; animation: m-shimmer 1.3s linear infinite;
}
.m-skeleton { display: flex; flex-direction: column; gap: 14px; }
.sk-header { height: 92px; border-radius: 18px; }
.sk-row { display: flex; gap: 8px; }
.sk-pill { height: 38px; width: 110px; border-radius: 12px; }
.sk-card { height: 86px; }
.sk-card.short { width: 70%; }

/* Before a capture screen's live connection is up, the page area is empty — show the skeleton */
.cap-main:not(:has(.m-page))::before {
    content: ""; display: block; height: 92px; border-radius: 18px; margin-bottom: 14px;
    background: linear-gradient(90deg, #E4EBF3 0px, #F3F7FB 160px, #E4EBF3 320px);
    background-size: 800px 100%; animation: m-shimmer 1.3s linear infinite;
}
.cap-main:not(:has(.m-page))::after {
    content: ""; display: block; height: 260px; border-radius: 16px;
    background:
        linear-gradient(90deg, #E4EBF3 0px, #F3F7FB 160px, #E4EBF3 320px) 0 0 / 800px 86px repeat-y;
    -webkit-mask: repeating-linear-gradient(#000 0 86px, transparent 86px 100px);
            mask: repeating-linear-gradient(#000 0 86px, transparent 86px 100px);
    animation: m-shimmer 1.3s linear infinite;
}

/* Dashboard pages' existing "Loading dashboard…" text → spinner + text */
.loading { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.loading::before {
    content: ""; width: 34px; height: 34px; border-radius: 50%;
    border: 3.5px solid #DBEAFE; border-top-color: #036BB5; animation: m-spin .8s linear infinite;
}

@media (prefers-reduced-motion: reduce) {
    #nav-progress.active::before, .m-busy-bar::before { animation-duration: 3s; }
    .sk, .cap-main:not(:has(.m-page))::before, .cap-main:not(:has(.m-page))::after { animation: none; }
}

/* =====================================================================
   RESPONSIVE — capture screens
   ===================================================================== */
@media (max-width: 1100px) {
    .m-two-col, .m-two-col-form { grid-template-columns: 1fr; }
    .m-kpis { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 700px) {
    /* Inputs: 16px stops iOS zooming on focus; bigger touch targets */
    .m-input, .m-search { font-size: 16px; padding: 13px 14px; max-width: none; }
    .m-btn { min-height: 46px; }
    .m-btn-sm { min-height: 36px; }
    .m-icon-btn { width: 42px; height: 42px; }
    .m-check { padding: 10px 8px; }
    .m-toggle-row { padding: 14px 0; }

    .m-grid, .m-grid-3, .m-checks-2 { grid-template-columns: 1fr; }
    .m-section { padding: 16px; border-radius: 14px; margin-bottom: 12px; }
    .m-dl { grid-template-columns: 1fr; gap: 2px; }
    .m-dl dd { margin-bottom: 8px; }

    /* Header */
    .m-header { padding: 16px; border-radius: 16px; margin-bottom: 14px; gap: 12px; flex-wrap: wrap; }
    .m-header h2 { font-size: 19px; }
    .m-header p { font-size: 12px; }
    .m-back { width: 36px; height: 36px; }
    .m-header-actions { width: 100%; }
    .m-header-actions .m-btn { flex: 1; }

    /* Toolbar & segmented filters scroll sideways */
    .m-toolbar { flex-direction: column; align-items: stretch; }
    .m-segment { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
    .m-segment::-webkit-scrollbar { display: none; }
    .m-segment button { white-space: nowrap; flex: 1 0 auto; padding: 10px 14px; }

    /* Form action bar sticks above the bottom tabs */
    .m-form > .m-actions,
    .m-two-col-form .m-actions:last-child {
        position: sticky; bottom: calc(70px + env(safe-area-inset-bottom)); z-index: 20;
        background: rgba(238,243,249,.94); backdrop-filter: blur(6px);
        margin: 8px -14px 0; padding: 10px 14px; flex-wrap: nowrap;
    }
    .m-actions .m-btn { flex: 1; }
    .m-actions .m-spacer { display: none; }

    /* Tables → stacked cards */
    .m-table-card:has(.m-stack) { background: transparent; border: none; padding: 0; }
    .m-stack thead { display: none; }
    .m-stack, .m-stack tbody, .m-stack tr { display: block; width: 100%; }
    .m-stack tbody tr {
        background: #fff; border: 1px solid var(--m-divider); border-radius: 14px;
        padding: 10px 14px; margin-bottom: 10px;
    }
    .m-section .m-stack tbody tr { background: #F7FAFD; }
    .m-stack tbody td {
        display: flex; justify-content: space-between; align-items: center; gap: 12px;
        border: none !important; padding: 5px 0 !important; text-align: right; font-size: 14px;
    }
    .m-stack tbody td::before {
        content: attr(data-label); flex-shrink: 0; text-align: left;
        font-size: 11px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; color: var(--m-muted);
    }
    .m-stack tbody td:first-child { font-size: 15px; text-align: left; justify-content: flex-start; flex-wrap: wrap; padding-bottom: 8px !important; }
    .m-stack tbody td:first-child::before, .m-stack tbody td:not([data-label])::before { content: none; }
    .m-stack tbody td.m-cell-action { justify-content: flex-end; padding-top: 8px !important; }
    .m-stack tbody tr:hover td { background: transparent; }

    /* Lists */
    .m-list-item { padding: 14px; align-items: flex-start; }
    .m-list-item .m-status { align-self: flex-start; }
    .m-event-time { width: 58px; font-size: 14px; }

    /* Home tiles: 2 per row */
    .m-tiles { grid-template-columns: 1fr 1fr; gap: 12px; }
    .m-tile { min-height: 128px; padding: 16px; border-radius: 16px; }
    .m-tile-icon { width: 42px; height: 42px; font-size: 24px; }
    .m-tile-title { font-size: 15px; }

    .m-folder-grid, .m-people-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .m-kpis { gap: 10px; }
    .m-kpi { padding: 14px; }
    .m-kpi strong { font-size: 24px; }
    .m-columns { height: 170px; gap: 4px; }

    .m-roster-row { flex-wrap: wrap; }
    .m-roster-row .m-row-actions { width: 100%; justify-content: flex-end; }

    .m-chat { max-height: 55vh; }
    .m-bubble { max-width: 92%; }
    .m-chat-input { position: sticky; bottom: calc(70px + env(safe-area-inset-bottom)); background: #fff; padding-top: 8px; }

    /* Dialog becomes a bottom sheet */
    .m-modal-backdrop { place-items: end center; padding: 0; }
    .m-modal { max-width: none; border-radius: 22px 22px 0 0; padding: 22px 18px calc(22px + env(safe-area-inset-bottom)); }
    .m-modal-actions .m-btn { flex: 1; }

    .m-notice { top: 66px; }
    .m-photo img { width: 130px; height: 130px; }

    /* Chooser */
    .chooser-logo { max-width: 280px; }
    .chooser-prompt { margin: 26px 0 14px; }
    .chooser-card { padding: 18px; gap: 14px; border-radius: 18px; }
    .chooser-icon { width: 48px; height: 48px; border-radius: 14px; }
    .chooser-title { font-size: 19px; }
}

@media (max-width: 380px) {
    .m-tiles, .m-folder-grid, .m-people-grid { grid-template-columns: 1fr; }
    .cap-church { max-width: 120px; }
    .cap-brand span { display: none; }
}
