:root {
  --bg-main: #fff1f2;
  --bg-card: #ffffff;
  --bg-soft: #fff5f6;
  --bg-elevated: rgba(255, 255, 255, 0.92);
  --text-main: #102027;
  --text-muted: #5d7280;
  --border: #f0c8ce;
  --border-strong: #df9aa5;
  --primary: #b4232f;
  --primary-600: #981b25;
  --primary-700: #7f1d1d;
  --cian: #dc3545;
  --mint: #e04e64;
  --success: #b4232f;
  --danger: #c9364d;
  --warning: #b57912;
  --surface-tint: #ffe4e8;
  --shadow-sm: 0 8px 22px rgba(180, 35, 47, 0.08);
  --shadow-md: 0 20px 44px rgba(127, 29, 29, 0.16);
  --radius-md: 8px;
  --radius-lg: 8px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "Aptos", "Inter", "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--text-main);
  background:
    linear-gradient(180deg, rgba(255, 228, 232, 0.92) 0%, rgba(255, 247, 248, 1) 42%, #fff1f2 100%),
    var(--bg-main);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(180, 35, 47, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(180, 35, 47, 0.045) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: linear-gradient(180deg, #000 0%, transparent 78%);
}

a {
  color: inherit;
}

.medical-shell,
#app-shell {
  width: min(1680px, 100%);
  margin: 0 auto;
  padding: 20px;
  position: relative;
}

.page-frame {
  display: grid;
  gap: 16px;
}

.layout-section {
  margin: 0;
}

body.modal-open {
  overflow: hidden;
}

body.modal-open #app-shell {
  display: none !important;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 18px 20px;
  border: 1px solid rgba(180, 35, 47, 0.22);
  border-left: 6px solid var(--primary);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.98) 0%, rgba(255, 228, 232, 0.96) 100%);
  box-shadow: var(--shadow-sm);
}

.app-header h1 {
  margin: 0;
  color: var(--primary-700);
  font-size: clamp(1.15rem, 2vw, 1.72rem);
  font-weight: 850;
  letter-spacing: 0;
}

.app-title {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  line-height: 1.18;
}

.medical-title-icon {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--primary), var(--mint));
  color: #fff;
  box-shadow: 0 8px 16px rgba(180, 35, 47, 0.16);
}

.medical-title-icon svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

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

.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 16px;
}

.filters {
  border-top: 3px solid var(--mint);
}

.filters .grid-4 {
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(260px, 2fr) minmax(160px, 1fr) minmax(160px, 1fr) auto;
  align-items: end;
}

.align-end {
  display: flex;
  align-items: end;
  gap: 8px;
  flex-wrap: wrap;
}

.form-unified label,
label.field > span,
label {
  font-size: 0.84rem;
  color: var(--text-muted);
  font-weight: 750;
}

input,
select,
textarea {
  width: 100%;
  margin-top: 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 11px 12px;
  background: #fffafa;
  color: var(--text-main);
  outline: none;
  font: inherit;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

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

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(224, 78, 100, 0.18);
  background: #fff;
}

input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}

input[readonly] {
  background: #fff1f2;
  color: #6d8089;
}

.password-input-wrap {
  position: relative;
  display: block;
  margin-top: 6px;
}

.password-input-wrap input {
  margin-top: 0;
  padding-right: 46px;
}

.password-toggle {
  position: absolute;
  right: 7px;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}

.password-toggle:hover,
.password-toggle:focus-visible {
  color: var(--primary);
  background: #fff1f2;
  outline: none;
}

.password-toggle svg {
  width: 19px;
  height: 19px;
}

.password-toggle .icon-eye-off {
  display: none;
}

.password-toggle[aria-pressed="true"] .icon-eye {
  display: none;
}

.password-toggle[aria-pressed="true"] .icon-eye-off {
  display: block;
}

.btn {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px 15px;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  text-decoration: none;
  font-weight: 800;
  font-size: 0.875rem;
  cursor: pointer;
  background: linear-gradient(135deg, var(--primary), var(--primary-600));
  color: #fff;
  box-shadow: 0 8px 16px rgba(180, 35, 47, 0.16);
  transition: transform 0.14s ease, box-shadow 0.18s ease, filter 0.14s ease;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(180, 35, 47, 0.2);
}

.btn:focus-visible {
  outline: 3px solid rgba(224, 78, 100, 0.32);
  outline-offset: 2px;
}

.btn.primary {
  background: linear-gradient(135deg, var(--mint), var(--primary));
}

