/* AR Consultoria — Admin panel. Brand: charcoal #475159, gold #F9CC47. */
:root {
  --charcoal: #475159;
  --charcoal-dark: #353d43;
  --gold: #f9cc47;
  --gold-dark: #e0b52f;
  --bg: #f4f5f6;
  --card: #ffffff;
  --line: #e3e6e8;
  --text: #2c3338;
  --muted: #79858d;
  --red: #d9534f;
  --green: #3a9d5d;
  --radius: 12px;
  --shadow: 0 4px 20px rgba(53, 61, 67, 0.08);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; }

/* ── Login ──────────────────────────────────────────────── */
.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--charcoal) 0%, var(--charcoal-dark) 100%);
  padding: 20px;
}
.login-card {
  background: var(--card);
  width: 100%;
  max-width: 380px;
  padding: 36px 32px;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  text-align: center;
}
.login-logo { height: 52px; margin-bottom: 18px; }
.login-card h1 { font-size: 1.25rem; margin: 0 0 4px; color: var(--charcoal); }
.login-sub { color: var(--muted); font-size: 0.85rem; margin: 0 0 24px; }
.login-card label {
  display: block; text-align: left; font-size: 0.8rem;
  font-weight: 600; color: var(--muted); margin-bottom: 6px;
}
.login-card input {
  width: 100%; padding: 12px 14px; border: 1.5px solid var(--line);
  border-radius: 10px; font-size: 0.95rem; margin-bottom: 18px;
  transition: border-color 0.15s;
}
.login-card input:focus { outline: none; border-color: var(--gold); }
#login-btn {
  width: 100%; padding: 12px; border: none; border-radius: 10px;
  background: var(--charcoal); color: #fff; font-weight: 600; font-size: 0.95rem;
  transition: background 0.15s;
}
#login-btn:hover { background: var(--charcoal-dark); }
#login-btn:disabled { opacity: 0.6; cursor: wait; }
.login-error {
  color: var(--red); font-size: 0.85rem; margin: 14px 0 0;
  background: #fdecea; padding: 10px; border-radius: 8px;
}

/* ── Topbar ─────────────────────────────────────────────── */
.app-view { min-height: 100vh; }
.topbar {
  display: flex; align-items: center; gap: 20px;
  background: var(--charcoal); color: #fff;
  padding: 0 22px; height: 60px; position: sticky; top: 0; z-index: 50;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; }
/* Logo horizontal com texto integrado e fundo transparente — não precisa de
   moldura branca; aumentei um pouco a altura para o texto ficar legível. */
.brand-logo { height: 38px; width: auto; display: block; }
/* O logo já contém "Consultoria & Gestão", por isso escondemos o texto
   "Painel AR" do span ao lado para não duplicar a marca. */
