/* ==========================================================
   Layout: página, cabeçalho, topo, números do dia e grade do painel
   ========================================================== */
.page {
  position: relative;
  overflow: hidden;
  overflow: clip;            /* clip não quebra o cabeçalho fixo (sticky) */
  min-height: calc(100vh / var(--zoom, 1));
  min-height: calc(100dvh / var(--zoom, 1));
  padding: 0 clamp(16px, 3vw, 48px) calc(32px + env(safe-area-inset-bottom, 0px));
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse 60% 45% at 50% 0%, rgba(40, 80, 170, 0.28) 0%, transparent 70%),
    radial-gradient(ellipse 50% 40% at 50% 70%, rgba(var(--accent-rgb), 0.2) 0%, transparent 70%);
}

/* Grade quadriculada que some nas bordas */
.page__grid {
  position: absolute;
  inset: 120px 0 auto 0;
  height: 900px;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(120, 160, 255, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(120, 160, 255, 0.07) 1px, transparent 1px);
  background-size: 28px 28px;
  -webkit-mask-image: radial-gradient(ellipse 45% 50% at 50% 50%, #000 0%, transparent 75%);
          mask-image: radial-gradient(ellipse 45% 50% at 50% 50%, #000 0%, transparent 75%);
}

/* ---------- Cabeçalho (fixo no topo ao rolar) ---------- */
.header {
  position: sticky;
  top: 0;
  z-index: 20;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: calc(14px + env(safe-area-inset-top, 0px)) 0 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.header::before {             /* fundo de vidro que ocupa a largura toda */
  content: "";
  position: absolute;
  inset: 0 -100vmax;
  z-index: -1;
  background: rgba(2, 8, 21, 0.72);
  -webkit-backdrop-filter: blur(8px);
          backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(140, 180, 255, 0.08);
}

.brand { display: flex; align-items: center; gap: 10px; color: var(--text-strong); flex: none; }
.brand__mark {
  width: 34px; height: 34px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: radial-gradient(circle at 35% 30%, #8EC5FF 0%, var(--accent) 45%, #0B2A7A 100%);
  box-shadow: 0 0 18px var(--accent-glow), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}
.brand__name { font-size: 20px; font-weight: 500; letter-spacing: -0.01em; }

.nav { display: flex; gap: clamp(16px, 2.4vw, 32px); font-size: 15px; }
.nav a { padding: 10px 2px; }

.header__right { display: flex; align-items: center; gap: 10px; flex: none; }

/* Indicador de conexão */
.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 14px;
  border-radius: var(--r-pill);
  font-size: 13px;
  color: var(--text-2);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.status__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); flex: none; }
.status[data-state="on"] .status__dot { background: var(--success); box-shadow: 0 0 8px var(--success); }
.status[data-state="off"] .status__dot { background: var(--danger); }
.status[data-state="demo"] .status__dot { background: #FCD34D; }
.status[data-state="loading"] .status__dot { animation: atlas-blink 1s ease-in-out infinite; }
@keyframes atlas-blink { 50% { opacity: .25; } }

/* ---------- Topo: saudação + esfera + ações ---------- */
.top {
  position: relative;
  max-width: var(--max-w);
  margin: clamp(16px, 2.5vw, 32px) auto 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px 24px;
}
.top__text { min-width: 0; }
.top__eyebrow { margin: 0 0 4px; font-size: 14px; color: var(--accent-light); }
.top__title {
  margin: 0;
  font-size: clamp(28px, 3vw, 40px);
  line-height: 1.1;
  font-weight: 400;
  letter-spacing: -0.025em;
  color: var(--text-strong);
}
.top__next { margin: 6px 0 0; font-size: 14px; color: var(--text-3); }
.top__actions { display: flex; align-items: center; gap: 14px; flex: none; }

/* Esfera (pequena, ao lado das ações) */
.orb {
  position: relative;
  flex: none;
  width: var(--orb-size);
  aspect-ratio: 1 / 1;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
}
.orb canvas { display: block; width: 100%; height: 100%; }
.orb:focus-visible { outline-offset: -14%; border-radius: 50%; }

/* ---------- Números do dia ---------- */
.stats {
  max-width: var(--max-w);
  margin: clamp(14px, 2vw, 24px) auto 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--gap);
}
.stat {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  align-items: center;
  column-gap: 14px;
  min-width: 0;
  padding: 14px 18px;
  border-radius: var(--r-ctl);
  color: var(--text);
  background: linear-gradient(180deg, var(--card-top) 0%, var(--card-bottom) 100%);
  border: 1px solid var(--border);
  transition: border-color .2s, transform .15s;
}
.stat:hover { color: var(--text); border-color: rgba(var(--accent-rgb), 0.55); transform: translateY(-1px); }
.stat__value {
  grid-row: 1 / 3;
  min-width: 1.4ch;
  font-size: 30px;
  font-weight: 500;
  line-height: 1;
  color: var(--text-strong);
  font-variant-numeric: tabular-nums;
}
.stat__label, .stat__detail { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat__label { font-size: 14px; color: var(--text); }
.stat__detail { font-size: 12.5px; color: var(--text-3); }
.stat--danger .stat__value, .stat--danger .stat__detail { color: var(--danger); }
.stat--success .stat__value { color: var(--success); }

/* ---------- Painel: grade que ocupa a tela ----------
   E-mails (maior) | Tarefas | Produtividade em cima de Automações */
.dash {
  max-width: var(--max-w);
  margin: var(--gap) auto 0;
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1.1fr) minmax(0, 0.95fr);
  grid-template-rows: minmax(0, 1fr) minmax(0, 1fr);
  grid-template-areas:
    "inbox tasks analytics"
    "inbox tasks auto";
  gap: var(--gap);
  height: max(500px, calc(100dvh / var(--zoom, 1) - var(--dash-offset)));
}
.dash__cell { min-width: 0; min-height: 0; scroll-margin-top: 84px; }
.dash__cell--inbox { grid-area: inbox; }
.dash__cell--tasks { grid-area: tasks; }
.dash__cell--analytics { grid-area: analytics; }
.dash__cell--auto { grid-area: auto; }

.foot {
  max-width: var(--max-w);
  margin: 24px auto 0;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
}

/* ---------- Avisos (toasts) ---------- */
.toasts {
  position: fixed;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  z-index: 60;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  max-width: min(420px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  padding: 12px 16px;
  border-radius: var(--r-ctl);
  font-size: 14px;
  line-height: 1.4;
  color: var(--text-strong);
  background: rgba(14, 26, 58, 0.95);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  animation: atlas-toast .25s ease both;
}
.toast--ok { border-left-color: var(--success); }
.toast--erro { border-left-color: var(--danger); }
.toast--out { opacity: 0; transform: translateY(6px); transition: opacity .3s, transform .3s; }
@keyframes atlas-toast { from { opacity: 0; transform: translateY(8px); } }

/* ---------- Responsivo ---------- */

/* Notebook / tela média: 2 colunas; Produtividade e Automações embaixo */
@media (max-width: 1180px) {
  .nav { display: none; }
  .dash {
    height: auto;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: 520px 300px;
    grid-template-areas:
      "inbox tasks"
      "analytics auto";
  }
}

/* Tablet: números em 2×2 */
@media (max-width: 860px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Celular: uma coluna, cartões com altura natural */
@media (max-width: 680px) {
  :root { --orb-size: 56px; --r-card: 18px; }
  .top { flex-direction: column; align-items: stretch; }
  .top__actions { justify-content: space-between; }
  .top__actions .btn { flex: 1; }
  .stat { padding: 12px 14px; column-gap: 10px; }
  .stat__value { font-size: 24px; }
  .dash {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: none;
    grid-template-areas: "inbox" "tasks" "analytics" "auto";
  }
  .toasts { left: 16px; right: 16px; align-items: stretch; max-width: none; }
}

/* Celular pequeno */
@media (max-width: 420px) {
  .status { width: 36px; padding: 0; justify-content: center; }
  .status__text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .brand__name { font-size: 18px; }
  .stat { grid-template-columns: 1fr; row-gap: 2px; }
  .stat__value { grid-row: auto; }
}
