@import url("https://fonts.googleapis.com/css2?family=Jost:wght@400;500;600;700;800&family=Montserrat:wght@600;700;800&display=swap");

:root {
  color-scheme: light;
  --bg: #f7f9fa;
  --surface: #ffffff;
  --surface-2: #f2f7f9;
  --text: #242424;
  --muted: #707b82;
  --line: #e1e7ea;
  --line-strong: #cbd5da;
  --primary: #2b87da;
  --primary-dark: #1d5f9b;
  --brand-dark: #414141;
  --brand-cyan: #6ec1e4;
  --green: #1f9d73;
  --orange: #d98b2b;
  --amber: #b98021;
  --red: #b83232;
  --blue-soft: #eaf6fc;
  --green-soft: #e8f7f0;
  --orange-soft: #fff4e7;
  --shadow: 0 18px 40px rgba(32, 48, 56, 0.11);
  --radius: 8px;
  --font: Jost, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --display-font: Montserrat, Jost, ui-sans-serif, system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  letter-spacing: 0;
}

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

button {
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.94), rgba(255, 255, 255, 0.76) 44%, rgba(65, 65, 65, 0.1)),
    url("/assets/alfaro-clinic-hero.jpg");
  background-size: cover;
  background-position: center;
}

.login-panel {
  width: min(520px, 100%);
  background: rgba(255, 255, 255, 0.97);
  border: 1px solid rgba(225, 231, 234, 0.95);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 30px;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-logo {
  width: 146px;
  height: auto;
  flex: 0 0 auto;
  object-fit: contain;
}

.brand-lockup strong,
.brand-lockup span {
  display: block;
}

.brand-lockup strong {
  color: var(--brand-dark);
  font-family: var(--display-font);
  font-size: 14px;
  text-transform: uppercase;
}

.brand-lockup div span {
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
}

.login-form {
  display: grid;
  gap: 16px;
  margin-top: 34px;
}

.login-form h1 {
  margin: 0 0 4px;
  font-family: var(--display-font);
  font-size: 30px;
  line-height: 1.1;
}

label {
  display: grid;
  gap: 7px;
  color: #35444d;
  font-size: 13px;
  font-weight: 650;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  padding: 10px 11px;
  outline: none;
}

.readonly-field {
  display: flex;
  align-items: center;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-2);
  color: #40505a;
  padding: 10px 11px;
  font-weight: 700;
}

textarea {
  min-height: 88px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(29, 95, 143, 0.14);
}

.primary-button,
.secondary-button,
.ghost-button,
.danger-button,
.icon-button {
  min-height: 40px;
  border-radius: 7px;
  border: 1px solid transparent;
  padding: 9px 13px;
  font-weight: 750;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.primary-button {
  background: var(--primary);
  color: #fff;
}

.primary-button:hover {
  background: var(--primary-dark);
}

.secondary-button {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--line);
}

.ghost-button,
.icon-button {
  background: transparent;
  color: var(--text);
  border-color: var(--line);
}

.danger-button {
  background: #fff3f3;
  color: var(--red);
  border-color: #efc5c5;
}

.icon-button {
  min-width: 40px;
  padding-inline: 10px;
}

.form-error {
  margin: 0;
  min-height: 20px;
  color: var(--red);
  font-size: 13px;
}

.login-hint {
  margin: -4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

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

.sidebar {
  min-height: 100vh;
  padding: 20px 16px;
  background: #ffffff;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 26px;
  position: sticky;
  top: 0;
}

.side-nav {
  display: grid;
  gap: 6px;
}

.nav-group {
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  padding: 6px;
}

.nav-group summary {
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 850;
  list-style: none;
  padding: 7px 8px;
  text-transform: uppercase;
}

.nav-group summary::-webkit-details-marker {
  display: none;
}

.nav-group summary::after {
  content: "+";
  color: var(--muted);
  font-weight: 900;
}

.nav-group[open] summary::after {
  content: "-";
}

.nav-group > div {
  display: grid;
  gap: 4px;
}

.side-nav button {
  min-height: 42px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #40505a;
  text-align: left;
  padding: 10px 12px;
  font-weight: 750;
}

.side-nav button:hover,
.side-nav button.active {
  background: #e8f2f6;
  color: #143c57;
}

#logoutButton {
  margin-top: auto;
  width: 100%;
}

.main-area {
  min-width: 0;
  padding: 22px 26px 36px;
}

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

.topbar h1 {
  margin: 2px 0 0;
  font-size: 28px;
  line-height: 1.15;
}

.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.date-badge {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: #40505a;
  font-weight: 750;
  white-space: nowrap;
}

.toast {
  position: fixed;
  right: 24px;
  top: 20px;
  z-index: 20;
  max-width: min(420px, calc(100vw - 48px));
  padding: 12px 14px;
  border-radius: var(--radius);
  background: #143c57;
  color: #fff;
  box-shadow: var(--shadow);
}

.view-root {
  min-width: 0;
}

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

