/* painel/estilo.css — identidade visual do painel (Instituto Balão Mágico).
 *
 * Fonte única de verdade do visual. Tudo parte dos tokens abaixo, extraídos do
 * Manual Visual do instituto (Edição 1): off-white como superfície, tinta quente
 * no lugar do preto, cantos arredondados, um destaque por composição, sem degradê.
 *
 * As variáveis --brand* são sobrescritas em runtime por painel/marca-boot.js a partir
 * de painel/config.js (COR_PRIMARIA, COR_SECUNDARIA). Os valores aqui são o padrão
 * do instituto e valem quando a config não traz cor própria.
 */

/* ===== 1. Tokens ===== */
:root {
  /* Paleta oficial */
  --c-off-white:        #F7F4EB;
  --c-off-white-raised: #FCFAF4;
  --c-sunken:           #EFEADC;
  --c-white:            #FFFFFF;
  --c-ink:              #3A342E;
  --c-warm-gray:        #BFAFA6;
  --c-warm-gray-strong: #8C7E76;
  --c-azul:             #69BAC8;
  --c-azul-soft:        #DCEEF1;
  --c-menta:            #77C5A6;
  --c-menta-soft:       #DFF2EA;
  --c-areia:            #E2C8A4;
  --c-areia-strong:     #C7A877;
  --c-areia-soft:       #F5EBDA;
  --c-mostarda:         #E9B949;
  /* Alerta: terracota calma (o manual pede avisos serenos, sem vermelho gritante) */
  --c-terracota:        #A84B33;
  --c-terracota-soft:   #F6E2DA;

  /* Marca (runtime) — padrão = Azul Sereno + Verde-Menta */
  --brand:        #69BAC8;
  --brand-2:      #77C5A6;
  --brand-rgb:    105 186 200;
  --brand-2-rgb:  119 197 166;
  --brand-text:   #3F7078;   /* azul escurecido até contraste AA no off-white */
  --brand-2-text: #477664;
  --brand-on:     #3A342E;   /* texto sobre a cor da marca: tinta quente, nunca preto */
  --brand-2-on:   #3A342E;

  /* Papéis semânticos */
  --surface-page:   var(--c-off-white);
  --surface-card:   var(--c-white);
  --surface-raised: var(--c-off-white-raised);
  --surface-sunken: var(--c-sunken);
  --text:           var(--c-ink);
  --text-sec:       #6E625B;   /* cinza quente escurecido: 5.3:1 no off-white */
  --text-muted:     var(--c-warm-gray-strong);   /* só placeholder e detalhes, nunca texto corrido */
  --border:         #E4DCCB;
  --border-strong:  #CFC3B0;
  --danger:         var(--c-terracota);
  --danger-soft:    var(--c-terracota-soft);
  --focus-ring:     var(--brand-text);

  /* Tipografia */
  --font-display: 'Quicksand', ui-rounded, system-ui, sans-serif;
  --font-body:    'Atkinson Hyperlegible', ui-sans-serif, system-ui, sans-serif;
  --fs-display: 2.5rem;   /* 40 */
  --fs-h1:      1.75rem;  /* 28 */
  --fs-h2:      1.3125rem;/* 21 */
  --fs-body:    1rem;     /* 16 */
  --fs-small:   0.9375rem;/* 15 */
  --fs-caption: 0.875rem; /* 14 — mínimo do manual em tela */

  /* Espaço (grade de 4px) */
  --space-1: 4px;  --space-2: 8px;  --space-3: 12px; --space-4: 16px;
  --space-5: 24px; --space-6: 32px; --space-7: 48px; --space-8: 64px;
  --content-max: 1080px;

  /* Forma, profundidade, movimento */
  --radius-sm:   12px;
  --radius-md:   20px;
  --radius-lg:   28px;
  --radius-pill: 999px;
  --shadow-card:   0 4px 16px rgba(140, 126, 118, 0.10);
  --shadow-raised: 0 8px 24px rgba(140, 126, 118, 0.14);
  --ease-gentle: cubic-bezier(.32, .72, .35, 1);
  --dur-fast:   150ms;
  --dur-normal: 240ms;

  --header-h: 96px;
  --bottom-nav-h: 68px;
}

