/* Base del panel y del portal: estructura, formularios y componentes comunes.
   Orden de carga en index.html: style → assistant, setup, practice, accounts → ui-motion → nuria/brand
   → nuria/polish → records, team, hub → motion → theme, que va la última y fija los tokens y el aspecto final. */
:root {
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
}
* { box-sizing: border-box; }
body { margin: 0; }
button, input, textarea, select { font: inherit; }
button, a, input, textarea, select, summary { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { opacity: .45; cursor: not-allowed; }
input:focus, textarea:focus, select:focus { outline-offset: 1px; }
[hidden], button[hidden] { display: none !important; }
input, textarea, select {
  width: 100%; min-width: 0; min-height: 44px; padding: 11px 13px;
  color: var(--ink); background: #fff; border: 1px solid #dedee4;
}
textarea { resize: vertical; line-height: 1.6; }
input::placeholder, textarea::placeholder { color: #6b6b74; }
input[type="checkbox"] { min-height: auto; }
input[type="file"] { max-width: 100%; }
h1, h2, h3, h4, p { margin: 0; }
h2, h3 { font-size: 19px; line-height: 1.3; }
h4 { font-size: 14px; line-height: 1.5; }
svg { width: 24px; height: 24px; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.app-shell { display: grid; grid-template-columns: 212px minmax(0, 1fr); min-height: 100dvh; }
.app-shell:has(#navigation[hidden]) { grid-template-columns: minmax(0, 1fr); }
.sidebar {
  position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; padding: 36px 16px 25px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; font-size: 21px; font-weight: 700; letter-spacing: -.6px; }
.brand-mark { display: grid; place-items: center; width: 39px; height: 39px; border-radius: 12px; color: white; background: var(--blue); }
.brand-mark svg { width: 25px; height: 25px; }
.brand-caption { display: block; margin-top: 4px; color: var(--muted); font-weight: 400; letter-spacing: 0; }
.sidebar-nav { display: flex; flex-direction: column; gap: 7px; margin-top: 42px; }
.nav-item { display: flex; align-items: center; gap: 11px; width: 100%; padding: 11px 14px; border: 0; border-radius: 12px; text-align: left; font-size: 14px; font-weight: 500; }
.nav-item svg { width: 22px; height: 22px; }
.nav-item[aria-current="page"] { font-weight: 600; }
.nav-badge { display: inline-grid; place-items: center; min-width: 21px; height: 21px; margin-left: auto; padding: 0 5px; border-radius: 7px; font-size: 11px; }
.sidebar-bottom { display: flex; align-items: center; gap: 10px; margin-top: auto; padding: 20px 10px 0; font-size: 11px; line-height: 1.6; }
.sidebar-bottom svg { width: 17px; height: 17px; }
main { width: 100%; min-width: 0; max-width: 1600px; padding: 0 36px; margin: 0 auto; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 68px; border-bottom: 1px solid var(--border); }
.topbar-context { min-width: 0; }

.topbar-right { display: flex; align-items: center; justify-content: flex-end; gap: 10px; min-width: 0; }
.session-identity { color: var(--muted); max-width: 160px; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }
.connection-pill { display: inline-flex; align-items: center; gap: 6px; max-width: 250px; line-height: 1.5; color: var(--muted); }
.connection-pill::before { content: ""; width: 6px; height: 6px; flex-shrink: 0; background: #a8a8ad; border-radius: 50%; }
.connection-pill.connected::before { background: #30a46c; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; }
.muted { color: var(--muted); line-height: 1.6; }
.timezone { color: var(--muted); white-space: nowrap; padding-bottom: 2px; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 10px 16px; border: 1px solid transparent; background: #f0f0f5; color: #0069db; font-size: 13px; line-height: 1.4; text-align: center; white-space: normal; transition: background .15s ease, box-shadow .15s ease; }
.button.small { padding: 8px 11px; }
.button.danger:hover:not(:disabled) { background: #ffe4e5; }
.button.quiet-button { min-height: 36px; color: var(--muted); background: transparent; padding: 7px 9px; }
.button.icon-button { width: 36px; min-height: 36px; padding: 8px; background: transparent; color: #64646b; }
.button.icon-button svg { width: 19px; height: 19px; }
.button.icon-button:hover:not(:disabled) { background: #eaeaf0; }
.access-card { width: min(100%, 430px); margin: 34px auto 70px; padding: 35px; background: white; text-align: center; box-shadow: 0 7px 35px #1d1d1f05; }
.access-icon { width: 62px; height: 62px; border-radius: 20px; place-items: center; color: var(--blue); background: #eef5ff; margin: 0 auto 21px; }
.access-icon svg { width: 29px; height: 29px; stroke-width: 1.7; }
.access-card h2 { margin-bottom: 10px; }
.access-card .muted { max-width: 285px; margin: 0 auto; }
.access-form { display: flex; flex-direction: column; gap: 11px; margin: 26px 0 18px; }
.access-form input { min-height: 48px; }
.notice { padding: 14px 17px; border: 1px solid #d6eadd; margin: 0 0 20px; font-size: 13px; line-height: 1.6; overflow-wrap: anywhere; }
.notice.error { border-color: #f8d9d3; }
.attention-summary { flex-wrap: wrap; gap: 6px; }
.summary-filter { display: flex; align-items: center; gap: 10px; border: 1px solid transparent; border-radius: 10px; color: #52525b; background: transparent; text-align: left; }
.summary-filter span { font-size: 13px; font-weight: 500; }
.summary-filter strong { min-width: 22px; padding: 3px 6px; background: #e8e8ed; font-size: 12px; font-weight: 600; line-height: 1.3; font-variant-numeric: tabular-nums; text-align: center; }
.summary-filter:hover { border-color: #bed8ff; }
.workspace { display: grid; grid-template-columns: 320px minmax(0, 1fr); align-items: start; min-height: 520px; border: 1px solid var(--border); border-radius: var(--radius); background: white; }
.patient-list-panel { align-self: start; min-width: 0; padding: 23px 14px 16px; }
.list-heading { display: flex; align-items: center; justify-content: space-between; padding: 0 8px; margin-bottom: 17px; }
.list-heading h2 { font-size: 16px; letter-spacing: -.3px; }
.count-badge { min-width: 24px; padding: 4px 7px; background: #f1f1f5; border-radius: 8px; font-size: 11px; text-align: center; }
.patient-filters { display: grid; gap: 8px; padding: 0 6px; }
.search-field { display: flex; position: relative; align-items: center; margin-bottom: 9px; }
.search-field svg { position: absolute; left: 11px; width: 17px; height: 17px; color: #8b8b93; }
.search-field input { min-height: 40px; padding: 10px 10px 10px 35px; border-radius: 10px; }
.patient-list-panel select { background: #fff; color: #6f6f77; min-height: 37px; padding: 8px 10px; border-color: #ededf2; }
.patient-list { margin-top: 18px; max-height: min(760px, calc(100dvh - 290px)); min-height: 80px; overflow: auto; }
.list-empty { padding: 22px 10px; font-size: 13px; color: var(--muted); line-height: 1.65; }
.patient-item { display: flex; gap: 11px; align-items: flex-start; width: 100%; padding: 14px 10px; border: 1px solid transparent; background: transparent; color: var(--ink); text-align: left; margin-bottom: 5px; }
.patient-item:hover { background: #f6f7fa; }
.avatar { display: grid; place-items: center; flex-shrink: 0; width: 38px; height: 38px; border-radius: 50%; font-size: 12px; font-weight: 600; text-transform: uppercase; }
.patient-info { flex: 1; min-width: 0; }
.patient-info strong { display: block; overflow-wrap: anywhere; font-weight: 600; line-height: 1.5; }
.patient-info small { display: block; margin-top: 4px; color: var(--muted); line-height: 1.5; }
.patient-meta { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.tag { display: inline-flex; align-items: center; padding: 4px 7px; background: #f0f1f5; color: #65656d; font-weight: 500; line-height: 1.4; }
.tag.ready { color: #23704d; background: #e8f5ec; }
.tag.warning { color: #8a5c12; background: #fff5df; }
.tag.danger { color: #ac383e; background: #ffebec; }
.patient-meta .tag { padding: 3px 6px; }
.patient-detail-area { min-width: 0; min-height: 520px; border-left: 1px solid var(--border); }
.patient-detail-panel { min-width: 0; }
.back-button { display: none; }
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 520px; padding: 40px 24px; }
.empty-state p { color: var(--muted); font-size: 13px; line-height: 1.8; max-width: 330px; margin-top: 10px; }
.detail-header { padding: 28px 28px 0; }
.detail-name-row { display: flex; align-items: center; gap: 14px; }
.detail-name-row .avatar { width: 48px; height: 48px; font-size: 16px; }
.detail-name-row > div { min-width: 0; }
.detail-name-row h3 { font-size: 24px; letter-spacing: -.8px; font-weight: 650; overflow-wrap: anywhere; }
.detail-name-row p { margin-top: 5px; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.detail-tags { display: flex; gap: 6px; flex-wrap: wrap; margin: 17px 0 21px; }
.tabs { display: flex; }
.tab { flex: 1; min-width: 0; border: 0; background: transparent; font-size: 13px; font-weight: 500; padding: 8px 12px; text-align: center; }
.tab.active { font-weight: 600; box-shadow: 0 1px 5px #00000014, 0 0 1px #0000001a; }
.tab-panel { padding: 26px 28px 30px; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 15px; }
.section-title h4 { font-size: 14px; font-weight: 650; }
.profile-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 19px 25px; margin: 0; }
.profile-field { min-width: 0; }
.profile-field-wide { grid-column: 1 / -1; }
.profile-field dt { color: var(--muted); font-size: 11px; margin-bottom: 6px; }
.profile-field dd { margin: 0; font-size: 14px; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; }
.detail-section + .detail-section { margin-top: 25px; padding-top: 24px; border-top: 1px solid var(--border); }
.section-empty { color: var(--muted); font-size: 13px; line-height: 1.65; }
#patient-heading { scroll-margin-top: 24px; }
#patient-heading:focus-visible { outline: 2px solid #8fbfff; outline-offset: 6px; border-radius: 3px; }
.patient-essentials { padding: 0 0 6px; }
.patient-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 15px 0 20px; }
.patient-service-state { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 14px; padding: 15px; margin: 0 0 22px; font-size: 12px; line-height: 1.65; }
.patient-service-state strong { font-size: 13px; font-weight: 600; }
.patient-service-state .help-text { margin-top: 3px; }
.patient-service-state .patient-actions { margin: 0; }
.patient-delivery-notice { flex-basis: 100%; margin: 0; }
.patient-privacy { margin-top: 18px; }
.patient-essentials > .action-disclosure[open] { padding-bottom: 16px; }
.patient-group { border: 0; border-top: 1px solid var(--border); margin: 16px 0 0; background: white; }
.patient-group > summary { display: flex; align-items: center; justify-content: space-between; gap: 14px; list-style: none; padding: 18px 0; font-weight: 600; font-size: 14px; cursor: pointer; }
.patient-group > summary::-webkit-details-marker { display: none; }
.patient-group > summary::after { content: ""; width: 7px; height: 7px; flex-shrink: 0; border-right: 1.7px solid #a0a0a8; border-bottom: 1.7px solid #a0a0a8; transform: rotate(-45deg); margin-right: 2px; }
.patient-group[open] > summary::after { transform: rotate(45deg); }
.patient-group-content { padding: 0 0 20px; }
.patient-group-content > .detail-section:first-child { padding-top: 4px; }
.appointment-card { padding: 16px 0; margin: 12px 0; border-bottom: 1px solid var(--border); }
.appointment-card > .appointment-row { padding-top: 0; }
.appointment-options { margin-top: 10px; }
.appointment-actions { margin: 8px 0 20px; }
.document-row, .appointment-row, .outbox-row, .order-row { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; padding: 14px 0; border-bottom: 1px solid #efeff3; }
.document-row:last-child, .appointment-row:last-child, .outbox-row:last-child, .order-row:last-child { border-bottom: 0; }
.appointment-row { align-items: flex-start; }
.row-text { min-width: 0; }
.row-text strong { display: block; font-size: 13px; font-weight: 500; line-height: 1.55; overflow-wrap: anywhere; }
.row-text small { display: block; color: var(--muted); line-height: 1.65; margin-top: 4px; overflow-wrap: anywhere; }
.appointment-row .row-text small, .coordination-card .row-text small { white-space: pre-line; }
.row-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; max-width: 100%; min-width: 0; }
.action-disclosure { border: 1px solid var(--border); border-radius: 12px; margin-top: 13px; padding: 0 14px; background: #fcfcfd; }
.action-disclosure > summary { padding: 14px 0; cursor: pointer; font-size: 13px; font-weight: 500; line-height: 1.5; color: #52647f; }
.action-disclosure[open] > summary { margin-bottom: 4px; }
.action-disclosure form { padding-bottom: 17px; }
.outbox-history .outbox-row { margin: 0 12px; padding: 16px 0; }
.form-field { margin-bottom: 15px; min-width: 0; }
.form-field label { display: block; font-weight: 500; line-height: 1.5; margin-bottom: 7px; }
.form-field small, .help-text { display: block; color: var(--muted); font-size: 11px; line-height: 1.7; margin-top: 7px; }
.checkbox-field { display: flex; align-items: flex-start; gap: 9px; line-height: 1.65; margin: 10px 0 16px; cursor: pointer; }
.checkbox-field input { width: 17px; min-width: 17px; height: 17px; margin: 2px 0 0; accent-color: var(--blue); }
.inline-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.action-explanation { line-height: 1.7; color: var(--muted); margin: 10px 0 16px; }
.messages { display: flex; flex-direction: column; gap: 16px; padding: 4px 0 22px; max-height: 510px; overflow: auto; }
.message { align-self: flex-start; max-width: 87%; padding: 13px 16px; background: #f0f0f4; }
.message.outgoing { align-self: flex-end; border-radius: 18px 18px 5px 18px; }
.message strong { display: block; color: #797981; font-weight: 600; margin-bottom: 6px; }
.message.outgoing strong { color: #5e7c9f; }
.message p { white-space: pre-wrap; overflow-wrap: anywhere; }
.message time { display: block; color: #7d7d85; margin-top: 8px; }
.message > .tag { margin-top: 8px; }
.reply-form { padding-top: 20px; border-top: 1px solid var(--border); }
.reply-form .form-field { margin-bottom: 11px; }
.reply-form textarea { background: #fafafd; border-radius: 14px; }
.reply-footer { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
.reply-footer p { color: var(--muted); line-height: 1.6; }
.detail-updates { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 15px; padding: 12px 16px; border: 1px solid #f1e3bd; border-radius: 13px; color: #866627; background: #fff9ed; font-size: 12px; line-height: 1.5; }
.task-board { padding: 24px; border: 1px solid var(--border); border-radius: var(--radius); background: white; margin-bottom: 20px; }
.task-board-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.task-board-heading h2, .task-board-heading h3 { margin-bottom: 6px; font-size: 19px; }
.task-filters { display: flex; gap: 8px; width: min(100%, 420px); }
.task-filters input, .task-filters select { font-size: 12px; background: #fbfbfd; }
.task-list { min-width: 0; }
.task-list > .section-empty { padding: 27px 0; }
.task-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; padding: 20px 0; border-bottom: 1px solid var(--border); }
.task-row:last-child { border: 0; }
.task-info { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; min-width: 0; }
.task-info > strong { font-size: 14px; font-weight: 500; line-height: 1.6; overflow-wrap: anywhere; }
.task-info > small { color: var(--muted); font-size: 11px; }
.button.task-patient { min-height: 24px; font-size: 13px; color: #0069d9; padding: 0; background: transparent; text-align: left; justify-content: flex-start; }
.button.task-patient:hover { text-decoration: underline; }
.task-actions { display: flex; align-items: center; gap: 12px; }
.task-edit { grid-column: 1 / -1; margin-top: 2px; }
.task-edit > summary { width: fit-content; color: #777781; cursor: pointer; font-size: 12px; padding: 6px 0; }
.task-controls { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: end; gap: 12px; max-width: 590px; margin-top: 13px; }
.task-controls > *, .coordination-form > *, .coordination-grid > *, .coordination-schedule-day > * { min-width: 0; }
.task-controls .form-field { margin: 0; }
.task-controls .form-field label { font-size: 11px; }
.task-controls > button { justify-self: start; }
.task-controls input, .task-controls select { font-size: 13px; }
.inbox-errors { background: #fff; border: 1px solid #f1dcdc; border-radius: var(--radius); padding: 23px; margin-bottom: 20px; }
.inbox-errors > h2, .inbox-errors > h3 { margin-bottom: 6px; }
.settings-view { max-width: 1040px; }
.service-card { display: flex; align-items: center; flex-wrap: wrap; gap: 15px; padding: 24px; border: 1px solid var(--border); border-radius: var(--radius); background: white; margin-bottom: 20px; }
.service-heading { display: flex; gap: 12px; align-items: center; }
.service-heading h2 { font-size: 16px; margin-bottom: 5px; }
.service-heading p { color: var(--muted); font-size: 12px; line-height: 1.6; }
.status-dot { width: 10px; height: 10px; flex-shrink: 0; border-radius: 50%; background: #31a46c; box-shadow: 0 0 0 5px #eff8f2; margin: 0 3px; }
.service-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-left: auto; }
.blockers { flex-basis: 100%; color: #976a27; font-size: 12px; line-height: 1.8; padding-left: 17px; margin: 0; }
.clinic-card { background: white; border: 1px solid var(--border); border-radius: 18px; margin-bottom: 14px; overflow: hidden; }
.clinic-card > summary { display: flex; justify-content: space-between; align-items: center; gap: 18px; padding: 21px 23px; cursor: pointer; list-style: none; }
.clinic-card > summary::-webkit-details-marker { display: none; }
.clinic-card summary strong { font-size: 14px; font-weight: 550; line-height: 1.5; }
.summary-description { display: block; color: var(--muted); font-size: 11px; line-height: 1.6; margin-top: 4px; }
.disclosure-chevron, .coordination-card > summary > span:last-child { font-size: 0; width: 8px; height: 8px; flex-shrink: 0; border-right: 1.6px solid #aaaab1; border-bottom: 1.6px solid #aaaab1; transform: rotate(-45deg); margin-right: 3px; }
.clinic-card[open] > summary .disclosure-chevron, .coordination-card[open] > summary > span:last-child { transform: rotate(45deg); }
.clinic-content { padding: 0 23px 23px; }
.clinic-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 25px; margin: 5px 0 20px; }
.clinic-content > .help-text { max-width: 710px; }
.maintenance { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 17px; border: 1px solid var(--border); border-radius: 18px; background: white; padding: 23px; margin: 18px 0; }
.maintenance h2, .maintenance h3 { font-size: 15px; }
.maintenance .help-text { margin-top: 5px; }
.maintenance > .action-disclosure { width: 100%; margin-top: 0; }
.clinic-days-list { margin-top: 17px; }
.support-card { margin-top: 18px; }
.service-health { padding: 15px 0; border-top: 1px solid var(--border); }
.service-health > summary { color: #626c7d; cursor: pointer; font-size: 13px; line-height: 1.5; }
.service-health:last-child { padding-bottom: 0; }
.health-component-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; padding: 13px 0; border-bottom: 1px solid var(--border); }
.health-component-row:last-child { border-bottom: 0; }
.health-component-row .row-text small { white-space: pre-line; }
.deletion-preview { margin-top: 18px; }
.deletion-preview:empty { display: none; }
.deletion-preview h4 { margin-bottom: 17px; }
.deletion-preview form { margin-top: 18px; }
.deletion-preview > .help-text { margin-top: 14px; }
.coordination { margin: 20px 0; }
.coordination > .help-text { margin: 10px 0 18px; }
.coordination-alerts { padding: 14px 17px; margin-bottom: 17px; font-size: 12px; line-height: 1.7; }
.coordination-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin: 18px 0; min-width: 0; }
.coordination-form > .form-field { margin: 0; }
.coordination-form > button, .coordination-form > .checkbox-field, .coordination-form > .coordination-days, .coordination-form > .coordination-history, .coordination-alternatives { grid-column: 1 / -1; }
.coordination-form > button { justify-self: start; }
.coordination-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; min-width: 0; }
.coordination-preview:not(:empty) { background: #f4f8fe; border: 1px solid #dfe9f9; border-radius: 14px; padding: 20px; margin: 18px 0; }
.coordination-preview h4 { margin-bottom: 12px; }
.coordination-preview p { font-size: 12px; line-height: 1.7; white-space: pre-line; margin: 8px 0; }
.coordination-preview .button { margin-top: 13px; }
.coordination-list { margin-top: 17px; }
.coordination-entry { padding: 19px 0; border-top: 1px solid var(--border); }
.coordination-entry .coordination-form { max-width: 650px; }
.coordination-history { padding: 14px; margin: 13px 0; border: 1px solid var(--border); border-radius: 12px; overflow-wrap: anywhere; }
.coordination-history > summary { font-size: 12px; cursor: pointer; line-height: 1.7; }
.coordination-history .help-text, .coordination-history .form-field { margin-top: 12px; }
.coordination-history .row-text small { white-space: pre-wrap; }
.coordination-days { display: flex; flex-wrap: wrap; gap: 15px; }
.coordination-summary { border-left: 1px solid #c9dcfa; padding-left: 12px; font-size: 12px; line-height: 1.7; white-space: pre-line; }
.coordination-schedule { border: 1px solid var(--border); padding: 15px; margin: 16px 0; border-radius: 12px; min-width: 0; }
.coordination-schedule legend { font-size: 12px; color: var(--muted); padding: 0 7px; }
.coordination-schedule-day { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; align-items: center; min-width: 0; }
.coordination-schedule-day .form-field { margin: 6px 0; }
.coordination-schedule-day .form-field label { font-size: 11px; }
.metrics-group { margin-top: 20px; }
.metrics-group h4 { font-size: 12px; margin-bottom: 12px; }
.metrics-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.metric-card { border: 1px solid var(--border); border-radius: 12px; padding: 15px; background: #fafafd; text-align: left; color: inherit; }
.metric-card span { display: block; font-size: 11px; line-height: 1.55; }
.metric-card strong { display: block; font-size: 26px; letter-spacing: -.65px; font-weight: 600; margin-top: 9px; }
.metric-card:hover { background: #f1f6ff; border-color: #cddff8; }
.coordination-metrics > .help-text, .metrics-group > .help-text { margin: 13px 0; }
.page-footer { display: flex; justify-content: center; padding: 26px 0; font-size: 10px; line-height: 1.6; }
.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 (min-width: 1500px) {
  main { padding: 0 48px; }
  .workspace { grid-template-columns: 300px minmax(0, 1fr); }
}
@media (max-width: 1100px) {
  .app-shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: sticky; top: 0; z-index: 25; height: auto; padding: 14px 26px; flex-direction: row; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); gap: 20px; }
  .brand { font-size: 20px; padding: 0; }
  .brand-mark { width: 35px; height: 35px; border-radius: 11px; }
  .sidebar-nav { flex-direction: row; gap: 4px; margin: 0; }
  .nav-item { width: auto; padding: 10px 13px; gap: 7px; font-size: 12px; }
  .nav-item svg { width: 19px; height: 19px; }
  .sidebar-bottom { display: none; }
  main { padding: 0 27px; }
  .topbar { min-height: 77px; }
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .patient-list-panel { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 0 25px; padding: 21px 24px 17px; }
  .list-heading { margin-bottom: 0; padding: 0; }
  .patient-filters { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; padding: 0; }
  .search-field { margin: 0; }
  .patient-list-panel select { min-height: 40px; }
  .patient-list { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px 13px; margin-top: 17px; max-height: 220px; min-height: 0; }
  .patient-list > .list-empty { grid-column: 1 / -1; padding: 14px 0; }
  .patient-item { margin: 0; }
  .patient-detail-area { border-left: 0; border-top: 1px solid var(--border); min-height: 350px; }
  .empty-state { min-height: 350px; }
  .detail-header { padding: 26px 27px 0; }
  .tab-panel { padding: 25px 27px; }
  .task-board-heading { flex-direction: column; gap: 16px; }
  .task-filters { max-width: 600px; width: 100%; }
}
@media (max-width: 700px) {
  body { padding-bottom: env(safe-area-inset-bottom); }
  body:has(#navigation:not([hidden])) { padding-bottom: calc(83px + env(safe-area-inset-bottom)); }
  .sidebar { position: fixed; z-index: 30; top: auto; bottom: 0; left: 0; right: 0; height: auto; padding: 8px 17px calc(9px + env(safe-area-inset-bottom)); border: 0; }
  .sidebar .brand { display: none; }
  .sidebar-nav { display: grid; width: 100%; }
  .nav-item { position: relative; flex-direction: column; justify-content: center; gap: 5px; border-radius: 12px; }
  .nav-item svg { width: 23px; height: 23px; }
  .nav-badge { position: absolute; top: 1px; left: calc(50% + 8px); margin: 0; height: 17px; min-width: 17px; font-size: 9px; border-radius: 9px; }
  main { padding: 0 18px; }
  .topbar { gap: 9px; }

  .topbar-context p { max-width: 150px; overflow-wrap: anywhere; }
  .topbar-right { gap: 4px; }
  .session-identity { display: none; }
  .connection-pill { max-width: 93px; }
  .button.icon-button { width: 31px; padding: 6px; }
  .button.quiet-button { padding: 6px; }
  .timezone { display: none; }
  .attention-summary { gap: 8px; }
  .summary-filter { justify-content: space-between; }
  .summary-filter span { font-size: 12px; }

  .workspace { min-height: 0; border-radius: var(--radius); }
  .patient-list-panel { display: block; padding: 20px 14px; }
  .list-heading { margin: 0 6px 15px; }
  .patient-filters { display: grid; grid-template-columns: minmax(0, 1fr); gap: 9px; padding: 0 5px; }
  .search-field input, .patient-list-panel select { min-height: 43px; }
  .patient-list-panel select { background: #fafafd; }
  .patient-list { display: flex; flex-direction: column; gap: 4px; max-height: none; margin-top: 13px; }
  .patient-list > .list-empty { padding: 20px 7px; }
  .patient-item { padding: 16px 10px; }
  .patient-detail-area { display: none; }
  body.patient-open #attention-summary { display: none; }
  body.patient-open .patient-list-panel { display: none; }
  body.patient-open .patient-detail-area { display: block; border: 0; min-height: 0; }
  body.patient-open .back-button { display: inline-flex; gap: 2px; color: var(--blue); min-height: 44px; font-weight: 500; }
  .back-button svg { width: 21px; height: 21px; }
  .detail-header { padding: 15px 19px 0; }
  .detail-name-row { gap: 11px; }
  .detail-name-row h3 { font-size: 24px; }
  .detail-name-row .avatar { width: 43px; height: 43px; font-size: 14px; }
  .detail-name-row p { font-size: 11px; }
  .detail-tags { margin: 15px 0 18px; }
  .tab-panel { padding: 22px 19px 24px; }
  .tab { font-size: 13px; }
  .profile-grid, .clinic-grid { grid-template-columns: minmax(0, 1fr); gap: 19px; }
  .patient-group > summary { padding: 18px 0; font-size: 14px; }
  .patient-group-content { padding: 0 0 17px; }
  .patient-actions { gap: 7px; }
  .patient-actions .button { flex: 1 1 auto; }
  .appointment-card { padding: 12px 0; }
  .appointment-row, .document-row, .outbox-row, .order-row { align-items: flex-start; }
  .action-disclosure { padding: 0 12px; }
  .outbox-history .outbox-row { margin: 0; }
  .form-field input, .form-field textarea, .form-field select, .access-form input { font-size: 16px; }
  .message { max-width: 93%; padding: 12px 14px; }
  .reply-footer { flex-direction: column; align-items: stretch; }
  .reply-footer .button { align-self: flex-end; }
  .task-board, .service-card, .inbox-errors { padding: 20px; border-radius: 19px; }
  .task-filters { flex-direction: column; }
  .task-row { grid-template-columns: minmax(0, 1fr); gap: 13px; }
  .task-actions { justify-content: flex-start; }
  .task-controls { grid-template-columns: minmax(0, 1fr); }
  .task-controls input, .task-controls select { font-size: 16px; }
  .detail-updates { align-items: flex-start; flex-direction: column; }
  .service-card { gap: 17px; }
  .service-tags { margin-left: 0; }
  .clinic-card > summary { padding: 19px; }
  .clinic-content { padding: 0 19px 20px; }
  .clinic-card summary strong { font-size: 14px; }
  .maintenance { padding: 20px; }
  .health-component-row { gap: 10px; flex-wrap: wrap; }
  .coordination-form, .coordination-grid { grid-template-columns: minmax(0, 1fr); }
  .coordination-schedule { padding: 11px; }
  .coordination-schedule-day { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .coordination-schedule-day > .checkbox-field { grid-column: 1 / -1; margin-bottom: 0; }
  .coordination-schedule input { padding: 9px; }
  .metrics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .access-card { padding: 29px 24px; margin: 18px auto 45px; }
  .page-footer { padding: 25px 0 14px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; }
}

@media (max-width: 700px) {
  body.patient-open[data-active-view="patients"] .page-heading { display: none; }
  body.patient-open[data-active-view="patients"] #workspace-content { padding-top: 18px; }
  body:not(.patient-open) #detail-updates { display: none; }
}

@media (min-width: 701px) and (max-width: 1100px) {
  #patient-heading, #page-title { scroll-margin-top: 95px; }
}
@media (max-width: 700px) {
  .patient-filters input, .patient-filters select, .task-filters input, .task-filters select { font-size: 16px; }
}

.status-dot[data-state="inactive"] { background: #8e8e93; box-shadow: 0 0 0 4px #8e8e9312; }
.status-dot[data-state="warning"] { background: #d68a05; box-shadow: 0 0 0 4px #d68a0512; }

/* Everyday coordination: clear hierarchy, readable labels and drafts kept in context. */
.heading-status { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: flex-end; }
.draft-indicator { color: #86520c; background: #fff1d6; border-radius: 8px; padding: 5px 9px; font-size: 13px; }

#notice, .task-undo { display: flex; align-items: center; justify-content: space-between; gap: 15px; }
#notice > span { flex: 1; }
.form-error { width: 100%; margin: 10px 0 0; padding: 10px 12px; color: #a1312c; background: #fff0ed; border-radius: 9px; font-size: 14px; line-height: 1.6; }
.help-text, .action-explanation, .muted, .form-field label, .checkbox-field, .button.small, .button.quiet-button, .patient-info small, .patient-list-panel select, .search-field input, .tag, .session-identity, .connection-pill, .access-card > .help-text { font-size: 13px; }
.message-preview { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; color: #494950; font-size: 13px; line-height: 1.5; margin-top: 8px; overflow-wrap: anywhere; }
.patient-time { display: block; color: #68686e; margin-top: 5px; }
.pagination { display: flex; gap: 8px; justify-content: center; margin-top: 15px; }
.task-assignee { color: #55555d; font-size: 13px; }
.task-actions { flex-wrap: wrap; }
.agenda-board { border: 1px solid var(--border); border-radius: var(--radius); background: #fff; padding: 24px; margin-bottom: 22px; }
.agenda-heading { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 14px; }
.agenda-heading h2 { margin-bottom: 6px; }
.agenda-controls { display: flex; align-items: center; flex-wrap: wrap; }
.agenda-controls input { width: 162px; min-height: 38px; font-size: 13px; }
.agenda-group-heading { font-size: 15px; margin: 22px 0 8px; line-height: 1.6; }
.agenda-row { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 14px 0; border-top: 1px solid #f0f0f4; }
.agenda-row .row-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.appointment-review { background: #f4f7fb; padding: 13px; border-radius: 12px; line-height: 1.7; font-size: 14px; }
.appointment-review p + p { margin-top: 7px; }
.conversation-context { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; padding: 18px 24px; background: #f7faff; border-bottom: 1px solid #e5edf8; }
.conversation-context > div:first-child { flex: 1; min-width: 180px; }
.conversation-context strong { font-size: 14px; }
.family-warning { flex-basis: 100%; border-radius: 10px; padding: 12px; color: #855014; background: #fff3db; line-height: 1.6; }
.family-warning .button { margin-top: 9px; }
.messages { scroll-behavior: auto; overflow-anchor: none; }
.message p { font-size: 15px; line-height: 1.65; }
.message strong, .message time { font-size: 13px; }
.message-delivery-review { color: var(--ink); background: #fff; border-radius: 12px; margin-top: 12px; }
.message-delivery-review .detail-section { padding: 14px; }
.new-messages-button { display: flex; margin: 0 auto 15px; }
.reply-form > .form-field:first-child { max-width: 360px; }
.reply-form textarea { font-size: 16px; }
.reply-form .checkbox-field { margin: 12px 0; }
.coordination-offer-summary { padding: 13px; border: 1px solid #dce7f5; border-radius: 11px; background: #f7faff; }
@media (max-width: 1000px) {
  .agenda-heading { align-items: flex-start; flex-direction: column; }
}
@media (max-width: 620px) {
  .heading-status { align-items: flex-end; flex-direction: column; gap: 6px; }
  .draft-indicator { font-size: 12px; }

  .agenda-board { padding: 18px 16px; }
  .agenda-controls { width: 100%; }
  .agenda-controls input { flex: 1; min-width: 130px; }
  .agenda-row { align-items: flex-start; flex-direction: column; gap: 10px; }
  .conversation-context { padding: 16px; }
  .conversation-context > .button { width: 100%; }
  .reply-form > .form-field:first-child { max-width: none; }
  .task-actions .button { flex: 1 1 140px; }
}

.patient-time, .timezone, .reply-footer p, .row-text small { font-size: 13px; }

.patient-filters .ts-wrapper { flex: 1; min-width: 0; width: 100%; }
.patient-filters .ts-control { border: 1px solid #d7dbe3; border-radius: 10px; padding: 12px; min-height: 44px; background: white; box-shadow: none; font-size: 14px; }
.patient-filters .ts-dropdown { border-radius: 12px; border: 1px solid #dde4ec; box-shadow: 0 12px 30px #20304020; overflow: hidden; min-width:min(320px, calc(100vw - 50px)); left:auto; right:0; }
.patient-suggestion { padding: 10px !important; }
.patient-suggestion > strong, .patient-suggestion > span { display: block; }
.patient-suggestion > span { font-size: .75rem; color: #5a6b7e; margin-top: 4px; }

.intake-review-field { display:grid; gap:4px; padding:10px 0; border-bottom:1px solid #e7ecf2; }
.intake-review-field strong { font-size:.82rem; text-transform:capitalize; }
.intake-review-field small { color:#58697c; }
.intake-missing { color:#89601c; }
.document-search-results { display:grid; gap:8px; margin-top:10px; }
.document-search-result { padding:12px; border-radius:12px; background:#f1f5fa; overflow-wrap:anywhere; }
.document-search-result p { white-space:pre-wrap; font-size:.82rem; margin:5px 0 0; }

/* Task-first refinements: shared controls and recoverable search states. */
.skip-link { position: fixed; z-index: 100; top: 8px; left: 12px; padding: 12px 16px; background: white; border: 2px solid var(--blue); border-radius: 8px; transform: translateY(-180%); }
.skip-link:focus { transform: translateY(0); }
.topbar-context p { margin-top: 0; font-size: 14px; }
.list-empty strong { display: block; color: var(--ink); margin-bottom: 8px; }
.list-empty p { margin-bottom: 12px; }
.patient-search-label { font-size: 12px; font-weight: 600; }
.search-hint { font-size: 12px; line-height: 1.5; color: var(--muted); margin: 0 0 2px; }
.clear-filters { justify-self: start; text-decoration: underline; text-underline-offset: 3px; }
.patient-filters .ts-control input { font-size: inherit; }
.patient-filters .ts-wrapper.focus .ts-control { border-color: var(--blue); outline: 3px solid #b5d8ff; outline-offset: 1px; }
.section-links { margin: 0 0 16px; }
.section-links a { display: inline-flex; align-items: center; font-weight: 500; }
.section-links a:hover { background: #e9ebf0; }
#agenda-board, #followup-board, #task-board { scroll-margin-top: 24px; }
.agenda-controls [aria-pressed="true"] { color: #0056b5; background: #e4efff; }
.patient-service-state { background: #f5f7fa; border: 0; border-radius: 10px; color: #344357; }
.patient-service-state .help-text { color: #526174; }
.page-footer { color: var(--muted); padding-bottom: 96px; }
@media (min-width: 701px) and (max-width: 1100px) {
  #agenda-board, #followup-board, #task-board { scroll-margin-top: 94px; }
}
@media (max-width: 700px) {
  .topbar { min-height: 64px; }
  .patient-filters .ts-control input { font-size: 16px; }
  .patient-filters .ts-dropdown { min-width: 0; width: 100%; }
  .page-footer { padding-bottom: 88px; }
  #patient-heading { scroll-margin-top: 76px; }
  body.patient-open .back-button { position: sticky; z-index: 2; padding: 10px 14px; margin: 0; width: 100%; justify-content: flex-start; border-radius: 16px 16px 0 0; background: white; }
}
