/* ============================================================
   Fluxo · Gestão Odontológica — estilos
   ============================================================ */

:root {
  /* Identidade ABAH Odontologia Integrada — bege/creme + dourado champanhe */
  --surface-1: #fbf9f3;      /* cartões / superfície de gráfico */
  --page: #f1ecdf;           /* plano de fundo creme */
  --text-primary: #211b10;
  --text-secondary: #5c5340;
  --text-muted: #8f8672;
  --grid-line: #e7e0cd;
  --baseline: #cec4a9;
  --border: rgba(33, 27, 16, 0.10);
  --border-strong: rgba(33, 27, 16, 0.18);

  --series-receita: #a37c28; /* dourado — receitas */
  --series-despesa: #00919e; /* petróleo — despesas */
  --seq-bar: #a37c28;

  --good: #0ca30c;
  --good-text: #006300;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --critical-text: #b02a2a;

  --accent: #8a6b2c;
  --accent-hover: #745a24;
  --accent-soft: rgba(163, 124, 40, 0.12);
  --accent-contrast: #ffffff;

  /* Barra lateral escura — remete ao letreiro iluminado da fachada */
  --sidebar-bg: #241e14;
  --sidebar-text: #ede4cd;
  --sidebar-muted: #a5987b;
  --sidebar-active: #d9b56a;
  --sidebar-active-bg: rgba(217, 181, 106, 0.12);
  --sidebar-border: rgba(237, 228, 205, 0.10);

  --shadow: 0 1px 2px rgba(33,27,16,0.05), 0 4px 16px rgba(33,27,16,0.06);
  --shadow-lg: 0 8px 40px rgba(33,27,16,0.22);
  --radius: 12px;
}

:root[data-theme="dark"] {
  --surface-1: #1e1a15;
  --page: #14110d;
  --text-primary: #f5efe2;
  --text-secondary: #cfc4ab;
  --text-muted: #978d78;
  --grid-line: #2f2a22;
  --baseline: #3f382c;
  --border: rgba(245, 239, 226, 0.10);
  --border-strong: rgba(245, 239, 226, 0.18);

  --series-receita: #b58c3e;
  --series-despesa: #1a97a6;
  --seq-bar: #b58c3e;

  --good: #0ca30c;
  --good-text: #4db34d;
  --critical-text: #e66767;

  --accent: #c9a55a;
  --accent-hover: #d9b56a;
  --accent-soft: rgba(201, 165, 90, 0.16);
  --accent-contrast: #241d10;

  --shadow: 0 1px 2px rgba(0,0,0,0.3), 0 4px 16px rgba(0,0,0,0.3);
  --shadow-lg: 0 8px 40px rgba(0,0,0,0.6);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --surface-1: #1e1a15;
    --page: #14110d;
    --text-primary: #f5efe2;
    --text-secondary: #cfc4ab;
    --text-muted: #978d78;
    --grid-line: #2f2a22;
    --baseline: #3f382c;
    --border: rgba(245, 239, 226, 0.10);
    --border-strong: rgba(245, 239, 226, 0.18);

    --series-receita: #b58c3e;
    --series-despesa: #1a97a6;
    --seq-bar: #b58c3e;

    --good: #0ca30c;
    --good-text: #4db34d;
    --critical-text: #e66767;

    --accent: #c9a55a;
    --accent-hover: #d9b56a;
    --accent-soft: rgba(201, 165, 90, 0.16);
    --accent-contrast: #241d10;

    --shadow: 0 1px 2px rgba(0,0,0,0.3), 0 4px 16px rgba(0,0,0,0.3);
    --shadow-lg: 0 8px 40px rgba(0,0,0,0.6);
  }
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }

body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--page);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
}

button { font: inherit; color: inherit; cursor: pointer; background: none; border: none; }
input, select, textarea { font: inherit; color: inherit; }

/* ============ Layout ============ */

.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 24px 18px 18px;
  text-align: center;
}

.brand-logo {
  width: 52px;
  height: 52px;
  color: var(--sidebar-active);
}
.brand-logo svg { width: 100%; height: 100%; display: block; }

.brand-text { display: flex; flex-direction: column; line-height: 1.3; align-items: center; }
.brand-text strong {
  font-size: 21px;
  font-weight: 600;
  letter-spacing: 0.28em;
  margin-right: -0.28em; /* compensa o tracking na centralização */
  color: var(--sidebar-active);
}
.brand-text span {
  font-size: 9px;
  letter-spacing: 0.24em;
  margin-right: -0.24em;
  text-transform: uppercase;
  color: var(--sidebar-muted);
}

