/* ============================================================
   Área restrita de terapeutas — Espaço Pindorama
   Reaproveita variáveis e tokens definidos em global.css.
   Identidade visual: verde-floresta + areia + brasa.
   ============================================================ */

:root {
  --terap-sidebar-w: 240px;
  --terap-topbar-h: 64px;
}

.terap-body {
  width: 100%;
  max-width: 100%;
  overflow-x: clip;
  min-height: 100vh;
  background:
    radial-gradient(900px 480px at 12% 0%, rgba(102, 180, 143, .14), transparent 60%),
    radial-gradient(700px 400px at 88% 4%, rgba(196, 106, 74, .10), transparent 55%),
    linear-gradient(180deg, var(--bg), #07110E 60%, #050C0A);
}

/* ----------------- Topbar ----------------- */
.terap-topbar {
  position: sticky;
  top: 0;
  z-index: 60;
  background: rgba(14, 28, 23, .82);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  height: var(--terap-topbar-h);
  width: 100%;
  max-width: 100%;
}
.terap-topbar__inner {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  height: 100%;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}
.terap-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  min-width: 0;
}
.terap-brand__logo {
  width: 40px;
  height: 40px;
  object-fit: contain;
}
.terap-brand strong {
  display: block;
  font-size: 14px;
  letter-spacing: .2px;
  overflow-wrap: anywhere;
}
.terap-brand span {
  display: block;
  font-size: 11px;
  color: var(--muted);
}

.terap-topbar__user {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 0 0 auto;
  min-width: 0;
}
.terap-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--leaf), var(--leaf2));
  color: #052015;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  box-shadow: 0 6px 18px rgba(62, 142, 106, .25);
}
.terap-topbar__userMeta {
  line-height: 1.2;
}
.terap-topbar__userMeta strong {
  display: block;
  font-size: 13px;
}
.terap-topbar__userMeta span {
  display: block;
  font-size: 11px;
  color: var(--muted);
}

/* Ações da topbar (Minha senha / Sair): visíveis no desktop; no mobile saem
   do cabeçalho e a saída passa a viver no drawer (ver media query). */
.terap-topbar__act { white-space: nowrap; }

.terap-burger {
  display: none;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(234, 243, 239, .04);
  color: var(--text);
  cursor: pointer;
  padding: 8px;
  flex-direction: column;
  justify-content: space-between;
}
.terap-burger span {
  display: block;
  height: 2px;
  width: 100%;
  background: var(--text);
  border-radius: 2px;
}

/* ----------------- Shell + Sidebar ----------------- */
.terap-shell {
  display: grid;
  grid-template-columns: var(--terap-sidebar-w) 1fr;
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  min-height: calc(100vh - var(--terap-topbar-h));
  min-width: 0;
}

.terap-sidebar {
  border-right: 1px solid var(--line);
  padding: 18px 12px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.terap-sidebar nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.terap-sidebar a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  color: var(--muted);
  font-size: 14px;
  transition: background .15s ease, color .15s ease;
}
.terap-sidebar a:hover {
  background: rgba(234, 243, 239, .06);
  color: var(--text);
}
.terap-sidebar a.is-active {
  background: rgba(102, 180, 143, .14);
  color: var(--text);
  border: 1px solid rgba(102, 180, 143, .25);
}
.terap-nav__icon {
  display: inline-flex;
  width: 22px;
  height: 22px;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  font-size: 13px;
  color: var(--leaf2);
  background: rgba(102, 180, 143, .12);
}
.terap-sidebar__foot {
  margin-top: auto;
  padding: 10px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
/* Sair da conta: ação de encerramento, em tom terroso, com ícone + texto. */
.terap-logout {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border-radius: 12px;
  border: 1px solid rgba(196, 106, 74, .35);
  background: rgba(196, 106, 74, .10);
  color: var(--clay2);
  font-size: 14px;
  font-weight: 600;
  min-height: 44px;
  transition: background .15s ease, border-color .15s ease;
}
.terap-logout:hover { background: rgba(196, 106, 74, .18); border-color: rgba(196, 106, 74, .55); }
.terap-logout:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--focus); }
.terap-logout__ico { flex: 0 0 auto; }
.terap-link {
  color: var(--sand);
  text-decoration: underline;
  font-size: 12px;
}

/* ----------------- Main ----------------- */
.terap-main {
  padding: 28px 28px 64px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}
.terap-page-head {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 22px;
  min-width: 0;
}
.terap-page-head > * {
  min-width: 0;
}
.terap-page-head h1 {
  margin: 0;
  font-size: clamp(22px, 2.3vw, 28px);
  letter-spacing: -.3px;
  overflow-wrap: anywhere;
}
.terap-page-head p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
  max-width: 70ch;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: normal;
}

/* ----------------- Cards / Feed ----------------- */
.terap-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 16px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}
.terap-card {
  background: rgba(19, 45, 38, .62);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: 0 12px 34px rgba(0, 0, 0, .22);
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
}
.terap-card h2,
.terap-card h3 {
  margin: 0 0 8px;
  font-size: 16px;
}
.terap-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}
.terap-span-12 { grid-column: span 12; }
.terap-span-8  { grid-column: span 8;  }
.terap-span-6  { grid-column: span 6;  }
.terap-span-4  { grid-column: span 4;  }
.terap-span-3  { grid-column: span 3;  }

.terap-tag {
  display: inline-flex;
  padding: 5px 9px;
  border-radius: 999px;
  background: rgba(234, 243, 239, .06);
  border: 1px solid rgba(234, 243, 239, .14);
  font-size: 11px;
  color: var(--muted);
}
.terap-tag--leaf { background: rgba(102, 180, 143, .15); border-color: rgba(102, 180, 143, .35); color: var(--leaf2); }
.terap-tag--sand { background: rgba(244, 231, 211, .12); border-color: rgba(244, 231, 211, .25); color: var(--sand); }
.terap-tag--clay { background: rgba(196, 106, 74, .15); border-color: rgba(196, 106, 74, .35); color: var(--clay2); }

