/* ============================================================================
   Dashboard — tema do ClioAtende (claro e escuro).
   Escopo: .dash-page. Não afeta nenhuma outra tela do portal.
   Paleta copiada do dashboard.css do ClioAtende para os dois sistemas ficarem
   com a mesma identidade. O modo escuro acompanha o botão "Modo noturno" do
   Nexus (:is([data-theme="dark"], [data-theme="pink"]) no <html>).
   ============================================================================ */
.dash-page {
  --d-bg: var(--nx-bg);
  --d-card: var(--nx-surface);
  --d-card2: var(--nx-surface-2);
  --d-border: var(--nx-border);
  --d-text: var(--nx-text);
  --d-muted: var(--nx-muted);
  --d-faint: var(--nx-faint);
  --d-grid: rgba(100, 116, 139, 0.2);
  --c-blue: var(--nx-blue);
  --c-violet: #7c3aed;
  --c-cyan: #0891b2;
  --c-pink: #db2777;
  --c-green: var(--nx-success);
  --c-amber: var(--nx-warning);
  --c-red: var(--nx-danger);
  --c-slate: #64748b;
  background: transparent;
  color: var(--d-text);
  /* cobre o padding do <main> para o fundo ocupar a área toda */
  margin: -28px -28px -40px;
  padding: 28px 28px 40px;
  min-height: calc(100% + 68px);
}
:is([data-theme="dark"], [data-theme="pink"]) .dash-page {
  --d-grid: rgba(120, 140, 200, 0.15);
  --c-blue: #4F8CFF;
  --c-violet: #A78BFA;
  --c-cyan: #22D3EE;
  --c-pink: #F472B6;
  --c-slate: #94A3B8;
}
@media (max-width: 900px) { .dash-page { margin: -16px -14px -32px; padding: 16px 14px 32px; min-height: calc(100% + 48px); } }

.dash-page { min-width: 0; max-width: 100%; }
.dash-page * { box-sizing: border-box; }
.dash-page a { color: inherit; text-decoration: none; }

/* ─── Cabeçalho ──────────────────────────────────────────────────────────── */
.d-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.d-head h1 { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; margin: 0; color: var(--d-text); }
.d-head p { margin: 4px 0 0; font-size: 13px; color: var(--d-muted); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.d-live { width: 7px; height: 7px; border-radius: 50%; background: var(--c-green); display: inline-block; }
.d-head-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.d-btn {
  background: var(--d-card); color: var(--d-text); border: 1px solid var(--d-border);
  border-radius: 10px; padding: 8px 14px; font-size: 13px; font-weight: 500; cursor: pointer; font-family: inherit;
  display: inline-flex; align-items: center; gap: 6px;
}
.d-btn:hover { border-color: color-mix(in srgb, var(--c-blue) 50%, var(--d-border)); }
.d-date-pill { background: var(--d-card); border: 1px solid var(--d-border); border-radius: 10px; padding: 8px 12px; font-size: 13px; color: var(--d-text); }

/* ─── Faixa de alertas ───────────────────────────────────────────────────── */
.d-alerts { background: var(--d-card); border: 1px solid color-mix(in srgb, var(--c-amber) 55%, var(--d-border)); border-radius: 12px; margin-bottom: 22px; }
.d-alerts > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px; padding: 12px 16px; font-size: 13px; }
.d-alerts > summary::-webkit-details-marker { display: none; }
.d-alerts > summary svg { width: 18px; height: 18px; color: var(--c-amber); flex-shrink: 0; }
.d-alerts > summary strong { font-weight: 600; }
/* O resumo mostra só o primeiro alerta, cortado com reticências: texto sem quebra
   forçava a página inteira a ficar mais larga que a tela no celular. */
