@font-face {
    font-family: "Montserrat";
    font-style: normal;
    font-weight: 500 700;
    font-display: swap;
    src: url("../fonts/montserrat-latin.311d352d9323.woff2") format("woff2");
}

:root {
    color-scheme: light;
    --brand-green: #59896c;
    --brand-purple: #9e7eac;
    --brand-light-green: #d6e2d8;
    --brand-light-purple: #e3dbea;
    --brand-gray: #878787;
    --background: #f7f8f5;
    --surface: #ffffff;
    --text: #2b382f;
    --muted: #68716b;
    --primary: #59896c;
    --primary-dark: #446b55;
    --border: #d6e2d8;
    --success-bg: #e5efe7;
    --success-text: #416349;
    --error-bg: #fff0f0;
    --error-text: #a12828;
    font-family: "Montserrat", "Avenir Next", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--background);
    color: var(--text);
    font-weight: 500;
}

.site-header {
    min-height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.brand {
    color: var(--text);
    font-size: 1.05rem;
    font-weight: 750;
    text-decoration: none;
}

.page-shell {
    width: min(100% - 32px, 780px);
    margin: 64px auto;
}

.card {
    padding: clamp(28px, 5vw, 52px);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: 0 14px 36px rgb(25 59 52 / 8%);
}

.login-card {
    max-width: 460px;
    margin-inline: auto;
}

h1 {
    margin: 12px 0 10px;
    font-size: clamp(2rem, 5vw, 2.8rem);
    letter-spacing: -0.04em;
}

p {
    line-height: 1.6;
}

.secondary,
.eyebrow {
    color: var(--muted);
}

.eyebrow {
    margin: 0;
    font-size: 0.82rem;
    font-weight: 750;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.status-badge {
    display: inline-flex;
    padding: 7px 11px;
    color: var(--success-text);
    background: var(--success-bg);
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 750;
}

.login-form {
    display: grid;
    gap: 10px;
    margin-top: 28px;
}

.login-form label {
    margin-top: 8px;
    font-size: 0.9rem;
    font-weight: 700;
}

.login-form input {
    width: 100%;
    padding: 13px 14px;
    color: var(--text);
    background: #fff;
    border: 1px solid #b8c9c5;
    border-radius: 10px;
    font: inherit;
}

.login-form input:focus {
    outline: 3px solid rgb(23 107 91 / 16%);
    border-color: var(--primary);
}

.primary-button {
    margin-top: 16px;
    padding: 13px 18px;
    color: #fff;
    background: var(--primary);
    border: 0;
    border-radius: 10px;
    font: inherit;
    font-weight: 750;
    cursor: pointer;
}

.primary-button:hover {
    background: var(--primary-dark);
}

.link-button {
    padding: 7px;
    color: var(--primary);
    background: none;
    border: 0;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.form-error {
    margin-top: 20px;
    padding: 12px 14px;
    color: var(--error-text);
    background: var(--error-bg);
    border-radius: 10px;
}

@media (max-width: 600px) {
    .site-header {
        padding-inline: 18px;
    }

    .page-shell {
        margin-block: 28px;
    }
}

.site-header {
    gap: 18px;
}

.brand {
    margin-right: auto;
}

.header-link,
.back-link,
.text-link {
    color: var(--primary);
    font-weight: 700;
    text-decoration: none;
}

.header-link:hover,
.back-link:hover,
.text-link:hover {
    text-decoration: underline;
}

.page-shell {
    width: min(100% - 32px, 1120px);
}

.page-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 24px;
}

.page-heading h1 {
    margin-bottom: 0;
}

.compact-card {
    padding: clamp(22px, 4vw, 34px);
}

.button-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-top: 0;
    text-decoration: none;
}

.secondary-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 17px;
    color: var(--primary);
    background: #fff;
    border: 1px solid #aac0bb;
    border-radius: 10px;
    font: inherit;
    font-weight: 750;
    cursor: pointer;
    text-decoration: none;
}

.secondary-button:hover {
    background: #f0f6f4;
}

.role-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 9px;
    margin-top: 22px;
}

.role-badge {
    padding: 6px 10px;
    color: var(--primary);
    background: var(--success-bg);
    border-radius: 999px;
    font-size: 0.84rem;
    font-weight: 750;
}

.dashboard-actions {
    margin-top: 30px;
}

.flash-message {
    margin-bottom: 18px;
    padding: 13px 16px;
    color: var(--success-text);
    background: var(--success-bg);
    border: 1px solid #b7e5d5;
    border-radius: 10px;
    font-weight: 650;
}

.search-form {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 26px;
}

.search-form input {
    flex: 1;
}

.form-control {
    width: 100%;
    min-height: 46px;
    padding: 11px 13px;
    color: var(--text);
    background: #fff;
    border: 1px solid #b8c9c5;
    border-radius: 10px;
    font: inherit;
}

