/* ── App Shell ── */
.app-body { min-height: 100dvh; background: var(--surface-soft); }
.app-body [hidden] { display: none !important; }
.app-layout { min-height: 100dvh; display: grid; grid-template-columns: 240px minmax(0, 1fr); }

/* Sidebar */
.sidebar {
  position: sticky; top: 0; height: 100dvh;
  display: flex; flex-direction: column;
  border-right: 1px solid #1e3d4a;
  background: var(--ink-950); color: #fff;
  padding: var(--sp-6) var(--sp-3);
  overflow-y: auto;
  scrollbar-width: thin;
}
.sidebar .brand { padding-inline: var(--sp-2); color: #fff; gap: 9px; }
.sidebar .brand-mark { background: var(--brand-600); }

.sidebar-nav { display: grid; gap: 2px; margin-top: var(--sp-8); flex-shrink: 0; }
.sidebar-nav a {
  display: flex; align-items: center; gap: 10px;
  border-radius: var(--r-sm);
  padding: 10px 12px;
  color: #96b2b9; font-size: 0.9rem; font-weight: 600;
  text-decoration: none;
  transition: background 120ms ease, color 120ms ease;
}
.sidebar-nav a:hover { background: #1e3d4a; color: #daedf1; }
.sidebar-nav a.active { background: #1e3d4a; color: #fff; }
.sidebar-nav a svg { flex: 0 0 auto; opacity: 0.75; }
.sidebar-nav a.active svg { opacity: 1; }

.sidebar-toggle { width: 100%; display: flex; align-items: center; gap: 10px; margin-top: var(--sp-3); border: 0; border-radius: var(--r-sm); background: transparent; color: #96b2b9; padding: 10px 12px; font: inherit; font-size: 0.84rem; font-weight: 600; text-align: left; cursor: pointer; }
.sidebar-toggle:hover { background: #1e3d4a; color: #daedf1; }
.sidebar-toggle__icon { width: 24px; height: 24px; display: grid; place-items: center; flex: 0 0 auto; }
.sidebar-toggle__label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mobile-sidebar-toggle, .sidebar-mobile-backdrop { display: none; }

.sidebar-user { margin-top: auto; border-top: 1px solid #1e3d4a; padding: var(--sp-4) var(--sp-2) 0; }
.sidebar-user strong, .sidebar-user span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user span { color: #7a9da5; font-size: 0.8rem; margin-top: 2px; }
.sidebar-user button { margin-top: var(--sp-3); border: 0; background: transparent; color: #c0d6db; padding: 0; font-size: 0.85rem; font-weight: 600; cursor: pointer; }
.sidebar-user button:hover { color: #fff; }

/* Conteudo principal */
.app-content { min-width: 0; width: 100%; }
.app-topbar {
  min-height: 68px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  padding: 10px clamp(16px, 3.5vw, 40px);
  backdrop-filter: blur(12px);
  position: sticky; top: 0; z-index: 20;
}
.topbar-context { margin: 0; color: var(--ink-600); font-size: 0.82rem; font-weight: 750; letter-spacing: 0.02em; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.app-main { width: 100%; max-width: 1200px; min-width: 0; margin-inline: auto; padding: clamp(28px, 4vw, 52px); }
.app-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: var(--sp-8); }
.app-heading h1 { margin: 5px 0 8px; font-size: clamp(2rem, 4vw, 3rem); }
.app-heading p { margin: 0; color: var(--ink-600); font-size: 0.95rem; }

/* Dashboard */
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(280px, 0.55fr); gap: var(--sp-5); }
.dashboard-grid--full { grid-template-columns: minmax(0, 1fr); }
.dashboard-stack { display: grid; gap: var(--sp-4); align-content: start; }
.dashboard-aside { display: grid; align-content: start; gap: var(--sp-4); }

.today-card {
  position: relative; overflow: hidden;
  isolation: isolate;
  background: linear-gradient(135deg, #0f3c48, var(--brand-700)); color: #fff;
  padding: clamp(26px, 4vw, 42px);
  border-radius: var(--r-lg);
  box-shadow: 0 18px 42px rgba(14, 40, 48, 0.16);
}
.today-card::before, .today-card::after { content: ""; position: absolute; z-index: -1; border: 1px solid rgba(255,255,255,0.12); border-radius: 50%; pointer-events: none; }
.today-card::before { width: 340px; height: 340px; right: -130px; top: -180px; box-shadow: 0 0 0 42px rgba(255,255,255,0.035), 0 0 0 84px rgba(255,255,255,0.018); }
.today-card::after { width: 170px; height: 170px; left: 55%; bottom: -130px; }
.today-card__heading { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); }
.today-card__eyebrow { display: inline-flex; align-items: center; gap: 7px; color: #c5e8ed; font-size: 0.75rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }
.today-card__state { border: 1px solid rgba(255,255,255,0.16); border-radius: 999px; background: rgba(255,255,255,0.08); color: #e9f7f8; padding: 5px 9px; font-size: 0.72rem; font-weight: 750; white-space: nowrap; }
.today-card h2 { max-width: 620px; margin: var(--sp-5) 0 var(--sp-2); font-size: clamp(1.6rem, 3.4vw, 2.35rem); line-height: 1.14; }
.today-card p { max-width: 600px; color: rgba(255,255,255,0.76); font-size: 0.98rem; margin-bottom: 0; }
.today-card__details { display: flex; flex-wrap: wrap; gap: 9px 24px; margin-top: var(--sp-5); color: rgba(255,255,255,0.78); font-size: 0.84rem; }
.today-card__details strong { color: #fff; font-size: 1rem; font-variant-numeric: tabular-nums; }
.today-card .button { margin-top: var(--sp-5); color: var(--ink-950); font-weight: 800; }
.today-card__motto { margin: var(--sp-4) 0 0; color: rgba(255,255,255,0.62); font-size: 0.78rem; font-style: italic; }
.today-card__guide { display: inline-flex; align-items: center; gap: 7px; margin-top: var(--sp-4); color: #d8f2f5; font-size: 0.82rem; font-weight: 750; text-decoration: none; }
.today-card__guide:hover { color: #fff; text-decoration: underline; text-underline-offset: 3px; }

.metric-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-3); }
.metric-card { min-height: 142px; padding: var(--sp-5); box-shadow: none; }
.metric-card span { display: block; color: var(--ink-600); font-size: 0.78rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
.metric-card strong { display: block; margin-top: var(--sp-2); font-size: clamp(1.45rem, 3.5vw, 2rem); letter-spacing: -0.04em; color: var(--ink-950); }
.metric-card > small { display: block; margin-top: 2px; color: var(--ink-400); font-size: 0.75rem; }
.metric-card--primary { border-color: #bddce2; background: linear-gradient(145deg, #f4fbfc, var(--surface)); }

.quick-card, .activity-card { padding: var(--sp-5); box-shadow: none; }
.quick-card h3, .activity-card h3 { margin: 2px 0 0; font-size: 1.05rem; }
.section-card__heading { display: flex; align-items: start; justify-content: space-between; gap: var(--sp-3); }
.section-kicker { color: var(--brand-600); font-size: 0.68rem; font-weight: 850; letter-spacing: 0.1em; text-transform: uppercase; }
.quick-list { display: grid; gap: var(--sp-2); }
.quick-link { display: flex; align-items: center; gap: 12px; border: 1px solid var(--line); border-radius: var(--r-sm); padding: 12px; text-decoration: none; transition: border-color 120ms ease, background 120ms ease; }
.quick-link:hover { border-color: var(--brand-500); background: var(--brand-100); }
.quick-link > span:not(.icon-box) { display: block; min-width: 0; }
.quick-link > span:not(.icon-box) > strong { display: block; color: var(--ink-950); font-size: 0.9rem; }
.quick-link > span:not(.icon-box) > span { display: block; color: var(--ink-600); font-size: 0.79rem; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.activity-list { display: grid; gap: var(--sp-3); margin-top: var(--sp-4); }
.activity-caption { color: var(--ink-400); font-size: 0.76rem; font-weight: 700; white-space: nowrap; }
.activity-heatmap { display: flex; gap: 8px; }
.activity-day { position: relative; flex: 1; aspect-ratio: 1; min-width: 0; border-radius: 9px; background: var(--surface-muted); }
.activity-day::after { content: attr(data-day); position: absolute; left: 50%; bottom: -20px; translate: -50% 0; color: var(--ink-400); font-size: 0.66rem; font-weight: 700; }
.activity-list p { margin: 20px 0 0; }

.activity-item { display: flex; gap: 12px; align-items: center; }
.activity-item > div > strong { display: block; font-size: 0.9rem; color: var(--ink-950); }
.activity-item > div > span { display: block; margin-top: 2px; color: var(--ink-600); font-size: 0.8rem; }
.activity-item time { margin-left: auto; color: var(--ink-400); font-size: 0.78rem; white-space: nowrap; }

/* Bottom nav - oculto por padrao no desktop */
.bottom-nav { display: none; }

/* ── Colapso da sidebar (desktop) ── */
@media (min-width: 701px) {
  .app-layout.is-sidebar-collapsed { grid-template-columns: 72px minmax(0, 1fr); }
  .app-layout.is-sidebar-collapsed .sidebar { align-items: center; padding-inline: var(--sp-2); }
  .app-layout.is-sidebar-collapsed .sidebar .brand > span:last-child,
  .app-layout.is-sidebar-collapsed .sidebar-nav a > span:last-child,
  .app-layout.is-sidebar-collapsed .sidebar-toggle__label,
  .app-layout.is-sidebar-collapsed .sidebar-user { display: none; }
  .app-layout.is-sidebar-collapsed .sidebar-toggle { width: auto; padding: 10px; }
}

/* ── Tablet ── */
@media (max-width: 980px) {
  /* Preserve the full menu unless the user explicitly collapses it. */
  .app-main { padding: 24px; }
  .topbar-actions > .small { display: none; }
  .dashboard-grid { grid-template-columns: 1fr; }
}

/* ── Mobile ── */
@media (max-width: 700px) {
  .app-layout { display: block; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 90;
    width: 232px; max-width: 64vw; height: 100dvh;
    display: flex; padding: var(--sp-6) var(--sp-3);
    transform: translateX(-105%); visibility: hidden;
    transition: transform 180ms ease, visibility 0s linear 180ms;
    box-shadow: 18px 0 42px rgba(6, 22, 29, 0.24);
  }
  .app-layout.is-mobile-sidebar-open .sidebar { transform: translateX(0); visibility: visible; transition: transform 180ms ease; }
  .sidebar .brand > span:last-child, .sidebar-nav a > span:last-child, .sidebar-toggle__label, .sidebar-user { display: block; }
  .sidebar .nav-symbol { display: inline-block; }
  .sidebar-nav a { padding: 10px 12px; justify-content: flex-start; }
  .sidebar-toggle { display: none; }
  .mobile-sidebar-toggle { display: inline-grid; place-items: center; width: 40px; height: 40px; flex: 0 0 auto; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); color: var(--ink-800); font: inherit; font-size: 1.35rem; cursor: pointer; }
  .sidebar-mobile-backdrop { display: block; position: fixed; inset: 0; z-index: 80; border: 0; background: rgba(5, 20, 27, 0.42); }
  .sidebar-mobile-backdrop[hidden] { display: none; }

  /* Bottom nav ativo no mobile */
  .bottom-nav {
    display: flex;
    position: fixed; bottom: 0; left: 0; right: 0;
    z-index: 40;
    border-top: 1px solid var(--line);
    background: rgba(255,255,255,0.97);
    backdrop-filter: blur(12px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .bottom-nav a {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 4px;
    padding: 10px 4px;
    color: var(--ink-400); font-size: 0.68rem; font-weight: 700;
    letter-spacing: 0.03em; text-decoration: none;
    transition: color 120ms ease;
  }
  .bottom-nav a svg { opacity: 0.65; transition: opacity 120ms ease; }
  .bottom-nav a.active, .bottom-nav a[aria-current="page"] { color: var(--brand-700); }
  .bottom-nav a.active svg, .bottom-nav a[aria-current="page"] svg { opacity: 1; }
  .nav-symbol { display: none; }

  .app-topbar { position: sticky; top: 0; min-height: 56px; padding: 8px 14px; }
  .app-topbar .topbar-actions { display: none; }
  .app-main { padding: var(--sp-4) var(--sp-3) calc(var(--sp-16) + 16px); }
  .app-heading { flex-direction: column; align-items: start; gap: 6px; }
  .metric-grid { grid-template-columns: repeat(3, 1fr); }
  .metric-card { padding: 13px 10px; }
  .metric-card strong { font-size: 1.35rem; }
  .quick-link { padding: 14px 12px; }
  .quick-link .icon-box { width: 38px; height: 38px; }
  .today-card h2 { font-size: 1.55rem; }
}

@media (max-width: 440px) {
  .metric-grid { grid-template-columns: 1fr; }
  .metric-card { display: flex; align-items: center; justify-content: space-between; }
  .metric-card strong { margin-top: 0; }
  .today-card p { font-size: 0.9rem; }
}

/* === Ajustes Dark Mode para o App Shell === */
[data-theme="dark"] .app-topbar {
  background: rgba(21, 32, 36, 0.94);
}
[data-theme="dark"] .bottom-nav {
  background: rgba(21, 32, 36, 0.97);
}
[data-theme="dark"] .sidebar {
  background: #0b1114;
  border-right-color: var(--line);
}
[data-theme="dark"] .sidebar-nav a:hover,
[data-theme="dark"] .sidebar-nav a.active {
  background: #17242a;
}
[data-theme="dark"] .today-card { background: linear-gradient(135deg, #0e313a, #174f5f); }
[data-theme="dark"] .metric-card--primary { background: linear-gradient(145deg, #152b31, var(--surface)); border-color: #244b56; }

/* === Grafico de Retencao Circular (CSS) === */
.retention-chart {
  display: flex; align-items: center; gap: 12px;
}
.retention-circle {
  width: 48px; height: 48px;
  border-radius: 50%;
  background: conic-gradient(var(--success-600) 0%, var(--success-600) var(--retention-pct, 0%), var(--surface-muted) var(--retention-pct, 0%), var(--surface-muted) 100%);
  display: grid; place-items: center;
  position: relative;
}
.retention-circle::after {
  content: ""; width: 38px; height: 38px;
  border-radius: 50%; background: var(--surface);
  position: absolute;
}
.retention-circle span {
  position: relative; z-index: 1;
  font-size: 0.8rem; font-weight: 800; color: var(--ink-950);
}
