:root {
  /* Colores principales basados en el logo */
  --primary: #0b69a3;
  /* Celeste turquesa del logo */
  --primary-dark: #004aad;
  /* Celeste más oscuro */
  --primary-light: #89bff7;
  /* Celeste más claro */
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --text: #273444;
  /* Gris oscuro para texto */
  --text-secondary: #456e83;
  /* Gris medio */
  --muted: #6b7c86;
  /* Gris para texto muted */
  --border: #e8eef3;
  /* Gris muy claro para bordes */
  --background: #ffffff;
  --background-alt: #ffffff;
  /* Gris clarísimo para fondos */
  --gap-under-header: 12px;
  --radius-sm: 8px;
  --radius: 8px;
  --radius-lg: 8px;
  --shadow-sm: 0 1px 2px 0 rgba(44, 62, 80, 0.05);
  --shadow: 0 1px 3px 0 rgba(44, 62, 80, 0.1), 0 1px 2px -1px rgba(44, 62, 80, 0.1);
  --shadow-md: 0 4px 6px -1px rgba(44, 62, 80, 0.1), 0 2px 4px -2px rgba(44, 62, 80, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(44, 62, 80, 0.1), 0 4px 6px -4px rgba(44, 62, 80, 0.1);
}


/* Layout */
*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  margin: 0;
  background: #ffffff;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.landing-page,
.login-page {
  min-height: 100vh;
  background: #ffffff;
}

.landing-page {
  display: flex;
  flex-direction: column;
}

.landing-page main {
  flex: 1;
  display: flex;
  min-height: 0;
}

.public-topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 16px 32px;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 8px 24px rgba(11, 105, 163, 0.05);
  backdrop-filter: blur(12px);
}

.public-brand {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  color: var(--text);
  text-decoration: none;
  min-width: 245px;
}

.public-brand img {
  width: 58px;
  height: 58px;
  object-fit: contain;
  flex: 0 0 auto;
}

.public-brand strong,
.public-brand span {
  display: block;
}

.public-brand strong {
  font-size: 18px;
  line-height: 1.2;
}

.public-brand span {
  color: var(--muted);
  font-size: 13px;
}

.public-nav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.public-nav a {
  color: #687782;
  font-weight: 700;
  text-decoration: none;
  padding: 9px 12px;
  border-radius: 8px;
}

.public-nav a:hover,
.public-login {
  color: #33424d;
  background: #f6f8fa;
}

.landing-hero {
  display: grid;
  grid-template-columns: minmax(520px, 0.86fr) minmax(480px, 1.14fr);
  align-items: center;
  gap: 0;
  width: 100%;
  max-width: 1480px;
  min-height: 0;
  height: 100%;
  margin: 0 auto;
  padding: 16px 24px 10px;
  position: relative;
  overflow: hidden;
}

.landing-copy {
  max-width: 650px;
  position: relative;
  z-index: 2;
}

.landing-domain {
  margin: 0 0 12px;
  color: var(--primary);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
}

.landing-copy h1 {
  margin: 0;
  color: #273444;
  font-size: 68px;
  line-height: 1.02;
  letter-spacing: 0;
}

.landing-tagline {
  margin: 12px 0 0;
  color: var(--primary-dark);
  font-size: 27px;
  font-weight: 800;
}

.landing-description {
  margin: 18px 0 0;
  max-width: 620px;
  color: var(--text-secondary);
  font-size: 19px;
  line-height: 1.7;
}

.landing-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 26px;
  flex-wrap: wrap;
}

.landing-actions a {
  text-decoration: none;
}

.history-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.history-header h2 {
  margin-bottom: 0;
}

.history-search {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.history-results {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.psych-assignment-list {
  max-height: 430px;
  overflow-y: auto;
  padding-right: 6px;
  overscroll-behavior: contain;
}

.history-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px 0;
  border-top: 1px solid var(--border);
}

.history-title {
  color: var(--text);
  font-weight: 800;
}

.history-meta {
  color: var(--muted);
  font-size: 13px;
}

.history-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.psych-header,
.psych-layout {
  display: grid;
  gap: 14px;
}

.psych-header {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
}

.psych-header h2,
.psych-panel h3 {
  margin-top: 0;
}

.psych-layout {
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
}

.psych-panel {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
  margin-top: 12px;
}

.psych-areas {
  display: grid;
  gap: 8px;
}

.psych-area {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f8fbfd;
}

.psych-area summary {
  cursor: pointer;
  font-weight: 800;
  padding: 10px 12px;
}

.psych-test-row {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) auto;
  gap: 4px 10px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  color: var(--text-secondary);
}

.psych-test-row small {
  grid-column: 1 / -1;
}

.psych-test-row.is-available {
  background: #fff;
  color: var(--text);
}

.psych-test-row.is-muted {
  color: var(--muted);
}

.psych-actions {
  margin-top: 12px;
}

.psych-status {
  min-height: 24px;
  margin-top: 10px;
}

.psych-status.ok {
  color: #15803d;
}

.psych-status.error {
  color: #b91c1c;
}

.psych-result-viewer {
  margin-top: 16px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f8fafc;
}

.psych-result-viewer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.psych-result-viewer-header h3 {
  margin: 0;
}

.psych-result-viewer .page-patient {
  margin-bottom: 14px;
}

.psych-result-viewer .psych-pdf-section:last-child {
  margin-bottom: 0;
}

.psych-link-box {
  display: grid;
  gap: 6px;
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid #cfe7f3;
  border-radius: 8px;
  background: #f2f9fc;
  overflow-wrap: anywhere;
}

.psych-link-box a {
  color: var(--primary-dark);
  font-weight: 700;
}

.psych-linked-result {
  border-radius: 8px;
  outline: 3px solid rgba(16, 185, 129, 0.35);
  outline-offset: 4px;
  background: #f0fdf4;
}

.psych-public-page {
  min-height: 100vh;
  background: #f6f9fb;
}

.psych-public-shell {
  width: min(100%, 1060px);
  margin: 0 auto;
  padding: 24px 18px 48px;
}

.psych-public-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(11, 105, 163, 0.06);
  padding: 22px;
}

.psych-public-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: start;
  margin-bottom: 16px;
}

.psych-public-heading h1 {
  margin: 0;
  font-size: 34px;
  line-height: 1.15;
}

.psych-public-progress {
  min-width: 82px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f4f8fb;
  color: var(--primary-dark);
  font-weight: 800;
  padding: 8px 10px;
  text-align: center;
}

.psych-progress-track {
  height: 8px;
  border-radius: 999px;
  background: #e9f0f5;
  overflow: hidden;
  margin: 16px 0;
}

.psych-progress-track span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--primary);
  transition: width 180ms ease;
}

.psych-public-questions {
  position: relative;
  display: grid;
  gap: 12px;
  min-height: 0;
}

.psych-public-question {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
  display: none;
  opacity: 0;
  transform: translateX(18px);
}

.psych-public-question.active {
  display: block;
  animation: psychQuestionIn 320ms ease forwards;
}

.psych-public-question.leaving-forward,
.psych-public-question.leaving-back {
  display: block;
}

.psych-public-question.leaving-forward {
  animation: psychQuestionOutForward 220ms ease forwards;
}

.psych-public-question.leaving-back {
  animation: psychQuestionOutBack 220ms ease forwards;
}

.psych-public-question.missing {
  border-color: #f59e0b;
  background: #fffaf0;
}

.psych-public-question legend {
  padding: 0;
  margin-bottom: 10px;
  font-weight: 800;
  color: var(--text);
}

.psych-public-question legend span {
  color: var(--primary-dark);
}

.psych-public-options {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.psych-public-option {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  min-height: 58px;
  padding: 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}

.psych-public-option:hover {
  border-color: var(--primary);
}

.psych-public-option input {
  margin-top: 3px;
  accent-color: var(--primary);
}

.psych-public-response-group + .psych-public-response-group {
  margin-top: 16px;
}

.psych-public-response-label {
  display: block;
  margin: 0 0 8px;
  color: var(--primary-dark);
  font-weight: 800;
}

.psych-public-distress {
  display: none;
  border-top: 1px solid var(--border);
  padding-top: 14px;
}

.psych-public-distress.visible {
  display: block;
  animation: psychQuestionIn 240ms ease forwards;
}

.psych-test-selector {
  max-width: 620px;
  margin: 12px 0;
}

.psych-test-title {
  margin: -2px 0 8px;
  font-size: 12px;
}

.psych-public-nav {
  margin-top: 12px;
  justify-content: center;
}

.psych-public-actions {
  margin-top: 10px;
  justify-content: center;
}

.psych-public-nav .btn,
.psych-public-actions .btn {
  padding: 8px 11px;
  font-size: 13px;
}

.psych-public-nav .btn.next-ready {
  background: #10b981;
  border-color: #10b981;
  color: #fff;
}

.psych-public-nav .btn.next-ready:hover,
.psych-public-nav .btn.next-ready:focus-visible {
  background: #059669;
  border-color: #059669;
}

.psych-public-downloads {
  margin-top: 16px;
}

.psych-download-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f8fbfd;
  padding: 16px;
}