/* ===== 2. Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  min-height: 100vh;
  background-color: var(--surface-page);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, .display { font-family: var(--font-display); font-weight: 700; color: var(--text); line-height: 1.25; }

.num { font-variant-numeric: tabular-nums; letter-spacing: 0.01em; }

.ico {
  width: 20px; height: 20px; flex-shrink: 0;
  fill: none; stroke: currentColor; stroke-width: 1.75;
  stroke-linecap: round; stroke-linejoin: round;
}
.ico-sm { width: 16px; height: 16px; }

:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 2px; border-radius: 8px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

#app { position: relative; }

/* ===== 3. Marca ===== */
.brand-logo { display: block; width: auto; max-width: 100%; object-fit: contain; }
/* altura mínima do manual em tela: 64px */
.login-brand .brand-logo  { height: 120px; }
.header-brand .brand-logo { height: 64px; }

.brand-text-fallback,
.login-brand, .header-brand {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--brand-text);
}

/* ===== 4. Botões ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: 44px;
  padding: 10px 20px;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  font-family: var(--font-display);
  font-size: var(--fs-small);
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color var(--dur-fast) var(--ease-gentle),
              border-color var(--dur-fast) var(--ease-gentle),
              color var(--dur-fast) var(--ease-gentle);
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--brand); color: var(--brand-on); }
.btn-primary:hover:not(:disabled) { background: color-mix(in srgb, var(--brand) 85%, var(--c-ink)); }
.btn-primary.full { width: 100%; min-height: 52px; font-size: var(--fs-body); }

.btn-ghost {
  background: var(--surface-card);
  border-color: var(--border-strong);
  color: var(--text);
}
.btn-ghost:hover:not(:disabled) { background: var(--surface-sunken); }

.btn-quiet { background: transparent; color: var(--text-sec); }
.btn-quiet:hover:not(:disabled) { background: var(--surface-sunken); color: var(--text); }

.btn-sm { min-height: 38px; padding: 7px 14px; font-size: var(--fs-caption); }
.btn-icon { width: 44px; padding: 0; }
.btn-icon.btn-sm { width: 38px; }

/* Ações de status: o "Realizado" é o único destaque (é ele que dispara retorno e avaliação) */
.btn-realizado  { background: var(--brand-2); color: var(--brand-2-on); }
.btn-realizado:hover:not(:disabled) { background: color-mix(in srgb, var(--brand-2) 85%, var(--c-ink)); }
.btn-confirmado { background: var(--surface-card); border-color: rgb(var(--brand-rgb) / 0.7); color: var(--brand-text); }
.btn-confirmado:hover:not(:disabled) { background: rgb(var(--brand-rgb) / 0.12); }
.btn-faltou     { background: var(--surface-card); border-color: rgb(168 75 51 / 0.45); color: var(--danger); }
.btn-faltou:hover:not(:disabled) { background: var(--danger-soft); }
.btn-cancelar   { background: transparent; color: var(--text-sec); }
.btn-cancelar:hover:not(:disabled) { background: var(--surface-sunken); color: var(--text); }

/* ===== 5. Formulários ===== */
.field { margin-bottom: var(--space-4); }
.field label {
  display: block;
  font-family: var(--font-display);
  font-size: var(--fs-small);
  font-weight: 600;
  color: var(--text);
  margin-bottom: var(--space-2);
}
.field-hint { display: block; font-size: var(--fs-caption); color: var(--text-sec); margin-top: var(--space-1); }

.input,
.field input, .field select {
  width: 100%;
  min-height: 48px;
  background: var(--surface-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  outline: none;
  transition: border-color var(--dur-fast) var(--ease-gentle), box-shadow var(--dur-fast) var(--ease-gentle);
}
.input:focus,
.field input:focus, .field select:focus {
  border-color: var(--brand-text);
  box-shadow: 0 0 0 3px rgb(var(--brand-rgb) / 0.25);
}
.input::placeholder, .field input::placeholder { color: var(--text-muted); }

.form-error {
  display: none;
  align-items: flex-start;
  gap: var(--space-2);
  background: var(--danger-soft);
  color: var(--danger);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: var(--fs-caption);
  margin-bottom: var(--space-4);
}

/* ===== 6. Login ===== */
#login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6) var(--space-4);
}

