:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --panel-soft: #f8fafb;
  --ink: #1d252c;
  --muted: #64727d;
  --line: #dce4e8;
  --accent: #087c72;
  --accent-strong: #055f58;
  --accent-soft: #e6f4f2;
  --gold: #9f6b16;
  --danger: #a5473f;
  --shadow: 0 16px 34px rgba(28, 43, 54, 0.08);
}

/* Reversible Material Design lilac skin shared with the main project. */
body.material-lilac-theme {
  --bg: #f7f2fa;
  --panel: #fffbfe;
  --panel-strong: #f3edf7;
  --text: #1d1b20;
  --muted: #625b71;
  --line: #cac4d0;
  --primary: #6750a4;
  --primary-dark: #4f378b;
  --accent: #7d5260;
  color: #1d1b20;
  background: #f7f2fa !important;
}

body.material-lilac-theme .topbar,
body.material-lilac-theme .filters,
body.material-lilac-theme .results,
body.material-lilac-theme .login-card,
body.material-lilac-theme .admin-panel,
body.material-lilac-theme .admin-card,
body.material-lilac-theme .log-panel,
body.material-lilac-theme .sql-crud-panel,
body.material-lilac-theme .history-panel,
body.material-lilac-theme .caja-modal-card,
body.material-lilac-theme .summary-grid > div {
  color: #1d1b20;
  border-color: #cac4d0 !important;
  background: #fffbfe !important;
  box-shadow: 0 10px 28px rgba(73, 54, 95, 0.14) !important;
  backdrop-filter: none;
}

body.material-lilac-theme h1,
body.material-lilac-theme h2,
body.material-lilac-theme h3,
body.material-lilac-theme strong {
  color: #1d1b20;
}

body.material-lilac-theme .eyebrow,
body.material-lilac-theme .summary-grid strong,
body.material-lilac-theme .panel-title strong {
  color: #6750a4 !important;
}

body.material-lilac-theme button,
body.material-lilac-theme .home-link,
body.material-lilac-theme .text-link,
body.material-lilac-theme .primary-action,
body.material-lilac-theme .secondary-action {
  border-radius: 20px !important;
  transition: background-color 180ms ease, color 180ms ease, box-shadow 180ms ease;
}

body.material-lilac-theme .primary-action,
body.material-lilac-theme button[type="submit"],
body.material-lilac-theme .page-size-toggle button.active {
  color: #ffffff !important;
  border-color: #6750a4 !important;
  background: #6750a4 !important;
  box-shadow: 0 4px 12px rgba(103, 80, 164, 0.28) !important;
}

body.material-lilac-theme .secondary-action,
body.material-lilac-theme .home-link,
body.material-lilac-theme .text-link,
body.material-lilac-theme .pagination button,
body.material-lilac-theme .crud-actions button {
  color: #6750a4 !important;
  border-color: #79747e !important;
  background: #fffbfe !important;
}

body.material-lilac-theme button:hover,
body.material-lilac-theme .home-link:hover,
body.material-lilac-theme .text-link:hover {
  color: #21005d !important;
  background: #eaddff !important;
}

body.material-lilac-theme input,
body.material-lilac-theme textarea,
body.material-lilac-theme select {
  color: #1d1b20 !important;
  border-color: #79747e !important;
  border-radius: 12px !important;
  background: #fffbfe !important;
}

body.material-lilac-theme input:focus,
body.material-lilac-theme textarea:focus,
body.material-lilac-theme select:focus {
  border-color: #6750a4 !important;
  box-shadow: 0 0 0 3px rgba(103, 80, 164, 0.18) !important;
  outline: 0;
}

body.material-lilac-theme thead th {
  color: #21005d !important;
  border-color: #cac4d0 !important;
  background: #eaddff !important;
}

body.material-lilac-theme tbody tr,
body.material-lilac-theme .detail-modal-section {
  border-color: #cac4d0 !important;
  background: #f7f2fa !important;
}

body.material-lilac-theme .theme-toggle-button {
  color: #ffffff !important;
  border-color: #6750a4 !important;
  background: #6750a4 !important;
}

body.material-lilac-theme.genia-dark-theme {
  color: #e6e1e5;
  background: #1d1b20 !important;
}

body.material-lilac-theme.genia-dark-theme .topbar,
body.material-lilac-theme.genia-dark-theme .filters,
body.material-lilac-theme.genia-dark-theme .results,
body.material-lilac-theme.genia-dark-theme .login-card,
body.material-lilac-theme.genia-dark-theme .admin-panel,
body.material-lilac-theme.genia-dark-theme .admin-card,
body.material-lilac-theme.genia-dark-theme .log-panel,
body.material-lilac-theme.genia-dark-theme .sql-crud-panel,
body.material-lilac-theme.genia-dark-theme .caja-modal-card {
  color: #e6e1e5;
  border-color: #49454f !important;
  background: #211f26 !important;
}

body.material-lilac-theme.genia-dark-theme h1,
body.material-lilac-theme.genia-dark-theme h2,
body.material-lilac-theme.genia-dark-theme h3,
body.material-lilac-theme.genia-dark-theme strong {
  color: #e6e1e5;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(8, 124, 114, 0.14) 0%, rgba(8, 124, 114, 0) 36%),
    linear-gradient(315deg, rgba(159, 107, 22, 0.14) 0%, rgba(159, 107, 22, 0) 34%),
    var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
}

body.sql-page {
  --bg: #eef5ff;
  --panel: rgba(255, 255, 255, 0.78);
  --panel-soft: rgba(247, 250, 255, 0.86);
  --ink: #0f172a;
  --muted: #64748b;
  --line: rgba(148, 163, 184, 0.28);
  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --accent-soft: rgba(219, 234, 254, 0.78);
  --shadow: 0 22px 60px rgba(15, 23, 42, 0.10);
  background:
    linear-gradient(180deg, #f8fbff 0%, #edf5ff 48%, #f7fbff 100%);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Arial, sans-serif;
}

.caja-page {
  --accent: #7c3aed;
  --accent-strong: #5b21b6;
  --accent-soft: #f3e8ff;
  --line: #ddd6fe;
  --shadow: 0 18px 42px rgba(91, 33, 182, 0.10);
  height: 100vh;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(124, 58, 237, 0.16) 0%, rgba(124, 58, 237, 0) 36%),
    linear-gradient(315deg, rgba(168, 85, 247, 0.14) 0%, rgba(168, 85, 247, 0) 34%),
    #faf7ff;
}

.caja-topbar {
  border-bottom-color: #ddd6fe;
  min-height: 54px;
  padding: 6px 16px;
}

.caja-topbar h1 {
  font-size: 20px;
}

.caja-topbar .source {
  gap: 6px;
  white-space: nowrap;
}

.caja-topbar .home-link,
.caja-topbar .text-link {
  min-height: 26px;
  padding: 0 8px;
  font-size: 11px;
}

.caja-topbar #cajaStatus {
  font-size: 12px;
}

.caja-filters,
.caja-results {
  border-color: #ddd6fe;
}

.caja-page .layout {
  height: calc(100vh - 54px);
  grid-template-columns: minmax(240px, 288px) minmax(0, 1fr);
  align-items: start;
  gap: 10px;
  padding: 4px 14px 10px;
}

.caja-filters,
.caja-results {
  min-height: 0;
  padding: 8px;
}

.caja-filters {
  display: flex;
  flex-direction: column;
  position: static;
  max-height: calc(100vh - 64px);
  overflow-y: hidden;
  overflow-x: hidden;
  overscroll-behavior: contain;
}

.caja-filters .panel-title {
  margin-bottom: 5px;
}

.caja-filters .panel-title h2 {
  font-size: 18px;
}

.caja-filters .panel-title p {
  display: none;
}

.caja-filters .field {
  gap: 3px;
  margin-bottom: 5px;
}

.caja-filters .field label {
  font-size: 11px;
}

.caja-filters .field input,
.caja-filters .field select {
  min-height: 34px;
  padding: 0 8px;
  font-size: 13px;
}

.caja-results {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 10px;
}

.caja-results .toolbar {
  margin-bottom: 0;
}

.caja-results .toolbar h2 {
  font-size: 18px;
}

.caja-summary-grid {
  grid-template-columns: repeat(2, 1fr);
  gap: 5px;
  margin-top: 6px;
}

.caja-summary-grid div {
  padding: 8px;
}

.caja-summary-grid strong {
  color: #4c1d95;
  font-size: 14px;
}

.secure-summary-card {
  min-width: 0;
}

