/* ============================================================================
   SAFETY HUDDLE · HSE — Design System
   Identidade: clínica, calma e precisa. Verde #1e9e73 = UTI GERAL,
   azul #3f5a86 = UTI CIRÚRGICA. Tipografia: REM (display) + Inter (UI).
   ========================================================================== */

/* ----------------------------------------------------------------------------
   1. Tokens
---------------------------------------------------------------------------- */
:root {
  /* Cores de caracterização das unidades */
  --green:       #1e9e73;
  --green-dark:  #157a58;
  --green-soft:  #e7f5ef;
  --green-line:  #bce3d3;

  --blue:        #3f5a86;
  --blue-dark:   #32486c;
  --blue-soft:   #eaeff7;
  --blue-line:   #c8d4e6;

  /* Neutros */
  --text:    #20262d;
  --text-2:  #5b6672;
  --text-3:  #99a1ab;
  --line:    #e5e9ec;
  --line-2:  #d3dade;
  --bg:      #f3f5f6;
  --surface: #ffffff;

  /* Estados */
  --danger:      #ce4036;
  --danger-dark: #a83228;
  --danger-soft: #fdf0ef;
  --danger-line: #f2cdc9;

  /* Acento contextual: neutro por padrão; muda dentro de .theme-geral /
     .theme-cirurgica para caracterizar a unidade em foco */
  --accent:      #29323b;
  --accent-dark: #161d24;
  --accent-soft: #eef1f3;
  --accent-line: #cfd6db;

  /* Tipografia */
  --font-ui:      'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-display: 'REM', 'Inter', system-ui, sans-serif;

  /* Raios e sombras */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --shadow-1: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .07);
  --shadow-2: 0 10px 28px rgba(16, 24, 40, .14);
  --shadow-3: 0 24px 64px rgba(16, 24, 40, .24);

  --header-h: 64px;
}

.theme-geral {
  --accent:      var(--green);
  --accent-dark: var(--green-dark);
  --accent-soft: var(--green-soft);
  --accent-line: var(--green-line);
}

.theme-cirurgica {
  --accent:      var(--blue);
  --accent-dark: var(--blue-dark);
  --accent-soft: var(--blue-soft);
  --accent-line: var(--blue-line);
}

/* ----------------------------------------------------------------------------
   2. Base
---------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

/* O atributo hidden vence qualquer display definido por classe */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
}

h1, h2, h3, h4 { margin: 0; font-family: var(--font-display); line-height: 1.25; }
p { margin: 0; }

a { color: inherit; }

img { max-width: 100%; display: block; }

button, input, select, textarea { font: inherit; color: inherit; }