textarea.form-control {
    min-height: 110px;
    resize: vertical;
}

.form-control:focus {
    outline: 3px solid rgb(23 107 91 / 16%);
    border-color: var(--primary);
}

.calculated-output {
    display: flex;
    align-items: center;
    background: var(--surface-soft);
    border-style: dashed;
}

.calculated-output.is-empty {
    color: var(--muted);
}

.table-wrap {
    position: relative;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 14px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

th {
    color: var(--muted);
    font-size: 0.78rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

tbody tr:last-child td {
    border-bottom: 0;
}

.patient-link {
    color: var(--text);
    font-weight: 750;
    text-decoration: none;
}

.patient-link:hover {
    color: var(--primary);
}

.empty-state {
    padding: 42px 16px;
    text-align: center;
}

.empty-state h2 {
    margin-bottom: 6px;
}

.empty-state p {
    margin: 0;
    color: var(--muted);
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
}

.detail-grid section:first-child {
    grid-row: span 2;
}

.card h2 {
    margin-top: 0;
    font-size: 1.25rem;
}

.data-list {
    display: grid;
    gap: 0;
    margin: 0;
}

.data-list div {
    display: grid;
    grid-template-columns: minmax(130px, 0.8fr) 1.2fr;
    gap: 18px;
    padding: 13px 0;
    border-bottom: 1px solid var(--border);
}

.data-list div:last-child {
    border-bottom: 0;
}

.data-list dt {
    color: var(--muted);
    font-size: 0.9rem;
}

.data-list dd {
    margin: 0;
    overflow-wrap: anywhere;
}

.form-section {
    margin-bottom: 18px;
    padding: clamp(22px, 4vw, 34px);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px 22px;
}

.form-field {
    display: grid;
    align-content: start;
    gap: 7px;
}

.form-field label {
    font-size: 0.9rem;
    font-weight: 750;
}

.form-field label span {
    color: #a12828;
}

.form-field small,
.form-hint {
    color: var(--muted);
    font-size: 0.84rem;
}

.has-error .form-control {
    border-color: #bd3a3a;
}

.field-error {
    color: var(--error-text);
    font-size: 0.84rem;
}

.optional-label {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 500;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
}

.form-actions .primary-button {
    margin-top: 0;
}

.errorlist {
    margin: 0;
    padding-left: 20px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@media (max-width: 760px) {
    .page-heading {
        align-items: stretch;
        flex-direction: column;
    }

    .detail-grid,
    .form-grid {
        grid-template-columns: 1fr;
    }

    .detail-grid section:first-child {
        grid-row: auto;
    }

    .search-form {
        align-items: stretch;
        flex-direction: column;
    }

    .search-form .secondary-button,
    .search-form .text-link {
        width: 100%;
        text-align: center;
    }

    .data-list div {
        grid-template-columns: 1fr;
        gap: 4px;
    }
}
.page-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
}

.episode-list {
    display: grid;
}

.episode-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 17px 4px;
    color: var(--text);
    border-bottom: 1px solid var(--border);
    text-decoration: none;
}

.episode-item:last-child {
    border-bottom: 0;
}

.episode-item:hover strong {
    color: var(--primary);
}

.episode-item span:first-child {
    display: grid;
    gap: 5px;
}

.episode-item small {
    color: var(--muted);
    line-height: 1.4;
}

.status-completed,
.status-suspended,
.muted-badge {
    color: var(--muted);
    background: #edf1f0;
}

.one-column {
    grid-template-columns: 1fr;
}

.section-heading {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 12px;
}

.section-heading h2,
.section-heading p {
    margin-bottom: 0;
}

.clinical-section {
    margin-bottom: 18px;
    padding: clamp(22px, 4vw, 34px);
}

.vertical-data div {
    grid-template-columns: 1fr;
    gap: 8px;
}

.measurement-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0 24px;
}

.measurement-list div {
    grid-template-columns: 1fr;
    gap: 4px;
}

.sticky-actions {
    position: sticky;
    bottom: 12px;
    z-index: 5;
    padding: 14px;
    background: rgb(244 247 246 / 96%);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 8px 24px rgb(25 59 52 / 12%);
}

.checkbox-control {
    width: 20px;
    height: 20px;
    accent-color: var(--primary);
}

.record-meta {
    color: var(--muted);
    font-size: 0.82rem;
    text-align: right;
}

@media (max-width: 760px) {
    .page-actions {
        justify-content: stretch;
    }

    .page-actions .button-link {
        flex: 1;
    }

    .episode-item {
        align-items: start;
        flex-direction: column;
    }

    .section-heading {
        flex-direction: column;
    }

    .measurement-list {
        grid-template-columns: 1fr;
    }

    .sticky-actions {
        bottom: 6px;
    }
}

