:root {
    --pine: #1c3a34;
    --pine-deep: #12261f;
    --cream: #f6f1e7;
    --paper: #fbf8f3;
    --ink: #1d2824;
    --muted: #5e6b64;
    --line: #e4d8c8;
    --clay: #c56a45;
    --sage: #d7e2d8;
    --shadow: 0 24px 60px rgba(18, 38, 31, 0.12);
    --serif: "Fraunces", "Iowan Old Style", Palatino, serif;
    --sans: "Outfit", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

.nowrap { white-space: nowrap; }

html, body { margin: 0; min-height: 100%; }

body {
    color: var(--ink);
    font-family: var(--sans);
    background: var(--cream);
}

img { display: block; max-width: 100%; }

button, input, select, textarea { font: inherit; }

a { color: inherit; }

.eyebrow {
    margin: 0 0 0.4rem;
    color: var(--clay);
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--paper);
    text-decoration: none;
}

.brand-dark { color: var(--pine); }

.brand-mark {
    display: grid;
    width: 2.4rem;
    height: 2.4rem;
    place-items: center;
    border-radius: 0.8rem;
    background: var(--pine);
    color: var(--paper);
    font-family: var(--serif);
    font-size: 1.25rem;
}

.brand-dark .brand-mark { background: var(--pine); color: var(--paper); }

.brand-name { display: flex; flex-direction: column; line-height: 1.1; }

.brand-name strong { font-family: var(--serif); font-size: 1.15rem; font-weight: 640; white-space: nowrap; }

.brand-name small { color: inherit; opacity: 0.72; font-size: 0.78rem; }

.is-guest { overflow: hidden; }

.gate {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

.gate-portrait {
    position: relative;
    min-height: 0;
    overflow: hidden;
    background: var(--pine-deep);
}

.gate-portrait img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center 18%;
}

.gate-caption {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    padding: 4.5rem 2.5rem 2.2rem;
    background: linear-gradient(to top, rgba(18, 38, 31, 0.92), rgba(18, 38, 31, 0));
    color: var(--paper);
}

.gate-caption h2 {
    margin: 0;
    font-family: var(--serif);
    font-size: clamp(2.2rem, 4vw, 3.4rem);
    font-weight: 520;
    letter-spacing: -0.03em;
}

.gate-caption p:last-child {
    max-width: 28rem;
    margin: 0.6rem 0 0;
    color: rgba(251, 248, 243, 0.82);
    font-size: 1.05rem;
}

.gate-panel {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 3rem clamp(1.5rem, 5vw, 4.5rem);
    background:
        radial-gradient(circle at top right, rgba(197, 106, 69, 0.08), transparent 28%),
        var(--paper);
}

.gate-intro h1 {
    margin: 2.4rem 0 0.55rem;
    font-family: var(--serif);
    font-size: clamp(2.4rem, 4vw, 3.6rem);
    font-weight: 520;
    letter-spacing: -0.04em;
    line-height: 0.95;
}

.gate-intro p {
    max-width: 26rem;
    margin: 0;
    color: var(--muted);
    font-size: 1.05rem;
}

.gate-form { margin-top: 2rem; max-width: 26rem; }

.field { display: flex; flex-direction: column; gap: 0.45rem; margin-bottom: 1rem; }

.field > label, .field > .label { font-size: 0.86rem; font-weight: 600; }

.field input:not([type="radio"]):not([type="checkbox"]), .field select, .field textarea {
    width: 100%;
    padding: 0.9rem 1rem;
    border: 1px solid var(--line);
    border-radius: 0.85rem;
    background: #fff;
    color: var(--ink);
}

.field textarea { resize: vertical; }

.field input:focus, .field select:focus, .field textarea:focus {
    outline: 2px solid var(--clay);
    outline-offset: 2px;
    border-color: transparent;
}

.password-row { position: relative; }

.password-row input { padding-right: 5.5rem; }

.reveal {
    position: absolute;
    top: 50%;
    right: 0.7rem;
    transform: translateY(-50%);
    border: 0;
    background: transparent;
    color: var(--pine);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
}

.field-error { color: #9c3b24; font-size: 0.82rem; }

.remember {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    margin: 0.3rem 0 1.3rem;
    color: var(--muted);
    font-size: 0.92rem;
}

.submit, .logout {
    border: 0;
    cursor: pointer;
}

.submit {
    width: 100%;
    padding: 0.95rem 1.2rem;
    border-radius: 999px;
    background: var(--pine);
    color: var(--paper);
    font-weight: 600;
}

.submit:hover { background: var(--pine-deep); }

.submit:focus-visible, .logout:focus-visible, .reveal:focus-visible, a:focus-visible {
    outline: 2px solid var(--clay);
    outline-offset: 3px;
}

.shell {
    display: grid;
    grid-template-columns: 250px minmax(0, 1fr);
    min-height: 100vh;
}

.rail {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    padding: 1.4rem 1.1rem 1.2rem;
    background: var(--pine-deep);
    color: var(--paper);
}

.rail-nav { display: flex; flex-direction: column; gap: 0.35rem; }

.rail-nav a {
    padding: 0.7rem 0.85rem;
    border-radius: 0.8rem;
    text-decoration: none;
}

.rail-nav a.is-current { background: rgba(251, 248, 243, 0.1); }

.rail-foot { margin-top: auto; }

.rail-doctor {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 0 0 0.9rem;
}

.rail-doctor img {
    width: 2.7rem;
    height: 2.7rem;
    border-radius: 50%;
    object-fit: cover;
    object-position: center 20%;
}

.rail-doctor figcaption { display: flex; flex-direction: column; }

.rail-doctor strong { font-size: 0.92rem; }

.rail-doctor span, .who { color: rgba(251, 248, 243, 0.72); font-size: 0.78rem; }

.logout {
    width: 100%;
    padding: 0.7rem 0.85rem;
    border-radius: 999px;
    background: transparent;
    color: var(--paper);
    border: 1px solid rgba(251, 248, 243, 0.2);
}

.logout:hover { background: rgba(251, 248, 243, 0.08); }

.workspace { padding: 1.5rem clamp(1.2rem, 3vw, 2.6rem) 2.5rem; }

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.6rem;
    color: var(--muted);
}

.who {
    margin: 0;
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    background: var(--sage);
    color: var(--pine);
    font-weight: 600;
}

.hero {
    display: grid;
    grid-template-columns: minmax(0, 1.3fr) minmax(240px, 0.7fr);
    gap: 1.2rem;
    align-items: stretch;
}

