/* ============================================================
   app.css — ClinicaBO3 Application Interface
   Modern Slate & Calm Aesthetic (Zero Visual Fatigue)
   ============================================================ */

/* --- Layout Estrutural --- */
.app-container {
  display: flex;
  min-height: 100vh;
  background-color: var(--bg);
}

/* --- Sidebar Lateral --- */
.sidebar {
  width: 240px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  flex-shrink: 0;
  transition: width 0.18s ease-in-out;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 40;
}

/* Estado Colapsado da Sidebar */
.sidebar.collapsed {
  width: 64px;
}

.sidebar-header {
  padding: var(--s3) var(--s4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 58px;
  border-bottom: 1px solid var(--border-subtle);
}

.sidebar.collapsed .sidebar-header {
  justify-content: center;
  padding: var(--s3) var(--s2);
}

/* Wrapper real entre .sidebar-header e .sidebar-nav: é ESTE o filho flex
   directo de .sidebar (o .sidebar-nav é neto, não filho — por isso o
   flex:1/min-height:0 dele sozinho nunca fazia efeito nenhum, ficava sempre
   do tamanho do conteúdo e empurrava o rodapé para fora do ecrã). */
.sidebar-scroll-wrap {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.brand-link {
  display: flex;
  align-items: center;
  gap: var(--s2);
  text-decoration: none;
  color: var(--ink);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  overflow: hidden;
  white-space: nowrap;
}

.sidebar.collapsed .brand-text {
  display: none;
}

.brand-icon {
  width: 28px;
  height: 28px;
  background: var(--brand);
  color: var(--ink-inverted);
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  flex-shrink: 0;
}

/* --- Navegação da Sidebar --- */
.sidebar-nav {
  flex: 1;
  min-height: 0; /* flex item com overflow precisa disto para encolher e fazer scroll — sem isto o menu cresce para fora do ecrã em vez de deslizar */
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--s3) var(--s2);
  display: flex;
  flex-direction: column;
  gap: var(--s4);
}

.sidebar.collapsed .sidebar-nav {
  padding: var(--s3) var(--s1);
  gap: var(--s3);
}

.nav-section-title {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-faint);
  padding: 0 var(--s3);
  margin-bottom: var(--s1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar.collapsed .nav-section-title {
  display: none;
}

.nav-item-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item-link {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s2) var(--s3);
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  border-radius: var(--r-sm);
  transition: background-color 0.12s ease, color 0.12s ease;
  position: relative;
  min-height: 38px;
}

.sidebar.collapsed .nav-item-link {
  justify-content: center;
  padding: var(--s2) 0;
}

.nav-item-link:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.nav-item-link.active {
  background: var(--brand-light);
  color: var(--brand);
  font-weight: 600;
}

.nav-item-link.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 3px;
  background: var(--brand);
  border-radius: 0 2px 2px 0;
}

.sidebar.collapsed .nav-item-link.active::before {
  left: 2px;
}

.nav-item-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  color: inherit;
  flex-shrink: 0;
}

.nav-item-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.sidebar.collapsed .nav-item-label {
  display: none;
}

/* Tooltip flutuante no modo colapsado */
.sidebar.collapsed .nav-item-link {
  position: relative;
}

.sidebar.collapsed .nav-item-link:hover::after {
  content: attr(data-title);
  position: absolute;
  left: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--ink);
  color: var(--ink-inverted);
  padding: 4px 10px;
  border-radius: var(--r-sm);
  font-size: 0.78rem;
  font-weight: 500;
  white-space: nowrap;
  z-index: 100;
  box-shadow: var(--shadow-md);
  pointer-events: none;
}

/* --- Rodapé da Sidebar & Botão de Colapso --- */
.sidebar-footer {
  padding: var(--s2);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: var(--s1);
}

.collapse-btn {
  display: flex;
  align-items: center;
  gap: var(--s3);
  width: 100%;
  padding: var(--s2) var(--s3);
  background: transparent;
  border: none;
  border-radius: var(--r-sm);
  color: var(--ink-soft);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 500;
  transition: background-color 0.12s ease, color 0.12s ease;
}

