/* ==========================================================================
   WS Central — Portal da Conta WS (/conta) e Console (/central)
   Construído só com os tokens do WS GLASS. Mobile primeiro: barra inferior flutuante no celular,
   barra lateral a partir de 1024 px (ou conforme a preferência "Navegação").
   ========================================================================== */

.cx { min-height: 100dvh; }
.cx-root { min-height: 100dvh; }
.cx-skip { position: absolute; left: var(--ws-space-4); top: -100px; z-index: var(--ws-z-toast); padding: var(--ws-space-3) var(--ws-space-4);
  border-radius: var(--ws-radius-sm); background: var(--ws-green); color: var(--ws-on-green); font-weight: var(--ws-weight-semibold); }
.cx-skip:focus { top: var(--ws-space-4); }
.cx-noscript { padding: var(--ws-space-8); text-align: center; }
.cx-loading { min-height: 60dvh; display: flex; align-items: center; justify-content: center; gap: var(--ws-space-3); color: var(--ws-text-3); }
.cx-spinner { width: 1.25rem; height: 1.25rem; border-radius: 50%; border: 2.5px solid var(--ws-surface-3); border-top-color: var(--ws-green); animation: ws-spin 0.8s linear infinite; }

/* ---------- Superfície glass compartilhada ---------- */
.cx-glass {
  background: var(--ws-surface); border: 1px solid var(--ws-border); box-shadow: var(--ws-highlight), var(--ws-shadow-md);
  -webkit-backdrop-filter: blur(var(--ws-blur)) saturate(var(--ws-saturate)); backdrop-filter: blur(var(--ws-blur)) saturate(var(--ws-saturate));
}

/* ---------- Telas de acesso (entrar, cadastro, senha) ---------- */
.cx-auth { min-height: 100dvh; display: grid; place-items: center; padding: calc(var(--ws-space-6) + env(safe-area-inset-top)) var(--ws-gutter) calc(var(--ws-space-6) + env(safe-area-inset-bottom)); }
.cx-auth__card { width: min(100%, 27rem); border-radius: var(--ws-radius-xl); padding: clamp(1.5rem, 1rem + 2vw, 2.25rem); display: flex; flex-direction: column; gap: var(--ws-space-5); }
.cx-auth__brand { display: flex; align-items: center; gap: var(--ws-space-3); }
.cx-auth__brand img { height: 2rem; width: auto; }
.cx-auth__brand span { font-family: var(--ws-font-display); font-weight: 800; letter-spacing: -0.02em; font-size: var(--ws-text-lg); }
.cx-auth__title { margin: 0; font-size: var(--ws-text-2xl); }
.cx-auth__lead { margin: 0; color: var(--ws-text-2); font-size: var(--ws-text-sm); }
.cx-auth__foot { margin: 0; text-align: center; font-size: var(--ws-text-sm); color: var(--ws-text-2); }
.cx-auth__foot a, .cx-link { color: var(--ws-accent-ink); font-weight: var(--ws-weight-semibold); text-decoration: none; }
.cx-auth__foot a:hover, .cx-link:hover { text-decoration: underline; }
.cx-auth__products { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--ws-space-2) var(--ws-space-4); font-size: var(--ws-text-xs); color: var(--ws-text-3); }
.cx-auth__products a { color: inherit; }
.cx-form { display: flex; flex-direction: column; gap: var(--ws-space-4); }
.cx-form__error:empty { display: none; }
.cx-code-input { font-family: var(--ws-font-mono); font-size: var(--ws-text-xl) !important; letter-spacing: 0.3em; text-align: center; }