.d-alerts > summary .d-muted { margin-left: auto; font-size: 12px; white-space: nowrap; min-width: 0; flex: 0 1 auto; overflow: hidden; text-overflow: ellipsis; max-width: 62%; }
@media (max-width: 560px) { .d-alerts > summary .d-muted { display: none; } }
.d-alerts-list { border-top: 1px solid var(--d-border); padding: 6px 8px 8px; display: grid; gap: 2px; }
.d-alert-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; font-size: 13px; }
a.d-alert-item:hover { background: color-mix(in srgb, var(--c-amber) 9%, transparent); }
.d-alert-item svg { width: 16px; height: 16px; color: var(--c-amber); flex-shrink: 0; }
.d-alerts--ok { border-color: color-mix(in srgb, var(--c-green) 40%, var(--d-border)); }
.d-alerts--ok > summary { cursor: default; }
.d-alerts--ok > summary svg { color: var(--c-green); }

/* ─── Títulos de seção ───────────────────────────────────────────────────── */
.d-section { margin-bottom: 26px; }
.d-section-label { display: flex; align-items: baseline; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.d-section-label strong { font-size: 11px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--d-faint); }
.d-section-label span { font-size: 12px; color: var(--d-faint); opacity: 0.85; }

/* ─── Grades ─────────────────────────────────────────────────────────────── */
.d-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.d-grid--sm { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.d-grid--2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.d-grid--3 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
@media (max-width: 560px) { .d-grid, .d-grid--sm, .d-grid--2, .d-grid--3 { grid-template-columns: minmax(0, 1fr); } }

/* ─── Cartões ────────────────────────────────────────────────────────────── */
.d-card { background: var(--d-card); border: 1px solid var(--d-border); border-radius: 14px; transition: border-color .15s ease; min-width: 0; }
a.d-card:hover, .d-card:hover { border-color: color-mix(in srgb, var(--c-blue) 40%, var(--d-border)); }
.d-card--alert  { border-color: color-mix(in srgb, var(--c-amber) 55%, var(--d-border)); }
.d-card--danger { border-color: color-mix(in srgb, var(--c-red) 55%, var(--d-border)); }
.d-pad { padding: 18px; }
.d-card h3 { margin: 0 0 3px; font-size: var(--nx-text-base); font-weight: 600; color: var(--d-text); }
.d-card .d-sub { margin: 0 0 14px; font-size: 12px; color: var(--d-faint); line-height: 1.4; }

.d-tone-blue   { --tone: var(--c-blue); }
.d-tone-violet { --tone: var(--c-violet); }
.d-tone-cyan   { --tone: var(--c-cyan); }
.d-tone-pink   { --tone: var(--c-pink); }
.d-tone-green  { --tone: var(--c-green); }
.d-tone-amber  { --tone: var(--c-amber); }
.d-tone-red    { --tone: var(--c-red); }
.d-tone-slate  { --tone: var(--c-slate); }

.d-stat { display: flex; gap: 14px; align-items: flex-start; padding: 16px; }
.d-ico {
  width: 46px; height: 46px; border-radius: 13px; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  color: var(--tone); background: color-mix(in srgb, var(--tone) 16%, transparent); border: 1px solid color-mix(in srgb, var(--tone) 24%, transparent);
}
.d-ico svg { width: 23px; height: 23px; }
.d-stat-body { min-width: 0; }
.d-stat-label { font-size: var(--nx-text-sm); color: var(--d-muted); line-height: 1.3; }
.d-num { font-variant-numeric: tabular-nums; font-weight: 700; letter-spacing: -0.02em; font-size: 28px; line-height: 1.15; color: var(--d-text); margin: 2px 0; }
.d-num--money { font-size: 22px; }
.d-hint { font-size: var(--nx-text-xs); color: var(--d-faint); line-height: 1.35; }
.d-stat--mini { padding: 13px 14px; gap: 12px; }
.d-stat--mini .d-ico { width: 38px; height: 38px; border-radius: 11px; }
.d-stat--mini .d-ico svg { width: 19px; height: 19px; }
.d-stat--mini .d-num { font-size: 22px; }

.d-chip { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; color: var(--tone); background: color-mix(in srgb, var(--tone) 15%, transparent); }
.d-muted { color: var(--d-muted); }
.d-faint { color: var(--d-faint); }

/* ─── Gráficos ───────────────────────────────────────────────────────────── */
/* Barra segmentada (no lugar da rosca) */
.d-seg-wrap { display: grid; gap: 14px; }
.d-seg-total { display: flex; align-items: baseline; gap: 8px; }
.d-seg-total b { font-size: var(--nx-text-2xl); font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; color: var(--d-text); }
.d-seg-total span { font-size: var(--nx-text-sm); color: var(--d-muted); }
.d-seg { display: flex; gap: 2px; height: 8px; border-radius: 4px; overflow: hidden; background: color-mix(in srgb, var(--d-grid) 80%, transparent); }
.d-seg i { display: block; min-width: 3px; background: var(--tone); }
.d-legend { display: grid; gap: 7px; font-size: var(--nx-text-sm); }
.d-legend-row { display: flex; align-items: center; gap: 8px; }
.d-legend-row i { width: 9px; height: 9px; border-radius: 50%; background: var(--tone); flex-shrink: 0; }
.d-legend-row span { color: var(--d-muted); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.d-legend-row b { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--d-text); }
.d-legend-row em { font-style: normal; font-size: 11px; color: var(--d-faint); width: 38px; text-align: right; }

.d-bars { display: grid; gap: 13px; }
.d-bar-row .d-bar-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-size: 13px; margin-bottom: 6px; }
.d-bar-row .d-bar-top span { display: flex; align-items: center; gap: 8px; min-width: 0; }
.d-bar-row .d-bar-top i { width: 8px; height: 8px; border-radius: 50%; background: var(--tone); flex-shrink: 0; }
.d-bar-row .d-bar-top b { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.d-bar-track { height: 7px; border-radius: 99px; background: var(--d-grid); overflow: hidden; }
.d-bar-fill { height: 100%; border-radius: 99px; background: var(--tone); min-width: 3px; }
.d-bar-note { font-size: 11px; color: var(--d-faint); margin-top: 4px; }

.d-cols { width: 100%; height: 190px; display: block; }
.d-cols .d-col { fill: var(--c-blue); }
.d-cols .d-col--hoje { fill: var(--c-cyan); }
.d-cols .d-axis { fill: var(--d-faint); font-size: 10px; text-anchor: middle; }
.d-cols .d-val { fill: var(--d-muted); font-size: 10px; text-anchor: middle; font-weight: 600; }
.d-cols .d-gridline { stroke: var(--d-grid); stroke-width: 1; }

/* ─── Listas (agenda, avisos, atividades) ────────────────────────────────── */
.d-list { display: grid; gap: 2px; }
.d-list-group-label { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--d-faint); margin: 8px 0 4px; }
.d-list-group-label:first-child { margin-top: 0; }
.d-row { display: flex; align-items: center; gap: 10px; padding: 9px 4px; border-top: 1px solid var(--d-border); font-size: 13px; min-width: 0; }
.d-row:first-of-type { border-top: 0; }
.d-row .d-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.d-row .d-time { font-variant-numeric: tabular-nums; color: var(--d-faint); font-size: 12px; width: 44px; flex-shrink: 0; }
.d-row .d-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.d-row .d-meta { font-size: 11.5px; color: var(--d-faint); white-space: nowrap; }
.d-link { display: inline-block; margin-top: 10px; font-size: 12.5px; font-weight: 600; color: var(--c-blue); }
.d-link:hover { text-decoration: underline; }
.d-empty { font-size: 13px; color: var(--d-muted); padding: 6px 0; }
.d-aviso { display: flex; gap: 12px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--d-border); background: var(--d-card2); }
.d-aviso + .d-aviso { margin-top: 10px; }
.d-aviso-ico { font-size: 18px; line-height: 1.2; }
.d-aviso-t { font-size: 13.5px; font-weight: 600; }
.d-aviso-d { font-size: 12.5px; color: var(--d-muted); margin-top: 2px; }
.d-aviso-dt { font-size: 11px; color: var(--d-faint); margin-top: 4px; }
.d-aviso.nivel-urgente, .d-aviso.nivel-critico { border-color: color-mix(in srgb, var(--c-red) 50%, var(--d-border)); }
.d-aviso.nivel-importante, .d-aviso.nivel-alerta, .d-aviso.nivel-atencao { border-color: color-mix(in srgb, var(--c-amber) 50%, var(--d-border)); }
.d-badge { font-size: 10.5px; font-weight: 700; padding: 2px 8px; border-radius: 999px; color: var(--c-blue); background: color-mix(in srgb, var(--c-blue) 15%, transparent); white-space: nowrap; }