.psych-download-card h2 {
  margin-top: 0;
}

.psych-score-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.psych-score-summary > div,
.psych-disclaimer,
.psych-interpretation {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  background: #f8fbfd;
}

.psych-disclaimer,
.psych-interpretation {
  margin: 10px 0 0;
}

.psych-pdf-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.psych-pdf-table th,
.psych-pdf-table td {
  border: 1px solid #dbe5ec;
  padding: 5px 6px;
  text-align: left;
  vertical-align: top;
}

.psych-pdf-table th {
  background: #f3f7fa;
  font-weight: 800;
}

.psych-pdf-table--answers td:nth-child(1),
.psych-pdf-table--answers td:nth-child(4) {
  width: 42px;
  text-align: center;
}

.psych-pdf-note {
  margin-top: 10px;
  border-top: 1px solid #d1d5db;
  padding-top: 8px;
  color: #4b5563;
  font-size: 11px;
  text-align: center;
}

.page--psychometrics-summary {
  width: 190mm;
  min-height: 0;
}

.page--psychometrics-summary .page-inner {
  padding: 8mm 9mm;
}

.page--psychometrics-summary .page-header img {
  max-height: 13mm;
}

.page--psychometrics-summary .page-patient {
  font-size: 11px;
  gap: 5px;
}

.page--psychometrics-summary .page-body {
  margin-top: 7px;
}

.page--psychometrics-summary .doc-title {
  margin-bottom: 4px;
  font-size: 16px;
}

.page--psychometrics-summary .psych-score-summary {
  gap: 6px;
}

.page--psychometrics-summary .psych-score-summary > div,
.page--psychometrics-summary .psych-disclaimer,
.page--psychometrics-summary .psych-interpretation {
  padding: 6px 7px;
  font-size: 11px;
  line-height: 1.28;
}

.page--psychometrics-summary .psych-pdf-table {
  font-size: 10.5px;
}

.page--psychometrics-summary .psych-pdf-table th,
.page--psychometrics-summary .psych-pdf-table td {
  padding: 4px 5px;
}

.page--psychometrics-summary .page-footer,
.page--psychometrics .page-footer {
  margin-top: 8px;
  padding-top: 7px;
  font-size: 10px;
  line-height: 1.25;
}

.page--psychometrics-summary .psych-pdf-note,
.page--psychometrics .psych-pdf-note {
  margin-top: 5px;
  padding-top: 5px;
  font-size: 9.5px;
  line-height: 1.25;
}

.psych-public-print-host {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 2147483647;
  width: 210mm;
  background: #fff;
  pointer-events: none;
}

.psych-public-print-host .page {
  box-shadow: none;
  border: 0;
  border-radius: 0;
}

@keyframes psychQuestionIn {
  from {
    opacity: 0;
    transform: translateX(18px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes psychQuestionOutForward {
  from {
    opacity: 1;
    transform: translateX(0);
  }

  to {
    opacity: 0;
    transform: translateX(-18px);
  }
}

@keyframes psychQuestionOutBack {
  from {
    opacity: 1;
    transform: translateX(0);
  }

  to {
    opacity: 0;
    transform: translateX(18px);
  }
}

@media (max-width: 900px) {
  .psych-layout,
  .psych-public-options,
  .psych-score-summary {
    grid-template-columns: 1fr;
  }

  .psych-public-heading,
  .psych-header {
    grid-template-columns: 1fr;
  }
}

.pdf-margin-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
}

.pdf-margin-controls label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.pdf-margin-controls input {
  width: 64px;
  padding: 6px 8px;
}

.email-confirm-panel {
  position: fixed;
  inset: 0;
  z-index: 12000;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(15, 23, 42, 0.38);
  color: var(--text);
}

.email-confirm-panel.hidden {
  display: none;
}

.email-confirm-dialog {
  width: min(980px, 100%);
  max-height: min(92vh, 920px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto auto;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.28);
}

.email-confirm-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.email-confirm-header strong,
.email-confirm-header span {
  display: block;
}

.email-confirm-header span {
  color: var(--muted);
}

.email-preview-frame-wrap {
  min-height: min(62vh, 620px);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: #f8fafc;
}

.email-preview-frame-wrap.hidden,
.email-modal-tools.hidden,
.pdf-margin-controls.hidden {
  display: none;
}

.email-preview-frame {
  display: block;
}

#emailPreviewFrame {
  width: 100%;
  height: min(62vh, 620px);
  border: 0;
  background: #fff;
}

.email-modal-tools {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.email-confirm-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.pwa-toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 3000;
  display: flex;
  align-items: center;
  gap: 16px;
  max-width: min(560px, calc(100vw - 32px));
  padding: 12px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: #eff6ff;
  box-shadow: var(--shadow-lg);
  color: #1e3a8a;
}

.pwa-toast[hidden] {
  display: none;
}

.pwa-toast-text {
  min-width: 0;
}

.pwa-toast-text strong,
.pwa-toast-text span {
  display: block;
}

.pwa-toast-text span {
  color: #1d4ed8;
  font-size: 13px;
}

.pwa-toast-actions {
  display: flex;
  gap: 8px;
  flex: 0 0 auto;
}

@media (max-width:700px) {
  .history-search,
  .history-item {
    grid-template-columns: 1fr;
  }

  .history-actions {
    justify-content: flex-start;
  }

  .email-confirm-panel {
    place-items: stretch;
  }

  .email-confirm-actions {
    justify-content: flex-start;
  }

  .pwa-toast {
    left: 12px;
    right: 12px;
    bottom: 12px;
    align-items: stretch;
    flex-direction: column;
  }

  .pwa-toast-actions {
    justify-content: flex-start;
  }
}

.landing-art {
  position: absolute;
  inset: 0 0 0 42%;
  z-index: 0;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  min-height: 0;
  height: 100%;
  margin-right: 0;
  isolation: isolate;
  overflow: hidden;
}

.landing-gallery {
  --gallery-offset: 0%;
  position: relative;
  width: min(52vw, calc(100vh - 120px), 820px);
  aspect-ratio: 1;
  height: auto;
  overflow: hidden;
  background: transparent;
}

.landing-gallery-track {
  display: flex;
  width: 100%;
  height: 100%;
  transform: translate3d(var(--gallery-offset), 0, 0);
  transition: transform 1500ms cubic-bezier(0.45, 0, 0.15, 1);
  will-change: transform;
}

.landing-slide {
  flex: 0 0 100%;
  width: 100%;
  height: 100%;
}

.landing-slide img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  background: transparent;
}

