/* ============================================================
   TFD - Sistema de Gestao do Programa de Tratamento Fora de
   Domicilio. Design system: paleta institucional de saude
   publica, tipografia legivel, layout responsivo (sidebar em
   desktop, drawer em mobile).
   ============================================================ */

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("/fonts/inter-var.woff2") format("woff2");
}

:root {
  --color-primary: #0f6e8c;
  --color-primary-dark: #0a4f65;
  --color-primary-light: #e6f3f7;
  --color-accent: #2e8b57;
  --color-danger: #c0392b;
  --color-danger-light: #fbeae8;
  --color-warning: #b45309;
  --color-warning-light: #fef3e2;
  --color-bg: #f3f6f8;
  --color-surface: #ffffff;
  --color-text: #1f2a37;
  --color-text-muted: #5b6b79;
  --color-border: #dde5ea;

  --sidebar-bg: #0a3347;
  --sidebar-bg-hover: #0f4863;
  --sidebar-text: #cfe3ec;
  --sidebar-text-muted: #8fb2c2;

  --radius-sm: 6px;
  --radius-md: 10px;
  --shadow-sm: 0 1px 2px rgba(15, 33, 46, 0.08);
  --shadow-md: 0 6px 20px rgba(15, 33, 46, 0.12);

  --font-sans: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;

  --sidebar-width: 264px;
  --topbar-height: 64px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--font-sans);
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 15px;
  line-height: 1.5;
}

a { color: var(--color-primary); }
a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid #ffb703;
  outline-offset: 2px;
}

h1, h2, h3, h4 { margin: 0 0 .5rem; font-weight: 600; color: var(--color-text); }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 1rem; }

/* ---------- Icones (sprite Lucide em /img/icons.svg) ---------- */
.icon {
  width: 1.1em;
  height: 1.1em;
  flex-shrink: 0;
  vertical-align: -0.15em;
}
.icon-danger { color: var(--color-danger); }

/* ---------- App shell (sidebar + main) ---------- */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 40;
  transform: translateX(0);
  transition: transform .2s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: 1.1rem 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-brand { gap: .75rem; }
.sidebar-brand .brand-mark { width: 40px; height: 40px; flex-shrink: 0; border-radius: 10px; box-shadow: 0 2px 8px rgba(0,0,0,.3); }
.sidebar-brand .brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.sidebar-brand .brand-name { font-size: 1.05rem; font-weight: 600; letter-spacing: .14em; color: #fff; }
.sidebar-brand .brand-name b { font-weight: 800; color: #7fd3ea; letter-spacing: .1em; }
.sidebar-brand .brand-text small { margin-top: .2rem; font-size: .66rem; letter-spacing: .02em; }
.sidebar-brand span { font-weight: 700; letter-spacing: .3px; color: #fff; }
.sidebar-brand small { display: block; color: var(--sidebar-text-muted); font-weight: 400; font-size: .72rem; }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: .75rem;
}
.sidebar-nav .nav-section {
  text-transform: uppercase;
  font-size: .68rem;
  letter-spacing: .06em;
  color: var(--sidebar-text-muted);
}
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .6rem .65rem;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: .92rem;
  margin-bottom: .15rem;
}
.sidebar-nav a:hover { background: var(--sidebar-bg-hover); color: #fff; }
.sidebar-nav a.active { background: var(--color-primary); color: #fff; font-weight: 600; }
.sidebar-nav a .icon { width: 1.15rem; height: 1.15rem; }

.app-main {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: var(--topbar-height);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  position: sticky;
  top: 0;
  z-index: 30;
}
.topbar-left { display: flex; align-items: center; gap: .75rem; }
.topbar-title { font-weight: 600; font-size: 1.05rem; }
.topbar-user { display: flex; align-items: center; gap: .75rem; }
.topbar-user-info { text-align: right; line-height: 1.2; }
.topbar-user-name { font-weight: 600; font-size: .88rem; }
.logout-form { margin: 0; }
.topbar-user .avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--color-primary-light); color: var(--color-primary-dark);
  display: flex; align-items: center; justify-content: center; font-weight: 700;
}
.topbar-user .perfil-badge {
  font-size: .7rem; color: var(--color-text-muted); text-transform: uppercase; letter-spacing: .04em;
}
.menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  background: none; border: 0; cursor: pointer; color: var(--color-text);
  padding: .4rem;
  border-radius: var(--radius-sm);
}
.menu-toggle:hover { background: var(--color-bg); }
.menu-toggle .icon { width: 1.35rem; height: 1.35rem; }

