/* MedYou — visual "glass" translúcido, inspirado no iOS */
:root {
  --bg: #e9edf6;
  --blob-1: #c9d8ff;
  --blob-2: #e6d4ff;
  --blob-3: #cdeef0;
  --glass: rgba(255, 255, 255, 0.58);
  --glass-strong: rgba(255, 255, 255, 0.78);
  --glass-soft: rgba(255, 255, 255, 0.36);
  --glass-border: rgba(255, 255, 255, 0.75);
  --hairline: rgba(27, 34, 51, 0.08);
  --shadow: 0 10px 40px rgba(40, 56, 110, 0.10), 0 1px 2px rgba(40, 56, 110, 0.06);
  --text: #1b2233;
  --text-2: #4d5870;
  --muted: #7a859d;
  --accent: #2f6bff;
  --accent-2: #7b61ff;
  --accent-soft: rgba(47, 107, 255, 0.12);
  --accent-text: #ffffff;
  --grid: rgba(27, 34, 51, 0.08);
  /* marcadores (identidade, sempre com rótulo) */
  --tag-sintoma: #0b8f8a;
  --tag-sintoma-bg: rgba(11, 143, 138, 0.12);
  --tag-diagnostico: #6a4fe0;
  --tag-diagnostico-bg: rgba(106, 79, 224, 0.12);
  --tag-pendencia: #c25b12;
  --tag-pendencia-bg: rgba(226, 118, 38, 0.14);
  /* status */
  --ok: #1f8a4c;
  --ok-bg: rgba(31, 138, 76, 0.12);
  --warn: #a86500;
  --warn-bg: rgba(232, 160, 32, 0.16);
  --danger: #c4312b;
  --danger-bg: rgba(196, 49, 43, 0.12);
  --radius: 22px;
  --radius-sm: 14px;
  --blur: saturate(170%) blur(22px);
  --sidebar-w: 292px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1020;
    --blob-1: #1c2d66;
    --blob-2: #3a2466;
    --blob-3: #0f3f47;
    --glass: rgba(28, 36, 58, 0.55);
    --glass-strong: rgba(34, 43, 68, 0.82);
    --glass-soft: rgba(28, 36, 58, 0.35);
    --glass-border: rgba(255, 255, 255, 0.09);
    --hairline: rgba(255, 255, 255, 0.08);
    --shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
    --text: #e8ecf6;
    --text-2: #b9c2d8;
    --muted: #8a94ad;
    --accent: #6f9bff;
    --accent-2: #a08cff;
    --accent-soft: rgba(111, 155, 255, 0.16);
    --accent-text: #0b1020;
    --grid: rgba(255, 255, 255, 0.08);
    --tag-sintoma: #4fd1c9;
    --tag-sintoma-bg: rgba(79, 209, 201, 0.14);
    --tag-diagnostico: #b3a2ff;
    --tag-diagnostico-bg: rgba(179, 162, 255, 0.15);
    --tag-pendencia: #ffab6b;
    --tag-pendencia-bg: rgba(255, 171, 107, 0.15);
    --ok: #6fd39a;
    --ok-bg: rgba(111, 211, 154, 0.14);
    --warn: #f3c15c;
    --warn-bg: rgba(243, 193, 92, 0.14);
    --danger: #ff8a80;
    --danger-bg: rgba(255, 138, 128, 0.14);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b1020; --blob-1: #1c2d66; --blob-2: #3a2466; --blob-3: #0f3f47;
  --glass: rgba(28, 36, 58, 0.55); --glass-strong: rgba(34, 43, 68, 0.82); --glass-soft: rgba(28, 36, 58, 0.35);
  --glass-border: rgba(255, 255, 255, 0.09); --hairline: rgba(255, 255, 255, 0.08); --shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
  --text: #e8ecf6; --text-2: #b9c2d8; --muted: #8a94ad; --accent: #6f9bff; --accent-2: #a08cff;
  --accent-soft: rgba(111, 155, 255, 0.16); --accent-text: #0b1020; --grid: rgba(255, 255, 255, 0.08);
  --tag-sintoma: #4fd1c9; --tag-sintoma-bg: rgba(79, 209, 201, 0.14);
  --tag-diagnostico: #b3a2ff; --tag-diagnostico-bg: rgba(179, 162, 255, 0.15);
  --tag-pendencia: #ffab6b; --tag-pendencia-bg: rgba(255, 171, 107, 0.15);
  --ok: #6fd39a; --ok-bg: rgba(111, 211, 154, 0.14); --warn: #f3c15c; --warn-bg: rgba(243, 193, 92, 0.14);
  --danger: #ff8a80; --danger-bg: rgba(255, 138, 128, 0.14);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { min-height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14.5px/1.5 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Inter, sans-serif;
  -webkit-font-smoothing: antialiased;
}
body::before {
  content: ""; position: fixed; inset: -10%; z-index: -1; pointer-events: none;
  background:
    radial-gradient(40% 45% at 12% 18%, var(--blob-1), transparent 70%),
    radial-gradient(35% 40% at 88% 12%, var(--blob-2), transparent 70%),
    radial-gradient(45% 50% at 70% 92%, var(--blob-3), transparent 70%),
    radial-gradient(30% 35% at 30% 80%, var(--blob-2), transparent 70%);
  filter: blur(10px);
}
a { color: var(--accent); }
h1, h2, h3 { margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 24px; font-weight: 700; }
h2 { font-size: 16px; font-weight: 650; }
h3 { font-size: 14px; font-weight: 650; }
.muted { color: var(--muted); font-size: 13px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Superfícies glass ---------- */
.glass {
  background: var(--glass);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card { padding: 20px; }
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.inset { background: var(--glass-soft); border: 1px solid var(--hairline); border-radius: var(--radius-sm); padding: 14px; }

/* ---------- Controles ---------- */
label { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--text-2); font-weight: 500; }
input, select, textarea {
  font: inherit; color: var(--text);
  background: var(--glass-strong);
  border: 1px solid var(--hairline);
  border-radius: 12px; padding: 9px 12px; width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
textarea { resize: vertical; min-height: 90px; line-height: 1.55; }
textarea[readonly] { background: var(--glass-soft); }
button {
  font: inherit; font-weight: 600; cursor: pointer;
  border: 0; border-radius: 999px; padding: 9px 16px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--accent-text);
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  transition: transform .12s, box-shadow .15s, opacity .15s;
  box-shadow: 0 4px 14px rgba(47, 107, 255, 0.25);
  white-space: nowrap;
}
button:hover { transform: translateY(-1px); }
button:active { transform: translateY(0); }
button:disabled { opacity: .5; cursor: default; transform: none; }
button.ghost { background: var(--glass-strong); color: var(--text); border: 1px solid var(--hairline); box-shadow: none; }
button.ghost:hover { border-color: var(--accent); color: var(--accent); }
button.danger { background: var(--danger); color: #fff; box-shadow: none; }
button.small { padding: 5px 11px; font-size: 12.5px; }
button.icon { padding: 7px; width: 34px; height: 34px; border-radius: 50%; }
button.link { background: none; box-shadow: none; padding: 0; color: var(--text); font-weight: 650; border-radius: 4px; }
button.link:hover { color: var(--accent); transform: none; text-decoration: underline; }
button:focus-visible, a:focus-visible { outline: 3px solid var(--accent-soft); outline-offset: 2px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.form-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.segmented { display: inline-flex; padding: 3px; gap: 2px; border-radius: 999px; background: var(--glass-soft); border: 1px solid var(--hairline); }
.segmented button { background: none; color: var(--text-2); box-shadow: none; padding: 5px 12px; font-size: 12.5px; }
.segmented button.active { background: var(--glass-strong); color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,.08); }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Layout ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); gap: 18px; padding: 18px; min-height: 100vh; }
.sidebar {
  position: sticky; top: 18px; height: calc(100vh - 36px);
  display: flex; flex-direction: column; gap: 14px; padding: 18px 14px; overflow: visible;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px 4px; font-weight: 750; font-size: 19px; letter-spacing: -0.02em; }