.secure-summary-button {
  display: block;
  width: 100%;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.secure-summary-button:hover {
  border-color: #a78bfa;
  background: #ffffff;
}

.summary-grid .secure-money {
  min-width: 0;
  margin-bottom: 1px;
  overflow: hidden;
  color: #4c1d95;
  font-size: clamp(14px, var(--money-size, 18px), 20px);
  line-height: 1.05;
  text-overflow: clip;
  white-space: nowrap;
}

.secure-money[data-hidden="true"] {
  letter-spacing: 1px;
}

.money-visibility-btn {
  width: 100%;
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 5px;
  padding: 0 10px;
  border: 1px solid #c4b5fd;
  border-radius: 8px;
  color: #5b21b6;
  background: #ffffff;
  cursor: pointer;
}

.money-visibility-btn svg {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.money-visibility-btn span {
  font-size: 12px;
  font-weight: 900;
}

.money-visibility-btn:hover {
  color: #ffffff;
  background: #7c3aed;
}

.money-popup {
  position: fixed;
  z-index: 90;
  min-width: 210px;
  max-width: calc(100vw - 32px);
  padding: 12px 14px;
  border: 1px solid #c4b5fd;
  border-radius: 10px;
  color: #4c1d95;
  background: #ffffff;
  box-shadow: 0 18px 42px rgba(91, 33, 182, 0.18);
  font-size: 16px;
  font-weight: 900;
  text-align: center;
}

.money-popup small {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

.caja-table {
  min-width: 980px;
}

.caja-page .table-wrap {
  min-height: 0;
  overflow: auto;
}

.caja-page th,
.caja-page td {
  padding: 8px 10px;
  font-size: 13px;
}

.caja-page th {
  position: sticky;
  top: 0;
  z-index: 2;
}

.caja-table td strong,
.caja-table td small {
  display: block;
}

.caja-table td small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.caja-detail-dropdown {
  min-width: 260px;
  border: 1px solid #ddd6fe;
  border-radius: 8px;
  background: #ffffff;
}

.caja-detail-dropdown summary {
  min-height: 30px;
  display: flex;
  align-items: center;
  padding: 0 10px;
  color: #5b21b6;
  cursor: pointer;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.caja-detail-dropdown[open] summary {
  border-bottom: 1px solid #ddd6fe;
  background: #f3e8ff;
}

.caja-detail-dropdown div {
  display: grid;
  gap: 6px;
  padding: 8px;
}

.caja-detail-dropdown p {
  color: var(--ink);
  font-size: 12px;
  line-height: 1.35;
}

.excel-detail-text {
  white-space: pre-wrap;
}

.caja-detail-dropdown strong {
  color: #5b21b6;
}

.treatment-list {
  display: grid;
  gap: 8px;
}

.treatment-list ul {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.treatment-list li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border: 1px solid #ddd6fe;
  border-radius: 8px;
  background: #faf7ff;
}

.treatment-filter-btn,
.caja-modal-close {
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid #c4b5fd;
  border-radius: 8px;
  color: #5b21b6;
  background: #ffffff;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 900;
}

.treatment-filter-btn:hover,
.caja-modal-close:hover {
  color: #ffffff;
  background: #7c3aed;
}

.caja-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(39, 18, 72, 0.35);
}

.caja-modal[hidden] {
  display: none;
}

.caja-modal-card {
  width: min(760px, 100%);
  max-height: min(720px, calc(100vh - 48px));
  overflow: auto;
  padding: 22px;
  border: 1px solid #ddd6fe;
  border-radius: 14px;
  background: #ffffff;
  box-shadow: 0 28px 70px rgba(39, 18, 72, 0.24);
}

.caja-modal-close {
  float: right;
}

.saving-overlay {
  position: fixed;
  inset: 0;
  z-index: 140;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(29, 16, 54, 0.58);
  backdrop-filter: blur(5px);
}

.saving-overlay[hidden] {
  display: none;
}

.saving-card {
  width: min(420px, 100%);
  display: grid;
  gap: 12px;
  padding: 24px;
  border: 1px solid #ddd6fe;
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 28px 80px rgba(39, 18, 72, 0.3);
}

.saving-card h2 {
  font-size: 22px;
}

.saving-card p:last-child {
  color: var(--muted);
  font-size: 14px;
}

.saving-progress {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #ede9fe;
}

.saving-progress span {
  display: block;
  width: 42%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #7c3aed, #22c55e);
  animation: saving-progress 1s ease-in-out infinite;
}

.is-saving-caja {
  cursor: wait;
}

.background-tasks-panel {
  display: grid;
  flex: 1 1 auto;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 6px;
  min-height: 150px;
  margin-top: 6px;
  padding: 8px;
  border: 1px solid rgba(124, 58, 237, 0.22);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(250, 247, 255, 0.88));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9), 0 14px 32px rgba(91, 33, 182, 0.08);
}

.background-tasks-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.background-tasks-head h3 {
  margin: 0;
  color: #2f1f54;
  font-size: 13px;
  line-height: 1.2;
}

.background-tasks-head span {
  min-width: 24px;
  min-height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  color: #ffffff;
  background: #7c3aed;
  font-size: 11px;
  font-weight: 900;
}

.background-tasks-list {
  display: grid;
  align-content: start;
  gap: 6px;
  min-height: 0;
  overflow-y: auto;
  padding-right: 2px;
}

.background-task {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 7px;
  width: 100%;
  padding: 7px;
  border: 1px solid rgba(196, 181, 253, 0.65);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 8px 18px rgba(91, 33, 182, 0.06);
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.background-task:hover {
  border-color: #a78bfa;
  background: #ffffff;
}

.background-task strong,
.background-task small,
.background-task p {
  overflow-wrap: anywhere;
}

.background-task strong {
  display: block;
  color: #3b2862;
  font-size: 12px;
}

.background-task small,
.background-task p {
  color: var(--muted);
  font-size: 10px;
}

.background-task span {
  align-self: start;
  min-height: 21px;
  display: inline-flex;
  align-items: center;
  padding: 0 7px;
  border-radius: 999px;
  color: #5b21b6;
  background: #f3e8ff;
  font-size: 10px;
  font-weight: 900;
}

.background-task.done span {
  color: #15803d;
  background: #dcfce7;
}

.background-task.error span {
  color: #b91c1c;
  background: #fee2e2;
}

.background-task-bar {
  grid-column: 1 / -1;
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: #f1eefc;
}

.background-task-bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #7c3aed, #a78bfa);
  transition: width 220ms ease;
}

.background-task.done .background-task-bar i {
  background: linear-gradient(90deg, #16a34a, #86efac);
}

.background-task.error .background-task-bar i {
  background: linear-gradient(90deg, #dc2626, #fca5a5);
}

.background-task p {
  grid-column: 1 / -1;
  margin: 0;
}

.caja-task-card {
  width: min(760px, 100%);
}

.task-change-list {
  display: grid;
  gap: 10px;
}

.task-change-item {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(196, 181, 253, 0.7);
  border-radius: 12px;
  background: #fbfaff;
}

.task-change-item strong {
  color: #3b2862;
}

.task-change-item span {
  display: block;
  margin-bottom: 4px;
  color: #6b7280;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.task-change-item p {
  margin: 0;
  color: #1f2937;
  overflow-wrap: anywhere;
}

@keyframes saving-progress {
  0% {
    transform: translateX(-110%);
  }
  100% {
    transform: translateX(250%);
  }
}

.treatment-history-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.treatment-history-item {
  display: grid;
  gap: 5px;
  padding: 12px;
  border: 1px solid #ddd6fe;
  border-radius: 8px;
  background: #faf7ff;
}

.treatment-history-item strong {
  color: #5b21b6;
}

.treatment-history-item span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.caja-edit-card {
  width: min(980px, 100%);
}

.caja-edit-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.caja-edit-form label {
  margin-bottom: 0;
}

.caja-edit-form .patient-field,
.caja-edit-form .birthdate-field {
  padding: 10px;
  border: 1px solid #c4b5fd;
  border-radius: 10px;
  background: #faf7ff;
}

.caja-edit-form input,
.caja-edit-form textarea {
  width: 100%;
  margin-top: 6px;
  padding: 9px 10px;
  border: 1px solid #ddd6fe;
  border-radius: 8px;
  color: var(--ink);
  font: inherit;
}

.caja-edit-form textarea {
  resize: vertical;
}

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

.caja-edit-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.caja-edit-btn {
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid #c4b5fd;
  border-radius: 8px;
  color: #5b21b6;
  background: #ffffff;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 900;
}

.caja-edit-btn:hover {
  color: #ffffff;
  background: #7c3aed;
}

.add-caja-patient-btn {
  min-width: 142px;
}

.caja-toolbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.download-caja-excel-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.caja-page {
  --icloud-bg: #f5f7ff;
  --icloud-panel: rgba(255, 255, 255, 0.82);
  --icloud-panel-strong: rgba(255, 255, 255, 0.94);
  --icloud-line: rgba(139, 92, 246, 0.18);
  --icloud-blue: #2563eb;
  --icloud-purple: #7c3aed;
  background:
    radial-gradient(circle at 16% 12%, rgba(147, 197, 253, 0.46), transparent 28%),
    radial-gradient(circle at 88% 8%, rgba(216, 180, 254, 0.46), transparent 26%),
    linear-gradient(180deg, #fbfdff 0%, #f3efff 100%);
}

.caja-topbar {
  margin: 10px 14px 0;
  border: 1px solid rgba(255, 255, 255, 0.76);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 18px 50px rgba(79, 70, 229, 0.10);
  backdrop-filter: blur(18px);
}

.caja-topbar h1 {
  color: #172033;
  font-size: 24px;
  font-weight: 900;
}

.caja-topbar .eyebrow {
  color: #6d5dfc;
}

.caja-topbar .source a,
.caja-topbar #cajaStatus {
  border-color: rgba(124, 58, 237, 0.16);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.70);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.caja-page .layout {
  height: calc(100vh - 76px);
  grid-template-columns: minmax(252px, 318px) minmax(0, 1fr);
  gap: 14px;
  padding: 12px 14px 14px;
}

.caja-filters,
.caja-results {
  border: 1px solid var(--icloud-line);
  border-radius: 22px;
  background: var(--icloud-panel);
  box-shadow: 0 22px 60px rgba(79, 70, 229, 0.12);
  backdrop-filter: blur(18px);
}

.caja-filters {
  max-height: calc(100vh - 90px);
  padding: 14px;
}

.caja-results {
  padding: 14px;
}

.caja-filters .panel-title h2,
.caja-results .toolbar h2 {
  color: #172033;
  font-size: 21px;
}

.caja-filters .panel-title p {
  display: block;
  margin-top: 3px;
  color: #64748b;
  font-size: 12px;
}

.caja-filters .field {
  margin-bottom: 9px;
}

.caja-filters .field label {
  color: #475569;
  font-size: 12px;
}

.caja-filters .field input,
.caja-filters .field select,
.caja-edit-form input,
.caja-edit-form textarea {
  border-color: rgba(124, 58, 237, 0.18);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.88);
}

.caja-filters .field input:focus,
.caja-filters .field select:focus,
.caja-edit-form input:focus,
.caja-edit-form textarea:focus {
  outline: 3px solid rgba(96, 165, 250, 0.22);
  border-color: rgba(37, 99, 235, 0.52);
}

.caja-summary-grid {
  gap: 8px;
}

.caja-summary-grid div,
.secure-summary-button {
  min-height: 74px;
  border-color: rgba(124, 58, 237, 0.16);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.94), 0 12px 28px rgba(79, 70, 229, 0.08);
}

.caja-summary-grid strong,
.summary-grid .secure-money {
  color: #4f46e5;
}

.money-visibility-btn,
.treatment-filter-btn,
.caja-edit-btn,
.caja-modal-close {
  min-height: 36px;
  border-color: rgba(124, 58, 237, 0.22);
  border-radius: 999px;
  color: #4f46e5;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 10px 24px rgba(79, 70, 229, 0.08);
}

.money-visibility-btn:hover,
.treatment-filter-btn:hover,
.caja-edit-btn:hover,
.caja-modal-close:hover {
  color: #ffffff;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
}

.background-tasks-panel,
.caja-detail-dropdown,
.treatment-history-item {
  border-color: rgba(124, 58, 237, 0.16);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.76);
}

