/*
 * Shared list page kit (lp-*): header, stat chips, toolbar + filters, table, pagination.
 *
 * One table markup serves every screen size: below 768px of viewport width the rows
 * become cards. Give each <td> a data-label and, where needed, a role class:
 *   lp-c-main     first cell (name/avatar), spans the whole card
 *   lp-c-wide     spans the whole card on phones (long text such as a school name)
 *   lp-c-opt      hidden on tablets, shown again on phone cards
 *   lp-c-hide-sm  hidden on phone cards
 *   lp-c-small    only where optional columns are hidden (tablet, phone table view); never in cards.
 *                 Pair it with lp-c-large on the column it stands in for
 *   lp-c-large    hidden on tablet and in the phone table view; shown on desktop and in cards
 *   lp-c-pay      narrow, no-wrap column holding a confirm button (full width on phone cards with lp-c-wide)
 *   lp-c-actions  action buttons; pinned to the card's top-right corner on phones
 *
 * Behaviour (menus, filter panel, chips, quick filters) lives in static/js/list.js.
 * Colours follow the Material tokens of partials/school/md_theme.html.
 */
:root {
    --lp-bg: #f8f9fa;
    --lp-surface: #ffffff;
    --lp-surface-2: #f6f8fb;
    --lp-line: #e2e6ec;
    --lp-line-strong: #cbd3dd;
    --lp-fg: #1c2530;
    --lp-fg-2: #5b6675;
    --lp-fg-3: #8a94a3;
    --lp-primary: #1976d2;
    --lp-primary-soft: #e8f0fe;
    --lp-primary-fg: #0d47a1;
    --lp-success: #1e7d32;
    --lp-success-soft: #e7f4ea;
    --lp-warning: #9a5b00;
    --lp-warning-soft: #fff3e0;
    --lp-danger: #c62828;
    --lp-danger-soft: #fdecea;
    --lp-info: #00796b;
    --lp-info-soft: #e0f2f1;
    --lp-neutral: #4b5563;
    --lp-neutral-soft: #eef1f5;
    --lp-shadow-1: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
    --lp-shadow-2: 0 4px 10px rgba(16, 24, 40, .10), 0 12px 28px rgba(16, 24, 40, .12);
    --lp-mono: ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

.lp {
    color: var(--lp-fg);
    margin-top: .5rem;
}

.lp-inner { display: grid; gap: 16px; padding-bottom: 24px; }
.lp-inner > * { min-width: 0; }

/* ===== Header ===== */
.lp .lp-crumb { display: flex; gap: 6px; margin: 0; padding: 0; list-style: none; font-size: .8rem; color: var(--lp-fg-3); background: none; }
.lp .lp-crumb a { color: var(--lp-fg-2); }
.lp .lp-crumb li + li::before { content: "/"; margin-right: 6px; }
.lp-head { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: flex-end; justify-content: space-between; }
.lp-title { margin: 2px 0 0; font-size: 1.35rem; font-weight: 700; line-height: 1.2; color: var(--lp-fg); }
.lp-sub { margin: 4px 0 0; color: var(--lp-fg-2); font-size: .875rem; }
.lp-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* ===== Buttons ===== */
.lp-btn,
.lp-btn:hover,
.lp-btn:focus { text-decoration: none; }
.lp-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    height: 38px; padding: 0 14px; border-radius: 10px;
    border: 1px solid var(--lp-line-strong); background: var(--lp-surface); color: var(--lp-fg);
    cursor: pointer; font-weight: 600; font-size: .875rem; white-space: nowrap; line-height: 1;
}
.lp-btn:hover { background: var(--lp-surface-2); color: var(--lp-fg); }
.lp-btn:disabled, .lp-btn.disabled, .lp-icon-btn:disabled, .lp-icon-btn.disabled { opacity: .45; cursor: default; pointer-events: none; }
.lp-btn svg { width: 16px; height: 16px; }
.lp-btn--primary { background: var(--lp-primary); border-color: var(--lp-primary); color: #fff; }
.lp-btn--primary:hover { background: var(--lp-primary-fg); border-color: var(--lp-primary-fg); color: #fff; }
.lp-btn--sm { height: 32px; padding: 0 12px; font-size: .8rem; }
.lp-btn--danger { color: var(--lp-danger); }
.lp-btn--danger:hover { color: var(--lp-danger); background: var(--lp-danger-soft); }
.lp-select-wrap { margin: 0; }
.lp-seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: 11px; background: var(--lp-surface); border: 1px solid var(--lp-line); }
.lp-seg a, .lp-seg button {
    display: inline-flex; align-items: center; height: 32px; padding: 0 14px; border-radius: 8px; border: 0; background: none;
    color: var(--lp-fg-2); font-weight: 600; font-size: .85rem; text-decoration: none; cursor: pointer;
}
.lp-seg a:hover, .lp-seg button:hover { background: var(--lp-surface-2); color: var(--lp-fg); text-decoration: none; }
.lp-seg [aria-current="page"], .lp-seg [aria-pressed="true"] { background: var(--lp-primary-soft); color: var(--lp-primary-fg); }
.lp-select {
    height: 38px; min-width: 96px; border-radius: 10px; border: 1px solid var(--lp-line-strong);
    background-color: var(--lp-surface); color: var(--lp-fg); font-weight: 600; font-size: .875rem; padding: 0 10px;
}
.lp-select:focus { outline: none; border-color: var(--lp-primary); box-shadow: 0 0 0 3px var(--lp-primary-soft); }
.lp-icon-btn {
    width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center;
    border-radius: 9px; border: 1px solid transparent; background: transparent; color: var(--lp-fg-2); cursor: pointer; padding: 0;
}
.lp-icon-btn:hover { background: var(--lp-surface-2); border-color: var(--lp-line); color: var(--lp-fg); }
.lp-icon-btn svg { width: 16px; height: 16px; }
.lp .btn:focus, .lp-btn:focus-visible, .lp-icon-btn:focus-visible { outline: 2px solid var(--lp-primary); outline-offset: 2px; box-shadow: none; }

/* ===== Notice ===== */
.lp-notice { display: flex; gap: 10px; align-items: center; padding: 10px 14px; border-radius: 10px; background: var(--lp-warning-soft); color: var(--lp-warning); font-weight: 600; font-size: .875rem; }
.lp-notice svg { width: 18px; height: 18px; flex: 0 0 auto; }

/* ===== Tones (stat chips, pills, avatars) ===== */
.lp-tone-primary { --lp-tone: var(--lp-primary); --lp-tone-soft: var(--lp-primary-soft); --lp-tone-fg: var(--lp-primary-fg); }
.lp-tone-success { --lp-tone: var(--lp-success); --lp-tone-soft: var(--lp-success-soft); --lp-tone-fg: var(--lp-success); }
.lp-tone-warning { --lp-tone: var(--lp-warning); --lp-tone-soft: var(--lp-warning-soft); --lp-tone-fg: var(--lp-warning); }
.lp-tone-danger  { --lp-tone: var(--lp-danger);  --lp-tone-soft: var(--lp-danger-soft);  --lp-tone-fg: var(--lp-danger); }
.lp-tone-info    { --lp-tone: var(--lp-info);    --lp-tone-soft: var(--lp-info-soft);    --lp-tone-fg: var(--lp-info); }
.lp-tone-neutral { --lp-tone: var(--lp-neutral); --lp-tone-soft: var(--lp-neutral-soft); --lp-tone-fg: var(--lp-neutral); }

/* ===== Stat chips ===== */
.lp-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
.lp-stat {
    text-align: left; display: grid; gap: 2px; padding: 12px 14px; border-radius: 12px;
    background: var(--lp-surface); border: 1px solid var(--lp-line); color: var(--lp-fg); min-width: 0; font: inherit;
}
button.lp-stat { cursor: pointer; }
button.lp-stat:hover { border-color: var(--lp-line-strong); }
.lp-stat[aria-pressed="true"] { border-color: var(--lp-tone); box-shadow: inset 0 0 0 1px var(--lp-tone); background: var(--lp-tone-soft); }
.lp-stat-label { display: flex; align-items: center; gap: 6px; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; color: var(--lp-fg-2); }
.lp-stat-label::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--lp-tone, var(--lp-neutral)); flex: 0 0 auto; }
.lp-stat-value { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.15; }
.lp-stat-split { font-size: .78rem; color: var(--lp-fg-3); font-variant-numeric: tabular-nums; }
.lp-stat-split b { color: var(--lp-fg-2); font-weight: 600; }