.login-shell {
  width: 100%;
  max-width: var(--content-max);
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  grid-template-areas: "intro card" "beneficios card";
  column-gap: var(--space-8);
  row-gap: var(--space-6);
  align-items: center;
}

.login-aside { grid-area: intro; align-self: end; }
.benefits    { grid-area: beneficios; align-self: start; }
.login-card  { grid-area: card; }
.login-brand { margin-bottom: var(--space-6); font-size: var(--fs-h1); }

.eyebrow {
  display: inline-flex; align-items: center; gap: var(--space-2);
  font-family: var(--font-display);
  font-size: var(--fs-caption);
  font-weight: 700;
  color: var(--brand-text);
  background: rgb(var(--brand-rgb) / 0.14);
  border-radius: var(--radius-pill);
  padding: 4px 12px;
  margin-bottom: var(--space-4);
}

.login-title { font-size: var(--fs-display); line-height: 1.2; margin-bottom: var(--space-4); max-width: 18ch; }
.login-lead  { font-size: 1.125rem; color: var(--text-sec); max-width: 44ch; margin-bottom: var(--space-6); }

.benefits { list-style: none; display: grid; gap: var(--space-4); }
.benefits li { display: flex; gap: var(--space-3); align-items: flex-start; }
.benefits .benefit-ico {
  width: 40px; height: 40px; border-radius: var(--radius-sm);
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface-card); border: 1px solid var(--border);
  color: var(--brand-text); flex-shrink: 0;
}
.benefits strong { display: block; font-family: var(--font-display); font-weight: 700; font-size: var(--fs-body); }
.benefits span   { display: block; font-size: var(--fs-caption); color: var(--text-sec); }

.login-card {
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-7) var(--space-6);
  box-shadow: var(--shadow-raised);
}
.login-card h1 { font-size: var(--fs-h1); margin-bottom: var(--space-2); }
.login-card .lead { color: var(--text-sec); margin-bottom: var(--space-6); }
.login-foot {
  display: flex; align-items: center; gap: var(--space-2);
  margin-top: var(--space-5);
  font-size: var(--fs-caption);
  color: var(--text-sec);
}

/* ===== 7. Estrutura do app ===== */
#main-screen { display: none; min-height: 100vh; flex-direction: column; }
#main-screen.visible { display: flex; }

.app-header {
  background: var(--surface-raised);
  border-bottom: 1px solid var(--border);
}
.app-header-inner {
  max-width: var(--content-max);
  margin: 0 auto;
  min-height: var(--header-h);
  padding: var(--space-4) var(--space-5);
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-4);
}
.header-left { display: flex; align-items: center; gap: var(--space-4); min-width: 0; }
.header-brand { font-size: var(--fs-h2); }
.header-divider { width: 1px; height: 40px; background: var(--border-strong); }
.header-label { font-family: var(--font-display); font-weight: 600; color: var(--text-sec); white-space: nowrap; }

.header-right { display: flex; align-items: center; gap: var(--space-3); min-width: 0; }
.user-chip {
  display: inline-flex; align-items: center; gap: var(--space-2);
  min-width: 0;
  font-size: var(--fs-caption);
  color: var(--text-sec);
}
.user-email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 240px; }
.user-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--c-areia-soft); color: var(--text);
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 700; text-transform: uppercase;
  flex-shrink: 0;
}

/* Abas (desktop/tablet): faixa fixa abaixo do topo */
.app-nav {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--surface-page) 92%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.app-nav-inner {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--space-3) var(--space-5);
  display: flex; gap: var(--space-2);
  overflow-x: auto;
  scrollbar-width: none;
}
.app-nav-inner::-webkit-scrollbar { display: none; }

.tab {
  display: inline-flex; align-items: center; gap: var(--space-2);
  min-height: 44px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  color: var(--text-sec);
  font-family: var(--font-display);
  font-size: var(--fs-small);
  font-weight: 600;
  padding: 8px 16px;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color var(--dur-fast) var(--ease-gentle), color var(--dur-fast) var(--ease-gentle);
}
.tab:hover { background: var(--surface-sunken); color: var(--text); }
.tab-label-short { display: none; }
.tab.active {
  background: var(--surface-card);
  border-color: var(--border);
  color: var(--brand-text);
  font-weight: 700;
  box-shadow: var(--shadow-card);
}