/* Feed estilo rede social */
.terap-feed {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.terap-feed__item {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(7, 17, 14, .35);
}
.terap-feed__icon {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  background: rgba(102, 180, 143, .18);
  color: var(--leaf2);
}
.terap-feed__body strong { display: block; font-size: 13px; margin-bottom: 2px; }
.terap-feed__body p { font-size: 13px; color: var(--muted); margin: 2px 0 0; }
.terap-feed__meta { font-size: 11px; color: var(--muted); margin-top: 4px; }

/* Atalhos */
.terap-shortcut {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 18px;
  border-radius: 16px;
  background: linear-gradient(150deg, rgba(102, 180, 143, .14), rgba(196, 106, 74, .08));
  border: 1px solid rgba(102, 180, 143, .25);
  color: var(--text);
  transition: transform .15s ease;
}
.terap-shortcut:hover { transform: translateY(-2px); }
.terap-shortcut strong { font-size: 15px; }
.terap-shortcut span { font-size: 12px; color: var(--muted); }

/* ----------------- Forms / Buttons ----------------- */
.terap-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.terap-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.terap-field label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .8px;
}
.terap-field input,
.terap-field select,
.terap-field textarea {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  background: rgba(7, 17, 14, .55);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  font-size: 14px;
  padding: 10px 12px;
  font-family: inherit;
}
.terap-field input:focus,
.terap-field select:focus,
.terap-field textarea:focus {
  outline: none;
  border-color: rgba(102, 180, 143, .55);
  box-shadow: 0 0 0 4px var(--focus);
}
.terap-field textarea { min-height: 90px; resize: vertical; }
.terap-field--row { flex-direction: row; gap: 12px; }
.terap-field--row > * { flex: 1; min-width: 0; }

.terap-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(234, 243, 239, .06);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  max-width: 100%;
  white-space: normal;
}
.terap-btn:hover { background: rgba(234, 243, 239, .12); }
.terap-btn--primary {
  background: linear-gradient(135deg, var(--leaf), var(--leaf2));
  color: #052015;
  border-color: rgba(102, 180, 143, .35);
  box-shadow: 0 14px 38px rgba(62, 142, 106, .25);
}
.terap-btn--primary:hover { background: linear-gradient(135deg, var(--leaf2), var(--leaf)); }
.terap-btn--ghost {
  background: transparent;
  color: var(--sand);
  border-color: rgba(244, 231, 211, .25);
}
.terap-btn--danger {
  background: rgba(196, 106, 74, .12);
  border-color: rgba(196, 106, 74, .35);
  color: var(--clay2);
}
/* Destaque positivo discreto (ex.: "Realizado") — dentro da paleta verde. */
.terap-btn--ok {
  background: rgba(102, 180, 143, .12);
  border-color: rgba(102, 180, 143, .42);
  color: var(--leaf2);
}
.terap-btn--ok:hover { background: rgba(102, 180, 143, .2); }
.terap-btn--sm { padding: 7px 12px; font-size: 12px; }

/* ----------------- Alerts ----------------- */
.terap-alert {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  font-size: 13px;
  margin-bottom: 14px;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.terap-alert--error   { background: rgba(196, 106, 74, .14); border-color: rgba(196, 106, 74, .35); color: var(--clay2); }
.terap-alert--success { background: rgba(102, 180, 143, .14); border-color: rgba(102, 180, 143, .35); color: var(--leaf2); }
.terap-alert--info    { background: rgba(244, 231, 211, .10); border-color: rgba(244, 231, 211, .25); color: var(--sand); }

/* ----------------- Tabela genérica ----------------- */
.terap-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.terap-table th, .terap-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
.terap-table th {
  font-weight: 600;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .6px;
}
.terap-table tr:hover td { background: rgba(234, 243, 239, .03); }

/* ----------------- Agenda semanal ----------------- */
.terap-week {
  display: grid;
  grid-template-columns: 60px repeat(7, 1fr);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: rgba(7, 17, 14, .35);
}
.terap-week__hourHead, .terap-week__dayHead {
  padding: 10px 8px;
  background: rgba(14, 28, 23, .8);
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .6px;
  text-align: center;
}
.terap-week__dayHead small { display: block; font-size: 11px; color: var(--muted); font-weight: 400; text-transform: none; letter-spacing: 0; }
.terap-week__dayHead.is-today { background: rgba(102, 180, 143, .18); color: var(--text); }
.terap-week__hour {
  padding: 6px 4px;
  border-top: 1px dashed rgba(234, 243, 239, .06);
  text-align: right;
  font-size: 11px;
  color: var(--muted);
}
.terap-week__cell {
  border-top: 1px dashed rgba(234, 243, 239, .06);
  border-left: 1px solid rgba(234, 243, 239, .04);
  min-height: 56px;
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.terap-week__cell--empty {
  align-items: center;
  justify-content: center;
  color: rgba(234, 243, 239, .18);
  text-decoration: none;
  transition: background .15s ease, color .15s ease;
}
.terap-week__cell--empty:hover,
.terap-week__cell--empty:focus-visible {
  background: rgba(102, 180, 143, .10);
  color: var(--leaf2);
  outline: none;
}
.terap-week__cell__plus {
  font-size: 18px;
  font-weight: 300;
  line-height: 1;
  opacity: 0;
  transition: opacity .15s ease;
}
.terap-week__cell--empty:hover .terap-week__cell__plus,
.terap-week__cell--empty:focus-visible .terap-week__cell__plus {
  opacity: 1;
}
.terap-week__event {
  display: block;
  padding: 6px 8px;
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(102, 180, 143, .25), rgba(102, 180, 143, .12));
  border: 1px solid rgba(102, 180, 143, .35);
  color: var(--text);
  font-size: 11px;
  line-height: 1.3;
}
.terap-week__event strong { display: block; font-size: 12px; }
.terap-week__event small { color: var(--muted); font-size: 10px; display: block; }
.terap-week__event--sand { background: linear-gradient(135deg, rgba(244, 231, 211, .22), rgba(244, 231, 211, .08)); border-color: rgba(244, 231, 211, .35); }
.terap-week__event--clay { background: linear-gradient(135deg, rgba(196, 106, 74, .22), rgba(196, 106, 74, .08)); border-color: rgba(196, 106, 74, .35); }

/* Variantes por status */
.terap-week__event--realizado {
  background: linear-gradient(135deg, rgba(244, 231, 211, .28), rgba(244, 231, 211, .10));
  border-color: rgba(244, 231, 211, .45);
}
.terap-week__event--cancelado {
  background: repeating-linear-gradient(135deg, rgba(196, 106, 74, .12) 0 8px, rgba(196, 106, 74, .04) 8px 16px);
  border-color: rgba(196, 106, 74, .35);
  text-decoration: line-through;
  opacity: .78;
}
.terap-week__event__badge {
  display: inline-block;
  margin-top: 3px;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 9px;
  font-style: normal;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  text-decoration: none;
  background: rgba(244, 231, 211, .14);
  color: var(--sand);
}
.terap-week__event--cancelado .terap-week__event__badge {
  background: rgba(196, 106, 74, .25);
  color: var(--clay2);
}

/* ----------------- Filtros de status ----------------- */
.terap-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  width: fit-content;
  max-width: 100%;
  min-width: 0;
  background: rgba(7, 17, 14, .45);
  padding: 4px;
  border-radius: 999px;
  border: 1px solid var(--line);
  margin-bottom: 18px;
}
.terap-filter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  transition: background .15s ease, color .15s ease;
  min-width: 0;
}
.terap-filter:hover { background: rgba(234, 243, 239, .06); color: var(--text); }
.terap-filter.is-active {
  background: linear-gradient(135deg, var(--leaf), var(--leaf2));
  color: #052015;
  box-shadow: 0 6px 18px rgba(62, 142, 106, .25);
}
.terap-filter span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  font-size: 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, .22);
  color: inherit;
}

