/* Church Portal — Frontend Styles
 * Design system tokens from DESIGN.md
 * Fonts: DM Sans (body), Instrument Serif (headings), JetBrains Mono (data)
 * Palette: Forest teal (#3f6b6c) + warm neutrals (#f8f6f3)
 */

/* ---- Google Fonts ---- */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:opsz,wght@9..40,400;9..40,500;9..40,600;9..40,700&family=Instrument+Serif&family=JetBrains+Mono:wght@400;500&display=swap');

/* ---- Design Tokens ---- */
:root {
    /* Core */
    --color-bg:            #f8f6f3;
    --color-surface:       #ffffff;
    --color-surface-alt:   #f1ede8;
    --color-primary:       #3f6b6c;
    --color-primary-hover: #345a5b;
    --color-primary-light: rgba(63, 107, 108, 0.08);
    --color-heading:       #1d3131;
    --color-body:          #464646;
    --color-muted:         #888888;
    --color-border:        #e0dbd5;
    --color-border-light:  #ece8e2;

    /* Semantic */
    --color-success-bg:     #e8f5e4;
    --color-success-border: #c3ddbf;
    --color-success-text:   #2d5a27;
    --color-warning-bg:     #fef4e6;
    --color-warning-border: #f0d9a8;
    --color-warning-text:   #7a5a1a;
    --color-error-bg:       #fdecea;
    --color-error-border:   #f0c4be;
    --color-error-text:     #721c24;
    --color-info-bg:        #e8f0f0;
    --color-info-border:    #bfd4d4;
    --color-info-text:      #2a4e4e;

    /* Typography */
    --font-display: 'Instrument Serif', Georgia, serif;
    --font-body:    'DM Sans', system-ui, -apple-system, sans-serif;
    --font-mono:    'JetBrains Mono', ui-monospace, monospace;

    /* Spacing (8px base) */
    --space-2xs: 2px;
    --space-xs:  4px;
    --space-sm:  8px;
    --space-md:  16px;
    --space-lg:  24px;
    --space-xl:  32px;
    --space-2xl: 48px;
    --space-3xl: 64px;

    /* Radius */
    --radius-sm:   4px;
    --radius-md:   8px;
    --radius-lg:   12px;
    --radius-card: 15px;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-card:       0 2px 20px rgba(29, 49, 49, 0.06);
    --shadow-card-hover: 0 4px 30px rgba(29, 49, 49, 0.10);
    --shadow-dropdown:   0 8px 24px rgba(29, 49, 49, 0.12);

    /* Focus */
    --focus-ring: 0 0 0 3px rgba(63, 107, 108, 0.15);

    /* Transitions */
    --ease-enter: cubic-bezier(0.22, 1, 0.36, 1);
    --duration-micro: 100ms;
    --duration-short: 200ms;
    --duration-medium: 300ms;
}

/* ---- Dark Mode ---- */
[data-theme="dark"] {
    --color-bg:            #1a2020;
    --color-surface:       #242e2e;
    --color-surface-alt:   #1e2828;
    --color-primary:       #6ba3a4;
    --color-primary-hover: #7fb5b6;
    --color-primary-light: rgba(107, 163, 164, 0.12);
    --color-heading:       #e8e4df;
    --color-body:          #bab5ad;
    --color-muted:         #7a7770;
    --color-border:        #3a4242;
    --color-border-light:  #2e3838;
    --color-success-bg:    #1e2e1c;
    --color-success-border:#3a5a36;
    --color-success-text:  #8ec488;
    --color-warning-bg:    #2e2a1a;
    --color-warning-border:#5a4e2a;
    --color-warning-text:  #d4b86a;
    --color-error-bg:      #2e1c1c;
    --color-error-border:  #5a2a2a;
    --color-error-text:    #d48888;
    --color-info-bg:       #1c2828;
    --color-info-border:   #2a4e4e;
    --color-info-text:     #88c4c4;

    --shadow-card:       0 2px 20px rgba(0, 0, 0, 0.20);
    --shadow-card-hover: 0 4px 30px rgba(0, 0, 0, 0.30);
    --shadow-dropdown:   0 8px 24px rgba(0, 0, 0, 0.35);
}

