/* Colors come from the desktop themes as CSS variables (see web/theme.py) */
* {
    box-sizing: border-box;
}

/* Classes like .appointment-form set display, which would otherwise show elements marked hidden */
[hidden] {
    display: none !important;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--fg);
    font-family: -apple-system, "SF Pro Display", Arial, sans-serif;
    font-size: 16px;
}

/* Taps act right away (no double-tap zoom wait) and don't flash a gray box on iPhones */
button,
a,
summary,
input,
select,
label {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

/* Keyboard focus is always visible, in the theme's text color so it shows on every theme; mouse clicks don't show it */
:focus-visible {
    outline: 2px solid var(--fg);
    outline-offset: 2px;
}

.title :focus-visible,
.sidebar :focus-visible {
    outline-color: var(--title-fg);
}

/* Hidden until reached with Tab: jumps over the top bar and the menu */
.skip-link {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    z-index: 20;
    padding: 0.5rem 0.75rem;
    color: var(--button-fg);
    background: var(--button-bg);
    border-radius: 6px;
    transform: translateY(-200%);
}

.skip-link:focus {
    transform: none;
}

main:focus {
    outline: none;
}

/* Read by screen readers, not shown */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

.title {
    background: var(--title-bg);
    color: var(--title-fg);
    font-size: 1.5rem;
    padding: 0.75rem 1.5rem;
}

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

.brand-name {
    font-weight: 700;
    letter-spacing: 0.08em;
}

/* Account button: email and initial on computers, just the initial on phones */
.account {
    position: relative;
    font-size: 1rem;
}

.account-button {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    min-width: 0;
    padding: 0.25rem 0.25rem 0.25rem 0.75rem;
    color: inherit;
    background: transparent;
    border-color: transparent;
    border-radius: 999px;
}

.account-button:hover,
.account-button[aria-expanded="true"] {
    color: inherit;
    background: color-mix(in srgb, var(--title-fg) 15%, transparent);
}

.avatar {
    display: grid;
    place-items: center;
    width: 2.25rem;
    height: 2.25rem;
    font-weight: 700;
    color: var(--title-bg);
    background: var(--title-fg);
    border-radius: 50%;
}

.account-menu {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    z-index: 30;
    width: max-content;
    max-width: min(20rem, calc(100vw - 2rem));
    padding: 0.5rem;
    color: var(--fg);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgb(0 0 0 / 18%);
}

.account-menu-email {
    margin: 0;
    padding: 0.5rem 0.75rem 0.75rem;
    overflow-wrap: anywhere;
    border-bottom: 1px solid color-mix(in srgb, var(--fg) 20%, transparent);
}

/* The name above the email; the email then reads as its detail */
.account-menu-name {
    margin: 0;
    padding: 0.5rem 0.75rem 0;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.account-menu-name + .account-menu-email {
    padding-top: 0.1rem;
    font-size: 0.9em;
    opacity: 0.75;
}

.account-menu form {
    margin: 0.5rem 0 0;
}

.account-menu-item {
    width: 100%;
    min-width: 0;
    text-align: left;
}

/* Bottom of the side menu */
.sidebar-version {
    margin: auto 0 0;
    padding: 0.5rem 0.75rem 0;
    font-size: 0.8rem;
    opacity: 0.65;
}

.title .brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* Three-line button that shows or hides the left menu */
.menu-toggle {
    display: flex;
    min-width: 0;
    padding: 0.35rem;
    color: inherit;
    background: transparent;
    border-color: transparent;
}

.menu-toggle:hover {
    color: inherit;
    background: color-mix(in srgb, var(--title-fg) 15%, transparent);
}

/* Schedule page: left menu under the top bar, the current content on the right */
.layout {
    position: relative;
    display: flex;
    align-items: flex-start;
}

.layout main {
    flex: 1;
    min-width: 0;
}

.sidebar {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    width: 14rem;
    flex-shrink: 0;
    min-height: calc(100vh - 3.75rem);
    min-height: calc(100dvh - 3.75rem);
    padding: 1rem 0.75rem;
    color: var(--title-fg);
    background: var(--title-bg);
    border-top: 1px solid color-mix(in srgb, var(--title-fg) 20%, transparent);
}

.sidebar a {
    padding: 0.5rem 0.75rem;
    color: inherit;
    text-decoration: none;
    border-radius: 6px;
}

.sidebar a:hover,
.sidebar a.active {
    background: color-mix(in srgb, var(--title-fg) 15%, transparent);
}

.sidebar a.active {
    font-weight: 600;
}

/* Sections that aren't built yet: shown, but not clickable */
.sidebar a[aria-disabled="true"] {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    opacity: 0.6;
    cursor: default;
}

.sidebar a[aria-disabled="true"]:hover {
    background: transparent;
}

/* Long names like "Resumen de ventas" wrap; the label stays on one line */
.sidebar .soon {
    flex-shrink: 0;
    white-space: nowrap;
    font-size: 0.75rem;
    padding: 0.1rem 0.4rem;
    border: 1px solid currentColor;
    border-radius: 999px;
}


main {
    max-width: 1100px;
    margin: 0 auto;
    padding: 1.5rem;
}

/* Agenda: date with previous/next day and Hoy, then site and staff */
.filters {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 1rem 1.5rem;
    margin-bottom: 1.75rem;
}

.filters label,
.date-nav {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.filters select {
    min-width: 12rem;
}

.date-nav-controls {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.date-nav input {
    min-width: 0;
}

.icon-button {
    display: grid;
    place-items: center;
    min-width: 0;
    width: 2.4rem;
    height: 2.4rem;
    padding: 0;
}

.today-button {
    min-width: 0;
    height: 2.4rem;
}

input,
select,
button {
    font: inherit;
    color: var(--field-fg);
    background: var(--field-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.4rem 0.6rem;
    min-width: 14rem;
}

button {
    color: var(--button-fg);
    background: var(--button-bg);
    cursor: pointer;
}

button:hover {
    color: var(--button-hover-fg);
    background: var(--button-hover-bg);
}

.message {
    margin: 0;
}

/* Day heading: the date in words, how full the day is, and the totals for users allowed to see them */
.day-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.day-title {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin: 0;
    font-size: 1.35rem;
    font-weight: 600;
}

.today-tag {
    padding: 0.1rem 0.55rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--title-fg);
    background: var(--title-bg);
    border-radius: 999px;
}

.day-count {
    margin: 0.25rem 0 0;
    opacity: 0.8;
}

.total {
    min-width: 0;
    text-align: left;
    font-variant-numeric: tabular-nums;
}

.total .total-split,
.total.split .total-sum {
    display: none;
}

.total.split .total-split {
    display: inline;
}

/* Before a site and staff member are chosen */
.schedule-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    padding: 3rem 1.5rem;
    text-align: center;
    border: 1px dashed color-mix(in srgb, var(--fg) 35%, transparent);
    border-radius: 10px;
}

.schedule-empty p {
    max-width: 28ch;
    margin: 0;
}

/* Mañana, then Tarde; in each, the :00 and :30 of an hour side by side, like the desktop app */
.day-columns {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    /* Room for the floating button at the end of the day */
    padding-bottom: 5rem;
}

.day-part h3 {
    margin: 0 0 0.5rem;
    font-size: 0.95rem;
    font-weight: 600;
    opacity: 0.8;
}

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

.slot {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    width: 100%;
    min-width: 0;
    min-height: 3.1rem;
    padding: 0.4rem 0.75rem;
    text-align: left;
    color: var(--fg);
    background: transparent;
    border: 1px dashed color-mix(in srgb, var(--fg) 25%, transparent);
}

.slot:hover {
    color: var(--fg);
    background: color-mix(in srgb, var(--field-bg) 70%, transparent);
    border-color: color-mix(in srgb, var(--fg) 45%, transparent);
}

/* Never wraps ("10:00 a." / "m."); wide enough for "12:30 p. m." so the names line up */
.slot-time {
    flex-shrink: 0;
    width: 5.9rem;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}

.slot-time small {
    font-size: 0.75em;
    font-weight: 500;
    opacity: 0.75;
}

.slot-free {
    opacity: 0.6;
}

/* A booked slot is solid, with a bar in the theme's dark color on the left */
.slot.booked {
    color: var(--field-fg);
    background: var(--field-bg);
    border: 1px solid var(--border);
    box-shadow: inset 4px 0 0 var(--title-bg);
}

.slot.booked:hover {
    background: color-mix(in srgb, var(--field-bg) 85%, var(--title-bg));
}

.slot-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

.slot-client {
    overflow: hidden;
    font-weight: 600;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.slot-treatment {
    overflow: hidden;
    font-size: 0.9em;
    white-space: nowrap;
    text-overflow: ellipsis;
    opacity: 0.8;
}

.slot-status {
    flex-shrink: 0;
    padding: 0.1rem 0.55rem;
    font-size: 0.8rem;
    font-weight: 600;
    border-radius: 999px;
    color: var(--title-fg);
    background: var(--title-bg);
}

/* No-shows stay readable but step back; the status says it in words */
.slot.absent {
    box-shadow: none;
    opacity: 0.7;
}

.slot.absent .slot-client {
    text-decoration: line-through;
}

.slot.absent .slot-status {
    color: var(--fg);
    background: transparent;
    border: 1px solid currentColor;
}

/* Floating button: new client, always in reach */
.fab {
    position: fixed;
    right: calc(1.5rem + env(safe-area-inset-right));
    bottom: calc(1.5rem + env(safe-area-inset-bottom));
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
    height: 3.5rem;
    padding: 0 1.4rem 0 1.1rem;
    font-weight: 600;
    color: var(--title-fg);
    background: var(--title-bg);
    border: 0;
    border-radius: 999px;
    box-shadow: 0 6px 18px color-mix(in srgb, var(--title-bg) 45%, transparent);
    transition: transform 0.15s ease-out, box-shadow 0.15s ease-out;
}

.fab:hover {
    color: var(--title-fg);
    background: color-mix(in srgb, var(--title-bg) 85%, black);
    box-shadow: 0 8px 22px color-mix(in srgb, var(--title-bg) 55%, transparent);
}

.fab:active {
    transform: scale(0.96);
}

@media (prefers-reduced-motion: reduce) {
    .fab {
        transition: none;
    }
}

dialog {
    width: min(32rem, 95vw);
    color: var(--fg);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.5rem;
    /* Scrolling to the end of a long dialog doesn't scroll the page behind it */
    overscroll-behavior: contain;
}

dialog::backdrop {
    background: rgb(0 0 0 / 40%);
}

.appointment-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.appointment-form h2 {
    margin: 0;
}

.appointment-form label {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.fields {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.25rem 1rem;
    margin: 0;
}

.fields dt {
    font-weight: 600;
}

.fields dd {
    margin: 0;
}

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

.search input {
    flex: 1;
}

.search button {
    min-width: 0;
}

/* Payment method: three large choices instead of small radio buttons */
.payment-methods {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(6rem, 1fr));
    gap: 0.4rem;
    margin: 0;
    padding: 0;
    border: 0;
}

.payment-methods legend {
    margin-bottom: 0.35rem;
    padding: 0;
}

.appointment-form .payment-methods label {
    position: relative;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    padding: 0.55rem 0.5rem;
    color: var(--field-fg);
    background: var(--field-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
}

/* The radio stays for the keyboard and screen readers; the whole box is the target */
.payment-methods input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.appointment-form .payment-methods label:has(:checked) {
    font-weight: 600;
    color: var(--title-fg);
    background: var(--title-bg);
    border-color: var(--title-bg);
}

.payment-methods label:has(:focus-visible) {
    outline: 2px solid var(--fg);
    outline-offset: 2px;
}

.appointment-form label.check {
    flex-direction: row;
    align-items: center;
}

.check input {
    min-width: 0;
}

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

.actions button {
    min-width: 0;
    flex: 1;
}

/* While a dialog saves: "Guardando…" under the buttons, which look busy; a second click is ignored (hx-sync) */
.actions .busy {
    display: none;
    flex-basis: 100%;
    order: 1;
    font-size: 0.9em;
    opacity: 0.75;
}

.htmx-request .actions .busy {
    display: block;
}

.htmx-request .actions button {
    opacity: 0.6;
    cursor: progress;
}

.actions button:disabled {
    opacity: 0.5;
    cursor: default;
}

.actions button:disabled:hover {
    color: var(--button-fg);
    background: var(--button-bg);
}

.message.error {
    color: #b00020;
    font-weight: 600;
}

/* Session numbers: a hand-entered number is marked so it isn't mistaken for a counted one */
.badge {
    display: inline-block;
    padding: 0 0.4rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 0.8em;
    line-height: 1.5;
    vertical-align: 0.1em;
}

.hint {
    display: block;
    font-size: 0.85em;
    opacity: 0.75;
}

.session-fix {
    margin-top: 0.25rem;
}

/* Dialog to correct session numbers from the client card: one group per treatment */
.session-numbers {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
}

.session-numbers input[type="number"] {
    width: 7rem;
}

.session-fix summary {
    cursor: pointer;
    width: fit-content;
    text-decoration: underline;
}

.session-fix[open] {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.session-fix input[type="number"] {
    min-width: 0;
    width: 7rem;
    flex: 0 0 auto;
}

button.link {
    min-width: 0;
    width: fit-content;
    padding: 0;
    border: 0;
    color: inherit;
    background: none;
    text-decoration: underline;
}

button.link:hover {
    color: inherit;
    background: none;
}

/* New appointment: the slot in words, then client, treatment, session and price */
.booking-header {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    padding-bottom: 0.85rem;
    border-bottom: 1px solid color-mix(in srgb, var(--fg) 20%, transparent);
}

.booking-header h2 {
    margin: 0 0 0.35rem;
}

.booking-when {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.booking-where {
    margin: 0;
    opacity: 0.8;
}

.booking-field {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

#client-info:not(:empty) {
    margin-top: 0.35rem;
}

#client-info .client-results {
    margin-top: 0.35rem;
}

/* The selected client, with the same bar as a booked slot in the agenda */
.booking-client {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    padding: 0.65rem 0.85rem;
    color: var(--field-fg);
    background: var(--field-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: inset 4px 0 0 var(--title-bg);
}

.booking-client p {
    margin: 0;
}

.booking-client-name {
    font-weight: 600;
    overflow-wrap: anywhere;
}

.booking-client-meta {
    font-size: 0.9em;
    opacity: 0.8;
}

.booking-client .check {
    margin-top: 0.35rem;
}

/* The session the new appointment will be: a hint right under Tratamiento, the same gap as the one under Cliente */
#session-preview:not(:empty) {
    margin-top: -0.5rem;
}

.optional {
    font-weight: normal;
    opacity: 0.7;
}

/* The main action of a dialog */
.actions .primary {
    flex: 2;
    font-weight: 600;
    color: var(--title-fg);
    background: var(--title-bg);
    border-color: var(--title-bg);
}

.actions .primary:hover {
    color: var(--title-fg);
    background: color-mix(in srgb, var(--title-bg) 85%, black);
}

/* Existing appointment */
.appointment-title {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.appointment-title h2 {
    margin: 0;
}

.booking-header .card-header {
    align-items: center;
    margin-bottom: 0.35rem;
}

.status-chip {
    padding: 0.1rem 0.6rem;
    font-size: 0.85rem;
    font-weight: 600;
    border: 1px solid currentColor;
    border-radius: 999px;
}

.status-chip.status-present {
    color: var(--title-fg);
    background: var(--title-bg);
    border-color: var(--title-bg);
}

.status-chip.status-absent {
    opacity: 0.8;
}

.booking-client a {
    color: inherit;
}

.treatment-line p {
    margin: 0;
}

/* The current attendance is marked on its button */
.actions button[aria-pressed="true"] {
    box-shadow: inset 0 0 0 2px currentColor;
}

/* Less frequent actions under the attendance buttons */
.secondary-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
}

button.link.danger {
    color: #b00020;
}

button.link.danger:hover {
    color: #7a0016;
}

.appointment-facts {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.35rem 1rem;
    margin: 0;
}

.appointment-facts dt {
    opacity: 0.75;
}

.appointment-facts dd {
    margin: 0;
    overflow-wrap: anywhere;
}

/* Attendance: two big choices; Asistió turns into the payment step */
.attendance {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.attendance-choice {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.attendance-choice button {
    min-width: 0;
    padding: 0.7rem;
    font-weight: 600;
}

.attendance-choice .primary {
    color: var(--title-fg);
    background: var(--title-bg);
    border-color: var(--title-bg);
}

.attendance-choice .primary:hover {
    color: var(--title-fg);
    background: color-mix(in srgb, var(--title-bg) 85%, black);
}

.payment-methods .actions {
    grid-column: 1 / -1;
    margin-top: 0.25rem;
}

.attendance .busy {
    display: none;
    font-size: 0.9em;
    opacity: 0.75;
}

.attendance.htmx-request .busy {
    display: block;
}

/* Cerrar closes the window off: full width, outlined, never filled */
.appointment-view .secondary-actions button,
.booking-actions button:not(.primary):not(.danger-fill) {
    flex: 1;
    min-width: 0;
    min-height: 2.75rem;
    background: none;
    color: var(--fg);
}

.appointment-view .secondary-actions button:hover,
.booking-actions button:not(.primary):not(.danger-fill):hover {
    color: var(--fg);
    background: color-mix(in srgb, var(--fg) 8%, transparent);
}

/* New appointment: Agendar cita across the window, Cerrar under it; "Guardando…" stays last */
.booking-actions {
    flex-direction: column;
    margin-top: 0.25rem;
}

.booking-actions button {
    min-height: 2.75rem;
}

/* Every field and button in the new appointment and the edit form has the same touch height */
.booking input:not([type="checkbox"]):not([type="radio"]),
.booking select,
.appointment-edit input:not([type="checkbox"]):not([type="radio"]),
.client-form input:not([type="checkbox"]):not([type="radio"]),
.appointment-edit select,
.appointment-edit .danger-zone button,
.appointment-form .payment-methods label,
.booking .search button,
.booking #client-info > button,
.booking .client-results button {
    min-height: 2.75rem;
}

/* A chosen client takes the search's place; Cambiar empties the card and the search comes back */
.booking-field:has(.booking-client) .search,
.booking-field:has(.booking-client) #booking-client-hint {
    display: none;
}

.booking-field:has(.booking-client) #client-info {
    margin-top: 0;
}

.booking-client .card-header {
    align-items: center;
}

/* Full touch height, pulled into the card's padding so the card stays compact */
.booking-client .quiet-edit {
    margin: -0.6rem -0.6rem -0.6rem 0;
}

/* Every button in the window has the same touch height */
.appointment-view .attendance button:not(.link) {
    min-height: 2.75rem;
}

/* Attendance already marked: the answer, with Cambiar to bring the buttons back */
.attendance-result {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.7rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: 6px;
}

.attendance-result p {
    margin: 0;
    font-weight: 600;
}

.attendance-result .quiet-edit {
    flex-shrink: 0;
    margin: -0.6rem -0.6rem -0.6rem 0;
}

/* Editar and Corregir: quiet text with a pencil, next to what they change */
button.quiet-edit {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    min-width: 0;
    min-height: 2.75rem;
    padding: 0 0.5rem;
    color: var(--fg);
    background: none;
    border-color: transparent;
    font-weight: 600;
}

button.quiet-edit:hover {
    color: var(--fg);
    background: color-mix(in srgb, var(--fg) 8%, transparent);
}

/* Pulls the text in line with the card's right edge */
.card-header button.quiet-edit {
    margin-right: -0.5rem;
}

/* Edit form */
.edit-when {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 0.75rem;
}

/* Fecha and Hora are drawn by the browser in different ways (Safari and phones size a date field by its text and
   a list by its own rules), so both get the same fixed height and full width, and the date drops its native look */
.edit-when input,
.edit-when select {
    width: 100%;
    min-width: 0;
    height: 2.75rem;
    margin: 0;
    line-height: normal;
}

.edit-when input[type="date"] {
    -webkit-appearance: none;
    appearance: none;
    display: flex;
    align-items: center;
}

/* iPhone centers the date text; left like the other fields */
.edit-when input[type="date"]::-webkit-date-and-time-value {
    margin: 0;
    text-align: left;
}

.appointment-edit .hint {
    margin-top: -0.4rem;
}

.appointment-edit #edit-session .hint {
    margin-top: 0;
}

.danger-zone {
    padding-top: 0.75rem;
    border-top: 1px solid color-mix(in srgb, var(--fg) 20%, transparent);
}

/* Cancelar cita: red outline, full width, the same height as the others; only the confirmation is filled red */
button.danger-outline,
button.danger-fill {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    width: 100%;
    min-width: 0;
    min-height: 2.75rem;
    font-weight: 600;
}

button.danger-outline {
    color: #b00020;
    background: none;
    border-color: color-mix(in srgb, #b00020 55%, transparent);
}

button.danger-outline:hover {
    color: #b00020;
    background: color-mix(in srgb, #b00020 8%, transparent);
}

.booking-actions button.danger-fill,
button.danger-fill {
    color: #fff;
    background: #b00020;
    border-color: #b00020;
}

.booking-actions button.danger-fill:hover,
button.danger-fill:hover {
    color: #fff;
    background: #8a0019;
}

.cancel-confirm {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    padding: 0.8rem 0.9rem;
    border: 1px solid color-mix(in srgb, #b00020 45%, transparent);
    border-radius: 6px;
    background: color-mix(in srgb, #b00020 6%, transparent);
}

.cancel-confirm p {
    margin: 0;
}

/* Clients page */
.page-title {
    margin: 0 0 1rem;
    font-size: 1.5rem;
}

.client-search {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    max-width: 32rem;
    margin-bottom: 1.5rem;
}

#client-details {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
    max-width: 32rem;
}

.client-card {
    align-self: stretch;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.25rem 1.5rem;
}

.client-card h2 {
    margin: 0 0 0.75rem;
    font-size: 1.25rem;
    overflow-wrap: anywhere;
}

.client-results {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-self: stretch;
    margin: 0;
    padding: 0;
    list-style: none;
}

.client-results button {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    width: 100%;
    min-width: 0;
    text-align: left;
    padding: 0.6rem 0.9rem;
    color: var(--field-fg);
    background: var(--field-bg);
}

.client-results .result-name {
    font-weight: 600;
    overflow-wrap: anywhere;
}

.client-results .result-meta {
    font-size: 0.9em;
    opacity: 0.75;
}

.next-appointment {
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.next-appointment h3 {
    margin: 0 0 0.5rem;
    font-size: 1rem;
}

.card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.card-header button {
    min-width: 0;
    flex-shrink: 0;
}

.client-card .fields {
    gap: 0.5rem 1.5rem;
}


.client-card dd {
    overflow-wrap: anywhere;
}

/* Client history: filters that wrap on phones, then one appointment per item */
.history-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 0.75rem;
}

.history-filters button {
    min-width: 0;
    padding: 0.3rem 0.75rem;
    border-radius: 999px;
    font-size: 0.9rem;
}

.history-filters button[aria-pressed="true"] {
    box-shadow: inset 0 0 0 2px currentColor;
}

.history-filters .count {
    font-variant-numeric: tabular-nums;
    opacity: 0.7;
}

.history-list {
    display: flex;
    flex-direction: column;
    margin: 0;
    padding: 0;
    list-style: none;
}

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

.history-item:last-of-type {
    border-bottom: none;
}

.history-line {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.history-when {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.history-meta,
.history-note {
    font-size: 0.9em;
    overflow-wrap: anywhere;
}

.history-meta {
    opacity: 0.8;
}

.history-note {
    margin-top: 0.15rem;
    opacity: 0.7;
}

.history-more {
    padding-top: 0.75rem;
}

/* Statuses that never happened step back, like a no-show in the agenda */
.status-chip {
    flex-shrink: 0;
    white-space: nowrap;
}

.status-chip.status-cancelled {
    border-style: dashed;
    opacity: 0.8;
}

.history-item:has(.status-cancelled) .history-when {
    text-decoration: line-through;
}

/* Usuarios page: same list as the client search results */
.users-title {
    margin-bottom: 0.25rem;
}

.users-intro {
    max-width: 32rem;
    margin: 0 0 1.25rem;
}

/* Room at the end for the floating Invitar usuario button, so it never covers the last user */
.user-list {
    max-width: 32rem;
    padding-bottom: 5rem;
}

/* Rol: the two choices one under the other, each with its explanation */
.role-choice {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin: 0;
    padding: 0;
    border: 0;
}

.role-choice legend {
    margin-bottom: 0.35rem;
    padding: 0;
}

/* The admin's own role: shown, but it can't be changed */
.role-choice:disabled label.choice-box {
    cursor: default;
    opacity: 0.6;
}

/* Recreated on every success, which restarts the fade */
.toast:not(:empty) {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    color: var(--title-fg);
    background: var(--title-bg);
    border-radius: 8px;
    padding: 0.75rem 1.25rem;
    margin-bottom: env(safe-area-inset-bottom);
    animation: toast-fade 3s forwards;
}

/* Without the fade, the message just stays a moment and disappears */
@media (prefers-reduced-motion: reduce) {
    .toast:not(:empty) {
        animation: toast-hide 4s steps(1, end) forwards;
    }
}

@keyframes toast-hide {
    to {
        visibility: hidden;
    }
}

@keyframes toast-fade {
    0%, 80% {
        opacity: 1;
    }
    100% {
        opacity: 0;
        visibility: hidden;
    }
}

/* Narrow phones: one slot per row, still in order (8:00, 8:30, 9:00…) */
/* Phones: one slot per row. minmax(0, 1fr), not 1fr: with 1fr a long client name (kept on one line) widened the
   column past the screen edge instead of being cut with "…" */
@media (max-width: 520px) {
    main {
        padding: 1rem;
    }

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

    .slot-list li {
        min-width: 0;
    }

    .slot {
        gap: 0.65rem;
        padding: 0.4rem 0.6rem;
    }

    /* "a. m." under the hour instead of beside it, so the name gets the room */
    .slot-time {
        display: flex;
        flex-direction: column;
        width: 3.4rem;
        line-height: 1.15;
    }

    .slot-status {
        padding: 0.1rem 0.45rem;
        font-size: 0.75rem;
    }

    /* The date row fits the width: the date field takes what the arrows and Hoy leave */
    .date-nav,
    .filters label {
        flex: 1 1 100%;
    }

    .date-nav input {
        flex: 1;
    }

    .filters select {
        min-width: 0;
        width: 100%;
    }
}

@media (max-width: 700px) {
    .account-email {
        display: none;
    }

    .account-button {
        padding: 0.25rem;
    }


    /* On phones the button is a round "+" only; its name stays for screen readers */
    .fab {
        width: 3.5rem;
        padding: 0;
        justify-content: center;
    }

    .fab-label {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip-path: inset(50%);
        white-space: nowrap;
    }

    /* On phones the menu opens over the schedule instead of squeezing it */
    .sidebar {
        position: absolute;
        top: 0;
        left: 0;
        z-index: 10;
        height: 100%;
        box-shadow: 4px 0 12px rgb(0 0 0 / 25%);
    }
}


/* Login and password pages: form on the right, the clinic's dark panel with what HOP does on the left.
   Colors come from the clinic's theme, so the page matches default, lavender, pink and sand */
.auth {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(24rem, 1fr);
    grid-template-areas: "intro main";
    min-height: 100vh;
    min-height: 100dvh;
    font-family: "Avenir Next", "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
    background: color-mix(in srgb, var(--bg) 35%, white);
}

.auth-main {
    grid-area: main;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2rem;
    max-width: none;
    margin: 0;
    padding: 3rem clamp(1.5rem, 6vw, 5rem);
    color: var(--fg);
}

.auth-panel {
    width: 100%;
    max-width: 22rem;
}

.auth-form {
    gap: 1rem;
}

.auth-form h1 {
    margin: 0 0 0.25rem;
    font-size: 1.75rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.auth-form p {
    margin: 0;
    line-height: 1.5;
}

.auth-form label {
    font-weight: 500;
}

.auth-form input {
    width: 100%;
    min-width: 0;
    padding: 0.65rem 0.75rem;
    color: var(--fg);
    background: white;
    border-color: color-mix(in srgb, var(--fg) 30%, transparent);
}

.auth-form input:hover {
    border-color: color-mix(in srgb, var(--fg) 55%, transparent);
}

.auth-form a {
    width: fit-content;
    color: var(--fg);
    text-underline-offset: 0.2em;
}

/* The one strong button on the page, in the panel's color */
.auth-submit {
    width: 100%;
    min-width: 0;
    margin-top: 0.25rem;
    padding: 0.7rem 1rem;
    font-weight: 600;
    color: var(--title-fg);
    background: var(--title-bg);
    border-color: var(--title-bg);
}

.auth-submit:hover {
    color: var(--title-fg);
    background: color-mix(in srgb, var(--title-bg) 82%, black);
}

.auth-help {
    max-width: 22rem;
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.5;
    opacity: 0.8;
}

.auth-intro {
    grid-area: intro;
    display: flex;
    flex-direction: column;
    gap: 2.25rem;
    padding: 3rem clamp(1.5rem, 6vw, 5rem);
    color: var(--title-fg);
    background: var(--title-bg);
}

.auth-brand {
    margin: 0;
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: 0.12em;
}

/* Only on phones, where the panel goes below the form */
.auth-brand-compact {
    display: none;
}

.auth-headline {
    max-width: 15ch;
    margin: auto 0 0;
    font-size: clamp(2.1rem, 3.8vw, 3.4rem);
    font-weight: 600;
    line-height: 1.06;
    letter-spacing: -0.025em;
    text-wrap: balance;
}

/* A day of the schedule; booked slots fill in once when the page opens */
.day-strip {
    display: grid;
    gap: 0.6rem;
    max-width: 34rem;
    margin: 0;
}

.day-slots {
    display: grid;
    grid-template-columns: repeat(24, 1fr);
    gap: 3px;
    height: 3.5rem;
}

.day-slots span {
    border-radius: 3px;
    background: color-mix(in srgb, var(--title-fg) 14%, transparent);
}

.day-slots .booked {
    background: var(--title-fg);
    transform-origin: bottom;
    animation: slot-booked 0.45s ease-out both;
    animation-delay: calc(var(--i) * 40ms + 150ms);
}

@keyframes slot-booked {
    from {
        opacity: 0;
        transform: scaleY(0.25);
    }
}

.day-hours {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    font-variant-numeric: tabular-nums;
    opacity: 0.75;
}

.day-strip figcaption {
    font-size: 0.95rem;
    opacity: 0.85;
}

.auth-features {
    display: grid;
    gap: 0.85rem;
    max-width: 34rem;
    margin: 0;
    padding: 0;
    list-style: none;
    line-height: 1.5;
}

.auth-features li {
    color: color-mix(in srgb, var(--title-fg) 82%, transparent);
}

.auth-features strong {
    color: var(--title-fg);
    font-weight: 600;
}

.auth-news {
    max-width: 34rem;
    padding-top: 1.5rem;
    border-top: 1px solid color-mix(in srgb, var(--title-fg) 25%, transparent);
}

.auth-news h2 {
    margin: 0 0 0.6rem;
    font-size: 1rem;
    font-weight: 600;
}

.auth-news ul {
    display: grid;
    gap: 0.5rem;
    margin: 0;
    padding-left: 1.1rem;
    line-height: 1.5;
    color: color-mix(in srgb, var(--title-fg) 82%, transparent);
}

.auth-version {
    margin: auto 0 0;
    font-size: 0.85rem;
    opacity: 0.65;
}

@media (max-width: 900px) {
    .auth {
        grid-template-columns: 1fr;
        grid-template-areas: "main" "intro";
    }

    .auth-main {
        gap: 1.5rem;
        padding: 2rem 1.5rem 2.5rem;
        justify-content: flex-start;
    }

    .auth-panel,
    .auth-help {
        max-width: 26rem;
    }

    .auth-brand-compact {
        display: block;
    }

    .auth-intro {
        gap: 1.75rem;
        padding: 2.5rem 1.5rem calc(2.5rem + env(safe-area-inset-bottom));
    }

    /* The brand already shows above the form */
    .auth-intro > .auth-brand {
        display: none;
    }

    .auth-headline {
        margin-top: 0;
        font-size: 2rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .day-slots .booked {
        animation: none;
    }
}

/* A yes/no choice with an explanation: the whole box is the target, outlined like the fields */
.appointment-form label.choice-box {
    align-items: flex-start;
    gap: 0.6rem;
    padding: 0.7rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
}

.choice-box input {
    width: 1.15rem;
    height: 1.15rem;
    margin: 0.15rem 0 0;
    flex: 0 0 auto;
    accent-color: var(--title-bg);
}

.choice-box > span {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.choice-box:has(:checked) {
    border-color: var(--title-bg);
    box-shadow: inset 4px 0 0 var(--title-bg);
}

.choice-box:has(:focus-visible) {
    outline: 2px solid var(--fg);
    outline-offset: 2px;
}

/* Split payment: "Dividir el pago" is a fourth choice across the row, under the three methods; when chosen, one
   amount per method, one under the other, and how much is missing to reach the price */
.payment-methods {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.appointment-form .payment-methods label {
    min-height: 2.75rem;
}

.payment-methods .split-choice,
.payment-methods .split-amounts {
    grid-column: 1 / -1;
}

.split-amounts {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin: 0;
    padding: 0.7rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: 6px;
}

.split-amounts[hidden] {
    display: none;
}

/* Overrides the choice-box look of the method labels: here it's a name and its amount on one line */
.appointment-form .payment-methods .split-amounts label {
    display: grid;
    grid-template-columns: 5.5rem minmax(0, 1fr);
    align-items: center;
    gap: 0.75rem;
    padding: 0;
    color: inherit;
    background: none;
    border: 0;
    font-weight: normal;
    cursor: default;
}

/* The method inputs above are hidden radios; these amounts are real fields */
.payment-methods .split-amounts input {
    position: static;
    opacity: 1;
    pointer-events: auto;
    min-width: 0;
    width: 100%;
    min-height: 2.75rem;
}

.split-status {
    margin: 0;
}

.payment-methods .split-amounts label:has(:focus-visible) {
    outline: none;
}