.stat-card,
.panel,
.list-item,
.patient-detail,
.timeline-item,
.voucher-item,
.physio-row,
.appointment-side {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.stat-card {
  padding: 18px;
  min-height: 118px;
}

.stat-card span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.stat-card strong {
  display: block;
  margin-top: 12px;
  font-size: 34px;
  line-height: 1;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
  gap: 14px;
  margin-top: 14px;
}

.clinic-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.profitability-dashboard {
  display: grid;
  gap: 14px;
}

.profitability-summary {
  margin-bottom: 0;
}

.profit-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.profit-metrics article {
  min-height: 82px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  padding: 13px;
}

.profit-metrics span,
.profit-row-foot {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.profit-metrics strong {
  display: block;
  margin-top: 8px;
  font-size: 25px;
  line-height: 1.1;
}

.profit-visual-panel {
  overflow: hidden;
}

.profit-visual-layout {
  display: grid;
  grid-template-columns: minmax(190px, 0.32fr) minmax(0, 1fr);
  gap: 14px;
}

.profit-gauge-card,
.profit-bars-card {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
}

.profit-gauge-card {
  min-height: 294px;
  display: grid;
  place-items: center;
  gap: 14px;
  padding: 18px;
  text-align: center;
}

.profit-gauge-card > div:last-child strong,
.profit-gauge-card > div:last-child span {
  display: block;
}

.profit-gauge-card > div:last-child strong {
  color: #0f684b;
  font-size: 24px;
  line-height: 1.1;
}

.profit-gauge-card > div:last-child span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
  margin-top: 6px;
}

.profit-gauge {
  width: min(168px, 100%);
  aspect-ratio: 1;
  border-radius: 50%;
  background: conic-gradient(var(--green) 0 var(--profit-slice), #e9eef1 var(--profit-slice) 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  text-align: center;
  isolation: isolate;
  position: relative;
}

.profit-gauge.negative {
  background: conic-gradient(var(--red) 0 100%);
}

.profit-gauge::after {
  content: "";
  position: absolute;
  inset: 18px;
  border-radius: inherit;
  background: #fff;
  box-shadow: inset 0 0 0 1px var(--line);
  z-index: 0;
}

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

.profit-gauge strong {
  font-size: 28px;
  line-height: 1;
  margin: 0;
}

.profit-gauge span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  line-height: 1;
  margin: 0;
  text-transform: uppercase;
}

.profit-bars-card {
  min-width: 0;
  padding: 14px;
}

.profit-visual-legend {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  margin-bottom: 8px;
}

.profit-visual-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  display: inline-block;
}

.legend-dot.revenue {
  background: var(--primary);
}

.legend-dot.cost {
  background: var(--orange);
}

.legend-dot.profit {
  background: var(--green);
}

.profit-columns {
  min-height: 240px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
  align-items: end;
  gap: 12px;
  padding: 16px 8px 0;
  background:
    repeating-linear-gradient(to top, transparent 0, transparent 47px, rgba(225, 231, 234, 0.72) 48px),
    linear-gradient(#fff, #fff);
}

.profit-column {
  min-width: 0;
  display: grid;
  gap: 8px;
}

.profit-column-plot {
  height: 182px;
  display: flex;
  align-items: end;
  justify-content: center;
  gap: 7px;
  border-bottom: 1px solid var(--line-strong);
}

.profit-bar {
  width: 18px;
  min-height: 4px;
  border-radius: 6px 6px 0 0;
  display: block;
}

.profit-bar.revenue {
  background: linear-gradient(180deg, var(--brand-cyan), var(--primary));
}

.profit-bar.cost {
  background: linear-gradient(180deg, #f6c36b, var(--orange));
}

.profit-column strong {
  min-width: 0;
  overflow: hidden;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.profit-column .profit-value {
  text-align: center;
  white-space: normal;
}

.profit-chart {
  display: grid;
  gap: 10px;
}

.profit-row {
  display: grid;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  padding: 12px;
}

.profit-row-head,
.profit-row-foot {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.profit-row strong {
  display: block;
}

.profit-value {
  color: #0f684b;
  font-weight: 900;
  white-space: nowrap;
}

.profit-row.negative .profit-value {
  color: var(--red);
}

.profit-track {
  display: block;
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-2);
}

.profit-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--primary));
}

.profit-row.negative .profit-track span {
  background: var(--red);
}

.compact-empty {
  min-height: 138px;
}

.export-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 14px;
}

.export-strip h2 {
  margin: 0;
  font-size: 18px;
}

.export-strip p {
  margin: 4px 0 0;
}

.client-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 156px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.96), rgba(255, 255, 255, 0.76)),
    url("data:image/svg+xml,%3Csvg width='900' height='240' viewBox='0 0 900 240' xmlns='http://www.w3.org/2000/svg'%3E%3Crect width='900' height='240' fill='%23d9e8e6'/%3E%3Cg fill='none' stroke='%23789691' stroke-width='5' opacity='0.42'%3E%3Cpath d='M78 186c74-118 169-118 242 0M293 181c73-108 164-108 234 0M496 182c72-113 162-113 234 0'/%3E%3Cpath d='M130 94h650M188 136h529'/%3E%3C/g%3E%3C/svg%3E");
  background-size: cover;
  background-position: center;
  padding: 22px;
  margin-bottom: 14px;
}

.client-hero h2 {
  margin: 6px 0 6px;
  font-size: 30px;
  line-height: 1.12;
}

.client-hero p {
  margin: 0;
  color: var(--muted);
  font-weight: 650;
}