/* ===== Toolbar ===== */
.lp-toolbar { display: grid; gap: 10px; position: relative; margin: 0; }
.lp-searchrow { display: flex; gap: 8px; }
.lp-search { position: relative; flex: 1 1 auto; min-width: 0; margin: 0; }
.lp-search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--lp-fg-3); pointer-events: none; }
.lp-search input {
    width: 100%; height: 40px; border-radius: 10px; border: 1px solid var(--lp-line-strong);
    background: var(--lp-surface); padding: 0 12px 0 38px; color: var(--lp-fg); font-size: .9rem;
}
.lp-search input:focus { outline: none; border-color: var(--lp-primary); box-shadow: 0 0 0 3px var(--lp-primary-soft); }
.lp-filter-btn { height: 40px; position: relative; }
.lp-count {
    min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--lp-primary); color: #fff;
    font-size: .72rem; display: inline-flex; align-items: center; justify-content: center; font-variant-numeric: tabular-nums;
}
.lp-chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.lp-chips:empty { display: none; }
.lp-chip {
    display: inline-flex; align-items: center; gap: 4px; height: 28px; padding: 0 6px 0 10px; border-radius: 14px;
    background: var(--lp-primary-soft); color: var(--lp-primary-fg); font-size: .8rem; font-weight: 500; border: 0; cursor: pointer;
}
.lp-chip b { font-weight: 700; }
.lp-chip svg { width: 14px; height: 14px; }
.lp-clear { border: 0; background: none; color: var(--lp-fg-2); font-size: .8rem; text-decoration: underline; cursor: pointer; padding: 4px; }
.lp-summary { color: var(--lp-fg-2); font-size: .85rem; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.lp-phone-tools { display: none; }
.lp-view-switch { display: none; }
.lp-view-switch button {
    width: 34px; height: 30px; border: 0; border-radius: 7px; background: transparent; color: var(--lp-fg-3); padding: 0;
    display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
}
.lp-view-switch button svg { width: 16px; height: 16px; }
.lp-view-switch button[aria-pressed="true"] { background: var(--lp-primary-soft); color: var(--lp-primary-fg); }
.lp-summary strong { color: var(--lp-fg); font-variant-numeric: tabular-nums; }

/* Filter panel: popover under the toolbar on desktop, bottom sheet on phones */
.lp-filters {
    position: absolute; z-index: 1030; top: 46px; right: 0; width: 340px; max-width: 100%;
    background: var(--lp-surface); border: 1px solid var(--lp-line); border-radius: 12px; box-shadow: var(--lp-shadow-2); padding: 14px;
}
.lp-fields { display: grid; gap: 12px; }
.lp-field { display: grid; gap: 4px; margin: 0; }
.lp-field label { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; color: var(--lp-fg-2); margin: 0; }
.lp-field select, .lp-field input[type="date"], .lp-perpage select {
    height: 40px; width: 100%; border-radius: 9px; border: 1px solid var(--lp-line-strong); background-color: var(--lp-surface);
    padding: 0 8px; color: var(--lp-fg); font-size: .875rem;
}
.lp-perpage select { height: 34px; width: auto; }
.lp-sheet-head { display: flex; justify-content: space-between; align-items: center; font-weight: 700; margin-bottom: 10px; }
.lp-sheet-grab { display: none; }
.lp-sheet-foot { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }

/* ===== Table ===== */
.lp-card { background: var(--lp-surface); border: 1px solid var(--lp-line); border-radius: 12px; overflow: hidden; }
/* position: relative keeps absolutely positioned bits (e.g. the .sr-only header label) inside the scroll box. */
.lp-table-wrap { overflow-x: auto; position: relative; }
.lp-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .875rem; margin: 0; color: var(--lp-fg); }
.lp-table thead th {
    background: var(--lp-surface-2); color: var(--lp-fg-2); font-size: .7rem; text-transform: uppercase; letter-spacing: .06em;
    font-weight: 600; text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--lp-line); white-space: nowrap; vertical-align: middle;
}
.lp-table thead th[data-lp-sort] { cursor: pointer; user-select: none; white-space: nowrap; }
.lp-table thead th[data-lp-sort]:hover { color: var(--lp-fg); }
.lp-table thead th[data-lp-sort]:focus-visible { outline: 2px solid var(--lp-primary); outline-offset: -2px; }
.lp-table thead th[data-lp-sort]::after { content: "↕"; margin-left: 5px; opacity: .3; font-size: .9em; }
.lp-table thead th[data-lp-sort][aria-sort="ascending"]::after { content: "↑"; opacity: 1; color: var(--lp-primary); }
.lp-table thead th[data-lp-sort][aria-sort="descending"]::after { content: "↓"; opacity: 1; color: var(--lp-primary); }
.lp-sort-btn svg { width: 16px; height: 16px; }
.lp-sort-btn.is-active { background: var(--lp-primary-soft); color: var(--lp-primary-fg); border-color: transparent; }
.lp-menu-item .lp-sort-mark { margin-left: auto; color: var(--lp-primary); font-weight: 700; }