.caja-page .table-wrap {
  border: 1px solid rgba(124, 58, 237, 0.16);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.74);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.92);
}

.caja-page th {
  color: #475569;
  background: rgba(248, 250, 252, 0.96);
}

.caja-page td {
  background: rgba(255, 255, 255, 0.62);
}

.caja-page tbody tr:hover td {
  background: rgba(239, 246, 255, 0.92);
}

.caja-modal {
  background: rgba(30, 41, 59, 0.28);
  backdrop-filter: blur(14px);
}

.caja-modal-card {
  border-color: rgba(255, 255, 255, 0.78);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 30px 90px rgba(30, 41, 59, 0.28);
}

.caja-edit-form .patient-field,
.caja-edit-form .birthdate-field,
.caja-edit-form .dni-field {
  padding: 12px;
  border: 1px solid rgba(124, 58, 237, 0.22);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(245, 243, 255, 0.88));
  box-shadow: 0 12px 28px rgba(79, 70, 229, 0.08);
}

.caja-edit-form .dni-field {
  outline: 2px solid rgba(37, 99, 235, 0.18);
}

.caja-edit-form .add-date-mode-field,
.caja-edit-form .add-date-field {
  padding: 12px;
  border: 1px solid rgba(37, 99, 235, 0.20);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(239, 246, 255, 0.94), rgba(255, 255, 255, 0.88));
}

.caja-edit-form select {
  width: 100%;
  min-height: 38px;
  margin-top: 6px;
  padding: 0 10px;
  border: 1px solid rgba(124, 58, 237, 0.18);
  border-radius: 14px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.86);
  font: inherit;
}

h1,
h2,
h3,
p {
  margin: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 22px 32px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

h1 {
  font-size: 28px;
  line-height: 1.1;
}

.source {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.home-link,
.text-link,
.text-button {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--accent-strong);
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  text-decoration: none;
}

.home-link:hover,
.text-link:hover,
.text-button:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.login-page {
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-shell {
  width: min(100%, 440px);
}

.login-card {
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 24px 58px rgba(28, 43, 54, 0.14);
}

.login-brand {
  margin-bottom: 22px;
}

.login-brand h1 {
  font-size: 30px;
}

.login-brand p:last-child {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.45;
}

.login-form .primary-action {
  margin-top: 18px;
  min-height: 46px;
}

/* iCloud-inspired access screen. */
.login-page {
  min-height: 100vh;
  min-height: 100dvh;
  overflow: auto;
  padding: clamp(18px, 5vw, 56px);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.76), rgba(255, 255, 255, 0) 42%),
    linear-gradient(135deg, #edf7ff 0%, #f7fbff 45%, #eef8f4 100%);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Arial, sans-serif;
}

.login-page .login-shell {
  width: min(100%, 460px);
}

.login-page .login-card {
  position: relative;
  overflow: hidden;
  padding: clamp(24px, 5vw, 40px);
  border: 1px solid rgba(255, 255, 255, 0.90);
  border-radius: 26px;
  background: rgba(255, 255, 255, 0.76);
  box-shadow: 0 28px 70px rgba(35, 73, 115, 0.16), inset 0 1px 0 rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(28px) saturate(1.15);
}

.login-page .login-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 5px;
  background: linear-gradient(90deg, #0a84ff 0 48%, #34c759 48% 72%, #ff9f0a 72% 100%);
}

.login-page .login-brand {
  margin-bottom: 26px;
  text-align: center;
}

.login-page .login-logo {
  width: 72px;
  height: 72px;
  display: block;
  margin: 0 auto 14px;
  object-fit: contain;
  filter: drop-shadow(0 10px 18px rgba(14, 165, 164, 0.18));
}

.login-page .login-brand .eyebrow {
  margin-bottom: 8px;
  color: #087c72;
  font-size: 0.76rem;
  letter-spacing: 0;
}

.login-page .login-brand h1 {
  margin: 0;
  color: #101828;
  font-size: clamp(1.9rem, 6vw, 2.35rem);
  line-height: 1.12;
}

.login-page .login-brand p:last-child {
  max-width: 330px;
  margin: 10px auto 0;
  color: #667085;
  font-size: 0.96rem;
}

.login-page .login-form {
  display: grid;
  gap: 14px;
}

.login-page .field {
  margin: 0;
}

.login-page .field label {
  margin: 0 0 7px 3px;
  color: #475467;
  font-size: 0.82rem;
}

.login-page .field input {
  min-height: 52px;
  padding: 0 15px;
  border: 1px solid rgba(148, 163, 184, 0.34);
  border-radius: 13px;
  color: #101828;
  background: rgba(255, 255, 255, 0.84);
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.03);
  font-size: 1rem;
}

.login-page .field input:focus {
  border-color: #0a84ff;
  outline: 4px solid rgba(10, 132, 255, 0.13);
  background: #ffffff;
}

.login-page .input-help {
  margin: 6px 3px 0;
  color: #7a8798;
  font-size: 0.72rem;
}

.login-page .primary-action,
.login-page .secondary-action {
  min-height: 50px;
  border-radius: 13px;
  font-size: 0.95rem;
}

.login-page .primary-action {
  margin-top: 6px;
  border: 1px solid #087c72;
  background: #087c72;
  box-shadow: 0 12px 24px rgba(8, 124, 114, 0.20);
}

.login-page .primary-action:hover:not(:disabled) {
  background: #066c64;
  transform: translateY(-1px);
}

.login-page .secondary-action {
  margin-top: 0;
  border-color: rgba(10, 132, 255, 0.24);
  color: #0969c3;
  background: rgba(255, 255, 255, 0.66);
}

.login-page .form-note {
  min-height: 20px;
  margin: 2px 0 0;
  color: #526173;
  text-align: center;
}

body.genia-dark-theme.login-page {
  background: linear-gradient(145deg, #07111f 0%, #101827 54%, #10201e 100%);
}

body.genia-dark-theme.login-page .login-card {
  border-color: rgba(148, 163, 184, 0.20);
  background: rgba(15, 23, 42, 0.76);
}

body.genia-dark-theme.login-page .login-brand h1 {
  color: #f8fafc;
}

body.genia-dark-theme.login-page .login-brand p:last-child,
body.genia-dark-theme.login-page .field label,
body.genia-dark-theme.login-page .input-help,
body.genia-dark-theme.login-page .form-note {
  color: #cbd5e1;
}

body.genia-dark-theme.login-page .field input,
body.genia-dark-theme.login-page .secondary-action {
  color: #f8fafc;
  border-color: rgba(148, 163, 184, 0.28);
  background: rgba(30, 41, 59, 0.78);
}

@media (max-width: 520px) {
  .login-page {
    align-items: start;
    padding: 12px;
  }

  .login-page .login-card {
    padding: 24px 18px;
    border-radius: 22px;
  }

  .login-page .login-logo {
    width: 60px;
    height: 60px;
  }
}

.redirect-action {
  justify-content: center;
  margin-top: 18px;
  text-decoration: none;
}

.input-help {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.layout {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 20px;
  padding: 20px 32px 32px;
}

.sql-layout {
  transition: grid-template-columns 220ms ease, gap 220ms ease, padding-left 220ms ease;
}

.sql-layout.sql-sidebar-collapsed {
  grid-template-columns: 0 minmax(0, 1fr);
  gap: 0;
  padding-left: 52px;
}

.admin-layout {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 20px;
  padding: 20px 32px 32px;
}

.single-panel-layout {
  grid-template-columns: 1fr;
}

.filters,
.results,
.admin-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.filters {
  align-self: start;
  position: sticky;
  top: 16px;
  padding: 18px;
  min-width: 0;
  transform-origin: left center;
  transition: opacity 180ms ease, transform 220ms ease, padding 220ms ease, border-color 180ms ease;
}

.sql-sidebar-collapsed .filters {
  width: 0;
  padding: 0;
  border-color: transparent;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
  transform: translateX(-32px);
  box-shadow: none;
}

.results {
  min-width: 0;
  padding: 18px;
}

.sidebar-toggle {
  position: fixed;
  left: 10px;
  top: 116px;
  z-index: 30;
  display: grid;
  place-items: center;
  gap: 4px;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--accent-strong);
  box-shadow: var(--shadow);
  cursor: pointer;
}

.sidebar-toggle span {
  display: block;
  width: 18px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
  transition: transform 180ms ease, opacity 180ms ease;
}

.sidebar-toggle[aria-expanded="true"] span:nth-child(1) {
  transform: translateY(6px) rotate(45deg);
}

.sidebar-toggle[aria-expanded="true"] span:nth-child(2) {
  opacity: 0;
}

.sidebar-toggle[aria-expanded="true"] span:nth-child(3) {
  transform: translateY(-6px) rotate(-45deg);
}

.sidebar-toggle:hover {
  border-color: rgba(8, 124, 114, 0.35);
  background: var(--accent-soft);
}

.admin-panel {
  align-self: start;
  padding: 18px;
}

.admin-table-panel {
  min-width: 0;
}

.log-detail {
  max-width: 520px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.panel-title {
  margin-bottom: 16px;
}

.panel-title h2 {
  font-size: 19px;
}

.panel-title p,
#resultsSubtitle,
.history-head p,
.form-note {
  margin-top: 5px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.4;
}

label,
.search-label {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 0 13px;
  border: 2px solid var(--accent);
  border-radius: 8px;
  background: #ffffff;
}

.search-box svg {
  width: 21px;
  height: 21px;
  flex: 0 0 auto;
  fill: none;
  stroke: var(--accent);
  stroke-linecap: round;
  stroke-width: 2;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  font: inherit;
}

.search-box input {
  min-height: 48px;
  border: 0;
  background: transparent;
  font-size: 17px;
}

input:focus,
select:focus,
.search-box:focus-within {
  border-color: var(--accent);
  outline: 3px solid rgba(8, 124, 114, 0.16);
}

.search-box input:focus {
  outline: 0;
}

select,
.field input {
  padding: 0 11px;
}

.filter-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 16px;
}

.field {
  margin-top: 16px;
}

.filter-group .field {
  margin-top: 0;
}

.summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 18px;
}

