/**
 * Amaltea — Design System
 * © 2026 Sónia Huerga, Daniel Lanzas, Sónia Semião
 * Serviço de Neonatologia · ULS Amadora Sintra — HFF
 *
 * Paleta: Terracota · Fundo creme · Sage verde
 */

/* ───────────────────────── Tokens globais ───────────────────────── */

:root {
  --font-display: "Playfair Display", Georgia, serif;
  --font-body: "DM Sans", "Helvetica Neue", sans-serif;

  --radius-s: 10px;
  --radius-m: 16px;
  --radius-l: 24px;
  --shadow-1: 0 2px 16px rgba(160, 80, 30, 0.10);
  --shadow-2: 0 6px 28px rgba(160, 80, 30, 0.17);
  --touch: 44px;

  --danger:  #D95F5F;
  --warning: #D4973A;
  --success: #5EA87D;

  --nav-h:    64px;
  --footer-h: 56px;
  --safe-b:   env(safe-area-inset-bottom, 0px);
}

/* ───────────── Perfil MÃE — claro ───────────── */
[data-profile="madre"][data-theme="light"],
[data-profile="madre"]:not([data-theme]) {
  --primary:        #D4895A;
  --primary-strong: #B86E3E;
  --secondary:      #8BAF9A;
  --bg:             #FDF5EE;
  --surface:        #FFFFFF;
  --surface-2:      #F7EDE2;
  --text:           #2A1810;
  --text-soft:      #7A5F4E;
  --border:         #EAD8C8;
  --on-primary:     #FFFFFF;
  --accent-gold:    #9B8455;
}

/* ───────────── Perfil MÃE — escuro ───────────── */
[data-profile="madre"][data-theme="dark"] {
  --primary:        #C47B55;
  --primary-strong: #D48A66;
  --secondary:      #7A9C89;
  --bg:             #1A1310;
  --surface:        #251D18;
  --surface-2:      #30261F;
  --text:           #F5EDE5;
  --text-soft:      #B09080;
  --border:         #3D2F26;
  --on-primary:     #1A1310;
  --accent-gold:    #B8A070;
  --shadow-1: 0 2px 10px rgba(0, 0, 0, 0.4);
  --shadow-2: 0 6px 24px rgba(0, 0, 0, 0.5);
}

/* ───────────── Perfil PROFISSIONAL — claro ───────────── */
[data-profile="pro"][data-theme="light"],
[data-profile="pro"]:not([data-theme]) {
  --primary:        #C17B50;
  --primary-strong: #9E6035;
  --secondary:      #7A9C89;
  --bg:             #F8F4F0;
  --surface:        #FFFFFF;
  --surface-2:      #F0E9E2;
  --text:           #1E1713;
  --text-soft:      #6B5A4E;
  --border:         #E5D8CE;
  --on-primary:     #FFFFFF;
  --accent-gold:    #9B8455;
}

/* ───────────── Perfil PROFISSIONAL — escuro ───────────── */
[data-profile="pro"][data-theme="dark"] {
  --primary:        #C47B55;
  --primary-strong: #D48A66;
  --secondary:      #7A9C89;
  --bg:             #141110;
  --surface:        #1E1813;
  --surface-2:      #28201A;
  --text:           #F0E8E0;
  --text-soft:      #A09080;
  --border:         #35281F;
  --on-primary:     #141110;
  --accent-gold:    #B8A070;
  --shadow-1: 0 2px 10px rgba(0, 0, 0, 0.45);
  --shadow-2: 0 6px 24px rgba(0, 0, 0, 0.55);
}

/* ───────────── Aliases de compatibilidade ───────────── */
:root,
[data-profile="madre"][data-theme="light"],
[data-profile="madre"][data-theme="dark"],
[data-profile="pro"][data-theme="light"],
[data-profile="pro"][data-theme="dark"] {
  --color-primary:    var(--primary);
  --color-primary-dk: var(--primary-strong);
  --color-secondary:  var(--secondary);
  --color-danger:     var(--danger);
  --bg-card:          var(--surface);
  --bg-input:         var(--surface-2);
  --text-muted:       var(--text-soft);
  --shadow:           var(--shadow-1);
  --shadow-lg:        var(--shadow-2);
  --radius:           var(--radius-m);
  --radius-sm:        var(--radius-s);
}

/* ───────────────────────── Reset & Base ───────────────────────── */

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
  min-height: 100dvh;
  transition: background 0.3s ease, color 0.3s ease;
}

h1, h2, h3, .display {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.2;
  margin: 0 0 0.5em;
}

h1 { font-size: 1.7rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.1rem; }

p { margin: 0 0 0.8em; }

a { color: var(--primary-strong); }