:focus-visible {
  outline: 2.5px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.container {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 22px;
}

main.container { padding-bottom: 64px; }

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

/* ----------------------------------------------------------------------------
   3. Header / navegação
---------------------------------------------------------------------------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 2px rgba(16, 24, 40, .03);
}

.app-header .container {
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 24px;
  position: relative;
}

.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.brand img { height: 30px; width: auto; }

.main-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

.main-nav a {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 14px;
  border-radius: 9px;
  font-weight: 550;
  font-size: 14px;
  color: var(--text-2);
  text-decoration: none;
  transition: background .18s, color .18s;
}

.main-nav a:hover { background: #f1f4f4; color: var(--text); }
.main-nav a svg { width: 16px; height: 16px; }

.header-spacer { flex: 1; }

.user-box {
  display: flex;
  align-items: center;
  gap: 14px;
}

.user-meta { text-align: right; line-height: 1.3; }
.user-meta .user-name { font-weight: 600; font-size: 13.5px; }
.user-meta .user-job  { font-size: 12px; color: var(--text-3); }

.logout-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 38px;
  padding: 0 14px;
  border: 1.5px solid var(--line-2);
  border-radius: 9px;
  background: var(--surface);
  font-weight: 600;
  font-size: 13.5px;
  color: var(--text-2);
  text-decoration: none;
  cursor: pointer;
  transition: border-color .18s, color .18s, background .18s;
}

.logout-btn:hover { border-color: var(--danger-line); color: var(--danger); background: var(--danger-soft); }
.logout-btn svg { width: 15px; height: 15px; }

/* Hambúrguer — só aparece no mobile */
.nav-toggle {
  display: none;
  width: 44px;
  height: 44px;
  border: 0;
  background: none;
  cursor: pointer;
  border-radius: 10px;
  align-items: center;
  justify-content: center;
}

.nav-toggle:hover { background: #f1f4f4; }

.nav-toggle .bars { position: relative; width: 20px; height: 14px; display: block; }
.nav-toggle .bars span {
  position: absolute;
  left: 0;
  width: 100%;
  height: 2px;
  border-radius: 2px;
  background: var(--text);
  transition: transform .22s, opacity .18s, top .22s;
}
.nav-toggle .bars span:nth-child(1) { top: 0; }
.nav-toggle .bars span:nth-child(2) { top: 6px; }
.nav-toggle .bars span:nth-child(3) { top: 12px; }

.nav-toggle.open .bars span:nth-child(1) { top: 6px; transform: rotate(45deg); }
.nav-toggle.open .bars span:nth-child(2) { opacity: 0; }
.nav-toggle.open .bars span:nth-child(3) { top: 6px; transform: rotate(-45deg); }

/* Painel mobile */
.mobile-panel {
  display: none;
  border-top: 1px solid var(--line);
  background: var(--surface);
  box-shadow: 0 16px 28px rgba(16, 24, 40, .12);
}

.mobile-panel.open { display: block; animation: panelDown .2s ease; }

@keyframes panelDown {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.mobile-panel a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 15px 22px;
  font-weight: 550;
  font-size: 15px;
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid #f0f3f4;
}

.mobile-panel a svg { width: 18px; height: 18px; color: var(--text-2); }
.mobile-panel a:active { background: #f4f7f7; }

.mobile-panel .mp-user {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 22px;
  background: #f8fafa;
}

.mobile-panel .mp-user .user-name { font-weight: 650; font-size: 14.5px; }
.mobile-panel .mp-user .user-job  { font-size: 12.5px; color: var(--text-3); }

/* ----------------------------------------------------------------------------
   4. Cabeçalho de página
---------------------------------------------------------------------------- */
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  margin: 30px 0 22px;
}

.page-head h1 {
  font-size: 23px;
  font-weight: 650;
  letter-spacing: .01em;
}

.page-head .page-sub { margin-top: 4px; font-size: 13.5px; color: var(--text-2); }

.page-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ----------------------------------------------------------------------------
   5. Botões
---------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 41px;
  padding: 0 18px;
  border: 1.5px solid transparent;
  border-radius: 10px;
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background .18s, border-color .18s, color .18s, box-shadow .18s, transform .12s;
}

.btn svg { width: 16px; height: 16px; flex: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; pointer-events: none; }

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); box-shadow: var(--shadow-1); }

.btn-outline { background: var(--surface); border-color: var(--line-2); color: var(--text); }
.btn-outline:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: #eef1f2; color: var(--text); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-dark); }

.btn-danger-outline { background: var(--surface); border-color: var(--danger-line); color: var(--danger); }
.btn-danger-outline:hover { background: var(--danger-soft); border-color: var(--danger); }

.btn-sm { height: 35px; padding: 0 13px; font-size: 13px; border-radius: 9px; }
.btn-lg { height: 47px; padding: 0 26px; font-size: 15px; border-radius: 12px; }

/* Botão de ícone (ações em linha na tabela) */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  transition: background .16s, color .16s;
}

.icon-btn svg { width: 17px; height: 17px; }
.icon-btn:hover { background: var(--accent-soft); color: var(--accent); }
.icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger); }

/* ----------------------------------------------------------------------------
   6. Formulários
---------------------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 6px; }

.field > label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-2);
  letter-spacing: .02em;
}

.input, .select, .textarea {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1.5px solid var(--line-2);
  border-radius: var(--r-sm);
  background: var(--surface);
  font-size: 14.5px;
  color: var(--text);
  transition: border-color .16s, box-shadow .16s;
}

.textarea { height: auto; padding: 10px 12px; resize: vertical; min-height: 88px; line-height: 1.5; }

.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3.5px color-mix(in srgb, var(--accent) 14%, transparent);
}

.select {
  appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%235b6672' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

.field-error { font-size: 12.5px; color: var(--danger); display: flex; gap: 5px; align-items: center; }

/* Alertas / flash */
.alert {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 15px;
  border-radius: var(--r-md);
  font-size: 13.5px;
  line-height: 1.5;
  margin-bottom: 18px;
}

