:root {
  color-scheme: light;
  --ink: #10201f;
  --muted: #647875;
  --line: #dbe7e4;
  --surface: #ffffff;
  --surface-soft: #f6faf9;
  --page: #edf5f3;
  --teal: #0f766e;
  --teal-dark: #0b4f4a;
  --mint: #d9fff7;
  --gold: #f6d365;
  --coral: #e95f4d;
  --blue: #2f6fed;
  --success: #12a66a;
  --warning: #d39b16;
  --danger: #d94f3d;
  --violet: #6c5ce7;
  --night: #10201f;
  --shadow: 0 18px 50px rgba(20, 54, 50, 0.12);
  font-family: "Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    linear-gradient(110deg, rgba(15, 118, 110, 0.08), transparent 36%),
    linear-gradient(180deg, #f9fcfb 0%, var(--page) 100%);
}

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

button {
  cursor: pointer;
}

button,
a,
.metric-card,
.panel,
.cash-day,
.patient-card,
.appointment,
.slot,
.finance-kpi,
.charge-list article {
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease, background 180ms ease, color 180ms ease;
}

button:hover,
.metric-card:hover,
.patient-card:hover,
.appointment:hover,
.slot:hover,
.charge-list article:hover {
  transform: translateY(-1px);
}

body.modal-open {
  overflow: hidden;
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 22px;
  background:
    linear-gradient(135deg, rgba(9, 47, 44, 0.94), rgba(15, 118, 110, 0.76)),
    linear-gradient(180deg, #f9fcfb 0%, var(--page) 100%);
}

.login-screen.is-hidden {
  display: none;
}

.login-card {
  width: min(520px, 100%);
  padding: 28px;
  border: 1px solid rgba(255, 255, 255, 0.38);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

.login-brand {
  margin-bottom: 24px;
  color: var(--teal-dark);
}

.login-card h1 {
  margin-bottom: 18px;
  font-size: clamp(28px, 5vw, 42px);
}

.login-form {
  display: grid;
  gap: 13px;
}

.trial-login-note {
  border: 1px solid rgba(15, 118, 110, 0.18);
  border-radius: 8px;
  padding: 10px 12px;
  background: rgba(15, 118, 110, 0.08);
  color: var(--teal-dark);
  font-weight: 800;
}

.login-form label,
.quick-form label,
.cash-entry-form label,
.record-form label,
.goal-list label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 820;
}

.login-form input,
.quick-form input,
.quick-form select,
.quick-form textarea,
.cash-entry-form input,
.cash-entry-form select,
.record-form input,
.record-form textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  padding: 12px;
}

.cash-entry-form input,
.cash-entry-form select {
  min-height: 42px;
  padding: 0 12px;
}

input:focus,
textarea:focus,
select:focus {
  border-color: rgba(15, 118, 110, 0.48);
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.1);
  outline: 0;
}

.app-shell {
  display: grid;
  grid-template-columns: 272px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 28px;
  height: 100vh;
  padding: 24px 18px;
  color: #e9fffb;
  background: linear-gradient(180deg, #092f2c 0%, #0d4f49 58%, #123936 100%);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: #ffffff;
  font-size: 25px;
  font-weight: 800;
  text-decoration: none;
}

.brand-mark {
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  filter: drop-shadow(0 12px 18px rgba(0, 0, 0, 0.18));
}

.main-nav {
  display: grid;
  gap: 7px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  width: 100%;
  border: 0;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.76);
  background: transparent;
  padding: 0 12px;
  text-align: left;
  font-weight: 780;
}

.nav-item:hover,
.nav-item.active {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.12);
}

.clinic-switcher {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: auto;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
}

.clinic-switcher strong,
.clinic-switcher span {
  display: block;
}

.clinic-switcher strong {
  font-size: 14px;
}

.clinic-switcher span {
  color: rgba(255, 255, 255, 0.66);
  font-size: 12px;
}

.clinic-avatar {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  color: var(--teal-dark);
  background: var(--gold);
  font-weight: 800;
}

.clinic-logout {
  min-height: 32px;
  margin-left: auto;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.1);
  padding: 0 10px;
  font-size: 12px;
  font-weight: 800;
}

.workspace {
  min-width: 0;
  padding: 24px clamp(16px, 3vw, 36px) 42px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 860;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(26px, 3vw, 42px);
  line-height: 1.05;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: min(100%, 650px);
}

.search {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 260px;
  flex: 1;
  height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
}

.search input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
}

.icon-button,
.primary-action,
.ghost-action,
.appointment button,
.segmented button {
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}

.icon-button {
  display: grid;
  place-items: center;
  width: 44px;
  flex: 0 0 auto;
}

.primary-action {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  border-color: var(--teal);
  color: #ffffff;
  background: linear-gradient(135deg, var(--teal), #0f8f82);
  padding: 0 16px;
  font-weight: 850;
  white-space: nowrap;
  box-shadow: 0 10px 22px rgba(15, 118, 110, 0.18);
}

.primary-action:hover {
  box-shadow: 0 14px 26px rgba(15, 118, 110, 0.24);
}

.primary-action:disabled {
  cursor: default;
  opacity: 0.78;
  box-shadow: none;
}

.ghost-action {
  padding: 0 14px;
  font-weight: 760;
}

.hero-band {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(260px, 0.7fr);
  gap: 20px;
  margin-bottom: 18px;
  padding: clamp(22px, 3vw, 34px);
  border-radius: 8px;
  color: #ffffff;
  background:
    linear-gradient(135deg, rgba(11, 79, 74, 0.97), rgba(20, 62, 86, 0.92)),
    url("data:image/svg+xml,%3Csvg width='960' height='420' viewBox='0 0 960 420' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='%23d9fff7' stroke-opacity='.22' stroke-width='2'%3E%3Cpath d='M0 340C150 238 277 390 420 250S670 54 960 126'/%3E%3Cpath d='M0 285C130 210 270 315 384 200S652 92 960 48'/%3E%3Cpath d='M0 392C164 334 250 424 400 330S672 166 960 214'/%3E%3C/g%3E%3Crect x='756' y='42' width='128' height='78' rx='18' fill='%23f6d365' fill-opacity='.20'/%3E%3Crect x='74' y='318' width='104' height='56' rx='16' fill='%23ffffff' fill-opacity='.12'/%3E%3C/svg%3E");
  background-size: cover;
  box-shadow: var(--shadow);
}

.hero-copy h2 {
  max-width: 760px;
  margin-bottom: 12px;
  font-size: clamp(28px, 4vw, 52px);
  line-height: 1;
}

.hero-copy p:not(.eyebrow) {
  max-width: 680px;
  margin-bottom: 0;
  color: rgba(255, 255, 255, 0.8);
  font-size: 16px;
  line-height: 1.55;
}

.hero-band .eyebrow {
  color: var(--gold);
}

.hero-panel {
  align-self: stretch;
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.11);
  backdrop-filter: blur(12px);
}

.mini-calendar {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  text-align: center;
}

.mini-calendar span,
.mini-calendar strong {
  display: grid;
  place-items: center;
  min-height: 34px;
  border-radius: 8px;
}

.mini-calendar span {
  color: rgba(255, 255, 255, 0.7);
  font-size: 12px;
}

.mini-calendar strong {
  background: rgba(255, 255, 255, 0.12);
}

.mini-calendar .today {
  color: var(--teal-dark);
  background: var(--gold);
}

.hero-stat span {
  color: rgba(255, 255, 255, 0.75);
}

.hero-stat strong {
  display: block;
  margin: 6px 0 10px;
  font-size: 42px;
}

.progress {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
}

.progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--gold);
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric-card,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 12px 34px rgba(20, 54, 50, 0.07);
}

.metric-card {
  padding: 18px;
}

.metric-label,
.metric-card small {
  display: block;
  color: var(--muted);
}

.metric-card strong {
  display: block;
  margin: 8px 0 5px;
  font-size: 27px;
}

.metric-card small {
  font-weight: 700;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.65fr);
  gap: 18px;
}