/* Evaluacion clinica: recorrido rapido y legible */
.evaluation-heading {
    margin-bottom: 18px;
}

.evaluation-toolbar {
    position: sticky;
    top: 10px;
    z-index: 8;
    display: grid;
    grid-template-columns: minmax(150px, auto) minmax(0, 1fr) auto;
    align-items: center;
    gap: 14px;
    margin-bottom: 18px;
    padding: 12px 14px;
    background: rgb(255 255 255 / 97%);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 8px 24px rgb(25 59 52 / 10%);
    backdrop-filter: blur(8px);
}

.evaluation-patient {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.evaluation-patient span {
    color: var(--muted);
    font-size: 0.7rem;
    font-weight: 750;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.evaluation-patient strong {
    overflow: hidden;
    font-size: 0.92rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.section-shortcuts {
    display: flex;
    gap: 6px;
    min-width: 0;
    padding: 2px;
    overflow-x: auto;
    scrollbar-width: thin;
}

.section-shortcuts a {
    flex: 0 0 auto;
    padding: 7px 10px;
    color: var(--primary);
    background: #f0f6f4;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 750;
    text-decoration: none;
}

.section-shortcuts a:hover,
.section-shortcuts a:focus-visible {
    color: #fff;
    background: var(--primary);
    outline: none;
}

.form-step {
    padding: 0;
    overflow: hidden;
    scroll-margin-top: 104px;
}

.form-step:target {
    border-color: #8bb7ae;
    box-shadow: 0 0 0 3px rgb(23 107 91 / 10%), 0 14px 36px rgb(25 59 52 / 8%);
}

.form-step-summary {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 14px;
    padding: 20px clamp(22px, 4vw, 34px);
    cursor: pointer;
    list-style: none;
}

.form-step-summary::-webkit-details-marker {
    display: none;
}

.form-step-summary:hover {
    background: #f8fbfa;
}

.form-step-summary:focus-visible {
    outline: 3px solid rgb(23 107 91 / 18%);
    outline-offset: -3px;
}

.form-step-summary::after {
    content: "+";
    display: grid;
    width: 30px;
    height: 30px;
    color: var(--primary);
    background: #edf6f3;
    border-radius: 50%;
    font-size: 1.25rem;
    font-weight: 500;
    place-items: center;
}

.form-step[open] .form-step-summary {
    border-bottom: 1px solid var(--border);
}

.form-step[open] .form-step-summary::after {
    content: "-";
}

.form-step-summary > span:not(.step-number) {
    display: grid;
    gap: 3px;
}

.form-step-summary strong {
    font-size: 1.08rem;
}

.form-step-summary small {
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 500;
}

.step-number {
    display: grid;
    width: 32px;
    height: 32px;
    color: var(--primary);
    background: var(--success-bg);
    border-radius: 50%;
    font-size: 0.82rem;
    font-weight: 800;
    place-items: center;
}

.form-step-body {
    padding: 24px clamp(22px, 4vw, 34px) clamp(24px, 4vw, 34px);
}

.compact-form-grid {
    max-width: 360px;
}

.grouped-fields {
    display: grid;
    gap: 16px;
}

.clinical-field-group,
.comparison-panel {
    min-width: 0;
    margin: 0;
    padding: 18px;
    background: #f8fbfa;
    border: 1px solid var(--border);
    border-radius: 12px;
}

.clinical-field-group legend,
.comparison-panel legend {
    padding: 0 7px;
    color: var(--text);
    font-size: 0.95rem;
    font-weight: 800;
}

.field-span-full {
    min-width: 0;
    grid-column: 1 / -1;
}

.section-intro,
.test-section-heading {
    margin-top: 0;
}

.measurement-form-grid,
.test-general-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.test-general-grid {
    margin-bottom: 22px;
}

.comparison-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.comparison-panel {
    padding-top: 14px;
    background: #fbfdfc;
    border-color: #cbded9;
}

.compact-fields {
    gap: 14px;
}

.pressure-grid {
    gap: 12px;
}

.field-after-group {
    margin-top: 22px;
}

.sticky-actions {
    align-items: center;
    justify-content: space-between;
}

.save-reminder {
    margin: 0 auto 0 0;
    color: var(--muted);
    font-size: 0.8rem;
    line-height: 1.4;
}

.action-buttons {
    display: flex;
    gap: 10px;
}

@media (max-width: 900px) {
    .evaluation-toolbar {
        grid-template-columns: minmax(0, 1fr) auto;
    }

    .section-shortcuts {
        grid-column: 1 / -1;
        grid-row: 2;
    }

    .measurement-form-grid,
    .test-general-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 760px) {
    .evaluation-toolbar {
        top: 6px;
        padding: 10px;
    }

    .evaluation-toolbar .status-badge {
        justify-self: end;
    }

    .form-step {
        scroll-margin-top: 128px;
    }

    .form-step-summary {
        gap: 10px;
        padding: 17px 18px;
    }

    .form-step-summary::after {
        width: 28px;
        height: 28px;
    }

    .form-step-summary small {
        line-height: 1.35;
    }

    .form-step-body {
        padding: 20px 18px 22px;
    }

    .clinical-field-group,
    .comparison-panel {
        padding: 15px;
    }

    .comparison-grid,
    .measurement-form-grid,
    .test-general-grid,
    .pressure-grid {
        grid-template-columns: 1fr;
    }

    .field-span-full {
        grid-column: auto;
    }

    .save-reminder {
        display: none;
    }

    .action-buttons {
        width: 100%;
    }

    .action-buttons > * {
        flex: 1;
    }
}

/* Identidad Respira y auditoria */
body {
    background:
        radial-gradient(circle at 8% 4%, rgb(214 226 216 / 55%), transparent 28rem),
        radial-gradient(circle at 94% 12%, rgb(227 219 234 / 58%), transparent 28rem),
        var(--background);
}

.site-header {
    min-height: 72px;
    border-top: 3px solid var(--brand-purple);
    box-shadow: 0 3px 18px rgb(70 91 75 / 6%);
}

.brand {
    display: grid;
    gap: 1px;
    color: var(--brand-green);
    letter-spacing: 0.18em;
    line-height: 1;
}

.brand span {
    font-size: 1rem;
    font-weight: 650;
}

.brand small {
    color: var(--muted);
    font-size: 0.58rem;
    font-weight: 650;
    letter-spacing: 0;
}

h1 {
    letter-spacing: -0.025em;
}

.card {
    box-shadow: 0 14px 36px rgb(70 91 75 / 9%);
}

.status-badge,
.role-badge,
.step-number {
    color: var(--success-text);
    background: var(--success-bg);
}

.brand-logo {
    display: block;
    max-width: 100%;
    height: auto;
    object-fit: contain;
}

.brand-logo-login {
    width: min(100%, 315px);
    margin: -20px auto 4px;
}

.brand-logo-dashboard {
    float: right;
    width: min(38%, 280px);
    margin: -28px -16px 16px 36px;
}

.dashboard-card {
    min-height: 330px;
    overflow: hidden;
}

.login-form input:focus,
.form-control:focus {
    outline-color: rgb(105 148 115 / 22%);
}

.secondary-button {
    border-color: var(--brand-light-green);
}

.secondary-button:hover {
    background: #eef4ef;
}

.inline-form {
    display: inline-flex;
    margin: 0;
}

.finalize-button {
    color: #725781;
    border-color: #c8b7d0;
}

.finalize-button:hover {
    background: #f3eef5;
}

.audit-list {
    border-top: 1px solid var(--border);
}

.audit-event {
    padding: 22px 2px;
    border-bottom: 1px solid var(--border);
}

.audit-event:last-child {
    border-bottom: 0;
}

.audit-event-heading {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 18px;
}

.audit-event-heading p,
.audit-entity {
    margin: 5px 0 0;
    color: var(--muted);
    font-size: 0.84rem;
    line-height: 1.5;
}

.audit-details {
    margin-top: 15px;
    padding: 12px 14px;
    background: #fafcf9;
    border: 1px solid var(--border);
    border-radius: 10px;
}

.audit-details summary {
    color: var(--primary);
    font-size: 0.88rem;
    font-weight: 750;
    cursor: pointer;
}

.audit-change-list {
    display: grid;
    margin-top: 12px;
}

.audit-change {
    display: grid;
    grid-template-columns: minmax(170px, 0.7fr) repeat(2, minmax(0, 1fr));
    gap: 14px;
    padding: 13px 0;
    border-top: 1px solid var(--border);
}

.audit-change > strong {
    font-size: 0.84rem;
}

.audit-change div span {
    color: var(--muted);
    font-size: 0.7rem;
    font-weight: 750;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}

.audit-change div p {
    margin: 3px 0 0;
    font-size: 0.88rem;
    line-height: 1.45;
    overflow-wrap: anywhere;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-top: 24px;
}

@media (max-width: 760px) {
    .site-header {
        flex-wrap: wrap;
        padding-block: 11px;
    }

    .brand small {
        display: none;
    }

    .brand-logo-dashboard {
        float: none;
        width: min(100%, 250px);
        margin: -18px auto 10px;
    }

    .dashboard-card {
        min-height: 0;
    }

    .audit-event-heading,
    .audit-change,
    .pagination {
        align-items: stretch;
        grid-template-columns: 1fr;
        flex-direction: column;
    }

    .audit-change {
        display: grid;
    }

    .page-actions .inline-form,
    .page-actions .inline-form button {
        width: 100%;
    }
}
/* Seguimiento clinico: evaluaciones, reevaluaciones y evoluciones diarias. */
.clinical-start-card {
    border-color: rgba(105, 148, 115, 0.42);
    background: linear-gradient(135deg, #ffffff 0%, #f2f7f3 100%);
}

.clinical-start-card h2,
.clinical-start-card p:last-child {
    margin-bottom: 0;
}

.clinical-timeline {
    display: grid;
    margin-top: 12px;
}

.timeline-item {
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr) auto;
    align-items: center;
    gap: 14px;
    padding: 18px 8px;
    color: inherit;
    text-decoration: none;
    border-top: 1px solid var(--border);
}

.timeline-item:first-child {
    border-top: 0;
}

.timeline-item:hover {
    background: #f8fbf8;
}

.timeline-marker {
    width: 12px;
    height: 12px;
    border: 3px solid #fff;
    border-radius: 50%;
    box-shadow: 0 0 0 2px var(--primary);
}

.evolution-marker {
    box-shadow: 0 0 0 2px var(--brand-purple);
}

.timeline-content {
    display: grid;
    gap: 3px;
    min-width: 0;
}

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

.timeline-content span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.clinical-reference {
    margin-bottom: 22px;
    padding: 0;
    overflow: hidden;
    border-color: rgba(158, 126, 172, 0.38);
}

.clinical-reference > summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 20px 24px;
    cursor: pointer;
    list-style: none;
    background: #f8f5fa;
}

.clinical-reference > summary::-webkit-details-marker {
    display: none;
}

.clinical-reference summary span:first-child {
    display: grid;
    gap: 3px;
}

.clinical-reference summary small {
    color: var(--muted);
}

.locked-badge {
    padding: 5px 10px;
    color: #6d5178;
    font-size: 0.76rem;
    font-weight: 750;
    border-radius: 999px;
    background: #eadff0;
}

.reference-body {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 22px;
    padding: 22px 24px;
}

.reference-body section:last-child {
    grid-column: 1 / -1;
}

.reference-body h3 {
    margin: 0 0 12px;
    font-size: 1rem;
}

.scale-tools {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px 14px;
}

.text-button {
    padding: 0;
    color: var(--primary);
    font: inherit;
    font-size: 0.88rem;
    font-weight: 750;
    text-decoration: underline;
    border: 0;
    background: transparent;
    cursor: pointer;
}

.text-button:disabled {
    color: var(--muted);
    cursor: wait;
}

.scale-refresh-status {
    color: var(--muted);
}

.scale-refresh-status.is-error {
    color: var(--danger, #9a3e3e);
}

.daily-evolution-card {
    max-width: 820px;
}

.daily-note p {
    margin-bottom: 0;
    line-height: 1.75;
    white-space: normal;
}

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

    .timeline-item > .status-badge {
        grid-column: 2;
        justify-self: start;
    }

    .reference-body {
        grid-template-columns: 1fr;
    }

    .reference-body section:last-child {
        grid-column: auto;
    }

    .clinical-reference > summary {
        align-items: flex-start;
    }
}

/* Panel de gestion y seguridad. */
.management-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 22px;
}

.stat-card {
    display: grid;
    gap: 7px;
    padding: 20px;
}

.stat-card span {
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 700;
}

.stat-card strong {
    color: var(--primary-dark);
    font-size: 2rem;
}

.stat-card a {
    color: var(--primary);
    font-size: 0.84rem;
    font-weight: 750;
}

.management-grid,
.category-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
    margin-bottom: 22px;
}