/* ---- Global: portal typography + link reset ---- */
.church-portal,
.cp-auth {
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.6;
    color: var(--color-body);
    -webkit-font-smoothing: antialiased;
}

.church-portal a,
.church-portal a:link,
.church-portal a:visited,
.church-portal a:hover,
.church-portal a:focus,
.church-portal a:active,
.cp-auth a { text-decoration: none !important; }

/* ---- Layout ---- */
.church-portal {
    display: flex;
    gap: 0;
    min-height: 520px;
    background: var(--color-surface);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
    overflow: hidden;
}

/* ---- Navigation sidebar ---- */
.cp-nav {
    width: 260px;
    flex-shrink: 0;
    background: linear-gradient(180deg, #f4f0ea 0%, var(--color-bg) 220px);
    color: var(--color-heading);
    display: flex;
    flex-direction: column;
    padding: 0 0 var(--space-md);
    border-right: 1px solid var(--color-border-light);
}

/* Brand block at the top */
.cp-nav__brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: var(--space-lg) var(--space-lg) var(--space-md);
}
.cp-nav__brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: var(--color-primary);
    color: #fff;
    font-size: 16px;
    line-height: 1;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(63, 107, 108, 0.25);
}
.cp-nav__brand-name {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 400;
    color: var(--color-heading);
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Member chip — avatar + name + status */
.cp-nav__member {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0 var(--space-md) var(--space-md);
    padding: 12px;
    background: var(--color-surface);
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-card);
    box-shadow: 0 1px 2px rgba(29, 49, 49, 0.04);
}
.cp-nav__avatar {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--color-primary);
    background-image: linear-gradient(135deg, var(--color-primary), #5d8c8d);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 14px;
    letter-spacing: 0.02em;
    box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.10);
}
.cp-nav__member-info { min-width: 0; flex: 1; }
.cp-nav__member-info strong {
    display: block;
    font-family: var(--font-body);
    font-weight: 600;
    color: var(--color-heading);
    font-size: 14px;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.cp-nav__member-info span {
    display: inline-block;
    margin-top: 2px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-muted);
    font-family: var(--font-mono);
}

/* Nav links */
.cp-nav__links {
    list-style: none;
    margin: 0;
    padding: var(--space-sm) var(--space-sm) 0;
    flex: 1;
    overflow-y: auto;
}

.cp-nav__group-label {
    padding: var(--space-md) 12px var(--space-xs);
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.10em;
    color: var(--color-muted);
    pointer-events: none;
}
.cp-nav__group-label:first-child { padding-top: var(--space-xs); }

.cp-nav__link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    margin-bottom: 1px;
    color: var(--color-body);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    border-radius: 10px;
    transition: background var(--duration-short) var(--ease-enter),
                color var(--duration-short) var(--ease-enter),
                transform var(--duration-short) var(--ease-enter);
    position: relative;
}
.cp-nav__link:hover {
    background: rgba(63, 107, 108, 0.06);
    color: var(--color-primary);
}
.cp-nav__link.is-active {
    background: var(--color-primary);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(63, 107, 108, 0.25);
}
.cp-nav__link.is-active .cp-nav__icon {
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
}
.cp-nav__link:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}
.cp-nav__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 7px;
    background: var(--color-surface);
    border: 1px solid var(--color-border-light);
    font-size: 14px;
    line-height: 1;
    flex-shrink: 0;
    transition: background var(--duration-short), border-color var(--duration-short);
}
.cp-nav__link:hover .cp-nav__icon {
    background: #fff;
    border-color: var(--color-primary-light);
}
.cp-nav__label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

/* Footer */
.cp-nav__footer {
    padding: var(--space-md) var(--space-md) 0;
    margin-top: var(--space-sm);
    border-top: 1px solid var(--color-border-light);
}
.cp-nav__signout {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 10px 12px;
    border-radius: 10px;
    color: var(--color-muted);
    font-size: 13px;
    font-weight: 500;
    transition: background var(--duration-short), color var(--duration-short);
}
.cp-nav__signout:hover {
    background: var(--color-surface);
    color: var(--color-heading);
}
.cp-nav__signout span { font-size: 14px; }

