:root {
  --core-primary: #0b132b;
  --core-primary-hover: #182744;
  --core-primary-soft: #e7f4f5;
  --core-sidebar: #0b132b;
  --core-sidebar-surface: #14223c;
  --core-sidebar-text: #f7f9fc;
  --core-sidebar-muted: #b2bfd1;
  --core-focus-ring: 0 0 0 3px rgba(76, 158, 243, .3);
}

html.ignex-demo { --environment-banner-height: 28px; }
html.ignex-demo body { padding-top: var(--environment-banner-height); }
html.ignex-demo .environment-banner {
  position: fixed;
  z-index: 2000;
  inset: 0 0 auto;
  display: flex;
  min-height: var(--environment-banner-height);
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 3px 8px;
  background: #111d37;
  color: #fde68a;
  border-bottom: 1px solid rgba(245, 158, 11, .55);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: .055em;
  text-align: center;
  white-space: nowrap;
}
html.ignex-demo .login-gate,
html.ignex-demo .sidebar,
html.ignex-demo .sidebar-scrim { top: var(--environment-banner-height); }
html.ignex-demo .login-gate { grid-template-columns: minmax(0, 420px); align-content: center; overflow: auto; }
html.ignex-demo .app-main { min-height: calc(100vh - var(--environment-banner-height)); }

.environment-banner {
  background: #111d37;
  color: #fde68a;
}

.login-gate {
  background:
    radial-gradient(circle at 18% 18%, rgba(245, 158, 11, .14), transparent 32%),
    radial-gradient(circle at 84% 85%, rgba(11, 19, 43, .1), transparent 34%),
    var(--gcn-surface-3);
}

.login-card {
  border-color: #dbe3ef;
  box-shadow: 0 28px 80px rgba(11, 19, 43, .16);
}

.login-card > img,
.sidebar__brand-logo {
  display: grid;
  place-items: center;
  background: transparent;
  filter: drop-shadow(0 7px 15px rgba(9, 23, 44, .16));
}

.login-card > img {
  padding: 0;
  object-fit: contain;
}

.demo-visitor-card {
  width: 100%;
  margin-top: 0;
  padding: 18px 22px;
  border: 1px solid rgba(11, 19, 43, .12);
  border-radius: 16px;
  background: rgba(255, 255, 255, .95);
  box-shadow: 0 16px 40px rgba(11, 19, 43, .1);
}
.demo-visitor-card[hidden] { display: none; }
.demo-visitor-card { order: -1; }
.demo-visitor-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #8b5b08;
  font-size: .7rem;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.demo-visitor-card p { margin: 8px 0 14px; color: #59677f; font-size: .8rem; line-height: 1.55; }
.demo-visitor-card .button { width: 100%; }

.sidebar__brand-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 0;
}

html.ignex-demo .sidebar__brand-name {
  color: #fff;
  letter-spacing: .075em;
  font-weight: 850;
}
html.ignex-demo .sidebar__brand-subtitle {
  color: #8edfd6;
  letter-spacing: .08em;
  font-weight: 700;
}

.mock-brand svg,
.mock-side-brand svg,
.footer-brand svg { width: 23px; height: 23px; flex: none; }

.button-primary {
  box-shadow: 0 7px 18px rgba(11, 19, 43, .16);
}

:is(button, a, input, select, textarea):focus-visible {
  outline-color: #c98208;
}

@media (max-width: 760px) {
  html.ignex-demo .environment-banner {
    min-height: 32px;
    padding: 5px 8px;
    font-size: 10px;
    white-space: normal;
  }

  html.ignex-demo .mobile-topbar {
    top: 0;
    min-height: 52px;
  }

  html.ignex-demo .app-main {
    padding-top: 18px;
  }
}