.lp-table tbody td { padding: 10px 12px; border-bottom: 1px solid var(--lp-line); vertical-align: middle; }
.lp-table tbody tr:last-child td { border-bottom: 0; }
.lp-table tbody tr:hover td { background: var(--lp-surface-2); }
.lp-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.lp-table .lp-c-small { display: none; }
.lp-table th.lp-c-pay, .lp-table td.lp-c-pay { white-space: nowrap; text-align: right; }
.lp-table tr.lp-group-row th {
    background: var(--lp-surface-2); color: var(--lp-fg-2); font-size: .7rem; text-transform: uppercase; letter-spacing: .06em;
    font-weight: 700; padding: 8px 12px; border-bottom: 1px solid var(--lp-line); text-align: left;
}
.lp-sec { display: block; color: var(--lp-fg-3); font-size: .78rem; }
.lp-table .lp-c-actions { width: 1%; white-space: nowrap; text-align: right; }
.lp-c-actions > * { vertical-align: middle; }
.lp:has(.htmx-request) .lp-table tbody { opacity: .5; transition: opacity .15s; }

.lp-who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.lp-who-text { min-width: 0; }
.lp-who-name { font-weight: 600; color: var(--lp-fg); }
.lp-who-name a { color: inherit; }
.lp-who-id { font-family: var(--lp-mono); font-size: .76rem; color: var(--lp-fg-2); }
.lp-who-ar { font-size: .9rem; color: var(--lp-fg-2); display: block; }
.lp-avatar {
    width: 40px; height: 40px; border-radius: 50%; flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center;
    font-size: .78rem; font-weight: 700; background: var(--lp-tone-soft, var(--lp-surface-2)); color: var(--lp-tone-fg, var(--lp-fg-3));
    position: relative;
}
.lp-avatar--sq { border-radius: 10px; }
.lp-avatar--empty { background: var(--lp-surface-2); color: var(--lp-fg-3); border: 1px dashed var(--lp-line-strong); }
.lp-avatar svg { width: 16px; height: 16px; }
.lp-avatar-img { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; flex: 0 0 auto; background: var(--lp-surface-2); box-shadow: 0 0 0 1px var(--lp-line-strong); }
.lp-avatar-add {
    position: absolute; right: -5px; bottom: -5px; width: 22px; height: 22px; border-radius: 50%; padding: 0;
    border: 2px solid var(--lp-surface); background: var(--lp-success); color: #fff; display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
}
.lp-avatar-add svg { width: 11px; height: 11px; }

