/* ==========================================================================
   FlatMate  |  application theme
   --------------------------------------------------------------------------
   Layered on Bootstrap 5. Bootstrap supplies the grid, components and
   reboot; everything here is the flat-specific look plus the responsive
   behaviour Bootstrap does not give you (collapsing sidebar, card grids,
   sticky meal rail, print styles).

   Contents
     1. Design tokens
     2. Base / layout shell
     3. Sidebar + topbar
     4. Cards & sections
     5. Chores
     6. Meals
     7. Money
     8. Residents
     9. Notices & activity
    10. Components (avatars, badges, toasts, modals, skeleton)
    11. Responsive
    12. Print
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Design tokens
   -------------------------------------------------------------------------- */
:root {
    /* Brand: a calm teal reads "shared home" rather than "banking app". */
    --fm-primary:        #0f766e;
    --fm-primary-dark:   #115e59;
    --fm-primary-light:  #ccfbf1;
    --fm-accent:         #f59e0b;

    /* Semantic */
    --fm-owed:           #dc2626;   /* you owe the flat   */
    --fm-owing:          #059669;   /* the flat owes you  */
    --fm-settled:        #64748b;
    --fm-info:           #2563eb;

    /* Surfaces */
    --fm-bg:             #f1f5f9;
    --fm-surface:        #ffffff;
    --fm-surface-2:      #f8fafc;
    --fm-border:         #e2e8f0;
    --fm-border-strong:  #cbd5e1;

    /* Text */
    --fm-text:           #0f172a;
    --fm-text-muted:     #64748b;
    --fm-text-faint:     #94a3b8;

    /* Shape */
    --fm-radius:         14px;
    --fm-radius-sm:      10px;
    --fm-radius-lg:      20px;
    --fm-shadow-sm:      0 1px 2px rgb(15 23 42 / 0.06);
    --fm-shadow:         0 4px 16px rgb(15 23 42 / 0.08);
    --fm-shadow-lg:      0 18px 40px rgb(15 23 42 / 0.14);

    /* Sidebar */
    --fm-sidebar-w:      264px;
    --fm-topbar-h:       64px;

    --fm-font: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
    --fm-mono: "JetBrains Mono", "Cascadia Code", ui-monospace, monospace;
}

/* --------------------------------------------------------------------------
   2. Base / layout shell
   -------------------------------------------------------------------------- */
* { -webkit-tap-highlight-color: transparent; }

body {
    font-family: var(--fm-font);
    background: var(--fm-bg);
    color: var(--fm-text);
    font-size: 0.9375rem;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 { font-weight: 650; letter-spacing: -0.015em; }

a { text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--fm-primary) 55%, transparent);
    outline-offset: 2px;
    border-radius: 4px;
}

.text-muted-2 { color: var(--fm-text-muted) !important; }
.text-faint    { color: var(--fm-text-faint) !important; }
.font-mono     { font-family: var(--fm-mono); font-variant-numeric: tabular-nums; }
.tnum          { font-variant-numeric: tabular-nums; }

/* Page shell: sidebar + scrolling content */
.fm-shell { display: flex; min-height: 100vh; }

.fm-main {
    flex: 1 1 auto;
    min-width: 0;                 /* lets wide tables scroll instead of stretching */
    padding: var(--fm-topbar-h) 0 0;
}

.fm-page {
    max-width: 1320px;
    margin: 0 auto;
    padding: 1.5rem 1.25rem 5rem;
}