.hero-copy h1 {
    margin: 0;
    font-family: var(--serif);
    font-size: clamp(3rem, 6vw, 5rem);
    font-weight: 520;
    letter-spacing: -0.045em;
    line-height: 0.9;
}

.hero-copy p:last-child {
    max-width: 34rem;
    margin: 1rem 0 0;
    color: var(--muted);
    font-size: 1.08rem;
}

.hero-doctor {
    margin: 0;
    overflow: hidden;
    border-radius: 1.4rem;
    background: var(--pine);
    color: var(--paper);
    box-shadow: var(--shadow);
}

.hero-doctor img {
    width: 100%;
    height: 280px;
    object-fit: cover;
    object-position: center 18%;
}

.hero-doctor figcaption { padding: 1rem 1.1rem 1.15rem; }

.hero-doctor strong { display: block; font-family: var(--serif); font-size: 1.25rem; font-weight: 520; }

.hero-doctor span { display: block; margin-top: 0.25rem; color: rgba(251, 248, 243, 0.78); font-size: 0.9rem; }

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

.stats article {
    padding: 1.1rem 1.15rem 1rem;
    border: 1px solid var(--line);
    border-radius: 1.1rem;
    background: rgba(255, 255, 255, 0.55);
}

.stats span, .stats small { color: var(--muted); }

.stats span { font-size: 0.86rem; }

.stats strong {
    display: block;
    margin: 0.35rem 0 0.15rem;
    font-family: var(--serif);
    font-size: 2.6rem;
    font-weight: 520;
    letter-spacing: -0.04em;
    line-height: 1;
}

.stats small { font-size: 0.82rem; }

.agenda {
    padding: 1.3rem 1.3rem 0.6rem;
    border-radius: 1.3rem;
    background: #fffdf9;
    border: 1px solid var(--line);
}

.agenda-head {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: baseline;
    padding-bottom: 0.8rem;
    border-bottom: 1px solid var(--line);
}

.agenda h2 {
    margin: 0;
    font-family: var(--serif);
    font-size: 1.8rem;
    font-weight: 520;
}

.agenda-head p { margin: 0; color: var(--muted); }

.slots { list-style: none; margin: 0; padding: 0.3rem 0 0.4rem; }

.slots li {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.85rem 0.15rem;
    border-bottom: 1px dashed #eadfcf;
}

.slots time { font-variant-numeric: tabular-nums; font-weight: 600; }

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

@media (max-width: 980px) {
    .is-guest { overflow: auto; }
    .gate, .shell, .hero, .stats { grid-template-columns: 1fr; }
    .gate { height: auto; overflow: visible; }
    .gate-portrait { height: 38vh; }
    .gate-portrait img { height: 100%; }
    .gate-panel { justify-content: flex-start; padding-top: 1.6rem; padding-bottom: 1.6rem; }
    .gate-intro h1 { margin-top: 1.3rem; }
    .shell { display: block; }
    .rail { gap: 1rem; }
    .rail-nav {
        flex-direction: row;
        margin: 0 -1.1rem;
        padding: 0 1.1rem 0.2rem;
        overflow-x: auto;
        scrollbar-width: none;
        -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 2rem), transparent);
        mask-image: linear-gradient(to right, #000 calc(100% - 2rem), transparent);
    }
    .rail-nav::-webkit-scrollbar { display: none; }
    .rail-nav a { flex: none; white-space: nowrap; }
    .rail-nav .rail-public { margin-top: 0; padding-right: 2rem; }
    .rail-foot { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
    .logout { width: auto; }
    .agenda-head { flex-direction: column; }
}

@media (max-width: 640px) {
    .rail-doctor span { display: none; }
    .hero-doctor img { height: 220px; }
    .gate-caption, .gate-panel, .workspace { padding-left: 1.1rem; padding-right: 1.1rem; }
    .gate-portrait { height: 32vh; }
    .gate-caption { padding-top: 2rem; padding-bottom: 1rem; }
    .gate-caption h2 { font-size: 1.8rem; }
}

/* ---------- Shared pieces ---------- */

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

td .muted, .table .muted { display: block; font-size: 0.82rem; }

.optional { color: var(--muted); font-weight: 400; }

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.lead { color: var(--muted); font-size: 1.12rem; line-height: 1.55; }

.link-quiet { color: var(--pine); font-weight: 500; text-decoration: none; }

