/* Rescue Pro: Plum and Peach. All styles for the app live in this one file. */

:root {
    --plum: #3E2A47;
    --plum-dark: #2B1C32;
    --peach: #F4A582;
    --deep-peach: #C8693F;
    --cream: #FBF6F1;
    --white: #FFFFFF;
    --ink: #261A2C;
    --muted: #5A4A60;
    --border: #E3E5E8;
    --page: #F5F6F7;

    /* Status colours, always shown with a word label. Amber is a course in progress. */
    --green: #1C8A4B;
    --red: #D93025;
    --grey: #8A97A0;
    --amber: #F2A900;

    /* Text-safe shades: any text on or coloured by a status colour (4.5:1 or better). */
    --green-text: #17703C;
    --red-text: #B3261E;
    --grey-text: #5F6B73;

    --font-heading: "Nunito", "Segoe UI", system-ui, sans-serif;
    --font-body: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
    --radius: 16px;

    /* One height for every single-line input, select and button (44px touch target). */
    --control-height: 44px;
    --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%233E2A47' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    --tick: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='10' viewBox='0 0 12 10'%3E%3Cpath d='M1 5l3.5 3.5L11 1.5' fill='none' stroke='%23FFFFFF' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    background: var(--page);
    color: var(--ink);
    font-family: var(--font-body);
    font-weight: 400;
    font-size: 1rem;
    line-height: 1.55;
}

h1,
h2,
h3 {
    font-family: var(--font-heading);
    font-weight: 800;
    line-height: 1.15;
    margin: 0 0 0.75rem;
}

p {
    margin: 0 0 1rem;
}

a {
    color: var(--deep-peach);
    font-weight: 600;
    text-underline-offset: 3px;
}

code {
    font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
    font-size: 0.95em;
}

:focus-visible {
    outline: 3px solid var(--deep-peach);
    outline-offset: 2px;
}

/* Logo: the peeking pup plus the wordmark */

.logo {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
}

.logo__mark {
    width: 48px;
    height: 48px;
    flex: none;
}

.logo__wordmark {
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: 1.6rem;
    letter-spacing: -0.01em;
}

.logo--on-plum .logo__wordmark {
    color: var(--white);
}

.logo--on-plum .logo__pro {
    color: var(--peach);
}

.logo--on-light .logo__wordmark {
    color: var(--plum);
}

.logo--on-light .logo__pro {
    color: var(--deep-peach);
}

/* Plum header band */

.band {
    background: var(--plum);
    color: var(--white);
}

.band__inner {
    max-width: 960px;
    margin: 0 auto;
    padding: 1.25rem 1.5rem;
}

/* Holding page: the logo lines up with the content column below (same width and side padding). */
.page--holding .band__inner {
    max-width: 720px;
}

/* Buttons: plum, or plum outline; at least 44px tall; fully rounded */

.btn {
    -webkit-appearance: none;
    appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: var(--control-height);
    padding: 0.6rem 1.6rem;
    border: 2px solid var(--plum);
    border-radius: 999px;
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.2;
    text-decoration: none;
    cursor: pointer;
}

.btn--primary {
    background: var(--plum);
    color: var(--white);
}

.btn--primary:hover {
    background: var(--plum-dark);
    border-color: var(--plum-dark);
}

.btn--outline {
    background: transparent;
    color: var(--plum);
}

.btn--outline:hover {
    background: var(--plum);
    color: var(--white);
}

.btn--block {
    width: 100%;
}

.btn--link {
    border-color: transparent;
    background: transparent;
    color: var(--plum);
    padding-left: 0;
    padding-right: 0;
    text-decoration: underline;
    text-underline-offset: 3px;
}

/* Peach ticks */

.ticks {
    list-style: none;
    margin: 0 0 1.5rem;
    padding: 0;
}

.ticks li {
    position: relative;
    padding-left: 2.4rem;
    margin-bottom: 0.85rem;
}

.ticks li::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0.05rem;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 50%;
    background: var(--peach);
}

.ticks li::after {
    content: "";
    position: absolute;
    left: 0.52rem;
    top: 0.33rem;
    width: 0.42rem;
    height: 0.75rem;
    border: solid var(--plum);
    border-width: 0 0.17rem 0.17rem 0;
    transform: rotate(45deg);
}