.app-content {
  padding: 1.5rem;
  width: 100%;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .75rem;
  margin-bottom: 1.25rem;
}
.page-header p.subtitle { color: var(--color-text-muted); margin: .2rem 0 0; }
.page-header-actions { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }

/* ---------- Cards / surfaces ---------- */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

.card-link { text-decoration: none; color: inherit; display: block; transition: box-shadow .15s ease, transform .15s ease; }
.card-link:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.card-link h2 { display: flex; align-items: center; gap: .5rem; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 1.1rem 1.25rem;
  box-shadow: var(--shadow-sm);
}
.stat-card .stat-label { color: var(--color-text-muted); font-size: .82rem; margin-bottom: .35rem; }
.stat-card .stat-value { font-size: 1.6rem; font-weight: 700; color: var(--color-primary-dark); }

/* ---------- Filtro grande do painel do motorista (item C.1) ---------- */
.filtro-motorista { margin-bottom: 1.25rem; }
.filtro-motorista label { display: block; font-weight: 600; font-size: 1rem; margin-bottom: .5rem; }
.select-grande {
  width: 100%;
  max-width: 420px;
  padding: .9rem 1rem;
  font-size: 1.1rem;
  font-weight: 600;
  border: 2px solid var(--color-primary);
  border-radius: var(--radius-sm);
  color: var(--color-primary-dark);
  background: #fff;
}
.btn-abrir-viagem { width: 100%; justify-content: center; margin-top: .75rem; font-size: 1rem; padding: .75rem 1rem; }

/* ---------- Autosave da tela do motorista (item C.2) ---------- */
.autosave-status {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  font-size: .76rem;
  margin-top: .3rem;
  min-height: 1rem;
}
.autosave-status .icon { width: 1em; height: 1em; }
.autosave-status.autosave-salvando { color: var(--color-text-muted); }
.autosave-status.autosave-ok { color: var(--color-accent); }
.autosave-status.autosave-erro { color: var(--color-danger); font-weight: 600; }

/* ---------- Cards de viagem (painel do motorista, item C.2) ---------- */
.viagem-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.viagem-card-header { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .6rem; }
.viagem-card-data { font-size: .82rem; color: var(--color-text-muted); }
.viagem-card-rota { font-weight: 600; font-size: 1.05rem; margin: 0 0 .5rem; display: flex; align-items: center; gap: .4rem; }
.viagem-card-meta { color: var(--color-text-muted); font-size: .85rem; display: flex; gap: 1rem; flex-wrap: wrap; }

/* ---------- Conteúdo exclusivo do PDF (item C.4) ----------
   Fica fora da tela (nunca visível na UI normal), mas com layout real
   renderizado — html2canvas precisa disso pra conseguir capturar. */
.pdf-only {
  position: fixed;
  top: 0;
  left: -10000px;
  width: 900px;
  background: #fff;
  padding: 1.5rem;
}
/* Item D.3: dentro do container off-screen do PDF a tabela não tem scroll
   disponível pra compensar cabeçalhos largos — sem isso, "white-space:
   nowrap" dos thead th (regra geral, ok nas telas normais com scroll)
   empurra a tabela pra fora da largura capturada pelo html2canvas e
   colunas à direita saem cortadas no PDF gerado. */