.panel {
  min-width: 0;
  padding: 18px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.panel-header h3 {
  margin-bottom: 0;
  font-size: 20px;
}

.segmented {
  display: inline-grid;
  grid-template-columns: repeat(3, minmax(54px, 1fr));
  min-height: 38px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.segmented button {
  min-height: 30px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 760;
}

.segmented .selected {
  color: var(--teal-dark);
  background: #ffffff;
  box-shadow: 0 4px 12px rgba(20, 54, 50, 0.1);
}

.appointment-list,
.risk-list,
.patient-cards,
.action-list,
.goal-list,
.cash-entry-form {
  display: grid;
  gap: 10px;
}

.appointment {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 72px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.appointment time {
  color: var(--teal);
  font-weight: 850;
}

.appointment strong,
.appointment span {
  display: block;
}

.appointment span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.appointment button {
  padding: 0 12px;
  color: var(--teal-dark);
  font-weight: 800;
}

.appointment.urgent {
  border-color: rgba(233, 95, 77, 0.35);
  background: #fff8f6;
}

.appointment.muted {
  border-style: dashed;
  background: var(--surface-soft);
}

.risk-list article {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr);
  gap: 12px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}

.risk-list article:last-child {
  border-bottom: 0;
}

.risk-dot {
  width: 10px;
  height: 10px;
  margin-top: 5px;
  border-radius: 999px;
}

.risk-dot.high {
  background: var(--coral);
}

.risk-dot.medium {
  background: var(--gold);
}

.risk-dot.low {
  background: var(--blue);
}

.risk-list strong,
.risk-list p {
  margin: 0;
}

.risk-list p {
  margin-top: 4px;
  color: var(--muted);
  line-height: 1.4;
}

.patient-table {
  overflow: auto;
}

.table-row {
  display: grid;
  grid-template-columns: minmax(180px, 1.2fr) minmax(160px, 1fr) minmax(110px, 0.7fr) minmax(140px, 0.8fr) minmax(90px, 0.6fr);
  min-width: 760px;
  gap: 12px;
  align-items: center;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
}

.table-row:last-child {
  border-bottom: 0;
}

.table-head {
  color: var(--ink);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.table-row strong,
.table-row small,
.patient-card strong,
.patient-card small {
  display: block;
}

.table-row strong {
  color: var(--ink);
}

.table-row small,
.patient-card small {
  margin-top: 3px;
  color: var(--muted);
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 850;
}

.status.ok {
  color: #0d5f36;
  background: #dff9ea;
}

.status.warn {
  color: #765100;
  background: #fff1c7;
}

.finance-panel {
  display: grid;
}

.bar-chart {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  align-items: end;
  gap: 10px;
  height: 190px;
  padding: 12px;
  border-radius: 8px;
  background: var(--surface-soft);
}

.bar-chart span {
  min-height: 24px;
  border-radius: 8px 8px 3px 3px;
  background: linear-gradient(180deg, var(--teal), #75c9bd);
}

.finance-footer {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
}

.finance-footer strong {
  font-size: 26px;
}

.finance-footer span {
  color: var(--muted);
}

.page-view {
  display: none;
}

.page-view.active {
  display: block;
}

.module-layout.active {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.65fr);
  gap: 18px;
}

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

.schedule-column {
  display: grid;
  align-content: start;
  gap: 9px;
  min-height: 360px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.schedule-column > strong {
  margin-bottom: 5px;
}

.slot {
  display: grid;
  gap: 5px;
  min-height: 64px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 10px;
  color: var(--ink);
  text-align: left;
  font-weight: 760;
}

.slot span {
  color: var(--teal);
  font-size: 12px;
  font-weight: 900;
}

.slot.open {
  border-style: dashed;
  color: var(--teal-dark);
  background: #f0fffb;
}

.slot.alert {
  border-color: rgba(233, 95, 77, 0.34);
  color: #84291f;
  background: #fff7f5;
}

.action-list button {
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  padding: 0 13px;
  text-align: left;
  font-weight: 760;
}

.patient-card {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  text-align: left;
}

.patient-card.selected {
  border-color: rgba(15, 118, 110, 0.44);
  box-shadow: inset 4px 0 0 var(--teal);
}

.patient-card > span,
.profile-avatar {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 8px;
  color: var(--teal-dark);
  background: var(--mint);
  font-weight: 900;
}

.profile-panel {
  align-self: start;
}

.profile-head {
  display: flex;
  align-items: center;
  gap: 13px;
  margin-bottom: 18px;
}

.profile-head h3,
.profile-head p {
  margin: 0;
}

.profile-head p {
  margin-top: 4px;
  color: var(--muted);
}

.profile-data {
  display: grid;
  gap: 12px;
  margin: 0;
}

.profile-data div {
  padding: 12px;
  border-radius: 8px;
  background: var(--surface-soft);
}

.profile-data dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.profile-data dd {
  margin: 5px 0 0;
  font-weight: 780;
}

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

.record-form textarea {
  resize: vertical;
}

.form-wide {
  grid-column: 1 / -1;
}

.goal-list label {
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  min-height: 42px;
  border-bottom: 1px solid var(--line);
}

.goal-list input {
  accent-color: var(--teal);
}

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

.billing-grid article,
.insight-grid article {
  padding: 16px;
  border-radius: 8px;
  background: var(--surface-soft);
}

.billing-grid span,
.billing-grid small,
.insight-grid span,
.insight-grid small {
  display: block;
  color: var(--muted);
}

.billing-grid strong,
.insight-grid strong {
  display: block;
  margin: 7px 0 3px;
  font-size: 27px;
}

.finance-command-center.active {
  grid-template-columns: minmax(0, 1.58fr) minmax(320px, 0.52fr);
}

.finance-master-panel {
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(248, 252, 250, 0.9)),
    linear-gradient(135deg, rgba(15, 118, 110, 0.12), rgba(246, 211, 101, 0.12));
}

.finance-master-panel::before {
  content: "";
  position: absolute;
  top: 0;
  left: 18px;
  right: 18px;
  height: 4px;
  border-radius: 0 0 8px 8px;
  background: linear-gradient(90deg, var(--success), var(--gold), var(--blue), var(--coral));
}

.finance-titlebar {
  align-items: center;
}

.live-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  margin-left: auto;
  padding: 0 11px;
  border: 1px solid rgba(18, 166, 106, 0.22);
  border-radius: 999px;
  color: #0d5f36;
  background: #e9fff3;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.live-chip i {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--success);
  box-shadow: 0 0 0 6px rgba(18, 166, 106, 0.12);
}

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

.finance-kpi {
  position: relative;
  overflow: hidden;
  min-height: 128px;
  border: 1px solid rgba(16, 32, 31, 0.07);
  background: #ffffff;
  box-shadow: 0 12px 32px rgba(20, 54, 50, 0.08);
}

.finance-kpi::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 4px;
  background: var(--accent, var(--teal));
}

.finance-kpi span,
.finance-kpi small,
.finance-kpi strong {
  position: relative;
  z-index: 1;
}

.finance-kpi strong {
  font-size: clamp(23px, 2.4vw, 32px);
  line-height: 1;
}

.finance-kpi i {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 12px;
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(16, 32, 31, 0.08);
}

.finance-kpi i::after {
  content: "";
  display: block;
  width: var(--meter, 72%);
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent, var(--teal)), rgba(255, 255, 255, 0.2));
}

.finance-kpi.income {
  --accent: var(--success);
}

.finance-kpi.margin {
  --accent: var(--blue);
}

.finance-kpi.cash {
  --accent: var(--gold);
}

.finance-kpi.risk {
  --accent: var(--coral);
}

.finance-stage {
  display: grid;
  grid-template-columns: minmax(190px, 0.42fr) minmax(0, 1fr) minmax(210px, 0.55fr);
  gap: 14px;
  margin-bottom: 18px;
}

.finance-health-card,
.finance-live-chart,
.finance-insight-stack,
.cashflow-chart-card,
.cashflow-forecast,
.finance-decision-panel {
  border: 1px solid rgba(16, 32, 31, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 12px 30px rgba(20, 54, 50, 0.07);
}

.finance-health-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 92px;
  gap: 12px;
  align-items: center;
  padding: 16px;
  color: #ffffff;
  background: linear-gradient(135deg, #10201f, #17423f 58%, #21384f);
}

.finance-health-card .eyebrow {
  color: var(--gold);
}

.finance-health-card strong,
.finance-health-card span {
  display: block;
}

.finance-health-card strong {
  margin-top: 4px;
  font-size: 42px;
  line-height: 1;
}

.finance-health-card span {
  color: rgba(255, 255, 255, 0.75);
  font-weight: 760;
}

.speed-ring {
  position: relative;
  display: grid;
  place-items: center;
  width: 88px;
  height: 88px;
  border-radius: 999px;
  background: conic-gradient(var(--gold) calc(var(--score) * 1%), rgba(255, 255, 255, 0.18) 0);
}

.speed-ring::after {
  content: "";
  width: 64px;
  height: 64px;
  border-radius: inherit;
  background: #153432;
}

.speed-ring i {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: var(--gold);
  transform: rotate(calc(var(--score) * 3.6deg)) translateY(-37px);
  transform-origin: 6px 43px;
}

.finance-live-chart {
  min-width: 0;
  padding: 16px;
}

.finance-live-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.finance-live-head strong,
.finance-live-head span {
  display: block;
}

.finance-live-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.finance-wave,
.cashflow-chart {
  min-height: 164px;
}

.finance-wave svg,
.cashflow-chart svg {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 164px;
  overflow: visible;
}

.finance-wave path,
.cashflow-chart path {
  vector-effect: non-scaling-stroke;
}

.finance-insight-stack {
  display: grid;
  align-content: stretch;
  gap: 9px;
  padding: 12px;
}

.finance-insight {
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 10px;
  border-radius: 8px;
  background: var(--surface-soft);
}

.finance-insight i {
  width: 8px;
  height: 100%;
  min-height: 34px;
  border-radius: 999px;
  background: var(--accent, var(--teal));
}

.finance-insight strong,
.finance-insight span {
  display: block;
}

.finance-insight span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.finance-tabs {
  display: inline-grid;
  grid-template-columns: repeat(3, minmax(130px, 1fr));
  min-height: 46px;
  margin: 2px 0 16px;
  padding: 4px;
  border: 1px solid rgba(16, 32, 31, 0.08);
  border-radius: 8px;
  background: rgba(237, 245, 243, 0.86);
}

.finance-tabs button {
  min-height: 36px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-weight: 880;
}

.finance-tabs button.selected {
  color: #ffffff;
  background: linear-gradient(135deg, var(--teal), #0f8f82);
  box-shadow: 0 10px 22px rgba(15, 118, 110, 0.2);
}

.finance-view {
  display: none;
}

.finance-view.active {
  display: block;
}

.charge-list {
  display: grid;
  gap: 10px;
}

.charge-list article {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) minmax(150px, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid rgba(16, 32, 31, 0.09);
  border-radius: 8px;
  background: #ffffff;
}

.charge-list span {
  color: var(--muted);
}

.charge-list button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--teal-dark);
  padding: 0 12px;
  font-weight: 820;
}

