:root {
  --bg-0: #e7f4f2;
  --bg-1: #f7fbfa;
  --ink-0: #102022;
  --ink-1: #365257;
  --accent-0: #0a9e95;
  --accent-1: #3db6a1;
  --danger: #b42318;
  --line: #cfe1df;
  --card: rgba(255, 255, 255, 0.86);
  --shadow: 0 14px 44px rgba(22, 56, 55, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  color: var(--ink-0);
  background: linear-gradient(120deg, var(--bg-0), var(--bg-1) 48%, #f1fbf7);
}

.bg-grid {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(circle at 20% 18%, rgba(61, 182, 161, 0.2), transparent 24%),
    radial-gradient(circle at 78% 78%, rgba(10, 158, 149, 0.12), transparent 26%),
    linear-gradient(to right, rgba(61, 182, 161, 0.08) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(61, 182, 161, 0.08) 1px, transparent 1px);
  background-size:
    auto,
    auto,
    22px 22px,
    22px 22px;
}

.shell {
  position: relative;
  max-width: 980px;
  margin: 0 auto;
  padding: 26px 18px 42px;
}

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

.topbar > div:first-child {
  flex: 0 0 auto;
  min-width: max-content;
}

.eyebrow {
  margin: 0;
  font-size: 16px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--ink-1);
}

.brand-lockup {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.brand-logo {
  width: 28px;
  height: 28px;
  display: block;
  border-radius: 8px;
  box-shadow: 0 5px 14px rgba(10, 158, 149, 0.22);
}

h1,
h2,
h3 {
  margin: 0;
  font-family: "Sora", "Trebuchet MS", sans-serif;
  letter-spacing: -0.02em;
}

h1 {
  margin-top: 4px;
  font-size: 29px;
  white-space: nowrap;
}

.session-controls {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: nowrap;
  overflow-x: auto;
  max-width: 100%;
  padding-bottom: 2px;
}

.chip {
  background: linear-gradient(120deg, rgba(10, 158, 149, 0.16), rgba(61, 182, 161, 0.2));
  border: 1px solid rgba(10, 158, 149, 0.25);
  border-radius: 999px;
  padding: 6px 9px;
  color: #0e5954;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.chip-warning {
  color: #6b4e00;
  background: linear-gradient(120deg, rgba(255, 208, 77, 0.2), rgba(255, 237, 179, 0.35));
  border-color: rgba(255, 193, 7, 0.45);
}

.chip-danger {
  color: #7a2018;
  background: linear-gradient(120deg, rgba(244, 67, 54, 0.16), rgba(255, 205, 210, 0.35));
  border-color: rgba(229, 57, 53, 0.45);
}

.card {
  border: 1px solid rgba(16, 32, 34, 0.1);
  border-radius: 18px;
  box-shadow: var(--shadow);
  background: var(--card);
  backdrop-filter: blur(4px);
  padding: 20px;
  position: relative;
  overflow: hidden;
  animation: slide-up 220ms ease-out;
}

@keyframes slide-up {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.view-shell {
  position: relative;
}

.view-shell.is-entering {
  opacity: 0;
  filter: blur(3px);
}

.view-shell.is-entering.is-forward {
  transform: translate3d(10px, 14px, 0) scale(0.992);
}

.view-shell.is-entering.is-backward {
  transform: translate3d(-10px, 14px, 0) scale(0.992);
}

.view-shell.is-entering.is-ready {
  opacity: 1;
  filter: blur(0);
  transform: translate3d(0, 0, 0) scale(1);
  transition:
    opacity 360ms cubic-bezier(0.22, 0.92, 0.24, 1),
    transform 420ms cubic-bezier(0.2, 0.92, 0.24, 1),
    filter 380ms ease-out;
}

.view-shell.is-entering::after {
  content: "";
  position: absolute;
  inset: -14% -38%;
  pointer-events: none;
  opacity: 0;
  background: linear-gradient(
    104deg,
    transparent 38%,
    rgba(168, 244, 233, 0.2) 50%,
    rgba(93, 214, 198, 0.18) 55%,
    transparent 66%
  );
  mix-blend-mode: screen;
}

.view-shell.is-entering.is-ready::after {
  animation: route-sweep 560ms cubic-bezier(0.2, 0.9, 0.24, 1);
}

.view-shell .reveal-item {
  opacity: 1;
  transform: translateY(0);
}

.view-shell.is-entering .reveal-item {
  opacity: 0;
  transform: translateY(10px);
}

.view-shell.is-entering.is-ready .reveal-item {
  opacity: 1;
  transform: translateY(0);
  transition:
    opacity 300ms ease-out var(--reveal-delay, 80ms),
    transform 360ms cubic-bezier(0.22, 0.92, 0.24, 1) var(--reveal-delay, 80ms);
}

@keyframes route-sweep {
  0% {
    opacity: 0;
    transform: translateX(-20%);
  }
  20% {
    opacity: 0.45;
  }
  100% {
    opacity: 0;
    transform: translateX(20%);
  }
}

@media (prefers-reduced-motion: reduce) {
  .card {
    animation: none !important;
  }

  .view-shell,
  .view-shell.is-entering,
  .view-shell.is-entering.is-ready,
  .view-shell .reveal-item,
  .view-shell.is-entering .reveal-item,
  .view-shell.is-entering.is-ready .reveal-item {
    opacity: 1 !important;
    transform: none !important;
    filter: none !important;
    transition: none !important;
    animation: none !important;
  }
}

.stack {
  display: grid;
  gap: 14px;
}

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

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

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

label {
  display: block;
  margin-bottom: 6px;
  color: #254044;
  font-size: 13px;
  font-weight: 600;
}

input,
select,
textarea {
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--line);
  padding: 10px 11px;
  font-size: 14px;
  color: var(--ink-0);
  background: #ffffff;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: rgba(10, 158, 149, 0.5);
  box-shadow: 0 0 0 3px rgba(10, 158, 149, 0.16);
}

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

.help {
  font-size: 12px;
  color: #496469;
  margin: 0;
}

.grid-2 > .login-card {
  align-self: start;
}

.login-card {
  align-content: start;
}

#cognitoHostedLoginForm {
  gap: 8px;
}

#cognitoHostedLoginForm .btn-login-compact,
#tokenLoginForm .btn-login-compact {
  width: 188px;
  justify-self: start;
}