/* Demo mobile: mantém cada etapa utilizável sem zoom ou rolagem lateral. */
@media (max-width: 900px) {
  html.ignex-demo,
  html.ignex-demo body {
    width: 100%;
    min-width: 320px;
    overflow-x: clip;
  }

  html.ignex-demo .app-shell,
  html.ignex-demo .app-main,
  html.ignex-demo .page,
  html.ignex-demo .content-card,
  html.ignex-demo .review-layout,
  html.ignex-demo .review-layout > *,
  html.ignex-demo .workspace-header > * {
    min-width: 0;
    max-width: 100%;
  }

  html.ignex-demo .app-main {
    width: 100%;
    margin-left: 0;
    padding-inline: clamp(12px, 4vw, 20px);
  }

  html.ignex-demo .mobile-topbar {
    padding-inline: max(14px, env(safe-area-inset-left));
  }

  html.ignex-demo .mobile-topbar strong {
    overflow: hidden;
    max-width: min(68vw, 320px);
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  html.ignex-demo #protocol-detail-page .detail-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  html.ignex-demo #protocol-detail-page .detail-header-meta {
    width: 100%;
    min-width: 0;
  }

  html.ignex-demo #protocol-detail-page .review-stepper {
    display: grid;
    width: 100%;
    max-width: none;
    min-width: 0;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    overflow: visible;
  }

  html.ignex-demo #protocol-detail-page .review-step {
    min-width: 0;
    min-height: 44px;
    justify-content: flex-start;
    gap: 0 7px;
    padding: 6px 8px;
    text-align: left;
  }

  html.ignex-demo #protocol-detail-page .review-step strong {
    min-width: 0;
    font-size: clamp(.66rem, 2.8vw, .78rem);
    line-height: 1.2;
    overflow-wrap: normal;
    word-break: normal;
  }

  html.ignex-demo #protocol-detail-page .review-step small { display: none; }

  html.ignex-demo body.review-workspace-mode,
  html.ignex-demo body.review-workspace-mode .app-main,
  html.ignex-demo body.review-workspace-mode #protocol-detail-page.page-visible {
    height: auto;
    min-height: 0;
    overflow: visible;
  }

  html.ignex-demo body.review-workspace-mode .app-main {
    padding: 14px 12px calc(112px + env(safe-area-inset-bottom));
  }

  html.ignex-demo body.review-workspace-mode #protocol-detail-page.page-visible {
    display: block;
  }

  html.ignex-demo body.review-workspace-mode #protocol-detail-page .review-layout,
  html.ignex-demo body.review-workspace-mode #protocol-detail-page[data-review-step] .review-layout {
    display: grid;
    width: 100%;
    height: auto;
    min-height: 0;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto;
    gap: 12px;
    overflow: visible;
  }

  html.ignex-demo body.review-workspace-mode #protocol-detail-page .document-panel,
  html.ignex-demo body.review-workspace-mode #protocol-detail-page .data-panel {
    position: relative;
    inset: auto;
    width: 100%;
    height: auto;
    min-width: 0;
    min-height: 0;
    max-height: none;
    overflow: visible;
  }

  html.ignex-demo body.review-workspace-mode #protocol-detail-page .document-stage {
    width: 100%;
    height: clamp(240px, 62vw, 390px);
    min-height: 0;
    max-height: none;
    flex: none;
  }

  html.ignex-demo body.review-workspace-mode #protocol-detail-page .data-panel > .card-heading,
  html.ignex-demo body.review-workspace-mode #protocol-detail-page .procedures-container > .card-heading {
    position: static;
    margin: 0 0 12px;
    padding: 0 0 10px;
    backdrop-filter: none;
  }

  html.ignex-demo body.review-workspace-mode #protocol-detail-page .action-bar {
    left: 0;
    width: 100%;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
  }

  html.ignex-demo :is(button, a, input, select, textarea) {
    scroll-margin-block: 84px;
  }

  html.ignex-demo :is(input:not([type="checkbox"]):not([type="radio"]), select, textarea) {
    font-size: 16px;
  }
}