/* ---- Main content area ---- */
.cp-main {
    flex: 1;
    padding: var(--space-xl) var(--space-xl) var(--space-2xl);
    overflow-y: auto;
    background: var(--color-bg);
}
.cp-main > * + * { margin-top: var(--space-lg); }

/* ---- Section ----
 * Sections are full-width content areas. The page title sits flush above
 * the panels below it; visual weight comes from the boxed panels rather
 * than the header itself.
 */
.cp-section__title {
    margin: 0 0 var(--space-sm);
    font-family: var(--font-display);
    font-size: 32px;
    font-weight: 400;
    color: var(--color-heading);
}
.cp-section__intro {
    color: var(--color-muted);
    font-size: 15px;
    margin-top: 0;
    margin-bottom: var(--space-lg);
}
.cp-section__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--space-md);
    margin-bottom: var(--space-md);
}

/* ---- Panel (boxed content container) ----
 * The default container for any block of content inside a section: forms,
 * tables, lists, etc. Creates clear visual separation between distinct
 * areas of a page.
 */
.cp-panel {
    background: var(--color-surface);
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
    padding: var(--space-xl);
}
.cp-panel + .cp-panel { margin-top: var(--space-lg); }
.cp-panel__title {
    margin: 0 0 var(--space-xs);
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 400;
    color: var(--color-heading);
}
.cp-panel__intro {
    margin: 0 0 var(--space-lg);
    font-size: 14px;
    color: var(--color-muted);
}
.cp-panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
    flex-wrap: wrap;
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-md);
    border-bottom: 1px solid var(--color-border-light);
}
.cp-panel__header .cp-panel__title { margin-bottom: 0; }
.cp-panel--flush { padding: 0; overflow: hidden; }
.cp-panel--flush .cp-table { box-shadow: none; border-radius: 0; }

/* ---- Stat cards ---- */
.cp-cards {
    display: flex;
    gap: var(--space-md);
    flex-wrap: wrap;
    margin: var(--space-lg) 0 var(--space-xl);
}
.cp-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
    padding: var(--space-lg);
    min-width: 160px;
    flex: 1;
    transition: box-shadow var(--duration-short) var(--ease-enter);
}
.cp-card:hover { box-shadow: var(--shadow-card-hover); }
.cp-card__label {
    font-family: var(--font-mono);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-muted);
}
.cp-card__value {
    font-family: var(--font-mono);
    font-size: 28px;
    font-weight: 500;
    color: var(--color-heading);
    line-height: 1.2;
    margin: var(--space-xs) 0;
}
.cp-card__meta  { font-size: 13px; color: var(--color-muted); }
.cp-card__meta a { color: var(--color-primary); }

/* ---- Quick links ---- */
.cp-quick-links { display: flex; gap: var(--space-md); flex-wrap: wrap; margin-top: var(--space-md); }
.cp-quick-link {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 10px var(--space-md);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    text-decoration: none;
    color: var(--color-heading);
    font-size: 14px;
    font-weight: 500;
    transition: border-color var(--duration-short), box-shadow var(--duration-short);
}
.cp-quick-link:hover {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 1px var(--color-primary);
    color: var(--color-primary);
}
.cp-quick-link:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

/* ---- Forms ----
 * Forms render as boxed panels by default so each form has clear visual
 * boundaries. Use .cp-form--bare inside an existing .cp-panel to opt out.
 */
.cp-form {
    background: var(--color-surface);
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
    padding: var(--space-xl);
    max-width: 720px;
}
.cp-form--bare,
.cp-auth__box .cp-form,
.cp-panel .cp-form {
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 0;
    max-width: none;
}
.cp-form--full { max-width: none; }
.cp-form__section-title {
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-muted);
    border-bottom: 1px solid var(--color-border-light);
    padding-bottom: var(--space-sm);
    margin: var(--space-xl) 0 var(--space-md);
}
.cp-form__section-title:first-child { margin-top: 0; }
.cp-form__row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-md); }
.cp-form__row--3 { grid-template-columns: 2fr 1fr 1fr; }
.cp-form__actions {
    margin-top: var(--space-lg);
    padding-top: var(--space-lg);
    border-top: 1px solid var(--color-border-light);
    display: flex;
    gap: var(--space-sm);
    flex-wrap: wrap;
}
.cp-form__hint { font-size: 13px; color: var(--color-muted); margin: var(--space-xs) 0 0; }

