/* Camada do app sobre o Slowe Design System (static/slowe/css/tokens.css + slowe.css).
   Nada de cor própria aqui: tudo deriva dos tokens, então os temas roxo/offwhite funcionam sozinhos. */

:root {
  /* aliases usados pelos gráficos ECharts (charts.js lê estes nomes) */
  --s1: var(--viz-2);      /* violeta */
  --s2: var(--viz-1);      /* caramelo */
  --s3: var(--success);    /* 3ª série: verde-água validado contra violeta/caramelo */
  --grid: var(--line);
  --axis: var(--line-strong);
  --chart-surface: var(--surface-raised);
}

body { font-family: var(--font-sans); }
.ink-2 { color: var(--ink-muted); }
.ink-3 { color: var(--ink-subtle); }
.num { font-variant-numeric: tabular-nums; }
a { color: inherit; }

/* layout */
.app-side { position: sticky; top: 0; height: 100vh; flex: none; }
.app-side .sl-nav a [data-sl-icon] { color: var(--brand-icon); }
.app-side__foot { margin-top: auto; display: flex; flex-direction: column; gap: var(--space-3); }
.sl-main { gap: 0; }
.app-section { margin-bottom: var(--space-5); }
.span-2 { grid-column: span 2; }
@media (max-width: 1100px) { .span-2 { grid-column: auto; } }
@media (max-width: 640px) { .sl-main { padding: var(--space-5) var(--space-4); } }

/* cabeçalho */
.app-greet { margin: 4px 0 0; font: 300 40px/48px var(--font-sans); letter-spacing: -.02em; }
.app-greet b { font-weight: 300; background: var(--sl-vivid); -webkit-background-clip: text; background-clip: text; color: transparent; }
[data-theme="offwhite"] .app-greet b { background: none; color: var(--ink); font-weight: 600; }
@media (max-width: 640px) { .app-greet { font-size: 30px; line-height: 36px; } }

/* formulário (o DS não traz inputs) */
.sl-input, .sl-select {
  height: 40px; width: 100%; padding: 0 14px; border-radius: var(--radius-md);
  background: var(--surface-sunken); border: 1px solid var(--line); color: var(--ink);
  font: 400 14px/1 var(--font-sans); outline: none; transition: border-color .2s, box-shadow .2s;
}
.sl-input::placeholder { color: var(--ink-subtle); }
.sl-input:focus, .sl-select:focus { border-color: var(--focus-ring); box-shadow: 0 0 0 3px var(--viz-1-soft); }
.sl-select {
  appearance: none; width: auto; padding-right: 36px; cursor: pointer; border-radius: var(--radius-pill);
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-muted) 50%), linear-gradient(135deg, var(--ink-muted) 50%, transparent 50%);
  background-position: right 18px top 18px, right 13px top 18px; background-size: 5px 5px; background-repeat: no-repeat;
}
.sl-select option { background: var(--surface-overlay); color: var(--ink); }
.sl-input--sm, .sl-select--sm { height: 32px; font-size: 12px; }
.sl-select--sm { background-position: right 16px top 14px, right 11px top 14px; }

/* painéis */
.sl-panel { min-width: 0; }
/* valores longos (R$ 1.226.098) não estouram o card em telas médias */
.sl-kpi { min-width: 0; container-type: inline-size; }
.sl-kpi__value { font-size: clamp(22px, 15cqi, 40px); line-height: 1.1; }
.panel-head-right { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; justify-content: flex-end; }
.sl-panel details summary { cursor: pointer; user-select: none; font-size: 12px; color: var(--ink-subtle); }
.chart { width: 100%; }