/* ----------------- Badges de status ----------------- */
.terap-tooltip__status {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  border: 1px solid transparent;
}
.terap-tooltip__status--agendado  { background: rgba(102, 180, 143, .18); color: var(--leaf2); border-color: rgba(102, 180, 143, .35); }
.terap-tooltip__status--realizado { background: rgba(244, 231, 211, .14); color: var(--sand);  border-color: rgba(244, 231, 211, .35); }
.terap-tooltip__status--cancelado { background: rgba(196, 106, 74, .18);  color: var(--clay2); border-color: rgba(196, 106, 74, .35);  }

.terap-row--cancelado td { opacity: .65; }
.terap-row--cancelado td:nth-child(5) { text-decoration: line-through; }

/* ----------------- Tooltip rico (hover/focus/touch) ----------------- */
.terap-tooltip-host {
  position: relative;
  display: block;
}
.terap-tooltip {
  position: absolute;
  z-index: 80;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  width: 280px;
  max-width: 88vw;
  padding: 14px;
  background: #0E1C17;
  border: 1px solid rgba(102, 180, 143, .35);
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .55);
  color: var(--text);
  font-size: 12px;
  line-height: 1.4;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .15s ease, transform .15s ease, visibility 0s linear .15s;
  text-decoration: none;
  white-space: normal;
  text-align: left;
}
.terap-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: rgba(102, 180, 143, .55);
}
.terap-tooltip-host:hover .terap-tooltip,
.terap-tooltip-host:focus-within .terap-tooltip,
.terap-tooltip-host.is-touched .terap-tooltip {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
  transition-delay: 0s, 0s, 0s;
}
.terap-tooltip__head {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: space-between;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(234, 243, 239, .12);
}
.terap-tooltip__head strong { font-size: 14px; color: var(--text); }
.terap-tooltip__list { display: grid; gap: 6px; margin: 0; }
.terap-tooltip__list > div { display: grid; grid-template-columns: 90px 1fr; gap: 8px; }
.terap-tooltip__list dt { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .5px; margin: 0; }
.terap-tooltip__list dd { margin: 0; color: var(--text); font-size: 12px; }

/* ----------------- Login ----------------- */
.terap-body--auth {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
}
.terap-auth-card {
  width: min(420px, 100%);
  background: rgba(19, 45, 38, .78);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 32px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .45);
  text-align: center;
}
.terap-auth-card__logo {
  width: 64px;
  height: 64px;
  margin: 0 auto 12px;
  display: block;
}
.terap-auth-card h1 { margin: 0 0 4px; font-size: 22px; }
.terap-auth-card p.terap-auth-sub { margin: 0 0 22px; color: var(--muted); font-size: 13px; }
.terap-auth-card .terap-form { text-align: left; }

/* ----------------- Responsividade ----------------- */
@media (max-width: 980px) {
  .terap-span-8, .terap-span-6, .terap-span-4, .terap-span-3 { grid-column: span 12; }
}
@media (max-width: 820px) {
  .terap-shell { grid-template-columns: 1fr; }
  .terap-sidebar {
    position: fixed;
    inset-block: var(--terap-topbar-h) 0;
    left: 0;
    width: min(86vw, 320px);
    max-width: 320px;
    background: #07110E;
    z-index: 70;
    transition: transform .22s ease;
    transform: translateX(-100%);
    border-right: 1px solid var(--line);
  }
  .terap-sidebar.is-open { transform: translateX(0); }
  .terap-burger { display: inline-flex; }
  .terap-topbar__userMeta { display: none; }
  .terap-main { padding: 18px 18px 72px; }
  .terap-week { grid-template-columns: 50px repeat(7, minmax(80px, 1fr)); overflow-x: auto; }

  /* Tooltip se adapta ao mobile: ancora à esquerda do bloco, ocupa quase a tela */
  .terap-tooltip {
    width: 260px;
    left: 0;
    transform: translateX(0) translateY(4px);
  }
  .terap-tooltip-host:hover .terap-tooltip,
  .terap-tooltip-host:focus-within .terap-tooltip,
  .terap-tooltip-host.is-touched .terap-tooltip {
    transform: translateX(0) translateY(0);
  }
  .terap-tooltip::after { left: 18px; transform: none; }
}