/* ---- Legacy inline-styled form wrappers ----
 * Many portal views ship form containers with inline
 * `style="background:#f6f7f7;border-radius:8px;padding:20px 24px;..."`.
 * Upgrade those to the boxed card treatment without touching every view.
 * Scoped to form/div tags so table rows (<tr>) using the same color are
 * left alone. !important is required to win against the inline styles.
 */
form[style*="background:#f6f7f7"],
div[style*="background:#f6f7f7"][style*="border-radius:8px"] {
    background: var(--color-surface) !important;
    border: 1px solid var(--color-border-light) !important;
    border-radius: var(--radius-card) !important;
    box-shadow: var(--shadow-card) !important;
    padding: var(--space-xl) !important;
}

/* Inputs inside those legacy form wrappers shipped with naked
 * `border:1px solid #ddd;border-radius:4px;` — bring them into the design
 * system so they match .cp-field inputs. Both the form-styled and
 * div-wrapped variants are covered.
 */
form[style*="background:#f6f7f7"] input[type="text"],
form[style*="background:#f6f7f7"] input[type="email"],
form[style*="background:#f6f7f7"] input[type="tel"],
form[style*="background:#f6f7f7"] input[type="url"],
form[style*="background:#f6f7f7"] input[type="number"],
form[style*="background:#f6f7f7"] input[type="date"],
form[style*="background:#f6f7f7"] input[type="time"],
form[style*="background:#f6f7f7"] input[type="datetime-local"],
form[style*="background:#f6f7f7"] input[type="password"],
form[style*="background:#f6f7f7"] input[type="search"],
form[style*="background:#f6f7f7"] select,
form[style*="background:#f6f7f7"] textarea,
div[style*="background:#f6f7f7"][style*="border-radius:8px"] input[type="text"],
div[style*="background:#f6f7f7"][style*="border-radius:8px"] input[type="email"],
div[style*="background:#f6f7f7"][style*="border-radius:8px"] input[type="tel"],
div[style*="background:#f6f7f7"][style*="border-radius:8px"] input[type="url"],
div[style*="background:#f6f7f7"][style*="border-radius:8px"] input[type="number"],
div[style*="background:#f6f7f7"][style*="border-radius:8px"] input[type="date"],
div[style*="background:#f6f7f7"][style*="border-radius:8px"] input[type="time"],
div[style*="background:#f6f7f7"][style*="border-radius:8px"] input[type="datetime-local"],
div[style*="background:#f6f7f7"][style*="border-radius:8px"] input[type="password"],
div[style*="background:#f6f7f7"][style*="border-radius:8px"] input[type="search"],
div[style*="background:#f6f7f7"][style*="border-radius:8px"] select,
div[style*="background:#f6f7f7"][style*="border-radius:8px"] textarea {
    border: 1px solid var(--color-border) !important;
    border-radius: var(--radius-md) !important;
    padding: 10px 14px !important;
    font-family: var(--font-body) !important;
    font-size: 14px !important;
    color: var(--color-body) !important;
    background: var(--color-surface) !important;
    transition: border-color var(--duration-short), box-shadow var(--duration-short);
}
form[style*="background:#f6f7f7"] input:focus,
form[style*="background:#f6f7f7"] select:focus,
form[style*="background:#f6f7f7"] textarea:focus,
div[style*="background:#f6f7f7"][style*="border-radius:8px"] input:focus,
div[style*="background:#f6f7f7"][style*="border-radius:8px"] select:focus,
div[style*="background:#f6f7f7"][style*="border-radius:8px"] textarea:focus {
    outline: none !important;
    border-color: var(--color-primary) !important;
    box-shadow: var(--focus-ring) !important;
}
form[style*="background:#f6f7f7"] label,
div[style*="background:#f6f7f7"][style*="border-radius:8px"] label {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-heading);
    text-transform: none;
    letter-spacing: 0;
}
form[style*="background:#f6f7f7"] h3,
div[style*="background:#f6f7f7"][style*="border-radius:8px"] h3 {
    font-family: var(--font-display) !important;
    font-size: 20px !important;
    font-weight: 400 !important;
    color: var(--color-heading) !important;
    margin: 0 0 var(--space-xs) !important;
}
form[style*="background:#f6f7f7"] button[type="submit"],
form[style*="background:#f6f7f7"] .button-primary,
div[style*="background:#f6f7f7"][style*="border-radius:8px"] button[type="submit"]:not(.cp-btn),
div[style*="background:#f6f7f7"][style*="border-radius:8px"] .button-primary {
    background: var(--color-primary) !important;
    border: 1px solid var(--color-primary) !important;
    color: #fff !important;
    border-radius: var(--radius-md) !important;
    padding: 10px var(--space-lg) !important;
    font-family: var(--font-body) !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    cursor: pointer;
    transition: background var(--duration-short);
}
form[style*="background:#f6f7f7"] button[type="submit"]:hover,
form[style*="background:#f6f7f7"] .button-primary:hover,
div[style*="background:#f6f7f7"][style*="border-radius:8px"] button[type="submit"]:not(.cp-btn):hover,
div[style*="background:#f6f7f7"][style*="border-radius:8px"] .button-primary:hover {
    background: var(--color-primary-hover) !important;
    border-color: var(--color-primary-hover) !important;
}

