/* ═══════════════════════════════════════════════════════════════════════
   DesVoz Design System — padrões Apple (HIG)
   Light/dark automáticos · tipografia SF · listas agrupadas iOS ·
   segmented control · switch · tab bar · blur — compartilhado por
   portal, admin e landing.
   ═══════════════════════════════════════════════════════════════════════ */

:root {
  color-scheme: light dark;
  /* verdes do sistema Apple (light/dark) — próximos da marca WhatsApp */
  --tint: #34c759;
  --tint-press: #2eb350;
  --tint-text: #248a3d;          /* verde acessível para texto/links no claro */
  --chart: #248a3d;              /* marca de gráfico com contraste ≥3:1 no claro */
  --danger: #ff3b30;
  --warn: #ff9500;

  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-2: #f2f2f4;
  --surface-3: #e8e8ed;
  --text: #1d1d1f;
  --text-2: #6e6e73;
  --text-3: #aeaeb2;
  --separator: rgba(0, 0, 0, 0.08);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 10px 30px rgba(0, 0, 0, 0.06);
  --blur-bg: rgba(245, 245, 247, 0.72);

  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --ease: cubic-bezier(0.32, 0.72, 0, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --tint: #30d158;
    --tint-press: #28b64c;
    --tint-text: #30d158;
    --chart: #30d158;
    --danger: #ff453a;
    --warn: #ff9f0a;

    --bg: #000000;
    --surface: #1c1c1e;
    --surface-2: #2c2c2e;
    --surface-3: #3a3a3c;
    --text: #f5f5f7;
    --text-2: #98989d;
    --text-3: #636366;
    --separator: rgba(255, 255, 255, 0.1);
    --shadow: none;
    --blur-bg: rgba(0, 0, 0, 0.65);
  }
}

/* ── Base ─────────────────────────────────────────────────────────────── */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--text);
  font: 400 17px/1.47 -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, sans-serif;
  letter-spacing: -0.012em;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a { color: var(--tint-text); text-decoration: none; }
button { font: inherit; letter-spacing: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
img { max-width: 100%; display: block; }

/* ── Tipografia (escala HIG) ──────────────────────────────────────────── */
.lt  { font-size: 34px; line-height: 1.12; font-weight: 700; letter-spacing: -0.022em; }
.t1  { font-size: 22px; line-height: 1.2;  font-weight: 700; letter-spacing: -0.018em; }
.t2  { font-size: 17px; line-height: 1.3;  font-weight: 600; }
.fn  { font-size: 13px; line-height: 1.4;  color: var(--text-2); }
.cap {
  font-size: 13px; font-weight: 600; color: var(--text-2);
  text-transform: uppercase; letter-spacing: 0.06em;
  margin: 26px 4px 8px;
}

/* ── Nav bar / Tab bar ────────────────────────────────────────────────── */
.navbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 12px;
  padding: 12px max(16px, env(safe-area-inset-left));
  background: var(--blur-bg);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 0.5px solid var(--separator);
}
.brand { display: flex; align-items: center; gap: 8px; font-size: 19px; font-weight: 700; letter-spacing: -0.02em; }
.brand .mic { font-size: 20px; }
.brand b { color: var(--tint-text); font-weight: 700; }

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  display: flex; justify-content: space-around;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  background: var(--blur-bg);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-top: 0.5px solid var(--separator);
}
.tabbar button {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 4px 18px; color: var(--text-3); border-radius: 10px;
  font-size: 10px; font-weight: 600; transition: color 0.2s var(--ease);
}
.tabbar button svg { width: 24px; height: 24px; }
.tabbar button.on { color: var(--tint-text); }

/* ── Cartões / grupos ─────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 0.5px solid var(--separator);
  box-shadow: var(--shadow);
  padding: 20px;
}
.group {
  background: var(--surface);
  border-radius: var(--radius-md);
  border: 0.5px solid var(--separator);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.row {
  display: flex; align-items: center; gap: 14px;
  padding: 13px 16px;
  min-height: 48px;
  border-bottom: 0.5px solid var(--separator);
}
.row:last-child { border-bottom: 0; }
.row .grow { flex: 1; min-width: 0; }
.row .label { font-size: 17px; }
.row .sub { font-size: 13px; color: var(--text-2); margin-top: 1px; }
.row .value { color: var(--text-2); font-size: 17px; }
.row.tappable { cursor: pointer; transition: background 0.15s; }
.row.tappable:active { background: var(--surface-2); }
.chevron { color: var(--text-3); font-size: 15px; }

/* ── Botões (pílula Apple) ────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 17px; font-weight: 600;
  padding: 13px 24px; border-radius: 980px;
  transition: transform 0.15s var(--ease), background 0.15s, opacity 0.15s;
  user-select: none; -webkit-user-select: none;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; pointer-events: none; }
.btn-primary { background: var(--tint); color: #fff; }
.btn-primary:hover { background: var(--tint-press); }
.btn-secondary { background: var(--surface-2); color: var(--tint-text); }
.btn-plain { color: var(--tint-text); padding: 8px 12px; }
.btn-danger { color: var(--danger); background: var(--surface-2); }
.btn-sm { font-size: 15px; padding: 8px 16px; }
.btn-block { width: 100%; }

/* ── Campos ───────────────────────────────────────────────────────────── */
.field {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 17px; color: var(--text);
  transition: border-color 0.15s, background 0.15s;
  -webkit-appearance: none; appearance: none;
}
.field:focus { outline: none; border-color: var(--tint); background: var(--surface); }
.field::placeholder { color: var(--text-3); }
select.field {
  background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%),
    linear-gradient(135deg, var(--text-3) 50%, transparent 50%);
  background-position: calc(100% - 18px) 55%, calc(100% - 13px) 55%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  padding-right: 34px;
}
label.flabel { display: block; font-size: 13px; color: var(--text-2); margin: 14px 2px 6px; }