.landing-gallery-dots {
  position: absolute;
  left: 50%;
  bottom: 22px;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 8px 22px rgba(10, 55, 86, 0.18);
  opacity: 0;
  transform: translate(-50%, 8px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.landing-gallery:hover .landing-gallery-dots,
.landing-gallery:focus-within .landing-gallery-dots {
  opacity: 1;
  transform: translate(-50%, 0);
}

.landing-gallery-dots button {
  width: 11px;
  height: 11px;
  border: 0;
  border-radius: 999px;
  padding: 0;
  background: rgba(61, 87, 101, 0.42);
  cursor: pointer;
  transition: background 160ms ease, transform 160ms ease, width 160ms ease;
}

.landing-gallery-dots button:hover,
.landing-gallery-dots button:focus-visible {
  background: var(--primary);
  outline: 2px solid rgba(11, 105, 163, 0.24);
  outline-offset: 3px;
}

.landing-gallery-dots button.is-active {
  width: 26px;
  background: var(--primary-dark);
}

.public-footer {
  flex-shrink: 0;
  width: calc(100% - 48px);
  max-width: 1280px;
  margin: 0 auto;
  padding: 14px 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  color: var(--text-secondary);
  border-top: 1px solid var(--border);
  font-size: 13px;
}

@media (min-width: 821px) {
  .landing-page {
    height: 100vh;
    overflow: hidden;
  }

  .landing-copy {
    margin-left: clamp(12px, 4vw, 56px);
    max-width: 680px;
  }

  .landing-description {
    max-width: 660px;
    font-size: 18px;
  }
}

@media (min-width: 821px) and (max-height: 780px) {
  .public-topbar {
    padding-top: 10px;
    padding-bottom: 10px;
  }

  .public-brand img {
    width: 50px;
    height: 50px;
  }

  .landing-hero {
    padding-top: 10px;
    padding-bottom: 8px;
  }

  .landing-domain {
    margin-bottom: 8px;
    font-size: 12px;
  }

  .landing-copy h1 {
    font-size: 54px;
  }

  .landing-tagline {
    margin-top: 8px;
    font-size: 23px;
  }

  .landing-description {
    margin-top: 14px;
    font-size: 17px;
    line-height: 1.55;
  }

  .landing-actions {
    margin-top: 18px;
  }

  .public-footer {
    padding-top: 8px;
    padding-bottom: 10px;
    font-size: 12px;
  }

  .public-footer strong {
    font-size: 14px;
  }
}

.public-footer strong,
.public-footer span {
  display: inline;
  white-space: nowrap;
}

.public-footer strong {
  color: var(--text);
  font-size: 16px;
}

.login-shell {
  min-height: calc(100vh - 82px);
  display: grid;
  place-items: center;
  padding: 44px 18px;
}

.login-panel {
  width: min(100%, 460px);
  padding: 34px;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 16px 42px rgba(11, 105, 163, 0.08);
}

.login-panel h1 {
  margin: 0;
  font-size: 34px;
  line-height: 1.1;
}

.login-panel p {
  margin: 10px 0 0;
  color: var(--text-secondary);
}

.login-form {
  display: grid;
  gap: 18px;
  margin-top: 28px;
}

.login-form .btn {
  width: 100%;
}

.login-error {
  margin: -6px 0 0;
  color: #991b1b;
  font-weight: 700;
}

.account-card {
  border-color: #b8d9ef;
  background: #f8fcff;
}

.account-status {
  min-height: 22px;
  margin: 12px 0 0;
}

.invite-history {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.invite-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

.invite-item strong,
.invite-item span {
  overflow-wrap: anywhere;
}

.invite-item span {
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 820px) {
  .public-topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 12px;
  }

  .public-nav {
    justify-content: flex-start;
  }

  .landing-hero {
    grid-template-columns: 1fr;
    min-height: auto;
    padding: 42px 12px 28px;
  }

  .landing-copy h1 {
    font-size: 46px;
  }

  .landing-tagline {
    font-size: 22px;
  }

  .landing-description {
    font-size: 16px;
  }

  .landing-art {
    position: relative;
    inset: auto;
    justify-content: center;
    min-height: 320px;
    height: auto;
    margin-right: 0;
    margin-top: 8px;
  }

  .landing-gallery {
    width: min(94vw, 520px);
    height: min(94vw, 520px);
    min-height: 0;
    aspect-ratio: 1;
  }

  .landing-gallery-dots {
    opacity: 1;
  }

  .landing-gallery-dots {
    bottom: 14px;
    transform: translate(-50%, 0);
  }

  .public-footer {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    width: calc(100% - 24px);
    margin-left: 12px;
    margin-right: 12px;
    padding-left: 0;
    padding-right: 0;
  }

  .public-footer strong,
  .public-footer span {
    white-space: normal;
  }
}

.container {
  max-width: 1160px;
  margin: 22px auto;
  padding: 0 18px
}

.card {
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: 0 8px 28px rgba(11, 105, 163, 0.06);
  transition: all 0.2s ease;
}

.card:hover {
  box-shadow: 0 12px 34px rgba(11, 105, 163, 0.08);
  border-color: #d5e6f4;
}

.card h2 {
  margin: 0 0 20px 0;
  font-size: 19px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

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

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px
}

@media (max-width:900px) {
  .grid-4 {
    grid-template-columns: repeat(2, 1fr)
  }
}

@media (max-width:500px) {
  .grid-4 {
    grid-template-columns: 1fr
  }
}

@media (max-width:700px) {
  .grid-3 {
    grid-template-columns: 1fr
  }

  .grid-2 {
    grid-template-columns: 1fr
  }

  /* Mejoras adicionales para móvil */
  .app-topbar {
    padding: 6px 10px;
  }

  .brand {
    gap: 6px;
  }

  .brand-logo {
    max-height: 26px;
  }

  .logo-circle {
    width: 28px;
    height: 28px;
    font-size: 11px;
  }

  .brand-text h1 {
    font-size: 10px;
    line-height: 1.2;
  }

  .brand-text p {
    font-size: 8px;
    line-height: 1.2;
  }

  .topnav {
    gap: 6px;
  }

  .topnav .btn {
    padding: 8px 12px;
    font-size: 11px;
    /* Botones un poco más grandes para touch */
  }

  .container {
    padding: 0 12px;
    margin: 16px auto;
  }

  .card {
    padding: 14px;
    margin-bottom: 12px;
  }

  .btn {
    padding: 8px 10px;
    font-size: 12px;
  }

  .field input,
  .field textarea,
  .field select {
    font-size: 16px;
    /* Evita zoom en iOS */
  }

  .actions-row {
    flex-direction: column;
    gap: 8px;
  }

  .actions-row .btn {
    width: 100%;
  }

  .sticky-actions {
    padding: 12px 14px;
  }

  .sticky-actions .muted {
    font-size: 11px;
  }
}

.field label {
  display: block;
  margin-bottom: 8px;
  color: #334155;
  font-weight: 600;
  font-size: 14px;
}

.field input[type="text"],
.field input[type="number"],
.field input[type="date"],
.field input[type="tel"],
.field input[type="email"],
.field input[type="password"],
.field select,
textarea {
  width: 100%;
  background: white;
  color: var(--text);
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  transition: all 0.2s;
}

.field input:focus,
.field select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

textarea {
  resize: vertical;
  min-height: 80px;
}

.divider {
  grid-column: 1 / -1;
  height: 1px;
  background: var(--border);
  margin: 6px 0
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px
}

.instrument-restricted {
  display: none !important;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 12px;
  cursor: pointer
}

.chip input {
  accent-color: var(--primary)
}

.btn {
  border: 1px solid var(--border);
  background: white;
  color: var(--text);
  padding: 10px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  text-decoration: none;
}

.btn.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff
}


.btn.secondary {
  background: #f4f8fb;
  color: var(--primary-dark)
}

.btn.danger {
  background: #fee2e2;
  border-color: #fecaca;
  color: #7f1d1d
}

.btn:active {
  transform: translateY(1px)
}

.actions-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap
}

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

.sticky-actions {
  position: static;
  bottom: 0;
  z-index: auto;
  background: #ffffff;
  box-shadow: 0 8px 28px rgba(11, 105, 163, 0.06)
}

.subsections details {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 10px;
  background: #fff
}

.subsections summary {
  cursor: pointer;
  font-weight: 700
}

.hidden {
  display: none
}

.preview-wrapper {
  margin-top: 16px
}

.print-area {
  display: flex;
  flex-direction: column;
  gap: 16px
}

.hero-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 430px);
  align-items: center;
  gap: 28px;
  min-height: 270px;
  margin: 18px 0 22px;
  padding: 30px 0 28px;
  border-bottom: 1px solid var(--border);
}

.hero-copy {
  max-width: 640px;
}

.hero-kicker {
  margin: 0 0 10px;
  color: var(--primary);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
}

.hero-copy h2 {
  margin: 0;
  max-width: 620px;
  color: #273444;
  font-size: 42px;
  line-height: 1.08;
  letter-spacing: 0;
}

.hero-copy p:not(.hero-kicker) {
  max-width: 540px;
  margin: 14px 0 0;
  color: var(--text-secondary);
  font-size: 17px;
  line-height: 1.6;
}

.hero-art {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  min-height: 250px;
  overflow: hidden;
}

.hero-art img {
  width: min(100%, 390px);
  aspect-ratio: 1;
  object-fit: contain;
  animation: heroFloat 7s ease-in-out infinite;
  filter: drop-shadow(0 18px 28px rgba(11, 105, 163, 0.14));
}

@keyframes heroFloat {
  0%, 100% {
    transform: translateY(0) rotate(0deg);
  }

  50% {
    transform: translateY(-10px) rotate(1deg);
  }
}