.sidebar.collapsed .collapse-btn {
  justify-content: center;
  padding: var(--s2) 0;
}

.collapse-btn:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.sidebar.collapsed .collapse-btn-text {
  display: none;
}

/* --- Área Principal & Header --- */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.top-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: var(--s2) var(--s5);
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 58px;
  position: sticky;
  top: 0;
  z-index: 30;
}

.top-bar-left {
  display: flex;
  align-items: center;
  gap: var(--s3);
}

.top-bar-right {
  display: flex;
  align-items: center;
  gap: var(--s4);
}

.mobile-menu-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: var(--s1);
  color: var(--ink);
  cursor: pointer;
}

@media (min-width: 1024px) {
  .mobile-menu-toggle {
    display: none;
  }
}

/* Entrada que muda de modo, no fundo do menu (#145) */
.nav-item-modo {
  width: 100%;
  border: 1px solid var(--border);
  background: transparent;
  font-family: inherit;
  cursor: pointer;
  margin-top: var(--s3);
}

/* Separadores no topo das páginas agrupadas (#145) */
.page-tabs {
  display: flex;
  gap: var(--s1);
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--s4);
}

.page-tabs a {
  padding: var(--s2) var(--s3);
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.page-tabs a:hover {
  color: var(--ink);
}

.page-tabs a[aria-current="page"] {
  color: var(--brand);
  font-weight: 600;
  border-bottom-color: var(--brand);
}

/* User Profile Badge */
.user-profile {
  display: flex;
  align-items: center;
  gap: var(--s2);
}

.user-avatar-small {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--brand);
  font-weight: 700;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* --- Conteúdo da Página (Page Canvas) --- */
.page-content {
  padding: var(--s5);
  max-width: var(--maxw);
  width: 100%;
  margin: 0 auto;
}

@media (min-width: 1024px) {
  .page-content {
    padding: var(--s6);
  }
}

/* --- Cards e Superfícies --- */
.card, .card-clean {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: var(--s5);
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--s4);
}

.card-header, .card-clean-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--s4);
  padding-bottom: var(--s2);
  border-bottom: 1px solid var(--surface-2);
}

.card-title, .card-clean-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.01em;
}

/* Stat Cards Arejados */
.kpi-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--s4);
  margin-bottom: var(--s5);
}

@media (min-width: 768px) {
  .kpi-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: var(--s4) var(--s5);
  box-shadow: var(--shadow-sm);
}

.kpi-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: var(--s1);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.kpi-value {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.02em;
}

.kpi-subtext {
  font-size: 0.8rem;
  color: var(--ink-faint);
  margin-top: var(--s1);
}

/* --- Formulários & Inputs --- */
.form-group {
  margin-bottom: var(--s4);
  text-align: left;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: var(--s1);
  color: var(--ink);
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: var(--s2) var(--s3);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink);
  min-height: 40px;
  font-size: 0.9rem;
  font-family: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.15);
}

/* --- Botões --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  padding: var(--s2) var(--s4);
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  min-height: 40px;
  font-family: inherit;
  transition: all 0.12s ease;
}

.btn-primary {
  background: var(--brand);
  color: var(--ink-inverted);
  border-color: var(--brand);
}

.btn-primary:hover {
  background: var(--brand-hover);
  border-color: var(--brand-hover);
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--ink);
  border-color: var(--border);
}

.btn-secondary:hover {
  background: var(--surface-3);
}

.btn-ghost {
  background: transparent;
  border: 1px solid transparent;
  color: var(--ink-soft);
  padding: var(--s1) var(--s3);
  font-size: 0.82rem;
  font-weight: 500;
  border-radius: var(--r-sm);
  cursor: pointer;
  text-decoration: none;
  min-height: auto;
}

.btn-ghost:hover {
  background: var(--surface-2);
  color: var(--ink);
}

/* --- Alertas & Mensagens Flash --- */
.alert {
  padding: var(--s3) var(--s4);
  border-radius: var(--r-sm);
  margin-bottom: var(--s4);
  font-size: 0.88rem;
  display: flex;
  align-items: center;
  gap: var(--s2);
}

