/* ===================================================================
   Sistema de Consultas — Mobile-first (uso em celular)
   No desktop, o app aparece centralizado como uma "moldura" de celular.
   =================================================================== */

:root {
  --brand:        #2563eb;
  --brand-dark:   #1d4ed8;
  --brand-soft:   #eff4ff;
  --bg:           #eef1f6;
  --surface:      #ffffff;
  --text:         #1e293b;
  --text-soft:    #64748b;
  --border:       #e2e8f0;
  --success:      #16a34a;
  --danger:       #dc2626;
  --shadow:       0 10px 30px rgba(15, 23, 42, .10);
  --radius:       14px;
  --app-max:      480px;   /* largura máxima = tela de celular */
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; }

body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===================================================================
   App shell — coluna de celular centralizada
   =================================================================== */
.app {
  width: 100%;
  max-width: var(--app-max);
  min-height: 100vh;
  margin: 0 auto;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  position: relative;
}
/* No desktop: dá contorno de celular */
@media (min-width: 520px) {
  body { padding: 20px 0; }
  .app {
    min-height: calc(100vh - 40px);
    border-radius: 24px;
    box-shadow: var(--shadow);
    overflow: hidden;
  }
}

/* ---------- Botões (grandes, bons para toque) ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 12px;
  padding: 14px 18px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  min-height: 48px;
  text-decoration: none;
  transition: background .15s, transform .05s;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-ghost {
  background: #fff;
  color: var(--text-soft);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: #f1f5f9; }
.btn-block { width: 100%; }
.btn-sm { padding: 9px 14px; font-size: 14px; min-height: 40px; }

/* ---------- Campos ---------- */
.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-soft);
  margin-bottom: 6px;
}
.field input,
.field select {
  width: 100%;
  padding: 14px;
  font-size: 16px;               /* 16px evita zoom automático no iOS */
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  color: var(--text);
  transition: border .15s, box-shadow .15s;
}
.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

/* ---------- Mensagens ---------- */
.msg {
  font-size: 14px;
  padding: 11px 14px;
  border-radius: 10px;
  margin-bottom: 14px;
  display: none;
}
.msg.show { display: block; }
.msg.error   { background: #fef2f2; color: var(--danger);  border: 1px solid #fecaca; }
.msg.success { background: #f0fdf4; color: var(--success); border: 1px solid #bbf7d0; }

/* ===================================================================
   Telas de autenticação (login / cadastro)
   =================================================================== */
.auth {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 28px 22px;
  background: linear-gradient(160deg, #eef2ff 0%, #f7f9fc 60%);
}
.auth-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 26px;
}
.auth-logo .mark {
  width: 52px; height: 52px;
  border-radius: 14px;
  background: var(--brand);
  color: #fff;
  display: grid; place-items: center;
  font-size: 24px; font-weight: 700;
}
.auth-logo h1 { font-size: 21px; }
.auth-logo p  { font-size: 14px; color: var(--text-soft); }
.auth-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px 20px;
}
.auth-foot {
  text-align: center;
  font-size: 15px;
  color: var(--text-soft);
  margin-top: 20px;
}
.auth-foot + .auth-foot { margin-top: 8px; }

/* Utilitário: esconder elementos */
.hidden { display: none !important; }

/* Dica dentro dos cards de auth */
.auth-hint {
  font-size: 13px;
  color: var(--text-soft);
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  margin: 0 0 16px;
  line-height: 1.4;
}

/* Espaçamento entre botões empilhados no card de auth */
.btn-block + .btn-block { margin-top: 10px; }
.auth-card form + .btn-block { margin-top: 12px; }

/* ===================================================================
   Cabeçalho do app
   =================================================================== */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky; top: 0; z-index: 20;
}
.topbar .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; }
.topbar .brand .mark {
  width: 34px; height: 34px;
  border-radius: 9px;
  background: var(--brand);
  color: #fff;
  display: grid; place-items: center;
  font-weight: 700;
}
.topbar .icon-btn {
  border: none;
  background: transparent;
  color: var(--text-soft);
  font-size: 22px;
  width: 42px; height: 42px;
  border-radius: 10px;
  cursor: pointer;
  display: grid; place-items: center;
}
.topbar .icon-btn:active { background: #f1f5f9; }

/* ===================================================================
   Conteúdo do painel
   =================================================================== */
.content { flex: 1; padding: 16px; padding-bottom: 84px; }

/* ===================================================================
   Menu inferior (tab bar)
   =================================================================== */
.tabbar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--app-max);
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
}
.tabbar .tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 4px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-soft);
  text-decoration: none;
}
.tabbar .tab:hover { text-decoration: none; }
.tabbar .tab .tab-ic { font-size: 20px; line-height: 1; opacity: .7; }
.tabbar .tab.active {
  color: var(--brand);
  background: var(--brand-soft);
  pointer-events: none;   /* aba atual não é clicável */
  cursor: default;
}
.tabbar .tab.active .tab-ic { opacity: 1; }