@media (max-width:900px) {
  .hero-shell {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .hero-art {
    justify-content: center;
    min-height: 190px;
  }

  .hero-art img {
    width: min(72vw, 330px);
  }

  .hero-copy h2 {
    font-size: 32px;
  }
}

/* === Page layout === */
.page {
  background: white;
  color: #111827;
  border-radius: 12px;
  overflow: visible;
  border: 1px solid #e5e7eb
}

.print-area .page:not(:last-child) {
  break-after: page;
  page-break-after: always;
}

.page-inner {
  padding: 16px 22px 16px 22px;
  display: flex;
  flex-direction: column
}

.page-header {
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid #d1d5db;
  padding-bottom: 6px
}

.page-header img {
  max-height: 1.8cm;
  width: auto;
  height: auto
}

.page-header .hdr-title {
  font-weight: 800;
  font-size: 16px
}

.page-patient {
  font-size: 14px;
  margin-top: 6px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px
}

@media (max-width:700px) {
  .page-patient {
    grid-template-columns: 1fr 1fr
  }
}

.page-body {
  flex: 1 1 auto;
  margin-top: var(--gap-under-header);
  overflow-wrap: anywhere;
  word-break: normal;
}

.page--medical-report {
  overflow: visible;
}

.page--medical-report .page-inner {
  overflow: visible;
}

.page--medical-report .page-body {
  line-height: 1.45;
}

.medical-report-section {
  break-inside: auto;
  page-break-inside: auto;
}

.medical-report-text {
  white-space: normal;
  overflow-wrap: break-word;
  word-break: normal;
  line-height: 1.48;
}

.medical-report-line {
  margin: 0 0 7px;
  break-inside: avoid;
  page-break-inside: avoid;
  orphans: 3;
  widows: 3;
}

.medical-report-text br {
  line-height: 1.48;
}

.page--peritaje .peritaje-body p,
.page--peritaje .peritaje-body li,
.page--peritaje .peritaje-body h1,
.page--peritaje .peritaje-body h2,
.page--peritaje .peritaje-body h3 {
  break-inside: avoid;
  page-break-inside: avoid;
}

/* columns for page 1 only */
.columns-2 {
  column-count: 2;
  column-gap: 16px
}

.columns-2 .section {
  break-inside: avoid;
  page-break-inside: avoid
}

.section-title {
  font-weight: 800;
  margin: 0 0 6px 0;
  border-top: 2px solid #e5e7eb;
  padding-top: 8px
}

ul.clean {
  margin: 6px 0 10px 18px
}

ul.clean li {
  margin: 2px 0
}

.page-sign {
  margin-top: 6px;
  border-top: 1px dashed #e5e7eb;
  padding-top: 6px;
  display: flex;
  align-items: flex-end;
  gap: 16px;
  justify-content: flex-start
}

.sign-firma {
  max-height: 2cm;
  height: auto;
  width: auto
}

.sign-timbre {
  max-height: 2cm;
  height: auto;
  width: auto
}

.sign-id {
  font-size: 12px;
  margin-top: 4px
}

.page-footer {
  margin-top: 6px;
  border-top: 1px solid #e5e7eb;
  padding-top: 6px;
  text-align: center;
  font-size: 9pt;
  color: #444
}

.page--exam-labs .page-inner,
.page--ges .page-inner {
  min-height: auto;
}

.page--exam-labs .page-body,
.page--ges .page-body,
.page--exam-cardio .page-body,
.page--exam-imaging .page-body {
  flex: 1 1 auto;
}

.page--exam-labs .section-title {
  margin-bottom: 4px;
  padding-top: 5px;
}

.page--exam-labs ul.clean {
  margin: 4px 0 6px 16px;
}

.page--exam-labs ul.clean li {
  margin: 0;
  line-height: 1.22;
}

.page--ges .ges-box {
  margin-bottom: 6px;
  padding: 8px;
}

.page--ges .ges-box h4 {
  margin: 0 0 5px;
}

/* Footer en todas las páginas del PDF */
@media print {
  .page-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    margin: 0;
    padding: 6px 18mm;
    border-top: 1px solid #ccc;
    background: white;
    font-size: 9pt;
    z-index: 100;
  }

  /* Espacio reservado para el footer fijo */
  .page-body {
    padding-bottom: 8mm;
  }

  /* Ocultar cualquier ícono generado por el navegador en el footer */
  .page-footer::before,
  .page-footer::after {
    content: none !important;
    display: none !important;
  }

  /* Ocultar TODOS los íconos, imágenes y SVGs en el footer */
  .page-footer img,
  .page-footer svg,
  .page-footer span[style*="background"],
  .page-footer::before,
  .page-footer *::before,
  .page-footer *::after {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    width: 0 !important;
    height: 0 !important;
  }

  /* Asegurar que el footer solo muestre texto */
  .page-footer {
    font-size: 9pt !important;
    line-height: 1.2 !important;
  }

  /* Ocultar el widget flotante de tareas en el PDF */
  .tasks-widget,
  #tasks-widget {
    display: none !important;
    visibility: hidden !important;
  }
}

/* Lists in generated sections */
.page .section ol {
  margin: 6px 0 8px 18px
}

.page .section ul {
  margin: 6px 0 8px 18px
}

.page .section li {
  margin: 2px 0
}

/* === Peritajes editor normalization === */
#peritajeTexto {
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, 'Helvetica Neue', Arial;
  font-size: 11px;
  line-height: 1.3;
  /* Reducido de 1.5 a 1.3 para menos espacio entre líneas */
  text-align: justify;
  outline: none;
  white-space: pre-wrap;
}



#peritajeTexto p {
  margin: 0 0 4pt 0;
  /* Reducido de 8pt a 4pt para menos espacio entre párrafos */
}

/* un poco de espacio entre párrafos */
#peritajeTexto ul,
#peritajeTexto ol {
  margin: 0 0 0 1.2em;
  padding: 0;
}

#peritajeTexto li {
  margin: 0;
}

/* === Peritajes generated body === */
.peritaje-body {
  font-size: 10px;
  line-height: 1.3;
  text-align: justify;
}

.peritaje-body p {
  margin: 0 0 6pt 0 !important;
}

.peritaje-body ul,
.peritaje-body ol {
  margin: 4pt 0 6pt 16pt !important;
  padding: 0 !important;
}

.peritaje-body li {
  margin: 2pt 0 !important;
}

/* === Print rules === */
@media print {
  @page {
    size: A4;
    margin: 22mm 25mm 20mm 25mm;
    /* top right bottom left */
  }

  body {
    background: white
  }

  .app-topbar,
  .actions,
  .actions-row,
  .email-confirm-panel,
  .card:not(.keep),
  .topnav,
  .chips,
  .subsections details>summary {
    display: none !important;
  }

  .print-area {
    gap: 0 !important;
  }

  /* evita espacio extra que puede crear hoja en blanco */
  .page {
    page-break-after: always;
    break-after: page;
    border: none;
    border-radius: 0;
    margin: 0;
    padding: 0;
    break-inside: avoid
  }

  .page:last-child {
    page-break-after: avoid;
    break-after: avoid;
  }

  .columns-2 {
    font-size: 12.2px;
    line-height: 1.25
  }

  /* Peritaje en impresión */
  .peritaje-body {
    font-size: 11pt !important;
    line-height: 1.35 !important;
    text-align: justify !important;
  }

  .peritaje-body p {
    margin: 0 0 5pt 0 !important;
  }

  .peritaje-body ul,
  .peritaje-body ol {
    margin: 3pt 0 5pt 18pt !important;
    padding: 0 !important;
  }
}

.grid-4 .field {
  margin-bottom: 6px
}

.app-topbar .brand {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-logo {
  max-height: 54px;
  max-width: 170px;
  width: auto;
  object-fit: contain
}

.logo-circle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: white;
  font-weight: 800;
  font-size: 18px
}


.brand-text h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--text)
}

.brand-text p {
  margin: 0;
  font-size: 13px;
  color: var(--muted)
}