img { max-width: 100%; }

[hidden] { display: none !important; }

/* ───────────────────────── Layout ───────────────────────── */

#app {
  max-width: 560px;
  margin: 0 auto;
  padding: 16px 16px calc(var(--nav-h) + var(--footer-h) + var(--safe-b) + 24px);
}

[data-profile="pro"] #app { max-width: 1080px; }

/* ───────── Splash de arranque ───────── */

.boot-splash {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 70vh; text-align: center; gap: 12px;
}

.boot-logo {
  width: 180px;
  height: 180px;
  object-fit: contain;
  border-radius: var(--radius-m);
}

.boot-title {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary-strong);
  letter-spacing: 0.06em;
  margin: 0;
}

.boot-subtitle {
  font-size: 0.85rem;
  color: var(--accent-gold, var(--text-soft));
  font-style: italic;
  margin: 0;
}

/* mantém compatibilidade com .boot-drop / .boot-sub usados no spinner() */
.boot-drop { font-size: 3.4rem; animation: drop-pulse 1.6s ease-in-out infinite; }
.boot-sub  { color: var(--text-soft); margin-top: 0.2em; }

@keyframes drop-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.1); opacity: 0.78; }
}

.view-header { margin: 8px 0 20px; }
.view-header .subtitle { color: var(--text-soft); font-size: 0.95rem; }

/* ───────────────────────── Cards ───────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-1);
  padding: 20px;
  margin-bottom: 14px;
  transition: box-shadow 0.2s ease;
}

.card.accent { border-left: 4px solid var(--primary); }
.card.danger-edge { border-left: 4px solid var(--danger); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-4 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 720px) { .grid-4 { grid-template-columns: repeat(4, 1fr); } }

.stat-card { text-align: center; padding: 14px 10px; }
.stat-card .value {
  font-family: var(--font-display);
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--primary-strong);
  display: block;
}
.stat-card .label { font-size: 0.78rem; color: var(--text-soft); }

/* ───────────────────────── Botões ───────────────────────── */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--touch);
  padding: 10px 22px;
  border: none;
  border-radius: var(--radius-l);
  font-family: var(--font-body);
  font-size: 1rem; font-weight: 500;
  cursor: pointer;
  background: var(--surface-2);
  color: var(--text);
  transition: transform 0.12s ease, box-shadow 0.2s ease, opacity 0.2s;
  -webkit-tap-highlight-color: transparent;
  text-decoration: none;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary   { background: var(--primary); color: var(--on-primary); box-shadow: var(--shadow-1); }
.btn-primary:hover { box-shadow: var(--shadow-2); }
.btn-secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-warning   { background: #C96A3A; color: #fff; } /* terracota-ambar — ação irreversível mas não crítica */
.btn-ghost     { background: transparent; border: 1.5px solid var(--border); color: var(--primary-strong); }
.btn-block { width: 100%; }
.btn-lg { font-size: 1.1rem; padding: 16px 28px; }
.btn-sm { min-height: 36px; padding: 6px 14px; font-size: 0.88rem; border-radius: 12px; }

/* CTA fixo de registo */
.cta-register {
  position: sticky;
  bottom: calc(var(--nav-h) + var(--footer-h) + var(--safe-b) + 10px);
  z-index: 5; width: 100%;
  font-size: 1.15rem;
}

/* ───────────────────────── Formulários ───────────────────────── */

.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 500; margin-bottom: 6px; font-size: 0.95rem; }
.field .hint { font-size: 0.8rem; color: var(--text-soft); margin-top: 4px; }

input[type="text"], input[type="number"], input[type="email"], input[type="password"],
input[type="date"], input[type="time"], select, textarea {
  width: 100%;
  min-height: var(--touch);
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-s);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1rem;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
  border-color: var(--primary);
}
textarea { resize: vertical; min-height: 80px; }

input[type="range"] { width: 100%; accent-color: var(--primary); min-height: var(--touch); }

.choice-row { display: flex; gap: 10px; flex-wrap: wrap; }
.choice-btn {
  flex: 1; min-width: 90px; min-height: 56px;
  border: 2px solid var(--border);
  border-radius: var(--radius-m);
  background: var(--surface);
  color: var(--text);
  font-size: 1rem; font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}
.choice-btn.selected {
  border-color: var(--primary);
  background: var(--primary);
  color: var(--on-primary);
}

/* Emoções */
.mood-row { display: flex; justify-content: space-between; gap: 6px; }
.mood-btn {
  flex: 1; aspect-ratio: 1; max-width: 72px;
  font-size: 1.9rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-m);
  background: var(--surface);
  cursor: pointer;
  transition: all 0.15s ease;
}
.mood-btn.selected { border-color: var(--primary); background: var(--surface-2); transform: scale(1.08); }
.mood-label { font-size: 0.68rem; display: block; color: var(--text-soft); margin-top: 2px; }

