:root {
  --bg: #eef4f6;
  --surface: #ffffff;
  --surface-soft: #f7fafb;
  --text: #183238;
  --muted: #6b7d82;
  --line: #dce6e8;
  --brand: #176b72;
  --brand-dark: #0e4f55;
  --brand-soft: #dff1f2;
  --normal: #f8d96b;
  --preferente: #81d4a4;
  --urgente: #f08a83;
  --holiday: #bfe8cb;
  --shadow: 0 20px 50px rgba(21, 66, 73, 0.12);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}

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

[hidden] { display: none !important; }

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px;
  background:
    radial-gradient(circle at top left, rgba(23, 107, 114, 0.22), transparent 35%),
    linear-gradient(135deg, #f7fbfc 0%, #e3eef0 100%);
}

.login-card {
  width: min(440px, 100%);
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(255,255,255,.8);
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: 38px;
}

.brand-mark {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background: var(--brand);
  color: white;
  font-weight: 800;
  font-size: 24px;
  margin-bottom: 22px;
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(25px, 3vw, 36px); line-height: 1.12; }
h2 { margin-bottom: 0; font-size: 20px; }

.eyebrow {
  margin-bottom: 6px;
  font-size: 12px;
  letter-spacing: .12em;
  text-transform: uppercase;
  font-weight: 800;
  color: var(--brand);
}

.muted, .helper-text { color: var(--muted); }
.helper-text { font-size: 12px; line-height: 1.45; margin: 10px 0 16px; }

.stack-form, .modal-card { display: grid; gap: 18px; }
.stack-form { margin-top: 28px; }

label, fieldset {
  display: grid;
  gap: 7px;
  font-size: 13px;
  font-weight: 700;
  color: #314b51;
}

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 12px;
  background: white;
  color: var(--text);
  outline: none;
  transition: border .2s, box-shadow .2s;
}

textarea { resize: vertical; }
input:focus, select:focus, textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(23, 107, 114, .12);
}