.alert-success { background: var(--ok-bg); border: 1px solid var(--ok-border); color: var(--ok); }
.alert-warning { background: var(--warn-bg); border: 1px solid var(--warn-border); color: var(--warn); }
.alert-error   { background: var(--err-bg); border: 1px solid var(--err-border); color: var(--err); }
.alert-info    { background: var(--brand-light); border: 1px solid var(--brand-border); color: var(--brand); }
.alert > span { flex: 1; }
.alert-fechar {
  background: none; border: 0; color: inherit; cursor: pointer;
  font-size: 1.2rem; line-height: 1; padding: 0 var(--s1); min-width: 32px; min-height: 32px;
  opacity: 0.7;
}
.alert-fechar:hover { opacity: 1; }
.alert.alert-a-sair { opacity: 0; transition: opacity 0.4s ease; }

/* --- Mobile Bottom Nav --- */
:root { --bottom-nav-h: 53px; } /* 44px do item + 2×4px de padding + 1px de borda; usada também por .paybar */
.mobile-bottom-nav {
  display: flex;
  box-sizing: border-box;
  height: var(--bottom-nav-h);
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 40;
  justify-content: space-around;
  padding: var(--s1) 0;
  box-shadow: 0 -2px 8px rgba(15, 23, 42, 0.04);
}

@media (min-width: 1024px) {
  .mobile-bottom-nav {
    display: none;
  }
}

.mobile-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 0.72rem;
  font-weight: 500;
  padding: var(--s1) var(--s2);
  min-width: 60px;
  min-height: 44px;
}

.mobile-nav-item.active {
  color: var(--brand);
  font-weight: 700;
}

.mobile-nav-icon {
  font-size: 1.1rem;
  margin-bottom: 2px;
}

/* Badges ao vivo — mensagens não lidas (sidebar + bottom nav mobile) */
.nav-item-badge {
  position: absolute;
  top: 4px;
  right: 8px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: var(--r-full);
  background: var(--ok);
  color: var(--brand-fg);
  font-size: 0.62rem;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  letter-spacing: -0.01em;
  display: none;
}

.sidebar.collapsed .nav-item-badge {
  right: 6px;
  top: 2px;
}

.mobile-nav-item {
  position: relative;
}

.mobile-nav-badge {
  position: absolute;
  top: 2px;
  right: 4px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: var(--r-full);
  background: var(--ok);
  color: var(--brand-fg);
  font-size: 0.62rem;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  letter-spacing: -0.01em;
  display: none;
}

.nav-item-badge.visible,
.mobile-nav-badge.visible {
  display: inline-block;
}

/* Responsividade Mobile Drawer */
@media (max-width: 1023px) {
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: -260px;
    width: 260px !important;
    transition: left 0.22s ease-in-out;
    box-shadow: 2px 0 16px rgba(15, 23, 42, 0.1);
  }

  .sidebar.mobile-open {
    left: 0;
  }

  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.35);
    backdrop-filter: blur(2px);
    z-index: 35;
  }

  .sidebar-backdrop.active {
    display: block;
  }
}

@media (min-width: 1024px) {
  .sidebar-backdrop {
    display: none !important;
  }
}

/* Abas sem JS (radio-driven) — usadas em /minha-disponibilidade */
.disp-tab-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.disp-tabs-nav {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s1);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--s4);
}

.disp-tab-label {
  cursor: pointer;
  padding: var(--s2) var(--s3);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-soft);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.disp-tab-panel {
  display: none;
}

#disp-tab-regular:checked ~ .disp-tabs-panels [data-panel="regular"],
#disp-tab-excecoes:checked ~ .disp-tabs-panels [data-panel="excecoes"],
#disp-tab-bloqueios:checked ~ .disp-tabs-panels [data-panel="bloqueios"] {
  display: block;
}