.topnav {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.topbar-history {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: min(420px, 44vw);
  max-width: 520px;
}

.topbar-history input {
  flex: 1 1 auto;
  min-width: 190px;
  min-height: 38px;
  border: 1px solid #dbe7ef;
  border-radius: 999px;
  background: #f8fafc;
  padding: 8px 14px;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  outline: none;
  transition: border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.topbar-history-submit {
  min-height: 38px;
  border: 1px solid #d8e8f2;
  border-radius: 999px;
  background: #f8fafc;
  color: #3f5668;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.topbar-history-submit:hover,
.topbar-history-submit:focus-visible {
  background: #f2f7fb;
  border-color: #8bc7df;
  color: var(--primary-dark);
  box-shadow: 0 6px 16px rgba(11, 105, 163, 0.08);
  outline: none;
}

.topbar-history input:focus {
  background: #ffffff;
  border-color: #8bc7df;
  box-shadow: 0 0 0 3px rgba(11, 105, 163, 0.12);
}

.topbar-history-status {
  position: absolute;
  right: 84px;
  top: calc(100% + 3px);
  max-width: 110px;
  color: var(--muted);
  font-size: 11px;
  pointer-events: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-history input:not(:placeholder-shown) {
  padding-right: 14px;
}

.topbar-history-results {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 90;
  display: grid;
  gap: 0;
  width: min(560px, calc(100vw - 24px));
  max-height: min(70vh, 560px);
  overflow: auto;
  border: 1px solid #dbe7ef;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 18px 42px rgba(15, 23, 42, 0.16);
}

.topbar-history-results.hidden {
  display: none;
}

.topbar-history-item {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border-top: 1px solid #e8eef3;
}

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

.topbar-history-kind {
  color: var(--primary-dark);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.topbar-history-title {
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
  line-height: 1.25;
}

.topbar-history-meta {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.topbar-history-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.topnav .topbar-history-actions .btn {
  min-height: 30px;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 12px;
}

.topbar-history-empty {
  padding: 14px;
  color: var(--muted);
  font-size: 13px;
}

.topnav .btn {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 8px 14px;
  background: transparent;
  color: #3f5668;
  box-shadow: none;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.topnav .btn:hover,
.topnav .btn:focus-visible {
  background: #f2f7fb;
  border-color: #d8e8f2;
  color: var(--primary-dark);
  box-shadow: 0 6px 16px rgba(11, 105, 163, 0.08);
  outline: none;
}

.topnav .btn[data-logout] {
  background: #f8fafc;
  border-color: #e2e8f0;
  color: #475569;
}

.topnav .btn[data-logout]:hover,
.topnav .btn[data-logout]:focus-visible {
  background: #fff5f5;
  border-color: #fecaca;
  color: #991b1b;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 0 1 auto;
  min-width: 0;
}

.user-display {
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.logout-btn {
  padding: 8px 14px !important;
  font-size: 13px !important;
  background: #fee2e2 !important;
  border-color: #fecaca !important;
  color: #7f1d1d !important;
  white-space: nowrap;
}

.logout-btn:hover {
  background: #fecaca !important;
}

.app-topbar {
  background: white;
  border-bottom: 1px solid var(--border);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 8px 24px rgba(11, 105, 163, 0.05)
}

@media (max-width: 700px) {
  .app-topbar {
    flex-wrap: wrap;
    align-items: flex-start;
  }

  .app-topbar .brand {
    flex: 1 1 100%;
    min-width: 0;
  }

  .user-info {
    order: 2;
    width: 100%;
    justify-content: space-between;
    margin-top: 6px;
  }

  .user-display {
    font-size: 12px;
    max-width: 60vw;
  }

  .topnav {
    order: 3;
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
    margin-top: 6px;
  }

  .topbar-history {
    flex: 1 1 100%;
    min-width: 100%;
    max-width: 100%;
  }

  .topbar-history-results {
    left: 0;
    right: auto;
    width: min(100%, calc(100vw - 18px));
  }
}

@media (max-width: 600px) {
  .app-topbar {
    padding: 6px 8px;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: space-between;
  }

  .brand {
    flex: 1;
    min-width: 0;
    /* Permite que el flex se encoja correctamente */
  }

  .brand-logo {
    max-height: 28px;
  }

  .logo-circle {
    width: 28px;
    height: 28px;
    font-size: 12px;
  }

  .brand-text h1 {
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Ocultar subtítulo en pantallas muy pequeñas */
  .brand-text p {
    display: none;
  }

  .topnav {
    flex-shrink: 0;
    display: flex;
    gap: 4px;
    align-items: center;
  }

  .topbar-history {
    order: 5;
    flex: 1 1 100%;
    min-width: 100%;
  }

  .topnav .btn {
    padding: 6px 8px;
    /* Reducir padding botones */
    font-size: 11px;
    white-space: nowrap;
  }

  /* Ajuste específico para el botón instalar */
  #btnInstallApp {
    padding: 6px 8px;
    font-size: 11px;
    /* Icono solo si hay poco espacio? No, dejémoslo visible */
  }

  .toolbar-btn {
    min-width: 36px;
    height: 36px;
  }
}

/* === MODIFICACIÓN PWA: Ocultar título en la App Instalada === */
@media (display-mode: standalone) {
  #brand-title {
    display: none;
  }

  /* Ajuste opcional: centrar logo si se quita el texto */
  .brand-text {
    display: none;
    /* Ocultamos todo el texto de marca en modo app para ahorrar espacio */
  }

  .app-topbar {
    justify-content: space-between;
  }

  .brand {
    flex: 0 1 auto;
  }
}


@media print {

  /* Patient meta as vertical list to allow full-width name */
  .page-patient {
    display: block !important;
    grid-template-columns: initial !important;
  }

  .page-patient>div {
    margin: 2mm 0;
  }
}

/* === Patch: más espacio entre campos en "Datos del paciente" === */
.container>.card:first-of-type .grid-4 {
  gap: 22px;
  /* más separación horizontal/vertical entre cajas */
}

.container>.card:first-of-type .field input,
.container>.card:first-of-type .field select,
.container>.card:first-of-type .field textarea {
  padding: 12px 14px;
  /* un poquito más de aire dentro del campo */
}


/* === Print v4: permitir flujo continuo entre Datos del paciente y Peritaje === */
@media print {

  /* Ya no "pegamos" secciones o cards completas: se pueden dividir si hace falta */
  .section,
  .card {
    break-inside: auto;
    page-break-inside: auto;
  }

  /* Conservamos cohesión solo en elementos pequeños/críticos */
  table,
  thead,
  tbody,
  tr,
  th,
  td {
    break-inside: avoid;
    page-break-inside: avoid;
  }
}

/* === Placeholder visual para peritaje (no se exporta) === */
#peritajeTexto:empty:before {
  content: "Escribe o pega aquí el texto del peritaje (se conservarán viñetas y estilo básico).";
  color: #9ca3af;
}

/* Evitar que el placeholder se imprima */
@media print {
  #peritajeTexto:before {
    content: none !important;
  }
}

/* === GES: firmas y layout === */
.firma-line {
  margin-top: 12px;
  display: flex;
  gap: 26px;
  align-items: flex-end;
  flex-wrap: wrap
}

.firma-col {
  flex: 1 1 320px;
}

.firma-col .line {
  border-top: 1px solid #9ca3af;
  height: 0;
  margin-top: 24px
}

.firma-col .lbl {
  text-align: center;
  font-size: 12px;
  color: #374151;
  margin-top: 4px
}

.ges-headline {
  font-weight: 900;
  text-align: center;
  font-size: 16px;
  margin-top: 6px
}

.ges-sub {
  text-align: center;
  font-size: 12px;
  color: #374151;
  margin: 2px 0 10px 0
}

.ges-grid,
.ges-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px
}

@media (max-width:800px) {

  .ges-grid,
  .ges-row {
    grid-template-columns: 1fr
  }
}

.ges-box {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  background: #fff
}

.kv {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 6px;
  margin: 4px 0
}

.kv-label {
  font-weight: 600;
  color: #374151
}

.kv-val {
  color: #111827;
}

.ges-sign-inline {
  margin-top: 8px;
  display: flex;
  align-items: flex-end;
  gap: 12px
}

.ges-sign-inline img {
  max-height: 2cm;
  height: auto;
  width: auto
}

.ges-sign-id {
  font-size: 12px;
  color: #374151;
  margin-top: 4px
}


/* Título principal para documentos (peritajes, etc.) */
.doc-title {
  font-family: Arial, Helvetica, sans-serif;
  text-align: center;
  font-weight: bold;
  font-size: 14pt;
  margin: 10mm 0 8mm 0;
  padding: 0;
  border: none;
  color: #000;
}


/* Ajustes de la línea de firma GES */
.firma-col.narrow {
  flex: 0 0 20%;
}

.firma-col.narrow .line {
  margin-top: 40px;
  /* más espacio para firmar */
}


/* === Ajustes GES para impresión en una sola hoja === */
@media print {
  .page-inner {
    padding: 16px 22px 16px 22px;
    display: flex;
    flex-direction: column
  }

  .ges-headline {
    font-size: 13px !important;
    margin: 0 0 4px 0 !important;
  }

  .ges-sub {
    font-size: 10px !important;
    margin: 0 0 6px 0 !important;
  }

  .ges-grid,
  .ges-row {
    gap: 6px !important;
  }

  .ges-box {
    padding: 6px !important;
  }

  .ges-box h4 {
    margin: 0 0 4px 0 !important;
    font-size: 12px !important;
  }

  .kv {
    grid-template-columns: 140px 1fr !important;
    gap: 4px !important;
    margin: 2px 0 !important;
  }

  .kv-label,
  .kv-val {
    font-size: 11px !important;
  }

  .page-body {
    font-size: 11px !important;
  }

  .ges-constancia {
    font-size: 10.5px !important;
    line-height: 1.25 !important;
    margin-top: 6px !important;
    text-align: justify;
  }

  /* Firma: más espacio sobre la línea para firma manual cómoda */
  .firma-col.narrow .line {
    margin-top: 95px !important;
  }

  /* Evitar cortes de sección GES */
  .page {
    page-break-inside: avoid !important;
  }
}

#gesDiagSel {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
}

/* Inasistencia: usa estilos base */


/* === Peritaje: jerarquía de títulos (editor y export) === */
#peritajeTexto h1,
.peritaje-body h1 {
  font-size: 20pt;
  text-transform: uppercase;
  font-weight: 800;
  margin: 0.45em 0 0.3em;
  color: #000 !important;
}

#peritajeTexto h2,
.peritaje-body h2 {
  font-size: 16pt;
  font-weight: 700;
  margin: 0.4em 0 0.28em;
  color: #000 !important;
}

#peritajeTexto h3,
.peritaje-body h3 {
  font-size: 13pt;
  font-weight: 700;
  margin: 0.38em 0 0.26em;
  color: #000 !important;
}

#peritajeTexto h4,
.peritaje-body h4 {
  font-size: 12pt;
  font-weight: 600;
  margin: 0.36em 0 0.24em;
  color: #000 !important;
}


@media print {
  .inasistencia-body {
    font-size: 14pt !important;
    line-height: 1.5 !important;
  }
}

/* === Peritaje: Selector de tipo de documento === */
.tipo-doc-selector {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
  border: 1px solid #bae6fd;
  border-radius: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.tipo-doc-label {
  font-size: 13px;
  font-weight: 600;
  color: #0369a1;
  white-space: nowrap;
}

.tipo-doc-chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.tipo-doc-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: 2px solid #e2e8f0;
  border-radius: 20px;
  background: white;
  color: #64748b;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.tipo-doc-chip:hover {
  border-color: #94a3b8;
  background: #f8fafc;
  color: #334155;
  transform: translateY(-1px);
}

.tipo-doc-chip.active {
  border-color: #4DD0E1;
  background: linear-gradient(135deg, #e0f7fa 0%, #b2ebf2 100%);
  color: #006064;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(77, 208, 225, 0.25);
}

#tipoLicencia.active {
  border-color: #7c3aed;
  background: linear-gradient(135deg, #ede9fe 0%, #ddd6fe 100%);
  color: #4c1d95;
  box-shadow: 0 2px 8px rgba(124, 58, 237, 0.2);
}

@media print {
  .tipo-doc-selector {
    display: none !important;
  }
}

/* === Peritaje: Barra de herramientas completa (2 filas) === */
.peritaje-toolbar {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 8px 12px 6px;
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  border: 1px solid var(--border);
  border-radius: 12px 12px 0 0;
  border-bottom: none;
}

.toolbar-row {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-wrap: wrap;
  padding: 4px 0;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 2px;
}

.toolbar-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  cursor: pointer;
  color: #475569;
  font-size: 12px;
  font-weight: 600;
  transition: all 0.15s ease;
}

.toolbar-btn:hover {
  background: #e0e7ff;
  border-color: #818cf8;
  color: #4f46e5;
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(79, 70, 229, 0.15);
}

.toolbar-btn:active {
  transform: translateY(0);
  background: #c7d2fe;
}

.toolbar-btn svg {
  pointer-events: none;
}

.toolbar-label {
  font-size: 11px;
  font-weight: 500;
  color: #64748b;
  white-space: nowrap;
  padding: 0 4px;
}

.toolbar-select {
  height: 30px;
  padding: 0 6px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  background: white;
  color: #475569;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s;
  min-width: 100px;
}

.toolbar-select:hover,
.toolbar-select:focus {
  border-color: #818cf8;
}

.toolbar-color-input {
  width: 30px;
  height: 30px;
  padding: 2px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  background: white;
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s;
}

.toolbar-color-input:hover {
  border-color: #818cf8;
}

.toolbar-divider {
  width: 1px;
  height: 24px;
  background: #cbd5e1;
  margin: 0 6px;
  flex-shrink: 0;
}

/* === Peritaje: Editor mejorado === */
.peritaje-editor {
  border: 1px solid var(--border);
  border-radius: 0 0 12px 12px;
  padding: 16px 20px;
  min-height: 280px;
  background: white;
  font-family: 'Georgia', 'Times New Roman', serif;
  font-size: 13px;
  line-height: 1.7;
  text-align: justify;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.peritaje-editor:focus {
  border-color: #818cf8;
  box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.15);
}

.peritaje-editor:empty:before {
  content: attr(data-placeholder);
  color: #9ca3af;
  font-style: italic;
  pointer-events: none;
}

.peritaje-editor p {
  margin: 0 0 12px 0;
}

.peritaje-editor h1 {
  font-size: 18px;
  font-weight: 800;
  margin: 16px 0 10px;
  text-transform: uppercase;
  color: #1e293b;
}

.peritaje-editor h2 {
  font-size: 15px;
  font-weight: 700;
  margin: 14px 0 8px;
  color: #334155;
}

.peritaje-editor h3 {
  font-size: 13px;
  font-weight: 700;
  margin: 12px 0 6px;
  color: #475569;
}

.peritaje-editor ul,
.peritaje-editor ol {
  margin: 8px 0 12px 24px;
}

.peritaje-editor li {
  margin: 4px 0;
}

/* === Peritaje: Campos estructurados === */
.peritaje-campos {
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  background: #fafafa;
}

.peritaje-campos summary {
  cursor: pointer;
  font-weight: 600;
  color: #475569;
}

.peritaje-campos summary:hover {
  color: #4f46e5;
}

/* === PDF: Título profesional mejorado === */
.doc-title {
  text-align: center;
  font-weight: 800;
  font-size: 16px;
  margin: 10px 0 6px;
  color: #1e293b;
  letter-spacing: 0.3px;
}

/* === PDF: Cuerpo del peritaje mejorado === */
.peritaje-body {
  font-family: 'Georgia', 'Times New Roman', serif;
  font-size: 11pt;
  line-height: 1.4;
  text-align: justify;
  color: #1a1a1a;
}

.peritaje-body p {
  margin: 0 0 6pt 0 !important;
  text-indent: 0;
}

.peritaje-body h1 {
  font-size: 13pt;
  font-weight: 800;
  text-transform: uppercase;
  margin: 10pt 0 6pt;
  color: #000 !important;
}

.peritaje-body h2 {
  font-size: 12pt;
  font-weight: 700;
  margin: 8pt 0 4pt;
  color: #000 !important;
}

.peritaje-body h3 {
  font-size: 11pt;
  font-weight: 700;
  margin: 6pt 0 3pt;
  color: #000 !important;
}

.peritaje-body ul,
.peritaje-body ol {
  margin: 4pt 0 6pt 18pt !important;
  padding: 0 !important;
}

.peritaje-body li {
  margin: 2pt 0 !important;
}

/* === PDF: Estilos de impresión para Peritaje === */
@media print {

  .peritaje-toolbar,
  .peritaje-campos {
    display: none !important;
  }

  /* NUEVA ESTRATEGIA: Usar flujo normal del documento, sin position:fixed */
  @page {
    size: A4;
    margin: 18mm 20mm 18mm 20mm;
    /* Márgenes moderados para espacio de contenido */
  }

  .page-inner {
    width: auto;
    margin: 0;
    padding: 8mm 0;
    /* Padding vertical para separar del borde */
    display: block;
    overflow: visible;
  }

  /* Encabezado en flujo normal - se mostrará en cada página */
  .page-header {
    position: relative;
    /* Cambiado de fixed a relative */
    display: flex !important;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid #d1d5db;
    padding-bottom: 4pt;
    margin-bottom: 8pt;
    background: white;
  }

  .page-header img {
    max-height: 12mm;
    width: auto;
  }

  .page-header .hdr-title {
    font-size: 10pt;
    font-weight: bold;
  }

  /* Footer en flujo normal al final del documento */
  .page-footer {
    position: relative;
    display: block !important;
    text-align: center;
    border-top: 1px solid #d1d5db;
    padding: 6pt 0;
    margin-top: 15pt;
    font-size: 8pt;
    color: #444;
  }

  /* page-body sin padding especial ya que footer está en flujo normal */
  .page-body {
    margin: 0;
  }

  /* Título visible al inicio del flujo */
  .doc-title {
    display: block !important;
    font-family: Arial, Helvetica, sans-serif !important;
    font-size: 11pt !important;
    font-weight: bold !important;
    text-align: center !important;
    margin: 6pt 0 4pt 0 !important;
    padding: 0 0 4pt 0 !important;
    border-bottom: 1px solid #d1d5db !important;
    /* Línea gris bajo el título */
    color: #000 !important;
  }

  /* Datos del paciente en peritaje */
  .peritaje-patient {
    margin: 6pt 0 8pt 0 !important;
    font-size: 9pt !important;
  }

  .peritaje-body {
    font-family: Arial, Helvetica, sans-serif !important;
    font-size: 10pt !important;
    line-height: 1.5 !important;
    text-align: justify !important;
    color: #000 !important;
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
  }

  .peritaje-body h1,
  .peritaje-body h2,
  .peritaje-body h3 {
    font-size: 11pt !important;
    font-weight: bold !important;
    margin: 12pt 0 4pt 0 !important;
    text-align: left !important;
    color: #000 !important;
    page-break-after: avoid;
    text-transform: none !important;
  }

  .peritaje-body p {
    margin: 0 0 6pt 0 !important;
    /* Reducido de 8pt a 6pt para menos espacio entre párrafos */
    orphans: 3;
    widows: 3;
  }

  .peritaje-body ul,
  .peritaje-body ol {
    margin: 4pt 0 8pt 18pt !important;
  }

  .peritaje-body li {
    margin: 0 !important;
  }

  /* Firma al final, asegurando espacio */
  .page-sign {
    display: flex !important;
    page-break-inside: avoid;
    margin-top: 6mm !important;
    padding-bottom: 0;
  }
}

/* === Ajustes de paginación para documentos compactos === */
.page--exam-labs {
  font-size: 9pt;
}

.page--exam-labs .page-header img,
.page--ges .page-header img {
  max-height: 12mm;
}

.page--exam-labs .page-patient,
.page--ges .page-patient {
  font-size: 9pt;
  gap: 5px;
}

.page--exam-labs .exam-lab-columns {
  column-count: 2;
  column-gap: 12px;
  font-size: 8.7pt;
  line-height: 1.16;
}

.page--exam-labs .page-bottom-block,
.page--ges .page-bottom-block {
  margin-top: 8px;
}

.page--exam-labs .signature-block,
.page--ges .signature-block {
  min-height: 0;
  padding-top: 4px;
}

.page--exam-labs .signature-images,
.page--ges .signature-images {
  min-height: 16mm;
}

.page--ges {
  font-size: 9pt;
  line-height: 1.2;
}

.page--ges .ges-headline {
  font-size: 11pt;
  margin-bottom: 2px;
}

.page--ges .ges-sub {
  margin-bottom: 6px;
}

.page--ges .ges-constancia {
  margin-top: 8px !important;
  font-size: 8.5pt !important;
  line-height: 1.25 !important;
}

.page--ges .ges-constancia p {
  margin: 0 0 5px !important;
}

.page--ges .ges-signature {
  margin-top: 22px !important;
}

@media print {
  .page--exam-labs,
  .page--ges,
  .page--exam-cardio,
  .page--exam-imaging {
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }

  .page--exam-labs .page-inner,
  .page--ges .page-inner {
    padding-top: 4mm !important;
    padding-bottom: 4mm !important;
  }

  .page--exam-labs .page-header,
  .page--ges .page-header {
    margin-bottom: 4pt !important;
    padding-bottom: 3pt !important;
  }

  .page--exam-labs .page-patient,
  .page--ges .page-patient {
    margin-top: 3pt !important;
  }

  .page--exam-labs .page-body,
  .page--ges .page-body {
    margin-top: 5pt !important;
  }

  .page--exam-labs .exam-lab-columns {
    font-size: 8pt !important;
    line-height: 1.12 !important;
  }

  .page--exam-labs .section-title {
    margin-bottom: 3pt !important;
    padding-top: 4pt !important;
  }

  .page--exam-labs ul.clean {
    margin: 3pt 0 4pt 13pt !important;
  }

  .page--exam-labs .page-footer,
  .page--ges .page-footer {
    margin-top: 6pt !important;
    padding-top: 4pt !important;
    font-size: 7.5pt !important;
  }

  .page--medical-report {
    overflow: visible !important;
    break-inside: auto !important;
    page-break-inside: auto !important;
  }

  .page--medical-report .page-inner,
  .page--medical-report .page-body,
  .page--medical-report .medical-report-section {
    overflow: visible !important;
    break-inside: auto !important;
    page-break-inside: auto !important;
  }

  .page--medical-report .medical-report-text {
    font-size: 10pt !important;
    line-height: 1.45 !important;
    overflow-wrap: break-word !important;
    word-break: normal !important;
  }

  .page--medical-report .medical-report-line,
  .page--peritaje .peritaje-body p,
  .page--peritaje .peritaje-body li {
    break-inside: avoid !important;
    page-break-inside: avoid !important;
  }
}

/* === Estilos para Sistema de Tareas === */

.tasks-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 12px
}

.task-item {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  background: white;
  transition: all 0.3s ease
}

/* Estados de color basados en tiempo */
.task-normal {
  background: white;
  border-left: 4px solid #94a3b8
}

.task-warning {
  background: #fefce8;
  border-left: 4px solid #facc15;
  box-shadow: 0 2px 8px rgba(250, 204, 21, 0.1)
}

.task-overdue {
  background: #fef2f2;
  border-left: 4px solid #ef4444;
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.1)
}

.task-completed {
  background: #f0fdf4;
  border-left: 4px solid #22c55e;
  opacity: 0.85
}

.task-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px
}