.cp-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--space-md); }
.cp-field label { font-size: 14px; font-weight: 500; color: var(--color-heading); }
.cp-field--inline { flex-direction: row; align-items: center; }
.cp-field--inline label { font-weight: 400; display: flex; align-items: center; gap: var(--space-sm); cursor: pointer; }

.cp-field input[type="text"],
.cp-field input[type="email"],
.cp-field input[type="password"],
.cp-field input[type="tel"],
.cp-field input[type="url"],
.cp-field input[type="number"],
.cp-field input[type="date"],
.cp-field select,
.cp-field textarea {
    padding: 12px 16px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-family: var(--font-body);
    font-size: 15px;
    color: var(--color-body);
    background: var(--color-surface);
    line-height: 1.4;
    transition: border-color var(--duration-short), box-shadow var(--duration-short);
}
.cp-field input:focus,
.cp-field select:focus,
.cp-field textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: var(--focus-ring);
}

/* ---- Buttons ---- */
.cp-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 12px var(--space-lg);
    border-radius: var(--radius-md);
    font-family: var(--font-body);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    text-decoration: none;
    transition: background var(--duration-short) var(--ease-enter),
                border-color var(--duration-short);
    min-height: 44px; /* Touch target */
}
.cp-btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.cp-btn--primary   { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
.cp-btn--primary:hover { background: var(--color-primary-hover); border-color: var(--color-primary-hover); color: #fff; }
.cp-btn--secondary { background: transparent; color: var(--color-primary); border-color: var(--color-primary); }
.cp-btn--secondary:hover { background: var(--color-primary-light); color: var(--color-primary-hover); }
.cp-btn--ghost     { background: transparent; color: var(--color-muted); border-color: var(--color-border); }
.cp-btn--ghost:hover { background: var(--color-surface-alt); color: var(--color-heading); border-color: var(--color-muted); }
.cp-btn--full      { width: 100%; justify-content: center; }
.cp-btn--sm        { padding: var(--space-sm) var(--space-md); font-size: 13px; min-height: 36px; }
.cp-btn:disabled,
.cp-btn[disabled]  { opacity: 0.7; cursor: not-allowed; }

/* ---- Notices ---- */
.cp-notice {
    padding: 12px var(--space-md);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-lg);
    font-size: 14px;
    border-left: 4px solid;
}
.cp-notice--success { background: var(--color-success-bg); border-color: var(--color-success-border); color: var(--color-success-text); }
.cp-notice--error   { background: var(--color-error-bg);   border-color: var(--color-error-border);   color: var(--color-error-text); }
.cp-notice--warning { background: var(--color-warning-bg); border-color: var(--color-warning-border); color: var(--color-warning-text); }

/* ---- Badges ---- */
.cp-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 600;
}
.cp-badge--success { background: var(--color-success-bg); color: var(--color-success-text); }
.cp-badge--warning { background: var(--color-warning-bg); color: var(--color-warning-text); }
.cp-badge--muted   { background: var(--color-surface-alt); color: var(--color-muted); }
.cp-badge--info    { background: var(--color-info-bg); color: var(--color-info-text); }