.pdf-only table { table-layout: fixed; }
.pdf-only thead th { white-space: normal; }
.pdf-assinaturas { display: flex; gap: 3rem; margin-top: 3rem; }
.pdf-assinatura-linha { flex: 1; border-top: 1px solid #333; padding-top: .4rem; text-align: center; font-size: .85rem; color: #444; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .55rem 1rem;
  border-radius: var(--radius-sm);
  font-size: .9rem;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.2;
}
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-dark); }
.btn-outline { background: transparent; color: var(--color-primary); border-color: var(--color-primary); }
.btn-outline:hover { background: var(--color-primary-light); }
.btn-danger { background: var(--color-danger); color: #fff; }
.btn-danger:hover { background: #a83226; }
.btn-sm { padding: .35rem .7rem; font-size: .8rem; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-block { width: 100%; justify-content: center; }

/* ---------- Forms ---------- */
label { display: block; font-weight: 600; font-size: .85rem; margin-bottom: .3rem; }
.form-group { margin-bottom: 1.1rem; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); gap: 1rem; }
input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="date"], input[type="datetime-local"],
select, textarea {
  width: 100%;
  padding: .6rem .7rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: .92rem;
  font-family: inherit;
  background: #fff;
  color: var(--color-text);
}
input:disabled, select:disabled { background: #f3f4f6; color: var(--color-text-muted); }
.field-error { color: var(--color-danger); font-size: .78rem; margin-top: .3rem; }
.field-hint { color: var(--color-text-muted); font-size: .78rem; margin-top: .3rem; }
.form-check-row { display: flex; gap: 1.25rem; flex-wrap: wrap; }
.form-check { display: flex; align-items: center; gap: .4rem; font-weight: normal; cursor: pointer; }
.form-check input[type="checkbox"] { width: auto; }
.form-check.form-check-travado { opacity: .65; pointer-events: none; }
.form-actions { display: flex; gap: .6rem; margin-top: 1.5rem; }
.filter-row { align-items: end; margin-bottom: 1rem; }
.form-row-end { align-items: end; }
.stat-value-sm { font-size: 1.15rem; }
.form-group-flush { margin-bottom: 0; }
.mt-3 { margin-top: .75rem; }
.mt-4 { margin-top: 1rem; }
.form-actions-flush { margin-top: 0; }
.card-header-row { margin-bottom: .75rem; }
.card-header-row h2 { margin: 0; }
.card-narrow { max-width: 640px; }
.card-narrow-sm { max-width: 560px; }
.label-note { font-weight: 400; }

/* ---------- Tom Select (selects pesquisaveis, Bloco 2 item 2.1) ---------- */
.ts-wrapper.single .ts-control {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: .6rem .7rem;
  font-size: .92rem;
  font-family: inherit;
  background: #fff;
  box-shadow: none;
  min-height: 0;
}
.ts-wrapper.single.input-active .ts-control,
.ts-wrapper.focus .ts-control {
  border-color: var(--color-primary);
  outline: 3px solid #ffb703;
  outline-offset: 2px;
}
.ts-dropdown {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: .92rem;
  font-family: inherit;
  box-shadow: var(--shadow-md);
}
.ts-dropdown .option { padding: .55rem .7rem; }
.ts-dropdown .option.active { background: var(--color-primary-light); color: var(--color-primary-dark); }
.ts-dropdown .no-results { padding: .55rem .7rem; color: var(--color-text-muted); }
.ts-wrapper.disabled .ts-control { background: #f3f4f6; color: var(--color-text-muted); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
thead th {
  text-align: left;
  background: var(--color-primary-light);
  color: var(--color-primary-dark);
  padding: .7rem .8rem;
  font-weight: 600;
  white-space: nowrap;
}
tbody td { padding: .65rem .8rem; border-bottom: 1px solid var(--color-border); vertical-align: middle; }
tbody tr:hover { background: #fafcfd; }
.table-actions { display: flex; gap: .4rem; }
.table-actions form { margin: 0; }
.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--color-text-muted); }
.empty-state .icon { width: 2.25rem; height: 2.25rem; margin-bottom: .5rem; opacity: .55; }
.empty-state p { margin: 0; }

.empty-state-card { text-align: center; padding: 3rem 2rem; }
.empty-state-card .icon { width: 3rem; height: 3rem; color: var(--color-text-muted); opacity: .6; }
.empty-state-card h1 { margin-top: .5rem; }

/* ---------- Badges / pills ---------- */
.badge {
  display: inline-block;
  padding: .2rem .6rem;
  border-radius: 999px;
  font-size: .74rem;
  font-weight: 700;
  letter-spacing: .02em;
}
.badge-origem { background: var(--color-primary-light); color: var(--color-primary-dark); }
.badge-destino { background: #eaf6ee; color: var(--color-accent); }
.badge-ativo { background: #eaf6ee; color: var(--color-accent); }
.badge-inativo { background: #f1f2f4; color: var(--color-text-muted); }
.badge-protegida { background: var(--color-warning-light); color: var(--color-warning); }
.badge-solicitado { background: var(--color-warning-light); color: var(--color-warning); }
.badge-aprovado { background: #eaf6ee; color: var(--color-accent); }
.badge-agendada { background: var(--color-primary-light); color: var(--color-primary-dark); }
.badge-realizada { background: #eaf6ee; color: var(--color-accent); }
.badge-concluido { background: #eaf6ee; color: var(--color-accent); }
.badge-rejeitado { background: var(--color-danger-light); color: var(--color-danger); }
.badge-cancelado { background: #f1f2f4; color: var(--color-text-muted); }
.badge-cancelada { background: #f1f2f4; color: var(--color-text-muted); }
.badge-pendente { background: var(--color-warning-light); color: var(--color-warning); }
.badge-pago { background: #eaf6ee; color: var(--color-accent); }

/* ---------- Alerts ---------- */
.alert {
  padding: .85rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1.1rem;
  font-size: .9rem;
  border: 1px solid transparent;
}
.alert-success { background: #eaf6ee; color: #1e5e3a; border-color: #cdeada; }
.alert-error { background: var(--color-danger-light); color: var(--color-danger); border-color: #f3cfc9; }
.alert-info { background: var(--color-primary-light); color: var(--color-primary-dark); border-color: #cfe6ee; }

/* ---------- Modais ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 51, 71, .55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}
.modal-overlay[hidden] { display: none; }

.modal-dialog {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  width: 100%;
  max-width: 640px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  animation: modal-entrada .18s ease;
}
.modal-dialog-sm { max-width: 440px; }

@keyframes modal-entrada {
  from { opacity: 0; transform: translateY(10px) scale(.98); }
  to   { opacity: 1; transform: none; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--color-border);
}
.modal-header h2 { display: flex; align-items: center; gap: .5rem; margin: 0; font-size: 1.15rem; }

.modal-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 0;
  cursor: pointer;
  color: var(--color-text-muted);
  padding: .4rem;
  border-radius: var(--radius-sm);
}
.modal-close:hover { background: var(--color-bg); color: var(--color-text); }
.modal-close .icon { width: 1.15rem; height: 1.15rem; }

.modal-body {
  padding: 1.25rem;
  overflow-y: auto;
}

body.modal-aberto { overflow: hidden; }

/* Botao em estado de envio (feedback de loading) */
.btn-loading {
  position: relative;
  pointer-events: none;
  opacity: .75;
}
.btn-loading::after {
  content: "";
  width: 1em;
  height: 1em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  display: inline-block;
  margin-left: .45rem;
  animation: girar .7s linear infinite;
  vertical-align: -0.15em;
}
@keyframes girar { to { transform: rotate(360deg); } }

@media (max-width: 560px) {
  /* Em telas pequenas, o modal vira uma folha ancorada na base */
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal-dialog { max-width: none; max-height: 94vh; border-radius: var(--radius-md) var(--radius-md) 0 0; }
}

/* ---------- Bar list (relatorios) ---------- */
.bar-list { display: flex; flex-direction: column; gap: .7rem; }
.bar-list-item {
  display: grid;
  grid-template-columns: 160px 1fr 100px;
  align-items: center;
  gap: .75rem;
  font-size: .85rem;
}
.bar-list-label {
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bar-track {
  background: var(--color-border);
  border-radius: 999px;
  height: 10px;
  overflow: hidden;
}
.bar-fill {
  background: var(--color-primary);
  height: 100%;
  border-radius: 999px;
  min-width: 4px;
}
.bar-list-value {
  text-align: right;
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.bar-list-empty { color: var(--color-text-muted); font-size: .85rem; padding: .5rem 0; }

@media (max-width: 560px) {
  .bar-list-item { grid-template-columns: 1fr; gap: .3rem; }
  .bar-list-value { text-align: left; }
}

/* ---------- Mural de Viagens ---------- */
.mural-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  flex-wrap: wrap;
  margin-bottom: 1.1rem;
}
.mural-nav-periodo {
  display: flex;
  align-items: center;
  gap: .75rem;
  font-weight: 600;
  color: var(--color-text);
}

.mural-grid-wrap { overflow-x: auto; padding-bottom: .25rem; }
.mural-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(190px, 1fr));
  gap: .9rem;
  align-items: start;
}

.mural-col {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  min-width: 0;
}
.mural-col-header {
  padding: .75rem .85rem;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-primary-light);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  display: flex;
  flex-direction: column;
  gap: .1rem;
}
.mural-col-header-hoje { background: var(--color-primary); }
.mural-col-header-hoje .mural-col-dia,
.mural-col-header-hoje .mural-col-data { color: #fff; }
.mural-col-dia { font-weight: 700; font-size: .82rem; color: var(--color-primary-dark); }
.mural-col-data { font-size: .76rem; color: var(--color-text-muted); }

.mural-col-body {
  padding: .7rem;
  display: flex;
  flex-direction: column;
  gap: .6rem;
  min-height: 80px;
}
.mural-col-vazio { color: var(--color-text-muted); font-size: .8rem; margin: .4rem 0; text-align: center; }

.mural-card {
  display: flex;
  flex-direction: column;
  gap: .3rem;
  padding: .65rem .75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-primary);
  background: var(--color-bg);
  text-decoration: none;
  color: var(--color-text);
  font-size: .82rem;
  transition: box-shadow .15s ease, transform .15s ease;
}
.mural-card:hover { box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.mural-card-agendada { border-left-color: var(--color-primary); }
.mural-card-realizada { border-left-color: var(--color-accent); }
.mural-card-cancelada { border-left-color: var(--color-text-muted); opacity: .7; }
.mural-card-hora { font-weight: 700; color: var(--color-primary-dark); }
.mural-card-destino { font-weight: 600; }
.mural-card-info {
  display: flex;
  justify-content: space-between;
  gap: .5rem;
  color: var(--color-text-muted);
  font-size: .78rem;
}

@media (max-width: 900px) {
  .mural-grid { grid-template-columns: repeat(7, minmax(170px, 1fr)); }
}

/* ---------- Pagination ---------- */
.pagination { display: flex; align-items: center; gap: .75rem; margin: 1.25rem 0 0; }
.pagination-info { color: var(--color-text-muted); font-size: .88rem; }
.pagination-info strong { color: var(--color-text); font-weight: 600; }
.pagination .btn[aria-disabled="true"] { opacity: .4; cursor: not-allowed; pointer-events: none; }

/* ---------- Login page ---------- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 15% 10%, rgba(127,211,234,.22), transparent 45%),
    radial-gradient(circle at 90% 95%, rgba(26,147,184,.28), transparent 50%),
    linear-gradient(135deg, var(--color-primary-dark), var(--sidebar-bg));
  padding: 1.5rem;
}
.login-brand { text-align: center; margin-bottom: 1.5rem; }
.login-mark { display: block; margin: -3.4rem auto 1rem; width: 72px; height: 72px; border-radius: 18px; box-shadow: 0 8px 20px rgba(10,79,101,.4); border: 3px solid var(--color-surface); }
.login-title { margin: 0; font-size: 1.6rem; font-weight: 600; letter-spacing: .14em; color: var(--color-primary-dark); }
.login-title b { font-weight: 800; color: var(--color-primary); letter-spacing: .1em; }
.login-brand .subtitle { margin: .5rem 0 0; line-height: 1.45; }
.login-card {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  width: 100%;
  max-width: 400px;
  padding: 2.25rem 2rem 2rem;
  margin-top: 2rem;
}
.login-card h1 { font-size: 1.25rem; }
.login-card .subtitle { color: var(--color-text-muted); font-size: .85rem; margin-bottom: 1.5rem; }
.login-footer { text-align: center; margin-top: 1.5rem; font-size: .76rem; color: var(--color-text-muted); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-md); }
  .app-main { margin-left: 0; }
  .menu-toggle { display: inline-flex; }
  .sidebar-backdrop {
    display: none;
    position: fixed; inset: 0; background: rgba(10, 51, 71, .45); z-index: 35;
  }
  .sidebar-backdrop.open { display: block; }
}

body.sidebar-aberta { overflow: hidden; }
.menu-toggle { min-width: 40px; min-height: 40px; }

@media (max-width: 900px) {
  .sidebar { width: min(var(--sidebar-width), 86vw); }
  .sidebar-backdrop { transition: opacity .2s ease; }
  .topbar-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar-left { min-width: 0; }
  .card, .table-wrap { max-width: 100%; }
  .table-wrap { -webkit-overflow-scrolling: touch; }
  .table-wrap table { min-width: 640px; }
}

@media (max-width: 700px) {
  .topbar-user-info { display: none; }
  .page-header { flex-direction: column; align-items: stretch; }
  .page-header-actions { width: 100%; }
  .page-header-actions .btn { flex: 1 1 auto; justify-content: center; }
  .form-actions { flex-wrap: wrap; }
  .form-actions .btn { flex: 1 1 auto; justify-content: center; }
  .mural-nav { flex-wrap: wrap; }
  input, select, textarea { font-size: 16px; } /* evita zoom automático no iOS */
}

@media (max-width: 560px) {
  .app-content { padding: 1rem; }
  .topbar { padding: 0 .85rem; }
  .page-header { align-items: stretch; }
  .logout-form .btn { padding-inline: .6rem; }
  .login-page { padding: 1rem; }
  .login-card { padding: 2.25rem 1.25rem 1.5rem; }
  .login-title { font-size: 1.4rem; }
  .pagination { flex-wrap: wrap; justify-content: center; }
}

@media print {
  .sidebar, .topbar, .form-actions, .table-actions, .menu-toggle { display: none !important; }
  .app-main { margin-left: 0 !important; }
}

/* ---------- Dashboard ---------- */
.alert-warning { background: var(--color-warning-light); color: var(--color-warning); border-color: #f3e0b8; }
.alert-link { display: flex; align-items: center; gap: .6rem; text-decoration: none; transition: box-shadow .15s ease; }
.alert-link:hover { box-shadow: var(--shadow-sm); }

.card-header-row h2 { display: flex; align-items: center; gap: .5rem; }

.stat-card-row { display: flex; align-items: center; gap: .85rem; }
.stat-card-icon {
  width: 42px; height: 42px; flex-shrink: 0;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
}
.stat-card-icon .icon { width: 1.3rem; height: 1.3rem; }
.stat-card-icon-primary { background: var(--color-primary-light); color: var(--color-primary-dark); }
.stat-card-icon-accent { background: #eaf6ee; color: var(--color-accent); }
.stat-card-icon-warning { background: var(--color-warning-light); color: var(--color-warning); }

.stat-delta { font-size: .78rem; color: var(--color-text-muted); margin-top: .3rem; }
.stat-delta-up { color: var(--color-warning); font-weight: 600; }
.stat-delta-down { color: var(--color-accent); font-weight: 600; }

.dashboard-grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.dashboard-grid-2 .card { margin-bottom: 0; }

.dashboard-grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.dashboard-grid-3 .card { margin-bottom: 0; }

.quick-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .4rem; }
.quick-list-item {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: .5rem;
  padding: .6rem .65rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  font-size: .88rem;
}
.quick-list-item a {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: .5rem;
  width: 100%;
  text-decoration: none;
  color: var(--color-text);
  margin: -.6rem -.65rem;
  padding: .6rem .65rem;
  border-radius: var(--radius-sm);
}
.quick-list-item a:hover { background: var(--color-bg); }
.quick-list-data { font-weight: 700; color: var(--color-primary-dark); }
.quick-list-muted { color: var(--color-text-muted); margin-left: auto; }

.motorista-resumo canvas, #chart-viagens-mes, #chart-ajuda-custo, #chart-status { max-width: 100%; }

/* ---------- Fonte maior só nos relatórios de gasto/pacientes (item "letra
   pequena nos relatórios") — não mexe no resto do sistema (dashboard,
   listagens, etc.), que continuam com o tamanho padrão acima. ---------- */
.relatorio-grande .stat-grid { grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr)); }
.relatorio-grande .stat-card .stat-label { font-size: 1.2rem; }
.relatorio-grande .stat-card .stat-value { font-size: 3rem; white-space: nowrap; }
.relatorio-grande .stat-value-sm { font-size: 2.1rem; }
.relatorio-grande table { font-size: 1.3rem; }
.relatorio-grande thead th { padding: .9rem 1rem; }
.relatorio-grande tbody td { padding: .9rem 1rem; }
.relatorio-grande .bar-list-item { font-size: 1.25rem; }
.relatorio-grande h2 { font-size: 1.5rem; }