.task-patient {
  font-weight: 700;
  font-size: 15px;
  color: var(--text)
}

.task-priority {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px
}

.priority-high {
  background: #fee2e2;
  color: #991b1b
}

.priority-medium {
  background: #fef3c7;
  color: #92400e
}

.priority-low {
  background: #dbeafe;
  color: #1e40af
}

.task-description {
  color: var(--text);
  font-size: 14px;
  margin-bottom: 10px;
  line-height: 1.5
}

.task-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap
}

.task-time {
  display: flex;
  flex-direction: column;
  gap: 4px
}

.task-time small {
  font-size: 12px;
  color: var(--muted)
}

.task-remaining {
  font-weight: 600;
  color: var(--primary)
}

.task-overdue .task-remaining {
  color: #ef4444;
  font-weight: 700
}

.task-warning .task-remaining {
  color: #d97706
}

.task-actions {
  display: flex;
  gap: 8px
}

.btn-small {
  padding: 6px 12px;
  font-size: 13px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: white;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s ease
}

.btn-complete {
  background: #22c55e;
  color: white;
  border-color: #16a34a
}

.btn-complete:hover {
  background: #16a34a;
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(34, 197, 94, 0.2)
}

.btn-delete {
  background: #ef4444;
  color: white;
  border-color: #dc2626
}