/* ---- Table ---- */
.cp-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--color-surface);
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-card);
    overflow: hidden;
    box-shadow: var(--shadow-card);
}
.cp-table th {
    background: var(--color-bg);
    font-family: var(--font-mono);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-muted);
    padding: 10px var(--space-md);
    text-align: left;
    border-bottom: 1px solid var(--color-border-light);
}
.cp-table td {
    padding: 10px var(--space-md);
    border-bottom: 1px solid var(--color-border-light);
    font-size: 14px;
    color: var(--color-body);
}
.cp-table tbody tr:last-child td { border-bottom: none; }
.cp-table__num {
    text-align: right;
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
}
.cp-table__total td {
    font-weight: 700;
    border-top: 2px solid var(--color-border);
    background: var(--color-bg);
}

/* ---- Year picker ---- */
.cp-year-picker select {
    padding: var(--space-sm) 10px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-family: var(--font-body);
    font-size: 14px;
    background: var(--color-surface);
    color: var(--color-body);
}
.cp-year-picker select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: var(--focus-ring);
}

/* ---- Events ---- */
.cp-events { display: flex; flex-direction: column; gap: var(--space-md); }
.cp-event-card {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    padding: var(--space-md);
    transition: box-shadow var(--duration-short) var(--ease-enter);
}
.cp-event-card:hover { box-shadow: var(--shadow-card-hover); }
.cp-event-card.is-registered { border-left: 3px solid var(--color-success-border); }
.cp-event-card__date {
    flex-shrink: 0;
    width: 52px;
    text-align: center;
    background: var(--color-bg);
    border-radius: var(--radius-md);
    padding: var(--space-sm) var(--space-xs);
    line-height: 1;
}
.cp-event-card__month {
    display: block;
    font-family: var(--font-mono);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-muted);
}
.cp-event-card__day {
    display: block;
    font-family: var(--font-display);
    font-size: 24px;
    font-weight: 400;
    color: var(--color-heading);
}
.cp-event-card__info  { flex: 1; }
.cp-event-card__title { margin: 0 0 var(--space-xs); font-size: 15px; font-weight: 600; color: var(--color-heading); }
.cp-event-card__meta  { font-size: 13px; color: var(--color-muted); margin: 0 0 var(--space-sm); }
.cp-event-card__desc  { font-size: 14px; color: var(--color-muted); margin: 0; }
.cp-event-card__action { flex-shrink: 0; display: flex; flex-direction: column; gap: var(--space-sm); align-items: flex-end; }

/* ---- Notification preferences ---- */
.cp-prefs { display: flex; flex-direction: column; gap: var(--space-xs); max-width: 560px; }
.cp-pref-row {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    background: var(--color-surface);
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-md);
    padding: 14px var(--space-md);
    cursor: pointer;
    transition: border-color var(--duration-short);
}
.cp-pref-row:hover { border-color: var(--color-primary); }
.cp-pref-row__icon { font-size: 22px; flex-shrink: 0; }
.cp-pref-row__text { flex: 1; }
.cp-pref-row__text strong { display: block; font-size: 14px; color: var(--color-heading); }
.cp-pref-row__text span   { font-size: 13px; color: var(--color-muted); }
.cp-pref-row__toggle { flex-shrink: 0; }

/* Toggle switch */
.cp-toggle {
    appearance: none;
    width: 40px;
    height: 22px;
    border-radius: var(--radius-full);
    background: var(--color-border);
    cursor: pointer;
    position: relative;
    transition: background var(--duration-short);
}
.cp-toggle::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--color-surface);
    transition: transform var(--duration-short);
    box-shadow: 0 1px 2px rgba(0,0,0,.15);
}
.cp-toggle:checked { background: var(--color-primary); }
.cp-toggle:checked::after { transform: translateX(18px); }
.cp-toggle:focus-visible { outline: none; box-shadow: var(--focus-ring); }