.nav { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; flex: 1; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--sidebar-muted);
  font-weight: 500;
  text-align: left;
  transition: background 0.12s, color 0.12s;
}

.nav-item svg { width: 18px; height: 18px; fill: currentColor; flex-shrink: 0; }
.nav-item:hover { background: var(--sidebar-active-bg); color: var(--sidebar-text); }
.nav-item.active { background: var(--sidebar-active-bg); color: var(--sidebar-active); }

.sidebar-footer {
  padding: 14px 18px;
  border-top: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-start;
}

.sidebar-footer .btn-ghost { color: var(--sidebar-active); }
.sidebar-footer .btn-ghost:hover { background: var(--sidebar-active-bg); }

.doctor-credit {
  font-size: 11px;
  line-height: 1.5;
  color: var(--sidebar-muted);
}
.doctor-credit b { color: var(--sidebar-text); font-weight: 600; display: block; }

.main {
  flex: 1;
  padding: 28px 32px 48px;
  max-width: 1240px;
  min-width: 0;
}

/* ============ Views / header ============ */

.view { display: none; }
.view.active { display: block; }

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

.view-header h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }
.subtitle { color: var(--text-muted); font-size: 13px; margin-top: 2px; }
.header-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* ============ Botões ============ */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--surface-1);
  font-weight: 500;
  transition: background 0.12s, border-color 0.12s;
}

.btn:hover { border-color: var(--accent); }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-ghost {
  color: var(--accent);
  font-weight: 500;
  padding: 4px 8px;
  border-radius: 6px;
}
.btn-ghost:hover { background: var(--accent-soft); }

.btn-sm { font-size: 12.5px; padding: 4px 10px; }

.btn-icon {
  width: 34px;
  justify-content: center;
  padding: 8px 0;
  font-size: 16px;
  line-height: 1;
}

.btn-danger-ghost { color: var(--critical-text); padding: 4px 8px; border-radius: 6px; font-size: 12.5px; }
.btn-danger-ghost:hover { background: rgba(208, 59, 59, 0.10); }

/* ============ KPI tiles ============ */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.kpi {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}

.kpi-label { font-size: 12.5px; color: var(--text-secondary); }
.kpi-value { font-size: 26px; font-weight: 600; margin-top: 4px; letter-spacing: -0.01em; }
.kpi-delta { font-size: 12px; margin-top: 4px; color: var(--text-muted); }
.kpi-delta .up { color: var(--good-text); font-weight: 600; }
.kpi-delta .down { color: var(--critical-text); font-weight: 600; }

/* ============ Cards / grid do dashboard ============ */

.dash-grid {
  display: grid;
  grid-template-columns: 3fr 2fr;
  gap: 14px;
}

@media (max-width: 1000px) {
  .dash-grid { grid-template-columns: 1fr; }
}

.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  min-width: 0;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.card-head h2 { font-size: 14px; font-weight: 600; color: var(--text-primary); }

.card-chart { overflow: hidden; }
.chart-wrap { width: 100%; }
.chart-wrap svg { display: block; width: 100%; height: auto; }

/* ============ Legenda ============ */

.legend { display: flex; gap: 14px; flex-wrap: wrap; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-secondary); }
.legend-swatch { width: 10px; height: 10px; border-radius: 3px; }

/* ============ Tooltip do gráfico ============ */

.chart-tooltip {
  position: fixed;
  z-index: 90;
  pointer-events: none;
  background: var(--surface-1);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  padding: 8px 12px;
  font-size: 12.5px;
  display: none;
  min-width: 140px;
}

.chart-tooltip.show { display: block; }
.chart-tooltip .tt-title { font-weight: 600; margin-bottom: 4px; }
.chart-tooltip .tt-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; color: var(--text-secondary); }
.chart-tooltip .tt-row b { color: var(--text-primary); font-weight: 600; font-variant-numeric: tabular-nums; }
.chart-tooltip .tt-key { display: inline-flex; align-items: center; gap: 6px; }
.chart-tooltip .tt-swatch { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }

/* ============ Listas do dashboard ============ */

.mini-list { display: flex; flex-direction: column; }