.alert svg { width: 17px; height: 17px; flex: none; margin-top: 1px; }
.alert-error   { background: var(--danger-soft); border: 1px solid var(--danger-line); color: var(--danger-dark); }
.alert-success { background: var(--green-soft); border: 1px solid var(--green-line); color: var(--green-dark); }

/* ----------------------------------------------------------------------------
   7. Cards e superfícies
---------------------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
}

.card-pad { padding: 22px; }

/* ----------------------------------------------------------------------------
   8. Login
---------------------------------------------------------------------------- */
.login-page {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 28px 18px;
  background:
    radial-gradient(640px 420px at 8% -4%, rgba(30, 158, 115, .09), transparent 60%),
    radial-gradient(640px 420px at 96% 104%, rgba(63, 90, 134, .10), transparent 60%),
    var(--bg);
}

.login-card {
  width: min(410px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow-2);
  overflow: hidden;
  animation: loginUp .35s cubic-bezier(.21, .8, .35, 1);
}

@keyframes loginUp {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* faixa dual: as duas UTIs lado a lado */
.login-card::before {
  content: '';
  display: block;
  height: 4px;
  background: linear-gradient(90deg, var(--green) 0 50%, var(--blue) 50% 100%);
}

.login-body { padding: 34px 34px 30px; }

.login-logo { height: 34px; width: auto; margin: 0 auto 24px; }

.login-title {
  text-align: center;
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 800;
  letter-spacing: .02em;
}

.login-sub {
  text-align: center;
  margin-top: 5px;
  margin-bottom: 26px;
  font-size: 13px;
  color: var(--text-2);
}

.login-form { display: flex; flex-direction: column; gap: 16px; }

.login-form .btn { margin-top: 6px; width: 100%; }

.login-foot {
  margin-top: 22px;
  text-align: center;
  font-size: 12px;
  color: var(--text-3);
}

/* ----------------------------------------------------------------------------
   9. Novo Huddle — seleção de unidade
---------------------------------------------------------------------------- */
.unit-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 22px;
  margin-top: 8px;
}

.unit-card {
  position: relative;
  overflow: hidden;
  padding: 26px 26px 24px;
  transition: box-shadow .2s, transform .2s, border-color .2s;
}

.unit-card:hover { box-shadow: var(--shadow-2); transform: translateY(-2px); border-color: var(--accent-line); }

.unit-card::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: var(--accent);
}

.unit-card h2 {
  margin-top: 4px;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: .01em;
}

.unit-card .unit-beds {
  margin-top: 6px;
  font-size: 13px;
  color: var(--text-2);
}

.unit-card .unit-beds strong { color: var(--text); font-weight: 600; }

.unit-card .unit-actions {
  display: flex;
  gap: 10px;
  margin-top: 22px;
  flex-wrap: wrap;
}

/* ----------------------------------------------------------------------------
   10. Formulário digital do huddle
---------------------------------------------------------------------------- */
.doc-card { overflow: hidden; }

.doc-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 16px 26px;
  border-bottom: 1px solid var(--line);
}

.doc-top img { height: 30px; width: auto; }

.doc-top .doc-code {
  text-align: right;
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--text-3);
}

.doc-top .doc-code strong { color: var(--text-2); font-weight: 600; }

.doc-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 18px;
  padding: 24px 26px 6px;
}

.doc-title h1 { font-size: 29px; font-weight: 800; letter-spacing: .015em; }
.doc-title .doc-sub { margin-top: 3px; font-size: 12.5px; letter-spacing: .04em; color: var(--text-2); text-transform: uppercase; }

.doc-unit { text-align: right; }
.doc-unit .doc-unit-name {
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 700;
  color: var(--accent);
}

.doc-datetime { display: flex; gap: 10px; margin-top: 9px; justify-content: flex-end; }
.doc-datetime .input { width: 150px; height: 38px; font-size: 13.5px; }
.doc-datetime .input[type="time"] { width: 108px; }