/* Holding page */

.holding {
    max-width: 720px;
    margin: 0 auto;
    padding: 3rem 1.5rem 2rem;
}

.holding__title {
    color: var(--plum);
    font-size: clamp(2rem, 6vw, 3.1rem);
}

.holding__lead {
    font-size: 1.2rem;
    color: var(--muted);
    margin-bottom: 2rem;
}

.holding .ticks li {
    font-size: 1.05rem;
}

.holding__soon {
    font-weight: 700;
    color: var(--plum);
    margin: 2rem 0 1.25rem;
}

.footer {
    max-width: 720px;
    margin: 0 auto;
    padding: 1.5rem;
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: 0.95rem;
}

/* Sign-in: plum panel on the left, white card on the right */

.auth {
    display: grid;
    grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
    min-height: 100vh;
}

.auth__panel {
    display: flex;
    flex-direction: column;
    gap: 2.5rem;
    background: var(--plum);
    color: var(--cream);
    padding: 2.5rem 3rem;
}

.auth__title {
    color: var(--white);
    font-size: clamp(1.8rem, 3vw, 2.5rem);
    margin-bottom: 1.75rem;
}

.auth__made {
    margin-top: auto;
    margin-bottom: 0;
    color: var(--peach);
    font-weight: 600;
}

.auth__main {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2.5rem 1.5rem;
}

.card {
    width: 100%;
    max-width: 440px;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2.25rem 2rem;
}

.card__title {
    color: var(--plum);
    font-size: 1.9rem;
    margin-bottom: 0.35rem;
}

.card__subtitle {
    color: var(--muted);
    margin-bottom: 1.5rem;
}

.card__note {
    margin: 1.5rem 0 0;
    color: var(--muted);
    font-size: 0.9rem;
}

/* Forms */

.form {
    margin: 0;
}

.form--quiet {
    margin-top: 1.25rem;
    text-align: center;
}

.field {
    margin-bottom: 1.1rem;
}

.field__label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.35rem;
}

/* House form controls: never the browser default (Safari and Chrome alike).
   Single-line inputs and selects are exactly --control-height, like buttons. */

.field__input {
    -webkit-appearance: none;
    appearance: none;
    display: block;
    width: 100%;
    min-height: var(--control-height);
    margin: 0;
    padding: 0.6rem 0.85rem;
    border: 1px solid var(--muted);
    border-radius: 10px;
    background-color: var(--white);
    color: var(--ink);
    font-family: var(--font-body);
    font-size: 1rem;
    line-height: 1.25;
}

input.field__input,
select.field__input {
    height: var(--control-height);
}

.field__input:focus-visible {
    border-color: var(--plum);
}

.field__input:disabled {
    background-color: var(--page);
    color: var(--muted);
}

/* Selects: the plum chevron on the right; long text is cut with an ellipsis before it. */
select.field__input {
    padding-right: 2.6rem;
    background-image: var(--chevron);
    background-repeat: no-repeat;
    background-position: right 0.9rem center;
    background-size: 12px 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
}

select.field__input::-ms-expand {
    display: none;
}

/* Search boxes: no Safari rounded search field, no extra decorations. */
input[type="search"].field__input::-webkit-search-decoration,
input[type="search"].field__input::-webkit-search-results-button,
input[type="search"].field__input::-webkit-search-results-decoration {
    -webkit-appearance: none;
}

/* Date fields: same box in Safari (which otherwise centres the text and shrinks the field). */
input[type="date"].field__input {
    display: flex;
    align-items: center;
}

input[type="date"].field__input::-webkit-date-and-time-value {
    margin: 0;
    text-align: left;
}

input[type="date"].field__input::-webkit-datetime-edit {
    padding: 0;
}

input[type="date"].field__input::-webkit-calendar-picker-indicator {
    cursor: pointer;
}

textarea.field__input {
    min-height: 5.5rem;
    resize: vertical;
    line-height: 1.4;
}

.field__input--code {
    font-size: 1.4rem;
    letter-spacing: 0.3em;
    text-align: center;
}

.field--check {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    min-height: var(--control-height);
    margin-bottom: 1.25rem;
}