.summary-grid div {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.summary-grid strong {
  display: block;
  margin-bottom: 2px;
  font-size: 24px;
  line-height: 1;
}

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

.collapsible-panel {
  display: block;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-soft);
  overflow: hidden;
}

.collapsible-panel summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  cursor: pointer;
  list-style: none;
  font-weight: 900;
  color: var(--ink);
}

.collapsible-panel summary::-webkit-details-marker {
  display: none;
}

.collapsible-panel summary::after {
  content: "+";
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--accent-strong);
  background: var(--panel);
}

.collapsible-panel[open] summary::after {
  content: "-";
}

.collapsible-panel summary small {
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.collapsible-content {
  padding: 0 14px 14px;
}

.filters-collapsible .panel-title {
  margin-bottom: 12px;
}

.patient-summary-details {
  margin-top: 12px;
}

.patient-summary-details .patient-collapsible {
  border-color: rgba(8, 124, 114, 0.24);
  background: var(--accent-soft);
  box-shadow: inset 4px 0 0 var(--accent);
}

.patient-summary-details summary span {
  color: var(--accent-strong);
  font-size: 12px;
  text-transform: uppercase;
}

.patient-summary-details .data-row {
  grid-template-columns: 96px minmax(0, 1fr);
  padding: 6px 0;
  border-color: rgba(8, 124, 114, 0.16);
}

.sql-crud-panel {
  padding: 12px;
  border: 1px solid rgba(8, 124, 114, 0.24);
  border-radius: 10px;
  background: var(--accent-soft);
  box-shadow: inset 4px 0 0 var(--accent);
}

.sql-crud-panel > strong {
  display: block;
  color: var(--accent-strong);
  font-size: 12px;
  text-transform: uppercase;
}

.crud-record-title {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.crud-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.crud-actions button {
  min-height: 38px;
  border: 1px solid rgba(8, 124, 114, 0.28);
  border-radius: 9px;
  background: var(--panel);
  color: var(--accent-strong);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 900;
}

.crud-actions button:hover {
  background: #ffffff;
  border-color: rgba(8, 124, 114, 0.48);
}

.crud-actions .danger-action {
  border-color: rgba(190, 18, 60, 0.28);
  color: #be123c;
}

.sql-detail-modal-card {
  width: min(920px, calc(100vw - 28px));
}

.detail-modal-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.detail-modal-section {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-soft);
}

.detail-modal-section h3 {
  margin-bottom: 10px;
  color: var(--accent-strong);
  font-size: 14px;
  text-transform: uppercase;
}

.detail-modal-section.wide-section {
  grid-column: 1 / -1;
}

.payment-type-box {
  color: var(--ink);
  line-height: 1.6;
}

.detail-bottom-action {
  margin-top: 14px;
}

.primary-action,
.secondary-action,
.compact-action {
  min-height: 42px;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
}

.primary-action {
  width: 100%;
  border: 0;
  background: var(--accent);
  color: #ffffff;
}

.primary-action:hover {
  background: var(--accent-strong);
}

.secondary-action {
  width: 100%;
  margin-top: 14px;
  border: 1px solid rgba(8, 124, 114, 0.35);
  background: #ffffff;
  color: var(--accent-strong);
}

.secondary-action:hover:not(:disabled),
.history-btn:hover,
.pagination button:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.secondary-action:disabled,
.pagination button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.compact-action {
  width: auto;
  min-width: 108px;
  margin-top: 0;
  padding: 0 12px;
}

.add-form,
.history-panel {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.add-form h2,
.history-head h2 {
  font-size: 18px;
}

.export-box {
  margin-top: 18px;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.toolbar h2 {
  font-size: 23px;
}

.view-toggle {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.view-toggle button {
  min-width: 88px;
  min-height: 36px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 800;
}

.view-toggle button.active {
  background: var(--accent);
  color: #ffffff;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin: 0 0 14px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.pagination button {
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
}

.pagination label {
  margin: 0;
}

.pagination input {
  width: 76px;
  min-height: 36px;
  padding: 0 8px;
  text-align: center;
}

.pagination span {
  color: var(--muted);
  font-size: 14px;
  white-space: nowrap;
}

.page-size-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  padding-left: 10px;
  border-left: 1px solid var(--line);
}

.page-size-toggle span {
  margin-right: 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.page-size-toggle button {
  min-width: 38px;
  padding: 0 10px;
}

.page-size-toggle button.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.patient-list {
  display: grid;
  gap: 12px;
}

.patient-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #ffffff;
}

.patient-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 15px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-soft);
}

.patient-head h3 {
  font-size: 21px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.patient-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.patient-meta span {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #ffffff;
}

.expand-btn {
  min-height: 32px;
  padding: 0 11px;
  border: 1px solid rgba(8, 124, 114, 0.35);
  border-radius: 8px;
  background: #ffffff;
  color: var(--accent-strong);
  cursor: pointer;
  font: inherit;
  font-weight: 800;
}

.expand-btn:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.visit {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 16px;
  padding: 14px 16px;
  border-top: 1px solid #edf1ef;
}

.visit:first-of-type {
  border-top: 0;
}

.date-pill {
  color: var(--accent-strong);
  font-weight: 900;
}

.sheet-name {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.detail {
  overflow-wrap: anywhere;
  line-height: 1.45;
}

.payment {
  color: var(--gold);
  font-weight: 800;
  text-align: right;
}

.empty {
  padding: 40px 18px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  text-align: center;
}

.empty p {
  margin-top: 8px;
  color: var(--muted);
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

.history-list {
  display: grid;
  gap: 10px;
}

.history-item {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr) 112px;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.history-date {
  color: var(--accent-strong);
  font-weight: 800;
}

.history-detail strong {
  display: block;
  margin-bottom: 3px;
}

.history-detail span {
  color: var(--muted);
  line-height: 1.35;
}

.history-amount {
  color: var(--gold);
  font-weight: 800;
  text-align: right;
}

.history-actions {
  display: grid;
  justify-items: end;
  gap: 6px;
}

.user-row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.history-btn {
  min-height: 28px;
  min-width: 78px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 800;
}

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

.save-user-btn {
  border-color: rgba(8, 124, 114, 0.28);
  color: #ffffff;
  background: var(--accent);
}

.save-user-btn:hover {
  background: var(--accent-strong);
}

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

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 840px;
}

.admin-table {
  min-width: 680px;
}

.admin-table select {
  min-width: 160px;
}

.table-input {
  width: min(260px, 100%);
  min-height: 34px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #ffffff;
  font: inherit;
}

.table-input:focus {
  border-color: var(--accent);
  outline: 2px solid rgba(8, 124, 114, 0.14);
}

.inline-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--ink);
  white-space: nowrap;
}

.inline-check input {
  width: 16px;
  min-height: 16px;
}

th,
td {
  padding: 12px;
  border-bottom: 1px solid #edf1ef;
  text-align: left;
  vertical-align: top;
}

th {
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.selectable-row {
  cursor: pointer;
}

.selectable-row:hover td {
  background: #f8fbfb;
}

.selected-row td {
  background: var(--accent-soft);
  border-top: 1px solid rgba(8, 124, 114, 0.24);
  border-bottom: 1px solid rgba(8, 124, 114, 0.24);
}

.selected-row td:first-child {
  border-left: 4px solid var(--accent);
}

.selected-row td:last-child {
  border-right: 1px solid rgba(8, 124, 114, 0.24);
}

td:last-child,
th:last-child {
  text-align: right;
}

.detail-cell {
  text-align: left !important;
}

.structured-detail {
  display: grid;
  gap: 10px;
  min-width: 320px;
}

.detail-section {
  display: grid;
  gap: 6px;
}

.diagnosis-dropdown {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.diagnosis-dropdown summary {
  min-height: 36px;
  display: flex;
  align-items: center;
  padding: 0 10px;
  color: var(--accent-strong);
  cursor: pointer;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.diagnosis-dropdown[open] summary {
  border-bottom: 1px solid var(--line);
  background: var(--accent-soft);
}

.diagnosis-dropdown .diagnosis-list {
  padding: 8px;
}

.detail-heading {
  color: var(--accent-strong);
  font-size: 12px;
  text-transform: uppercase;
}

.diagnosis-list,
.data-list {
  display: grid;
  gap: 6px;
}

.diagnosis-row {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr) 34px;
  align-items: start;
  gap: 8px;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.diagnosis-code,
.diagnosis-state {
  color: var(--accent-strong);
  font-weight: 900;
}

.diagnosis-state {
  cursor: help;
  text-align: center;
}

.diagnosis-name {
  overflow-wrap: anywhere;
}

.data-row {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr);
  gap: 8px;
  padding: 5px 0;
  border-bottom: 1px solid #edf1ef;
}

.data-row:last-child {
  border-bottom: 0;
}

.data-row strong {
  color: var(--muted);
}

.data-row span {
  overflow-wrap: anywhere;
}

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

mark {
  border-radius: 4px;
  background: rgba(159, 107, 22, 0.2);
  color: inherit;
  padding: 0 2px;
}

.new-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

@media (max-width: 980px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 20px 18px 16px;
  }

  .source {
    justify-content: flex-start;
  }

  .layout {
    grid-template-columns: 1fr;
    padding: 16px;
  }

  .sql-layout.sql-sidebar-collapsed {
    grid-template-columns: 1fr;
    padding-left: 16px;
  }

  .sql-sidebar-collapsed .filters {
    max-height: 0;
    transform: translateX(-16px);
  }

  .sidebar-toggle {
    top: auto;
    bottom: 16px;
    left: 16px;
  }

  .admin-layout {
    grid-template-columns: 1fr;
    padding: 16px;
  }

  .filters {
    position: static;
  }

  .caja-page {
    height: auto;
    min-height: 100vh;
    overflow: auto;
  }

  .caja-page .layout {
    height: auto;
    grid-template-columns: 1fr;
    padding: 14px;
  }

  .caja-topbar {
    margin: 10px 10px 0;
  }

  .caja-filters {
    max-height: none;
    overflow: visible;
  }

  .caja-summary-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .caja-results {
    min-height: min(680px, calc(100vh - 180px));
  }

  .caja-edit-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  h1 {
    font-size: 25px;
  }

  .toolbar,
  .history-head,
  .patient-head,
  .visit {
    align-items: stretch;
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .filter-group,
  .summary-grid,
  .history-item {
    grid-template-columns: 1fr;
  }

  .patient-meta,
  .payment,
  .history-amount,
  .history-actions {
    justify-content: flex-start;
    justify-items: start;
    text-align: left;
  }

  .view-toggle {
    width: 100%;
  }

  .view-toggle button {
    flex: 1;
  }

  .pagination {
    align-items: stretch;
    display: grid;
    grid-template-columns: 1fr auto 76px auto 1fr;
  }

  .page-size-toggle {
    grid-column: 1 / -1;
    justify-content: center;
    margin-left: 0;
    padding-left: 0;
    padding-top: 8px;
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .detail-modal-layout {
    grid-template-columns: 1fr;
  }

  .caja-page .layout {
    padding: 10px;
  }

  .caja-topbar {
    border-radius: 16px;
    padding: 14px;
  }

  .caja-topbar .source {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .caja-topbar .source a,
  .caja-topbar #cajaStatus {
    justify-content: center;
    min-width: 0;
    width: 100%;
  }

  .caja-filters,
  .caja-results {
    border-radius: 18px;
    padding: 12px;
  }

  .caja-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .caja-results {
    min-height: 0;
  }

  .caja-page .table-wrap {
    overflow: visible;
    border: 0;
    background: transparent;
    box-shadow: none;
  }

  .caja-table,
  .caja-table thead,
  .caja-table tbody,
  .caja-table tr,
  .caja-table td {
    display: block;
    width: 100%;
    min-width: 0;
  }

  .caja-table thead {
    display: none;
  }

  .caja-table tr {
    margin-bottom: 10px;
    padding: 12px;
    border: 1px solid rgba(124, 58, 237, 0.16);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.80);
    box-shadow: 0 12px 30px rgba(79, 70, 229, 0.08);
  }

  .caja-page .caja-table td {
    display: grid;
    grid-template-columns: 112px minmax(0, 1fr);
    gap: 10px;
    padding: 8px 0;
    border: 0;
    background: transparent;
    font-size: 13px;
  }

  .caja-page .caja-table td::before {
    color: #64748b;
    font-size: 11px;
    font-weight: 900;
    text-transform: uppercase;
  }

  .caja-page .caja-table td:nth-child(1)::before { content: "Paciente"; }
  .caja-page .caja-table td:nth-child(2)::before { content: "Mes"; }
  .caja-page .caja-table td:nth-child(3)::before { content: "Fecha"; }
  .caja-page .caja-table td:nth-child(4)::before { content: "Comprobante"; }
  .caja-page .caja-table td:nth-child(5)::before { content: "Total"; }
  .caja-page .caja-table td:nth-child(6)::before { content: "Pendiente"; }
  .caja-page .caja-table td:nth-child(7)::before { content: "Detalle"; }
  .caja-page .caja-table td:nth-child(8)::before { content: "Acciones"; }

  .caja-detail-dropdown {
    min-width: 0;
  }

  .caja-edit-form {
    grid-template-columns: 1fr;
  }

  .caja-edit-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .caja-toolbar-actions {
    justify-content: stretch;
  }

  .caja-toolbar-actions .treatment-filter-btn {
    width: 100%;
  }
}

/* Cross-device visibility polish for SQL, Caja and administration pages. */
html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

img,
svg,
canvas,
video {
  max-width: 100%;
  height: auto;
}

.topbar,
.caja-topbar {
  gap: 12px;
}

.topbar h1,
.caja-topbar h1,
.toolbar h2,
.panel-title h2 {
  overflow-wrap: anywhere;
  text-wrap: balance;
}

.layout,
.admin-layout,
.caja-page .layout {
  min-width: 0;
}

.filters,
.results,
.admin-panel,
.caja-filters,
.caja-results,
.table-wrap,
.caja-page .table-wrap {
  min-width: 0;
  max-width: 100%;
}

table {
  max-width: 100%;
}

th,
td,
.data-row span,
.patient-name,
.caja-detail-dropdown p {
  overflow-wrap: anywhere;
}

.source,
.caja-topbar .source,
.toolbar,
.caja-results .toolbar,
.caja-toolbar-actions {
  flex-wrap: wrap;
}

.summary-grid,
.filter-group,
.caja-summary-grid {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.admin-form-grid,
.caja-edit-form {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.caja-edit-form .patient-field,
.caja-edit-form .birthdate-field,
.caja-edit-form .dni-field,
.caja-edit-form .wide-field {
  grid-column: auto;
}

.caja-modal-card,
.modal-card {
  width: min(760px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
}

@media (max-width: 1180px) {
  .caja-page {
    height: auto;
    min-height: 100vh;
    overflow: auto;
  }

  .caja-page .layout {
    height: auto;
    grid-template-columns: 1fr;
  }

  .caja-filters {
    max-height: none;
    overflow: visible;
  }
}

@media (max-width: 760px) {
  .topbar,
  .caja-topbar {
    align-items: stretch;
    flex-direction: column;
    margin: 10px;
    padding: 14px;
  }

  .source,
  .caja-topbar .source {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .source a,
  .source button,
  .caja-topbar .source a,
  .caja-topbar #cajaStatus {
    justify-content: center;
    min-width: 0;
    width: 100%;
    white-space: normal;
  }

  .layout,
  .admin-layout,
  .caja-page .layout {
    padding: 10px;
  }

  .filters,
  .results,
  .admin-panel,
  .caja-filters,
  .caja-results {
    border-radius: 18px;
    padding: 12px;
  }

  .toolbar,
  .caja-results .toolbar,
  .caja-toolbar-actions,
  .record-actions,
  .modal-actions {
    align-items: stretch;
    display: grid;
    grid-template-columns: 1fr;
  }

  .toolbar button,
  .toolbar a,
  .caja-toolbar-actions button,
  .caja-toolbar-actions a,
  .record-actions button,
  .modal-actions button {
    width: 100%;
  }
}

@media (max-width: 420px) {
  .source,
  .caja-topbar .source,
  .summary-grid,
  .filter-group,
  .caja-summary-grid {
    grid-template-columns: 1fr;
  }

  .pagination {
    grid-template-columns: 1fr;
  }

  .page-size-toggle {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .caja-page .caja-table td {
    grid-template-columns: 1fr;
  }
}

/* Shared light/night toggle for consultador pages. */
.chat-toast-stack {
  position: fixed;
  right: 18px;
  bottom: 78px;
  z-index: 10020;
  width: min(360px, calc(100vw - 32px));
  display: grid;
  gap: 10px;
  pointer-events: none;
}

.chat-toast {
  display: grid;
  gap: 4px;
  padding: 14px 16px;
  border: 1px solid rgba(96, 165, 250, 0.38);
  border-radius: 16px;
  color: #17202a;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 18px 42px rgba(15, 23, 42, 0.22);
  backdrop-filter: blur(18px);
  text-decoration: none;
  pointer-events: auto;
  animation: consultador-chat-toast-in 240ms ease-out both;
}

.chat-toast strong,
.chat-toast span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-toast span {
  color: #64748b;
  font-size: 0.88rem;
}

.chat-toast.is-mention {
  border-color: rgba(225, 29, 72, 0.48);
  box-shadow: 0 18px 42px rgba(225, 29, 72, 0.18);
}

.chat-toast.is-leaving {
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 240ms ease, transform 240ms ease;
}

body.genia-dark-theme .chat-toast {
  color: #f8fafc;
  background: rgba(15, 23, 42, 0.94);
}

body.genia-dark-theme .chat-toast span {
  color: #cbd5e1;
}

@keyframes consultador-chat-toast-in {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.theme-toggle-button {
  position: fixed;
  top: auto;
  right: 18px;
  bottom: 18px;
  z-index: 120;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 50%;
  color: #0f172a;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 16px 38px rgba(15, 23, 42, 0.16), inset 0 1px 0 rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(18px);
  cursor: pointer;
  font: inherit;
  font-size: 1.35rem;
  font-weight: 900;
  line-height: 1;
}

.theme-toggle-button:hover {
  transform: translateY(-1px);
}

body.genia-dark-theme {
  --bg: #0f172a;
  --panel: rgba(15, 23, 42, 0.84);
  --panel-soft: rgba(30, 41, 59, 0.76);
  --ink: #f8fafc;
  --muted: #cbd5e1;
  --line: rgba(148, 163, 184, 0.24);
  --accent-soft: rgba(59, 130, 246, 0.14);
  color: #f8fafc;
  background:
    radial-gradient(circle at 18% 8%, rgba(59, 130, 246, 0.20), rgba(59, 130, 246, 0) 31%),
    radial-gradient(circle at 82% 16%, rgba(168, 85, 247, 0.12), rgba(168, 85, 247, 0) 30%),
    linear-gradient(145deg, #07111f 0%, #101827 50%, #172033 100%);
}

body.genia-dark-theme .theme-toggle-button {
  color: #fde68a;
  border-color: rgba(147, 197, 253, 0.20);
  background: rgba(15, 23, 42, 0.78);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.34), inset 0 1px 0 rgba(255, 255, 255, 0.10);
}

body.genia-dark-theme .topbar,
body.genia-dark-theme .caja-topbar,
body.genia-dark-theme .filters,
body.genia-dark-theme .results,
body.genia-dark-theme .admin-panel,
body.genia-dark-theme .caja-filters,
body.genia-dark-theme .caja-results,
body.genia-dark-theme .login-card,
body.genia-dark-theme .patient-card,
body.genia-dark-theme .visit,
body.genia-dark-theme .history-item,
body.genia-dark-theme .caja-modal-card,
body.genia-dark-theme .caja-detail-dropdown,
body.genia-dark-theme .caja-edit-card,
body.genia-dark-theme .metric-card,
body.genia-dark-theme .data-panel,
body.genia-dark-theme .admin-table-panel {
  color: #f8fafc;
  border-color: rgba(148, 163, 184, 0.20);
  background: rgba(15, 23, 42, 0.76);
  box-shadow: 0 20px 52px rgba(0, 0, 0, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

body.genia-dark-theme h1,
body.genia-dark-theme h2,
body.genia-dark-theme h3,
body.genia-dark-theme strong,
body.genia-dark-theme th {
  color: #f8fafc;
}

body.genia-dark-theme p,
body.genia-dark-theme label,
body.genia-dark-theme .muted-text,
body.genia-dark-theme .source,
body.genia-dark-theme .data-row strong,
body.genia-dark-theme small {
  color: #cbd5e1;
}

body.genia-dark-theme input,
body.genia-dark-theme textarea,
body.genia-dark-theme select,
body.genia-dark-theme .table-input {
  color: #f8fafc;
  border-color: rgba(148, 163, 184, 0.28);
  background: rgba(15, 23, 42, 0.84);
}

body.genia-dark-theme input::placeholder,
body.genia-dark-theme textarea::placeholder {
  color: #94a3b8;
}

body.genia-dark-theme button,
body.genia-dark-theme .home-link,
body.genia-dark-theme .text-link,
body.genia-dark-theme .text-button,
body.genia-dark-theme .caja-edit-btn,
body.genia-dark-theme .secure-summary-button,
body.genia-dark-theme .money-visibility-btn {
  border-color: rgba(148, 163, 184, 0.24);
}

body.genia-dark-theme table,
body.genia-dark-theme td,
body.genia-dark-theme th {
  border-color: rgba(148, 163, 184, 0.20);
}

body.genia-dark-theme td,
body.genia-dark-theme .caja-table tr {
  background: rgba(15, 23, 42, 0.48);
}

@media (max-width: 760px) {
  .theme-toggle-button {
    top: auto;
    right: 12px;
    bottom: 12px;
    width: 42px;
    height: 42px;
  }
}

/* Smooth day/night transition across consultador pages. */
body,
.topbar,
.caja-topbar,
.filters,
.results,
.admin-panel,
.caja-filters,
.caja-results,
.login-card,
.patient-card,
.visit,
.history-item,
.caja-modal-card,
.caja-detail-dropdown,
.caja-edit-card,
.metric-card,
.data-panel,
.admin-table-panel,
.theme-toggle-button,
input,
textarea,
select,
button,
a,
td,
th {
  transition:
    background-color 520ms ease,
    background 520ms ease,
    color 520ms ease,
    border-color 520ms ease,
    box-shadow 520ms ease,
    opacity 360ms ease,
    transform 180ms ease;
}

.genia-theme-changing body {
  animation: genia-theme-wash 680ms ease both;
}

@keyframes genia-theme-wash {
  0% {
    filter: saturate(1) brightness(1);
  }
  45% {
    filter: saturate(1.14) brightness(1.08);
  }
  100% {
    filter: saturate(1) brightness(1);
  }
}

/* iCloud-style rework for the unified Caja/SQL view. */
body.sql-page {
  --bg: #eef5ff;
  --panel: rgba(255, 255, 255, 0.78);
  --panel-soft: rgba(247, 250, 255, 0.86);
  --ink: #0f172a;
  --muted: #64748b;
  --line: rgba(148, 163, 184, 0.28);
  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --accent-soft: rgba(219, 234, 254, 0.78);
  --shadow: 0 22px 60px rgba(15, 23, 42, 0.10);
  background: linear-gradient(180deg, #f8fbff 0%, #edf5ff 48%, #f7fbff 100%);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Arial, sans-serif;
}

body.sql-page.genia-dark-theme {
  --bg: #07111f;
  --panel: rgba(15, 23, 42, 0.76);
  --panel-soft: rgba(30, 41, 59, 0.74);
  --ink: #f8fafc;
  --muted: #cbd5e1;
  --line: rgba(148, 163, 184, 0.22);
  --accent: #60a5fa;
  --accent-strong: #93c5fd;
  --accent-soft: rgba(59, 130, 246, 0.14);
  --shadow: 0 28px 80px rgba(0, 0, 0, 0.30);
  background: linear-gradient(145deg, #07111f 0%, #101827 50%, #172033 100%);
}

body.sql-page .topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  margin: 14px 18px 0;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.68);
  box-shadow: 0 12px 42px rgba(15, 23, 42, 0.08);
  backdrop-filter: blur(22px);
}

body.sql-page.genia-dark-theme .topbar {
  background: rgba(15, 23, 42, 0.70);
}

body.sql-page .topbar h1 {
  font-size: clamp(24px, 2.4vw, 34px);
  font-weight: 850;
}

body.sql-page .eyebrow {
  color: var(--accent-strong);
  letter-spacing: 0;
}

body.sql-page .source {
  gap: 8px;
}

body.sql-page .home-link,
body.sql-page .text-link,
body.sql-page .source span {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.70);
  color: #1e3a8a;
  backdrop-filter: blur(18px);
}

body.sql-page.genia-dark-theme .home-link,
body.sql-page.genia-dark-theme .text-link,
body.sql-page.genia-dark-theme .source span {
  background: rgba(15, 23, 42, 0.62);
  color: #bfdbfe;
}

body.sql-page .layout {
  gap: 18px;
  padding: 18px 28px 28px;
}

body.sql-page .filters,
body.sql-page .results {
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.64);
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.10);
  backdrop-filter: blur(26px);
}

body.sql-page.genia-dark-theme .filters,
body.sql-page.genia-dark-theme .results {
  background: rgba(15, 23, 42, 0.66);
  box-shadow: 0 28px 84px rgba(0, 0, 0, 0.28);
}

body.sql-page .results {
  padding: 20px;
}

body.sql-page .sidebar-toggle {
  left: 16px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(18px);
}

body.sql-page.genia-dark-theme .sidebar-toggle {
  background: rgba(15, 23, 42, 0.76);
}

body.sql-page .collapsible-panel,
body.sql-page .summary-grid div,
body.sql-page .sql-crud-panel,
body.sql-page .pagination,
body.sql-page .detail-modal-section {
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.70);
  backdrop-filter: blur(18px);
}

body.sql-page.genia-dark-theme .collapsible-panel,
body.sql-page.genia-dark-theme .summary-grid div,
body.sql-page.genia-dark-theme .sql-crud-panel,
body.sql-page.genia-dark-theme .pagination,
body.sql-page.genia-dark-theme .detail-modal-section {
  background: rgba(30, 41, 59, 0.62);
}

body.sql-page input,
body.sql-page select,
body.sql-page .pagination input {
  min-height: 44px;
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.74);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

body.sql-page.genia-dark-theme input,
body.sql-page.genia-dark-theme select,
body.sql-page.genia-dark-theme .pagination input {
  background: rgba(15, 23, 42, 0.72);
}

body.sql-page input:focus,
body.sql-page select:focus {
  outline: 4px solid rgba(37, 99, 235, 0.16);
  border-color: rgba(37, 99, 235, 0.58);
}

body.sql-page .primary-action,
body.sql-page .page-size-toggle button.active {
  border: 0;
  border-radius: 13px;
  background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%);
  box-shadow: 0 10px 22px rgba(37, 99, 235, 0.22);
}

body.sql-page .secondary-action,
body.sql-page .pagination button,
body.sql-page .crud-actions button,
body.sql-page .page-size-toggle button {
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.76);
  color: #1d4ed8;
}

body.sql-page.genia-dark-theme .secondary-action,
body.sql-page.genia-dark-theme .pagination button,
body.sql-page.genia-dark-theme .crud-actions button,
body.sql-page.genia-dark-theme .page-size-toggle button {
  background: rgba(15, 23, 42, 0.66);
  color: #bfdbfe;
}

body.sql-page .toolbar h2 {
  font-size: clamp(22px, 2vw, 30px);
  font-weight: 850;
}

body.sql-page .table-wrap {
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.68);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.58);
}

body.sql-page table {
  border-collapse: separate;
  border-spacing: 0;
}

body.sql-page th {
  background: rgba(248, 250, 252, 0.92);
  color: #475569;
  font-size: 12px;
  text-transform: uppercase;
  white-space: nowrap;
  word-break: normal;
}

body.sql-page.genia-dark-theme th {
  background: rgba(15, 23, 42, 0.88);
  color: #cbd5e1;
}

body.sql-page td {
  border-bottom-color: rgba(148, 163, 184, 0.22);
  background: rgba(255, 255, 255, 0.48);
}

body.sql-page.genia-dark-theme td {
  background: rgba(15, 23, 42, 0.42);
}

body.sql-page tbody tr:hover td {
  background: rgba(219, 234, 254, 0.42);
}

body.sql-page.genia-dark-theme tbody tr:hover td {
  background: rgba(37, 99, 235, 0.20);
}

body.sql-page .selected-row td {
  background: rgba(219, 234, 254, 0.72);
}

body.sql-page.genia-dark-theme .selected-row td {
  background: rgba(37, 99, 235, 0.28);
}

body.sql-page .diagnosis-row,
body.sql-page .data-row {
  border-color: rgba(148, 163, 184, 0.22);
}

body.sql-page .caja-modal-card {
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 28px 90px rgba(15, 23, 42, 0.22);
  backdrop-filter: blur(26px);
}

body.sql-page.genia-dark-theme .caja-modal-card {
  background: rgba(15, 23, 42, 0.86);
}

@media (max-width: 760px) {
  body.sql-page .topbar {
    margin: 10px;
    border-radius: 18px;
  }

  body.sql-page .layout {
    padding: 12px;
  }

  body.sql-page .filters,
  body.sql-page .results {
    border-radius: 18px;
  }
}

/* Final iCloud-style polish for Consulta Caja. */
body.sql-page {
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.94) 0%, rgba(238, 245, 255, 0.76) 45%, rgba(245, 250, 255, 0.94) 100%),
    linear-gradient(115deg, rgba(96, 165, 250, 0.18), rgba(255, 255, 255, 0) 42%),
    linear-gradient(245deg, rgba(186, 230, 253, 0.18), rgba(255, 255, 255, 0) 38%);
}

