* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  background: #f3f6f8;
  color: #172033;
}

html {
  min-height: 100%;
  background: #f3f6f8;
  color: #172033;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body.csp-v2 {
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  background: #f3f6f8;
  color: #172033;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  overflow-x: clip;
}

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

button,
input:not([type="checkbox"]):not([type="radio"]) {
  -webkit-appearance: none;
  appearance: none;
}

button {
  border: 0;
}

input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]) {
  width: 100%;
  min-height: 48px;
  border: 1px solid #cbd5df;
  border-radius: 12px;
  background: #ffffff;
  color: #172033;
  padding: 12px 14px;
  outline: none;
}

input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):focus {
  border-color: #176b63;
  box-shadow: 0 0 0 3px rgba(23, 107, 99, 0.14);
}

input[type="hidden"] {
  display: none !important;
}

.auth-shell {
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: max(24px, env(safe-area-inset-top, 0px)) max(20px, env(safe-area-inset-right, 0px)) max(24px, env(safe-area-inset-bottom, 0px)) max(20px, env(safe-area-inset-left, 0px));
  background: #f3f6f8;
}

.auth-card {
  width: min(100%, 440px);
  background: #ffffff;
  color: #172033;
  border: 1px solid #dde5ec;
  border-radius: 20px;
  padding: 28px;
  box-shadow: 0 18px 50px rgba(15, 23, 42, 0.09);
}

.auth-header {
  display: flex;
  align-items: center;
  gap: 14px;
  background: #ffffff;
  color: #172033;
}

.brand-mark {
  width: 54px;
  height: 54px;
  flex: 0 0 54px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: #0f172a;
  color: #ffffff;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.eyebrow {
  color: #176b63;
  font-size: 12px;
  line-height: 1.3;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.auth-header h1 {
  margin-top: 3px;
  color: #172033;
  font-size: clamp(22px, 5vw, 28px);
  line-height: 1.15;
  font-weight: 750;
}

.auth-intro {
  margin-top: 20px;
  color: #5b6677;
  font-size: 15px;
  line-height: 1.55;
}

.auth-form {
  display: grid;
  gap: 18px;
  margin-top: 24px;
}

.field {
  display: grid;
  gap: 7px;
  background: #ffffff;
  color: #172033;
}

.field label {
  color: #334155;
  font-size: 14px;
  line-height: 1.35;
  font-weight: 650;
}

.password-wrap {
  position: relative;
  background: #ffffff;
  color: #172033;
}

.password-wrap input {
  padding-right: 82px;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 7px;
  transform: translateY(-50%);
  min-height: 36px;
  border-radius: 9px;
  background: #eef3f5;
  color: #176b63;
  padding: 7px 10px;
  font-size: 13px;
  line-height: 1;
  font-weight: 700;
  cursor: pointer;
}

.password-toggle:focus-visible {
  outline: 3px solid rgba(23, 107, 99, 0.2);
  outline-offset: 1px;
}

.primary-button {
  width: 100%;
  min-height: 50px;
  border-radius: 12px;
  background: #176b63;
  color: #ffffff;
  padding: 13px 18px;
  font-size: 16px;
  line-height: 1.25;
  font-weight: 750;
  cursor: pointer;
}

.primary-button:active {
  transform: translateY(1px);
}

.primary-button:disabled {
  opacity: 0.65;
  cursor: wait;
}

.form-status {
  min-height: 24px;
  color: #5b6677;
  font-size: 14px;
  line-height: 1.45;
}

.form-status.is-error {
  color: #a11a1a;
}

.form-status.is-success {
  color: #146047;
}

.app-tabbar {
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

@media (max-width: 520px) {
  .auth-shell {
    place-items: stretch;
    align-content: center;
    padding-left: max(16px, env(safe-area-inset-left, 0px));
    padding-right: max(16px, env(safe-area-inset-right, 0px));
  }

  .auth-card {
    width: 100%;
    border-radius: 18px;
    padding: 22px 18px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
    transition: none !important;
    animation: none !important;
  }
}

.remember-row {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #475569;
  font-size: 14px;
  line-height: 1.35;
}

.remember-row input[type="checkbox"] {
  -webkit-appearance: checkbox;
  appearance: auto;
  width: 18px;
  min-width: 18px;
  min-height: 18px;
  height: 18px;
  flex: 0 0 18px;
  margin: 0;
  padding: 0;
  border: 0;
  box-shadow: none;
  background: transparent;
}


/* =========================================================
   CSP AI Clinic V2 — Agenda
   Frontend estático, sem herança de WordPress.
   Mobile first. Sem transform/overflow em ancestrais de modais.
   ========================================================= */

body.csp-v2-app {
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px));
  background: #f3f6f8;
  overflow-x: clip;
  overflow-y: visible;
}

.v2-topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: max(10px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) 10px max(16px, env(safe-area-inset-left, 0px));
  background: #ffffff;
  color: #172033;
  border-bottom: 1px solid #dde5ec;
}

.v2-brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: #172033;
  text-decoration: none;
}

.v2-brand-mark {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  background: #0f172a;
  color: #ffffff;
  font-size: 12px;
  font-weight: 850;
  letter-spacing: .04em;
}

.v2-brand span:last-child {
  display: grid;
  gap: 1px;
}

.v2-brand small {
  color: #176b63;
  font-size: 10px;
  line-height: 1.1;
  font-weight: 850;
  letter-spacing: .12em;
}

.v2-brand strong {
  color: #172033;
  font-size: 19px;
  line-height: 1.15;
  font-weight: 800;
}

.v2-user {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: #526071;
  font-size: 13px;
}

.v2-user > span {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.v2-logout {
  min-height: 40px;
  border: 1px solid #cbd5df;
  border-radius: 10px;
  background: #ffffff;
  color: #334155;
  padding: 8px 12px;
  font-weight: 700;
}

.v2-main {
  width: min(100%, 1500px);
  margin: 0 auto;
  padding: 18px 18px 26px;
  overflow: visible;
}

.app-tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 25;
  width: 100%;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  background: #ffffff;
  border-top: 1px solid #d8e0e7;
  padding: 7px max(8px, env(safe-area-inset-right, 0px)) env(safe-area-inset-bottom, 0px) max(8px, env(safe-area-inset-left, 0px));
  box-shadow: 0 -8px 24px rgba(15, 23, 42, .06);
}

.app-tabbar a {
  min-width: 0;
  min-height: 56px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 2px;
  border-radius: 12px;
  color: #6b7280;
  text-decoration: none;
  font-size: 11px;
  line-height: 1.15;
}

.app-tabbar a > span {
  font-size: 20px;
  line-height: 1;
}

.app-tabbar a > strong {
  font-size: 11px;
  line-height: 1.15;
  font-weight: 700;
}

.app-tabbar a.is-active {
  background: #edf7f5;
  color: #176b63;
}

.csp-agenda-app,
.csp-agenda-app *,
.csp-agenda-app *::before,
.csp-agenda-app *::after {
  box-sizing: border-box;
}

.csp-agenda-app {
  width: 100%;
  min-width: 0;
  overflow: visible;
  color: #172033;
  background: transparent;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.csp-agenda-app button,
.csp-agenda-app input,
.csp-agenda-app select,
.csp-agenda-app textarea {
  font: inherit;
}

.csp-agenda-app button {
  cursor: pointer;
}

.csp-agenda-app button:disabled {
  cursor: default;
}

.csp-sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.csp-page-kicker {
  color: #176b63;
  font-size: 11px;
  line-height: 1.25;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: .11em;
}

.csp-help {
  color: #687385;
  font-size: 13px;
  line-height: 1.45;
}

.csp-card {
  border: 1px solid #dbe3ea;
  border-radius: 16px;
  background: #ffffff;
  color: #172033;
  padding: 18px;
}

.csp-icon-button {
  min-width: 42px;
  min-height: 42px;
  display: inline-grid;
  place-items: center;
  border: 1px solid #d6dee6;
  border-radius: 11px;
  background: #ffffff;
  color: #334155;
  padding: 7px;
  line-height: 1;
}

.csp-icon-button:active {
  background: #eef3f5;
}

.v2-icon {
  display: inline-grid;
  place-items: center;
  min-width: 1em;
  font-size: 18px;
  line-height: 1;
}

.csp-button-primary,
.csp-button-secondary,
.csp-whatsapp-button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border-radius: 11px;
  padding: 10px 14px;
  font-size: 14px;
  line-height: 1.2;
  font-weight: 750;
  text-decoration: none;
}

.csp-button-primary {
  background: #176b63;
  color: #ffffff;
  border: 1px solid #176b63;
}

.csp-button-secondary {
  background: #ffffff;
  color: #334155;
  border: 1px solid #cbd5df;
}

.csp-whatsapp-button {
  background: #eaf8ef;
  color: #17663b;
  border: 1px solid #bfe7cc;
}

.csp-button-auto {
  width: auto;
}

.csp-link-button {
  justify-self: start;
  background: transparent;
  color: #176b63;
  text-decoration: underline;
  text-underline-offset: 3px;
  font-size: 13px;
  font-weight: 700;
  padding: 5px 0;
}

.csp-agenda-toolbar {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
  border: 1px solid #dbe3ea;
  border-radius: 16px;
  background: #ffffff;
  padding: 12px;
}

.csp-agenda-mobile-quickbar {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  gap: 8px;
  align-items: center;
}

.csp-agenda-mobile-date-button {
  min-height: 42px;
  border: 1px solid #d6dee6;
  border-radius: 11px;
  background: #ffffff;
  color: #172033;
  padding: 8px 10px;
  font-weight: 800;
}