.dre-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.dre-summary article {
  position: relative;
  overflow: hidden;
  padding: 16px;
  border: 1px solid rgba(16, 32, 31, 0.08);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff, #f5fbfa);
}

.dre-summary article::after {
  content: "";
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 11px;
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--success), var(--blue), var(--gold));
}

.dre-summary span,
.dre-summary strong,
.dre-summary small {
  display: block;
}

.dre-summary span,
.dre-summary small {
  color: var(--muted);
}

.dre-summary strong {
  margin-top: 7px;
  font-size: clamp(22px, 2vw, 30px);
}

.dre-summary small {
  margin-top: 4px;
  padding-bottom: 8px;
  font-weight: 760;
}

.dre-visual-grid {
  display: grid;
  grid-template-columns: minmax(260px, 0.8fr) minmax(0, 1.2fr);
  gap: 14px;
}

.dre-waterfall,
.dre-table {
  overflow: hidden;
  border: 1px solid rgba(16, 32, 31, 0.09);
  border-radius: 8px;
  background: #ffffff;
}

.dre-waterfall {
  display: grid;
  gap: 12px;
  align-content: start;
  padding: 16px;
}

.waterfall-step {
  display: grid;
  grid-template-columns: minmax(0, 0.82fr) minmax(120px, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.waterfall-step span,
.waterfall-step strong {
  font-size: 13px;
}

.waterfall-step span {
  color: var(--muted);
  font-weight: 800;
}

.waterfall-step strong {
  text-align: right;
}

.waterfall-track {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(16, 32, 31, 0.08);
}

.waterfall-track i {
  display: block;
  width: var(--fill);
  height: 100%;
  border-radius: inherit;
  background: var(--accent, var(--teal));
}

.waterfall-step.negative .waterfall-track i {
  background: linear-gradient(90deg, var(--coral), #ff9a7b);
}

.waterfall-step.positive .waterfall-track i {
  background: linear-gradient(90deg, var(--success), #8ee8b2);
}

.waterfall-step.neutral .waterfall-track i {
  background: linear-gradient(90deg, var(--blue), #9cc2ff);
}

.dre-table {
  overflow: auto;
}

.dre-row {
  display: grid;
  grid-template-columns: minmax(210px, 1fr) minmax(110px, 0.35fr) minmax(78px, 0.2fr) minmax(90px, 0.35fr);
  min-width: 690px;
  gap: 12px;
  align-items: center;
  min-height: 50px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
}

.dre-row:last-child {
  border-bottom: 0;
}

.dre-row strong {
  color: var(--ink);
}

.dre-row small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-weight: 700;
}

.dre-row span:nth-child(2),
.dre-row span:nth-child(3) {
  text-align: right;
  font-weight: 820;
}

.dre-row em {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(16, 32, 31, 0.08);
}

.dre-row em::after {
  content: "";
  display: block;
  width: var(--fill, 0%);
  height: 100%;
  border-radius: inherit;
  background: var(--row-accent, var(--teal));
}

.dre-row.negative {
  --row-accent: var(--coral);
}

.dre-row.subtotal {
  --row-accent: var(--blue);
  background: #f4f8ff;
}

.dre-row.result {
  --row-accent: var(--gold);
  color: #ffffff;
  background: linear-gradient(135deg, var(--teal-dark), #163b56);
}

.dre-row.result strong,
.dre-row.result small,
.dre-row.result span {
  color: #ffffff;
}

.cashflow-analytics {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 0.42fr);
  gap: 14px;
  margin-bottom: 14px;
}

.cashflow-chart-card {
  min-width: 0;
  padding: 16px;
}

.cashflow-forecast {
  display: grid;
  align-content: center;
  gap: 12px;
  padding: 16px;
}

.cashflow-forecast strong,
.cashflow-forecast span {
  display: block;
}

.cashflow-forecast strong {
  font-size: 28px;
}

.cashflow-forecast span {
  color: var(--muted);
  line-height: 1.4;
}

.cashflow-header {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
}

.cashflow-header strong {
  text-align: center;
  font-size: 20px;
}

.cashflow-calendar {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
}

.cash-day,
.cash-weekday {
  min-height: 76px;
  border-radius: 8px;
}

.cash-weekday {
  display: grid;
  place-items: center;
  min-height: 30px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.cash-day {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #ffffff;
  padding: 8px;
  text-align: left;
}

.cash-day::after {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 7px;
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--success), var(--gold), var(--coral));
  opacity: 0.88;
  transform: scaleX(var(--density, 0));
  transform-origin: left;
}

.cash-day:hover,
.cash-day.selected {
  border-color: rgba(15, 118, 110, 0.42);
  box-shadow: inset 0 0 0 2px rgba(15, 118, 110, 0.08), 0 12px 24px rgba(20, 54, 50, 0.08);
}

.cash-day.selected {
  background: #f0fffb;
}

.cash-day.muted {
  opacity: 0.42;
}

.cash-day strong,
.cash-day span {
  position: relative;
  z-index: 1;
  display: block;
}

.cash-day strong {
  margin-bottom: 6px;
}

.cash-day .positive,
.cash-entry b.entrada {
  color: #0d5f36;
}

.cash-day .negative,
.cash-entry b.saida {
  color: #84291f;
}

.cash-day-panel {
  display: grid;
  grid-template-columns: minmax(180px, 0.35fr) minmax(0, 1fr);
  gap: 16px;
  margin-top: 16px;
  padding: 14px;
  border: 1px solid rgba(16, 32, 31, 0.08);
  border-radius: 8px;
  background: rgba(246, 250, 249, 0.92);
}

.cash-day-panel h3 {
  margin-bottom: 0;
}

.cash-day-list {
  display: grid;
  gap: 8px;
}

.cash-entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.cash-entry strong,
.cash-entry small {
  display: block;
}

.cash-entry small {
  margin-top: 3px;
  color: var(--muted);
}

.finance-side-panel {
  align-self: start;
  position: sticky;
  top: 18px;
}

.cash-entry-form .primary-action {
  justify-content: center;
  width: 100%;
}

.finance-side-summary {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.finance-side-summary dl {
  display: grid;
  gap: 10px;
  margin: 0;
}

.finance-side-summary div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.finance-side-summary dt {
  color: var(--muted);
  font-weight: 760;
}

.finance-side-summary dd {
  margin: 0;
  font-weight: 900;
}

.finance-decision-panel {
  display: grid;
  gap: 10px;
  margin-top: 18px;
  padding: 14px;
  background: linear-gradient(180deg, #ffffff, #f8fbff);
}

.finance-action {
  display: grid;
  gap: 3px;
  padding: 10px;
  border-left: 4px solid var(--accent, var(--teal));
  border-radius: 8px;
  background: var(--surface-soft);
}

.finance-action strong,
.finance-action span {
  display: block;
}

.finance-action span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

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

.report-bars {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  align-items: end;
  gap: 12px;
  height: 260px;
  padding: 18px;
  border-radius: 8px;
  background: var(--surface-soft);
}

.report-bars span {
  min-height: 24px;
  border-radius: 8px 8px 3px 3px;
  background: linear-gradient(180deg, var(--blue), #8dc6ff);
}

.visit-drawer {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  justify-items: end;
  background: rgba(9, 47, 44, 0);
  pointer-events: none;
  transition: background 180ms ease;
}

.visit-drawer.is-open {
  background: rgba(9, 47, 44, 0.22);
  pointer-events: auto;
}

.drawer-card {
  width: min(420px, 100%);
  min-height: 100%;
  padding: 26px;
  border-left: 1px solid var(--line);
  background: #ffffff;
  box-shadow: -18px 0 42px rgba(20, 54, 50, 0.15);
  transform: translateX(100%);
  transition: transform 180ms ease;
}

.visit-drawer.is-open .drawer-card {
  transform: translateX(0);
}

.drawer-close,
.modal-close {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  margin-left: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--ink);
  font-size: 24px;
  line-height: 1;
}

.drawer-card h2,
.modal-card h2 {
  margin-bottom: 18px;
  font-size: 28px;
  line-height: 1.1;
}

.drawer-card dl {
  display: grid;
  gap: 12px;
  margin: 0 0 20px;
}

.drawer-card dl div {
  padding: 13px;
  border-radius: 8px;
  background: var(--surface-soft);
}

.drawer-card dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.drawer-card dd {
  margin: 5px 0 0;
  font-weight: 800;
}

.drawer-actions {
  display: grid;
  gap: 10px;
}

.drawer-actions .primary-action,
.drawer-actions .ghost-action {
  justify-content: center;
  width: 100%;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(9, 47, 44, 0.32);
}

.modal-backdrop[hidden],
.modal-backdrop.is-hidden {
  display: none !important;
}

.modal-card {
  width: min(560px, 100%);
  max-height: min(760px, calc(100vh - 36px));
  overflow: auto;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.quick-form {
  display: grid;
  gap: 13px;
}

.quick-form select {
  appearance: none;
}

.quick-form .care-field[hidden] {
  display: none;
}

.care-package-hint {
  grid-column: 1 / -1;
  margin: -6px 0 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.care-package-hint[hidden] {
  display: none;
}

.quick-form .primary-action {
  justify-content: center;
  margin-top: 4px;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 50;
  max-width: min(360px, calc(100vw - 44px));
  padding: 13px 16px;
  border: 1px solid rgba(15, 118, 110, 0.24);
  border-radius: 8px;
  color: var(--teal-dark);
  background: #ffffff;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
  font-weight: 800;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.icon {
  position: relative;
  display: inline-block;
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.icon::before,
.icon::after {
  content: "";
  position: absolute;
  inset: 0;
  border: 2px solid currentColor;
  border-radius: 5px;
}

.dashboard::after {
  inset: 7px 2px 2px 2px;
  border-top: 2px solid currentColor;
  border-right: 0;
  border-bottom: 0;
  border-left: 0;
  border-radius: 0;
}

.calendar::before {
  top: 3px;
}

.calendar::after {
  top: 0;
  height: 6px;
  border-right: 0;
  border-bottom: 0;
  border-left: 0;
  border-radius: 0;
}

.users::before {
  inset: 2px 8px 8px 2px;
  border-radius: 999px;
}

.users::after {
  inset: 10px 2px 2px 0;
  border-radius: 999px 999px 4px 4px;
}

.record::before {
  border-radius: 4px;
}

.record::after {
  inset: 5px 4px auto;
  height: 0;
  border-right: 0;
  border-bottom: 0;
  border-left: 0;
  border-radius: 0;
  box-shadow: 0 5px 0 currentColor;
}

.wallet::before {
  top: 4px;
}

.wallet::after {
  inset: 8px 2px 4px 10px;
  border-left: 2px solid currentColor;
}

.chart::before {
  border: 0;
  border-left: 3px solid currentColor;
  border-bottom: 3px solid currentColor;
  border-radius: 0;
}

.chart::after {
  inset: 4px 2px 3px 5px;
  border: 0;
  border-top: 3px solid currentColor;
  border-right: 3px solid currentColor;
  border-radius: 0;
  transform: skewY(-24deg);
}

.search-icon::before {
  inset: 2px 5px 5px 2px;
  border-radius: 999px;
}

.search-icon::after {
  inset: auto 1px 1px auto;
  width: 7px;
  height: 2px;
  border: 0;
  border-radius: 0;
  background: currentColor;
  transform: rotate(45deg);
}

.bell::before {
  inset: 3px 4px 5px;
  border-radius: 999px 999px 5px 5px;
}

.bell::after {
  inset: auto 6px 1px;
  height: 2px;
  border: 0;
  background: currentColor;
}

.plus::before {
  inset: 8px 3px;
  height: 2px;
  border: 0;
  background: currentColor;
}

.plus::after {
  inset: 3px 8px;
  width: 2px;
  border: 0;
  background: currentColor;
}

@media (prefers-reduced-motion: no-preference) {
  .brand-mark path {
    stroke-dasharray: 72;
    animation: logoTrace 4s ease-in-out infinite;
  }

  .progress span,
  .bar-chart span,
  .report-bars span,
  .waterfall-track i,
  .dre-row em::after,
  .finance-kpi i::after {
    animation: growWidth 900ms ease both;
  }

  .bar-chart span,
  .report-bars span {
    animation-name: growUp;
  }

  .metric-card,
  .panel,
  .finance-kpi {
    animation: riseIn 420ms ease both;
  }

  .finance-wave path,
  .cashflow-chart path {
    stroke-dasharray: 900;
    stroke-dashoffset: 900;
    animation: drawLine 1100ms ease forwards;
  }

  .live-chip i {
    animation: pulseDot 1400ms ease-in-out infinite;
  }
}

@keyframes riseIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes growUp {
  from {
    transform: scaleY(0.3);
    transform-origin: bottom;
  }

  to {
    transform: scaleY(1);
    transform-origin: bottom;
  }
}

@keyframes growWidth {
  from {
    transform: scaleX(0.2);
    transform-origin: left;
  }

  to {
    transform: scaleX(1);
    transform-origin: left;
  }
}

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

@keyframes pulseDot {
  50% {
    box-shadow: 0 0 0 9px rgba(18, 166, 106, 0.08);
  }
}

@keyframes logoTrace {
  0%,
  100% {
    stroke-dashoffset: 0;
  }

  50% {
    stroke-dashoffset: 18;
  }
}

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: 88px minmax(0, 1fr);
  }

  .brand span,
  .nav-item span:last-child,
  .clinic-switcher div,
  .clinic-logout {
    display: none;
  }

  .sidebar {
    align-items: center;
    padding-inline: 14px;
  }

  .nav-item {
    justify-content: center;
    width: 54px;
  }

  .clinic-switcher {
    padding: 8px;
  }

  .metrics-grid,
  .finance-kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .content-grid,
  .module-layout.active,
  .finance-command-center.active,
  .schedule-board,
  .finance-stage,
  .cashflow-analytics,
  .dre-visual-grid {
    grid-template-columns: 1fr;
  }

  .schedule-column {
    min-height: auto;
  }

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

  .cash-day-panel {
    grid-template-columns: 1fr;
  }

  .finance-side-panel {
    position: static;
  }
}

@media (max-width: 820px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 40;
    height: auto;
    align-items: stretch;
    gap: 10px;
    padding: 10px 14px 8px;
  }

  .brand span,
  .nav-item span:last-child,
  .clinic-switcher div,
  .clinic-logout {
    display: block;
  }

  .main-nav {
    display: flex;
    overflow-x: auto;
    gap: 6px;
    padding-bottom: 4px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .main-nav::-webkit-scrollbar { display: none; }

  .nav-item {
    flex: 0 0 auto;
    justify-content: flex-start;
    width: auto;
    white-space: nowrap;
    min-height: 42px;
    padding: 0 14px;
    scroll-margin-inline: 14px;
  }

  .brand { font-size: 19px; }
  .brand-mark { width: 32px; height: 32px; }
  .clinic-switcher { padding: 6px 10px; gap: 8px; }
  .clinic-avatar { width: 34px !important; height: 34px !important; }

  .topbar,
  .topbar-actions,
  .hero-band,
  .panel-header,
  .finance-footer,
  .finance-titlebar,
  .finance-live-head {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar,
  .topbar-actions {
    display: grid;
  }

  .topbar-actions {
    min-width: 0;
  }

  .search {
    min-width: 0;
  }

  .icon-button,
  .primary-action {
    width: 100%;
    justify-content: center;
  }

  .hero-band,
  .metrics-grid,
  .record-form,
  .billing-grid,
  .insight-grid,
  .dre-summary,
  .finance-tabs,
  .finance-kpi-grid {
    grid-template-columns: 1fr;
  }

  .appointment {
    grid-template-columns: 54px minmax(0, 1fr);
  }

  .appointment button {
    grid-column: 1 / -1;
    width: 100%;
  }

  .patient-card,
  .charge-list article {
    grid-template-columns: 1fr;
  }

  .finance-health-card {
    grid-template-columns: 1fr;
  }

  .cashflow-calendar {
    gap: 5px;
  }

  .cash-day {
    min-height: 66px;
    padding: 6px;
  }

  .report-bars {
    height: 190px;
  }
}

@media (max-width: 540px) {
  .workspace {
    padding-inline: 12px;
  }

  .hero-copy h2 {
    font-size: 31px;
  }

  .segmented,
  .finance-tabs {
    width: 100%;
  }
}

/* EIFISIO - CORRECAO COMPLETA DA TELA FINANCEIRA */

.finance-command-center.active {
  grid-template-columns: minmax(0, 1fr) minmax(340px, 0.38fr) !important;
  align-items: start !important;
  gap: 22px !important;
}

.finance-master-panel {
  overflow: visible !important;
}

.finance-titlebar {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) auto auto !important;
  align-items: center !important;
}

.finance-kpi-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  gap: 14px !important;
}

.finance-kpi {
  min-height: 126px !important;
  padding: 18px !important;
}

.finance-kpi strong {
  font-size: clamp(28px, 2.2vw, 42px) !important;
  line-height: 1 !important;
  white-space: nowrap !important;
}

.finance-stage {
  display: grid !important;
  grid-template-columns: minmax(280px, 0.42fr) minmax(0, 0.58fr) !important;
  gap: 18px !important;
  align-items: stretch !important;
}

.finance-health-card {
  position: relative !important;
  grid-template-columns: 1fr !important;
  min-height: 280px !important;
  overflow: hidden !important;
  padding: 24px !important;
}

.finance-health-card strong {
  position: relative !important;
  z-index: 2 !important;
  font-size: clamp(58px, 5vw, 82px) !important;
  max-width: 170px !important;
}

.finance-health-card span {
  position: relative !important;
  z-index: 2 !important;
  max-width: 170px !important;
  font-size: 22px !important;
  line-height: 1.12 !important;
}

.speed-ring {
  position: absolute !important;
  right: 24px !important;
  bottom: 24px !important;
  width: 130px !important;
  height: 130px !important;
}

.speed-ring::after {
  width: 94px !important;
  height: 94px !important;
}

.speed-ring i {
  transform: rotate(calc(var(--score) * 3.6deg)) translateY(-56px) !important;
  transform-origin: 6px 62px !important;
}

.finance-live-chart {
  min-height: 280px !important;
}

.finance-live-head {
  display: grid !important;
  grid-template-columns: 1fr !important;
  gap: 6px !important;
}

.finance-live-head span {
  max-width: none !important;
}

.finance-wave,
.cashflow-chart {
  min-height: 210px !important;
}

.finance-wave svg,
.cashflow-chart svg {
  min-height: 210px !important;
}

.finance-insight-stack {
  grid-column: 1 / -1 !important;
  display: grid !important;
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  gap: 14px !important;
}

.finance-insight {
  min-height: 92px !important;
  align-items: stretch !important;
}

.finance-tabs {
  width: min(100%, 760px) !important;
  margin-top: 26px !important;
}

.cashflow-analytics {
  grid-template-columns: minmax(0, 1fr) minmax(260px, 0.38fr) !important;
  gap: 18px !important;
}

.cashflow-chart-card,
.cashflow-forecast {
  min-height: 250px !important;
}

.finance-side-panel {
  align-self: start !important;
  position: sticky !important;
  top: 18px !important;
}

.finance-side-panel .primary-action {
  width: 100% !important;
  justify-content: center !important;
}

.cash-entry-form input,
.cash-entry-form select {
  min-height: 54px !important;
  font-size: 16px !important;
}

.finance-side-summary dd {
  white-space: nowrap !important;
}

@media (max-width: 1650px) {
  .finance-kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  .finance-stage {
    grid-template-columns: 1fr !important;
  }

  .finance-insight-stack {
    grid-template-columns: 1fr !important;
  }

  .finance-health-card {
    min-height: 230px !important;
  }
}

@media (max-width: 1250px) {
  .finance-command-center.active {
    grid-template-columns: 1fr !important;
  }

  .finance-side-panel {
    position: static !important;
  }

  .cashflow-analytics {
    grid-template-columns: 1fr !important;
  }
}

@media (max-width: 820px) {
  .finance-titlebar {
    grid-template-columns: 1fr !important;
  }

  .finance-kpi-grid {
    grid-template-columns: 1fr !important;
  }

  .finance-kpi strong {
    white-space: normal !important;
  }

  .finance-health-card {
    min-height: 260px !important;
  }

  .speed-ring {
    width: 112px !important;
    height: 112px !important;
  }

  .speed-ring::after {
    width: 82px !important;
    height: 82px !important;
  }
}

/* EIFISIO - AGENDA PREMIUM */

.agenda-command.active {
  grid-template-columns: minmax(0, 1fr) minmax(330px, 0.38fr) !important;
  gap: 22px !important;
  align-items: start !important;
}

.agenda-master-panel {
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(247, 252, 250, 0.94)),
    linear-gradient(135deg, rgba(15, 118, 110, 0.08), rgba(47, 111, 237, 0.07));
}

.agenda-titlebar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.agenda-actions {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
}

.agenda-actions .ghost-action,
.agenda-actions .primary-action {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

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

.agenda-kpis article {
  position: relative;
  overflow: hidden;
  min-height: 106px;
  padding: 15px;
  border: 1px solid rgba(16, 32, 31, 0.08);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 12px 28px rgba(20, 54, 50, 0.07);
}

.agenda-kpis article::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 4px;
  background: linear-gradient(90deg, var(--teal), var(--blue), var(--gold));
}

.agenda-kpis span,
.agenda-kpis strong,
.agenda-kpis small {
  display: block;
}

.agenda-kpis span,
.agenda-kpis small {
  color: var(--muted);
}

.agenda-kpis strong {
  margin: 8px 0 3px;
  font-size: 32px;
  line-height: 1;
}

.agenda-filter-bar {
  display: grid;
  grid-template-columns: minmax(150px, 0.7fr) minmax(220px, 1fr) minmax(220px, 1fr) minmax(220px, 1fr);
  gap: 12px;
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid rgba(16, 32, 31, 0.08);
  border-radius: 8px;
  background: rgba(246, 250, 249, 0.84);
}

.agenda-filter-bar label,
.agenda-mini-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 860;
  text-transform: uppercase;
}

.agenda-filter-bar input,
.agenda-filter-bar select,
.agenda-mini-form input,
.agenda-mini-form select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  padding: 0 12px;
  text-transform: none;
}

.agenda-mode-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}

.agenda-view-tabs {
  width: 100% !important;
  max-width: 720px;
  grid-template-columns: repeat(5, minmax(92px, 1fr)) !important;
  margin: 0 !important;
}

.agenda-period-control {
  display: grid;
  grid-template-columns: 44px minmax(180px, 1fr) auto 44px;
  align-items: center;
  gap: 8px;
}

.agenda-period-control strong {
  text-align: center;
  white-space: nowrap;
}

.agenda-board-wrap {
  overflow: auto;
  border: 1px solid rgba(16, 32, 31, 0.08);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.74);
}

.schedule-board {
  min-width: 980px;
}

.agenda-week-board {
  display: grid;
}

.agenda-week-head,
.agenda-week-row {
  display: grid;
  grid-template-columns: 72px repeat(6, minmax(132px, 1fr));
}

.agenda-week-head {
  position: sticky;
  top: 0;
  z-index: 3;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
}

.agenda-week-head strong {
  display: grid;
  gap: 3px;
  place-items: center;
  min-height: 58px;
  border-left: 1px solid var(--line);
  font-size: 15px;
}

.agenda-week-head small {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.agenda-week-row {
  min-height: 92px;
  border-bottom: 1px solid var(--line);
}

.agenda-week-row > time {
  display: grid;
  place-items: start center;
  padding-top: 12px;
  color: var(--muted);
  background: var(--surface-soft);
  font-weight: 850;
}

.agenda-cell {
  position: relative;
  display: grid;
  align-content: start;
  gap: 6px;
  min-height: 92px;
  padding: 7px;
  border-left: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(15, 118, 110, 0.025), transparent 44%),
    #ffffff;
}

.agenda-event,
.agenda-empty {
  width: 100%;
  border-radius: 8px;
  text-align: left;
}

.agenda-event {
  display: grid;
  gap: 3px;
  min-height: 70px;
  border: 0;
  color: #ffffff;
  padding: 9px;
  box-shadow: 0 10px 18px rgba(20, 54, 50, 0.13);
}

.agenda-event span,
.agenda-event strong,
.agenda-event small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.agenda-event span {
  font-size: 12px;
  font-weight: 900;
}

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

.agenda-event small {
  color: rgba(255, 255, 255, 0.78);
  font-size: 11px;
}

/* Tones legados neutralizados no Design Lift v3 — a cor do evento vem do
   status real (.evt-agendado…evt-cancelado) definido no eifisio_boost.css. */

.agenda-empty {
  display: grid;
  place-items: center;
  min-height: 70px;
  border: 1px dashed rgba(15, 118, 110, 0.18);
  color: rgba(15, 118, 110, 0.56);
  background: rgba(15, 118, 110, 0.03);
  font-size: 20px;
  font-weight: 900;
  opacity: 0;
}

.agenda-cell:hover .agenda-empty {
  opacity: 1;
}

.agenda-side-panel {
  position: sticky;
  top: 18px;
  align-self: start;
  display: grid;
  gap: 14px;
}

.agenda-priority-stack {
  display: grid;
  gap: 10px;
}

.agenda-priority {
  display: grid;
  gap: 5px;
  padding: 12px;
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  background: var(--surface-soft);
}

.agenda-priority.danger {
  --accent: var(--coral);
}

.agenda-priority.success {
  --accent: var(--success);
}

.agenda-priority.blue {
  --accent: var(--blue);
}

.agenda-priority.gold {
  --accent: var(--gold);
}

.agenda-priority strong,
.agenda-priority span {
  display: block;
}

.agenda-priority span,
.agenda-smart-card p {
  color: var(--muted);
  line-height: 1.42;
}

.agenda-smart-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid rgba(16, 32, 31, 0.08);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff, #f8fbff);
}