.brand-mark { width: 30px; height: 30px; border-radius: 10px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); display: grid; place-items: center; color: #fff; }
.brand small { font-weight: 500; color: var(--muted); font-size: 12px; display: block; letter-spacing: 0; }
.search-box { position: relative; }
.search-box input { padding-left: 38px; border-radius: 14px; }
.search-box > svg { position: absolute; left: 12px; top: 10px; color: var(--muted); }
.search-box kbd { position: absolute; right: 10px; top: 9px; font: 11px/1 ui-monospace, monospace; color: var(--muted); border: 1px solid var(--hairline); border-radius: 6px; padding: 3px 6px; }
.dropdown {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 30;
  max-height: 360px; overflow-y: auto; padding: 6px;
  background: linear-gradient(var(--glass-strong), var(--glass-strong)), var(--bg);
  border: 1px solid var(--glass-border); border-radius: 16px; box-shadow: var(--shadow);
}
.dropdown .opt { display: block; width: 100%; text-align: left; background: none; box-shadow: none; color: var(--text); border-radius: 10px; padding: 8px 10px; font-weight: 500; white-space: normal; }
.dropdown .opt:hover, .dropdown .opt.active { background: var(--accent-soft); transform: none; }
.dropdown .opt small { display: block; color: var(--muted); font-weight: 400; font-size: 12px; }
.dropdown .opt.new { color: var(--accent); font-weight: 650; border-top: 1px solid var(--hairline); border-radius: 0 0 10px 10px; }
.org-switcher { display: flex; gap: 10px; align-items: center; padding: 10px; }
.org-mark { width: 34px; height: 34px; flex: none; }
.org-name { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.unit-pick { gap: 3px; padding: 0 4px; }
.unit-pick select { padding: 6px 10px; border-radius: 10px; font-size: 13px; }
.units-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.unit-card { padding: 14px; border-radius: var(--radius-sm); background: var(--glass-soft); border: 1px solid var(--hairline); display: flex; flex-direction: column; gap: 4px; }
.unit-card.inactive { opacity: .6; }
.tag-local { color: var(--text-2); background: var(--glass-strong); border: 1px solid var(--hairline); }
label.check { flex-direction: row; align-items: center; gap: 8px; font-size: 13.5px; color: var(--text); }
.org-switcher select { padding: 4px 8px; font-weight: 650; border-radius: 9px; }
.patient-chip { display: flex; gap: 10px; align-items: center; padding: 10px; }
.avatar { width: 38px; height: 38px; border-radius: 50%; flex: none; display: grid; place-items: center; font-weight: 700; font-size: 14px; color: #fff; background: linear-gradient(135deg, var(--accent-2), var(--accent)); }
.patient-chip .grow div:first-child { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav { display: flex; flex-direction: column; gap: 3px; margin-top: 4px; }
.nav a {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 13px;
  color: var(--text-2); text-decoration: none; font-weight: 550; transition: background .15s, color .15s;
}
.nav a:hover { background: var(--glass-soft); color: var(--text); }
.nav a.active { background: var(--glass-strong); color: var(--accent); box-shadow: 0 2px 10px rgba(40, 56, 110, .08); }
.nav a.needs-patient.disabled { opacity: .55; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 10px 12px 2px; font-weight: 650; }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }
.doctor-card { display: flex; gap: 10px; align-items: center; padding: 10px; }
.doctor-card .avatar { background: linear-gradient(135deg, #1fb5a8, var(--accent)); }
.main { min-width: 0; display: flex; flex-direction: column; gap: 18px; }
.topbar { display: flex; align-items: center; gap: 14px; padding: 14px 20px; }
.topbar .grow h1 { font-size: 20px; }
.menu-btn { display: none; }
.scrim { display: none; }
.rec-pill { display: inline-flex; align-items: center; gap: 8px; padding: 6px 8px 6px 12px; border-radius: 999px; background: var(--danger-bg); color: var(--danger); font-weight: 650; font-size: 13px; }
.rec-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--danger); animation: pulse 1.1s infinite; }
@keyframes pulse { 50% { opacity: .25; } }
.view { animation: fadein .25s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- Escuta ativa ---------- */
.listen-panel {
  margin-top: 14px; padding: 12px 16px 12px; border-radius: var(--radius-sm);
  background: linear-gradient(135deg, rgba(47, 107, 255, .10), rgba(123, 97, 255, .10));
  border: 1px solid rgba(123, 97, 255, .25);
  animation: listen-in .35s cubic-bezier(.2, .9, .3, 1.1);
}
@keyframes listen-in { from { opacity: 0; transform: translateY(-6px) scaleY(.9); } }
.listen-panel .wave { width: 100%; height: 96px; display: block; }
.listen-info { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 13px; margin-top: 4px; }
.listen-timer { font-variant-numeric: tabular-nums; color: var(--text-2); font-weight: 600; }
.listen-status { color: var(--text-2); }
.listen-status.warn { color: var(--warn); font-weight: 650; }
.wave-mini { width: 27px; height: 18px; display: block; }

/* ---------- Dashboard ---------- */
.kpis { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 16px; }
.kpi { padding: 18px 20px; position: relative; overflow: hidden; }
.kpi .muted { font-weight: 550; }
.kpi .value { font-size: 34px; font-weight: 750; letter-spacing: -0.03em; margin-top: 6px; }
.kpi .value small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 4px; letter-spacing: 0; }
.kpi::after { content: ""; position: absolute; right: -30px; top: -30px; width: 110px; height: 110px; border-radius: 50%; background: radial-gradient(circle, var(--accent-soft), transparent 70%); }
.dash-grid { display: grid; gap: 16px; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); align-items: start; }
.dash-grid .card + .card { margin-top: 0; }
.chart { position: relative; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart .bar { fill: var(--accent); transition: opacity .15s; }
.chart.hovering .bar { opacity: .4; }
.chart.hovering .col.hover .bar { opacity: 1; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .axis-text { fill: var(--muted); font-size: 11px; }
.chart .value-text { fill: var(--text-2); font-size: 11px; font-weight: 650; }
.chart .hit { fill: transparent; cursor: default; }
.tooltip { position: absolute; pointer-events: none; transform: translate(-50%, calc(-100% - 10px)); padding: 7px 10px; border-radius: 10px; font-size: 12.5px; white-space: nowrap; background: var(--glass-strong); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); border: 1px solid var(--glass-border); box-shadow: var(--shadow); }
.tooltip strong { display: block; font-size: 15px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--text-2); }
.legend span::before { content: ""; display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; background: currentColor; }
.legend .l-sintoma::before { background: var(--tag-sintoma); }
.legend .l-diagnostico::before { background: var(--tag-diagnostico); }
.legend .l-pendencia::before { background: var(--tag-pendencia); }
.alert-list { display: flex; flex-direction: column; gap: 10px; max-height: 620px; overflow-y: auto; margin: 0 -6px; padding: 0 6px; }
.alert-item { padding: 12px 14px; border-radius: var(--radius-sm); background: var(--glass-soft); border: 1px solid var(--hairline); }
.alert-item .impression { margin: 4px 0 8px; font-size: 13px; color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.status-chip { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 650; padding: 3px 9px; border-radius: 999px; }
.status-chip.overdue { color: var(--danger); background: var(--danger-bg); }
.status-chip.soon { color: var(--warn); background: var(--warn-bg); }
.status-chip.later { color: var(--text-2); background: var(--glass-strong); border: 1px solid var(--hairline); }
.status-chip.ok { color: var(--ok); background: var(--ok-bg); }
.status-chip.progress { color: var(--accent); background: var(--accent-soft); }

/* ---------- Marcadores ---------- */
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.tag { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 3px 4px 3px 9px; border-radius: 999px; line-height: 1.5; }
.tag:not(:has(button)) { padding-right: 9px; }
.tag .cat { font-weight: 500; opacity: .75; }
.tag button { background: none; box-shadow: none; padding: 0 5px; color: inherit; font-size: 13px; border-radius: 999px; line-height: 1.3; }
.tag button:hover { background: rgba(0,0,0,.08); transform: none; }
.tag-sintoma { color: var(--tag-sintoma); background: var(--tag-sintoma-bg); }
.tag-diagnostico { color: var(--tag-diagnostico); background: var(--tag-diagnostico-bg); }
.tag-pendencia { color: var(--tag-pendencia); background: var(--tag-pendencia-bg); }
.tag.resolved { text-decoration: line-through; opacity: .55; }
.tag-editor { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.tag-group h3 { font-size: 12.5px; margin-bottom: 6px; }
.tag-group form { display: flex; gap: 6px; margin-bottom: 8px; }
.tag-group input { padding: 6px 10px; font-size: 13px; }
.suggest { border: 1px dashed var(--hairline); border-radius: var(--radius-sm); padding: 10px 12px; margin-top: 10px; }
.suggest .tag { cursor: pointer; }

/* ---------- Timeline ---------- */
.timeline { position: relative; padding-left: 26px; }
.timeline::before { content: ""; position: absolute; left: 8px; top: 6px; bottom: 6px; width: 2px; border-radius: 2px; background: linear-gradient(var(--accent), var(--accent-2), transparent); opacity: .35; }
.tl-day { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 16px 0 8px -26px; padding-left: 26px; }
.tl-day:first-child { margin-top: 0; }
.tl-item { position: relative; padding: 14px 16px; border-radius: var(--radius-sm); background: var(--glass-soft); border: 1px solid var(--hairline); margin-bottom: 10px; transition: background .15s, transform .15s; }
.tl-item:hover { background: var(--glass-strong); }
.tl-item::before { content: ""; position: absolute; left: -24px; top: 19px; width: 12px; height: 12px; border-radius: 50%; background: var(--glass-strong); border: 3px solid var(--accent); }
.tl-item.open::before { border-color: var(--warn); }
.tl-when { font-size: 12.5px; color: var(--muted); font-weight: 550; }
.tl-title { font-weight: 650; }
.tl-item .impression { margin: 6px 0; font-size: 13px; color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ---------- Anamnese e evolução ---------- */
.evo { display: grid; gap: 16px; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); align-items: start; transition: grid-template-columns .5s cubic-bezier(.2, .8, .2, 1); }
.evo.chat-wide { grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr); }
.evo .card + .card { margin-top: 16px; }
.patient-strip { display: flex; align-items: center; gap: 14px; padding: 14px 18px; margin-bottom: 16px; flex-wrap: wrap; }
.workspace-head { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.section-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 18px 0 8px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.highlight {
  position: relative; padding: 16px 18px; border-radius: var(--radius-sm);
  background: linear-gradient(135deg, rgba(47, 107, 255, .12), rgba(123, 97, 255, .12));
  border: 1px solid rgba(123, 97, 255, .28);
}
.highlight h3 { display: flex; align-items: center; gap: 7px; color: var(--accent-2); font-size: 12.5px; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 8px; }
.highlight .cols { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.highlight textarea { min-height: 70px; background: var(--glass-strong); }
.md { overflow-wrap: anywhere; }
.md h3 { font-size: 14px; margin: 12px 0 4px; color: var(--text); }
.md h3:first-child { margin-top: 0; }
.md p { margin: 4px 0; }
.md ul, .md ol { margin: 4px 0; padding-left: 20px; }
.md code { font-size: 12.5px; background: var(--glass-soft); padding: 1px 5px; border-radius: 5px; }
.editor-toggle { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.editor-toggle .preview { max-height: 420px; overflow-y: auto; padding: 12px 14px; }
@media (max-width: 1250px) { .editor-toggle { grid-template-columns: 1fr; } }
.chat-card { position: sticky; top: calc(var(--topbar-h, 80px) + 16px); display: flex; flex-direction: column; height: calc(100vh - var(--topbar-h, 80px) - 48px); min-height: 520px; padding: 16px; }
.chat-log { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 4px 2px; margin: 8px 0; }
.msg { padding: 10px 13px; border-radius: 16px; max-width: 94%; overflow-wrap: anywhere; font-size: 14px; animation: fadein .2s ease; }
.msg.user { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; align-self: flex-end; border-bottom-right-radius: 5px; }
.msg.assistant { background: var(--glass-strong); border: 1px solid var(--hairline); align-self: flex-start; border-bottom-left-radius: 5px; }
.msg.thinking { color: var(--muted); }
.chat-input { display: flex; gap: 8px; align-items: flex-end; }
.chat-input textarea { min-height: 46px; max-height: 180px; border-radius: 16px; }
.quick { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.quick button { font-size: 12px; padding: 5px 10px; font-weight: 550; }
.expand-btn svg { transition: transform .4s; }
.chat-wide .expand-btn svg { transform: rotate(180deg); }

/* ---------- Prescrições / exames ---------- */
.two-col { display: grid; gap: 16px; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); align-items: start; }
.two-col .card + .card { margin-top: 16px; }
.ac { position: relative; }
.items { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; counter-reset: item; }
.items li { display: flex; gap: 12px; align-items: center; padding: 8px 10px 8px 12px; border-radius: 13px; background: var(--glass-soft); border: 1px solid var(--hairline); counter-increment: item; }
.items li::before { content: counter(item); flex: none; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; color: var(--accent); background: var(--accent-soft); }
.items .name { font-weight: 650; }
.history { display: flex; flex-direction: column; gap: 10px; }
.history-item { padding: 12px 14px; border-radius: var(--radius-sm); background: var(--glass-soft); border: 1px solid var(--hairline); }
.history-item ul { margin: 6px 0 8px; padding-left: 18px; font-size: 13.5px; }
.protocols { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.protocol { padding: 12px; border-radius: var(--radius-sm); background: var(--glass-soft); border: 1px solid var(--hairline); display: flex; flex-direction: column; gap: 6px; }
.linked { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ok); background: var(--ok-bg); padding: 4px 10px; border-radius: 999px; font-weight: 600; }
.empty { text-align: center; padding: 48px 20px; }
.empty .big { width: 56px; height: 56px; border-radius: 18px; margin: 0 auto 14px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.empty .big svg { width: 26px; height: 26px; }
.empty p { color: var(--text-2); max-width: 420px; margin: 8px auto 18px; }

/* ---------- Modal ---------- */
.modal-root { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(10, 16, 32, .35); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; } }
.modal-card { position: relative; width: min(860px, 100%); max-height: calc(100vh - 40px); overflow-y: auto; padding: 22px; background: var(--glass-strong); animation: pop .28s cubic-bezier(.2, .9, .3, 1.2); }
.modal-card.wide { width: min(1000px, 100%); }
@keyframes pop { from { opacity: 0; transform: scale(.96) translateY(10px); } }
.modal-close { position: absolute; right: 14px; top: 14px; }
.modal-section { margin-top: 16px; }

/* ---------- Documento para impressão ---------- */
.sheet { background: #fff; color: #111; width: 100%; max-width: 780px; margin: 0 auto; padding: 44px 50px; border-radius: 6px; box-shadow: 0 4px 30px rgba(0,0,0,.18); font: 14px/1.55 Georgia, "Times New Roman", serif; min-height: 900px; display: flex; flex-direction: column; }
.sheet header { border-bottom: 2px solid #111; padding-bottom: 12px; margin-bottom: 22px; display: flex; justify-content: space-between; gap: 20px; }
.sheet header .clinic { font: 700 18px/1.3 -apple-system, "Segoe UI", sans-serif; }
.sheet header .sub { font: 12px/1.4 -apple-system, "Segoe UI", sans-serif; color: #444; white-space: pre-line; }
.sheet .doc-title { text-align: center; font: 700 16px/1 -apple-system, "Segoe UI", sans-serif; letter-spacing: .18em; text-transform: uppercase; margin-bottom: 22px; }
.sheet .patient-line { margin-bottom: 20px; font-size: 14px; }
.sheet ol { padding-left: 22px; margin: 0; }
.sheet ol li { margin-bottom: 16px; }
.sheet .posology { margin-top: 2px; }
.sheet .note { margin-top: 18px; white-space: pre-line; }
.sheet footer { margin-top: auto; padding-top: 50px; text-align: center; }
.sheet .signature img { max-height: 80px; max-width: 260px; display: block; margin: 0 auto -6px; }
.sheet .signature .line { border-top: 1px solid #111; width: 300px; margin: 0 auto 6px; }
.sheet .date-line { text-align: right; margin-top: 26px; }
.sheet .validity { text-align: right; margin-top: 4px; font: 600 12.5px/1.4 -apple-system, "Segoe UI", sans-serif; }
.sheet .via { align-self: flex-end; margin: -24px -26px 14px 0; padding: 3px 10px; border: 1px solid #111; border-radius: 4px; font: 700 11px/1.4 -apple-system, "Segoe UI", sans-serif; letter-spacing: .08em; text-transform: uppercase; }
/* Carimbo do médico: bloco com borda, como o carimbo físico. Não é assinatura digital. */
.sheet .stamp { display: inline-block; margin-top: 4px; padding: 6px 14px; border: 1.5px solid #1b2f6b; border-radius: 4px; color: #1b2f6b; font: 12.5px/1.45 -apple-system, "Segoe UI", sans-serif; text-align: center; }
.sheet .stamp .stamp-name { font-weight: 700; font-size: 13.5px; }
.stamp-preview { min-height: 0; padding: 14px; box-shadow: none; border: 1px solid var(--hairline); align-items: center; }
.sheets { display: flex; flex-direction: column; gap: 24px; }
.chip.ok, .chip.muted, .chip.warn { display: inline-flex; align-items: center; padding: 1px 8px; border-radius: 999px; font: 650 11px/1.6 -apple-system, "Segoe UI", sans-serif; background: color-mix(in srgb, var(--warn, #b7791f) 16%, transparent); color: var(--warn, #8a5a12); }

/* ---------- Autenticação ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth-card { width: min(460px, 100%); padding: 30px; }
.auth-card .brand { justify-content: center; margin-bottom: 18px; font-size: 22px; }

/* ---------- Assinatura ---------- */
.sig-pad { width: 100%; height: 160px; border-radius: var(--radius-sm); background: #fff; border: 1px dashed var(--hairline); touch-action: none; cursor: crosshair; display: block; }

#toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 200; padding: 11px 18px; border-radius: 999px; font-weight: 550; background: var(--glass-strong); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); border: 1px solid var(--glass-border); box-shadow: var(--shadow); max-width: 90vw; }

/* ---------- Responsivo ---------- */
@media (max-width: 1100px) {
  .dash-grid, .two-col { grid-template-columns: 1fr; }
  .evo, .evo.chat-wide { grid-template-columns: 1fr; }
  .chat-card { position: relative; top: 0; height: 640px; }
  .expand-btn { display: none; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; padding: 12px 16px; }
  .sidebar { position: fixed; z-index: 50; left: 12px; top: 12px; bottom: 12px; height: auto; width: min(300px, calc(100vw - 24px)); transform: translateX(calc(-100% - 20px)); transition: transform .3s ease; }
  body.menu-open .sidebar { transform: none; }
  .sidebar { background: var(--glass-strong); }
  body.menu-open .scrim { display: block; position: fixed; inset: 0; z-index: 40; background: rgba(10, 16, 32, .3); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
  .menu-btn { display: inline-flex; }
  .kpi .value { font-size: 28px; }
  .sheet { padding: 28px 22px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Impressão ---------- */
@media print {
  body.print-mode::before { display: none; }
  body.print-mode > *:not(.modal-root) { display: none !important; }
  body.print-mode .modal-root { position: static; padding: 0; display: block; }
  body.print-mode .modal-backdrop, body.print-mode .modal-chrome { display: none !important; }
  body.print-mode .modal-card { background: none; box-shadow: none; border: 0; padding: 0; max-height: none; overflow: visible; width: 100%; animation: none; -webkit-backdrop-filter: none; backdrop-filter: none; }
  body.print-mode .sheet { box-shadow: none; padding: 0; max-width: none; min-height: calc(100vh - 2cm); border-radius: 0; }
  body.print-mode .sheets { gap: 0; }
  body.print-mode .sheets .sheet + .sheet { break-before: page; }
  body.print-mode .sheet .via { margin: 0 0 12px; }
  @page { margin: 1.6cm; }
}

/* ---------- Cadastro do paciente ---------- */
.id-grid { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 18px; align-items: start; }
@media (max-width: 700px) { .id-grid { grid-template-columns: 1fr; } }
.photo-box { display: flex; flex-direction: column; align-items: center; gap: 10px; }
img.avatar.photo { object-fit: cover; border: 2px solid var(--glass-border); box-shadow: var(--shadow); background: var(--glass-strong); }
.insurance-row { display: flex; flex-direction: column; gap: 10px; }

/* ---------- Agenda ---------- */
.agenda-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 1000px) { .agenda-layout { grid-template-columns: 1fr; } }
.agenda-side { position: sticky; top: calc(var(--topbar-h, 80px) + 16px); display: flex; flex-direction: column; gap: 14px; }
.agenda-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.mini-cal { display: flex; flex-direction: column; gap: 8px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; text-align: center; }
.cal-wd { font-size: 11px; color: var(--muted); font-weight: 650; padding: 2px 0; }
.cal-day { position: relative; background: none; box-shadow: none; color: var(--text); font-weight: 550; padding: 0; height: 34px; border-radius: 10px; font-size: 13px; }
.cal-day:hover { background: var(--glass-strong); transform: none; }
.cal-day.out { color: var(--muted); opacity: .5; }
.cal-day.nowork { color: var(--muted); }
.cal-day.today { box-shadow: inset 0 0 0 2px var(--accent); }
.cal-day.sel { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; }
.cal-dot { position: absolute; right: 2px; top: 1px; min-width: 15px; height: 15px; padding: 0 3px; border-radius: 999px; font-size: 9.5px; line-height: 15px; font-weight: 700; background: var(--accent-soft); color: var(--accent); }
.cal-day.sel .cal-dot { background: rgba(255,255,255,.3); color: #fff; }
.status-legend { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--text-2); margin-top: 8px; }

.day-summary { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--glass-soft); border: 1px solid var(--hairline); }
.sum-item { display: flex; flex-direction: column; padding-right: 14px; border-right: 1px solid var(--hairline); }
.sum-item strong { font-size: 18px; letter-spacing: -.02em; }
.sum-status { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.sum-chip { font-size: 12.5px; font-weight: 650; padding: 3px 9px; border-radius: 999px; background: var(--glass-strong); border: 1px solid var(--hairline); }

.slot-list { display: flex; flex-direction: column; }
.slot { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 12px; padding: 8px 0; border-top: 1px solid var(--hairline); position: relative; }
.slot:first-child { border-top: 0; }
.slot.past .slot-time strong { color: var(--muted); }
.slot.now::before { content: ""; position: absolute; left: 0; right: 0; top: -1px; height: 2px; background: var(--danger); border-radius: 2px; }
.slot.now .slot-time strong { color: var(--danger); }
.slot.extra { border-top: 2px dashed var(--hairline); margin-top: 8px; padding-top: 12px; }
.slot-time { display: flex; flex-direction: column; align-items: flex-start; padding-top: 8px; }
.slot-time strong { font-size: 15px; font-variant-numeric: tabular-nums; }
.slot-place { font-size: 11.5px; }
.slot-body { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.slot-free { display: flex; justify-content: space-between; align-items: center; width: 100%; background: transparent; color: var(--muted); border: 1.5px dashed var(--hairline); box-shadow: none; border-radius: 14px; padding: 12px 14px; font-weight: 550; }
.slot-free:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); transform: none; }
.slot-add { display: inline-flex; align-items: center; gap: 4px; opacity: 0; transition: opacity .15s; }
.slot-free:hover .slot-add, .slot-free:focus-visible .slot-add { opacity: 1; }
.fit-btn { background: var(--accent-soft); box-shadow: none; color: var(--accent); padding: 0; width: 22px; height: 22px; border-radius: 999px; font-size: 13px; font-weight: 700; justify-content: center; }
.fit-btn:hover { transform: none; background: var(--accent); color: #fff; }

.appt { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; padding: 11px 14px; border-radius: 14px; background: var(--glass-strong); border: 1px solid var(--hairline); border-left: 4px solid var(--tone, var(--hairline)); }
.appt.fit { margin-left: 18px; }
.appt.off { opacity: .55; }
.appt.off .appt-name { text-decoration: line-through; }
.appt-name { font-size: 14.5px; }
.appt-meta { margin-top: 4px; font-size: 12.5px; }
.appt-notes { margin-top: 4px; }
.appt-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.payer { font-weight: 650; font-size: 12.5px; padding: 2px 8px; border-radius: 999px; }
.payer.part { color: var(--ok); background: var(--ok-bg); }
.payer.conv { color: var(--accent); background: var(--accent-soft); }
.proc-chip { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--glass-soft); border: 1px solid var(--hairline); color: var(--text-2); }
.badge-mini { font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 999px; background: var(--glass-soft); border: 1px solid var(--hairline); color: var(--text-2); }
.badge-mini.new { color: var(--tag-diagnostico); background: var(--tag-diagnostico-bg); border-color: transparent; }
.badge-mini.fit { color: var(--tag-pendencia); background: var(--tag-pendencia-bg); border-color: transparent; }
.wait-timer { font-weight: 650; color: var(--warn); }
.wait-timer.late { color: var(--danger); }
.wa-btn { font-size: 12.5px; font-weight: 650; text-decoration: none; padding: 4px 10px; border-radius: 999px; color: #0e7a3c; background: rgba(37, 211, 102, .15); }
.appt-status { background: var(--glass-soft); color: var(--text); box-shadow: none; border: 1px solid var(--hairline); padding: 4px 10px; font-size: 12.5px; gap: 6px; }
.appt-status:disabled { opacity: 1; }
.tone-pending { --tone: #8a94ad; }
.tone-ok { --tone: var(--ok); }
.tone-wait { --tone: var(--warn); }
.tone-call { --tone: #e2761f; }
.tone-progress { --tone: var(--accent); }
.tone-done { --tone: var(--accent-2); }
.tone-bad { --tone: var(--danger); }
.tone-off { --tone: var(--hairline); }
.appt-status.tone-ok, .sum-chip.tone-ok { border-color: var(--ok); }
.appt-status.tone-wait, .appt-status.tone-call, .sum-chip.tone-wait, .sum-chip.tone-call { border-color: var(--tone); }
.appt-status.tone-progress, .sum-chip.tone-progress { border-color: var(--accent); }
.appt-status.tone-bad, .sum-chip.tone-bad { border-color: var(--danger); }
.status-menu { position: fixed; z-index: 150; display: flex; flex-direction: column; padding: 6px; min-width: 250px; background: var(--glass-strong); }
.status-menu button { background: none; box-shadow: none; color: var(--text); justify-content: flex-start; padding: 7px 10px; border-radius: 10px; font-weight: 550; }
.status-menu button:hover, .status-menu button.active { background: var(--accent-soft); transform: none; }
.status-menu hr { border: 0; border-top: 1px solid var(--hairline); margin: 4px 0; width: 100%; }

.slot.booking-open { z-index: 30; }
.booking { position: relative; z-index: 30; padding: 16px; border-radius: 16px; border: 1.5px solid var(--accent); animation: listen-in .3s cubic-bezier(.2, .9, .3, 1.1); display: flex; flex-direction: column; gap: 12px; }
.booking .picked { padding: 10px; border-radius: 12px; background: var(--glass-soft); border: 1px solid var(--hairline); }
.proc-toggle { background: var(--glass-soft); color: var(--text); box-shadow: none; border: 1px solid var(--hairline); padding: 5px 11px; font-size: 12.5px; font-weight: 550; }
.proc-toggle.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.proc-toggle small { color: var(--muted); font-weight: 500; }
.quick-new { padding: 12px; border-radius: 12px; border: 1px dashed var(--hairline); }

.week-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
@media (max-width: 900px) { .week-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.week-col { border-radius: 14px; background: var(--glass-soft); border: 1px solid var(--hairline); display: flex; flex-direction: column; min-height: 220px; overflow: hidden; }
.week-col.today { border-color: var(--accent); }
.week-head { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; background: var(--glass-strong); color: var(--text); box-shadow: none; border-radius: 0; padding: 8px 10px; }
.week-head:hover { transform: none; color: var(--accent); }
.week-items { display: flex; flex-direction: column; gap: 4px; padding: 6px; }
.week-appt { display: flex; flex-direction: column; align-items: flex-start; gap: 0; background: var(--glass-strong); color: var(--text); box-shadow: none; border-radius: 9px; padding: 4px 7px; border-left: 3px solid var(--tone, var(--hairline)); font-size: 12px; font-weight: 600; white-space: normal; text-align: left; }
.week-appt:hover { transform: none; }
.week-appt.off { opacity: .5; text-decoration: line-through; }
.wa-name { font-weight: 500; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }

.agenda-widget .today-head { margin: 14px 0 6px; display: flex; align-items: baseline; gap: 4px; }
.today-count { font-size: 26px; letter-spacing: -.03em; }
.today-list { display: flex; flex-direction: column; gap: 4px; max-height: 360px; overflow-y: auto; }
.today-item { display: flex; gap: 10px; align-items: center; background: none; box-shadow: none; color: var(--text); padding: 7px 6px; border-radius: 12px; text-align: left; font-weight: 500; white-space: normal; }
.today-item:hover { background: var(--glass-strong); transform: none; }
.today-name { font-weight: 650; }
.today-right { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }

.grid-days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; margin-top: 8px; }
@media (max-width: 900px) { .grid-days { grid-template-columns: repeat(2, 1fr); } }
.grid-day { padding: 6px; border-radius: 10px; background: var(--glass-strong); border: 1px solid var(--hairline); display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; }
.grid-day.empty > span, .grid-day.empty > small { opacity: .55; }
.grid-block { display: flex; align-items: center; flex-wrap: wrap; gap: 2px; font-weight: 650; }
.grid-block small { font-weight: 500; color: var(--muted); }
.day-check { padding: 4px 10px; border-radius: 999px; border: 1px solid var(--hairline); background: var(--glass-soft); }
.history-item.off { opacity: .55; }

/* Menu lateral: a lista rola quando não cabe (busca e cartão do usuário ficam fixos) */
.sidebar .nav { flex: 1 1 auto; min-height: 0; overflow-y: auto; margin-right: -6px; padding-right: 6px; }
.sidebar .nav a { padding: 9px 12px; }
.sidebar-foot { margin-top: 0; flex: none; }

/* Central de cadastro de pacientes */
.badge-mini.warn { color: var(--tag-pendencia); background: var(--tag-pendencia-bg); border-color: transparent; white-space: nowrap; }
.missing-hint { margin: 0 0 10px; padding: 8px 12px; border-radius: 10px; font-size: 13px; color: var(--tag-pendencia); background: var(--tag-pendencia-bg); }
.field-rules { display: flex; flex-direction: column; }
.field-rule { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 0; border-top: 1px solid var(--hairline); flex-wrap: wrap; }
.field-rule:first-child { border-top: 0; }
.segmented button.lv-obrigatorio.active { color: var(--danger); }
.segmented button.lv-recomendado.active { color: var(--tag-pendencia); }

/* Agenda compacta: o panorama do dia com um olhar, sem rolar a tela */
.dense .day-summary { padding: 6px 10px; margin-bottom: 8px; gap: 8px; }
.dense .sum-item strong { font-size: 15px; }
.dense .sum-item .muted, .dense .sum-chip { font-size: 11.5px; }
.dense .slot { grid-template-columns: 66px minmax(0, 1fr); gap: 8px; padding: 2px 0; }
.dense .slot-time { flex-direction: row; align-items: center; gap: 6px; padding-top: 3px; }
.dense .slot-time strong { font-size: 12.5px; }
.dense .slot-dur, .dense .slot-place { display: none; }
.dense .fit-btn { width: 18px; height: 18px; font-size: 11px; }
.dense .slot-body { gap: 2px; }
.dense .slot-free { padding: 3px 10px; font-size: 12px; border-width: 1px; border-radius: 8px; }
.dense .slot-add svg { width: 12px; height: 12px; }
.dense .appt { padding: 3px 8px 3px 10px; gap: 8px; align-items: center; border-radius: 8px; border-left-width: 3px; }
.dense .appt.fit { margin-left: 12px; }
.dense .appt-main { display: flex; align-items: center; gap: 8px; min-width: 0; overflow: hidden; white-space: nowrap; }
.dense .appt-main > .row { flex-wrap: nowrap; gap: 6px !important; flex-shrink: 0; }
.dense .appt-main > .appt-meta { flex-shrink: 1; min-width: 0; overflow: hidden; }
.dense .appt-name { font-size: 13px; }
.dense .appt-main .muted, .dense .appt-meta, .dense .wait-timer { font-size: 11.5px; }
.dense .appt-meta { margin-top: 0; }
.dense .appt-notes { margin-top: 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.dense .payer, .dense .proc-chip { font-size: 11px; padding: 0 6px; }
.dense .badge-mini { font-size: 10px; padding: 0 5px; }
.dense .appt-actions { flex-direction: row; align-items: center; gap: 4px; }
.dense .appt-actions .row { flex-wrap: nowrap; }
.dense .appt-status { padding: 1px 8px; font-size: 11.5px; }
.dense .appt-actions button.small, .dense .wa-btn { padding: 2px 8px; font-size: 11.5px; }
.dense .slot.extra { margin-top: 4px; padding-top: 6px; }
@media (max-width: 700px) {
  .dense .appt { grid-template-columns: minmax(0, 1fr); }
  .dense .appt-main { flex-wrap: wrap; white-space: normal; }
  .dense .appt-main > .row, .dense .appt-actions .row { flex-wrap: wrap; flex-shrink: 1; }
  .dense .appt-actions { justify-content: space-between; flex-wrap: wrap; }
  .dense .slot { grid-template-columns: 52px minmax(0, 1fr); gap: 6px; }
}

/* Períodos de trabalho: horários bloqueados e local do dia */
.grid-block { flex-direction: column; align-items: stretch; gap: 0; padding: 4px 6px; border-radius: 8px; background: var(--glass-soft); }
.grid-block .ghost.icon.small { width: 22px; height: 22px; padding: 0; font-size: 12px; }
.grid-break { display: flex; justify-content: space-between; align-items: center; gap: 4px; font-size: 11.5px; color: var(--muted); border: 1px dashed var(--hairline); border-radius: 8px; padding: 2px 4px 2px 6px; }
.grid-break .ghost.small, .grid-add { padding: 2px 8px; font-size: 11.5px; }
.grid-add { margin-top: auto; align-self: flex-start; }
.slot.break .slot-time strong { color: var(--muted); }
.break-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 14px; font-weight: 600; color: var(--text-2);
  background: repeating-linear-gradient(135deg, var(--glass-soft) 0 8px, transparent 8px 16px); border: 1px solid var(--hairline); }
.dense .break-row { padding: 3px 10px; font-size: 12px; border-radius: 8px; }
.day-place { font-size: 12.5px; margin: -6px 0 8px; }
.grid-block-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 2px; }
.grid-time { white-space: nowrap; font-variant-numeric: tabular-nums; }
.grid-actions { display: inline-flex; gap: 0; margin-left: auto; }
.grid-break > span { white-space: nowrap; }

/* Navegação geral no cabeçalho; a coluna lateral fica só com o atendimento do paciente */
.topbar { position: relative; z-index: 20; flex-wrap: wrap; }
.top-nav { display: flex; align-items: center; gap: 4px; margin-left: auto; padding: 4px; border-radius: 999px; background: var(--glass-soft); border: 1px solid var(--hairline); max-width: 100%; }
.top-tab { display: inline-flex; align-items: center; gap: 7px; padding: 7px 13px; border-radius: 999px; font-size: 13.5px; font-weight: 600; color: var(--text-2); text-decoration: none; white-space: nowrap;
  background: none; box-shadow: none; border: 0; }
.top-tab svg { width: 16px; height: 16px; }
.top-tab:hover { background: var(--glass-strong); color: var(--text); transform: none; }
.top-tab.active { background: var(--glass-strong); color: var(--accent); box-shadow: 0 1px 6px rgba(40, 56, 110, .1); }
.admin-wrap { position: relative; }
.admin-btn .caret { font-size: 10px; opacity: .7; }
.admin-menu { position: absolute; right: 0; top: calc(100% + 8px); z-index: 60; min-width: 270px; padding: 6px; display: flex; flex-direction: column; gap: 2px;
  background: linear-gradient(var(--glass-strong), var(--glass-strong)), var(--bg); box-shadow: var(--shadow); }
.admin-menu a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 11px; color: var(--text-2); text-decoration: none; font-weight: 550; font-size: 13.5px; }
.admin-menu a:hover { background: var(--accent-soft); color: var(--text); }
.admin-menu a.active { color: var(--accent); background: var(--glass-soft); }
@media (max-width: 1180px) {
  .top-nav { order: 10; margin-left: 0; flex-basis: 100%; overflow-x: auto; border-radius: 14px; scrollbar-width: none; }
  .top-nav::-webkit-scrollbar { display: none; }
  .admin-wrap { position: static; }
  .admin-menu { right: 12px; left: auto; }
}

/* Central de integrações e busca em sistemas conectados */
.badge-mini.ext { color: var(--accent-2); background: rgba(123, 97, 255, .12); border-color: transparent; white-space: nowrap; }
.dd-section { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; padding: 8px 10px 4px; border-top: 1px solid var(--hairline); margin-top: 4px; }
.dropdown .opt.ext small { color: var(--accent-2); opacity: .85; }
.integration .sync-line { font-size: 13px; margin: -4px 0 10px; }
.danger-text { color: var(--danger); }
.section-title .copy-btn { margin-left: auto; width: 28px; height: 28px; padding: 0; }
.copy-btn.done { color: var(--ok); }
.diag-line { padding: 6px 0; border-top: 1px solid var(--hairline); gap: 12px; }

/* Convites pendentes em destaque */
.invite-bar { display: flex; flex-direction: column; gap: 10px; }
.invite-bar:empty { display: none; }
.invite-alert { display: flex; align-items: center; gap: 14px; padding: 14px 18px; border: 1.5px solid var(--accent); flex-wrap: wrap; animation: listen-in .35s cubic-bezier(.2, .9, .3, 1.1); }
.invite-alert .invite-ico { font-size: 26px; }
.invite-alert .grow { min-width: 220px; }
.invite-alert .muted { font-size: 13px; margin-top: 2px; }
.invite-info { font-size: 12.5px; margin-top: 4px; }
.invite-info.ok { color: var(--ok); }
.invite-info.warn { color: var(--tag-pendencia); }
.test-chip { display: inline-block; margin-top: 4px; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; padding: 2px 7px; border-radius: 999px; color: var(--tag-pendencia); background: var(--tag-pendencia-bg); white-space: nowrap; }

/* Primeiro acesso: etapas, código e senha */
.steps { display: flex; gap: 6px; list-style: none; padding: 0; margin: 0; counter-reset: st; }
.steps li { flex: 1; font-size: 12px; font-weight: 650; color: var(--muted); padding-top: 6px; border-top: 3px solid var(--hairline); counter-increment: st; }
.steps li::before { content: counter(st) ". "; }
.steps li.on { color: var(--accent); border-color: var(--accent); }
.steps li.done { color: var(--ok); border-color: var(--ok); }
.code-input { font: 700 30px/1.2 ui-monospace, monospace; letter-spacing: 12px; text-align: center; padding: 14px; }
.big-code { font: 800 38px/1.2 ui-monospace, monospace; letter-spacing: 8px; text-align: center; padding: 14px; border-radius: 14px; background: var(--accent-soft); color: var(--accent); user-select: all; }
.pw-rules { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; font-size: 12.5px; color: var(--muted); }
.pw-rules li.ok { color: var(--ok); }
.pw-meter { height: 6px; border-radius: 999px; background: var(--hairline); overflow: hidden; margin-top: -2px; }
.pw-meter span { display: block; height: 100%; width: 10%; background: var(--danger); transition: width .2s, background .2s; }
.pw-meter.s1 span { width: 35%; background: var(--warn); }
.pw-meter.s2 span { width: 60%; background: #c9a400; }
.pw-meter.s3 span { width: 85%; background: var(--ok); }
.pw-meter.s4 span { width: 100%; background: var(--ok); }

/* Em andamento (verde, com pulso) */
.status-chip.live { color: var(--ok); background: var(--ok-bg); }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); animation: pulse 1.4s infinite; }

/* Central de modelos de anamnese */
.tpl-btn strong { font-weight: 700; }
.tpl-center { min-height: 60vh; }
.tpl-grid { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 14px; min-height: 0; }
.tpl-list { display: flex; flex-direction: column; gap: 2px; max-height: 62vh; overflow-y: auto; padding-right: 4px; }
.tpl-group { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; padding: 10px 8px 4px; }
.tpl-item { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; background: none; box-shadow: none; color: var(--text); border-radius: 10px; padding: 8px 10px; font-weight: 600; }
.tpl-item small { color: var(--muted); font-weight: 400; }
.tpl-item:hover { background: var(--glass-soft); transform: none; }
.tpl-item.active { background: var(--accent-soft); color: var(--accent); }
.tpl-name { display: flex; align-items: center; gap: 6px; }
.tpl-detail { display: flex; flex-direction: column; gap: 6px; min-width: 0; border-left: 1px solid var(--hairline); padding-left: 14px; }
.tpl-scroll { max-height: 46vh; overflow-y: auto; padding: 10px 12px; border-radius: 12px; background: var(--glass-soft); border: 1px solid var(--hairline); }
.tpl-preview h4 { margin: 10px 0 4px; font-size: 14px; }
.tpl-preview h4:first-child { margin-top: 0; }
.tpl-preview ul { margin: 0 0 6px; padding-left: 18px; }
.tpl-preview li { font-size: 13px; margin: 3px 0; }
.tpl-preview li small { display: block; color: var(--muted); font-size: 11.5px; }
.tpl-actions { margin-top: 6px; }
.choice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.choice-card { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; padding: 22px 18px; border-radius: 16px; background: var(--glass-soft); color: var(--text); border: 1.5px solid var(--hairline); box-shadow: none; white-space: normal; font-weight: 500; }
.choice-card:hover { border-color: var(--accent); transform: none; }
.choice-card strong { font-size: 16px; }
.choice-ico { font-size: 34px; }
.tpl-builder { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 16px; }
.tpl-chat { display: flex; flex-direction: column; gap: 8px; height: 38vh; overflow-y: auto; padding: 8px; border-radius: 12px; background: var(--glass-soft); border: 1px solid var(--hairline); }
.tpl-chat .bubble { max-width: 92%; padding: 8px 12px; border-radius: 14px; font-size: 13.5px; }
.tpl-chat .bubble.user { align-self: flex-end; background: var(--accent); color: #fff; }
.tpl-chat .bubble.assistant { align-self: flex-start; background: var(--glass-strong); border: 1px solid var(--hairline); }
.tpl-chat .bubble p { margin: 0 0 4px; }
.tpl-body { font: 12.5px/1.5 ui-monospace, monospace; min-height: 38vh; }
.tag-toggle { font-size: 12px; padding: 4px 10px; border-radius: 999px; background: var(--glass-soft); color: var(--text-2); border: 1px solid var(--hairline); box-shadow: none; font-weight: 600; }
.tag-toggle.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.tag-toggle:hover { transform: none; }
@media (max-width: 860px) {
  .tpl-grid, .tpl-builder, .choice-grid { grid-template-columns: 1fr; }
  .tpl-detail { border-left: 0; padding-left: 0; }
}
.tpl-center > .row:first-child { padding-right: 44px; }
.tpl-name { flex-wrap: wrap; }
.modal-card .stack > h2:first-child { padding-right: 40px; }


/* ---------- Cabeçalho fixo e faixas flutuantes ---------- */
.main > .topbar { position: sticky; top: 0; z-index: 40; background: linear-gradient(var(--glass-strong), var(--glass-strong)), var(--bg); }
.top-left { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.sticky-strip { position: sticky; top: calc(var(--topbar-h, 80px) + 6px); z-index: 30; background: linear-gradient(var(--glass-strong), var(--glass-strong)), var(--bg); box-shadow: var(--shadow); }
.ws-cards { display: flex; flex-direction: column; }
.ws-cards + .card { margin-top: 16px; }

/* Seletor de clínica no cabeçalho (compacto) */
.top-left .org-switcher { padding: 0; background: none; border: 0; box-shadow: none; gap: 8px; }
.top-left .org-switcher .org-mark { width: 22px; height: 22px; border-radius: 7px; }
.top-left .org-switcher .org-mark svg { width: 13px; height: 13px; }
.top-left .org-switcher .org-name, .top-left .org-switcher select { font-size: 12.5px; }
.top-left .org-switcher .muted { display: none; }
.top-left > .stack { flex-direction: row !important; align-items: center; flex-wrap: wrap; gap: 8px !important; }
.top-left .unit-pick { flex-direction: row; align-items: center; gap: 6px; padding: 0; }
.top-left .unit-pick .muted { font-size: 11.5px; }
.top-left .unit-pick select, .top-left .org-switcher select { padding: 3px 8px; }
.top-left > .stack > button.ghost.small { padding: 3px 10px; font-size: 12px; }

/* Menus do cabeçalho: dica embaixo do rótulo */
.admin-menu a span small { display: block; color: var(--muted); font-size: 11.5px; font-weight: 400; }

/* Agenda: comandos do paciente somem da coluna lateral */
body[data-view="agenda"] .sidebar .nav, body[data-view="agenda"] .sidebar .patient-chip { display: none; }

/* Anamnese: final em destaque, editor ao lado quando "Editar" */
.anam-box { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.anam-box > textarea { display: none; min-height: 420px; }
.anam-box.editing { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.anam-box.editing > textarea { display: block; }
.anam-box .preview { padding: 14px 18px; min-height: 120px; max-height: none; }
.anam-box.editing .preview { max-height: 560px; overflow-y: auto; }
@media (max-width: 1250px) { .anam-box.editing { grid-template-columns: 1fr; } }
.highlight-card .card-head h2 { display: flex; align-items: center; gap: 8px; }
.return-pick { flex-direction: row; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.return-pick input { max-width: 170px; }

/* Lista de pacientes */
.letter-nav { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0 14px; }
.letter-nav button { min-width: 32px; padding: 5px 8px; font-size: 12.5px; font-weight: 700; background: var(--glass-soft); color: var(--text-2); border: 1px solid var(--hairline); box-shadow: none; }
.letter-nav button.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.letter-nav button.empty { opacity: .35; }
.letter-nav button:hover:not(:disabled) { transform: none; border-color: var(--accent); }
.table-wrap { overflow-x: auto; }
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.muted { background: var(--glass-soft); color: var(--text-2); }
.patients-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.patients-table th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--hairline); }
.patients-table td { padding: 9px 10px; border-bottom: 1px solid var(--hairline); vertical-align: middle; }
.patients-table tbody tr { cursor: pointer; }
.patients-table tbody tr:hover { background: var(--accent-soft); }
.patients-table .mono { font-variant-numeric: tabular-nums; white-space: nowrap; }
.patients-table .nowrap { white-space: nowrap; }
.patients-table .right { text-align: right; }
.pager { justify-content: center; margin-top: 12px; }
.btn-link { text-decoration: none; }
@media (max-width: 1000px) {
  .agenda-layout { grid-template-columns: 1fr; }
  .agenda-side { position: static; order: -1; }
}
@media (max-width: 860px) {
  .sticky-strip { top: calc(var(--topbar-h, 120px) + 8px); }
}

/* Calendário da Agenda dentro da coluna lateral */
.side-slot:empty { display: none; }
.agenda-side.in-sidebar { position: static; padding: 12px; border-radius: var(--radius-sm); background: var(--glass-soft); border: 1px solid var(--hairline); gap: 10px; }
.agenda-side.in-sidebar .cal-day { height: 30px; font-size: 12.5px; }
.sidebar { overflow-y: auto; }
.sidebar-foot { margin-top: auto; }

/* ================= Barra superior (largura total, fixa) + caixa de contexto ================= */
.appbar { position: fixed; top: 0; left: 0; right: 0; z-index: 60; height: 56px; display: flex; align-items: center; gap: 14px; padding: 0 18px;
  background: linear-gradient(var(--glass-strong), var(--glass-strong)), var(--bg); border-bottom: 1px solid var(--hairline); box-shadow: 0 2px 14px rgba(40, 56, 110, .07); }
.app-brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--text); font-weight: 750; font-size: 17px; letter-spacing: -.02em; flex: none; }
.app-brand .brand-mark { width: 28px; height: 28px; border-radius: 9px; }
.app-brand .test-chip { margin: 0 0 0 2px; }
.appbar .top-nav { margin-left: 8px; padding: 0; background: none; border: 0; gap: 2px; flex: 1 1 auto; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.appbar .top-nav::-webkit-scrollbar { display: none; }
.appbar .top-tab { padding: 7px 11px; font-size: 13.5px; border-radius: 10px; }
.appbar .top-tab.active { background: var(--accent-soft); box-shadow: none; }
.appbar-right { display: flex; align-items: center; gap: 10px; flex: none; }
.appbar .admin-wrap { position: static; }
.appbar .admin-menu { top: calc(100% + 4px); right: auto; }
.appbar .admin-wrap .admin-menu { position: fixed; top: 58px; right: auto; max-width: calc(100vw - 16px); }
/* seletor de clínica compacto */
.appbar .org-switcher { padding: 4px 10px 4px 6px; gap: 8px; border-radius: 12px; background: var(--glass-soft); border: 1px solid var(--hairline); box-shadow: none; }
.appbar .org-switcher .org-mark { width: 24px; height: 24px; border-radius: 7px; }
.appbar .org-switcher .org-mark svg { width: 13px; height: 13px; }
.appbar .org-switcher .org-name, .appbar .org-switcher select { font-size: 13px; max-width: 200px; }
.appbar .org-switcher .muted { display: none; }
.appbar-right > .stack { flex-direction: row !important; align-items: center; gap: 8px !important; }
.appbar .unit-pick { flex-direction: row; align-items: center; gap: 6px; padding: 0; }
.appbar .unit-pick .muted { display: none; }
.appbar .unit-pick select, .appbar .org-switcher select { padding: 4px 8px; border-radius: 9px; font-size: 12.5px; }
.appbar-right > .stack > button.ghost.small { padding: 4px 10px; font-size: 12px; }
.user-btn { padding: 0; background: none; box-shadow: none; border-radius: 50%; }
.user-btn .avatar { width: 34px; height: 34px; font-size: 13px; background: linear-gradient(135deg, #1fb5a8, var(--accent)); }
.user-btn:hover { transform: none; filter: brightness(1.05); }
.user-menu { right: 12px !important; left: auto !important; min-width: 250px; }
.user-menu .user-head { display: flex; gap: 10px; align-items: center; padding: 8px 10px 10px; border-bottom: 1px solid var(--hairline); margin-bottom: 4px; }
.user-menu .user-head .muted { font-size: 12px; }
.user-menu button { display: flex; align-items: center; gap: 10px; width: 100%; background: none; box-shadow: none; color: var(--text-2); padding: 9px 12px; border-radius: 11px; font-weight: 550; font-size: 13.5px; justify-content: flex-start; }
.user-menu button:hover { background: var(--accent-soft); color: var(--text); transform: none; }

.shell { padding-top: calc(56px + 16px); }
.sidebar { top: calc(56px + 16px); height: calc(100vh - 56px - 32px); }

.ctx-bar { position: sticky; top: var(--appbar-h, 56px); z-index: 35; display: flex; align-items: center; gap: 16px; padding: 10px 18px; min-height: 64px;
  background: linear-gradient(var(--glass-strong), var(--glass-strong)), var(--bg); box-shadow: var(--shadow); flex-wrap: wrap; }
.ctx-title h1 { font-size: 18px; margin: 0; letter-spacing: -.01em; }
.ctx-title .muted { font-size: 12px; }
.ctx-patient { margin-left: auto; min-width: 0; }
.ctx-patient:empty { display: none; }
.ctx-patient-inner { display: flex; align-items: center; gap: 12px; padding-left: 16px; border-left: 1px solid var(--hairline); flex-wrap: wrap; }
.ctx-patient-text { min-width: 0; }
.ctx-patient-name { font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ctx-patient-text .muted { font-size: 12.5px; }
.ctx-patient-inner > button, .ctx-patient-inner > .status-chip { margin-left: 6px; }
.main { gap: 14px; }
@media (max-width: 1100px) {
  .appbar .org-switcher .org-name, .appbar .org-switcher select { max-width: 130px; }
  .appbar .unit-pick { display: none; }
}
@media (max-width: 860px) {
  .appbar { gap: 8px; padding: 0 10px; }
  .app-brand .brand-name, .app-brand .test-chip { display: none; }
  .appbar-right .org-switcher { display: none; }
  .shell { padding-top: calc(56px + 12px); }
  .sidebar { top: 68px; }
  .ctx-patient { margin-left: 0; width: 100%; }
  .ctx-patient-inner { border-left: 0; padding-left: 0; }
}

/* cobre a faixa entre a barra superior e a caixa de contexto enquanto rola */
/* só enquanto está grudada na barra superior: encosta nela, sem faixa nem cantos soltos */
.ctx-bar.stuck { border-top-left-radius: 0; border-top-right-radius: 0; border-top-color: transparent; }

/* Paciente logo ao lado do nome da área; ação principal na ponta direita */
.ctx-patient { margin-left: 0; flex: 1 1 auto; }
.ctx-patient-inner { width: 100%; }
.ctx-patient-inner > button, .ctx-patient-inner > .status-chip { margin-left: auto; }

/* Sinal de atendimento em curso */
.live-pill { display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px 6px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600;
  color: var(--ok); background: var(--ok-bg); border: 1px solid color-mix(in srgb, var(--ok) 35%, transparent); box-shadow: none; white-space: nowrap; }
.live-pill:hover { transform: none; filter: brightness(.97); }
.live-pill strong { color: var(--text); font-weight: 700; }
.live-pill .live-time { font-variant-numeric: tabular-nums; opacity: .8; }
.live-pill .live-dot, .chip-live .live-dot { width: 8px; height: 8px; box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 60%, transparent); animation: live-ring 1.6s infinite; }
@keyframes live-ring { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 55%, transparent); } 70% { box-shadow: 0 0 0 7px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
.appbar .top-tab.live-pill { color: var(--ok); background: var(--ok-bg); }
.patient-chip.is-live { border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.chip-live { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 650; color: var(--ok); }
.nav a.live { position: relative; }
.nav a.live::after { content: ""; position: absolute; right: 12px; top: 50%; width: 8px; height: 8px; margin-top: -4px; border-radius: 50%; background: var(--ok); animation: live-ring 1.6s infinite; }
@media (max-width: 1100px) { .live-pill .live-label { display: none; } }
.chip-live { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 11.5px; }
.patient-chip .grow { min-width: 0; }
.status-chip.live .live-dot { animation: live-ring 1.6s infinite; }

/* Ação principal junto das informações do paciente */
.ctx-patient-inner > button, .ctx-patient-inner > .status-chip { margin-left: 14px; }
.ctx-patient-inner { width: auto; }

/* ---------- Painel do atendimento: etapas guiadas ---------- */
.workspace-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.ws-steps { display: flex; align-items: flex-start; gap: 10px; flex-wrap: wrap; min-width: 0; }
.ws-step { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding-left: 26px; min-width: 0; }
.ws-num { position: absolute; left: 0; top: 9px; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 800;
  color: var(--muted); background: var(--glass-soft); border: 1px solid var(--hairline); transition: all .25s; }
.ws-step.done .ws-num { color: #fff; background: var(--ok); border-color: var(--ok); font-size: 0; }
.ws-step.done .ws-num::after { content: "✓"; font-size: 11px; }
.ws-step.current .ws-num { color: #fff; background: var(--accent); border-color: var(--accent); }
.ws-next { font-size: 11px; color: var(--muted); font-weight: 600; opacity: 0; transform: translateY(-2px); transition: opacity .25s, transform .25s; white-space: nowrap; }
.ws-step.current .ws-next { opacity: 1; transform: none; color: var(--accent); }
.ws-step[data-step="gerar"].current > button { animation: next-glow 1.8s ease-in-out infinite; }
.ws-step[data-step="gerar"].current .ws-next::after { content: " →"; display: inline-block; animation: nudge 1.2s ease-in-out infinite; }
@keyframes next-glow { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 45%, transparent); } 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent) 12%, transparent); } }
@keyframes nudge { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(4px); } }
.ws-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-left: auto; }
.ws-actions .next { border-color: var(--ok); color: var(--ok); animation: next-glow-ok 2s ease-in-out infinite; }
@keyframes next-glow-ok { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 40%, transparent); } 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--ok) 10%, transparent); } }
.tpl-btn { max-width: 300px; }
.tpl-btn > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.btn-timer { font-variant-numeric: tabular-nums; font-weight: 700; margin-left: 4px; padding: 1px 7px; border-radius: 999px; background: rgba(255, 255, 255, .22); font-size: 12px; }
.spin { width: 14px; height: 14px; border-radius: 50%; border: 2px solid color-mix(in srgb, var(--accent) 30%, transparent); border-top-color: var(--accent); animation: spin .8s linear infinite; flex: none; }
.spin.light { border-color: color-mix(in srgb, currentColor 30%, transparent); border-top-color: currentColor; }
@keyframes spin { to { transform: rotate(360deg); } }

.ws-hint { display: flex; align-items: center; gap: 12px; margin-top: 12px; padding: 12px 14px; border-radius: 14px; background: color-mix(in srgb, var(--accent) 8%, var(--glass-strong));
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent); animation: listen-in .35s cubic-bezier(.2, .9, .3, 1.1); flex-wrap: wrap; font-size: 13.5px; }
.ws-hint-ico { font-size: 22px; }
.ws-hint-next { margin-top: 3px; color: var(--accent); font-size: 12.5px; }
.ws-hint-actions { display: flex; gap: 6px; align-items: center; }
.ws-progress { margin-top: 12px; padding: 10px 14px; border-radius: 14px; background: var(--glass-soft); border: 1px solid var(--hairline); }
.ws-progress-bar { height: 4px; border-radius: 999px; background: var(--hairline); overflow: hidden; margin-bottom: 8px; }
.ws-progress-bar span { display: block; height: 100%; width: 35%; border-radius: 999px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); animation: indet 1.4s ease-in-out infinite; }
@keyframes indet { 0% { transform: translateX(-100%); } 100% { transform: translateX(300%); } }
.ws-progress-text { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); }
.ws-progress-time { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--text); }
.ws-done, .ws-error { display: flex; align-items: center; gap: 8px; margin-top: 12px; padding: 10px 14px; border-radius: 14px; font-size: 13px; font-weight: 600; flex-wrap: wrap; }
.ws-done { color: var(--ok); background: var(--ok-bg); }
.ws-error { color: var(--danger); background: var(--danger-bg); }
.preview.flash { animation: flash-ok 1.6s ease; }
@keyframes flash-ok { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 50%, transparent); } 40% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--ok) 18%, transparent); } 100% { box-shadow: 0 0 0 0 transparent; } }
@media (max-width: 1400px) {
  .ws-steps { gap: 8px; }
  .ws-steps button, .ws-actions button { padding-left: 12px; padding-right: 12px; font-size: 13px; }
  .tpl-btn { max-width: 230px; }
}
@media (max-width: 700px) { .ws-actions { margin-left: 0; } .ws-next { display: none; } }

/* ---- etapas compactas: número como selo no canto do botão, dica flutuando abaixo ---- */
.ws-cards > .card:first-child { container-type: inline-size; container-name: ws; }
.workspace-head { align-items: center; padding: 6px 0 16px; row-gap: 18px; }
.ws-steps { flex-wrap: nowrap; gap: 12px; align-items: center; }
.ws-steps { gap: 8px; }
.ws-step { padding-left: 0; display: flex; flex-direction: row; align-items: center; gap: 6px; }
/* stepper: número em linha com o botão e um traço ligando as etapas (lê-se como sequência, não como contador) */
.ws-num { position: static; width: 20px; height: 20px; flex: none; background: transparent; border: 1.5px solid color-mix(in srgb, var(--muted) 45%, transparent); color: var(--muted); }
.ws-step + .ws-step::before { content: ""; width: 16px; height: 2px; border-radius: 2px; background: color-mix(in srgb, var(--muted) 45%, transparent); flex: none; margin-right: 2px; transition: background .25s; }
.ws-step.done + .ws-step::before { background: var(--ok); }
.ws-step.current .ws-num { background: transparent; color: var(--accent); border-color: var(--accent); }
.ws-next { position: absolute; left: calc(50% + 13px); top: calc(100% + 3px); transform: translateX(-50%); pointer-events: none; }
.ws-step + .ws-step .ws-next { left: calc(50% + 22px); }
.ws-step.current .ws-next { transform: translateX(-50%); }
/* próximo passo: contorno azul pulsando, texto legível; só fica sólido ao passar o mouse */
.ws-step[data-step="gerar"].current > button:not(:disabled) { background: var(--glass-strong); color: var(--accent); border: 1.5px solid var(--accent); }
.ws-step[data-step="gerar"].current > button:not(:disabled):hover { background: var(--accent); color: #fff; }
.ws-step:not(.current) .ws-next { display: none; }
.ws-actions { align-items: center; flex-wrap: nowrap; }
.save-btn { width: 38px; height: 38px; padding: 0; }
.tpl-btn { max-width: 260px; }
@container ws (max-width: 760px) {
  .ws-steps { gap: 10px; }
  .ws-steps button, .ws-actions button { padding: 8px 11px; font-size: 12.5px; }
  .tpl-btn { max-width: 170px; }
  .finish-btn { padding: 8px 11px; }
}
@container ws (max-width: 640px) {
  .tpl-btn { max-width: 140px; }
  .finish-btn .finish-long { display: none; }
}
@container ws (max-width: 700px) { .ws-step + .ws-step::before { width: 8px; } }
@container ws (max-width: 560px) {
  .ws-steps { flex-wrap: wrap; }
  .ws-step + .ws-step::before { display: none; }
  .ws-actions { margin-left: 0; }
}

.ws-step button:disabled { opacity: 1; cursor: progress; }
.ws-step[data-step="gerar"] button:disabled { color: var(--accent); background: var(--accent-soft); border: 1px solid var(--accent); }
@container ws (max-width: 760px) { .tpl-btn { max-width: 230px; } }
@container ws (max-width: 640px) { .tpl-btn { max-width: 170px; } }

/* ---------- Conexão de agenda (espelho da Feegow) ---------- */
.small-link { font-size: 13px; font-weight: 600; color: var(--accent); text-decoration: none; }
.small-text { font-size: 12px; }
.link-stats { display: flex; flex-wrap: wrap; gap: 10px; margin: 14px 0 8px; }
.link-stat { display: flex; flex-direction: column; gap: 2px; padding: 10px 14px; border-radius: 14px; background: var(--glass-soft); border: 1px solid var(--hairline); min-width: 150px; }
.link-stat strong { font-size: 22px; font-variant-numeric: tabular-nums; }
.link-stat.warn strong { color: var(--warn, #b7791f); }
.link-stat.bad strong { color: var(--danger); }
.sync-line select { width: auto; display: inline-block; padding: 3px 8px; font-size: 12.5px; margin: 0 2px; }
.link-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.link-table th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; padding: 8px 10px; border-bottom: 1px solid var(--hairline); }
.link-table td { padding: 10px; border-bottom: 1px solid var(--hairline); vertical-align: top; }
.link-table select, .link-table input { width: 100%; min-width: 180px; }
.link-table tr.muted strong { color: var(--muted); }
.match { font-size: 12px; font-weight: 650; margin-top: 5px; }
.match.strong { color: var(--ok); }
.match.weak { color: var(--warn, #b7791f); }
.link-table td > button.small { margin-top: 6px; }
.copy-line { display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 12px; border-radius: 12px; background: var(--glass-soft); border: 1px solid var(--hairline); margin: 10px 0; min-width: 0; }
.copy-line code { flex: 1; min-width: 0; overflow-wrap: anywhere; font-size: 12.5px; }
.steps-list { margin: 6px 0 12px; padding-left: 20px; font-size: 13.5px; display: grid; gap: 4px; }
.preview-box { padding: 12px 14px; border-radius: 14px; background: color-mix(in srgb, var(--accent) 7%, var(--glass-strong)); border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent); margin: 8px 0 12px; font-size: 13.5px; }
.preview-box ul { margin: 6px 0 0; padding-left: 18px; }
.sync-log { list-style: none; margin: 8px 0; padding: 0; display: grid; gap: 2px; font-size: 13px; max-height: 420px; overflow: auto; }
.sync-log li { display: grid; grid-template-columns: 22px 150px 1fr; gap: 8px; padding: 6px 4px; border-bottom: 1px solid var(--hairline); align-items: baseline; }
.sync-log li.bad { color: var(--danger); }
.sync-log .dir { font-weight: 800; text-align: center; }
.sync-log .dir.entrada { color: var(--accent); }
.sync-log .dir.saida { color: var(--ok); }
.sync-log .dir.webhook { color: #b7791f; }
@media (max-width: 640px) { .sync-log li { grid-template-columns: 22px 1fr; } .sync-log li > span:last-child { grid-column: 2; } }
.mirror-banner { display: flex; align-items: center; gap: 12px; padding: 10px 14px; margin-bottom: 10px; border-radius: 14px; font-size: 13px;
  background: color-mix(in srgb, var(--accent) 7%, var(--glass-strong)); border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent); }
.mirror-banner > div { flex: 1; min-width: 0; }
.mirror-ico { font-size: 20px; font-weight: 800; color: var(--accent); }
.mirror-mark { font-size: 13px; font-weight: 800; color: var(--accent); opacity: .75; cursor: help; }
.slot-free.mirrored { cursor: default; display: flex; justify-content: space-between; align-items: center; }
.proc-map { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.proc-map label { display: grid; gap: 3px; }

/* ---------- Atendimento rápido (sem paciente) ---------- */
.guest-avatar { display: grid; place-items: center; border-radius: 50%; font-weight: 800; color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--glass-strong)); border: 1.5px dashed color-mix(in srgb, var(--accent) 45%, transparent); flex: none; }
.badge-mini.guest { background: color-mix(in srgb, var(--warn, #b7791f) 14%, transparent); color: var(--warn, #b7791f); }
.quick-start { position: relative; overflow: hidden; }
.quick-start h2 { font-size: 21px; margin: 8px 0 6px; }
.quick-start > p { margin: 0 0 14px; max-width: 720px; }
.qs-badge { display: inline-block; font-size: 11.5px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); padding: 3px 9px; border-radius: 999px; }
.qs-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.qs-row input { flex: 1; min-width: 220px; }
.big-cta { padding: 13px 22px; font-size: 15px; }
.qs-steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 16px 0 10px; }
.qs-steps > div { display: grid; grid-template-columns: auto 1fr; column-gap: 8px; align-items: center; padding: 10px 12px; border-radius: 14px; background: var(--glass-soft); border: 1px solid var(--hairline); font-size: 13px; }
.qs-steps > div .muted { grid-column: 2; font-size: 12px; }
.qs-num { grid-row: span 2; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 11.5px; font-weight: 800; color: var(--accent); border: 1.5px solid var(--accent); }
@media (max-width: 720px) { .qs-steps { grid-template-columns: 1fr; } }
.guest-line { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.guest-line input { padding: 5px 10px; font-size: 13px; max-width: 320px; }
.link-modal { width: min(560px, 100%); }
.link-results { display: grid; gap: 4px; max-height: 260px; overflow: auto; }
.link-results .opt { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; background: var(--glass-soft); color: var(--text); border: 1px solid var(--hairline); box-shadow: none; border-radius: 12px; padding: 8px 12px; }
.link-results .opt:hover { border-color: var(--accent); }
.link-results .opt small { color: var(--muted); font-weight: 500; }
.welcome-card { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; border: 1px solid color-mix(in srgb, var(--ok) 35%, transparent); }
.welcome-emoji { font-size: 28px; }
.quick-start-box { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; padding: 14px 16px; border-radius: 16px;
  background: color-mix(in srgb, var(--accent) 8%, var(--glass-strong)); border: 1px solid color-mix(in srgb, var(--accent) 28%, transparent); }
.full-org summary { cursor: pointer; font-weight: 650; color: var(--muted); padding: 6px 0; }

/* ---------- Assistente: tabelas, citações e fontes ---------- */
.md h4 { font-size: 13.5px; margin: 10px 0 3px; }
.md hr { border: 0; border-top: 1px solid var(--hairline); margin: 10px 0; }
.md blockquote { margin: 6px 0; padding: 6px 12px; border-left: 3px solid var(--accent); background: var(--glass-soft); border-radius: 0 10px 10px 0; }
.md a { color: var(--accent); }
.md-table { overflow-x: auto; margin: 8px 0; border: 1px solid var(--hairline); border-radius: 12px; }
.md-table table { border-collapse: collapse; width: 100%; font-size: 13px; }
.md-table th { background: color-mix(in srgb, var(--accent) 7%, var(--glass-strong)); text-align: left; font-weight: 700; font-size: 12px; }
.md-table th, .md-table td { padding: 7px 10px; border-bottom: 1px solid var(--hairline); vertical-align: top; }
.md-table tbody tr:last-child td { border-bottom: 0; }
.md-table tbody tr:nth-child(even) td { background: var(--glass-soft); }
.md a.cite { display: inline-grid; place-items: center; min-width: 17px; height: 17px; padding: 0 4px; margin: 0 1px; border-radius: 999px; font-size: 10.5px; font-weight: 800; text-decoration: none; vertical-align: 2px;
  color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.md a.cite:hover { background: var(--accent); color: #fff; }
.sources { margin-top: 10px; padding-top: 8px; border-top: 1px dashed var(--hairline); }
.sources-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 6px; }
.sources-list { display: flex; flex-wrap: wrap; gap: 6px; }
.src { display: inline-flex; align-items: center; gap: 6px; max-width: 240px; padding: 4px 9px 4px 5px; border-radius: 10px; text-decoration: none; color: var(--text); background: var(--glass-soft); border: 1px solid var(--hairline); font-size: 12px; }
.src:hover { border-color: var(--accent); }
.src img, .src-letter { width: 16px; height: 16px; border-radius: 4px; flex: none; }
.src-letter { display: grid; place-items: center; font-size: 10px; font-weight: 800; background: var(--hairline); }
.src-n { font-size: 10px; font-weight: 800; color: var(--accent); min-width: 12px; text-align: center; }
.src-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.src-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.src-domain { font-size: 10.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg.assistant { max-width: 100%; }
.msg-tools { display: flex; justify-content: flex-end; margin-top: 4px; opacity: .6; }
.msg-tools:hover { opacity: 1; }
.msg.thinking { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.chat-history:empty { display: none; }
.chat-threads { margin-top: 10px; border: 1px solid var(--hairline); border-radius: 14px; background: var(--glass-soft); }
.chat-threads > summary { cursor: pointer; padding: 9px 12px; font-size: 13px; font-weight: 650; display: flex; align-items: center; gap: 6px; }
.chat-threads .thread { border-top: 1px solid var(--hairline); }
.chat-threads .thread > summary { cursor: pointer; padding: 8px 12px; font-size: 12.5px; }
.thread-log { max-height: 360px; margin: 0; padding: 4px 10px 10px; }
.chat-threads .msg { font-size: 13px; }
.chat-history { max-height: 42%; overflow-y: auto; flex: none; }
.md-table th, .md-table td { overflow-wrap: normal; word-break: normal; hyphens: auto; min-width: 84px; }
.md-table td:first-child, .md-table th:first-child { min-width: 96px; }

/* ---------- Espera (fila do dia): tabela compacta, uma linha por paciente ---------- */
/* "Em espera" (paciente pausado aguardando procedimento/exame): âmbar, distinto do azul de "Aguardando" mesmo sozinho na fila */
:root { --requeue: #b26a00; --requeue-bg: rgba(214, 140, 20, .13); --requeue-border: rgba(214, 140, 20, .42); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --requeue: #f3c15c; --requeue-bg: rgba(243, 193, 92, .13); --requeue-border: rgba(243, 193, 92, .38); } }
:root[data-theme="dark"] { --requeue: #f3c15c; --requeue-bg: rgba(243, 193, 92, .13); --requeue-border: rgba(243, 193, 92, .38); }
.queue-card { container-type: inline-size; container-name: queue; }
.queue-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.queue-title { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.queue-title h2 { margin: 0; }
.queue-kpis { display: flex; flex-wrap: wrap; gap: 6px; }
.qk { font-size: 12.5px; color: var(--muted); padding: 3px 10px; border-radius: 999px; background: var(--glass-soft); border: 1px solid var(--hairline); white-space: nowrap; }
.qk strong { color: var(--text); font-variant-numeric: tabular-nums; }
.qk.warn strong { color: var(--warn, #b7791f); }
.qk.bad strong { color: var(--danger); }
.qk.req strong { color: var(--requeue); }
.queue-tools { gap: 8px; }
.queue-filters { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.queue-filters select { width: auto; padding: 6px 30px 6px 10px; font-size: 13px; }
.queue-groups, .reason-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-btn { background: var(--glass-soft); color: var(--text); border: 1px solid var(--hairline); box-shadow: none; padding: 5px 11px; font-size: 12.5px; }
.chip-btn.active { background: color-mix(in srgb, var(--accent) 12%, var(--glass-strong)); border-color: var(--accent); color: var(--accent); }
.queue-list { display: flex; flex-direction: column; }
.qrow { display: grid; grid-template-columns: 24px 58px 52px 64px minmax(170px, 1.6fr) minmax(100px, 1.2fr) minmax(90px, 130px) minmax(140px, 180px) 150px;
  gap: 10px; align-items: center; min-height: 38px; padding: 4px 10px; font-size: 13px; }
.qhead { min-height: 26px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); border-bottom: 1px solid var(--hairline); }
.queue-row { border-bottom: 1px solid var(--hairline); border-left: 3px solid transparent; transition: background .15s; }
.queue-row:hover { background: var(--glass-soft); }
.queue-row.requeued { background: var(--requeue-bg); border-left-color: var(--requeue); }
.queue-row.calling { border-left-color: var(--accent); animation: calling 2s ease-in-out infinite; }
@keyframes calling { 0%, 100% { background: transparent; } 50% { background: color-mix(in srgb, var(--accent) 8%, transparent); } }
.q-pos { font-weight: 800; font-size: 12px; color: var(--muted); text-align: center; }
.queue-row.requeued .q-pos { color: var(--requeue); }
.q-time, .q-arrival { font-variant-numeric: tabular-nums; font-weight: 650; display: flex; align-items: center; gap: 4px; }
.q-arrival { color: var(--text-2); font-weight: 550; }
.q-wait { font-variant-numeric: tabular-nums; font-size: 12.5px; white-space: nowrap; }
.q-wait:not(.warn):not(.late) { color: var(--muted); }
.q-patient { display: flex; align-items: center; gap: 6px; min-width: 0; white-space: nowrap; overflow: hidden; }
.q-patient .appt-name { display: block; padding: 0; font-size: 13.5px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 0 1 auto; text-align: left; }
.q-procs { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; font-size: 12.5px; }
.requeue-tag { font-size: 11.5px; font-weight: 650; color: var(--requeue); overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.a-flag.prio { color: var(--ok); background: var(--ok-bg); border-color: transparent; }
.q-actions { display: flex; gap: 6px; justify-content: flex-end; }
.q-actions button { padding: 4px 10px; font-size: 12px; gap: 4px; }
.q-actions svg { width: 13px; height: 13px; }
.wait-timer.warn { color: var(--warn, #b7791f); }
.badge-mini.prio { background: rgba(14, 122, 60, .12); color: var(--ok); }
.wait-btn[disabled] { opacity: .5; }
.requeue-modal { width: min(560px, 100%); }
.proc-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 4px 12px; margin-top: 8px; max-height: 220px; overflow: auto; }
.proc-pick .muted { margin-left: auto; }
/* Procedimentos e produtos lançados pelo médico (espera e finalização) */
.charge-editor { display: flex; flex-direction: column; gap: 8px; }
.charge-list { display: flex; flex-direction: column; gap: 6px; }
.charge-row { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) auto; gap: 8px; align-items: center; padding: 8px 10px; border: 1px solid var(--line, var(--glass-border)); border-radius: 12px; background: var(--surface, transparent); }
.charge-row.off { opacity: .55; }
.charge-row.off .charge-name strong { text-decoration: line-through; }
.charge-name { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-width: 0; }
.charge-name strong { font-weight: 600; overflow-wrap: anywhere; }
.charge-row input:not([type=checkbox]) { min-width: 0; }
.charge-done { white-space: nowrap; font-size: 13px; gap: 6px; }
.charge-done input { width: auto; }
.charge-search { position: relative; }
.charge-results { display: flex; flex-direction: column; margin-top: 4px; border-radius: 12px; overflow-y: auto; max-height: min(320px, 45vh); }
.charge-results:empty { display: none; }
.charge-hit { display: flex; justify-content: space-between; gap: 10px; align-items: center; text-align: left; padding: 9px 12px; border-radius: 0; background: var(--glass-strong); color: var(--text); border: 1px solid var(--glass-border); border-top-width: 0; font-weight: 500; }
.charge-hit:first-child { border-top-width: 1px; border-radius: 12px 12px 0 0; }
.charge-hit:last-child { border-radius: 0 0 12px 12px; }
.charge-hit:only-child { border-radius: 12px; }
.charge-hit:hover, .charge-hit:focus-visible { background: color-mix(in srgb, var(--accent) 10%, var(--glass-strong)); }
.charge-hit .muted { white-space: nowrap; }
.charge-hit.free { color: var(--accent); justify-content: flex-start; }
.charge-hit.free svg { width: 14px; height: 14px; flex: none; }
.warn-note { margin: 0; padding: 8px 12px; border-radius: 10px; background: color-mix(in srgb, var(--warn, #b7791f) 12%, transparent); color: var(--text); font-size: 13px; }
@media (max-width: 560px) {
  .charge-row { grid-template-columns: minmax(0, 1fr) auto; }
  .charge-row .charge-name { grid-column: 1 / -1; }
}
@container queue (max-width: 1040px) {
  .qrow { grid-template-columns: 20px 50px 56px 56px minmax(140px, 1.5fr) minmax(84px, 118px) minmax(150px, 196px) 112px; gap: 8px; }
  .qrow > :nth-child(6) { display: none; }  /* procedimento vai para o tooltip */
  .q-lbl-btn { display: none; }
}
@container queue (max-width: 700px) {
  .qhead { display: none; }
  .qrow { grid-template-columns: 22px minmax(0, 1fr) auto; grid-template-areas: "pos pat wait" "pos st act"; row-gap: 4px; padding: 6px 8px; }
  .qrow > :nth-child(2), .qrow > :nth-child(3), .qrow > :nth-child(6), .qrow > :nth-child(7) { display: none; }
  .q-pos { grid-area: pos; } .q-patient { grid-area: pat; } .q-wait { grid-area: wait; } .a-status { grid-area: st; } .q-actions { grid-area: act; }
  .q-patient .a-age { display: none; }
  /* celular: nada pode alargar a linha; nome usa o espaço livre e o status encurta com reticências */
  .qrow { grid-template-columns: 22px minmax(0, 1fr) auto auto; grid-template-areas: "pos pat pat pat" "pos st wait act"; column-gap: 8px; padding: 8px 6px 8px 4px; }
  .qrow .appt-status > span:first-child { margin-right: 6px; }
  .qrow > * { min-width: 0; }
  .q-patient { gap: 4px; }
  .q-patient .appt-name { flex: 1 1 auto; font-size: 14px; }
  .q-patient .a-flag { flex: none; }
  .q-patient .requeue-tag { display: none; }
  .qrow .a-status { display: block; overflow: hidden; }
  .qrow .appt-status { display: block; max-width: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; text-align: left; }
  .q-actions { gap: 4px; flex-wrap: nowrap; }
  .q-actions button { flex: none; white-space: nowrap; }
  .q-call { width: 32px; padding: 4px 0; justify-content: center; }
}
.queue-list { min-width: 0; max-width: 100%; overflow-x: hidden; }
@media (max-width: 420px) { .card:has(.queue-list) { padding-left: 12px; padding-right: 12px; } }
.appt.requeued { background: var(--requeue-bg); box-shadow: inset 3px 0 0 var(--requeue); }

/* ---------- Agenda: linha única em colunas alinhadas ---------- */
.agenda-body { container-type: inline-size; container-name: agenda; }
.slot { grid-template-columns: 62px minmax(0, 1fr); gap: 10px; padding: 3px 0; }
.slot-time { flex-direction: row; align-items: center; gap: 4px; padding-top: 4px; }
.slot-time strong { font-size: 12.5px; padding: 2px 7px; border-radius: 7px; border: 1px solid var(--hairline); background: var(--glass-strong); line-height: 1.35; }
.slot.now .slot-time strong { background: var(--accent); color: #fff; border-color: var(--accent); }
.slot-dur, .slot-place { display: none; }
.slot .fit-btn { width: 18px; height: 18px; font-size: 11px; opacity: 0; transition: opacity .15s; }
.slot:hover .fit-btn, .fit-btn:focus-visible { opacity: 1; }
.slot-body { gap: 0; }
.slot-free { padding: 6px 10px; font-size: 12.5px; border: 1px dashed transparent; border-radius: 8px; min-height: 32px; }
.slot-free:hover { border-color: var(--accent); }
.appt.arow { display: grid; grid-template-columns: 22px minmax(190px, 1.8fr) minmax(110px, 1.3fr) 56px minmax(150px, 190px) minmax(90px, 130px) 88px;
  gap: 10px; align-items: center; min-height: 34px; padding: 4px 8px; border: 0; border-left: 3px solid var(--tone, var(--hairline)); border-radius: 8px; background: transparent; margin: 0; }
.appt.arow + .appt.arow { border-top: 1px dotted var(--hairline); border-top-left-radius: 0; border-top-right-radius: 0; }
.appt.arow:hover { background: var(--glass-soft); }
.appt.arow.requeued { background: var(--requeue-bg); }
.a-ico { font-size: 14px; text-align: center; }
.a-name { display: flex; align-items: center; gap: 6px; min-width: 0; white-space: nowrap; }
.a-name .appt-name { font-size: 13.5px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; min-width: 0; text-align: left; }
.a-age { font-size: 12px; flex: none; }
.a-flag { flex: none; font-size: 10.5px; font-weight: 800; line-height: 16px; min-width: 16px; padding: 0 4px; border-radius: 5px; text-align: center; background: var(--glass-soft); border: 1px solid var(--hairline); color: var(--text-2); cursor: help; }
.a-flag.new { color: var(--tag-diagnostico); background: var(--tag-diagnostico-bg); border-color: transparent; }
.a-flag.fit { color: var(--tag-pendencia); background: var(--tag-pendencia-bg); border-color: transparent; }
.a-flag.mirror { color: var(--accent); background: transparent; border: 0; }
.a-name .badge-mini { flex: none; }
.a-proc { font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.a-wait { font-size: 12px; white-space: nowrap; }
.a-wait .wait-timer:not(.warn):not(.late) { color: var(--muted); }
.a-status { min-width: 0; }
.a-status .appt-status { width: 100%; justify-content: flex-start; font-size: 12px; padding: 3px 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.a-pay { display: inline-flex; align-items: center; justify-content: flex-end; gap: 4px; font-size: 12.5px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.a-pay svg { width: 13px; height: 13px; flex: none; }
.a-pay.conv { color: var(--accent); }
.a-pay.part { color: var(--ok); }
.a-act { display: flex; justify-content: flex-end; }
.a-act .a-start { padding: 4px 10px; font-size: 12px; gap: 4px; }
.a-act .a-start svg { width: 13px; height: 13px; }
.a-act .wa-btn { font-size: 11.5px; padding: 3px 8px; white-space: nowrap; }
.appt.arow.off .appt-name { text-decoration: line-through; }
/* confortável: a mesma grade, com mais respiro */
.agenda-body:not(.dense) .appt.arow { min-height: 42px; padding: 7px 10px; }
.agenda-body:not(.dense) .slot { padding: 5px 0; }
.agenda-body:not(.dense) .a-name .appt-name { font-size: 14px; }
@container agenda (max-width: 900px) {
  .appt.arow { grid-template-columns: 22px minmax(140px, 1fr) 56px minmax(140px, 180px) minmax(90px, 120px) 88px; }
  .a-proc { display: none; }
}
@container agenda (max-width: 620px) {
  .slot { grid-template-columns: 54px minmax(0, 1fr); gap: 6px; }
  .appt.arow { grid-template-columns: 20px minmax(0, 1fr) auto; grid-template-areas: "ico name pay" "ico status act"; row-gap: 4px; }
  .a-ico { grid-area: ico; } .a-name { grid-area: name; } .a-pay { grid-area: pay; } .a-status { grid-area: status; } .a-act { grid-area: act; }
  .a-wait { display: none; }
}
.a-name .appt-name { display: block; justify-content: flex-start; padding: 0; white-space: nowrap; }
.appt.arow.fit, .dense .appt.arow.fit { margin-left: 0; }
/* contador da fila no botão Espera do cabeçalho */
.q-badge { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; margin-left: 2px; border-radius: 999px; font-size: 11.5px; font-weight: 800;
  font-variant-numeric: tabular-nums; color: #fff; background: var(--accent); box-shadow: 0 0 0 2px var(--glass-strong); transition: transform .2s; }
.q-badge.warn { background: var(--warn, #b7791f); }
.q-badge.late { background: var(--danger); }
.q-badge.zero { color: var(--muted); background: var(--glass-soft); box-shadow: none; border: 1px solid var(--hairline); }
/* início rápido enxuto: um botão só */
.quick-start { text-align: center; padding: 34px 24px 26px; }
.quick-start h2 { font-size: 22px; margin: 0 0 6px; }
.quick-start > p { margin: 0 auto 18px; max-width: 460px; }
.quick-start .big-cta { padding: 15px 30px; font-size: 16px; }
.quick-start .big-cta svg { width: 20px; height: 20px; }
.qs-foot { margin-top: 12px; }
/* modelo de anamnese: só uma dica ao lado das etapas */
.ws-steps .tpl-inline { margin-left: 4px; max-width: 220px; font-size: 12.5px; color: var(--muted); border-style: dashed; }
.ws-steps .tpl-inline strong { color: var(--text); }
.ws-hint.slim { padding: 8px 12px; gap: 10px; font-size: 13px; }
.ws-hint-ok { display: inline-flex; align-items: center; gap: 5px; font-weight: 700; color: var(--ok); white-space: nowrap; }
.ws-hint-ok svg { width: 15px; height: 15px; }

/* ---------- Central de conduta (chips de receita e exames) ---------- */
.composer { display: flex; flex-direction: column; gap: 10px; }
.composer .section-title { margin-bottom: 0; }
.sg { display: flex; flex-direction: column; gap: 10px; }
.sg:empty { display: none; }
.sg-group { display: flex; flex-direction: column; gap: 6px; }
.sg-title { display: flex; align-items: center; gap: 8px; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.sg-title button { text-transform: none; letter-spacing: 0; }
.sg-status { gap: 8px; }
.sg-chip { display: inline-flex; flex-direction: column; align-items: flex-start; gap: 0; min-height: 36px; padding: 5px 12px; border-radius: 14px; background: var(--glass-soft); color: var(--text); border: 1px solid var(--hairline); box-shadow: none; font-size: 13px; font-weight: 600; text-align: left; line-height: 1.3; }
.sg-chip small { font-weight: 500; font-size: 11.5px; color: var(--muted); }
.sg-chip:hover { border-color: var(--accent); transform: none; }
.sg-chip.said { border-style: dashed; border-color: var(--accent); }
.sg-chip.fav span::before { content: "★ "; color: var(--warn); }
.sg-chip.warn { background: var(--warn-bg); }
.sg-chip.added { opacity: .55; }
.sg-chip.added span::after { content: " ✓"; color: var(--ok); }
.sg-chip.mini { min-height: 28px; padding: 3px 9px; font-size: 12px; border-radius: 999px; }
.chips.quick { margin-top: 6px; }
.sg-quote { font-size: 12.5px; font-style: italic; color: var(--text-2); }
.sg-quote:empty { display: none; }
.rx-line { display: flex; flex-direction: column; gap: 10px; padding: 12px 14px; border-radius: 16px; border: 1px solid var(--accent); background: var(--accent-soft); }
.rx-line[hidden] { display: none; }
.rx-line-head { align-items: flex-end; flex-wrap: nowrap; }
.fav-btn { font-size: 18px; line-height: 1; color: var(--muted); }
.fav-btn.on { color: var(--warn); }
.item-edit { background: none; box-shadow: none; color: inherit; padding: 0; text-align: left; display: block; font: inherit; }
.item-edit:hover { transform: none; }
.item-edit:hover .name { color: var(--accent); }
.conduct-tabs { align-self: flex-start; margin-bottom: 4px; }
.conduct-card .card-head { align-items: flex-start; }
.transcript-box > summary { cursor: pointer; list-style: none; justify-content: flex-start; }
.transcript-box > summary::before { content: "▸"; font-size: 11px; transition: transform .15s; }
.transcript-box[open] > summary::before { transform: rotate(90deg); }
.transcript-box > summary::-webkit-details-marker { display: none; }

/* ---------- Semáforo de revisão clínica ---------- */
.sem-light { display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 6px 14px; border-radius: 999px; font-size: 13px; font-weight: 650; box-shadow: none; background: var(--glass-soft); color: var(--text-2); border: 1px solid var(--hairline); white-space: nowrap; }
.sem-light:hover { transform: none; }
.sem-dot { flex: none; display: inline-block; width: 11px; height: 11px; border-radius: 50%; background: var(--muted); }
.sem-light.green { color: var(--ok); background: var(--ok-bg); } .sem-light.green .sem-dot, .sem-dot.green { background: var(--ok); }
.sem-light.yellow { color: var(--warn); background: var(--warn-bg); } .sem-light.yellow .sem-dot, .sem-dot.yellow { background: var(--warn); }
.sem-light.red { color: var(--danger); background: var(--danger-bg); } .sem-light.red .sem-dot, .sem-dot.red { background: var(--danger); }
.sem-light.loading .sem-dot { background: var(--accent); animation: pulse 1.1s infinite; }
.sem-body { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.sem-body:empty { display: none; }
.sem-card { border-radius: 14px; padding: 8px 12px; border: 1px solid var(--hairline); background: var(--glass-soft); }
.sem-card.yellow { border-color: color-mix(in srgb, var(--warn) 45%, transparent); background: var(--warn-bg); }
.sem-card.red { border-color: color-mix(in srgb, var(--danger) 45%, transparent); background: var(--danger-bg); }
.sem-card summary { display: flex; align-items: center; gap: 8px; cursor: pointer; list-style: none; min-height: 28px; }
.sem-card summary::-webkit-details-marker { display: none; }
.sem-card.yellow .sem-dot { background: var(--warn); } .sem-card.red .sem-dot { background: var(--danger); }
.sem-card p { margin: 6px 0 2px 19px; font-size: 13.5px; }
.sem-area { margin-left: auto; font-size: 11px; font-weight: 650; color: var(--text-2); }
.sem-action { color: var(--text-2); }
.sem-foot { gap: 6px; flex-wrap: wrap; }
.sem-foot button.active { background: var(--accent-soft); color: var(--accent); }
.sem-stats { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.sem-stat { display: flex; flex-direction: column; padding: 12px 14px; border-radius: 14px; background: var(--glass-soft); border: 1px solid var(--hairline); }
.sem-stat strong { font-size: 24px; }
.sem-stat span { font-size: 13px; color: var(--text-2); }
.sem-weeks { display: flex; gap: 6px; align-items: flex-end; height: 120px; overflow-x: auto; }
.sem-week { display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; min-width: 28px; }
.sem-bar { flex: 1; width: 16px; display: flex; flex-direction: column-reverse; border-radius: 6px; overflow: hidden; background: var(--glass-soft); }
.sem-bar span { display: block; } .sem-bar .green { background: var(--ok); } .sem-bar .yellow { background: var(--warn); } .sem-bar .red { background: var(--danger); }
.sem-week small { font-size: 10.5px; color: var(--muted); }
.sem-top { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; }
.sem-top li { display: list-item; } .sem-top .sem-dot { margin-right: 6px; vertical-align: -1px; }
@media (max-width: 640px) { .conduct-card .card-head { flex-direction: column; } .rx-line-head { flex-wrap: wrap; } }
.items li.incomplete { border-color: color-mix(in srgb, var(--warn) 55%, transparent); }
.item-warn { font-size: 12px; font-weight: 600; color: var(--warn); margin-top: 2px; }
.sg-chip.picked { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.sg-toggle { align-self: flex-start; color: var(--text-2); }
.sem-light { gap: 6px; }
.sem-light strong { font-weight: 700; }
.sem-light-label { color: var(--text-2); font-weight: 600; }
.sem-light.red { animation: sem-pulse 2.4s ease-in-out 3; }
@keyframes sem-pulse { 50% { box-shadow: 0 0 0 5px var(--danger-bg); } }
@media (prefers-reduced-motion: reduce) { .sem-light.red { animation: none; } }
.sem-modal .sem-body { margin: 4px 0 0; }
@media (min-width: 641px) { .conduct-card .card-head { flex-wrap: nowrap; } .conduct-card .card-head .sem-light { flex: none; } }

/* Ações do atendimento dentro da caixa do paciente (menu lateral) */
.patient-chip:has(> .ws-actions) { flex-wrap: wrap; }
.patient-chip > .ws-actions { flex-basis: 100%; margin: 6px 0 0; display: grid; grid-template-columns: 1fr auto; gap: 6px; }
.patient-chip > .ws-actions .finish-btn { grid-column: 1 / -1; justify-content: center; }
.patient-chip > .ws-actions .wait-btn { justify-content: center; }
.ws-actions-home[hidden] { display: none; }
.tpl-row { display: flex; align-items: center; gap: 2px; }
.tpl-row .tpl-item { flex: 1; min-width: 0; }

/* ---------- Conduta: cartão com cor própria (azul-índigo suave) ---------- */
.conduct-card {
  background:
    linear-gradient(160deg, color-mix(in srgb, var(--accent) 9%, transparent), color-mix(in srgb, var(--accent-2) 7%, transparent) 60%, transparent),
    var(--glass);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
  box-shadow: var(--shadow), inset 3px 0 0 color-mix(in srgb, var(--accent) 55%, transparent);
}
.conduct-card .card-head h2 { color: color-mix(in srgb, var(--accent) 70%, var(--text)); }
/* Seletor Receita / Exames em destaque */
.segmented.conduct-tabs { padding: 4px; gap: 4px; background: var(--glass-strong); border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent); margin-bottom: 8px; }
.segmented.conduct-tabs button { padding: 8px 22px; font-size: 14.5px; font-weight: 700; color: var(--text-2); }
.segmented.conduct-tabs button.active { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: var(--accent-text); box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 30%, transparent); }

/* Botões que abrem os grupos ocultos */
.sg-toggles { display: flex; flex-direction: column; gap: 10px; }
.sg-toggle-row { gap: 6px; flex-wrap: wrap; }
.sg-toggle { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 4px 12px; border-radius: 999px; font-size: 12.5px; font-weight: 650;
  background: var(--glass-soft); color: var(--text-2); border: 1px solid var(--hairline); box-shadow: none; }
.sg-toggle:hover { transform: none; border-color: var(--accent); }
.sg-toggle.open { background: var(--accent-soft); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.sg-count { font-size: 11px; padding: 0 6px; border-radius: 999px; background: var(--glass-strong); color: var(--text-2); }

/* Escolha na lista CMED: o grupo recolhe e a posologia ganha destaque (próximo passo) */
.alt-picked { gap: 8px; padding: 8px 10px; border-radius: 12px; background: var(--ok-bg); color: var(--ok); font-size: 13px; flex-wrap: nowrap; }
.alt-picked[hidden] { display: none; }
.alt-picked .grow { color: var(--text); }
.rx-posology { border-radius: 14px; transition: box-shadow .3s; }
.rx-posology.next-step { animation: next-step 1.6s ease-out 2; }
@keyframes next-step { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 45%, transparent); } 70% { box-shadow: 0 0 0 10px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }

/* Assistente: brilho suave depois que a anamnese fica pronta */
.chat-card.attn { animation: attn-glow 2.4s ease-in-out 3; }
@keyframes attn-glow { 50% { box-shadow: var(--shadow), 0 0 0 4px color-mix(in srgb, var(--accent-2) 22%, transparent), 0 0 28px color-mix(in srgb, var(--accent-2) 25%, transparent); } }
.attn-tag { display: inline-block; margin-top: 6px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; color: var(--accent-2);
  background: color-mix(in srgb, var(--accent-2) 10%, transparent); animation: attn-in .4s ease-out; transition: opacity .5s; }
.attn-tag.out { opacity: 0; }
@keyframes attn-in { from { opacity: 0; transform: translateY(-3px); } }
@media (prefers-reduced-motion: reduce) { .chat-card.attn, .rx-posology.next-step, .attn-tag { animation: none; } }


/* ---------- Marca (docs/design/BRAND.md) ---------- */
:root { --mark: #2F5BFF; --mark-dot: #0E1532; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --mark: #8EA6FF; --mark-dot: #FFFFFF; } }
:root[data-theme="dark"] { --mark: #8EA6FF; --mark-dot: #FFFFFF; }
.brand-logo { display: inline-flex; align-items: center; }
.brand-logo .brand-full { height: 24px; width: auto; display: block; }
.brand-logo .brand-sym { height: 22px; width: auto; display: none; overflow: visible; }
@media (max-width: 860px) { .brand-logo .brand-full { display: none; } .brand-logo .brand-sym { display: block; } }
.lg-stroke { fill: none; stroke: var(--mark); }
.lg-dot { fill: var(--mark-dot); }
.lg-med { fill: var(--mark); }
.lg-you { fill: var(--text); }

/* ---------- Imagens e documentos analisados pela IA ---------- */
.workspace-head .att-btn { border-style: dashed; white-space: nowrap; flex: none; }
.att-panel { margin: 4px 0 14px; padding: 14px; border-radius: 16px; background: var(--glass-soft); border: 1px solid var(--hairline); animation: listen-in .3s cubic-bezier(.2, .9, .3, 1.1); }
.att-panel .section-title { display: flex; align-items: center; gap: 8px; }
.att-send { gap: 8px; margin-bottom: 10px; }
.att-drop { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border: 1.5px dashed color-mix(in srgb, var(--accent) 45%, var(--hairline)); border-radius: 14px;
  background: var(--glass-strong); cursor: pointer; transition: background .15s, border-color .15s; }
.att-drop:hover, .att-drop.over { background: color-mix(in srgb, var(--accent) 8%, var(--glass-strong)); border-color: var(--accent); }
.att-drop > .i { width: 22px; height: 22px; color: var(--accent); flex: none; }
.att-status:empty { display: none; }
.att-status { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); }
.att-status .ws-error { margin-top: 0; }
.att-list { display: grid; gap: 8px; }
.att-item { border: 1px solid var(--hairline); border-radius: 14px; background: var(--glass-strong); padding: 10px 12px; }
.att-item > summary { display: flex; align-items: center; gap: 8px; cursor: pointer; flex-wrap: wrap; list-style: none; }
.att-item > summary::-webkit-details-marker { display: none; }
.att-item > summary .muted { font-size: 12px; }
.att-q { margin: 8px 0 0; font-size: 13px; }
.att-body { margin-top: 8px; font-size: 14px; }
.att-actions { gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.chat-input > .ghost.icon { flex: none; width: 40px; height: 40px; padding: 0; }

/* Busca de paciente dentro da página ("Buscar paciente") */
.inline-search { max-width: 460px; margin: 12px auto 0; text-align: left; }
.inline-search:empty { display: none; }
.search-box.inline .dropdown { position: absolute; left: 0; right: 0; }
/* Lista de resultados aberta: o cartão sobe acima dos vizinhos (o vidro cria camadas próprias e o cartão seguinte cobria a lista) */
.card:has(.inline-search .dropdown), .card:has(.ac .dropdown) { position: relative; z-index: 40; }

/* Escolha da clínica ao entrar (vínculo com mais de uma) */
.auth-wrap:has(.org-picker) { grid-template-columns: minmax(0, 1fr); justify-items: center; padding: 16px; }
.org-picker { width: min(520px, 100%); min-width: 0; }
@media (max-width: 480px) { .org-picker { padding: 22px 18px; } }
.org-picker h1 { font-size: 1.45rem; line-height: 1.25; margin: 0; }
.org-pick-list { display: grid; gap: 10px; }
.org-pick { white-space: normal; overflow-wrap: anywhere; display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 14px 16px; min-height: 64px; border-radius: 16px;
  background: var(--glass-strong); color: var(--text); border: 1px solid var(--hairline); box-shadow: none; }
.org-pick:hover, .org-pick:focus-visible { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 7%, var(--glass-strong)); }
.org-pick.last { border-color: color-mix(in srgb, var(--accent) 45%, var(--hairline)); }
.org-pick .grow { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.org-pick .grow strong { font-size: 15px; }
.org-pick .grow .muted { font-size: 12.5px; font-weight: 500; }
.org-pick .i.flip { transform: scaleX(-1); color: var(--muted); flex: none; }

/* Envio pelo celular (QR code) */
.att-send-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: stretch; }
.att-send-row > button { white-space: nowrap; }
@media (max-width: 560px) { .att-send-row { grid-template-columns: 1fr; } }
.att-phone { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 12px; border-radius: 12px; font-size: 13px;
  background: color-mix(in srgb, var(--ok) 10%, var(--glass-strong)); border: 1px solid color-mix(in srgb, var(--ok) 35%, transparent); color: var(--text); }
.att-phone[hidden] { display: none; }
.modal-card:has(.qr-modal) { width: min(480px, 100%); }
.qr-box { display: grid; place-items: center; padding: 14px; border-radius: 18px; background: #fff; border: 1px solid var(--hairline); justify-self: center; }
.qr-box img { display: block; width: 232px; height: 232px; image-rendering: pixelated; }
.qr-clock { font-variant-numeric: tabular-nums; color: var(--text-2); font-size: 13px; }
.qr-rules { margin: 0; padding-left: 18px; display: grid; gap: 2px; }

/* Arquivos do prontuário: miniatura, visualizador e galeria de imagens */
.att-row { display: flex; gap: 12px; align-items: flex-start; }
.att-info { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.att-info > strong { overflow-wrap: anywhere; }
.att-info .muted { font-size: 12px; }
.att-thumb { flex: none; width: 76px; height: 76px; padding: 0; border-radius: 12px; overflow: hidden; display: grid; place-items: center;
  background: var(--glass-soft); border: 1px solid var(--hairline); color: var(--muted); box-shadow: none; cursor: zoom-in; }
.att-thumb .i { width: 26px; height: 26px; }
.att-thumb.doc { cursor: pointer; color: var(--accent); }
.att-thumb:disabled { cursor: default; opacity: .6; }
.att-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.att-read { margin-top: 8px; }
.att-read > summary { cursor: pointer; font-size: 13px; font-weight: 700; color: var(--accent); }
.att-body:empty { display: none; }
.viewer { display: grid; gap: 12px; }
.viewer-head { gap: 10px; flex-wrap: wrap; padding-right: 44px; }
.viewer-title { min-width: 0; overflow-wrap: anywhere; }
.viewer-body { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 14px; min-height: 60vh; }
.viewer-stage { display: grid; place-items: center; background: #0B1024; border-radius: 16px; overflow: hidden; min-height: 60vh; }
.viewer-stage img { max-width: 100%; max-height: 74vh; object-fit: contain; display: block; }
.viewer-stage iframe { width: 100%; height: 74vh; border: 0; background: #fff; }
.viewer-side { overflow-y: auto; max-height: 74vh; font-size: 14px; }
@media (max-width: 860px) { .viewer-body { grid-template-columns: 1fr; } .viewer-side { max-height: none; } }
.img-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.img-tile { margin: 0; display: grid; gap: 6px; }
.img-tile .att-thumb { width: 100%; height: auto; aspect-ratio: 1; }
.img-tile figcaption { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; font-size: 12px; color: var(--text-2); }
.i.flip { transform: scaleX(-1); }

/* ---------- Espaço de tela: menu lateral recolhível ---------- */
.side-top { display: flex; align-items: center; gap: 6px; }
.side-top .search-box { flex: 1 1 auto; min-width: 0; }
.side-toggle, .side-search { flex: none; width: 36px; height: 36px; padding: 0; }
.side-search { display: none; }
.side-toggle svg { transition: transform .25s; }
body.side-collapsed .side-toggle svg { transform: scaleX(-1); }
.shell, .sidebar { transition: grid-template-columns .28s cubic-bezier(.2, .8, .2, 1), width .28s; }
@media (max-width: 860px) { .side-toggle { display: none; } }

body.side-collapsed { --sidebar-w: 76px; }
body.side-collapsed .sidebar { padding: 14px 10px; align-items: center; }
body.side-collapsed .side-top { flex-direction: column-reverse; gap: 8px; }
body.side-collapsed .side-top .search-box, body.side-collapsed .side-slot { display: none; }
body.side-collapsed .side-search { display: inline-flex; }
body.side-collapsed .nav { width: 100%; align-items: center; margin-right: 0; padding-right: 0; }
body.side-collapsed .nav a { justify-content: center; width: 48px; height: 44px; padding: 0; gap: 0; }
body.side-collapsed .nav a .nav-text { display: none; }
body.side-collapsed .nav a.live::after { right: 6px; top: 8px; margin-top: 0; }
body.side-collapsed .nav-label { font-size: 0; padding: 6px 0 2px; width: 32px; border-top: 1px solid var(--hairline); }
body.side-collapsed .patient-chip { padding: 6px; justify-content: center; }
body.side-collapsed .patient-chip > :not(.avatar) { display: none; }
body.side-collapsed .patient-chip.is-live .avatar { box-shadow: 0 0 0 3px var(--ok-bg), 0 0 0 5px var(--ok); }
/* lupa no menu recolhido: a busca abre por cima do conteúdo, e some ao sair do campo */
body.side-collapsed.side-peek .side-top .search-box { display: block; position: absolute; left: calc(100% + 10px); top: 14px; width: 320px; z-index: 45; }
body.side-collapsed.side-peek .side-top .search-box input { box-shadow: var(--shadow); }

/* ---------- Assistente em janela (notebook) ---------- */
.assist-btn, .assist-fab { display: none; }
.ws-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
body.chat-popup .assist-btn { display: inline-flex; }
.pop-btn, .dock-btn, .close-chat { display: none; }
@media (min-width: 1101px) { body:not(.chat-popup) .pop-btn { display: inline-flex; } body.chat-popup .dock-btn { display: inline-flex; } }
body.chat-popup .close-chat { display: inline-flex; }
body.chat-popup .expand-btn { display: none; }
body.chat-popup .evo, body.chat-popup .evo.chat-wide { grid-template-columns: minmax(0, 1fr); }
body.chat-popup .evo .chat-card {
  position: fixed; top: calc(var(--appbar-h, 56px) + 12px); right: 16px; bottom: 16px; left: auto; z-index: 70;
  width: min(480px, calc(100vw - 32px)); height: auto; min-height: 0; margin: 0;
  background: var(--glass-strong); box-shadow: 0 24px 60px -18px rgba(20, 30, 70, .45);
  transform: translateX(calc(100% + 32px)); visibility: hidden; transition: transform .3s cubic-bezier(.2, .8, .2, 1), visibility .3s;
}
body.chat-popup.chat-open .evo .chat-card { transform: none; visibility: visible; }
body.chat-popup .assist-fab {
  display: inline-flex; align-items: center; gap: 8px; position: fixed; right: 20px; bottom: 20px; z-index: 65; padding: 12px 18px; border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; font-weight: 700; box-shadow: 0 14px 30px -12px var(--accent);
}
body.chat-popup.chat-open .assist-fab { display: none; }
.assist-btn.attn, .assist-fab.attn { animation: next-glow 1.8s ease-in-out infinite; }
.chat-head-btns { gap: 4px; flex-wrap: nowrap; }
@media (max-width: 860px) { body.chat-popup .evo .chat-card { top: 64px; right: 8px; bottom: 8px; width: calc(100vw - 16px); } }
body.side-collapsed .sidebar { overflow: visible; }
body.side-collapsed .side-top { position: relative; width: 100%; align-items: center; }
body.side-collapsed.side-peek .side-top .search-box { top: auto; bottom: 0; }
body.side-collapsed .sidebar { z-index: 45; }
/* com atendimento aberto, o botão fica junto dos controles da transcrição; o flutuante é só para as outras telas do atendimento */
body.chat-popup .evo:has(.ws-tools .assist-btn) .assist-fab { display: none; }

/* ---------- Celular: atendimento por estados (uma ação principal por momento) ---------- */
.m-stage, .m-tabs, .m-dock { display: none; }
@media (max-width: 860px) {
  /* cabeçalho de uma linha: nome, dados em uma linha; tocar abre os detalhes */
  .ctx-bar { padding: 8px 12px; min-height: 0; gap: 8px; border-radius: 20px; }
  .ctx-bar:has(.ctx-patient-inner) .ctx-title { display: none; }
  .ctx-patient { cursor: pointer; }
  .ctx-patient-inner { flex-wrap: nowrap; gap: 10px; }
  .ctx-patient-inner > .avatar { width: 34px !important; height: 34px !important; font-size: 12px !important; }
  .ctx-patient-text { flex: 1 1 auto; min-width: 0; }
  .ctx-patient-name { display: block; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .ctx-patient-text .muted { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 12px; }
  .ctx-patient.expanded .ctx-patient-text .muted, .ctx-patient.expanded .ctx-patient-name { white-space: normal; }
  .ctx-patient-inner > .status-chip, .ctx-patient-inner > button { margin-left: auto !important; flex: none; font-size: 12px; }

  .m-stage { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; text-align: center;
    padding: 14px 2px 6px; min-height: calc(100dvh - var(--topbar-h, 130px) - 150px); }
  .m-stage[data-phase="revisar"] { min-height: 0; padding: 0 0 4px; }
  .m-stage[data-phase="gerando"] { min-height: 0; padding-top: 22px; }
  /* no celular a linha de controles do computador dá lugar ao palco */
  .ws-cards:has(.m-stage) .workspace-head, .ws-cards:has(.m-stage) .m-main > .card-head, .ws-cards:has(.m-stage) .listen-panel { display: none; }
  .ws-cards[data-mphase]:not([data-mphase="revisar"]) > .card:not(.m-main) { display: none; }
  .ws-cards[data-mphase]:not([data-mphase="revisar"]) .m-main > :is(.transcript-box, .section-title, .anam-box, .preview) { display: none; }
  .ws-cards.show-tx .m-main > .transcript-box { display: block !important; }
  .ws-cards[data-mtab="consulta"] > .m-conduta, .ws-cards[data-mtab="consulta"] .m-main > .att-panel { display: none; }
  .ws-cards[data-mtab="conduta"] > .card:not(.m-conduta) { display: none; }
  .ws-cards[data-mtab="arquivos"] > .card:not(.m-main), .ws-cards[data-mtab="arquivos"] .m-main > :not(.att-panel) { display: none; }
  .ws-cards[data-mtab="arquivos"] .m-main > .att-panel { display: block !important; margin: 0; }
  .ws-cards:has(.m-stage) .m-main { padding: 16px 14px; }

  .m-mode { padding: 4px; }
  .m-mode button { min-height: 38px; padding: 0 20px; font-size: 14px; }
  .m-mode button.active { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; }
  /* Botão de gravar: círculo sólido na cor do símbolo, anel fino que respira e o ponto do logotipo */
  .m-orb { position: relative; flex: none; width: 148px; height: 148px; min-width: 148px; padding: 0; border: 0; border-radius: 50%; background: none; box-shadow: none; display: grid; place-items: center; }
  .m-orb:hover { transform: none; }
  .m-orb:active .m-core { transform: scale(.97); }
  .m-orb::after { content: ""; position: absolute; right: -8px; bottom: 8px; width: 16px; height: 16px; border-radius: 50%; background: var(--mark-dot); }
  .m-orb.gen::after, .m-orb.paused::after { opacity: .35; }
  .m-core { position: absolute; inset: 0; border-radius: 50%; background: var(--mark); transition: transform .15s ease, background .2s ease;
    box-shadow: 0 18px 36px -18px var(--mark), inset 0 0 0 1px rgba(255, 255, 255, .14); }
  .m-core::after { content: ""; position: absolute; inset: 12px; border-radius: 50%; border: 1.5px solid rgba(255, 255, 255, .22); }
  .m-halo { position: absolute; inset: -14px; border-radius: 50%; border: 1.5px solid color-mix(in srgb, var(--mark) 32%, transparent);
    transform: scale(var(--lvl, 1)); transition: transform .12s linear; }
  .m-halo::before { content: ""; position: absolute; inset: -14px; border-radius: 50%; border: 1px solid color-mix(in srgb, var(--mark) 16%, transparent); }
  .m-orb > svg.i { position: relative; z-index: 1; width: 40px; height: 40px; color: #fff; stroke-width: 2; }
  .m-orb .spin.light { position: relative; z-index: 1; width: 34px; height: 34px; border-width: 3px; color: #fff; }
  .m-orb:not(.live):not(.gen) .m-halo { animation: m-ring 3s ease-in-out infinite; }
  .m-orb.paused .m-core { background: color-mix(in srgb, var(--mark) 45%, var(--muted)); }
  .m-orb.paused .m-halo { transform: none; opacity: .5; }
  .m-orb.gen .m-halo { border: 2px solid transparent; border-top-color: var(--mark); animation: m-spin 1.1s linear infinite; }
  .m-orb.gen .m-halo::before { display: none; }
  @keyframes m-ring { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.06); opacity: .55; } }
  @keyframes m-spin { to { transform: rotate(360deg); } }
  .m-cta { margin: 0; font-size: 1.3rem; font-weight: 700; letter-spacing: -.01em; }
  .m-hint { margin: 0; max-width: 32ch; font-size: 14px; color: var(--muted); }
  .m-pill { display: inline-flex; align-items: center; gap: 8px; min-height: 42px; max-width: 100%; padding: 0 16px; border-radius: 999px; font-weight: 500; font-size: 14px;
    background: var(--glass-strong); color: var(--text-2); border: 1px dashed color-mix(in srgb, var(--accent) 35%, var(--hairline)); box-shadow: none; }
  .m-pill b { color: var(--text); font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 170px; display: inline-block; vertical-align: bottom; }
  .m-timer { font: 500 2.5rem/1 ui-monospace, "SF Mono", Menlo, monospace; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
  .m-wave { display: flex; align-items: center; gap: 4px; height: 42px; }
  .m-wave span { width: 5px; height: 6px; border-radius: 3px; background: linear-gradient(var(--accent), var(--accent-2)); transition: height .12s linear; }
  .m-ctls { display: flex; align-items: flex-start; gap: 22px; }
  .m-ctl { display: grid; justify-items: center; gap: 6px; font-size: 12px; font-weight: 650; color: var(--text-2); }
  .m-round { width: 62px; height: 62px; padding: 0; border-radius: 50%; display: grid; place-items: center; color: var(--text); background: var(--glass-strong); border: 1px solid var(--hairline); box-shadow: 0 10px 24px -16px rgba(20, 30, 70, .4); }
  .m-round.stop { width: 74px; height: 74px; margin-top: -6px; background: var(--danger); color: #fff; border-color: transparent; box-shadow: 0 16px 30px -14px var(--danger); }
  .m-round .i { width: 24px; height: 24px; }
  .m-live, .m-card { width: 100%; display: grid; justify-content: stretch; white-space: normal; gap: 4px; padding: 10px 14px; border-radius: 16px; text-align: left; font-weight: 400; color: var(--text-2);
    background: var(--glass-strong); border: 1px solid var(--hairline); box-shadow: none; }
  .m-live .label, .m-card .label { font-size: 11px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
  .m-live span:last-child { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 13.5px; }
  .m-clamp { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; font-size: 14px; }
  .m-done { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: center; min-height: 40px; padding: 4px 6px 4px 14px; border-radius: 999px;
    background: var(--glass-strong); border: 1px solid var(--hairline); font-weight: 650; font-size: 14px; }
  .m-done.rev { width: 100%; flex-wrap: nowrap; justify-content: space-between; gap: 6px; padding-left: 12px; font-size: 13.5px; }
  .m-done.rev > span { margin-right: auto; white-space: nowrap; }
  .m-done.rev button { padding: 0 10px; font-size: 12.5px; white-space: nowrap; }
  .ws-cards[data-mphase="revisar"] .ws-done { display: none; }
  .m-done i { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
  .m-done button { min-height: 32px; padding: 0 12px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 13px; box-shadow: none; border: 0; }
  .m-primary { width: 100%; min-height: 62px; border-radius: 20px; justify-content: center; font-size: 1.1rem; font-weight: 700; color: #fff; border: 0;
    background: linear-gradient(135deg, var(--accent), var(--accent-2)); box-shadow: 0 18px 34px -16px var(--accent); animation: next-glow 2.4s ease-in-out infinite; }
  .m-primary .i { width: 22px; height: 22px; }

  .m-tabs { display: flex; position: sticky; top: calc(var(--topbar-h, 120px) + 6px); z-index: 20; width: 100%; padding: 4px; }
  .m-tabs[hidden] { display: none; }
  .m-tabs button { flex: 1; min-height: 38px; font-size: 14px; }
  .m-tabs button.active { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; }
  /* abas com fundo sólido: não somem sobre o vidro */
  .m-tabs { background: color-mix(in srgb, var(--bg) 90%, var(--text)); border: 1px solid color-mix(in srgb, var(--text) 14%, transparent);
    box-shadow: 0 10px 24px -14px rgba(14, 21, 50, .45); -webkit-backdrop-filter: none; backdrop-filter: none; }
  .m-tabs button { color: var(--text); font-weight: 650; }
  .m-tabs button.active { background: var(--mark); box-shadow: 0 6px 14px -8px var(--mark); }

  /* barra de ações na zona do polegar */
  .m-dock { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; position: fixed; left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom, 0px)); z-index: 60;
    padding: 7px; border-radius: 24px; background: var(--glass-strong); border: 1px solid var(--glass-border); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
    box-shadow: 0 18px 40px -20px rgba(20, 30, 70, .45); }
  .m-dock button { display: grid; justify-items: center; align-content: center; gap: 3px; min-height: 54px; padding: 0; border-radius: 18px; border: 0; background: none; box-shadow: none;
    font-size: 11.5px; font-weight: 650; color: var(--text-2); }
  .m-dock button:active { background: var(--accent-soft); }
  .m-dock .m-fin { color: var(--muted); }
  .m-dock .m-fin.ready { background: var(--ok); color: #fff; box-shadow: 0 10px 22px -12px var(--ok); }
  body:has(.m-dock) .view-host { padding-bottom: 92px; }
  body:has(.m-dock) .assist-fab { display: none !important; }
  body:has(.m-dock) #toast { bottom: calc(96px + env(safe-area-inset-bottom, 0px)); }
}
/* Modelos de anamnese no celular: folha com uma rolagem só e botão fixo embaixo */
.modal-card:has(.tpl-m) { display: flex; flex-direction: column; padding: 0; overflow: hidden; max-height: calc(100dvh - 24px); }
.tpl-m { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.tpl-m-head { display: grid; gap: 10px; padding: 18px 16px 10px; border-bottom: 1px solid var(--hairline); }
.tpl-m-head h2 { margin: 0; padding-right: 40px; font-size: 1.15rem; }
.tpl-m-filters { display: flex; flex-wrap: wrap; gap: 6px; }
.tpl-m-filters button { min-height: 32px; padding: 0 12px; border-radius: 999px; font-size: 13px; font-weight: 600; box-shadow: none; background: var(--glass-soft); color: var(--text-2); border: 1px solid var(--hairline); }
.tpl-m-filters button.active { background: var(--mark); color: #fff; border-color: transparent; }
.tpl-m-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 8px 10px 12px; }
.tpl-m-list { display: grid; gap: 4px; }
.tpl-m-row { display: flex; align-items: center; gap: 4px; border-radius: 14px; }
.tpl-m-row.on { background: var(--accent-soft); }
.tpl-m-item { flex: 1; display: flex; align-items: flex-start; gap: 12px; min-height: 56px; padding: 10px 8px 10px 10px; text-align: left; justify-content: flex-start;
  background: none; border: 0; box-shadow: none; color: var(--text); font-weight: 400; white-space: normal; }
.tpl-m-dot { flex: none; width: 20px; height: 20px; margin-top: 2px; border-radius: 50%; border: 2px solid color-mix(in srgb, var(--text) 30%, transparent); }
.tpl-m-row.on .tpl-m-dot { border: 6px solid var(--mark); }
.tpl-m-text { display: grid; gap: 2px; min-width: 0; }
.tpl-m-text b { font-weight: 650; }
.tpl-m-text small { color: var(--muted); font-size: 12.5px; }
.tpl-m-secs { margin-top: 4px; font-size: 12.5px; color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.tpl-m-new { margin: 10px 0 0 6px; }
.tpl-m-foot { display: flex; align-items: center; gap: 12px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--hairline); background: var(--glass-strong); }
.tpl-m-foot .check { font-size: 13px; white-space: nowrap; }
.tpl-m-use { flex: 1; min-height: 48px; justify-content: center; border-radius: 14px; }
@media (max-width: 860px) {
  .modal-root:has(.tpl-m) { align-items: flex-end; padding: 12px 0 0; }
  .modal-card:has(.tpl-m) { width: 100%; border-radius: 22px 22px 0 0; max-height: 88dvh; }
}
/* QR no celular: o médico anexa direto; o QR fica como opção para o paciente enviar do telefone dele */
.att-qr-link { display: none; }
@media (max-width: 860px) {
  .att-send-row > .att-phone { display: none; }
  .att-qr-link { display: inline-flex; justify-self: start; min-height: 40px; padding: 0 4px; background: none; border: 0; box-shadow: none; color: var(--accent); font-weight: 600; font-size: 13.5px; text-align: left; white-space: normal; text-decoration: underline; text-underline-offset: 3px; }
}
/* Menu principal no celular: botão ⋯ e folha que sobe de baixo */
.more-btn { display: none; }
.ms { display: grid; gap: 16px; padding: 18px 16px calc(16px + env(safe-area-inset-bottom, 0px)); }
.ms-title { margin: 0; font-size: 1.15rem; padding-right: 40px; }
.ms-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 8px; }
.ms-tile { display: grid; justify-items: center; gap: 6px; min-height: 84px; padding: 12px 6px; border-radius: 16px; background: var(--glass-soft); border: 1px solid var(--hairline);
  box-shadow: none; color: var(--text); font-weight: 600; font-size: 13px; white-space: normal; text-align: center; }
.ms-tile.active { background: var(--accent-soft); border-color: color-mix(in srgb, var(--mark) 35%, transparent); color: var(--mark); }
.ms-ico { position: relative; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: color-mix(in srgb, var(--mark) 10%, transparent); color: var(--mark); }
.ms-ico .i { width: 20px; height: 20px; }
.ms-ico > :not(.i) { position: absolute; top: -6px; right: -10px; }
.ms-group { display: grid; gap: 2px; }
.ms-label { font-size: 11px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 0 6px 4px; }
.ms-row { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 52px; padding: 8px 10px; border-radius: 14px; background: none; border: 0; box-shadow: none;
  color: var(--text); font-weight: 600; font-size: 14.5px; justify-content: flex-start; text-align: left; white-space: normal; }
.ms-row > .i { flex: none; width: 20px; height: 20px; color: var(--mark); }
.ms-row > span:not(.ms-chev) { display: grid; gap: 1px; flex: 1; min-width: 0; }
.ms-row small { color: var(--muted); font-weight: 400; font-size: 12.5px; }
.ms-row.active { background: var(--accent-soft); }
.ms-chev { color: var(--muted); font-size: 20px; }
@media (max-width: 860px) {
  .appbar .top-nav { display: none; }
  .more-btn { display: inline-flex; width: 40px; height: 40px; }
  .appbar-right { margin-left: auto; min-width: 0; gap: 6px; }
  .modal-root:has(.ms) { align-items: end; padding: 12px 0 0; }
  .modal-card:has(.ms) { width: 100%; padding: 0; border-radius: 22px 22px 0 0; max-height: 88dvh; }
}
/* Agenda no celular: lista limpa por horário */
.mday-sum { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 4px 2px 10px; font-size: 13.5px; color: var(--text-2); }
.mday-sum b { color: var(--text); font-size: 15px; }
/* Agenda no celular, no modelo da Feegow: faixa do consultório, etiqueta da hora, ícone e nome numa linha */
.ag-list { display: grid; grid-template-columns: minmax(0, 1fr); min-width: 0; }
.ag-list > * { min-width: 0; }
.ag-band { margin: 10px 0 2px; padding: 7px 12px; border-radius: 12px; text-align: center; font-size: 12px; font-weight: 750; letter-spacing: .04em; text-transform: uppercase;
  color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent-2)); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ag-band:first-child { margin-top: 0; }
.ag-break { margin: 10px 0 2px; padding: 6px 12px; border-radius: 12px; text-align: center; font-size: 12px; font-weight: 650; color: var(--muted);
  background: repeating-linear-gradient(135deg, var(--glass-soft) 0 8px, transparent 8px 16px); border: 1px dashed var(--hairline); }
.ag-row { display: grid; grid-template-columns: 18px 58px 22px minmax(0, 1fr); align-items: center; column-gap: 8px; width: 100%; min-width: 0; min-height: 50px;
  padding: 6px 6px 6px 2px; border: 0; border-bottom: 1px solid var(--hairline); border-radius: 0; background: none; box-shadow: none;
  color: var(--text); font-weight: 400; text-align: left; justify-content: stretch; white-space: nowrap; }
.ag-row:hover { transform: none; }
.ag-row:active { background: var(--accent-soft); }
.ag-flag { display: grid; place-items: center; color: var(--tag-diagnostico); }
.ag-flag .i { width: 16px; height: 16px; }
.ag-time { display: grid; place-items: center; height: 30px; border-radius: 9px; font: 650 14px/1 ui-monospace, "SF Mono", Menlo, monospace; font-variant-numeric: tabular-nums;
  color: var(--text-2); background: var(--glass-strong); border: 1px solid color-mix(in srgb, var(--text) 16%, transparent); }
.ag-ico { text-align: center; font-size: 17px; line-height: 1; }
.ag-name { display: flex; align-items: baseline; gap: 6px; min-width: 0; overflow: hidden; }
.ag-name b { min-width: 0; overflow: hidden; text-overflow: ellipsis; font-weight: 600; font-size: 15px; }
.ag-name small { flex: none; color: var(--muted); font-size: 12px; }
.ag-row.free { min-height: 46px; }
.ag-row.free .ag-time { color: #fff; background: var(--mark); border-color: transparent; }
.ag-row.free.past .ag-time { background: color-mix(in srgb, var(--mark) 35%, var(--muted)); }
.ag-add { color: var(--accent); font-weight: 600; font-size: 12.5px; opacity: .8; }
.ag-row.requeued { background: var(--requeue-bg); box-shadow: inset 3px 0 0 var(--requeue); }
.ag-row.off .ag-name b { text-decoration: line-through; color: var(--muted); }
.ag-row.now { box-shadow: inset 3px 0 0 var(--ok); }
.ag-row.past:not(.free) { opacity: .75; }
.ag-book:empty { display: none; }
@media (max-width: 420px) {
  .agenda-main.card { padding-left: 10px; padding-right: 10px; }
  .ag-row { grid-template-columns: 16px 54px 20px minmax(0, 1fr); column-gap: 6px; }
  .ag-time { font-size: 13px; }
}
.ag-book .booking { margin: 6px 0 10px; }
.mcancel { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--hairline); }
.appt-sheet .as-head { display: flex; gap: 12px; align-items: center; padding-right: 36px; }
.appt-sheet .as-head .ms-title { padding-right: 0; }
.as-status { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.as-lines { display: grid; gap: 8px; }
.as-line { display: grid; grid-template-columns: 110px 1fr; gap: 8px; font-size: 14px; }
.as-actions { display: grid; gap: 8px; }
.as-actions > * { min-height: 48px; justify-content: center; }
@media (max-width: 860px) {
  .modal-root:has(.appt-sheet) { align-items: end; padding: 12px 0 0; }
  .modal-card:has(.appt-sheet) { width: 100%; padding: 0; border-radius: 22px 22px 0 0; max-height: 88dvh; }
}
@media (max-width: 860px) {
  .appbar .rec-label, .appbar .live-label { display: none; }
  .appbar .rec-pill { gap: 6px; padding: 4px 4px 4px 10px; }
  .appbar .rec-pill button { padding: 6px 8px; }
  .appbar .live-pill { padding: 6px 10px; gap: 6px; }
  .appbar .live-pill .caret { display: none; }
  body:has(.ws-cards[data-mtab="conduta"]) .tl-card, body:has(.ws-cards[data-mtab="arquivos"]) .tl-card { display: none; }
  .agenda-side-fold > summary { display: flex; align-items: center; gap: 8px; min-height: 40px; cursor: pointer; font-weight: 650; list-style: none; }
  .agenda-side-fold > summary::-webkit-details-marker { display: none; }
  .agenda-side-fold > summary small { margin-left: auto; font-weight: 400; max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .agenda-side-fold[open] > summary { margin-bottom: 10px; }
  .agenda-side-fold { display: grid; gap: 10px; }
  .agenda-side.glass.card { padding: 10px 16px; }
}
@media (max-width: 860px) {
  /* iPhone: campo com letra menor que 16px dá zoom ao tocar e desalinha a tela */
  input, select, textarea { font-size: 16px; }
  /* abas no cabeçalho do paciente */
  .ctx-bar > .m-tabs { position: static; flex-basis: 100%; margin: 2px 0 0; padding: 3px; box-shadow: none; }
  .ctx-bar > .m-tabs button { min-height: 34px; }
  .ctx-bar:has(> .m-tabs:not([hidden])) { padding-bottom: 8px; }
  /* com o teclado aberto, a barra de ações sai da frente do campo */
  body:has(input:focus, textarea:focus, select:focus) .m-dock { display: none; }
}
/* nomes longos de remédio quebram a linha em vez de alargar a página */
.items li { min-width: 0; }
.items .item-edit { flex: 1; min-width: 0; white-space: normal; overflow-wrap: anywhere; }
@media (prefers-reduced-motion: reduce) { .m-core, .m-primary, .m-orb:not(.gen) .m-halo { animation: none !important; } .m-halo { transition: none; } }
.ditado-chip { align-self: center; background: var(--accent-soft); color: var(--accent); border-color: transparent; }

/* ---------- Procedimentos (cadastro da clínica) ---------- */
.proc-filters { display: grid; grid-template-columns: minmax(220px, 2fr) repeat(3, minmax(130px, 1fr)); gap: 10px; margin: 6px 0 12px; }
.proc-filters label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--muted); min-width: 0; }
.alpha-bar { display: flex; flex-wrap: wrap; gap: 3px; }
.alpha { padding: 4px 7px; min-width: 26px; font-size: 12px; font-weight: 600; border-radius: 7px; background: transparent; color: var(--muted); border: 1px solid transparent; box-shadow: none; }
.alpha:hover { color: var(--text); border-color: var(--glass-border); }
.alpha.active { background: var(--accent); color: #fff; }
.proc-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.proc-table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--glass-border); white-space: nowrap; }
.proc-table td { padding: 9px 10px; border-bottom: 1px solid color-mix(in srgb, var(--glass-border) 70%, transparent); vertical-align: middle; }
.proc-table td.num { white-space: nowrap; }
.proc-table tr.off td { color: var(--muted); }
.proc-table tbody tr:hover td { background: color-mix(in srgb, var(--accent) 4%, transparent); }
.proc-actions { display: flex; gap: 4px; justify-content: flex-end; align-items: center; }
.link-btn { padding: 0; background: none; border: 0; box-shadow: none; color: var(--accent); font-weight: 550; text-align: left; cursor: pointer; font-size: inherit; }
.link-btn:hover { text-decoration: underline; background: none; }
.src-chip { margin-left: 6px; font-size: 10.5px; padding: 1px 6px; vertical-align: middle; }
.pager { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; justify-content: center; margin-top: 14px; }
.pager button.active { background: var(--accent); color: #fff; border-color: transparent; }
@media (max-width: 760px) {
  .proc-filters { grid-template-columns: 1fr 1fr; }
  .proc-filters label:first-child { grid-column: 1 / -1; }
  .proc-table thead { display: none; }
  .proc-table, .proc-table tbody, .proc-table tr, .proc-table td { display: block; width: 100%; }
  .proc-table tr { padding: 10px 0; border-bottom: 1px solid var(--glass-border); }
  .proc-table td { border: 0; padding: 2px 0; }
  .proc-table td[data-label]:not(:first-child)::before { content: attr(data-label) ": "; color: var(--muted); font-size: 12px; }
  .proc-table td:first-child { font-size: 14.5px; padding-bottom: 4px; }
  .proc-actions { justify-content: flex-start; margin-top: 6px; }
  .proc-table td.empty { display: none; }
}