main {
  flex: 1;
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--space-6) var(--space-5) var(--space-7);
}

.screen { display: none; }
.screen.active { display: block; animation: aparecer var(--dur-normal) var(--ease-gentle); }
@keyframes aparecer { from { opacity: 0; } to { opacity: 1; } }

/* ===== 8. Cabeçalho de seção ===== */
.section-header {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
  margin-bottom: var(--space-5);
}
.section-heading { min-width: 0; }
.section-title-row { display: flex; align-items: baseline; gap: var(--space-3); flex-wrap: wrap; }
.section-title { font-family: var(--font-display); font-size: var(--fs-h1); font-weight: 700; color: var(--text); line-height: 1.25; }
.section-sub {
  font-size: var(--fs-caption);
  font-weight: 700;
  color: var(--text-sec);
  font-variant-numeric: tabular-nums;
}
.section-sub:empty { display: none; }
.section-desc { color: var(--text-sec); margin-top: var(--space-1); max-width: 60ch; }

/* Navegação de data */
.date-nav {
  display: flex; align-items: center; gap: var(--space-1);
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: var(--space-1);
}
.date-nav .btn { border: none; }
.agenda-tools { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.btn-remarcar { background: transparent; color: var(--text-sec); }
.btn-remarcar:hover:not(:disabled) { background: var(--surface-sunken); color: var(--text); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); }
.ag-resumo { margin-bottom: var(--space-4); font-weight: 600; }
.date-display {
  font-family: var(--font-display);
  font-weight: 700;
  min-width: 120px;
  text-align: center;
  text-transform: capitalize;
}

/* ===== 9. Resumo do dia ===== */
.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-5);
}
.stats:empty { display: none; }
.stat {
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
}
.stat-label {
  display: flex; align-items: center; gap: var(--space-2);
  font-size: var(--fs-caption); color: var(--text-sec);
}
.stat-value {
  font-family: var(--font-display);
  font-size: var(--fs-h1);
  font-weight: 700;
  line-height: 1.2;
  margin-top: var(--space-1);
  font-variant-numeric: tabular-nums;
}

.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; background: var(--border-strong); }
.dot-agendado   { background: var(--c-areia-strong); }
.dot-confirmado { background: var(--brand); }
.dot-realizado  { background: var(--brand-2); }
.dot-faltou     { background: var(--danger); }
.dot-cancelado  { background: var(--c-warm-gray); }

/* Aviso informativo */
.note {
  display: flex; gap: var(--space-3); align-items: flex-start;
  background: rgb(var(--brand-rgb) / 0.12);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  font-size: var(--fs-small);
  color: var(--text);
  margin-bottom: var(--space-5);
}
.note .ico { color: var(--brand-text); margin-top: 2px; }

/* ===== 10. Cartões e listas ===== */
.card, .list-item {
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: border-color var(--dur-fast) var(--ease-gentle), box-shadow var(--dur-fast) var(--ease-gentle);
}
.card:hover, .list-item:hover { border-color: var(--border-strong); box-shadow: var(--shadow-card); }

.stack { display: grid; gap: var(--space-3); }

/* Agendamento */
.card { padding: var(--space-4) var(--space-5); }
.agenda-row {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) auto;
  grid-template-areas: "hora info status" "hora acoes acoes";
  column-gap: var(--space-4);
  row-gap: var(--space-3);
  align-items: center;
}
.agenda-time {
  grid-area: hora;
  align-self: start;
  font-family: var(--font-display);
  font-size: var(--fs-h2);
  font-weight: 700;
  color: var(--brand-text);
  font-variant-numeric: tabular-nums;
  padding-top: 2px;
}
.agenda-info   { grid-area: info; min-width: 0; }
.agenda-status { grid-area: status; justify-self: end; }
.agenda-nome { font-family: var(--font-display); font-weight: 700; font-size: 1.0625rem; color: var(--text); }
.agenda-proc { font-size: var(--fs-small); color: var(--text-sec); margin-top: 2px; display: flex; flex-wrap: wrap; gap: 0 var(--space-2); }
.agenda-actions { grid-area: acoes; display: flex; gap: var(--space-2); flex-wrap: wrap; }
.agenda-done { font-size: var(--fs-caption); color: var(--text-sec); display: inline-flex; align-items: center; gap: var(--space-2); }