@media (max-width: 600px) {
  html.ignex-demo #login-gate {
    align-content: start;
    gap: 12px;
    padding: 18px 14px calc(22px + env(safe-area-inset-bottom));
  }

  html.ignex-demo #login-form { order: 2; }

  html.ignex-demo .demo-visitor-card {
    order: 1;
    padding: 18px;
    border-color: rgba(11, 19, 43, .15);
    background: linear-gradient(145deg, #fff 5%, #f0f8f8 100%);
    box-shadow: 0 14px 34px rgba(11, 19, 43, .12);
  }

  html.ignex-demo .demo-visitor-card .button {
    min-height: 48px;
    font-size: .92rem;
  }

  html.ignex-demo #protocol-list-page .workspace-header {
    align-items: stretch;
  }

  html.ignex-demo #protocol-list-page .workspace-header .admin-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    width: 100%;
  }

  html.ignex-demo #protocol-list-page .workspace-header .admin-actions .button {
    width: 100%;
    min-height: 48px;
  }

  html.ignex-demo #protocol-list-page .protocol-queue-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
  }

  html.ignex-demo #protocol-list-page .protocol-queue-metrics .metric-card {
    display: flex;
    min-height: 102px;
    flex-direction: column;
    align-items: flex-start;
    justify-content: space-between;
    gap: 7px;
    padding: 12px;
    border-radius: 14px;
  }

  html.ignex-demo #protocol-list-page .protocol-queue-metrics .metric-card strong {
    order: 2;
    margin: 0;
    font-size: 1.45rem;
  }

  html.ignex-demo #protocol-list-page .protocol-queue-metrics .metric-label {
    order: 1;
    font-size: .68rem;
    line-height: 1.25;
  }

  html.ignex-demo #protocol-list-page .protocol-queue-metrics .metric-card small {
    order: 3;
    display: -webkit-box;
    max-width: 100%;
    overflow: hidden;
    font-size: .62rem;
    line-height: 1.25;
    white-space: normal;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  html.ignex-demo #protocol-list-page .protocol-toolbar-primary {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
  }

  html.ignex-demo #protocol-list-page .protocol-toolbar-primary .search-field {
    grid-column: 1 / -1;
    grid-row: 1;
  }

  html.ignex-demo #protocol-list-page .protocol-toolbar-primary .queue-scope-field,
  html.ignex-demo #protocol-list-page .protocol-toolbar-primary .protocol-filter-toggle {
    grid-row: 2;
    min-width: 0;
  }

  html.ignex-demo #protocol-list-page .protocol-toolbar-primary :is(select, .button) {
    width: 100%;
    min-height: 44px;
  }

  html.ignex-demo #protocol-list-page .table-wrap {
    overflow: visible;
  }

  html.ignex-demo #protocol-list-page .protocol-list-table tbody tr {
    grid-template-areas:
      "request actions"
      "beneficiary beneficiary"
      "stage assignee";
    grid-template-columns: minmax(0, 1fr) minmax(0, auto);
    align-items: center;
    gap: 0 8px;
    padding: 10px 12px;
  }

  html.ignex-demo #protocol-list-page .protocol-list-table tbody td {
    min-width: 0;
    padding: 6px 2px;
  }

  html.ignex-demo #protocol-list-page .protocol-list-table .protocol-request-cell {
    grid-area: request;
    padding: 6px 0 8px 34px;
  }

  html.ignex-demo #protocol-list-page .protocol-list-table .protocol-actions-cell {
    grid-area: actions;
    align-self: start;
    padding: 4px 0;
  }

  html.ignex-demo #protocol-list-page .protocol-list-table .beneficiary-cell {
    grid-area: beneficiary;
    border-top: 1px solid var(--gcn-border);
  }

  html.ignex-demo #protocol-list-page .protocol-list-table .protocol-stage-cell {
    grid-area: stage;
    border-top: 1px solid var(--gcn-border) !important;
  }

  html.ignex-demo #protocol-list-page .protocol-list-table .assignee-column {
    grid-area: assignee;
    border-top: 1px solid var(--gcn-border) !important;
    text-align: right;
  }

  html.ignex-demo #protocol-list-page .protocol-list-table .protocol-assignee-stack {
    align-items: flex-end;
  }

  html.ignex-demo #protocol-list-page .protocol-list-table .protocol-assignee-stack small {
    text-align: right;
  }
}