.lp-pill {
    display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: 12px;
    background: var(--lp-tone-soft); color: var(--lp-tone-fg); font-size: .76rem; font-weight: 600; white-space: nowrap;
}
.lp-pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--lp-tone); }
.lp-pill-key { font-weight: 500; opacity: .75; }

/* Row action menu (opened by list.js; position:fixed so the table scroll never clips it) */
.lp-menu-wrap { display: inline-block; }
.lp-menu {
    position: fixed; z-index: 1046; min-width: 220px; max-width: calc(100vw - 16px);
    background: var(--lp-surface); border: 1px solid var(--lp-line); border-radius: 12px; box-shadow: var(--lp-shadow-2); padding: 6px; text-align: left;
}
.lp-menu-title { display: none; font-weight: 700; padding: 6px 10px 8px; }
.lp-menu-item,
a.lp-menu-item {
    width: 100%; display: flex; align-items: center; gap: 10px; border: 0; background: none; padding: 9px 10px; border-radius: 8px;
    cursor: pointer; text-align: left; font-size: .875rem; color: var(--lp-fg); text-decoration: none; white-space: nowrap;
}
.lp-menu-item:hover { background: var(--lp-surface-2); color: var(--lp-fg); text-decoration: none; }
.lp-menu-item:disabled { opacity: .45; cursor: default; }
.lp-menu-item svg { width: 16px; height: 16px; color: var(--lp-fg-2); }
.lp-menu-item--danger, .lp-menu-item--danger svg, .lp-menu-item--danger:hover { color: var(--lp-danger); }
.lp-menu-sep { height: 1px; background: var(--lp-line); margin: 4px 6px; }
.lp-menu-identity { display: none; }