/* ---------- Estrutura com navegação ---------- */
.cx-app { min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
.cx-top {
  position: sticky; top: 0; z-index: var(--ws-z-header); display: flex; align-items: center; gap: var(--ws-space-3);
  min-height: var(--ws-header-h); padding: env(safe-area-inset-top) var(--ws-gutter) 0; border-width: 0 0 1px; border-radius: 0; box-shadow: none;
}
.cx-top__brand { display: inline-flex; align-items: center; gap: var(--ws-space-2); text-decoration: none; min-width: 0; }
.cx-top__brand img { height: 1.6rem; width: auto; flex: none; }
.cx-top__brand b { font-family: var(--ws-font-display); font-weight: 800; letter-spacing: -0.02em; white-space: nowrap; }
.cx-top__badge { font-size: var(--ws-text-xs); font-weight: var(--ws-weight-semibold); padding: 0.15rem 0.55rem; border-radius: var(--ws-radius-pill);
  background: var(--ws-accent-soft); color: var(--ws-accent-ink); border: 1px solid var(--ws-accent-border); }
.cx-top__spacer { flex: 1; }
.cx-top__user { display: flex; align-items: center; gap: var(--ws-space-2); min-width: 0; }
.cx-avatar { flex: none; display: grid; place-items: center; width: 2.25rem; height: 2.25rem; border-radius: 50%; background: var(--ws-surface-3);
  color: var(--ws-text); font-weight: var(--ws-weight-bold); font-size: var(--ws-text-sm); }
.cx-top__name { font-size: var(--ws-text-sm); font-weight: var(--ws-weight-medium); max-width: 12rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.cx-body { display: grid; grid-template-columns: minmax(0, 1fr); }
.cx-main { min-width: 0; padding: var(--ws-space-6) var(--ws-gutter) calc(var(--ws-tabbar-h) + var(--ws-space-10) + env(safe-area-inset-bottom)); }
.cx-main:focus { outline: none; }
.cx-main__inner { width: 100%; max-width: 52rem; margin-inline: auto; display: flex; flex-direction: column; gap: var(--ws-space-6); }
.cx-main__inner--wide { max-width: var(--ws-container-wide); }

/* Barra lateral */
.cx-side { display: none; }
.cx-side__nav { position: sticky; top: calc(var(--ws-header-h) + var(--ws-space-4)); display: flex; flex-direction: column; gap: 2px; padding: var(--ws-space-4) var(--ws-space-3); }
.cx-side__link, .cx-tab {
  display: flex; align-items: center; gap: var(--ws-space-3); min-height: var(--ws-touch); padding: 0 var(--ws-space-3); border-radius: var(--ws-radius-md);
  color: var(--ws-text-2); text-decoration: none; font-weight: var(--ws-weight-medium); font-size: var(--ws-text-sm);
  transition: background-color var(--ws-dur-fast) var(--ws-ease), color var(--ws-dur-fast) var(--ws-ease);
}
.cx-side__link:hover { background: var(--ws-surface-2); color: var(--ws-text); }
.cx-side__link[aria-current="page"] { background: var(--ws-accent-soft); color: var(--ws-text); box-shadow: inset 3px 0 0 var(--ws-green); }
.cx-side__link[aria-current="page"] .ws-icon { color: var(--ws-accent-ink); }
.cx-side__sep { height: 1px; background: var(--ws-border); margin: var(--ws-space-3) var(--ws-space-2); }

/* Barra inferior flutuante (celular) */
.cx-tabbar {
  position: fixed; z-index: var(--ws-z-tabbar); left: 50%; transform: translateX(-50%);
  bottom: calc(var(--ws-space-3) + env(safe-area-inset-bottom)); width: min(calc(100vw - 1.5rem), 30rem);
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 2px; padding: 4px; border-radius: var(--ws-radius-xl);
}
.cx-tab { flex-direction: column; justify-content: center; gap: 2px; min-height: 3.4rem; padding: var(--ws-space-1); font-size: 0.6875rem; text-align: center; border-radius: calc(var(--ws-radius-xl) - 4px); }
.cx-tab span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cx-tab[aria-current="page"] { background: var(--ws-accent-soft); color: var(--ws-text); }
.cx-tab[aria-current="page"] .ws-icon { color: var(--ws-accent-ink); }
.cx-tab:focus-visible, .cx-side__link:focus-visible { outline: 2px solid var(--ws-focus); outline-offset: 1px; }

@media (min-width: 1024px) {
  html:not([data-nav="inferior"]) .cx-body { grid-template-columns: 15.5rem minmax(0, 1fr); }
  html:not([data-nav="inferior"]) .cx-side { display: block; border-right: 1px solid var(--ws-border); }
  html:not([data-nav="inferior"]) .cx-tabbar { display: none; }
  html:not([data-nav="inferior"]) .cx-main { padding-bottom: var(--ws-space-12); }
}
@media (min-width: 640px) and (max-width: 1023.98px) {
  html[data-nav="lateral"] .cx-body { grid-template-columns: 13.5rem minmax(0, 1fr); }
  html[data-nav="lateral"] .cx-side { display: block; border-right: 1px solid var(--ws-border); }
  html[data-nav="lateral"] .cx-tabbar { display: none; }
  html[data-nav="lateral"] .cx-main { padding-bottom: var(--ws-space-12); }
}
@media (min-width: 2200px) { .cx-main__inner--wide { max-width: 130rem; } }

/* ---------- Cabeçalho de página ---------- */
.cx-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--ws-space-3); }
.cx-head h1 { margin: 0; font-size: var(--ws-text-2xl); }
.cx-head p { margin: var(--ws-space-1) 0 0; color: var(--ws-text-2); font-size: var(--ws-text-sm); max-width: 42rem; }
.cx-head__actions { display: flex; flex-wrap: wrap; gap: var(--ws-space-2); }
.cx-back { display: inline-flex; align-items: center; gap: var(--ws-space-1); color: var(--ws-text-2); font-size: var(--ws-text-sm); text-decoration: none; }
.cx-back:hover { color: var(--ws-text); }