/* Checkboxes: a house box, plum with a white tick when checked. */
input[type="checkbox"] {
    -webkit-appearance: none;
    appearance: none;
    flex: 0 0 auto;
    width: 1.25rem;
    height: 1.25rem;
    margin: 0;
    border: 2px solid var(--muted);
    border-radius: 5px;
    background: var(--white) no-repeat center / 12px 10px;
    cursor: pointer;
}

input[type="checkbox"]:checked {
    border-color: var(--plum);
    background-color: var(--plum);
    background-image: var(--tick);
}

input[type="checkbox"]:focus-visible {
    outline: 3px solid var(--deep-peach);
    outline-offset: 2px;
}

.alert {
    border: 1px solid var(--border);
    border-left: 4px solid var(--grey);
    background: var(--white);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    margin-bottom: 1.25rem;
}

.alert p {
    margin: 0;
}

.alert--error {
    border-left-color: var(--red);
    color: var(--red-text);
    font-weight: 600;
}

.alert--success {
    border-left-color: var(--green);
    color: var(--green-text);
    font-weight: 600;
}

/* Two-step setup */

.qr {
    display: flex;
    justify-content: center;
    padding: 1rem;
    margin-bottom: 1rem;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 12px;
}

.qr svg {
    width: 200px;
    height: 200px;
}

.setup-key {
    color: var(--muted);
    font-size: 0.9rem;
    overflow-wrap: anywhere;
}

.recovery {
    margin-top: 1.5rem;
}