.client-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.82fr) minmax(0, 1.18fr);
  gap: 14px;
  align-items: start;
}

.client-history {
  margin-top: 14px;
}

.slot-grid,
.product-grid,
.activity-list {
  display: grid;
  gap: 10px;
}

.slot-grid {
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
}

.slot-button,
.product-card,
.activity-row {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
}

.slot-button {
  min-height: 68px;
  text-align: left;
  padding: 11px;
}

.slot-button strong,
.slot-button span {
  display: block;
}

.slot-button span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.slot-button:hover {
  border-color: #94b9ce;
  background: #f5fafc;
}

.product-card {
  display: grid;
  gap: 12px;
  padding: 13px;
}

.product-card strong,
.activity-row strong {
  display: block;
}

.product-card p,
.activity-row p {
  margin: 7px 0 0;
  color: #41505a;
  line-height: 1.45;
}

.price {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--green-soft);
  color: #0f684b;
  font-weight: 850;
  white-space: nowrap;
}

.client-card {
  grid-template-columns: 5px minmax(0, 1fr) minmax(124px, auto);
}

.client-card-actions,
.activity-action {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  align-items: center;
}

.activity-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(160px, auto);
  gap: 14px;
  align-items: center;
  padding: 14px;
}

.panel {
  padding: 18px;
}

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

.panel-header h2,
.panel h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.25;
}

.panel-header p,
.panel p {
  margin: 4px 0 0;
  color: var(--muted);
}

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

.appointment-chip {
  display: grid;
  grid-template-columns: 5px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 62px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  padding: 10px 12px 10px 0;
}

.appointment-chip .stripe {
  width: 5px;
  height: 100%;
  min-height: 42px;
  border-radius: 0 4px 4px 0;
}

.appointment-chip strong,
.list-item strong,
.timeline-item strong,
.voucher-item strong,
.physio-row strong {
  display: block;
}

.meta,
.small {
  color: var(--muted);
  font-size: 13px;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  border-radius: 999px;
  padding: 4px 9px;
  background: var(--blue-soft);
  color: var(--primary-dark);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.status.confirmada {
  background: var(--green-soft);
  color: #0f684b;
}

.status.cancelada {
  background: #fff3f3;
  color: var(--red);
}

.status.solicitada {
  background: var(--orange-soft);
  color: #9a4316;
}

.status.pendiente,
.status.programada {
  background: var(--blue-soft);
  color: var(--primary-dark);
}

.status.enviada,
.status.enviado,
.status.completada {
  background: var(--green-soft);
  color: #0f684b;
}

.status.preparado {
  background: var(--orange-soft);
  color: #9a4316;
}

.status.error {
  background: #fff3f3;
  color: var(--red);
}

.section-grid {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 14px;
}

.stack {
  display: grid;
  gap: 14px;
}

.compact-form {
  display: grid;
  gap: 11px;
}

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

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

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

.check-label {
  min-height: 38px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  padding: 8px 10px;
  color: #35444d;
  font-size: 13px;
  font-weight: 750;
}

.check-label input,
.inline-actions input[type="checkbox"] {
  width: 16px;
  min-height: 16px;
  accent-color: var(--primary);
}

.search-input {
  margin-bottom: 12px;
}

.patient-list {
  display: grid;
  gap: 9px;
  max-height: calc(100vh - 236px);
  overflow: auto;
  padding-right: 2px;
}

.list-item {
  width: 100%;
  text-align: left;
  padding: 12px;
}

.list-item.active,
.list-item:hover {
  border-color: #94b9ce;
  background: #f5fafc;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 9px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 8px;
  background: var(--surface-2);
  color: #40505a;
  font-size: 12px;
  font-weight: 750;
}

.tag.green {
  background: var(--green-soft);
  color: #0f684b;
}

.tag.orange {
  background: var(--orange-soft);
  color: #9a4316;
}

.patient-detail {
  min-width: 0;
  overflow: hidden;
}

.detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 20px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfc;
}

.detail-header h2 {
  margin: 0;
  font-size: 24px;
}

.detail-tabs {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--line);
  padding: 10px 16px 0;
  overflow-x: auto;
}

.detail-tabs button {
  min-height: 38px;
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: var(--muted);
  padding: 8px 10px;
  font-weight: 800;
  white-space: nowrap;
}

.detail-tabs button.active {
  color: var(--primary-dark);
  border-color: var(--primary);
}

.detail-body {
  padding: 18px;
}

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

.info-box {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 11px;
  min-height: 72px;
  background: #fff;
}

.info-box span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.info-box strong {
  display: block;
  margin-top: 7px;
  overflow-wrap: anywhere;
}

.note-block {
  margin-top: 12px;
  display: grid;
  gap: 10px;
}

.portal-access-panel {
  margin-top: 14px;
}

.note-block article {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 12px;
  background: #fff;
}

.note-block h3 {
  margin: 0 0 7px;
  font-size: 14px;
}

.note-block p {
  margin: 0;
  color: #41505a;
  line-height: 1.45;
}

.summary-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.clinical-summary-field {
  display: grid;
  gap: 7px;
}

.audio-summary-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfcfc;
}

.audio-summary-tools span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.clinical-contrast-panel {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 16px;
}