#cognitoHostedLoginForm .btn-login-compact {
  margin-top: 30px;
}

.session-controls button {
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  white-space: nowrap;
}

.divider {
  border-top: 1px solid var(--line);
  margin: 2px 0;
}

.title-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.title-row p {
  margin: 0;
  font-size: 13px;
  color: #436469;
}

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

button {
  border: 0;
  border-radius: 11px;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 120ms ease, opacity 120ms ease;
}

button:active {
  transform: translateY(1px);
}

.btn-primary {
  color: #fff;
  background: linear-gradient(120deg, var(--accent-0), var(--accent-1));
}

.btn-secondary {
  color: #124a4a;
  background: #e5f4f1;
  border: 1px solid #b5ddda;
}

.btn-danger {
  color: #fff;
  background: #b42318;
}

button[disabled] {
  cursor: not-allowed;
  opacity: 0.55;
}

.error {
  border: 1px solid #f5c2be;
  background: #fff2f1;
  color: #7f1f18;
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 13px;
}

.ok {
  border: 1px solid #9cd4bf;
  background: #ecfaf3;
  color: #0f5f40;
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 13px;
}

.provider-signature-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, 260px);
  gap: 12px;
  align-items: center;
  border: 1px solid #cde4df;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.92), rgba(235, 250, 246, 0.82));
  border-radius: 12px;
  padding: 10px 12px;
}

.provider-signature-preview {
  min-height: 58px;
  display: grid;
  place-items: center;
  border: 1px dashed #9dcac1;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.78);
  overflow: hidden;
}

.provider-signature-image {
  max-width: 230px;
  max-height: 48px;
  object-fit: contain;
  display: block;
}

.sample-barcode-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(190px, 280px) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid #cde4df;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.94), rgba(236, 251, 247, 0.86)),
    radial-gradient(circle at 14% 8%, rgba(61, 182, 161, 0.16), transparent 32%);
  border-radius: 14px;
  padding: 12px;
}

.sample-barcode-copy {
  display: grid;
  gap: 4px;
}

.sample-barcode-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  color: #24494d;
  font-size: 12px;
}

.sample-barcode-preview {
  min-height: 78px;
  display: grid;
  gap: 4px;
  place-items: center;
  border: 1px dashed #96c6bd;
  border-radius: 10px;
  background: #ffffff;
  padding: 8px;
  overflow: hidden;
}

.sample-barcode-svg {
  display: block;
  width: 100%;
  max-width: 260px;
  height: 46px;
}

.sample-barcode-svg rect:not(:first-child) {
  fill: #111;
}

.sample-barcode-preview span {
  max-width: 250px;
  color: #1d383d;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.muted {
  color: #597378;
  font-size: 13px;
}

.checkbox-panel {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #ffffff;
  padding: 10px;
  max-height: 280px;
  overflow: auto;
  display: grid;
  gap: 6px;
}

.check-row {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin: 0;
  font-size: 13px;
  color: #213a3f;
  font-weight: 500;
}

.check-row input[type="checkbox"] {
  width: auto;
  margin-top: 2px;
}

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

.question-block {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #ffffff;
  padding: 10px;
}

.question-block h4 {
  margin: 0 0 8px 0;
  font-size: 13px;
  color: #224145;
}

.check-grid {
  display: grid;
  gap: 6px;
}

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

.admin-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #ffffff;
  padding: 10px;
}

.admin-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.admin-item-head h4 {
  margin: 0;
  font-size: 13px;
  color: #224145;
}

.admin-item-head h4 .chip {
  margin-left: 6px;
}

.template-preflight-list {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.template-preflight-row {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 8px;
  display: grid;
  gap: 4px;
}

.admin-collapsible {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #ffffff;
  padding: 10px;
}

.admin-collapsible > summary {
  cursor: pointer;
  font-weight: 700;
  color: #17373c;
  margin: -4px 0 10px;
}

.admin-collapsible > summary::-webkit-details-marker {
  color: #2b8f87;
}

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

.inline-check {
  margin-right: 6px;
}

.span-2 {
  grid-column: span 2;
}

.template-mapper-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1.8fr) minmax(260px, 1fr);
  margin-bottom: 12px;
}