body.sql-page.genia-dark-theme {
  color: var(--ink);
  background:
    linear-gradient(150deg, rgba(2, 6, 23, 0.98) 0%, rgba(15, 23, 42, 0.94) 46%, rgba(30, 41, 59, 0.92) 100%),
    linear-gradient(112deg, rgba(59, 130, 246, 0.20), rgba(15, 23, 42, 0) 40%),
    linear-gradient(245deg, rgba(14, 165, 233, 0.11), rgba(15, 23, 42, 0) 42%);
}

body.sql-page .topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 86px;
  padding: 16px 18px;
}

body.sql-page .topbar > div:first-child {
  min-width: 220px;
}

body.sql-page .source {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
}

body.sql-page .source span {
  font-size: 12px;
  font-weight: 850;
}

body.sql-page .home-link,
body.sql-page .text-link {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  text-decoration: none;
}

body.sql-page .home-link:hover,
body.sql-page .text-link:hover,
body.sql-page .secondary-action:hover:not(:disabled),
body.sql-page .pagination button:hover:not(:disabled),
body.sql-page .crud-actions button:hover {
  border-color: rgba(37, 99, 235, 0.34);
  background: rgba(219, 234, 254, 0.72);
  transform: translateY(-1px);
}

body.sql-page.genia-dark-theme .home-link:hover,
body.sql-page.genia-dark-theme .text-link:hover,
body.sql-page.genia-dark-theme .secondary-action:hover:not(:disabled),
body.sql-page.genia-dark-theme .pagination button:hover:not(:disabled),
body.sql-page.genia-dark-theme .crud-actions button:hover {
  background: rgba(37, 99, 235, 0.24);
}