.fm-page-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.75rem 1rem;
    margin-bottom: 1.25rem;
}
.fm-page-head h1 { font-size: 1.5rem; margin: 0; }
.fm-page-head .fm-sub { color: var(--fm-text-muted); font-size: 0.875rem; margin: 0; }
.fm-page-head .fm-actions { margin-left: auto; display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* Grid helpers used across pages */
.fm-grid { display: grid; gap: 1rem; }
.fm-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.fm-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.fm-grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.fm-split { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.fm-split-wide { grid-template-columns: minmax(0, 3fr) minmax(0, 1.15fr); }

/* --------------------------------------------------------------------------
   3. Sidebar + topbar
   -------------------------------------------------------------------------- */
.fm-sidebar {
    width: var(--fm-sidebar-w);
    flex: 0 0 var(--fm-sidebar-w);
    background: var(--fm-surface);
    border-right: 1px solid var(--fm-border);
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    z-index: 1035;
}

.fm-brand {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    height: var(--fm-topbar-h);
    padding: 0 1.1rem;
    border-bottom: 1px solid var(--fm-border);
    flex: 0 0 auto;
}
.fm-brand-mark {
    width: 34px; height: 34px;
    border-radius: 10px;
    display: grid; place-items: center;
    background: linear-gradient(135deg, var(--fm-primary), var(--fm-primary-dark));
    color: #fff;
    font-size: 1.05rem;
    flex: 0 0 auto;
}
.fm-brand-text { font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; }
.fm-brand-text small { display: block; font-weight: 500; font-size: 0.68rem; color: var(--fm-text-faint); letter-spacing: 0.02em; }

.fm-nav { flex: 1 1 auto; overflow-y: auto; padding: 0.85rem 0.7rem; }
.fm-nav-label {
    font-size: 0.66rem;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: var(--fm-text-faint);
    font-weight: 700;
    padding: 0.75rem 0.65rem 0.35rem;
}

.fm-nav-link {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.55rem 0.65rem;
    border-radius: var(--fm-radius-sm);
    color: var(--fm-text-muted);
    font-weight: 550;
    font-size: 0.9rem;
    transition: background 0.12s, color 0.12s;
}
.fm-nav-link i { font-size: 1.05rem; width: 1.25rem; text-align: center; flex: 0 0 auto; }
.fm-nav-link:hover { background: var(--fm-surface-2); color: var(--fm-text); text-decoration: none; }
.fm-nav-link.active { background: var(--fm-primary-light); color: var(--fm-primary-dark); }
.fm-nav-link.active i { color: var(--fm-primary); }

.fm-nav-link .fm-count {
    margin-left: auto;
    background: var(--fm-owed);
    color: #fff;
    font-size: 0.68rem;
    font-weight: 700;
    padding: 0.05rem 0.4rem;
    border-radius: 999px;
    min-width: 1.25rem;
    text-align: center;
}
.fm-nav-link.active .fm-count { background: var(--fm-primary-dark); }

.fm-sidebar-foot {
    flex: 0 0 auto;
    padding: 0.7rem;
    border-top: 1px solid var(--fm-border);
    background: var(--fm-surface-2);
}

.fm-topbar {
    position: fixed;
    top: 0;
    right: 0;
    left: var(--fm-sidebar-w);
    height: var(--fm-topbar-h);
    background: color-mix(in srgb, var(--fm-surface) 88%, transparent);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--fm-border);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0 1.1rem;
    z-index: 1020;
}
.fm-topbar-title { font-weight: 650; font-size: 0.98rem; }
.fm-topbar .fm-spacer { margin-left: auto; }

.fm-burger { display: none; }

/* --------------------------------------------------------------------------
   4. Cards & sections
   -------------------------------------------------------------------------- */
.fm-card {
    background: var(--fm-surface);
    border: 1px solid var(--fm-border);
    border-radius: var(--fm-radius);
    box-shadow: var(--fm-shadow-sm);
}
.fm-card-head {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.85rem 1.05rem;
    border-bottom: 1px solid var(--fm-border);
}
.fm-card-head h2, .fm-card-head h3 {
    font-size: 0.95rem;
    margin: 0;
    font-weight: 650;
}
.fm-card-head .fm-card-sub { font-size: 0.78rem; color: var(--fm-text-faint); margin: 0; }
.fm-card-head .fm-end { margin-left: auto; display: flex; gap: 0.4rem; align-items: center; }
.fm-card-body { padding: 1.05rem; }
.fm-card-body.tight { padding: 0.55rem 0.7rem; }
.fm-card-foot {
    padding: 0.7rem 1.05rem;
    border-top: 1px solid var(--fm-border);
    background: var(--fm-surface-2);
    border-radius: 0 0 var(--fm-radius) var(--fm-radius);
}

.fm-section-title {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.085em;
    font-weight: 700;
    color: var(--fm-text-faint);
    margin: 0 0 0.6rem;
}

/* Big number tile */
.fm-stat { padding: 1rem 1.05rem; }
.fm-stat-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--fm-text-faint);
    font-weight: 700;
}
.fm-stat-value {
    font-size: 1.7rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    font-variant-numeric: tabular-nums;
    line-height: 1.15;
    margin-top: 0.2rem;
}
.fm-stat-hint { font-size: 0.78rem; color: var(--fm-text-muted); margin-top: 0.15rem; }
.fm-stat-value.owed  { color: var(--fm-owed); }
.fm-stat-value.owing { color: var(--fm-owing); }
.fm-stat-value.flat  { color: var(--fm-settled); }