/* ───────────────────────── Barra de progresso ───────────────────────── */

.progress-wrap { background: var(--surface-2); border-radius: 99px; height: 18px; overflow: hidden; }
.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--secondary), var(--primary));
  border-radius: 99px;
  transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1);
  min-width: 6px;
}
.progress-meta { display: flex; justify-content: space-between; font-size: 0.85rem; color: var(--text-soft); margin-top: 6px; }

/* ───────────────────────── Listas ───────────────────────── */

.extraction-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--border);
}
.extraction-item:last-child { border-bottom: none; }
.extraction-item .ml { font-family: var(--font-display); font-weight: 700; font-size: 1.15rem; color: var(--primary-strong); }
.extraction-item .meta { font-size: 0.85rem; color: var(--text-soft); }

/* ───────────────────────── Badges ───────────────────────── */

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 0.78rem; font-weight: 500;
  padding: 3px 10px;
  border-radius: 99px;
  background: var(--surface-2);
}
.badge.ok   { background: color-mix(in srgb, var(--success) 20%, transparent); color: var(--success); }
.badge.warn { background: color-mix(in srgb, var(--warning) 22%, transparent); color: #9A6D1A; }
.badge.alert{ background: color-mix(in srgb, var(--danger)  20%, transparent); color: var(--danger); }
[data-theme="dark"] .badge.warn { color: var(--warning); }

.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot.green  { background: var(--success); animation: drop-pulse 2s infinite; }
.dot.red    { background: var(--danger); }
.dot.yellow { background: var(--warning); }

/* ───────────────────────── Navegação inferior ───────────────────────── */

.bottom-nav {
  position: fixed;
  bottom: calc(var(--footer-h) + var(--safe-b));
  left: 0;
  right: 0;
  height: var(--nav-h);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 50;
  /* Sem max-width — a nav ocupa toda a largura do ecrã */
}

/* Quando a nav está visível, oculta o footer e desce a nav para o fundo */
body.nav-visible .app-footer { display: none; }
body.nav-visible .bottom-nav { bottom: var(--safe-b); }
body.nav-visible #app       { padding-bottom: calc(var(--nav-h) + var(--safe-b) + 24px); }
body.nav-visible .cta-register { bottom: calc(var(--nav-h) + var(--safe-b) + 10px); }
body.nav-visible .chat-fab  { bottom: calc(var(--nav-h) + var(--safe-b) + 16px); }

.nav-item {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  background: none; border: none;
  font-family: var(--font-body); font-size: 0.64rem; font-weight: 500;
  color: var(--text-soft);
  cursor: pointer;
  min-height: var(--touch);
  padding: 6px 4px;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.15s;
}

.nav-item svg { display: block; flex-shrink: 0; }

.nav-item.active {
  color: var(--primary-strong);
  font-weight: 700;
}

.nav-item.active svg {
  stroke: var(--primary-strong);
}

/* ───────────────────────── FAB chat ───────────────────────── */

.chat-fab {
  position: fixed;
  right: 16px;
  bottom: calc(var(--nav-h) + var(--footer-h) + var(--safe-b) + 16px);
  width: 56px; height: 56px;
  border-radius: 50%;
  border: none;
  background: var(--secondary);
  color: #fff;
  font-size: 1.5rem;
  box-shadow: var(--shadow-2);
  cursor: pointer;
  z-index: 60;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.15s;
}
.chat-fab:active { transform: scale(0.93); }

/* ───────────────────────── Chat ───────────────────────── */

.chat-box { display: flex; flex-direction: column; gap: 10px; min-height: 50vh; }
.chat-msg { max-width: 85%; padding: 10px 14px; border-radius: var(--radius-m); font-size: 0.95rem; }
.chat-msg.user { align-self: flex-end; background: var(--primary); color: var(--on-primary); border-bottom-right-radius: 4px; }
.chat-msg.bot  { align-self: flex-start; background: var(--surface-2); border-bottom-left-radius: 4px; }
.chip-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.chip {
  border: 1.5px solid var(--border); background: var(--surface);
  color: var(--text);
  border-radius: 99px; padding: 8px 14px; font-size: 0.85rem;
  cursor: pointer; min-height: var(--touch);
}

/* ───────────────────────── Toast ───────────────────────── */

.toast-root { position: fixed; top: 14px; left: 0; right: 0; display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 200; pointer-events: none; }
.toast {
  background: var(--text); color: var(--bg);
  padding: 12px 22px; border-radius: var(--radius-l);
  box-shadow: var(--shadow-2);
  font-size: 0.95rem;
  animation: toast-in 0.3s ease;
  max-width: 90vw;
}
.toast.success { background: var(--success); color: #0D2A1A; }
.toast.error   { background: var(--danger); color: #fff; }
@keyframes toast-in { from { transform: translateY(-16px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ───────────────────────── Modal ───────────────────────── */

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.45);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 150;
  animation: fade-in 0.2s ease;
}
@media (min-width: 600px) { .modal-backdrop { align-items: center; } }
.modal {
  background: var(--surface);
  border-radius: var(--radius-l) var(--radius-l) 0 0;
  padding: 22px;
  width: 100%; max-width: 520px;
  max-height: 88vh; overflow-y: auto;
}
@media (min-width: 600px) { .modal { border-radius: var(--radius-l); } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* ───────────────────────── Confirmação ───────────────────────── */

.confirm-anim {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 30px 0; text-align: center;
}
.confirm-anim .check {
  width: 72px; height: 72px; border-radius: 50%;
  background: var(--success); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 2.2rem;
  animation: pop-in 0.45s cubic-bezier(0.22, 1.4, 0.36, 1);
}
@keyframes pop-in { from { transform: scale(0); } to { transform: scale(1); } }

/* ───────────────────────── Cronómetro ───────────────────────── */

.timer-display {
  font-family: var(--font-display);
  font-size: 3rem; font-weight: 700;
  text-align: center;
  letter-spacing: 2px;
  margin: 10px 0;
  color: var(--primary-strong);
}

/* ───────────────────────── Tabelas (pro) ───────────────────────── */

.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
table.data th, table.data td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.data th { color: var(--text-soft); font-weight: 500; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.4px; }

/* ───────────────────────── Lista de mães (pro) ───────────────────────── */

.mother-row {
  display: grid; grid-template-columns: 1fr auto;
  gap: 8px; padding: 13px 4px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.mother-row:hover { background: var(--surface-2); }
.mother-row .name { font-weight: 700; }
.mother-row .meta { font-size: 0.82rem; color: var(--text-soft); }
.sparkline { width: 110px; height: 30px; }

/* ───────────────────────── Calendário emocional ───────────────────────── */

.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.cal-cell {
  aspect-ratio: 1; border-radius: 8px;
  background: var(--surface-2);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.72rem; color: var(--text-soft);
  position: relative;
}
.cal-cell .emo { position: absolute; bottom: 1px; right: 2px; font-size: 0.75rem; }
.cal-cell.m1 { background: color-mix(in srgb, var(--danger)  35%, var(--surface-2)); }
.cal-cell.m2 { background: color-mix(in srgb, var(--warning) 35%, var(--surface-2)); }
.cal-cell.m3 { background: var(--surface-2); }
.cal-cell.m4 { background: color-mix(in srgb, var(--secondary) 35%, var(--surface-2)); }
.cal-cell.m5 { background: color-mix(in srgb, var(--success)   40%, var(--surface-2)); }

/* ───────────────────────── Biblioteca ───────────────────────── */

.video-card { display: flex; gap: 12px; align-items: flex-start; }
.video-thumb {
  width: 120px; aspect-ratio: 16/9;
  border-radius: var(--radius-s);
  background: var(--surface-2);
  object-fit: cover; flex-shrink: 0;
}
.video-frame { width: 100%; aspect-ratio: 16/9; border: none; border-radius: var(--radius-s); }

/* ───────────────────────── Consentimento ───────────────────────── */

.consent-box {
  max-height: 46vh; overflow-y: auto;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-s);
  padding: 16px;
  background: var(--surface);
  font-size: 0.92rem;
}
.signature-pad {
  width: 100%; height: 160px;
  border: 2px dashed var(--border);
  border-radius: var(--radius-s);
  background: var(--surface);
  touch-action: none;
}

/* ───────────────────────── Onboarding ───────────────────────── */

/* ── Barra de progresso do onboarding ── */
.ob-progress { margin-bottom: 20px; }
.ob-progress-header {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 6px;
}
.ob-step-label { font-size: .88rem; font-weight: 600; color: var(--primary-strong); }
.ob-step-count { font-size: .78rem; color: var(--text-soft); }
.ob-progress-track {
  height: 5px; background: var(--border); border-radius: 99px; overflow: hidden;
  margin-bottom: 10px;
}
.ob-progress-bar {
  height: 100%; background: var(--primary); border-radius: 99px;
  transition: width .4s ease;
}
.ob-step-dots { display: flex; gap: 6px; justify-content: center; }
.ob-step-dots .step-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--border); transition: background .2s, width .2s;
}
.ob-step-dots .step-dot.active { background: var(--primary); width: 22px; border-radius: 99px; }
.ob-step-dots .step-dot.done  { background: var(--secondary); }

/* legado (manter compatibilidade) */
.steps-indicator { display: flex; gap: 6px; justify-content: center; margin-bottom: 22px; }
.steps-indicator .step-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--border); }
.steps-indicator .step-dot.active { background: var(--primary); width: 26px; border-radius: 99px; }

/* ───────────────────────── Rodapé de autoria ───────────────────────── */

.app-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  /* Sem max-width — ocupa toda a largura */
  min-height: calc(var(--footer-h) + var(--safe-b));
  padding: 6px 8px var(--safe-b);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 0.60rem; line-height: 1.3;
  color: var(--text-soft);
  opacity: 0.72;
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 40;
  text-align: center;
  padding-left: 8px; padding-right: 8px;
}

