/* =====================================================================
   Gestão da Clínica — tema
   ===================================================================== */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --text: #111827;
  --text-2: #374151;
  --muted: #6b7280;
  --border: #e5e7eb;
  --border-strong: #d1d5db;

  --primary: #0f766e;
  --primary-hover: #115e59;
  --primary-soft: #e6f4f2;
  --primary-text: #0f5f58;

  --danger: #b42318;
  --danger-soft: #fef3f2;
  --warn: #b54708;
  --warn-soft: #fffaeb;
  --ok: #067647;
  --ok-soft: #ecfdf3;
  --info: #175cd3;
  --info-soft: #eff8ff;

  --side-bg: #0b1220;
  --side-text: #cbd5e1;
  --side-muted: #64748b;
  --side-hover: #131c2e;
  --side-active: #1b2740;

  --wa-in: #ffffff;
  --wa-out: #e7f5f1;
  --chat-bg: #f3f4f6;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-lg: 0 20px 40px -12px rgba(16, 24, 40, .25);
  --focus: 0 0 0 3px rgba(15, 118, 110, .18);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0b0f17; --surface: #121826; --surface-2: #161d2d; --text: #e5e7eb; --text-2: #cbd5e1; --muted: #8b95a7;
    --border: #232c3d; --border-strong: #2f3a4f;
    --primary: #2bb3a3; --primary-hover: #36c7b6; --primary-soft: #11302d; --primary-text: #5fd6c8;
    --danger: #f97066; --danger-soft: #2d1414; --warn: #fdb022; --warn-soft: #2b2110; --ok: #47cd89; --ok-soft: #0f2a1d;
    --info: #84caff; --info-soft: #102236;
    --side-bg: #070b12; --side-hover: #0f1625; --side-active: #16203a;
    --wa-in: #161d2d; --wa-out: #12322e; --chat-bg: #0e1420;
    --shadow: 0 1px 3px rgba(0, 0, 0, .4); --shadow-lg: 0 20px 40px -12px rgba(0, 0, 0, .6);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 14px/1.5 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv11", "ss01";
}
.hidden { display: none !important; }
h1 { font-size: 22px; font-weight: 650; letter-spacing: -.02em; margin: 0; }
h2 { font-size: 15px; font-weight: 600; margin: 0 0 14px; letter-spacing: -.01em; }
h3 { font-size: 13px; font-weight: 600; margin: 18px 0 8px; color: var(--text-2); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12.5px; }
code { background: var(--surface-2); border: 1px solid var(--border); padding: 1px 6px; border-radius: 6px; }
.muted { color: var(--muted); }
.error { color: var(--danger); }
.small { font-size: 12px; }
.icon { width: 18px; height: 18px; flex-shrink: 0; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon.sm { width: 15px; height: 15px; }

/* ---------- Layout ---------- */
.layout { display: flex; height: 100vh; }
.sidebar {
  width: 248px; background: var(--side-bg); color: var(--side-text);
  display: flex; flex-direction: column; padding: 18px 12px; flex-shrink: 0; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 20px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(135deg, #14b8a6, #0f766e); color: #fff; font-weight: 700;
}
.brand-name { color: #fff; font-weight: 600; font-size: 15px; line-height: 1.2; }
.brand-sub { color: var(--side-muted); font-size: 11.5px; }
nav { display: flex; flex-direction: column; gap: 1px; flex: 1; }
.nav-group { color: var(--side-muted); font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; padding: 16px 12px 6px; }
nav a {
  display: flex; align-items: center; gap: 11px; padding: 8px 12px; border-radius: 8px;
  color: var(--side-text); text-decoration: none; font-weight: 500; font-size: 13.5px;
}
nav a:hover { background: var(--side-hover); color: #fff; text-decoration: none; }
nav a.active { background: var(--side-active); color: #fff; box-shadow: inset 2px 0 0 #2dd4bf; }
nav a .icon { opacity: .85; }
.badge { margin-left: auto; background: #ef4444; color: #fff; border-radius: 999px; padding: 0 7px; font-size: 11px; font-weight: 600; line-height: 18px; }
.side-foot { border-top: 1px solid #1e293b; margin-top: 12px; padding-top: 12px; }
.side-foot button { width: 100%; justify-content: flex-start; color: var(--side-text); }
.side-foot button:hover { background: var(--side-hover); color: #fff; }

main { flex: 1; overflow: auto; min-width: 0; }
.page { max-width: 1320px; margin: 0 auto; padding: 28px 32px 48px; }

/* ---------- Page header / toolbar ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 20px; }
.toolbar .spacer { flex: 1; }
.page-head { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head .titles { flex: 1; min-width: 220px; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm); }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.card-head h2 { margin: 0; flex: 1; }
.grid { display: grid; gap: 16px; }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); }
.stat { position: relative; }
.stat .label { color: var(--muted); font-size: 12.5px; font-weight: 500; }
.stat .value { font-size: 26px; font-weight: 650; letter-spacing: -.02em; margin-top: 6px; }
.stat .stat-icon { position: absolute; top: 18px; right: 18px; width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px; justify-content: center;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2);
  border-radius: var(--radius-sm); padding: 8px 14px; cursor: pointer; font: inherit; font-weight: 500;
  white-space: nowrap; box-shadow: var(--shadow-sm); transition: background .12s, border-color .12s, color .12s;
  text-decoration: none;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:focus-visible { outline: none; box-shadow: var(--focus); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.small { padding: 5px 10px; font-size: 12.5px; border-radius: 7px; }
.btn:disabled { opacity: .6; cursor: wait; }
.btn-block { width: 100%; }

/* ---------- Forms ---------- */
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: 8px 11px; width: 100%; transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: var(--focus); }
textarea { resize: vertical; min-height: 76px; }
label { display: block; font-size: 12.5px; font-weight: 500; color: var(--text-2); margin-bottom: 12px; }
label > input, label > select, label > textarea { margin-top: 5px; }
label.check { display: flex; gap: 9px; align-items: center; font-weight: 400; font-size: 13.5px; color: var(--text); }
label.check input { width: 16px; height: 16px; margin: 0; accent-color: var(--primary); }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0 14px; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 10px; }
.hint { font-size: 12px; color: var(--muted); margin: -6px 0 12px; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 16px 4px; margin: 0 0 14px; }
legend { font-size: 12px; font-weight: 600; color: var(--muted); padding: 0 6px; text-transform: uppercase; letter-spacing: .05em; }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 11.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; background: var(--surface-2); }
tbody tr:last-child td { border-bottom: none; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--surface-2); }
.table-wrap { overflow-x: auto; }
.card.table-wrap { padding: 0; }
.card.table-wrap > h2 { padding: 18px 20px 0; }

/* ---------- Pills ---------- */
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 500; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); white-space: nowrap; text-transform: capitalize; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .7; }
.pill.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.pill.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pill.danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.pill.info { background: var(--info-soft); color: var(--info); border-color: transparent; }
.pill.plain::before { display: none; }
.money { font-variant-numeric: tabular-nums; }
.money.neg { color: var(--danger); font-weight: 600; }
.money.pos { color: var(--ok); font-weight: 600; }

/* ---------- Modal / toast ---------- */
.modal { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); backdrop-filter: blur(2px); display: flex; align-items: flex-start; justify-content: center; padding: 48px 16px; overflow: auto; z-index: 20; }
.modal-box { width: 100%; max-width: 640px; box-shadow: var(--shadow-lg); padding: 24px; }
.modal-box.wide { max-width: 1000px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal-head h2 { margin: 0; font-size: 17px; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #111827; color: #f9fafb; padding: 11px 18px; border-radius: 10px; z-index: 30; max-width: 90vw; box-shadow: var(--shadow-lg); font-weight: 500; }
.toast.err { background: var(--danger); color: #fff; }

/* ---------- Login ---------- */
.login { position: fixed; inset: 0; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-art {
  background: radial-gradient(1200px 600px at -10% -10%, #14b8a6 0%, transparent 55%), linear-gradient(160deg, #0b1220 0%, #0f2a2a 100%);
  color: #e2e8f0; padding: 56px; display: flex; flex-direction: column; justify-content: space-between;
}
.login-art h2 { font-size: 30px; line-height: 1.2; color: #fff; letter-spacing: -.02em; max-width: 420px; margin: 0 0 12px; }
.login-art p { color: #94a3b8; max-width: 420px; }
.login-art ul { list-style: none; padding: 0; margin: 24px 0 0; display: grid; gap: 10px; color: #cbd5e1; }
.login-art li { display: flex; gap: 10px; align-items: center; }
.login-side { display: grid; place-items: center; padding: 24px; background: var(--bg); }
.login-card { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 12px; padding: 32px; }
.login-card h1 { font-size: 20px; }

/* ---------- WhatsApp ---------- */
.wa { display: grid; grid-template-columns: 320px 1fr 340px; gap: 16px; height: calc(100vh - 150px); min-height: 520px; }
.wa > .card { padding: 0; display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.wa-search { padding: 12px; border-bottom: 1px solid var(--border); }
.wa-list { overflow: auto; flex: 1; }
.wa-chat-item { padding: 12px 14px; border-bottom: 1px solid var(--border); cursor: pointer; display: flex; gap: 11px; align-items: center; }
.wa-chat-item:hover { background: var(--surface-2); }
.wa-chat-item.active { background: var(--primary-soft); }
.wa-chat-item .body { min-width: 0; flex: 1; }
.wa-chat-item .top { display: flex; justify-content: space-between; gap: 6px; }
.wa-chat-item .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wa-chat-item .last { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-weight: 600; font-size: 13px; background: var(--primary-soft); color: var(--primary-text); flex-shrink: 0; }
.wa-head { padding: 12px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.wa-msgs { flex: 1; overflow: auto; padding: 18px; display: flex; flex-direction: column; gap: 6px; background: var(--chat-bg); }
.msg { max-width: 72%; padding: 8px 12px; border-radius: 12px 12px 12px 4px; background: var(--wa-in); border: 1px solid var(--border); white-space: pre-wrap; word-wrap: break-word; box-shadow: var(--shadow-sm); }
.msg.me { align-self: flex-end; background: var(--wa-out); border-radius: 12px 12px 4px 12px; border-color: transparent; }
.msg .time { font-size: 10.5px; color: var(--muted); text-align: right; margin-top: 3px; }
.wa-compose { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--border); align-items: flex-end; }
.wa-compose textarea { min-height: 42px; height: 42px; }
.wa-side { padding: 18px; overflow: auto; }
.suggestion { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; cursor: pointer; white-space: pre-wrap; transition: border-color .12s, background .12s; }
.suggestion:hover { border-color: var(--primary); background: var(--primary-soft); }
.suggestion b { display: block; font-size: 11px; color: var(--primary); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 3px; }
.qr { text-align: center; padding: 40px 20px; }
.qr img { width: 264px; height: 264px; background: #fff; padding: 10px; border-radius: 12px; border: 1px solid var(--border); }
.empty { text-align: center; padding: 36px 16px; color: var(--muted); }
.empty .icon { width: 30px; height: 30px; margin-bottom: 8px; opacity: .6; }

/* ---------- Agenda ---------- */
.day { margin-bottom: 18px; }
.day h3 { margin: 0 0 8px; text-transform: capitalize; font-size: 13px; color: var(--muted); }
.day.today h3 { color: var(--primary); }
.appt { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border: 1px solid var(--border); border-left: 3px solid var(--primary); border-radius: 10px; margin-bottom: 6px; background: var(--surface); flex-wrap: wrap; box-shadow: var(--shadow-sm); }
.appt .time { font-weight: 600; min-width: 100px; font-variant-numeric: tabular-nums; }
.appt .who { flex: 1; min-width: 160px; }
.appt.gcal { border-left-color: var(--border-strong); background: var(--surface-2); box-shadow: none; }
.appt select { width: auto; padding: 4px 8px; font-size: 12.5px; }

/* ---------- Assistente ---------- */
.chat { display: flex; flex-direction: column; height: calc(100vh - 76px); }
.chat-log { flex: 1; overflow: auto; display: flex; flex-direction: column; gap: 12px; padding: 20px; }
.bubble { max-width: 78%; padding: 11px 14px; border-radius: 14px; white-space: pre-wrap; line-height: 1.55; }
.bubble.user { align-self: flex-end; background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.bubble.bot { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.bubble .actions { margin-top: 8px; font-size: 12px; color: var(--muted); border-top: 1px dashed var(--border); padding-top: 6px; }
.chat-input { display: flex; gap: 8px; margin-top: 12px; align-items: flex-end; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 16px; flex-wrap: wrap; }
.tabs button { border: none; background: none; padding: 9px 14px; cursor: pointer; font: inherit; font-weight: 500; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ---------- Integrações / documentação ---------- */
.integ-head { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 16px; }
.integ-logo { width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--border); flex-shrink: 0; }
.integ-head h2 { margin: 0 0 2px; }
.integ-head p { margin: 0; color: var(--muted); font-size: 13px; }
.steps { counter-reset: step; list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 10px; }
.steps > li { counter-increment: step; position: relative; padding-left: 36px; color: var(--text-2); }
.steps > li::before { content: counter(step); position: absolute; left: 0; top: -1px; width: 24px; height: 24px; border-radius: 50%; background: var(--primary-soft); color: var(--primary-text); font-weight: 600; font-size: 12px; display: grid; place-items: center; }
.steps b { color: var(--text); }
.copy-field { display: flex; gap: 6px; align-items: center; margin: 6px 0 14px; }
.copy-field input { font-family: "JetBrains Mono", ui-monospace, Consolas, monospace; font-size: 12.5px; background: var(--surface-2); }
.callout { border: 1px solid var(--border); border-left: 3px solid var(--info); background: var(--info-soft); border-radius: 8px; padding: 10px 14px; margin: 12px 0; font-size: 13px; color: var(--text-2); }
.callout.warn { border-left-color: var(--warn); background: var(--warn-soft); }
.divider { height: 1px; background: var(--border); margin: 18px 0; }

.docs { display: grid; grid-template-columns: 220px 1fr; gap: 32px; align-items: start; }
.docs-toc { position: sticky; top: 24px; display: flex; flex-direction: column; gap: 2px; }
.docs-toc a { color: var(--muted); padding: 6px 10px; border-radius: 6px; font-size: 13px; }
.docs-toc a:hover { background: var(--surface); color: var(--text); text-decoration: none; }
.docs-toc .toc-group { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 12px 10px 4px; }
.doc-section { margin-bottom: 20px; scroll-margin-top: 20px; }
.doc-section h2 { font-size: 17px; display: flex; align-items: center; gap: 10px; }
.doc-section p, .doc-section li { color: var(--text-2); line-height: 1.65; }
.doc-section table td, .doc-section table th { padding: 8px 12px; }

@media (max-width: 1200px) {
  .wa { grid-template-columns: 280px 1fr; height: auto; }
  .wa > .card { min-height: 460px; }
  .wa-side-card { grid-column: 1 / -1; }
}
@media (max-width: 900px) {
  .login { grid-template-columns: 1fr; }
  .login-art { display: none; }
  .docs { grid-template-columns: 1fr; }
  .docs-toc { position: static; flex-direction: row; flex-wrap: wrap; }
}
@media (max-width: 760px) {
  .layout { flex-direction: column; height: auto; }
  .sidebar { width: 100%; flex-direction: row; overflow-x: auto; padding: 8px; align-items: center; }
  .brand, .nav-group, .side-foot { display: none; }
  nav { flex-direction: row; }
  nav a span { display: none; }
  .page { padding: 16px; }
  .wa { grid-template-columns: 1fr; }
  .bubble { max-width: 92%; }
}