/* ─── Acesso rápido e módulos ────────────────────────────────────────────── */
.d-quick { display: flex; align-items: center; gap: 12px; padding: 14px 16px; }
.d-quick-ico { width: 40px; height: 40px; border-radius: 11px; display: flex; align-items: center; justify-content: center; background: var(--d-card2); border: 1px solid var(--d-border); flex-shrink: 0; overflow: hidden; }
.d-quick-ico img { max-width: 24px; max-height: 24px; }
.d-quick-name { font-size: 13.5px; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.d-module { display: flex; align-items: center; gap: 16px; padding: 18px; }
.d-module h3 { font-size: 15px; margin: 0 0 3px; }
.d-module p { margin: 0; font-size: 12.5px; color: var(--d-muted); line-height: 1.4; }
.d-module .d-go { margin-left: auto; flex-shrink: 0; }
.d-go { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 10px; font-size: 13px; font-weight: 600; color: #fff; }
.d-go:hover { filter: brightness(1.08); }
@media (max-width: 560px) { .d-module { flex-wrap: wrap; } .d-module .d-go { margin-left: 0; width: 100%; justify-content: center; } }

@media (prefers-reduced-motion: reduce) { .dash-page * { transition: none !important; } }

/* ============================================================================
   Nexus premium — acabamento do Dashboard (só aparência, mesma marcação).
   ============================================================================ */

/* Cabeçalho: título forte e brilho de galáxia ao fundo */
.d-head { position: relative; padding: 4px 0 6px; isolation: isolate; }
.d-head h1 { font-size: var(--nx-text-xl); font-weight: 600; letter-spacing: -0.012em; }
:is([data-theme="dark"], [data-theme="pink"]) .d-head h1 {
  color: var(--d-text);
}

/* Botões do cabeçalho: secundário (fundo do cartão e borda de campo); no hover o fundo sobe um tom */
.d-btn {
  font-weight: 700; border: 1.5px solid var(--nx-field);
  background: var(--d-card);
  transition: background var(--nx-dur-fast) var(--nx-ease), border-color var(--nx-dur-fast) var(--nx-ease), color var(--nx-dur-fast) var(--nx-ease);
}
.d-btn:hover { background: var(--d-card2); border-color: var(--nx-blue-text); }
.d-btn:active { transform: translateY(0.5px); }
.d-date-pill { border-radius: var(--nx-radius-md); border-color: var(--nx-border-solid); font-weight: 600; }

/* Títulos de seção */
.d-section-label strong { display: inline-flex; align-items: center; gap: 8px; color: var(--d-muted); font-size: var(--nx-text-xs); font-weight: 600; letter-spacing: 0.08em; }

/* Cartões: fio fino e tom; no hover só a borda muda (sem brilho nem elevação) */
.d-card {
  border-radius: var(--nx-radius-lg);
  border-color: var(--nx-border-solid);
  box-shadow: var(--nx-shadow-sm);
  transition: border-color var(--nx-dur-fast) var(--nx-ease);
}
.d-card:hover { border-color: var(--nx-border-strong); }

/* Indicadores: número forte, ícone na cor do tom */
.d-stat { position: relative; overflow: hidden; }
.d-num { font-size: var(--nx-text-2xl); font-weight: 600; letter-spacing: -0.02em; }
.d-num--money { font-size: var(--nx-text-xl); }
.d-stat--mini .d-num { font-size: var(--nx-text-xl); }
.d-chip { border: 1px solid color-mix(in srgb, var(--tone) 32%, transparent); }

/* Gráficos: cor chapada, sem brilho */
.d-bar-track { height: 6px; background: color-mix(in srgb, var(--d-grid) 80%, transparent); }
.d-bar-fill { background: var(--tone); }
.d-cols .d-col { fill: var(--c-blue); rx: 2px; }
.d-cols .d-col--hoje { fill: var(--nx-cyan); }

/* Listas e linhas */
.d-row { transition: background var(--nx-dur-fast) var(--nx-ease); border-radius: var(--nx-radius-md); }
a.d-row:hover, .d-row:hover { background: color-mix(in srgb, var(--nx-cyan) 10%, transparent); }
.d-aviso { border-radius: var(--nx-radius-lg); }

/* Estado vazio com moldura tracejada */
.d-empty {
  padding: 18px 14px; text-align: center; color: var(--d-muted);
  border: 1.5px dashed var(--nx-primary-soft-border); border-radius: var(--nx-radius-lg);
}

/* Faixa de alertas */
.d-alerts { border-radius: var(--nx-radius-lg); box-shadow: var(--nx-shadow-sm); }
.d-alerts > summary { transition: background var(--nx-dur-fast) var(--nx-ease); border-radius: var(--nx-radius-lg); }
.d-alerts:not(.d-alerts--ok) > summary:hover { background: color-mix(in srgb, var(--c-amber) 9%, transparent); }

/* Acesso rápido e módulos */
.d-quick-ico { border-radius: var(--nx-radius-lg); transition: border-color var(--nx-dur-fast) var(--nx-ease); }
.d-quick:hover .d-quick-ico { border-color: var(--nx-blue-text); }

/* "Abrir" dos módulos: primário elétrico com brilho que varre */
.d-go {
  background: var(--nx-btn-solid);
  border: 1px solid var(--nx-btn-solid); color: #fff; font-weight: 700;
  transition: background var(--nx-dur-fast) var(--nx-ease), border-color var(--nx-dur-fast) var(--nx-ease);
}
.d-go:hover { filter: none; background: var(--nx-btn-solid-hover); border-color: var(--nx-btn-solid-hover); }

/* Entrada suave das seções */
@keyframes d-entra { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.dash-page .d-section, .dash-page .d-alerts { animation: d-entra 0.45s var(--nx-ease) both; }
.dash-page .d-section:nth-of-type(2) { animation-delay: 0.04s; }
.dash-page .d-section:nth-of-type(3) { animation-delay: 0.08s; }
.dash-page .d-section:nth-of-type(4) { animation-delay: 0.12s; }

/* O link "Abrir" fica branco também no tema claro (a regra .dash-page a herdava a cor escura do texto) */
.dash-page a.d-go, .dash-page a.d-go:hover { color: #fff; }

/* Tema pink: o "azul" dos indicadores vira rosa e a grade dos gráficos fica rosada (demais cores seguem como no escuro) */
[data-theme="pink"] .dash-page { --c-blue: #F0509E; --d-grid: rgba(240, 80, 160, 0.20); }

/* ─── Faixa de indicadores (direção A): um cartão só, células separadas por fio ──────────────
   Vale para qualquer grade que tenha indicadores (Operação, Gestão, Processos de TI). As células
   cortam a borda direita e a de baixo com margem negativa, então qualquer número de colunas fecha certinho. */
.d-grid:has(> .d-stat) {
  gap: 0;
  background: var(--d-card);
  border: 1px solid var(--nx-border-solid);
  border-radius: var(--nx-radius-lg);
  overflow: hidden;
}
.d-grid:has(> .d-stat) > .d-stat {
  border: 0;
  border-right: 1px solid var(--nx-border-solid);
  border-bottom: 1px solid var(--nx-border-solid);
  border-radius: 0;
  box-shadow: none;
  background: transparent;
  margin: 0 -1px -1px 0;
}
.d-grid:has(> .d-stat) > a.d-stat:hover { background: var(--d-card2); }
.d-grid:has(> .d-stat) > .d-card--alert { background: color-mix(in srgb, var(--c-amber) 8%, transparent); }
.d-grid:has(> .d-stat) > .d-card--danger { background: color-mix(in srgb, var(--c-red) 8%, transparent); }
.d-grid:has(> .d-stat) .d-ico { width: 34px; height: 34px; border-radius: var(--nx-radius-md); }
.d-grid:has(> .d-stat) .d-ico svg { width: 18px; height: 18px; }