.btn.ghost,
.btn.back {
  background: #fff;
  color: var(--primary-700);
  border-color: var(--border);
  box-shadow: none;
}

.btn.ghost:hover,
.btn.back:hover {
  box-shadow: 0 8px 18px rgba(180, 35, 47, 0.12);
  border-color: var(--border-strong);
}

.btn.danger {
  background: linear-gradient(135deg, #e04e64, var(--danger));
  color: #fff;
}

.inline {
  margin: 0;
}

.alert {
  padding: 13px 15px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.alert.success {
  border-color: rgba(180, 35, 47, 0.3);
  background: rgba(180, 35, 47, 0.08);
}

.alert.error {
  border-color: rgba(201, 54, 77, 0.3);
  background: rgba(201, 54, 77, 0.08);
}

.records-section {
  padding: 0;
  overflow: hidden;
}

.stats-section {
  padding: 0;
  overflow: hidden;
}

.records-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, #fff, #fff1f3);
}

.records-head h2 {
  margin: 0;
  color: var(--primary-700);
  font-size: 1rem;
  font-weight: 850;
  letter-spacing: 0;
}

.records-toggle {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  border: 1px solid rgba(180, 35, 47, 0.28);
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  color: var(--primary-700);
  font: inherit;
  font-size: 1.55rem;
  font-weight: 850;
  line-height: 1;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 0.14s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.records-toggle:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(180, 35, 47, 0.14);
  background: #fffafa;
}

.records-toggle:focus-visible {
  outline: 3px solid rgba(224, 78, 100, 0.32);
  outline-offset: 2px;
}

.records-toggle .when-open,
.records-section.is-open .records-toggle .when-closed {
  display: none;
}

.records-section.is-open .records-toggle .when-open {
  display: inline;
}

.stats-section.is-open .records-toggle .when-closed {
  display: none;
}

.stats-section.is-open .records-toggle .when-open {
  display: inline;
}

.records-panel[hidden] {
  display: none;
}

.stats-panel {
  padding: 16px;
  background: #fffafa;
}

.stats-kpis {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.stat-kpi {
  min-width: 0;
  border: 1px solid #f1ccd2;
  border-radius: 8px;
  background: #fff;
  padding: 13px 14px;
  box-shadow: var(--shadow-sm);
}

.stat-kpi__label {
  display: block;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
  margin-bottom: 7px;
}

.stat-kpi strong {
  color: var(--primary-700);
  font-size: clamp(1.45rem, 3vw, 2rem);
  line-height: 1;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.stats-card {
  min-width: 0;
  border: 1px solid #f1ccd2;
  border-radius: 8px;
  background: #fff;
  padding: 15px;
  box-shadow: var(--shadow-sm);
}

.stats-card-wide {
  grid-column: 1 / -1;
}

.stats-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.stats-card-head h3 {
  margin: 0;
  color: var(--primary-700);
  font-size: 0.98rem;
  font-weight: 850;
}

.stats-card-head span {
  flex: 0 0 auto;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 750;
}

.month-chart {
  height: 230px;
  display: grid;
  grid-template-columns: repeat(6, minmax(38px, 1fr));
  gap: 9px;
  align-items: end;
  overflow-x: auto;
  padding-bottom: 4px;
}

.month-bar {
  min-width: 38px;
  display: grid;
  grid-template-rows: 22px 1fr auto;
  gap: 6px;
  align-items: end;
  height: 100%;
}

.month-bar__value {
  color: var(--primary-700);
  font-size: 0.78rem;
  font-weight: 850;
  text-align: center;
}

.month-bar__track {
  height: 160px;
  border-radius: 8px;
  background: #fff1f3;
  border: 1px solid #f1ccd2;
  display: flex;
  align-items: end;
  overflow: hidden;
}

.month-bar__track span {
  width: 100%;
  display: block;
  border-radius: 7px 7px 0 0;
  background: linear-gradient(180deg, #e04e64, #b4232f);
}

.month-bar__label {
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-align: center;
  white-space: nowrap;
}

.donut-wrap {
  display: grid;
  grid-template-columns: 138px 1fr;
  gap: 16px;
  align-items: center;
}

.donut {
  width: 138px;
  height: 138px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at center, #fff 0 58%, transparent 59%),
    conic-gradient(var(--primary) calc(var(--pct) * 1%), #f4d5da 0);
}

.donut span {
  color: var(--primary-700);
  font-weight: 900;
  font-size: 1.25rem;
}

.donut-wrap p {
  margin: 0;
  color: var(--text-muted);
  line-height: 1.45;
  font-size: 0.9rem;
}

.rank-list,
.diagnosis-chart {
  display: grid;
  gap: 12px;
}

.rank-row {
  display: grid;
  gap: 6px;
}

.rank-row__top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--text-main);
  font-size: 0.88rem;
  font-weight: 800;
}

.rank-row__top span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.rank-row__top strong,
.diagnosis-row strong {
  color: var(--primary-700);
}

.rank-track,
.diagnosis-track {
  height: 10px;
  border-radius: 999px;
  background: #fff1f3;
  overflow: hidden;
  border: 1px solid #f1ccd2;
}

.rank-track span,
.diagnosis-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #e04e64, #b4232f);
}

.diagnosis-row {
  display: grid;
  grid-template-columns: minmax(180px, 1.1fr) minmax(120px, 2fr) 44px;
  gap: 12px;
  align-items: center;
}

.diagnosis-label {
  min-width: 0;
  color: var(--text-main);
  font-size: 0.88rem;
  font-weight: 750;
  overflow-wrap: anywhere;
}

.empty-chart {
  margin: 0;
  color: var(--text-muted);
  font-style: italic;
}

.records-pager {
  padding: 12px 16px 14px;
  border-top: 1px solid #f4d5da;
  background: #fffafa;
}

.table-scroll {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

table.data {
  width: 100%;
  min-width: 940px;
  border-collapse: separate;
  border-spacing: 0;
}

table.data th,
table.data td {
  padding: 13px 14px;
  border-bottom: 1px solid #f4d5da;
  text-align: left;
  vertical-align: middle;
}

table.data thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: linear-gradient(180deg, #ffe0e5, #fff1f3);
  color: var(--primary-700);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0;
  font-weight: 850;
}

table.data tbody tr {
  background: rgba(255, 255, 255, 0.74);
}

table.data tbody tr:nth-child(even) {
  background: rgba(255, 245, 246, 0.88);
}

table.data tbody tr:hover {
  background: #ffe8ec;
}

.empty {
  text-align: center;
  color: var(--text-muted);
  padding: 28px !important;
}

.center {
  text-align: center;
}

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

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid var(--border-strong);
  margin-right: 8px;
  background: #fff1f2;
  vertical-align: middle;
}

.alerta-roja-icon {
  display: inline-flex;
  margin-left: 8px;
  color: var(--danger);
  font-weight: 900;
}

.btn-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-main);
  transition: transform 0.14s ease, box-shadow 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

.btn-icon svg {
  width: 18px;
  height: 18px;
}

.btn-icon:hover {
  transform: translateY(-1px);
  border-color: var(--border-strong);
  box-shadow: 0 8px 18px rgba(180, 35, 47, 0.12);
}

.btn-icon.edit {
  color: var(--primary);
}

.btn-icon.print {
  color: var(--success);
}

.btn-icon.view {
  color: var(--primary);
}

.btn-icon.delete {
  color: var(--danger);
}

.btn-icon.history {
  color: #946314;
}

.pagination,
.hc-pager {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.pagination .info,
.hc-pager .info {
  margin-right: auto;
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 650;
}

.hc-pager .pager-btn,
.pagination a,
.pagination span {
  text-decoration: none;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text-main);
  border-radius: 8px;
  padding: 8px 12px;
  font-weight: 800;
  transition: transform 0.14s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.hc-pager .pager-btn:hover,
.pagination a:hover {
  transform: translateY(-1px);
  border-color: var(--border-strong);
  box-shadow: 0 8px 18px rgba(180, 35, 47, 0.12);
}

.hc-pager .pager-current,
.pagination .active {
  border: none;
  background: linear-gradient(135deg, var(--mint), var(--primary));
  color: #fff;
  min-width: 38px;
  text-align: center;
}

.hc-pager .disabled,
.pagination .disabled {
  opacity: 0.5;
  pointer-events: none;
}

.hc-header,
.hc-head-block {
  display: grid;
  gap: 10px;
}

.hc-nombre {
  margin: 0;
  color: var(--primary-700);
  font-size: clamp(1.1rem, 2vw, 1.42rem);
}

.hc-datos {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--text-muted);
}

.hc-datos strong {
  color: var(--text-main);
}

.alerta-roja-box {
  width: 100%;
  border: 1px solid rgba(201, 54, 77, 0.32);
  border-radius: var(--radius-md);
  padding: 12px;
  background: rgba(201, 54, 77, 0.055);
}

.alerta-roja-box.active {
  background: rgba(201, 54, 77, 0.1);
  border-color: rgba(201, 54, 77, 0.52);
}

.alerta-roja-top {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.alerta-roja-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 850;
  color: var(--danger);
}

.alerta-roja-label .dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--danger);
}

