/* ============================================================================
   Painel da clínica (Dr. Antônio) — recepção, triagem e agenda
   Identidade: azul-prússia (confiança) + latão (cuidado, alto padrão) sobre porcelana fria.
   Newsreader nos títulos (tom de publicação médica), Hanken Grotesk no uso diário.
   Tokens → base → layout → componentes → páginas. Claro por padrão; escuro por [data-theme] ou pelo sistema.
   ========================================================================== */
:root {
  --bg: #f2f4f6;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --surface-3: #edf0f4;
  --line: #e2e7ec;
  --line-strong: #cdd5de;
  --text: #13212f;
  --text-2: #4e5e6f;
  --text-3: #85929f;
  --primary: #1e3a5f;
  --primary-hover: #152b47;
  --primary-soft: #e5ecf4;
  --primary-ink: #ffffff;
  --accent: #a2762f;
  --accent-soft: #f5ecdc;
  --green: #1d7556;
  --green-soft: #e1f2ea;
  --amber: #a8650a;
  --amber-soft: #fbefd9;
  --red: #bf3a30;
  --red-soft: #fbe5e2;
  --blue: #2e6aa8;
  --blue-soft: #e3edf8;
  --bubble-in: #ffffff;
  --bubble-bot: #e6edf5;
  --bubble-human: #e0f1e9;
  --hero-from: #1e3a5f;
  --hero-to: #2b5079;
  --shadow: 0 1px 2px rgba(19, 33, 47, .05), 0 10px 28px -16px rgba(19, 33, 47, .18);
  --shadow-lg: 0 28px 64px -24px rgba(19, 33, 47, .38);
  --radius: 14px;
  --radius-sm: 9px;
  --side-w: 252px;
  --font: "Hanken Grotesk", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --font-display: "Newsreader", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0c131b; --surface: #121b25; --surface-2: #16212c; --surface-3: #1c2835; --line: #233243; --line-strong: #2f4154;
  --text: #e7edf3; --text-2: #a1b1c1; --text-3: #6e7f90; --primary: #8fb6e3; --primary-hover: #a9c8ec; --primary-soft: rgba(143, 182, 227, .14);
  --primary-ink: #0c131b; --accent: #d6ab69; --accent-soft: rgba(214, 171, 105, .14); --green: #5ccaa0; --green-soft: rgba(92, 202, 160, .13);
  --amber: #e9b158; --amber-soft: rgba(233, 177, 88, .14); --red: #f07a6f; --red-soft: rgba(240, 122, 111, .14); --blue: #82aee6; --blue-soft: rgba(130, 174, 230, .14);
  --bubble-in: #19242f; --bubble-bot: #1d3149; --bubble-human: #183a30; --hero-from: #142b47; --hero-to: #1d3b5e;
  --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 10px 28px -16px rgba(0, 0, 0, .6); --shadow-lg: 0 28px 64px -24px rgba(0, 0, 0, .75);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c131b; --surface: #121b25; --surface-2: #16212c; --surface-3: #1c2835; --line: #233243; --line-strong: #2f4154;
    --text: #e7edf3; --text-2: #a1b1c1; --text-3: #6e7f90; --primary: #8fb6e3; --primary-hover: #a9c8ec; --primary-soft: rgba(143, 182, 227, .14);
    --primary-ink: #0c131b; --accent: #d6ab69; --accent-soft: rgba(214, 171, 105, .14); --green: #5ccaa0; --green-soft: rgba(92, 202, 160, .13);
    --amber: #e9b158; --amber-soft: rgba(233, 177, 88, .14); --red: #f07a6f; --red-soft: rgba(240, 122, 111, .14); --blue: #82aee6; --blue-soft: rgba(130, 174, 230, .14);
    --bubble-in: #19242f; --bubble-bot: #1d3149; --bubble-human: #183a30; --hero-from: #142b47; --hero-to: #1d3b5e;
    --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 10px 28px -16px rgba(0, 0, 0, .6); --shadow-lg: 0 28px 64px -24px rgba(0, 0, 0, .75);
    color-scheme: dark;
  }
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
h1, h2, h3, h4, p { margin: 0; }
h1 { font: 500 30px/1.15 var(--font-display); letter-spacing: -.01em; text-wrap: balance; }
h2 { font-size: 16.5px; font-weight: 650; letter-spacing: -.005em; }
h3 { font-size: 14px; font-weight: 650; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 6px; }
.muted { color: var(--text-2); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.num { font-variant-numeric: tabular-nums lining-nums; }
.eyebrow { font-size: 11.5px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--accent); }
.brand-word { font: 500 21px/1.1 var(--font-display); letter-spacing: -.005em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.logo-mark { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--primary); color: var(--accent); flex: none; }
:root[data-theme="dark"] .logo-mark { background: #1d3b5e; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .logo-mark { background: #1d3b5e; } }
.logo-mark svg { width: 24px; height: 24px; stroke-width: 2.1; stroke: #d6ab69; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--text-3); display: inline-block; flex: none; }
.dot.ok { background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.dot.warn { background: var(--amber); box-shadow: 0 0 0 3px var(--amber-soft); }
.dot.bad { background: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }

/* ---------- campos e botões ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span, .field-label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.field small { color: var(--text-3); font-size: 12px; }
input[type=text], input[type=password], input[type=search], input[type=tel], input[type=date], input[type=time], input[type=number], select, textarea {
  width: 100%; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  padding: 10px 12px; line-height: 1.4; transition: border-color .15s, box-shadow .15s; min-width: 0;
}
textarea { resize: vertical; min-height: 84px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
input::placeholder, textarea::placeholder { color: var(--text-3); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--text);
  border-radius: var(--radius-sm); padding: 9px 14px; font-weight: 600; font-size: 14px; line-height: 1.2; transition: background .15s, border-color .15s, transform .05s; white-space: nowrap; }
.btn:hover { background: var(--surface-3); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-danger { color: var(--red); border-color: color-mix(in srgb, var(--red) 40%, var(--line-strong)); }
.btn-danger:hover { background: var(--red-soft); }
.btn-ok { color: var(--green); border-color: color-mix(in srgb, var(--green) 40%, var(--line-strong)); }
.btn-ok:hover { background: var(--green-soft); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 10px; font-size: 13px; }
.btn svg { width: 17px; height: 17px; }
.icon-btn { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 10px; border: 1px solid transparent; background: transparent; color: var(--text-2); }
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.form-error { color: var(--red); font-size: 13px; background: var(--red-soft); padding: 8px 10px; border-radius: var(--radius-sm); }

.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; line-height: 1.4; background: var(--surface-3); color: var(--text-2); white-space: nowrap; }
.chip i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip-navy { background: var(--primary-soft); color: var(--primary); }
.chip-green { background: var(--green-soft); color: var(--green); }
.chip-amber { background: var(--amber-soft); color: var(--amber); }
.chip-red { background: var(--red-soft); color: var(--red); }
.chip-blue { background: var(--blue-soft); color: var(--blue); }
.chip-brass { background: var(--accent-soft); color: var(--accent); }

.badge { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--red); color: #fff; font-size: 11px; font-weight: 700; display: inline-grid; place-items: center; font-style: normal; }
.badge-amber { background: var(--amber); color: #fff; }

/* ---------- linha de pulso (assinatura) ---------- */
.pulse-line { position: absolute; left: 0; right: 0; width: 100%; height: 120px; overflow: visible; pointer-events: none; }
.pulse-line path { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke;
  stroke-dasharray: 900; stroke-dashoffset: 900; animation: trace 2.4s cubic-bezier(.4, 0, .2, 1) .3s forwards; }
@keyframes trace { to { stroke-dashoffset: 0; } }

/* ---------- login ---------- */
.login { min-height: 100%; display: grid; grid-template-columns: 1.15fr 1fr; background: var(--bg); }
.login-art { position: relative; overflow: hidden; background: radial-gradient(120% 90% at 0% 0%, #2b5079 0%, #1e3a5f 45%, #12263f 100%); color: #f3f6fa; display: grid; place-items: center; padding: 56px; }
.login-art .pulse-line { top: 14%; opacity: .7; }
.login-art .pulse-line path { stroke: #d6ab69; }
.login-art-inner { max-width: 440px; position: relative; display: grid; gap: 16px; }
.login-art .eyebrow { color: #d6ab69; }
.login-art .brand-word { font-size: 52px; white-space: normal; line-height: 1.02; }
.login-art p { font-size: 18px; line-height: 1.55; color: #d5dfea; }
.login-art ul { margin: 12px 0 0; padding: 0; list-style: none; display: grid; gap: 12px; }
.login-art li { padding-left: 28px; position: relative; color: #e3eaf2; }
.login-art li::before { content: ""; position: absolute; left: 0; top: .62em; width: 16px; height: 1.5px; background: #d6ab69; }
.login-card { align-self: center; justify-self: center; width: min(400px, calc(100% - 32px)); display: grid; gap: 16px; padding: 24px 0; }
.login-card .logo-mark { margin-bottom: 4px; }
.login-foot { line-height: 1.45; }

/* ---------- layout do app ---------- */
.app { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); height: 100dvh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 18px 14px; gap: 20px; min-height: 0; }
.side-brand { display: flex; gap: 12px; align-items: center; padding: 4px 6px; min-width: 0; }
.side-brand .brand-word { white-space: normal; font-size: 19px; line-height: 1.12; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.side-sub { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.nav { display: grid; gap: 3px; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: var(--text-2); font-weight: 600; font-size: 14.5px; position: relative; }
.nav a:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--primary-soft); color: var(--primary); }
.nav a.active::before { content: ""; position: absolute; left: -14px; top: 9px; bottom: 9px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.nav .dot { margin-left: auto; }
.nav .short { display: none; }
.side-foot { margin-top: auto; display: grid; gap: 10px; }
.pause-toggle { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 11px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); }
.pause-toggle:hover { border-color: var(--line-strong); }
.switch { width: 36px; height: 21px; border-radius: 999px; background: var(--green); position: relative; flex: none; transition: background .2s; }
.switch i { position: absolute; top: 2px; left: 17px; width: 17px; height: 17px; border-radius: 50%; background: #fff; transition: left .2s; }
.pause-toggle[aria-pressed="true"] .switch { background: var(--line-strong); }
.pause-toggle[aria-pressed="true"] .switch i { left: 2px; }
.pause-text { display: grid; line-height: 1.25; }
.pause-text small { color: var(--text-3); font-size: 12px; }
.side-actions { display: flex; justify-content: space-between; padding: 0 2px; }

.main { min-width: 0; min-height: 0; overflow-y: auto; outline: none; }
.page { padding: 28px 32px 44px; max-width: 1280px; margin: 0 auto; display: grid; gap: 22px; grid-template-columns: minmax(0, 1fr); }
.page > * { min-width: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head p { margin-top: 6px; }
.page-wide { max-width: none; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }
.card-pad { padding: 18px 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 20px 0; flex-wrap: wrap; }
.empty { padding: 34px 20px; text-align: center; color: var(--text-3); display: grid; gap: 6px; justify-items: center; }
.empty strong { color: var(--text-2); font-weight: 650; }

/* ---------- visão geral ---------- */
.hero { position: relative; overflow: hidden; display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; flex-wrap: wrap; padding: 26px 28px;
  border-radius: 18px; background: linear-gradient(125deg, var(--hero-from), var(--hero-to)); color: #f3f6fa; box-shadow: var(--shadow); }
.hero .pulse-line { top: 10px; left: auto; right: 0; width: 44%; height: 80px; opacity: .45; }
.hero .pulse-line path { stroke: #d6ab69; }
.hero > div { position: relative; }
.hero .eyebrow { color: #d6ab69; display: block; margin-bottom: 6px; }
.hero h1 { font-size: 32px; color: #fff; }
.hero p { color: #c9d6e4; margin-top: 6px; }
.hero-status { display: flex; gap: 8px; flex-wrap: wrap; }
.hero .chip { background: rgba(255, 255, 255, .1); color: #e8eef5; border: 1px solid rgba(255, 255, 255, .14); }
.hero .chip.ok i { background: #5ccaa0; } .hero .chip.warn i { background: #e9b158; } .hero .chip.bad i { background: #f07a6f; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.kpi { padding: 16px 18px; display: grid; gap: 4px; align-content: start; }
.kpi .kpi-label { font-size: 13px; color: var(--text-2); font-weight: 600; }
.kpi .kpi-num { font: 500 40px/1.05 var(--font-display); letter-spacing: -.02em; font-variant-numeric: tabular-nums lining-nums; }
.kpi .kpi-num small { font: 600 15px var(--font); color: var(--text-3); margin-left: 4px; letter-spacing: 0; }
.kpi .kpi-note { font-size: 12.5px; color: var(--text-3); }
.kpi-hot { border-color: color-mix(in srgb, var(--amber) 45%, var(--line)); }
.kpi-hot .kpi-num { color: var(--amber); }
.meter { height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; margin-top: 6px; }
.meter i { display: block; height: 100%; background: var(--green); border-radius: 999px; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 14px; }
.grid-2 > * { min-width: 0; }
.alert-band { display: flex; gap: 14px; align-items: center; padding: 14px 18px; border-radius: var(--radius); background: var(--red-soft); color: var(--red); border: 1px solid color-mix(in srgb, var(--red) 35%, transparent); cursor: pointer; }
.alert-band strong { color: var(--red); }
.alert-band .txt { flex: 1; min-width: 0; color: var(--text); }
.alert-band .ic { width: 38px; height: 38px; border-radius: 50%; background: var(--red); color: #fff; display: grid; place-items: center; flex: none; animation: beat 1.6s ease-in-out infinite; }
@keyframes beat { 0%, 100% { transform: scale(1); } 12% { transform: scale(1.12); } 24% { transform: scale(1); } 36% { transform: scale(1.08); } }

/* timeline de hoje */
.timeline { padding: 6px 20px 16px; display: grid; }
.tl-row { display: grid; grid-template-columns: 58px 14px minmax(0, 1fr) auto; gap: 12px; align-items: start; padding: 10px 0; cursor: pointer; border-radius: 8px; }
.tl-row:hover .tl-name { color: var(--primary); }
.tl-time { font: 500 17px/1.2 var(--font-display); font-variant-numeric: tabular-nums lining-nums; text-align: right; padding-top: 1px; }
.tl-rail { position: relative; align-self: stretch; display: grid; justify-items: center; }
.tl-rail::before { content: ""; position: absolute; top: 0; bottom: -10px; width: 1.5px; background: var(--line); }
.tl-row:last-child .tl-rail::before { bottom: 50%; }
.tl-rail b { position: relative; margin-top: 6px; width: 11px; height: 11px; border-radius: 50%; background: var(--surface); border: 2.5px solid var(--primary); }
.tl-row.st-confirmado .tl-rail b { border-color: var(--green); background: var(--green); }
.tl-row.st-realizado .tl-rail b { border-color: var(--text-3); background: var(--text-3); }
.tl-row.st-faltou .tl-rail b, .tl-row.st-cancelado .tl-rail b { border-color: var(--red); }
.tl-row.past { opacity: .6; }
.tl-row.now .tl-time { color: var(--accent); }
.tl-name { font-weight: 650; }
.tl-sub { font-size: 13px; color: var(--text-2); }

.chart { padding: 8px 20px 18px; }
.chart svg { width: 100%; height: 190px; overflow: visible; stroke: none; stroke-width: 0; }
.chart .legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-2); padding-top: 6px; }
.chart .legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; background: var(--c); }
.bars { padding: 10px 20px 18px; display: grid; gap: 12px; }
.bar-row { display: grid; gap: 5px; }
.bar-row .bar-top { display: flex; justify-content: space-between; gap: 10px; font-size: 13.5px; }
.bar-track { height: 7px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; background: var(--primary); }
.ins-list { display: flex; gap: 6px; flex-wrap: wrap; padding: 0 20px 18px; }
.wait-list { display: grid; padding-bottom: 6px; }
.wait-item { display: flex; gap: 14px; align-items: center; padding: 13px 20px; border-top: 1px solid var(--line); cursor: pointer; }
.wait-item:first-child { border-top: none; }
.wait-item:hover { background: var(--surface-2); }
.wait-item .who { font-weight: 650; }
.wait-item .what { color: var(--text-2); font-size: 13.5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; flex: none; font-weight: 700; font-size: 14.5px; background: var(--primary-soft); color: var(--primary); }
.avatar.sm { width: 34px; height: 34px; font-size: 13px; }
.avatar.alert { background: var(--red-soft); color: var(--red); }

/* ---------- atendimentos (conversas) ---------- */
.conv { display: grid; grid-template-columns: 330px minmax(0, 1fr) 340px; height: 100dvh; }
.conv-list { border-right: 1px solid var(--line); background: var(--surface); display: flex; flex-direction: column; min-height: 0; }
.conv-list-head { padding: 18px 16px 10px; display: grid; gap: 12px; }
.conv-list-head h2 { font: 500 22px var(--font-display); }
.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.filter { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 4px 11px; font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.filter.active { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.conv-items { overflow-y: auto; flex: 1; }
.conv-item { display: flex; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); cursor: pointer; align-items: flex-start; width: 100%; background: transparent; border-left: 0; border-right: 0; border-top: 0; text-align: left; }
.conv-item:hover { background: var(--surface-2); }
.conv-item.active { background: var(--primary-soft); }
.conv-item .body { min-width: 0; flex: 1; display: grid; gap: 2px; }
.conv-item .row { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.conv-item .name { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-item .time { font-size: 12px; color: var(--text-3); flex: none; }
.conv-item .last { font-size: 13.5px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-item .tags { display: flex; gap: 6px; margin-top: 4px; flex-wrap: wrap; }
.chat { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); }
.chat-head { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--line); background: var(--surface); flex-wrap: wrap; }
.chat-head .who { min-width: 0; flex: 1 1 200px; }
.chat-head .who strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-head .actions { display: flex; gap: 8px; flex-wrap: wrap; margin-left: auto; }
.back-btn { display: none; }
.ficha-toggle, .ficha-close { display: none; }
.msgs { flex: 1; overflow-y: auto; padding: 18px 20px; display: flex; flex-direction: column; gap: 8px; }
.day-sep { align-self: center; font-size: 12px; color: var(--text-3); background: var(--surface-3); border-radius: 999px; padding: 2px 12px; margin: 8px 0 2px; }
.bubble { max-width: min(560px, 82%); padding: 8px 12px 6px; border-radius: 14px; box-shadow: 0 1px 1px rgba(19, 33, 47, .06); white-space: pre-wrap; word-break: break-word; line-height: 1.45; }
.bubble .meta { display: flex; gap: 8px; justify-content: space-between; align-items: baseline; font-size: 11.5px; color: var(--text-3); margin-top: 3px; }
.bubble .tag { font-weight: 700; letter-spacing: .04em; text-transform: uppercase; font-size: 10.5px; }
.bubble.in { align-self: flex-start; background: var(--bubble-in); border-bottom-left-radius: 4px; }
.bubble.bot { align-self: flex-end; background: var(--bubble-bot); border-bottom-right-radius: 4px; }
.bubble.bot .tag { color: var(--primary); }
.bubble.human { align-self: flex-end; background: var(--bubble-human); border-bottom-right-radius: 4px; }
.bubble.human .tag { color: var(--green); }
.composer { border-top: 1px solid var(--line); background: var(--surface); padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); display: grid; gap: 8px; }
.composer-row { display: flex; gap: 10px; align-items: flex-end; }
.composer textarea { min-height: 44px; max-height: 140px; resize: none; flex: 1; min-width: 0; }
.composer-row .btn { flex: none; }
.composer .hint { font-size: 12.5px; color: var(--text-3); }
.paused-banner { display: flex; gap: 10px; align-items: center; padding: 8px 14px; background: var(--amber-soft); color: var(--amber); font-size: 13.5px; font-weight: 600; border-bottom: 1px solid var(--line); }
.alert-banner { display: flex; gap: 10px; align-items: center; padding: 9px 14px; background: var(--red-soft); color: var(--red); font-size: 13.5px; font-weight: 600; border-bottom: 1px solid var(--line); }
.ficha { border-left: 1px solid var(--line); background: var(--surface); overflow-y: auto; padding: 18px; display: grid; gap: 14px; align-content: start; }
.ficha h2 { font: 500 21px/1.2 var(--font-display); }
.ficha .summary-box { background: var(--primary-soft); border-radius: var(--radius-sm); padding: 12px 14px; font-size: 14px; }
.ficha .summary-box strong { display: block; font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--primary); margin-bottom: 4px; }
.ficha .section-t { font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-3); font-weight: 700; margin-top: 4px; }
.ficha .two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.appt-mini { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); cursor: pointer; text-align: left; width: 100%; }
.appt-mini:hover { border-color: var(--line-strong); }
.appt-mini .when { font: 500 15px/1.15 var(--font-display); font-variant-numeric: tabular-nums lining-nums; }
.conv-empty { display: grid; place-items: center; color: var(--text-3); text-align: center; padding: 24px; grid-column: 2 / 4; }
.conv-empty h2 { font: 500 24px var(--font-display); color: var(--text); margin-bottom: 6px; }

/* ---------- quadro de triagem ---------- */
.board { display: grid; grid-template-columns: repeat(5, minmax(200px, 1fr)); gap: 14px; align-items: start; overflow-x: auto; padding-bottom: 8px; }
.col { background: var(--surface-3); border-radius: var(--radius); padding: 10px; display: grid; gap: 10px; align-content: start; min-height: 220px; border: 2px solid transparent; }
.col.drop { border-color: var(--primary); background: var(--primary-soft); }
.col-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 6px; }
.col-head h3 { display: flex; align-items: center; gap: 8px; }
.col-count { font-size: 12.5px; font-weight: 700; color: var(--text-2); background: var(--surface); border-radius: 999px; padding: 1px 9px; }
.lead-card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: grid; gap: 8px; cursor: grab; box-shadow: var(--shadow); text-align: left; width: 100%; }
.lead-card:hover { border-color: var(--line-strong); }
.lead-card.dragging { opacity: .5; }
.lead-card .top { display: flex; gap: 10px; align-items: center; }
.lead-card .name { font-weight: 650; line-height: 1.25; }
.lead-card .interest { font-size: 13.5px; color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.lead-card .meta-row { display: flex; gap: 6px; flex-wrap: wrap; }
.lead-card .foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.urg-alta { box-shadow: inset 3px 0 0 var(--red), var(--shadow); }

/* ---------- agenda ---------- */
.agenda-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.agenda-bar .range { font: 500 20px var(--font-display); min-width: 210px; }
.agenda-bar .spacer { flex: 1; }
.agenda-bar select { width: auto; min-width: 180px; }
.agenda-stats { display: flex; gap: 10px; flex-wrap: wrap; }
.week { display: grid; grid-template-columns: repeat(7, minmax(150px, 1fr)); gap: 10px; overflow-x: auto; padding-bottom: 6px; }
.day { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; min-height: 320px; min-width: 0; }
.day.today { border-color: color-mix(in srgb, var(--accent) 60%, var(--line)); box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent), var(--shadow); }
.day.closed { background: var(--surface-2); }
.day-head { padding: 10px 12px 8px; border-bottom: 1px solid var(--line); display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.day-head .dname { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); }
.day.today .day-head .dname { color: var(--accent); }
.day-head .dnum { font: 500 24px/1 var(--font-display); font-variant-numeric: tabular-nums lining-nums; }
.day-body { padding: 8px; display: grid; gap: 6px; align-content: start; flex: 1; }
.day-add { margin: 0 8px 8px; border: 1px dashed var(--line-strong); background: transparent; border-radius: 9px; padding: 6px; font-size: 12.5px; color: var(--text-3); font-weight: 600; }
.day-add:hover { color: var(--primary); border-color: var(--primary); }
.appt { text-align: left; width: 100%; border: 1px solid var(--line); border-left: 3px solid var(--primary); background: var(--surface-2); border-radius: 8px; padding: 7px 9px; display: grid; gap: 1px; }
.appt:hover { border-color: var(--line-strong); border-left-color: var(--primary); background: var(--surface); }
.appt .t { font-weight: 700; font-size: 12.5px; font-variant-numeric: tabular-nums; color: var(--text-2); display: flex; justify-content: space-between; gap: 6px; }
.appt .p { font-weight: 650; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appt .d { font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appt.st-confirmado { border-left-color: var(--green); }
.appt.st-realizado { border-left-color: var(--text-3); opacity: .75; }
.appt.st-faltou { border-left-color: var(--red); }
.appt.st-cancelado { border-left-color: var(--line-strong); opacity: .55; text-decoration: line-through; text-decoration-color: var(--text-3); }
.appt .bell { width: 13px; height: 13px; color: var(--accent); }
.legend-row { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-2); }
.legend-row span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; background: var(--c); }

/* modal */
.modal-back { position: fixed; inset: 0; background: rgba(9, 17, 27, .55); display: grid; place-items: center; z-index: 60; padding: 16px; animation: fade .15s ease-out; }
.modal { background: var(--surface); border-radius: 16px; padding: 22px; width: min(440px, 100%); display: grid; gap: 14px; box-shadow: var(--shadow-lg); max-height: calc(100dvh - 32px); overflow-y: auto; }
.modal h2 { font: 500 22px/1.2 var(--font-display); }
.modal-wide { width: min(620px, 100%); }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.modal-actions .left { margin-right: auto; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid-3 { display: grid; grid-template-columns: 1.2fr 1fr .8fr; gap: 12px; }
.span-2 { grid-column: 1 / -1; }
.status-actions { display: flex; gap: 8px; flex-wrap: wrap; padding: 12px; background: var(--surface-2); border-radius: 10px; border: 1px solid var(--line); }
.preview-box { white-space: pre-wrap; background: var(--bubble-bot); border-radius: 12px; padding: 12px 14px; font-size: 14px; }
@keyframes fade { from { opacity: 0; } }

/* ---------- configuração + simulador ---------- */
.bot-layout { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 18px; align-items: start; }
.form-card { display: grid; gap: 18px; padding: 20px; }
.form-card h2 { font: 500 20px var(--font-display); }
.tones { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.tone { border: 1.5px solid var(--line-strong); background: var(--surface); border-radius: 12px; padding: 12px; text-align: left; display: grid; gap: 3px; }
.tone strong { font-size: 14px; }
.tone small { color: var(--text-3); font-size: 12.5px; line-height: 1.35; }
.tone[aria-pressed="true"] { border-color: var(--primary); background: var(--primary-soft); }
.hours { display: grid; gap: 8px; }
.hours-row { display: grid; grid-template-columns: 96px 1fr; gap: 10px; align-items: center; }
.hours-row label { font-weight: 600; color: var(--text-2); font-size: 14px; text-transform: capitalize; }
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.check input { margin-top: 4px; width: 17px; height: 17px; accent-color: var(--primary); flex: none; }
.savebar { position: sticky; bottom: 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(8px); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg); flex-wrap: wrap; }
.sim { position: sticky; top: 20px; display: flex; flex-direction: column; height: min(720px, calc(100dvh - 40px)); overflow: hidden; }
.sim-head { padding: 14px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; }
.sim-head .who { flex: 1; min-width: 0; }
.sim-opt { padding: 8px 16px; border-bottom: 1px solid var(--line); font-size: 13px; background: var(--surface-2); }
.sim .msgs { background: var(--bg); padding: 14px; }
.sim .triage { align-self: flex-end; max-width: 92%; font-size: 12px; background: var(--surface); border: 1px dashed var(--line-strong); border-radius: 10px; padding: 8px 10px; color: var(--text-2); display: grid; gap: 3px; }
.sim .triage b { color: var(--text); }
.sim .composer { padding: 10px 12px; }
.typing { display: inline-flex; gap: 4px; padding: 10px 14px; align-self: flex-end; background: var(--bubble-bot); border-radius: 14px; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--primary); opacity: .35; animation: blink 1.1s infinite; }
.typing i:nth-child(2) { animation-delay: .18s; } .typing i:nth-child(3) { animation-delay: .36s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.sim-suggest { display: flex; gap: 6px; flex-wrap: wrap; padding: 0 12px 10px; }
.sim-suggest button { font-size: 12.5px; border: 1px solid var(--line-strong); background: var(--surface); border-radius: 999px; padding: 4px 11px; color: var(--text-2); }
.sim-suggest button:hover { border-color: var(--primary); color: var(--primary); }

/* ---------- conexão ---------- */
.conn-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 18px; align-items: start; }
.conn-state { display: flex; gap: 16px; align-items: center; padding: 22px; flex-wrap: wrap; }
.conn-state .big { width: 54px; height: 54px; border-radius: 16px; display: grid; place-items: center; background: var(--green-soft); color: var(--green); }
.conn-state .big svg { width: 28px; height: 28px; }
.conn-state.off .big { background: var(--amber-soft); color: var(--amber); }
.qr-box { display: grid; gap: 14px; justify-items: center; padding: 22px; text-align: center; }
.qr-box svg.qr { width: min(270px, 100%); height: auto; border-radius: 12px; border: 1px solid var(--line); background: #fff; padding: 0; }
/* o svg global (ícones) põe fill:none e stroke 1.8 — no QR isso engorda cada módulo e o código fica ilegível */
.qr-box svg.qr, .qr-box svg.qr * { stroke: none !important; }
.qr-box svg.qr rect { fill: #fff !important; }
.qr-box svg.qr path { fill: #000 !important; }
.qr-wait { width: 270px; max-width: 100%; aspect-ratio: 1; border-radius: 12px; border: 1px dashed var(--line-strong); display: grid; place-items: center; color: var(--text-3); }
.steps { margin: 0; padding-left: 20px; display: grid; gap: 8px; color: var(--text-2); }
.pair-code { font: 700 32px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .14em; color: var(--primary); background: var(--primary-soft); padding: 14px 18px; border-radius: 12px; }

/* ---------- avisos ---------- */
.toasts { position: fixed; right: 18px; bottom: 18px; display: grid; gap: 8px; z-index: 70; pointer-events: none; }
.toast { background: var(--text); color: var(--bg); padding: 11px 16px; border-radius: 12px; box-shadow: var(--shadow-lg); font-weight: 600; font-size: 14px; max-width: min(380px, calc(100vw - 36px)); animation: toast-in .2s ease-out; pointer-events: auto; }
.toast.err { background: var(--red); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
.skeleton { background: linear-gradient(90deg, var(--surface-3), var(--surface-2), var(--surface-3)); background-size: 200% 100%; animation: sk 1.3s infinite; border-radius: 8px; min-height: 18px; }
@keyframes sk { to { background-position: -200% 0; } }

/* ---------- responsivo ---------- */
@media (max-width: 1240px) {
  .conv { grid-template-columns: 300px minmax(0, 1fr); }
  .ficha { display: none; }
  .ficha-toggle, .ficha-close { display: inline-flex; }
  .ficha.open { display: grid; position: fixed; inset: 0 0 0 auto; width: min(380px, 100%); z-index: 40; box-shadow: var(--shadow-lg); }
  .bot-layout, .conn-grid { grid-template-columns: 1fr; }
  .sim { position: static; height: 600px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .conv-empty { grid-column: 2; }
}
@media (max-width: 820px) {
  .login { grid-template-columns: 1fr; }
  .login-art { display: none; }
  .app { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) auto; }
  .sidebar { grid-row: 2; flex-direction: row; padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--line); gap: 0; justify-content: space-around; }
  .side-brand, .side-foot { display: none; }
  .nav { display: flex; width: 100%; justify-content: space-around; min-width: 0; }
  .nav a { flex-direction: column; gap: 3px; font-size: 10px; padding: 6px 1px; flex: 1 1 0; min-width: 0; align-items: center; text-align: center; }
  .nav a.active::before { display: none; }
  .nav a .badge, .nav a .dot { position: absolute; top: 2px; right: calc(50% - 20px); margin: 0; }
  .nav a span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  .nav .full { display: none; } .nav .short { display: inline; }
  .hero .pulse-line { display: none; }
  .alert-band { flex-wrap: wrap; } .alert-band .txt { flex-basis: calc(100% - 60px); }
  .page { padding: 18px 16px 28px; }
  h1 { font-size: 26px; }
  .grid-2, .form-grid, .form-grid-3, .tones, .ficha .two { grid-template-columns: minmax(0, 1fr); }
  .kpi .kpi-num { font-size: 34px; }
  .hero { padding: 20px; }
  .hero h1 { font-size: 26px; }
  .conv { grid-template-columns: minmax(0, 1fr); height: calc(100dvh - 62px); }
  .conv .chat, .conv .conv-empty { display: none; }
  .conv.show-chat .conv-list { display: none; }
  .conv.show-chat .chat { display: flex; }
  .back-btn { display: grid; }
  .board { grid-template-columns: repeat(5, 82%); scroll-snap-type: x mandatory; }
  .col { scroll-snap-align: start; }
  .week { grid-template-columns: minmax(0, 1fr); }
  .day { min-height: 0; }
  .day.empty-day .day-body { display: none; }
  .agenda-bar .range { min-width: 0; font-size: 18px; }
  .agenda-bar select { min-width: 0; flex: 1; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
  .pulse-line path { stroke-dashoffset: 0; }
}
