/* CleanNote — design system próprio */
:root {
  color-scheme: light;
  --bg: #f4f6f8; --surface: #ffffff; --surface-2: #f8fafb; --surface-3: #eef2f5;
  --border: #e3e8ec; --border-strong: #cfd6dc;
  --text: #14202b; --text-2: #4a5866; --text-3: #7a8794;
  --brand: #0e8577; --brand-strong: #0a6b60; --brand-soft: #e3f4f1; --on-brand: #ffffff;
  --info: #2563c9; --info-soft: #e7effb;
  --ok: #1f8a4c; --ok-soft: #e4f4ea;
  --warn: #b26a00; --warn-soft: #fdf2dc;
  --danger: #c93a3a; --danger-soft: #fbe7e7;
  --violet: #6b4fd1; --violet-soft: #efebfc;
  --series-1: #2a78d6; --series-2: #eb6834; --tooth-line: #a9b2bb;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .18);
  --radius: 10px; --radius-sm: 7px;
  --side-w: 236px;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0f1418; --surface: #171e24; --surface-2: #1c242b; --surface-3: #232d35;
    --border: #2a353e; --border-strong: #3a4752;
    --text: #e8edf1; --text-2: #b4c0ca; --text-3: #8392a0;
    --brand: #22b3a2; --brand-strong: #3fc7b6; --brand-soft: #123631; --on-brand: #04201c;
    --info: #6aa1f0; --info-soft: #172a45;
    --ok: #4cc27d; --ok-soft: #14301f;
    --warn: #f0b04a; --warn-soft: #362810;
    --danger: #f07a7a; --danger-soft: #3a1a1a;
    --violet: #a493f2; --violet-soft: #262043;
    --series-1: #3987e5; --series-2: #d95926; --tooth-line: #6f7d89;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4); --shadow-lg: 0 12px 32px rgba(0, 0, 0, .55);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1418; --surface: #171e24; --surface-2: #1c242b; --surface-3: #232d35;
  --border: #2a353e; --border-strong: #3a4752;
  --text: #e8edf1; --text-2: #b4c0ca; --text-3: #8392a0;
  --brand: #22b3a2; --brand-strong: #3fc7b6; --brand-soft: #123631; --on-brand: #04201c;
  --info: #6aa1f0; --info-soft: #172a45;
  --ok: #4cc27d; --ok-soft: #14301f;
  --warn: #f0b04a; --warn-soft: #362810;
  --danger: #f07a7a; --danger-soft: #3a1a1a;
  --violet: #a493f2; --violet-soft: #262043;
  --series-1: #3987e5; --series-2: #d95926; --tooth-line: #6f7d89;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4); --shadow-lg: 0 12px 32px rgba(0, 0, 0, .55);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
h1 { font-size: 22px; font-weight: 650; }
h2 { font-size: 17px; font-weight: 650; }
h3 { font-size: 15px; font-weight: 650; }
h4 { font-size: 13px; font-weight: 650; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); }
hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }
.muted { color: var(--text-3); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.mono { font-variant-numeric: tabular-nums; }
.grow { flex: 1; min-width: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- Login ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: url(/img/pattern.svg) 0 0 / 180px 180px repeat, linear-gradient(135deg, #0a5f56 0%, #0e8577 55%, #13a08f 100%); }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-lg); padding: 32px 28px; }
.auth-card .logo { display: flex; align-items: center; gap: 10px; font-size: 22px; font-weight: 700; color: var(--brand); margin-bottom: 4px; }
.auth-card .logo svg { width: 32px; height: 32px; flex: none; }
.auth-card p.sub { margin: 0 0 22px; color: var(--text-3); }
.auth-card .btn { width: 100%; justify-content: center; margin-top: 8px; padding: 11px; }
.auth-switch { margin-top: 18px; text-align: center; font-size: 13px; color: var(--text-3); }

/* ---------- Shell ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar { width: var(--side-w); flex: none; background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; z-index: 30; }
.side-brand { display: flex; align-items: center; gap: 9px; padding: 16px 18px; font-weight: 700; font-size: 17px; color: var(--brand); }
.side-brand svg { width: 28px; height: 28px; flex: none; }
.clinic-switch { margin: 0 12px 10px; }
.clinic-switch button { width: 100%; display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--border); background: var(--surface-2); border-radius: var(--radius-sm); cursor: pointer; color: var(--text); text-align: left; font: inherit; }
.clinic-switch button:hover { border-color: var(--border-strong); }
.clinic-switch .cs-name { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.clinic-switch .cs-role { font-size: 11.5px; color: var(--text-3); }
.av { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; font-weight: 700; font-size: 12px; color: #fff; background: var(--brand); flex: none; }
.av.round { border-radius: 50%; }
.av.lg { width: 52px; height: 52px; font-size: 18px; border-radius: 14px; }
.av.xl { width: 112px; height: 112px; font-size: 36px; }
.av-photo { object-fit: cover; background: var(--surface-3); padding: 0; border: 1px solid var(--border); }
button.av-btn { border: 0; padding: 0; background: none; cursor: pointer; border-radius: 14px; position: relative; flex: none; }
button.av-btn:hover::after { content: "Trocar foto"; position: absolute; inset: 0; border-radius: inherit; background: rgba(0, 0, 0, .55); color: #fff; font-size: 10.5px; font-weight: 600; display: grid; place-items: center; text-align: center; }
.photo-field { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.photo-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.photo-actions label.btn { cursor: pointer; }
.cam-view { position: relative; aspect-ratio: 1; background: #000; border-radius: var(--radius); overflow: hidden; }
.cam-view video, .cam-view img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cam-view img:not([hidden]) ~ .cam-guide { display: none; }
.cam-guide { position: absolute; inset: 12%; border: 2px dashed rgba(255, 255, 255, .7); border-radius: 50%; pointer-events: none; }
.nav { flex: 1; overflow-y: auto; padding: 4px 10px 12px; }
.nav-sec { font-size: 11px; font-weight: 650; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; padding: 14px 10px 6px; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: var(--radius-sm); color: var(--text-2); font-weight: 520; margin-bottom: 1px; }
.nav a:hover { background: var(--surface-3); text-decoration: none; color: var(--text); }
.nav a.on { background: var(--brand-soft); color: var(--brand-strong); }
.nav a .cnt { margin-left: auto; background: var(--danger); color: #fff; border-radius: 10px; font-size: 11px; padding: 0 6px; font-weight: 700; }
.side-foot { border-top: 1px solid var(--border); padding: 10px; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 58px; display: flex; align-items: center; gap: 10px; padding: 0 22px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.topbar .title { font-weight: 650; font-size: 15px; }
.topbar .spacer { flex: 1; }
.icon-btn.menu-btn { display: none; }
.content { padding: 22px; max-width: 1440px; width: 100%; margin: 0 auto; }
.banner { padding: 9px 22px; font-size: 13px; display: flex; gap: 10px; align-items: center; }
.banner.warn { background: var(--warn-soft); color: var(--warn); }
.banner.danger { background: var(--danger-soft); color: var(--danger); }

/* dropdowns */
.dd { position: relative; }
.dd-menu { position: absolute; right: 0; top: calc(100% + 6px); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); min-width: 260px; max-width: 380px; z-index: 50; overflow: hidden; }
.dd-menu.left { left: 0; right: auto; }
.dd-head { padding: 12px 14px; border-bottom: 1px solid var(--border); font-weight: 650; display: flex; justify-content: space-between; align-items: center; }
.dd-list { max-height: 420px; overflow-y: auto; }
.dd-item { display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px; cursor: pointer; border-bottom: 1px solid var(--border); color: var(--text); width: 100%; background: none; border-left: 0; border-right: 0; border-top: 0; text-align: left; font: inherit; }
.dd-item:last-child { border-bottom: 0; }
.dd-item:hover { background: var(--surface-2); }
.dd-item.on { background: var(--brand-soft); }
.dd-item.unread { background: var(--info-soft); }
.dd-item small { display: block; color: var(--text-3); font-size: 12px; }
.bell-dot { position: absolute; top: 3px; right: 3px; background: var(--danger); color: #fff; font-size: 10px; font-weight: 700; border-radius: 9px; padding: 0 5px; min-width: 16px; text-align: center; line-height: 16px; }

/* ---------- Page ---------- */
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head .sub { color: var(--text-3); font-size: 13px; margin-top: 2px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.card-head .actions { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.card-body { padding: 18px; }
.card-body.tight { padding: 0; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-side { grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); }
.grid > .card + .card { margin-top: 0; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.stack > * + * { margin-top: 12px; }

/* KPI / stat tile */
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.kpi .k-label { color: var(--text-3); font-size: 12.5px; font-weight: 550; display: flex; gap: 6px; align-items: center; }
.kpi .k-value { font-size: 26px; font-weight: 700; margin-top: 6px; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.kpi .k-foot { font-size: 12.5px; color: var(--text-3); margin-top: 2px; }
.kpi.link { cursor: pointer; }
.kpi.link:hover { border-color: var(--border-strong); }

/* ---------- Botões ---------- */
.btn { display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: inherit; font-weight: 560; cursor: pointer; white-space: nowrap; line-height: 1.2; }
.btn:hover { background: var(--surface-3); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn svg.i { width: 16px; height: 16px; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn-primary:hover { background: var(--brand-strong); border-color: var(--brand-strong); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(.95); background: var(--danger); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); }
.btn-soft { background: var(--brand-soft); border-color: transparent; color: var(--brand-strong); }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-xs { padding: 3px 8px; font-size: 12px; border-radius: 6px; }
.icon-btn { width: 36px; height: 36px; display: inline-grid; place-items: center; border-radius: var(--radius-sm); border: 0; background: transparent; color: var(--text-2); cursor: pointer; position: relative; }
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn.sm { width: 30px; height: 30px; }
.icon-btn.sm svg.i { width: 16px; height: 16px; }
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-left: -1px; }
.btn-group .btn:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); margin-left: 0; }
.btn-group .btn:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.btn-group .btn.on { background: var(--brand-soft); color: var(--brand-strong); border-color: var(--brand); z-index: 1; }

/* ---------- Formulários ---------- */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label, .lbl { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.field .hint { font-size: 12px; color: var(--text-3); }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 8px 10px; width: 100%; min-width: 0; }
input[type="checkbox"], input[type="radio"] { width: auto; accent-color: var(--brand); }
input[type="color"] { padding: 2px; height: 36px; }
textarea { resize: vertical; min-height: 70px; line-height: 1.5; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, .icon-btn:focus-visible, .nav a:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; border-color: var(--brand); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.form-grid .span-2 { grid-column: span 2; }
.form-grid .span-3 { grid-column: span 3; }
.form-grid .full { grid-column: 1 / -1; }
.form-sec { grid-column: 1 / -1; font-weight: 650; font-size: 13px; color: var(--text-2); border-bottom: 1px solid var(--border); padding-bottom: 6px; margin-top: 6px; }
.check { display: inline-flex; gap: 8px; align-items: center; cursor: pointer; font-size: 13.5px; }
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 13.5px; }
.switch input { appearance: none; width: 36px; height: 20px; border-radius: 20px; background: var(--border-strong); position: relative; cursor: pointer; border: 0; padding: 0; flex: none; transition: background .15s; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: left .15s; box-shadow: 0 1px 2px rgba(0, 0, 0, .3); }
.switch input:checked { background: var(--brand); }
.switch input:checked::after { left: 18px; }
.search { position: relative; }
.search svg.i { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-3); width: 16px; height: 16px; }
.search input { padding-left: 34px; }
.ac { position: relative; }
.ac-list { position: absolute; left: 0; right: 0; top: calc(100% + 3px); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); z-index: 60; max-height: 260px; overflow-y: auto; }
.ac-list button { display: block; width: 100%; text-align: left; padding: 8px 12px; border: 0; background: none; font: inherit; color: var(--text); cursor: pointer; border-bottom: 1px solid var(--border); }
.ac-list button:hover, .ac-list button.on { background: var(--surface-2); }
.ac-list small { color: var(--text-3); }

/* ---------- Tabelas ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; font-weight: 650; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; }
.table td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr.click { cursor: pointer; }
.table tbody tr.click:hover td { background: var(--surface-2); }
.table td.actions { text-align: right; white-space: nowrap; }
.table td .sub { font-size: 12.5px; color: var(--text-3); }
.table tfoot td { font-weight: 650; background: var(--surface-2); }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; background: var(--surface-3); color: var(--text-2); white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.plain::before { display: none; }
.b-ok { background: var(--ok-soft); color: var(--ok); }
.b-info { background: var(--info-soft); color: var(--info); }
.b-warn { background: var(--warn-soft); color: var(--warn); }
.b-danger { background: var(--danger-soft); color: var(--danger); }
.b-violet { background: var(--violet-soft); color: var(--violet); }
.b-brand { background: var(--brand-soft); color: var(--brand-strong); }
.b-muted { background: var(--surface-3); color: var(--text-3); }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 6px 3px 10px; border-radius: 16px; background: var(--brand-soft); color: var(--brand-strong); font-size: 12.5px; font-weight: 600; }
.chip button { border: 0; background: none; color: inherit; cursor: pointer; padding: 0 3px; font-size: 14px; line-height: 1; }

/* ---------- Abas ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); overflow-x: auto; overflow-y: hidden; margin-bottom: 18px; scrollbar-width: thin; }
.tabs a, .tabs button { padding: 10px 14px; border: 0; background: none; font: inherit; font-weight: 580; color: var(--text-3); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; margin-bottom: -1px; }
.tabs a:hover, .tabs button:hover { color: var(--text); text-decoration: none; }
.tabs .on { color: var(--brand-strong); border-bottom-color: var(--brand); }

/* ---------- Alertas / vazios ---------- */
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 11px 14px; border-radius: var(--radius-sm); font-size: 13.5px; background: var(--info-soft); color: var(--info); }
.alert svg.i { margin-top: 1px; }
.alert.warn { background: var(--warn-soft); color: var(--warn); }
.alert.danger { background: var(--danger-soft); color: var(--danger); }
.alert.ok { background: var(--ok-soft); color: var(--ok); }
.alert b { font-weight: 650; }
.empty { padding: 36px 20px; text-align: center; color: var(--text-3); }
.empty svg.i { width: 34px; height: 34px; margin-bottom: 8px; opacity: .6; }
.empty .btn { margin-top: 12px; }
.loading { padding: 40px; text-align: center; color: var(--text-3); }
.spinner { width: 22px; height: 22px; border: 2.5px solid var(--border-strong); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Listas ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { display: flex; align-items: center; gap: 12px; padding: 11px 18px; border-bottom: 1px solid var(--border); }
.list > li:last-child { border-bottom: 0; }
.list > li.click { cursor: pointer; }
.list > li.click:hover { background: var(--surface-2); }
.list .li-main { flex: 1; min-width: 0; }
.list .li-title { font-weight: 600; }
.list .li-sub { font-size: 12.5px; color: var(--text-3); }
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 8px 14px; font-size: 13.5px; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; font-weight: 520; word-break: break-word; }

/* ---------- Modal ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(10, 18, 26, .5); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto; z-index: 100; animation: fade .12s ease-out; }
.modal { background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); width: 100%; max-width: 560px; animation: pop .14s ease-out; }
.modal.lg { max-width: 820px; }
.modal.xl { max-width: 1080px; }
.modal.sm { max-width: 420px; }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h2 { flex: 1; }
.modal-body { padding: 20px; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 14px 14px; flex-wrap: wrap; }
.modal-foot .left { margin-right: auto; display: flex; gap: 8px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0; } }

/* ---------- Toast ---------- */
#toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 200; max-width: calc(100vw - 36px); }
.toast { background: var(--text); color: var(--bg); padding: 11px 16px; border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); font-size: 13.5px; max-width: 420px; animation: pop .15s ease-out; }
.toast.err { background: var(--danger); color: #fff; }
.toast.ok { background: var(--ok); color: #fff; }

/* ---------- Gráficos ---------- */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid-line { stroke: var(--border); stroke-width: 1; }
.chart .axis-label { fill: var(--text-3); font-size: 11px; }
.chart .bar { transition: opacity .1s; }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover + .bar, .chart.hovering .bar.dim { opacity: .35; }
.chart-tip { position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg); border-radius: var(--radius-sm); padding: 7px 10px; font-size: 12.5px; white-space: nowrap; z-index: 5; transform: translate(-50%, calc(-100% - 8px)); }
.chart-tip b { display: block; margin-bottom: 2px; }
.chart-tip .sw { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-2); margin-bottom: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.hbar { display: grid; grid-template-columns: minmax(120px, 38%) 1fr auto; gap: 6px 10px; align-items: center; font-size: 13px; }
.hbar .hb-track { height: 14px; display: flex; align-items: center; }
.hbar .hb-fill { height: 12px; background: var(--series-1); border-radius: 0 4px 4px 0; min-width: 2px; }
.hbar .hb-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-2); }
.hbar .hb-val { font-variant-numeric: tabular-nums; color: var(--text); font-weight: 600; text-align: right; }
details.table-view summary { cursor: pointer; font-size: 12.5px; color: var(--text-3); margin-top: 8px; }