.template-preview-panel {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f9fdfc;
  padding: 10px;
}

.template-preview-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}

.template-inline-field {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  font-size: 12px;
}

.template-inline-field input {
  width: 84px;
  padding: 6px 8px;
}

.template-canvas-wrap {
  overflow: auto;
  max-height: 720px;
  border: 1px solid #d6e8e5;
  border-radius: 10px;
  background: #ffffff;
}

#adminTemplatePdfCanvas {
  display: block;
  width: auto;
  height: auto;
  cursor: crosshair;
}

.template-mapper-sidebar {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #ffffff;
  padding: 10px;
}

.table-scroll {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.template-map-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 620px;
}

.template-map-table th,
.template-map-table td {
  border-bottom: 1px solid #e6f0ee;
  padding: 6px;
  text-align: left;
  vertical-align: middle;
  font-size: 12px;
}

.template-map-table th {
  font-weight: 700;
  color: #204347;
  background: #f2f9f7;
}

.template-map-table td input {
  min-width: 90px;
  padding: 6px 8px;
  font-size: 12px;
}

.template-map-table td .btn-secondary,
.template-map-table td .btn-danger {
  padding: 6px 8px;
  font-size: 12px;
}

.admin-queue-wide {
  width: 100%;
  max-width: 100%;
}

.queue-layout {
  display: block;
}

.queue-main {
  min-width: 0;
}

.queue-table-scroll {
  overflow-x: visible;
}

.queue-record-table {
  min-width: 0;
  table-layout: fixed;
}

.queue-record-table th,
.queue-record-table td {
  padding: 8px 9px;
  vertical-align: top;
}

.queue-record-table th:first-child,
.queue-record-table td:first-child {
  width: 34px;
  text-align: center;
}

.queue-record-table th:nth-child(2),
.queue-record-table td:nth-child(2) {
  width: 24%;
}

.queue-record-table th:nth-child(3),
.queue-record-table td:nth-child(3) {
  width: 16%;
}

.queue-record-table th:nth-child(4),
.queue-record-table td:nth-child(4) {
  width: 25%;
}

.queue-record-table th:nth-child(5),
.queue-record-table td:nth-child(5) {
  width: 17%;
}

.queue-record-table th:nth-child(6),
.queue-record-table td:nth-child(6),
.queue-record-table th:nth-child(7),
.queue-record-table td:nth-child(7) {
  width: 9%;
}

.queue-patient-cell strong,
.queue-record-table td > strong {
  display: block;
  color: #123b40;
  font-size: 12px;
  line-height: 1.25;
}

.queue-patient-cell span,
.queue-cell-sub {
  display: block;
  margin-top: 3px;
  color: #5d777b;
  font-size: 10.5px;
  line-height: 1.25;
  word-break: break-word;
}

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

.queue-nowrap {
  white-space: nowrap;
}

.queue-payload-row > td {
  padding: 0;
  background: linear-gradient(180deg, rgba(238, 249, 247, 0.9), rgba(255, 255, 255, 0.95));
}

.queue-payload-panel {
  margin: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 10px 28px rgba(22, 56, 55, 0.08);
}

.queue-drawer {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 10px;
  position: sticky;
  top: 12px;
  max-height: 84vh;
  overflow: auto;
}

.queue-drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.queue-drawer-head h4 {
  margin: 0;
  font-size: 14px;
  color: #17373c;
}

.queue-drawer-actions {
  margin-bottom: 10px;
}

.queue-row-selected td {
  background: #eef9f7;
}

.queue-output-details {
  min-width: 520px;
}

.queue-output-details > summary {
  margin: 0;
}

.queue-payload-wrap {
  display: grid;
  gap: 10px;
}

.queue-kv-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 10px;
}

.queue-kv {
  display: grid;
  gap: 2px;
}

.queue-kv strong {
  font-size: 11px;
  color: #355b60;
}

.queue-kv span {
  font-size: 12px;
  color: #0f2d33;
  word-break: break-word;
}

.queue-icd {
  font-size: 12px;
  color: #0f2d33;
  line-height: 1.35;
}

.queue-json-pre {
  margin: 0;
  padding: 8px;
  border: 1px solid #d8e8e5;
  border-radius: 8px;
  background: #f6fbfa;
  max-height: 260px;
  overflow: auto;
  font-size: 11px;
  line-height: 1.35;
  white-space: pre;
}

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

  .queue-kv-grid {
    grid-template-columns: 1fr;
  }

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

  .provider-signature-card {
    grid-template-columns: 1fr;
  }

  .sample-barcode-card {
    grid-template-columns: 1fr;
  }

  .sample-barcode-card .btn-secondary {
    justify-self: flex-end;
  }

  .queue-drawer {
    position: static;
    max-height: none;
  }

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

  .span-2 {
    grid-column: span 1;
  }

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

  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }
}