.mini-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 2px;
  border-bottom: 1px solid var(--grid-line);
}
.mini-row:last-child { border-bottom: none; }

.mini-time {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 13px;
  color: var(--text-primary);
  width: 44px;
  flex-shrink: 0;
}

.mini-main { flex: 1; min-width: 0; }
.mini-main .t { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-main .s { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-amount { font-variant-numeric: tabular-nums; font-weight: 600; flex-shrink: 0; }

.empty-note { color: var(--text-muted); font-size: 13px; padding: 14px 2px; }

/* ============ Pills de status ============ */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
}

.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.pill-blue    { color: #7c5f22; background: rgba(163, 124, 40, 0.14); }
.pill-green   { color: var(--good-text); background: rgba(12, 163, 12, 0.12); }
.pill-yellow  { color: #8a6100; background: rgba(250, 178, 25, 0.16); }
.pill-red     { color: var(--critical-text); background: rgba(208, 59, 59, 0.12); }
.pill-gray    { color: var(--text-secondary); background: rgba(143, 134, 114, 0.16); }
.pill-violet  { color: #0f6d77; background: rgba(0, 145, 158, 0.12); }

:root[data-theme="dark"] .pill-blue   { color: #d9b56a; }
:root[data-theme="dark"] .pill-yellow { color: #fab219; }
:root[data-theme="dark"] .pill-violet { color: #5cc3d0; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .pill-blue   { color: #d9b56a; }
  :root:not([data-theme="light"]) .pill-yellow { color: #fab219; }
  :root:not([data-theme="light"]) .pill-violet { color: #5cc3d0; }
}

/* ============ Filtros / chips / tabs ============ */

.filter-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.search-input { max-width: 320px; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 0; }
#budget-status-chips { margin-bottom: 14px; }

.chip {
  font-size: 12.5px;
  font-weight: 500;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface-1);
  color: var(--text-secondary);
}
.chip:hover { border-color: var(--accent); }
.chip.active { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }

.tabs {
  display: inline-flex;
  gap: 2px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 3px;
}

.tab {
  padding: 6px 14px;
  border-radius: 7px;
  font-weight: 500;
  color: var(--text-secondary);
}
.tab.active { background: var(--accent); color: var(--accent-contrast); }

/* ============ Tabelas ============ */

.table-scroll { overflow-x: auto; }

.table { width: 100%; border-collapse: collapse; }

.table th {
  text-align: left;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  padding: 8px 10px;
  border-bottom: 1px solid var(--grid-line);
  white-space: nowrap;
}

.table td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--grid-line);
  vertical-align: middle;
}

.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr.clickable { cursor: pointer; }
.table tbody tr.clickable:hover { background: var(--accent-soft); }

.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table td.actions { text-align: right; white-space: nowrap; }

.cell-main { font-weight: 500; }
.cell-sub { font-size: 12px; color: var(--text-muted); }

.amount-pos { color: var(--good-text); font-weight: 600; }
.amount-neg { color: var(--critical-text); font-weight: 600; }

.wa-link { color: var(--accent); text-decoration: none; }
.wa-link:hover { text-decoration: underline; }

/* ============ Agenda ============ */

.agenda-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

.agenda-date { font-size: 15px; font-weight: 600; margin-left: 8px; text-transform: capitalize; }

.appt-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--grid-line);
}
.appt-row:last-child { border-bottom: none; }

.appt-time {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 15px;
  width: 52px;
  flex-shrink: 0;
}

.appt-main { flex: 1; min-width: 0; }
.appt-main .name { font-weight: 600; }
.appt-main .proc { font-size: 12.5px; color: var(--text-muted); }
.appt-actions { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }

/* ============ Financeiro ============ */

.fin-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.month-nav { display: flex; align-items: center; gap: 8px; }
.month-nav span { font-weight: 600; min-width: 130px; text-align: center; text-transform: capitalize; }

.fin-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

/* ============ Drawer (painel do paciente) ============ */

.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(11,11,11,0.35);
  z-index: 60;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s;
}
.drawer-overlay.open { opacity: 1; pointer-events: auto; }

.drawer {
  position: fixed;
  top: 0; right: 0;
  height: 100vh;
  width: min(440px, 92vw);
  background: var(--surface-1);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  z-index: 61;
  transform: translateX(105%);
  transition: transform 0.22s ease;
  overflow-y: auto;
  padding: 24px;
}
.drawer.open { transform: translateX(0); }

.drawer-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.drawer-head h2 { font-size: 19px; }
.drawer-close { font-size: 20px; color: var(--text-muted); padding: 2px 8px; border-radius: 6px; }
.drawer-close:hover { background: var(--accent-soft); }

.drawer-section { margin-top: 20px; }
.drawer-section h3 {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
.info-item .k { font-size: 11.5px; color: var(--text-muted); }
.info-item .v { font-weight: 500; }

.drawer-stats { display: flex; gap: 10px; }
.drawer-stat {
  flex: 1;
  background: var(--page);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}
.drawer-stat .k { font-size: 11.5px; color: var(--text-muted); }
.drawer-stat .v { font-weight: 600; font-size: 16px; }

/* ============ Modal ============ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(11,11,11,0.40);
  z-index: 70;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 6vh 16px;
  overflow-y: auto;
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 480px;
  padding: 22px;
}

.modal h2 { font-size: 17px; margin-bottom: 16px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-field { display: flex; flex-direction: column; gap: 4px; }
.form-field.full { grid-column: 1 / -1; }
.form-field label { font-size: 12px; font-weight: 600; color: var(--text-secondary); }

.input, select.input, textarea.input {
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--surface-1);
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.12s, box-shadow 0.12s;
}

.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

.budget-items { display: flex; flex-direction: column; gap: 8px; }
.budget-item-row { display: grid; grid-template-columns: 1fr 110px 32px; gap: 8px; align-items: center; }
.budget-total { text-align: right; font-weight: 600; margin-top: 8px; }

/* ============ Odontograma ============ */

.odonto-grid { display: flex; flex-direction: column; gap: 6px; }
.odonto-row { display: flex; gap: 3px; justify-content: center; }
.odonto-gap { width: 10px; flex-shrink: 0; }

.tooth {
  width: 30px; height: 36px;
  border-radius: 7px;
  border: 1.5px solid var(--border-strong);
  background: var(--surface-1);
  font-size: 10px;
  font-weight: 700;
  color: var(--text-secondary);
  display: grid;
  place-items: center;
  padding: 0;
  transition: transform 0.08s;
}
.tooth.mini { width: 20px; height: 24px; font-size: 8px; border-radius: 5px; cursor: default; }
.odonto-grid.editable .tooth:hover { transform: scale(1.12); border-color: var(--accent); }

.tooth.t-cariado    { background: #d03b3b; border-color: #d03b3b; color: #fff; }
.tooth.t-restaurado { background: var(--series-despesa); border-color: var(--series-despesa); color: #fff; }
.tooth.t-canal      { background: var(--series-receita); border-color: var(--series-receita); color: #fff; }
.tooth.t-coroa      { background: #7b68c9; border-color: #7b68c9; color: #fff; }
.tooth.t-implante   { background: #6b675e; border-color: #6b675e; color: #fff; }
.tooth.t-ausente    { background: transparent; border-style: dashed; color: var(--text-muted); opacity: 0.55; }

.odonto-legend { display: flex; flex-wrap: wrap; gap: 8px 14px; margin-top: 12px; }
.odonto-legend .legend-item { font-size: 11.5px; }
.odonto-hint { font-size: 12px; color: var(--text-muted); margin-top: 10px; }

/* ============ Anamnese ============ */

.anamnese-alert {
  background: rgba(208, 59, 59, 0.10);
  border: 1px solid rgba(208, 59, 59, 0.35);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  color: var(--critical-text);
}
.anamnese-ok { font-size: 13px; color: var(--good-text); }

.anamnese-q {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid var(--grid-line);
  font-size: 13.5px;
}
.anamnese-q:last-of-type { border-bottom: none; }
.anamnese-q .opts { display: flex; gap: 4px; flex-shrink: 0; }
.anamnese-q .opts label {
  padding: 4px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-secondary);
}
.anamnese-q .opts input { display: none; }
.anamnese-q .opts input:checked + span { }
.anamnese-q .opts label:has(input:checked) {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
}

/* ============ Evolução clínica ============ */

.evolucao-item {
  padding: 9px 0;
  border-bottom: 1px solid var(--grid-line);
  font-size: 13px;
}
.evolucao-item:last-child { border-bottom: none; }
.evolucao-item .d { font-size: 11.5px; color: var(--text-muted); font-weight: 600; }

/* ============ Pix ============ */

.pix-code {
  width: 100%;
  font-family: Consolas, monospace;
  font-size: 11.5px;
  word-break: break-all;
  background: var(--page);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 10px;
  min-height: 88px;
  resize: none;
}

/* ============ Toast ============ */

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: var(--text-primary);
  color: var(--page);
  padding: 10px 18px;
  border-radius: 10px;
  font-weight: 500;
  font-size: 13.5px;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 99;
  max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ============ Gráficos (SVG) ============ */

.axis-text { font-size: 11px; fill: var(--text-muted); }
.bar-label { font-size: 11px; fill: var(--text-secondary); font-weight: 600; }
.gridline { stroke: var(--grid-line); stroke-width: 1; }
.baseline-line { stroke: var(--baseline); stroke-width: 1; }

.bar-receita { fill: var(--series-receita); }
.bar-despesa { fill: var(--series-despesa); }
.bar-seq { fill: var(--seq-bar); }
.bar-hit { fill: transparent; }
.bar-hit:hover { fill: rgba(137,135,129,0.08); }

/* ============ Responsivo ============ */

@media (max-width: 780px) {
  .app { flex-direction: column; }
  .sidebar {
    width: 100%;
    height: auto;
    position: static;
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
  }
  .nav { flex-direction: row; }
  .nav-item span { display: none; }
  .sidebar-footer { display: none; }
  .brand { flex-direction: row; padding: 10px 14px; gap: 8px; }
  .brand-logo { width: 30px; height: 30px; flex-shrink: 0; }
  .brand-text { align-items: flex-start; }
  .brand-text strong { font-size: 14px; letter-spacing: 0.2em; margin-right: 0; }
  .brand-text span { display: none; }
  .main { padding: 18px 14px 40px; }
  .view-header { flex-direction: column; }
  .dash-grid { grid-template-columns: 1fr; }
}

/* ================= Nuvem: tela de login e status de sincronização ================= */

.cloud-gate {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--page);
  padding: 24px;
}
.cloud-gate-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px 28px;
  text-align: center;
  box-shadow: 0 12px 40px rgba(33, 27, 16, 0.12);
}
.cloud-gate-card svg {
  width: 52px;
  height: 52px;
  color: var(--accent);
  margin-bottom: 10px;
}
.cloud-gate-card h1 {
  font-size: 17px;
  color: var(--text-primary);
  margin-bottom: 18px;
}
.cloud-gate-msg {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.5;
}
.cloud-gate-error {
  color: #c0392b;
  font-size: 13px;
  margin: 2px 0 4px;
}
#cloud-login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: left;
}
#cloud-login-form label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 5px;
}
#cloud-login-form input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--page);
  color: var(--text-primary);
  font: inherit;
  font-size: 14px;
}
#cloud-login-form input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: transparent;
}
#cloud-login-form button {
  margin-top: 6px;
  padding: 11px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-contrast);
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
#cloud-login-form button:hover { background: var(--accent-hover); }
#cloud-login-form button:disabled { opacity: 0.6; cursor: default; }