#disp-tab-regular:checked ~ .disp-tabs-nav label[for="disp-tab-regular"],
#disp-tab-excecoes:checked ~ .disp-tabs-nav label[for="disp-tab-excecoes"],
#disp-tab-bloqueios:checked ~ .disp-tabs-nav label[for="disp-tab-bloqueios"] {
  color: var(--brand);
  border-bottom-color: var(--brand);
}

#disp-tab-regular:focus-visible ~ .disp-tabs-nav label[for="disp-tab-regular"],
#disp-tab-excecoes:focus-visible ~ .disp-tabs-nav label[for="disp-tab-excecoes"],
#disp-tab-bloqueios:focus-visible ~ .disp-tabs-nav label[for="disp-tab-bloqueios"] {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

.disp-add-details {
  margin-top: var(--s2);
  border-top: 1px solid var(--border-subtle);
  padding-top: var(--s3);
}

.disp-add-summary {
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--brand);
}

/* Utilitários */
.text-muted { color: var(--ink-soft); }
.text-faint { color: var(--ink-faint); }
.font-mono { font-family: var(--font-mono); }

/* --- Conversas fullscreen (Inbox e Minhas Mensagens) --- */
.inbv2 { display: flex; flex: 1; min-height: 0; flex-direction: column; gap: var(--s2); overflow: hidden; }
.inbv2-hdr { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.inbv2-hdr-meta { flex: 1; min-width: 0; }
.inbv2-hdr-name { color: var(--ink); font-size: 1rem; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inbv2-hdr-sub { color: var(--ink-faint); font-size: .72rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inbv2-actions { display: flex; gap: var(--s2); flex-wrap: wrap; }
.inbv2-body { position: relative; display: flex; flex: 1; min-height: 0; overflow: hidden; border: 1px solid var(--border); border-radius: var(--r); background: var(--surface); }
.inbv2-chat { position: relative; display: flex; flex: 1; min-width: 0; min-height: 0; flex-direction: column; }
.inbv2-msgs { display: flex; flex: 1; min-width: 0; min-height: 0; flex-direction: column; gap: var(--s3); overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; padding: var(--s4); }
.inbv2-bubble-wrap { display: flex; min-width: 0; flex-shrink: 0; flex-direction: column; }
.inbv2-bubble { max-width: 78%; overflow-wrap: anywhere; white-space: pre-wrap; }
.inbv2-compose { display: flex; flex-shrink: 0; align-items: flex-end; gap: var(--s2); border-top: 1px solid var(--border); padding: var(--s3); background: var(--surface); }
.inbv2-compose textarea { flex: 1; min-width: 0; min-height: 44px; max-height: calc(1.45em * 5 + var(--s4)); resize: none; overflow-y: auto; }
.inbv2-unread { position: absolute; bottom: 68px; left: 50%; z-index: 10; display: none; transform: translateX(-50%); border: 0; border-radius: var(--r-full); background: var(--brand); box-shadow: var(--shadow-md); color: var(--ink-inverted); cursor: pointer; font-size: .75rem; font-weight: 700; padding: var(--s1) var(--s3); white-space: nowrap; }
.inbv2-panel { width: 300px; flex-shrink: 0; overflow-y: auto; border-left: 1px solid var(--border); background: var(--surface); }
.inbv2-panel-inner { display: flex; flex-direction: column; gap: var(--s3); padding: var(--s3); }
.inbv2-panel-drag, .inbv2-panel-toggle, .inbv2-overlay { display: none; }

/* Lista de conversas (Inbox e Minhas Mensagens): itens touch-friendly */
.inbv2-filter-legacy { display: none; }
.inbv2-conv-item { display: flex; align-items: stretch; border-bottom: 1px solid var(--surface-2); transition: background .12s ease; }
.inbv2-conv-item:hover { background: var(--surface-2); }
.inbv2-conv-link { display: flex; align-items: center; justify-content: space-between; padding: .75rem 1rem; text-decoration: none; flex: 1; min-width: 0; gap: .75rem; }
.inbv2-conv-avatar { width: 44px; height: 44px; border-radius: 50%; background: rgba(13,148,136,.1); color: var(--brand); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 1.1rem; flex-shrink: 0; }
.inbv2-conv-body { min-width: 0; flex: 1; }
.inbv2-conv-name { font-weight: 700; color: var(--ink); font-size: .92rem; margin-bottom: 2px; display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.inbv2-conv-preview { font-size: .82rem; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inbv2-conv-meta { flex-shrink: 0; text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }

body.inbox-fs { height: var(--inbox-viewport-height, 100dvh); min-height: 0; overflow: hidden; }
body.inbox-fs .app-container { height: 100%; min-height: 0; overflow: hidden; }
body.inbox-fs .main-wrapper { min-height: 0; overflow: hidden; }
body.inbox-fs .page-content { display: flex; flex: 1; min-height: 0; flex-direction: column; overflow: hidden; }

@media (max-width: 1023px) {
  body.inbox-fs .mobile-bottom-nav { display: none; }
  body.inbox-fs .page-content { padding-bottom: max(var(--s3), env(safe-area-inset-bottom)); }
}

@media (max-width: 1023px) {
  body.inbox-fs .page-content { padding: var(--s3); padding-bottom: max(var(--s3), env(safe-area-inset-bottom)); }
  .inbv2-actions.inbv2-actions-in-panel { flex-direction: column; padding-bottom: var(--s2); border-bottom: 1px solid var(--border-subtle); }
  .inbv2-panel { position: fixed; inset: auto 0 0; z-index: 200; width: 100%; max-height: min(80dvh, 80%); transform: translateY(100%); transition: transform .25s cubic-bezier(.4,0,.2,1); border-top: 2px solid var(--border); border-left: 0; border-radius: var(--r-lg) var(--r-lg) 0 0; box-shadow: 0 -4px 32px rgba(15,23,42,.15); }
  .inbv2-panel.open { transform: translateY(0); }
  .inbv2-overlay { position: fixed; inset: 0; z-index: 199; background: rgba(15,23,42,.4); }
  .inbv2-overlay.open { display: block; }
  .inbv2-panel-toggle { display: flex; }
  .inbv2-panel-drag { display: flex; flex-shrink: 0; justify-content: center; padding: var(--s3) 0 var(--s1); cursor: pointer; }
  .inbv2-panel-drag span { display: block; width: 40px; height: 4px; border-radius: var(--r-xs); background: var(--border); }
  .inbv2-bubble { max-width: 88%; }
}

@media (min-width: 768px) {
  .inbv2-msgs { min-height: 300px; }
}

/* ==========================================================================
   /locais — lista de locais (só activos visíveis; inactivos agrupados)
   Mobile-first: tabela em ecrãs largos, cartões empilhados abaixo de 768px
   (mesma quebra do .marc-table/.marc-cards de crm/clientes/show.php).
   ========================================================================== */
.loc-criar-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)) 120px;
  gap: var(--s3);
  align-items: flex-end;
}

/* minmax(200px,1fr)+120px dá 332px de min-content: abaixo de 768px empilha,
   senão o cartão puxa a página para ~406px e obriga a scroll num telemóvel. */
@media (max-width: 767px) {
  .loc-criar-form { grid-template-columns: 1fr; }
}

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

.loc-list-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.88rem;
}
.loc-list-table td { padding: var(--s3); }
.loc-list-table td.tac { text-align: center; }
.loc-list-table td.tar { text-align: right; white-space: nowrap; }
.loc-list-table tbody tr { border-bottom: 1px solid var(--surface-2); }
.loc-list-table td.tar form { display: inline-block; }

@media (max-width: 767px) {
  .loc-list-table { display: block; }
  .loc-list-table thead { display: none; }
  .loc-list-table tbody { display: block; }
  .loc-list-table tbody tr {
    display: block;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    padding: var(--s2) var(--s3);
    margin-bottom: var(--s3);
    white-space: normal;
  }
  .loc-list-table tbody tr:last-child { margin-bottom: 0; }
  .loc-list-table td,
  .loc-list-table td.tac,
  .loc-list-table td.tar {
    display: block;
    width: 100%;
    box-sizing: border-box;
    padding: var(--s2) 0;
    text-align: left;
    white-space: normal;
    border-bottom: 1px solid var(--border);
  }
  .loc-list-table td:last-child { border-bottom: none; }
  .loc-list-table td::before {
    content: attr(data-label);
    display: block;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--ink-faint);
    margin-bottom: 2px;
  }
  .loc-list-table td.tar form { margin-right: var(--s2); }
  .loc-list-table td .btn-ghost { min-height: 44px; padding: 0 var(--s3); }
}

