/*
 * PetRescue web panel — shared design tokens, layout and components.
 * Mirrors the app's theme (lib/core/theme/tokens.dart): Karuna navy palette, Inter + Source Serif, 8-pt grid.
 * Plain CSS, no build step (rules.md §1, §6). Feature styles live in their own files.
 */

@font-face { font-family: "Inter"; src: url("../fonts/Inter-Regular.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Inter"; src: url("../fonts/Inter-Medium.ttf") format("truetype"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Inter"; src: url("../fonts/Inter-SemiBold.ttf") format("truetype"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Inter"; src: url("../fonts/Inter-Bold.ttf") format("truetype"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Karuna Serif"; src: url("../fonts/SourceSerif4Display-Bold.ttf") format("truetype"); font-weight: 700; font-display: swap; }

:root {
    /* AppColors.light */
    --bg: #ffffff;
    --card: #ffffff;
    --surface: #f1f4fb;
    --border: #dfe5f1;
    --text: #1b2133;
    --text-2: #5f6578;
    --text-muted: #9ca2b3;
    --accent: #1e3a8a;
    --accent-pressed: #172e6e;
    --accent-dark: #0f2557;
    --accent-soft: #eaeffa;
    --on-accent: #ffffff;
    --success: #18813a;
    --warning: #d97f00;
    --info: #0e7490;
    --neutral: #767c8e;
    --danger: #c62828;
    --whatsapp: #128c4a;
    --shadow: 0 2px 8px rgba(15, 37, 87, 0.06);
    --shadow-overlay: 0 6px 20px rgba(15, 37, 87, 0.12);
    --scrim: rgba(27, 33, 51, 0.4);

    /* DashboardPalette */
    --page: #fdfcf9;
    --sky: #d3e5fc;
    --sky-soft: #edf4fe;
    --ink: #16235a;
    --ink-2: #3e4659;
    --brush: #e9a63c;
    --section-bar: #4c81df;
    --t-blue: #5b90f1;
    --t-teal: #45a3aa;
    --t-amber: #e4ad52;
    --t-green: #5fa066;
    --t-slate: #5f6e84;
    --t-red: #d75a61;

    /* Space, radius, sizes */
    --s-xs: 4px; --s-s: 8px; --s-m: 12px; --s-l: 16px; --s-xl: 24px; --s-xxl: 32px;
    --r-input: 10px; --r-card: 12px; --r-sheet: 20px; --r-full: 999px;
    --field-h: 48px;
    --sidebar-w: 248px;
    --topbar-h: 64px;
    --bottombar-h: 64px;

    --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --font-brand: "Karuna Serif", Georgia, serif;
    color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.45;
    color: var(--text);
    background: var(--page);
    -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; line-height: 1.3; }
p { margin: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
[hidden] { display: none !important; }

/* ------------------------------------------------------------------ text styles (AppTypography) */
.t-display { font-size: 25px; font-weight: 700; letter-spacing: -0.4px; line-height: 1.2; }
.t-title { font-size: 19px; font-weight: 700; }
.t-heading { font-size: 16px; font-weight: 600; }
.t-caption { font-size: 13px; font-weight: 500; color: var(--text-2); }
.t-label { font-size: 12px; font-weight: 600; color: var(--text-muted); letter-spacing: 0.6px; text-transform: uppercase; }
.t-muted { color: var(--text-muted); }
.t-secondary { color: var(--text-2); }
.t-danger { color: var(--danger); }
.t-brand { font-family: var(--font-brand); font-weight: 700; color: var(--accent); }
.nowrap { white-space: nowrap; }
.mono { font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------------ app shell */
.shell { min-height: 100vh; display: flex; }
.sidebar {
    position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w);
    background: var(--card); border-right: 1px solid var(--border);
    display: flex; flex-direction: column; z-index: 30;
}
.sidebar__brand { display: flex; align-items: center; gap: var(--s-m); padding: var(--s-l) var(--s-l) var(--s-m); }
.sidebar__brand img { height: 46px; width: auto; }
.sidebar__rule { width: 2px; height: 40px; background: var(--ink); }
.sidebar__name { font-family: var(--font-brand); font-size: 24px; color: var(--ink); line-height: 1.05; }
.sidebar__tag { font-size: 12px; color: var(--ink-2); }
.sidebar__nav { flex: 1; padding: var(--s-s) var(--s-m); display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.nav-link {
    display: flex; align-items: center; gap: var(--s-m); min-height: 44px; padding: 0 var(--s-m);
    border-radius: var(--r-input); color: var(--text-2); font-weight: 500;
}
.nav-link:hover { background: var(--surface); color: var(--text); text-decoration: none; }
.nav-link.is-active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-link .icon { width: 20px; height: 20px; flex: none; }
.sidebar__user { border-top: 1px solid var(--border); padding: var(--s-m) var(--s-l); display: flex; align-items: center; gap: var(--s-m); }
.sidebar__user-name { font-weight: 600; font-size: 14px; }
.sidebar__user-role { font-size: 12px; color: var(--text-2); }

.main { flex: 1; min-width: 0; margin-left: var(--sidebar-w); display: flex; flex-direction: column; }
.topbar {
    position: sticky; top: 0; z-index: 20; min-height: var(--topbar-h);
    display: flex; align-items: center; gap: var(--s-m);
    padding: var(--s-s) var(--s-xl); background: var(--page); border-bottom: 1px solid var(--border);
}
.topbar__back { flex: none; }
.topbar__title { flex: 1; min-width: 0; display: flex; align-items: center; gap: var(--s-s); }
.topbar__title h1 { font-size: 19px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar__actions { display: flex; align-items: center; gap: var(--s-s); flex: none; }
.content { width: 100%; max-width: 1680px; margin: 0 auto; padding: var(--s-xl); flex: 1; }
.content--narrow { max-width: 960px; }

.bottombar { display: none; }

@media (max-width: 1023px) {
    .sidebar { display: none; }
    .main { margin-left: 0; padding-bottom: calc(var(--bottombar-h) + env(safe-area-inset-bottom)); }
    .topbar { padding: var(--s-s) var(--s-l); min-height: 56px; }
    .content { padding: var(--s-l); }
    .bottombar {
        display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
        height: calc(var(--bottombar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
        background: var(--card); border-top: 1px solid var(--border); box-shadow: 0 -2px 12px rgba(15, 37, 87, 0.06);
    }
    .bottombar a {
        flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
        color: var(--text-muted); font-size: 11px; font-weight: 600;
    }
    .bottombar a:hover { text-decoration: none; }
    .bottombar a.is-active { color: var(--accent); }
    .bottombar .icon { width: 22px; height: 22px; }
    .bottombar__fab span.fab {
        width: 48px; height: 48px; border-radius: 50%; background: var(--accent); color: var(--on-accent);
        display: grid; place-items: center; box-shadow: 0 4px 12px rgba(30, 58, 138, 0.35); margin-top: -18px;
    }
    .bottombar__fab .icon { width: 26px; height: 26px; }
}

/* ------------------------------------------------------------------ icons */
.icon { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon--sm { width: 16px; height: 16px; }
.icon--lg { width: 24px; height: 24px; }
.icon--fill { fill: currentColor; stroke: none; }

/* ------------------------------------------------------------------ buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: var(--s-s);
    min-height: 44px; padding: 0 var(--s-l); border-radius: var(--r-input);
    border: 1px solid transparent; background: var(--accent); color: var(--on-accent);
    font-weight: 600; font-size: 15px; cursor: pointer; text-decoration: none; white-space: nowrap;
    transition: background 150ms, transform 150ms, box-shadow 150ms;
}
.btn:hover { background: var(--accent-pressed); text-decoration: none; }
.btn:active { transform: scale(0.98); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn--lg { min-height: 52px; font-size: 16px; padding: 0 var(--s-xl); box-shadow: 0 6px 16px rgba(30, 58, 138, 0.18); }
.btn--sm { min-height: 34px; padding: 0 var(--s-m); font-size: 13px; }
.btn--block { width: 100%; }
.btn--secondary { background: var(--card); color: var(--accent); border-color: var(--border); }
.btn--secondary:hover { background: var(--accent-soft); }
.btn--ghost { background: transparent; color: var(--accent); }
.btn--ghost:hover { background: var(--accent-soft); }
.btn--danger { background: var(--danger); }
.btn--danger:hover { background: #a82020; }
.btn--danger-outline { background: var(--card); color: var(--danger); border-color: rgba(198, 40, 40, 0.3); }
.btn--danger-outline:hover { background: rgba(198, 40, 40, 0.06); }
.btn--whatsapp { background: rgba(37, 211, 102, 0.12); color: var(--whatsapp); }
.btn--whatsapp:hover { background: rgba(37, 211, 102, 0.2); }
.icon-btn {
    width: 40px; height: 40px; border-radius: 50%; display: inline-grid; place-items: center;
    border: 1px solid transparent; background: transparent; color: var(--text-2); cursor: pointer;
}
.icon-btn:hover { background: var(--surface); color: var(--text); text-decoration: none; }
.icon-btn.is-active { background: var(--accent-soft); color: var(--accent); }
.icon-btn--danger { color: var(--danger); }

/* ------------------------------------------------------------------ cards, sections, lists */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--r-card); box-shadow: var(--shadow); }
.card--pad { padding: var(--s-l); }
.card + .card, .section + .section { margin-top: var(--s-l); }
.section__title {
    display: flex; align-items: center; justify-content: space-between; gap: var(--s-s);
    margin: var(--s-xl) 0 var(--s-m);
}
.section__title:first-child { margin-top: 0; }
.section__title h2 { font-size: 13px; font-weight: 700; color: var(--text-2); letter-spacing: 0.6px; text-transform: uppercase; }
.card__head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-s); padding: var(--s-m) var(--s-l); border-bottom: 1px solid var(--border); }
.card__head h3 { font-size: 13px; font-weight: 700; color: var(--text-2); letter-spacing: 0.6px; text-transform: uppercase; }
.card__body { padding: var(--s-l); }

.list { list-style: none; margin: 0; padding: 0; }
.list-row {
    display: flex; align-items: center; gap: var(--s-m); padding: var(--s-m) var(--s-l); min-height: 60px;
    border-bottom: 1px solid var(--border); color: var(--text);
}
.list-row:last-child { border-bottom: 0; }
a.list-row:hover { background: var(--surface); text-decoration: none; }
.list-row__main { flex: 1; min-width: 0; }
.list-row__title { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-row__sub { display: block; font-size: 13px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-row__end { display: flex; align-items: center; gap: var(--s-s); flex: none; color: var(--text-muted); }
@media (max-width: 760px) { .grid--2, .grid--3 { grid-template-columns: 1fr; } }
.stack { display: flex; flex-direction: column; gap: var(--s-m); }
.row { display: flex; align-items: center; gap: var(--s-s); flex-wrap: wrap; }
.mt-l { margin-top: var(--s-l); }
.mb-l { margin-bottom: var(--s-l); }
.mt-xl { margin-top: var(--s-xl); }

.profile-card { display: flex; align-items: center; gap: var(--s-l); }

/* key / value lines inside a card */
.kv { margin: 0; display: grid; grid-template-columns: 150px 1fr; gap: var(--s-s) var(--s-l); align-items: baseline; }
.kv dt { color: var(--text-2); font-size: 13px; font-weight: 500; }
.kv dd { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 560px) { .kv { grid-template-columns: 1fr; gap: 2px; } .kv dd { margin-bottom: var(--s-s); } }

/* ------------------------------------------------------------------ data tables (desktop lists) */
.table-card { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th {
    padding: var(--s-m) var(--s-l); text-align: left; white-space: nowrap; background: var(--surface); border-bottom: 1px solid var(--border);
    font-size: 12px; font-weight: 600; color: var(--text-2); letter-spacing: 0.6px; text-transform: uppercase;
}
.table td { padding: var(--s-s) var(--s-l); border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface); }
.table tr.is-link { position: relative; cursor: pointer; }
.table__link { color: var(--text); font-weight: 600; }
.table__link::after { content: ""; position: absolute; inset: 0; }
.table__link:hover { text-decoration: none; }
.table__name { display: flex; align-items: center; gap: var(--s-m); min-height: 44px; }
.table__name .avatar { width: 36px; height: 36px; font-size: 13px; }
.table__name .avatar .icon { width: 18px; height: 18px; }
.table .table__end { text-align: right; white-space: nowrap; }
.table td.table__end { color: var(--text-muted); }
.table__end > * { display: inline-flex; vertical-align: middle; }
.table__end form { position: relative; z-index: 1; }
@media (max-width: 760px) {
    .table .col-opt { display: none; }
    .table th, .table td { padding-left: var(--s-m); padding-right: var(--s-m); }
    .table__name .avatar { display: none; }
    .table__end .icon-btn { width: 36px; height: 36px; }
}

/* menu links laid out as a grid of cards */
.link-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: var(--s-m); }
.link-grid .list-row { height: 100%; background: var(--card); border: 1px solid var(--border); border-radius: var(--r-card); box-shadow: var(--shadow); }
.link-grid a.list-row:hover { border-color: #c5cfe4; background: var(--card); box-shadow: var(--shadow-overlay); }

/* ------------------------------------------------------------------ badges, dots, chips, tabs */
.badge {
    display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: var(--r-full);
    font-size: 12px; font-weight: 600; white-space: nowrap; color: var(--tone, var(--neutral));
    background: color-mix(in srgb, var(--tone, var(--neutral)) 10%, white);
}
.badge--solid { background: var(--tone); color: #fff; }
.tone-accent { --tone: var(--accent); }
.tone-info { --tone: var(--info); }
.tone-success { --tone: var(--success); }
.tone-warning { --tone: var(--warning); }
.tone-danger { --tone: var(--danger); }
.tone-neutral { --tone: var(--neutral); }

.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--tone, var(--neutral)); flex: none; }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--tone); white-space: nowrap; }

.chips { display: flex; gap: var(--s-s); overflow-x: auto; padding: 2px 0 var(--s-s); scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
    display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: var(--r-full);
    border: 1px solid var(--border); background: var(--card); color: var(--text-2); font-size: 14px; font-weight: 600;
    white-space: nowrap; cursor: pointer;
}
.chip:hover { text-decoration: none; border-color: var(--accent); color: var(--accent); }
.chip.is-active { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.chip__count { font-size: 12px; font-weight: 700; padding: 1px 7px; border-radius: var(--r-full); background: var(--surface); color: var(--text-2); }
.chip.is-active .chip__count { background: rgba(255, 255, 255, 0.2); color: #fff; }

.tabs { display: flex; gap: 4px; padding: 4px; background: var(--surface); border-radius: var(--r-input); overflow-x: auto; }
.tab {
    flex: 1; min-width: max-content; text-align: center; padding: 8px 14px; border-radius: 8px;
    color: var(--text-2); font-weight: 600; font-size: 14px;
}
.tab:hover { text-decoration: none; color: var(--text); }
.tab.is-active { background: var(--card); color: var(--accent); box-shadow: var(--shadow); }
@media (min-width: 1024px) { .tabs { width: fit-content; min-width: 360px; } .tab { padding: 8px 28px; } }

/* ------------------------------------------------------------------ forms */
.field { display: flex; flex-direction: column; gap: 6px; }
.field + .field { margin-top: var(--s-l); }
@media (max-width: 560px) { .field-row { grid-template-columns: 1fr; } }
.label { font-size: 14px; font-weight: 600; color: var(--text); }
.label small { font-weight: 500; color: var(--text-muted); }
.input, .select, .textarea {
    width: 100%; min-height: var(--field-h); padding: 0 14px; border-radius: var(--r-input);
    border: 1px solid #cbd3e3; background: var(--card); font-size: 15px; transition: border-color 150ms, box-shadow 150ms;
}
.textarea { padding: 12px 14px; min-height: 96px; resize: vertical; line-height: 1.45; }
.select { appearance: none; padding-right: 40px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%231e3a8a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: #8798c0; box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.12); }
.input[readonly] { background: var(--surface); color: var(--text-2); }
.field.has-error .input, .field.has-error .select, .field.has-error .textarea { border-color: var(--danger); }
.field__error { color: var(--danger); font-size: 13px; font-weight: 500; }
.field__hint { color: var(--text-muted); font-size: 13px; }
.field__counter { align-self: flex-end; color: var(--text-muted); font-size: 12px; }
.input-group { display: flex; gap: var(--s-s); }
.input-group .select { width: 120px; flex: none; }
.input-prefix { display: flex; align-items: stretch; }
.input-prefix span {
    display: grid; place-items: center; padding: 0 12px; border: 1px solid #cbd3e3; border-right: 0;
    border-radius: var(--r-input) 0 0 var(--r-input); background: var(--surface); color: var(--text-2); font-weight: 600;
}
.input-prefix .input { border-radius: 0 var(--r-input) var(--r-input) 0; }
.form-actions { display: flex; gap: var(--s-m); justify-content: flex-end; margin-top: var(--s-xl); flex-wrap: wrap; }
@media (max-width: 560px) { .form-actions .btn { flex: 1; } }

/* toggle switch (checkbox) */
.switch { display: flex; align-items: center; justify-content: space-between; gap: var(--s-m); cursor: pointer; }
.switch input { appearance: none; width: 46px; height: 28px; border-radius: 14px; background: #cbd3e3; position: relative; cursor: pointer; flex: none; transition: background 150ms; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2); transition: transform 150ms; }
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(18px); }
.switch input:disabled { opacity: 0.5; cursor: not-allowed; }

/* choice cards (radio / checkbox styled as large cards) */
.choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: var(--s-s); }
.choice { position: relative; }
.choice input { position: absolute; opacity: 0; inset: 0; cursor: pointer; margin: 0; }
.choice > span {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 56px; padding: var(--s-s) var(--s-m);
    border: 1.5px solid var(--border); border-radius: var(--r-card); background: var(--card); text-align: center; font-weight: 600; font-size: 14px;
    transition: border-color 150ms, background 150ms;
}
.choice > span img { width: 40px; height: 40px; object-fit: contain; }
.choice input:checked + span { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.choice input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.choice--tone input:checked + span { border-color: var(--tone); background: color-mix(in srgb, var(--tone) 10%, white); color: var(--tone); }
.choices--list { grid-template-columns: 1fr; }
.choices--list .choice > span { flex-direction: row; justify-content: flex-start; text-align: left; padding: var(--s-m) var(--s-l); }

/* ------------------------------------------------------------------ notices, toasts, empty states */
.notice {
    display: flex; gap: var(--s-m); padding: var(--s-m) var(--s-l); border-radius: var(--r-card);
    background: color-mix(in srgb, var(--tone, var(--info)) 9%, white);
    border: 1px solid color-mix(in srgb, var(--tone, var(--info)) 25%, white); color: var(--text);
}
.notice .icon { color: var(--tone, var(--info)); margin-top: 1px; }
.notice__title { font-weight: 700; color: var(--tone, var(--info)); }
.notice__body { font-size: 14px; color: var(--text-2); }
.notice + .notice { margin-top: var(--s-s); }

.toasts { position: fixed; top: var(--s-l); left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: var(--s-s); width: min(520px, calc(100% - 32px)); }
.toast {
    display: flex; align-items: center; gap: var(--s-m); padding: var(--s-m) var(--s-l); border-radius: var(--r-card);
    background: var(--text); color: #fff; box-shadow: var(--shadow-overlay); font-weight: 500; animation: toast-in 200ms ease-out;
}
.toast--error { background: var(--danger); }
.toast--success { background: var(--success); }
.toast .icon-btn { color: #fff; margin-left: auto; width: 32px; height: 32px; }
.toast .icon-btn:hover { background: rgba(255, 255, 255, 0.15); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

.empty { text-align: center; padding: var(--s-xxl) var(--s-l); color: var(--text-2); }
.empty__icon { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; margin: 0 auto var(--s-m); background: var(--accent-soft); color: var(--accent); }
.empty__icon .icon { width: 28px; height: 28px; }
.empty__title { font-size: 16px; font-weight: 700; color: var(--text); }
.empty__body { margin-top: 4px; font-size: 14px; }

.load-more { display: flex; justify-content: center; padding: var(--s-l); }
.load-more .btn.is-loading { pointer-events: none; opacity: 0.6; }

/* ------------------------------------------------------------------ avatars, photos */
.avatar {
    width: 44px; height: 44px; border-radius: 50%; flex: none; display: grid; place-items: center; overflow: hidden;
    background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 15px;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar--lg { width: 64px; height: 64px; font-size: 20px; }
.thumb { width: 56px; height: 56px; border-radius: var(--r-input); object-fit: cover; flex: none; background: var(--surface); }
.thumb--icon { object-fit: contain; padding: 6px; }
.photos { display: flex; gap: var(--s-s); flex-wrap: wrap; }
.photos a { display: block; }
.photos img { width: 96px; height: 96px; object-fit: cover; border-radius: var(--r-input); border: 1px solid var(--border); background: var(--surface); }

/* ------------------------------------------------------------------ dialogs (native <dialog>) */
dialog.sheet {
    border: 0; padding: 0; border-radius: var(--r-sheet); width: min(560px, calc(100% - 24px)); max-height: calc(100vh - 48px);
    box-shadow: var(--shadow-overlay); color: var(--text); background: var(--card);
}
dialog.sheet::backdrop { background: var(--scrim); }
.sheet__head { display: flex; align-items: center; gap: var(--s-s); padding: var(--s-l) var(--s-l) var(--s-s) var(--s-xl); }
.sheet__head h2 { flex: 1; font-size: 19px; font-weight: 700; }
.sheet__body { padding: var(--s-s) var(--s-xl) var(--s-l); overflow-y: auto; max-height: calc(100vh - 220px); }
.sheet__foot { padding: var(--s-m) var(--s-xl) var(--s-xl); display: flex; gap: var(--s-m); border-top: 1px solid var(--border); }
.sheet__foot .btn { flex: 1; }
@media (max-width: 560px) {
    dialog.sheet { width: 100%; max-width: 100%; margin: auto 0 0; border-radius: var(--r-sheet) var(--r-sheet) 0 0; max-height: 92vh; }
}
dialog.lightbox { border: 0; padding: 0; background: transparent; max-width: 96vw; max-height: 96vh; }
dialog.lightbox::backdrop { background: rgba(0, 0, 0, 0.85); }
dialog.lightbox img { max-width: 96vw; max-height: 90vh; border-radius: var(--r-card); }
dialog.lightbox .icon-btn { position: fixed; top: 16px; right: 16px; background: rgba(255, 255, 255, 0.15); color: #fff; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

.center { text-align: center; }
.list-row--button { width: 100%; border: 0; background: transparent; cursor: pointer; text-align: left; font: inherit; }
.list-row--button:hover { background: var(--surface); }

/* week strip (follow-ups, attendance) */
.week { display: flex; align-items: center; gap: var(--s-s); max-width: 820px; margin-inline: auto; }
.week__days { flex: 1; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.week__day {
    position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 10px; border-radius: var(--r-card);
    border: 1px solid var(--border); background: var(--card); color: var(--text); font-weight: 600;
}
.week__day:hover { text-decoration: none; border-color: var(--accent); }
.week__day small { font-size: 11px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; }
.week__day span { font-size: 18px; }
.week__day.is-today { border-color: var(--accent); }
.week__day.is-active { background: var(--accent); border-color: var(--accent); color: #fff; }
.week__day.is-active small { color: rgba(255, 255, 255, 0.8); }
.week__day.is-disabled { opacity: 0.4; pointer-events: none; }
.week__count { position: absolute; top: -6px; right: -4px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; background: var(--warning); color: #fff; font-size: 11px; display: grid; place-items: center; }

/* error pages */
.error-page { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--s-m); padding: var(--s-xl); text-align: center; }
.error-page img { width: 96px; height: auto; margin-bottom: var(--s-l); }
.error-page__code { font-family: var(--font-brand); font-size: 48px; color: var(--accent); line-height: 1; }
.error-page__actions { margin-top: var(--s-l); justify-content: center; }
.notice > .btn { align-self: center; flex: none; }
@media (max-width: 1023px) { .hide-mobile { display: none !important; } }
.plain-fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }

/* The pager under a long list: "Showing 1–20 of 57" on the left, ‹ 1 2 3 › on the right. */
.pager { display: flex; align-items: center; justify-content: space-between; gap: var(--s-m); flex-wrap: wrap; margin-top: var(--s-m); padding: var(--s-s) var(--s-xs); }
.pager__info { margin: 0; font-size: 13px; color: var(--text-2); }
.pager__info strong { color: var(--text); font-weight: 600; }
.pager__pages { display: flex; align-items: center; gap: 4px; list-style: none; margin: 0; padding: 0; }
.pager__btn {
    display: inline-grid; place-items: center; min-width: 36px; height: 36px; padding: 0 10px; border-radius: var(--r-input);
    border: 1px solid var(--border); background: var(--card); color: var(--text); font-size: 14px; font-weight: 600;
    font-variant-numeric: tabular-nums;
}
a.pager__btn:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.pager__btn.is-current { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.pager__btn.is-disabled { color: var(--text-muted); opacity: 0.5; }
.pager__gap { display: inline-grid; place-items: center; min-width: 24px; color: var(--text-muted); }

/* The ambulance placeholder (a photo on white): shown whole, on white, wherever an ambulance has no photo. */
img[src$="img/ambulance.png"] { object-fit: contain; background: #fff; }

/* ------------------------------------------------------------------ fixed page header (owner, 2026-10-21)
   The title bar and the page's own controls (counters, tabs, search, filters) stay put; only the list scrolls, and its
   column names stick under them. --sticky-top (title bar + controls) is measured by common.js. */
.pinned { position: sticky; top: var(--topbar-real, var(--topbar-h)); z-index: 15; background: var(--page); }
.pinned__inner { width: 100%; max-width: 1680px; margin: 0 auto; padding: var(--s-l) var(--s-xl) var(--s-m); display: flex; flex-direction: column; gap: var(--s-m); }
.pinned__inner.content--narrow { max-width: 960px; }
.pinned__inner > * { margin-top: 0 !important; margin-bottom: 0 !important; }
.pinned__inner > .week { width: 100%; }
.pinned::after { content: ""; position: absolute; left: 0; right: 0; bottom: -8px; height: 8px; pointer-events: none; background: linear-gradient(rgba(15, 37, 87, 0.06), transparent); opacity: var(--pinned-shadow, 0); transition: opacity 150ms; }
.content--pinned { padding-top: var(--s-s); }
.case-list__head, .table thead th { position: sticky; top: var(--sticky-top, var(--topbar-h)); z-index: 5; }
.table thead th { background: var(--surface); }
.case-list { overflow: clip; }
@media (min-width: 1024px) { .table-card { overflow: clip; } }
@media (max-width: 1023px) { .pinned__inner { padding: var(--s-m) var(--s-l) var(--s-s); } .hide-desktop { display: inline-flex; } }
@media (min-width: 1024px) { .hide-desktop { display: none !important; } }

/* The period dialog (Reports, Follow-ups): From – To on one line, the hint under them, quick periods as chips. */
.period-dialog__dates { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: end; gap: var(--s-s); }
.period-dialog__dates .field { margin: 0; }
.period-dialog__dash { padding-bottom: 12px; color: var(--text-muted); }
.period-dialog__quick { flex-wrap: wrap; }
@media (max-width: 480px) { .period-dialog__dates { grid-template-columns: 1fr; } .period-dialog__dash { display: none; } }

/* Follow-ups: a smaller week strip (owner, 2026-10-21) with the calendar button beside it, and the picked range. */
.week--compact { max-width: 680px; gap: 4px; }
.week--compact .week__days { gap: 4px; }
.week--compact .week__day { min-height: 48px; padding: 4px 0; border-radius: 10px; }
.week--compact .week__day span { font-size: 15px; }
.week--compact .week__day small { font-size: 10px; }
.week-row { display: flex; align-items: center; justify-content: center; gap: var(--s-s); }
.week-row .week { margin-inline: 0; flex: 1; }
.range-banner {
    display: flex; align-items: center; justify-content: space-between; gap: var(--s-m); padding: var(--s-s) var(--s-s) var(--s-s) var(--s-l);
    border: 1px solid var(--accent); border-radius: var(--r-card); background: var(--accent-soft); color: var(--accent); font-weight: 600;
}
.range-banner span { display: inline-flex; align-items: center; gap: var(--s-s); }

/* Phones: tables scroll sideways, so their header row scrolls with them (a sticky row would float mid-list). */
@media (max-width: 1023px) { .table thead th, .table-card .table thead th { position: static; } }

/* ------------------------------------------------------------------ title bar: centre slot + header search (owner, 2026-10-21)
   Title on the left, the page's tabs in the middle, search and actions on the right. */
.topbar--center .topbar__title, .topbar--center .topbar__actions { flex: 1 1 0; min-width: 0; }
.topbar--center .topbar__actions { justify-content: flex-end; }
.topbar__center { flex: none; display: flex; justify-content: center; }
.topbar .tabs { width: auto; min-width: 0; padding: 3px; }
.topbar .tab { padding: 6px 20px; font-size: 14px; }
.topbar-search { position: relative; display: flex; align-items: center; width: 260px; max-width: 100%; margin: 0; }
.topbar-search .input {
    height: 38px; min-height: 38px; padding: 0 34px 0 36px; border-radius: var(--r-full); font-size: 14px;
    background: var(--card) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239ca2b3' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") no-repeat 12px center;
}
.topbar-search .input:focus { border-color: var(--accent); }
.topbar-search__clear { position: absolute; right: 4px; width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; color: var(--text-muted); }
.topbar-search__clear:hover { background: var(--surface); color: var(--text); text-decoration: none; }
.topbar__search { display: flex; }
.topbar__search-row { display: none; }
.topbar-search--prefix .input { padding-left: 76px; background-position: 50px center; }
.topbar-search__prefix { position: absolute; left: 4px; top: 4px; bottom: 4px; display: grid; place-items: center; padding: 0 10px; border-radius: var(--r-full); background: var(--surface); color: var(--text-2); font-size: 13px; font-weight: 600; }
@media (max-width: 1279px) { .topbar-search { width: 210px; } .topbar .tab { padding: 6px 14px; } }
/* No tabs in the middle (e.g. the Operator's Cases): the search can take more of the bar, so its hint fits. */
@media (min-width: 1024px) { .topbar:not(.topbar--center) .topbar-search { width: 340px; } }
/* Phones and small tablets: the title bar wraps — title + actions, then the page's tabs, then the search. */
@media (max-width: 1023px) {
    .topbar:has(.topbar__search-row), .topbar--center { flex-wrap: wrap; row-gap: var(--s-s); }
    .topbar--center .topbar__title { flex: 1 1 auto; }
    .topbar--center .topbar__actions { flex: none; }
    .topbar__center { order: 3; width: 100%; }
    .topbar__center .tabs { width: 100%; }
    .topbar__center .tab { flex: 1; text-align: center; padding: 6px 8px; }
    .topbar__search { display: none; }
    .topbar__search-row { display: flex; order: 4; width: 100%; }
    .topbar__search-row .topbar-search { width: 100%; }
}

/* The # column of a table (owner, 2026-10-21): the row's place in the list, counted across pages. */
.table .table__sr { width: 44px; padding-right: 0; text-align: right; color: var(--text-muted); font-size: 13px; font-weight: 600; }
.table th.table__sr { color: var(--text-2); }
@media (max-width: 760px) { .table .table__sr { display: none; } }

/* A week strip in the title bar's middle (Attendance, owner 2026-10-21): slim enough to fit the bar. */
.week--header { width: 440px; max-width: 100%; gap: 4px; margin: 0; }
.week--header .week__days { gap: 3px; }
.week--header .week__day { min-height: 0; gap: 0; padding: 3px 0; border-radius: 9px; line-height: 1.15; }
.week--header .week__day span { font-size: 14px; }
.week--header .week__day small { font-size: 9.5px; }
.week--header .icon-btn { width: 32px; height: 32px; }
@media (max-width: 1279px) { .week--header { width: 380px; } }
@media (max-width: 1023px) { .topbar__center .week--header { width: 100%; } }