.link-quiet:hover { text-decoration: underline; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    white-space: nowrap;
    padding: 0.72rem 1.15rem;
    border: 1px solid transparent;
    border-radius: 999px;
    font-weight: 600;
    line-height: 1.1;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

.btn:focus-visible { outline: 2px solid var(--clay); outline-offset: 3px; }

.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary { background: var(--pine); color: var(--paper); }

.btn-primary:not(:disabled):hover { background: var(--pine-deep); }

.btn-secondary { background: var(--sage); color: var(--pine); }

.btn-secondary:hover { background: #c8d7ca; }

.btn-ghost { border-color: var(--line); background: transparent; color: var(--pine); }

.btn-ghost:hover { border-color: var(--pine); }

.btn-quiet { background: transparent; color: #9c3b24; }

.btn-quiet:hover { background: rgba(156, 59, 36, 0.08); }

.btn-danger { background: #9c3b24; color: var(--paper); }

.btn-danger:hover { background: #7a2c18; }

.btn-light { background: var(--paper); color: var(--pine); }

.btn-small { padding: 0.45rem 0.8rem; font-size: 0.85rem; }

.btn-lg { padding: 0.95rem 1.5rem; font-size: 1.02rem; }

.notice {
    margin: 0 0 1.2rem;
    padding: 0.9rem 1.1rem;
    border-radius: 0.9rem;
    font-size: 0.95rem;
}

.notice ul { margin: 0.35rem 0 0; padding-left: 1.2rem; }

.notice-ok { background: var(--sage); color: var(--pine-deep); }

.notice-error { background: #f6dfd6; color: #7a2c18; }

.alert-dialog {
    width: min(28rem, calc(100vw - 2rem));
    margin: 0 auto 1.2rem;
    padding: 1.6rem 1.6rem 1.3rem;
    border: 0;
    border-radius: 1.2rem;
    background: var(--paper);
    color: var(--ink);
    text-align: center;
    box-shadow: 0 24px 60px rgba(29, 40, 36, 0.28);
}

.alert-dialog:modal { margin: auto; }

.alert-dialog::backdrop { background: rgba(29, 40, 36, 0.45); backdrop-filter: blur(2px); }

.alert-dialog-icon {
    display: inline-grid;
    place-items: center;
    width: 3rem;
    height: 3rem;
    margin-bottom: 0.6rem;
    border-radius: 50%;
    background: #f6dfd6;
    color: #7a2c18;
    font-size: 1.5rem;
    font-weight: 700;
}

.alert-dialog h2 { margin: 0 0 0.6rem; font-family: var(--serif); font-size: 1.5rem; font-weight: 520; }

.alert-dialog ul { margin: 0 0 1.2rem; padding: 0; list-style: none; color: #7a2c18; line-height: 1.45; }

.alert-dialog li + li { margin-top: 0.4rem; }

.alert-dialog-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.6rem; }

.badge {
    display: inline-block;
    padding: 0.22rem 0.6rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-pendiente { background: #f7e3cf; color: #8a4a1d; }

.badge-confirmada { background: var(--sage); color: var(--pine); }

.badge-atendida { background: #dde3ee; color: #2f4064; }

.badge-cancelada { background: #ece7e1; color: #6f6a64; text-decoration: line-through; }

.avatar {
    display: grid;
    flex: none;
    width: 3rem;
    height: 3rem;
    place-items: center;
    border-radius: 50%;
    background: var(--sage);
    color: var(--pine);
    font-weight: 600;
}

.avatar-rail { width: 2.7rem; height: 2.7rem; background: rgba(251, 248, 243, 0.14); color: var(--paper); }

.segmented { display: flex; flex-wrap: wrap; gap: 0.4rem; }

.segmented label { position: relative; }

.segmented input, .chip input, .choice input, .doctor-choice input, .date-chip input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.segmented span {
    display: block;
    padding: 0.7rem 1rem;
    border: 1px solid var(--line);
    border-radius: 0.8rem;
    background: #fff;
    cursor: pointer;
}

.segmented input:checked + span { border-color: var(--pine); background: var(--pine); color: var(--paper); }

.segmented input:focus-visible + span, .chip input:focus-visible + span { outline: 2px solid var(--clay); outline-offset: 2px; }

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

.field-wide { grid-column: 1 / -1; }

/* ---------- Public site ---------- */

.is-public {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--paper);
}

.is-public > main { flex: 1 0 auto; }

.site-header {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    padding: 0.9rem clamp(1.1rem, 4vw, 3.5rem);
    background: rgba(251, 248, 243, 0.88);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(228, 216, 200, 0.7);
}

.site-nav { display: flex; gap: 1.6rem; }

.site-nav a { color: var(--ink); text-decoration: none; font-weight: 500; }

.site-nav a:hover { color: var(--clay); }

.site-actions { display: flex; align-items: center; gap: 1.1rem; }

.landing-hero {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(280px, 0.9fr);
    gap: clamp(1.5rem, 4vw, 4rem);
    align-items: center;
    padding: clamp(2rem, 6vw, 5rem) clamp(1.1rem, 4vw, 3.5rem) clamp(2rem, 5vw, 4rem);
}

.landing-copy h1 {
    margin: 0 0 1rem;
    font-family: var(--serif);
    font-size: clamp(2.8rem, 6.4vw, 5.6rem);
    font-weight: 520;
    letter-spacing: -0.045em;
    line-height: 0.93;
}

.landing-copy .lead { max-width: 34rem; margin: 0; }

.landing-actions { display: flex; flex-wrap: wrap; gap: 0.8rem; margin: 2rem 0 2.4rem; }

.landing-facts { display: flex; flex-wrap: wrap; gap: 2.4rem; margin: 0; }

.landing-facts div { display: flex; flex-direction: column; }

.landing-facts dt { font-family: var(--serif); font-size: 2.4rem; line-height: 1; }

.landing-facts dd { margin: 0.25rem 0 0; color: var(--muted); font-size: 0.9rem; }

.landing-portrait {
    position: relative;
    margin: 0;
    overflow: hidden;
    border-radius: 2rem 2rem 2rem 0.6rem;
    box-shadow: var(--shadow);
}

.landing-portrait img { width: 100%; aspect-ratio: 4 / 4.6; object-fit: cover; object-position: center 18%; }

.landing-portrait figcaption {
    position: absolute;
    right: 1rem;
    bottom: 1rem;
    left: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    padding: 1rem 1.1rem;
    border-radius: 1.1rem;
    background: rgba(18, 38, 31, 0.86);
    color: var(--paper);
    backdrop-filter: blur(6px);
}

.landing-portrait strong { font-family: var(--serif); font-size: 1.3rem; font-weight: 520; }

.landing-portrait span { color: rgba(251, 248, 243, 0.78); font-size: 0.9rem; }

.landing-portrait a { margin-top: 0.4rem; color: #f2c3ad; font-weight: 600; text-decoration: none; }

.section-head { margin-bottom: 1.6rem; }

.section-head h2 {
    margin: 0;
    font-family: var(--serif);
    font-size: clamp(2rem, 3.6vw, 3rem);
    font-weight: 520;
    letter-spacing: -0.03em;
}

.landing-steps, .landing-section { padding: clamp(2rem, 5vw, 4rem) clamp(1.1rem, 4vw, 3.5rem); }

.landing-steps { background: var(--cream); }

.steps {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.steps li { padding: 1.4rem; border-radius: 1.3rem; background: var(--paper); }

.steps h3 { margin: 0.9rem 0 0.4rem; font-size: 1.15rem; }

.steps p { margin: 0; color: var(--muted); }

.step-num {
    display: inline-grid;
    width: 2rem;
    height: 2rem;
    place-items: center;
    border-radius: 50%;
    background: var(--pine);
    color: var(--paper);
    font-size: 0.92rem;
    font-weight: 600;
}

.facility-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
    gap: 1rem;
}

.facility-card {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    padding: 1.4rem;
    border: 1px solid var(--line);
    border-radius: 1.3rem;
    background: #fff;
}

.facility-card h3 { margin: 0; font-family: var(--serif); font-size: 1.5rem; font-weight: 520; letter-spacing: -0.02em; }

.facility-meta { margin: 0; color: var(--clay); font-size: 0.8rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; }

.facility-address { margin: 0; font-weight: 500; }

.facility-text { margin: 0.2rem 0 0; color: var(--muted); font-size: 0.94rem; }

.facility-card .btn { align-self: flex-start; margin-top: auto; }

.tag-list { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0.6rem 0 1rem; padding: 0; list-style: none; }

.tag-list li { padding: 0.25rem 0.6rem; border-radius: 999px; background: var(--cream); color: var(--pine); font-size: 0.8rem; }

.specialty-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 0;
    margin: 0;
    padding: 0;
    border-top: 1px solid var(--line);
    list-style: none;
}

.specialty-list li { display: flex; flex-direction: column; gap: 0.2rem; padding: 1.1rem 1rem 1.1rem 0; border-bottom: 1px solid var(--line); }

.specialty-list strong { font-size: 1.05rem; }

.specialty-list span { color: var(--muted); font-size: 0.92rem; }

.specialty-list small { color: var(--clay); font-weight: 600; }

.landing-cta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    margin: 1rem clamp(1.1rem, 4vw, 3.5rem) 3rem;
    padding: clamp(1.6rem, 4vw, 3rem);
    border-radius: 1.6rem;
    background: var(--pine);
    color: var(--paper);
}

.landing-cta h2 { max-width: 34rem; margin: 0; font-family: var(--serif); font-size: clamp(1.7rem, 3vw, 2.5rem); font-weight: 520; }

.site-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.6rem clamp(1.1rem, 4vw, 3.5rem);
    border-top: 1px solid var(--line);
    color: var(--muted);
}

.site-footer p { margin: 0; }

/* ---------- Booking ---------- */

.booking-wrap, .receipt-wrap { padding: clamp(1.6rem, 4vw, 3rem) clamp(1.1rem, 4vw, 3.5rem) 4rem; }

.booking-head h1 {
    margin: 0 0 0.4rem;
    font-family: var(--serif);
    font-size: clamp(2.6rem, 5vw, 4rem);
    font-weight: 520;
    letter-spacing: -0.04em;
}

.booking-head .lead { margin: 0 0 1.8rem; }

.booking-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 1.5rem;
    align-items: start;
}

.step {
    min-width: 0;
    margin: 0 0 1rem;
    padding: 1.3rem 1.3rem 1.4rem;
    border: 1px solid var(--line);
    border-radius: 1.3rem;
    background: #fff;
    scroll-margin-top: 6rem;
}

.step legend {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    float: left;
    width: 100%;
    margin-bottom: 1rem;
    padding: 0;
    font-family: var(--serif);
    font-size: 1.45rem;
}

.step legend + * { clear: both; }

.step-hint { margin: 0 0 0.9rem; color: var(--muted); }

.booking-search { margin: 0 0 1rem; padding: 1.1rem 1.3rem 1.2rem; border-radius: 1.3rem; background: var(--sage); }

.booking-search > label { display: block; margin-bottom: 0.55rem; color: var(--pine); font-family: var(--serif); font-size: 1.25rem; font-weight: 520; }

.booking-search input {
    width: 100%;
    padding: 0.85rem 1.1rem 0.85rem 2.8rem;
    border: 1px solid transparent;
    border-radius: 999px;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' fill='none' stroke='%235e6b64' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='8' cy='8' r='6'/%3E%3Cpath d='m13 13 4 4'/%3E%3C/svg%3E") no-repeat 1.05rem center;
    color: var(--ink);
    font: inherit;
}

.booking-search input:focus { outline: 2px solid var(--clay); outline-offset: 2px; }

.search-results { display: grid; gap: 1rem; margin-top: 1rem; }

.search-group h3 { margin: 0 0 0.5rem; color: var(--pine); font-size: 0.78rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; }

.doctor-hit { padding: 0.9rem 1rem; border-radius: 1rem; background: #fff; }

.doctor-hit + .doctor-hit { margin-top: 0.6rem; }

.doctor-hit header { display: flex; align-items: center; gap: 0.75rem; }

.doctor-hit header img { width: 2.8rem; height: 2.8rem; border-radius: 50%; object-fit: cover; object-position: center 20%; }

.doctor-hit header .avatar { width: 2.8rem; height: 2.8rem; }

.doctor-hit header span:last-child { display: flex; flex-direction: column; }

.doctor-hit header small { color: var(--muted); }

.doctor-hit p { margin: 0.7rem 0 0.4rem; color: var(--muted); font-size: 0.88rem; }

.site-options { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 0.5rem; margin-top: 0.6rem; }

.doctor-hit p + .site-options { margin-top: 0; }

.site-option {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    padding: 0.75rem 0.9rem;
    border: 1px solid var(--line);
    border-radius: 0.9rem;
    background: var(--paper);
    color: var(--ink);
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.site-option:hover { border-color: var(--pine); background: #f1f5f1; }

.site-option:focus-visible { outline: 2px solid var(--clay); outline-offset: 2px; }

.search-results .site-option small { color: var(--clay); font-size: 0.72rem; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; }

.site-option span { color: var(--muted); font-size: 0.86rem; }

.search-empty { margin: 0; color: var(--pine); font-size: 0.92rem; }

.step > .field { clear: both; max-width: 30rem; margin-bottom: 0; }

.step .facility-detail { margin: 0.6rem 0 0; font-size: 0.9rem; }

.choice[hidden] { display: none; }

.choice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0.7rem; clear: both; }

.choice-body {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    height: 100%;
    padding: 0.95rem 1rem;
    border: 1px solid var(--line);
    border-radius: 1rem;
    cursor: pointer;
    transition: border-color 0.15s, background-color 0.15s;
}

.choice-body small { color: var(--clay); font-size: 0.75rem; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; }

.choice-body strong { font-size: 1.02rem; }

.choice-body span { color: var(--muted); font-size: 0.88rem; }

.choice:hover .choice-body, .doctor-choice:hover, .chip:hover span, .date-chip:hover span { border-color: var(--pine); }

.choice input:checked + .choice-body { border-color: var(--pine); background: #f1f5f1; box-shadow: inset 0 0 0 1px var(--pine); }

.choice input:focus-visible + .choice-body, .doctor-choice:has(input:focus-visible), .date-chip input:focus-visible + span { outline: 2px solid var(--clay); outline-offset: 2px; }

.chip-row { display: flex; flex-wrap: wrap; gap: 0.5rem; clear: both; }

.chip { position: relative; }

.chip span {
    display: block;
    padding: 0.62rem 1rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #fff;
    cursor: pointer;
}

.chip input:checked + span { border-color: var(--pine); background: var(--pine); color: var(--paper); }

.chip-time span { min-width: 6.4rem; white-space: nowrap; font-variant-numeric: tabular-nums; text-align: center; }

.time-row { margin-top: 1rem; }

.chip.is-taken span {
    border-style: dashed;
    background: transparent;
    color: var(--muted);
    text-decoration: line-through;
    cursor: not-allowed;
}

.time-conflict {
    margin: 0.9rem 0 0;
    padding: 0.7rem 0.9rem;
    border-radius: 0.8rem;
    background: #f6dfd6;
    color: #7a2c18;
    font-size: 0.92rem;
}

.doctor-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 0.7rem; clear: both; }

.doctor-choice {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.8rem 0.9rem;
    border: 1px solid var(--line);
    border-radius: 1rem;
    cursor: pointer;
}

.doctor-choice:has(input:checked) { border-color: var(--pine); background: #f1f5f1; box-shadow: inset 0 0 0 1px var(--pine); }

.doctor-choice img { width: 3rem; height: 3rem; border-radius: 50%; object-fit: cover; object-position: center 20%; }

.doctor-choice > span:last-child { display: flex; flex-direction: column; }

.doctor-choice small { color: var(--muted); }

.date-strip {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding: 0.2rem 0.1rem 0.6rem;
    scroll-snap-type: x proximity;
}

.date-chip { position: relative; flex: none; scroll-snap-align: start; }

.date-chip span {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 4.9rem;
    padding: 0.6rem 0.3rem;
    border: 1px solid var(--line);
    border-radius: 1rem;
    background: #fff;
    cursor: pointer;
    text-align: center;
}

.date-chip small { color: var(--muted); font-size: 0.75rem; text-transform: capitalize; }

.date-chip strong { font-family: var(--serif); font-size: 1.6rem; line-height: 1.1; }

.date-chip em { margin-top: 0.25rem; color: var(--clay); font-size: 0.7rem; font-style: normal; font-weight: 600; }

.date-chip input:checked + span { border-color: var(--pine); background: var(--pine); color: var(--paper); }

.date-chip input:checked + span small, .date-chip input:checked + span em { color: rgba(251, 248, 243, 0.82); }

.id-row { display: grid; grid-template-columns: 5.5rem minmax(0, 16rem) auto; gap: 0.7rem; align-items: end; clear: both; }

.id-row .field { margin-bottom: 0; }

.id-row .btn { padding-top: 0.95rem; padding-bottom: 0.95rem; }

[data-lookup-error] { margin: 0.6rem 0 0; }

.known {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    margin: 1.1rem 0 0.4rem;
    padding: 0.9rem 1rem;
    border-radius: 1rem;
    background: #f1f5f1;
}

.known small { display: block; color: var(--muted); }

.known strong { font-family: var(--serif); font-size: 1.35rem; font-weight: 520; }

.new-patient { min-width: 0; margin: 1.2rem 0 0; padding: 0; border: 0; }

.new-patient[disabled] { display: none; }

[data-step="patient"] > .field:last-child { margin: 1rem 0 0; }

.booking-submit { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem; margin-top: 0.4rem; }

.booking-submit p { margin: 0; color: var(--muted); }

.booking-summary {
    position: sticky;
    top: 6rem;
    padding: 1.3rem;
    border-radius: 1.3rem;
    background: var(--pine);
    color: var(--paper);
}

.booking-summary .eyebrow { color: #f2c3ad; }

.booking-summary dl { margin: 0; }

.booking-summary dl div { padding: 0.7rem 0; border-bottom: 1px solid rgba(251, 248, 243, 0.14); }

.booking-summary dl div:last-child { border-bottom: 0; }

.booking-summary dt { color: rgba(251, 248, 243, 0.65); font-size: 0.78rem; }

.booking-summary dd { margin: 0.15rem 0 0; font-weight: 500; }

.booking-summary dd.is-empty { color: rgba(251, 248, 243, 0.4); font-weight: 400; }

.receipt {
    max-width: 44rem;
    margin: 0 auto;
    padding: clamp(1.5rem, 4vw, 2.6rem);
    border: 1px solid var(--line);
    border-radius: 1.6rem;
    background: #fff;
    box-shadow: var(--shadow);
}

.receipt h1 { margin: 0 0 0.6rem; font-family: var(--serif); font-size: clamp(2rem, 4vw, 2.9rem); font-weight: 520; letter-spacing: -0.03em; line-height: 1.05; }

.receipt-code {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin: 1.4rem 0;
    padding: 1rem 1.2rem;
    border: 1px dashed var(--clay);
    border-radius: 1rem;
    background: #fdf6f1;
}

.receipt-code span { color: var(--muted); }

.receipt-code strong { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 1.6rem; letter-spacing: 0.18em; }

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

.receipt-details dt { color: var(--muted); font-size: 0.82rem; }

.receipt-details dd { margin: 0.15rem 0 0; font-weight: 500; }

.receipt-details small { color: var(--muted); font-weight: 400; }

.receipt-note { margin: 1.5rem 0; padding-top: 1.2rem; border-top: 1px solid var(--line); color: var(--muted); }

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

.receipt .lead a { color: var(--pine); font-weight: 600; }

.lookup form { margin-top: 1.6rem; }

.lookup .code-input { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 1.3rem; letter-spacing: 0.18em; text-transform: uppercase; }

.lookup-id { display: grid; grid-template-columns: 5.5rem minmax(0, 1fr); gap: 0.7rem; }

.lookup .receipt-actions { margin-top: 1.4rem; }

.footer-links { display: flex; flex-wrap: wrap; gap: 1.2rem; }

/* ---------- Panels ---------- */

.rail-public { margin-top: 0.6rem; color: rgba(251, 248, 243, 0.7); font-size: 0.9rem; }

.rail-nav a:not(.is-current):hover { background: rgba(251, 248, 243, 0.06); }

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

.page-head h1, .page-intro h1 {
    margin: 0;
    font-family: var(--serif);
    font-size: clamp(2.2rem, 4vw, 3.2rem);
    font-weight: 520;
    letter-spacing: -0.035em;
}

.page-head p.muted { max-width: 40rem; margin: 0.4rem 0 0; }

.page-head .eyebrow a { text-decoration: none; }

.page-intro { margin-bottom: 1.2rem; }

.page-intro h1 { font-size: clamp(2.8rem, 5vw, 4.2rem); line-height: 0.95; }

.page-intro p:last-child { margin: 0.6rem 0 0; color: var(--muted); }

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

.stats a { color: var(--pine); font-weight: 500; }

.panel {
    margin-bottom: 1.2rem;
    padding: 1.2rem;
    border: 1px solid var(--line);
    border-radius: 1.3rem;
    background: #fffdf9;
}

.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: 0.6rem; }

.panel-head h2, .form-panel h2 { margin: 0; font-family: var(--serif); font-size: 1.6rem; font-weight: 520; }

.panel-head p { margin: 0; }

.table-wrap { position: relative; overflow-x: auto; }

.table { width: 100%; border-collapse: collapse; font-size: 0.94rem; }

.table th {
    padding: 0.6rem 0.7rem;
    border-bottom: 1px solid var(--line);
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-align: left;
    text-transform: uppercase;
}

.table td { padding: 0.8rem 0.7rem; border-bottom: 1px dashed #eadfcf; vertical-align: top; }

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

.table td.empty { padding: 1.6rem; color: var(--muted); text-align: center; }

.row-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0.35rem; }

.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; margin-bottom: 1rem; }

.filters label { color: var(--muted); font-size: 0.9rem; }

.filters select { padding: 0.5rem 0.8rem; border: 1px solid var(--line); border-radius: 0.7rem; background: #fff; }

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

.form-panel { padding: 1.4rem; }

.form-panel h2 { margin-bottom: 1rem; }

.form-narrow { max-width: 36rem; }

.form-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0.6rem; margin-top: 0.6rem; padding-top: 1rem; border-top: 1px solid var(--line); }

.catalog-layout { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 1.2rem; align-items: start; }

.week-card {
    padding: 1.2rem 1.3rem;
    border-radius: 1.4rem;
    background: var(--pine);
    color: var(--paper);
    box-shadow: var(--shadow);
}

.week-card-head { display: flex; align-items: baseline; justify-content: space-between; }

.week-card h2 { margin: 0 0 0.6rem; font-family: var(--serif); font-size: 1.4rem; font-weight: 520; }

.week-card a { color: #f2c3ad; font-weight: 600; }

.week-card ul { margin: 0; padding: 0; list-style: none; }

.week-card li {
    display: grid;
    grid-template-columns: 6rem 1fr auto;
    gap: 0.5rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid rgba(251, 248, 243, 0.12);
    font-size: 0.92rem;
}

.week-card li span:nth-child(2) { color: rgba(251, 248, 243, 0.7); font-variant-numeric: tabular-nums; }

.week-card-foot, .week-card .muted { margin: 0.8rem 0 0; color: rgba(251, 248, 243, 0.7); font-size: 0.88rem; }

.agenda { margin-bottom: 1.2rem; }

.slots li { align-items: center; }

.slots li.is-booked { background: linear-gradient(90deg, rgba(215, 226, 216, 0.45), transparent); }

.slots li.is-past { opacity: 0.45; }

.slot-patient { flex: 1; display: flex; flex-direction: column; color: var(--ink) !important; font-size: 1rem !important; }

.slot-patient small { color: var(--muted); }

.slots .slot-free { flex: 1; text-align: right; }

.slots .slot-site { flex: 0 0 11rem; font-size: 0.82rem; text-align: right; }

.week-site { display: block; font-size: 0.78rem; }

.day-off-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.4rem 1.4rem; align-items: center; }

.day-off-form h2 { margin: 0; font-family: var(--serif); font-size: 1.6rem; font-weight: 520; }

.day-off-form p { max-width: 36rem; margin: 0.3rem 0 0; }

.day-off-form .field-error { grid-column: 1 / -1; justify-self: end; }

.day-off-fields { display: flex; flex-wrap: wrap; gap: 0.6rem; }

.day-off-fields input { padding: 0.6rem 0.8rem; border: 1px solid var(--line); border-radius: 0.8rem; background: #fff; font: inherit; }

.day-off-calls { margin-top: 1rem; padding: 0.9rem 1rem; border-radius: 0.9rem; background: #f7e3cf; color: #5c3416; }

.day-off-calls h3 { margin: 0 0 0.4rem; font-size: 0.95rem; }

.day-off-calls ul, .day-off-list { margin: 0; padding: 0; list-style: none; }

.day-off-calls li { display: flex; flex-wrap: wrap; gap: 0.5rem; padding: 0.2rem 0; font-variant-numeric: tabular-nums; }

.day-off-calls a { color: inherit; font-weight: 600; }

.day-off-list { margin-top: 1rem; border-top: 1px solid var(--line); }

.day-off-list li { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.6rem 0; border-bottom: 1px dashed #eadfcf; }

.day-off-tag { color: #9c3b24; }

@media (max-width: 640px) {
    .day-off-form { grid-template-columns: 1fr; }
    .day-off-form .field-error { justify-self: start; }
}

@media (max-width: 640px) {
    .slots li { flex-wrap: wrap; }
    .slots .slot-site { flex-basis: 100%; text-align: left; }
}

.schedule-form { max-width: 46rem; }

.duration-field { margin-bottom: 1.2rem; }

.schedule-days { border-top: 1px solid var(--line); }

.schedule-site .schedule-day:last-child { border-bottom: 0; padding-bottom: 0; }

.schedule-day.has-error { margin: 0 -0.6rem; padding-inline: 0.6rem; border-radius: 0.7rem; background: #f6dfd6; }

.site-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 22rem), 1fr)); gap: 1rem; margin-bottom: 1.6rem; }

.site-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.2rem;
    border: 1px solid var(--line);
    border-radius: 1.3rem;
    background: #fffdf9;
}

.site-card h2 { margin: 0.3rem 0 0.2rem; font-family: var(--serif); font-size: 1.45rem; font-weight: 520; }

.site-card .muted { margin: 0; }

.site-card .facility-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }

.site-days { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.9rem 0 0; padding: 0; list-style: none; font-size: 0.88rem; font-variant-numeric: tabular-nums; }

.site-days li { padding: 0.25rem 0.6rem; border-radius: 999px; background: var(--sage); color: var(--pine-deep); }

.site-days.is-empty { display: block; color: #8a4a1d; }

.site-list > .empty { grid-column: 1 / -1; margin: 0; color: var(--muted); }

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

.site-forms .muted, .office-form { margin-top: 0; }

.office-form { max-width: 40rem; }

.site-tag { display: block; color: var(--muted); font-size: 0.82rem; }

.site-picker { margin: 1.2rem 0 0; padding: 0; border: 0; }

.site-options { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 15rem), 1fr)); gap: 0.6rem; margin-top: 0.5rem; }

.site-option {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    padding: 0.7rem 0.8rem;
    border: 1px solid var(--line);
    border-radius: 0.9rem;
    background: #fff;
    cursor: pointer;
}

.site-option:has(input:checked) { border-color: var(--pine); background: rgba(215, 226, 216, 0.4); }

.site-option input { margin-top: 0.2rem; accent-color: var(--pine); }

.site-option span { display: flex; flex-direction: column; }

.site-option small { color: var(--muted); }

.schedule-day {
    display: grid;
    grid-template-columns: 9rem minmax(0, 1fr) 7.5rem;
    gap: 1rem;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px dashed #eadfcf;
}

.schedule-day.is-off .time-range { opacity: 0.35; }

.toggle { display: flex; align-items: center; gap: 0.6rem; font-weight: 600; cursor: pointer; }

.toggle input { width: 1.1rem; height: 1.1rem; accent-color: var(--pine); }

.time-range { display: flex; align-items: center; gap: 0.6rem; color: var(--muted); }

.time-range input { padding: 0.55rem 0.7rem; border: 1px solid var(--line); border-radius: 0.7rem; background: #fff; font-variant-numeric: tabular-nums; }

.day-capacity { color: var(--pine); font-weight: 600; text-align: right; }

.schedule-day.is-off .day-capacity { color: var(--muted); font-weight: 400; }

.schedule-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem; padding-top: 1.1rem; }

.schedule-foot p { margin: 0; }

/* ---------- Ficha del paciente ---------- */

.slots li.is-booked { position: relative; }

.slot-link { color: inherit; text-decoration: none; }

.slot-link::after { content: ""; position: absolute; inset: 0; border-radius: inherit; }

.slots li.is-booked:hover { background: linear-gradient(90deg, rgba(215, 226, 216, 0.85), transparent); }

.slot-link:focus-visible { outline: 2px solid var(--clay); outline-offset: 3px; }

.patient-link { color: var(--pine); font-weight: 600; text-decoration-color: rgba(28, 58, 52, 0.3); text-underline-offset: 0.2em; }

.patient-link:hover { text-decoration-color: var(--clay); }

.eyebrow a { color: inherit; }

.chart-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 1.2rem; align-items: start; }

.chart-layout aside { position: sticky; top: 1.2rem; }

.reason-card { border: 0; background: var(--pine); color: var(--paper); }

.reason-card .eyebrow { color: #f2c3ad; }

.reason-card blockquote { margin: 0.4rem 0 0; font-family: var(--serif); font-size: clamp(1.3rem, 2.2vw, 1.75rem); line-height: 1.3; }

.reason-card .muted { margin: 0.4rem 0 0; color: rgba(251, 248, 243, 0.75); font-size: 1.05rem; }

.allergy-alert { display: inline-block; margin: 1rem 0 0; padding: 0.55rem 0.9rem; border-radius: 0.7rem; background: #f6dfd6; color: #7a2c18; }

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

.facts dt { color: var(--muted); font-size: 0.76rem; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; }

.facts dd { margin: 0.15rem 0 0; }

.facts dd a { color: var(--pine); }

.facts-wide { grid-column: 1 / -1; }

.facts-stack { grid-template-columns: 1fr; gap: 0.7rem; }

.vitals { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0 0 1rem; padding: 0; list-style: none; }

.vitals li { padding: 0.5rem 0.8rem; border-radius: 0.8rem; background: #f4efe6; font-variant-numeric: tabular-nums; font-weight: 600; }

.vitals small { display: block; color: var(--muted); font-size: 0.72rem; font-weight: 500; }

.record-summary { margin: 0; }

.record-summary div + div { margin-top: 0.8rem; }

.record-summary dt, .rx-preview h3 { margin: 0; color: var(--muted); font-size: 0.76rem; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; }

.record-summary dd { margin: 0.15rem 0 0; white-space: pre-line; }

.rx-preview { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 1rem; }

.rx-preview p { margin: 0.25rem 0 0; white-space: pre-line; }

.visit-actions { flex-wrap: wrap; justify-content: flex-start; margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--line); }

.visit-link { display: grid; gap: 0.1rem; margin: 0 -0.6rem; padding: 0.65rem 0.6rem; border-radius: 0.8rem; color: var(--ink); text-decoration: none; }

.visit-link + .visit-link { border-top: 1px dashed #eadfcf; }

.visit-link:hover { background: #f4efe6; }

.visit-link span, .visit-link small { color: var(--muted); font-size: 0.86rem; }

/* ---------- Mis pacientes ---------- */

.patient-search { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1.2rem; }

.patient-search input { flex: 1 1 18rem; padding: 0.75rem 1rem; border: 1px solid var(--line); border-radius: 999px; background: #fff; color: var(--ink); font: inherit; }

.patient-search input:focus { outline: 2px solid var(--clay); outline-offset: 2px; border-color: transparent; }

.allergy-tag { display: inline-block; margin-top: 0.3rem; padding: 0.15rem 0.55rem; border-radius: 999px; background: #f6dfd6; color: #7a2c18; font-size: 0.76rem; font-weight: 600; }

.allergy-banner { margin: 0 0 1.2rem; padding: 0.85rem 1.1rem; border-left: 4px solid #9c3b24; border-radius: 0.9rem; background: #f6dfd6; color: #7a2c18; }

.record-columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.9rem 1.4rem; }

.record-columns div + div { margin-top: 0; }

.visit-entry { padding: 1rem 0; border-top: 1px dashed #eadfcf; }

.visit-entry:first-of-type { border-top: 0; padding-top: 0.2rem; }

.visit-entry header { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.3rem 0.8rem; margin-bottom: 0.6rem; }

.visit-entry header a { color: var(--pine); text-decoration: none; }

.visit-entry header a:hover { text-decoration: underline; text-decoration-color: var(--clay); }

.visit-entry header .muted { font-size: 0.88rem; }

.visit-entry header .badge { margin-left: auto; }

.vitals-compact { margin-bottom: 0.7rem; }

.vitals-compact li { padding: 0.35rem 0.65rem; font-size: 0.88rem; }

.visit-reason { margin: 0; color: var(--muted); font-style: italic; }

.visit-rx { margin: 0.7rem 0 0; padding: 0.55rem 0.8rem; border-radius: 0.7rem; background: #f4efe6; font-size: 0.9rem; }

.visit-rx span { color: var(--pine); font-family: var(--serif); font-style: italic; font-weight: 600; }

.visit-rx a { margin-left: 0.4rem; color: var(--pine); font-weight: 600; white-space: nowrap; }

/* ---------- Historia clínica ---------- */

.record-form { display: grid; grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr); gap: 1.2rem; align-items: start; }

.record-form .panel { margin: 0; }

.record-side { display: grid; gap: 1.2rem; }

.record-count { margin: 0 0 1rem; font-size: 0.9rem; }

.earlier-note { padding: 0.8rem 0; border-top: 1px dashed #eadfcf; }

.earlier-note:first-of-type { border-top: 0; padding-top: 0; }

.earlier-note summary { display: flex; flex-wrap: wrap; gap: 0.2rem 0.6rem; align-items: baseline; cursor: pointer; color: var(--pine); }

.earlier-note summary .muted { font-size: 0.86rem; }

.earlier-note[open] summary { margin-bottom: 0.7rem; }

.history-facts { margin-bottom: 1.2rem; }

.history-page-number { color: var(--clay); font-size: 0.76rem; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; }

.history-page.is-current { margin: 0 -1rem; padding-left: 1rem; padding-right: 1rem; border-radius: 0.9rem; background: #f4efe6; }

.history-page.is-current + .history-page { border-top-color: transparent; }

.vitals-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0.6rem; margin: 0 0 1rem; padding: 0; border: 0; }

.vitals-grid legend { margin-bottom: 0.45rem; padding: 0; font-size: 0.86rem; font-weight: 600; }

.vital-input { display: flex; flex-direction: column; gap: 0.3rem; color: var(--muted); font-size: 0.78rem; }

.with-unit { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 0.8rem; background: #fff; }

.with-unit:focus-within { outline: 2px solid var(--clay); outline-offset: 2px; border-color: transparent; }

.with-unit input { width: 100%; min-width: 0; padding: 0.7rem 0 0.7rem 0.75rem; border: 0; background: transparent; color: var(--ink); font: inherit; font-size: 1rem; font-variant-numeric: tabular-nums; outline: 0; }

.with-unit small { padding: 0 0.7rem 0 0.3rem; color: var(--muted); }

/* ---------- Récipes ---------- */

.letterhead {
    --accent: var(--pine);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 1.6rem;
    min-height: 15rem;
    padding: 1.4rem 1.5rem;
    border: 1px solid var(--line);
    border-top: 6px solid var(--accent);
    border-radius: 0.4rem;
    background: #fff;
    box-shadow: 0 18px 40px -28px rgba(18, 38, 31, 0.45);
}

.letterhead-top { display: flex; justify-content: space-between; gap: 1rem; padding-bottom: 0.8rem; border-bottom: 2px solid var(--accent); }

.letterhead-top div { display: flex; flex-direction: column; gap: 0.15rem; }

.letterhead-name { color: var(--accent); font-family: var(--serif); font-size: 1.45rem; font-weight: 600; line-height: 1.15; }

.letterhead-credentials, .letterhead-footer { color: var(--muted); font-size: 0.8rem; }

.letterhead-mark { align-self: flex-end; color: var(--accent); font-family: var(--serif); font-size: 2.2rem; font-style: italic; line-height: 1; }

.letterhead-place { display: flex; flex-direction: column; gap: 0.15rem; padding-top: 0.7rem; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.86rem; }

.letterhead-place strong { color: var(--ink); }

.letterhead [hidden] { display: none; }

.rx-editor { display: grid; grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr); gap: 1.4rem; align-items: start; }

.rx-editor > .letterhead { position: sticky; top: 1.2rem; }

.rx-editor > .panel { margin: 0; }

.rx-patient { display: flex; flex-wrap: wrap; gap: 0.5rem 1.6rem; margin: 0 0 1rem; padding-bottom: 0.9rem; border-bottom: 1px dashed var(--line); }

.rx-patient small { display: block; color: var(--muted); font-size: 0.72rem; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; }

.rx-diagnosis { margin: 0 0 1rem; }

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

.rx-templates { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 24rem), 1fr)); gap: 1.2rem; }

.rx-template { display: flex; flex-direction: column; gap: 1rem; margin: 0; }

.rx-template .panel-head { margin: 0; }

.rx-template .panel-head h2 { font-size: 1.3rem; }

.rx-template .row-actions { justify-content: flex-start; }

.accent-picker span { display: flex; align-items: center; gap: 0.45rem; }

.accent-picker i { width: 0.95rem; height: 0.95rem; border: 2px solid #fff; border-radius: 50%; box-shadow: 0 0 0 1px var(--line); }

@media (max-width: 1100px) {
    .stats-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .booking-layout, .catalog-layout, .site-forms, .chart-layout, .record-form, .rx-editor { grid-template-columns: minmax(0, 1fr); }
    .chart-layout aside, .rx-editor > .letterhead { position: static; }
    .rx-editor > .letterhead { min-height: 0; }
    .vitals-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .booking-summary { position: static; order: -1; }
    .booking-summary dl { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 1rem; }
}

@media (max-width: 980px) {
    .landing-hero, .steps { grid-template-columns: 1fr; }
    .site-nav { display: none; }
    .landing-portrait img { aspect-ratio: 4 / 3.4; }
    .stats-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
    .site-actions .link-quiet { display: none; }
    .form-grid, .receipt-details { grid-template-columns: 1fr; }
    .id-row { grid-template-columns: 4.8rem minmax(0, 1fr); }
    .id-row .btn { grid-column: 1 / -1; }
    .booking-summary dl { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .schedule-day { grid-template-columns: 1fr auto; }
    .schedule-day .time-range { grid-column: 1 / -1; grid-row: 2; }
    .time-range label { flex: 1 1 0; min-width: 0; }
    .time-range input { width: 100%; min-width: 0; }
    .page-head { flex-direction: column; align-items: flex-start; }
    .landing-facts { gap: 1.4rem; }
    .facts { grid-template-columns: 1fr 1fr; }
    .record-columns { grid-template-columns: 1fr; }
    .rx-fields { grid-template-columns: 1fr; }
    .vitals-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .panel-head { flex-wrap: wrap; }
    .slots .slot-site { flex-basis: auto; }
    .site-header { gap: 0.75rem; }
    .site-actions { gap: 0.5rem; }
}

@media (max-width: 420px) {
    .site-header { flex-wrap: wrap; row-gap: 0.6rem; padding-left: 1rem; padding-right: 1rem; }
    .site-header .brand { gap: 0.5rem; }
    .site-header .brand-mark { width: 2rem; height: 2rem; border-radius: 0.65rem; font-size: 1.05rem; }
    .site-header .brand-name strong { font-size: 1.05rem; }
    .site-header .brand-name small { display: none; }
    .site-actions { gap: 0.4rem; }
    .site-actions .btn { padding: 0.55rem 0.75rem; font-size: 0.86rem; }
}