body.sql-page .layout {
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  align-items: start;
  max-width: 1640px;
  margin: 0 auto;
}

body.sql-page .sql-layout.sql-sidebar-collapsed {
  grid-template-columns: minmax(0, 1fr);
  gap: 0;
  max-width: none;
  padding-left: 66px;
}

body.sql-page .sql-layout.sql-sidebar-collapsed .filters {
  position: absolute;
  width: 0;
  min-width: 0;
  max-width: 0;
}

body.sql-page .filters {
  top: 120px;
  max-height: calc(100vh - 142px);
  overflow-y: auto;
}

body.sql-page .filters::-webkit-scrollbar,
body.sql-page .table-wrap::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

body.sql-page .filters::-webkit-scrollbar-thumb,
body.sql-page .table-wrap::-webkit-scrollbar-thumb {
  border: 3px solid transparent;
  border-radius: 999px;
  background: rgba(96, 165, 250, 0.42);
  background-clip: padding-box;
}

body.sql-page .collapsible-panel {
  padding: 12px;
  border: 1px solid var(--line);
}

body.sql-page .collapsible-panel summary {
  padding: 4px 2px 12px;
}

body.sql-page .panel-title h2 {
  font-size: 21px;
}

body.sql-page .field {
  margin-bottom: 13px;
}