/* Empty state */
.fm-empty { text-align: center; padding: 2.25rem 1rem; color: var(--fm-text-muted); }
.fm-empty i { font-size: 2.1rem; color: var(--fm-text-faint); display: block; margin-bottom: 0.5rem; }
.fm-empty h3 { font-size: 0.95rem; margin-bottom: 0.25rem; }
.fm-empty p { font-size: 0.84rem; max-width: 34ch; margin: 0 auto 0.85rem; }

/* --------------------------------------------------------------------------
   5. Chores
   -------------------------------------------------------------------------- */
.fm-chore {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.7rem 1.05rem;
    border-bottom: 1px solid var(--fm-border);
}
.fm-chore:last-child { border-bottom: 0; }
.fm-chore:hover { background: var(--fm-surface-2); }

.fm-chore-icon {
    width: 34px; height: 34px;
    flex: 0 0 auto;
    border-radius: 9px;
    display: grid; place-items: center;
    background: var(--fm-primary-light);
    color: var(--fm-primary-dark);
    font-size: 1rem;
}
.fm-chore-icon.optional { background: #fef3c7; color: #92400e; }
.fm-chore-icon.done      { background: #d1fae5; color: #065f46; }
.fm-chore-icon.skipped   { background: var(--fm-surface-2); color: var(--fm-text-faint); }

.fm-chore-main { min-width: 0; flex: 1 1 auto; }
.fm-chore-title {
    font-weight: 600;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
}
.fm-chore-meta { font-size: 0.78rem; color: var(--fm-text-muted); }

.fm-chore.mine  { border-left: 3px solid var(--fm-primary); }
.fm-chore.other { opacity: 0.72; }
.fm-chore.past  { opacity: 0.55; }

/* Week strip */
.fm-week {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 0.35rem;
}
.fm-day {
    background: var(--fm-surface);
    border: 1px solid var(--fm-border);
    border-radius: var(--fm-radius-sm);
    padding: 0.5rem 0.4rem;
    text-align: center;
    min-width: 0;
}
.fm-day.today { border-color: var(--fm-primary); box-shadow: 0 0 0 2px var(--fm-primary-light); }
.fm-day .fm-day-dow { font-size: 0.68rem; text-transform: uppercase; color: var(--fm-text-faint); font-weight: 700; }
.fm-day .fm-day-num { font-size: 1.05rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.fm-day .fm-day-dot {
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--fm-primary);
    margin: 0.25rem auto 0;
}
.fm-day .fm-day-dot.mine { background: var(--fm-accent); }
.fm-day .fm-day-count { font-size: 0.68rem; color: var(--fm-text-muted); }

/* Fairness bar */
.fm-fair-row { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.5rem; }
.fm-fair-name { width: 8.5rem; font-size: 0.84rem; font-weight: 550; flex: 0 0 auto; }
.fm-fair-track {
    flex: 1 1 auto;
    height: 9px;
    background: var(--fm-surface-2);
    border: 1px solid var(--fm-border);
    border-radius: 999px;
    overflow: hidden;
}
.fm-fair-fill { height: 100%; background: var(--fm-primary); border-radius: 999px; }
.fm-fair-fill.over { background: var(--fm-owed); }
.fm-fair-fill.me   { background: var(--fm-accent); }
.fm-fair-val { width: 4.25rem; text-align: right; font-size: 0.8rem; font-variant-numeric: tabular-nums; color: var(--fm-text-muted); }

/* Rotation preview chips */
.fm-rot-preview { display: flex; gap: 0.3rem; flex-wrap: wrap; }
.fm-rot-chip {
    font-size: 0.7rem;
    padding: 0.15rem 0.4rem;
    border-radius: 6px;
    background: var(--fm-surface-2);
    border: 1px solid var(--fm-border);
    color: var(--fm-text-muted);
}
.fm-rot-chip.me { background: var(--fm-primary-light); border-color: var(--fm-primary); color: var(--fm-primary-dark); font-weight: 600; }

/* Expense ledger rows */
.fm-expense {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 1rem;
    border-bottom: 1px solid var(--fm-border);
    cursor: pointer;
    transition: background var(--fm-transition);
}
.fm-expense:last-child { border-bottom: 0; }
.fm-expense:hover { background: var(--fm-surface-2); }
.fm-expense.mine { box-shadow: inset 3px 0 0 var(--fm-accent); }
.fm-expense.disputed { box-shadow: inset 3px 0 0 var(--fm-owed); }
.fm-expense-icon {
    width: 34px; height: 34px;
    flex: 0 0 auto;
    border-radius: 9px;
    display: grid; place-items: center;
    background: var(--fm-primary-light);
    color: var(--fm-primary-dark);
    font-size: 1rem;
}
.fm-expense-main { min-width: 0; flex: 1 1 auto; }
.fm-expense-title {
    font-weight: 600;
    font-size: 0.9rem;
    display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap;
}
.fm-expense-meta {
    font-size: 0.76rem;
    color: var(--fm-text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.fm-expense-end { flex: 0 0 auto; text-align: right; }
.fm-expense-amount { font-weight: 650; font-size: 0.92rem; font-variant-numeric: tabular-nums; }
.fm-expense-share { font-size: 0.72rem; color: var(--fm-text-faint); }
.fm-expense-share.mine { color: var(--fm-owed); font-weight: 600; }

/* Balance direction colouring on the settle-up board */
.fm-fair-val.credit { color: var(--fm-owing); font-weight: 600; }
.fm-fair-val.debit  { color: var(--fm-owed);   font-weight: 600; }
.fm-fair-val.flat   { color: var(--fm-text-faint); }

/* Notice board */
.fm-notice {
    display: flex;
    align-items: flex-start;
    gap: 0.85rem;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--fm-border);
    cursor: pointer;
    transition: background var(--fm-transition);
}
.fm-notice:last-child { border-bottom: 0; }
.fm-notice:hover { background: var(--fm-surface-2); }
.fm-notice.read { opacity: 0.72; }
.fm-notice.unread { box-shadow: inset 3px 0 0 var(--fm-accent); }
.fm-notice.pinned { background: color-mix(in srgb, var(--fm-info-light, #eff6ff) 55%, transparent); }
.fm-notice-icon {
    width: 36px; height: 36px;
    flex: 0 0 auto;
    border-radius: 10px;
    display: grid; place-items: center;
    font-size: 1.05rem;
    background: var(--fm-surface-2);
    color: var(--fm-text-muted);
}
.fm-notice-icon.ok    { background: #d1fae5; color: #065f46; }
.fm-notice-icon.warn  { background: #fef3c7; color: #92400e; }
.fm-notice-icon.bad   { background: #fee2e2; color: #991b1b; }
.fm-notice-icon.info  { background: #dbeafe; color: #1e40af; }
.fm-notice-icon.muted { background: var(--fm-surface-2); color: var(--fm-text-faint); }
.fm-notice-main { min-width: 0; flex: 1 1 auto; }
.fm-notice-title {
    font-weight: 600;
    font-size: 0.92rem;
    display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap;
}
.fm-notice-meta { font-size: 0.76rem; color: var(--fm-text-muted); margin-top: 0.1rem; }
.fm-notice-excerpt {
    font-size: 0.84rem;
    color: var(--fm-text-muted);
    margin: 0.3rem 0 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.fm-notice-end { flex: 0 0 auto; align-items: center; gap: 0.25rem; }

/* Rotation preview chips used on the chores page */

/* --------------------------------------------------------------------------
   6. Meals
   -------------------------------------------------------------------------- */
.fm-meals { display: grid; gap: 1rem; grid-template-columns: minmax(0, 1fr); }

.fm-meal-row {
    display: grid;
    grid-template-columns: 74px minmax(0, 1fr) auto;
    gap: 0.75rem;
    align-items: center;
    padding: 0.65rem 0.9rem;
    border-bottom: 1px solid var(--fm-border);
}
.fm-meal-row:last-child { border-bottom: 0; }
.fm-meal-row.is-today { background: linear-gradient(90deg, var(--fm-primary-light), transparent 60%); }

.fm-meal-day { font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; }
.fm-meal-day small { display: block; font-size: 0.68rem; color: var(--fm-text-faint); text-transform: none; letter-spacing: 0; font-weight: 600; }
.fm-meal-day.today { color: var(--fm-primary); }

.fm-slot { display: flex; flex-wrap: wrap; gap: 0.4rem; min-width: 0; }
.fm-slot-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    border: 1px solid var(--fm-border);
    border-radius: var(--fm-radius-sm);
    padding: 0.3rem 0.5rem;
    background: var(--fm-surface);
    min-width: 0;
    max-width: 100%;
}
.fm-slot-item.empty { border-style: dashed; color: var(--fm-text-faint); font-size: 0.78rem; }
.fm-slot-item.locked { opacity: 0.6; }
.fm-slot-type {
    font-size: 0.62rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--fm-text-faint);
}
.fm-slot-menu { font-size: 0.86rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fm-slot-cook { font-size: 0.7rem; color: var(--fm-text-muted); }

/* Opt-in pill group */
.fm-optin { display: inline-flex; border: 1px solid var(--fm-border); border-radius: 999px; overflow: hidden; }
.fm-optin button {
    border: 0;
    background: var(--fm-surface);
    padding: 0.25rem 0.6rem;
    font-size: 0.76rem;
    font-weight: 600;
    color: var(--fm-text-muted);
    border-right: 1px solid var(--fm-border);
}
.fm-optin button:last-child { border-right: 0; }
.fm-optin button.on { background: var(--fm-primary); color: #fff; }
.fm-optin button.on.out { background: var(--fm-owed); }

/* Suggestion vote cards */
.fm-suggestion { border: 1px solid var(--fm-border); border-radius: var(--fm-radius-sm); padding: 0.75rem; margin-bottom: 0.6rem; }
.fm-suggestion.winner { border-color: var(--fm-primary); background: color-mix(in srgb, var(--fm-primary-light) 45%, transparent); }
.fm-suggestion h4 { font-size: 0.9rem; margin: 0 0 0.2rem; }
.fm-votes { display: flex; gap: 0.25rem; align-items: center; }
.fm-votes i { color: var(--fm-border-strong); }
.fm-votes i.on { color: var(--fm-accent); }

/* --------------------------------------------------------------------------
   7. Money
   -------------------------------------------------------------------------- */
.fm-money-pos { color: var(--fm-owing); font-weight: 650; }
.fm-money-neg { color: var(--fm-owed);   font-weight: 650; }
.fm-money-zero { color: var(--fm-settled); font-weight: 550; }

.fm-settle-plan { border: 1px solid var(--fm-border); border-radius: var(--fm-radius-sm); padding: 0.7rem; margin-bottom: 0.5rem; display: flex; align-items: center; gap: 0.6rem; }
.fm-settle-plan .fm-arrow { color: var(--fm-text-faint); font-size: 1.1rem; }
.fm-settle-amt { margin-left: auto; font-weight: 700; font-variant-numeric: tabular-nums; }

.fm-cat-row { display: flex; align-items: center; gap: 0.6rem; padding: 0.45rem 0; }
.fm-cat-name { width: 9rem; font-size: 0.85rem; font-weight: 550; }
.fm-cat-track { flex: 1 1 auto; height: 8px; background: var(--fm-surface-2); border-radius: 999px; overflow: hidden; }
.fm-cat-fill { height: 100%; border-radius: 999px; background: var(--fm-info); }
.fm-cat-val { width: 5.5rem; text-align: right; font-size: 0.82rem; font-variant-numeric: tabular-nums; }

/* Ledger table */
.fm-table { width: 100%; border-collapse: separate; border-spacing: 0; }
.fm-table th {
    text-align: left;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--fm-text-faint);
    font-weight: 700;
    padding: 0.55rem 0.7rem;
    border-bottom: 1px solid var(--fm-border);
    white-space: nowrap;
}
.fm-table td { padding: 0.6rem 0.7rem; border-bottom: 1px solid var(--fm-border); font-size: 0.875rem; vertical-align: middle; }
.fm-table tbody tr:last-child td { border-bottom: 0; }
.fm-table tbody tr:hover { background: var(--fm-surface-2); }
.fm-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.fm-table-wrap { overflow-x: auto; }

/* --------------------------------------------------------------------------
   8. Residents
   -------------------------------------------------------------------------- */
.fm-resident {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.7rem 1.05rem;
    border-bottom: 1px solid var(--fm-border);
}
.fm-resident:last-child { border-bottom: 0; }
.fm-resident-main { min-width: 0; flex: 1 1 auto; }
.fm-resident-name { font-weight: 600; font-size: 0.9rem; display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.fm-resident-meta { font-size: 0.78rem; color: var(--fm-text-muted); }
.fm-resident.offboarded { opacity: 0.5; }
.fm-resident.invited { background: #fffbeb; }

.fm-code {
    font-family: var(--fm-mono);
    font-size: 0.72rem;
    font-weight: 600;
    background: var(--fm-surface-2);
    border: 1px solid var(--fm-border);
    border-radius: 6px;
    padding: 0.05rem 0.3rem;
    letter-spacing: 0.04em;
}

/* Checklist */
.fm-check { display: flex; align-items: flex-start; gap: 0.6rem; padding: 0.5rem 0; border-bottom: 1px dashed var(--fm-border); }
.fm-check:last-child { border-bottom: 0; }
.fm-check.done .fm-check-title { text-decoration: line-through; color: var(--fm-text-faint); }
.fm-check-title { font-size: 0.875rem; font-weight: 550; }
.fm-check-meta { font-size: 0.76rem; color: var(--fm-text-faint); }

/* --------------------------------------------------------------------------
   9. Notices & activity
   -------------------------------------------------------------------------- */
.fm-notice {
    border: 1px solid var(--fm-border);
    border-radius: var(--fm-radius-sm);
    padding: 0.85rem 1rem;
    margin-bottom: 0.6rem;
    background: var(--fm-surface);
}
.fm-notice.pinned { border-left: 4px solid var(--fm-accent); background: #fffbeb; }
.fm-notice.unread { box-shadow: inset 3px 0 0 var(--fm-info); }
.fm-notice-head { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.3rem; flex-wrap: wrap; }
.fm-notice-title { font-weight: 650; font-size: 0.95rem; }
.fm-notice-body { font-size: 0.875rem; color: var(--fm-text-muted); white-space: pre-wrap; }

.fm-feed { position: relative; padding-left: 1.35rem; }
.fm-feed::before {
    content: "";
    position: absolute;
    left: 6px; top: 6px; bottom: 6px;
    width: 2px;
    background: var(--fm-border);
}
.fm-feed-item { position: relative; padding: 0.35rem 0; font-size: 0.85rem; }
.fm-feed-item::before {
    content: "";
    position: absolute;
    left: -1.35rem; top: 0.75rem;
    width: 10px; height: 10px;
    border-radius: 50%;
    background: var(--fm-surface);
    border: 2px solid var(--fm-border-strong);
}
.fm-feed-item.hi::before { border-color: var(--fm-primary); background: var(--fm-primary-light); }
.fm-feed-time { font-size: 0.74rem; color: var(--fm-text-faint); }

/* --------------------------------------------------------------------------
   10. Components
   -------------------------------------------------------------------------- */
.fm-avatar {
    width: 34px; height: 34px;
    border-radius: 50%;
    display: grid; place-items: center;
    font-weight: 700;
    font-size: 0.8rem;
    color: #fff;
    flex: 0 0 auto;
    letter-spacing: -0.02em;
}
.fm-avatar.sm { width: 26px; height: 26px; font-size: 0.68rem; }
.fm-avatar.lg { width: 52px; height: 52px; font-size: 1.1rem; }
.fm-avatar.ring { box-shadow: 0 0 0 2px var(--fm-surface), 0 0 0 3.5px var(--fm-primary); }

.fm-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.72rem;
    font-weight: 650;
    padding: 0.12rem 0.45rem;
    border-radius: 999px;
    background: var(--fm-surface-2);
    border: 1px solid var(--fm-border);
    color: var(--fm-text-muted);
    white-space: nowrap;
}
.fm-pill.ok    { background: #d1fae5; border-color: #6ee7b7; color: #065f46; }
.fm-pill.warn  { background: #fef3c7; border-color: #fcd34d; color: #92400e; }
.fm-pill.bad   { background: #fee2e2; border-color: #fca5a5; color: #991b1b; }
.fm-pill.info  { background: #dbeafe; border-color: #93c5fd; color: #1e40af; }
.fm-pill.muted { background: var(--fm-surface-2); color: var(--fm-text-faint); }

/* Buttons */
.btn { font-weight: 600; border-radius: var(--fm-radius-sm); font-size: 0.875rem; }
.btn-primary { background: var(--fm-primary); border-color: var(--fm-primary); }
.btn-primary:hover, .btn-primary:focus { background: var(--fm-primary-dark); border-color: var(--fm-primary-dark); }
.btn-outline-secondary { border-color: var(--fm-border-strong); color: var(--fm-text-muted); }
.btn-outline-secondary:hover { background: var(--fm-surface-2); border-color: var(--fm-border-strong); color: var(--fm-text); }
.btn-sm { font-size: 0.8rem; padding: 0.25rem 0.55rem; }

/* Forms */
.form-label { font-size: 0.8rem; font-weight: 600; color: var(--fm-text-muted); margin-bottom: 0.25rem; }
.form-control, .form-select {
    border-color: var(--fm-border-strong);
    border-radius: var(--fm-radius-sm);
    font-size: 0.9rem;
}
.form-control:focus, .form-select:focus {
    border-color: var(--fm-primary);
    box-shadow: 0 0 0 3px var(--fm-primary-light);
}
.form-hint { font-size: 0.76rem; color: var(--fm-text-faint); margin-top: 0.2rem; }
.invalid-feedback { font-size: 0.76rem; }

/* Toasts */
.fm-toasts {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    z-index: 1090;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: min(380px, calc(100vw - 2rem));
}
.fm-toast {
    background: var(--fm-text);
    color: #f8fafc;
    border-radius: var(--fm-radius-sm);
    padding: 0.7rem 0.9rem;
    box-shadow: var(--fm-shadow-lg);
    font-size: 0.86rem;
    display: flex;
    align-items: flex-start;
    gap: 0.55rem;
    animation: fm-toast-in 0.18s ease-out;
}
.fm-toast.ok   { background: #065f46; }
.fm-toast.err  { background: #991b1b; }
.fm-toast.warn { background: #92400e; }
@keyframes fm-toast-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: none; }
}

/* Loading skeleton */
.fm-skeleton {
    background: linear-gradient(90deg, var(--fm-surface-2) 25%, #eef2f7 37%, var(--fm-surface-2) 63%);
    background-size: 400% 100%;
    animation: fm-shimmer 1.3s ease-in-out infinite;
    border-radius: 6px;
    height: 1rem;
}
@keyframes fm-shimmer {
    0%   { background-position: 100% 0; }
    100% { background-position: 0 0; }
}

.fm-spinner { color: var(--fm-primary); }

/* Auth screens */
.fm-auth-wrap {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1.5rem;
    background:
        radial-gradient(1000px 500px at 12% -10%, #ccfbf1 0%, transparent 55%),
        radial-gradient(800px 420px at 100% 0%, #e0f2fe 0%, transparent 50%),
        var(--fm-bg);
}
.fm-auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--fm-surface);
    border: 1px solid var(--fm-border);
    border-radius: var(--fm-radius-lg);
    box-shadow: var(--fm-shadow-lg);
    padding: 1.75rem;
}
.fm-auth-card.wide { max-width: 620px; }

/* Demo credential helper */
.fm-demo {
    background: var(--fm-surface-2);
    border: 1px dashed var(--fm-border-strong);
    border-radius: var(--fm-radius-sm);
    padding: 0.7rem 0.85rem;
    font-size: 0.8rem;
}
.fm-demo code { color: var(--fm-primary-dark); font-weight: 600; }
.fm-demo-row { display: flex; justify-content: space-between; gap: 0.75rem; padding: 0.15rem 0; }

/* Utility */
.fm-divider { height: 1px; background: var(--fm-border); margin: 1rem 0; border: 0; }
.fm-scroll-y { overflow-y: auto; }
.fm-max-h-320 { max-height: 320px; }
.fm-max-h-420 { max-height: 420px; }
.fm-sticky-top { position: sticky; top: calc(var(--fm-topbar-h) + 0.75rem); }
.fm-clickable { cursor: pointer; }
.fm-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --------------------------------------------------------------------------
   11. Responsive
   -------------------------------------------------------------------------- */

/* Tablet: sidebar collapses to an off-canvas drawer */
@media (max-width: 1100px) {
    .fm-split, .fm-split-wide { grid-template-columns: minmax(0, 1fr); }
    .fm-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .fm-sticky-top { position: static; }
}

@media (max-width: 991.98px) {
    .fm-sidebar {
        position: fixed;
        left: 0; top: 0; bottom: 0;
        transform: translateX(-100%);
        transition: transform 0.22s ease;
        box-shadow: var(--fm-shadow-lg);
        width: min(280px, 84vw);
        flex-basis: auto;
    }
    body.fm-nav-open .fm-sidebar { transform: none; }

    .fm-topbar { left: 0; padding-left: 0.75rem; }
    .fm-burger {
        display: inline-grid;
        place-items: center;
        width: 38px; height: 38px;
        border-radius: var(--fm-radius-sm);
        border: 1px solid var(--fm-border);
        background: var(--fm-surface);
        color: var(--fm-text);
        font-size: 1.15rem;
    }

    .fm-grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

    /* Scrim behind the drawer */
    body.fm-nav-open::after {
        content: "";
        position: fixed;
        inset: 0;
        background: rgb(15 23 42 / 0.45);
        z-index: 1030;
    }
}

@media (max-width: 767.98px) {
    body { font-size: 0.9rem; }

    .fm-page { padding: 1rem 0.85rem 4.5rem; }
    .fm-grid-2, .fm-grid-3, .fm-grid-4 { grid-template-columns: minmax(0, 1fr); }

    .fm-page-head { align-items: stretch; }
    .fm-page-head .fm-actions { margin-left: 0; width: 100%; }
    .fm-page-head .fm-actions .btn { flex: 1 1 auto; }

    .fm-stat-value { font-size: 1.45rem; }
    .fm-card-body { padding: 0.85rem; }

    /* Meals read as stacked cards rather than rows */
    .fm-meal-row {
        grid-template-columns: 62px minmax(0, 1fr);
        gap: 0.5rem;
    }
    .fm-meal-row > .fm-meal-end { grid-column: 1 / -1; margin-top: 0.35rem; }

    /* Chore rows wrap the action to its own line */
    .fm-chore { flex-wrap: wrap; }
    .fm-chore > .fm-chore-end { margin-left: auto; }

    .fm-fair-name { width: 5.5rem; font-size: 0.78rem; }
    .fm-fair-val { width: 3.25rem; font-size: 0.72rem; }
    .fm-cat-name { width: 6rem; font-size: 0.78rem; }

    .fm-week { gap: 0.2rem; }
    .fm-day { padding: 0.4rem 0.15rem; }
    .fm-day .fm-day-num { font-size: 0.9rem; }

    .fm-toasts { left: 0.75rem; right: 0.75rem; bottom: 0.75rem; max-width: none; }
}

@media (max-width: 400px) {
    .fm-week { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .fm-optin button { padding: 0.25rem 0.4rem; font-size: 0.7rem; }
}

/* Respect users who ask for less 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;
    }
    .fm-skeleton { animation: none; background: var(--fm-surface-2); }
}

/* --------------------------------------------------------------------------
   12. Print
   -------------------------------------------------------------------------- */
@media print {
    .fm-sidebar, .fm-topbar, .fm-toasts, .fm-actions, .btn, .fm-optin { display: none !important; }
    .fm-main { padding: 0; }
    .fm-page { padding: 0; max-width: none; }
    .fm-card { border: 1px solid #cbd5e1; box-shadow: none; break-inside: avoid; }
    body { background: #fff; font-size: 0.8rem; }
    a { color: inherit; text-decoration: none; }
}
/* --------------------------------------------------------------------------
   13. Diagnostics
   --------------------------------------------------------------------------
   The floating "Report" button. Present on every page, deliberately quiet, and
   carrying a badge count of errors seen since it was last opened. It must stay
   on top of the footer and any modal backdrop it is shown above.
   -------------------------------------------------------------------------- */
.fm-diag-btn {
    position: fixed;
    right: 14px;
    bottom: 14px;
    z-index: 1080;
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .45rem .7rem;
    border: 0;
    border-radius: 999px;
    background: #1e1e2e;
    color: #cdd6f4;
    font-size: .78rem;
    line-height: 1.2;
    box-shadow: 0 6px 18px rgba(0, 0, 0, .22);
    cursor: pointer;
    opacity: .82;
    transition: opacity .15s ease, background .15s ease;
}
.fm-diag-btn:hover { opacity: 1; background: #313244; }
.fm-diag-btn .badge { font-size: .62rem; }
.fm-diag-btn .badge:empty { display: none; }
@media (max-width: 480px) { .fm-diag-label { display: none; } }
@media print { .fm-diag-btn { display: none !important; } }

/* The report itself: monospace, dark, scrollable, wraps long SQL. */
.fm-diag-pre {
    background: #1e1e2e;
    color: #cdd6f4;
    padding: 14px;
    border-radius: 10px;
    font-size: .72rem;
    line-height: 1.45;
    max-height: 58vh;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-word;
}