/* ============================================================
   Pacientes — lista, busca, ficha, formulário em seções
   Reaproveita as variáveis de global.css (--leaf, --sand, --clay2…).
   ============================================================ */

/* Barra de busca */
.pac-toolbar { margin-bottom: 12px; }
.pac-search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(7, 17, 14, .55);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 6px 8px 6px 12px;
}
.pac-search__icon { color: var(--muted); font-size: 16px; }
.pac-search input[type="search"] {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 14px;
  padding: 8px 4px;
  min-width: 0;
}
.pac-search input[type="search"]:focus { outline: none; }

/* Lista de pacientes (cards responsivos) */
.pac-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}
.pac-card {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(19, 45, 38, .62);
  color: var(--text);
  transition: transform .15s ease, border-color .15s ease;
}
.pac-card:hover { transform: translateY(-2px); border-color: rgba(102, 180, 143, .35); }
.pac-card__avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 17px;
  background: linear-gradient(135deg, var(--leaf), var(--leaf2));
  color: #052015;
}
.pac-card__name { display: block; font-weight: 600; font-size: 14px; }
.pac-card__meta { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
.pac-card__hint { display: block; font-size: 12px; color: var(--muted); margin-top: 4px; opacity: .85; }

.pac-badge {
  display: inline-block;
  font-style: normal;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  padding: 2px 7px;
  border-radius: 999px;
  vertical-align: middle;
}
.pac-badge--off { background: rgba(196, 106, 74, .18); color: var(--clay2); border: 1px solid rgba(196, 106, 74, .35); }

.pac-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 18px;
  flex-wrap: wrap;
}
.pac-pagination__info { font-size: 12px; color: var(--muted); }

.pac-help { font-size: 12px; color: var(--muted); line-height: 1.5; }

/* Formulário em seções (acordeões nativos) */
.pac-form { gap: 12px; }
.pac-section {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(19, 45, 38, .55);
  overflow: hidden;
}
.pac-section > summary {
  list-style: none;
  cursor: pointer;
  padding: 16px 18px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.pac-section > summary::-webkit-details-marker { display: none; }
.pac-section > summary::after {
  content: '▸';
  color: var(--muted);
  font-size: 13px;
  transition: transform .15s ease;
}
.pac-section[open] > summary::after { transform: rotate(90deg); }
.pac-section__title { font-size: 15px; font-weight: 600; color: var(--text); }
.pac-section__hint { font-size: 11px; color: var(--muted); text-align: right; }
.pac-section__body {
  padding: 0 18px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.pac-subgroup {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  margin: 0;
}
.pac-subgroup legend {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--muted);
  padding: 0 6px;
}

/* Condições de saúde (checkbox + detalhe) */
.pac-cond-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 10px;
}
.pac-cond {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  background: rgba(7, 17, 14, .35);
  transition: border-color .15s ease, background .15s ease;
}
.pac-cond.is-on { border-color: rgba(102, 180, 143, .45); background: rgba(102, 180, 143, .08); }
.pac-cond__check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); cursor: pointer; }
.pac-cond__check input { width: 16px; height: 16px; accent-color: var(--leaf2); }
.pac-cond__det {
  margin-top: 8px;
  width: 100%;
  background: rgba(7, 17, 14, .55);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  padding: 7px 9px;
}
.pac-cond__det:focus { outline: none; border-color: rgba(102, 180, 143, .45); }

/* Linhas de medicamentos */
.pac-med-row {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr 1.4fr;
  gap: 8px;
  margin-bottom: 8px;
}
.pac-med-row input {
  background: rgba(7, 17, 14, .55);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  padding: 8px 10px;
}
.pac-med-row input:focus { outline: none; border-color: rgba(102, 180, 143, .45); }

.pac-form__actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 6px;
}

/* Ficha (visualização read-only) */
.ficha-list { margin: 0; display: grid; gap: 10px; }
.ficha-row { display: grid; grid-template-columns: 200px 1fr; gap: 12px; }
.ficha-row dt { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; margin: 0; }
.ficha-row dd { margin: 0; color: var(--text); font-size: 14px; }
.ficha-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.ficha-chip {
  display: inline-flex;
  gap: 4px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(102, 180, 143, .12);
  border: 1px solid rgba(102, 180, 143, .3);
  font-size: 12px;
  color: var(--text);
}
.ficha-chip em { color: var(--muted); font-style: normal; }
.ficha-meds { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 8px; }
.ficha-meds li {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  background: rgba(7, 17, 14, .35);
  font-size: 13px;
}
.ficha-meds li strong { display: block; }
.ficha-meds li span { color: var(--muted); font-size: 12px; }

.terap-feed__item.is-inativa { opacity: .6; }

/* Autocomplete de paciente (agenda) */
.pac-autocomplete { position: relative; }
.pac-autocomplete__list {
  list-style: none;
  margin: 4px 0 0;
  padding: 4px;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 50;
  background: #0E1C17;
  border: 1px solid rgba(102, 180, 143, .35);
  border-radius: 12px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, .5);
  max-height: 260px;
  overflow-y: auto;
}
.pac-autocomplete__item {
  padding: 9px 10px;
  border-radius: 8px;
  cursor: pointer;
}
.pac-autocomplete__item:hover { background: rgba(102, 180, 143, .14); }
.pac-autocomplete__item strong { display: block; font-size: 13px; color: var(--text); }
.pac-autocomplete__item span { display: block; font-size: 11px; color: var(--muted); }

@media (max-width: 720px) {
  .ficha-row { grid-template-columns: 1fr; gap: 2px; }
  .pac-med-row { grid-template-columns: 1fr 1fr; }
  .pac-section__hint { display: none; }
}

/* ============================================================
   Pacotes e sessões (ficha + agenda)
   ============================================================ */