.huddle-form-body { padding: 20px 26px 26px; }

.cat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px 20px;
}

.cat-block {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 15px 16px 14px;
  background: var(--surface);
  transition: border-color .18s, box-shadow .18s;
}

.cat-block:focus-within { border-color: var(--accent-line); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 7%, transparent); }

.cat-block .cat-label {
  font-family: var(--font-display);
  font-size: 12.5px;
  font-weight: 650;
  letter-spacing: .025em;
  margin-bottom: 11px;
}

.bed-row { display: flex; flex-wrap: wrap; gap: 7px; }

.bed-chip { position: relative; }

.bed-chip input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.bed-chip span {
  display: grid;
  place-items: center;
  min-width: 42px;
  height: 37px;
  padding: 0 6px;
  border: 1.5px solid var(--line-2);
  border-radius: 9px;
  background: #fbfcfc;
  font-weight: 600;
  font-size: 13.5px;
  color: var(--text-2);
  cursor: pointer;
  user-select: none;
  transition: background .15s, border-color .15s, color .15s, transform .15s;
}

.bed-chip:hover span { border-color: var(--accent); color: var(--accent); }

.bed-chip input:checked + span {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  animation: chipPop .22s ease;
}

.bed-chip input:focus-visible + span {
  outline: 2.5px solid var(--accent);
  outline-offset: 2px;
}

@keyframes chipPop {
  0%   { transform: scale(.9); }
  60%  { transform: scale(1.07); }
  100% { transform: scale(1); }
}

.cat-note-input {
  width: 100%;
  margin-top: 12px;
  padding: 7px 2px;
  border: 0;
  border-bottom: 1.5px solid var(--line);
  background: transparent;
  font-size: 13.5px;
  color: var(--text);
  transition: border-color .16s;
}

.cat-note-input::placeholder { color: var(--text-3); }
.cat-note-input:focus { outline: none; border-color: var(--accent); }

.huddle-extra {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  margin-top: 22px;
}

.huddle-extra .section-label {
  font-family: var(--font-display);
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: .03em;
  margin-bottom: 8px;
}

.team-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.form-actions {
  position: sticky;
  bottom: 0;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 0 18px;
  margin-top: 10px;
  background: linear-gradient(to top, var(--bg) 62%, transparent);
}

/* ----------------------------------------------------------------------------
   11. Filtros / listagem
---------------------------------------------------------------------------- */
.filters-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px 14px;
  padding: 16px 18px;
  margin-bottom: 18px;
}

.filters-bar .field { min-width: 150px; flex: 0 1 auto; }
.filters-bar .field .input, .filters-bar .field .select { height: 39px; font-size: 13.5px; }

/* Multi-seleção (dropdown com checkboxes) — usado no filtro de categoria */
.ms { position: relative; }
.ms-toggle {
  width: 100%;
  height: 39px;
  padding: 0 34px 0 12px;
  text-align: left;
  border: 1.5px solid var(--line-2);
  border-radius: var(--r-sm);
  background: var(--surface);
  font-size: 13.5px;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%235b6672' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}
.ms-toggle:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3.5px color-mix(in srgb, var(--accent) 14%, transparent);
}
.ms-panel {
  position: absolute;
  top: calc(100% + 5px);
  left: 0;
  z-index: 30;
  min-width: 248px;
  max-height: 286px;
  overflow-y: auto;
  background: var(--surface);
  border: 1.5px solid var(--line-2);
  border-radius: 10px;
  box-shadow: var(--shadow-1);
  padding: 6px;
}
.ms-option {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 9px;
  border-radius: 7px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
}
.ms-option:hover { background: var(--accent-soft); }
.ms-option input {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
  cursor: pointer;
  flex: none;
}

.filters-actions { display: flex; gap: 8px; margin-left: auto; align-items: center; }

/* Filtros recolhíveis (accordion suave, sem altura fixa) */
.filters-collapse {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows .28s ease;
}
.filters-collapse.is-open { grid-template-rows: 1fr; }
.filters-collapse-inner { overflow: hidden; min-height: 0; }
/* Quando aberto, libera overflow (após a animação) para dropdowns não serem cortados */
.filters-collapse.is-open .filters-collapse-inner {
  overflow: visible;
  transition: overflow 0s .28s;
}