/* alertas compactos */
.alert { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-4); text-decoration: none; transition: transform .25s cubic-bezier(.2,.8,.2,1), border-color .25s; }
.alert:hover { transform: translateY(-2px); border-color: var(--line-strong); }
.alert .sl-kpi__icon { flex: none; }
.alert__value { font: 300 26px/30px var(--font-sans); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.tone-danger { --sl-c1: var(--danger); --sl-soft: var(--danger-soft); }
.tone-warning { --sl-c1: var(--warning); --sl-soft: var(--warning-soft); }
.tone-success { --sl-c1: var(--success); --sl-soft: var(--success-soft); }

/* listas de pessoas */
.people { list-style: none; margin: 0; padding: 0; }
.people > li { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) 0; border-bottom: 1px solid var(--line); }
.people > li:last-child { border-bottom: 0; }
.people .grow { min-width: 0; flex: 1; }
.people .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.people .meta { font-size: 12px; line-height: 18px; color: var(--ink-subtle); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.people > li:nth-child(4n+2) { --sl-c1: var(--viz-1); --sl-soft: var(--viz-1-soft); }
.people > li:nth-child(4n+3) { --sl-c1: var(--viz-4); --sl-soft: var(--viz-4-soft); }
.people > li:nth-child(4n+4) { --sl-c1: var(--viz-3); --sl-soft: var(--viz-3-soft); }
.sl-avatar img { width: 100%; height: 100%; border-radius: inherit; object-fit: cover; }
.sl-avatar { overflow: hidden; }
.scroll-y { overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }

/* barras de funil (renovação) */
.funnel { display: flex; flex-direction: column; gap: var(--space-3); }
.funnel .row { display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: var(--ink-muted); }
.funnel .row b { color: var(--ink); font-variant-numeric: tabular-nums; }
.funnel .sl-bars__track { margin-top: 6px; }

/* carregando (HTMX) */
.skeleton { border-radius: var(--radius-lg); background: linear-gradient(90deg, var(--surface-raised) 25%, var(--surface-overlay) 37%, var(--surface-raised) 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; border: 1px solid var(--line); }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* entrada escalonada */
.rise { animation: rise .7s cubic-bezier(.2,.8,.2,1) both; }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.sl-grid > .rise:nth-child(2) { animation-delay: .06s; } .sl-grid > .rise:nth-child(3) { animation-delay: .12s; }
.sl-grid > .rise:nth-child(4) { animation-delay: .18s; }

.live-dot { width: 8px; height: 8px; border-radius: 99px; background: var(--success); display: inline-block; box-shadow: 0 0 0 0 var(--success-soft); animation: pulse 2s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 10px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }

/* itens clicáveis que abrem a lista de clientes */
.is-drill { cursor: pointer; border-radius: var(--radius-md); margin: -6px -8px; padding: 6px 8px; transition: background .15s ease; }
.is-drill:hover, .is-drill:focus-visible { background: var(--surface-sunken); outline: none; }
.is-drill:focus-visible { box-shadow: 0 0 0 2px var(--line-strong); }
.sl-bars:has(.is-drill) { gap: var(--space-2); }
.funnel:has(.is-drill) { gap: var(--space-1); }
.is-drill-card { cursor: pointer; transition: transform .15s ease, box-shadow .15s ease; }
.is-drill-card:hover, .is-drill-card:focus-visible { transform: translateY(-2px); outline: none; box-shadow: 0 0 0 1px var(--line-strong), var(--shadow-md, 0 12px 32px -16px rgba(13,5,13,.5)); }
.is-drill-pill { cursor: pointer; border-radius: var(--radius-sm, 6px); text-underline-offset: 3px; }
.is-drill-pill:hover, .is-drill-pill:focus-visible { text-decoration: underline; outline: none; }

/* gaveta lateral */
.drawer { margin: 0 0 0 auto; height: 100dvh; max-height: none; width: min(560px, 100vw); padding: 0; border: 0; border-left: 1px solid var(--line);
  background: var(--surface-raised); color: var(--ink); box-shadow: -24px 0 64px -24px rgba(13,5,13,.6); }
.drawer[open] { animation: drawer-in .28s cubic-bezier(.2,.8,.2,1); }
.drawer::backdrop { background: rgba(13,5,13,.45); backdrop-filter: blur(2px); }
@keyframes drawer-in { from { transform: translateX(32px); opacity: 0; } to { transform: none; opacity: 1; } }
#drawer-body { height: 100%; }
.drawer__inner { display: flex; flex-direction: column; height: 100%; padding: var(--space-5) var(--space-5) 0; }
.drawer__head { display: flex; align-items: flex-start; gap: var(--space-3); margin-bottom: var(--space-4); }
.drawer__head > :first-child { flex: 1; }
.drawer__list { flex: 1; min-height: 0; padding-right: 4px; padding-bottom: var(--space-5); }
.drawer .skeleton { margin: var(--space-5); height: calc(100% - 2 * var(--space-5)); }
@media (max-width: 640px) { .drawer__inner { padding: var(--space-4) 16px 0; } }

@media (prefers-reduced-motion: reduce) { .rise, .skeleton, .live-dot, .drawer[open] { animation: none !important; } }