.csp-agenda-disclosure-toggle {
  width: 100%;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: #f7f9fa;
  color: #334155;
  border: 1px solid #e4e9ee;
  border-radius: 11px;
  padding: 8px 10px;
  text-align: left;
}

.csp-agenda-disclosure-toggle > span {
  display: grid;
  gap: 2px;
}

.csp-agenda-disclosure-toggle strong {
  font-size: 14px;
}

.csp-agenda-disclosure-toggle small {
  color: #7a8594;
  font-size: 12px;
}

.csp-agenda-controls-body {
  display: grid;
  gap: 12px;
}

.csp-agenda-toolbar-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.csp-agenda-period-controls,
.csp-agenda-view-controls,
.csp-agenda-navigation,
.csp-agenda-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.csp-agenda-date-input {
  min-height: 42px !important;
  width: auto !important;
  min-width: 150px;
  padding: 8px 10px !important;
  border-radius: 10px !important;
}

.csp-agenda-period-title {
  color: #172033;
  font-size: 17px;
  line-height: 1.25;
  font-weight: 800;
}

.csp-segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  border-radius: 11px;
  background: #eef2f5;
}

.csp-segmented button {
  min-height: 36px;
  border-radius: 8px;
  background: transparent;
  color: #596577;
  padding: 7px 10px;
  font-size: 13px;
  font-weight: 750;
}

.csp-segmented button[aria-pressed="true"] {
  background: #ffffff;
  color: #176b63;
  box-shadow: 0 1px 3px rgba(15, 23, 42, .1);
}

.csp-agenda-professional-control {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #526071;
  font-size: 13px;
  font-weight: 700;
}

.csp-agenda-professional-control select {
  min-width: 190px;
}

.csp-agenda-app select,
.csp-agenda-app textarea,
.csp-agenda-app input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]) {
  width: 100%;
  min-height: 44px;
  border: 1px solid #cbd5df;
  border-radius: 10px;
  background: #ffffff;
  color: #172033;
  padding: 9px 11px;
  outline: none;
}

.csp-agenda-app textarea {
  resize: vertical;
}

.csp-agenda-app select:focus,
.csp-agenda-app textarea:focus,
.csp-agenda-app input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):focus {
  border-color: #176b63;
  box-shadow: 0 0 0 3px rgba(23, 107, 99, .13);
}

.csp-agenda-app input[type="checkbox"],
.csp-agenda-app input[type="radio"] {
  width: 18px;
  min-width: 18px;
  height: 18px;
  accent-color: #176b63;
}

.csp-agenda-feedback {
  margin: 0 0 12px;
  border: 1px solid #b9d9cf;
  border-radius: 12px;
  background: #edf8f5;
  color: #155b4f;
  padding: 11px 13px;
  font-size: 14px;
  line-height: 1.4;
}

.csp-agenda-feedback.is-error,
.csp-form-error-summary,
.csp-finance-feedback.is-error {
  border-color: #edc2c2;
  background: #fff0f0;
  color: #942828;
}

.csp-agenda-feedback.is-warning {
  border-color: #e7d5a7;
  background: #fff9e8;
  color: #775a17;
}

.csp-agenda-layout {
  min-width: 0;
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  overflow: visible;
}

.csp-agenda-mini-panel {
  position: sticky;
  top: 84px;
  border: 1px solid #dbe3ea;
  border-radius: 15px;
  background: #ffffff;
  padding: 12px;
}

.csp-mini-calendar-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.csp-mini-calendar-heading strong {
  font-size: 14px;
}

.csp-mini-calendar-weekdays,
.csp-mini-calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 3px;
}

.csp-mini-calendar-weekdays span {
  color: #8993a1;
  text-align: center;
  font-size: 10px;
  font-weight: 750;
}

.csp-mini-calendar-grid button {
  aspect-ratio: 1;
  border-radius: 8px;
  background: transparent;
  color: #445064;
  font-size: 11px;
}

.csp-mini-calendar-grid button.is-today {
  background: #176b63;
  color: #ffffff;
}

.csp-mini-calendar-grid button.is-selected {
  outline: 2px solid #176b63;
  outline-offset: -2px;
}

.csp-agenda-stage {
  min-width: 0;
  border: 1px solid #dbe3ea;
  border-radius: 16px;
  background: #ffffff;
  padding: 12px;
  overflow: visible;
}

.csp-agenda-loading {
  padding: 20px;
  color: #687385;
  text-align: center;
}

.csp-agenda-mobile-list {
  display: none;
}

.csp-agenda-time-grid {
  position: relative;
  min-width: 760px;
  display: grid;
  grid-template-columns: 64px repeat(var(--agenda-days), minmax(150px, 1fr));
  grid-template-rows: 52px var(--agenda-height);
  border: 1px solid #e2e7ec;
  border-radius: 13px;
  background: #ffffff;
}

.csp-agenda-time-corner {
  grid-column: 1;
  grid-row: 1;
  border-right: 1px solid #e4e9ee;
  border-bottom: 1px solid #e4e9ee;
  background: #f8fafb;
}

.csp-agenda-day-header {
  grid-row: 1;
  min-width: 0;
  display: grid;
  place-items: center;
  gap: 1px;
  border-left: 1px solid #e4e9ee;
  border-bottom: 1px solid #e4e9ee;
  background: #f8fafb;
  color: #526071;
  padding: 5px;
}

.csp-agenda-day-header span {
  font-size: 11px;
  text-transform: capitalize;
}

.csp-agenda-day-header strong {
  font-size: 18px;
}

.csp-agenda-day-header.is-today {
  background: #eaf5f2;
  color: #176b63;
}

.csp-agenda-time-labels {
  position: relative;
  grid-column: 1;
  grid-row: 2;
  border-right: 1px solid #e4e9ee;
  background: #fbfcfd;
}

.csp-agenda-time-labels span {
  position: absolute;
  left: 5px;
  color: #8993a1;
  font-size: 10px;
  line-height: 1;
}

.csp-agenda-day-column {
  position: relative;
  grid-row: 2;
  min-width: 0;
  border-left: 1px solid #edf0f3;
  background:
    repeating-linear-gradient(
      to bottom,
      transparent 0,
      transparent 33px,
      #eef2f4 33px,
      #eef2f4 34px
    );
}

.csp-agenda-slot {
  position: absolute;
  left: 0;
  right: 0;
  width: 100%;
  border: 0;
  background: transparent;
  color: transparent;
}

.csp-agenda-slot:hover {
  background: rgba(23, 107, 99, .05);
}

.csp-agenda-slot.is-unavailable {
  background: rgba(148, 163, 184, .04);
}

.csp-agenda-event,
.csp-agenda-block,
.csp-agenda-break {
  position: absolute;
  left: 3px;
  right: 3px;
  z-index: 3;
  min-width: 0;
  border-radius: 9px;
  padding: 6px 7px;
  text-align: left;
}