@media (max-width: 380px) {
  html.ignex-demo #protocol-list-page .protocol-queue-metrics .metric-card {
    min-height: 96px;
    padding: 10px;
  }

  html.ignex-demo #protocol-list-page .protocol-list-table .assignee-column {
    max-width: 46vw;
  }
}

/* Demo mobile: acesso direto aos dados clínicos da guia original. */
@media (max-width: 820px) {
  html.ignex-demo #authorizer-detail-card .authorizer-detail-heading {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
  }
  html.ignex-demo #authorizer-detail-card .authorizer-heading-tools {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    min-width: 0;
  }
  html.ignex-demo #authorizer-detail-card #open-authorizer-original {
    display: inline-flex;
    min-height: 44px;
    max-width: 100%;
    white-space: normal;
  }
}
html.ignex-demo #authorizer-detail-card #open-authorizer-original[hidden] { display: none; }

/* Demo mobile: os dados do autorizador seguem o mesmo padrão de cartões de Solicitações. */
@media (max-width: 900px) {
  html.ignex-demo #authorizer-page .table-wrap {
    max-width: 100%;
    overflow: visible;
    border: 0;
    background: transparent;
    box-shadow: none;
  }
  html.ignex-demo #authorizer-page .protocol-table {
    display: block;
    width: 100%;
    min-width: 0;
    border-collapse: separate;
  }
  html.ignex-demo #authorizer-page .protocol-table thead { display: none; }
  html.ignex-demo #authorizer-page .protocol-table tbody {
    display: grid;
    gap: 10px;
  }
  html.ignex-demo #authorizer-page .protocol-table tbody tr {
    position: relative;
    display: grid;
    grid-template-areas: "protocol action" "beneficiary beneficiary" "guide guide" "sender status" "updated updated";
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0 10px;
    min-width: 0;
    padding: 8px 12px;
    border: 1px solid var(--gcn-border);
    border-left: 3px solid var(--gcn-primary);
    border-radius: 13px;
    background: var(--gcn-surface);
    box-shadow: 0 3px 12px rgba(16, 42, 67, .045);
    cursor: pointer;
  }
  html.ignex-demo #authorizer-page .protocol-table tbody td {
    display: block;
    width: auto;
    min-width: 0;
    padding: 8px 2px;
    border: 0;
    background: transparent;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  html.ignex-demo #authorizer-page .authorizer-protocol-cell { grid-area: protocol; padding-right: 4px; }
  html.ignex-demo #authorizer-page .authorizer-beneficiary-cell { grid-area: beneficiary; border-top: 1px solid var(--gcn-border); }
  html.ignex-demo #authorizer-page .authorizer-guide-number-cell { grid-area: guide; border-top: 1px solid var(--gcn-border); }
  html.ignex-demo #authorizer-page .authorizer-sender-cell { grid-area: sender; border-top: 1px solid var(--gcn-border); color: var(--gcn-muted); font-size: .68rem; }
  html.ignex-demo #authorizer-page .authorizer-sender-cell::before { content: "Enviado por"; display: block; margin-bottom: 3px; color: var(--gcn-muted); font-size: .58rem; font-weight: 800; }
  html.ignex-demo #authorizer-page .authorizer-status-cell-data { grid-area: status; align-items: flex-end; justify-content: center; border-top: 1px solid var(--gcn-border); }
  html.ignex-demo #authorizer-page .authorizer-updated-cell { grid-area: updated; border-top: 1px solid var(--gcn-border); color: var(--gcn-muted); font-size: .64rem; }
  html.ignex-demo #authorizer-page .authorizer-updated-cell::before { content: "Atualizado "; font-weight: 800; }
  html.ignex-demo #authorizer-page .authorizer-action-cell { grid-area: action; align-self: start; padding: 4px 0; }
  html.ignex-demo #authorizer-page .authorizer-original-link { display: grid; gap: 3px; min-width: 0; overflow-wrap: anywhere; }
  html.ignex-demo #authorizer-page .authorizer-beneficiary-cell > strong { display: block; overflow-wrap: anywhere; }
  html.ignex-demo #authorizer-page .authorizer-beneficiary-cell > small,
  html.ignex-demo #authorizer-page .authorizer-guide-number-cell > small { display: block; overflow-wrap: anywhere; }
  html.ignex-demo #authorizer-detail-card { padding: 16px; }
  html.ignex-demo #authorizer-detail-card .authorizer-summary-grid { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  html.ignex-demo #authorizer-detail-card .authorizer-summary-grid > div { min-width: 0; overflow-wrap: anywhere; }
  html.ignex-demo #authorizer-detail-card .authorizer-guide-item { align-items: flex-start; gap: 8px; padding: 12px; }
  html.ignex-demo #authorizer-detail-card .authorizer-guide-item > div { min-width: 0; overflow-wrap: anywhere; }
  html.ignex-demo #authorizer-detail-card .authorizer-guide-item small { overflow-wrap: anywhere; }
  html.ignex-demo #authorizer-detail-card .guide-items-scroll { overflow: visible; }
  html.ignex-demo #authorizer-detail-card .guide-items-table,
  html.ignex-demo #authorizer-detail-card .guide-items-table tbody { display: block; width: 100%; min-width: 0; }
  html.ignex-demo #authorizer-detail-card .guide-items-table thead { display: none; }
  html.ignex-demo #authorizer-detail-card .guide-items-table tbody { display: grid; gap: 8px; }
  html.ignex-demo #authorizer-detail-card .guide-items-table tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0 10px;
    min-width: 0;
    padding: 8px 10px;
    border: 1px solid var(--gcn-border);
    border-radius: 11px;
    background: var(--gcn-surface);
  }
  html.ignex-demo #authorizer-detail-card .guide-items-table td {
    display: flex;
    min-width: 0;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 0;
    border: 0;
    overflow-wrap: anywhere;
    text-align: right;
  }
  html.ignex-demo #authorizer-detail-card .guide-items-table td::before {
    flex: 0 0 auto;
    color: var(--gcn-muted);
    font-size: .6rem;
    font-weight: 800;
    text-align: left;
  }
  html.ignex-demo #authorizer-detail-card .guide-items-table td:nth-child(1) { grid-column: 1 / -1; color: var(--gcn-primary); font-weight: 800; }
  html.ignex-demo #authorizer-detail-card .guide-items-table td:nth-child(1)::before { content: "TUSS"; }
  html.ignex-demo #authorizer-detail-card .guide-items-table td:nth-child(2) { grid-column: 1 / -1; text-align: left; }
  html.ignex-demo #authorizer-detail-card .guide-items-table td:nth-child(2)::before { content: "Procedimento"; }
  html.ignex-demo #authorizer-detail-card .guide-items-table td:nth-child(3)::before { content: "Complemento"; }
  html.ignex-demo #authorizer-detail-card .guide-items-table td:nth-child(4)::before { content: "Solicitada"; }
  html.ignex-demo #authorizer-detail-card .guide-items-table td:nth-child(5)::before { content: "Autorizada"; }
  html.ignex-demo #authorizer-detail-card .guide-items-table td:nth-child(6) { grid-column: 1 / -1; justify-content: flex-start; text-align: left; }
  html.ignex-demo #authorizer-detail-card .guide-items-table td:nth-child(6)::before { content: "Situação"; }
}

@media (max-width: 900px) { html.ignex-demo #authorizer-detail-card .guide-item-simulated-label { margin-left: 6px; color: var(--gcn-muted); font-size: .62rem; font-weight: 700; } }

html.ignex-demo #authorization-queue-monitor { display: none !important; }


@media (max-width: 760px) {
  html.ignex-demo #app #authorizer-center-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
}
@media (max-width: 359px) {
  html.ignex-demo #app #authorizer-center-summary { grid-template-columns: minmax(0, 1fr); }
}

/* Visitantes só consultam, mas precisam enxergar os dados estruturados da demo. */
html.ignex-demo body.auditor-readonly #protocol-detail-page #protocol-form .field :is(input, select, textarea) {
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
}
html.ignex-demo body.auditor-readonly #protocol-detail-page #protocol-form .procedure-compact-summary {
  display: flex !important;
  visibility: visible !important;
  opacity: 1 !important;
}