.pac-pkg-list { display: grid; gap: 12px; margin-top: 12px; }
.pac-pkg {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  background: rgba(7, 17, 14, .35);
}
.pac-pkg__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.pac-pkg__head strong { font-size: 15px; }
.pac-pkg__stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.pac-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 74px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(234, 243, 239, .03);
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .4px;
}
.pac-stat b { font-size: 20px; color: var(--text); font-weight: 700; }
.pac-stat--avail {
  background: rgba(102, 180, 143, .14);
  border-color: rgba(102, 180, 143, .35);
}
.pac-stat--avail b { color: var(--leaf2); }
.pac-pkg__det { margin-top: 10px; }
.pac-pkg__det > summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--sand);
  list-style: none;
}
.pac-pkg__det > summary::-webkit-details-marker { display: none; }
.pac-pkg__det > summary::before { content: '▸ '; }
.pac-pkg__det[open] > summary::before { content: '▾ '; }

.pac-mov-list { display: grid; gap: 6px; margin-top: 10px; }
.pac-mov {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(7, 17, 14, .35);
}
.pac-mov__qty {
  text-align: center;
  font-weight: 700;
  font-size: 14px;
  padding: 4px 0;
  border-radius: 8px;
  background: rgba(234, 243, 239, .06);
  color: var(--muted);
}
.pac-mov__qty.is-pos { background: rgba(102, 180, 143, .18); color: var(--leaf2); }
.pac-mov__qty.is-neg { background: rgba(196, 106, 74, .18); color: var(--clay2); }
.pac-mov__body strong { display: block; font-size: 13px; }

/* Resumo de saldo do pacote no formulário de agendamento */
.pac-saldo-box {
  border: 1px solid rgba(102, 180, 143, .3);
  background: rgba(102, 180, 143, .08);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 13px;
  margin-top: 8px;
}
.pac-saldo-box.is-warn {
  border-color: rgba(196, 106, 74, .4);
  background: rgba(196, 106, 74, .1);
  color: var(--clay2);
}

/* Badges dos status estendidos (Fase 3) */
.terap-tooltip__status--confirmado { background: rgba(102, 180, 143, .26); color: var(--leaf2); border-color: rgba(102, 180, 143, .5); }
.terap-tooltip__status--falta      { background: rgba(196, 106, 74, .16);  color: var(--clay2); border-color: rgba(196, 106, 74, .35); }
.terap-tooltip__status--reagendado { background: rgba(244, 231, 211, .12); color: var(--sand);  border-color: rgba(244, 231, 211, .3); }
.terap-week__event--confirmado { border-color: rgba(102, 180, 143, .6); box-shadow: inset 0 0 0 1px rgba(102, 180, 143, .35); }
.terap-week__event--falta { background: repeating-linear-gradient(135deg, rgba(196,106,74,.10) 0 8px, rgba(196,106,74,.03) 8px 16px); border-color: rgba(196,106,74,.3); }
.terap-week__event--reagendado { background: linear-gradient(135deg, rgba(244,231,211,.2), rgba(244,231,211,.06)); border-color: rgba(244,231,211,.35); }

/* ============================================================
   Modal flutuante do agendamento (Fase 3)
   ============================================================ */