body.sql-page .field label {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0;
  text-transform: uppercase;
}

body.sql-page .summary-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

body.sql-page .summary-grid div {
  min-height: 94px;
  border: 1px solid rgba(147, 197, 253, 0.42);
  padding: 14px;
  min-width: 0;
  overflow: hidden;
}

body.sql-page .summary-grid div:has(#sqlAmountTotal) {
  grid-column: 1 / -1;
}

body.sql-page .summary-grid div:nth-child(3) {
  grid-column: 1 / -1;
}

body.sql-page .summary-grid strong {
  color: #1e40af;
  font-size: clamp(24px, 2.3vw, 34px);
  line-height: 1.05;
  max-width: 100%;
  overflow-wrap: anywhere;
}

body.sql-page #sqlAmountTotal {
  font-size: clamp(24px, 1.55vw, 30px);
  white-space: nowrap;
}

body.sql-page.genia-dark-theme .summary-grid strong {
  color: #bfdbfe;
}

body.sql-page .summary-grid span {
  color: var(--muted);
  font-size: 13px;
}

body.sql-page .sql-crud-panel {
  margin-top: 12px;
  border: 1px solid rgba(45, 212, 191, 0.26);
  padding: 14px;
}

body.sql-page .results {
  min-height: calc(100vh - 132px);
}

body.sql-page .toolbar {
  min-height: 58px;
  margin-bottom: 12px;
}

body.sql-page #sqlResultsSubtitle {
  max-width: 760px;
}

body.sql-page .pagination {
  justify-content: flex-start;
  gap: 8px;
  border: 1px solid var(--line);
  padding: 8px;
}

body.sql-page .pagination button {
  min-height: 38px;
  white-space: nowrap;
}

body.sql-page .page-size-toggle {
  margin-left: auto;
}

body.sql-page .table-wrap {
  max-height: calc(100vh - 330px);
  overflow: auto;
  border: 1px solid var(--line);
}

body.sql-page thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  height: 48px;
  border-bottom: 1px solid var(--line);
}

body.sql-page td,
body.sql-page th {
  padding: 13px 14px;
  vertical-align: top;
}

body.sql-page td {
  font-size: 14px;
}

body.sql-page .empty {
  min-height: 280px;
  display: grid;
  place-items: center;
  padding: 32px;
  border: 1px dashed rgba(96, 165, 250, 0.42);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.52);
  text-align: center;
}

body.sql-page.genia-dark-theme .empty {
  background: rgba(15, 23, 42, 0.48);
}

body.sql-page .history-panel {
  border-top: 0;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.58);
  padding: 16px;
}

body.sql-page.genia-dark-theme .history-panel {
  background: rgba(15, 23, 42, 0.42);
}

body.sql-page .caja-modal {
  background: rgba(15, 23, 42, 0.28);
  backdrop-filter: blur(16px);
}

body.sql-page .caja-modal-close {
  border-radius: 999px;
}