.cloud-footer {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}
.cloud-sync {
  font-size: 11px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.cloud-sync::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.cloud-ok { color: var(--sidebar-muted, var(--text-muted)); }
.cloud-ok::before { background: #4caf7d; }
.cloud-busy { color: var(--sidebar-muted, var(--text-muted)); }
.cloud-busy::before { background: #d9b56a; }
.cloud-err { color: #e08c7f; }
.cloud-err::before { background: #d03b3b; }

.cloud-link {
  background: none;
  border: none;
  color: var(--text-muted);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  text-decoration: underline;
  padding: 2px;
}
.cloud-link:hover { color: var(--accent); }

/* ================= Papéis: recepção não vê o confidencial ================= */
/* Financeiro da clínica */
.role-recepcao .nav-item[data-view="financeiro"] { display: none; }
.role-recepcao #kpi-grid { display: none; }
.role-recepcao .card-chart { display: none; }
.role-recepcao .dash-grid .card:has(#dash-due) { display: none; }
.role-recepcao [data-action="config-pix"] { display: none; }
/* Prontuário clínico (sigilo profissional) */
.role-recepcao .drawer-section:has([data-anamnese]) { display: none; }
.role-recepcao .drawer-section:has([data-odontograma]) { display: none; }
.role-recepcao .drawer-section:has([data-evolucao]) { display: none; }
.role-recepcao [data-action="nova-despesa"] { display: none; }