.primary-button, .secondary-button, .ghost-button, .upload-button, .danger-ghost-button {
  border: 0;
  border-radius: 12px;
  padding: 11px 15px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.primary-button { background: var(--brand); color: white; }
.primary-button:hover { background: var(--brand-dark); }
.secondary-button { background: var(--brand-soft); color: var(--brand-dark); }
.ghost-button { background: #edf3f4; color: var(--text); }
.danger-ghost-button { background: #fff0ef; color: #a23e37; }
.compact { padding: 8px 12px; }

.form-error { color: #b64038; font-size: 13px; margin: -6px 0 0; }
.demo-credentials {
  margin-top: 24px;
  padding: 14px;
  border-radius: 14px;
  background: var(--surface-soft);
  display: grid;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
}

.app-shell { min-height: 100vh; }
.topbar {
  height: 84px;
  padding: 0 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.topbar h1 { font-size: 25px; margin: 0; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.user-pill {
  padding: 9px 13px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-dark);
  font-size: 13px;
  font-weight: 800;
}

.workspace {
  height: calc(100vh - 84px);
  display: grid;
  grid-template-columns: minmax(330px, 29%) 1fr;
  gap: 18px;
  padding: 18px;
}

.requests-panel, .calendar-panel {
  min-height: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: 0 8px 26px rgba(21, 66, 73, 0.06);
}

.requests-panel {
  padding: 20px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  transition: box-shadow .18s, border-color .18s;
}
.requests-panel.return-drop-active {
  border-color: var(--brand);
  box-shadow: inset 0 0 0 3px rgba(23, 107, 114, .18), 0 8px 26px rgba(21, 66, 73, 0.10);
}
.requests-panel.return-drop-active::after {
  content: "Suelta aquí para devolver a pendientes";
  position: absolute;
  inset: 12px;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  border: 2px dashed var(--brand);
  border-radius: 17px;
  background: rgba(223, 241, 242, .94);
  color: var(--brand-dark);
  font-weight: 900;
  text-align: center;
  pointer-events: none;
}

.panel-heading, .calendar-toolbar, .week-navigation, .request-actions, .modal-heading, .modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.counter {
  min-width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--brand);
  color: white;
  font-weight: 800;
}

.request-actions { margin-top: 18px; justify-content: flex-start; }
.upload-button { background: #edf7f8; color: var(--brand-dark); flex: 1; }
.icon-button, .round-button, .close-button {
  border: 0;
  display: grid;
  place-items: center;
  background: var(--brand);
  color: white;
  font-weight: 800;
}
.icon-button { width: 44px; height: 44px; border-radius: 12px; font-size: 26px; }
.round-button { width: 38px; height: 38px; border-radius: 50%; font-size: 26px; }
.close-button { width: 34px; height: 34px; border-radius: 10px; background: #edf3f4; color: var(--text); font-size: 22px; }

.filters { display: grid; grid-template-columns: 1fr 145px; gap: 8px; margin-bottom: 14px; }
.filters input, .filters select { padding: 9px 10px; font-size: 12px; }

.request-list {
  min-height: 0;
  overflow-y: auto;
  display: grid;
  gap: 12px;
  align-content: start;
  padding-right: 4px;
}

.request-card {
  border-radius: 17px;
  border: 1px solid rgba(24,50,56,.09);
  padding: 14px;
  box-shadow: 0 7px 18px rgba(21,66,73,.07);
  cursor: grab;
  transition: transform .15s, box-shadow .15s;
}
.request-card:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(21,66,73,.11); }
.request-card.dragging { opacity: .45; }
.request-card.normal { background: color-mix(in srgb, var(--normal) 44%, white); }
.request-card.preferente { background: color-mix(in srgb, var(--preferente) 44%, white); }
.request-card.urgente { background: color-mix(in srgb, var(--urgente) 42%, white); }
.request-card-top { display: flex; justify-content: space-between; gap: 10px; }
.request-card h3 { font-size: 16px; margin: 0 0 4px; }
.request-summary { display: grid; gap: 5px; margin-top: 10px; font-size: 12px; }
.request-summary strong { color: #40575c; }
.expand-button {
  flex: 0 0 30px;
  height: 30px;
  border-radius: 9px;
  border: 0;
  background: rgba(255,255,255,.72);
  font-size: 20px;
  color: var(--text);
}
.request-expanded {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(24,50,56,.12);
  display: grid;
  gap: 9px;
  font-size: 12px;
}
.request-expanded p { margin: 0; line-height: 1.45; }
.card-actions { display: flex; gap: 8px; margin-top: 4px; }
.card-actions button {
  border: 0;
  border-radius: 9px;
  padding: 7px 10px;
  font-size: 11px;
  font-weight: 800;
}
.edit-card { background: rgba(255,255,255,.72); color: var(--brand-dark); }
.delete-card { background: rgba(255,255,255,.56); color: #9e3d37; }
.priority-badge {
  justify-self: start;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(255,255,255,.64);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 900;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 16px;
  padding: 30px 18px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.calendar-panel { display: flex; flex-direction: column; overflow: hidden; }
.calendar-toolbar { padding: 18px 20px; border-bottom: 1px solid var(--line); }
.week-navigation { justify-content: flex-start; }
.calendar-scroll { min-height: 0; overflow: auto; flex: 1; }
.calendar-grid {
  min-width: 920px;
  display: grid;
  grid-template-columns: 76px repeat(5, minmax(155px, 1fr));
  grid-template-rows: 72px repeat(18, 48px);
  position: relative;
  background: var(--surface);
}
.calendar-cell {
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  position: relative;
}
.day-header {
  padding: 13px;
  background: var(--surface-soft);
  display: grid;
  align-content: center;
  gap: 3px;
  text-align: center;
}
.day-header.today { background: var(--brand-soft); }
.day-header strong { font-size: 13px; text-transform: uppercase; }
.day-header span { font-size: 12px; color: var(--muted); }
.time-header { background: var(--surface-soft); }
.time-label {
  display: grid;
  place-items: start center;
  padding-top: 8px;
  background: var(--surface-soft);
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
}
.time-label.half-hour-label {
  padding-top: 4px;
  font-size: 10px;
  color: #91a0a4;
  font-weight: 600;
}
.slot {
  padding: 3px;
  transition: background .15s, box-shadow .15s;
}
.slot.first-half {
  border-bottom-style: dashed;
  border-bottom-color: #edf2f3;
}
.slot.drag-over { background: var(--brand-soft); box-shadow: inset 0 0 0 2px var(--brand); }
.slot.drag-invalid { background: #fff0ef; box-shadow: inset 0 0 0 2px #c85e56; }
.slot.holiday {
  background: var(--holiday);
  display: grid;
  place-items: center;
  text-align: center;
  color: #1e6940;
  font-weight: 900;
  letter-spacing: .06em;
}
.slot.holiday span { font-size: 11px; display: block; margin-top: 4px; letter-spacing: 0; }
.calendar-event {
  z-index: 4;
  min-height: 0;
  align-self: stretch;
  justify-self: stretch;
  border: 0;
  border-radius: 10px;
  padding: 7px 8px;
  margin: 3px 5px;
  width: auto;
  height: auto;
  text-align: left;
  color: #183238;
  display: grid;
  align-content: start;
  gap: 3px;
  overflow: hidden;
  box-shadow: 0 5px 12px rgba(21,66,73,.14);
  cursor: grab;
}
.calendar-event:active { cursor: grabbing; }
.calendar-event.dragging { opacity: .45; }
.calendar-event.normal { background: var(--normal); }
.calendar-event.preferente { background: var(--preferente); }
.calendar-event.urgente { background: var(--urgente); }
.calendar-event strong, .calendar-event span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.calendar-event strong { font-size: 12px; }
.calendar-event span { font-size: 10px; }
.calendar-event-heading {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.calendar-event-heading strong { flex: 1; min-width: 0; }
.calendar-event-expand {
  flex: 0 0 20px;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(255,255,255,.62);
  font-size: 15px !important;
  line-height: 1;
  font-weight: 900;
  color: #183238;
}
.calendar-event:hover .calendar-event-expand,
.calendar-event:focus-visible .calendar-event-expand { background: rgba(255,255,255,.9); }

/* Las citas de una hora necesitan una composición más compacta para que
   nombre, horario, historia, procedimiento y estado sean legibles. */
.calendar-event.duration-60 {
  padding: 5px 7px;
  margin: 2px 4px;
  gap: 1px;
  border-radius: 9px;
}
.calendar-event.duration-60 strong { font-size: 11px; line-height: 1.1; }
.calendar-event.duration-60 > span:not(.calendar-event-heading):not(.calendar-event-badges) {
  font-size: 9px;
  line-height: 1.08;
}
.calendar-event.duration-60 .calendar-event-heading { gap: 4px; min-height: 17px; }
.calendar-event.duration-60 .calendar-event-expand {
  flex-basis: 17px;
  width: 17px;
  height: 17px;
  font-size: 13px !important;
}
.calendar-event.duration-60 .calendar-event-badges { min-height: 12px; gap: 3px; }
.calendar-event.duration-60 .event-status-badge {
  padding: 1px 4px;
  font-size: 7px !important;
  line-height: 1;
}
.calendar-event.duration-60 .message-icon {
  flex-basis: 14px;
  width: 14px;
  height: 14px;
  font-size: 7px !important;
}
.calendar-event.duration-60 .event-procedure,
.calendar-event.duration-60 .event-comment {
  font-size: 8.5px !important;
}

.modal {
  border: 0;
  padding: 0;
  border-radius: 22px;
  width: min(760px, calc(100vw - 32px));
  box-shadow: var(--shadow);
}
.modal::backdrop { background: rgba(9,35,39,.52); backdrop-filter: blur(3px); }
.modal-card { padding: 24px; background: white; }
.small-modal { width: min(480px, 100%); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.full-width { grid-column: 1 / -1; }
.procedure-fieldset { border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
.procedure-fieldset legend { padding: 0 6px; }
.procedure-fieldset label { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.procedure-fieldset input { width: auto; }
.modal-actions { justify-content: flex-end; margin-top: 6px; }
.split-actions { justify-content: space-between; }
.event-details { display: grid; gap: 14px; font-size: 13px; }
.event-detail-highlight {
  display: grid;
  gap: 3px;
  padding: 13px 14px;
  border-radius: 13px;
  background: var(--brand-soft);
  color: var(--brand-dark);
}
.event-detail-highlight span { font-size: 11px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.event-detail-highlight strong { font-size: 14px; }
.event-detail-list {
  margin: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
}
.event-detail-list > div {
  min-width: 0;
  padding: 11px 13px;
  border-bottom: 1px solid var(--line);
}
.event-detail-list > div:nth-child(odd):not(.event-detail-wide) { border-right: 1px solid var(--line); }
.event-detail-list > div:last-child { border-bottom: 0; }
.event-detail-list dt { margin-bottom: 4px; color: var(--muted); font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; }
.event-detail-list dd { margin: 0; line-height: 1.45; overflow-wrap: anywhere; }
.event-detail-wide { grid-column: 1 / -1; }
.priority-text { font-weight: 900; }
.priority-text.normal { color: #836900; }
.priority-text.preferente { color: #167044; }
.priority-text.urgente { color: #a32d28; }

.toast {
  position: fixed;
  z-index: 100;
  right: 22px;
  bottom: 22px;
  max-width: 360px;
  padding: 13px 16px;
  border-radius: 13px;
  background: #173b40;
  color: white;
  box-shadow: var(--shadow);
  transform: translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: .2s;
}
.toast.show { opacity: 1; transform: translateY(0); }
.admin-placeholder { text-align: center; justify-items: center; }

@media (max-width: 980px) {
  .workspace { grid-template-columns: 1fr; height: auto; }
  .requests-panel { max-height: 520px; }
  .calendar-panel { min-height: 720px; }
  .topbar { height: auto; padding: 18px; align-items: flex-start; }
  .topbar-actions { flex-wrap: wrap; justify-content: flex-end; }
}

@media (max-width: 640px) {
  .event-detail-list { grid-template-columns: 1fr; }
  .event-detail-list > div:nth-child(odd):not(.event-detail-wide) { border-right: 0; }
  .login-shell { padding: 16px; }
  .login-card { padding: 25px; }
  .topbar { flex-direction: column; }
  .topbar-actions { width: 100%; justify-content: space-between; }
  .workspace { padding: 10px; gap: 10px; }
  .calendar-toolbar { align-items: stretch; flex-direction: column; }
  .week-navigation { flex-wrap: wrap; }
  .filters, .form-grid { grid-template-columns: 1fr; }
  .full-width { grid-column: auto; }
}

/* V5: guardado de borradores y coordinación médico-administrativo */
.primary-button:disabled,
.secondary-button:disabled,
.ghost-button:disabled {
  cursor: not-allowed;
  opacity: .52;
}

.save-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
}
.save-status::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}
.save-status.saved { background: #e7f6eb; color: #267044; }
.save-status.dirty { background: #fff3d1; color: #8b6500; }

.draft-inline-badge {
  display: inline-flex;
  margin-left: 5px;
  padding: 4px 7px;
  border-radius: 999px;
  background: rgba(255,255,255,.72);
  color: #8b6500;
  font-size: 9px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.calendar-event.admin-confirmed {
  background: #d8effb;
  box-shadow: inset 0 0 0 2px #65a9cf, 0 5px 12px rgba(21,66,73,.14);
}
.calendar-event.admin-changed {
  background: #ffd9a8;
  box-shadow: inset 0 0 0 2px #d6882a, 0 5px 12px rgba(21,66,73,.14);
}
.calendar-event.draft-change {
  outline: 3px dashed rgba(24,50,56,.7);
  outline-offset: -4px;
}
.calendar-event-badges {
  display: flex !important;
  align-items: center;
  gap: 4px;
  min-height: 15px;
  overflow: visible !important;
}
.event-status-badge {
  display: inline-flex !important;
  align-items: center;
  width: fit-content;
  max-width: 100%;
  padding: 2px 5px;
  border-radius: 999px;
  background: rgba(255,255,255,.76);
  color: #183238;
  font-size: 8px !important;
  line-height: 1.1;
  font-weight: 950;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.event-status-badge.confirmed { color: #17623a; }
.event-status-badge.changed { color: #8d5109; }
.event-status-badge.draft { color: #725500; }
.event-status-badge.pending { color: #53666b; }
.message-icon {
  flex: 0 0 17px;
  width: 17px;
  height: 17px;
  display: grid !important;
  place-items: center;
  border-radius: 50%;
  background: #fff;
  color: var(--brand);
  font-size: 8px !important;
  box-shadow: 0 0 0 2px rgba(23,107,114,.28);
}

.draft-highlight { background: #fff3d1; color: #725500; }
.admin-change-highlight { background: #fff0dc; color: #8d5109; }
.official-status { color: #207044; font-weight: 900; }
.changed-status { color: #9a5d13; font-weight: 850; }
.admin-message-box {
  padding: 10px 12px;
  border-radius: 10px;
  background: #eef9f1;
  border-left: 4px solid #4c9d69;
}

.admin-workspace {
  height: calc(100vh - 84px);
  padding: 18px;
}
.admin-calendar-panel {
  height: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: 0 8px 26px rgba(21, 66, 73, 0.06);
}
.admin-toolbar { gap: 20px; }
.admin-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px 14px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}
.admin-legend span { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.legend-dot {
  width: 11px;
  height: 11px;
  border-radius: 3px;
  border: 1px solid #b7c4c7;
  background: #fff;
}
.legend-dot.confirmed { background: #b9ebc9; border-color: #4c9d69; }
.legend-dot.changed { background: #ffd9a8; border-color: #d6882a; }

.admin-calendar-event {
  cursor: pointer;
  background: #fff;
  border: 1px solid #b9c8cb;
  color: #183238;
  box-shadow: 0 4px 10px rgba(21,66,73,.10);
}
.admin-calendar-event.pending { background: #fff; }
.admin-calendar-event.confirmed {
  background: #b9ebc9;
  border-color: #4c9d69;
  box-shadow: inset 0 0 0 1px #4c9d69, 0 4px 10px rgba(21,66,73,.10);
}
.admin-calendar-event.changed {
  background: #ffd9a8;
  border-color: #d6882a;
  box-shadow: inset 0 0 0 1px #d6882a, 0 4px 10px rgba(21,66,73,.10);
}
.admin-calendar-event:active { cursor: pointer; }

.admin-notice-bar {
  padding: 10px 14px;
  border-bottom: 1px solid #f0c686;
  background: #fff6e8;
}
.admin-notice-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  color: #794b12;
  font-size: 12px;
}
.admin-notice-item + .admin-notice-item {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #efd6ad;
}

.admin-confirmation-area {
  display: grid;
  gap: 14px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-soft);
}
.admin-check-row {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--text);
}
.admin-check-row input {
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  accent-color: var(--brand);
}
.optional-text { color: var(--muted); font-weight: 600; }
.admin-basic-list > div:nth-child(3) { border-bottom: 0; }

@media (max-width: 1180px) {
  .topbar-actions { flex-wrap: wrap; justify-content: flex-end; }
  .save-status { order: 3; }
}

@media (max-width: 980px) {
  .admin-workspace { height: auto; padding: 10px; }
  .admin-calendar-panel { min-height: 720px; }
  .admin-toolbar { align-items: stretch; flex-direction: column; }
  .admin-legend { justify-content: flex-start; }
}

@media (max-width: 640px) {
  .save-status { width: 100%; justify-content: center; }
  #saveScheduleButton { flex: 1; }
  .admin-notice-item { align-items: flex-start; flex-direction: column; }
}


/* Integración de extracción PDF */
.upload-button.is-loading {
  opacity: .72;
  cursor: wait;
  pointer-events: none;
}

.upload-button.is-loading span:first-child {
  animation: pdf-upload-spin .9s linear infinite;
}

@keyframes pdf-upload-spin {
  to { transform: rotate(360deg); }
}

.api-status {
  display: block;
  margin-bottom: 5px;
  font-weight: 800;
}

.api-status.checking { color: var(--muted); }
.api-status.ready { color: #176b52; }
.api-status.error { color: #a23e37; }
.api-status.mock { color: #805e12; }

.extraction-notice {
  padding: 12px 14px;
  border: 1px solid #b7dce6;
  border-radius: 13px;
  background: #edf8fb;
  color: #194f5d;
  font-size: 13px;
  line-height: 1.45;
}

.extraction-notice strong { display: block; margin-bottom: 3px; }
.extraction-notice ul { margin: 7px 0 0; padding-left: 19px; }
.extraction-notice.confidence-media { background: #fff8e5; border-color: #ead28a; color: #705817; }
.extraction-notice.confidence-baja,
.extraction-notice.not-a-request { background: #fff0ef; border-color: #e5aaa5; color: #8b3832; }


/* Carga secuencial de lotes PDF */
.pdf-batch-progress {
  margin: -4px 0 16px;
  padding: 12px 13px;
  border: 1px solid #c8dfe4;
  border-radius: 14px;
  background: #f7fbfc;
}

.pdf-batch-progress-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--text);
  font-size: 13px;
}

.pdf-batch-progress-heading span {
  flex: 0 0 auto;
  color: var(--muted);
  font-weight: 800;
}

.pdf-batch-progress-track {
  height: 8px;
  margin-top: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #dfecee;
}

.pdf-batch-progress-bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--brand);
  transition: width .25s ease;
}

.pdf-batch-detail {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.pdf-batch-errors {
  max-height: 120px;
  margin: 8px 0 0;
  padding-left: 18px;
  overflow: auto;
  color: #8b3832;
  font-size: 12px;
  line-height: 1.4;
}

.batch-review-status {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid #c8dfe4;
  border-radius: 12px;
  background: #f4fafb;
  color: #194f5d;
  font-size: 12px;
  line-height: 1.35;
}

.batch-review-status strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.batch-review-status span {
  max-width: 58%;
  color: var(--muted);
  text-align: right;
}

#newRequestButton:disabled {
  opacity: .55;
  cursor: wait;
}

@media (max-width: 640px) {
  .batch-review-status { flex-direction: column; }
  .batch-review-status span { max-width: none; text-align: left; }
}

.batch-review-status[hidden] { display: none; }

/* V8: interfaz más compacta, zoom del calendario y mensajes administrativos */
.compact-ai-copy {
  display: grid;
  gap: 3px;
  margin: 9px 0 14px;
}
.compact-ai-copy .api-status {
  width: fit-content;
  margin: 0;
  font-weight: 900;
}

.workspace {
  grid-template-columns: minmax(420px, 32%) minmax(0, 1fr);
}
.requests-panel { container-type: inline-size; }
.request-list {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 9px;
}
.request-card {
  min-width: 0;
  padding: 10px;
  border-radius: 14px;
}
.request-card.is-expanded { grid-column: 1 / -1; }
.request-card h3 {
  font-size: 14px;
  line-height: 1.18;
  margin-bottom: 3px;
}
.request-card-top { gap: 7px; }
.request-summary {
  gap: 3px;
  margin-top: 7px;
  font-size: 10.5px;
  line-height: 1.3;
}
.request-summary span:nth-child(2) {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}
.priority-badge {
  padding: 3px 6px;
  font-size: 8px;
}
.expand-button {
  flex-basis: 25px;
  width: 25px;
  height: 25px;
  border-radius: 8px;
  font-size: 17px;
}
.request-expanded {
  margin-top: 9px;
  padding-top: 9px;
  gap: 7px;
  font-size: 11px;
}
.empty-state { grid-column: 1 / -1; }

.calendar-toolbar-actions,
.admin-toolbar-actions,
.calendar-zoom,
.event-modal-right-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.calendar-toolbar-actions { justify-content: flex-end; flex-wrap: wrap; }
.admin-toolbar-actions { justify-content: flex-end; gap: 14px; flex-wrap: wrap; }
.calendar-zoom {
  padding: 5px 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
}
.calendar-zoom-title {
  padding-left: 3px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.zoom-button {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 8px;
  background: var(--brand);
  color: white;
  font-size: 19px;
  line-height: 1;
  font-weight: 900;
}
.zoom-button:disabled {
  cursor: not-allowed;
  opacity: .38;
}
.zoom-label {
  min-width: 38px;
  text-align: center;
  color: var(--text);
  font-size: 10px;
  font-weight: 900;
}

.calendar-grid {
  grid-template-rows: 72px repeat(18, var(--calendar-slot-height, 48px));
  transition: grid-template-rows .18s ease;
}
.calendar-grid[data-calendar-density="compact"] .calendar-event {
  margin: 2px 3px;
  padding: 4px 6px;
  gap: 1px;
}
.calendar-grid[data-calendar-density="compact"] .calendar-event .event-procedure,
.calendar-grid[data-calendar-density="compact"] .calendar-event .event-comment {
  display: none;
}
.calendar-grid[data-calendar-density="compact"] .calendar-event.duration-60 .event-history {
  display: none;
}
.calendar-grid[data-calendar-density="compact"] .calendar-event strong { font-size: 10px; }
.calendar-grid[data-calendar-density="compact"] .calendar-event span { font-size: 8.5px; }
.calendar-grid[data-calendar-density="compact"] .calendar-event-expand {
  flex-basis: 16px;
  width: 16px;
  height: 16px;
  font-size: 12px !important;
}
.calendar-grid[data-calendar-density="spacious"] .calendar-event {
  padding: 9px 10px;
  gap: 4px;
}

.message-icon {
  background: #6d46c7;
  color: #fff;
  box-shadow: 0 0 0 3px rgba(109,70,199,.24), 0 2px 7px rgba(69,43,133,.28);
  font-size: 9px !important;
  animation: adminMessagePulse 2.1s ease-in-out infinite;
}
@keyframes adminMessagePulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(109,70,199,.20), 0 2px 7px rgba(69,43,133,.25); }
  50% { box-shadow: 0 0 0 6px rgba(109,70,199,.08), 0 3px 9px rgba(69,43,133,.34); }
}
.message-resolution-state {
  display: block;
  width: fit-content;
  margin-top: 8px;
  padding: 4px 7px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 900;
}
.message-resolution-state.unresolved { background: #eee8ff; color: #5b39ad; }
.message-resolution-state.resolved { background: #e5f5ea; color: #267044; }
.message-resolved-button {
  border: 0;
  border-radius: 11px;
  padding: 10px 13px;
  background: #eee8ff;
  color: #5b39ad;
  font-weight: 850;
}
.message-resolved-button:hover { background: #e3d9ff; }

@container (max-width: 405px) {
  .request-list { grid-template-columns: 1fr; }
}

@media (max-width: 1120px) {
  .workspace { grid-template-columns: minmax(380px, 38%) minmax(0, 1fr); }
  .calendar-toolbar-actions { justify-content: flex-start; }
}

@media (max-width: 980px) {
  .workspace { grid-template-columns: 1fr; }
  .request-list { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
}

@media (max-width: 640px) {
  .calendar-toolbar-actions,
  .admin-toolbar-actions { justify-content: flex-start; }
  .event-modal-actions { align-items: stretch; }
  .event-modal-right-actions { width: 100%; flex-wrap: wrap; justify-content: flex-end; }
}

/* V9: agrupación de pendientes, pacientes ingresados y vista diaria */
.access-card { width: min(520px, 100%); }
.access-choice {
  display: grid;
  gap: 12px;
  margin-top: 27px;
}
.access-choice > .muted { margin-bottom: 2px; font-weight: 750; }
.access-option {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  background: #f4fafb;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 14px;
  text-align: left;
  transition: border-color .18s, transform .18s, background .18s;
}
.access-option:hover {
  transform: translateY(-1px);
  border-color: var(--brand);
  background: var(--brand-soft);
}
.access-option.secondary-access { background: #f8f7fc; }
.access-option.secondary-access:hover { background: #eee9fb; border-color: #7960b1; }
.access-option-icon {
  flex: 0 0 46px;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: var(--brand);
  color: #fff;
  font-size: 22px;
  font-weight: 900;
}
.secondary-access .access-option-icon { background: #6d55a5; }
.access-option > span:last-child { display: grid; gap: 4px; }
.access-option strong { font-size: 15px; }
.access-option small { color: var(--muted); font-size: 12px; line-height: 1.35; }
.back-link {
  border: 0;
  padding: 4px 0;
  margin: 20px 0 10px;
  background: transparent;
  color: var(--brand-dark);
  font-weight: 850;
}
#programmingLoginPanel .stack-form { margin-top: 18px; }

.request-filter-grid {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}
.request-filter-grid #requestSearch { grid-column: 1 / -1; }
.request-filter-grid #requestGrouping { min-width: 0; }

.request-group {
  grid-column: 1 / -1;
  display: grid;
  gap: 8px;
  min-width: 0;
}
.request-group + .request-group {
  padding-top: 3px;
  border-top: 1px solid var(--line);
}
.request-group-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 3px 2px;
}
.request-group-heading h3 {
  margin: 0;
  color: var(--brand-dark);
  font-size: 13px;
}
.request-group-heading p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 9.5px;
  line-height: 1.25;
}
.request-group-heading > span {
  flex: 0 0 27px;
  height: 27px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  font-size: 10px;
  font-weight: 900;
}
.request-group-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}
.request-group-grid .request-card.is-expanded { grid-column: 1 / -1; }
.request-card-title { min-width: 0; }
.request-card-badges {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
}
.inpatient-badge,
.inpatient-detail-badge,
.viewer-inpatient-badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  border-radius: 999px;
  background: #6b2340;
  color: #fff;
  font-weight: 950;
  letter-spacing: .04em;
}
.inpatient-badge {
  padding: 3px 6px;
  font-size: 8px;
}
.request-card.inpatient-request {
  box-shadow: inset 4px 0 0 #6b2340, 0 7px 18px rgba(21,66,73,.08);
}
.inpatient-expanded-alert {
  padding: 8px 9px;
  border-radius: 9px;
  background: #f8e8ee;
  color: #6b2340;
}
.inpatient-form-option { align-content: start; }
.inpatient-check-row {
  min-height: 48px;
  border: 1px solid #d9c5cd;
  border-radius: 12px;
  padding: 9px 10px;
  background: #fff8fa;
  display: flex;
  align-items: center;
  gap: 10px;
}
.inpatient-check-row input {
  flex: 0 0 20px;
  width: 20px;
  height: 20px;
  accent-color: #6b2340;
}
.inpatient-check-row > span { display: grid; gap: 2px; }
.inpatient-check-row strong { color: #6b2340; font-size: 12px; }
.inpatient-check-row small { color: var(--muted); font-size: 10px; line-height: 1.25; }
#requestPriority:disabled {
  opacity: .72;
  background: #f3f5f5;
  cursor: not-allowed;
}
.inpatient-detail-badge { padding: 5px 8px; font-size: 10px; }
.admin-inpatient-alert {
  padding: 10px 12px;
  border-radius: 11px;
  background: #6b2340;
  color: white;
  font-size: 11px;
  font-weight: 950;
  letter-spacing: .04em;
}
.calendar-event.inpatient-patient {
  border-left: 5px solid #6b2340;
}
.event-status-badge.inpatient {
  background: #6b2340;
  color: #fff;
}
.calendar-event.duration-60 .event-status-badge.inpatient { font-size: 6.5px !important; }

.viewer-shell { background: var(--bg); }
.viewer-workspace {
  height: calc(100vh - 84px);
  padding: 18px;
}
.viewer-calendar-panel {
  height: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: 0 8px 26px rgba(21,66,73,.06);
}
.viewer-toolbar { gap: 20px; }
.day-navigation {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
}
.viewer-summary {
  display: grid;
  justify-items: end;
  gap: 2px;
  padding: 8px 12px;
  border-radius: 12px;
  background: var(--surface-soft);
}
.viewer-summary strong { font-size: 13px; }
.viewer-summary span { color: var(--muted); font-size: 10px; }
.viewer-calendar-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
}
.viewer-day-grid {
  display: grid;
  grid-template-columns: 90px minmax(520px, 1fr);
  grid-template-rows: 66px repeat(18, 42px);
  min-width: 680px;
  position: relative;
  background: var(--surface);
}
.viewer-grid-cell {
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.viewer-time-header,
.viewer-time-label { background: var(--surface-soft); }
.viewer-day-header {
  display: grid;
  align-content: center;
  gap: 4px;
  padding: 12px 18px;
  background: var(--surface-soft);
}
.viewer-day-header.today { background: var(--brand-soft); }
.viewer-day-header strong { font-size: 17px; }
.viewer-day-header span { color: var(--muted); font-size: 11px; }
.viewer-time-label {
  padding-top: 8px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}
.viewer-time-label.half-hour { padding-top: 4px; color: #91a0a4; font-size: 10px; }
.viewer-slot.first-half { border-bottom-style: dashed; border-bottom-color: #edf2f3; }
.viewer-event {
  z-index: 4;
  margin: 3px 12px;
  border: 1px solid #9fbfc7;
  border-left: 7px solid #3d8290;
  border-radius: 12px;
  padding: 8px 12px;
  background: #eff8fa;
  color: var(--text);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(21,66,73,.10);
}
.viewer-event.confirmed { background: #e8f4fb; border-color: #79acd0; border-left-color: #367fae; }
.viewer-event.changed { background: #fff1df; border-color: #dda65f; border-left-color: #c27820; }
.viewer-event.inpatient-patient { border-left-color: #6b2340; box-shadow: inset 4px 0 0 rgba(107,35,64,.12), 0 4px 12px rgba(21,66,73,.10); }
.viewer-event-main { min-width: 0; display: grid; gap: 4px; }
.viewer-event-heading {
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 14px;
}
.viewer-event-heading strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 15px;
}
.viewer-event-time { color: var(--brand-dark); font-weight: 900; font-size: 12px; white-space: nowrap; }
.viewer-event-meta { display: flex; flex-wrap: wrap; gap: 7px 18px; color: #40575c; font-size: 11px; font-weight: 750; }
.viewer-event p { margin: 0; color: var(--muted); font-size: 10px; line-height: 1.25; }
.viewer-event-badges { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 5px; }
.viewer-inpatient-badge,
.viewer-status-badge {
  padding: 4px 7px;
  font-size: 8px;
  white-space: nowrap;
}
.viewer-status-badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  border-radius: 999px;
  background: rgba(255,255,255,.8);
  font-weight: 950;
  letter-spacing: .04em;
}
.viewer-status-badge.confirmed { color: #245f84; }
.viewer-status-badge.changed { color: #8d5109; }
.viewer-status-badge.pending { color: #53666b; }
.viewer-holiday {
  z-index: 5;
  margin: 6px 12px;
  border-radius: 14px;
  background: var(--holiday);
  color: #1e6940;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 7px;
  font-weight: 950;
  letter-spacing: .08em;
}
.viewer-holiday strong { font-size: 24px; }
.viewer-holiday span { font-size: 13px; letter-spacing: 0; }

@container (max-width: 405px) {
  .request-group-grid { grid-template-columns: 1fr; }
}

@media (max-width: 980px) {
  .request-group-grid { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
  .viewer-workspace { height: auto; min-height: calc(100vh - 84px); }
  .viewer-calendar-panel { min-height: 780px; }
}

@media (max-width: 640px) {
  .request-filter-grid { grid-template-columns: 1fr; }
  .request-filter-grid #requestSearch { grid-column: auto; }
  .request-group-grid { grid-template-columns: 1fr; }
  .viewer-toolbar { align-items: stretch; }
  .day-navigation { flex-wrap: wrap; }
  .viewer-summary { justify-items: start; }
}


/* V10: detección automática de paciente ingresado desde PDF */
.auto-inpatient-detected {
  margin-top: 10px;
  padding: 9px 11px;
  border: 1px solid #efb0a9;
  border-radius: 10px;
  background: #fff1ef;
  color: #7d251f;
  display: grid;
  gap: 2px;
}
.auto-inpatient-detected span {
  font-size: 0.86rem;
}

/* V11: panel médico compacto, pantalla autenticada y estado de procedimiento */
.requests-panel {
  padding: 14px;
}
.requests-panel .panel-heading {
  min-height: 42px;
}
.requests-panel .panel-heading .eyebrow {
  margin-bottom: 2px;
  font-size: 10px;
}
.requests-panel .panel-heading h2 {
  font-size: 18px;
  line-height: 1.1;
}
.requests-panel .counter {
  min-width: 31px;
  width: 31px;
  height: 31px;
  font-size: 12px;
}
.request-actions {
  margin-top: 9px;
  gap: 7px;
}
.request-actions .upload-button {
  min-height: 43px;
  padding: 7px 11px;
  gap: 9px;
}
.upload-copy {
  min-width: 0;
  display: grid;
  gap: 1px;
  line-height: 1.15;
}
.upload-copy strong {
  font-size: 12px;
}
.upload-copy small {
  color: var(--muted);
  font-size: 9px;
  font-weight: 750;
}
.upload-copy .api-status {
  display: inline;
  margin: 0;
  color: #176b52;
  font-size: inherit;
}
.upload-copy .api-status.error { color: #a23e37; }
.upload-copy .api-status.mock { color: #805e12; }
.request-actions .icon-button {
  width: 43px;
  height: 43px;
  flex: 0 0 43px;
}
.request-filter-grid {
  grid-template-columns: minmax(120px, 1.25fr) minmax(104px, .85fr) minmax(122px, 1fr);
  gap: 6px;
  margin: 9px 0 9px;
}
.request-filter-grid #requestSearch {
  grid-column: auto;
}
.request-filter-grid input,
.request-filter-grid select {
  min-width: 0;
  padding: 7px 8px;
  border-radius: 10px;
  font-size: 10px;
}
.request-list,
.request-group-grid {
  gap: 7px;
}
.request-group {
  gap: 5px;
}
.request-group + .request-group {
  padding-top: 1px;
}
.request-group-heading {
  padding: 4px 2px 1px;
}
.request-group-heading h3 {
  font-size: 11.5px;
}
.request-group-heading p {
  margin-top: 1px;
  font-size: 8.5px;
}
.request-group-heading > span {
  flex-basis: 24px;
  width: 24px;
  height: 24px;
  font-size: 9px;
}
.request-card {
  padding: 8px;
  border-radius: 12px;
}
.request-card h3 {
  font-size: 12.5px;
  line-height: 1.12;
}
.request-summary {
  margin-top: 5px;
  gap: 2px;
  font-size: 9.5px;
  line-height: 1.22;
}
.request-summary span:nth-child(2) {
  -webkit-line-clamp: 2;
}
.request-card-badges { gap: 3px; }
.priority-badge,
.inpatient-badge,
.draft-inline-badge {
  font-size: 7px;
  padding: 2px 5px;
}
.expand-button {
  flex-basis: 23px;
  width: 23px;
  height: 23px;
  font-size: 15px;
}
.request-expanded {
  margin-top: 7px;
  padding-top: 7px;
  gap: 6px;
  font-size: 10px;
}

/* Formulario con más procedimientos */
.procedure-fieldset {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 16px;
  row-gap: 8px;
}
.procedure-fieldset legend { margin-bottom: 3px; }

/* Vista diaria pensada para una pantalla grande */
.viewer-topbar h1 { font-size: 28px; }
.viewer-day-grid {
  grid-template-columns: 102px minmax(560px, 1fr);
  grid-template-rows: 68px repeat(18, 45px);
}
.viewer-day-header strong { font-size: 20px; }
.viewer-day-header span { font-size: 13px; }
.viewer-time-label {
  padding-top: 9px;
  font-size: 15px;
}
.viewer-time-label.half-hour {
  padding-top: 5px;
  font-size: 12px;
}
.viewer-summary strong { font-size: 15px; }
.viewer-summary span { font-size: 12px; }
.viewer-event {
  appearance: none;
  width: auto;
  text-align: left;
  font: inherit;
  cursor: pointer;
  margin: 3px 10px;
  padding: 8px 14px;
  border-radius: 13px;
  transition: opacity .18s, filter .18s, background .18s, transform .18s;
}
.viewer-event:hover { transform: translateY(-1px); }
.viewer-event-heading strong { font-size: 19px; }
.viewer-event-time { font-size: 15px; }
.viewer-event-meta {
  font-size: 13px;
  gap: 6px 20px;
}
.viewer-event-comment {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
}
.viewer-inpatient-badge,
.viewer-status-badge,
.viewer-outcome-badge {
  padding: 5px 8px;
  font-size: 9px;
}
.viewer-outcome-badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  border-radius: 999px;
  background: #fff;
  font-weight: 950;
  letter-spacing: .05em;
  white-space: nowrap;
}
.viewer-outcome-badge.done { color: #276344; border: 1px solid #8ebba1; }
.viewer-outcome-badge.cancelled { color: #8d3c3c; border: 1px solid #d6a1a1; }
.viewer-event.viewer-outcome-done {
  background: #e1ece5;
  border-color: #9fb9a9;
  border-left-color: #6f927d;
  opacity: .66;
  filter: saturate(.48);
}
.viewer-event.viewer-outcome-cancelled {
  background: #eee5e5;
  border-color: #c7aaaa;
  border-left-color: #a07171;
  opacity: .58;
  filter: saturate(.38);
}
.viewer-event.viewer-outcome-done:hover,
.viewer-event.viewer-outcome-cancelled:hover {
  opacity: .78;
}
.viewer-action-card {
  width: min(560px, 100%);
}
.viewer-action-summary {
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--surface-soft);
  display: grid;
  gap: 4px;
  font-size: 13px;
}
.viewer-action-summary strong { font-size: 18px; color: var(--brand-dark); }
.viewer-action-question {
  margin: 0;
  font-size: 18px;
  font-weight: 900;
  text-align: center;
}
.viewer-current-outcome {
  margin-top: 5px;
  padding: 6px 8px;
  border-radius: 8px;
  font-weight: 850;
}
.viewer-current-outcome.done { background: #e3f2e8; color: #276344; }
.viewer-current-outcome.cancelled { background: #f7e7e7; color: #8d3c3c; }
.viewer-action-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}
.viewer-action-buttons .ghost-button { grid-column: 1 / -1; }
.viewer-done-button,
.viewer-cancelled-button {
  border: 0;
  border-radius: 12px;
  padding: 12px 14px;
  font-weight: 900;
}
.viewer-done-button { background: #dcefe3; color: #245d3f; }
.viewer-cancelled-button { background: #f5dfdf; color: #843737; }

@container (max-width: 500px) {
  .request-filter-grid {
    grid-template-columns: 1fr 1fr;
  }
  .request-filter-grid #requestSearch { grid-column: 1 / -1; }
}

@media (max-width: 640px) {
  .procedure-fieldset { grid-template-columns: 1fr; }
  .viewer-action-buttons { grid-template-columns: 1fr; }
  .viewer-action-buttons .ghost-button { grid-column: auto; }
}

/* Citas de 30 minutos: mostrar lo esencial sin deformar la cuadrícula */
.calendar-event.duration-30 {
  margin: 2px 4px;
  padding: 3px 6px;
  gap: 0;
  border-radius: 8px;
}
.calendar-event.duration-30 .calendar-event-heading { gap: 3px; min-height: 15px; }
.calendar-event.duration-30 .calendar-event-heading strong { font-size: 9.5px; line-height: 1; }
.calendar-event.duration-30 .calendar-event-expand {
  flex-basis: 15px;
  width: 15px;
  height: 15px;
  font-size: 11px !important;
}
.calendar-event.duration-30 .event-time { font-size: 7.8px !important; line-height: 1; }
.calendar-event.duration-30 .event-history,
.calendar-event.duration-30 .event-procedure,
.calendar-event.duration-30 .event-comment,
.calendar-event.duration-30 .calendar-event-badges { display: none; }
.calendar-event.duration-30.inpatient-patient::after {
  content: "INGRESADO";
  position: absolute;
  right: 24px;
  bottom: 3px;
  font-size: 6px;
  font-weight: 950;
  color: #6b2340;
}

.viewer-event.duration-30 {
  padding: 4px 10px;
  gap: 8px;
}
.viewer-event.duration-30 .viewer-event-main { gap: 1px; }
.viewer-event.duration-30 .viewer-event-heading strong { font-size: 16px; }
.viewer-event.duration-30 .viewer-event-time { font-size: 12px; }
.viewer-event.duration-30 .viewer-event-meta { font-size: 10.5px; gap: 4px 12px; }
.viewer-event.duration-30 .viewer-event-comment { display: none; }
.viewer-event.duration-30 .viewer-event-badges { align-content: center; }
.viewer-event.duration-30 .viewer-inpatient-badge,
.viewer-event.duration-30 .viewer-status-badge,
.viewer-event.duration-30 .viewer-outcome-badge { font-size: 7px; padding: 3px 5px; }

/* Confirmación directa de programación por el médico */
.doctor-programmed-button {
  border: 1px solid #8db9d8;
  border-radius: 11px;
  background: #eaf6ff;
  color: #155a86;
  padding: 10px 14px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}
.doctor-programmed-button:hover { background: #dcefff; }

/* V12: responsables diarios desde Google Calendar (solo lectura) */
.duty-strip {
  flex: 0 0 auto;
  border-bottom: 1px solid var(--line);
  background: #fbfdfd;
}
.weekly-duty-strip {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  min-height: 84px;
}
.duty-strip-source {
  padding: 11px 7px;
  border-right: 1px solid var(--line);
  color: var(--muted);
  display: grid;
  place-items: center;
  align-content: center;
  gap: 5px;
  text-align: center;
  font-size: 8px;
  font-weight: 850;
  line-height: 1.2;
}
.duty-source-dot {
  width: 9px;
  height: 9px;
  display: inline-block;
  border-radius: 50%;
  background: #9ba9ac;
  flex: 0 0 9px;
}
.duty-source-dot.online { background: #2f9b65; box-shadow: 0 0 0 3px rgba(47,155,101,.12); }
.duty-source-dot.pending { background: #d59d33; }
.duty-source-dot.offline { background: #9ba9ac; }
.duty-source-dot.error { background: #c74d45; }
.duty-source-dot.loading { background: var(--brand); animation: dutyPulse 1.15s ease-in-out infinite; }
@keyframes dutyPulse { 50% { opacity: .35; transform: scale(.78); } }
.weekly-duty-grid {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
}
.duty-day-card {
  min-width: 0;
  padding: 7px 9px 8px;
  border-right: 1px solid var(--line);
  display: grid;
  gap: 4px;
  align-content: center;
  background: white;
}
.duty-day-card:last-child { border-right: 0; }
.duty-day-card.today { background: #eff8f9; }
.duty-day-date {
  color: var(--brand-dark);
  font-size: 8.5px;
  letter-spacing: .04em;
}
.duty-role {
  min-width: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: baseline;
  gap: 5px;
  font-size: 9px;
  line-height: 1.15;
}
.duty-role > span:first-child {
  color: var(--muted);
  font-size: 8px;
  font-weight: 750;
}
.duty-role strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 9.5px;
  color: var(--text);
}
.duty-role.urgent-duty strong { color: #7b344d; }
.duty-empty { color: #99a6a9; font-weight: 650; }
.duty-loading,
.duty-status {
  grid-column: 1 / -1;
  min-height: 64px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  color: var(--muted);
  font-size: 11px;
  text-align: left;
}
.duty-status > span:nth-child(2) { display: grid; gap: 2px; }
.duty-status strong { color: var(--text); font-size: 11px; }
.duty-status small { font-size: 9px; line-height: 1.25; }
.duty-status.error strong { color: #943e38; }
.duty-connect-button {
  margin-left: 8px;
  padding: 7px 10px;
  border-radius: 9px;
  background: var(--brand);
  color: white;
  text-decoration: none;
  font-size: 9.5px;
  font-weight: 900;
  white-space: nowrap;
}
.duty-connect-button.secondary { background: #edf3f4; color: var(--brand-dark); }

.viewer-duty-strip {
  padding: 0;
  background: linear-gradient(90deg, #f6fbfb, #fbf9fc);
}
.viewer-duty-source {
  padding: 7px 18px 0;
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}
.viewer-duty-content {
  padding: 8px 18px 12px;
  display: grid;
  grid-template-columns: minmax(150px, .75fr) repeat(2, minmax(220px, 1fr));
  align-items: center;
  gap: 14px;
}
.viewer-duty-date span {
  color: var(--brand-dark);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: .035em;
}
.viewer-duty-role {
  min-width: 0;
  padding: 7px 13px;
  border-left: 3px solid var(--brand);
  display: grid;
  gap: 1px;
}
.viewer-duty-role.urgent-duty { border-left-color: #7b344d; }
.viewer-duty-role > span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.viewer-duty-role strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
  font-size: 21px;
  line-height: 1.1;
}
.viewer-duty-role.urgent-duty strong { color: #713147; }
.viewer-duty-loading { min-height: 78px; font-size: 13px; }
.viewer-duty-strip .duty-status { min-height: 80px; }
.viewer-duty-strip .duty-status strong { font-size: 14px; }
.viewer-duty-strip .duty-status small { font-size: 11px; }
.viewer-duty-strip .duty-connect-button { font-size: 11px; padding: 8px 12px; }

@media (max-width: 1100px) {
  .duty-role { grid-template-columns: 1fr; gap: 1px; }
  .viewer-duty-content { grid-template-columns: 1fr 1fr; }
  .viewer-duty-date { grid-column: 1 / -1; }
}

@media (max-width: 700px) {
  .weekly-duty-strip { grid-template-columns: 1fr; }
  .duty-strip-source { display: none; }
  .weekly-duty-grid { grid-template-columns: 1fr; }
  .duty-day-card { border-right: 0; border-bottom: 1px solid var(--line); }
  .duty-role { grid-template-columns: 86px 1fr; }
  .viewer-duty-content { grid-template-columns: 1fr; }
  .viewer-duty-date { grid-column: auto; }
  .viewer-duty-role strong { font-size: 18px; }
}

/* v10 · Comentarios separados y configuración de prestaciones */
.procedure-options {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 16px;
}
.procedure-option {
  display: flex !important;
  align-items: flex-start !important;
  gap: 9px !important;
  padding: 8px 10px;
  border-radius: 10px;
  background: #f8fbfb;
  border: 1px solid #e5edef;
}
.procedure-option > span { display: grid; gap: 2px; }
.procedure-option strong { font-size: 12px; color: var(--text); }
.procedure-option small { font-size: 10px; color: var(--muted); font-weight: 600; }
.procedure-option.inactive-procedure { opacity: .65; }

.config-workspace {
  min-height: calc(100vh - 84px);
  padding: 22px;
}
.config-panel {
  width: min(1180px, 100%);
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: 0 8px 26px rgba(21, 66, 73, 0.06);
  padding: 24px;
}
.config-intro { margin-bottom: 20px; }
.config-intro h2 { font-size: 24px; margin-bottom: 7px; }
.config-intro p:not(.eyebrow) { margin: 0; color: var(--muted); max-width: 850px; line-height: 1.5; }
.new-procedure-form {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #f7fbfb;
  padding: 18px;
  margin-bottom: 22px;
}
.new-procedure-heading h3 { margin: 0 0 4px; font-size: 17px; }
.new-procedure-heading p { margin: 0 0 14px; color: var(--muted); font-size: 12px; }
.new-procedure-grid {
  display: grid;
  grid-template-columns: 1.4fr .7fr 1fr;
  gap: 12px;
  align-items: end;
}
.new-procedure-aliases { grid-column: 1 / -1; }
.config-add-action { display: flex; justify-content: flex-end; margin-top: 14px; }
.procedure-config-list { display: grid; gap: 12px; }
.config-procedure-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 15px;
  background: white;
}
.config-procedure-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}
.config-procedure-heading > div { display: grid; gap: 3px; }
.config-procedure-heading strong { font-size: 15px; }
.config-procedure-heading span { font-size: 11px; color: var(--muted); }
.config-active-toggle {
  display: flex;
  grid-auto-flow: column;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
}
.config-active-toggle input { width: auto; }
.config-procedure-fields {
  display: grid;
  grid-template-columns: 180px 230px 1fr;
  gap: 12px;
}
.config-aliases-field { min-width: 0; }
.config-card-actions { display: flex; justify-content: flex-end; margin-top: 12px; }

@media (max-width: 850px) {
  .procedure-options { grid-template-columns: 1fr; }
  .new-procedure-grid, .config-procedure-fields { grid-template-columns: 1fr; }
  .new-procedure-aliases { grid-column: auto; }
  .config-procedure-heading { align-items: flex-start; flex-direction: column; }
}