.recovery summary {
    min-height: 44px;
    display: flex;
    align-items: center;
    cursor: pointer;
    color: var(--plum);
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.recovery .form {
    margin-top: 0.75rem;
}

.recovery-codes {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem 1rem;
    margin: 0 0 1.5rem;
    padding: 1rem 1rem 1rem 2.25rem;
    background: var(--page);
    border: 1px solid var(--border);
    border-radius: 12px;
}

/* Welcome page */

.welcome {
    max-width: 720px;
    margin: 0 auto;
    padding: 3rem 1.5rem;
}

.welcome__title {
    color: var(--plum);
    font-size: clamp(2rem, 5vw, 2.8rem);
}

.welcome__lead {
    color: var(--muted);
    font-size: 1.15rem;
    margin-bottom: 2rem;
}

/* App pages: header with navigation */

.band__inner--app {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem 1.5rem;
    max-width: 1120px;
}

.topnav {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.topnav__link {
    color: var(--white);
    min-height: 44px;
    display: inline-flex;
    align-items: center;
}

.topnav__form {
    margin: 0;
}

.btn--on-plum {
    background: transparent;
    border-color: var(--peach);
    color: var(--white);
}

.btn--on-plum:hover {
    background: var(--peach);
    color: var(--plum);
}

.btn--small {
    min-height: var(--control-height);
    padding: 0.4rem 1.1rem;
    font-size: 0.95rem;
}

.btn--danger {
    background: var(--red);
    border-color: var(--red);
    color: var(--white);
}

.btn--danger:hover {
    background: #A32020;
    border-color: #A32020;
}

/* Viewing banner: read only (admin viewing a real rescue) or Demo Rescue */

.viewing {
    border-bottom: 1px solid var(--border);
}

.viewing--readonly {
    background: var(--white);
    border-left: 6px solid var(--grey);
}

.viewing--demo {
    background: var(--peach);
}

.viewing__inner {
    max-width: 1120px;
    margin: 0 auto;
    padding: 0.6rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
}

.viewing__text {
    margin: 0;
    font-weight: 700;
    color: var(--plum);
}

.viewing form {
    margin: 0;
}

/* Admin pages */

.app-main {
    max-width: 1120px;
    margin: 0 auto;
    padding: 2rem 1.5rem 3rem;
}

.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.page-head form {
    margin: 0;
}

.page-head__title {
    color: var(--plum);
    font-size: clamp(1.7rem, 4vw, 2.3rem);
    margin: 0;
}

.crumbs {
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

.muted {
    color: var(--muted);
}

.grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.panel {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.grid .panel {
    margin-bottom: 0;
}

.panel--narrow {
    max-width: 560px;
}

.panel__title {
    color: var(--plum);
    font-size: 1.35rem;
}

.form--boxed {
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border);
}

.form__title {
    color: var(--plum);
    font-size: 1.1rem;
}

.field__help {
    color: var(--muted);
    font-size: 0.9rem;
    margin: 0.35rem 0 0;
}

.details {
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr);
    gap: 0.5rem 1.25rem;
    margin: 0;
}

.details dt {
    font-weight: 600;
    color: var(--muted);
}

.details dd {
    margin: 0;
}

.counts,
.plain-list,
.choices,
.modules {
    list-style: none;
    margin: 0 0 1rem;
    padding: 0;
}

.counts {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.25rem;
}

.counts__label {
    color: var(--muted);
}

.counts__value {
    font-weight: 700;
}

.plain-list li {
    padding: 0.35rem 0;
    border-bottom: 1px solid var(--border);
}

.choices__item {
    margin-bottom: 0.75rem;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.actions form {
    margin: 0;
}

/* Tags: green, red and grey are the fixed status colours */

.tag {
    display: inline-block;
    padding: 0.1rem 0.6rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 700;
    vertical-align: middle;
    color: var(--white);
    background: var(--grey-text);
}

.tag--green {
    background: var(--green-text);
}

.tag--red {
    background: var(--red);
}

.tag--grey {
    background: var(--grey-text);
}

.tag--demo {
    background: var(--peach);
    color: var(--plum);
}

.tag--locked {
    background: var(--plum);
}

/* Tables: rows become cards on phones */

.table-wrap {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow-x: auto;
}

.panel .table-wrap {
    border: 0;
    border-radius: 0;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    text-align: left;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

.table th {
    font-size: 0.85rem;
    color: var(--muted);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.table tbody tr:last-child td {
    border-bottom: 0;
}

/* Number columns: right-aligned in the heading and in every cell. */
.table th.table__num,
.table td.table__num {
    text-align: right;
}

.table--compact th,
.table--compact td {
    padding: 0.5rem 0.75rem;
    font-size: 0.92rem;
}

/* Module switches: four accordion sections, one compact row per module */

.modsecs {
    display: grid;
    gap: 0.75rem;
}

.modsec {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--page);
}

.modsec[open] {
    background: var(--white);
}

.modsec__summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-height: 52px;
    padding: 0.6rem 1rem;
    cursor: pointer;
    list-style: none;
    border-radius: 12px;
}

.modsec__summary::-webkit-details-marker {
    display: none;
}

.modsec__summary::before {
    content: "";
    flex: none;
    width: 0.55rem;
    height: 0.55rem;
    border: solid var(--plum);
    border-width: 0 0.15rem 0.15rem 0;
    transform: rotate(-45deg);
    transition: transform 0.15s ease;
}

.modsec[open] > .modsec__summary::before {
    transform: rotate(45deg);
}

.modsec__title {
    flex: 1;
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: 1.1rem;
    color: var(--plum);
}

.modsec__count {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--muted);
    white-space: nowrap;
}

.modsec__status {
    margin: 0 1rem 0.5rem;
    padding: 0.5rem 0.75rem;
    border-left: 4px solid var(--green);
    background: var(--page);
    border-radius: 6px;
    color: var(--green-text);
    font-weight: 600;
}

.modrows {
    list-style: none;
    margin: 0;
    padding: 0 1rem 0.5rem;
}

.modrow {
    border-top: 1px solid var(--border);
    padding: 0.35rem 0;
}

.modrow__form {
    margin: 0;
}

.modrow__main {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-height: 44px;
}

.modrow__name {
    font-weight: 600;
}

.modrow__control {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
}

.modrow__locked {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--muted);
}

.modrow__note {
    margin: -0.25rem 0 0.35rem;
    font-size: 0.88rem;
    color: var(--muted);
}

.modrow__reason {
    margin: 0.25rem 0 0.6rem;
    padding: 0.75rem;
    background: var(--page);
    border: 1px solid var(--border);
    border-radius: 10px;
}

.modrow__reason[hidden] {
    display: none;
}

.modrow__label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.35rem;
}

.modrow__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.modrow__actions .field__input {
    flex: 1 1 180px;
    width: auto;
}

.modrow__reason .alert {
    margin-bottom: 0.5rem;
}

/* Toggle switch: on green, off grey; 44px tall touch target */

.toggle {
    -webkit-appearance: none;
    appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: var(--control-height);
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
    border-radius: 999px;
}

.toggle__track {
    position: relative;
    display: block;
    width: 52px;
    height: 30px;
    border-radius: 999px;
    background: var(--grey);
    transition: background 0.15s ease;
}