.management-card,
.category-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.management-card > p:not(.eyebrow),
.category-card > p {
    flex: 1;
    line-height: 1.6;
}

.card-actions,
.table-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 9px;
}

.compact-event-list {
    display: grid;
}

.compact-event-list > div {
    display: grid;
    grid-template-columns: 130px minmax(0, 1fr) minmax(120px, 0.6fr);
    gap: 14px;
    padding: 13px 0;
    border-top: 1px solid var(--border);
}

.compact-event-list > div:first-child {
    border-top: 0;
}

.compact-event-list span,
.compact-event-list small,
.current-user-label,
.hash-preview {
    display: block;
    color: var(--muted);
    font-size: 0.76rem;
}

.table-actions form {
    margin: 0;
}

.danger-link {
    color: #8b3c3c;
}

.danger-button {
    color: #7e3434;
    border-color: #d9b8b8;
}

.management-form-card,
.password-card,
.credential-card {
    max-width: 820px;
    margin-inline: auto;
}

.category-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    width: 100%;
    gap: 16px;
}

.category-heading h2 {
    margin-bottom: 3px;
}

.category-heading small {
    color: var(--brand-purple);
    font-weight: 750;
}

.capability-section > h2 {
    margin-bottom: 18px;
}

#id_capabilities {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    padding: 0;
    list-style: none;
}