/* ---- Auth box (login/reset) ---- */
.cp-auth {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 40px var(--space-md);
    font-family: var(--font-body);
}
.cp-auth__box {
    background: var(--color-surface);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
    padding: 50px 45px;
    width: 100%;
    max-width: 520px;
}
.cp-auth__title {
    font-family: var(--font-display);
    font-size: 32px;
    font-weight: 400;
    color: var(--color-heading);
    margin: 0 0 var(--space-xs);
    text-align: center;
}
.cp-auth__subtitle {
    font-size: 15px;
    color: var(--color-muted);
    text-align: center;
    margin: 0 0 var(--space-xl);
}
.cp-auth__links { text-align: center; margin-top: var(--space-md); font-size: 14px; }
.cp-auth__links a { color: var(--color-primary); }
.cp-auth__links a:hover { text-decoration: underline !important; }

/* ---- Prayer Wall ---- */
.church-prayer-wall__submit {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    padding: var(--space-lg);
    margin-bottom: var(--space-lg);
}
.church-prayer-wall__submit-title {
    margin: 0 0 var(--space-md);
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 400;
    color: var(--color-heading);
}
.church-prayer-wall__field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 14px;
}
.church-prayer-wall__field label {
    font-size: 14px;
    font-weight: 500;
    color: var(--color-heading);
}
.church-prayer-wall__field input[type="text"],
.church-prayer-wall__field select,
.church-prayer-wall__field textarea {
    padding: 12px 16px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-family: var(--font-body);
    font-size: 15px;
    color: var(--color-body);
    background: var(--color-surface);
    line-height: 1.4;
    transition: border-color var(--duration-short), box-shadow var(--duration-short);
    width: 100%;
    box-sizing: border-box;
}
.church-prayer-wall__field input[type="text"]:focus,
.church-prayer-wall__field select:focus,
.church-prayer-wall__field textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: var(--focus-ring);
}
.church-prayer-wall__field--inline { flex-direction: row; align-items: center; }
.church-prayer-wall__field--inline label { font-weight: 400; display: flex; align-items: center; gap: var(--space-sm); cursor: pointer; }
.church-prayer-wall__row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-md); }
.church-prayer-wall__status { font-size: 14px; margin-bottom: 10px; color: var(--color-success-text); }
.church-prayer-wall__submit-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 12px var(--space-lg);
    border-radius: var(--radius-md);
    font-family: var(--font-body);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid var(--color-primary);
    background: var(--color-primary);
    color: #fff;
    transition: background var(--duration-short) var(--ease-enter);
    min-height: 44px;
}
.church-prayer-wall__submit-btn:hover { background: var(--color-primary-hover); border-color: var(--color-primary-hover); }
.church-prayer-wall__submit-btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.church-prayer-wall__login-prompt { font-size: 14px; color: var(--color-muted); margin-bottom: var(--space-lg); }
.church-prayer-wall__login-prompt a { color: var(--color-primary); }
.church-prayer-wall__count { font-size: 13px; color: var(--color-muted); margin: 0 0 var(--space-md); }
.church-prayer-wall__grid { display: grid; gap: var(--space-md); margin-bottom: var(--space-lg); }
.church-prayer-wall__grid--1col { grid-template-columns: 1fr; }
.church-prayer-wall__grid--2col { grid-template-columns: repeat(2, 1fr); }
.church-prayer-wall__grid--3col { grid-template-columns: repeat(3, 1fr); }
.church-prayer-wall__grid--4col { grid-template-columns: repeat(4, 1fr); }
.church-prayer-card {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    padding: var(--space-md) 18px;
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    transition: box-shadow var(--duration-short) var(--ease-enter);
}
.church-prayer-card:hover { box-shadow: var(--shadow-card-hover); }
.church-prayer-card--answered { border-left: 3px solid var(--color-success-border); }
.church-prayer-card__header { display: flex; align-items: center; justify-content: space-between; gap: var(--space-sm); }
.church-prayer-card__category {
    font-family: var(--font-mono);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-muted);
    font-weight: 500;
}
.church-prayer-card__answered-badge {
    display: inline-block;
    padding: 2px var(--space-sm);
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 600;
    background: var(--color-success-bg);
    color: var(--color-success-text);
}
.church-prayer-card__title { margin: 0; font-size: 15px; font-weight: 600; color: var(--color-heading); }
.church-prayer-card__body { margin: 0; font-size: 14px; color: var(--color-muted); line-height: 1.6; }
.church-prayer-card__testimony {
    margin: 0;
    padding: var(--space-sm) var(--space-md);
    border-left: 3px solid var(--color-success-border);
    background: var(--color-success-bg);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-size: 13px;
    color: var(--color-success-text);
}
.church-prayer-card__testimony p { margin: 0; }
.church-prayer-card__footer { display: flex; align-items: center; justify-content: space-between; gap: var(--space-sm); margin-top: auto; }
.church-prayer-card__author,
.church-prayer-card__date { font-size: 11px; color: var(--color-muted); }
.church-prayer-card__actions { margin-top: var(--space-xs); }
.church-prayer-card__pray-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid var(--color-border);
    background: transparent;
    color: var(--color-muted);
    transition: background var(--duration-short), border-color var(--duration-short), color var(--duration-short);
}
.church-prayer-card__pray-btn:hover:not(:disabled) {
    background: var(--color-surface-alt);
    border-color: var(--color-muted);
    color: var(--color-heading);
}
.church-prayer-card__pray-btn--prayed,
.church-prayer-card__pray-btn:disabled {
    border-color: var(--color-primary);
    color: var(--color-primary);
    background: var(--color-primary-light);
    cursor: default;
}
.church-prayer-card__pray-count { color: var(--color-muted); }
.church-prayer-wall__pagination { display: flex; gap: var(--space-xs); flex-wrap: wrap; margin-top: var(--space-sm); }
.church-prayer-wall__pagination .page-numbers {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 var(--space-sm);
    border-radius: var(--radius-md);
    font-size: 14px;
    text-decoration: none;
    border: 1px solid var(--color-border);
    color: var(--color-body);
    background: var(--color-surface);
    transition: background var(--duration-short), border-color var(--duration-short);
}
.church-prayer-wall__pagination .page-numbers:hover {
    background: var(--color-surface-alt);
    border-color: var(--color-muted);
}
.church-prayer-wall__pagination .page-numbers.current {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
}