.btn-delete:hover {
  background: #dc2626;
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(239, 68, 68, 0.2)
}

.count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  padding: 0 8px;
  background: linear-gradient(135deg, var(--primary), #60a5fa);
  color: white;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  margin-left: 8px
}

/* Responsive para tareas */
@media (max-width: 700px) {
  .task-footer {
    flex-direction: column;
    align-items: flex-start
  }

  .task-actions {
    width: 100%
  }

  .task-actions button {
    flex: 1
  }

  .count-badge {
    font-size: 11px;
    min-width: 20px;
    height: 20px;
    padding: 0 6px
  }
}

/* === Tarjetas de Estadísticas === */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin: 16px 0
}

.stat-card {
  background: linear-gradient(135deg, #f8fafc, white);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  text-align: center;
  transition: transform 0.2s
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1)
}

.stat-card.wide {
  grid-column: span 3
}

.stat-value {
  font-size: 32px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 8px
}

.stat-value.pending {
  color: #f59e0b
}

.stat-value.completed {
  color: #22c55e
}

.stat-label {
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px
}

.progress-container {
  width: 100%
}

.progress-bar-large {
  width: 100%;
  height: 12px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 12px
}

.progress-fill-large {
  height: 100%;
  background: linear-gradient(90deg, #22c55e, #16a34a);
  transition: width 0.5s ease;
  border-radius: 999px
}

.progress-text {
  font-size: 14px;
  font-weight: 700;
  color: var(--text)
}

@media (max-width: 700px) {
  .stats-grid {
    grid-template-columns: 1fr
  }

  .stat-card.wide {
    grid-column: span 1
  }

  .stat-value {
    font-size: 24px
  }
}

/* === Widget Flotante de Tareas === */

.tasks-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999
}