#id_capabilities label {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 48px;
    padding: 12px 14px;
    font-weight: 750;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fbfcfa;
}

#id_capabilities input {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}

.capability-help {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px 20px;
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
}

.capability-help div {
    display: grid;
    gap: 3px;
}

.capability-help strong {
    font-size: 0.83rem;
}

.capability-help span {
    color: var(--muted);
    font-size: 0.8rem;
    line-height: 1.4;
}

.credential-card {
    text-align: center;
}

.credential-box {
    display: grid;
    gap: 1px;
    max-width: 590px;
    margin: 24px auto;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--border);
}

.credential-box div {
    display: grid;
    grid-template-columns: 150px 1fr;
    align-items: center;
    text-align: left;
    background: #fff;
}

.credential-box dt,
.credential-box dd {
    margin: 0;
    padding: 14px 16px;
}

.credential-box dt {
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 750;
}

.temporary-secret {
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: 1.05rem;
    font-weight: 750;
    overflow-wrap: anywhere;
}

.security-notice {
    color: var(--muted);
    font-size: 0.85rem;
}

.security-callout {
    padding: 16px 18px;
    color: #594663;
    border: 1px solid #d9c9e1;
    border-radius: 10px;
    background: #f8f3fa;
}

.security-callout p:last-child {
    margin-bottom: 0;
}