/* No desktop, alinha a barra fixa ao rodapé da moldura de celular */
@media (min-width: 520px) {
  .tabbar {
    bottom: 20px;
    border-bottom-left-radius: 24px;
    border-bottom-right-radius: 24px;
  }
}

.page-title { font-size: 20px; margin-bottom: 2px; }
.page-sub { color: var(--text-soft); font-size: 14px; margin-bottom: 18px; }

/* ---------- Estatísticas (linha compacta) ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 10px;
  text-align: center;
}
.stat .value { font-size: 22px; font-weight: 700; }
.stat .value.brand { color: var(--brand); }
.stat .label { font-size: 11px; color: var(--text-soft); margin-top: 2px; }

/* ---------- Busca + filtros ---------- */
.search {
  position: relative;
  margin-bottom: 10px;
}
.search input {
  width: 100%;
  padding: 14px 14px 14px 44px;
  font-size: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
}
.search input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.search .ic {
  position: absolute;
  left: 14px; top: 50%;
  transform: translateY(-50%);
  font-size: 18px;
  opacity: .5;
}

.filter-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 10px;
}
.filter-row--full { grid-template-columns: 1fr; }
.filter-row select {
  width: 100%;
  padding: 12px;
  font-size: 15px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
}
.filter-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}
.filter-actions .count { font-size: 16px; font-weight: 700; color: var(--text); }

/* ---------- Lista de resultados (cards) ---------- */
.list { display: flex; flex-direction: column; gap: 12px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.card .name {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.card .rows { display: flex; flex-direction: column; gap: 5px; }
.card .r {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text-soft);
}
.card .r .ic { width: 18px; text-align: center; opacity: .7; }
.card .r a { color: var(--brand); font-weight: 600; }

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--brand-soft);
  color: var(--brand-dark);
  white-space: nowrap;
}
.badge-lider {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fcd34d;
}

.empty {
  padding: 50px 20px;
  text-align: center;
  color: var(--text-soft);
}
.empty .big { font-size: 44px; margin-bottom: 10px; }

/* ===================================================================
   Agenda
   =================================================================== */
.agenda-form { margin-bottom: 18px; }
.form-actions { display: flex; gap: 10px; }
.form-actions .btn { flex: 1; }
.agenda-group { margin-bottom: 18px; }
.agenda-date {
  font-size: 13px;
  font-weight: 700;
  color: var(--brand-dark);
  text-transform: uppercase;
  letter-spacing: .3px;
  margin-bottom: 8px;
}
.agenda-group .card { margin-bottom: 10px; }
.agenda-actions { display: flex; gap: 8px; margin-top: 10px; }
.agenda-actions .btn { flex: 1; }
.export-area.exporting .agenda-actions { display: none; }

/* ---------- Relatório em formato de calendário (exportação) ---------- */
.cal-report {
  width: 1000px;
  background: #fff;
  padding: 20px;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  color: #1e293b;
}
.cal-report-head { font-size: 20px; font-weight: 700; margin-bottom: 14px; }
.cal { margin-bottom: 22px; }
.cal-title {
  font-size: 16px;
  font-weight: 700;
  color: #1d4ed8;
  margin-bottom: 8px;
  text-transform: capitalize;
}
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  overflow: hidden;
}
.cal-head {
  background: #2563eb;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  padding: 8px 4px;
}
.cal-cell {
  min-height: 92px;
  border-top: 1px solid #e2e8f0;
  border-left: 1px solid #e2e8f0;
  padding: 4px 5px 6px;
}
.cal-cell:nth-child(7n + 1) { border-left: none; }
.cal-empty { background: #f8fafc; }
.cal-daynum { font-size: 12px; font-weight: 700; color: #64748b; margin-bottom: 3px; }
.cal-ev {
  font-size: 10px;
  line-height: 1.25;
  background: #eff4ff;
  color: #1e293b;
  border-radius: 5px;
  padding: 2px 4px;
  margin-bottom: 3px;
  word-break: break-word;
}
.cal-ev b { color: #1d4ed8; }
.cal-vazio { padding: 30px; text-align: center; color: #64748b; }

/* ===================================================================
   Estatística — títulos de seção e barras
   =================================================================== */
.section-title {
  font-size: 15px;
  font-weight: 700;
  margin: 18px 0 10px;
}
/* Exportação (PDF / PNG) */
.export-row {
  display: flex;
  gap: 10px;
  margin: 12px 0 4px;
}
.export-row .btn { flex: 1; }
.export-area {
  background: var(--bg);
  border-radius: 12px;
  padding: 14px;
  margin-top: 8px;
}
.export-head {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 12px;
}
.export-head strong { font-size: 15px; }
.export-filtro { font-size: 12px; color: var(--text-soft); }

.bars { display: flex; flex-direction: column; gap: 12px; }
.bar-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
}
.bar-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
  gap: 8px;
}
.bar-name { font-size: 14px; font-weight: 600; }
.bar-val { font-size: 12px; color: var(--text-soft); white-space: nowrap; }
.bar-track {
  height: 8px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  background: var(--brand);
  border-radius: 999px;
  transition: width .3s ease;
}