.agenda-smart-card h4,
.agenda-smart-card p {
  margin: 0;
}

.agenda-mini-form {
  display: grid;
  gap: 10px;
}

.drawer-status-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: -6px 0 16px;
  color: var(--muted);
  font-weight: 800;
}

@media print {
  .sidebar,
  .topbar,
  .hero-band,
  .agenda-filter-bar,
  .agenda-actions,
  .agenda-side-panel,
  .visit-drawer,
  .modal-backdrop,
  .toast {
    display: none !important;
  }

  .app-shell,
  .workspace,
  .agenda-command.active {
    display: block !important;
  }

  .workspace {
    padding: 0 !important;
  }

  .agenda-master-panel {
    border: 0 !important;
    box-shadow: none !important;
  }

  .schedule-board {
    min-width: 0 !important;
  }
}

@media (max-width: 1500px) {
  .agenda-command.active,
  .agenda-mode-row {
    grid-template-columns: 1fr !important;
  }

  .agenda-kpis,
  .agenda-filter-bar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .agenda-side-panel {
    position: static;
  }
}

@media (max-width: 820px) {
  .agenda-titlebar,
  .agenda-kpis,
  .agenda-filter-bar,
  .agenda-period-control {
    grid-template-columns: 1fr !important;
  }

  .agenda-actions {
    display: grid;
  }

  .agenda-view-tabs {
    grid-template-columns: 1fr !important;
  }
}