/* Agrupamento dos inactivos — <details> colapsado por omissão. */
.loc-inactivos {
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--surface);
  margin-top: var(--s4);
  overflow: hidden;
}
.loc-inactivos > summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--s3);
  padding: var(--s3) var(--s4);
  min-height: 44px;
  box-sizing: border-box;
  background: var(--surface-2);
  font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
  list-style: none;
  user-select: none;
  -webkit-user-select: none;
}
.loc-inactivos > summary::-webkit-details-marker { display: none; }
.loc-inactivos > summary::marker { content: ""; }
.loc-chv {
  font-size: 0.6rem;
  opacity: 0.35;
  flex-shrink: 0;
  margin-left: 0.5rem;
  display: inline-block;
  transition: transform 0.15s;
}
.loc-inactivos[open] .loc-chv { transform: rotate(180deg); }
.loc-inactivos .loc-table-wrap {
  border-top: 1px solid var(--border);
  padding: 0 var(--s3) var(--s3);
}

/* Ficha da Sessão — bloco do cliente e pagamento */
.fs-cliente-cab { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; margin-bottom: .6rem; }
.fs-titulo { margin: 0; font-size: .95rem; color: var(--ink); }
.fs-contagem { font-size: .75rem; color: var(--ink-soft); white-space: nowrap; }
.fs-campos { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .6rem; }
.fs-campo { display: flex; flex-direction: column; gap: .25rem; }
.fs-campo-topo { display: flex; justify-content: space-between; align-items: center; font-size: .78rem; color: var(--ink-soft); }
.fs-chip { font-size: .66rem; padding: 1px 6px; border-radius: 99px; font-weight: 600; border: 1px solid var(--border); background: var(--surface-2); color: var(--ink-soft); }
.fs-campo[data-estado="ok"] .fs-chip { background: var(--ok-bg); color: var(--ok); border-color: var(--ok-border); }
.fs-campo[data-estado="falta"] .fs-chip { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-border); }
.fs-campo[data-estado="falta"] input, .fs-campo[data-estado="falta"] select { border-color: var(--warn-border); background: var(--warn-bg); }
.fs-estado { font-size: .72rem; color: var(--ink-faint); min-height: 0; }
.fs-campo input, .fs-campo select { font-size: 16px; min-height: 44px; }
.fs-pilula { align-self: flex-start; font-size: .78rem; min-height: 36px; padding: 8px 14px; border-radius: 99px; border: 1px solid var(--border); background: var(--surface); color: var(--ink-soft); cursor: pointer; }
.fs-dialog { border: 1px solid var(--border); border-radius: var(--r-sm); padding: 1rem; max-width: 360px; width: 90vw; }
.fs-dialog > * + * { margin-top: .6rem; }
.fs-dialog-botoes { display: flex; justify-content: flex-end; gap: .5rem; }
.fs-pag-ok { color: var(--ok); font-weight: 600; font-size: .82rem; margin-bottom: .4rem; }
.fs-pag-falta { color: var(--warn); font-weight: 600; font-size: .82rem; margin-bottom: .4rem; }
.fs-pag-linha { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-bottom: .6rem; }
.fs-pag-linha input { max-width: 120px; }
.paybar { display: none; }
@media (max-width: 820px) {
  .fs-pag-form { display: none; }
  .paybar { display: flex; position: sticky; bottom: var(--bottom-nav-h); gap: .5rem; align-items: center; padding: .6rem 1rem; background: var(--surface); border-top: 1px solid var(--border); }
  .paybar input { width: 76px; flex: 0 0 auto; }
  .paybar select { flex: 1 1 auto; min-width: 0; }
  .paybar input, .paybar select, .paybar .btn { height: 44px; min-height: 44px; font-size: 16px; }
  .paybar .btn { white-space: nowrap; flex: 0 0 auto; padding: 0 .9rem; }
}