body.sql-page .detail-modal-layout {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

body.sql-page .detail-modal-section {
  border: 1px solid var(--line);
}

body.sql-page .theme-toggle-button {
  border-color: rgba(96, 165, 250, 0.34);
}

@media (max-width: 1080px) {
  body.sql-page .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  body.sql-page .source {
    justify-content: flex-start;
  }

  body.sql-page .layout {
    grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
    padding-inline: 18px;
  }

  body.sql-page .pagination {
    flex-wrap: wrap;
  }

  body.sql-page .page-size-toggle {
    width: 100%;
    margin-left: 0;
    padding-left: 0;
    border-left: 0;
  }
}

@media (max-width: 820px) {
  body.sql-page .layout {
    grid-template-columns: 1fr;
  }

  body.sql-page .filters {
    position: relative;
    top: auto;
    max-height: none;
  }

  body.sql-page .sql-sidebar-collapsed .filters {
    height: 0;
  }

  body.sql-page .sql-layout.sql-sidebar-collapsed {
    padding-left: 54px;
  }

  body.sql-page .results {
    min-height: 0;
  }

  body.sql-page .table-wrap {
    max-height: none;
  }

  body.sql-page .detail-modal-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  body.sql-page .topbar {
    margin: 8px;
    padding: 14px;
  }

  body.sql-page .topbar h1 {
    font-size: 26px;
  }

  body.sql-page .source {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }

  body.sql-page .source span {
    grid-column: 1 / -1;
    min-height: 34px;
  }

  body.sql-page .layout {
    padding: 10px;
  }

  body.sql-page .results {
    padding: 14px;
  }

  body.sql-page .summary-grid {
    grid-template-columns: 1fr;
  }

  body.sql-page .pagination {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  body.sql-page .pagination input,
  body.sql-page .pagination span,
  body.sql-page .pagination label,
  body.sql-page .page-size-toggle {
    grid-column: 1 / -1;
    width: 100%;
  }

  body.sql-page .page-size-toggle {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

/* Material lilac final priority for SQL, administration and login. */
body.material-lilac-theme.sql-page,
body.material-lilac-theme.admin-page,
body.material-lilac-theme.login-page {
  color: #1d1b20 !important;
  background: #f7f2fa !important;
}

body.material-lilac-theme.sql-page .topbar,
body.material-lilac-theme.sql-page .filters,
body.material-lilac-theme.sql-page .results,
body.material-lilac-theme.sql-page .sql-crud-panel,
body.material-lilac-theme .admin-shell,
body.material-lilac-theme .admin-panel,
body.material-lilac-theme.login-page .login-card {
  color: #1d1b20 !important;
  border-color: #cac4d0 !important;
  background: #fffbfe !important;
  box-shadow: 0 10px 28px rgba(73, 54, 95, 0.14) !important;
}

body.material-lilac-theme.sql-page thead th {
  color: #21005d !important;
  background: #eaddff !important;
}

body.material-lilac-theme.genia-dark-theme.sql-page,
body.material-lilac-theme.genia-dark-theme.admin-page,
body.material-lilac-theme.genia-dark-theme.login-page {
  color: #e6e1e5 !important;
  background: #1d1b20 !important;
}

body.material-lilac-theme.genia-dark-theme.sql-page .topbar,
body.material-lilac-theme.genia-dark-theme.sql-page .filters,
body.material-lilac-theme.genia-dark-theme.sql-page .results,
body.material-lilac-theme.genia-dark-theme.sql-page .sql-crud-panel,
body.material-lilac-theme.genia-dark-theme .admin-shell,
body.material-lilac-theme.genia-dark-theme .admin-panel,
body.material-lilac-theme.genia-dark-theme.login-page .login-card {
  color: #e6e1e5 !important;
  border-color: #49454f !important;
  background: #211f26 !important;
}

/* Reversible Windows XP Luna skin shared with the main project. */
body.luna-xp-theme {
  --bg: #3a78c2;
  --panel: #ece9d8;
  --panel-soft: #f7f5e9;
  --ink: #000000;
  --muted: #4b4b4b;
  --line: #7f9db9;
  --accent: #245edb;
  --accent-strong: #003caa;
  color: #000000;
  background: linear-gradient(155deg, #64a7e8 0%, #2d6cb5 52%, #6da83d 100%) fixed !important;
  font-family: Tahoma, "Segoe UI", Arial, sans-serif !important;
}

body.luna-xp-theme .topbar,
body.luna-xp-theme .filters,
body.luna-xp-theme .results,
body.luna-xp-theme .login-card,
body.luna-xp-theme .admin-panel,
body.luna-xp-theme .admin-card,
body.luna-xp-theme .log-panel,
body.luna-xp-theme .sql-crud-panel,
body.luna-xp-theme .history-panel,
body.luna-xp-theme .caja-modal-card,
body.luna-xp-theme .summary-grid > div {
  color: #000000;
  border: 3px solid #0054e3 !important;
  border-radius: 8px !important;
  background: #ece9d8 !important;
  box-shadow: 3px 4px 10px rgba(0, 32, 96, 0.34) !important;
  backdrop-filter: none !important;
}

body.luna-xp-theme .topbar {
  color: #ffffff !important;
  background: linear-gradient(#3f8cf3 0%, #0b5bd3 48%, #0645ad 100%) !important;
}

body.luna-xp-theme .topbar h1,
body.luna-xp-theme .topbar strong,
body.luna-xp-theme .topbar p {
  color: #ffffff !important;
  text-shadow: 1px 1px #00337f;
}

body.luna-xp-theme h1,
body.luna-xp-theme h2,
body.luna-xp-theme h3,
body.luna-xp-theme strong {
  color: #003399;
}

body.luna-xp-theme button,
body.luna-xp-theme .home-link,
body.luna-xp-theme .text-link,
body.luna-xp-theme .primary-action,
body.luna-xp-theme .secondary-action {
  color: #000000 !important;
  border: 1px solid #003caa !important;
  border-radius: 3px !important;
  background: linear-gradient(#ffffff 0%, #f2f0e4 45%, #d7d2bc 100%) !important;
  box-shadow: inset 1px 1px #ffffff, inset -1px -1px #aca899 !important;
  font-family: Tahoma, "Segoe UI", Arial, sans-serif !important;
}

body.luna-xp-theme button:hover,
body.luna-xp-theme .home-link:hover,
body.luna-xp-theme .text-link:hover {
  color: #000000 !important;
  border-color: #ff8c00 !important;
  background: #fff4ce !important;
}

body.luna-xp-theme .primary-action,
body.luna-xp-theme button[type="submit"],
body.luna-xp-theme .page-size-toggle button.active {
  color: #ffffff !important;
  border-color: #1d690f !important;
  background: linear-gradient(#73c85b 0%, #3c9b2f 48%, #24751d 100%) !important;
  text-shadow: 1px 1px #165611;
}

body.luna-xp-theme input,
body.luna-xp-theme textarea,
body.luna-xp-theme select {
  color: #000000 !important;
  border: 2px inset #ffffff !important;
  border-radius: 2px !important;
  background: #ffffff !important;
  box-shadow: inset 1px 1px 2px rgba(0, 0, 0, 0.18) !important;
  font-family: Tahoma, "Segoe UI", Arial, sans-serif !important;
}

body.luna-xp-theme input:focus,
body.luna-xp-theme textarea:focus,
body.luna-xp-theme select:focus {
  border-color: #245edb !important;
  outline: 1px dotted #000000;
  outline-offset: 1px;
}

body.luna-xp-theme thead th {
  color: #ffffff !important;
  border-color: #003caa !important;
  background: #245edb !important;
}

body.luna-xp-theme tbody tr,
body.luna-xp-theme .detail-modal-section {
  color: #000000 !important;
  border-color: #7f9db9 !important;
  background: #ffffff !important;
}

body.luna-xp-theme .theme-toggle-button {
  color: #ffffff !important;
  border-color: #003caa !important;
  background: linear-gradient(#3f8cf3, #0645ad) !important;
}

body.luna-xp-theme.genia-dark-theme {
  color: #ffffff;
  background: #152238 !important;
}

body.luna-xp-theme.genia-dark-theme .topbar,
body.luna-xp-theme.genia-dark-theme .filters,
body.luna-xp-theme.genia-dark-theme .results,
body.luna-xp-theme.genia-dark-theme .login-card,
body.luna-xp-theme.genia-dark-theme .admin-panel,
body.luna-xp-theme.genia-dark-theme .admin-card,
body.luna-xp-theme.genia-dark-theme .log-panel,
body.luna-xp-theme.genia-dark-theme .sql-crud-panel,
body.luna-xp-theme.genia-dark-theme .caja-modal-card {
  color: #ffffff;
  border-color: #4f83cc !important;
  background: #24344f !important;
}

body.luna-xp-theme.genia-dark-theme h1,
body.luna-xp-theme.genia-dark-theme h2,
body.luna-xp-theme.genia-dark-theme h3,
body.luna-xp-theme.genia-dark-theme strong {
  color: #ffffff;
}

/* Complete Luna coverage for administration, login and SQL records. */
body.luna-xp-theme .admin-layout,
body.luna-xp-theme .layout,
body.luna-xp-theme .login-shell {
  width: min(1440px, calc(100% - 24px));
}

body.luna-xp-theme .login-card,
body.luna-xp-theme .admin-panel,
body.luna-xp-theme .filters,
body.luna-xp-theme .results,
body.luna-xp-theme .redirect-card {
  overflow: hidden;
}

body.luna-xp-theme .login-card::before,
body.luna-xp-theme .admin-panel::before,
body.luna-xp-theme .filters::before,
body.luna-xp-theme .results::before,
body.luna-xp-theme .redirect-card::before {
  content: "Genia Clinic";
  display: block;
  margin: -24px -24px 18px;
  padding: 6px 12px;
  color: #ffffff;
  background: linear-gradient(90deg, #0a55d7 0%, #3c8bf0 74%, #76a9f5 100%);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
  text-shadow: 1px 1px #00337f;
}

body.luna-xp-theme .collapsible-panel,
body.luna-xp-theme .add-form,
body.luna-xp-theme .export-box,
body.luna-xp-theme .empty,
body.luna-xp-theme .history-panel,
body.luna-xp-theme .sql-crud-panel,
body.luna-xp-theme .table-wrap,
body.luna-xp-theme .pagination,
body.luna-xp-theme .login-form,
body.luna-xp-theme .login-brand,
body.luna-xp-theme .summary-grid > div,
body.luna-xp-theme .detail-modal-section {
  color: #000000 !important;
  border: 1px solid #7f9db9 !important;
  border-radius: 3px !important;
  background: #f7f5e9 !important;
  box-shadow: none !important;
}

body.luna-xp-theme .table-wrap {
  background: #ffffff !important;
  scrollbar-color: #245edb #ece9d8;
}

body.luna-xp-theme .summary-grid strong {
  display: block;
  max-width: 100%;
  overflow: hidden;
  font-size: clamp(18px, 1.7vw, 30px) !important;
  line-height: 1.12;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.luna-xp-theme tbody tr:hover,
body.luna-xp-theme tbody tr.selected,
body.luna-xp-theme tbody tr.is-selected {
  color: #ffffff !important;
  background: #245edb !important;
}

body.luna-xp-theme tbody tr:hover td,
body.luna-xp-theme tbody tr.selected td,
body.luna-xp-theme tbody tr.is-selected td {
  color: inherit !important;
}

body.luna-xp-theme .sidebar-toggle,
body.luna-xp-theme .caja-modal-close {
  color: #ffffff !important;
  background: linear-gradient(#3f8cf3, #0645ad) !important;
}

body.luna-xp-theme.genia-dark-theme .collapsible-panel,
body.luna-xp-theme.genia-dark-theme .add-form,
body.luna-xp-theme.genia-dark-theme .export-box,
body.luna-xp-theme.genia-dark-theme .empty,
body.luna-xp-theme.genia-dark-theme .history-panel,
body.luna-xp-theme.genia-dark-theme .sql-crud-panel,
body.luna-xp-theme.genia-dark-theme .table-wrap,
body.luna-xp-theme.genia-dark-theme .pagination,
body.luna-xp-theme.genia-dark-theme .login-form,
body.luna-xp-theme.genia-dark-theme .login-brand,
body.luna-xp-theme.genia-dark-theme .summary-grid > div,
body.luna-xp-theme.genia-dark-theme .detail-modal-section {
  color: #ffffff !important;
  border-color: #4f83cc !important;
  background: #1b2940 !important;
}

body.luna-xp-theme.genia-dark-theme tbody tr {
  color: #ffffff !important;
  border-color: #4f83cc !important;
  background: #24344f !important;
}

@media (max-width: 760px) {
  body.luna-xp-theme .admin-layout,
  body.luna-xp-theme .layout,
  body.luna-xp-theme .login-shell {
    width: min(100% - 12px, 1440px);
  }

  body.luna-xp-theme .login-card::before,
  body.luna-xp-theme .admin-panel::before,
  body.luna-xp-theme .filters::before,
  body.luna-xp-theme .results::before,
  body.luna-xp-theme .redirect-card::before {
    margin: -16px -16px 14px;
  }
}