/* ---- Accessibility: reduced motion ---- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ---- Responsive ---- */
@media (max-width: 680px) {
    .church-portal { flex-direction: column; border-radius: 0; }
    .cp-nav {
        width: 100%;
        padding: 0 0 var(--space-sm);
        background: var(--color-bg);
        border-right: none;
        border-bottom: 1px solid var(--color-border-light);
    }
    .cp-nav__brand { padding: var(--space-md) var(--space-md) var(--space-sm); }
    .cp-nav__member { margin-bottom: var(--space-sm); }
    .cp-nav__links {
        display: flex;
        flex-wrap: wrap;
        gap: var(--space-xs);
        padding: var(--space-sm);
        overflow-x: auto;
    }
    .cp-nav__group-label { display: none; }
    .cp-nav__link { margin-bottom: 0; padding: var(--space-sm) 12px; }
    .cp-nav__footer { padding: var(--space-sm) var(--space-md) 0; }
    .cp-main { padding: var(--space-lg) var(--space-md); }
    .cp-form__row, .cp-form__row--3 { grid-template-columns: 1fr; }
    .cp-auth__box { padding: var(--space-xl) var(--space-lg); }
    .cp-event-card { flex-wrap: wrap; }
    .church-prayer-wall__grid--2col,
    .church-prayer-wall__grid--3col,
    .church-prayer-wall__grid--4col { grid-template-columns: 1fr; }
    .church-prayer-wall__row { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
    .cp-auth__box { padding: var(--space-xl) 20px; }
}