/* Ajuda (#3): por tarefas, tudo à vista. Títulos grandes, passos numerados,
   um botão por tarefa e muito espaço entre tarefas (pedido do dono). */
.ajuda { max-width: 42rem; }
.ajuda-titulo { font-size: 2rem; font-weight: 700; color: var(--ink); letter-spacing: -0.02em; margin: 0 0 var(--s4); }
.ajuda-busca { width: 100%; font-size: 1.1rem; padding: var(--s3) var(--s4); margin-bottom: var(--s8); }
.ajuda-vazio { color: var(--ink-soft); font-size: 1.05rem; }
.ajuda-grupo { margin-bottom: var(--s8); }
.ajuda-grupo > h2 { font-size: 1.85rem; font-weight: 700; color: var(--brand); margin: 0 0 var(--s4); padding-bottom: var(--s2); border-bottom: 2px solid var(--brand-border); }
.ajuda-tarefa { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--s5); margin-bottom: var(--s5); }
.ajuda-tarefa > h3 { font-size: 1.15rem; font-weight: 600; color: var(--ink); margin: 0 0 var(--s4); line-height: 1.3; }
.ajuda-passos { list-style: none; counter-reset: passo; padding: 0; margin: 0 0 var(--s4); display: grid; gap: var(--s4); }
.ajuda-passos > li { counter-increment: passo; display: flex; gap: var(--s3); align-items: baseline; font-size: 1.05rem; line-height: 1.55; color: var(--ink); }
.ajuda-passos > li::before {
  content: counter(passo); flex: none; width: 1.8rem; height: 1.8rem; border-radius: var(--r-full);
  display: inline-grid; place-items: center; font-size: 0.95rem; font-weight: 700;
  background: var(--brand-light); color: var(--brand); border: 1px solid var(--brand-border);
}
.ajuda-nota { margin: 0 0 var(--s4); padding: var(--s3) var(--s4); border-left: 4px solid var(--warn-border); background: var(--warn-bg); color: var(--ink); border-radius: var(--r-xs); font-size: 1rem; line-height: 1.55; }
.ajuda-tarefa > :last-child { margin-bottom: 0; }