/* Phone bottom sheet: one host appended to <body> by list.js (like the student card sheet),
   so no ancestor of the list can hide it or trap it under the bottom nav. */
.lp-sheet { position: fixed; inset: 0; z-index: 1080; }
.lp-sheet-backdrop {
    position: absolute; inset: 0; width: 100%; height: 100%; border: 0; padding: 0; background: rgba(22, 32, 38, .48);
    opacity: 0; transition: opacity .2s ease;
}
.lp-sheet-panel {
    position: absolute; left: 0; right: 0; bottom: 0; max-height: 82vh; overflow-y: auto; background: var(--lp-surface);
    border-radius: 16px 16px 0 0; padding: 0 1rem calc(1rem + env(safe-area-inset-bottom, 0px)); color: var(--lp-fg);
    transform: translateY(100%); transition: transform .24s cubic-bezier(.2, .8, .2, 1);
}
/* Slide up and fade in on open, slide down and fade out on close (list.js keeps the host visible for SHEET_MS). */
.lp-sheet.is-open .lp-sheet-backdrop { opacity: 1; }
.lp-sheet.is-open .lp-sheet-panel { transform: translateY(0); }
.lp-sheet:not(.is-open) { pointer-events: none; }
.lp-sheet:not(.is-open) .lp-sheet-panel { transition-duration: .18s; transition-timing-function: ease-in; }
@media (prefers-reduced-motion: reduce) { .lp-sheet-backdrop, .lp-sheet-panel { transition: none; } }
.lp-sheet-handle { width: 42px; height: 4px; border-radius: 999px; background: #c5ced3; margin: .65rem auto .75rem; }
.lp-sheet-head h2 { font-size: 1rem; font-weight: 700; margin: 0; }
.lp-sheet .lp-sheet-head { margin-bottom: .75rem; }
.lp-sheet .lp-sheet-head .lp-icon-btn { width: 36px; height: 36px; border-radius: 50%; background: #fff; box-shadow: 0 2px 5px rgba(18, 38, 63, .18); }
.lp-sheet .lp-sheet-grab { display: none; }
.lp-sheet .lp-filters { position: static; width: auto; max-width: none; border: 0; box-shadow: none; padding: 0; border-radius: 0; }
.lp-sheet .lp-menu-items { display: grid; }
.lp-sheet .lp-menu-title { display: none; }
.lp-sheet .lp-menu-identity { display: flex; align-items: center; gap: .75rem; padding: .25rem 0 .9rem; margin-bottom: .4rem; border-bottom: 1px solid var(--lp-line); }
.lp-sheet .lp-menu-identity strong, .lp-sheet .lp-menu-identity span { display: block; }
.lp-sheet .lp-menu-identity span { color: var(--lp-fg-2); font-size: .8rem; }
.lp-sheet .lp-menu-identity .lp-mcard-img, .lp-sheet .lp-menu-identity .lp-mcard-noimg { width: 48px; height: 48px; flex: 0 0 auto; }
.lp-sheet .lp-menu-item { padding: 13px 4px; font-size: .95rem; gap: 14px; }
.lp-sheet .lp-menu-item svg { width: 18px; height: 18px; }
.lp-sheet .lp-menu-sep { margin: 4px 0; }
.lp-sheet .lp-sheet-foot .lp-btn { flex: 1; height: 46px; }

/* ===== Phone cards (same design as the student card list) =====
   Render them next to the table inside .lp-card.lp-card--mcards; they replace the table below 768px. */
.lp-mcards { display: none; }
.lp-mcard { background: #fff; border: 1px solid #dfe5e8; border-radius: 8px; box-shadow: 0 2px 7px rgba(18, 38, 63, .08); overflow: hidden; }
.lp-mcard-head { display: flex; align-items: center; gap: .75rem; padding: .875rem; }
.lp-mcard-photo { position: relative; width: 52px; height: 52px; flex: 0 0 auto; }
.lp-mcard-img { width: 52px; height: 52px; border-radius: 50%; object-fit: cover; border: 1px solid #dfe5e8; }
.lp-mcard-add, .lp-mcard-noimg {
    width: 52px; height: 52px; border-radius: 50%; border: 0; padding: 0; background: #fff; color: #52636e;
    box-shadow: 0 2px 5px rgba(18, 38, 63, .18); display: inline-flex; align-items: center; justify-content: center;
}
.lp-mcard-noimg { box-shadow: none; background: var(--lp-surface-2); color: var(--lp-fg-3); }
.lp-mcard-add svg, .lp-mcard-noimg svg { width: 20px; height: 20px; }
.lp-mcard-id { display: grid; flex: 1; gap: .15rem; min-width: 0; }
.lp-mcard-id strong, .lp-mcard-id span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lp-mcard-id strong { font-size: .9rem; }
.lp-mcard-id strong a { color: inherit; }
.lp-mcard-id span { color: #69747d; font-size: .75rem; }
.lp-mcard-id .lp-mcard-ar { font-size: .85rem; }
.lp-mcard-actions { display: flex; gap: .35rem; flex: 0 0 auto; }
.lp-mcard-btn {
    width: 32px; height: 32px; border-radius: 50%; border: 0; padding: 0; background: #fff; color: #52636e;
    box-shadow: 0 2px 5px rgba(18, 38, 63, .18); display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
}
.lp-mcard-btn svg { width: 16px; height: 16px; }
.lp-mcard-btn--edit { color: #b46f00; }
.lp-mcard-statuses { display: flex; flex-wrap: wrap; gap: .5rem; padding: .625rem .875rem; border-top: 1px solid #edf0f2; }
.lp-mcard-details { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .625rem; margin: 0; padding: .125rem .875rem .75rem; }
.lp-mcard-details div { min-width: 0; }
.lp-mcard-details dt { color: #78838c; font-size: .7rem; font-weight: 600; margin: 0; text-transform: uppercase; }
.lp-mcard-details dd { color: #28333b; font-size: .8rem; margin: .15rem 0 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lp-mcard-details .lp-mcard-full { grid-column: 1 / -1; }

/* ===== Empty state ===== */
.lp-empty { padding: 40px 20px; display: grid; justify-items: center; gap: 8px; text-align: center; }
.lp-empty-ico { width: 56px; height: 56px; border-radius: 50%; background: var(--lp-surface-2); color: var(--lp-fg-3); display: inline-flex; align-items: center; justify-content: center; }
.lp-empty-ico svg { width: 26px; height: 26px; }
.lp-empty-title { margin: 6px 0 0; font-size: 1rem; font-weight: 700; }
.lp-empty p { margin: 0; color: var(--lp-fg-2); max-width: 42ch; }
.lp-table tbody tr.lp-empty-row:hover td { background: transparent; }

/* ===== Pagination ===== */
.lp-pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; padding: 10px 12px; border-top: 1px solid var(--lp-line); font-size: .85rem; color: var(--lp-fg-2); }
.lp-pager strong { color: var(--lp-fg); font-variant-numeric: tabular-nums; }
.lp-pages { display: flex; gap: 4px; align-items: center; margin: 0; padding: 0; list-style: none; }
.lp-page {
    min-width: 34px; height: 34px; padding: 0 8px; border-radius: 9px; border: 1px solid transparent; background: transparent; cursor: pointer;
    font-variant-numeric: tabular-nums; color: var(--lp-fg); display: inline-flex; align-items: center; justify-content: center; text-decoration: none;
}
.lp-page:hover { background: var(--lp-surface-2); border-color: var(--lp-line); color: var(--lp-fg); text-decoration: none; }
.lp-page[aria-current="page"] { background: var(--lp-primary); color: #fff; font-weight: 700; }
.lp-page.disabled { opacity: .35; pointer-events: none; }
.lp-page svg { width: 16px; height: 16px; }
.lp-gap { padding: 0 4px; color: var(--lp-fg-3); }
.lp-perpage { display: flex; align-items: center; gap: 8px; margin: 0; }
.lp-pager-mobile { display: none; }

/* ===== Tablet: drop optional columns ===== */
@media (max-width: 1199.98px) {
    .lp-c-opt, .lp-table .lp-c-large { display: none; }
    .lp-table .lp-c-small { display: table-cell; }
}

/* ===== Phone: cards (or the table, by choice), bottom sheets ===== */
@media (max-width: 767.98px) {
    .lp { padding-inline: 12px; overflow-x: clip; }
    .lp-inner { gap: 12px; }
    .lp-title { font-size: 1.15rem; }
    .lp-actions { width: 100%; }
    .lp-actions > * { flex: 1 1 0; }
    .lp-actions .lp-btn { width: 100%; }

    /* Compact stat chips: label + value, then the boys/girls split in small type */
    .lp-stats { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; gap: 8px; scrollbar-width: none; padding-bottom: 2px; }
    .lp-stats::-webkit-scrollbar { display: none; }
    .lp-stat {
        flex: 0 0 auto; display: grid; grid-template-columns: auto auto; align-items: baseline; justify-content: start;
        gap: 0 8px; padding: 7px 14px 6px; border-radius: 16px; scroll-snap-align: start;
    }
    .lp-stat-label { font-size: .68rem; }
    .lp-stat-value { font-size: 1rem; }
    .lp-stat-split { grid-column: 1 / -1; font-size: .62rem; line-height: 1.2; padding-left: 14px; }

    .lp-toolbar { position: sticky; top: var(--lp-sticky-top, 56px); z-index: 1020; background: var(--lp-bg); padding: 8px 0; }
    .lp-filter-label { display: none; }
    .lp-searchrow { padding-right: 6px; }
    .lp-filter-btn { width: 44px; padding: 0; }
    .lp-filter-btn .lp-count { position: absolute; top: -6px; right: -6px; }

    .lp-phone-tools { display: inline-flex; align-items: center; gap: 6px; }
    .lp-view-switch { display: inline-flex; gap: 2px; padding: 2px; border-radius: 9px; background: var(--lp-surface); border: 1px solid var(--lp-line); }

    /* Card view (default). .lp-view-table on .lp switches back to the desktop table, scrolling sideways. */
    .lp:not(.lp-view-table) .lp-card--mcards .lp-table-wrap { display: none; }
    .lp:not(.lp-view-table) .lp-mcards { display: grid; gap: .75rem; }
    .lp-mcards + .lp-pager { margin-top: 12px; }
    /* contain: paint keeps the wide table from widening the page (phone menus open in the body-level sheet). */
    .lp.lp-view-table .lp-table-wrap { -webkit-overflow-scrolling: touch; contain: paint; }
    .lp.lp-view-table .lp-table td.lp-c-main { min-width: 150px; }
    .lp.lp-view-table .lp-pager-mobile { padding: 4px 12px 8px; }

    .lp:not(.lp-view-table) .lp-card { background: transparent; border: 0; border-radius: 0; overflow: visible; }
    .lp:not(.lp-view-table) .lp-table-wrap { overflow: visible; }
    .lp:not(.lp-view-table) .lp-table thead { display: none; }
    .lp:not(.lp-view-table) .lp-table,
    .lp:not(.lp-view-table) .lp-table tbody { display: block; }
    .lp:not(.lp-view-table) .lp-table tbody { display: grid; gap: 10px; }
    .lp:not(.lp-view-table) .lp-table tr {
        display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px 14px; position: relative;
        background: var(--lp-surface); border: 1px solid var(--lp-line); border-radius: 12px; padding: 12px; box-shadow: var(--lp-shadow-1);
    }
    .lp:not(.lp-view-table) .lp-table td,
    .lp:not(.lp-view-table) .lp-table tbody td { display: block; padding: 0; border: 0; min-width: 0; }
    .lp:not(.lp-view-table) .lp-table tbody tr:hover td { background: transparent; }
    .lp:not(.lp-view-table) .lp-table td[data-label]::before {
        content: attr(data-label); display: block; font-size: .66rem; text-transform: uppercase; letter-spacing: .07em;
        font-weight: 600; color: var(--lp-fg-3); margin-bottom: 3px;
    }
    .lp:not(.lp-view-table) .lp-table .num { text-align: left; }
    .lp:not(.lp-view-table) .lp-table td.lp-c-main { grid-column: 1 / -1; padding: 0 44px 10px 0; border-bottom: 1px solid var(--lp-line); }
    .lp:not(.lp-view-table) .lp-table td.lp-c-wide,
    .lp:not(.lp-view-table) .lp-table tr.lp-empty-row td { grid-column: 1 / -1; }
    .lp:not(.lp-view-table) .lp-table td.lp-c-hide-sm,
    .lp:not(.lp-view-table) .lp-table td.lp-c-small { display: none; }
    .lp:not(.lp-view-table) .lp-table td.lp-c-pay { text-align: left; }
    .lp:not(.lp-view-table) .lp-table tr.lp-group-row { display: block; background: none; border: 0; box-shadow: none; padding: 10px 2px 0; }
    .lp:not(.lp-view-table) .lp-table tr.lp-group-row th { display: block; background: none; border: 0; padding: 0; }
    .lp:not(.lp-view-table) .lp-table td.lp-c-actions { position: absolute; top: 8px; right: 6px; width: auto; }
    .lp:not(.lp-view-table) .lp-inline-action { display: none !important; }
    .lp:not(.lp-view-table) .lp-who-name { font-size: .95rem; }

    .lp:not(.lp-view-table) .lp-pager { border-top: 0; padding: 4px 0 0; }
    .lp-pages, .lp-perpage, .lp-range { display: none; }
    .lp-pager-mobile { display: flex; align-items: center; gap: 12px; width: 100%; justify-content: space-between; }
    .lp-pager-mobile .lp-btn { height: 42px; }
}