/* =====================================================================
   MÓDULOS PACIENTES + ATENDIMENTOS + HISTÓRICO (Dossiê)
   Apêndice — não remove nada acima. Usa os tokens já existentes.
   ===================================================================== */

/* Ícone prancheta (mesmo estilo CSS-shape dos demais) */
.clipboard::before { inset: 2px 3px 2px 3px; border-radius: 6px; }
.clipboard::after {
  inset: 0 5px auto 5px; height: 6px;
  border: 2px solid currentColor; border-radius: 4px;
  background: var(--surface);
}

/* ---- Layout das páginas de módulo (coluna única, densa) ---- */
.patients-module.active,
.attendances-module.active {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* ---- Cards de resumo ---- */
.module-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}
.summary-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 10px 26px rgba(20, 54, 50, 0.06);
}
.summary-card > div { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.summary-card span:not(.summary-icon) { color: var(--muted); font-size: 12.5px; font-weight: 750; }
.summary-card strong { font-size: 24px; font-weight: 850; letter-spacing: -0.02em; color: var(--ink); }
.summary-icon {
  display: grid; place-items: center;
  width: 44px; height: 44px; flex: 0 0 auto;
  border-radius: 8px; color: #fff;
}
.summary-icon .icon { width: 20px; height: 20px; }
.summary-icon.teal  { background: linear-gradient(140deg, var(--teal), #14a194); }
.summary-icon.green { background: linear-gradient(140deg, var(--success), #38c98a); }
.summary-icon.blue  { background: linear-gradient(140deg, var(--blue), #5b8bff); }
.summary-icon.gold  { background: linear-gradient(140deg, #e3a72a, var(--gold)); color: #5b4300; }
.summary-icon.coral { background: linear-gradient(140deg, var(--coral), #f08070); }

/* ---- Painel de módulo ---- */
.module-panel { padding: 18px; display: flex; flex-direction: column; gap: 16px; }

/* ---- Toolbar ---- */
.module-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.module-search {
  position: relative;
  display: flex; align-items: center; gap: 8px;
  flex: 1 1 280px; min-width: 220px;
  padding: 0 12px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}
.module-search .icon { color: var(--muted); }
.module-search input {
  flex: 1; border: 0; background: transparent;
  font: inherit; color: var(--ink); outline: none;
}
.chip-row { display: inline-flex; gap: 6px; padding: 4px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-soft); }
.chip {
  border: 0; background: transparent; cursor: pointer;
  padding: 7px 13px; border-radius: 6px;
  font: inherit; font-size: 13px; font-weight: 750; color: var(--muted);
  transition: background 150ms ease, color 150ms ease;
}
.chip:hover { color: var(--ink); }
.chip.selected { background: var(--teal); color: #fff; box-shadow: 0 6px 14px rgba(15, 118, 110, 0.28); }
.module-select select {
  height: 42px; padding: 0 30px 0 12px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface-soft) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23647875' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 12px center;
  font: inherit; font-weight: 700; color: var(--ink);
  appearance: none; -webkit-appearance: none; cursor: pointer;
}
.module-toolbar-actions { display: inline-flex; gap: 8px; margin-left: auto; }

/* ---- Tabela de dados ---- */
.data-table-wrap { width: 100%; overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; }
.data-table { width: 100%; border-collapse: collapse; min-width: 880px; }
.data-table thead th {
  position: sticky; top: 0; z-index: 1;
  text-align: left; padding: 12px 14px;
  font-size: 11px; font-weight: 850; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--muted);
  background: var(--surface-soft);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.data-table th.col-actions, .data-table td.col-actions { text-align: right; width: 1%; white-space: nowrap; }
.data-table th.col-right, .data-table td.col-right { text-align: right; }
.data-table tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid #eef4f2;
  font-size: 13.5px; color: var(--ink); vertical-align: middle;
}
.data-table tbody tr { transition: background 130ms ease; }
.data-table tbody tr:hover { background: var(--surface-soft); }
.data-table tbody tr:last-child td { border-bottom: 0; }

.cell-patient { display: flex; align-items: center; gap: 11px; min-width: 200px; }
.cell-avatar {
  display: grid; place-items: center;
  width: 34px; height: 34px; flex: 0 0 auto;
  border-radius: 8px; color: #fff; font-size: 12.5px; font-weight: 850;
  background: linear-gradient(140deg, var(--teal-dark), var(--teal));
}
.cell-stack { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cell-stack strong { font-weight: 800; font-size: 13.5px; line-height: 1.2; }
.cell-stack small { color: var(--muted); font-size: 11.5px; }
.cell-muted { color: var(--muted); }
.cell-age { display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 999px; font-size: 11px; font-weight: 800; color: #5b4300; background: #fdeec2; }
.cell-tag { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 800; color: var(--teal-dark); background: var(--mint); }
.cell-tag.neutral { color: var(--muted); background: var(--surface-soft); border: 1px solid var(--line); }

/* Ações por linha */
.row-actions { display: inline-flex; gap: 6px; justify-content: flex-end; }
.row-action {
  display: grid; place-items: center;
  width: 32px; height: 32px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); color: var(--muted); cursor: pointer;
  transition: all 140ms ease;
}
.row-action:hover { color: var(--teal); border-color: var(--teal); background: var(--mint); transform: translateY(-1px); }
.row-action.danger:hover { color: var(--danger); border-color: var(--danger); background: #fdecea; }
.row-action .icon { width: 16px; height: 16px; }

/* Pills de status semânticas */
.status.agendado  { color: #1f4fb0; background: #e3ecff; }
.status.confirmado{ color: #0d5f36; background: #dff9ea; }
.status.atendido  { color: #0a6b4a; background: #cdf3e0; }
.status.faltou    { color: #9a2417; background: #fde2dd; }
.status.cancelado { color: #5a6b68; background: #e9efed; }
.status.ativo     { color: #0d5f36; background: #dff9ea; }
.status.renovar   { color: #765100; background: #fff1c7; }
.status.arquivado { color: #5a6b68; background: #e9efed; }

.bill-badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 800; }
.bill-badge.yes { color: #0a6b4a; background: #cdf3e0; }
.bill-badge.no  { color: var(--muted); background: var(--surface-soft); border: 1px solid var(--line); }

/* Estado vazio */
.table-empty { display: flex; flex-direction: column; gap: 4px; align-items: center; text-align: center; padding: 38px 20px; }
.table-empty strong { font-size: 15px; }
.table-empty span { color: var(--muted); font-size: 13px; }

/* ---- Filtros de atendimentos ---- */
.att-filter-bar {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
}
.att-filter-bar label { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.att-filter-bar label span { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.att-filter-bar input,
.att-filter-bar select {
  height: 40px; padding: 0 11px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface-soft); font: inherit; font-weight: 650; color: var(--ink);
  outline: none; width: 100%;
}
.att-filter-bar select { appearance: none; -webkit-appearance: none; padding-right: 28px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23647875' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center; }
.att-filter-bar input:focus, .att-filter-bar select:focus { border-color: var(--teal); }
.att-clear { height: 40px; align-self: end; }
.att-toolbar-actions { justify-content: space-between; }
.att-report-group { display: inline-flex; gap: 8px; flex-wrap: wrap; }

/* =====================================================================
   HISTÓRICO DO PACIENTE — Dossiê (overlay full-screen)
   ===================================================================== */
.dossier-overlay {
  position: fixed; inset: 0; z-index: 60;
  display: grid; place-items: center;
  padding: 24px;
  background: rgba(9, 33, 31, 0);
  pointer-events: none;
  transition: background 200ms ease;
}
.dossier-overlay.is-open { background: rgba(9, 33, 31, 0.42); pointer-events: auto; }
.dossier-shell {
  position: relative;
  display: grid;
  grid-template-columns: 320px 1fr;
  width: min(1120px, 100%);
  max-height: min(88vh, 880px);
  overflow: hidden;
  background: var(--surface);
  border-radius: 12px;
  box-shadow: 0 40px 90px rgba(9, 33, 31, 0.4);
  transform: translateY(14px) scale(0.985);
  opacity: 0;
  transition: transform 220ms ease, opacity 220ms ease;
}
.dossier-overlay.is-open .dossier-shell { transform: translateY(0) scale(1); opacity: 1; }
.dossier-close {
  position: absolute; top: 14px; right: 14px; z-index: 3;
  display: grid; place-items: center; width: 36px; height: 36px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); color: var(--ink); font-size: 22px; line-height: 1; cursor: pointer;
}
.dossier-close:hover { background: var(--surface-soft); }

.dossier-profile {
  display: flex; flex-direction: column; gap: 18px;
  padding: 26px 22px;
  background: linear-gradient(180deg, #0c4f4a, #0f766e);
  color: #eafaf7;
  overflow-y: auto;
}
.dossier-id { display: flex; gap: 14px; align-items: flex-start; }
.dossier-id .eyebrow { color: #9fe6db; }
.dossier-id h2 { font-size: 22px; line-height: 1.15; margin: 2px 0 4px; color: #fff; }
.dossier-sub { font-size: 12.5px; color: #bfeee7; margin-bottom: 8px; }
.dossier-avatar {
  display: grid; place-items: center;
  width: 54px; height: 54px; flex: 0 0 auto;
  border-radius: 10px; font-size: 19px; font-weight: 850;
  background: rgba(255, 255, 255, 0.16); color: #fff;
}
.dossier-contact { display: grid; gap: 9px; margin: 0; }
.dossier-contact div { display: flex; flex-direction: column; gap: 1px; padding: 9px 11px; border-radius: 8px; background: rgba(255, 255, 255, 0.09); }
.dossier-contact dt { font-size: 10.5px; font-weight: 850; text-transform: uppercase; letter-spacing: 0.04em; color: #9fe6db; }
.dossier-contact dd { margin: 0; font-size: 13px; font-weight: 700; color: #f2fffd; word-break: break-word; }
.dossier-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.dossier-stats article { padding: 10px; border-radius: 8px; background: rgba(255, 255, 255, 0.12); text-align: center; }
.dossier-stats span { display: block; font-size: 10.5px; font-weight: 750; color: #bfeee7; }
.dossier-stats strong { display: block; margin-top: 3px; font-size: 17px; color: #fff; }
.dossier-profile-actions { display: grid; gap: 8px; margin-top: auto; }
.dossier-profile-actions .primary-action,
.dossier-profile-actions .ghost-action { width: 100%; justify-content: center; }
.dossier-profile-actions .ghost-action { background: rgba(255,255,255,0.12); color: #fff; border-color: rgba(255,255,255,0.22); }
.dossier-profile-actions .ghost-action:hover { background: rgba(255,255,255,0.2); }

.dossier-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.dossier-tabs { display: flex; gap: 4px; padding: 16px 22px 0; border-bottom: 1px solid var(--line); }
.dossier-tabs button {
  border: 0; background: transparent; cursor: pointer;
  padding: 10px 14px; border-radius: 8px 8px 0 0;
  font: inherit; font-size: 13.5px; font-weight: 750; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.dossier-tabs button:hover { color: var(--ink); }
.dossier-tabs button.selected { color: var(--teal); border-bottom-color: var(--teal); }
.dossier-panels { padding: 20px 22px; overflow-y: auto; }
.dossier-panel { display: none; }
.dossier-panel.active { display: block; animation: dossierFade 220ms ease; }
@keyframes dossierFade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* Linha do tempo */
.timeline { position: relative; display: flex; flex-direction: column; gap: 2px; padding-left: 26px; }
.timeline::before { content: ""; position: absolute; left: 9px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.timeline-item { position: relative; padding: 10px 0 14px; }
.timeline-item::before {
  content: ""; position: absolute; left: -22px; top: 14px;
  width: 12px; height: 12px; border-radius: 50%;
  background: #fff; border: 3px solid var(--teal);
}
.timeline-item.dot-blue::before  { border-color: var(--blue); }
.timeline-item.dot-green::before { border-color: var(--success); }
.timeline-item.dot-gold::before  { border-color: #e3a72a; }
.timeline-item.dot-coral::before { border-color: var(--coral); }
.timeline-item.dot-gray::before  { border-color: #97a8a4; }
.timeline-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.timeline-head strong { font-size: 14px; }
.timeline-date { font-size: 12px; font-weight: 750; color: var(--muted); }
.timeline-item p { margin: 4px 0 0; font-size: 13px; color: var(--muted); }
.timeline-empty { color: var(--muted); font-size: 13px; padding: 8px 0; }

/* Prontuário (evoluções) */
.dossier-records { display: flex; flex-direction: column; gap: 12px; }
.record-card { padding: 14px 16px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-soft); }
.record-card .timeline-date { margin-bottom: 4px; display: block; }
.record-card h4 { font-size: 14px; margin: 0 0 4px; }
.record-card p { margin: 0; font-size: 13px; color: var(--ink); line-height: 1.5; }
.record-card .goal { margin-top: 6px; font-size: 12px; color: var(--teal-dark); font-weight: 700; }

/* Documentos */
.dossier-doc-form { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.dossier-doc-form input, .dossier-doc-form select {
  height: 40px; padding: 0 11px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface-soft); font: inherit; outline: none; flex: 1 1 140px;
}
.dossier-doc-form select { appearance: none; -webkit-appearance: none; cursor: pointer; }
.dossier-doc-form input:focus, .dossier-doc-form select:focus { border-color: var(--teal); }
.dossier-docs { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.doc-card { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.doc-card .doc-mark { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 8px; background: var(--mint); color: var(--teal-dark); flex: 0 0 auto; }
.doc-card .doc-mark .icon { width: 17px; height: 17px; }
.doc-card div { min-width: 0; flex: 1; }
.doc-card strong { display: block; font-size: 13px; }
.doc-card small { color: var(--muted); font-size: 11.5px; }
.doc-card .row-action { margin-left: auto; }

/* Financeiro do paciente */
.dossier-finance { display: flex; flex-direction: column; gap: 10px; }
.finance-line { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 16px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.finance-line div { min-width: 0; }
.finance-line strong { display: block; font-size: 13.5px; }
.finance-line small { color: var(--muted); font-size: 12px; }
.finance-line b { font-size: 15px; color: var(--ink); white-space: nowrap; }
.finance-empty { color: var(--muted); font-size: 13px; padding: 8px 0; }

/* =====================================================================
   DRAWERS LATERAIS (cadastro de paciente + detalhe de atendimento)
   ===================================================================== */
.side-drawer {
  position: fixed; inset: 0; z-index: 70;
  display: grid; justify-items: end;
  background: rgba(9, 47, 44, 0); pointer-events: none;
  transition: background 180ms ease;
}
.side-drawer.is-open { background: rgba(9, 47, 44, 0.24); pointer-events: auto; }
.side-drawer-card { width: min(440px, 100%); max-height: 100vh; overflow-y: auto; }
.side-drawer.is-open .side-drawer-card { transform: translateX(0); }
.drawer-form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.drawer-form label { display: flex; flex-direction: column; gap: 5px; }
.drawer-form label.form-wide { grid-column: 1 / -1; }
.drawer-form label span { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.drawer-form input, .drawer-form textarea {
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface-soft); font: inherit; color: var(--ink); outline: none;
}
.drawer-form input:focus, .drawer-form textarea:focus { border-color: var(--teal); background: #fff; }
.drawer-form textarea { resize: vertical; }
.drawer-form .primary-action { grid-column: 1 / -1; justify-content: center; }

.att-drawer-controls { display: grid; gap: 12px; margin: 4px 0 18px; }
.att-drawer-controls > label { display: flex; flex-direction: column; gap: 6px; }
.att-drawer-controls > label > span { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.att-drawer-controls select {
  height: 42px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface-soft); font: inherit; font-weight: 700; color: var(--ink);
  appearance: none; -webkit-appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23647875' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
.att-billed-toggle { flex-direction: row !important; align-items: center; gap: 9px !important; padding: 11px 13px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-soft); cursor: pointer; }
.att-billed-toggle input { width: 18px; height: 18px; accent-color: var(--teal); }
.att-billed-toggle span { font-size: 13.5px; font-weight: 700; color: var(--ink); text-transform: none; letter-spacing: 0; }
.drawer-status-row { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.drawer-status-row span { font-size: 13px; font-weight: 700; color: var(--muted); }

/* =====================================================================
   RESPONSIVO
   ===================================================================== */
@media (max-width: 1120px) {
  .module-summary { grid-template-columns: repeat(2, 1fr); }
  .att-filter-bar { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .dossier-shell { grid-template-columns: 280px 1fr; }
}
@media (max-width: 820px) {
  .att-filter-bar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .module-toolbar-actions { margin-left: 0; }
  .att-toolbar-actions { flex-direction: column; align-items: stretch; }
  .dossier-overlay { padding: 0; }
  .dossier-shell { grid-template-columns: 1fr; max-height: 100vh; height: 100%; width: 100%; border-radius: 0; }
  .dossier-profile { max-height: 38vh; }
  .dossier-profile-actions { margin-top: 14px; }
}
@media (max-width: 540px) {
  .module-summary { grid-template-columns: 1fr; }
  .att-filter-bar { grid-template-columns: 1fr; }
  .chip-row { width: 100%; justify-content: space-between; }
  .module-search { flex-basis: 100%; }
  .module-toolbar-actions { width: 100%; }
  .module-toolbar-actions .primary-action, .module-toolbar-actions .ghost-action { flex: 1; justify-content: center; }
  .drawer-form { grid-template-columns: 1fr; }
  .side-drawer-card { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .dossier-shell, .dossier-panel.active, .row-action, .chip, .summary-card, .data-table tbody tr { transition: none; animation: none; }
}

/* Compositor de evolução dentro do dossiê */
.dossier-evo-form { display: grid; gap: 9px; padding: 14px; margin-bottom: 16px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-soft); }
.dossier-evo-form .evo-row { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.dossier-evo-form input, .dossier-evo-form textarea {
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font: inherit; color: var(--ink); outline: none;
}
.dossier-evo-form input:focus, .dossier-evo-form textarea:focus { border-color: var(--teal); }
.dossier-evo-form textarea { resize: vertical; }
.dossier-evo-form .primary-action { justify-content: center; }

.import-module.active {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.subscription-module.active {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.subscription-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 18px;
  align-items: stretch;
}

.subscription-hero h3 {
  margin: 0 0 8px;
  font-size: 1.45rem;
}

.subscription-hero p {
  margin: 0;
  color: var(--muted);
}

.subscription-status-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: var(--surface-soft);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
}

.subscription-status-card span,
.subscription-status-card small,
.subscription-plan-card p,
.subscription-payment p {
  color: var(--muted);
}

.subscription-status-card strong {
  font-size: 1.12rem;
}

.subscription-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.subscription-plan-card {
  gap: 12px;
}

.subscription-plan-card.selected {
  border-color: rgba(15, 118, 110, 0.38);
  box-shadow: 0 18px 54px rgba(15, 118, 110, 0.12);
}

.subscription-plan-card h3,
.subscription-payment h3 {
  margin: 0;
}

.subscription-plan-card strong {
  font-size: 1.32rem;
}

.subscription-payment {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 18px;
  align-items: center;
}

.import-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  align-items: stretch;
  gap: 18px;
}

.import-hero h3 {
  margin: 0 0 8px;
  font-size: 1.45rem;
}

.import-hero p {
  margin: 0;
  color: var(--muted);
  max-width: 760px;
}

.import-status-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: var(--surface-soft);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
}

.import-status-card span,
.import-status-card small {
  color: var(--muted);
}

.import-status-card strong {
  font-size: 1.1rem;
}

.import-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.75fr);
  gap: 18px;
}

.import-dropzone {
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  min-height: 150px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 8px;
  background: var(--surface-soft);
  cursor: pointer;
  padding: 20px;
}

.import-dropzone input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.import-dropzone .icon {
  width: 34px;
  height: 34px;
}

.import-dropzone small,
.import-file-list small,
.import-checklist small {
  color: var(--muted);
}

.import-file-list {
  display: grid;
  gap: 8px;
}

.import-file-list article {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.import-checklist {
  display: grid;
  gap: 10px;
}

.import-checklist article {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 10px;
  align-items: start;
}

.import-checklist [data-import-check] {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  margin-top: 4px;
  border: 2px solid var(--line-strong);
  background: var(--surface);
}

.import-checklist [data-import-check].done {
  border-color: var(--success);
  background: var(--success);
  box-shadow: inset 0 0 0 3px var(--surface);
}

.import-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

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

.import-header-actions button:disabled {
  opacity: 0.65;
  cursor: wait;
}

.import-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.import-summary article {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--surface-soft);
}

.import-summary span {
  display: block;
  color: var(--muted);
  margin-bottom: 5px;
}

.import-summary strong {
  font-size: 1.35rem;
}

.import-result {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  background: var(--surface-soft);
  color: var(--text);
  font-weight: 700;
}

.import-result[hidden] {
  display: none;
}

.import-result.success {
  border-color: rgba(18, 166, 106, 0.35);
  background: rgba(18, 166, 106, 0.1);
}

.import-result.error {
  border-color: rgba(209, 72, 54, 0.35);
  background: rgba(209, 72, 54, 0.1);
}

.import-result.pending {
  border-color: rgba(47, 111, 237, 0.35);
  background: rgba(47, 111, 237, 0.1);
}

.import-preview-wrap {
  margin-top: 14px;
}

.import-preview-table {
  min-width: 760px;
}

.import-badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 4px 10px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.78rem;
  white-space: nowrap;
}
@media (max-width: 540px) { .dossier-evo-form .evo-row { grid-template-columns: 1fr; } }

/* =====================================================================
   RELATÓRIO DE ATENDIMENTOS
   ===================================================================== */
.report-module { display: grid; gap: 18px; }

.report-toolbar { display: flex; flex-wrap: wrap; gap: 18px; align-items: flex-end; justify-content: space-between; }
.report-heading h3 { margin: 4px 0 2px; }
.report-range { margin: 0; color: var(--muted); font-size: 13px; }
.report-controls { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.report-dates { display: flex; gap: 10px; }
.report-dates label { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }
.report-dates input {
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff;
  font: inherit; font-size: 13px; color: var(--ink); outline: none; color-scheme: light;
}
.report-dates input:focus { border-color: var(--teal); }
.report-presets .chip.selected { background: var(--teal); border-color: var(--teal); color: #fff; }
.report-exports { display: flex; gap: 10px; }

/* KPIs */
.report-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-top: 4px; }
.report-kpi { display: flex; gap: 12px; align-items: center; padding: 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-soft); }
.report-kpi-ico { flex: none; width: 40px; height: 40px; border-radius: 8px; position: relative; }
.report-kpi-ico::after { content: ""; position: absolute; width: 16px; height: 16px; border-radius: 4px; top: 12px; left: 12px; }
.report-kpi-ico.tone-teal { background: rgba(15, 118, 110, 0.14); } .report-kpi-ico.tone-teal::after { background: var(--teal); }
.report-kpi-ico.tone-blue { background: rgba(47, 111, 237, 0.14); } .report-kpi-ico.tone-blue::after { background: var(--blue); }
.report-kpi-ico.tone-gold { background: rgba(246, 211, 101, 0.28); } .report-kpi-ico.tone-gold::after { background: #d39b16; }
.report-kpi-ico.tone-green { background: rgba(18, 166, 106, 0.14); } .report-kpi-ico.tone-green::after { background: var(--success); }
.report-kpi strong { display: block; font-size: 24px; font-weight: 800; color: var(--ink); line-height: 1.1; }
.report-kpi span { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
.report-kpi small { display: block; font-size: 11px; color: var(--teal); margin-top: 2px; }

/* Grid de donuts */
.report-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.report-card { display: flex; flex-direction: column; }

/* Áreas de gráfico (altura fixa obrigatória p/ Chart.js) */
.report-chart-wrap { position: relative; height: 240px; margin-top: 6px; }
.report-chart-tall { position: relative; height: 330px; margin-top: 6px; }
.report-chart-wrap canvas, .report-chart-tall canvas { max-width: 100%; }

/* Legenda */
.report-legend { display: flex; flex-wrap: wrap; gap: 10px 16px; margin-top: 12px; }
.report-legend-item { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.report-legend-item i { width: 11px; height: 11px; border-radius: 3px; flex: none; }
.report-legend-item b { color: var(--ink); font-weight: 700; }
.report-legend-item em { font-style: normal; color: var(--muted); }

/* Estado vazio */
.report-empty { display: flex; align-items: center; justify-content: center; min-height: 180px; margin: 0; color: var(--muted); font-size: 13px; text-align: center; }

/* Totais do gráfico por período */
.report-totals { display: flex; flex-wrap: wrap; gap: 8px; }
.report-total { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.report-total b { font-weight: 800; }
.report-total.t-blue { background: rgba(47, 111, 237, 0.12); color: var(--blue); }
.report-total.t-green { background: rgba(18, 166, 106, 0.14); color: var(--success); }
.report-total.t-gold { background: rgba(211, 155, 22, 0.16); color: #b07d0b; }

/* Ícone de download (CSS shape) */
.download::before { width: 2px; height: 8px; border: 0; border-radius: 1px; background: currentColor; top: 2px; left: 8px; }
.download::after { width: 7px; height: 7px; border: 2px solid currentColor; border-top: 0; border-left: 0; border-radius: 0; top: 5px; left: 5px; transform: rotate(45deg); }

/* Responsivo */
@media (max-width: 1120px) {
  .report-grid { grid-template-columns: 1fr; }
  .report-kpis { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 820px) {
  .report-toolbar { align-items: stretch; }
  .report-controls { width: 100%; justify-content: space-between; }
}
@media (max-width: 540px) {
  .report-kpis { grid-template-columns: 1fr; }
  .report-dates { width: 100%; }
  .report-dates label { flex: 1; }
  .report-exports { width: 100%; }
  .report-exports .ghost-action, .report-exports .primary-action { flex: 1; justify-content: center; }
  .subscription-hero, .subscription-grid, .subscription-payment { grid-template-columns: 1fr; }
}