/* Régua do dia no painel "Hoje no Espaço" (#146): uma barra por sala */
.regua-escala {
  position: relative;
  height: 1.1rem;
  margin: var(--s1) 0;
  font-size: 0.72rem;
  color: var(--ink-faint);
}

.regua-escala span {
  position: absolute;
  transform: translateX(-50%);
}

.regua {
  position: relative;
  height: 32px;
  background: var(--ok-bg);
  border: 1px solid var(--ok-border);
  border-radius: var(--r-xs);
  margin-bottom: var(--s1);
}

.regua-bloco {
  position: absolute;
  top: 0;
  bottom: 0;
  min-width: 3px;
  padding: 0 var(--s1);
  border: none;
  border-left: 1px solid var(--surface);
  border-radius: var(--r-xs);
  background: var(--brand);
  color: var(--brand-fg);
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}

.regua-bloco.passado {
  background: var(--surface-3);
  color: var(--ink-soft);
}

.regua-bloco.partilhada {
  background: repeating-linear-gradient(45deg, var(--surface-3) 0 6px, var(--surface-2) 6px 12px);
  color: var(--ink-soft);
}

.regua-agora {
  position: absolute;
  top: -4px;
  bottom: -4px;
  width: 2px;
  background: var(--err);
  pointer-events: none;
}

.regua-info {
  min-height: 1.1rem;
  margin-bottom: var(--s2);
  font-size: 0.8rem;
  color: var(--ink-soft);
}
