* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: radial-gradient(900px 420px at 90% -10%, rgba(30, 136, 229, 0.16), transparent 60%), var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
[hidden] { display: none !important; }

/* Top bar (CRM-style): brand · tabs · search · CTA */
.topbar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; background: var(--surface); border-bottom: 1px solid var(--border); box-shadow: 0 6px 24px rgba(0,0,0,0.25); }
.topbar-inner { max-width: 1280px; margin: 0 auto; padding: 12px var(--space-4); display: flex; align-items: center; gap: var(--space-4); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); font-weight: 600; font-size: 14px; white-space: nowrap; }
.brand .mark { width: 30px; height: 30px; border-radius: 10px 10px 4px 4px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; }
.demo-pill { display: inline-block; font-size: 10px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent); background: var(--accent-soft); border-radius: 999px; padding: 2px 8px; margin-left: 6px; vertical-align: middle; }

.topnav { display: flex; gap: 4px; flex: 1; justify-content: center; }
.nav-item { display: inline-flex; align-items: center; gap: 8px; padding: 10px 14px; color: var(--text-muted); text-decoration: none; font-size: 13.5px; font-weight: 500; border-bottom: 2px solid transparent; border-radius: 6px 6px 0 0; white-space: nowrap; }
.nav-item:hover { color: var(--text); background: var(--surface-2); }
.nav-item.active { color: var(--accent); border-bottom-color: var(--accent); }
.nav-item .live-tag { font-size: 9px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; background: var(--m-pink); color: #fff; border-radius: 999px; padding: 2px 7px; }

.topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-search { display: flex; align-items: center; border-radius: 999px; padding: 7px 14px; background: var(--surface-2); color: var(--text-faint); font-size: 13px; min-width: 180px; border: 1px solid var(--border); }
.topbar-cta { white-space: nowrap; background: var(--m-pink); color: #fff; border-radius: 999px; padding: 8px 16px; font-size: 13px; font-weight: 600; text-decoration: none; }

.topbar-links { border-top: 1px solid var(--border); background: var(--bg); font-size: 12.5px; }
.topbar-links .topbar-inner { min-height: 38px; gap: 16px; }
.topbar-links a { color: var(--text-faint); text-decoration: none; }
.topbar-links a:hover { color: var(--accent); }
.topbar-links .spacer { flex: 1; }
.page-title { font-weight: 600; color: var(--text); }
.page-date { color: var(--text-faint); }

.page { max-width: 1280px; margin: 0 auto; }
.view { padding: var(--space-4); }
.view-grid { display: grid; gap: var(--space-3); }
.view-grid > * { min-width: 0; }
.row-kpis { grid-template-columns: repeat(5, 1fr); }
.row-charts { grid-template-columns: 2fr 1fr; }
.row-half { grid-template-columns: 1fr 1fr; }
canvas { max-width: 100%; }

.page-footer { border-top: 1px solid var(--border); margin-top: var(--space-5); color: var(--text-faint); font-size: 11.5px; }
.page-footer .topbar-inner { padding: 16px var(--space-4) 24px; }

@media (max-width: 1024px) {
  .topbar-search { display: none; }
  .row-kpis { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 760px) {
  .topbar-inner { flex-wrap: wrap; gap: 8px 16px; }
  .topnav { order: 3; width: 100%; justify-content: flex-start; overflow-x: auto; }
  .brand-text { display: none; }
  .row-kpis, .row-charts, .row-half { grid-template-columns: 1fr; }
  .page-date { display: none; }
}

.drawer-overlay { position: fixed; inset: 0; background: rgba(5, 9, 18, 0.6); z-index: 20; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 480px; max-width: 100vw;
  background: var(--surface); box-shadow: var(--shadow-md); z-index: 21;
  display: flex; flex-direction: column; overflow-y: auto;
  border-left: 1px solid var(--border);
  border-radius: 28px 0 0 0;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
