/* NSP HU UEM — refino visual, carregado por último (depois de app.css, demo.css e
 * notificar.css). Reúne: tipografia auto-hospedada, botões em relevo com sensação de
 * apertar, ajustes de celular e de telas largas e as classes que substituíram estilos
 * embutidos no HTML e no JavaScript. Regras e medidas em docs/DESIGN.md. */

/* ===== Tipografia ===== */
@font-face {
  font-family: 'Inter Variable';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('../vendor/fonts/inter-latin-wght-normal.woff2') format('woff2-variations');
}
@font-face {
  font-family: 'Manrope Variable';
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url('../vendor/fonts/manrope-latin-wght-normal.woff2') format('woff2-variations');
}
:root {
  --fonte-texto:
    'Inter Variable', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue',
    Arial, sans-serif;
  --fonte-titulo:
    'Manrope Variable', 'Inter Variable', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
    sans-serif;
  --marca-ponto: #df62ef;
  --foco: #31c8ff;

  /* Relevo dos botões: face (gradiente), aresta inferior, brilho no topo e sombra de contato. */
  --b3-altura: 4px;
  --b3-face-1: #33497a;
  --b3-face-2: #263c64;
  --b3-borda: #50689a;
  --b3-aresta: #1a2b50;
  --b3-contorno: #060d1cb3;
  --b3-brilho: #c9d9ff38;
  --b3-sombra: #0000003d;
  --b3-tinta: #f2f5ff;
  --b3-fundo-apertado: #1e3157;
  --b3p-face-1: #bfadff;
  --b3p-face-2: #9c83ff;
  --b3p-borda: #d3c8ff;
  --b3p-aresta: #5a43b9;
  --b3p-brilho: #ffffff73;
  --b3p-tinta: #121c37;
  --b3-poco: #12213b;
  --b3-poco-sombra: #00000059;
}
:root[data-tema='claro'] {
  --marca-ponto: #b02fc4;
  --foco: #4b32c3;
  --b3-face-1: #ffffff;
  --b3-face-2: #eef3fa;
  --b3-borda: #c6d2e4;
  --b3-aresta: #b3c1d8;
  --b3-contorno: #8fa1bd66;
  --b3-brilho: #ffffff;
  --b3-sombra: #172a4624;
  --b3-tinta: #22324d;
  --b3-fundo-apertado: #e3eaf5;
  --b3p-face-1: #7359f2;
  --b3p-face-2: #5438da;
  --b3p-borda: #4a30cb;
  --b3p-aresta: #36229c;
  --b3p-brilho: #ffffff59;
  --b3p-tinta: #ffffff;
  --b3-poco: #e6ecf6;
  --b3-poco-sombra: #172a4630;
}
body {
  font-family: var(--fonte-texto);
  font-feature-settings: 'cv11', 'ss03';
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button,
input,
select,
textarea {
  font-family: inherit;
}
h1,
h2,
h3,
.brand-name,
.nf-brand,
.metric-value,
.histogram-value,
.flow-number,
.item-title,
.ring-number {
  font-family: var(--fonte-titulo);
}
h1 {
  font-weight: 750;
  letter-spacing: -0.03em;
}
h2 {
  font-weight: 700;
  letter-spacing: -0.012em;
}
.histogram-value,
.flow-number,
.ring-number,
.type-label strong,
.badge {
  font-variant-numeric: tabular-nums;
}

/* ===== Classes que substituíram estilos embutidos ===== */
.sprite {
  display: none;
}
.brand-dot,
.nf-brand span {
  color: var(--marca-ponto);
}
.icon-suave {
  width: 17px;
  color: var(--muted);
}
.type-pct {
  font-weight: 400;
  margin-left: 6px;
}
.item-text {
  min-width: 0;
}
.notice-espaco {
  margin-bottom: 18px;
}
.ring-number {
  paint-order: stroke;
  stroke: var(--ring-center-stroke);
  stroke-width: 1;
}
.bar-fill {
  width: var(--w, 0%);
  background: var(--bar-color);
}
.flow-track div {
  width: var(--w, 0%);
}

/* ===== Foco ===== */
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.nf-field input:focus-visible,
.nf-field select:focus-visible,
.nf-field textarea:focus-visible {
  outline: 3px solid var(--foco);
  outline-offset: 3px;
}

/* ===== Botões em relevo =====
 * Repouso: face em gradiente, brilho no topo, aresta inferior sólida e sombra de contato.
 * Hover: sobe 1 px e a aresta cresce. Active: desce até quase encostar e ganha sombra interna.
 * O seletor do tema claro entra na mesma lista para vencer as regras antigas de superfície. */
.button,
:root[data-tema='claro'] .button,
.close,
:root[data-tema='claro'] .close,
.theme-toggle,
:root[data-tema='claro'] .theme-toggle,
.case-button,
:root[data-tema='claro'] .case-button {
  background: linear-gradient(180deg, var(--b3-face-1), var(--b3-face-2));
  border: 1px solid var(--b3-borda);
  color: var(--b3-tinta);
  box-shadow:
    inset 0 1px 0 var(--b3-brilho),
    0 var(--b3-altura) 0 var(--b3-aresta),
    0 calc(var(--b3-altura) + 1px) 0 var(--b3-contorno),
    0 calc(var(--b3-altura) + 5px) 12px var(--b3-sombra);
  transform: translateY(0);
  transition:
    transform 0.11s var(--ease),
    box-shadow 0.11s var(--ease),
    background 0.18s,
    color 0.18s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.button {
  border-radius: 10px;
  min-height: 40px;
  padding: 9px 15px;
  font-weight: 650;
  letter-spacing: 0.005em;
  margin-bottom: var(--b3-altura);
}
.button:hover,
:root[data-tema='claro'] .button:hover,
.close:hover,
:root[data-tema='claro'] .close:hover,
.theme-toggle:hover,
:root[data-tema='claro'] .theme-toggle:hover,
.case-button:hover,
:root[data-tema='claro'] .case-button:hover {
  filter: none;
  background: linear-gradient(180deg, var(--b3-face-1), var(--b3-face-2));
  color: var(--b3-tinta);
  transform: translateY(-1px);
  box-shadow:
    inset 0 1px 0 var(--b3-brilho),
    0 calc(var(--b3-altura) + 1px) 0 var(--b3-aresta),
    0 calc(var(--b3-altura) + 2px) 0 var(--b3-contorno),
    0 calc(var(--b3-altura) + 8px) 16px var(--b3-sombra);
}
.button:active,
:root[data-tema='claro'] .button:active,
.close:active,
:root[data-tema='claro'] .close:active,
.theme-toggle:active,
:root[data-tema='claro'] .theme-toggle:active,
.case-button:active,
:root[data-tema='claro'] .case-button:active {
  transform: translateY(calc(var(--b3-altura) - 1px));
  background: linear-gradient(180deg, var(--b3-face-2), var(--b3-face-2));
  box-shadow:
    inset 0 2px 5px var(--b3-poco-sombra),
    0 1px 0 var(--b3-aresta),
    0 2px 4px var(--b3-sombra);
  transition-duration: 0.05s;
}
.button.primary,
:root[data-tema='claro'] .button.primary,
.button.primary:hover,
:root[data-tema='claro'] .button.primary:hover {
  --b3-face-1: var(--b3p-face-1);
  --b3-face-2: var(--b3p-face-2);
  --b3-borda: var(--b3p-borda);
  --b3-aresta: var(--b3p-aresta);
  --b3-brilho: var(--b3p-brilho);
  --b3-tinta: var(--b3p-tinta);
  border-color: var(--b3p-borda);
  color: var(--b3p-tinta);
}
.button:disabled,
.button[aria-disabled='true'],
.text-button:disabled,
.close:disabled {
  transform: none;
  box-shadow: inset 0 1px 0 var(--b3-brilho);
  cursor: not-allowed;
  opacity: 0.5;
}
.close {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  --b3-altura: 3px;
}
.theme-toggle {
  --b3-altura: 3px;
  min-height: 34px;
  padding: 6px 13px;
}
.theme-toggle[aria-pressed='true'] {
  border-color: var(--b3-borda);
}
.case-button {
  --b3-altura: 3px;
  border-radius: 12px;
  margin-bottom: 3px;
}
:root[data-tema='claro'] .case-button small {
  color: #5a6b85;
}

/* Botão de texto: sem volume, mas responde ao toque. */
.text-button {
  border-radius: 8px;
  padding: 6px 8px;
  margin: 0 -8px;
  transition:
    transform 0.11s var(--ease),
    background 0.18s;
  -webkit-tap-highlight-color: transparent;
}
.text-button:hover {
  filter: none;
  background: color-mix(in srgb, currentColor 10%, transparent);
}
.text-button:active {
  transform: translateY(2px);
  background: color-mix(in srgb, currentColor 18%, transparent);
}
.text-button .icon {
  transition: transform 0.18s var(--ease);
}
.text-button:hover .icon {
  transform: translateX(3px);
}

/* Navegação lateral: item ativo fica em relevo; os demais afundam ao toque. */
.nav-button {
  position: relative;
  border: 1px solid transparent;
  transition:
    transform 0.11s var(--ease),
    box-shadow 0.11s var(--ease),
    background 0.18s,
    color 0.18s;
  -webkit-tap-highlight-color: transparent;
}
.nav-button:hover {
  filter: none;
  transform: translateY(-1px);
}
.nav-button:active {
  transform: translateY(2px);
  box-shadow: inset 0 2px 5px var(--b3-poco-sombra);
}
.nav-button.active,
:root[data-tema='claro'] .nav-button.active {
  background: linear-gradient(180deg, var(--b3-face-1), var(--b3-face-2));
  border-color: var(--b3-borda);
  box-shadow:
    inset 0 1px 0 var(--b3-brilho),
    0 3px 0 var(--b3-aresta),
    0 4px 0 var(--b3-contorno),
    0 8px 14px var(--b3-sombra);
}
.nav-button.active:active {
  transform: translateY(2px);
  box-shadow:
    inset 0 2px 5px var(--b3-poco-sombra),
    0 1px 0 var(--b3-aresta);
}

/* Abas: grupo em "poço"; a aba escolhida é a tecla em relevo. */
.priority-tabs {
  gap: 4px;
  padding: 4px;
  border-bottom: 0;
  border-radius: 12px;
  background: var(--b3-poco);
  box-shadow: inset 0 2px 4px var(--b3-poco-sombra);
  width: fit-content;
  max-width: calc(100% - 44px);
}
.tab,
:root[data-tema='claro'] .tab {
  border: 1px solid transparent;
  color: var(--muted);
}
.tab {
  border-radius: 9px;
  padding: 7px 12px;
  min-height: 34px;
  font-weight: 600;
  transition:
    transform 0.11s var(--ease),
    box-shadow 0.11s var(--ease),
    background 0.18s,
    color 0.18s;
  -webkit-tap-highlight-color: transparent;
}
.tab:hover {
  filter: none;
  color: var(--ink);
}
.tab:active {
  transform: translateY(1px);
}
.tab[aria-selected='true'],
:root[data-tema='claro'] .tab[aria-selected='true'] {
  color: var(--b3-tinta);
  background: linear-gradient(180deg, var(--b3-face-1), var(--b3-face-2));
  border-color: var(--b3-borda);
  box-shadow:
    inset 0 1px 0 var(--b3-brilho),
    0 2px 0 var(--b3-aresta),
    0 3px 0 var(--b3-contorno),
    0 5px 9px var(--b3-sombra);
}
.tab[aria-selected='true']:active {
  transform: translateY(2px);
  box-shadow: inset 0 2px 4px var(--b3-poco-sombra);
}

/* Linhas clicáveis da lista de prioridades. */
.priority-item {
  border-radius: 10px;
  padding-left: 8px;
  padding-right: 8px;
  margin: 0 -8px;
  width: calc(100% + 16px);
  transition:
    transform 0.11s var(--ease),
    box-shadow 0.11s var(--ease),
    background 0.18s;
  -webkit-tap-highlight-color: transparent;
}
.priority-item:hover {
  filter: none;
}
.priority-item:active {
  transform: translateY(2px);
  background: var(--b3-fundo-apertado);
  box-shadow: inset 0 2px 5px var(--b3-poco-sombra);
}
.priority-item .item-end .icon {
  transition: transform 0.18s var(--ease);
}
.priority-item:hover .item-end .icon {
  transform: translateX(3px);
}

/* Cartões de indicador: o relevo já existia; o toque afunda mais e sem atraso. */
.metric {
  -webkit-tap-highlight-color: transparent;
}
.metric:active {
  transform: translateY(4px);
  transition-duration: 0.06s;
}
:root[data-tema='claro'] .metric:active {
  transform: translateY(4px);
}

/* Campos em "poço": par visual dos botões em relevo. */
.nf-field input,
.nf-field select,
.nf-field textarea,
.receber-campo select,
:root[data-tema='claro'] .nf-field input,
:root[data-tema='claro'] .nf-field select,
:root[data-tema='claro'] .nf-field textarea {
  box-shadow: inset 0 2px 4px var(--b3-poco-sombra);
  transition:
    border-color 0.18s,
    box-shadow 0.18s;
}
:root[data-tema='claro'] .receber-campo select {
  background: #ffffff;
  border-color: #cfd9e8;
  color: #16233a;
}

/* Ajustes pontuais encontrados na conferência visual. */
.settings input {
  flex-shrink: 0;
}
:root[data-tema='claro'] .profile strong {
  color: #16233a;
}
@media (max-width: 1200px) {
  .metric-foot {
    padding-bottom: 16px;
  }
}
@media (max-width: 1000px) {
  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (min-width: 1001px) and (max-width: 1200px) {
  .nav-button {
    padding: 11px 9px;
    gap: 9px;
    font-size: 12.5px;
    white-space: nowrap;
  }
}

/* ===== Formulário de notificação ===== */
.nf-acoes .button {
  min-height: 48px;
  padding: 12px 22px;
  font-size: 15px;
}
.nf-acoes .text-button {
  min-height: 44px;
  margin: 0;
  padding: 8px 10px;
}
.nf-top .theme-toggle span {
  display: inline;
}
@media (min-width: 900px) {
  .nf-main {
    max-width: 780px;
    margin: 36px auto 44px;
    padding: 34px 40px 38px;
    flex: 0 0 auto;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: linear-gradient(145deg, #2a4067 0%, #213456 100%);
    box-shadow:
      inset 0 1px 0 #c5d6ff14,
      0 6px 0 #101f38,
      0 22px 40px #0000002e;
  }
  :root[data-tema='claro'] .nf-main {
    background: #ffffff;
    box-shadow:
      inset 0 1px 0 #ffffff,
      0 6px 0 #cfd9e8,
      0 22px 40px #172a461a;
  }
  .nf-top {
    padding: 16px 32px;
  }
  .nf-head h1 {
    font-size: 28px;
  }
  .nf-head .subtitle {
    font-size: 13px;
  }
  .nf-foot {
    margin-top: auto;
  }
}

/* ===== Telas largas ===== */
@media (min-width: 1700px) {
  .shell {
    grid-template-columns: 248px minmax(0, 1fr);
  }
  main {
    max-width: 1760px;
    padding-left: 48px;
    padding-right: 48px;
  }
  h1 {
    font-size: 34px;
  }
  .subtitle {
    font-size: 13px;
  }
  h2 {
    font-size: 16px;
  }
  .panel-subtitle,
  .type-label,
  .item-meta,
  .flow-label {
    font-size: 12px;
  }
  .item-title {
    font-size: 13px;
  }
  .nav-button {
    font-size: 14px;
  }
}

/* ===== Tablet e celular: alvos de toque ===== */
@media (max-width: 760px) {
  .button,
  .nf-acoes .button {
    min-height: 46px;
  }
  .title-row .button {
    min-width: 46px;
  }
  .tab {
    min-height: 44px;
    padding: 10px 12px;
    font-size: 12px;
  }
  .priority-tabs {
    max-width: calc(100% - 32px);
  }
  .close {
    width: 44px;
    height: 44px;
  }
  .theme-toggle {
    min-height: 44px;
    min-width: 44px;
    justify-content: center;
  }
  .text-button {
    min-height: 44px;
    font-size: 12px;
  }
  .filter {
    min-height: 46px;
  }
  .filter select,
  .search input,
  .receber-campo select,
  .nf-field input,
  .nf-field select,
  .nf-field textarea {
    font-size: 16px;
    min-height: 44px;
  }
  .priority-item {
    min-height: 60px;
  }
  .settings label {
    min-height: 48px;
  }
  .nf-top .theme-toggle span {
    display: none;
  }
}

/* ===== Celular: navegação inferior fixa, ao alcance do polegar ===== */
@media (max-width: 600px) {
  .shell {
    display: block;
  }
  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    overflow: visible;
    padding-top: calc(10px + env(safe-area-inset-top, 0px));
  }
  .brand {
    padding: 0;
    gap: 9px;
  }
  .brand-mark {
    width: 26px;
    height: 30px;
  }
  .brand-name {
    display: block;
    font-size: 19px;
  }
  .brand small {
    display: block;
    font-size: 10px;
    margin-top: 3px;
  }
  .sidebar .nav-divider,
  .sidebar .profile,
  .sidebar .secondary-nav,
  .sidebar .nav-label,
  .sidebar .hospital {
    display: none;
  }
  .sidebar nav {
    position: fixed;
    z-index: 8;
    left: 0;
    right: 0;
    bottom: 0;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 2px;
    padding: 7px 6px calc(7px + env(safe-area-inset-bottom, 0px));
    background: var(--nav);
    border-top: 1px solid var(--line);
    box-shadow: 0 -8px 24px #00000038;
  }
  :root[data-tema='claro'] .sidebar nav {
    background: #ffffff;
    box-shadow: 0 -8px 24px #172a461f;
  }
  .sidebar nav .nav-button {
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    margin: 0;
    padding: 7px 0 6px;
    min-width: 0;
    min-height: 54px;
    border-radius: 12px;
    text-align: center;
  }
  .sidebar nav .nav-button span {
    display: block;
    font-size: 10px;
    font-weight: 600;
    line-height: 1.15;
    letter-spacing: -0.02em;
    max-width: 100%;
  }
  .sidebar nav .nav-button .icon {
    width: 21px;
    height: 21px;
  }
  .sidebar nav .nav-button:hover {
    transform: none;
  }
  .topbar {
    height: 56px;
    padding: 0 16px;
  }
  .crumb {
    display: none;
  }
  .top-actions {
    width: 100%;
    gap: 10px;
    flex-direction: row-reverse;
    justify-content: space-between;
  }
  .filters {
    gap: 10px;
  }
  .filters .filter {
    flex: 1 1 100%;
    max-width: none;
  }
  .filters .filter select {
    flex: 1;
    max-width: none;
    width: auto;
  }
  main {
    padding: 20px 16px calc(96px + env(safe-area-inset-bottom, 0px));
  }
  #toast {
    bottom: calc(86px + env(safe-area-inset-bottom, 0px));
  }
  .sheet,
  .settings,
  .receber {
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100dvh;
    margin: 0;
    inset: 0;
    border-radius: 0;
  }
  .settings {
    position: fixed;
    display: none;
    flex-direction: column;
  }
  .settings[open] {
    display: flex;
  }
  .settings form {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
  }
  .settings-footer {
    padding-bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  }
  .settings-footer .button {
    flex: 1;
  }
  .dialog-head {
    padding-top: calc(18px + env(safe-area-inset-top, 0px));
  }
  .receber-acoes .button {
    flex: 1 1 100%;
  }
  .nf-acoes .button {
    flex: 1 1 100%;
  }
  .nf-acoes {
    gap: 8px;
  }
  .nf-top {
    padding-top: calc(12px + env(safe-area-inset-top, 0px));
    row-gap: 10px;
  }
  .nf-top .theme-toggle {
    order: 2;
    margin-left: auto;
  }
  .nf-top .demo-tag {
    order: 3;
    flex: 0 1 auto;
  }
  .nf-top::after {
    content: '';
    order: 2;
    flex-basis: 100%;
    height: 0;
  }
  .nf-foot {
    padding-bottom: calc(22px + env(safe-area-inset-bottom, 0px));
  }
}

/* ===== Movimento reduzido ===== */
@media (prefers-reduced-motion: reduce) {
  .button,
  .close,
  .theme-toggle,
  .case-button,
  .text-button,
  .nav-button,
  .tab,
  .priority-item,
  .metric,
  .button:hover,
  .button:active,
  .close:hover,
  .close:active,
  .theme-toggle:hover,
  .theme-toggle:active,
  .case-button:hover,
  .case-button:active,
  .text-button:active,
  .nav-button:hover,
  .nav-button:active,
  .tab:active,
  .priority-item:active,
  .metric:hover,
  .metric:active,
  .text-button:hover .icon,
  .priority-item:hover .item-end .icon {
    transform: none !important;
    transition: none !important;
  }
}

/* O atributo hidden precisa vencer display de componentes (.text-button é inline-flex). */
[hidden] {
  display: none !important;
}