/* Botão de filtros: seta que gira e ponto de "filtros ativos" */
#filtersToggle { position: relative; }
#filtersToggle .chevron { width: 15px; height: 15px; opacity: .7; transition: transform .25s ease; }
#filtersToggle[aria-expanded="true"] .chevron { transform: rotate(180deg); }
#filtersToggle .filter-badge {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 2px var(--surface);
}

/* Toggle "Cancelados" — fica evidente quando ativo */
.toggle-cancelled {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 39px;
  padding: 0 15px;
  border: 1.5px solid var(--line-2);
  border-radius: 10px;
  background: var(--surface);
  font-weight: 600;
  font-size: 13.5px;
  color: var(--text-2);
  text-decoration: none;
  cursor: pointer;
  transition: all .18s;
}

.toggle-cancelled svg { width: 15px; height: 15px; }

.toggle-cancelled.active {
  background: var(--danger-soft);
  border-color: var(--danger);
  color: var(--danger-dark);
  box-shadow: 0 0 0 3px rgba(206, 64, 54, .08);
}

.table-wrap { overflow-x: auto; }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.table th {
  padding: 13px 18px;
  text-align: left;
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-3);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.table td {
  padding: 13px 18px;
  border-bottom: 1px solid #eef1f3;
  vertical-align: middle;
}

.table tbody tr { transition: background .14s; }
.table tbody tr:hover { background: #f8fafa; }
.table tbody tr:last-child td { border-bottom: 0; }

.table .td-actions { display: flex; gap: 4px; justify-content: flex-end; }

/* Linha cancelada — feedback fino: barra lateral + conteúdo esmaecido */
tr.row-cancelled td { background: rgba(206, 64, 54, .025); }
tr.row-cancelled td:first-child { box-shadow: inset 3px 0 0 var(--danger); }
tr.row-cancelled .hud-date, tr.row-cancelled .hud-by { opacity: .62; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.badge .dot { width: 7px; height: 7px; border-radius: 50%; }

.badge-geral     { background: var(--green-soft); color: var(--green-dark); }
.badge-geral .dot { background: var(--green); }

.badge-cirurgica { background: var(--blue-soft); color: var(--blue-dark); }
.badge-cirurgica .dot { background: var(--blue); }

.badge-cancelled {
  background: var(--danger-soft);
  color: var(--danger-dark);
  font-size: 11.5px;
}

.badge-cancelled svg { width: 12px; height: 12px; }

.cancel-info { margin-top: 4px; font-size: 12px; color: var(--danger-dark); display: flex; align-items: center; gap: 5px; }
.cancel-info svg { width: 12.5px; height: 12.5px; flex: none; }

/* Paginação */
.list-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 18px;
}

.list-count { font-size: 13px; color: var(--text-2); }

.pagination { display: flex; gap: 6px; }

.page-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 37px;
  height: 37px;
  padding: 0 6px;
  border: 1.5px solid var(--line-2);
  border-radius: 10px;
  background: var(--surface);
  font-weight: 600;
  font-size: 13.5px;
  color: var(--text-2);
  text-decoration: none;
  transition: border-color .16s, color .16s, background .16s;
}