.contrast-result {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfcfc;
  padding: 12px;
  color: #40505a;
  line-height: 1.45;
}

.contrast-result.severity-green {
  border-color: #b8dfca;
  background: #f3fbf6;
}

.contrast-result.severity-orange {
  border-color: #efd09d;
  background: #fff9ef;
}

.contrast-result.severity-red {
  border-color: #efb8b8;
  background: #fff5f5;
}

.contrast-result-head {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.contrast-risk {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 850;
}

.contrast-date {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.contrast-risk.green {
  background: #dff5e8;
  color: #126643;
}

.contrast-risk.orange {
  background: #ffedcf;
  color: #8a5b1a;
}

.contrast-risk.red {
  background: #ffe1e1;
  color: var(--red);
}

.contrast-result.loading,
.contrast-result.empty {
  color: var(--muted);
  font-weight: 750;
}

.contrast-result.loading {
  min-height: 72px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.contrast-loader-logo {
  width: 34px;
  height: 34px;
  object-fit: contain;
  animation: contrast-loader 1.1s ease-in-out infinite;
}

@keyframes contrast-loader {
  0% {
    transform: rotate(0deg) scale(0.96);
    opacity: 0.65;
  }

  50% {
    transform: rotate(180deg) scale(1.08);
    opacity: 1;
  }

  100% {
    transform: rotate(360deg) scale(0.96);
    opacity: 0.65;
  }
}

.contrast-result.error {
  border-color: #efc5c5;
  background: #fff8f8;
  color: var(--red);
}

.contrast-result.configuration_missing {
  border-color: #f2d4a8;
  background: #fffaf2;
  color: #8a5b1a;
}

.contrast-result pre {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font: inherit;
}

.source-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.source-links a {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border: 1px solid #cdeaf6;
  border-radius: 999px;
  background: #f0f8fc;
  color: var(--primary-dark);
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
}

.timeline {
  display: grid;
  gap: 10px;
}

.timeline-item,
.voucher-item {
  padding: 13px;
}

.timeline-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
}

.pain-score {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

.voucher-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
}

.progress-bar {
  height: 9px;
  background: #e5ecef;
  border-radius: 99px;
  overflow: hidden;
  margin-top: 10px;
}

.progress-bar span {
  display: block;
  height: 100%;
  background: var(--green);
}

.anatomy-layout {
  display: grid;
  grid-template-columns: minmax(280px, 440px) minmax(260px, 1fr);
  gap: 16px;
  align-items: start;
}

.anatomy-stage {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfc;
  min-height: 620px;
  padding: 12px;
  display: grid;
  place-items: center;
}

.anatomy-svg {
  width: 100%;
  max-width: 420px;
  height: auto;
}

.body-region {
  fill: #e6a698;
  stroke: #9d5b52;
  stroke-width: 1.6;
  transition: fill 0.15s ease, stroke-width 0.15s ease, opacity 0.15s ease;
  cursor: pointer;
}

.body-region.tendon {
  fill: #f4d99d;
  stroke: #9d7a27;
}

.body-region:hover,
.body-region.selected {
  fill: #df6b4d;
  stroke-width: 2.6;
}

.body-region.marked {
  filter: drop-shadow(0 0 4px rgba(200, 95, 40, 0.5));
}

.bone-line {
  stroke: #63727b;
  stroke-width: 1.2;
  opacity: 0.42;
}

.anatomy-side {
  display: grid;
  gap: 14px;
}

.mark-list {
  display: grid;
  gap: 9px;
}

.mark-item {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 11px;
  background: #fff;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.mark-item button {
  align-self: start;
}

.physio-grid {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  gap: 14px;
}

.billing-page,
.billing-summary-layout,
.billing-editor-layout {
  display: grid;
  gap: 14px;
}

.billing-tabs-panel {
  padding: 12px;
}

.billing-editor-layout {
  max-width: 960px;
}

.billing-summary-layout > .panel {
  min-width: 0;
}

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

.invoice-lines {
  display: grid;
  gap: 10px;
}

.invoice-lines-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.invoice-item-row {
  display: grid;
  grid-template-columns: minmax(130px, 0.8fr) minmax(180px, 1.2fr) 92px 120px auto;
  gap: 8px;
  align-items: end;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  margin-top: 8px;
}

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

.invoice-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
}

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

.invoice-card-side {
  display: grid;
  gap: 7px;
  justify-items: end;
}

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

.accounts-layout {
  max-width: 1120px;
}

.security-layout {
  display: grid;
  gap: 14px;
  max-width: 1120px;
}

.security-list {
  margin-top: 14px;
}

.security-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
}

.security-row strong {
  display: block;
}

.security-row p {
  overflow-wrap: anywhere;
}

.readonly-block {
  display: grid;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-2);
  padding: 12px;
  overflow-wrap: anywhere;
}

.small-empty {
  min-height: 84px;
}

.account-list {
  display: grid;
  gap: 12px;
}

