.hub-card { display: block; text-decoration: none; color: inherit; padding: 1.4rem 1.5rem; height: 100%; }
.hub-card:hover { color: inherit; transform: translateY(-2px); }
.hub-count { font-size: 2rem; font-weight: 700; color: #0d6efd; line-height: 1.1; }

html {
  position: relative;
  min-height: 100%;
}

body {
  background-color: #f4f6f9;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: #344767;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

main {
  flex: 1 0 auto;
  width: 100%;
  display: flex;
  flex-direction: column;
}

.navbar-custom {
  background: #ffffff;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .04);
  border-bottom: 1px solid #eef1f5;
  padding: 0.75rem 0;
}

.navbar-brand {
  font-weight: 700;
  color: #344767 !important;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.navbar-brand i {
  color: #0d6efd;
  font-size: 1.4rem;
}

.nav-link {
  font-weight: 500;
  color: #67748e !important;
  transition: color .15s ease-in-out, background-color .15s ease-in-out;
  border-radius: 0.5rem;
  padding: 0.5rem 1rem !important;
}

.nav-link:hover,
.nav-link.active {
  color: #0d6efd !important;
  background-color: rgba(13, 110, 253, 0.08);
}

.nav-link.nav-user {
  color: #344767 !important;
  cursor: default;
}

.nav-link.nav-user:hover {
  background: transparent;
  color: #344767 !important;
}

.nav-link.text-danger {
  color: #dc3545 !important;
}

.nav-link.text-danger:hover {
  color: #b02a37 !important;
  background-color: rgba(220, 53, 69, 0.08);
}

.main-container {
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 1rem;
}

.footer-custom {
  background: #fff;
  border-top: 1px solid #eef1f5;
  padding: 1.5rem 0;
  margin-top: 3rem;
  color: #67748e;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.page-header {
  background: linear-gradient(135deg, #0d6efd 0%, #6610f2 100%);
  color: #fff;
  border-radius: 1rem;
  padding: 1.5rem 2rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 6px 18px rgba(13, 110, 253, .25);
}

.page-header h1 {
  font-size: 1.4rem;
  margin: 0;
  font-weight: 600;
  color: #fff;
}

.page-header .subtitle {
  opacity: .85;
  font-size: .9rem;
}

.page-header .counter-pill {
  background: rgba(255, 255, 255, .18);
  border-radius: 999px;
  padding: .45rem 1rem;
  font-size: .9rem;
  font-weight: 500;
}

.page-header .counter-pill strong {
  font-weight: 700;
}

.sync-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: .75rem;
}

.sync-stat { padding: 1rem 1.15rem; }
.sync-label { color: #67748e; font-size: .8rem; }
.sync-value { font-size: 1.7rem; font-weight: 700; line-height: 1.2; }

@media (max-width: 900px) {
  .sync-grid { grid-template-columns: 1fr 1fr; }
}

.card-clean {
  border: none;
  border-radius: 1rem;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .06);
  background: #fff;
}

.card-clean .card-header {
  background: #fff;
  border-bottom: 1px solid #eef1f5;
  border-radius: 1rem 1rem 0 0 !important;
  font-weight: 600;
  color: #344767;
  padding: 1rem 1.25rem;
}

.card-clean .card-footer {
  background: #f8f9fc;
  border-top: 1px solid #eef1f5;
  border-radius: 0 0 1rem 1rem !important;
}

.filter-bar {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  align-items: flex-end;
  background: #fff;
  border: none;
  border-radius: 1rem;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .06);
}

.filter-bar .field {
  display: flex;
  flex-direction: column;
}

.filter-bar label {
  font-size: .8rem;
  color: #67748e;
  font-weight: 500;
  margin-bottom: .35rem;
  text-transform: uppercase;
  letter-spacing: .03em;
}

.filter-bar input[type="text"],
.filter-bar input[type="date"] {
  border: 1px solid #e2e6ee;
  border-radius: .5rem;
  padding: .5rem .85rem;
  font-size: .9rem;
  color: #344767;
  background: #f8f9fc;
  outline: none;
  min-width: 170px;
  transition: border-color .15s, box-shadow .15s, background .15s;
}

.filter-bar input:focus {
  border-color: #0d6efd;
  background: #fff;
  box-shadow: 0 0 0 .2rem rgba(13, 110, 253, .15);
}

.filter-bar .actions {
  display: flex;
  gap: .5rem;
  margin-left: auto;
}

.journal-table { width: 100%; min-width: 1100px; }
.journal-table .d-inline-block > button:disabled { pointer-events: none; }
.journal-table th:nth-child(1),
.journal-table td:nth-child(1) { width: 130px; }
.journal-table th:nth-child(3),
.journal-table td:nth-child(3) { width: 220px; }
.journal-table th:nth-child(5),
.journal-table td:nth-child(5) { width: 160px; white-space: nowrap; }
.journal-table th:nth-child(6),
.journal-table td:nth-child(6) { width: 140px; }
.journal-pdf {
  display: flex;
  align-items: flex-start;
  gap: .35rem;
  margin: .15rem 0;
  line-height: 1.3;
  text-decoration: none;
}
.journal-pdf:hover { text-decoration: underline; }
.blank-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .35rem .6rem;
  margin-bottom: .65rem;
}
.blank-uploaded {
  color: #198754;
  font-size: .85rem;
  font-weight: 600;
}
.blank-error {
  flex-basis: 100%;
  margin: 0;
  padding: .45rem .7rem;
  border: 1px solid #f5c2c7;
  border-radius: .55rem;
  background: #fff5f5;
  color: #b02a37;
  font-size: .85rem;
  line-height: 1.35;
}
.journal-filters th { padding: .45rem .75rem .7rem; background: #fff; }
select.journal-filter { color: #344767; }
.journal-filter {
  display: block;
  width: 100%;
  box-sizing: border-box;
  border: 1px solid #e2e6ee;
  border-radius: .45rem;
  background: #f8f9fc;
  padding: .35rem .6rem;
  font-size: .85rem;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: #344767;
}
.journal-filter:focus {
  outline: none;
  border-color: #0d6efd;
  background: #fff;
  box-shadow: 0 0 0 .15rem rgba(13, 110, 253, .15);
}
.th-sort {
  border: 0;
  background: transparent;
  padding: 0;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
}
.th-sort.is-asc::after { content: " ↑"; }
.th-sort.is-desc::after { content: " ↓"; }
.journal-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  padding: .9rem 1.25rem;
  border-top: 1px solid #eef1f5;
}

.services-table thead th {
  background: #f8f9fc;
  color: #67748e;
  font-weight: 600;
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .03em;
  border-bottom: 1px solid #eef1f5;
  white-space: nowrap;
  padding: .9rem .75rem;
}

.services-table tbody tr {
  transition: background .12s;
}

.services-table tbody tr:hover {
  background: #f8f9fc;
}

.services-table td {
  vertical-align: top;
  padding: 1rem .75rem;
  border-color: #eef1f5;
}

.patient-name {
  font-weight: 600;
  color: #344767;
  font-size: .95rem;
  line-height: 1.3;
  margin-bottom: .25rem;
}

.patient-sub {
  font-size: .8rem;
  color: #67748e;
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  align-items: center;
}

.patient-sub span {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
}

.study-toggle {
  border: 0;
  background: transparent;
  padding: 0;
  color: #0d6efd;
  font-weight: 600;
  font-size: .9rem;
}

.study-toggle:hover { color: #0a58ca; }

.study-list {
  display: none;
  position: fixed;
  z-index: 40;
  list-style: none;
  margin: 0;
  padding: .7rem .8rem;
  flex-direction: column;
  gap: .45rem;
  width: min(680px, calc(100vw - 16px));
  max-height: min(70vh, 640px);
  overflow: auto;
  overscroll-behavior: contain;
  background: #fff;
  border: 1px solid #e2e6ee;
  border-radius: .75rem;
  box-shadow: 0 12px 32px rgba(15, 23, 42, .16);
}

.study-list.open { display: flex; }

.pre-toggle {
  border: 0;
  background: transparent;
  color: #0d6efd;
  padding: 0 .15rem;
  line-height: 1;
  vertical-align: middle;
}

.pre-pop {
  display: none;
  position: fixed;
  z-index: 50;
  width: min(420px, calc(100vw - 16px));
  max-height: 320px;
  overflow: auto;
  background: #fff;
  border: 1px solid #e2e6ee;
  border-radius: .75rem;
  box-shadow: 0 12px 32px rgba(15, 23, 42, .16);
  padding: .85rem 1rem;
}

.pre-pop.open { display: block; }

.dict-log {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 360px;
  overflow: auto;
}

.dict-log li {
  position: relative;
  padding: .4rem 0 .4rem 1.6rem;
}

.dict-log li.ok::before {
  content: "✓";
  position: absolute;
  left: 0;
  color: #198754;
  font-weight: 700;
}

.dict-log li.error {
  color: #dc3545;
}

.dict-log li.run::before {
  content: "";
  position: absolute;
  left: 0;
  top: .55rem;
  width: .75rem;
  height: .75rem;
  border: 2px solid #0d6efd;
  border-right-color: transparent;
  border-radius: 50%;
  animation: dict-spin .7s linear infinite;
}

@keyframes dict-spin {
  to { transform: rotate(360deg); }
}

.study-list > li {
  display: grid;
  grid-template-columns: 5.5rem 1fr;
  gap: .5rem;
  align-items: start;
}

.study-list > li.study-blanks {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .35rem .6rem;
  grid-template-columns: none;
}

.study-open {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: .15rem;
  width: 100%;
  border: 0;
  background: transparent;
  padding: 0;
  text-align: left;
  color: inherit;
}

.study-list > li.can-open .study-open { cursor: pointer; }
.study-list > li.can-open .study-name { color: #0d6efd; }
.study-list > li.can-open.is-open .study-name { color: #344767; }
.study-result { display: none; margin-top: .35rem; }
.study-list > li.is-open .study-result { display: block; }
.study-open:disabled { cursor: default; }

.study-tests {
  list-style: none;
  margin: .15rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: .2rem;
}

.study-tests li {
  display: flex;
  flex-wrap: wrap;
  gap: .15rem .45rem;
  font-size: .78rem;
}

.study-value { font-weight: 600; color: #344767; }
.study-value.out { color: #dc3545; }

.study-body { display: flex; flex-direction: column; gap: .15rem; min-width: 0; }
.study-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem .6rem; color: #67748e; font-size: .75rem; }
.study-meta .status-badge { padding: .12rem .55rem; font-size: .72rem; }
.study-state.state-4 { color: #198754; font-weight: 600; }
.study-state.state-3 { color: #b58105; font-weight: 600; }
.study-state.state-5 { color: #dc3545; font-weight: 600; }
.study-state.state-1 { color: #67748e; }

.study-code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: .78rem;
  font-weight: 700;
  color: #0d6efd;
  background: rgba(13, 110, 253, .08);
  border-radius: .35rem;
  padding: .12rem .4rem;
  text-align: center;
}

.study-name {
  color: #344767;
  line-height: 1.35;
}

.order-number {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: .8rem;
  font-weight: 600;
  color: #0d6efd;
  background: rgba(13, 110, 253, .08);
  padding: .15rem .5rem;
  border-radius: .35rem;
  display: inline-block;
  margin: 0 .25rem .35rem 0;
}

.contact-line {
  font-size: .875rem;
  color: #344767;
  margin-bottom: .2rem;
  display: flex;
  align-items: center;
  gap: .35rem;
}

.contact-line.muted {
  color: #67748e;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .35rem .75rem;
  border-radius: 999px;
  font-size: .8rem;
  font-weight: 600;
  white-space: nowrap;
}

.status-badge::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  opacity: .9;
}

.status-badge.created {
  background: rgba(13, 110, 253, .1);
  color: #0d6efd;
}

.status-badge.partial {
  background: rgba(255, 193, 7, .15);
  color: #b8860b;
}

.status-badge.ready {
  background: rgba(25, 135, 84, .12);
  color: #198754;
}

.status-badge.cancelled {
  background: rgba(108, 117, 125, .15);
  color: #6c757d;
  text-decoration: line-through;
}

.status-badge.unknown {
  background: rgba(108, 117, 125, .12);
  color: #6c757d;
}

button.status-badge-link {
  border: none;
  cursor: pointer;
}

button.status-badge-link:hover {
  text-decoration: underline;
}

.modal-content {
  border: none;
  border-radius: 1rem;
  box-shadow: 0 12px 40px rgba(52, 71, 103, .18);
}

.modal-header {
  border-bottom: 1px solid #eef1f5;
}

#productsTable tbody tr {
  transition: none;
}

.services details summary {
  cursor: pointer;
  color: #0d6efd;
  font-size: .85rem;
  font-weight: 500;
  user-select: none;
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: .35rem;
}

.services details summary::-webkit-details-marker {
  display: none;
}

.services details summary::before {
  content: "▸";
  transition: transform .15s;
  display: inline-block;
}

.services details[open] summary::before {
  transform: rotate(90deg);
}

.services ul {
  margin: .5rem 0 0;
  padding: .5rem 0 0;
  list-style: none;
  font-size: .85rem;
  border-top: 1px dashed #eef1f5;
  max-height: 220px;
  overflow-y: auto;
}

.services li {
  padding: .35rem 0;
  display: flex;
  align-items: flex-start;
  gap: .5rem;
  flex-wrap: wrap;
}

.services .code,
.tube-label .code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: .75rem;
  color: #0d6efd;
  background: rgba(13, 110, 253, .1);
  padding: .15rem .55rem;
  border-radius: .35rem;
  white-space: nowrap;
}

.services .term {
  font-size: .75rem;
  color: #67748e;
  margin-left: auto;
  white-space: nowrap;
}

.results-list {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: .35rem;
  margin-top: .5rem;
}

.result-link {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  font-size: .8rem;
  color: #dc3545;
  text-decoration: none;
  padding: .25rem .5rem;
  border-radius: .35rem;
  background: rgba(220, 53, 69, .06);
  border: 1px solid rgba(220, 53, 69, .15);
  transition: background .15s, border-color .15s;
  max-width: 100%;
}

.result-link:hover {
  background: rgba(220, 53, 69, .12);
  border-color: rgba(220, 53, 69, .3);
  color: #b02a37;
}

.result-link span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: #67748e;
  background: #fff;
  border-radius: 1rem;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .06);
}

.empty-state i {
  font-size: 2.5rem;
  color: #b6c0cf;
  display: block;
  margin-bottom: .75rem;
}

.info-row {
  display: flex;
  padding: .7rem 0;
  border-bottom: 1px dashed #eef1f5;
  gap: 1rem;
}

.info-row:last-child {
  border-bottom: none;
}

.info-row .label {
  width: 220px;
  flex-shrink: 0;
  color: #67748e;
  font-weight: 500;
  padding-top: .35rem;
}

.info-row .value {
  flex: 1;
  color: #344767;
  font-weight: 500;
  min-width: 0;
}

.form-control,
.form-select {
  border: 1px solid #e2e6ee;
  border-radius: .5rem;
  padding: .5rem .85rem;
  font-size: .9rem;
  color: #344767;
  background-color: #f8f9fc;
  transition: border-color .15s, box-shadow .15s, background-color .15s;
}

.form-control:focus,
.form-select:focus {
  border-color: #0d6efd;
  background-color: #fff;
  box-shadow: 0 0 0 .2rem rgba(13, 110, 253, .15);
}

.btn {
  border-radius: .5rem;
  font-weight: 500;
}

.btn-primary {
  background: #0d6efd;
  border: none;
  padding: .5rem 1.25rem;
}

.btn-primary:hover,
.btn-primary:focus {
  background: #0a58ca;
}

.btn-primary:hover {
  transform: translateY(-1px);
}

.btn:focus,
.btn:active:focus,
.btn-link.nav-link:focus,
.form-control:focus,
.form-check-input:focus {
  box-shadow: 0 0 0 .2rem rgba(13, 110, 253, .15);
}

.btn-icon {
  width: 34px;
  height: 34px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #e2e6ee;
  background: #f8f9fc;
  color: #344767;
  border-radius: .5rem;
  vertical-align: middle;
}

.btn-icon:hover {
  background: #fff;
  color: #0d6efd;
  border-color: #b6c8f2;
}

.btn-icon.text-danger:hover {
  color: #dc3545;
  border-color: rgba(220, 53, 69, .35);
  background: rgba(220, 53, 69, .06);
}

.download-link {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  color: #0d6efd;
  text-decoration: none;
  font-weight: 500;
}

.download-link:hover {
  color: #0a58ca;
  text-decoration: underline;
}

.alert {
  border: none;
  border-radius: .75rem;
}

.prep-text { white-space: pre-line; }

.preanalytic-note {
  margin-top: .5rem;
  background: rgba(13, 110, 253, .08);
  border-radius: .5rem;
  padding: .5rem .75rem;
  font-size: .8rem;
  color: #344767;
  font-weight: 400;
  display: flex;
  gap: .5rem;
  align-items: flex-start;
}

.aux-field {
  margin-bottom: 1rem;
}

.aux-field > label {
  display: block;
  font-size: .8rem;
  color: #67748e;
  font-weight: 500;
  margin-bottom: .35rem;
}

.aux-control {
  display: flex;
  align-items: center;
  gap: .5rem;
}

.aux-control .form-control,
.aux-field .form-select,
.aux-field .form-control {
  max-width: 320px;
}

.aux-unit {
  color: #67748e;
  font-size: .85rem;
}

.bio-cell {
  width: 340px;
  min-width: 280px;
  max-width: 380px;
}

.bio-select {
  position: relative;
  margin-bottom: .4rem;
}

.bio-select:last-child {
  margin-bottom: 0;
}

.bio-select-btn,
.bio-static {
  display: block;
  width: 100%;
  margin: 0;
  text-align: left;
  background: #fff;
  border: 1px solid #d8dee9;
  border-radius: .6rem;
  padding: .5rem 2rem .5rem .75rem;
  font-size: .9rem;
  font-weight: 500;
  line-height: 1.4;
  color: #344767;
  white-space: normal;
  box-shadow: 0 1px 2px rgba(20, 30, 50, .04);
}

.bio-select-btn {
  position: relative;
  cursor: pointer;
}

.bio-select-btn:hover,
.bio-select.open .bio-select-btn {
  border-color: #0d6efd;
}

.bio-select-value {
  display: block;
  white-space: normal;
}

.bio-select-btn i {
  position: absolute;
  right: .7rem;
  top: .6rem;
  color: #67748e;
  font-size: .85rem;
  pointer-events: none;
}

.bio-static {
  padding-right: .75rem;
  background: #f8f9fc;
  color: #344767;
  margin-bottom: .4rem;
}

.bio-static:last-child {
  margin-bottom: 0;
}

.bio-select-menu {
  display: none;
  position: fixed;
  z-index: 30;
  max-height: 280px;
  overflow: auto;
  padding: .3rem;
  background: #fff;
  border: 1px solid #e2e6ee;
  border-radius: .7rem;
  box-shadow: 0 12px 32px rgba(20, 30, 50, .16);
}

.bio-select.open .bio-select-menu {
  display: block;
}

.bio-select-option {
  display: block;
  width: 100%;
  margin: 0;
  text-align: left;
  border: 0;
  background: transparent;
  border-radius: .5rem;
  padding: .5rem .7rem;
  font-size: .9rem;
  line-height: 1.4;
  color: #344767;
  white-space: normal;
  cursor: pointer;
}

.bio-select-option:hover {
  background: #f4f6f9;
}

.bio-select-option.is-selected {
  background: rgba(13, 110, 253, .1);
  color: #0a3d91;
  font-weight: 600;
}

.inline-editor {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
}

.inline-editor .form-control,
.inline-editor .form-select {
  width: 240px;
  max-width: 100%;
}

.patient-card .card-header,
.aux-card .card-header {
  padding: .6rem 1rem;
}

.patient-card .card-body,
.aux-card .card-body {
  padding: .35rem 1rem .5rem;
}

.patient-card .info-row {
  padding: .28rem 0;
  align-items: center;
  gap: .75rem;
}

.patient-card .info-row .label {
  width: 158px;
  padding-top: 0;
  font-size: .85rem;
  display: flex;
  align-items: center;
  gap: .45rem;
}

.patient-card .info-row .label i {
  color: #0d6efd;
  width: 1rem;
  text-align: center;
}

.patient-card .info-row .value {
  font-size: .9rem;
  font-weight: 500;
}

.patient-card .inline-editor { display: inline-flex; width: auto; max-width: 100%; flex-wrap: wrap; gap: .3rem; align-items: center; }
.patient-card .inline-editor .editor-input { display: none; width: 210px; flex: 0 0 210px; height: 34px; padding: .25rem .6rem; }
.patient-card .editor-error { display: none; flex: 1 0 100%; color: #dc3545; font-size: .75rem; font-weight: 500; }
.patient-card .inline-editor.is-invalid .editor-error { display: block; }
.patient-card .inline-editor.is-invalid .editor-input { border-color: #dc3545; background: #fff7f7; }
.patient-card .inline-editor.is-editing .editor-input { display: block; }
.patient-card .inline-editor.is-editing .editor-text,
.patient-card .inline-editor.is-editing .editor-edit { display: none; }
.patient-card .inline-editor .editor-ok,
.patient-card .inline-editor .editor-cancel { display: none; }
.patient-card .inline-editor.is-editing .editor-ok,
.patient-card .inline-editor.is-editing .editor-cancel { display: inline-flex; }
.patient-card .editor-text.is-empty { color: #8b95a7; font-weight: 500; }
.patient-card .btn-icon { width: 34px; height: 34px; flex: none; }
.patient-card .editor-ok { color: #198754; border-color: #b7e4c7; background: #f3fbf6; }
.patient-card .editor-ok:hover { color: #146c43; border-color: #8fd4a8; }
.patient-card .editor-cancel:hover { color: #dc3545; border-color: rgba(220, 53, 69, .35); }

.order-pair {
  align-items: stretch;
}

.order-pair > .aux-col {
  display: flex;
  min-height: 0;
}
.order-side { width: 100%; display: flex; flex-direction: column; }
.order-side .card-header { padding: .6rem 1rem; }
.order-side .order-panel { display: flex; flex-direction: column; }
.order-side .order-toolbar { margin-bottom: .15rem; }
.order-side .order-actions { margin-top: auto; }

.aux-card {
  position: absolute;
  top: 0;
  bottom: 0;
  left: calc(var(--bs-gutter-x, 1rem) * 0.5);
  right: calc(var(--bs-gutter-x, 1rem) * 0.5);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.aux-card .card-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}

.patient-extra {
  margin-top: .45rem;
  padding-top: .7rem;
  border-top: 1px solid #e6ebf2;
}

.patient-extra label {
  display: flex;
  align-items: center;
  gap: .45rem;
  margin-bottom: .35rem;
  font-size: .85rem;
  font-weight: 500;
  color: #67748e;
}

.patient-extra label i {
  color: #0d6efd;
  width: 1rem;
  text-align: center;
}

.patient-extra .form-control {
  max-width: 240px;
  padding: .35rem .7rem;
}

.aux-card .aux-field {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin: 0;
  padding: .35rem 0;
  border-bottom: 1px dashed #eef1f5;
}

.aux-card .aux-field:last-child {
  border-bottom: none;
}

.aux-card .aux-field > label {
  width: 148px;
  flex-shrink: 0;
  margin: 0;
  font-size: .85rem;
}

.aux-card .aux-control {
  flex: 1;
  min-width: 0;
}

.aux-card .form-control,
.aux-card .form-select {
  max-width: none;
  width: 100%;
  padding: .3rem .65rem;
  min-height: 34px;
}

.aux-card .card-body:empty,
.aux-card #tbl_dop:empty {
  min-height: 0;
}

.tube-item {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  padding: .75rem 0;
  border-bottom: 1px dashed #eef1f5;
}

.tube-item:last-of-type {
  border-bottom: none;
}

.tube-label {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
  cursor: pointer;
  margin: 0;
}

.tube-name {
  font-weight: 500;
}

.cover-frame {
  width: 100%;
  height: 640px;
  border: 1px solid #eef1f5;
  border-radius: .75rem;
  margin-bottom: 1rem;
  background: #fff;
}

.auth-page {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2.5rem 1rem;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: 1.25rem;
  box-shadow: 0 12px 40px rgba(52, 71, 103, .12);
  overflow: hidden;
}

.auth-card-header {
  background: linear-gradient(135deg, #3b6cff 0%, #6d28d9 100%);
  color: #fff;
  text-align: center;
  padding: 2rem 1.5rem 1.6rem;
}

.auth-icon {
  width: 52px;
  height: 52px;
  margin: 0 auto .75rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, .18);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
}

.auth-card-header h2 {
  font-size: 1.35rem;
  font-weight: 600;
  margin: 0;
}

.auth-card-header p {
  margin: .35rem 0 0;
  opacity: .85;
  font-size: .9rem;
}

.auth-card-body {
  padding: 1.5rem 1.75rem 1.75rem;
}

.auth-card-body label {
  display: block;
  font-size: .75rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: #67748e;
  font-weight: 600;
  margin-bottom: .4rem;
}

.input-icon {
  position: relative;
  margin-bottom: 1rem;
}

.input-icon > i {
  position: absolute;
  left: .9rem;
  top: 50%;
  transform: translateY(-50%);
  color: #8b97ab;
  pointer-events: none;
}

.input-icon .form-control {
  padding-left: 2.5rem;
  height: 46px;
}

.auth-card .btn-primary {
  width: 100%;
  height: 46px;
  font-weight: 600;
}

.raw-log table {
  width: 100%;
  margin: 0;
}

@media (max-width: 992px) {
  .services-table:not(.journal-table) thead {
    display: none;
  }

  .services-table:not(.journal-table) tbody tr {
    display: block;
    padding: 1rem;
    border-bottom: 1px solid #eef1f5;
  }

  .services-table:not(.journal-table) tbody td {
    display: block;
    padding: .35rem 0;
    border: none;
  }

    .services-table:not(.journal-table) tbody td[data-label=""]::before {
    content: none;
    display: none;
  }

  .services-table:not(.journal-table) tbody td::before {
    content: attr(data-label);
    display: block;
    font-size: .7rem;
    text-transform: uppercase;
    color: #67748e;
    letter-spacing: .03em;
    margin-bottom: .15rem;
    font-weight: 600;
  }

  .filter-bar .actions {
    margin-left: 0;
    width: 100%;
  }
}

@media (max-width: 991.98px) {
  .aux-card {
    position: static;
    width: 100%;
    overflow: visible;
  }

  .aux-card .card-body {
    overflow: visible;
  }

  .aux-card .aux-field {
    flex-direction: column;
    align-items: stretch;
  }

  .aux-card .aux-field > label {
    width: 100%;
  }
}
@media (max-width: 768px) {
  .page-header {
    padding: 1.25rem;
  }

  .info-row {
    flex-direction: column;
    gap: .35rem;
  }

  .info-row .label {
    width: 100%;
    padding-top: 0;
  }
}

.prean_table { width: 100%; }
.prean_table tr { border-bottom: 1px solid #eef1f5; }
.prean_table tr td { padding: .55rem .4rem; vertical-align: top; }
.prean_table_head { font-weight: 600; width: 34%; color: #344767; }
.order-actions { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin-top: .85rem; padding: .85rem 1rem; background: #fff; border: 1px solid #e6ebf2; border-radius: 1rem; box-shadow: 0 8px 24px rgba(15, 23, 42, .04); }
.order-actions .btn { min-height: 42px; padding-left: 1rem; padding-right: 1rem; }
.order-head { padding: .55rem 1.15rem; margin-bottom: 1rem; }
.order-head h1 { font-size: 1.12rem; line-height: 1.2; }
.order-head .counter-pill { padding: .25rem .7rem; font-size: .82rem; line-height: 1.2; border: 1px solid rgba(255,255,255,.28); background: rgba(255,255,255,.16); border-radius: .65rem; }
.order-head .counter-pill strong { font-size: .95rem; }
.order-chip { display: inline-flex; align-items: baseline; gap: .4rem; background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.28); border-radius: .65rem; padding: .25rem .7rem; white-space: nowrap; font-size: .82rem; }
.order-chip strong { font-size: .95rem; font-weight: 700; letter-spacing: .02em; }
.order-toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .85rem 1.25rem; }
.order-toolbar .order-field { width: min(320px, 100%); }
.order-urgent { display: inline-flex; align-items: center; gap: .7rem; min-height: 38px; margin: 0 0 .15rem; padding: .35rem .9rem .35rem .6rem; border: 1px solid #e2e6ee; border-radius: 999px; background: #fff; }
.order-urgent .form-check-input { float: none; position: static; margin: 0; width: 2.45rem; height: 1.28rem; cursor: pointer; }
.order-urgent .form-check-label { margin: 0; padding: 0; cursor: pointer; font-weight: 600; }
.order-urgent:has(input:checked) { border-color: #0d6efd; background: rgba(13, 110, 253, .08); color: #0b5ed7; }
.order-field label { display: block; margin-bottom: .3rem; font-size: .78rem; color: #67748e; }
.order-notify { display: flex; flex-wrap: wrap; gap: .35rem .85rem; margin-top: .65rem; }
.order-quiet { display: inline-flex; align-items: center; gap: .4rem; margin: 0; color: #8b95a7; font-size: .78rem; font-weight: 500; cursor: pointer; }
.order-quiet .form-check-input { float: none; position: static; margin: 0; width: 1.7rem; height: .95rem; cursor: pointer; }
.order-switches { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .9rem; }
.order-switch { display: inline-flex; align-items: center; gap: .45rem; margin: 0; border: 1px solid #e2e6ee; border-radius: 999px; padding: .4rem .8rem; background: #fff; cursor: pointer; font-size: .9rem; }
.order-switch input { margin: 0; }
.order-switch:has(input:checked) { border-color: #0d6efd; background: rgba(13,110,253,.08); color: #0b5ed7; }
.order-extra { margin-top: .75rem; padding: .85rem 1rem; background: #f8fafc; border: 1px solid #eef1f6; border-radius: .8rem; }
.order-extra select, .order-extra input[type="text"], .order-extra input[type="number"], .order-extra textarea { border: 1px solid #d7dde7; border-radius: .5rem; padding: .3rem .5rem; }
.study-facts { color: #67748e; font-size: .75rem; line-height: 1.35; }
.order-code-cell { white-space: nowrap; width: 1%; vertical-align: top; }
.order-code { font-weight: 700; color: #344767; white-space: nowrap; }
.order-term { white-space: nowrap; }
.study-line { display: flex; align-items: flex-start; gap: .45rem; }
.prean-btn { flex: none; border: 1px solid #cfe0ff; background: #f3f7ff; color: #0d6efd; border-radius: .5rem; width: 1.8rem; height: 1.8rem; padding: 0; line-height: 1; }
.prean-btn:hover { background: #0d6efd; color: #fff; }
.prean-body { display: flex; flex-direction: column; gap: .85rem; }
.prean-label { font-size: .75rem; color: #67748e; margin-bottom: .15rem; }
.prean-value { color: #344767; line-height: 1.45; }
.lab-price { font-size: .75rem; color: #8b95a7; font-weight: 500; white-space: nowrap; }
.lab-price-cito { font-size: .68rem; color: #b0b8c6; white-space: nowrap; }
.order-dialog { width: min(1280px, calc(100vw - 1.5rem)); max-width: none; height: calc(100vh - 1.5rem); }
.order-dialog .modal-content {
  border-radius: 1rem;
  overflow: hidden;
  height: min(88vh, 920px);
  display: flex;
  flex-direction: column;
  animation: order-pop .28s ease;
}
@keyframes order-pop {
  from { transform: translateY(12px) scale(.98); opacity: 0; }
  to { transform: none; opacity: 1; }
}
.order-dialog .modal-body { position: relative; flex: 1; min-height: 0; background: #f4f6f9; }
.order-dialog iframe { width: 100%; height: 100%; border: 0; background: #f4f6f9; }
.order-dialog-spin {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(244, 246, 249, .92);
  z-index: 2;
}
.res { padding: .45rem .7rem; font-weight: 600; }

.label-list { display: flex; flex-direction: column; gap: 1rem; }
.label-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 1rem;
  align-items: center;
  padding: 1rem;
  border: 1px solid #eef1f5;
  border-radius: .75rem;
}
.label-item .form-check { margin: 0; }
.container-name { font-weight: 600; color: #344767; }
.sticker {
  width: 280px;
  background: #fff;
  border: 1px solid #d7dee8;
  border-radius: .35rem;
  padding: .45rem .5rem .35rem;
  text-align: center;
  color: #111;
  line-height: 1.2;
}
.sticker-lpu, .sticker-code { font-size: .92rem; font-weight: 700; }
.sticker-patient { font-size: 1.05rem; font-weight: 700; }
.sticker-bio { font-size: .85rem; margin: .1rem 0 .2rem; }
.sticker img { max-width: 100%; height: auto; }
@media (max-width: 768px) {
  .label-item { grid-template-columns: 1fr; }
}