.brand > span { display: none; }
.tabs { display: flex; gap: 4px; margin-left: 12px; }
.tab {
  background: transparent; border: none; color: rgba(255, 255, 255, 0.7);
  padding: 8px 16px; border-radius: 8px; font-size: 0.9rem; font-weight: 500;
  display: flex; align-items: center; gap: 8px; transition: all 0.15s;
}
.tab:hover { color: #fff; background: rgba(255, 255, 255, 0.08); }
.tab.active { color: var(--charcoal); background: var(--gold); font-weight: 600; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.sound-toggle { font-size: 1.1rem; cursor: pointer; user-select: none; opacity: 1; }
/* push-toggle usa SVG inline (não emoji): herda a cor via currentColor e
   muda consoante o estado de subscrição de notificações. */
#push-toggle { display: inline-flex; align-items: center; line-height: 0; vertical-align: middle; color: rgba(255, 255, 255, 0.55); transition: color 0.2s; }
/* O atributo [hidden] tem de vencer o display: inline-flex acima, senão o
   ícone fica visível mesmo quando o push não está configurado. */
#push-toggle[hidden] { display: none; }
#push-toggle svg { width: 1.2rem; height: 1.2rem; }
#push-toggle[data-state="active"] { color: #4ade80; }
#push-toggle[data-state="off"] { color: rgba(255, 255, 255, 0.55); }
#push-toggle[data-state="denied"] { color: #f87171; }
/* Quando muted, o próprio ícone (🔕) já comunica o estado — mantemos a opacidade plena
   para não duplicar o sinal visual com o push-toggle, que usa o mesmo padrão. */
.conn-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); transition: background 0.3s; }
.conn-dot.live { background: #4ade80; box-shadow: 0 0 8px #4ade80; }
.who { font-size: 0.85rem; color: rgba(255, 255, 255, 0.85); }
.ghost-btn {
  background: transparent; border: 1.5px solid rgba(255, 255, 255, 0.3);
  color: #fff; padding: 6px 14px; border-radius: 8px; font-size: 0.85rem;
}
.ghost-btn:hover { border-color: var(--gold); color: var(--gold); }
.badge {
  background: var(--gold); color: var(--charcoal); font-size: 0.72rem;
  font-weight: 700; min-width: 18px; height: 18px; border-radius: 9px;
  display: inline-grid; place-items: center; padding: 0 5px;
}
.tab.active .badge { background: var(--charcoal); color: var(--gold); }
.badge-live { background: #4ade80; color: #0b3a1d; }
.tab.active .badge-live { background: var(--charcoal); color: #4ade80; }

/* ── Flash banner ───────────────────────────────────────── */
.flash {
  background: var(--gold); color: var(--charcoal); font-weight: 600;
  padding: 12px 22px; display: flex; align-items: center; justify-content: space-between;
  animation: flashpulse 1s ease-in-out 3;
}
@keyframes flashpulse {
  0%, 100% { background: var(--gold); }
  50% { background: #fff0b8; }
}
.flash-x { background: none; border: none; font-size: 1.3rem; color: var(--charcoal); line-height: 1; }

/* ── Audio prime banner ─────────────────────────────────── */
.audio-prime {
  background: #eef4ff; color: var(--charcoal); font-weight: 500;
  padding: 12px 22px; display: flex; align-items: center; gap: 14px;
  border-bottom: 1px solid #d3e1f5;
}
/* Sem isto, o display: flex acima sobrepõe-se ao atributo hidden e o aviso
   nunca sai de cena ao clicar "Ativar som". */
.audio-prime[hidden] { display: none; }
.audio-prime__icon { font-size: 1.2rem; }
.audio-prime__text { flex: 1; font-size: 0.92rem; }
.audio-prime__yes,
.audio-prime__no {
  border: none; padding: 7px 14px; border-radius: 6px; font-weight: 600;
  font-size: 0.85rem; cursor: pointer; transition: background 0.15s ease;
}
.audio-prime__yes { background: var(--charcoal); color: #fff; }
.audio-prime__yes:hover { background: #000; }
.audio-prime__no { background: transparent; color: var(--muted); }
.audio-prime__no:hover { background: rgba(0, 0, 0, 0.05); color: var(--charcoal); }

/* ── Views ──────────────────────────────────────────────── */
.view { display: none; padding: 26px 28px; max-width: 1100px; margin: 0 auto; }
.view.active { display: block; }
.view-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; flex-wrap: wrap; gap: 12px; }
.view-head h2 { margin: 0; font-size: 1.3rem; color: var(--charcoal); }
.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  background: var(--card); border: 1.5px solid var(--line); color: var(--muted);
  padding: 7px 14px; border-radius: 20px; font-size: 0.83rem; font-weight: 500; transition: all 0.15s;
}
.chip:hover { border-color: var(--gold); }
.chip.active { background: var(--charcoal); color: #fff; border-color: var(--charcoal); }
.empty { color: var(--muted); text-align: center; padding: 40px; }

/* ── Queue cards ────────────────────────────────────────── */
.queue-list { display: flex; flex-direction: column; gap: 12px; }
.qcard {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px 18px; border-left: 4px solid var(--line);
}
.qcard.high { border-left-color: var(--red); }
.qcard.pending { border-left-color: var(--gold); }
.qcard.resolved { border-left-color: var(--green); opacity: 0.75; }
.qcard.dismissed { opacity: 0.55; }
.qcard.fresh { animation: cardin 0.5s ease; }
@keyframes cardin { from { transform: translateY(-8px); opacity: 0; } to { transform: none; opacity: 1; } }
.qcard-top { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.qtag {
  font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  padding: 3px 9px; border-radius: 6px; background: var(--bg); color: var(--muted);
}
.qtag.reason { background: #eef4f8; color: var(--charcoal); }
.qtag.high { background: #fdecea; color: var(--red); }
.qtag.target { background: #fff4d9; color: #8a6300; }
.qcard a.qmail { color: var(--charcoal); font-weight: 600; text-decoration: none; }
.qcard a.qmail:hover { text-decoration: underline; }
.qtime { color: var(--muted); font-size: 0.78rem; margin-left: auto; }
.qquestion { color: var(--text); font-size: 0.92rem; line-height: 1.5; margin: 6px 0 12px; white-space: pre-wrap; }
.qhistory { background: var(--bg); border-radius: 8px; padding: 10px 12px; margin: 0 0 12px; font-size: 0.82rem; color: var(--muted); }
.qhistory b { color: var(--charcoal); }
.qactions { display: flex; gap: 8px; }
.primary-btn, .danger-btn, .mini-btn {
  border: none; border-radius: 8px; padding: 8px 16px; font-size: 0.85rem; font-weight: 600;
}
.primary-btn { background: var(--charcoal); color: #fff; }
.primary-btn:hover { background: var(--charcoal-dark); }
.danger-btn { background: #fdecea; color: var(--red); }
.danger-btn:hover { background: var(--red); color: #fff; }
.mini-btn { background: var(--bg); color: var(--charcoal); border: 1.5px solid var(--line); }
.mini-btn:hover { border-color: var(--gold); }
.qresolved-by { font-size: 0.78rem; color: var(--muted); margin-top: 8px; }

/* ── KB editor ──────────────────────────────────────────── */
.kb-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.kb-list { display: flex; flex-direction: column; gap: 8px; max-height: 70vh; overflow-y: auto; }
.kb-item {
  background: var(--card); border-radius: 10px; box-shadow: var(--shadow);
  padding: 12px 14px; cursor: pointer; border: 1.5px solid transparent; transition: border-color 0.15s;
}
.kb-item:hover { border-color: var(--gold); }
.kb-item.sel { border-color: var(--charcoal); }
.kb-item .q { font-weight: 600; font-size: 0.88rem; color: var(--charcoal); }
.kb-item .a { font-size: 0.8rem; color: var(--muted); margin-top: 4px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.kb-new { width: 100%; margin-bottom: 4px; }
.kb-form {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px; position: sticky; top: 86px; display: flex; flex-direction: column; gap: 14px;
}
.kb-form label { display: flex; flex-direction: column; gap: 6px; font-size: 0.82rem; font-weight: 600; color: var(--muted); }
.kb-form label small { font-weight: 400; }
.kb-form input[type=text], .kb-form textarea {
  padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 8px;
  font-size: 0.9rem; font-family: inherit; color: var(--text); resize: vertical;
}
.kb-form input:focus, .kb-form textarea:focus { outline: none; border-color: var(--gold); }
.kb-form label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; color: var(--text); }
.kb-form-actions { display: flex; gap: 8px; align-items: center; }
.kb-msg { font-size: 0.85rem; margin: 0; padding: 8px 10px; border-radius: 8px; }
.kb-msg.ok { background: #e8f6ed; color: var(--green); }
.kb-msg.err { background: #fdecea; color: var(--red); }

/* ── Live (atendimento humano) ──────────────────────────── */
#view-live { max-width: 1280px; padding: 18px 22px; }
.live-layout {
  display: grid; grid-template-columns: 320px 1fr; gap: 18px;
  height: calc(100vh - 60px - 36px);
}
.live-sidebar {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px; display: flex; flex-direction: column; min-height: 0;
}
.live-sidebar .view-head { margin: 2px 4px 12px; }
.live-sidebar .view-head h2 { font-size: 1.05rem; }
.live-hint { font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.live-list { display: flex; flex-direction: column; gap: 6px; overflow-y: auto; flex: 1; padding-right: 2px; }
.live-card {
  background: var(--bg); border: 1.5px solid transparent; border-radius: 10px;
  padding: 10px 12px; text-align: left; cursor: pointer; transition: all 0.15s;
  display: flex; flex-direction: column; gap: 4px;
}
.live-card:hover { border-color: var(--gold); }
.live-card.sel { background: var(--card); border-color: var(--charcoal); box-shadow: 0 2px 8px rgba(53,61,67,0.1); }
.live-card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.live-card-peer { font-weight: 600; font-size: 0.88rem; color: var(--charcoal); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.live-card-last { font-size: 0.78rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.live-card-meta { font-size: 0.72rem; color: var(--muted); }
.live-state-tag {
  font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  padding: 2px 8px; border-radius: 10px; white-space: nowrap;
}
.st-bot     { background: var(--bg); color: var(--muted); }
.st-waiting { background: #fff4d6; color: #8a6500; animation: pulseWait 1.6s ease-in-out infinite; }
.st-live    { background: #d6f5e1; color: #1f6b3a; }
@keyframes pulseWait { 0%,100% { opacity: 1; } 50% { opacity: 0.55; } }

.live-pane {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  display: flex; flex-direction: column; min-height: 0; overflow: hidden;
}
.live-pane-empty { padding: 60px 30px; text-align: center; color: var(--muted); }
.live-pane-empty p { margin: 6px 0; }
.live-pane-hint { font-size: 0.85rem; }
.live-pane-active { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.live-pane-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.live-peer-info { display: flex; align-items: center; gap: 10px; }
.live-peer { font-weight: 700; color: var(--charcoal); }
.live-pane-actions { display: flex; gap: 8px; }

.live-transcript {
  flex: 1; overflow-y: auto; padding: 18px 20px;
  display: flex; flex-direction: column; gap: 10px; background: #fafbfc;
}
.lb { max-width: 78%; display: flex; flex-direction: column; gap: 3px; }
.lb-who { font-size: 0.7rem; color: var(--muted); font-weight: 600; padding: 0 4px; }
.lb-text {
  padding: 9px 13px; border-radius: 14px; font-size: 0.9rem; line-height: 1.45;
  white-space: pre-wrap; word-wrap: break-word;
}
.lb-user            { align-self: flex-start; }
.lb-user .lb-text   { background: #eef2f5; color: var(--text); border-top-left-radius: 4px; }
.lb-bot             { align-self: flex-start; }
.lb-bot .lb-text    { background: #f6efd9; color: var(--charcoal); border-top-left-radius: 4px; }
.lb-agent           { align-self: flex-end; align-items: flex-end; }
.lb-agent .lb-text  { background: var(--charcoal); color: #fff; border-top-right-radius: 4px; }
.lb-system {
  align-self: center; font-size: 0.75rem; color: var(--muted); font-style: italic;
  background: transparent; padding: 4px 8px;
}

.live-composer {
  display: flex; gap: 10px; padding: 12px 14px; border-top: 1px solid var(--line); background: var(--card);
}
.live-composer textarea {
  flex: 1; border: 1.5px solid var(--line); border-radius: 10px;
  padding: 10px 12px; font: inherit; font-size: 0.9rem; resize: none; max-height: 120px;
}
.live-composer textarea:focus { outline: none; border-color: var(--gold); }
.live-composer .primary-btn { align-self: flex-end; }
.live-locked {
  padding: 14px 18px; margin: 0; background: #fff8e1; color: #8a6500;
  border-top: 1px solid var(--line); font-size: 0.85rem; text-align: center;
}

/* ── Definições ─────────────────────────────────────────── */
.view-sub { margin: 4px 0 0; color: var(--muted); font-size: 0.88rem; }

.settings-card {
  background: var(--card);
  border-radius: 14px;
  box-shadow: var(--shadow);
  max-width: 780px;
  margin: 0 auto 22px;
  overflow: hidden;
  border: 1px solid var(--line);
}

.settings-card__head {
  display: flex; gap: 14px; align-items: flex-start;
  padding: 18px 22px 16px;
  background: linear-gradient(135deg, rgba(249, 204, 71, 0.08) 0%, rgba(71, 81, 89, 0.04) 100%);
  border-bottom: 1px solid var(--line);
}
.settings-card__icon {
  width: 40px; height: 40px; flex-shrink: 0;
  display: grid; place-items: center; font-size: 1.3rem;
  background: #fff; border-radius: 10px;
  box-shadow: 0 2px 6px rgba(53, 61, 67, 0.08);
}
.settings-card__title { margin: 0; font-size: 1.05rem; color: var(--charcoal); font-weight: 700; }
.settings-card__desc { margin: 4px 0 0; color: var(--muted); font-size: 0.85rem; line-height: 1.45; }

.settings-form {
  display: flex; flex-direction: column; gap: 16px;
  padding: 20px 22px 22px;
}

.settings-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px;
}

.settings-field { display: flex; flex-direction: column; gap: 6px; }
.settings-field__label {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.8rem; font-weight: 600; color: var(--charcoal); letter-spacing: 0.01em;
}
.settings-field__optional {
  font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  background: var(--bg); color: var(--muted); padding: 2px 7px; border-radius: 6px;
}
.settings-field__hint { color: var(--muted); font-size: 0.78rem; line-height: 1.4; }

.settings-field input[type=text],
.settings-field input[type=number],
.settings-field select,
.settings-field textarea {
  width: 100%; padding: 10px 12px;
  border: 1.5px solid var(--line); border-radius: 9px;
  font: inherit; font-size: 0.92rem; color: var(--text);
  background: #fff; resize: vertical;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.settings-field input:hover, .settings-field select:hover, .settings-field textarea:hover {
  border-color: var(--muted);
}
.settings-field input:focus, .settings-field select:focus, .settings-field textarea:focus {
  outline: none; border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(249, 204, 71, 0.18);
}
.settings-field select {
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2379858d' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 14px;
  padding-right: 36px;
}

/* Num com sufixo (caracteres). */
.settings-num {
  position: relative;
}
.settings-num input { padding-right: 92px; font-variant-numeric: tabular-nums; }
.settings-num__suffix {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  font-size: 0.78rem; color: var(--muted); pointer-events: none;
  background: var(--bg); padding: 3px 8px; border-radius: 6px; font-weight: 500;
}

/* Toggle switch — substitui o checkbox plano. */
.settings-toggle {
  display: flex; gap: 14px; align-items: flex-start;
  padding: 14px 16px; background: var(--bg);
  border: 1.5px solid var(--line); border-radius: 11px;
  cursor: pointer; transition: border-color 0.15s ease, background 0.15s ease;
}
.settings-toggle:hover { border-color: var(--gold); background: #fff; }
.settings-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.settings-toggle__switch {
  flex-shrink: 0; width: 42px; height: 24px;
  background: #c8ced2; border-radius: 12px; position: relative;
  transition: background 0.18s ease;
  margin-top: 1px;
}
.settings-toggle__switch::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 18px; height: 18px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: transform 0.18s ease;
}
.settings-toggle input:checked + .settings-toggle__switch { background: var(--green); }
.settings-toggle input:checked + .settings-toggle__switch::after { transform: translateX(18px); }
.settings-toggle input:focus-visible + .settings-toggle__switch {
  box-shadow: 0 0 0 3px rgba(249, 204, 71, 0.3);
}
.settings-toggle__body { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.settings-toggle__title { font-weight: 600; color: var(--charcoal); font-size: 0.92rem; }
.settings-toggle__desc { color: var(--muted); font-size: 0.8rem; line-height: 1.45; }

/* Pill com "Atualmente em uso: ..." */
.settings-card__pill {
  margin: 0; padding: 8px 12px;
  background: rgba(58, 157, 93, 0.08); color: var(--green);
  border: 1px solid rgba(58, 157, 93, 0.2); border-radius: 8px;
  font-size: 0.82rem; font-weight: 500;
  display: inline-flex; align-items: center; gap: 8px;
}
.settings-card__pill::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--green);
  box-shadow: 0 0 6px var(--green);
}
.settings-card__pill:empty { display: none; }

.settings-actions {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  margin-top: 4px;
}
.settings-msg {
  margin: 0; padding: 9px 12px; border-radius: 8px;
  font-size: 0.85rem; font-weight: 500;
}
.settings-msg.ok { background: #e8f6ed; color: var(--green); border: 1px solid rgba(58,157,93,0.2); }
.settings-msg.err { background: #fdecea; color: var(--red); border: 1px solid rgba(217,83,79,0.2); }

/* Push status list (Definições → Notificações no telemóvel) */
.push-status-list { display: flex; flex-direction: column; gap: 10px; margin: 4px 0; }
.push-admin {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 10px;
  background: #fafafa; border: 1px solid #ececec;
}
.push-admin__dot {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
  background: var(--red); box-shadow: 0 0 6px rgba(217, 83, 79, 0.4);
}
.push-admin.is-active .push-admin__dot {
  background: var(--green); box-shadow: 0 0 6px rgba(58, 157, 93, 0.45);
}
.push-admin__body { flex: 1 1 auto; min-width: 0; }
.push-admin__name { font-weight: 600; color: var(--charcoal); font-size: 0.95rem; }
.push-admin__email { color: var(--muted); font-size: 0.78rem; margin-top: 1px; }
.push-admin__meta { color: var(--muted); font-size: 0.78rem; margin-top: 3px; }
.push-admin__badge {
  flex-shrink: 0; font-size: 0.72rem; font-weight: 600;
  padding: 4px 10px; border-radius: 999px;
  background: rgba(217, 83, 79, 0.1); color: var(--red);
  border: 1px solid rgba(217, 83, 79, 0.2);
}
.push-admin.is-active .push-admin__badge {
  background: rgba(58, 157, 93, 0.1); color: var(--green);
  border-color: rgba(58, 157, 93, 0.25);
}

/* ── Audit ──────────────────────────────────────────────── */
.audit-list { display: flex; flex-direction: column; gap: 4px; font-size: 0.84rem; }
.audit-row {
  background: var(--card); border-radius: 8px; padding: 9px 14px;
  display: flex; gap: 14px; align-items: baseline; box-shadow: var(--shadow);
}
.audit-row .at { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.audit-row .ty { font-weight: 600; color: var(--charcoal); min-width: 150px; }
.audit-row .de { color: var(--muted); }

/* ── Responsivo ─────────────────────────────────────────── */

/* Botão "voltar à lista" para a vista Ao Vivo no mobile — só visível em ≤560px. */
.live-back-btn {
  display: none;
  background: transparent; border: none; color: var(--charcoal);
  font-size: 0.9rem; font-weight: 600; padding: 6px 10px;
  border-radius: 8px;
}
.live-back-btn:hover { background: var(--bg); }

/* Hamburger — escondido em desktop, só aparece em ≤560px (regra abaixo). */
.nav-toggle {
  display: none; background: transparent; border: none;
  width: 40px; height: 40px; padding: 0;
  align-items: center; justify-content: center;
  flex-direction: column; gap: 5px; border-radius: 8px;
  cursor: pointer;
}
.nav-toggle:hover { background: rgba(255, 255, 255, 0.1); }
.nav-toggle__bar {
  width: 22px; height: 2px; background: #fff; border-radius: 2px;
  transition: transform 0.2s ease, opacity 0.2s ease;
}
/* "X" quando aberto. */
body.nav-open .nav-toggle__bar:nth-child(1) { transform: translateY(7px) rotate(45deg); }
body.nav-open .nav-toggle__bar:nth-child(2) { opacity: 0; }
body.nav-open .nav-toggle__bar:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Backdrop por baixo do drawer — começa abaixo da topbar (60px) para que
   o hamburger continue acessível para fechar o menu. */
.nav-backdrop {
  position: fixed; top: 60px; right: 0; bottom: 0; left: 0;
  background: rgba(20, 24, 28, 0.5);
  z-index: 39; opacity: 0; transition: opacity 0.2s ease;
}
body.nav-open .nav-backdrop { opacity: 1; }

/* Rodapé do drawer com o botão Sair — só visível no drawer mobile. */
.nav-footer { margin-top: auto; padding-top: 16px; }
.nav-logout {
  width: 100%; padding: 12px 16px;
  background: transparent; color: rgba(255, 255, 255, 0.85);
  border: 1.5px solid rgba(255, 255, 255, 0.18); border-radius: 10px;
  font-size: 0.95rem; font-weight: 600; cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.nav-logout:hover { border-color: var(--gold); color: var(--gold); background: rgba(249, 204, 71, 0.08); }
.tabs .nav-footer { display: none; } /* só ativo no breakpoint mobile (regra abaixo) */

/* Tablet (≤900px) */
@media (max-width: 900px) {
  .view { padding: 18px 16px; }
  .view-head h2 { font-size: 1.15rem; }
  .kb-layout { grid-template-columns: 1fr; gap: 14px; }
  .kb-form { position: static; }
  .kb-list { max-height: 50vh; }
  #view-live { padding: 14px; }
  .live-layout { grid-template-columns: 260px 1fr; gap: 12px; }
  .live-sidebar { padding: 10px; }
  .topbar { padding: 0 14px; gap: 10px; }
  .tabs { gap: 2px; margin-left: 4px; }
  .tab { padding: 8px 10px; font-size: 0.85rem; }
  .topbar-right { gap: 10px; }
}

/* Telemóvel (≤560px) — reorganiza a topbar, tabs scrolláveis e Live em vista única. */
@media (max-width: 560px) {
  /* iOS evita auto-zoom em foco quando font-size >= 16px nos inputs. */
  .login-card input,
  .kb-form input[type=text],
  .kb-form textarea,
  .live-composer textarea,
  #twofa-code,
  #setup-pw, #setup-pw2,
  #setup-totp-code, #setup-email-code {
    font-size: 16px;
  }

  /* Topbar compacta com hamburger à esquerda. */
  .topbar {
    height: 56px; padding: 0 10px; gap: 8px;
  }
  .nav-toggle { display: flex; flex: 0 0 auto; }
  .brand { flex: 0 1 auto; min-width: 0; overflow: hidden; }
  .brand-logo { height: 30px; }
  .topbar-right { margin-left: auto; gap: 8px; }
  .who { display: none; }
  .ghost-btn { padding: 5px 10px; font-size: 0.8rem; }

  /* Drawer lateral em vez de tabs inline. Começa por baixo da topbar
     (top: 56px) para que o hamburger esteja sempre acessível. */
  .tabs {
    position: fixed; top: 56px; left: 0;
    width: 78vw; max-width: 280px; height: calc(100vh - 56px);
    background: var(--charcoal-dark);
    flex-direction: column; align-items: stretch; gap: 4px;
    padding: 16px 14px 20px; margin: 0;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.3);
    z-index: 40; overflow-y: auto;
  }
  body.nav-open .tabs { transform: translateX(0); }
  /* Backdrop alinhado com a topbar mobile (56px). */
  .nav-backdrop { top: 56px; }
  .tab {
    width: 100%; justify-content: flex-start; text-align: left;
    padding: 12px 16px; font-size: 0.95rem; border-radius: 10px;
  }
  .tab .badge { margin-left: auto; }
  /* Mostra o rodapé com Sair dentro do drawer e esconde o do topbar. */
  .tabs .nav-footer { display: block; }
  .topbar-right > #logout-btn { display: none; }

  /* Views: padding mais compacto. */
  .view { padding: 14px 12px; }
  .view-head { margin-bottom: 14px; gap: 8px; }
  .view-head h2 { font-size: 1.05rem; }
  .chip { padding: 6px 11px; font-size: 0.78rem; }

  /* Queue cards */
  .qcard { padding: 14px 14px; }
  .qcard-top { gap: 6px; }
  .qtime { margin-left: 0; width: 100%; order: 99; }
  .qactions { flex-wrap: wrap; gap: 6px; }
  .qactions .primary-btn,
  .qactions .danger-btn,
  .qactions .mini-btn { flex: 1 1 auto; min-width: 120px; padding: 9px 12px; text-align: center; }

  /* Settings — campos lado a lado passam a empilhar. */
  #view-settings .kb-form > div[style*="display:flex"] { flex-direction: column; gap: 14px !important; }

  /* AUDIT — linhas em coluna no mobile. */
  .audit-row { flex-direction: column; gap: 4px; padding: 10px 12px; }
  .audit-row .ty { min-width: 0; }

  /* Recovery codes: 1 coluna. */
  .recovery-list { grid-template-columns: 1fr; gap: 6px; }
  .totp-qr { width: 170px; height: 170px; }

  /* ── Live (atendimento humano) — vista única alternada ── */
  /* No telemóvel mostramos a lista OU a conversa, nunca os dois. O `data-mobile`
     no #view-live controla qual está visível; é definido pelo admin.js ao
     abrir/fechar uma conversa. */
  #view-live { padding: 0; }
  .live-layout {
    grid-template-columns: 1fr; gap: 0; height: calc(100vh - 110px);
  }
  .live-sidebar { border-radius: 0; box-shadow: none; max-height: none; padding: 12px 14px; }
  .live-pane    { border-radius: 0; box-shadow: none; }

  /* Por omissão: lista visível, pane escondido. */
  #view-live[data-mobile="list"] .live-pane { display: none; }
  /* Quando uma conversa está aberta: pane visível, lista escondida. */
  #view-live[data-mobile="pane"] .live-sidebar { display: none; }

  /* Botão de voltar visível só no telemóvel quando a pane está aberta. */
  #view-live[data-mobile="pane"] .live-back-btn { display: inline-flex; }
  .live-pane-head { padding: 10px 12px; gap: 8px; }
  .live-peer { font-size: 0.95rem; }
  .live-pane-actions { gap: 6px; }
  .live-pane-actions .primary-btn,
  .live-pane-actions .danger-btn { padding: 7px 12px; font-size: 0.82rem; }
  .live-transcript { padding: 14px 12px; min-height: 0; }
  .lb { max-width: 90%; }
  .live-composer { padding: 10px 12px; gap: 8px; }
  .live-composer .primary-btn { padding: 9px 14px; font-size: 0.85rem; }

  /* Flash banner mais compacto. */
  .flash { padding: 10px 14px; font-size: 0.85rem; }

  /* Login card ocupa todo o ecrã. */
  .login-card { padding: 28px 22px; max-width: 100%; }
  .login-card h1 { font-size: 1.1rem; }
}

/* Ecrãs muito estreitos (< 380px) — corte adicional para evitar overflow. */
@media (max-width: 380px) {
  .topbar { padding: 6px 8px; }
  .brand span { display: none; } /* deixa só o logo */
  .view { padding: 12px 10px; }
  .qactions .primary-btn,
  .qactions .danger-btn,
  .qactions .mini-btn { min-width: 100px; font-size: 0.8rem; }
}

/* ── Auth screens (login → setup | 2FA) ────────────────── */
.auth-screen { text-align: center; }
.auth-hint {
  font-size: 0.78rem; color: var(--muted); margin: 14px 0 0; line-height: 1.45;
  background: var(--bg); padding: 10px 12px; border-radius: 8px;
}
.auth-btn {
  width: 100%; padding: 12px; border: none; border-radius: 10px;
  background: var(--charcoal); color: #fff; font-weight: 600; font-size: 0.95rem;
  transition: background 0.15s; margin-top: 4px;
}
.auth-btn:hover { background: var(--charcoal-dark); }
.auth-btn:disabled { opacity: 0.6; cursor: wait; }
.auth-link-btn {
  background: none; border: none; color: var(--muted); font-size: 0.82rem;
  margin-top: 12px; text-decoration: underline; padding: 4px;
}
.auth-link-btn:hover { color: var(--charcoal); }
.auth-links {
  display: flex; flex-wrap: wrap; gap: 14px; justify-content: center;
  margin-top: 16px;
}
.auth-links a { color: var(--muted); font-size: 0.82rem; text-decoration: none; }
.auth-links a:hover { color: var(--charcoal); text-decoration: underline; }

/* Wizard step indicator */
.wizard-steps {
  list-style: none; display: flex; gap: 6px; padding: 0; margin: 0 0 24px;
  counter-reset: wz; justify-content: center;
}
.wizard-steps li {
  counter-increment: wz; font-size: 0.72rem; color: var(--muted); flex: 1;
  padding-top: 26px; position: relative; text-align: center; font-weight: 500;
}
.wizard-steps li::before {
  content: counter(wz); position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 22px; height: 22px; border-radius: 50%; background: var(--line); color: var(--muted);
  display: grid; place-items: center; font-weight: 700; transition: all 0.2s;
}
.wizard-steps li.active { color: var(--charcoal); }
.wizard-steps li.active::before { background: var(--gold); color: var(--charcoal); }
.wizard-steps li.done::before { content: '✓'; background: var(--green); color: #fff; }

.setup-step { text-align: left; }
.setup-q { font-size: 0.92rem; font-weight: 600; color: var(--charcoal); margin: 0 0 14px; text-align: center; }

/* Method choice cards */
.method-grid { display: flex; flex-direction: column; gap: 12px; margin-bottom: 8px; }
.method-card {
  position: relative; text-align: left; background: var(--card);
  border: 1.5px solid var(--line); border-radius: 12px; padding: 16px;
  display: flex; flex-direction: column; gap: 4px; transition: all 0.15s;
}
.method-card:hover { border-color: var(--gold); box-shadow: var(--shadow); }
.method-title { font-weight: 700; color: var(--charcoal); font-size: 0.95rem; }
.method-desc { font-size: 0.8rem; color: var(--muted); line-height: 1.4; }
.method-badge {
  position: absolute; top: 12px; right: 12px; font-size: 0.62rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.04em; background: var(--gold);
  color: var(--charcoal); padding: 3px 8px; border-radius: 6px;
}

/* TOTP QR */
.totp-qr {
  display: block; margin: 0 auto 12px; width: 200px; height: 200px;
  border: 1px solid var(--line); border-radius: 12px; background: #fff;
}
.totp-secret-row { text-align: center; font-size: 0.8rem; color: var(--muted); margin: 0 0 18px; }
.totp-secret-row code {
  font-family: ui-monospace, 'SFMono-Regular', Menlo, monospace; font-size: 0.9rem;
  background: var(--bg); padding: 4px 8px; border-radius: 6px; color: var(--charcoal);
  letter-spacing: 0.06em; word-break: break-all;
}

/* Recovery codes */
.recovery-list {
  list-style: none; padding: 14px; margin: 0 0 6px; background: var(--bg);
  border: 1.5px dashed var(--line); border-radius: 12px;
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px;
}
.recovery-list li {
  font-family: ui-monospace, 'SFMono-Regular', Menlo, monospace; font-size: 0.92rem;
  color: var(--charcoal); letter-spacing: 0.04em; text-align: center;
}

/* Checkbox row inside auth card */
.login-card .check {
  display: flex; align-items: flex-start; gap: 8px; text-align: left;
  font-size: 0.84rem; color: var(--text); font-weight: 500; margin: 6px 0 16px;
}
.login-card .check input { width: auto; margin: 2px 0 0; }