/* ───────────────────────── QR ───────────────────────── */

.qr-print-card { text-align: center; padding: 26px; }
.qr-print-card #qr-canvas { display: inline-block; margin: 14px 0; }
.qr-container {
  display: flex; justify-content: center; align-items: center;
  padding: 1.5rem;
  background: #fff;
  border-radius: var(--radius-m);
  margin: 1rem 0; min-height: 240px;
}
.qr-url { font-size: .75rem; color: var(--text-soft); word-break: break-all; text-align: center; margin-bottom: .75rem; }
.qr-actions { display: flex; gap: .75rem; flex-wrap: wrap; }
.qr-fallback-link { font-size: .78rem; word-break: break-all; color: var(--primary-strong); }
.qr-print-sheet { display: none; }

/* ───────────────────────── Ecrã de boas-vindas (mãe) ───────────────────────── */

.welcome-screen {
  display: flex;
  flex-direction: column;
  min-height: calc(100dvh - var(--footer-h) - var(--safe-b));
  /* #app já tem padding lateral — removemos o padding-top aqui */
  margin: -16px -16px 0; /* cancela o padding do #app para hero full-bleed */
}

.welcome-hero {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 4rem 2rem 2.5rem;
  background: linear-gradient(160deg, var(--bg) 0%, var(--surface-2) 100%);
  border-radius: 0 0 var(--radius-l) var(--radius-l);
}