.csp-agenda-event {
  border: 1px solid #cfdad8;
  border-left: 5px solid var(--professional-color, #176b63);
  background: #ffffff;
  color: #172033;
  box-shadow: 0 2px 8px rgba(15, 23, 42, .08);
}

.csp-agenda-event strong,
.csp-agenda-event > span:not(.csp-agenda-resize-handle):not(.csp-agenda-fit-in-badge) {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.csp-agenda-event strong {
  font-size: 11px;
}

.csp-agenda-event > span {
  color: #687385;
  font-size: 10px;
}

.csp-agenda-event.is-readonly {
  cursor: default;
}

.csp-agenda-fit-in-badge {
  display: inline-block;
  margin-top: 2px;
  border-radius: 999px;
  background: #fff0d8;
  color: #8a5710;
  padding: 1px 5px;
  font-size: 9px;
  font-weight: 800;
}

.csp-agenda-resize-handle {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 1px;
  height: 5px;
  border-radius: 999px;
  background: #cbd5df;
}

.csp-agenda-break {
  z-index: 2;
  border: 1px dashed #cfd6dd;
  background: #f5f7f9;
  color: #6b7280;
  pointer-events: none;
}

.csp-agenda-break strong,
.csp-agenda-block strong {
  display: block;
  font-size: 10px;
}

.csp-agenda-break span,
.csp-agenda-block span {
  display: block;
  font-size: 9px;
}

.csp-agenda-block {
  z-index: 4;
  border: 1px solid #df9999;
  background: #f9dede;
  color: #8b2626;
}

.csp-agenda-block.is-holiday {
  background: #f3dddd;
  cursor: default;
}

.csp-agenda-now-line {
  position: absolute;
  z-index: 8;
  height: 2px;
  background: #d73030;
  pointer-events: none;
}

.csp-agenda-now-line::before {
  content: "";
  position: absolute;
  left: -4px;
  top: -3px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #d73030;
}

.csp-agenda-month-grid {
  min-width: 720px;
  display: grid;
  grid-template-columns: repeat(7, minmax(100px, 1fr));
  border: 1px solid #e2e7ec;
  border-radius: 13px;
  background: #ffffff;
}

.csp-agenda-month-weekday {
  padding: 8px;
  border-bottom: 1px solid #e4e9ee;
  background: #f8fafb;
  color: #687385;
  text-align: center;
  font-size: 11px;
  font-weight: 800;
}

.csp-agenda-month-day {
  min-height: 116px;
  border-right: 1px solid #edf0f3;
  border-bottom: 1px solid #edf0f3;
  background: #ffffff;
  padding: 6px;
}

.csp-agenda-month-date {
  display: inline-grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border-radius: 50%;
  color: #526071;
  font-size: 11px;
  font-weight: 750;
}

.csp-agenda-month-day.is-today .csp-agenda-month-date {
  background: #176b63;
  color: #ffffff;
}

.csp-agenda-month-events {
  display: grid;
  gap: 4px;
  margin-top: 4px;
}

.csp-agenda-month-event,
.csp-agenda-month-block {
  min-height: 26px;
  border-radius: 7px;
  padding: 4px 6px;
  text-align: left;
  font-size: 10px;
}

.csp-agenda-month-event {
  border-left: 4px solid var(--professional-color, #176b63);
  background: #edf6f4;
  color: #244b47;
}

.csp-agenda-month-block {
  background: #f9dede;
  color: #8b2626;
}

.csp-agenda-month-more {
  color: #687385;
  font-size: 10px;
  font-weight: 700;
}

.csp-agenda-year-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.csp-agenda-year-month {
  min-height: 116px;
  border: 1px solid #e1e7ec;
  border-radius: 13px;
  background: #ffffff;
  color: #334155;
  padding: 11px;
  text-align: left;
}

.csp-agenda-year-month strong {
  display: block;
  margin-bottom: 7px;
  font-size: 14px;
}

.csp-agenda-year-dots {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
}

.csp-agenda-summary {
  margin-top: 14px;
  border: 1px solid #dbe3ea;
  border-radius: 16px;
  background: #ffffff;
  padding: 12px;
}

.csp-agenda-summary-heading {
  border: 0;
  background: transparent;
}

.csp-agenda-summary-body {
  display: grid;
  gap: 14px;
  margin-top: 10px;
}

.csp-agenda-summary-metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.csp-agenda-summary-metrics > div {
  border: 1px solid #e3e8ed;
  border-radius: 11px;
  background: #f9fbfc;
  padding: 10px;
}

.csp-agenda-summary-metrics strong {
  display: block;
  color: #172033;
  font-size: 20px;
  line-height: 1.15;
}

.csp-agenda-summary-metrics span {
  color: #687385;
  font-size: 11px;
}

.csp-agenda-cancellation-list {
  display: grid;
  gap: 8px;
}

.csp-agenda-cancellation-result {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  border: 1px solid #e5e9ed;
  border-radius: 11px;
  background: #ffffff;
  color: #334155;
  padding: 10px;
  text-align: left;
}

.csp-agenda-cancellation-patient {
  font-weight: 800;
}

.csp-agenda-cancellation-status {
  color: #8b5a2b;
  font-size: 11px;
  font-weight: 750;
}

.csp-agenda-empty,
.csp-agenda-summary-empty {
  display: grid;
  gap: 7px;
  color: #687385;
}

.csp-agenda-empty h2 {
  color: #334155;
  font-size: 18px;
}

/* -------- managed dialogs: not native top-layer -------- */
.csp-agenda-app [data-v2-dialog] {
  margin: 0;
  max-width: none;
  max-height: none;
  border: 0;
}

.csp-agenda-app [data-v2-dialog]:not([open]) {
  display: none !important;
}

.csp-agenda-app [data-v2-dialog][open] {
  position: fixed;
  inset: 0;
  z-index: 1000;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: max(16px, env(safe-area-inset-top, 0px)) max(14px, env(safe-area-inset-right, 0px)) max(16px, env(safe-area-inset-bottom, 0px)) max(14px, env(safe-area-inset-left, 0px));
  background: rgba(15, 23, 42, .52);
  color: #172033;
}

.csp-agenda-app [data-v2-dialog] > form,
.csp-agenda-app .csp-agenda-date-dialog-shell,
.csp-agenda-app .csp-finance-dialog-shell {
  width: min(100%, 760px);
  max-height: min(88vh, 88dvh);
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin: auto;
  border: 1px solid #dce3e9;
  border-radius: 18px;
  background: #ffffff;
  color: #172033;
  padding: 18px;
  overflow-y: auto;
  overscroll-behavior: contain;
  box-shadow: 0 22px 70px rgba(15, 23, 42, .24);
}

.csp-agenda-app .csp-agenda-dialog-wide > form,
.csp-agenda-app .csp-finance-dialog-shell {
  width: min(100%, 980px);
}

.csp-agenda-date-dialog[open] {
  align-items: flex-start;
}

.csp-agenda-date-dialog-shell {
  margin-top: min(15vh, 110px) !important;
}

.csp-agenda-date-dialog-shell > header,
.csp-agenda-dialog-header,
.csp-finance-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.csp-agenda-dialog-header h2,
.csp-finance-heading h3 {
  color: #172033;
  font-size: 21px;
  line-height: 1.2;
}

.csp-agenda-dialog-close {
  min-width: 42px;
  min-height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid #d6dee6;
  border-radius: 11px;
  background: #ffffff;
  color: #334155;
}

.csp-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.csp-field {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 6px;
}

.csp-field > label,
.csp-field-label-row > label {
  color: #334155;
  font-size: 13px;
  line-height: 1.3;
  font-weight: 750;
}

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

.csp-field-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.csp-agenda-dialog-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.csp-agenda-dialog-actions-main {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.csp-form-error-summary {
  border: 1px solid #edc2c2;
  border-radius: 11px;
  padding: 10px 12px;
}

.csp-form-error-summary ul {
  margin: 6px 0 0 18px;
}

.csp-error-summary-title {
  font-weight: 800;
}

.csp-fit-in-notice,
.csp-notice {
  border-radius: 11px;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.4;
}

.csp-fit-in-notice {
  display: grid;
  gap: 2px;
  border: 1px solid #e7d5a7;
  background: #fff8e5;
  color: #785a17;
}

.csp-notice-warning {
  border: 1px solid #e7d5a7;
  background: #fff8e5;
  color: #785a17;
}

.csp-agenda-inline-panel,
.csp-appointment-status-options,
.csp-type-editor,
.csp-finance-payment-form {
  min-width: 0;
  border: 1px solid #e2e7ec;
  border-radius: 12px;
  background: #f9fbfc;
  padding: 12px;
}

.csp-agenda-inline-panel legend,
.csp-appointment-status-options legend,
.csp-type-editor legend,
.csp-finance-payment-form legend {
  padding: 0 6px;
  color: #445064;
  font-size: 13px;
  font-weight: 800;
}

.csp-check-row,
.csp-compact-check {
  display: flex;
  align-items: center;
  gap: 8px;
}

.csp-check-row > span {
  display: grid;
  gap: 2px;
}

.csp-check-row small {
  color: #7a8594;
  font-size: 11px;
}

.csp-appointment-status-options {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.csp-patient-combobox {
  position: relative;
  z-index: 4;
}

.csp-patient-search-results {
  position: absolute;
  top: calc(100% + 5px);
  left: 0;
  right: 0;
  z-index: 20;
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid #ccd6de;
  border-radius: 11px;
  background: #ffffff;
  box-shadow: 0 10px 25px rgba(15, 23, 42, .15);
  padding: 5px;
}

.csp-patient-search-result {
  width: 100%;
  display: grid;
  gap: 2px;
  border-radius: 8px;
  background: #ffffff;
  color: #334155;
  padding: 9px 10px;
  text-align: left;
}

.csp-patient-search-result:hover,
.csp-patient-search-result:focus {
  background: #edf7f5;
}

.csp-patient-search-result strong {
  font-size: 13px;
}

.csp-patient-search-result small,
.csp-patient-search-empty {
  color: #718096;
  font-size: 11px;
}

.csp-selected-patient-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.csp-selected-patient-name {
  color: #176b63;
  font-size: 13px;
  font-weight: 800;
}

.csp-appointment-mobile-summary {
  display: grid;
  gap: 10px;
  border: 1px solid #dde5eb;
  border-radius: 12px;
  background: #f8fafb;
  padding: 11px;
}

.csp-appointment-mobile-summary-copy {
  display: grid;
  gap: 2px;
}

.csp-appointment-mobile-summary-copy strong {
  font-size: 16px;
}

.csp-appointment-mobile-summary-copy span {
  color: #687385;
  font-size: 12px;
}

.csp-appointment-mobile-primary-actions,
.csp-appointment-mobile-more {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.csp-mobile-action-button,
.csp-appointment-menu-item {
  min-height: 40px;
  border: 1px solid #d7e0e7;
  border-radius: 9px;
  background: #ffffff;
  color: #334155;
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 700;
}

.csp-appointment-menu {
  position: relative;
  margin-left: auto;
}

.csp-appointment-menu-panel {
  position: absolute;
  right: 0;
  bottom: calc(100% + 5px);
  z-index: 30;
  width: min(280px, calc(100vw - 40px));
  display: grid;
  gap: 4px;
  border: 1px solid #d6dee6;
  border-radius: 12px;
  background: #ffffff;
  padding: 6px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, .15);
}

.csp-appointment-menu-item {
  width: 100%;
  text-align: left;
}

.csp-appointment-menu-item.is-danger {
  color: #a12c2c;
}

.csp-type-manager-list {
  display: grid;
  gap: 7px;
  max-height: 220px;
  overflow-y: auto;
}

.csp-type-manager-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  border: 1px solid #e1e6eb;
  border-radius: 10px;
  background: #ffffff;
  padding: 9px;
}

.csp-type-manager-copy {
  display: grid;
  gap: 2px;
}

.csp-type-manager-copy small {
  color: #738091;
}

.csp-type-manager-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.csp-type-manager-actions button {
  min-height: 34px;
  border-radius: 8px;
  background: #eef3f5;
  color: #445064;
  padding: 6px 8px;
  font-size: 11px;
  font-weight: 700;
}

.csp-agenda-settings-options {
  display: grid;
  gap: 9px;
}

.csp-agenda-settings-card {
  width: 100%;
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) 24px;
  align-items: center;
  gap: 10px;
  border: 1px solid #dfe5ea;
  border-radius: 12px;
  background: #ffffff;
  color: #334155;
  padding: 12px;
  text-align: left;
}

.csp-agenda-settings-card span:nth-child(2) {
  display: grid;
  gap: 2px;
}

.csp-agenda-settings-card small {
  color: #738091;
  font-size: 11px;
}

.csp-availability-grid {
  display: grid;
  gap: 8px;
}

.csp-availability-row {
  border: 1px solid #e0e6eb;
  border-radius: 11px;
  background: #ffffff;
  padding: 0;
}

.csp-availability-row > summary {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
  padding: 10px 12px;
}

.csp-availability-row > summary span {
  color: #738091;
  font-size: 12px;
}

.csp-availability-fields {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
  padding: 0 12px 12px;
}

.csp-availability-fields label {
  display: grid;
  gap: 5px;
  color: #526071;
  font-size: 11px;
  font-weight: 700;
}

.csp-block-weekday-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 5px;
}

.csp-block-weekday-grid label {
  display: grid;
  place-items: center;
  gap: 4px;
  border: 1px solid #dce3e9;
  border-radius: 9px;
  background: #ffffff;
  padding: 7px 3px;
  font-size: 11px;
  font-weight: 700;
}

.csp-cancellation-context,
.csp-cancellation-details-grid {
  border: 1px solid #e1e6eb;
  border-radius: 11px;
  background: #f9fbfc;
  padding: 11px;
}

.csp-cancellation-context {
  display: grid;
  gap: 2px;
}

.csp-cancellation-context span {
  color: #687385;
  font-size: 12px;
}

.csp-cancellation-details-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.csp-cancellation-details-grid > div {
  display: grid;
  gap: 3px;
}

.csp-cancellation-details-grid span {
  color: #7b8795;
  font-size: 11px;
}

.csp-cancellation-details-grid p,
.csp-cancellation-details-grid strong {
  color: #334155;
  font-size: 13px;
}

.csp-appointment-finance {
  display: grid;
  gap: 13px;
}

.csp-finance-feedback {
  border: 1px solid #b9d9cf;
  border-radius: 10px;
  background: #edf8f5;
  color: #155b4f;
  padding: 9px 11px;
  font-size: 13px;
}

.csp-finance-history {
  display: grid;
  gap: 7px;
}

.csp-finance-history ul {
  display: grid;
  gap: 5px;
  padding-left: 18px;
}

/* Mobile: a Agenda diária é lista, não a grade de posicionamento. */
@media (max-width: 760px) {
  body.csp-v2-app {
    padding-bottom: calc(70px + env(safe-area-inset-bottom, 0px));
  }

  .v2-topbar {
    min-height: 60px;
    padding-top: max(8px, env(safe-area-inset-top, 0px));
    gap: 8px;
  }

  .v2-brand-mark {
    width: 38px;
    height: 38px;
    flex-basis: 38px;
  }

  .v2-brand small {
    font-size: 9px;
  }

  .v2-brand strong {
    font-size: 17px;
  }

  .v2-user > span {
    display: none;
  }

  .v2-logout {
    min-height: 38px;
    padding: 7px 9px;
    font-size: 12px;
  }

  .v2-main {
    padding: 12px max(10px, env(safe-area-inset-right, 0px)) 16px max(10px, env(safe-area-inset-left, 0px));
  }

  .csp-agenda-toolbar {
    padding: 10px;
    border-radius: 14px;
  }

  .csp-agenda-mobile-quickbar {
    display: grid;
  }

  .csp-agenda-toolbar-line {
    display: grid;
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .csp-agenda-period-controls,
  .csp-agenda-view-controls,
  .csp-agenda-actions {
    width: 100%;
  }

  .csp-agenda-period-controls {
    display: grid;
    grid-template-columns: auto auto minmax(0, 1fr);
  }

  .csp-agenda-period-controls .csp-agenda-date-input,
  .csp-agenda-period-controls .csp-agenda-period-title {
    grid-column: 1 / -1;
    width: 100% !important;
  }

  .csp-agenda-period-title {
    font-size: 15px;
  }

  .csp-agenda-navigation {
    flex-wrap: nowrap;
  }

  .csp-segmented {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    overflow: visible;
  }

  .csp-segmented button {
    min-width: 0;
    padding: 7px 3px;
    font-size: 11px;
  }

  .csp-agenda-professional-control {
    width: 100%;
    display: grid;
    gap: 5px;
  }

  .csp-agenda-professional-control select {
    min-width: 0;
    width: 100%;
  }

  .csp-agenda-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .csp-agenda-actions > button {
    min-width: 0;
    width: 100%;
  }

  .csp-agenda-layout {
    display: block;
  }

  .csp-agenda-mini-panel {
    display: none;
  }

  .csp-agenda-stage {
    padding: 8px;
    border-radius: 14px;
  }

  .csp-agenda-app[data-agenda-view="day"] [data-csp-agenda-calendar] {
    display: none;
  }

  .csp-agenda-app[data-agenda-view="day"] .csp-agenda-mobile-list {
    display: grid;
    gap: 10px;
  }

  .csp-agenda-app:not([data-agenda-view="day"]) [data-csp-agenda-calendar] {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
  }

  .csp-agenda-mobile-day {
    display: grid;
    gap: 7px;
  }

  .csp-agenda-mobile-day-title {
    position: sticky;
    top: 61px;
    z-index: 8;
    background: #ffffff;
    color: #334155;
    padding: 8px 5px 6px;
    font-size: 14px;
    line-height: 1.25;
    border-bottom: 1px solid #e5eaee;
  }

  .csp-agenda-mobile-event,
  .csp-agenda-mobile-free,
  .csp-agenda-mobile-block,
  .csp-agenda-mobile-break {
    width: 100%;
    min-height: 58px;
    display: grid;
    grid-template-columns: 54px minmax(0, 1fr);
    gap: 10px;
    align-items: center;
    border-radius: 11px;
    padding: 9px;
    text-align: left;
  }

  .csp-agenda-mobile-event {
    border: 1px solid #dbe3e9;
    border-left: 5px solid var(--professional-color, #176b63);
    background: #ffffff;
    color: #172033;
  }

  .csp-agenda-mobile-free {
    border: 1px dashed #b9d6ce;
    background: #f1faf7;
    color: #176b63;
  }

  .csp-agenda-mobile-block {
    border: 1px solid #e3aaaa;
    background: #fbe7e7;
    color: #8b2626;
  }

  .csp-agenda-mobile-break {
    border: 1px dashed #d4dbe1;
    background: #f6f8f9;
    color: #6b7280;
  }

  .csp-agenda-mobile-time {
    color: inherit;
    font-size: 13px;
    font-weight: 850;
  }

  .csp-agenda-mobile-main {
    min-width: 0;
    display: grid;
    gap: 2px;
  }

  .csp-agenda-mobile-main strong {
    overflow: hidden;
    color: inherit;
    font-size: 14px;
    line-height: 1.25;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .csp-agenda-mobile-main span,
  .csp-agenda-mobile-main small {
    overflow: hidden;
    color: #687385;
    font-size: 11px;
    line-height: 1.3;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .csp-agenda-mobile-now {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #b22525;
    font-size: 11px;
    font-weight: 850;
  }

  .csp-agenda-mobile-now::before,
  .csp-agenda-mobile-now::after {
    content: "";
    height: 1px;
    flex: 1;
    background: #d44b4b;
  }

  .csp-agenda-mobile-fit-in {
    min-height: 44px;
    border: 1px dashed #d2b274;
    border-radius: 10px;
    background: #fff8e8;
    color: #805b18;
    font-weight: 750;
  }

  .csp-agenda-mobile-empty {
    display: grid;
    gap: 3px;
    border: 1px dashed #dce3e8;
    border-radius: 10px;
    background: #fafcfd;
    color: #687385;
    padding: 12px;
  }

  .csp-agenda-mobile-empty strong {
    color: #445064;
    font-size: 13px;
  }

  .csp-agenda-summary {
    padding: 10px;
  }

  .csp-agenda-summary-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .csp-agenda-year-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .csp-agenda-app [data-v2-dialog][open] {
    align-items: stretch;
    justify-content: stretch;
    padding: max(8px, env(safe-area-inset-top, 0px)) max(8px, env(safe-area-inset-right, 0px)) max(8px, env(safe-area-inset-bottom, 0px)) max(8px, env(safe-area-inset-left, 0px));
  }

  .csp-agenda-app [data-v2-dialog] > form,
  .csp-agenda-app .csp-agenda-date-dialog-shell,
  .csp-agenda-app .csp-finance-dialog-shell {
    width: 100%;
    max-height: calc(100dvh - max(16px, env(safe-area-inset-top, 0px)) - max(16px, env(safe-area-inset-bottom, 0px)));
    margin: auto;
    border-radius: 14px;
    padding: 14px;
  }

  .csp-agenda-date-dialog-shell {
    margin-top: auto !important;
  }

  .csp-form-grid,
  .csp-cancellation-details-grid {
    grid-template-columns: 1fr;
  }

  .csp-field-span-2 {
    grid-column: 1;
  }

  .csp-agenda-dialog-actions,
  .csp-agenda-dialog-actions-main {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }

  .csp-agenda-dialog-actions button,
  .csp-agenda-dialog-actions a,
  .csp-agenda-dialog-actions-main button,
  .csp-agenda-dialog-actions-main a {
    width: 100%;
  }

  .csp-availability-fields {
    grid-template-columns: 1fr 1fr;
  }

  .csp-block-weekday-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .csp-appointment-menu {
    width: 100%;
    margin-left: 0;
  }

  .csp-appointment-menu-toggle {
    width: 100%;
  }

  .csp-appointment-menu-panel {
    position: static;
    width: 100%;
    margin-top: 5px;
    box-shadow: none;
  }

  .app-tabbar {
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
}

@media (max-width: 390px) {
  .v2-brand span:last-child {
    max-width: 170px;
  }

  .csp-segmented {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .csp-segmented .csp-agenda-year-view {
    grid-column: auto;
  }

  .csp-agenda-actions {
    grid-template-columns: 1fr;
  }

  .csp-agenda-summary-metrics {
    grid-template-columns: 1fr 1fr;
  }

  .csp-availability-fields {
    grid-template-columns: 1fr;
  }

  .app-tabbar a > strong {
    font-size: 10px;
  }
}

@media (min-width: 761px) {
  .csp-agenda-mobile-quickbar,
  .csp-agenda-disclosure-toggle[data-csp-agenda-controls-toggle] {
    display: none;
  }

  [data-csp-agenda-calendar] {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

@media (prefers-reduced-motion: reduce) {
  .csp-agenda-app *,
  .csp-agenda-app *::before,
  .csp-agenda-app *::after {
    scroll-behavior: auto !important;
    transition: none !important;
    animation: none !important;
  }
}

/* =========================================================
   CSP AI Clinic V2 — Pacientes
   HTML/CSS/JS puro. Mobile first. Overlays próprios para iOS.
   ========================================================= */

.csp-patients-v2,
.csp-patients-v2 *,
.csp-patients-v2 *::before,
.csp-patients-v2 *::after,
.v2-overlay,
.v2-overlay *,
.v2-overlay *::before,
.v2-overlay *::after {
  box-sizing: border-box;
}

.csp-patients-v2 {
  width: 100%;
  min-width: 0;
  color: #172033;
  background: transparent;
}

.csp-patients-v2 button,
.csp-patients-v2 input,
.csp-patients-v2 select,
.csp-patients-v2 textarea,
.v2-overlay button,
.v2-overlay input,
.v2-overlay select,
.v2-overlay textarea {
  font: inherit;
  font-size: 16px;
}

.patients-page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.patients-page-head h1 {
  margin-top: 3px;
  color: #172033;
  font-size: clamp(25px, 4vw, 34px);
  line-height: 1.12;
  font-weight: 820;
}

.patients-page-head > div > p:last-child {
  margin-top: 6px;
  color: #687385;
  font-size: 14px;
  line-height: 1.45;
}

.patients-toolbar {
  display: grid;
  gap: 12px;
  border: 1px solid #dbe3ea;
  border-radius: 16px;
  background: #ffffff;
  padding: 14px;
}

.patients-search {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.patients-search input {
  min-width: 0;
  min-height: 46px;
}

.patients-filters {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.patients-filters label,
.patient-field {
  min-width: 0;
  display: grid;
  gap: 6px;
}

.patients-filters label > span,
.patient-field > span {
  color: #475569;
  font-size: 12px;
  line-height: 1.25;
  font-weight: 750;
}

.patients-filters select,
.patient-field select,
.patient-field textarea {
  width: 100%;
  min-height: 46px;
  border: 1px solid #cbd5df;
  border-radius: 11px;
  background: #ffffff;
  color: #172033;
  padding: 10px 12px;
  outline: none;
}

.patient-field textarea {
  min-height: 92px;
  resize: vertical;
}

.patients-filters select:focus,
.patient-field select:focus,
.patient-field textarea:focus {
  border-color: #176b63;
  box-shadow: 0 0 0 3px rgba(23, 107, 99, .12);
}

.patients-status-line {
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 3px 4px;
  color: #687385;
  font-size: 13px;
}

.patients-status-line [data-storage-status] {
  color: #176b63;
  font-weight: 700;
}

.patients-notice {
  margin: 8px 0;
  border: 1px solid #cbd5df;
  border-radius: 12px;
  background: #ffffff;
  color: #475569;
  padding: 11px 13px;
  font-size: 14px;
  line-height: 1.4;
}

.patients-notice.is-error {
  border-color: #e7bcbc;
  background: #fff1f1;
  color: #8f2424;
}

.patients-notice.is-warning {
  border-color: #ead39a;
  background: #fff9e8;
  color: #785717;
}

.patients-notice.is-success {
  border-color: #b9ddcf;
  background: #edf9f4;
  color: #176347;
}

.patients-list {
  min-height: 120px;
}

.patients-list[aria-busy="true"]::before {
  content: "Carregando pacientes…";
  display: block;
  border: 1px solid #dbe3ea;
  border-radius: 14px;
  background: #ffffff;
  color: #687385;
  padding: 20px;
  text-align: center;
}

.patients-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid #dbe3ea;
  border-radius: 16px;
  background: #ffffff;
}

.patients-table {
  width: 100%;
  min-width: 900px;
  border-collapse: collapse;
}

.patients-table th,
.patients-table td {
  border-bottom: 1px solid #e7edf1;
  padding: 12px 14px;
  text-align: left;
  vertical-align: middle;
  color: #334155;
  font-size: 13px;
}

.patients-table th {
  background: #f8fafb;
  color: #667085;
  font-size: 11px;
  line-height: 1.2;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.patients-table tbody tr:last-child td {
  border-bottom: 0;
}

.patient-table-name {
  width: 100%;
  min-width: 220px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: transparent;
  color: #172033;
  text-align: left;
}

.patient-table-name > span:last-child {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.patient-table-name strong,
.patient-table-name small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.patient-table-name strong {
  color: #172033;
  font-size: 14px;
}

.patient-table-name small {
  color: #7b8794;
  font-size: 12px;
}

.patient-list-avatar,
.patient-avatar,
.patient-photo-preview {
  display: grid;
  place-items: center;
  overflow: clip;
  border-radius: 14px;
  background: #eaf3f1;
  color: #176b63;
  font-weight: 850;
}

.patient-list-avatar {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  font-size: 12px;
}

.patient-status {
  display: inline-flex;
  align-items: center;
  min-height: 27px;
  border-radius: 999px;
  padding: 4px 9px;
  background: #eef2f5;
  color: #526071;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.patient-status.is-active {
  background: #e9f8f1;
  color: #176347;
}

.patient-status.is-inactive {
  background: #eef1f4;
  color: #5d6674;
}

.patient-status.is-trashed,
.patient-status.is-deceased {
  background: #f8eaea;
  color: #8d2929;
}

.patient-open-button {
  white-space: nowrap;
}

.patients-card-list {
  display: none;
}

.patient-card {
  border: 1px solid #dbe3ea;
  border-radius: 15px;
  background: #ffffff;
  overflow: clip;
}

.patient-card-main {
  width: 100%;
  min-height: 84px;
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) 20px;
  gap: 10px;
  align-items: center;
  background: #ffffff;
  color: #172033;
  padding: 12px;
  text-align: left;
}

.patient-card-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.patient-card-copy strong,
.patient-card-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.patient-card-copy strong {
  color: #172033;
  font-size: 15px;
}

.patient-card-copy small {
  color: #6d7888;
  font-size: 12px;
}

.patient-card-chevron {
  color: #8b97a5;
  font-size: 26px;
  line-height: 1;
}

.patient-card-footer {
  min-height: 41px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-top: 1px solid #edf1f4;
  padding: 7px 10px;
}

.patient-mini-wa {
  color: #176347;
  font-size: 12px;
  font-weight: 750;
  text-decoration: none;
}

.patients-empty {
  display: grid;
  gap: 5px;
  border: 1px dashed #cfd9e1;
  border-radius: 14px;
  background: #ffffff;
  color: #6b7280;
  padding: 24px;
  text-align: center;
}

.patients-empty strong {
  color: #334155;
}

.patients-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px 0 4px;
}

.patients-pagination > span {
  color: #667085;
  font-size: 13px;
}

/* Overlays are direct children of body. No transformed/clipped ancestor. */
.v2-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  display: flex;
  align-items: stretch;
  justify-content: center;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  background: rgba(12, 21, 34, .62);
  padding: max(12px, env(safe-area-inset-top, 0px)) max(12px, env(safe-area-inset-right, 0px)) max(12px, env(safe-area-inset-bottom, 0px)) max(12px, env(safe-area-inset-left, 0px));
}

.v2-overlay[hidden] {
  display: none !important;
}

.v2-sheet {
  position: relative;
  width: min(100%, 980px);
  min-height: 0;
  margin: auto;
  border: 1px solid #dbe3ea;
  border-radius: 18px;
  background: #ffffff;
  color: #172033;
  box-shadow: 0 24px 70px rgba(7, 14, 25, .26);
}

.v2-sheet-header {
  position: sticky;
  top: 0;
  z-index: 4;
  min-height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid #e4e9ed;
  border-radius: 18px 18px 0 0;
  background: #ffffff;
  color: #172033;
  padding: 14px 16px;
}

.v2-sheet-header h2 {
  color: #172033;
  font-size: clamp(21px, 4vw, 27px);
  line-height: 1.14;
  font-weight: 820;
}

.patient-profile-sheet {
  overflow: visible;
}

.patient-profile-identity {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.patient-avatar {
  width: 52px;
  height: 52px;
  flex: 0 0 52px;
  font-size: 14px;
}

.patient-avatar img,
.patient-photo-preview img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.patient-profile-subtitle {
  margin-top: 3px;
  color: #697586;
  font-size: 13px;
}

.patient-profile-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  border-bottom: 1px solid #edf1f4;
  background: #ffffff;
  padding: 12px 16px;
}

.patient-section-picker {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: #f8fafb;
}

.patient-section-picker > span {
  color: #657184;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.patient-section-picker select {
  min-width: 220px;
  min-height: 42px;
  border: 1px solid #cbd5df;
  border-radius: 10px;
  background: #ffffff;
  color: #172033;
  padding: 8px 10px;
}

.patient-profile-panels {
  min-height: 260px;
  background: #ffffff;
  padding: 16px;
}

.patient-summary-grid,
.patient-data-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.patient-summary-grid > div,
.patient-data-grid > div {
  min-width: 0;
  display: grid;
  gap: 4px;
  border: 1px solid #e2e8ed;
  border-radius: 12px;
  background: #fbfcfd;
  padding: 12px;
}

.patient-summary-grid span,
.patient-data-grid span {
  color: #778292;
  font-size: 11px;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.patient-summary-grid strong,
.patient-data-grid strong {
  overflow-wrap: anywhere;
  color: #273244;
  font-size: 14px;
  line-height: 1.35;
}

.patient-primary-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.patient-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.patient-section-title h3,
.patient-form-section h3,
.patient-photo-block h3 {
  color: #283548;
  font-size: 16px;
  line-height: 1.25;
  font-weight: 800;
}

.patient-appointments {
  display: grid;
  gap: 8px;
}

.patient-appointment-card {
  display: grid;
  gap: 3px;
  border: 1px solid #dfe6eb;
  border-radius: 12px;
  background: #ffffff;
  padding: 11px 12px;
}

.patient-appointment-card strong {
  color: #283548;
  font-size: 14px;
}

.patient-appointment-card span,
.patient-appointment-card small {
  color: #697586;
  font-size: 12px;
}

.patient-load-more {
  width: 100%;
  margin-top: 10px;
}

.patient-profile-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  border-top: 1px solid #e4e9ed;
  border-radius: 0 0 18px 18px;
  background: #f8fafb;
  padding: 12px 16px;
}

.csp-button-danger {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #c44c4c;
  border-radius: 11px;
  background: #b63333;
  color: #ffffff;
  padding: 10px 14px;
  font-size: 14px;
  line-height: 1.2;
  font-weight: 750;
}

.patient-form-sheet {
  width: min(100%, 1040px);
}

.patient-form-body {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.patient-photo-block,
.patient-form-section {
  border: 1px solid #e0e7ec;
  border-radius: 14px;
  background: #ffffff;
  padding: 14px;
}

.patient-photo-block {
  display: grid;
  grid-template-columns: 90px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
}

.patient-photo-preview {
  width: 90px;
  height: 90px;
  font-size: 20px;
}

.patient-inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 9px;
}

.patient-file-button {
  position: relative;
  overflow: clip;
}

.patient-file-button input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: .001;
  cursor: pointer;
}

.patient-quiet-button {
  min-height: 42px;
  border-radius: 10px;
  background: #f2f5f7;
  color: #7c3030;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 700;
}

.patient-form-section {
  display: grid;
  gap: 12px;
}

.patient-form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.patient-form-grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.patient-form-grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.patient-form-grid-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.patient-span-2 {
  grid-column: span 2;
}

.patient-span-3 {
  grid-column: span 3;
}

.patient-field input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]) {
  min-height: 46px;
  border-radius: 11px;
}

.patient-field small {
  color: #768292;
  font-size: 11px;
}

.patient-repeater {
  display: grid;
  gap: 9px;
}

.patient-repeater-row {
  position: relative;
  display: grid;
  grid-template-columns: 150px minmax(180px, 1fr) minmax(130px, .7fr) auto auto 42px;
  gap: 8px;
  align-items: end;
  border: 1px solid #e0e7ec;
  border-radius: 12px;
  background: #f9fbfc;
  padding: 10px;
}

.patient-document-row {
  grid-template-columns: 160px minmax(0, 1fr) 42px;
}

.patient-responsible-row {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: end;
  padding-right: 54px;
}

.patient-responsible-row .patient-remove-row {
  position: absolute;
  top: 10px;
  right: 10px;
}

.patient-repeater-grow {
  min-width: 0;
}

.patient-check {
  min-height: 46px;
  display: flex;
  align-items: center;
  gap: 7px;
  color: #536173;
  font-size: 12px;
}

.patient-check input[type="checkbox"] {
  width: 18px;
  min-width: 18px;
  height: 18px;
  margin: 0;
  accent-color: #176b63;
}

.patient-remove-row {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid #e1b6b6;
  border-radius: 10px;
  background: #fff4f4;
  color: #9b3030;
  font-size: 20px;
  line-height: 1;
}

.patient-form-footer {
  position: sticky;
  bottom: 0;
  z-index: 4;
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  border-top: 1px solid #dfe6eb;
  border-radius: 0 0 18px 18px;
  background: #ffffff;
  padding: 12px 16px max(12px, env(safe-area-inset-bottom, 0px));
}

.patient-duplicate-box {
  margin: 14px 16px 0;
  border: 1px solid #e4c36d;
  border-radius: 12px;
  background: #fff9e8;
  color: #6f521b;
  padding: 12px;
}

.patient-duplicate-box p,
.patient-duplicate-box ul {
  margin-top: 6px;
  font-size: 13px;
}

.patient-duplicate-box ul {
  padding-left: 18px;
}

@media (max-width: 760px) {
  .v2-main {
    padding: 12px 10px 22px;
  }

  .patients-page-head {
    align-items: stretch;
  }

  .patients-page-head > div {
    min-width: 0;
  }

  .patients-page-head > button {
    flex: 0 0 auto;
    align-self: end;
  }

  .patients-toolbar {
    padding: 10px;
  }

  .patients-search {
    grid-template-columns: 1fr;
  }

  .patients-filters {
    grid-template-columns: 1fr 1fr;
  }

  .patients-table-wrap {
    display: none;
  }

  .patients-card-list {
    display: grid;
    gap: 8px;
  }

  .patients-status-line {
    align-items: flex-start;
    flex-direction: column;
    gap: 2px;
  }

  .v2-overlay {
    align-items: stretch;
    padding: 0;
    background: #ffffff;
  }

  .v2-sheet,
  .patient-form-sheet {
    width: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    margin: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .v2-sheet-header {
    top: 0;
    min-height: 66px;
    border-radius: 0;
    padding: max(10px, env(safe-area-inset-top, 0px)) max(12px, env(safe-area-inset-right, 0px)) 10px max(12px, env(safe-area-inset-left, 0px));
  }

  .patient-profile-actions,
  .patient-section-picker,
  .patient-profile-panels,
  .patient-form-body {
    padding-left: max(12px, env(safe-area-inset-left, 0px));
    padding-right: max(12px, env(safe-area-inset-right, 0px));
  }

  .patient-section-picker {
    align-items: stretch;
    flex-direction: column;
    gap: 5px;
  }

  .patient-section-picker select {
    width: 100%;
    min-width: 0;
  }

  .patient-summary-grid,
  .patient-data-grid {
    grid-template-columns: 1fr;
  }

  .patient-primary-links,
  .patient-profile-actions,
  .patient-profile-footer,
  .patient-form-footer {
    display: grid;
    grid-template-columns: 1fr;
  }

  .patient-profile-actions > *,
  .patient-primary-links > *,
  .patient-profile-footer > *,
  .patient-form-footer > * {
    width: 100%;
  }

  .patient-profile-footer {
    border-radius: 0;
    padding-bottom: max(14px, env(safe-area-inset-bottom, 0px));
  }

  .patient-form-grid-2,
  .patient-form-grid-3,
  .patient-form-grid-4 {
    grid-template-columns: 1fr;
  }

  .patient-span-2,
  .patient-span-3 {
    grid-column: 1;
  }

  .patient-photo-block {
    grid-template-columns: 72px minmax(0, 1fr);
    gap: 11px;
  }

  .patient-photo-preview {
    width: 72px;
    height: 72px;
  }

  .patient-section-title {
    align-items: stretch;
    flex-direction: column;
  }

  .patient-section-title > button {
    width: 100%;
  }

  .patient-repeater-row,
  .patient-document-row,
  .patient-responsible-row {
    grid-template-columns: 1fr;
    padding: 10px;
    padding-top: 50px;
  }

  .patient-repeater-row .patient-remove-row,
  .patient-responsible-row .patient-remove-row {
    position: absolute;
    top: 8px;
    right: 8px;
  }

  .patient-check {
    min-height: 36px;
  }

  .patient-form-footer {
    position: sticky;
    bottom: 0;
    border-radius: 0;
    padding-left: max(12px, env(safe-area-inset-left, 0px));
    padding-right: max(12px, env(safe-area-inset-right, 0px));
  }
}

@media (max-width: 430px) {
  .patients-page-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
  }

  .patients-page-head > div > p:last-child {
    display: none;
  }

  .patients-page-head h1 {
    font-size: 25px;
  }

  .patients-page-head > button {
    min-height: 42px;
    padding: 8px 11px;
  }

  .patients-filters {
    grid-template-columns: 1fr;
  }

  .patient-card-main {
    grid-template-columns: 42px minmax(0, 1fr) 18px;
  }

  .patient-list-avatar {
    width: 42px;
    height: 42px;
  }

  .patient-profile-identity {
    gap: 9px;
  }

  .patient-avatar {
    width: 44px;
    height: 44px;
    flex-basis: 44px;
  }

  .v2-sheet-header h2 {
    max-width: 225px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 20px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .csp-patients-v2 *,
  .csp-patients-v2 *::before,
  .csp-patients-v2 *::after,
  .v2-overlay *,
  .v2-overlay *::before,
  .v2-overlay *::after {
    scroll-behavior: auto !important;
    transition: none !important;
    animation: none !important;
  }
}

/* =========================================================
   CSP AI Clinic V2 — Prontuário
   Sem dialog nativo. Sem backdrop-filter. Mobile first.
   ========================================================= */

.clinical-v2 {
  width: min(100%, 1480px);
  margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}

.clinical-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 0 18px;
}

.clinical-hero h1 {
  margin-top: 3px;
  color: #172033;
  font-size: clamp(25px, 4vw, 34px);
  line-height: 1.15;
}

.clinical-hero p:last-child {
  margin-top: 7px;
  color: #64748b;
  font-size: 14px;
  line-height: 1.5;
}

.clinical-hero-actions,
.clinical-inline-actions,
.clinical-empty-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.clinical-hero-actions .csp-button-secondary,
.clinical-hero-actions .csp-whatsapp-button,
.clinical-inline-actions .csp-button-secondary,
.clinical-inline-actions .csp-button-primary,
.clinical-empty-actions .csp-button-primary,
.clinical-empty-actions .csp-button-secondary,
.clinical-history-actions .csp-button-secondary {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 11px;
  padding: 9px 13px;
  text-decoration: none;
  font-size: 14px;
  font-weight: 750;
  line-height: 1.2;
}

.clinical-notice {
  margin-bottom: 16px;
  border: 1px solid #c8ddd8;
  border-radius: 13px;
  background: #edf8f5;
  color: #145f53;
  padding: 12px 14px;
  font-size: 14px;
  line-height: 1.45;
}

.clinical-notice.compact {
  margin: 12px 0;
}

.clinical-notice.is-error {
  border-color: #efc6c6;
  background: #fff2f2;
  color: #9b1c1c;
}

.clinical-empty {
  max-width: 720px;
  margin: 32px auto;
  border: 1px solid #dde5ec;
  border-radius: 18px;
  background: #ffffff;
  padding: 28px;
}

.clinical-empty h2 {
  color: #172033;
  font-size: 22px;
  line-height: 1.2;
}

.clinical-empty p {
  margin: 8px 0 18px;
  color: #64748b;
}

.clinical-context-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.clinical-context-grid article {
  min-width: 0;
  display: grid;
  gap: 4px;
  border: 1px solid #dde5ec;
  border-radius: 15px;
  background: #ffffff;
  padding: 15px;
}

.clinical-context-grid span {
  color: #708090;
  font-size: 12px;
  line-height: 1.2;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.clinical-context-grid strong {
  overflow-wrap: anywhere;
  color: #172033;
  font-size: 15px;
  line-height: 1.35;
}

.clinical-context-grid small {
  overflow-wrap: anywhere;
  color: #64748b;
  font-size: 12px;
  line-height: 1.4;
}

.clinical-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(300px, .8fr);
  gap: 16px;
  align-items: start;
}

.clinical-layout.is-history-only {
  grid-template-columns: 1fr;
  max-width: 980px;
  margin: 0 auto;
}

.clinical-layout.is-history-only .clinical-history-card {
  position: static;
  max-height: none;
  overflow: visible;
}

.clinical-workspace {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.clinical-editor-card,
.clinical-card,
.clinical-history-card {
  min-width: 0;
  border: 1px solid #dde5ec;
  border-radius: 18px;
  background: #ffffff;
  color: #172033;
  padding: 20px;
}

.clinical-history-card {
  position: sticky;
  top: 86px;
  max-height: calc(100dvh - 178px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

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

.clinical-card-head h2 {
  margin-top: 3px;
  color: #172033;
  font-size: 20px;
  line-height: 1.2;
}

.clinical-state,
.clinical-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  background: #eef5f4;
  color: #176b63;
  padding: 5px 10px;
  font-size: 12px;
  line-height: 1.1;
  font-weight: 750;
}

.clinical-badge.is-current {
  background: #e7f7ef;
  color: #126342;
}

.clinical-help {
  margin-top: 8px;
  color: #64748b;
  font-size: 14px;
  line-height: 1.5;
}

.clinical-field {
  display: grid;
  gap: 7px;
  margin-top: 16px;
}

.clinical-field > span {
  color: #334155;
  font-size: 14px;
  line-height: 1.35;
  font-weight: 700;
}

.clinical-field textarea,
.clinical-field select,
.clinical-field input:not([type="file"]):not([type="hidden"]) {
  width: 100%;
  min-width: 0;
  border: 1px solid #cbd5df;
  border-radius: 12px;
  background: #ffffff;
  color: #172033;
  padding: 12px 14px;
  outline: none;
  font-size: 16px;
  line-height: 1.5;
}

.clinical-field select,
.clinical-field input:not([type="file"]):not([type="hidden"]) {
  min-height: 48px;
}

.clinical-field textarea {
  min-height: 150px;
  resize: vertical;
}

.clinical-editor-card .clinical-field textarea {
  min-height: 380px;
}

.clinical-field textarea:focus,
.clinical-field select:focus,
.clinical-field input:not([type="file"]):not([type="hidden"]):focus {
  border-color: #176b63;
  box-shadow: 0 0 0 3px rgba(23,107,99,.13);
}

.clinical-field textarea:disabled,
.clinical-field select:disabled,
.clinical-field input:disabled {
  background: #f6f8fa;
  color: #526173;
}

.clinical-editor-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.clinical-counter {
  color: #64748b;
  font-size: 12px;
}

.clinical-details > summary,
.clinical-subdetails > summary {
  cursor: pointer;
  color: #172033;
  font-weight: 750;
  line-height: 1.35;
}

.clinical-details > summary {
  font-size: 16px;
}

.clinical-details-body {
  padding-top: 18px;
}

.clinical-template-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.clinical-template-row .clinical-field {
  margin-top: 0;
}

.clinical-subdetails {
  margin-top: 16px;
  border-top: 1px solid #e5ebf0;
  padding-top: 15px;
}

.clinical-template-editor {
  padding-top: 6px;
}

.clinical-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.clinical-span-2 {
  grid-column: span 2;
}

.clinical-file-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 16px 0;
}

.clinical-file-card {
  display: grid;
  gap: 5px;
  min-width: 0;
  border: 1px dashed #b9c7d2;
  border-radius: 14px;
  background: #f8fafb;
  padding: 14px;
}

.clinical-file-card strong {
  color: #172033;
  font-size: 14px;
}

.clinical-file-card span {
  color: #64748b;
  font-size: 12px;
}

.clinical-file-card input[type="file"] {
  width: 100%;
  margin-top: 7px;
  color: #425466;
  font-size: 13px;
}

.clinical-attachment-list,
.clinical-history {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.clinical-attachment-item,
.clinical-history-item {
  min-width: 0;
  border: 1px solid #e1e7ec;
  border-radius: 14px;
  background: #fbfcfd;
  padding: 14px;
}

.clinical-attachment-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.clinical-attachment-item > div:first-child {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.clinical-attachment-item strong {
  overflow-wrap: anywhere;
  color: #172033;
  font-size: 14px;
}

.clinical-attachment-item span {
  color: #64748b;
  font-size: 12px;
}

.clinical-history-item.is-current {
  border-color: #83b8ac;
  background: #f3fbf8;
}

.clinical-history-meta {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.clinical-history-meta strong {
  color: #172033;
  font-size: 13px;
  line-height: 1.4;
}

.clinical-history-meta span,
.clinical-history-professional {
  color: #64748b;
  font-size: 12px;
  line-height: 1.4;
}

.clinical-history-professional {
  margin-top: 3px;
}

.clinical-history-text {
  max-height: 220px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  margin-top: 10px;
  border-top: 1px solid #e5ebf0;
  padding-top: 10px;
  color: #334155;
  font-size: 13px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.clinical-history-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 11px;
}

.clinical-load-more {
  width: 100%;
  margin-top: 12px;
}

@media (max-width: 980px) {
  .clinical-context-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .clinical-layout {
    grid-template-columns: 1fr;
  }

  .clinical-history-card {
    position: static;
    max-height: none;
    overflow: visible;
  }
}

@media (max-width: 640px) {
  .clinical-v2 {
    padding-left: max(12px, env(safe-area-inset-left, 0px));
    padding-right: max(12px, env(safe-area-inset-right, 0px));
  }

  .clinical-hero {
    display: grid;
    gap: 14px;
    padding-top: 16px;
  }

  .clinical-hero-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }

  .clinical-hero-actions > * {
    width: 100%;
  }

  .clinical-context-grid {
    grid-template-columns: 1fr;
  }

  .clinical-editor-card,
  .clinical-card,
  .clinical-history-card {
    border-radius: 15px;
    padding: 16px;
  }

  .clinical-editor-card .clinical-field textarea {
    min-height: 52dvh;
    max-height: 68dvh;
  }

  .clinical-editor-footer,
  .clinical-card-head,
  .clinical-attachment-item,
  .clinical-history-meta {
    align-items: stretch;
  }

  .clinical-editor-footer,
  .clinical-attachment-item {
    display: grid;
  }

  .clinical-editor-footer .csp-button-primary,
  .clinical-attachment-item .clinical-inline-actions,
  .clinical-attachment-item .clinical-inline-actions > * {
    width: 100%;
  }

  .clinical-template-row,
  .clinical-form-grid,
  .clinical-file-options {
    grid-template-columns: 1fr;
  }

  .clinical-span-2 {
    grid-column: auto;
  }

  .clinical-file-card input[type="file"] {
    min-height: 44px;
  }

  .clinical-history-text {
    max-height: none;
    overflow: visible;
  }
}

/* CSP AI Clinic V2 — correção do modal da consulta no mobile.
   Quando a consulta existente abre em modo-resumo, exibe somente
   o resumo operacional e suas ações. O formulário completo volta
   ao tocar em "Editar dados". */
@media (max-width: 760px) {
  .csp-agenda-dialog.is-mobile-summary .csp-form-error-summary,
  .csp-agenda-dialog.is-mobile-summary .csp-fit-in-notice,
  .csp-agenda-dialog.is-mobile-summary .csp-form-grid,
  .csp-agenda-dialog.is-mobile-summary .csp-agenda-dialog-actions {
    display: none !important;
  }

  .csp-agenda-dialog.is-mobile-summary .csp-appointment-mobile-summary {
    display: grid;
  }
}

/* =========================================================
   CSP AI Clinic V2 — shell visual alinhado ao aplicativo atual
   0.22.5 / frontend v7
   ========================================================= */

:root {
  --v2-brand-bar: #004D40;
  --v2-brand-accent: #12a58c;
  --v2-shell-border: #dce4e8;
  --v2-shell-text: #172033;
}

/* Regra semântica necessária para accordions/modais controlados por hidden. */
.csp-v2 [hidden] {
  display: none !important;
}

.v2-shell-topbar {
  position: sticky;
  top: 0;
  z-index: 80;
  min-height: 72px;
  display: grid;
  grid-template-columns: auto minmax(180px, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding:
    max(10px, env(safe-area-inset-top, 0px))
    max(14px, env(safe-area-inset-right, 0px))
    10px
    max(14px, env(safe-area-inset-left, 0px));
  background: var(--v2-brand-bar);
  color: #fff;
  border-bottom: 0;
  box-shadow: 0 1px 0 rgba(15, 23, 42, .08);
  overflow: visible;
}

.v2-shell-topbar .v2-brand {
  min-width: 0;
  color: #fff;
}

.v2-brand-symbol {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  display: block;
  object-fit: contain;
  border-radius: 12px;
}

.v2-shell-topbar .v2-brand-label {
  display: grid;
  gap: 1px;
}

.v2-shell-topbar .v2-brand-label small,
.v2-shell-topbar .v2-brand-label strong {
  color: #fff;
}

.v2-shell-topbar .v2-brand-label small {
  font-size: 10px;
  font-weight: 850;
  letter-spacing: .12em;
}

.v2-shell-topbar .v2-brand-label strong {
  font-size: 18px;
  line-height: 1.15;
  font-weight: 850;
}

.v2-topbar-context {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}

.v2-topbar-context strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 16px;
  font-weight: 850;
}

.v2-agenda-top-date {
  min-width: 0;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  align-items: center;
  gap: 4px;
}

.v2-agenda-top-date button,
.v2-training-launch,
.v2-avatar-button {
  -webkit-appearance: none;
  appearance: none;
  border: 0;
  background: transparent;
  color: #fff;
}

.v2-agenda-top-date > button {
  min-width: 44px;
  min-height: 44px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  padding: 0;
}

.v2-agenda-top-date svg,
.v2-training-launch svg,
.v2-profile-menu svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.v2-agenda-top-date-label {
  min-width: 0 !important;
  width: 100%;
  padding: 0 8px !important;
  font-size: 15px;
  font-weight: 850;
  line-height: 1.2;
  text-align: center;
}

.v2-agenda-top-date-label span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.v2-topbar-actions {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
}

.v2-training-launch {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255,255,255,.30);
  border-radius: 13px;
  background: rgba(255,255,255,.08);
  text-decoration: none;
}

.v2-profile {
  position: relative;
  overflow: visible;
}

.v2-avatar-button {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 2px solid rgba(255,255,255,.72);
  border-radius: 999px;
  padding: 0;
  background: rgba(255,255,255,.12);
}

.v2-avatar-button img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.v2-avatar-button [data-v2-avatar-fallback] {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 13px;
  font-weight: 850;
}

.v2-avatar-button [data-v2-avatar-fallback] svg {
  width: 23px;
  height: 23px;
}

.v2-profile-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 120;
  width: min(320px, calc(100vw - 24px));
  max-height: min(620px, calc(100dvh - 92px));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--v2-shell-border);
  border-radius: 16px;
  background: #fff;
  color: var(--v2-shell-text);
  padding: 8px;
  box-shadow: 0 18px 50px rgba(15,23,42,.22);
}

.v2-profile-name {
  padding: 10px 11px 11px;
  color: #172033;
  font-size: 14px;
  font-weight: 850;
  border-bottom: 1px solid #edf1f3;
  margin-bottom: 4px;
}

.v2-profile-menu a,
.v2-profile-menu button {
  width: 100%;
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 11px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #334155;
  padding: 9px 10px;
  text-align: left;
  text-decoration: none;
  font: inherit;
  font-size: 13px;
  font-weight: 720;
}

.v2-profile-menu a:hover,
.v2-profile-menu button:hover,
.v2-profile-menu a:focus-visible,
.v2-profile-menu button:focus-visible {
  background: #f2f7f6;
  color: #005b4f;
}

.v2-profile-menu-icon {
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  display: grid;
  place-items: center;
}

.v2-profile-menu-icon svg {
  width: 20px;
  height: 20px;
}

.v2-profile-separator {
  height: 1px;
  margin: 5px 6px;
  background: #e6ecef;
}

/* Accordion real: qualquer body marcado hidden precisa sair do layout. */
.csp-agenda-controls-body[hidden],
.csp-agenda-summary-body[hidden] {
  display: none !important;
}

.csp-agenda-disclosure-toggle[aria-expanded="false"] .v2-icon {
  transform: rotate(-90deg);
}

.csp-agenda-disclosure-toggle[aria-expanded="true"] .v2-icon {
  transform: rotate(0deg);
}

/* Navegação inferior próxima ao aplicativo atual, sem blur para Safari/iOS. */
.app-tabbar {
  left: 12px;
  right: 12px;
  bottom: max(8px, env(safe-area-inset-bottom, 0px));
  width: auto;
  border: 1px solid rgba(213, 222, 226, .92);
  border-radius: 28px;
  background: rgba(248, 250, 250, .97);
  padding: 5px 7px;
  box-shadow: 0 10px 30px rgba(15,23,42,.12);
}

.app-tabbar a {
  min-height: 58px;
  border-radius: 22px;
  color: #475569;
}

.app-tabbar a.is-active {
  background: #e7f4f1;
  color: #00695c;
}

/* A antiga quickbar móvel fica redundante: data e calendário agora estão no topbar. */
@media (max-width: 760px) {
  body.csp-v2-app {
    padding-bottom: calc(88px + env(safe-area-inset-bottom, 0px));
  }

  .v2-shell-topbar {
    min-height: 74px;
    grid-template-columns: 48px minmax(0, 1fr) auto;
    gap: 5px;
    padding:
      max(8px, env(safe-area-inset-top, 0px))
      max(10px, env(safe-area-inset-right, 0px))
      8px
      max(10px, env(safe-area-inset-left, 0px));
  }

  .v2-shell-topbar .v2-brand {
    width: 48px;
    min-width: 48px;
    justify-content: flex-start;
  }

  .v2-brand-symbol {
    width: 42px;
    height: 42px;
  }

  .v2-shell-topbar .v2-brand-label {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0,0,0,0) !important;
    white-space: nowrap !important;
    border: 0 !important;
  }

  .v2-topbar-context {
    grid-column: 2;
    grid-row: 1;
  }

  .v2-topbar-context strong {
    font-size: 15px;
  }

  .v2-agenda-top-date {
    grid-column: 2;
    grid-row: 1;
    grid-template-columns: 42px minmax(0, 1fr) 42px;
  }

  .v2-agenda-top-date > button {
    min-width: 42px;
    min-height: 46px;
  }

  .v2-agenda-top-date-label {
    font-size: 15px;
    padding-inline: 4px !important;
  }

  .v2-topbar-actions {
    grid-column: 3;
    grid-row: 1;
    gap: 3px;
  }

  .v2-training-launch {
    width: 46px;
    height: 46px;
    border-radius: 13px;
  }

  .v2-avatar-button {
    width: 48px;
    height: 48px;
  }

  .v2-profile-menu {
    position: fixed;
    top: calc(74px + env(safe-area-inset-top, 0px));
    right: max(10px, env(safe-area-inset-right, 0px));
    left: max(10px, env(safe-area-inset-left, 0px));
    width: auto;
    max-height: calc(100dvh - 92px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  }

  .csp-agenda-mobile-quickbar {
    display: none !important;
  }

  .csp-agenda-toolbar {
    margin-top: 4px;
  }

  .csp-agenda-disclosure-toggle {
    min-height: 64px;
    border: 0;
    background: transparent;
    padding: 5px 8px;
  }

  .csp-agenda-disclosure-toggle strong {
    font-size: 16px;
    color: #172033;
  }

  .csp-agenda-disclosure-toggle small {
    color: #667085;
    font-size: 13px;
  }

  .csp-agenda-toolbar.is-controls-collapsed,
  .csp-agenda-app.is-controls-collapsed .csp-agenda-toolbar {
    padding-bottom: 7px;
  }

  .app-tabbar {
    z-index: 75;
  }
}

@media (min-width: 761px) {
  .v2-agenda-top-date {
    max-width: 540px;
    justify-self: center;
  }
}

.app-tabbar .app-tabbar-icon {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  font-size: 0;
}
.app-tabbar .app-tabbar-icon svg {
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