.alerta-roja-state {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.04em;
  background: #fff;
  color: var(--text-muted);
}

.alerta-roja-state.on {
  color: var(--danger);
  border-color: rgba(201, 54, 77, 0.5);
  background: rgba(201, 54, 77, 0.1);
}

.alerta-roja-actions {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.alerta-roja-feedback {
  margin-top: 8px;
  font-size: 0.84rem;
}

.alerta-roja-feedback.success {
  color: var(--success);
}

.alerta-roja-feedback.error {
  color: var(--danger);
}

.switch {
  position: relative;
  display: inline-block;
  width: 54px;
  height: 30px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  border: 1px solid rgba(127, 29, 29, 0.16);
  background: #f1c6cc;
  cursor: pointer;
  transition: 0.2s;
}

.slider::before {
  content: "";
  position: absolute;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  left: 3px;
  top: 50%;
  transform: translateY(-50%);
  background: #fff;
  box-shadow: 0 3px 8px rgba(127, 29, 29, 0.24);
  transition: 0.2s;
}

.switch input:checked + .slider {
  background: var(--danger);
}

.switch input:checked + .slider::before {
  transform: translate(24px, -50%);
}

.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  background: rgba(60, 10, 16, 0.44);
  backdrop-filter: blur(5px);
  padding: 14px;
}