.welcome-logo {
  width: min(320px, 80vw);
  height: min(320px, 80vw);
  object-fit: contain;
  margin-bottom: 1.5rem;
  border-radius: var(--radius-m);
}

.welcome-title {
  font-family: var(--font-display);
  font-size: 2.4rem;
  font-weight: 700;
  color: var(--primary-strong);
  letter-spacing: 0.05em;
  margin: 0 0 0.6rem;
}

.welcome-tagline {
  font-size: 1rem;
  color: var(--text-soft);
  font-style: italic;
  max-width: 280px;
  margin: 0 auto;
  line-height: 1.6;
}

.welcome-actions {
  padding: 2rem 1.5rem 1rem;
}

.welcome-qr-hint {
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-soft);
  margin-top: 0.75rem;
  line-height: 1.55;
  padding: 0 0.5rem;
}

.welcome-footer {
  padding: 0.5rem 1.5rem 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.9rem;
}

.pro-link {
  font-size: 0.84rem;
  color: var(--text-soft);
  text-decoration: none;
  border-bottom: 1px dashed var(--border);
  padding-bottom: 2px;
  transition: color 0.2s ease;
}
.pro-link:hover { color: var(--primary-strong); border-color: var(--primary-strong); }

/* ── Formulário de regresso (mãe com conta) ── */
.returning-toggle {
  text-align: center;
  margin-top: 1rem;
}

.returning-form {
  margin-top: 1rem;
  padding: 1.25rem;
  background: var(--surface-2);
  border-radius: var(--radius-m);
  border: 1px solid var(--border);
}

.returning-form .field {
  margin-bottom: 0.9rem;
}

.returning-form .field:last-of-type {
  margin-bottom: 1.1rem;
}

/* ───────────────────────── Admin — painel de gestão ───────────────────────── */

.view-admin,
.view-admin-users {
  max-width: 680px;
  margin: 0 auto;
}

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  gap: .75rem;
}

.admin-user-row {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .75rem 0;
  border-bottom: 1px solid var(--border);
}
.admin-user-row:last-child { border-bottom: none; }

.admin-user-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--on-primary);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .95rem;
  flex-shrink: 0;
}