/* ── Segmented control ────────────────────────────────────────────────── */
.seg {
  display: flex; gap: 2px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 2px;
}
.seg button {
  flex: 1; padding: 8px 6px;
  font-size: 13px; font-weight: 600; color: var(--text-2);
  border-radius: 8px;
  transition: all 0.2s var(--ease);
  white-space: nowrap;
}
.seg button.on {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}

/* ── Switch iOS ───────────────────────────────────────────────────────── */
.switch { position: relative; width: 51px; height: 31px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch i {
  position: absolute; inset: 0; display: block;
  background: var(--surface-3); border-radius: 31px;
  transition: background 0.25s var(--ease);
}
.switch i::before {
  content: ''; position: absolute; width: 27px; height: 27px; left: 2px; top: 2px;
  background: #fff; border-radius: 50%;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15), 0 1px 1px rgba(0, 0, 0, 0.16);
  transition: transform 0.25s var(--ease);
}
.switch input:checked + i { background: var(--tint); }
.switch input:checked + i::before { transform: translateX(20px); }

/* ── Badges de status ─────────────────────────────────────────────────── */
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.dot-on { background: var(--tint); box-shadow: 0 0 0 4px color-mix(in srgb, var(--tint) 18%, transparent); }
.dot-off { background: var(--danger); box-shadow: 0 0 0 4px color-mix(in srgb, var(--danger) 15%, transparent); }
.dot-warn { background: var(--warn); box-shadow: 0 0 0 4px color-mix(in srgb, var(--warn) 15%, transparent); }
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; border-radius: 980px; padding: 4px 11px;
}
.badge::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge-on { color: var(--tint-text); background: color-mix(in srgb, var(--tint) 14%, transparent); }
.badge-off { color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, transparent); }
.badge-warn { color: var(--warn); background: color-mix(in srgb, var(--warn) 14%, transparent); }

/* ── Modais (sheet) ───────────────────────────────────────────────────── */
.overlay {
  position: fixed; inset: 0; z-index: 60;
  display: none; align-items: flex-end; justify-content: center;
  background: rgba(0, 0, 0, 0.4);
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
  padding: 0;
}
.overlay.show { display: flex; animation: fade 0.25s var(--ease); }
.sheet {
  background: var(--surface);
  width: 100%; max-width: 560px;
  max-height: 90vh; overflow-y: auto;
  border-radius: 20px 20px 0 0;
  padding: 12px 22px calc(24px + env(safe-area-inset-bottom));
  animation: rise 0.35s var(--ease);
}
.sheet .grabber { width: 36px; height: 5px; border-radius: 3px; background: var(--surface-3); margin: 2px auto 16px; }
@media (min-width: 640px) {
  .overlay { align-items: center; padding: 24px; }
  .sheet { border-radius: 20px; animation: pop 0.3s var(--ease); }
  .sheet .grabber { display: none; }
}
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(40px); opacity: 0.6; } }
@keyframes pop { from { transform: scale(0.96); opacity: 0; } }

/* ── Toast ────────────────────────────────────────────────────────────── */
#toast {
  position: fixed; bottom: calc(84px + env(safe-area-inset-bottom)); left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  border: 0.5px solid var(--separator);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
  color: var(--text);
  padding: 12px 22px; border-radius: 980px;
  font-size: 14px; font-weight: 500;
  display: none; z-index: 99; max-width: 90vw; text-align: center;
}

/* ── Gráficos (specs dataviz: marcas finas, ponta 4px, gap 2px) ───────── */
.chart-bars {
  display: flex; align-items: flex-end; gap: 2px;
  height: 130px; margin-top: 16px;
  border-bottom: 1px solid var(--separator);
}
.chart-slot { flex: 1; display: flex; align-items: flex-end; justify-content: center; height: 100%; position: relative; }
.chart-slot .bar { width: 70%; max-width: 24px; background: var(--chart); border-radius: 4px 4px 0 0; }
.chart-slot .bar.zero { background: var(--surface-3); }
.chart-slot .peak {
  position: absolute; top: -2px; left: 50%; transform: translate(-50%, -100%);
  font-size: 11px; color: var(--text); font-weight: 700;
}
.chart-x { display: flex; gap: 2px; margin-top: 6px; }
.chart-x span { flex: 1; text-align: center; font-size: 10px; color: var(--text-3); }
.chart-tip {
  position: absolute;
  background: var(--surface);
  border: 0.5px solid var(--separator);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.16);
  border-radius: 10px;
  padding: 7px 12px; font-size: 12px; font-weight: 500;
  pointer-events: none; white-space: nowrap; display: none; z-index: 5;
  transform: translate(-50%, -112%);
}
.sender-row { display: flex; align-items: center; gap: 12px; padding: 8px 0; }
.sender-name { width: 34%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; }
.sender-track { flex: 1; }
.sender-bar { height: 8px; background: var(--chart); border-radius: 0 4px 4px 0; min-width: 3px; }
.sender-count { min-width: 28px; text-align: right; color: var(--text-2); font-size: 14px; font-variant-numeric: tabular-nums; }

/* ── Utilidades ───────────────────────────────────────────────────────── */
.hidden { display: none !important; }
.mt  { margin-top: 16px; }
.mt2 { margin-top: 28px; }
.center { text-align: center; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.hrow { display: flex; align-items: center; gap: 10px; }
.err { color: var(--danger); font-size: 14px; min-height: 20px; margin-top: 10px; }
.reveal { opacity: 0; transform: translateY(14px); }
.reveal.in { opacity: 1; transform: none; transition: opacity 0.7s var(--ease), transform 0.7s var(--ease); }