.account-row {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.account-main {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.account-main strong,
.account-main span {
  display: block;
}

.account-fields {
  align-items: end;
}

.export-layout {
  display: grid;
  gap: 14px;
  max-width: 1040px;
}

.export-hero-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.export-hero-panel h2 {
  margin: 5px 0 0;
  font-size: 24px;
}

.export-sheet-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.physio-row {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 13px;
}

.color-dot {
  width: 12px;
  height: 42px;
  border-radius: 99px;
}

.calendar-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 14px;
  align-items: start;
}

.calendar-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-width: 0;
  overflow: hidden;
}

.calendar-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.week-title {
  font-weight: 850;
  white-space: nowrap;
}

.physio-filter {
  max-width: 220px;
}

.calendar-board {
  display: grid;
  grid-template-columns: 64px repeat(7, minmax(132px, 1fr));
  height: 760px;
  overflow: auto;
  position: relative;
}

.time-corner,
.day-head {
  position: sticky;
  top: 0;
  z-index: 3;
  height: 58px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.time-corner {
  left: 0;
  z-index: 4;
  border-right: 1px solid var(--line);
}

.day-head {
  display: grid;
  place-items: center;
  border-right: 1px solid var(--line);
  text-align: center;
  padding: 8px;
}

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

.day-head strong {
  font-size: 13px;
  text-transform: uppercase;
  color: var(--muted);
}

.day-head span {
  margin-top: 3px;
  font-weight: 850;
}

.time-axis {
  position: sticky;
  left: 0;
  z-index: 2;
  grid-column: 1;
  background: #fff;
  border-right: 1px solid var(--line);
}

.time-slot-label {
  height: 64px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

.day-column {
  position: relative;
  min-height: 768px;
  border-right: 1px solid var(--line);
  background-image: linear-gradient(to bottom, transparent 63px, var(--line) 64px);
  background-size: 100% 64px;
}

.calendar-event {
  position: absolute;
  left: 6px;
  right: 6px;
  min-height: 34px;
  border-radius: 7px;
  color: #fff;
  padding: 7px 8px;
  box-shadow: 0 8px 18px rgba(31, 48, 56, 0.18);
  overflow: hidden;
}

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

.calendar-event strong {
  font-size: 13px;
}

.calendar-event span {
  margin-top: 2px;
  font-size: 12px;
  opacity: 0.93;
}

.appointment-side {
  padding: 16px;
  position: sticky;
  top: 18px;
}

.appointment-side h2 {
  margin: 0 0 14px;
  font-size: 18px;
}

.empty-state {
  min-height: 220px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--muted);
  background: #fbfcfc;
  padding: 18px;
}

.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.segmented-control {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  overflow: hidden;
}

.segmented-control button {
  min-height: 36px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  padding: 8px 10px;
  font-weight: 800;
}

.segmented-control button:last-child {
  border-right: 0;
}

.segmented-control button.active {
  background: var(--blue-soft);
  color: var(--primary-dark);
}

.notification-list,
.treatment-list,
.document-list,
.tooth-history {
  display: grid;
  gap: 10px;
}

.notification-item,
.treatment-item,
.document-item,
.tooth-record {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  padding: 12px;
}

.notification-item,
.treatment-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.treatment-item {
  grid-template-columns: 12px minmax(0, 1fr) auto;
}

.treatment-item p,
.document-item p,
.tooth-record p {
  margin: 5px 0 0;
  color: #41505a;
  line-height: 1.4;
}

.document-item a {
  display: inline-block;
  margin-top: 8px;
  color: var(--primary);
  font-weight: 750;
  overflow-wrap: anywhere;
}

.catalog-grid {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  gap: 14px;
}

.checkbox-panel {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 12px;
  background: #fbfcfc;
}

.checkbox-panel legend {
  padding: 0 6px;
  color: #35444d;
  font-size: 13px;
  font-weight: 800;
}

.month-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(128px, 1fr));
  min-height: 720px;
  overflow: auto;
  background: #fff;
}

.month-day {
  min-height: 118px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 9px;
  background: #fff;
}

.month-day.muted {
  background: #f7f9fa;
  color: var(--muted);
}

.month-day > strong {
  display: block;
  margin-bottom: 8px;
}

.month-events {
  display: grid;
  gap: 5px;
}

.month-events button {
  min-height: 26px;
  border: 0;
  border-radius: 5px;
  background: #f1f6f8;
  color: #25333b;
  padding: 5px 6px;
  text-align: left;
  font-size: 12px;
  font-weight: 750;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.month-events button span {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-right: 5px;
}

.month-events small {
  color: var(--muted);
  font-weight: 800;
}

.odontogram-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  align-items: start;
}

.odontogram-stage {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfc;
  padding: 14px;
}

.odontogram-toolbar,
.quadrant-actions,
.status-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.odontogram-toolbar {
  justify-content: space-between;
  margin-bottom: 12px;
}

.quadrant-actions {
  margin-bottom: 14px;
}

.odontogram {
  display: grid;
  grid-template-columns: 1fr;
  justify-items: center;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  padding: 18px;
  overflow: visible;
}

.dental-arch {
  display: grid;
  width: min(100%, var(--arch-max, 779px));
  gap: 5px;
  justify-self: center;
  min-width: 0;
  padding: 2px 0;
}

.tooth-strip,
.tooth-number-row {
  display: grid;
  grid-template-columns: repeat(var(--tooth-count), minmax(0, 1fr));
  width: 100%;
  gap: 5px;
  justify-content: center;
  min-width: 0;
}