.modal.show {
  display: flex;
}

.modal-content {
  width: min(1160px, 100%);
  max-height: 92vh;
  overflow: auto;
  background: #fff;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.modal-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 15px 17px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #ffe8ec, #fff);
}

.modal-head h2 {
  margin: 0;
  color: var(--primary-700);
  font-size: 1.2rem;
}

.close {
  width: 38px;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--primary-700);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

.section {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin: 12px;
  overflow: hidden;
  background: #fff;
}

.section > summary {
  list-style: none;
  cursor: pointer;
  padding: 13px 15px;
  font-weight: 850;
  color: var(--primary-700);
  background: linear-gradient(180deg, #ffe8ec, #fffafa);
  border-left: 4px solid var(--mint);
}

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

.section .grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 14px;
}

.checks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}

.chk {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #fff5f6;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
}

.thumb-preview {
  display: flex;
  align-items: center;
  gap: 10px;
}

.thumb-preview img {
  width: 58px;
  height: 58px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  position: sticky;
  bottom: 0;
  z-index: 1;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: linear-gradient(0deg, #fff1f3, #fff);
}

.spacer-cell {
  grid-column: 1 / span 1;
}

.field-wide {
  grid-column: 1 / -1;
}

.app-footer {
  padding: 14px 16px;
  text-align: center;
  color: #fff;
  border: 1px solid var(--primary-600);
  border-left: 6px solid var(--primary);
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--mint), var(--primary));
  box-shadow: var(--shadow-sm);
  font-weight: 800;
}

.app-footer small {
  color: #fff;
}

.hc-actions-wrap {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.hc-doc-actions,
.hc-row-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.hc-actions__form {
  margin: 0;
}

.hc-doc-none {
  color: var(--text-muted);
  font-weight: 750;
}

.btn-doc {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text-main);
  padding: 7px 11px;
  font-size: 0.8rem;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
}

.btn-doc__icon {
  display: inline-flex;
  width: 16px;
  height: 16px;
  align-items: center;
  justify-content: center;
}