/* ---------- Agenda ---------- */
.ag-toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.ag-toolbar .ag-title { font-weight: 650; font-size: 15px; min-width: 180px; }
.ag-wrap { overflow: auto; max-height: calc(100vh - 210px); position: relative; touch-action: pan-x pan-y; }
.ag-zoom .btn { min-width: 34px; justify-content: center; font-variant-numeric: tabular-nums; }
.ag-grid { display: grid; position: relative; min-width: 640px; }
.ag-head { position: sticky; top: 0; z-index: 4; background: var(--surface); border-bottom: 1px solid var(--border); padding: 8px 6px; text-align: center; font-size: 12.5px; color: var(--text-3); }
.ag-head b { display: block; font-size: 18px; color: var(--text); font-weight: 650; }
.ag-head.today b { color: var(--brand); }
.ag-head.corner { left: 0; z-index: 5; }
/* zoom reduzido: colunas estreitas (semana inteira no celular) */
.ag-grid.compact .ag-head { padding: 6px 1px; font-size: 10.5px; }
.ag-grid.compact .ag-head b { font-size: 14px; }
.ag-grid.compact .ag-head .avatar { display: none; }
.ag-grid.compact .ag-gutter span { font-size: 9.5px; right: 3px; }
.ag-grid.compact .ag-ev { padding: 1px 3px; font-size: 10px; border-left-width: 3px; border-radius: 4px; line-height: 1.2; }
.ag-grid.compact .ag-ev .s { display: none; }
.ag-grid.compact .ag-ev .t { white-space: normal; overflow-wrap: anywhere; }
.ag-gutter { position: relative; border-right: 1px solid var(--border); background: var(--surface); }
.ag-gutter span { position: absolute; right: 6px; font-size: 11px; color: var(--text-3); transform: translateY(-50%); }
.ag-col { position: relative; border-right: 1px solid var(--border); cursor: copy; background-image: repeating-linear-gradient(to bottom, transparent 0, transparent calc(var(--hour) - 1px), var(--border) calc(var(--hour) - 1px), var(--border) var(--hour)); }
.ag-col.closed { background-color: var(--surface-3); }
.ag-col .off { position: absolute; left: 0; right: 0; background: repeating-linear-gradient(135deg, var(--surface-3) 0 6px, transparent 6px 12px); pointer-events: none; }
.ag-col .blk { position: absolute; left: 0; right: 0; background: repeating-linear-gradient(135deg, var(--warn-soft) 0 6px, transparent 6px 12px); border-left: 3px solid var(--warn); font-size: 11px; color: var(--warn); padding: 2px 6px; pointer-events: none; overflow: hidden; }
.ag-ev { position: absolute; border-radius: 6px; padding: 3px 7px; font-size: 12px; overflow: hidden; cursor: pointer; border-left: 4px solid var(--ev, var(--brand)); background: var(--surface); box-shadow: var(--shadow); color: var(--text); line-height: 1.3; }
.ag-ev:hover { z-index: 3; box-shadow: var(--shadow-lg); }
.ag-ev .t { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ag-ev .s { color: var(--text-3); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ag-ev.st-confirmado { background: var(--ok-soft); }
.ag-ev.st-solicitado { background: var(--violet-soft); border-left-style: dashed; }
.ag-ev.st-chegou, .ag-ev.st-em_atendimento { background: var(--info-soft); }
.ag-ev.st-concluido { opacity: .7; }
.ag-ev.st-faltou { background: var(--danger-soft); text-decoration: line-through; opacity: .75; }
.ag-ev.st-cancelado { background: var(--danger-soft); border-left-color: var(--danger); color: var(--danger); }
.ag-ev.st-cancelado .t { text-decoration: line-through; }
.ag-ev.st-cancelado .s { color: var(--danger); opacity: .8; }
/* cancelado na grade: atrás dos demais e "transparente" ao clique (o horário fica livre para outro paciente) */
.ag-ev.ag-canc { left: 2px; right: 2px; z-index: 0; pointer-events: none; box-shadow: none; border: 1px dashed var(--danger); border-left: 4px solid var(--danger); padding-right: 24px; }
.ag-cx { position: absolute; top: 0; right: 0; bottom: 0; width: 20px; pointer-events: auto; cursor: pointer; border: 0; padding: 0; background: var(--danger); color: #fff; display: grid; place-items: center; }
.ag-cx svg { width: 12px; height: 12px; }
.ag-cx:hover { filter: brightness(1.1); }
.ag-grid.compact .ag-ev.ag-canc { padding-right: 10px; }
.ag-grid.compact .ag-cx { width: 8px; }
.ag-grid.compact .ag-cx svg { display: none; }
.ag-ev.tp-compromisso { background: var(--surface-3); border-left-color: var(--text-3); }
input.loading-in { background-image: linear-gradient(90deg, transparent, var(--brand-soft), transparent); background-size: 200% 100%; animation: inload 1s linear infinite; }
@keyframes inload { from { background-position: 100% 0; } to { background-position: -100% 0; } }
.ag-ev { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.ag-ev.dragging { opacity: .3; }
.ag-ghost { box-shadow: var(--shadow-lg); outline: 2px solid var(--ev, var(--brand)); opacity: .95; cursor: grabbing; transition: transform .05s linear; }
.ag-ghost.nodrop { opacity: .5; outline-style: dashed; }
.ag-ghost-when { font-size: 10.5px; font-weight: 700; color: var(--ev, var(--brand)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ag-rs { position: absolute; left: 0; right: 0; bottom: 0; height: 8px; cursor: ns-resize; touch-action: none; }
.ag-rs::after { content: ''; position: absolute; left: 50%; bottom: 2px; width: 22px; margin-left: -11px; height: 3px; border-radius: 2px; background: var(--ev, var(--brand)); opacity: 0; transition: opacity .12s; }
.ag-ev:hover .ag-rs::after, .ag-ev.resizing .ag-rs::after { opacity: .8; }
.ag-ev.resizing { z-index: 5; box-shadow: var(--shadow-lg); outline: 2px solid var(--ev, var(--brand)); user-select: none; }
.ag-now { position: absolute; left: 0; right: 0; height: 2px; background: var(--danger); z-index: 2; pointer-events: none; }
.ag-now::before { content: ""; position: absolute; left: -4px; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--danger); }
.ag-list .ag-li { display: flex; gap: 14px; padding: 12px 16px; border-bottom: 1px solid var(--border); align-items: center; cursor: pointer; }
.ag-list .ag-li:hover { background: var(--surface-2); }
.ag-li .hr { font-weight: 700; font-variant-numeric: tabular-nums; width: 52px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
.slots { display: flex; flex-wrap: wrap; gap: 6px; }
.slots button { padding: 6px 10px; border: 1px solid var(--border-strong); border-radius: 6px; background: var(--surface); cursor: pointer; font: inherit; font-size: 13px; font-variant-numeric: tabular-nums; color: var(--text); }
.slots button:hover { border-color: var(--brand); }
.slots button.on { background: var(--brand); color: var(--on-brand); border-color: var(--brand); }
.month-grid { display: grid; grid-template-columns: repeat(7, 1fr); border-top: 1px solid var(--border); }
.month-grid .mh { padding: 8px; font-size: 12px; color: var(--text-3); text-align: center; border-bottom: 1px solid var(--border); font-weight: 600; }
.month-grid .md { min-height: 96px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 6px; cursor: pointer; font-size: 12px; }
.month-grid .md:hover { background: var(--surface-2); }
.month-grid .md.out { color: var(--text-3); background: var(--surface-2); }
.month-grid .md.today .dn { background: var(--brand); color: var(--on-brand); border-radius: 50%; }
.month-grid .dn { display: inline-grid; place-items: center; width: 24px; height: 24px; font-weight: 650; }
.month-grid .mc { margin-top: 4px; font-size: 11.5px; color: var(--text-2); }

/* ---------- Odontograma ---------- */
.odonto { overflow-x: auto; padding: 4px 0; }
.odonto-arch { display: flex; justify-content: center; gap: 4px; min-width: 720px; }
.odonto-arch .q { display: flex; gap: 3px; }
.odonto-arch .q + .q { padding-left: 10px; border-left: 2px solid var(--border-strong); }
.tooth { display: flex; flex-direction: column; align-items: center; gap: 2px; width: 40px; cursor: pointer; }
.tooth .tn { font-size: 11px; font-weight: 650; color: var(--text-3); }
.tooth svg { width: 36px; height: 36px; }
.tooth .face { stroke: var(--border-strong); stroke-width: 1; fill: var(--surface); }
.tooth .face:hover { fill: var(--surface-3); }
.tooth.sel .tn { color: var(--brand); }
.tooth.sel svg { outline: 2px solid var(--brand); outline-offset: 1px; border-radius: 4px; }
.tooth .mark { pointer-events: none; }
.odonto-mid { height: 14px; }
.odonto-legend { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.odonto-legend button { display: inline-flex; gap: 6px; align-items: center; border: 1px solid var(--border-strong); background: var(--surface); padding: 5px 10px; border-radius: 16px; cursor: pointer; font: inherit; font-size: 12.5px; color: var(--text); }
.odonto-legend button.on { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-strong); font-weight: 600; }
.odonto-legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }

/* ---------- Tratamentos: odontograma anatômico de planejamento ---------- */
svg.i.xs { width: 13px; height: 13px; vertical-align: -2px; }
svg.i.flip { transform: rotate(180deg); }
.tp-fields { display: grid; grid-template-columns: minmax(120px, .8fr) minmax(180px, 1.6fr) minmax(160px, 1.3fr) minmax(100px, .7fr); gap: 12px; align-items: start; }
.chipbox { min-height: 38px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 5px 6px; display: flex; flex-wrap: wrap; gap: 5px; align-items: center; background: var(--surface); }
.btn.pill { border-radius: 20px; }
.btn.pill.on { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-strong); }
.podo { overflow-x: auto; padding: 4px 0 2px; }
.podo-row { display: flex; justify-content: center; min-width: 600px; }
.podo-q { display: flex; gap: 1px; padding: 0 6px; }
.podo-q + .podo-q { border-left: 1px dashed var(--border-strong); }
.podo-mid { height: 0; border-top: 1px dashed var(--border-strong); margin: 6px auto; max-width: 560px; }
.ptooth { display: flex; flex-direction: column; align-items: center; gap: 3px; width: 34px; }
.ptooth .tn { font-size: 12px; font-weight: 600; color: var(--text-2); cursor: pointer; position: relative; line-height: 16px; user-select: none; }
.ptooth .tn .anot { position: absolute; top: -2px; right: -8px; color: var(--violet); font-weight: 800; font-size: 13px; }
.ptooth svg.anat { width: 26px; height: 52px; cursor: pointer; overflow: visible; }
.anat .crown, .anat .root { fill: var(--surface); stroke: var(--tooth-line); stroke-width: .75; stroke-linejoin: round; transition: fill .12s; }
.anat .root.back { fill: var(--surface-2); }
.anat:hover .crown, .anat:hover .root { fill: var(--surface-3); stroke: var(--text-3); }
.anat.open .crown { fill: #fdb022; stroke: #b54708; } .anat.open .root { fill: #fef0c7; stroke: #b54708; }
.anat.done .crown { fill: #47cd89; stroke: #067647; } .anat.done .root { fill: #dcfae6; stroke: #067647; }
.anat.sel .crown { fill: var(--brand); stroke: var(--brand-strong); } .anat.sel .root { fill: var(--brand-soft); stroke: var(--brand-strong); }
.anat.focus .crown, .anat.focus .root { stroke: var(--info); stroke-width: 2; }
.anat.gone .crown, .anat.gone .root { opacity: .28; }
.anat.incl .crown, .anat.incl .root { stroke-dasharray: 2 1.6; fill: var(--surface-3); }
.podo-clin .ptooth { width: 40px; }
.podo-clin .ptooth svg.anat { width: 30px; height: 60px; }
.podo-clin .ptooth svg.fsq { width: 28px; height: 28px; }
.podo-clin .podo-row { min-width: 700px; }
.anat.part .crown { fill: var(--brand-soft); stroke: var(--brand-strong); stroke-width: 1.6; }
.ptooth svg.fsq { width: 24px; height: 24px; }
.fsq .face { fill: var(--surface); stroke: var(--tooth-line); stroke-width: 1.1; cursor: pointer; }
.fsq .face:hover { fill: var(--surface-3); }
.fsq .face.on { fill: var(--brand); stroke: var(--brand-strong); }
.podo-pick .ptooth { border-radius: 8px; padding: 2px 0; }
.podo-pick .ptooth.picked { background: var(--brand-soft); box-shadow: inset 0 0 0 2px var(--brand); }
.podo-pick .ptooth.picked.part { box-shadow: inset 0 0 0 1.5px var(--brand); }
.podo-pick .ptooth.picked .tn { color: var(--brand-strong); }
.bud-odo { border-top: 1px dashed var(--border); margin-top: 10px; }
.lg-sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; }
.lg-sw.open { background: #fdb022; } .lg-sw.done { background: #47cd89; }
.list > li.tp-focus { background: var(--info-soft); }
.tp-recs { align-self: start; position: sticky; top: 74px; max-height: calc(100vh - 96px); overflow: auto; }
@media (max-width: 1100px) { .tp-recs { position: static; max-height: none; } }
@media (max-width: 860px) { .tp-fields { grid-template-columns: 1fr; } }

/* ---------- Paciente ---------- */
.pt-head { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.pt-head .pt-name { font-size: 20px; font-weight: 700; }
.pt-head .pt-meta { color: var(--text-3); font-size: 13px; display: flex; gap: 12px; flex-wrap: wrap; margin-top: 3px; }
.pt-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 16px 22px; border-left: 2px solid var(--border); margin-left: 6px; }
.timeline li::before { content: ""; position: absolute; left: -7px; top: 3px; width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 2px solid var(--brand); }
.timeline li:last-child { border-left-color: transparent; }
.timeline .tl-meta { font-size: 12.5px; color: var(--text-3); }
.timeline .tl-text { white-space: pre-wrap; margin-top: 3px; }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.thumb { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface-2); cursor: pointer; }
.thumb .ph { aspect-ratio: 4/3; display: grid; place-items: center; color: var(--text-3); background: var(--surface-3); }
.thumb img { width: 100%; aspect-ratio: 4/3; object-fit: cover; display: block; }
.thumb .tc { padding: 7px 9px; font-size: 12px; }
.thumb .tc b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.anam-row { display: grid; grid-template-columns: 1fr auto minmax(140px, 32%); gap: 10px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--border); }
.anam-row .seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 6px; overflow: hidden; }
.anam-row .seg label { padding: 4px 10px; cursor: pointer; font-size: 12.5px; }
.anam-row .seg input { display: none; }
.anam-row .seg input:checked + span { font-weight: 700; }
.anam-row .seg label:has(input:checked) { background: var(--brand-soft); color: var(--brand-strong); }
.anam-row .seg label.yes:has(input:checked) { background: var(--danger-soft); color: var(--danger); }

/* ---------- Impressão ---------- */
.print-only { display: none; }
@media print {
  body { background: #fff; color: #000; }
  .sidebar, .topbar, .banner, .no-print, #toasts, .modal-bg { display: none !important; }
  .print-only { display: block !important; }
  .content { padding: 0; max-width: none; }
  .card { box-shadow: none; border: 0; }
}
/* Aba Documentos */
.doc-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.doc-tile { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 16px 8px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); cursor: pointer; font: inherit; font-weight: 600; font-size: 13px; color: var(--text); }
.doc-tile:hover { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-strong); }
.doc-tile svg.i { width: 24px; height: 24px; color: var(--brand); }
.doc-editor { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.doc-help { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; }
.doc-preview { position: sticky; top: 0; }
.doc-preview-paper { background: #e9edf0; border-radius: var(--radius-sm); padding: 14px; max-height: 70vh; overflow: auto; }
.doc-preview-paper .doc-print { box-shadow: 0 1px 4px rgba(0, 0, 0, .18); padding: 28px 30px; font-size: 13px; }
.doc-preview-paper .doc-print .dp-body { min-height: 120px; font-size: 13.5px; }
@media (max-width: 1000px) { .doc-editor { grid-template-columns: 1fr; } .doc-preview { position: static; } }

/* Página pública do documento (/d/:token) */
body.doc-page { background: #e9edf0; }
.doc-bar { position: sticky; top: 0; z-index: 10; background: #fff; border-bottom: 1px solid #dde3e8; box-shadow: 0 1px 3px rgba(0, 0, 0, .06); }
.doc-bar-in { max-width: 820px; margin: 0 auto; padding: 10px 16px; display: flex; gap: 10px; align-items: center; }
.doc-sheet { max-width: 820px; margin: 18px auto; padding: 0 12px; }
.doc-sheet .doc-print { box-shadow: 0 1px 6px rgba(0, 0, 0, .15); }
.doc-sign { max-width: 796px; margin: 0 auto 18px; }
.sigpad { position: relative; border: 2px dashed #b8c2cb; border-radius: 10px; background: #fff; height: 180px; touch-action: none; }
.sigpad canvas { width: 100%; height: 100%; display: block; cursor: crosshair; touch-action: none; }
.sigpad-hint { position: absolute; inset: 0; display: grid; place-items: center; color: #9aa6b1; pointer-events: none; font-size: 15px; }
.doc-foot { text-align: center; font-size: 12px; color: #6b7884; padding: 8px 16px 28px; }
@media (max-width: 640px) {
  .doc-bar-in { padding: 8px 12px; } .doc-bar-in .small { display: none; } .doc-bar-in b { font-size: 13.5px; line-height: 1.25; display: block; }
  .doc-bar-in .btn { padding: 7px 10px; font-size: 13px; }
}
@media (max-width: 640px) { .doc-sheet { padding: 0; margin: 10px 0; } .doc-sheet .doc-print { padding: 22px 18px; } .doc-sheet .doc-print .dp-body { font-size: 14px; } }
@media print { body.doc-page { background: #fff; } .doc-sheet { margin: 0; padding: 0; max-width: none; } .doc-sheet .doc-print { box-shadow: none; } }

/* Documento clínico (impressão, pré-visualização e página do paciente) */
.doc-print { font-family: "Segoe UI", Arial, Helvetica, sans-serif; font-variant-numeric: lining-nums tabular-nums; color: #111; background: #fff; padding: 44px 52px; max-width: 800px; margin: 0 auto; line-height: 1.5; }
.doc-print .dp-head { text-align: center; border-bottom: 2px solid #0e8577; padding-bottom: 12px; margin-bottom: 24px; }
.doc-print .dp-clinic { font-size: 21px; font-weight: 700; letter-spacing: .01em; }
.doc-print .dp-clinic-info { font-size: 12px; color: #444; margin-top: 4px; font-family: "Segoe UI", Arial, sans-serif; }
.doc-print .dp-title { text-align: center; text-transform: uppercase; letter-spacing: .08em; font-size: 17px; margin: 0 0 22px; }
.doc-print .dp-patient { margin: 0 0 14px; font-size: 15px; }
.doc-print .dp-body { white-space: pre-wrap; font-size: 15px; line-height: 1.8; min-height: 300px; word-wrap: break-word; }
.doc-print .dp-date { margin-top: 34px; text-align: right; font-size: 14.5px; }
.doc-print .dp-sigs { display: flex; justify-content: center; gap: 48px; margin-top: 54px; flex-wrap: wrap; }
.doc-print .dp-sig { text-align: center; width: 300px; max-width: 100%; display: flex; flex-direction: column; align-items: center; font-size: 13.5px; }
.doc-print .dp-sig .dp-line { border-top: 1px solid #111; width: 100%; margin-bottom: 5px; }
.doc-print .dp-sig small { color: #444; font-size: 11.5px; font-family: "Segoe UI", Arial, sans-serif; }
.doc-print .dp-sig-img { max-width: 240px; max-height: 80px; margin-bottom: -6px; }
.doc-print.dp-especial { padding: 28px 34px; }
.doc-print .dp-esp-title { display: flex; justify-content: space-between; align-items: baseline; border-bottom: 2px solid #111; padding-bottom: 6px; margin-bottom: 10px; font-size: 15px; }
.doc-print .dp-esp-title span { font-size: 12px; font-family: "Segoe UI", Arial, sans-serif; }
.doc-print .dp-box { width: 100%; border-collapse: collapse; margin-bottom: 12px; font-size: 12.5px; }
.doc-print .dp-box td { border: 1px solid #111; padding: 6px 8px; vertical-align: top; line-height: 1.7; }
.doc-print .dp-box small { font-weight: 700; font-size: 10.5px; letter-spacing: .04em; font-family: "Segoe UI", Arial, sans-serif; }
.doc-print.dp-especial .dp-body { min-height: 150px; font-size: 14px; }
.doc-print.dp-especial .dp-sigs { margin-top: 28px; }
.doc-print .dp-buyer { margin-top: 18px; }
.dp-pagebreak { height: 24px; }
@media print { .dp-pagebreak { break-after: page; height: 0; } .doc-print { max-width: none; padding: 0; } @page { margin: 16mm 14mm; } }

/* ---------- Responsivo ---------- */
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-side { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); transition: transform .18s; box-shadow: var(--shadow-lg); }
  .app.side-open .sidebar { transform: none; }
  .app.side-open::after { content: ""; position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 25; }
  .icon-btn.menu-btn { display: inline-grid; }
  .content { padding: 16px; }
  .topbar { padding: 0 12px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .form-grid, .form-grid.cols-3, .form-grid.cols-4 { grid-template-columns: 1fr; }
  .form-grid .span-2, .form-grid .span-3 { grid-column: auto; }
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .kv dd { margin-bottom: 8px; }
  .anam-row { grid-template-columns: 1fr; }
  .modal-bg { padding: 0; }
  .modal { border-radius: 0; min-height: 100vh; }
}
@media (max-width: 520px) {
  .grid-4 { grid-template-columns: 1fr 1fr; }
  .kpi .k-value { font-size: 22px; }
  .page-head .actions { margin-left: 0; width: 100%; }
}

/* ---------- Zona de risco: migrar pacientes / remover clínica ---------- */
.danger-zone { border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); }
.danger-zone .card-head h2 { color: var(--danger); display: flex; align-items: center; gap: 8px; }
.btn-danger-ghost { background: transparent; border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); color: var(--danger); }
.btn-danger-ghost:hover { background: var(--danger-soft); }
.mig-list { max-height: 340px; overflow: auto; border: 1px solid var(--border); border-radius: 10px; }
.mig-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-bottom: 1px solid var(--border); cursor: pointer; font-size: 13.5px; }
.mig-item:last-child { border-bottom: 0; }
.mig-item:hover { background: var(--surface-2); }
.mig-item[hidden] { display: none; }
.rm-stats { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.rm-stat { border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; display: flex; flex-direction: column; }
.rm-stat b { font-size: 18px; }
.rm-stat span { font-size: 12px; color: var(--text-2); }
.rm-group { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.rm-group legend { font-weight: 600; margin-bottom: 6px; padding: 0; }
.rm-opt { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; cursor: pointer; }
.rm-opt > span { display: flex; flex-direction: column; gap: 2px; }
.rm-opt input { margin-top: 3px; }
.rm-opt:has(input:checked) { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 6%, transparent); }
.rm-opt.danger:has(input:checked) { border-color: var(--danger); background: var(--danger-soft); }
.rm-confirm { border-top: 1px solid var(--border); padding-top: 12px; }
#rmFin[hidden] { display: none; }
@media (max-width: 720px) { .rm-stats { grid-template-columns: repeat(3, 1fr); } }

/* ---------- Planilha de pacientes (exportar / importar) ---------- */
.sheet-box { border: 1px solid var(--border); border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.sheet-box h3 { margin: 0; }
.sheet-box p { margin: 0; }
.sheet-ic { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand-strong); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips .chip { padding: 3px 10px; font-weight: 500; }
.rm-stat.bad b { color: var(--danger); }
.imp-issues { max-height: 220px; overflow: auto; }
.imp-issues li { padding: 8px 0; }

/* Pagamento de fatura (Mercado Pago) */
.pay-tabs { display: flex; width: 100%; }
.pay-tabs .btn { flex: 1; justify-content: center; }
.pay-qr { width: 240px; max-width: 100%; border: 1px solid var(--border); border-radius: 10px; background: #fff; padding: 8px; }
.pay-wait { display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--text-3); padding: 8px 0; }
.spinner.sm { width: 14px; height: 14px; border-width: 2px; }
.pay-done { text-align: center; padding: 18px 0 8px; }
.pay-done > .i { width: 44px; height: 44px; padding: 10px; border-radius: 50%; background: var(--ok-soft); color: var(--ok); }
.pay-done h3 { margin: 10px 0 4px; }
.auto-card { display: flex; align-items: center; gap: 12px; margin-top: 16px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.auto-card > .i { width: 22px; height: 22px; color: var(--brand); flex: none; }
.auto-card .li-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
@media (max-width: 560px) { .auto-card { flex-wrap: wrap; } }

/* Permissões individuais do membro */
.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.perm-mod { border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px 10px; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.perm-mod legend { font-weight: 650; font-size: 12.5px; padding: 0 4px; }
.perm-mod .check { font-size: 13px; align-items: flex-start; }
.perm-mod .check input { flex-shrink: 0; margin-top: 2px; }

/* Modal de confirmação de reagendamento */
.move-cmp { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: center; background: var(--surface-2); border-radius: 8px; padding: 10px 12px; font-size: 13px; line-height: 1.45; }
.move-cmp s { color: var(--text-3); }
.move-arrow { color: var(--brand); }

/* ---------- Marca CleanNote ---------- */
:root { --logo-navy: #0b2d55; --logo-teal: #1a9a9e; --logo-mint: #2bb39b; --logo-top: #1a8d9b; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --logo-navy: #dbe7f5; --logo-teal: #3cc4c0; --logo-mint: #3fd1b4; --logo-top: #3cc4c0; } }
:root[data-theme="dark"] { --logo-navy: #dbe7f5; --logo-teal: #3cc4c0; --logo-mint: #3fd1b4; --logo-top: #3cc4c0; }
.cn-logo .cn-s1 { stop-color: var(--logo-top); } .cn-logo .cn-s2 { stop-color: var(--logo-navy); }
.cn-logo .cn-acc { fill: var(--logo-mint); } .cn-logo .cn-ln { stroke: var(--logo-navy); } .cn-logo .cn-ck { stroke: var(--logo-mint); }
.cn-name { font-weight: 800; letter-spacing: -.01em; white-space: nowrap; }
.cn-name .cn-a { color: var(--logo-navy); } .cn-name .cn-b { color: var(--logo-teal); }
.auth-tagline { margin: -2px 0 14px 40px; font-size: 12.5px; letter-spacing: .06em; color: var(--text-3); }
.cn-logo { width: 100%; height: 100%; display: block; }

/* Balão de mensagem recebida no WhatsApp */
.wa-balloon { display: flex; gap: 10px; align-items: flex-start; width: 340px; max-width: 100%; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-left: 4px solid #25d366;
  border-radius: 12px; box-shadow: var(--shadow-lg); padding: 10px 10px 10px 12px; text-decoration: none; animation: pop .18s ease-out; transition: opacity .2s, transform .2s; }
.wa-balloon:hover { border-color: var(--border-strong); border-left-color: #25d366; }
.wa-balloon.out { opacity: 0; transform: translateX(20px); }
.wa-b-av { flex: none; width: 36px; height: 36px; border-radius: 50%; background: #e7f9ee; color: #128c4b; display: grid; place-items: center; overflow: hidden; }
.wa-b-av img { width: 100%; height: 100%; object-fit: cover; }
.wa-b-av svg { width: 20px; height: 20px; }
.wa-b-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.wa-b-txt b { font-size: 13.5px; }
.wa-b-msg { white-space: pre-wrap; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.wa-b-txt small { color: var(--text-3); font-size: 11px; }
.wa-b-x { flex: none; border: 0; background: none; color: var(--text-3); cursor: pointer; padding: 2px; border-radius: 6px; }
.wa-b-x:hover { background: var(--surface-3); color: var(--text); }
.wa-b-x svg { width: 14px; height: 14px; }

/* Caixa de envio da conversa do WhatsApp */
.wa-composer { border-top: 1px solid var(--border); padding: 10px 12px 8px; background: var(--surface); border-radius: 0 0 var(--radius) var(--radius); }
.wa-row { display: flex; align-items: flex-end; gap: 6px; }
.wa-row textarea { flex: 1; resize: none; min-height: 40px; max-height: 140px; padding: 9px 12px; border-radius: 20px; line-height: 1.4; }
.wa-row .icon-btn { width: 40px; height: 40px; flex: none; cursor: pointer; }
.wa-send { width: 44px; height: 40px; padding: 0; justify-content: center; border-radius: 20px; flex: none; }
.wa-attach { display: flex; align-items: center; gap: 10px; padding: 8px 10px; margin-bottom: 8px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; font-size: 13px; }
.wa-attach img { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; }
.wa-fi { font-size: 26px; line-height: 1; }
.wa-recording { align-items: center; padding: 4px 2px; }
.wa-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: waPulse 1s infinite; }
@keyframes waPulse { 50% { opacity: .3; } }
#pfWaRecT { font-variant-numeric: tabular-nums; font-weight: 650; min-width: 38px; }
.wa-hint { margin-top: 4px; font-size: 11px; }
@media (max-width: 640px) { .wa-hint { display: none; } }

/* Mídia na conversa */
.wa-media { display: block; max-width: 100%; margin: 2px 0 6px; border-radius: 8px; }
audio.wa-media { width: 300px; max-width: 100%; height: 40px; }
.wa-img { max-height: 260px; cursor: zoom-in; background: var(--surface-3); min-width: 80px; min-height: 60px; }
video.wa-media { max-height: 300px; background: #000; }
.wa-doc { margin: 2px 0 6px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Página pública do orçamento */
.orc-tot { margin: 12px 0 0 auto; max-width: 320px; display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.orc-tot > div { display: flex; justify-content: space-between; gap: 16px; }
.orc-total { border-top: 1px solid var(--border); padding-top: 6px; font-size: 18px; font-weight: 750; }
.orc-cond { display: flex; gap: 10px; align-items: flex-start; margin-top: 14px; padding: 10px 12px; background: var(--surface-2); border-radius: 10px; font-size: 13.5px; }
.orc-cond svg { width: 20px; height: 20px; flex: none; color: var(--brand); margin-top: 2px; }

/* Evoluções por sessão */
.ev-day + .ev-day { margin-top: 6px; }
.ev-date { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); margin: 4px 0 10px; }
.ev-chip { font-size: 11.5px; padding: 1px 8px; background: var(--brand-soft); color: var(--brand-strong); border-radius: 999px; }
.timeline li.ev-done::before { background: var(--ok); border-color: var(--ok); }

/* PDF na conversa: prévia da 1ª página + barra com nome; visualizador completo no modal */
.wa-pdf { width: 300px; max-width: 100%; margin: 2px 0 6px; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--surface); }
.wa-pdf-prev { position: relative; height: 190px; background: #fff; overflow: hidden; }
.wa-pdf-frame { width: 100%; height: 420px; border: 0; pointer-events: none; display: block; }
.wa-pdf-hit { position: absolute; inset: 0; width: 100%; border: 0; background: transparent; cursor: zoom-in; }
.wa-pdf-bar { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 10px; border: 0; border-top: 1px solid var(--border); background: var(--surface-2); color: var(--text); cursor: pointer; text-align: left; font: inherit; font-size: 13px; }
.wa-pdf-bar:hover { background: var(--surface-3); }
.wa-pdf-ic { flex: none; font-size: 10px; font-weight: 800; color: #fff; background: #d92d20; border-radius: 4px; padding: 3px 5px; }
.wa-pdf-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.wa-pdf-bar small { color: var(--text-3); flex: none; }
.wa-pdf-full { width: 100%; height: 75vh; border: 0; border-radius: 8px; background: #fff; display: block; }

/* ---------- Balão de suporte (administradores da clínica) ---------- */
.sup-btn { position: fixed; right: 18px; bottom: 18px; z-index: 150; width: 52px; height: 52px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--brand); color: var(--on-brand); box-shadow: var(--shadow-lg); display: grid; place-items: center; transition: transform .15s; }
.sup-btn:hover { transform: scale(1.06); }
.sup-btn svg { width: 24px; height: 24px; }
.sup-btn.on { background: var(--brand-strong); }
.sup-dot { position: absolute; top: -2px; right: -2px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; border: 2px solid var(--surface); }
body.has-sup #toasts { bottom: 82px; }
.sup-panel { position: fixed; right: 18px; bottom: 82px; z-index: 160; width: 380px; max-width: calc(100vw - 24px); height: min(580px, calc(100vh - 110px));
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; overflow: hidden; }
.sup-panel[hidden] { display: none; }
.sup-head { display: flex; align-items: center; gap: 10px; padding: 12px 12px 12px 14px; background: var(--brand); color: var(--on-brand); }
.sup-head .icon-btn { color: inherit; }
.sup-head b { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 250px; }
.sup-head small { opacity: .85; font-size: 11px; }
.sup-logo svg { width: 22px; height: 22px; }
.sup-body { flex: 1; overflow-y: auto; padding: 12px; }
.sup-new { width: 100%; justify-content: center; margin-bottom: 10px; }
.sup-list { list-style: none; margin: 0; padding: 0; }
.sup-list li { display: flex; gap: 10px; padding: 10px; border: 1px solid var(--border); border-radius: 10px; margin-bottom: 8px; cursor: pointer; }
.sup-list li:hover { background: var(--surface-2); }
.sup-list li.unread { border-color: var(--brand); background: var(--brand-soft); }
.sup-t { font-weight: 650; font-size: 13.5px; }
.sup-s { font-size: 12px; color: var(--text-3); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }
.sup-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: none; }
.sup-meta small { color: var(--text-3); font-size: 11px; }
.sup-empty { text-align: center; color: var(--text-3); padding: 20px 10px; font-size: 13.5px; }
.sup-empty svg { width: 34px; height: 34px; color: var(--brand); }
.sup-form { display: flex; flex-direction: column; gap: 10px; }
.sup-attach { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sup-chat { background: var(--surface-2); }
.sup-msg { display: flex; margin: 6px 0; }
.sup-msg.me { justify-content: flex-end; }
.sup-bub { max-width: 85%; padding: 8px 11px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); font-size: 13.5px; }
.sup-msg.me .sup-bub { background: var(--brand-soft); }
.sup-txt { white-space: pre-wrap; overflow-wrap: anywhere; }
.sup-bub small { display: block; margin-top: 4px; font-size: 10.5px; color: var(--text-3); text-align: right; }
.sup-img { display: block; max-width: 100%; max-height: 220px; border-radius: 8px; margin-top: 4px; cursor: zoom-in; background: var(--surface-3); min-height: 40px; }
.sup-closed { text-align: center; font-size: 12px; color: var(--text-3); margin: 10px 0; }
.sup-compose { border-top: 1px solid var(--border); padding: 8px 10px 10px; display: flex; flex-direction: column; gap: 6px; }
.sup-compose textarea { flex: 1; resize: none; }
@media (max-width: 640px) { .sup-panel { right: 8px; left: 8px; width: auto; max-width: none; bottom: 78px; height: calc(100vh - 100px); } .sup-btn { right: 12px; bottom: 12px; } }
@media print { .sup-btn, .sup-panel { display: none !important; } }

/* Suporte no painel master */
.sup-adm { display: grid; grid-template-columns: minmax(280px, 380px) 1fr; gap: 16px; align-items: start; }
.sup-adm-list .list { max-height: 70vh; overflow-y: auto; }
.sup-adm-list li.sel { background: var(--brand-soft); }
.sup-adm-list li.unread .li-title { font-weight: 800; }
.sup-adm-last { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }
.sup-adm-side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: none; }
.sup-adm-msgs { max-height: 55vh; min-height: 200px; overflow-y: auto; padding: 12px 16px; background: var(--surface-2); }
.tab-count { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; margin-left: 6px; border-radius: 9px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; }
@media (max-width: 900px) { .sup-adm { grid-template-columns: 1fr; } }
@media (min-width: 641px) { body.sup-open #toasts { right: 412px; } }