.ag-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.ag-modal[hidden] { display: none; }
.ag-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 8, 6, .66);
  backdrop-filter: blur(2px);
}
.ag-modal__panel {
  position: relative;
  width: min(480px, 100%);
  max-width: 100%;
  min-width: 0;
  max-height: 88vh;
  overflow-y: auto;
  overflow-x: hidden;
  background: #0E1C17;
  border: 1px solid rgba(102, 180, 143, .3);
  border-radius: 18px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .55);
  padding: 22px;
}
.ag-modal__x {
  position: absolute;
  top: 12px;
  right: 14px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(234, 243, 239, .05);
  color: var(--text);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.ag-modal__x:hover { background: rgba(234, 243, 239, .12); }
.ag-modal__loading { color: var(--muted); font-size: 14px; padding: 8px 0; }
.ag-modal__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 30px 14px 0;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.ag-modal__head h3 { margin: 0; font-size: 18px; }
.ag-modal__list { display: grid; gap: 8px; margin: 0 0 16px; }
.ag-modal__list > div { display: grid; grid-template-columns: 110px 1fr; gap: 10px; }
.ag-modal__list dt { margin: 0; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .5px; }
.ag-modal__list dd { margin: 0; color: var(--text); font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; min-width: 0; }
.ag-modal__actions { display: flex; flex-wrap: wrap; gap: 8px; }

@media (max-width: 560px) {
  .ag-modal { padding: 0; align-items: flex-end; }
  .ag-modal__panel {
    width: 100%;
    max-width: 100%;
    max-height: 92vh;
    border-radius: 18px 18px 0 0;
    padding: 20px 16px 24px;
  }
  .ag-modal__list > div { grid-template-columns: 1fr; gap: 2px; }
}

/* ============================================================
   AGENDA — timeline proporcional (posição/altura por minuto),
   arraste, redimensionamento e clonagem. Geometria espelha
   window.AG_GRID / lib/agendamentos.php (--ag-pph).
   ============================================================ */
.ag-cal-scroll {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}
.ag-cal {
  --ag-gutter: 52px;
  min-width: 720px;
  width: 100%;
  user-select: none;
}
.ag-cal__head {
  display: grid;
  grid-template-columns: var(--ag-gutter) repeat(7, minmax(86px, 1fr));
  position: sticky; top: 0; z-index: 5;
  background: var(--card, #12241d);
}
.ag-cal__corner, .ag-cal__dayhead {
  padding: 8px 6px; text-align: center; font-size: 12px; font-weight: 700;
  color: var(--muted); text-transform: uppercase; letter-spacing: .4px;
  border-bottom: 1px solid rgba(255, 255, 255, .12);
}
.ag-cal__dayhead small { display: block; font-size: 11px; color: var(--muted); font-weight: 400; text-transform: none; letter-spacing: 0; }
.ag-cal__dayhead.is-today { background: rgba(102, 180, 143, .18); color: var(--text); border-radius: 8px 8px 0 0; }

.ag-cal__body {
  position: relative;
  display: grid;
  grid-template-columns: var(--ag-gutter) repeat(7, minmax(86px, 1fr));
}
.ag-cal__gutter { position: relative; }
.ag-cal__hourline { position: absolute; left: 0; right: 0; height: 0; }
.ag-cal__hourline span {
  position: absolute; top: -7px; right: 6px;
  font-size: 11px; color: var(--muted); background: var(--card, #12241d); padding: 0 2px;
}
.ag-cal__col {
  position: relative;
  border-left: 1px solid rgba(255, 255, 255, .07);
  touch-action: pan-y; /* permite rolar verticalmente; o arraste cancela isso via JS */
}
.ag-cal__col.is-today { background: rgba(102, 180, 143, .05); }
.ag-cal__rule { position: absolute; left: 0; right: 0; height: 0; border-top: 1px dashed rgba(255, 255, 255, .07); }

/* Bloco de evento posicionado por minuto */
.ag-ev {
  position: absolute;
  box-sizing: border-box;
  display: flex; flex-direction: column;
  overflow: hidden;
  padding: 0; border-radius: 8px;
  background: linear-gradient(135deg, rgba(102, 180, 143, .30), rgba(102, 180, 143, .14));
  border: 1px solid rgba(102, 180, 143, .40);
  color: var(--text); font-size: 11px; line-height: 1.25;
  text-decoration: none;
  cursor: pointer;
  transition: box-shadow .12s ease, filter .12s ease;
  z-index: 1;
  min-width: 0;
  max-width: calc(100% - 4px);
}
.ag-ev:hover { box-shadow: 0 4px 14px rgba(0, 0, 0, .35); filter: brightness(1.06); z-index: 3; }
.ag-ev:focus-visible { outline: 2px solid var(--leaf, #66b48f); outline-offset: 1px; }
.ag-ev__body { padding: 5px 8px; min-height: 0; flex: 1; overflow: hidden; min-width: 0; }
.ag-ev__time { display: block; font-size: 12px; font-weight: 700; }
.ag-ev__pac,
.ag-ev__meta,
.ag-ev__time {
  min-width: 0;
  max-width: 100%;
  white-space: normal;
  overflow: hidden;
  text-overflow: ellipsis;
  overflow-wrap: anywhere;
}
.ag-ev__pac  { display: block; }
.ag-ev__meta { display: block; color: var(--muted); font-size: 10px; }
.ag-ev--curto .ag-ev__body { padding: 2px 8px; }
.ag-ev--curto .ag-ev__pac, .ag-ev--curto .ag-ev__meta { display: none; }
.ag-ev--curto .ag-ev__time { font-size: 11px; }
.ag-ev__badge {
  align-self: flex-start; margin: 2px 8px 4px;
  padding: 1px 6px; border-radius: 999px;
  font-size: 9px; font-style: normal; font-weight: 700;
  text-transform: uppercase; letter-spacing: .6px;
  background: rgba(244, 231, 211, .14); color: var(--sand);
}

/* Alças de redimensionamento (topo/base) */
.ag-ev__grip {
  position: absolute; left: 0; right: 0; height: 10px;
  cursor: ns-resize; z-index: 2;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity .12s ease;
}
.ag-ev__grip--top { top: 0; }
.ag-ev__grip--bottom { bottom: 0; }
.ag-ev__grip::after {
  content: ""; width: 26px; height: 3px; border-radius: 3px;
  background: rgba(255, 255, 255, .65);
}
.ag-ev:hover .ag-ev__grip, .ag-ev.is-dragging .ag-ev__grip { opacity: .8; }
.ag-ev--curto .ag-ev__grip { height: 8px; }

/* Corpo arrastável (movimentação) */
.ag-ev[data-pode="1"] .ag-ev__body { cursor: grab; }
.ag-ev.is-dragging { z-index: 50; box-shadow: 0 10px 26px rgba(0, 0, 0, .5); filter: brightness(1.1); opacity: .96; }
.ag-ev.is-dragging .ag-ev__body { cursor: grabbing; }
.ag-ev--readonly { cursor: pointer; }

/* Variantes por status / propriedade */
.ag-ev--sand { background: linear-gradient(135deg, rgba(244, 231, 211, .24), rgba(244, 231, 211, .09)); border-color: rgba(244, 231, 211, .38); }
.ag-ev--realizado { background: linear-gradient(135deg, rgba(244, 231, 211, .30), rgba(244, 231, 211, .12)); border-color: rgba(244, 231, 211, .48); }
.ag-ev--confirmado { border-color: rgba(102, 180, 143, .7); box-shadow: inset 0 0 0 1px rgba(102, 180, 143, .4); }
.ag-ev--falta { background: repeating-linear-gradient(135deg, rgba(196,106,74,.12) 0 8px, rgba(196,106,74,.04) 8px 16px); border-color: rgba(196,106,74,.35); }
.ag-ev--reagendado { background: linear-gradient(135deg, rgba(244,231,211,.22), rgba(244,231,211,.07)); border-color: rgba(244,231,211,.38); }
.ag-ev--cancelado { background: repeating-linear-gradient(135deg, rgba(196,106,74,.12) 0 8px, rgba(196,106,74,.04) 8px 16px); border-color: rgba(196,106,74,.35); opacity: .72; }
.ag-ev--cancelado .ag-ev__time { text-decoration: line-through; }

/* Cópia (clonagem) flutuante */
.ag-ev--ghost {
  border-style: dashed; opacity: .85; z-index: 60; cursor: grab;
  background: linear-gradient(135deg, rgba(102, 180, 143, .26), rgba(102, 180, 143, .10));
  box-shadow: 0 10px 26px rgba(0, 0, 0, .5);
  touch-action: none;
}
.ag-ev__ghosttag {
  position: absolute; top: 2px; right: 4px;
  font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px;
  background: rgba(0, 0, 0, .35); color: #fff; padding: 1px 5px; border-radius: 999px;
}
.ag-clone-hint {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%);
  width: min(100% - 24px, 520px);
  max-width: calc(100% - 24px);
  background: rgba(14, 28, 23, .96); color: var(--text);
  border: 1px solid rgba(255, 255, 255, .16); border-radius: 10px;
  padding: 10px 16px; font-size: 13px; z-index: 200;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .4);
  overflow-wrap: anywhere;
}
.ag-clone-hint button { margin-left: 10px; }

/* Toast de feedback (sucesso/erro de salvamento) */
.ag-toast {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%) translateY(8px);
  width: min(100% - 24px, 520px);
  max-width: calc(100% - 24px);
  background: var(--card, #12241d); color: var(--text);
  border: 1px solid rgba(255, 255, 255, .16); border-left-width: 4px;
  border-radius: 10px; padding: 11px 16px; font-size: 13px; z-index: 210;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .45);
  opacity: 0; transition: opacity .18s ease, transform .18s ease; pointer-events: none;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.ag-toast.is-on { opacity: 1; transform: translateX(-50%) translateY(0); }
.ag-toast--ok  { border-left-color: var(--leaf, #66b48f); }
.ag-toast--err { border-left-color: var(--clay2, #c46a4a); }

/* Reagendar dentro do modal */
.ag-resched { margin: 4px 0 14px; padding: 12px; border: 1px solid rgba(255,255,255,.12); border-radius: 10px; }
.ag-resched__row { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; }
.ag-resched__row .terap-field { flex: 1; min-width: 120px; margin: 0; }
.ag-resched h4 { margin: 0 0 8px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }

@media (max-width: 768px) {
  .ag-cal { --ag-gutter: 52px; min-width: 660px; }
  .ag-ev__grip { height: 16px; }              /* alças maiores para toque */
  .ag-ev__grip::after { width: 34px; height: 4px; }
}

/* ============================================================
   MOBILE — Agenda dos terapeutas (interface orientada a toque).
   Tudo isolado por media query / classes ativadas via JS no mobile;
   o desktop permanece exatamente como está.
   ============================================================ */

/* Controles da agenda no mobile: alternador Dia/Semana + navegação de dia.
   Escondidos por padrão; só aparecem dentro da media query abaixo. */
.ag-mobilebar {
  display: none;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  margin-bottom: 12px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}
.ag-viewtoggle {
  display: inline-flex;
  gap: 3px;
  padding: 3px;
  background: rgba(7, 17, 14, .45);
  border: 1px solid var(--line);
  border-radius: 999px;
}
.ag-viewtoggle__btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  padding: 8px 16px;
  min-height: 38px;
  border-radius: 999px;
  cursor: pointer;
}
.ag-viewtoggle__btn.is-active {
  background: linear-gradient(135deg, var(--leaf), var(--leaf2));
  color: #052015;
  box-shadow: 0 6px 18px rgba(62, 142, 106, .25);
}
.ag-viewtoggle__btn:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--focus); }
.ag-daynav { display: inline-flex; align-items: center; gap: 6px; }
.ag-daynav__btn {
  appearance: none;
  width: 40px; height: 40px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(234, 243, 239, .06);
  color: var(--text);
  font-size: 20px; line-height: 1;
  cursor: pointer;
}
.ag-daynav__btn:hover { background: rgba(234, 243, 239, .12); }
.ag-daynav__btn:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--focus); }
.ag-daynav__label {
  min-width: 0;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  white-space: normal;
  overflow-wrap: anywhere;
}

/* Modo "dia": a grade semanal mostra só a coluna do dia ativo, em largura
   total — sem rolagem horizontal. Reaproveita todo o markup/JS da semana. */
.ag-cal--day {
  min-width: 0;
  width: 100%;
  max-width: 100%;
}
.ag-cal--day .ag-cal__head,
.ag-cal--day .ag-cal__body { grid-template-columns: var(--ag-gutter) minmax(0, 1fr); }
.ag-cal--day .ag-cal__dayhead:not(.is-active-day),
.ag-cal--day .ag-cal__col:not(.is-active-day) { display: none; }

/* Formulário de atendimento como bottom-sheet no mobile.
   No desktop, o backdrop e o "×" ficam ocultos e a seção é um card normal. */
.ag-sheet-bd { display: none; }
.ag-sheet__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.ag-sheet__head h2 { margin: 0; }
.ag-sheet__x {
  display: none;                 /* só aparece no mobile (bottom-sheet) */
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 40px; height: 40px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(234, 243, 239, .06);
  color: var(--text);
  font-size: 24px;
  line-height: 1;
  text-decoration: none;
}
.ag-sheet__x:hover { background: rgba(234, 243, 239, .12); }
.ag-sheet__x:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--focus); }