.page-link svg { width: 15px; height: 15px; }
.page-link:hover { border-color: var(--text); color: var(--text); }
.page-link.current { background: var(--text); border-color: var(--text); color: #fff; pointer-events: none; }
.page-link.disabled { opacity: .45; pointer-events: none; }
.page-gap { align-self: center; color: var(--text-3); padding: 0 2px; }

/* Cards da listagem no mobile */
.huddle-cards { display: none; }

/* ----------------------------------------------------------------------------
   12. Dashboard
---------------------------------------------------------------------------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  margin-bottom: 18px;
}

.kpi { padding: 19px 21px; position: relative; overflow: hidden; }

.kpi .kpi-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: .03em;
  color: var(--text-2);
  text-transform: uppercase;
}

.kpi .kpi-label svg { width: 15px; height: 15px; color: var(--text-3); }

.kpi .kpi-value {
  margin-top: 8px;
  font-family: var(--font-display);
  font-size: 34px;
  font-weight: 700;
  line-height: 1;
}

.kpi .kpi-meta { margin-top: 10px; font-size: 12.5px; color: var(--text-2); }

.kpi-units { display: flex; gap: 18px; margin-top: 8px; }

.kpi-units .ku {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.kpi-units .ku .ku-num {
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 700;
  line-height: 1.1;
}

.kpi-units .ku .ku-label { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--text-2); }
.kpi-units .ku .dot { width: 8px; height: 8px; border-radius: 50%; }
.kpi-units .ku.geral .ku-num { color: var(--green); }
.kpi-units .ku.geral .dot { background: var(--green); }
.kpi-units .ku.cirurgica .ku-num { color: var(--blue); }
.kpi-units .ku.cirurgica .dot { background: var(--blue); }
.kpi-units .ku-sep { width: 1px; background: var(--line); }

.chart-grid {
  display: grid;
  grid-template-columns: 1.9fr 1fr;
  gap: 18px;
}

.chart-card { padding: 20px 21px; }

.chart-card .chart-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.chart-card .chart-title {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 650;
  margin-bottom: 3px;
}

.chart-card .chart-sub { font-size: 12.5px; color: var(--text-2); margin-bottom: 16px; }

.chart-card .chart-range {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-2);
  white-space: nowrap;
  letter-spacing: .01em;
}

.chart-box { position: relative; height: 300px; }
.chart-box.tall { height: 430px; }
.chart-box.donut { height: 270px; }

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

.chart-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 13.5px;
  color: var(--text-3);
}

/* ----------------------------------------------------------------------------
   13. Relatório (documento) — medidas em pt, proporção idêntica ao Figma/A4.
       Na tela, 595pt ≈ 793px: um documento confortável e fiel.
---------------------------------------------------------------------------- */
.report-stage {
  display: flex;
  justify-content: center;
  margin-top: 6px;
}

.report-scroll { overflow-x: auto; max-width: 100%; padding-bottom: 8px; }

.report {
  width: 595pt;
  min-height: 842pt;
  padding: 28pt;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 4px;
  box-shadow: var(--shadow-2);
  font-family: var(--font-display);
  color: #000;
}

.report * { box-sizing: border-box; }

/* Cabeçalho institucional */
.rep-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16pt;
  border-top: .75pt solid #d9dde2;
  padding-top: 6pt;
}

.rep-head img { width: 347pt; height: auto; }