.widget-toggle {
  position: relative;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #60a5fa);
  color: white;
  border: none;
  font-size: 24px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center
}

.widget-toggle:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 16px rgba(59, 130, 246, 0.6)
}

.widget-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #ef4444;
  color: white;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  border: 2px solid white
}

.widget-badge.is-empty {
  background: #64748b;
}

.widget-panel {
  position: absolute;
  bottom: 75px;
  right: 0;
  width: 360px;
  max-height: 500px;
  background: white;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;
  animation: slideUp 0.3s ease
}

.widget-panel.hidden {
  display: none
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: scale(0.9) translateY(20px)
  }

  to {
    opacity: 1;
    transform: scale(1) translateY(0)
  }
}

.widget-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, #f8fafc, #f1f5f9)
}

.widget-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--text)
}

.widget-close {
  background: none;
  border: none;
  font-size: 28px;
  color: var(--muted);
  cursor: pointer;
  line-height: 1;
  padding: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s
}

.widget-close:hover {
  background: #e2e8f0;
  color: var(--text)
}

/* Botón de acceso rápido a tareas pendientes */
.widget-btn-pendientes {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 12px 14px 4px 14px;
  padding: 12px 16px;
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: white;
  text-decoration: none;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.2px;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.35);
  transition: all 0.25s ease;
  flex-shrink: 0;
}

.widget-btn-pendientes:hover {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(59, 130, 246, 0.45);
  color: white;
}

.widget-btn-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  padding: 0 7px;
  background: #ef4444;
  color: white;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  margin-left: 10px;
  border: 2px solid rgba(255,255,255,0.4);
  animation: pulse-badge 2s infinite;
}

.widget-btn-badge.is-empty,
.pending-count.is-empty {
  background: #e2e8f0;
  color: #475569;
  border-color: rgba(148, 163, 184, 0.36);
  animation: none;
}

.widget-empty-state {
  margin: 0;
  padding: 12px;
  border: 1px solid #dbeafe;
  border-radius: 10px;
  background: #f8fbff;
  color: #456e83;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
}

@keyframes pulse-badge {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

.widget-psych-alerts {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: #f0fdf4;
}

.widget-psych-alerts.hidden {
  display: none;
}

.widget-psych-alerts h4 {
  margin: 0 0 8px;
  color: #166534;
  font-size: 13px;
}

.widget-psych-alert {
  display: block;
  padding: 9px 10px;
  margin-bottom: 7px;
  border: 1px solid #bbf7d0;
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  text-decoration: none;
}

.widget-psych-alert:hover,
.widget-psych-alert:focus-visible {
  border-color: #22c55e;
  background: #f7fff9;
}

.widget-psych-alert strong,
.widget-psych-alert span {
  display: block;
}

.widget-psych-alert strong {
  font-size: 13px;
}

.widget-psych-alert span {
  color: #456e83;
  font-size: 12px;
}


.widget-add-form {
  padding: 12px 16px;
  background: #f8fafc;
  border-bottom: 1px solid var(--border)
}

.widget-add-form h4 {
  margin: 0 0 12px 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--text)
}

.widget-input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 8px;
  font-family: inherit
}

.widget-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1)
}

.btn-widget-add {
  width: 100%;
  padding: 10px;
  background: linear-gradient(135deg, var(--primary), #60a5fa);
  color: white;
  border: none;
  border-radius: 8px;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s
}

.btn-widget-add:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(59, 130, 246, 0.3)
}

.widget-stats {
  padding: 12px 16px;
  background: #fafbfc;
  border-bottom: 1px solid var(--border)
}

.stat-item {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px
}

.stat-label {
  font-size: 13px;
  color: var(--muted)
}

.stat-value {
  font-size: 16px;
  font-weight: 700;
  color: var(--text)
}

.progress-bar {
  width: 100%;
  height: 8px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
  margin: 12px 0 8px 0
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #22c55e, #16a34a);
  transition: width 0.3s ease;
  border-radius: 999px
}

.progress-label {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  font-weight: 600
}

.widget-tasks {
  flex: 1;
  overflow-y: auto;
  padding: 10px 16px;
  max-height: 120px
}

.widget-task {
  padding: 10px 12px;
  margin-bottom: 10px;
  border-radius: 10px;
  border-left: 3px solid #94a3b8;
  background: white;
  transition: all 0.2s
}

.widget-task:hover {
  background: #f8fafc;
  transform: translateX(-2px)
}

.widget-task.task-warning {
  background: #fefce8;
  border-left-color: #facc15
}

.widget-task.task-overdue {
  background: #fef2f2;
  border-left-color: #ef4444
}

.widget-task-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px
}

.widget-task-icon {
  font-size: 12px
}

.widget-task-patient {
  font-weight: 700;
  font-size: 13px;
  color: var(--text)
}

.widget-task-desc {
  font-size: 12px;
  color: #64748b;
  margin-bottom: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden
}

.widget-task-time {
  font-size: 11px;
  color: var(--primary);
  font-weight: 600
}

.widget-task.task-overdue .widget-task-time {
  color: #ef4444
}

.widget-task.task-warning .widget-task-time {
  color: #d97706
}

.widget-link {
  display: block;
  text-align: center;
  padding: 16px 14px 20px 14px;
  border-top: 1px solid var(--border);
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  background: white;
  transition: all 0.2s;
  flex-shrink: 0
}

.widget-link:hover {
  background: #f8fafc
}

/* Responsive para widget */
@media (max-width: 700px) {
  .tasks-widget {
    bottom: 16px;
    right: 16px
  }

  .widget-toggle {
    width: 56px;
    height: 56px;
    font-size: 20px
  }

  .widget-panel {
    width: calc(100vw - 32px);
    max-width: 360px;
    right: 0
  }
}

/* === Gestión de Roles === */
.roles-management {
  margin-top: 4px;
}

.roles-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.role-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 13px;
  transition: all 0.2s;
}

.role-item:hover {
  box-shadow: var(--shadow-sm);
  border-color: #cbd5e1;
}

.role-color {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.role-name {
  font-weight: 600;
  color: var(--text);
}

.role-actions {
  display: flex;
  gap: 4px;
  margin-left: 4px;
}

.btn-small {
  padding: 4px 8px;
  font-size: 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: white;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s;
}

.btn-small:hover {
  background: #f8fafc;
  transform: translateY(-1px);
}

.btn-small.btn-delete-role {
  color: #dc2626;
  border-color: #fecaca;
}

.btn-small.btn-delete-role:hover {
  background: #fee2e2;
}

.btn-small.btn-complete {
  background: #10b981;
  color: white;
  border-color: #10b981;
}

.btn-small.btn-complete:hover {
  background: #059669;
  border-color: #059669;
}

.btn-small.btn-delete {
  color: #dc2626;
  border-color: #fecaca;
}

.btn-small.btn-delete:hover {
  background: #fee2e2;
}

/* Estilos para tarea asignada */
.task-assigned {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  display: inline-block;
}

.task-assigned.unassigned {
  background: #f1f5f9;
  color: #64748b;
  border: 1px solid #e2e8f0;
}

.task-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Responsivo para roles */
@media (max-width: 700px) {
  .task-meta {
    gap: 4px;
  }

  .role-item {
    font-size: 12px;
    padding: 5px 10px;
  }

  .role-color {
    width: 10px;
    height: 10px;
  }

  .task-assigned {
    font-size: 10px;
    padding: 3px 8px;
  }
}