.security-event-list article {
    padding: 18px 0;
    border-top: 1px solid var(--border);
}

.security-event-list article:first-child {
    border-top: 0;
}

.security-event-list article > div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.security-event-list article > div span {
    color: var(--muted);
    font-size: 0.8rem;
}

.security-event-list dl {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 28px;
    margin: 10px 0 0;
}

.security-event-list dl div {
    display: flex;
    gap: 6px;
}

.security-event-list dt {
    color: var(--muted);
    font-size: 0.78rem;
}

.security-event-list dd {
    margin: 0;
    font-size: 0.8rem;
}

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

@media (max-width: 760px) {
    .management-stats,
    .management-grid,
    .category-grid,
    #id_capabilities,
    .capability-help {
        grid-template-columns: 1fr;
    }

    .compact-event-list > div {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .credential-box div {
        grid-template-columns: 1fr;
    }

    .credential-box dd {
        padding-top: 0;
    }
}

/* Pulido visual compartido: navegacion, listados y gestion. */
:root {
    --surface-soft: #f3f7f3;
    --surface-purple: #f7f3f9;
    --border-strong: #c4d3c7;
    --shadow-soft: 0 10px 28px rgb(55 78 61 / 7%);
}

body {
    text-rendering: optimizeLegibility;
}

.page-shell {
    margin-block: clamp(38px, 6vw, 68px);
}

.site-header {
    gap: 6px;
    padding-inline: clamp(18px, 3vw, 42px);
    background: rgb(255 255 255 / 94%);
    backdrop-filter: blur(12px);
}

.site-header form {
    margin: 0;
}

.header-link,
.site-header .link-button {
    display: inline-flex;
    align-items: center;
    min-height: 38px;
    padding: 8px 11px;
    border-radius: 9px;
    line-height: 1.2;
    text-decoration: none;
    transition: color 160ms ease, background-color 160ms ease;
}

.header-link:hover,
.header-link:focus-visible,
.site-header .link-button:hover,
.site-header .link-button:focus-visible {
    color: var(--primary-dark);
    background: var(--surface-soft);
    text-decoration: none;
    outline: none;
}

.brand:focus-visible,
.back-link:focus-visible,
.text-link:focus-visible {
    border-radius: 6px;
    outline: 3px solid rgb(105 148 115 / 24%);
    outline-offset: 3px;
}

.page-heading {
    align-items: center;
    margin-bottom: 28px;
}

.page-heading h1 {
    margin-top: 9px;
}

.page-heading .secondary {
    max-width: 720px;
    margin-bottom: 0;
}

.card {
    border-color: var(--border-strong);
    box-shadow: var(--shadow-soft);
}

.primary-button,
.secondary-button {
    transition: transform 150ms ease, box-shadow 150ms ease, color 150ms ease,
        background-color 150ms ease, border-color 150ms ease;
}

.primary-button {
    box-shadow: 0 7px 16px rgb(60 87 67 / 15%);
}

.primary-button:hover,
.primary-button:focus-visible {
    transform: translateY(-1px);
    box-shadow: 0 9px 20px rgb(60 87 67 / 20%);
}

.secondary-button:hover,
.secondary-button:focus-visible {
    border-color: #8eaea2;
}

.primary-button:focus-visible,
.secondary-button:focus-visible,
.password-toggle:focus-visible,
.text-button:focus-visible {
    outline: 3px solid rgb(105 148 115 / 24%);
    outline-offset: 2px;
}

.form-control:hover,
.login-form input:hover {
    border-color: #99b1aa;
}

.search-form {
    padding-bottom: 22px;
    border-bottom: 1px solid var(--border);
}

.search-form input.form-control {
    width: auto;
    min-width: 0;
}

.search-form select.form-control {
    width: auto;
    min-width: 170px;
}

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

.table-wrap th {
    padding-block: 12px;
    background: var(--surface-soft);
    border-bottom-color: var(--border-strong);
}

.table-wrap tbody tr {
    transition: background-color 140ms ease;
}

.table-wrap tbody tr:hover {
    background: #fafcf9;
}

.empty-state {
    display: grid;
    min-height: 230px;
    place-content: center;
}

.empty-state::before {
    content: "";
    width: 72px;
    height: 68px;
    margin: 0 auto 18px;
    background: url("../img/respira-isotipo.884dfd212133.png") center / 150px auto no-repeat;
    filter: drop-shadow(0 8px 12px rgb(55 78 61 / 12%));
}

.empty-state h2 {
    margin-top: 0;
}

.stat-card {
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    height: 4px;
    background: linear-gradient(90deg, var(--brand-green), #94b39b);
}

.stat-card:nth-child(even)::before {
    background: linear-gradient(90deg, var(--brand-purple), #c3afd0);
}

.stat-card strong {
    letter-spacing: -0.035em;
}

.management-card,
.category-card {
    position: relative;
    overflow: hidden;
}

.management-card::before,
.category-card::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 4px;
    background: linear-gradient(180deg, var(--brand-green), var(--brand-light-purple));
}

.management-card > p:not(.eyebrow),
.category-card > p {
    color: var(--muted);
}

.episode-item {
    margin-inline: -8px;
    padding-inline: 12px;
    border-radius: 10px;
    transition: background-color 150ms ease, transform 150ms ease;
}

.episode-item:hover,
.episode-item:focus-visible {
    background: var(--surface-soft);
    outline: none;
    transform: translateX(2px);
}

.form-hint:first-child {
    margin-top: 0;
    padding: 12px 14px;
    background: var(--surface-purple);
    border: 1px solid var(--brand-light-purple);
    border-radius: 10px;
    line-height: 1.55;
}

@media (max-width: 900px) {
    .header-link,
    .site-header .link-button {
        padding-inline: 8px;
        font-size: 0.86rem;
    }
}

@media (max-width: 760px) {
    html,
    body {
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
    }

    .page-shell {
        width: calc(100% - 24px);
        max-width: 100%;
        margin-block: 30px;
        overflow-x: hidden;
    }

    .site-header {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        row-gap: 5px;
        width: 100%;
        overflow: hidden;
    }

    .site-header .brand {
        grid-column: 1 / -1;
        margin-bottom: 3px;
    }

    .header-link,
    .site-header .link-button {
        justify-content: center;
        min-width: 0;
        min-height: 36px;
        padding: 7px 9px;
        text-align: center;
        white-space: normal;
    }

    .site-header form,
    .site-header form .link-button {
        width: 100%;
    }

    .page-shell > *,
    .card,
    .search-form,
    .table-wrap {
        width: 100%;
        min-width: 0;
        max-width: 100%;
    }

    .card {
        overflow: hidden;
    }

    .table-wrap {
        contain: inline-size;
        overflow-x: auto;
    }

    .table-wrap table {
        min-width: 680px;
    }

    .page-heading,
    .management-stats,
    .management-grid,
    .category-grid {
        min-width: 0;
        max-width: 100%;
    }

    .page-heading h1,
    .page-heading p {
        overflow-wrap: anywhere;
    }

    .page-heading {
        align-items: stretch;
    }

    .page-heading > .primary-button {
        align-self: flex-start;
    }

    .search-form select.form-control {
        width: 100%;
        min-width: 0;
    }

    .empty-state {
        min-height: 210px;
    }

    .table-wrap {
        border-radius: 10px;
    }
}

/* Identidad visual oficial Respira. */
.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    letter-spacing: 0;
}

.brand-symbol {
    display: block;
    flex: 0 0 40px;
    width: 40px;
    height: 40px;
    overflow: hidden;
}

.brand-symbol img {
    display: block;
    width: 84px;
    max-width: none;
    height: auto;
    transform: translate(-22px, -10px);
}

.brand-wordmark {
    display: grid;
    gap: 3px;
    min-width: 0;
}

.brand-wordmark strong {
    color: var(--brand-green);
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.22em;
    line-height: 1;
}

.brand-wordmark small {
    color: var(--brand-gray);
    font-size: 0.58rem;
    font-weight: 600;
    letter-spacing: 0;
    line-height: 1.2;
}

@media (max-width: 760px) {
    .site-header .brand {
        justify-self: start;
    }

    .brand-symbol {
        flex-basis: 34px;
        width: 34px;
        height: 34px;
    }

    .brand-symbol img {
        width: 72px;
        transform: translate(-19px, -9px);
    }

    .brand-wordmark strong {
        font-size: 0.92rem;
    }
}

/* Agenda externa de Respira: consulta de solo lectura. */
.appointments-shell {
    display: grid;
}

.appointments-heading {
    align-items: flex-end;
}

.readonly-badge {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    padding: 8px 13px;
    color: var(--primary);
    background: var(--surface-purple);
    border: 1px solid var(--brand-light-purple);
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 750;
    white-space: nowrap;
}

.appointments-card {
    padding: clamp(20px, 3.5vw, 34px);
}

.appointments-filter {
    display: grid;
    grid-template-columns: minmax(180px, 240px) minmax(220px, 1fr) auto;
    align-items: end;
    gap: 14px;
    margin-bottom: 22px;
    padding-bottom: 22px;
    border-bottom: 1px solid var(--border);
}

.appointments-filter .form-field {
    display: grid;
    gap: 7px;
}

.appointments-filter label {
    color: var(--text);
    font-size: 0.84rem;
    font-weight: 750;
}

.appointments-filter .primary-button {
    min-height: 46px;
    margin-top: 0;
}

.appointments-notice,
.appointments-error,
.appointments-result {
    margin-bottom: 18px;
    padding: 13px 15px;
    border-radius: 10px;
}

.appointments-notice {
    color: var(--muted);
    background: var(--surface-soft);
    border: 1px solid var(--border);
}

.appointments-error {
    display: grid;
    gap: 4px;
    color: #7a3f3f;
    background: #fff5f5;
    border: 1px solid #ebc8c8;
}

.appointments-result {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    color: var(--success-text);
    background: var(--success-bg);
    border: 1px solid #c9ded0;
}

.appointments-result small {
    color: var(--muted);
    white-space: nowrap;
}

.appointments-table {
    min-width: 1080px;
    font-size: 0.88rem;
}

.appointments-table th,
.appointments-table td {
    padding: 12px 10px;
    vertical-align: top;
}

.appointments-table th:first-child,
.appointments-table td:first-child {
    padding-left: 16px;
}

.appointments-table th:last-child,
.appointments-table td:last-child {
    padding-right: 16px;
}

.appointments-notes {
    min-width: 180px;
    max-width: 300px;
    color: var(--muted);
    line-height: 1.45;
}

.appointment-status {
    display: inline-flex;
    padding: 6px 9px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 750;
    white-space: nowrap;
}

.appointment-status--success {
    color: var(--success-text);
    background: var(--success-bg);
}

.appointment-status--pending {
    color: #735283;
    background: var(--surface-purple);
}

.appointment-status--muted {
    color: var(--muted);
    background: #edf1f0;
}

.appointments-empty {
    border: 1px dashed var(--border-strong);
    border-radius: 12px;
    text-align: center;
}

@media (max-width: 760px) {
    .appointments-page .site-header {
        align-items: flex-start;
    }

    .appointments-heading {
        align-items: flex-start;
    }

    .appointments-filter {
        grid-template-columns: 1fr;
    }

    .appointments-filter .primary-button {
        width: 100%;
    }

    .appointments-result {
        align-items: flex-start;
        flex-direction: column;
        gap: 4px;
    }

    .appointments-result small {
        white-space: normal;
    }

    .appointments-table-wrap {
        contain: none;
        overflow: visible;
        background: transparent;
        border: 0;
        border-radius: 0;
    }

    .appointments-table-wrap .appointments-table {
        display: block;
        min-width: 0;
    }

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

    .appointments-table tbody {
        display: grid;
        gap: 12px;
    }

    .appointments-table tr {
        display: block;
        overflow: hidden;
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: 12px;
        box-shadow: 0 8px 22px rgb(70 91 75 / 6%);
    }

    .appointments-table td {
        display: grid;
        grid-template-columns: minmax(105px, 0.44fr) minmax(0, 1fr);
        gap: 12px;
        min-width: 0;
        max-width: none;
        padding: 10px 13px;
        overflow-wrap: anywhere;
        border-bottom: 1px solid var(--border);
    }

    .appointments-table td:first-child,
    .appointments-table td:last-child {
        padding: 10px 13px;
    }

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

    .appointments-table td::before {
        content: attr(data-label);
        color: var(--muted);
        font-size: 0.72rem;
        font-weight: 750;
        letter-spacing: 0.05em;
        text-transform: uppercase;
    }

    .appointments-notes {
        min-width: 0;
    }
}