/* ---------- Cards ---------- */
.cx-card { position: relative; border-radius: var(--ws-radius-lg); padding: var(--ws-space-5); display: flex; flex-direction: column; gap: var(--ws-space-4); min-width: 0; }
.cx-card__head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--ws-space-3); }
.cx-card__title { margin: 0; font-size: var(--ws-text-lg); font-weight: var(--ws-weight-semibold); letter-spacing: -0.01em; display: flex; align-items: center; gap: var(--ws-space-2); }
.cx-card__title .ws-icon { color: var(--ws-accent-ink); }
.cx-card__text { margin: 0; color: var(--ws-text-2); font-size: var(--ws-text-sm); }
.cx-card__foot { display: flex; flex-wrap: wrap; gap: var(--ws-space-2); }

.cx-kpis { display: grid; gap: var(--ws-space-3); grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 760px) { .cx-kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (min-width: 1600px) { .cx-kpis--6 { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
.cx-kpi { border-radius: var(--ws-radius-lg); padding: var(--ws-space-4); display: flex; flex-direction: column; gap: var(--ws-space-1); min-width: 0; }
.cx-kpi__label { font-size: var(--ws-text-xs); color: var(--ws-text-3); font-weight: var(--ws-weight-semibold); text-transform: uppercase; letter-spacing: 0.07em; }
.cx-kpi__value { font-family: var(--ws-font-display); font-size: var(--ws-text-2xl); font-weight: var(--ws-weight-bold); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; line-height: 1.1; }
.cx-kpi__hint { font-size: var(--ws-text-xs); color: var(--ws-text-3); }

.cx-grid { display: grid; gap: var(--ws-space-4); grid-template-columns: minmax(0, 1fr); }
@media (min-width: 900px) { .cx-grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .cx-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1500px) { .cx-grid--auto { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 900px) and (max-width: 1499.98px) { .cx-grid--auto { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ---------- Listas de linhas (contas, sessões, eventos) ---------- */
.cx-rows { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.cx-rows > li { border-top: 1px solid var(--ws-border); }
.cx-rows > li:first-child { border-top: 0; }
.cx-row { display: flex; align-items: center; gap: var(--ws-space-3); min-height: 3.5rem; padding: var(--ws-space-3) 0; min-width: 0; color: inherit; text-decoration: none; }
a.cx-row:hover .cx-row__title { text-decoration: underline; }
.cx-row__body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.cx-row__title { font-weight: var(--ws-weight-medium); overflow-wrap: anywhere; }
.cx-row__meta { font-size: var(--ws-text-xs); color: var(--ws-text-3); overflow-wrap: anywhere; }
.cx-row__side { display: flex; align-items: center; gap: var(--ws-space-2); flex-wrap: wrap; justify-content: flex-end; }
.cx-chips { display: flex; flex-wrap: wrap; gap: var(--ws-space-1); }

/* ---------- Formulários e opções ---------- */
.cx-fieldset { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--ws-space-3); min-width: 0; }
.cx-fieldset legend { padding: 0; margin-bottom: var(--ws-space-2); font-weight: var(--ws-weight-semibold); font-size: var(--ws-text-sm); }
.cx-options { display: grid; gap: var(--ws-space-2); grid-template-columns: repeat(auto-fill, minmax(min(100%, 9.5rem), 1fr)); }
.cx-option { position: relative; display: flex; flex-direction: column; gap: 2px; padding: var(--ws-space-3) var(--ws-space-4); border-radius: var(--ws-radius-md);
  border: 1px solid var(--ws-border); background: var(--ws-surface-2); cursor: pointer; min-height: var(--ws-touch); }
.cx-option input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.cx-option b { font-size: var(--ws-text-sm); }
.cx-option small { color: var(--ws-text-3); font-size: var(--ws-text-xs); line-height: 1.35; }
.cx-option:has(input:checked) { border-color: var(--ws-accent-border); background: var(--ws-accent-soft); box-shadow: inset 0 0 0 1px var(--ws-accent-border); }
.cx-option:has(input:focus-visible) { outline: 2px solid var(--ws-focus); outline-offset: 2px; }
.cx-perm-group { display: flex; flex-direction: column; gap: var(--ws-space-2); }
.cx-perm-group h3 { margin: var(--ws-space-2) 0 0; font-size: var(--ws-text-xs); text-transform: uppercase; letter-spacing: 0.08em; color: var(--ws-text-3); }
.cx-actions { display: flex; flex-wrap: wrap; gap: var(--ws-space-2); align-items: center; }
.cx-actions--end { justify-content: flex-end; }
.cx-filters { display: grid; gap: var(--ws-space-3); grid-template-columns: minmax(0, 1fr); }
@media (min-width: 720px) { .cx-filters { grid-template-columns: minmax(0, 2fr) repeat(3, minmax(0, 1fr)); align-items: end; } }

/* ---------- Segredos e códigos ---------- */
.cx-secret { font-family: var(--ws-font-mono); font-size: var(--ws-text-sm); padding: var(--ws-space-3) var(--ws-space-4); border-radius: var(--ws-radius-md);
  background: var(--ws-surface-3); border: 1px dashed var(--ws-border-strong); overflow-wrap: anywhere; user-select: all; }
.cx-codes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--ws-space-2); margin: 0; padding: 0; list-style: none; }
.cx-codes li { font-family: var(--ws-font-mono); text-align: center; padding: var(--ws-space-2); border-radius: var(--ws-radius-sm); background: var(--ws-surface-3); }
.cx-qr { align-self: center; width: min(14rem, 70vw); padding: 0.75rem; border-radius: var(--ws-radius-md); background: #fff; }
.cx-qr svg { width: 100%; height: auto; display: block; }
.cx-steps { margin: 0; padding-left: 1.25rem; display: flex; flex-direction: column; gap: var(--ws-space-2); font-size: var(--ws-text-sm); color: var(--ws-text-2); }

/* ---------- Gráfico de barras (logins 7 dias) ---------- */
.cx-chart { display: flex; flex-direction: column; gap: var(--ws-space-3); }
.cx-chart svg { width: 100%; height: auto; overflow: visible; }
.cx-chart .grid { stroke: var(--ws-chart-grid); stroke-width: 1; }
.cx-chart .axis { fill: var(--ws-text-3); font-size: 11px; font-family: var(--ws-font-sans); }
.cx-chart .s1 { fill: var(--ws-chart-1); }
.cx-chart .s2 { fill: var(--ws-chart-2); }
.cx-chart .hit { fill: transparent; cursor: default; }
.cx-chart .hit:hover + .col, .cx-chart .col:hover { opacity: 0.85; }
.cx-chart .val { fill: var(--ws-text-2); font-size: 11px; font-variant-numeric: tabular-nums; }
.cx-legend { display: flex; flex-wrap: wrap; gap: var(--ws-space-4); font-size: var(--ws-text-xs); color: var(--ws-text-2); margin: 0; padding: 0; list-style: none; }
.cx-legend li { display: inline-flex; align-items: center; gap: var(--ws-space-2); }
.cx-legend i { width: 0.75rem; height: 0.75rem; border-radius: 3px; display: inline-block; }
.cx-legend .s1 { background: var(--ws-chart-1); }
.cx-legend .s2 { background: var(--ws-chart-2); }
.cx-tip { position: fixed; z-index: var(--ws-z-toast); pointer-events: none; padding: var(--ws-space-2) var(--ws-space-3); border-radius: var(--ws-radius-sm);
  background: var(--ws-surface-inverse); color: var(--ws-text-inverse); font-size: var(--ws-text-xs); box-shadow: var(--ws-shadow-md); white-space: nowrap; }
.cx-meter { display: flex; flex-direction: column; gap: var(--ws-space-2); }
.cx-meter__row { display: flex; justify-content: space-between; font-size: var(--ws-text-sm); }

/* ---------- Diagnóstico ---------- */
.cx-check { display: flex; gap: var(--ws-space-3); align-items: flex-start; }
.cx-check__dot { flex: none; width: 0.65rem; height: 0.65rem; border-radius: 50%; margin-top: 0.4rem; }
.cx-check__dot--ok { background: var(--ws-success); }
.cx-check__dot--atencao { background: var(--ws-warning); }
.cx-check__dot--erro { background: var(--ws-danger); }

/* ---------- Bottom sheet (menu "Mais" no celular) ---------- */
.cx-sheet { width: min(30rem, 100vw); margin: auto auto 0; border-radius: var(--ws-radius-xl) var(--ws-radius-xl) 0 0; padding: 0; border: 1px solid var(--ws-border);
  background: var(--ws-surface-solid); color: var(--ws-text); max-height: 85dvh; }
.cx-sheet::backdrop { background: var(--ws-overlay); }
.cx-sheet__body { padding: var(--ws-space-4) var(--ws-space-4) calc(var(--ws-space-6) + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 2px; }
.cx-sheet__grip { width: 2.5rem; height: 0.3rem; border-radius: 999px; background: var(--ws-border-strong); margin: 0 auto var(--ws-space-3); }

/* ---------- Status de conexão ---------- */
.cx-offline { position: fixed; z-index: var(--ws-z-toast); top: calc(var(--ws-header-h) + var(--ws-space-2) + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: var(--ws-space-2); padding: var(--ws-space-2) var(--ws-space-4); border-radius: var(--ws-radius-pill);
  background: var(--ws-warning-soft); color: var(--ws-text); border: 1px solid var(--ws-warning); font-size: var(--ws-text-xs); font-weight: var(--ws-weight-semibold); }

.cx-pager { display: flex; justify-content: space-between; align-items: center; gap: var(--ws-space-3); font-size: var(--ws-text-sm); color: var(--ws-text-3); }
.cx-kv { display: grid; grid-template-columns: minmax(0, auto) minmax(0, 1fr); gap: var(--ws-space-2) var(--ws-space-4); margin: 0; font-size: var(--ws-text-sm); }
.cx-kv dt { color: var(--ws-text-3); }
.cx-kv dd { margin: 0; overflow-wrap: anywhere; font-weight: var(--ws-weight-medium); }
.cx-danger-zone { border-color: color-mix(in srgb, var(--ws-danger) 35%, var(--ws-border)); }

@media (forced-colors: active) {
  .cx-chart .s1, .cx-chart .s2 { fill: CanvasText; }
  .cx-option:has(input:checked) { outline: 2px solid Highlight; }
}

.cx-modal--wide { width: min(40rem, calc(100vw - 2rem)); }

/* Ajustes de leitura no celular (revisão visual das capturas) */
@media (max-width: 560px) {
  .cx-top__badge, .cx-top__name { display: none; }
}
.cx-top__brand { flex: 0 1 auto; overflow: hidden; }
.cx-grid { align-items: start; }
.cx-kv { grid-template-columns: minmax(0, 1fr) auto; }
.cx-kv dd { text-align: right; font-variant-numeric: tabular-nums; }
.cx-meter__row { gap: var(--ws-space-3); }
.cx-meter__row b { white-space: nowrap; }

.cx-doc-body { min-height: 16rem; font-family: var(--ws-font-mono); font-size: var(--ws-text-sm); }