/* Trava de rolagem da página enquanto o bottom-sheet está aberto (mobile). */
.ag-sheet-open, .ag-sheet-open body { overflow: hidden; }

@media (max-width: 768px) {
  .ag-mobilebar { display: flex; }
  .terap-body,
  .terap-shell,
  .terap-topbar,
  .terap-main {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .terap-main {
    padding-inline: 12px;
    margin: 0;
  }

  .terap-topbar__inner {
    padding-inline: 12px;
    gap: 8px;
  }

  .terap-brand {
    flex: 1 1 auto;
    gap: 8px;
  }

  .terap-brand > div {
    min-width: 0;
  }

  .terap-topbar__user,
  .terap-burger,
  .terap-avatar,
  .terap-topbar__act {
    flex: 0 0 auto;
  }

  /* No mobile, "Minha senha"/"Sair" saem do cabeçalho (vão para o drawer:
     "Segurança da conta" no menu + "Sair da conta" no rodapé do drawer). */
  .terap-topbar__act { display: none; }

  .terap-page-head h1,
  .terap-card h2,
  .terap-card p {
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .terap-page-head > div:last-child {
    display: flex !important;
    flex-wrap: wrap;
    gap: 8px;
    width: 100%;
    min-width: 0;
  }

  .terap-page-head > div:last-child .terap-btn {
    flex: 1 1 auto;
    min-width: 0;
  }

  .terap-page-head > div:last-child .terap-btn--primary {
    flex: 1 0 100%;
    width: 100%;
  }

  .terap-filters {
    width: 100%;
    border-radius: 16px;
    gap: 8px;
  }

  .terap-filters .terap-filter {
    flex: 1 1 auto;
    justify-content: center;
  }

  .terap-filters label {
    flex: 0 0 100%;
  }

  .terap-filters select {
    flex: 1 1 100%;
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  /* ---- Cabeçalho da página empilha: texto em cima, comandos embaixo ---- */
  .terap-page-head { flex-direction: column; align-items: stretch; gap: 14px; }
  .terap-page-head > div:last-child { width: 100%; }

  .ag-mobilebar {
    align-items: stretch;
  }

  .ag-viewtoggle {
    width: 100%;
    min-width: 0;
  }

  .ag-viewtoggle__btn {
    flex: 1 1 0;
    min-width: 0;
  }

  .ag-daynav {
    width: 100%;
    min-width: 0;
    display: flex;
  }

  .ag-daynav__label {
    flex: 1 1 auto;
    min-width: 0;
    align-self: center;
  }

  .ag-daynav__btn {
    flex: 0 0 40px;
  }

  .ag-cal-scroll {
    overflow-x: hidden;
  }

  .ag-cal-scroll.is-week-view {
    overflow-x: auto;
  }

  .ag-cal {
    width: 660px;
    max-width: none;
  }

  .ag-cal--day {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .ag-cal--day .ag-cal__head,
  .ag-cal--day .ag-cal__body {
    grid-template-columns: 52px minmax(0, 1fr);
  }

  .ag-cal--day .ag-cal__corner,
  .ag-cal--day .ag-cal__dayhead {
    min-width: 0;
  }

  .ag-cal--day .ag-ev {
    left: 4px !important;
    right: 4px;
    width: auto !important;
    max-width: calc(100% - 8px);
  }

  /* ---- Novo atendimento como bottom-sheet ---- */
  /* Backdrop: escurece a agenda e dá contexto, com blur suave (barato). */
  .ag-sheet-bd {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(5, 12, 10, .72);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    z-index: 115;
    animation: agSheetFade .18s ease;
  }
  /* Painel: fundo SÓLIDO (sem herdar a translucidez do .terap-card), para a
     agenda não atravessar os campos. Cabeçalho sticky mantém título e X. */
  .ag-sheet {
    position: fixed;
    inset-inline: 0;
    bottom: 0;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    margin: 0 !important;
    max-height: 92dvh;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    border-radius: 18px 18px 0 0;
    padding-top: 0;
    padding-bottom: max(28px, env(safe-area-inset-bottom));
    background: #122a22;                       /* verde escuro sólido (paleta) */
    border: 1px solid rgba(102, 180, 143, .22);
    z-index: 120;
    box-shadow: 0 -16px 48px rgba(0, 0, 0, .6);
    animation: agSheetUp .22s ease;
  }
  /* Cabeçalho estável: gruda no topo ao rolar e cobre o conteúdo (fundo sólido). */
  .ag-sheet__head {
    position: sticky;
    top: 0;
    z-index: 2;
    margin: 0 -18px 14px;                      /* encosta nas bordas do painel */
    padding: 16px 18px 12px;
    background: #122a22;
    border-bottom: 1px solid var(--line);
    border-radius: 18px 18px 0 0;
  }
  .ag-sheet__x {
    display: flex;
    position: static;
  }
  .ag-sheet .terap-field[style] {
    min-width: 0 !important;
  }
  .ag-sheet .terap-field--row {
    width: 100%;
    min-width: 0;
  }
  @keyframes agSheetUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
  @keyframes agSheetFade { from { opacity: 0; } to { opacity: 1; } }

  /* ---- Lista detalhada da semana: tabela vira cartões empilhados ---- */
  .terap-table thead { display: none; }
  .terap-table, .terap-table tbody, .terap-table tr, .terap-table td { display: block; }
  .terap-table tr {
    border: 1px solid var(--line);
    border-radius: 14px;
    background: rgba(7, 17, 14, .40);
    padding: 12px 14px;
    margin-bottom: 12px;
  }
  .terap-table tr:hover td { background: transparent; }
  .terap-table td {
    border: 0;
    padding: 4px 0;
    text-align: left;
    white-space: normal;            /* anula o nowrap inline da célula de ações */
  }
  .terap-table td::before {
    content: attr(data-label) ': ';
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
    margin-right: 6px;
  }
  /* Célula de ações: grade responsiva (auto-fit). Duas colunas quando há
     largura; cai sozinha para uma coluna em telas muito estreitas. Cada
     botão preenche a célula, sem estourar o card e com bom alvo de toque. */
  .terap-table td:last-child {
    margin-top: 8px;
    padding-top: 10px;
    border-top: 1px dashed var(--line);
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 8px;
    align-items: stretch;
  }
  .terap-table td:last-child::before { grid-column: 1 / -1; display: block; margin: 0 0 2px; }
  .terap-table td:last-child > form { display: block; margin: 0; min-width: 0; }
  .terap-table td:last-child .terap-btn {
    width: 100%;
    margin: 0;
    min-height: 40px;
  }
}

@media (max-width: 560px) {
  /* ---- Topbar compacta: ações viram ícones, subtítulo da marca oculto ---- */
  .terap-topbar__inner { padding: 0 12px; gap: 10px; }
  .terap-brand span { display: none; }
  .terap-brand__logo { width: 34px; height: 34px; }
  .terap-topbar__user { gap: 8px; }

  /* ---- Formulário de atendimento em coluna única ---- */
  .terap-field--row { flex-direction: column; gap: 12px; }
}

@media (max-width: 480px) {
  /* "+ Novo atendimento" ganha linha própria, com largura confortável e
     sem truncar — os demais comandos (semana/hoje) ficam acima. */
  .terap-page-head .terap-btn--primary { flex: 1 0 100%; }
}