.btn-doc--word {
  border-color: #df9aa5;
  color: var(--primary-700);
  background: linear-gradient(180deg, #fff1f3, #fff);
}

.btn-doc--danger {
  border-color: #efc4ca;
  color: #922734;
  background: linear-gradient(180deg, #fff2f4, #fff);
}

.report-body {
  background: #fff1f2;
}

.report-page {
  min-height: 100vh;
}

small,
.muted {
  color: var(--text-muted);
}

.login-page {
  min-height: 100vh;
  background: #fff1f2 url("assets/login-bg.png") center center / cover no-repeat fixed;
}

.login-page::before {
  display: none;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.login-card {
  width: min(100%, 420px);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 24px;
}

.login-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 20px;
  text-align: left;
}

.login-brand h1 {
  margin: 0;
  font-size: 1.4rem;
  color: var(--primary-700);
}

.login-brand p {
  margin: 2px 0 0;
  color: var(--text-muted);
  font-weight: 700;
}

.login-error {
  margin-bottom: 14px;
  padding: 11px 12px;
  border-radius: 8px;
  border: 1px solid rgba(201,54,77,.3);
  background: rgba(201,54,77,.08);
  color: #7f1d1d;
  font-weight: 700;
}

.login-card .field {
  display: block;
  margin-bottom: 14px;
}

.login-card .field:last-of-type {
  margin-bottom: 22px;
}

.login-submit {
  width: 100%;
}

@media (max-width: 1180px) {
  .filters .grid-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  #app-shell {
    padding: 12px;
  }

  .stats-grid,
  .stats-kpis {
    grid-template-columns: 1fr;
  }

  .diagnosis-row {
    grid-template-columns: 1fr 70px;
    gap: 7px 10px;
  }

  .diagnosis-label {
    grid-column: 1 / -1;
  }

  .diagnosis-track {
    min-width: 0;
  }

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

  .form-actions {
    justify-content: stretch;
  }

  .form-actions .btn {
    flex: 1 1 auto;
  }

  .hc-head-block {
    grid-template-columns: 1fr;
  }
}

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

  #app-shell,
  .medical-shell {
    width: 100%;
    max-width: 100%;
    padding: 10px;
  }

  .app-header {
    padding: 13px;
    min-width: 0;
  }

  .app-header h1 {
    width: 100%;
    min-width: 0;
    font-size: 1.18rem;
    line-height: 1.2;
    overflow-wrap: anywhere;
  }

  .app-header .actions {
    width: 100%;
    min-width: 0;
  }

  .app-header .actions .btn,
  .app-header .actions form,
  .app-header .actions button {
    width: 100%;
  }

  .filters .grid-4 {
    grid-template-columns: 1fr;
  }

  .align-end {
    width: 100%;
  }

  .align-end .btn {
    flex: 1 1 100%;
  }

  .card {
    padding: 12px;
    min-width: 0;
    overflow: hidden;
  }

  .hc-head-block {
    display: grid !important;
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .hc-nombre {
    font-size: 1.3rem;
    line-height: 1.16;
    overflow-wrap: anywhere;
  }

  .hc-datos {
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
    overflow-wrap: anywhere;
  }

  .print-range-form,
  .print-range-form .print-actions {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }

  .print-range-form .field {
    min-width: 0;
  }

  .historial-page .table-wrap {
    overflow: visible;
  }

  .historial-page .table-scroll {
    overflow: visible;
  }

  .historial-page table.data {
    min-width: 0;
    width: 100%;
  }

  .historial-page table.data thead {
    display: none;
  }

  .historial-page table.data,
  .historial-page table.data tbody,
  .historial-page table.data tr,
  .historial-page table.data td {
    display: block;
  }

  .historial-page table.data tbody tr {
    margin-bottom: 12px;
    border: 1px solid #f4d5da;
    border-radius: 8px;
    background: #fff;
    overflow: hidden;
  }

  .historial-page table.data td {
    display: grid;
    grid-template-columns: minmax(96px, 38%) minmax(0, 1fr);
    gap: 10px;
    padding: 11px 12px;
    text-align: left !important;
    overflow-wrap: anywhere;
  }

  .historial-page table.data td::before {
    content: attr(data-label);
    color: var(--text-muted);
    font-weight: 850;
  }

  .historial-page table.data td.empty {
    display: block;
    text-align: center !important;
  }

  .historial-page table.data td.empty::before {
    content: none;
  }

  .hc-actions-wrap {
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 8px;
  }

  .hc-doc-actions,
  .hc-row-actions {
    flex-wrap: wrap;
  }

  .hc-pager {
    align-items: stretch;
  }

  .hc-pager .info {
    width: 100%;
    margin-right: 0;
  }

  .stats-section {
    padding: 0;
  }

  .stats-panel {
    padding: 12px;
  }

  .stats-card-head {
    display: grid;
    gap: 4px;
  }

  .stats-card-head span {
    white-space: normal;
  }

  .donut-wrap {
    grid-template-columns: 1fr;
    justify-items: start;
  }

  .month-chart {
    grid-template-columns: repeat(6, minmax(44px, 1fr));
  }

  .hc-pager .label {
    display: none;
  }

}