.sep::before { content: "·"; margin-right: var(--space-2); color: var(--c-warm-gray); }

/* Badge de status: ponto + texto (a cor nunca informa sozinha) */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-display);
  font-size: var(--fs-caption);
  font-weight: 700;
  padding: 3px 12px 3px 10px;
  border-radius: var(--radius-pill);
  white-space: nowrap;
}
.badge::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; opacity: 0.85; }
.badge-agendado   { background: var(--c-areia-soft);            color: #7A6440; }
.badge-confirmado { background: rgb(var(--brand-rgb) / 0.16);   color: var(--brand-text); }
.badge-realizado  { background: rgb(var(--brand-2-rgb) / 0.2);  color: var(--brand-2-text); }
.badge-cancelado  { background: var(--surface-sunken);          color: var(--text-sec); }
.badge-faltou     { background: var(--danger-soft);             color: var(--danger); }

/* Busca */
.search-wrap { position: relative; margin-bottom: var(--space-4); }
.search-wrap .ico { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: var(--text-muted); pointer-events: none; }
.search-wrap input { padding-left: 46px; border-radius: var(--radius-pill); }

/* Itens de lista */
.list-item {
  padding: var(--space-4) var(--space-5);
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
}
.list-item-main { display: flex; align-items: center; gap: var(--space-4); min-width: 0; flex: 1; }
.list-item-title { font-family: var(--font-display); font-weight: 700; color: var(--text); font-size: 1.0625rem; }
.list-item-sub   { font-size: var(--fs-small); color: var(--text-sec); margin-top: 2px; display: flex; flex-wrap: wrap; gap: 0 var(--space-2); }
.list-item-actions { display: flex; gap: var(--space-2); align-items: center; flex-shrink: 0; }

.avatar {
  width: 44px; height: 44px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--c-areia-soft); color: #7A6440;
  font-family: var(--font-display); font-weight: 700;
  flex-shrink: 0;
}
.posicao {
  width: 44px; height: 44px; border-radius: var(--radius-sm);
  display: inline-flex; align-items: center; justify-content: center;
  background: rgb(var(--brand-rgb) / 0.14); color: var(--brand-text);
  font-family: var(--font-display); font-weight: 700; font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

/* Serviços: edição em linha */
.proc-fields { display: flex; flex-wrap: wrap; gap: var(--space-3) var(--space-5); align-items: center; margin-top: var(--space-3); }
.inline-edit { display: flex; align-items: center; gap: var(--space-2); }
.inline-edit label { font-size: var(--fs-caption); color: var(--text-sec); }
.inline-edit input[type="number"] {
  width: 88px;
  min-height: 40px;
  background: var(--surface-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  font-variant-numeric: tabular-nums;
  text-align: right;
  outline: none;
}
.inline-edit input[type="number"]:focus {
  border-color: var(--brand-text);
  box-shadow: 0 0 0 3px rgb(var(--brand-rgb) / 0.25);
}
.chip {
  display: inline-flex; align-items: center;
  font-size: var(--fs-caption); font-weight: 700;
  color: var(--text-sec);
  background: var(--surface-sunken);
  border-radius: var(--radius-pill);
  padding: 3px 12px;
  font-variant-numeric: tabular-nums;
}

/* Mensagens: conversa */
.msg { display: flex; }
.msg-out { justify-content: flex-end; }
.msg-bubble {
  max-width: min(640px, 88%);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  background: var(--surface-card);
  border: 1px solid var(--border);
}
.msg-in  .msg-bubble { border-bottom-left-radius: 6px; }
.msg-out .msg-bubble { border-bottom-right-radius: 6px; background: rgb(var(--brand-rgb) / 0.12); border-color: rgb(var(--brand-rgb) / 0.3); }
.msg-meta {
  display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-1) var(--space-3);
  font-size: var(--fs-caption); color: var(--text-sec);
  margin-bottom: var(--space-1);
}
.msg-tel { font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.msg-dir { display: inline-flex; align-items: center; gap: 4px; font-weight: 700; }
.msg-in  .msg-dir { color: var(--text-sec); }
.msg-out .msg-dir { color: var(--brand-text); }
.msg-agente { background: var(--c-areia-soft); color: #7A6440; border-radius: var(--radius-pill); padding: 0 10px; font-weight: 700; }
.msg-hora { margin-left: auto; font-variant-numeric: tabular-nums; }
.msg-corpo { white-space: pre-wrap; word-break: break-word; color: var(--text); }

/* ===== 11. Estados: vazio, erro, carregando ===== */
.empty {
  text-align: center;
  padding: var(--space-7) var(--space-5);
  background: var(--surface-raised);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  color: var(--text-sec);
}
.empty-ico {
  width: 56px; height: 56px; border-radius: 50%;
  margin: 0 auto var(--space-4);
  display: flex; align-items: center; justify-content: center;
  background: rgb(var(--brand-rgb) / 0.14); color: var(--brand-text);
}
.empty-ico .ico { width: 26px; height: 26px; }
.empty strong { display: block; font-family: var(--font-display); color: var(--text); margin-bottom: var(--space-1); font-size: var(--fs-h2); }
.empty.is-error { border-style: solid; border-color: rgb(168 75 51 / 0.3); background: var(--danger-soft); }
.empty.is-error .empty-ico { background: var(--surface-card); color: var(--danger); }
.empty.is-error strong { color: var(--danger); }

.loading-row {
  display: flex; align-items: center; justify-content: center; gap: var(--space-3);
  color: var(--text-sec);
  padding: var(--space-7) 0;
}
.spinner {
  display: inline-block;
  width: 22px; height: 22px;
  border: 3px solid var(--border);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: girar 1.1s linear infinite;
}
@keyframes girar { to { transform: rotate(360deg); } }

/* ===== 12. Toast ===== */
#toast {
  position: fixed;
  right: var(--space-5);
  bottom: var(--space-5);
  z-index: 100;
  max-width: 400px;
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  background: var(--surface-card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-raised);
  font-size: var(--fs-small);
  font-weight: 700;
  color: var(--text);
  pointer-events: none;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity var(--dur-normal) var(--ease-gentle), transform var(--dur-normal) var(--ease-gentle);
}
#toast::before {
  content: ""; width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
}
#toast.visible { opacity: 1; transform: translateY(0); }
#toast.success { border-color: rgb(var(--brand-2-rgb) / 0.6); }
#toast.success::before { background: var(--brand-2); }
#toast.error   { background: var(--danger-soft); border-color: rgb(168 75 51 / 0.35); color: var(--danger); }
#toast.error::before { background: var(--danger); }

/* ===== 13. Modal ===== */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgb(58 52 46 / 0.42);
  z-index: 50;
  display: flex; align-items: center; justify-content: center;
  padding: var(--space-5);
}
.modal-backdrop.hidden { display: none; }
.modal {
  background: var(--surface-card);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  width: 100%;
  max-width: 460px;
  box-shadow: var(--shadow-raised);
  animation: subir var(--dur-normal) var(--ease-gentle);
}
@keyframes subir { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.modal h2 { font-size: var(--fs-h2); margin-bottom: var(--space-1); }
.modal .lead { color: var(--text-sec); font-size: var(--fs-small); margin-bottom: var(--space-5); }
.modal-actions { display: flex; gap: var(--space-3); margin-top: var(--space-5); justify-content: flex-end; }

/* ===== 14. Rodapé ===== */
.app-footer { border-top: 1px solid var(--border); }
.app-footer-inner {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--space-5);
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-2) var(--space-5);
  font-size: var(--fs-caption);
  color: var(--text-sec);
}
.app-footer strong { font-family: var(--font-display); color: var(--text); }
.footer-status { display: inline-flex; align-items: center; gap: var(--space-2); }