.admin-user-info { flex: 1; min-width: 0; }
.admin-user-name { font-weight: 600; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.admin-user-meta { font-size: .78rem; color: var(--text-soft); }

/* ───────────────────────── Login profissional ───────────────────────── */

.page-pro-login {
  max-width: 420px;
  margin: 0 auto;
  padding-top: 1rem;
}

.pro-login-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.5rem 0;
}

/* ───────────────────────── Impressão ───────────────────────── */

@media print {
  .bottom-nav, .chat-fab, .toast-root, .app-footer, .no-print { display: none !important; }
  body { background: #fff; }
  #app { padding: 0; max-width: none; }
  .qr-print-sheet { display: block !important; }
  .print-header { text-align: center; margin-bottom: 1rem; }
  .print-qr { display: flex; justify-content: center; margin: 1.5rem 0; }
  .print-info { text-align: center; }
  .print-info p { margin: .3rem 0; }
  .print-instruction { font-size: 1.1rem; font-weight: 700; margin: 1rem 0; }
  .print-url { font-size: .8rem; color: #666; word-break: break-all; }
  .print-branding { margin-top: 2rem; text-align: center; font-size: .75rem; color: #888; }
}

/* ───────────────────────── Acessibilidade ───────────────────────── */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

.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;
}

/* ───────────────────────── Tabs ───────────────────────── */
.tab-row {
  display: flex; gap: .4rem;
  border-bottom: 2px solid var(--border);
  padding-bottom: 0;
}
.tab-btn {
  flex: 1; padding: .6rem .5rem;
  background: none; border: none; border-bottom: 2px solid transparent;
  font-family: var(--font-body); font-size: .9rem; font-weight: 500;
  color: var(--text-soft); cursor: pointer;
  margin-bottom: -2px; /* overlap border-bottom */
  transition: color .15s, border-color .15s;
}
.tab-btn.active {
  color: var(--primary-strong);
  border-bottom-color: var(--primary);
}
.tab-count {
  display: inline-block; min-width: 18px;
  background: var(--surface-2); border-radius: 99px;
  font-size: .72rem; padding: 1px 6px; margin-left: 4px;
}
.tab-btn.active .tab-count { background: var(--primary); color: var(--on-primary); }

/* ───────────────────────── Chips de filtro ───────────────────────── */
.chip {
  padding: .3rem .75rem;
  border-radius: 99px; border: 1.5px solid var(--border);
  background: var(--surface); color: var(--text-soft);
  font-size: .82rem; cursor: pointer; font-family: var(--font-body);
  transition: background .12s, color .12s, border-color .12s;
}
.chip:hover { border-color: var(--primary); color: var(--primary-strong); }
.chip-active {
  background: var(--primary); color: var(--on-primary);
  border-color: var(--primary);
}
.chip strong { font-size: .78rem; }

/* ───────────────────────── Vista Auditoria ───────────────────────── */
.audit-row {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: .75rem; padding: .7rem 1rem;
  border-bottom: 1px solid var(--border);
}
.audit-row:last-child { border-bottom: none; }
.audit-role-icon {
  font-size: 1rem; color: var(--text-soft);
  min-width: 1.2rem; text-align: center; line-height: 1.2;
}

/* ───────────────────────── Utilitários ───────────────────────── */

.hidden   { display: none !important; }
.optional { font-weight: 400; font-size: .8em; color: var(--text-soft); }
.empty-note { text-align: center; color: var(--text-soft); padding: 1.5rem; font-size: .9rem; }
.ref-note   { font-size: 0.78rem; color: var(--text-soft); font-style: italic; text-align: center; margin-top: 6px; }

.tag {
  display: inline-block;
  background: var(--surface-2);
  color: var(--text-soft);
  padding: .15rem .55rem;
  border-radius: 99px;
  font-size: .72rem; font-weight: 600;
}
.tag-inactive { background: var(--danger); color: #fff; opacity: .75; }

/* Input genérico */
.input {
  width: 100%;
  min-height: var(--touch);
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-s);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1rem;
  transition: border-color .15s ease;
}
.input:focus { outline: 2px solid var(--primary); outline-offset: 1px; border-color: var(--primary); }
.input.input-sm { min-height: 36px; padding: 6px 12px; font-size: .88rem; }
.textarea { resize: vertical; min-height: 80px; }

/* Form groups */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-weight: 600; font-size: .9rem; color: var(--text-soft); margin-bottom: .35rem; }

/* Page header */
.page-header {
  display: flex; align-items: center;
  gap: .75rem; margin-bottom: 1.25rem; padding-top: .25rem;
}
.page-header h1 { flex: 1; font-size: 1.4rem; margin: 0; }

/* Spinner */
.spinner-center {
  display: flex; align-items: center; justify-content: center;
  min-height: 180px; color: var(--text-soft); font-size: .9rem; gap: .5rem;
}
.spinner-center::before {
  content: "";
  width: 20px; height: 20px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Tabs */
.tabs { display: flex; gap: .4rem; border-bottom: 2px solid var(--border); margin-bottom: 1rem; }
.tab {
  padding: .5rem 1rem; font-size: .9rem; font-weight: 600;
  background: transparent; color: var(--text-soft);
  border: none; border-bottom: 2px solid transparent;
  margin-bottom: -2px; cursor: pointer;
  transition: color .15s, border-color .15s;
}
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-panel.hidden, .tab-panel[hidden] { display: none !important; }

/* Stats row */
.stats-row {
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: .75rem; margin-bottom: 1rem;
}
@media (min-width: 420px) { .stats-row { grid-template-columns: repeat(4, 1fr); } }
.stat-value {
  display: block; font-family: var(--font-display);
  font-size: 1.6rem; font-weight: 700;
  color: var(--primary-strong); line-height: 1.1;
}
.stat-label {
  display: block; font-size: .72rem; font-weight: 600;
  color: var(--text-soft); text-transform: uppercase;
  letter-spacing: .03em; margin-top: .2rem;
}
.alert-stat .stat-value { color: var(--danger); }

/* Chart */
.chart-card { overflow: hidden; }
.chart-wrap { position: relative; height: 200px; margin-top: .75rem; }
.chart-note { font-size: .8rem; color: var(--text-soft); margin-bottom: .5rem; }

/* Period buttons */
.period-btns { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: .4rem; }
.btn-period, .btn-period-unit, .btn-period-stat {
  padding: .32rem .8rem; border-radius: 99px;
  background: var(--surface-2); color: var(--text-soft);
  font-size: .82rem; font-weight: 600;
  border: 1.5px solid var(--border);
  cursor: pointer; transition: all .15s;
}
.btn-period.active, .btn-period-unit.active, .btn-period-stat.active {
  background: var(--primary); color: var(--on-primary); border-color: var(--primary);
}
.custom-dates { display: flex; align-items: center; gap: .5rem; margin-top: .6rem; flex-wrap: wrap; font-size: .85rem; }

/* Export */
.export-note {
  font-size: .85rem; color: var(--text-soft);
  background: var(--surface-2);
  border-left: 3px solid var(--primary);
  padding: .6rem .9rem;
  border-radius: 0 var(--radius-s) var(--radius-s) 0;
  margin-bottom: 1rem;
}
.export-btns { display: flex; gap: .75rem; flex-wrap: wrap; margin-top: 1rem; }

/* Icon button */
.icon-btn {
  background: transparent; border: none;
  font-size: 1.3rem; padding: .4rem;
  border-radius: 50%; color: var(--text);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s;
  min-width: 36px; min-height: 36px;
}
.icon-btn:hover { background: var(--surface-2); }

/* Alertas banner pro */
.alerts-banner {
  background: color-mix(in srgb, var(--danger) 8%, var(--surface));
  border: 1.5px solid color-mix(in srgb, var(--danger) 50%, var(--border));
  border-radius: var(--radius-m);
  padding: 1rem; margin-bottom: 1rem;
}
.alerts-banner h2 { color: var(--danger); margin-bottom: .5rem; }
.alerts-banner ul { list-style: none; padding: 0; display: flex; flex-direction: column; gap: .5rem; }
.see-all { font-size: .85rem; font-weight: 700; color: var(--danger); display: block; margin-top: .5rem; }

/* Mother list pro */
.mothers-list-header {
  display: flex; align-items: center;
  gap: .75rem; flex-wrap: wrap; margin-bottom: .75rem;
}
.mothers-list-header h2 { flex: 1; margin: 0; }
.sort-row { display: flex; align-items: center; gap: .4rem; font-size: .82rem; }
.mother-list { list-style: none; padding: 0; display: flex; flex-direction: column; gap: .5rem; }
.mother-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  padding: .85rem 1rem;
  display: flex; flex-direction: column; gap: .4rem;
  cursor: pointer; transition: box-shadow .15s;
}
.mother-item:hover { box-shadow: var(--shadow-2); }
.mother-item.status-critical { border-left: 3px solid var(--danger); }
.mother-item.status-inactivity { border-left: 3px solid var(--warning); }
.mother-item.status-drop { border-left: 3px solid color-mix(in srgb, var(--warning) 60%, var(--danger)); }
.mother-main { display: flex; align-items: center; justify-content: space-between; }
.mother-id { display: flex; align-items: center; gap: .5rem; }
.mother-meta { display: flex; gap: .4rem; flex-wrap: wrap; }
.mother-stats { display: flex; gap: .75rem; font-size: .82rem; color: var(--text-soft); flex-wrap: wrap; }

/* Status dots */
.status-dot     { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; display: inline-block; }
.dot-ok         { background: #5EA87D; }
.dot-inactivity { background: #D4973A; }
.dot-drop       { background: #C47B50; }
.dot-critical   { background: #D95F5F; }

.status-badge { padding: .15rem .55rem; border-radius: 99px; font-size: .72rem; font-weight: 700; }
.badge-ok         { background: #D5EFE2; color: #185A34; }
.badge-inactivity { background: #F9EDD0; color: #7A4A00; }
.badge-drop       { background: #F5E0D0; color: #7A3500; }
.badge-critical   { background: #F5D5D5; color: #7A0000; }

/* Live badge */
.live-badge { color: var(--danger); font-size: .75rem; font-weight: 700; animation: pulse 1.5s ease infinite; }
@keyframes pulse { 0%,100% { opacity:1; } 50% { opacity:.35; } }

/* Pro header */
.pro-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 1.25rem; }
.shift-badge { font-size: .78rem; color: var(--text-soft); font-weight: 600; margin-top: .2rem; }
.clock { font-family: var(--font-display); font-size: 1.8rem; font-weight: 700; color: var(--primary); }

/* Alerts list */
.alert-section-title { font-size: .95rem; margin: 1rem 0 .4rem; }
.alert-list { list-style: none; padding: 0; display: flex; flex-direction: column; gap: .5rem; }
.alert-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--border);
  border-radius: var(--radius-s);
  padding: .85rem 1rem;
  display: flex; flex-direction: column; gap: .5rem;
}
.alert-inactivity { border-left-color: var(--warning); }
.alert-drop       { border-left-color: color-mix(in srgb, var(--warning) 60%, var(--danger)); }
.alert-critical   { border-left-color: var(--danger); }
.alert-info { display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: .3rem; }
.alert-id { display: flex; flex-direction: column; gap: .15rem; }
.alert-detail { font-size: .78rem; color: var(--text-soft); }
.alert-time { font-size: .75rem; color: var(--text-soft); }
.alert-actions { display: flex; gap: .4rem; flex-wrap: wrap; }
.alert-type-badge { font-size: .7rem; padding: .15rem .5rem; border-radius: 99px; background: var(--surface-2); color: var(--text-soft); margin-left: .35rem; }
.handled-badge { font-size: .72rem; color: var(--primary); font-weight: 600; }

/* Biblioteca admin */
.video-admin-section { margin-bottom: 1.5rem; }
.section-title { font-size: .9rem; color: var(--text-soft); margin-bottom: .5rem; font-family: var(--font-body); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.video-admin-list { list-style: none; padding: 0; display: flex; flex-direction: column; gap: .5rem; }
.video-admin-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  padding: .85rem 1rem;
}
.video-admin-item.inactive { opacity: .6; }
.video-admin-info { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; margin-bottom: .25rem; }
.video-admin-url { font-size: .72rem; color: var(--text-soft); word-break: break-all; margin-bottom: .35rem; }
.video-admin-desc { font-size: .82rem; color: var(--text-soft); margin-bottom: .35rem; }
.video-admin-actions { display: flex; gap: .4rem; flex-wrap: wrap; }

/* Config / perfil pro */
.config-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  padding: 1rem 1.2rem;
  margin-bottom: .75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.config-section label { font-size: .95rem; font-weight: 500; color: var(--text); cursor: pointer; }
.config-section .config-hint { font-size: .78rem; color: var(--text-soft); margin-top: .15rem; }

/* Toggle switch */
.toggle-wrap { display: flex; align-items: center; gap: .5rem; }
.toggle {
  position: relative; display: inline-block;
  width: 46px; height: 26px;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0;
  background: var(--border);
  border-radius: 99px;
  transition: background .2s;
  cursor: pointer;
}
.toggle-slider::before {
  content: "";
  position: absolute;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: #fff;
  top: 3px; left: 3px;
  transition: transform .2s;
  box-shadow: 0 1px 4px rgba(0,0,0,.25);
}
.toggle input:checked + .toggle-slider { background: var(--primary); }
.toggle input:checked + .toggle-slider::before { transform: translateX(20px); }

/* Botão de idioma */
.lang-btns { display: flex; gap: .4rem; }
.lang-btn {
  padding: .3rem .8rem; border-radius: 99px;
  border: 1.5px solid var(--border);
  background: var(--surface-2);
  color: var(--text-soft);
  font-size: .85rem; font-weight: 600;
  cursor: pointer; transition: all .15s;
}
.lang-btn.active {
  background: var(--primary); color: var(--on-primary); border-color: var(--primary);
}