.toggle__knob {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--white);
    box-shadow: 0 1px 2px rgba(38, 26, 44, 0.3);
    transition: transform 0.15s ease;
}

.toggle[aria-checked="true"] .toggle__track {
    background: var(--green);
}

.toggle[aria-checked="true"] .toggle__knob {
    transform: translateX(22px);
}

.toggle:focus-visible {
    outline: 3px solid var(--deep-peach);
    outline-offset: 2px;
}

.toggle--locked,
.toggle:disabled {
    cursor: not-allowed;
    opacity: 0.7;
}

.toggle--locked .toggle__knob::after {
    content: "";
    position: absolute;
    inset: 8px;
    border-radius: 2px;
    background: var(--green);
}

/* Script-only and no-script-only bits (html.js is set by /js/admin-modules.js) */

.js-only {
    display: none;
}

.js .js-only {
    display: inline-flex;
}

.js .nojs-only {
    display: none;
}

@media (prefers-reduced-motion: reduce) {
    .toggle__track,
    .toggle__knob,
    .modsec__summary::before {
        transition: none;
    }
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Animals: list cards, profile, tiles and the Record form (Paul's mockup, in Plum and
   Peach). Colour is never the only signal: every dot comes with words. */

.page-head__count {
    margin: 0;
}

.notice {
    background: var(--white);
    border: 1px solid var(--border);
    border-left: 6px solid var(--grey);
    border-radius: 10px;
    padding: 0.6rem 1rem;
    font-weight: 600;
    color: var(--plum);
}

/* Dots: 12px by default, 14px in the summary bar; "not recorded or not due" is hollow. */
.dot {
    display: inline-block;
    flex: 0 0 auto;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--grey);
    vertical-align: middle;
}

.dot--14 { width: 14px; height: 14px; }
.dot--green { background: var(--green); }
.dot--amber { background: var(--amber); }
.dot--red { background: var(--red); }
.dot--grey { background: var(--white); border: 2px solid var(--grey); }

/* List: heading, species pills, search */

.list-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.list-head__count {
    margin: 0.35rem 0 0;
    color: var(--muted);
}

.pills {
    display: flex;
    gap: 0.5rem;
}

.pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 4.5rem;
    height: var(--control-height);
    padding: 0 1.25rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--white);
    color: var(--plum);
    font-weight: 700;
    text-decoration: none;
}

.pill:hover {
    border-color: var(--plum);
}

.pill--on,
.pill--on:hover {
    background: var(--plum);
    border-color: var(--plum);
    color: var(--white);
}

.finder {
    margin-bottom: 1.5rem;
}

.finder__search {
    margin-bottom: 0.75rem;
}

input.field__input--wide {
    height: 46px;
}

.finder__row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 14rem)) auto;
    gap: 0.75rem;
    align-items: end;
}

.finder__label {
    display: block;
    margin-bottom: 0.3rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--muted);
}

.finder__actions {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
}

.finder .field__input,
.finder .btn {
    height: var(--control-height);
}

.finder input.field__input--wide {
    height: 46px;
}

/* List: the card grid, 4 / 2 / 1 across */

.cards {
    list-style: none;
    margin: 0 0 1.5rem;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
}

.acard {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 16px;
    overflow: hidden;
    color: var(--ink);
    text-decoration: none;
}

.acard:hover {
    border-color: var(--plum);
}

.acard:focus-visible {
    outline: 3px solid var(--deep-peach);
    outline-offset: 2px;
}

.acard__photo,
.hero__photo {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #EFE9F2;
}

.acard__photo {
    height: 170px;
}

.initial {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: var(--plum);
    color: var(--white);
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: 2rem;
}

.initial--large {
    width: 112px;
    height: 112px;
    font-size: 3.2rem;
}

.acard__body {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    padding: 14px 16px 16px;
}

.acard__name {
    font-size: 18px;
    font-weight: 700;
    color: var(--plum);
}

.acard__line {
    color: var(--muted);
    font-size: 0.92rem;
}

.acard__status {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    margin-top: 0.2rem;
    font-size: 14px;
    font-weight: 700;
}

.acard__where {
    color: var(--muted);
    font-size: 13px;
}