.tooth-profile-strip {
  align-items: end;
}

.dental-arch-lower .tooth-profile-strip {
  align-items: start;
}

.arch-divider {
  height: 1px;
  background: var(--line);
}

.tooth {
  width: 100%;
  min-width: 0;
  min-height: 0;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--brand-dark);
  padding: 1px;
  display: grid;
  place-items: center;
  position: relative;
  --mark-fill: transparent;
  --mark-stroke: transparent;
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.tooth-profile {
  height: 76px;
}

.tooth-occlusal {
  height: 43px;
}

.tooth-number {
  width: 100%;
  height: 24px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: #69747a;
  display: grid;
  place-items: center;
  padding: 0;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.tooth:hover,
.tooth.selected,
.tooth-number:hover,
.tooth-number.selected {
  background: #eef9fd;
  border-color: var(--brand-cyan);
  box-shadow: 0 0 0 3px rgba(110, 193, 228, 0.18);
}

.tooth:focus-visible,
.tooth-number:focus-visible {
  outline: 2px solid var(--brand-cyan);
  outline-offset: 2px;
}

.tooth-svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.tooth-arch-lower.tooth-profile .tooth-svg {
  transform: rotate(180deg);
}

.tooth-root-shape {
  fill: #fff2c7;
}

.tooth-crown-shape {
  fill: #fffafa;
}

.tooth-root-shape,
.tooth-crown-shape {
  stroke: #8f989d;
  stroke-width: 2.2;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.tooth-surface-line {
  fill: none;
  stroke: #9ea7ab;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.tooth-band-mark,
.tooth-center-mark,
.tooth-treatment-mark {
  opacity: 0;
  pointer-events: none;
  vector-effect: non-scaling-stroke;
}

.tooth-band-mark,
.tooth-center-mark {
  fill: var(--mark-fill);
  stroke: var(--mark-stroke);
  stroke-width: 2;
}

.tooth-treatment-mark {
  fill: none;
  stroke: var(--mark-stroke);
  stroke-width: 3.2;
  stroke-linecap: round;
}

.tooth.tratado,
.tooth-number.tratado {
  --mark-fill: rgba(87, 205, 70, 0.76);
  --mark-stroke: #42a83a;
}

.tooth.pendiente,
.tooth-number.pendiente {
  --mark-fill: rgba(217, 139, 43, 0.72);
  --mark-stroke: var(--orange);
}

.tooth.en_tratamiento,
.tooth-number.en_tratamiento {
  --mark-fill: rgba(110, 193, 228, 0.5);
  --mark-stroke: var(--brand-cyan);
}

.tooth.tratado .tooth-band-mark,
.tooth.pendiente .tooth-center-mark,
.tooth.en_tratamiento .tooth-treatment-mark {
  opacity: 1;
}

.tooth.selected .tooth-crown-shape,
.tooth:hover .tooth-crown-shape {
  stroke: var(--brand-cyan);
}

.tooth-number.tratado,
.tooth-dot.tratado {
  background: var(--green-soft);
  border-color: var(--green);
  color: #166a49;
}

.tooth-number.pendiente,
.tooth-dot.pendiente {
  background: var(--orange-soft);
  border-color: var(--orange);
  color: #965f1d;
}

.tooth-number.en_tratamiento,
.tooth-dot.en_tratamiento {
  background: var(--blue-soft);
  border-color: var(--brand-cyan);
  color: var(--primary-dark);
}

.tooth-dot.sano {
  background: #fff;
  border-color: #9fb0b9;
}

.status-legend {
  margin-top: 12px;
}

.status-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.tooth-dot {
  width: 14px;
  height: 14px;
  border: 2px solid var(--line-strong);
  border-radius: 50%;
}

/* ── Treatment icon overlays ───────────────────────────────────── */
.tooth-icon {
  pointer-events: none;
}
.tooth-icon line,
.tooth-icon path,
.tooth-icon circle,
.tooth-icon rect {
  vector-effect: non-scaling-stroke;
}

.tooth-icon-extraccion line {
  stroke: #dc2626;
  stroke-width: 3.5;
  stroke-linecap: round;
  fill: none;
  opacity: 0.9;
}
.tooth-icon-endodoncia circle,
.tooth-icon-endodoncia path {
  fill: #7c3aed;
  stroke: none;
  opacity: 0.85;
}
.tooth-icon-empaste path,
.tooth-icon-empaste rect {
  fill: #1e40af;
  stroke: none;
  opacity: 0.72;
}
.tooth-icon-corona path,
.tooth-icon-corona circle {
  fill: none;
  stroke: #b45309;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.tooth-icon-implante line,
.tooth-icon-implante circle {
  fill: none;
  stroke: #374151;
  stroke-width: 2;
  stroke-linecap: round;
}
.tooth-icon-ortodoncia rect {
  fill: #0f766e;
  stroke: none;
  opacity: 0.8;
}
.tooth-icon-ortodoncia line {
  stroke: #0f766e;
  stroke-width: 2;
  stroke-linecap: round;
}
.tooth-icon-blanqueamiento path {
  fill: none;
  stroke: #2563eb;
  stroke-width: 2.5;
  stroke-linecap: round;
}

/* ── Treatment icon legend ─────────────────────────────────────── */
.treatment-icon-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}
.ti-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
}
.ti-legend-svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* ── Icon picker in treatment form ────────────────────────────── */
.icon-picker-fieldset {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px 12px;
  margin: 0;
}
.icon-picker-fieldset legend {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 0 4px;
}
.icon-picker-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.icon-picker-opt {
  cursor: pointer;
}
.icon-picker-opt input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.icon-picker-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 10px 6px;
  border: 2px solid var(--line);
  border-radius: 8px;
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  background: var(--surface);
  min-width: 64px;
  transition: border-color .15s, background .15s;
  cursor: pointer;
}
.icon-picker-btn svg {
  width: 26px;
  height: 26px;
}
.icon-picker-opt input:checked + .icon-picker-btn {
  border-color: var(--brand-cyan);
  background: var(--blue-soft);
  color: var(--primary-dark);
}
.icon-picker-opt:hover .icon-picker-btn {
  border-color: var(--brand-cyan);
}

/* ── Icon in treatment catalog list ───────────────────────────── */
.ti-item-svg {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  align-self: center;
}

.odontogram-side {
  display: grid;
  grid-template-columns: minmax(280px, 420px) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.patients-workspace {
  align-items: start;
}

.patients-nav-panel .panel {
  padding: 0;
  overflow: hidden;
}

.patients-nav-panel .compact-form,
.patients-nav-panel .search-field,
.patients-nav-panel .patient-list,
.compact-panel-header {
  margin-inline: 16px;
}

.patients-nav-panel .compact-form,
.patients-nav-panel .patient-list {
  margin-bottom: 16px;
}

.subnav-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-bottom: 1px solid var(--line);
  background: #fbfcfc;
}

.subnav-tabs button {
  min-height: 46px;
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: var(--muted);
  font-weight: 850;
}

.subnav-tabs button.active {
  border-color: var(--primary);
  color: var(--primary-dark);
  background: #fff;
}

.compact-panel-header {
  margin-top: 16px;
}

.search-field {
  margin-bottom: 12px;
}

.document-upload-form input[type="file"] {
  padding: 8px;
}

.upload-preview {
  min-height: 220px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfcfc;
  display: grid;
  gap: 10px;
  place-items: center;
  padding: 12px;
  overflow: hidden;
}

.upload-preview.empty {
  min-height: 96px;
  border-style: dashed;
  color: var(--muted);
  text-align: center;
}

.upload-preview img,
.upload-preview iframe {
  width: 100%;
  max-height: 420px;
  border: 0;
  border-radius: 6px;
  object-fit: contain;
  background: #fff;
}

.upload-preview iframe {
  height: 420px;
}

.upload-preview span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.document-item {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.document-preview {
  width: 100%;
  height: 160px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f7fafb;
  object-fit: cover;
}

.document-preview.pdf-preview {
  border: 1px solid var(--line);
}

.document-preview.placeholder {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-weight: 800;
}

.communications-grid {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.compact-list {
  max-height: calc(100vh - 310px);
}

.template-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.communication-log {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  padding: 12px;
}

.communication-log p {
  margin: 7px 0 0;
  color: #41505a;
  line-height: 1.45;
}

.message-error {
  color: var(--red) !important;
  font-size: 13px;
}

/* Alfaro brand layer */
body {
  background:
    linear-gradient(rgba(247, 249, 250, 0.96), rgba(247, 249, 250, 0.96)),
    url("/assets/alfaro-hex.png");
  background-size: 900px auto;
  background-position: right top;
}

.app-shell {
  background: rgba(255, 255, 255, 0.34);
}

.sidebar {
  background: rgba(255, 255, 255, 0.98);
  border-right-color: #edf1f3;
  box-shadow: 14px 0 38px rgba(32, 48, 56, 0.06);
}

.sidebar .brand-lockup {
  display: grid;
  gap: 8px;
}

.sidebar .brand-logo {
  width: 184px;
}

.sidebar .brand-lockup div span {
  color: #8a969d;
}

.side-nav {
  gap: 8px;
}

.nav-group {
  border-color: #edf1f3;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.nav-group summary {
  color: #75828a;
}

.side-nav button {
  border-left: 3px solid transparent;
  border-radius: 0 7px 7px 0;
  color: #414141;
  font-weight: 700;
}

.side-nav button:hover,
.side-nav button.active {
  background: #f0f8fc;
  border-left-color: var(--primary);
  color: var(--primary-dark);
}

.main-area {
  padding-top: 26px;
}

.topbar {
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(225, 231, 234, 0.9);
  border-radius: var(--radius);
  box-shadow: 0 14px 28px rgba(32, 48, 56, 0.06);
  padding: 16px 18px;
}

.topbar h1,
.client-hero h2,
.login-form h1,
.detail-header h2,
.panel-header h2,
.panel h2 {
  font-family: var(--display-font);
  color: var(--brand-dark);
}

.eyebrow {
  color: var(--primary);
  letter-spacing: 0;
}

.date-badge {
  border-color: #d7edf6;
  background: #f2fbff;
  color: var(--primary-dark);
}

.primary-button {
  background: #414141;
  border-color: #414141;
  color: #fff;
}

.primary-button:hover {
  background: #2f2f2f;
}

.secondary-button {
  background: #f0f8fc;
  color: var(--primary-dark);
  border-color: #cdeaf6;
}

.ghost-button,
.icon-button {
  background: #fff;
  border-color: #dfe9ee;
  color: #414141;
}

.ghost-button:hover,
.icon-button:hover,
.secondary-button:hover {
  border-color: var(--brand-cyan);
}

input,
select,
textarea {
  border-color: #dfe7eb;
  background: #fff;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand-cyan);
  box-shadow: 0 0 0 3px rgba(110, 193, 228, 0.2);
}

.stat-card,
.panel,
.list-item,
.patient-detail,
.timeline-item,
.voucher-item,
.physio-row,
.appointment-side,
.calendar-panel,
.login-panel {
  border-color: #e4eaed;
  box-shadow: 0 14px 34px rgba(32, 48, 56, 0.06);
}

.stat-card {
  background:
    linear-gradient(135deg, #ffffff 0%, #ffffff 68%, #eef9fd 100%);
}

.stat-card strong {
  color: var(--brand-dark);
  font-family: var(--display-font);
}

.panel-header {
  border-bottom: 1px solid transparent;
}

.appointment-chip,
.notification-item,
.treatment-item,
.document-item,
.tooth-record,
.slot-button,
.product-card,
.activity-row,
.note-block article,
.mark-item,
.info-box {
  border-color: #e4eaed;
}

.calendar-toolbar,
.time-corner,
.day-head,
.time-axis {
  background: #fff;
}

.calendar-event {
  box-shadow: 0 10px 18px rgba(32, 48, 56, 0.16);
}

.month-events button {
  background: #f3fafc;
}

.detail-header {
  background:
    linear-gradient(90deg, #ffffff 0%, #ffffff 70%, #eef9fd 100%);
}

.detail-tabs button.active {
  color: var(--primary-dark);
  border-color: var(--primary);
}

.client-hero {
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.96), rgba(255, 255, 255, 0.78)),
    url("/assets/alfaro-clinic-hero.jpg");
  background-size: cover;
  background-position: center 35%;
}

.odontogram-stage {
  background:
    linear-gradient(rgba(251, 252, 252, 0.96), rgba(251, 252, 252, 0.96)),
    url("/assets/alfaro-hex.png");
  background-size: 620px auto;
}

.tooth:hover,
.tooth.selected,
.tooth-number:hover,
.tooth-number.selected {
  border-color: var(--brand-cyan);
  box-shadow: 0 0 0 3px rgba(110, 193, 228, 0.2);
}

.tooth-dot.en_tratamiento {
  background: #eaf7fc;
  border-color: var(--brand-cyan);
}

.toast {
  background: #414141;
}

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

  .dashboard-grid,
  .clinic-stats-grid,
  .profit-visual-layout,
  .calendar-shell,
  .physio-grid,
  .section-grid,
  .anatomy-layout,
  .client-grid,
  .catalog-grid,
  .odontogram-layout,
  .communications-grid {
    grid-template-columns: 1fr;
  }

  .appointment-side {
    position: static;
  }
}

@media (max-width: 820px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
    position: static;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .side-nav {
    grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
  }

  .side-nav button {
    text-align: center;
    padding-inline: 6px;
  }

  #logoutButton {
    margin-top: 0;
  }

  .main-area {
    padding: 18px 14px 28px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .form-grid,
  .info-grid,
  .checkbox-grid,
  .profit-metrics,
  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr;
  }

  .invoice-item-row,
  .invoice-card {
    grid-template-columns: 1fr;
  }

  .invoice-card-side {
    justify-items: start;
  }

  .profit-columns {
    grid-template-columns: repeat(auto-fit, minmax(78px, 1fr));
  }

  .profit-column-plot {
    height: 150px;
  }

  .form-grid .span-2 {
    grid-column: span 1;
  }

  .detail-header,
  .calendar-toolbar,
  .client-hero,
  .activity-row {
    flex-direction: column;
    align-items: stretch;
  }

  .client-hero {
    display: grid;
  }

  .activity-row {
    display: grid;
  }

  .patient-list {
    max-height: none;
  }

  .calendar-board {
    grid-template-columns: 56px repeat(7, 128px);
  }

  .month-grid {
    grid-template-columns: repeat(7, 128px);
  }

  .tooth-profile {
    height: 70px;
  }

  .tooth-occlusal {
    height: 40px;
  }

  .odontogram-side {
    grid-template-columns: 1fr;
  }

  .document-item {
    grid-template-columns: 1fr;
  }

  .document-preview {
    height: 220px;
  }
}


/* ─── Consent components ──────────────────────────────────────────────────── */
.compact-button {
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background .12s, border-color .12s;
}
.compact-button:hover {
  background: var(--surface-2);
  border-color: var(--primary);
  color: var(--primary);
}
.compact-button.danger-button {
  border-color: #fca5a5;
  color: var(--red);
}
.compact-button.danger-button:hover {
  background: #fee2e2;
}

.consent-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
}

.consent-item {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.consent-item-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.consent-item-header strong {
  font-size: .9rem;
  display: block;
  margin-bottom: 3px;
}

.consent-item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
