* { box-sizing: border-box; }
:root { font: 16px/1.5 system-ui, sans-serif; color: #222d38; background: #f2f6f8; --teal: #006e65; --graphite: #252e38; --line: #d4dee4; }
body { margin: 0; display: grid; grid-template-columns: 175px minmax(0,1fr); min-height: 100vh; grid-template-rows: auto 1fr; }
header { grid-column: 1/-1; display: flex; align-items: center; gap: 14px; padding: 14px 24px; background: var(--graphite); color: white; border-bottom: 1px solid #42505c; }
header b { display: block; font-size: 1.3rem; line-height: 1; }
.mark { color: #46d3bf; font-size: 2.3rem; line-height: 1; }
.environment { margin-left: auto; font-size: .85rem; color: #d6e3e7; }
aside { background: var(--graphite); color: #e4ebef; padding: 18px 10px; display: flex; flex-direction: column; gap: 8px; }
aside > * { padding: 9px 12px; border-radius: 6px; }
aside strong, li[aria-current] { background: var(--teal); color: white; }
main { padding: clamp(16px,3vw,38px); }
h1 { font-size: 2.3rem; margin: 0 0 18px; letter-spacing: -.04em; }
h2 { margin: 0 0 18px; font-size: 1.25rem; }
h3 { margin: 0 0 8px; }
ol { margin: 0 0 20px; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(6,1fr); gap: 5px; }
li { display: grid; align-content: center; text-align: center; padding: 10px 6px; font-weight: 650; background: #e4eef0; border-radius: 6px; }
small { font-weight: 400; }
.columns { display: grid; grid-template-columns: minmax(290px, 2fr) minmax(0,3fr); gap: 16px; align-items: start; }
section { padding: 20px; background: white; border: 1px solid var(--line); border-radius: 10px; }
label { display: block; font-weight: 600; }
input, select, button { font: inherit; border-radius: 6px; min-height: 44px; }
input, select { width: 100%; padding: 8px; border: 1px solid #869aa7; }
button { border: 0; background: var(--teal); color: white; padding: 8px 14px; font-weight: 650; cursor: pointer; }
button:disabled { opacity: .6; cursor: default; }
:focus-visible { outline: 3px solid #007eae; outline-offset: 3px; }
.search-row { display: flex; gap: 8px; margin-top: 6px; }
.search-row button { flex-shrink: 0; }
#profile, #register { border-top: 1px solid var(--line); padding-top: 16px; }
#register label { margin-bottom: 12px; }
.table { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th, td { text-align: left; padding: 10px; border-bottom: 1px solid var(--line); }
th { background: #e8eff3; }
td:last-child { color: var(--teal); font-weight: 650; }
@media (max-width: 1040px) { .columns { grid-template-columns: 1fr; } ol { grid-template-columns: repeat(3,1fr); } }
@media (max-width: 600px) { body { grid-template-columns: minmax(0,1fr); } aside { flex-direction: row; overflow-x: auto; padding: 6px; } aside > * { padding: 6px; } section { padding: 14px; } .search-row { flex-wrap: wrap; } }
[hidden] { display: none !important; }
.skip { position: fixed; z-index: 2; top: 8px; left: 8px; transform: translateY(-150%); background: white; color: var(--teal); padding: 10px; }
.skip:focus { transform: none; }
:root { background: #edf2f5; }
body { grid-template-columns: 190px minmax(0, 1fr); grid-template-rows: auto 1fr; }
header { min-height: 74px; padding-inline: 26px; }
.mark { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 11px; background: #154d4e; }
.environment { border: 1px solid #53636b; border-radius: 999px; padding: 5px 12px; }
aside { padding: 24px 12px; }
aside > * { padding: 12px; }
aside span { color: #c6d2d9; }
main { width: 100%; max-width: 1600px; margin: 0 auto; }
.page-heading { display: flex; align-items: center; gap: 14px; padding-bottom: 18px; margin-bottom: 16px; border-bottom: 1px solid #c8d5dc; }
.page-icon { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 10px; color: var(--teal); background: #d9eeeb; font-size: 24px; }
.page-heading h1 { margin: 0; line-height: 1.15; }
.page-heading p { margin: 5px 0 0; color: #435766; }
#workspace { position: relative; }
#logout { margin: 0 0 12px auto; display: block; color: var(--teal); background: white; border: 1px solid #b3c9cb; }
#login { max-width: 450px; background: white; padding: 24px; border: 1px solid var(--line); border-radius: 12px; }
#login input { margin: 6px 0 12px; }
#login-status:empty { display: none; }
ol { background: white; border: 1px solid var(--line); border-radius: 12px; padding: 9px; gap: 7px; }
li { min-height: 60px; font-size: .9rem; }
.columns { grid-template-columns: minmax(300px, 2fr) minmax(0, 3fr); }
section { box-shadow: 0 2px 4px #263c4a0a; }
section h2 { padding-bottom: 12px; border-bottom: 1px solid var(--line); }
#status { min-height: 24px; color: #415766; font-size: .875rem; }
#profile { padding: 16px; border: 1px solid #bddbd7; border-radius: 9px; background: #ecf8f6; }
#profile p { margin: 0 0 12px; }
#open { width: 100%; }
#register input, #register select { margin-top: 4px; }
#empty { padding: 42px 12px; text-align: center; color: #435766; }
#empty span { display: block; color: var(--teal); font-size: 2rem; }
#empty strong { display: block; color: #222d38; }
#empty p { margin: 4px auto 0; max-width: 33ch; }
tbody tr:nth-child(even) { background: #f2f7f8; }
button:not(:disabled):hover { background: #00584f; }
#logout:hover { background: #e5f3f1; }
@media (max-width: 1050px) { .columns { grid-template-columns: 1fr; } }
@media (max-width: 650px) {
  body { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto 1fr; }
  header { padding-inline: 12px; }
  aside { flex-direction: row; padding: 6px; }
  aside > * { padding: 8px; white-space: nowrap; }
  .environment { font-size: .72rem; }
  .page-heading h1 { font-size: 1.85rem; }
  ol { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
#staff-panel { margin-bottom: 16px; }
#staff-list fieldset { border: 1px solid var(--line); margin: 0 0 12px; }
#staff-list input[type="checkbox"] { width: auto; min-height: 0; margin-right: 8px; }
#staff-list button { margin-top: 8px; }
aside a { color: inherit; text-decoration: none; }
aside a:hover, aside a[aria-current="page"] { background: var(--teal); color: white; }

#staff-nav { margin-top: 14px; border-top: 1px solid #53616c; }
.staff-columns { display: grid; grid-template-columns: minmax(230px, 1fr) minmax(0, 2fr); gap: 18px; align-items: start; }
#staff-create { display: grid; gap: 14px; }
#staff-create input { margin-top: 5px; }
#staff-list fieldset { border-radius: 8px; padding: 12px 16px; }
#staff-list legend { font-weight: 700; padding: 0 6px; }
#staff-list label { display: inline-flex; align-items: center; margin: 0 16px 8px 0; }
#staff-list button { display: block; }
:focus-visible { outline: 2px solid #007f75; outline-offset: 3px; }
aside :focus-visible { outline-color: #46d3bf; }
@media (max-width: 850px) { .staff-columns { grid-template-columns: 1fr; } }
@media (max-width: 650px) { aside { flex-wrap: wrap; } #staff-nav { margin-top: 0; border-top: 0; } }
/* Cabecera y recorrido de atención de Fibovida */
header .system-name { padding-left: 24px; margin-left: 14px; border-left: 1px solid #65717d; color: #d5dde4; }
.site { margin-left: auto; font-weight: 600; }
header #logout { margin: 0 0 0 10px; padding-left: 18px; border: 0; border-left: 1px solid #65717d; border-radius: 0; background: transparent; color: white; }
header #logout:hover { background: #364450; }
.page-heading { position: relative; }
.page-heading::after { content: ""; position: absolute; bottom: -2px; left: 0; width: 64px; height: 4px; border-radius: 4px; background: #008d80; }
#admission-panel ol { gap: 3px; padding: 12px; }
#admission-panel li { background: #e9eff4; min-height: 68px; }
#admission-panel li[aria-current] { background: #007e74; color: white; }
.patient-column { min-width: 0; display: grid; gap: 16px; }
.queue-panel { min-height: 340px; align-self: stretch; }
.queue-heading { display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.queue-heading h2 { margin: 0; border: 0; padding: 0; }
#refresh-queue { color: var(--teal); background: transparent; font-size: 1.45rem; }
#refresh-queue:hover { background: #e5f3f1; }
thead { background: #e7edf3; }
@media (min-width: 1041px) {
  #admission-panel li { padding-inline: 19px; clip-path: polygon(0 0, calc(100% - 15px) 0, 100% 50%, calc(100% - 15px) 100%, 0 100%, 15px 50%); }
  #admission-panel li:first-child { clip-path: polygon(0 0, calc(100% - 15px) 0, 100% 50%, calc(100% - 15px) 100%, 0 100%); }
}
@media (max-width: 900px) { header .system-name { display: none; } }
@media (max-width: 550px) { header { flex-wrap: wrap; } .site { font-size: .82rem; } }

.ui-icon { width: 24px; height: 24px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
aside > *, .site, .queue-heading h2 { display: flex; align-items: center; gap: 12px; }
aside { gap: 9px; padding-inline: 6px; }
aside > * { min-height: 50px; padding-inline: 16px; border-radius: 10px; }
aside a[aria-current="page"] { background: #00877e; }
main { padding: 28px clamp(16px, 1.55vw, 30px); }
#admission-heading .page-icon { background: transparent; }
.page-icon .ui-icon { width: 38px; height: 38px; }
#admission-panel li { display: flex; align-items: center; justify-content: center; gap: 8px; line-height: 1.2; }
#admission-panel li small { display: block; margin-top: 3px; }
#admission-panel li:not([aria-current]) .ui-icon, .queue-heading .ui-icon { color: var(--teal); }
.queue-panel { display: flex; flex-direction: column; min-height: 410px; }
.queue-count { margin: auto 0 0; padding-top: 14px; border-top: 1px solid var(--line); color: #435766; }
.queue-panel tbody td:last-child { background: #e1f3f0; }
.patient-dni { display: grid; grid-template-columns: 1fr 2fr; padding-block: 10px; border-block: 1px solid #bddbd7; }
.patient-dni dd { margin: 0; }
#profile #open { margin-top: 10px; min-height: 52px; }
@media (min-width: 1250px) {
  .columns { grid-template-columns: minmax(0, 36fr) minmax(0, 64fr); gap: 20px; }
  #admission-panel ol { grid-template-columns: 1.05fr .92fr 1.14fr 1.06fr 1.42fr .96fr; }
  #admission-panel li { font-size: clamp(.85rem, 1.18vw, 1.25rem); }
  #admission-panel li .ui-icon { width: 30px; height: 30px; }
  .queue-panel { min-height: min(64vh, 605px); }
}
#login .remember-session { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
#login .remember-session input { width: 18px; min-height: 18px; margin: 0; }

#triage-entry { margin-top: 16px; }
.vitals { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
#triage-form { display: grid; gap: 14px; }
#triage-form textarea { display: block; width: 100%; padding: 8px; font: inherit; border: 1px solid #869aa7; border-radius: 6px; }
#triage-form button { justify-self: start; }
.clinical-row { padding: 14px 0; border-top: 1px solid var(--line); }
.clinical-row button { margin-left: 14px; }
#consultation-entry { margin-top: 16px; }
#consultation-form { display: grid; gap: 14px; }
#consultation-form textarea { display: block; width: 100%; padding: 8px; font: inherit; border: 1px solid #869aa7; border-radius: 6px; }
#consultation-form button { justify-self: start; }

.exam-group { border: 1px solid var(--line); padding: 8px 12px; border-radius: 6px; margin-bottom: 6px; }
.exam-group summary { cursor: pointer; font-weight: 650; }
.exam-group fieldset { border: 0; padding: 8px 0 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 8px; }
.exam-group label { display: flex; align-items: center; gap: 8px; font-weight: 400; }
.exam-group input { width: 18px; min-height: 18px; flex: none; }
.lab-results { display: grid; gap: 12px; } .lab-results textarea { display: block; width: 100%; padding: 8px; font: inherit; } .lab-results button { justify-self: start; margin-left: 0; } .clinical-row dd { white-space: pre-wrap; }
.lab-parameter { display: grid; grid-template-columns: repeat(auto-fit, minmax(135px, 1fr)); gap: 8px; align-items: end; margin-bottom: 10px; } .lab-results fieldset { min-width: 0; border: 1px solid var(--line); } .lab-results fieldset > label { margin-top: 12px; }

.prescription-sheet { display: none; }
@media print {
  @page { size: A4 landscape; margin: 12mm; }
  body { display: block; background: white; color: #172c30; }
  body > :not(.prescription-sheet) { display: none !important; }
  .prescription-sheet { display: grid; grid-template-columns: 1fr 1fr; gap: 8mm; }
  .prescription-sheet section { border: 1px solid #006e65; border-top: 8px solid #006e65; padding: 8mm; border-radius: 0; box-shadow: none; }
  .prescription-sheet h2 { color: #006e65; margin-bottom: 0; }
  .prescription-sheet h3 { border-bottom: 2px solid #00877e; padding-bottom: 3mm; }
  .prescription-text { white-space: pre-wrap; overflow-wrap: anywhere; min-height: 80mm; }
  .prescription-sheet footer { border-top: 1px solid #006e65; padding-top: 3mm; }
}