.pager {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

/* Profile: back button, top card, summary bar */

.back {
    margin: 0 0 1rem;
}

.btn--back {
    gap: 0.5rem;
    background: var(--white);
    border: 1px solid var(--border);
    color: var(--plum);
    padding-left: 1rem;
}

.btn--back::before {
    content: "";
    width: 8px;
    height: 12px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='12' viewBox='0 0 8 12'%3E%3Cpath d='M6.5 1L1.5 6l5 5' fill='none' stroke='%233E2A47' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat center;
}

.btn--back:hover {
    background: var(--white);
    color: var(--plum);
    border-color: var(--plum);
}

.hero {
    display: flex;
    gap: 24px;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 24px;
    margin-bottom: 1rem;
}

.hero__photo {
    flex: 0 0 240px;
    width: 240px;
    height: 240px;
    border-radius: 14px;
}

.hero__main {
    flex: 1 1 auto;
    min-width: 0;
}

.hero__title {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.hero__name {
    margin: 0;
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: 40px;
    line-height: 1.1;
    color: var(--plum);
}

.status-pill {
    display: inline-block;
    padding: 0.3rem 0.85rem;
    border-radius: 999px;
    font-size: 0.9rem;
    font-weight: 700;
}

.status-pill--care { background: #EFE9F2; color: var(--plum); }
.status-pill--foster { background: #FDEDE4; color: #8A3F1D; }
.status-pill--left { background: #ECEEF0; color: #4A555C; }

.hero__ids {
    margin: 0.5rem 0 1.25rem;
    color: var(--muted);
}

.facts {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem 1.5rem;
    margin: 0;
}

.facts dt {
    font-size: 0.82rem;
    color: var(--muted);
    margin-bottom: 0.15rem;
}

.facts dd {
    margin: 0;
    font-weight: 700;
}

.bar {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin: 0 0 1rem;
    padding: 0.75rem 1rem;
    border-radius: 12px;
    font-weight: 700;
}

.bar--red { background: #FDECEA; color: #8C1D18; }
.bar--amber { background: #FFF4D1; color: #5C4300; }
.bar--green { background: #E8F5EC; color: var(--green-text); }
.bar--grey { background: #EEF0F2; color: #4A555C; }

/* Profile: six tiles in one row */

.tiles {
    list-style: none;
    margin: 0 0 1.5rem;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 12px;
}

.tile {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px;
}

.tile__title {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    margin: 0;
    font-family: var(--font-body);
    font-size: 15px;
    font-weight: 700;
    color: var(--ink);
}

.tile__state {
    margin: 0;
    font-size: 13px;
    font-weight: 700;
}

.tile__detail {
    margin: 0;
    font-size: 13px;
    color: var(--muted);
}

.tile__button {
    align-self: flex-start;
    margin-top: auto;
    padding-left: 1rem;
    padding-right: 1rem;
}

/* Profile below the tiles: Health record and Full history at full width, then Notes
   and Paperwork side by side (stacked on tablets and phones, Notes first). */

.split {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.5rem;
    align-items: start;
}

.split .panel {
    margin-bottom: 0;
}

.timeline {
    list-style: none;
    margin: 0;
    padding: 0;
}

.timeline__item {
    position: relative;
    display: grid;
    grid-template-columns: 96px minmax(0, 1fr);
    gap: 0 1.5rem;
    padding: 0 0 1rem;
}

/* The vertical line and a dot per entry, between the date column and the text. */
.timeline__item::before {
    content: "";
    position: absolute;
    left: calc(96px + 0.75rem - 1px);
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border);
}

.timeline__item:last-child::before {
    bottom: auto;
    height: 0.6rem;
}

.timeline__item::after {
    content: "";
    position: absolute;
    left: calc(96px + 0.75rem - 6px);
    top: 0.3rem;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--white);
    border: 2px solid var(--grey);
    box-sizing: border-box;
}

.timeline__item--green::after { background: var(--green); border-color: var(--green); }
.timeline__item--red::after { background: var(--red); border-color: var(--red); }

.timeline__date {
    color: var(--muted);
    font-size: 0.88rem;
}

.timeline__body p {
    margin: 0;
}

.timeline__title {
    font-weight: 700;
}

.timeline__who {
    color: var(--muted);
    font-size: 0.88rem;
}

.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table.table--scroll {
    min-width: 560px;
}

/* Health record: headings on one line; dates never wrap; text columns share the rest
   and wrap only when the screen is too narrow. A minimum width per text column means
   more columns can be added later without squeezing (the table scrolls instead). */
.table--health {
    table-layout: auto;
    min-width: 720px;
}

.table--health th {
    white-space: nowrap;
}

.table--health .col-date {
    width: 1%;
    white-space: nowrap;
}

.table--health .col-text {
    min-width: 10rem;
}

.nowrap {
    white-space: nowrap;
}

.btn--dashed,
.btn--dashed:disabled {
    margin-top: 0.75rem;
    border: 2px dashed var(--grey);
    background: var(--page);
    color: var(--grey-text);
    cursor: not-allowed;
    opacity: 1;
}

.notes {
    list-style: none;
    margin: 0 0 1rem;
    padding: 0;
}

.notes__item {
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--border);
}

.notes__item p {
    margin: 0;
}

.notes__meta {
    margin-top: 0.2rem;
    color: var(--muted);
    font-size: 0.88rem;
}

.notes__form {
    margin-top: 0.5rem;
}

.group-pick {
    border: 0;
    padding: 0;
    margin: 0 0 1.1rem;
}

.group-pick .field--check {
    margin-bottom: 0;
}

.btn:disabled {
    opacity: 0.6;
    cursor: wait;
}

@media (max-width: 1100px) {
    .cards {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

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

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

    .split {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 760px) {
    .finder__row {
        grid-template-columns: minmax(0, 1fr);
    }

    .hero {
        flex-direction: column;
        padding: 16px;
    }

    .hero__photo {
        flex-basis: auto;
        width: 100%;
        height: 200px;
    }

    .hero__name {
        font-size: 32px;
    }


    /* The health table keeps its columns and scrolls sideways. */
    .table.table--scroll thead {
        display: table-header-group;
    }

    .table.table--scroll {
        display: table;
    }

    .table.table--scroll tbody {
        display: table-row-group;
    }

    .table.table--scroll tr {
        display: table-row;
        padding: 0;
    }

    .table.table--scroll td {
        display: table-cell;
        width: auto;
        padding: 0.5rem 0.75rem;
        border-bottom: 1px solid var(--border);
        text-align: left;
    }

    .table.table--scroll td::before {
        content: none;
    }
}

@media (max-width: 560px) {
    .cards {
        grid-template-columns: minmax(0, 1fr);
    }

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

    .facts {
        grid-template-columns: minmax(0, 1fr);
    }

    .list-head {
        align-items: flex-start;
    }

    .timeline__item {
        grid-template-columns: 76px minmax(0, 1fr);
    }

    .timeline__item::before {
        left: calc(76px + 0.75rem - 1px);
    }

    .timeline__item::after {
        left: calc(76px + 0.75rem - 6px);
    }
}

/* Phones: one column; the sign-in panel shrinks to the logo */

@media (max-width: 760px) {
    .auth {
        grid-template-columns: minmax(0, 1fr);
        min-height: 0;
    }

    .auth__panel {
        padding: 1rem 1.25rem;
        gap: 0;
    }

    .auth__pitch,
    .auth__made {
        display: none;
    }

    .auth__main {
        padding: 1.5rem 1rem 2.5rem;
        align-items: flex-start;
    }

    .card {
        padding: 1.75rem 1.25rem;
    }

    .holding {
        padding-top: 2rem;
    }

    .recovery-codes {
        grid-template-columns: minmax(0, 1fr);
    }

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

    .app-main {
        padding: 1.5rem 1rem 2.5rem;
    }

    .panel {
        padding: 1.25rem 1rem;
    }

    .table thead {
        display: none;
    }

    .table,
    .table tbody,
    .table tr,
    .table td {
        display: block;
        width: 100%;
    }

    .table tr {
        padding: 0.75rem 1rem;
        border-bottom: 1px solid var(--border);
    }

    .table tbody tr:last-child {
        border-bottom: 0;
    }

    .table td {
        display: flex;
        justify-content: space-between;
        gap: 1rem;
        padding: 0.25rem 0;
        border: 0;
        text-align: right;
    }

    .table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--muted);
        text-align: left;
    }

    .table td[colspan]::before {
        content: none;
    }
}