.rep-doc-id { text-align: left; font-family: var(--font-ui); font-size: 8pt; line-height: 1.45; }
.rep-doc-id .l1 strong { font-weight: 500; color: #000; }
.rep-doc-id .muted-id { color: #919fb3; }

/* Título */
.rep-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-top: 16pt;
  padding-bottom: 10pt;
}

.rep-title h1 { font-size: 26pt; font-weight: 700; letter-spacing: .01em; line-height: 1; font-family: var(--font-display); }
.rep-title .rep-sub { margin-top: 4pt; font-size: 10pt; color: #767676; }

.rep-unit { text-align: right; }
.rep-unit .rep-unit-name { font-size: 18pt; font-weight: 600; line-height: 1.1; }
.rep-unit .rep-datetime { margin-top: 7pt; font-size: 11pt; color: #767676; letter-spacing: .05em; white-space: pre; }

/* Categorias sinalizadas */
.rep-cats { margin-top: 12pt; }

.rep-cat { margin-bottom: 11pt; }

.rep-cat .rep-cat-label {
  font-size: 9pt;
  font-weight: 500;
  letter-spacing: .01em;
  margin-bottom: 4pt;
}

.rep-beds { display: flex; flex-wrap: wrap; gap: 5pt 8.9pt; }

.rep-bed {
  display: grid;
  place-items: center;
  width: 16.8pt;
  height: 12.4pt;
  border-radius: 2pt;
  background: var(--accent, #29323b);
  color: #fff;
  font-size: 7pt;
  font-weight: 600;
  line-height: 1;
}

.rep-cat-note {
  margin-top: 5pt;
  padding: 4pt 6pt;
  background: #f3f4f6;
  border-radius: 2pt;
  font-size: 8pt;
  color: #364153;
  line-height: 1.5;
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* Categorias não sinalizadas */
.rep-not-flagged { margin-top: 16pt; }

.rep-not-flagged p {
  font-size: 9pt;
  font-weight: 500;
  color: #99a1af;
  margin-bottom: 8pt;
}

.rep-not-flagged p span { font-weight: 300; }

/* Nota da reunião */
.rep-note-block { margin-top: 18pt; }

.rep-note-block .rep-note-label { font-size: 11pt; font-weight: 400; margin-bottom: 7pt; }

.rep-note-box {
  border: 1.5pt solid var(--accent, #29323b);
  border-radius: 2pt;
  padding: 7pt 9pt;
  min-height: 46pt;
  font-size: 9pt;
  line-height: 12pt;
  color: #364153;
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* Assinaturas / equipe */
.rep-team {
  display: flex;
  justify-content: space-between;
  gap: 20pt;
  margin-top: 42pt;
}

.rep-team .rep-sign { width: 152.7pt; text-align: center; }

.rep-sign .rep-sign-names {
  font-size: 7pt;
  font-weight: 500;
  letter-spacing: .05em;
  color: #767676;
  padding-bottom: 3pt;
  border-bottom: .75pt solid #6a737d;
  min-height: 12pt;
}

.rep-sign .rep-sign-role {
  margin-top: 3pt;
  font-size: 5pt;
  font-weight: 500;
  letter-spacing: .05em;
  color: #000;
}

/* Aviso de huddle cancelado sobre o relatório */
.report-cancel-banner {
  width: 595pt;
  max-width: 100%;
  margin: 0 auto 14px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 13px 16px;
  background: var(--danger-soft);
  border: 1px solid var(--danger-line);
  border-radius: var(--r-md);
  color: var(--danger-dark);
  font-size: 13.5px;
}

.report-cancel-banner svg { width: 17px; height: 17px; flex: none; margin-top: 1px; }
.report-cancel-banner strong { font-weight: 650; }

/* ----------------------------------------------------------------------------
   14. Modais
---------------------------------------------------------------------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15, 23, 42, .52);
  backdrop-filter: blur(3px);
  animation: fadeIn .16s ease;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  width: min(442px, 100%);
  background: var(--surface);
  border-radius: 18px;
  box-shadow: var(--shadow-3);
  padding: 26px;
  animation: modalUp .24s cubic-bezier(.2, .85, .3, 1.08);
}

@keyframes modalUp {
  from { opacity: 0; transform: translateY(16px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal .modal-icon {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  margin-bottom: 16px;
}

.modal .modal-icon svg { width: 24px; height: 24px; }
.modal .modal-icon.danger { background: var(--danger-soft); color: var(--danger); }
.modal .modal-icon.warn   { background: #fdf6e8; color: #b07c10; }

.modal h3 { font-size: 18px; font-weight: 700; margin-bottom: 7px; }
.modal .modal-text { font-size: 13.5px; color: var(--text-2); line-height: 1.55; }

.modal .modal-body { margin-top: 16px; }

.modal .char-hint { margin-top: 6px; font-size: 12px; color: var(--text-3); }
.modal .char-hint.ok { color: var(--green-dark); }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
}

/* Modal de sucesso (huddle salvo) */
.success-modal { text-align: center; }

.success-modal .check-wrap { margin: 4px auto 18px; width: 84px; height: 84px; }

.success-modal svg.checkmark { width: 84px; height: 84px; }

.checkmark .check-circle {
  stroke: var(--accent, var(--green));
  stroke-width: 2.4;
  fill: none;
  stroke-dasharray: 166;
  stroke-dashoffset: 166;
  animation: checkStroke .55s cubic-bezier(.65, 0, .45, 1) forwards;
}

.checkmark .check-mark {
  stroke: var(--accent, var(--green));
  stroke-width: 3.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  stroke-dasharray: 36;
  stroke-dashoffset: 36;
  animation: checkStroke .38s cubic-bezier(.65, 0, .45, 1) .5s forwards;
}

@keyframes checkStroke { to { stroke-dashoffset: 0; } }

.success-modal h3 { font-size: 21px; }
.success-modal .modal-text { margin-top: 6px; }

.success-modal .modal-actions { justify-content: center; flex-wrap: wrap; margin-top: 24px; }

/* ----------------------------------------------------------------------------
   15. Toasts
---------------------------------------------------------------------------- */
.toast-stack {
  position: fixed;
  top: calc(var(--header-h) + 14px);
  right: 20px;
  z-index: 95;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 270px;
  max-width: 380px;
  padding: 13px 15px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3.5px solid var(--green);
  border-radius: 12px;
  box-shadow: var(--shadow-2);
  font-size: 13.5px;
  pointer-events: auto;
  animation: toastIn .24s cubic-bezier(.2, .85, .3, 1.05);
}

.toast.leaving { animation: toastOut .25s ease forwards; }

.toast svg { width: 17px; height: 17px; flex: none; margin-top: 1px; color: var(--green-dark); }
.toast.error { border-left-color: var(--danger); }
.toast.error svg { color: var(--danger); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(18px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
  to { opacity: 0; transform: translateX(18px); }
}

/* ----------------------------------------------------------------------------
   16. Estado vazio
---------------------------------------------------------------------------- */
.empty-state {
  padding: 58px 24px;
  text-align: center;
}

.empty-state .empty-icon {
  width: 58px;
  height: 58px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: #eef2f2;
  display: grid;
  place-items: center;
  color: var(--text-3);
}

.empty-state .empty-icon svg { width: 26px; height: 26px; }
.empty-state h3 { font-size: 16px; font-weight: 650; }
.empty-state p { margin: 6px auto 18px; font-size: 13.5px; color: var(--text-2); max-width: 380px; }

/* ----------------------------------------------------------------------------
   17. Responsivo
---------------------------------------------------------------------------- */
@media (max-width: 1024px) {
  .chart-grid { grid-template-columns: 1fr; }
  .cat-grid { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .main-nav, .user-box { display: none; }
  .nav-toggle { display: inline-flex; }
  .app-header .container { gap: 12px; }
  .brand img { height: 26px; }

  .kpi-grid { grid-template-columns: 1fr; gap: 13px; }
  .unit-grid { grid-template-columns: 1fr; }
  .team-grid { grid-template-columns: 1fr; }

  .page-head { margin: 22px 0 16px; }
  .page-head h1 { font-size: 20px; }

  /* listagem vira cards */
  .table-card { display: none; }
  .huddle-cards { display: grid; gap: 13px; }

  .filters-bar .field { flex: 1 1 140px; min-width: 0; }
  .filters-actions { margin-left: 0; width: 100%; justify-content: stretch; }
  .filters-actions .btn, .filters-actions .toggle-cancelled { flex: 1; justify-content: center; }

  .doc-title-row, .doc-top, .huddle-form-body { padding-left: 16px; padding-right: 16px; }
  .doc-top { flex-direction: column; align-items: flex-start; gap: 7px; }
  .doc-top .doc-code { text-align: left; }
  .doc-title h1 { font-size: 23px; }
  .doc-unit { text-align: left; }
  .doc-datetime { justify-content: flex-start; flex-wrap: wrap; }

  .bed-chip span { min-width: 46px; height: 44px; }

  .form-actions { flex-direction: column-reverse; }
  .form-actions .btn { width: 100%; }

  .toast-stack { left: 16px; right: 16px; }
  .toast { max-width: none; min-width: 0; width: 100%; }

  .container { padding: 0 16px; }
}

/* Card individual da listagem mobile */
.hcard { padding: 16px; }

.hcard.cancelled { box-shadow: inset 3.5px 0 0 var(--danger); background: rgba(206, 64, 54, .018); }

.hcard .hcard-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.hcard .hcard-date { font-family: var(--font-display); font-weight: 700; font-size: 16.5px; }
.hcard .hcard-by { margin-top: 12px; margin-bottom: 6px; color: var(--text-2); }
.hcard .hcard-by strong { color: var(--text); font-weight: 600; }

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

/* ----------------------------------------------------------------------------
   18. Impressão — esconda tudo que não é documento (regra geral).
       O CSS fino da impressão do relatório vive em print.css.
---------------------------------------------------------------------------- */
@media print {
  .app-header, .mobile-panel, .page-head, .toast-stack, .no-print { display: none !important; }
  body { background: #fff; }
}
