/* ═══════════════════════════════════════════════════════════════
   ChurchWorks — TailAdmin Design System
   Brand: #10b981  Surface: #fff  Background: #f9fafb
   ═══════════════════════════════════════════════════════════════ */

/* ── Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
    /* 16px — the browser default. This was 14px, which quietly shrank EVERY rem in the app by 12.5%:
       0.75rem rendered at 10.5px instead of 12px, and roughly 2,000 elements sat under 12px.

       Keep this as its own rule. Folding font-size into the `html, body` selector below lands it on
       html as well, where 0.875rem resolves against the initial 16px, puts the root back to 14px and
       shrinks every rem all over again. */
    font-size: 16px;
}

/* Body carries the reading size; the sizes throughout are re-mapped so body stays where it was and
   only the small text grows. */
body {
    font-size: var(--fs-md);
}

html, body {
    font-family: 'Inter', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    line-height: 1.6;
    background: var(--color-background, #f9fafb);
    color: var(--color-foreground, #1d2939);
    -webkit-font-smoothing: antialiased;
}

:root {
    /* Type scale — every size in the app resolves to one of these. Comments are the rendered px. */
    --fs-2xs: 0.6875rem;  /* 11 */
    --fs-xs:   0.75rem;   /* 12 — the floor for anything a person has to read */
    --fs-sm:   0.8125rem; /* 13 */
    --fs-md:   0.875rem;  /* 14 — body */
    --fs-base: 1rem;      /* 16 */
    --fs-lg:   1.125rem;  /* 18 */
    --fs-xl:   1.25rem;   /* 20 */
    --fs-2xl:  1.375rem;  /* 22 */
    --fs-3xl:  1.5rem;    /* 24 */

    /* Radii — was eight ad-hoc values, which is what made the surfaces look unconsidered. */
    --radius-sm:   0.375rem; /* 6 */
    --radius-md:   0.5rem;   /* 8 */
    --radius-lg:   0.75rem;  /* 12 */
    --radius-xl:   1rem;     /* 16 */
    --radius-pill: 999px;

    --brand: #059669;
    --brand-25: #ecfdf5;
    --brand-50: #d1fae5;
    --brand-100: #a7f3d0;
    --brand-500: #059669;
    --brand-600: #047857;
    --brand-soft: rgba(5, 150, 105, 0.1);
    --color-background: #f9fafb;
    --color-surface: #ffffff;
    --color-surface-muted: #f9fafb;
    --color-foreground: #101828;
    --color-muted-foreground: #667085;
    --color-border: #e4e7ec;
    --color-border-strong: #d0d5dd;
    --color-hover-bg: #f2f4f7;
    --color-success-bg: #ecfdf3;
    --color-success-text: #027a48;
    --color-warning-bg: #fffaeb;
    --color-warning-text: #b54708;
    --color-danger-bg: #fef3f2;
    --color-danger-text: #b42318;
    /* ── Sidebar tokens (light) ── */
    --sidebar-bg: #ffffff;
    --sidebar-border: #e4e7ec;
    --sidebar-link-color: #475467;
    --sidebar-link-hover-bg: #f2f4f7;
    --sidebar-link-hover-color: #101828;
    --sidebar-link-active-bg: rgba(5, 150, 105,0.09);
    --sidebar-link-active-color: #059669;
    --sidebar-logo-text: #101828;
    --sidebar-logo-mark-bg: #059669;
    --sidebar-logo-mark-border: transparent;
    --sidebar-logo-mark-color: #ffffff;
    --sidebar-close-color: #667085;
    --sidebar-close-border: #e4e7ec;
    --sidebar-section-label: #98a2b3;
    --sidebar-sub-line: #e4e7ec;
    --sidebar-footer-border: #e4e7ec;
    --sidebar-user-bg: #f9fafb;
    --sidebar-user-border: #e4e7ec;
    --sidebar-user-avatar-bg: #059669;
    --sidebar-user-avatar-color: #ffffff;
    --sidebar-user-avatar-border: rgba(5, 150, 105,0.2);
    --sidebar-user-name: #101828;
    --sidebar-user-role: #98a2b3;
    --sidebar-signout-color: #667085;
    --sidebar-signout-hover-bg: rgba(239,68,68,0.08);
    --sidebar-signout-hover-color: #b42318;
    --sidebar-icon-opacity: 0.5;
    --sidebar-scroll: rgba(0,0,0,0.1);
    --sidebar-group-label-color: #475467;
    --sidebar-group-active-color: #059669;
    --sidebar-chev-opacity: 0.4;
}

.dark {
    color-scheme: dark;
    --color-background: #101828;
    --color-surface: #1d2939;
    --color-surface-muted: #111827;
    --color-foreground: #f9fafb;
    --color-muted-foreground: #98a2b3;
    --color-border: #344054;
    --color-border-strong: #475467;
    --color-hover-bg: rgba(255, 255, 255, 0.06);
    --brand-soft: rgba(5, 150, 105, 0.18);
    /* ── Sidebar tokens (dark navy) ── */
    --sidebar-bg: #059669;
    --sidebar-border: rgba(255,255,255,0.06);
    --sidebar-link-color: rgba(255,255,255,0.62);
    --sidebar-link-hover-bg: rgba(255,255,255,0.08);
    --sidebar-link-hover-color: #ffffff;
    --sidebar-link-active-bg: rgba(255,255,255,0.14);
    --sidebar-link-active-color: #ffffff;
    --sidebar-logo-text: #ffffff;
    --sidebar-logo-mark-bg: rgba(255,255,255,0.15);
    --sidebar-logo-mark-border: rgba(255,255,255,0.22);
    --sidebar-logo-mark-color: #ffffff;
    --sidebar-close-color: rgba(255,255,255,0.55);
    --sidebar-close-border: rgba(255,255,255,0.14);
    --sidebar-section-label: rgba(255,255,255,0.32);
    --sidebar-sub-line: rgba(255,255,255,0.14);
    --sidebar-footer-border: rgba(255,255,255,0.1);
    --sidebar-user-bg: rgba(255,255,255,0.07);
    --sidebar-user-border: rgba(255,255,255,0.1);
    --sidebar-user-avatar-bg: rgba(255,255,255,0.18);
    --sidebar-user-avatar-color: #ffffff;
    --sidebar-user-avatar-border: rgba(255,255,255,0.22);
    --sidebar-user-name: #ffffff;
    --sidebar-user-role: rgba(255,255,255,0.42);
    --sidebar-signout-color: rgba(255,255,255,0.45);
    --sidebar-signout-hover-bg: rgba(239,68,68,0.18);
    --sidebar-signout-hover-color: #fca5a5;
    --sidebar-icon-opacity: 0.62;
    --sidebar-scroll: rgba(255,255,255,0.1);
    --sidebar-group-label-color: rgba(255,255,255,0.62);
    --sidebar-group-active-color: #ffffff;
    --sidebar-chev-opacity: 0.45;
}

a { color: #059669; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Page wrapper ── */
.cw-page {
    padding: 1rem 1rem 2rem;
    max-width: 100%;
}
@media (min-width: 768px)  { .cw-page { padding: 1.5rem 1.5rem 2rem; } }
@media (min-width: 1024px) { .cw-page { padding: 1.75rem 2rem 2rem; } }

/* ── Page Header ── */
.cw-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--color-border, #e4e7ec);
    flex-wrap: wrap;
}
.cw-page-header-left { flex: 1; min-width: 0; }
.cw-page-title {
    font-size: var(--fs-lg);
    font-weight: 700;
    color: var(--color-foreground, #101828);
    letter-spacing: -0.02em;
    line-height: 1.3;
}
.cw-page-subtitle {
    font-size: var(--fs-sm);
    color: var(--color-muted-foreground, #667085);
    margin-top: 0.15rem;
    line-height: 1.5;
}
.cw-page-header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
    flex-wrap: wrap;
}

/* ── Section label ── */
.cw-section-label {
    font-size: var(--fs-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--color-muted-foreground, #667085);
    margin-bottom: 0.6rem;
}

/* ═══════════ CARD ═══════════ */
.cw-card {
    background: var(--color-surface, #fff);
    border: 1px solid var(--color-border, #e4e7ec);
    border-radius: var(--radius-xl);
    box-shadow: 0 1px 3px rgba(16,24,40,0.04), 0 1px 2px rgba(16,24,40,0.03);
    padding: 1.375rem 1.5rem;
    margin-bottom: 1.25rem;
    transition: box-shadow 0.18s ease;
}
.cw-card:hover { box-shadow: 0 4px 16px rgba(16,24,40,0.07), 0 1px 4px rgba(16,24,40,0.04); }

/* nested / list-item cards don't need the section gap */
.cw-card--flat { box-shadow: none; margin-bottom: 0; padding: 1rem 1.25rem; }
.cw-card--flat:hover { box-shadow: none; }
.cw-card .cw-card { margin-bottom: 0; }

.cw-card--accent-l { border-left: 3px solid #059669; }

.cw-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 1.125rem;
    padding-bottom: 0.875rem;
    border-bottom: 1px solid var(--color-border, #f2f4f7);
}
.cw-card-title {
    font-size: var(--fs-md);
    font-weight: 600;
    color: var(--color-foreground, #101828);
    letter-spacing: -0.01em;
}
.cw-card-subtitle {
    font-size: var(--fs-xs);
    color: var(--color-muted-foreground, #667085);
    margin-top: 0.15rem;
    line-height: 1.5;
}
.cw-card-footer {
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--color-border, #e4e7ec);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

/* ═══════════ KPI / STAT CARD ═══════════ */
.cw-stat {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}
.cw-stat-label {
    font-size: var(--fs-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--color-muted-foreground, #667085);
}
.cw-stat-value {
    font-size: var(--fs-3xl);
    font-weight: 700;
    color: var(--color-foreground, #101828);
    letter-spacing: -0.025em;
    line-height: 1;
}
.cw-stat-meta {
    font-size: var(--fs-xs);
    color: var(--color-muted-foreground, #667085);
    display: flex;
    align-items: center;
    gap: 0.3rem;
    flex-wrap: wrap;
}
.cw-stat-up   { color: #027a48; font-weight: 600; }
.cw-stat-down { color: #b42318; font-weight: 600; }

/* ═══════════ BUTTONS ═══════════ */
.cw-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    font-size: var(--fs-sm);
    font-weight: 600;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s, transform 0.1s;
    text-decoration: none;
    white-space: nowrap;
    line-height: 1.4;
    font-family: inherit;
    letter-spacing: 0.005em;
}
.cw-btn:active { transform: scale(0.98); }
.cw-btn:disabled,
.cw-btn[disabled] { opacity: 0.48; cursor: not-allowed; pointer-events: none; }

/* Primary — filled brand */
.cw-btn-primary {
    background: #059669;
    color: #fff;
    border-color: #059669;
    box-shadow: 0 1px 2px rgba(5, 150, 105,0.2);
}
.cw-btn-primary:hover:not(:disabled) {
    background: #047857;
    border-color: #047857;
    box-shadow: 0 2px 8px rgba(5, 150, 105,0.28);
    color: #fff;
    text-decoration: none;
}

/* Secondary — light outline */
.cw-btn-secondary {
    background: var(--color-surface, #fff);
    color: var(--color-foreground, #344054);
    border-color: var(--color-border, #d0d5dd);
    box-shadow: 0 1px 2px rgba(16,24,40,0.05);
}
.cw-btn-secondary:hover:not(:disabled) {
    background: var(--color-hover-bg, #f9fafb);
    border-color: var(--color-border-strong, #c1c7d0);
    color: var(--color-foreground, #1d2939);
    text-decoration: none;
}

/* Ghost — no border */
.cw-btn-ghost {
    background: transparent;
    color: var(--color-muted-foreground, #667085);
    border-color: transparent;
}
.cw-btn-ghost:hover:not(:disabled) {
    background: var(--color-hover-bg, rgba(0,0,0,0.05));
    color: var(--color-foreground, #1d2939);
    text-decoration: none;
}

/* Danger */
.cw-btn-danger {
    background: #fff1f0;
    color: #b42318;
    border-color: #fecdca;
}
.cw-btn-danger:hover:not(:disabled) {
    background: #fde8e8;
    color: #912018;
    border-color: #fca5a5;
    text-decoration: none;
}
.cw-btn-danger-solid {
    background: #d92d20;
    color: #fff;
    border-color: #d92d20;
    box-shadow: 0 1px 2px rgba(217,45,32,0.2);
}
.cw-btn-danger-solid:hover:not(:disabled) {
    background: #b42318;
    text-decoration: none;
}

/* Success */
.cw-btn-success {
    background: #ecfdf3;
    color: #027a48;
    border-color: #a9efc5;
}
.cw-btn-success:hover:not(:disabled) {
    background: #d1fadf;
    text-decoration: none;
}

/* Sizes */
.cw-btn-sm  { padding: 0.375rem 0.75rem; font-size: var(--fs-xs); border-radius: var(--radius-sm); }
.cw-btn-lg  { padding: 0.7rem 1.5rem; font-size: var(--fs-md); border-radius: var(--radius-md); }
.cw-btn-icon {
    padding: 0.45rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border, #e4e7ec);
    background: var(--color-surface, #fff);
    color: var(--color-muted-foreground, #667085);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
}
.cw-btn-icon:hover { background: var(--color-hover-bg, rgba(0,0,0,0.05)); color: var(--color-foreground); }
.cw-btn-icon svg { width: 15px; height: 15px; }

/* ═══════════ INPUTS / FORMS ═══════════ */
.cw-form-group { margin-bottom: 1rem; }
.cw-form-group:last-child { margin-bottom: 0; }

.cw-label {
    display: block;
    margin-bottom: 0.35rem;
    font-size: var(--fs-sm);
    font-weight: 500;
    color: var(--color-foreground, #344054);
}
.cw-label-hint {
    font-size: var(--fs-xs);
    font-weight: 400;
    color: var(--color-muted-foreground, #667085);
    margin-left: 0.25rem;
}

.cw-input,
.cw-select,
.cw-textarea {
    width: 100%;
    padding: 0.525rem 0.8rem;
    font-size: var(--fs-sm);
    font-family: inherit;
    border: 1px solid var(--color-border, #d0d5dd);
    border-radius: var(--radius-md);
    background: var(--color-surface, #fff);
    color: var(--color-foreground, #1d2939);
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
    line-height: 1.5;
    appearance: none;
    box-shadow: 0 1px 2px rgba(16,24,40,0.04);
}
.cw-input:focus,
.cw-select:focus,
.cw-textarea:focus {
    border-color: #059669;
    box-shadow: 0 0 0 3px rgba(5, 150, 105,0.10), 0 1px 2px rgba(16,24,40,0.04);
}
.cw-input::placeholder,
.cw-textarea::placeholder { color: #98a2b3; }
.cw-input:disabled,
.cw-select:disabled,
.cw-textarea:disabled { background: #f9fafb; color: #98a2b3; cursor: not-allowed; }
.dark .cw-input:disabled,
.dark .cw-select:disabled,
.dark .cw-textarea:disabled { background: rgba(255,255,255,0.03); color: #475467; }

.cw-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%236B7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3E%3C/svg%3E");
    background-position: right 0.65rem center;
    background-repeat: no-repeat;
    background-size: 1.1em;
    padding-right: 2rem;
    cursor: pointer;
}

.cw-textarea { resize: vertical; min-height: 80px; }

.cw-input-error { border-color: #fda29b !important; }
.cw-input-error:focus { box-shadow: 0 0 0 3px rgba(240,68,56,0.12) !important; }
.cw-field-error { font-size: var(--fs-xs); color: #d92d20; margin-top: 0.25rem; }
.cw-field-hint  { font-size: var(--fs-xs); color: var(--color-muted-foreground,#667085); margin-top: 0.25rem; }

/* Input group (icon+input) */
.cw-input-group { position: relative; }
.cw-input-group .cw-input { padding-left: 2.2rem; }
.cw-input-group-icon {
    position: absolute;
    left: 0.65rem;
    top: 50%;
    transform: translateY(-50%);
    color: #98a2b3;
    width: 15px;
    height: 15px;
    pointer-events: none;
}

/* Form row layout */
.cw-form-row {
    display: grid;
    gap: 1rem;
    grid-template-columns: 1fr;
}
@media (min-width: 640px) { .cw-form-row-2 { grid-template-columns: 1fr 1fr; } }
@media (min-width: 640px) { .cw-form-row-3 { grid-template-columns: 1fr 1fr 1fr; } }

/* Checkbox input sizing */
input.cw-checkbox, input[type="checkbox"].cw-checkbox {
    width: 1rem;
    height: 1rem;
    flex-shrink: 0;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border, #d0d5dd);
    accent-color: #059669;
    cursor: pointer;
}
/* When .cw-checkbox is on a <label> wrapper it becomes a flex row, not a box */
label.cw-checkbox {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: var(--fs-md);
    width: auto;
    height: auto;
}
label.cw-checkbox input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
    flex-shrink: 0;
    accent-color: #059669;
    cursor: pointer;
}

/* ═══════════ TABLES ═══════════ */
.cw-table-wrap {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border, #e4e7ec);
    background: var(--color-surface, #fff);
}
.cw-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--fs-sm);
}
.cw-table thead th {
    text-align: left;
    padding: 0.6rem 1rem;
    font-size: var(--fs-2xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-muted-foreground, #667085);
    background: #f9fafb;
    border-bottom: 1px solid var(--color-border, #e4e7ec);
    white-space: nowrap;
}
.cw-table thead th:first-child { border-radius: var(--radius-lg) 0 0 0; }
.cw-table thead th:last-child  { border-radius: 0 0.75rem 0 0; }
.cw-table tbody td {
    padding: 0.7rem 1rem;
    border-bottom: 1px solid var(--color-border, #f2f4f7);
    color: var(--color-foreground, #344054);
    vertical-align: middle;
}
.cw-table tbody tr:last-child td { border-bottom: none; }
.cw-table tbody tr:hover { background: #f9fafb; }
.cw-table tfoot td {
    padding: 0.65rem 1rem;
    border-top: 1px solid var(--color-border, #e4e7ec);
    font-size: var(--fs-sm);
    color: var(--color-muted-foreground, #667085);
    background: #f9fafb;
}
.cw-table-cell-muted { color: var(--color-muted-foreground, #667085); }
.cw-table-cell-mono  { font-family: 'Courier New', monospace; font-size: var(--fs-sm); }

/* ═══════════ BADGES ═══════════ */
.cw-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.18rem 0.6rem;
    border-radius: 9999px;
    font-size: var(--fs-xs);
    font-weight: 600;
    white-space: nowrap;
    line-height: 1.4;
}
.cw-badge-brand   { background: rgba(5, 150, 105,0.1); color: #059669; }
.cw-badge-success { background: #ecfdf3; color: #027a48; }
.cw-badge-warning { background: #fffaeb; color: #b54708; }
.cw-badge-danger  { background: #fef3f2; color: #b42318; }
.cw-badge-muted   { background: #f2f4f7; color: #475467; }
.cw-badge-purple  { background: rgba(107,63,160,0.1); color: #6b3fa0; }
.cw-badge-teal    { background: rgba(14,159,110,0.1); color: #0e9f6e; }
.cw-badge-orange  { background: rgba(249,115,22,0.1); color: #c2410c; }
.cw-badge-dot::before {
    content: '';
    display: inline-block;
    width: 6px; height: 6px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
}

/* ═══════════ MODALS ═══════════ */
.cw-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(16,24,40,0.5);
    backdrop-filter: blur(3px);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    animation: cwFadeIn 0.15s ease;
}
@keyframes cwFadeIn { from { opacity: 0; } to { opacity: 1; } }

.cw-modal {
    background: var(--color-surface, #fff);
    border-radius: var(--radius-xl);
    border: 1px solid var(--color-border, #e4e7ec);
    box-shadow: 0 20px 60px rgba(16,24,40,0.2);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    animation: cwSlideUp 0.2s ease;
}
.cw-modal-lg  { max-width: 760px; }
.cw-modal-xl  { max-width: 1000px; }
.cw-modal-sm  { max-width: 400px; }
@keyframes cwSlideUp {
    from { opacity: 0; transform: translateY(12px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.cw-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--color-border, #e4e7ec);
}
.cw-modal-title {
    font-size: var(--fs-base);
    font-weight: 700;
    color: var(--color-foreground, #1d2939);
    letter-spacing: -0.01em;
}
.cw-modal-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px; height: 28px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border, #e4e7ec);
    background: transparent;
    color: #98a2b3;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
}
.cw-modal-close:hover { background: #fee4e2; color: #b42318; border-color: #fecdca; }
.cw-modal-body { padding: 1.5rem; }
.cw-modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--color-border, #e4e7ec);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* ═══════════ ALERTS / NOTICES ═══════════ */
.cw-alert {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.9rem 1rem;
    border-radius: var(--radius-lg);
    font-size: var(--fs-sm);
    border: 1px solid;
    line-height: 1.5;
    margin-bottom: 1rem;
}
.cw-alert-icon { flex-shrink: 0; width: 17px; height: 17px; margin-top: 1px; }
.cw-alert-success { background: #ecfdf3; border-color: #a9efc5; color: #027a48; }
.cw-alert-error   { background: #fef3f2; border-color: #fecdca; color: #b42318; }
.cw-alert-warning { background: #fffaeb; border-color: #fedf89; color: #b54708; }
.cw-alert-info    { background: rgba(5, 150, 105,0.06); border-color: rgba(5, 150, 105,0.2); color: #059669; }

/* ═══════════ EMPTY STATE ═══════════ */
.cw-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 3rem 1rem;
    gap: 0.75rem;
}
.cw-empty-icon {
    width: 44px; height: 44px;
    color: #d0d5dd;
}
.cw-empty-title {
    font-size: var(--fs-md);
    font-weight: 600;
    color: var(--color-foreground, #1d2939);
}
.cw-empty-desc {
    font-size: var(--fs-sm);
    color: var(--color-muted-foreground, #667085);
    max-width: 320px;
}

/* ═══════════ SPINNER / LOADING ═══════════ */
.cw-spinner {
    display: inline-block;
    width: 18px; height: 18px;
    border: 2px solid rgba(5, 150, 105,0.2);
    border-top-color: #059669;
    border-radius: 50%;
    animation: cwSpin 0.65s linear infinite;
}
.cw-spinner-sm { width: 14px; height: 14px; }
.cw-spinner-lg { width: 32px; height: 32px; border-width: 3px; }
@keyframes cwSpin { to { transform: rotate(360deg); } }

.cw-loading-overlay {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 1rem;
    gap: 0.75rem;
    color: var(--color-muted-foreground, #667085);
    font-size: var(--fs-sm);
}

/* ═══════════ TABS ═══════════ */
.cw-tabs {
    display: flex;
    gap: 0.15rem;
    border-bottom: 1px solid var(--color-border, #e4e7ec);
    overflow-x: auto;
    scrollbar-width: none;
    margin-bottom: 1.25rem;
}
.cw-tabs::-webkit-scrollbar { display: none; }
.cw-tab {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.65rem 0.9rem;
    font-size: var(--fs-sm);
    font-weight: 500;
    color: var(--color-muted-foreground, #667085);
    border-bottom: 2px solid transparent;
    cursor: pointer;
    white-space: nowrap;
    transition: color 0.15s, border-color 0.15s;
    background: transparent;
    border-top: none;
    border-left: none;
    border-right: none;
    font-family: inherit;
    margin-bottom: -1px;
}
.cw-tab:hover { color: var(--color-foreground, #1d2939); }
.cw-tab--active { color: #059669 !important; border-bottom-color: #059669; font-weight: 600; }
.cw-tab-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px; height: 18px;
    padding: 0 5px;
    border-radius: 9999px;
    font-size: var(--fs-2xs);
    font-weight: 700;
    background: rgba(5, 150, 105,0.1);
    color: #059669;
}

/* ═══════════ DIVIDER ═══════════ */
.cw-divider {
    height: 1px;
    background: var(--color-border, #e4e7ec);
    margin: 1rem 0;
    border: none;
}
.cw-divider-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--color-muted-foreground, #667085);
    font-size: var(--fs-xs);
    font-weight: 500;
    margin: 1rem 0;
}
.cw-divider-label::before,
.cw-divider-label::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--color-border, #e4e7ec);
}

/* ═══════════ AVATAR ═══════════ */
.cw-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: linear-gradient(135deg, #059669, #34d399);
    color: #fff;
    font-weight: 700;
    flex-shrink: 0;
    font-size: var(--fs-2xs);
    width: 30px;
    height: 30px;
}
.cw-avatar-sm { width: 24px; height: 24px; font-size: var(--fs-2xs); }
.cw-avatar-lg { width: 40px; height: 40px; font-size: var(--fs-sm); }
.cw-avatar-xl { width: 52px; height: 52px; font-size: var(--fs-base); }

.cw-avatar-group { display: flex; }
.cw-avatar-group .cw-avatar { border: 2px solid var(--color-surface, #fff); margin-left: -6px; }
.cw-avatar-group .cw-avatar:first-child { margin-left: 0; }

/* ═══════════ FILTER BAR ═══════════ */
.cw-filter-bar {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

/* ═══════════ PAGINATION ═══════════ */
.cw-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding-top: 0.75rem;
    font-size: var(--fs-sm);
    color: var(--color-muted-foreground, #667085);
    flex-wrap: wrap;
}
.cw-pagination-btns { display: flex; align-items: center; gap: 0.25rem; }
.cw-page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 0.4rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border, #d0d5dd);
    background: var(--color-surface, #fff);
    color: var(--color-foreground, #344054);
    font-size: var(--fs-sm);
    font-weight: 500;
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
    font-family: inherit;
}
.cw-page-btn:hover { background: #f2f4f7; }
.cw-page-btn--active { background: #059669; color: #fff; border-color: #059669; }
.cw-page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ═══════════ DROPDOWN ═══════════ */
.cw-dropdown-wrap { position: relative; display: inline-block; }
.cw-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 180px;
    background: var(--color-surface, #fff);
    border: 1px solid var(--color-border, #e4e7ec);
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 24px rgba(16,24,40,0.12);
    padding: 0.4rem;
    z-index: 100;
    animation: cwFadeIn 0.12s ease;
}
.cw-dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0.65rem;
    border-radius: var(--radius-sm);
    font-size: var(--fs-sm);
    color: var(--color-foreground, #344054);
    cursor: pointer;
    transition: background 0.12s;
    background: transparent;
    border: none;
    width: 100%;
    text-align: left;
    font-family: inherit;
    text-decoration: none;
}
.cw-dropdown-item:hover { background: #f2f4f7; text-decoration: none; }
.cw-dropdown-item--danger { color: #b42318; }
.cw-dropdown-item--danger:hover { background: #fef3f2; }
.cw-dropdown-divider { height: 1px; background: var(--color-border, #e4e7ec); margin: 0.3rem 0; }

/* ═══════════ CUSTOM SELECT (CwSelect) ═══════════ */
/* Replaces native <select> so dark-mode dropdown list is fully styleable */
.cw-sel-backdrop {
    position: fixed;
    inset: 0;
    z-index: 55;
}
.cw-sel-wrap {
    position: relative;
    display: block;
    width: 100%;
}
.cw-sel-trigger {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.525rem 0.8rem;
    font-size: var(--fs-sm);
    font-family: inherit;
    line-height: 1.5;
    border: 1px solid var(--color-border, #d0d5dd);
    border-radius: var(--radius-md);
    background: var(--color-surface, #fff);
    color: var(--color-foreground, #1d2939);
    text-align: left;
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s;
    box-shadow: 0 1px 2px rgba(16,24,40,0.04);
    min-height: 38px;
}
.cw-sel-trigger:focus {
    outline: none;
    border-color: #059669;
    box-shadow: 0 0 0 3px rgba(5, 150, 105,0.10), 0 1px 2px rgba(16,24,40,0.04);
}
.cw-sel-trigger:disabled { background: #f9fafb; color: #98a2b3; cursor: not-allowed; }
.dark .cw-sel-trigger {
    background: rgba(255,255,255,0.06);
    border-color: rgba(255,255,255,0.1);
    color: #f8fafc;
}
.dark .cw-sel-trigger:focus {
    border-color: rgba(255,255,255,0.35);
    box-shadow: 0 0 0 3px rgba(255,255,255,0.06);
}
.dark .cw-sel-trigger:disabled { background: rgba(255,255,255,0.03); color: #475467; }
.cw-sel-value { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; }
.cw-sel-placeholder { color: #98a2b3; }
.dark .cw-sel-placeholder { color: #475467; }
.cw-sel-chev {
    width: 1.1em; height: 1.1em;
    flex-shrink: 0;
    color: #6b7280;
    transition: transform 0.15s;
}
.cw-sel-wrap--open .cw-sel-chev { transform: rotate(180deg); }
.dark .cw-sel-chev { color: #98a2b3; }

.cw-sel-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 60;
    background: var(--color-surface, #ffffff);
    border: 1px solid var(--color-border, #e4e7ec);
    border-radius: var(--radius-md);
    box-shadow: 0 4px 20px rgba(0,0,0,0.12), 0 2px 8px rgba(0,0,0,0.06);
    max-height: 260px;
    overflow-y: auto;
    padding: 0.25rem 0;
}
.dark .cw-sel-dropdown {
    background: #1d2939;
    border-color: #344054;
    box-shadow: 0 4px 20px rgba(0,0,0,0.45), 0 2px 8px rgba(0,0,0,0.25);
}
.cw-sel-option {
    display: block;
    width: 100%;
    padding: 0.475rem 0.8rem;
    font-size: var(--fs-sm);
    font-family: inherit;
    line-height: 1.5;
    text-align: left;
    color: var(--color-foreground, #1d2939);
    background: transparent;
    border: none;
    cursor: pointer;
    transition: background 0.1s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cw-sel-option:hover { background: var(--color-hover-bg, rgba(0,0,0,0.04)); }
.cw-sel-option--selected {
    background: rgba(5, 150, 105,0.08);
    color: #059669;
    font-weight: 600;
}
.dark .cw-sel-option { color: #e4e7ec; }
.dark .cw-sel-option:hover { background: rgba(255,255,255,0.06); }
.dark .cw-sel-option--selected { background: rgba(255,255,255,0.1); color: #93c5fd; }
.cw-sel-search-wrap {
    position: sticky;
    top: 0;
    padding: 0.35rem 0.45rem;
    background: var(--color-surface, #fff);
    border-bottom: 1px solid var(--color-border, #f2f4f7);
    z-index: 1;
}
.dark .cw-sel-search-wrap { background: #1d2939; border-color: #344054; }
.cw-sel-search {
    width: 100%;
    padding: 0.4rem 0.65rem;
    font-size: var(--fs-sm);
    font-family: inherit;
    border: 1px solid var(--color-border, #d0d5dd);
    border-radius: var(--radius-sm);
    background: var(--color-background, #f9fafb);
    color: var(--color-foreground, #1d2939);
    outline: none;
}
.cw-sel-search:focus { border-color: #059669; box-shadow: 0 0 0 3px rgba(5, 150, 105,0.1); }
.dark .cw-sel-search {
    background: rgba(255,255,255,0.06);
    border-color: rgba(255,255,255,0.12);
    color: #f8fafc;
}
.cw-sel-empty {
    padding: 0.6rem 0.8rem;
    font-size: var(--fs-sm);
    color: #98a2b3;
}

/* ═══════════ DARK MODE OVERRIDES ═══════════ */
.dark .cw-card { border-color: rgba(255,255,255,0.08); }
.dark .cw-table thead th { background: rgba(255,255,255,0.04); }
.dark .cw-table tbody tr:hover { background: rgba(255,255,255,0.04); }
.dark .cw-table-wrap { background: var(--color-surface); border-color: rgba(255,255,255,0.08); }
.dark .cw-input,
.dark .cw-select,
.dark .cw-textarea {
    color-scheme: dark;
    background: rgba(255,255,255,0.06);
    border-color: rgba(255,255,255,0.1);
    color: #f8fafc;
}
.dark .cw-input:focus,
.dark .cw-select:focus,
.dark .cw-textarea:focus { border-color: #059669; }
.dark .cw-input::placeholder,
.dark .cw-textarea::placeholder { color: #475467; }
.dark .cw-btn-secondary {
    background: rgba(255,255,255,0.06);
    border-color: rgba(255,255,255,0.1);
    color: #f8fafc;
}
.dark .cw-btn-icon { background: rgba(255,255,255,0.06); border-color: rgba(255,255,255,0.1); }
.dark .cw-modal { border-color: rgba(255,255,255,0.1); }
.dark .cw-tabs { border-bottom-color: rgba(255,255,255,0.08); }
.dark .cw-badge-muted { background: rgba(255,255,255,0.08); color: #98a2b3; }
.dark .cw-dropdown { border-color: rgba(255,255,255,0.1); }
.dark .cw-dropdown-item:hover { background: rgba(255,255,255,0.06); }
.dark .cw-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%2398A2B3' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3E%3C/svg%3E");
}
.dark .cw-page-btn { background: rgba(255,255,255,0.06); border-color: rgba(255,255,255,0.1); color: #f8fafc; }
.dark .cw-page-btn:hover { background: rgba(255,255,255,0.1); }
.dark .cw-alert-success { background: rgba(2,122,72,0.1); border-color: rgba(2,122,72,0.2); }
.dark .cw-alert-error   { background: rgba(180,35,24,0.1); border-color: rgba(180,35,24,0.2); }
.dark .cw-alert-warning { background: rgba(181,71,8,0.1); border-color: rgba(181,71,8,0.2); }

/* ═══════════ AUTOFILL FIXES ═══════════ */
.dark input:-webkit-autofill,
.dark input:-webkit-autofill:hover,
.dark input:-webkit-autofill:focus,
.dark textarea:-webkit-autofill,
.dark select:-webkit-autofill {
    -webkit-text-fill-color: #f4f4f5 !important;
    -webkit-box-shadow: 0 0 0px 1000px #27272a inset !important;
    transition: background-color 5000s ease-in-out 0s;
}
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
textarea:-webkit-autofill,
select:-webkit-autofill {
    -webkit-text-fill-color: #18181b !important;
    -webkit-box-shadow: 0 0 0px 1000px #f4f4f5 inset !important;
    transition: background-color 5000s ease-in-out 0s;
}

/* ═══════════ BLAZOR SYSTEM ═══════════ */
.valid.modified:not([type=checkbox]) { outline: 1px solid #12b76a; }
.invalid { outline: 1px solid #f04438; }
.validation-message { color: #d92d20; font-size: var(--fs-xs); margin-top: 0.2rem; }

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}
.blazor-error-boundary::after { content: "An error has occurred."; }

/* ═══════════ GRID UTILITIES ═══════════ */
.cw-grid-2 { display: grid; gap: 1.25rem; grid-template-columns: 1fr; }
.cw-grid-3 { display: grid; gap: 1.25rem; grid-template-columns: 1fr; }
.cw-grid-4 { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 640px) {
    .cw-grid-2 { grid-template-columns: repeat(2, 1fr); }
    .cw-grid-3 { grid-template-columns: repeat(2, 1fr); }
    .cw-grid-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1024px) {
    .cw-grid-3 { grid-template-columns: repeat(3, 1fr); }
    .cw-grid-4 { grid-template-columns: repeat(4, 1fr); }
}

/* On tablet (2-col), collapse all explicit span declarations so form+list
   panels stack as equal columns instead of producing orphaned half-width panels */
@media (min-width: 640px) and (max-width: 1023px) {
    .cw-grid-3 > * { grid-column: span 1 !important; }
}

/* Full-width item inside any grid (use instead of inline style="grid-column:span N") */
.cw-col-full { grid-column: 1 / -1; }
@media (min-width: 640px) { .cw-col-full-sm { grid-column: 1 / -1; } }

/* Horizontal scroll container for wide fixed-column content (e.g. calendar views) */
.cw-scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ═══════════ FLEX UTILITIES ═══════════ */
.cw-flex-between { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.cw-flex-center  { display: flex; align-items: center; justify-content: center; gap: 0.5rem; }
.cw-flex-start   { display: flex; align-items: center; gap: 0.5rem; }
.cw-flex-wrap    { flex-wrap: wrap; }
.cw-flex-1       { flex: 1; min-width: 0; }

/* ═══════════ TEXT UTILITIES ═══════════ */
.cw-text-muted   { color: var(--color-muted-foreground, #667085); }
.cw-text-sm      { font-size: var(--fs-sm); }
.cw-text-xs      { font-size: var(--fs-xs); }
.cw-text-bold    { font-weight: 700; }
.cw-text-semi    { font-weight: 600; }
.cw-text-mono    { font-family: 'Courier New', monospace; }
.cw-text-up      { color: #027a48; }
.cw-text-down    { color: #b42318; }
.cw-text-brand   { color: #059669; }
.cw-truncate     { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ═══════════ SPACING UTILITIES ═══════════ */
.cw-space-y-4 > * + * { margin-top: 1rem; }
.cw-space-y-6 > * + * { margin-top: 1.5rem; }
.cw-mb-4 { margin-bottom: 1rem; }
.cw-mb-6 { margin-bottom: 1.5rem; }
.cw-gap-3 { gap: 0.75rem; }
.cw-gap-4 { gap: 1rem; }

/* ═══════════ GLOBAL TAILWIND COMPATIBILITY OVERRIDES ═══════════ */

/* Page wrapper */
.mx-auto.max-w-4xl,
.mx-auto.max-w-5xl {
    padding: 1.25rem 1rem !important;
    max-width: 100% !important;
}
@media (min-width: 768px) {
    .mx-auto.max-w-4xl,
    .mx-auto.max-w-5xl {
        padding: 1.75rem 1.5rem !important;
    }
}
@media (min-width: 1024px) {
    .mx-auto.max-w-4xl,
    .mx-auto.max-w-5xl {
        padding: 2rem 2.5rem !important;
    }
}

/* Page titles */
.text-2xl.font-bold.tracking-tight {
    font-size: var(--fs-xl) !important;
    font-weight: 700 !important;
    color: var(--color-foreground, #1d2939) !important;
    letter-spacing: -0.02em !important;
    line-height: 1.3 !important;
}

/* Cards (Standard Tailwind layouts) */
.rounded-2xl.border.border-slate-200\/60,
.rounded-xl.border.border-slate-250 {
    background: var(--color-surface, #fff) !important;
    border: 1px solid var(--color-border, #e4e7ec) !important;
    border-radius: var(--radius-xl) !important;
    box-shadow: 0 1px 3px rgba(16, 24, 40, 0.06), 0 1px 2px rgba(16, 24, 40, 0.04) !important;
    padding: 1.25rem !important;
    transition: box-shadow 0.15s !important;
}
.rounded-2xl.border.border-slate-200\/60:hover,
.rounded-xl.border.border-slate-250:hover {
    box-shadow: 0 4px 12px rgba(16,24,40,0.08) !important;
}

/* Inputs, Selects, Textareas */
input[type="text"].w-full.rounded-lg.border.border-slate-300,
input[type="number"].w-full.rounded-lg.border.border-slate-300,
input[type="date"].w-full.rounded-lg.border.border-slate-300,
input[type="datetime-local"].w-full.rounded-lg.border.border-slate-300,
select.w-full.rounded-lg.border.border-slate-300,
textarea.w-full.rounded-lg.border.border-slate-300 {
    width: 100% !important;
    padding: 0.55rem 0.8rem !important;
    font-size: var(--fs-sm) !important;
    border: 1px solid var(--color-border, #d0d5dd) !important;
    border-radius: var(--radius-md) !important;
    background: var(--color-surface, #fff) !important;
    color: var(--color-foreground, #1d2939) !important;
    outline: none !important;
    transition: border-color 0.15s, box-shadow 0.15s !important;
    line-height: 1.5 !important;
}
.dark input[type="text"].w-full.rounded-lg.border,
.dark input[type="number"].w-full.rounded-lg.border,
.dark input[type="date"].w-full.rounded-lg.border,
.dark select.w-full.rounded-lg.border,
.dark textarea.w-full.rounded-lg.border {
    color-scheme: dark !important;
    background: rgba(255,255,255,0.06) !important;
    border-color: rgba(255,255,255,0.1) !important;
    color: #f8fafc !important;
}

input:-webkit-autofill,
input:-webkit-autofill:hover, 
input:-webkit-autofill:focus,
textarea:-webkit-autofill,
textarea:-webkit-autofill:hover,
textarea:-webkit-autofill:focus,
select:-webkit-autofill,
select:-webkit-autofill:hover,
select:-webkit-autofill:focus {
    -webkit-text-fill-color: #18181b !important; /* zinc-900 */
    -webkit-box-shadow: 0 0 0px 1000px #f4f4f5 inset !important; /* zinc-100 */
    transition: background-color 5000s ease-in-out 0s;
}
/* Form labels */
label.block.text-sm.text-slate-600 {
    font-size: var(--fs-sm) !important;
    font-weight: 500 !important;
    color: var(--color-foreground, #344054) !important;
    margin-bottom: 0.35rem !important;
}

/* Primary buttons */
.rounded-xl.bg-brand-500,
.rounded-lg.bg-brand-500,
.bg-brand-500 {
    background: #059669 !important;
    color: #fff !important;
    border: 1px solid #059669 !important;
    border-radius: var(--radius-md) !important;
    font-weight: 600 !important;
    font-size: var(--fs-sm) !important;
    padding: 0.55rem 1.1rem !important;
    box-shadow: none !important;
    transition: background 0.15s, border-color 0.15s !important;
}
.rounded-xl.bg-brand-500:hover,
.rounded-lg.bg-brand-500:hover,
.bg-brand-500:hover {
    background: #047857 !important;
    border-color: #047857 !important;
}

/* Secondary/Ghost buttons */
.rounded-lg.border.border-slate-300,
.border.border-slate-300 {
    background: var(--color-surface, #fff) !important;
    color: var(--color-foreground, #344054) !important;
    border-color: var(--color-border, #d0d5dd) !important;
    border-radius: var(--radius-md) !important;
    font-weight: 600 !important;
    font-size: var(--fs-sm) !important;
    padding: 0.55rem 1.1rem !important;
    transition: background 0.15s !important;
}
.dark .rounded-lg.border.border-slate-300,
.dark .border.border-slate-300 {
    background: rgba(255,255,255,0.06) !important;
    border-color: rgba(255,255,255,0.1) !important;
    color: #f8fafc !important;
}

/* Warning Alerts */
.rounded-xl.border.border-amber-300\/50 {
    background: #fffaeb !important;
    border: 1px solid #fedf89 !important;
    color: #b54708 !important;
    border-radius: var(--radius-lg) !important;
    padding: 0.9rem 1rem !important;
}
.dark .rounded-xl.border.border-amber-300\/50 {
    background: rgba(181,71,8,0.1) !important;
    border-color: rgba(181,71,8,0.2) !important;
    color: #fffaeb !important;
}

/* Error Alerts */
.rounded-xl.border.border-red-300\/60 {
    background: #fef3f2 !important;
    border: 1px solid #fecdca !important;
    color: #b42318 !important;
    border-radius: var(--radius-lg) !important;
    padding: 0.9rem 1rem !important;
}
.dark .rounded-xl.border.border-red-300\/60 {
    background: rgba(180,35,24,0.1) !important;
    border-color: rgba(180,35,24,0.2) !important;
    color: #fef3f2 !important;
}

/* The accounting (.acc-*) rules live in one layer at the end of this file. */

/* ═══════════ MOBILE / TOUCH IMPROVEMENTS ═══════════ */

/* Larger tap targets for buttons on touch devices */
@media (max-width: 639px) {
    .cw-btn { min-height: 44px; }
    .cw-btn-sm { min-height: 40px; }
    .cw-input, .cw-select, .cw-textarea { font-size: 16px; } /* prevent iOS zoom on focus */
    .cw-sel-trigger { font-size: 16px; min-height: 42px; }
    .cw-tab { padding: 0.75rem 0.75rem; }
    .cw-page-header { gap: 0.75rem; }
    .cw-card { padding: 1rem 1rem; }
    .cw-modal-body { padding: 1rem; }
    .cw-modal-header { padding: 1rem; }
    .cw-modal-footer { padding: 0.75rem 1rem; }
}

/* Page header actions wrap tightly on phone */
@media (max-width: 479px) {
    .cw-page-header-actions { width: 100%; }
    .cw-page-header-actions .cw-btn { flex: 1; justify-content: center; }
}

/* Filter bar stacks on phone */
@media (max-width: 479px) {
    .cw-filter-bar { gap: 0.5rem; }
    .cw-filter-bar .cw-input,
    .cw-filter-bar .cw-sel-trigger { font-size: 15px; }
}

/* Stat card values slightly smaller on phone */
@media (max-width: 479px) {
    .cw-stat-value { font-size: var(--fs-2xl); }
}

/* ── Row actions menu: one primary button and a "more" (⋮) menu ── */
.cw-ram { display: inline-flex; align-items: center; gap: .25rem; white-space: nowrap; }
.cw-ram-btn { display: inline-flex; align-items: center; justify-content: center; gap: .3rem; min-width: 2rem; height: 2rem; padding: 0 .4rem; border: 1px solid transparent; border-radius: .4rem; background: transparent; color: #64748b; cursor: pointer; transition: background .15s, color .15s; }
.cw-ram-btn:hover { background: #f1f5f9; color: #0f172a; }
.cw-ram-btn:focus-visible { outline: 2px solid #059669; outline-offset: 1px; }
.cw-ram-btn:disabled { opacity: .5; cursor: not-allowed; }
.dark .cw-ram-btn { color: #94a3b8; }
.dark .cw-ram-btn:hover { background: #1e293b; color: #f1f5f9; }
.cw-ram-backdrop { position: fixed; inset: 0; z-index: 1090; }
.cw-ram-pop { position: fixed; z-index: 1100; min-width: 11rem; padding: .25rem; background: #fff; border: 1px solid #e2e8f0; border-radius: .6rem; box-shadow: 0 8px 24px rgba(15, 23, 42, .14), 0 2px 6px rgba(15, 23, 42, .08); }
.dark .cw-ram-pop { background: #1d2939; border-color: #344054; box-shadow: 0 8px 24px rgba(0, 0, 0, .45); }
.cw-ram-item { display: flex; align-items: center; gap: .55rem; width: 100%; padding: .5rem .65rem; border: 0; border-radius: .4rem; background: transparent; color: #334155; font-size: .85rem; text-align: left; cursor: pointer; }
.cw-ram-item:hover { background: #f1f5f9; }
.cw-ram-item:disabled { opacity: .5; cursor: not-allowed; }
.cw-ram-item .cw-ram-icon { display: inline-flex; color: #94a3b8; }
.cw-ram-item--danger { color: #dc2626; }
.cw-ram-item--danger:hover { background: #fef2f2; }
.cw-ram-item--danger .cw-ram-icon { color: #dc2626; }
.dark .cw-ram-item { color: #e2e8f0; }
.dark .cw-ram-item:hover { background: #2a3a50; }
.dark .cw-ram-item--danger { color: #f87171; }
.dark .cw-ram-item--danger:hover { background: #3b1d1d; }
/* A Primary-slot button or link, drawn as a menu entry rather than a coloured button. */
.cw-ram-primary > button, .cw-ram-primary > a { display: flex !important; align-items: center; gap: .55rem; width: 100%; padding: .5rem .65rem !important; border: 0 !important; border-radius: .4rem !important; background: transparent !important; color: #334155 !important; font-size: .85rem !important; font-weight: 500 !important; text-align: left; text-decoration: none; cursor: pointer; box-shadow: none !important; height: auto !important; }
.cw-ram-primary > button:hover, .cw-ram-primary > a:hover { background: #f1f5f9 !important; }
.cw-ram-primary > button:disabled { opacity: .5; cursor: not-allowed; }
.cw-ram-primary > span { display: block; padding: .5rem .65rem; font-size: .8rem; }
.dark .cw-ram-primary > button, .dark .cw-ram-primary > a { color: #e2e8f0 !important; }
.dark .cw-ram-primary > button:hover, .dark .cw-ram-primary > a:hover { background: #2a3a50 !important; }
/* A row menu lives inside its (sticky) action cell, whose z-index makes it a stacking layer of its own — so the
   menu's z-index only counts inside that cell and the sidebar, or the next row's sticky cell, paints over it.
   While a menu is open, lift its cell above them. */
.acc-table td:has(> .cw-ram-pop), .acc-table td:has(.cw-ram-pop), .acc-table th:has(.cw-ram-pop) { z-index: 1200 !important; }
/* Wide pop-up panel (Correct receipt): scrolls inside itself on a short screen. */
/* Doubled class: the base .acc-modal rule (max-width 440px) is declared LATER in this file, so a single-class rule here
   lost and every "wide" pop-up on every page was stuck at 440px. */
.acc-modal.acc-modal--wide { max-width: 860px; max-height: 92vh; overflow-y: auto; }
.acc-modal-body.acc-correct-panel { border-left: 0; padding: 1rem 1.25rem; }
/* TablePager */
.cw-pager { display: flex; align-items: center; justify-content: space-between; gap: .75rem 1.25rem; flex-wrap: wrap; padding: .7rem 1rem; border-top: 1px solid #e2e8f0; font-size: .8rem; color: #64748b; }
.cw-pager-nav { display: inline-flex; align-items: center; gap: .3rem; }
.cw-pager-btn { min-width: 2rem; height: 2rem; border: 1px solid #e2e8f0; border-radius: .4rem; background: #fff; color: #334155; cursor: pointer; font-size: 1rem; line-height: 1; }
.cw-pager-btn:hover:not(:disabled) { background: #f1f5f9; }
.cw-pager-btn:disabled { opacity: .45; cursor: not-allowed; }
.cw-pager-page { padding: 0 .5rem; white-space: nowrap; }
.cw-pager-num { font-size: .8rem; font-weight: 600; }
.cw-pager-btn--on, .cw-pager-btn--on:hover:not(:disabled) { background: #059669; border-color: #059669; color: #fff; }
.cw-pager-gap { padding: 0 .15rem; color: #94a3b8; }
.cw-pager-info strong { color: #334155; }
.dark .cw-pager-info strong { color: #e2e8f0; }
@media (max-width: 640px) { .cw-pager { justify-content: center; } .cw-pager-info { width: 100%; text-align: center; } .cw-pager-num:not(.cw-pager-btn--on) { display: none; } }
.cw-pager-size { display: inline-flex; align-items: center; gap: .4rem; }
.cw-pager-size select { border: 1px solid #e2e8f0; border-radius: .4rem; padding: .25rem .4rem; background: #fff; color: #334155; }
.dark .cw-pager { border-color: #334155; }
.dark .cw-pager-btn, .dark .cw-pager-size select { background: #0f172a; border-color: #334155; color: #e2e8f0; }
/* Left-hand action column: narrow, pinned, no wrap. */
.acc-col-act-left { width: 2.5rem; }

/* ══ Finance pages: the .acc-* layer (one source for the accounting pages; see docs/design/page-organisation.md) ══
   Plain rules. A page that deliberately differs (Pledges and Automated Transactions are denser)
   keeps a small override in its own <style>, which comes after this. ══ */
.acc-header{display:flex;align-items:flex-start;justify-content:space-between;gap:1rem;margin-bottom:1.5rem;flex-wrap:wrap}
.acc-title{margin:0;font-size:var(--fs-xl);font-weight:700;color:var(--color-foreground, #1d2939);letter-spacing:-0.02em;line-height:1.3}
.dark .acc-title{color:#f1f5f9}
.acc-subtitle{margin:.2rem 0 0;font-size:var(--fs-sm);color:var(--color-muted-foreground, #667085);margin-top:0.2rem}
.acc-btn-primary:hover{opacity:.88;background:#047857;border-color:#047857}
.acc-btn-secondary{text-decoration:none;transition:background .15s;background:var(--color-surface, #fff);color:var(--color-foreground, #344054);border:1px solid var(--color-border, #d0d5dd) !important;border-radius:var(--radius-md) !important;font-size:var(--fs-sm) !important;font-weight:600;padding:0.55rem 1.1rem !important}
.acc-btn-full{width:100%;text-align:center;display:block}
.dark .acc-card{background:#1e293b;border-color:#334155}
.acc-card-header{display:flex;align-items:center;justify-content:space-between;border-bottom:1px solid var(--color-border, #e4e7ec);padding:1rem 1.25rem}
.dark .acc-card-header{border-color:#334155}
.acc-card-title{margin:0;font-size:var(--fs-md);font-weight:600;color:var(--color-foreground, #1d2939);letter-spacing:-0.01em}
.dark .acc-card-title{color:#f1f5f9}
.acc-form-body{padding:1.25rem;display:flex;flex-direction:column;gap:.9rem}
.acc-table-wrap{border-radius:var(--radius-lg);border:1px solid var(--color-border, #e4e7ec);background:var(--color-surface, #fff);overflow-x:auto}
.acc-table{width:100%;border-collapse:collapse;font-size:var(--fs-sm)}
.acc-table th{padding:.6rem 1rem;text-align:left;background:#f9fafb !important;border-bottom:1px solid var(--color-border, #e4e7ec) !important;color:var(--color-muted-foreground, #667085) !important;font-size:var(--fs-xs) !important;font-weight:700;text-transform:uppercase;letter-spacing:0.06em !important}
.dark .acc-table th{border-color:#334155;color:#64748b;background:rgba(255,255,255,0.04) !important}
.acc-table td{padding:.7rem 1rem;vertical-align:middle;border-bottom:1px solid var(--color-border, #f2f4f7) !important;color:var(--color-foreground, #344054) !important}
.dark .acc-table td{border-color:#1e293b;color:#cbd5e1}
.acc-table tr:last-child td{border-bottom:none}
.acc-amount-pos{font-weight:600;color:#16a34a}
.acc-amount-neg{font-weight:600;color:#dc2626}
.acc-badge{display:inline-flex;align-items:center;border-radius:999px;padding:.2rem .6rem;font-size:.7rem;font-weight:600}
.acc-badge-blue{background:#eff6ff;color:#2563eb}
.acc-badge-orange{background:#fff7ed;color:#c2410c}
.acc-badge-green{background:#f0fdf4;color:#16a34a}
.acc-badge-red{background:#fff1f2;color:#dc2626}
.acc-badge-gray{background:#f1f5f9;color:#64748b}
.acc-badge-purple{background:#f5f3ff;color:#047857}
.acc-empty-icon{font-size:2.5rem;margin-bottom:.75rem}
.acc-semibold{font-weight:600;color:#0f172a}
.dark .acc-semibold{color:#f1f5f9}
.w-full{width:100%}
.dark .acc-modal{background:#1e293b}
.acc-modal-title{font-size:1rem;font-weight:600;color:#0f172a;margin:0}
.dark .acc-modal-title{color:#f1f5f9}
.items-center{align-items:center}
.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}
.mb-2{margin-bottom:.5rem}
.acc-btn-sm{border:none;border-radius:.4rem;padding:.25rem .65rem;font-size:.75rem;font-weight:600;cursor:pointer;transition:background .15s}
.acc-btn-sm:disabled{opacity:.5}
.acc-btn-sm-orange{background:#fff7ed;color:#ea580c}
.acc-btn-sm-orange:hover{background:#ffedd5}
.acc-btn-sm-blue{background:#eff6ff;color:#2563eb}
.acc-btn-sm-blue:hover{background:#dbeafe}
.acc-modal-header{display:flex;align-items:center;justify-content:space-between;padding:1rem 1.25rem;border-bottom:1px solid #f1f5f9}
.dark .acc-modal-header{border-color:#334155}
.acc-modal-close{background:transparent;border:none;cursor:pointer;font-size:1rem;color:#94a3b8;padding:.25rem}
.acc-btn-sm-green{background:#f0fdf4;color:#16a34a}
.acc-btn-sm-green:hover{background:#dcfce7}
.acc-page{margin:0 auto;font-family:'Inter',system-ui,sans-serif;padding:1.25rem 1rem !important;max-width:100% !important}
.acc-btn-primary{cursor:pointer;white-space:nowrap;transition:opacity .15s;background:#059669;color:#fff;border-radius:var(--radius-md);font-size:var(--fs-sm) !important;font-weight:600;border:1px solid #059669;padding:0.55rem 1.1rem !important;box-shadow:none}
.acc-btn-primary:disabled{opacity:.5;cursor:not-allowed}
.acc-btn-secondary:hover{background:var(--color-hover-bg, rgba(0,0,0,0.04))}
.dark .acc-btn-secondary{background:#1e293b;color:#94a3b8;border-color:#334155}
.acc-btn-secondary-sm{background:#f1f5f9;color:#475569;border:1px solid #e2e8f0;border-radius:.4rem;padding:.25rem .65rem;font-size:.75rem;font-weight:600;cursor:pointer;transition:background .15s}
.acc-btn-secondary-sm:hover{background:#e2e8f0}
.acc-btn-secondary-sm:disabled{opacity:.5;cursor:not-allowed}
.dark .acc-btn-secondary-sm{background:#1e293b;color:#94a3b8;border-color:#334155}
.acc-btn-danger-sm{background:#fff1f2;color:#dc2626;border:1px solid #fecdd3;border-radius:.4rem;padding:.25rem .65rem;font-size:.75rem;font-weight:600;cursor:pointer;transition:background .15s}
.acc-two-col{display:grid;grid-template-columns:1fr 340px;gap:1rem;align-items:start}
.acc-col-main{min-width:0}
.acc-col-side{}
.acc-card{overflow:hidden;margin-bottom:1rem;background:var(--color-surface, #fff);border:1px solid var(--color-border, #e4e7ec);border-radius:var(--radius-xl);box-shadow:0 1px 3px rgba(16, 24, 40, 0.06), 0 1px 2px rgba(16, 24, 40, 0.04)}
.acc-form-group{display:flex;flex-direction:column;gap:.3rem}
.acc-hint{font-weight:400;font-size:.7rem;color:#94a3b8}
.acc-label{font-size:.78rem;font-weight:600;color:#64748b;text-transform:uppercase;letter-spacing:.04em}
.acc-input{padding:.5rem .75rem;font-size:.875rem;outline:none;transition:border .15s;width:100%;box-sizing:border-box;border:1px solid var(--color-border, #d0d5dd);border-radius:var(--radius-md);background:var(--color-surface, #fff);color:var(--color-foreground, #1d2939)}
.acc-input:focus{border-color:#059669;box-shadow:0 0 0 3px rgba(5, 150, 105,.12)}
.dark .acc-input{color-scheme:dark;background:rgba(255,255,255,0.06);border-color:rgba(255,255,255,0.1);color:#f8fafc}
.acc-textarea{resize:vertical;min-height:60px;border:1px solid var(--color-border, #d0d5dd);border-radius:var(--radius-md);background:var(--color-surface, #fff);color:var(--color-foreground, #1d2939)}
.acc-muted{color:#64748b;font-size:.8rem}
.acc-alert-error{font-size:.85rem;margin-bottom:.75rem;background:#fef3f2;border:1px solid #fecdca;color:#b42318;border-radius:var(--radius-lg);padding:0.9rem 1rem}
.acc-alert-success{font-size:.85rem;margin-bottom:.75rem;background:#ecfdf3;border:1px solid #a9efc5;color:#027a48;border-radius:var(--radius-lg);padding:0.9rem 1rem}
.acc-empty-state{padding:3rem 1.5rem;text-align:center}
.acc-empty-title{font-size:1rem;font-weight:600;color:#334155;margin-bottom:.25rem}
.dark .acc-empty-title{color:#cbd5e1}
.acc-empty-sub{font-size:.85rem;color:#64748b}
.acc-skeleton-rows{padding:1rem 1.25rem;display:flex;flex-direction:column;gap:.75rem}
.acc-skeleton-row{height:36px;border-radius:.5rem;background:linear-gradient(90deg,#f1f5f9 25%,#e2e8f0 50%,#f1f5f9 75%);background-size:200% 100%;animation:shimmer 1.4s infinite}
.acc-link-btn{background:none;border:0;padding:0;font-size:.78rem;font-weight:600;color:#059669;cursor:pointer;text-decoration:underline;text-underline-offset:2px}
.dark .acc-btn-secondary:hover{background:#334155}
.dark .acc-label{color:#cbd5e1}
.acc-modal-backdrop{position:fixed;inset:0;background:rgba(0,0,0,.45);z-index:200;display:flex;align-items:center;justify-content:center;padding:1rem}
.acc-modal{background:#fff;border-radius:1rem;width:100%;max-width:440px;box-shadow:0 20px 60px rgba(0,0,0,.2);overflow-x:hidden;overflow-y:auto;max-height:92vh;white-space:normal}
.acc-modal-title{overflow-wrap:anywhere}
.flex{display:flex}
.text-right{text-align:right}
.text-green-600{color:#16a34a}
.text-brand-500{color:#059669}
.acc-tabs{display:flex;gap:.5rem;margin-bottom:1.25rem;background:#f8fafc;border:1px solid #e2e8f0;border-radius:.75rem;padding:.35rem;width:fit-content;flex-wrap:wrap;border-bottom:1px solid var(--color-border, #e4e7ec)}
.dark .acc-tabs{background:#1e293b;border-color:#334155}
.acc-tab{padding:.4rem 1.1rem;border-radius:.55rem;border:none;cursor:pointer;font-size:.85rem;font-weight:500;color:#64748b;background:transparent;transition:all .15s}
.acc-tab:hover{background:#e2e8f0}
.dark .acc-tab:hover{background:#334155}
.acc-btn-danger-sm:hover{background:#fecdd3}
.acc-tab-active{background:#fff;color:#059669;font-weight:700;box-shadow:0 1px 4px rgba(0,0,0,.08)}
.dark .acc-tab-active{background:#0f172a;color:#93c5fd}
.acc-table tr:hover{background:#f9fafb}
.dark .acc-table tr:hover{background:rgba(255,255,255,0.04)}
.acc-two-col > *{min-width:0}
.acc-table th:first-child{white-space:nowrap}
.acc-table td:first-child{white-space:nowrap}
.acc-filter-bar{flex-wrap:wrap}
.acc-tool{min-width:140px}
.acc-tool--status{min-width:150px}
.acc-tool--date{min-width:135px}
.acc-tool--search{min-width:170px}
.acc-tool--paybill{min-width:200px}
.acc-row-actions{display:flex;gap:.35rem;white-space:nowrap}
.acc-select{border:1px solid var(--color-border, #d0d5dd);border-radius:var(--radius-md);background:var(--color-surface, #fff);color:var(--color-foreground, #1d2939)}
.dark .acc-select{color-scheme:dark;background:rgba(255,255,255,0.06);border-color:rgba(255,255,255,0.1);color:#f8fafc}
.dark .acc-textarea{color-scheme:dark;background:rgba(255,255,255,0.06);border-color:rgba(255,255,255,0.1);color:#f8fafc}
.dark .acc-alert-success{background:rgba(2,122,72,0.1);border-color:rgba(2,122,72,0.2)}
.dark .acc-alert-error{background:rgba(180,35,24,0.1);border-color:rgba(180,35,24,0.2)}
.acc-tab--active{color:#059669;background:rgba(5, 150, 105,0.1)}
.acc-record-details{display:grid;grid-template-columns:repeat(auto-fit, minmax(11rem, 1fr));gap:.5rem 1rem;margin:0 0 .75rem 0;padding:.6rem .75rem;background:var(--gray-50, #f9fafb);border:1px solid var(--gray-200, #e5e7eb);border-radius:.5rem}
.acc-record-details dt{font-size:.7rem;text-transform:uppercase;letter-spacing:.03em;color:var(--gray-500, #6b7280)}
.acc-record-details dd{margin:0;font-size:.85rem;font-weight:500;overflow-wrap:anywhere}
.acc-nowrap{white-space:nowrap;font-variant-numeric:tabular-nums}
@media(max-width:768px){
  .acc-two-col{grid-template-columns:1fr}
}
@media (min-width: 768px){
  .acc-page{padding:1.75rem 1.5rem !important}
}
@media (min-width: 1024px){
  .acc-page{padding:2rem 2.5rem !important}
}
@media (max-width: 639px){
  .acc-filter-bar > *{flex:1 1 140px}
  .acc-filter-bar .acc-input{width:100%}
  .acc-filter-bar .acc-seg{display:flex;width:100%}
  .acc-filter-bar .acc-seg-btn{flex:1 1 0;padding:.5rem .45rem;line-height:1.25}
  .acc-header-tools > .acc-tool{min-width:0;flex:1 1 calc(50% - .75rem)}
  .acc-header-tools > .acc-tool--search{flex-basis:100%}
  .acc-header-tools > .acc-tool--paybill{flex-basis:100%}
}
@media (max-width: 479px){
  .acc-tabs .acc-tab{padding:.45rem .7rem}
}
@media (max-width: 1023px){
  .acc-page .acc-two-col{grid-template-columns:minmax(0, 1fr)}
  .acc-page .acc-two-col > .acc-col-side{order:-1}
}
@media (max-width: 900px){
  .acc-table-wrap.acc-table-wrap--cards{padding:0 .75rem .25rem;overflow-x:visible;border:0;border-radius:0;background:transparent}
  .acc-table-wrap--cards .acc-table thead{display:none}
  .acc-table-wrap--cards .acc-table{display:block;width:100%}
  .acc-table-wrap--cards .acc-table tbody{display:block;width:100%}
  .acc-table-wrap--cards .acc-table tr{display:flex;flex-wrap:wrap;align-items:center;border:1px solid var(--color-border, #e4e7ec);border-radius:var(--radius-lg, .75rem);margin:.75rem 0;padding:.35rem 0;background:var(--color-surface, #fff)}
  .dark .acc-table-wrap--cards .acc-table tr{border-color:#334155;background:#1e293b}
  .acc-table-wrap--cards .acc-table tr td{flex:1 1 100%;min-width:0;display:flex;align-items:flex-start;justify-content:space-between;gap:1rem;padding:.35rem .85rem;text-align:right;white-space:normal;overflow-wrap:anywhere;border-bottom:0 !important}
  .acc-table-wrap--cards .acc-table tr td[data-label]::before{content:attr(data-label);flex:0 0 auto;padding-top:.1rem;font-size:.68rem;font-weight:700;text-transform:uppercase;letter-spacing:.04em;color:var(--color-muted-foreground, #94a3b8);text-align:left}
  .acc-table-wrap--cards .acc-table tr td[data-label] > *{max-width:70%}
  .acc-table-wrap--cards .acc-table tr td:not([data-label]){display:block;text-align:left}
  .acc-table-wrap--cards .acc-table tr td.acc-cell-tick{flex:0 0 auto;padding-right:0}
  .acc-table-wrap--cards .acc-table tr td.acc-cell-actions{flex:1 1 0;padding-bottom:.55rem;margin-bottom:.2rem;border-bottom:1px solid var(--color-border, #f2f4f7) !important}
  .acc-table-wrap--cards .acc-cell-actions .acc-row-actions{flex-wrap:wrap;white-space:normal}
  .acc-table-wrap--cards .acc-cell-actions .acc-action-cell{flex-wrap:wrap;white-space:normal}
  .acc-table-wrap--cards .acc-cell-actions button{min-height:36px}
  .acc-table-wrap--cards .acc-table tr.acc-row-panel{padding:0;overflow:hidden}
  .acc-table-wrap--cards .acc-table tr.acc-row-panel > td{display:block;padding:.9rem .85rem}
}

/* ═══════════════════════════════════════════════════════════════
   TailAdmin polish layer (Oct 2026)
   White header with hairline border, quieter surfaces, tighter tables.
   Appended last so it wins over the component <style> blocks that were
   written for the old solid-green topbar; remove this block to revert.
   ═══════════════════════════════════════════════════════════════ */
.topbar {
    background: var(--color-surface, #fff);
    border-bottom: 1px solid var(--color-border, #e4e7ec);
    box-shadow: 0 1px 2px rgba(16,24,40,0.04);
    height: 52px; min-height: 52px;
}
.sidebar--mobile { top: 52px; height: calc(100% - 52px); }
.sidebar-backdrop { top: 52px; }
.topbar .topbar-logo-mark { background: var(--brand-25); border-color: var(--brand-100); color: var(--brand-600); }
.topbar .topbar-logo-img { background: transparent; }
.topbar .topbar-brand-name { color: var(--color-foreground); }
.topbar .topbar-brand-sep { background: var(--color-border); }
.topbar .topbar-menu-btn,
.topbar .topbar-theme-btn { border-color: var(--color-border); color: var(--color-muted-foreground); }
.topbar .topbar-menu-btn:hover,
.topbar .topbar-theme-btn:hover { background: var(--color-hover-bg); color: var(--color-foreground); }
.topbar .branch-sw-pill,
.topbar .sms-pill,
.topbar .upm-trigger { border-color: var(--color-border); background: var(--color-surface-muted); color: var(--color-foreground); }
.topbar .branch-sw-pill:hover,
.topbar .sms-pill:hover,
.topbar .upm-trigger:hover { background: var(--color-hover-bg); border-color: var(--color-border-strong); color: var(--color-foreground); }
.topbar .branch-sw-icon { color: var(--brand-500); }
.topbar .branch-sw-chev,
.topbar .upm-chev { color: var(--color-muted-foreground); }
.topbar .upm-avatar { background: var(--brand-soft); border-color: var(--brand-100); color: var(--brand-600); }
.topbar .upm-name { color: var(--color-foreground); }
.topbar .upm-role { color: var(--color-muted-foreground); }
.topbar .upm-signin { color: var(--color-foreground); border-color: var(--color-border); }
.topbar .upm-signin:hover { background: var(--color-hover-bg); }

/* Cards: flat with a hairline, lift only on interactive ones. */
.cw-card { border-radius: var(--radius-xl); box-shadow: 0 1px 2px rgba(16,24,40,0.04); }
.cw-card:hover { box-shadow: 0 1px 2px rgba(16,24,40,0.04); }

/* Tables: sticky muted header, brand-tinted hover, no clipped corners. */
.cw-table thead th { position: sticky; top: 0; z-index: 1; background: var(--color-surface-muted); }
.cw-table tbody tr:hover { background: var(--brand-25); }
.dark .cw-table tbody tr:hover { background: var(--color-hover-bg); }
.cw-table tbody td { padding: 0.75rem 1rem; }
.cw-table-wrap { box-shadow: 0 1px 2px rgba(16,24,40,0.04); }

/* Buttons and inputs: TailAdmin focus ring and slightly firmer primary. */
.cw-btn { border-radius: var(--radius-md); }
.cw-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(5,150,105,0.25); }
.cw-btn-primary { box-shadow: 0 1px 2px rgba(16,24,40,0.08); }
.cw-btn-primary:hover:not(:disabled) { box-shadow: 0 1px 2px rgba(16,24,40,0.12); }
.cw-input:hover:not(:disabled):not(:focus),
.cw-select:hover:not(:disabled):not(:focus),
.cw-textarea:hover:not(:disabled):not(:focus) { border-color: var(--color-border-strong); }

/* Page header: no rule under it, the cards below already separate. */
.cw-page-header { border-bottom: none; padding-bottom: 0; margin-bottom: 1.25rem; }
.cw-page-title { font-size: var(--fs-xl); }

.page-main { background: var(--color-background); }

/* Dark mode: a dark sidebar like the rest of the shell (was solid green). */
.dark {
    --sidebar-bg: #0c1322;
    --sidebar-border: #1f2a3c;
    --sidebar-link-active-bg: rgba(16,185,129,0.14);
    --sidebar-link-active-color: #34d399;
    --sidebar-group-active-color: #34d399;
    --sidebar-logo-mark-bg: rgba(16,185,129,0.16);
    --sidebar-logo-mark-border: rgba(16,185,129,0.3);
}
.dark .topbar .topbar-logo-mark { background: rgba(16,185,129,0.16); border-color: rgba(16,185,129,0.3); color: #34d399; }
.dark .topbar .upm-avatar { color: #34d399; background: rgba(16,185,129,0.16); border-color: rgba(16,185,129,0.3); }

/* ── Page loader: shown in place of content while a page fetches its data, so a heavy page never sits blank ── */
.cw-pageloader{display:flex;flex-direction:column;gap:.7rem;padding:1.25rem;border:1px solid #e2e8f0;border-radius:1rem;background:#fff;box-shadow:0 1px 3px rgba(15,23,42,.06)}
.dark .cw-pageloader{background:#1d2939;border-color:#334155}
.cw-pageloader-head{display:flex;align-items:center;gap:.7rem;font-size:.9rem;font-weight:500;color:#475569}
.dark .cw-pageloader-head{color:#cbd5e1}
.cw-spinner{flex:none;width:1.15rem;height:1.15rem;border-radius:50%;border:2px solid #cbd5e1;border-top-color:#059669;animation:cw-spin .8s linear infinite}
.dark .cw-spinner{border-color:#475569;border-top-color:#34d399}
.cw-skel{height:.85rem;border-radius:.4rem;background:linear-gradient(90deg,#e2e8f0 25%,#f1f5f9 37%,#e2e8f0 63%);background-size:400% 100%;animation:cw-shimmer 1.4s ease infinite}
.dark .cw-skel{background:linear-gradient(90deg,#334155 25%,#475569 37%,#334155 63%);background-size:400% 100%}
@keyframes cw-spin{to{transform:rotate(360deg)}}
@keyframes cw-shimmer{0%{background-position:100% 50%}100%{background-position:0 50%}}
@media (prefers-reduced-motion:reduce){.cw-spinner,.cw-skel{animation:none}}

/* Progress bar across the top while any request is in flight (activity-bar.js sets html.cw-busy).
   The animation delay keeps quick requests from flashing it. Screen only. */
@media screen {
    html::after {
        content: "";
        position: fixed;
        top: 0;
        left: 0;
        height: 3px;
        width: 0;
        z-index: 100000;
        background: #465fff;
        opacity: 0;
        pointer-events: none;
    }
    html.cw-busy::after {
        animation: cw-activity-run 2.2s ease-out 0.35s infinite;
    }
}
@keyframes cw-activity-run {
    0% { width: 0; opacity: 1; }
    80% { width: 92%; opacity: 1; }
    100% { width: 96%; opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
    html.cw-busy::after { animation: none; width: 100%; opacity: .6; }
}

/* ── Tables as cards on a phone, for every list (table-cards.js adds .cw-autocards and the data-labels) ──
   Same look as .acc-table-wrap--cards above. Screen only, so printing a report never turns into cards. */
@media screen and (max-width: 900px) {
  table.cw-autocards{display:block;width:100%;border:0}
  table.cw-autocards thead{display:none}
  table.cw-autocards tbody, table.cw-autocards tfoot{display:block;width:100%}
  table.cw-autocards tr{display:flex;flex-wrap:wrap;align-items:center;border:1px solid var(--color-border, #e4e7ec);border-radius:var(--radius-lg, .75rem);margin:.75rem 0;padding:.35rem 0;background:var(--color-surface, #fff)}
  .dark table.cw-autocards tr{border-color:#334155;background:#1e293b}
  table.cw-autocards tr td{flex:1 1 100%;min-width:0;display:flex;align-items:flex-start;justify-content:space-between;gap:1rem;padding:.35rem .85rem;text-align:right;white-space:normal;overflow-wrap:anywhere;border-bottom:0 !important}
  table.cw-autocards tr td[data-label]::before{content:attr(data-label);flex:0 0 auto;padding-top:.1rem;font-size:.68rem;font-weight:700;text-transform:uppercase;letter-spacing:.04em;color:var(--color-muted-foreground, #94a3b8);text-align:left}
  table.cw-autocards tr td[data-label] > *{max-width:70%}
  table.cw-autocards tr td:not([data-label]){display:block;text-align:left}
}

/* ── A tab bar with many tabs wraps instead of hiding the last ones off the edge (Settings has 13) ── */
.cw-tabs.cw-tabs--wrap{flex-wrap:wrap;overflow-x:visible}
@media (max-width: 639px){ .cw-tabs.cw-tabs--wrap .cw-tab{padding:.6rem .7rem} }

/* ── Phones: comfortable to touch and to read (responsive audit, 22 Oct 2026) ──
   Screen and phone width only. Sizes follow what was measured on the live pages at 400px:
   inputs at 12.8-14.4px (iOS Safari zooms the whole page when you focus a field under 16px), report links 17px tall,
   star buttons 29px, link-style buttons 15-19px, badges and mini labels at 10.88px, Home labels at 10px. */
@media screen and (max-width: 639px) {
  main input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file]):not([type=color]):not([type=hidden]),
  main select,
  main textarea { font-size: 16px !important; }

  main .rc-name a { display: inline-block; padding: .5rem 0; }
  main .rc-star { min-width: 40px; min-height: 40px; }
  main .acc-link-btn { display: inline-flex; align-items: center; min-height: 40px; }
  main a[class*="hover:underline"] { display: inline-block; padding: .5rem .25rem; }
  main [class*="text-2xs"][class*="font-bold"] { min-height: 36px; display: inline-flex; align-items: center; }

  .acc-badge, .pv-mini-label, .rc-cat-title { font-size: .72rem !important; }
  main [class*="text-[10px]"]:not([class*="h-5"]):not([class*="h-6"]) { font-size: .72rem !important; }
}

/* A Tailwind `grid` with no column template makes one implicit column that is as wide as its widest item, so a
   single wide input (a Settings form) pushed it past its card on a phone and the whole page scrolled sideways.
   On a phone those grids get one column that can shrink to the card. A grid that names its own columns
   without a breakpoint (grid-cols-3) keeps them; the sm:/md: ones are not affected below 640px either. */
@media screen and (max-width: 639px) {
  main .grid:not([class^="grid-cols-"]):not([class*=" grid-cols-"]) { grid-template-columns: minmax(0, 1fr); }
}