/* Tela de configuração ausente */
.config-erro { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: var(--space-5); }
.config-erro .empty { max-width: 520px; }
.config-erro code { font-size: var(--fs-caption); background: var(--surface-card); border-radius: 6px; padding: 1px 6px; }

/* ===== 15. Responsivo ===== */

/* Tablet */
@media (max-width: 960px) {
  .login-shell { grid-template-columns: 1fr; grid-template-areas: "intro" "card" "beneficios"; gap: var(--space-6); max-width: 560px; }
  .login-aside { text-align: center; }
  .login-brand { display: flex; justify-content: center; margin-bottom: var(--space-4); }
  .login-brand .brand-logo { height: 96px; }
  .login-title { font-size: 2rem; margin-inline: auto; }
  .login-lead { margin-inline: auto; margin-bottom: 0; }
  /* benefícios descem para depois do formulário */
  .benefits { text-align: left; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-3); }
  .benefits li { flex-direction: column; background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--radius-md); padding: var(--space-4); }

  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .header-label { display: none; }
  .header-divider { display: none; }
}

/* Mobile */
@media (max-width: 640px) {
  :root { --header-h: 80px; }

  #login-screen { align-items: flex-start; padding: var(--space-5) var(--space-4) var(--space-6); }
  .login-shell { gap: var(--space-5); }
  .login-brand .brand-logo { height: 80px; }
  .login-title { font-size: var(--fs-h1); }
  .login-lead { font-size: var(--fs-body); }
  .login-card { padding: var(--space-5); border-radius: var(--radius-md); }
  .benefits { grid-template-columns: 1fr; }
  .benefits li { flex-direction: row; }

  .app-header-inner { padding: var(--space-2) var(--space-4); }
  .header-brand .brand-logo { height: 64px; }
  .user-email { display: none; }
  #logout-btn .btn-label { display: none; }
  #logout-btn { width: 44px; padding: 0; }

  /* Abas viram barra inferior com ícone + rótulo curto */
  .app-nav {
    position: fixed; top: auto; bottom: 0; left: 0; right: 0;
    border-bottom: none; border-top: 1px solid var(--border);
    background: var(--surface-raised);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .app-nav-inner { padding: var(--space-1) var(--space-1); gap: 0; justify-content: space-between; overflow: visible; }
  .tab {
    flex: 1 1 0; min-width: 0;
    flex-direction: column; gap: 2px;
    min-height: 58px;
    padding: 6px 2px;
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    border: none;
  }
  .tab .tab-label-long { display: none; }
  .tab .tab-label-short { display: inline; }
  .tab.active { box-shadow: none; background: rgb(var(--brand-rgb) / 0.14); }
  #main-screen { padding-bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom)); }

  main { padding: var(--space-5) var(--space-4) var(--space-6); }
  .section-header { align-items: stretch; flex-direction: column; }
  .section-title { font-size: 1.5rem; }
  .section-header > .btn { width: 100%; }
  .agenda-tools { flex-direction: column; align-items: stretch; }
  .agenda-tools > .btn { width: 100%; }
  .date-nav { justify-content: space-between; }
  .date-display { flex: 1; }

  .stats { gap: var(--space-2); }
  .stat { padding: var(--space-3); }
  .stat-value { font-size: var(--fs-h2); }

  .card { padding: var(--space-4); }
  .agenda-row {
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-areas: "hora status" "info info" "acoes acoes";
  }
  .agenda-status { justify-self: end; }
  .agenda-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .agenda-actions .btn { width: 100%; }
  .agenda-actions .btn-realizado { grid-column: 1 / -1; min-height: 44px; }
  .agenda-actions .agenda-done { grid-column: 1 / -1; }

  .list-item { padding: var(--space-4); }
  .list-item-actions { width: 100%; }
  .list-item-actions .btn { width: 100%; }
  .proc-fields { gap: var(--space-3); }

  .msg-bubble { max-width: 94%; }

  #toast { left: var(--space-4); right: var(--space-4); max-width: none; bottom: calc(var(--bottom-nav-h) + var(--space-3) + env(safe-area-inset-bottom)); }

  /* Modal vira folha inferior */
  .modal-backdrop { align-items: flex-end; padding: 0; }
  .modal { max-width: none; border-radius: var(--radius-lg) var(--radius-lg) 0 0; padding: var(--space-5) var(--space-4) calc(var(--space-5) + env(safe-area-inset-bottom)); }
  .modal-actions { flex-direction: column-reverse; }
  .modal-actions .btn { width: 100%; }

  .app-footer-inner { justify-content: center; text-align: center; padding: var(--space-4); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  .spinner { animation: girar 2.4s linear infinite !important; }
}
