/*
 * NowDev UI ND138 — lógica, legibilidade e governança
 * Correções globais da revisão R12.
 */

/* Marca: reserva real para o botão e peso uniforme. */
body.nf-redesign .sidebar-head {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) 42px !important;
  align-items: center !important;
  gap: 12px !important;
}
body.nf-redesign .sidebar-logo {
  min-width: 0 !important;
  width: 100% !important;
  gap: 10px !important;
  overflow: hidden !important;
}
body.nf-redesign .sidebar-logo-badge {
  flex: 0 0 48px !important;
  width: 48px !important;
  height: 48px !important;
}
body.nf-redesign .sidebar-logo-text {
  min-width: 0 !important;
  max-width: 100% !important;
  overflow: hidden !important;
  text-overflow: clip !important;
  font-size: 20px !important;
  font-weight: 900 !important;
  letter-spacing: -.82px !important;
}
body.nf-redesign .sidebar-logo-text b,
body.nf-redesign .sidebar-logo-text strong {
  font-weight: 900 !important;
}
body.nf-redesign .sidebar-toggle {
  position: relative !important;
  z-index: 4 !important;
  justify-self: end !important;
}
body.nf-redesign .app-shell.sidebar-collapsed .sidebar-head {
  grid-template-columns: 1fr !important;
  justify-items: center !important;
}
body.nf-redesign .app-shell.sidebar-collapsed .sidebar-toggle { justify-self: center !important; }

/* Saúde empresarial: contraste estável nos dois temas. */
body.nf-redesign .business-health-gauge {
  isolation: isolate;
  min-height: 150px;
  display: grid;
  align-content: center;
  background: linear-gradient(145deg, #124c9f 0%, #087ca3 100%) !important;
  border: 1px solid rgba(255,255,255,.48) !important;
  box-shadow: 0 18px 44px rgba(4,35,65,.24), inset 0 1px 0 rgba(255,255,255,.2) !important;
}
body.nf-redesign .business-health-gauge::after { opacity: .28 !important; z-index: -1; }
body.nf-redesign .business-health-gauge span,
body.nf-redesign .business-health-gauge small {
  color: #eaf8ff !important;
  opacity: 1 !important;
  text-shadow: 0 1px 1px rgba(0,20,45,.25);
}
body.nf-redesign .business-health-gauge strong {
  color: #fff !important;
  opacity: 1 !important;
  font-size: clamp(34px, 4vw, 48px) !important;
  text-shadow: 0 2px 8px rgba(0,25,60,.28);
}

/* Investimentos: todo texto precisa sobreviver ao gradiente. */
body.nf-redesign .investment-balance-card {
  position: relative;
  overflow: hidden;
  background: linear-gradient(126deg, #073765 0%, #075b77 52%, #078f85 100%) !important;
  border: 1px solid rgba(255,255,255,.25) !important;
  box-shadow: 0 24px 58px rgba(5,39,75,.22) !important;
  color: #fff !important;
}
body.nf-redesign .investment-balance-card::after {
  content: "NB";
  position: absolute;
  right: -24px;
  bottom: -62px;
  font-size: clamp(150px, 22vw, 300px);
  line-height: 1;
  font-weight: 900;
  letter-spacing: -.12em;
  color: rgba(255,255,255,.055);
  pointer-events: none;
}
body.nf-redesign .investment-balance-card :where(h2,h3,strong,b,span,small,p) {
  position: relative;
  z-index: 1;
  color: #fff !important;
  opacity: 1 !important;
}
body.nf-redesign .investment-balance-head > div > span,
body.nf-redesign .investment-balance-footer article > span,
body.nf-redesign .investment-chart-meta,
body.nf-redesign .investment-chart-empty small {
  color: #d9f3ff !important;
}
body.nf-redesign .investment-balance-head h2 {
  color: #fff !important;
  text-shadow: 0 2px 10px rgba(0,27,61,.25);
}
body.nf-redesign .investment-balance-footer > * {
  background: rgba(3,36,70,.34) !important;
  border-color: rgba(255,255,255,.24) !important;
  backdrop-filter: blur(8px);
}
body.nf-redesign .investment-result-chip {
  background: rgba(255,255,255,.16) !important;
  border: 1px solid rgba(255,255,255,.25) !important;
  color: #fff !important;
}
body.nf-redesign .investment-result-chip.is-positive,
body.nf-redesign .investment-balance-footer .text-positive { color: #b9ffe4 !important; }
body.nf-redesign .investment-result-chip.is-negative { color: #ffe0e4 !important; }
body.nf-redesign .investment-chart-shell { color: #bcecff !important; }
body.nf-redesign .investment-chart-empty svg { color: #c2efff !important; opacity: 1 !important; }

/* Segurança: aviso não pode desaparecer no degradê. */
body.nf-redesign .security-hero .security-status,
body.nf-redesign .security-status.is-warning {
  background: #fff !important;
  color: #18324f !important;
  border: 1px solid rgba(255,255,255,.72) !important;
  box-shadow: 0 10px 28px rgba(0,37,88,.18) !important;
  opacity: 1 !important;
}
body.nf-redesign .security-hero .security-status :where(span,strong,small,svg),
body.nf-redesign .security-status.is-warning :where(span,strong,small,svg) {
  color: #18324f !important;
  opacity: 1 !important;
}
body.nf-redesign .security-status.is-secure {
  background: #e9fff6 !important;
  color: #075f43 !important;
  border-color: #a3e6cb !important;
}

/* Contexto de Operações: o menu lateral navega; a página apenas informa a localização. */
body.nf-redesign .operations-context-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 18px;
  padding: 12px 15px;
  border: 1px solid var(--nd-card-line);
  border-radius: 15px;
  background: var(--nd-card-bg);
}
body.nf-redesign .operations-context-bar a {
  font-weight: 850;
  color: var(--nd-primary);
}
body.nf-redesign .operations-context-bar span {
  color: var(--nd-muted);
  font-size: 13px;
}

/* Equipe e permissões. */
body.nf-redesign .team-overview-grid,
body.nf-redesign .team-governance-flow {
  display: grid;
  grid-template-columns: repeat(4,minmax(0,1fr));
  gap: 14px;
}
body.nf-redesign .team-overview-card,
body.nf-redesign .team-flow-step {
  padding: 18px;
  border-radius: 18px;
  border: 1px solid var(--nd-card-line);
  background: var(--nd-card-bg);
}
body.nf-redesign .team-overview-card span { color: var(--nd-muted); font-weight: 750; }
body.nf-redesign .team-overview-card strong { display:block; margin-top:8px; font-size:30px; color:var(--nd-ink); }
body.nf-redesign .team-flow-step > span {
  display:grid; place-items:center; width:38px; height:38px; border-radius:13px;
  background:linear-gradient(135deg,var(--nd-primary),var(--nd-cyan)); color:#fff; font-weight:900;
}
body.nf-redesign .team-flow-step h3 { margin:12px 0 6px; }
body.nf-redesign .member-access-editor {
  grid-column: 1 / -1;
  width: 100%;
  border-top: 1px solid var(--nd-card-line);
  padding-top: 12px;
}
body.nf-redesign .member-access-editor > summary {
  cursor:pointer; color:var(--nd-primary); font-weight:850; list-style:none;
}
body.nf-redesign .member-access-editor > summary::-webkit-details-marker { display:none; }
body.nf-redesign .member-access-editor > summary::after { content:"＋"; float:right; }
body.nf-redesign .member-access-editor[open] > summary::after { content:"−"; }
body.nf-redesign .team-member-form {
  margin-top: 14px;
  display:grid !important;
  grid-template-columns:repeat(3,minmax(0,1fr)) !important;
  gap:14px !important;
  align-items:end !important;
}
body.nf-redesign .scope-guidance {
  grid-column:1/-1; margin:0; padding:11px 13px; border-radius:12px;
  background:var(--nd-inset-bg); color:var(--nd-muted); font-size:13px;
}
body.nf-redesign .permission-search-row {
  display:flex; align-items:end; gap:12px; flex-wrap:wrap;
}
body.nf-redesign .permission-search-row label { flex:1 1 260px; }
body.nf-redesign .permission-selected-count { color:var(--nd-muted); font-weight:800; }
body.nf-redesign .permission-option[hidden],
body.nf-redesign .permission-group[hidden] { display:none !important; }
body.nf-redesign .permission-option small { display:none !important; }

/* NowMenu: ciclo da mesa e QR individual. */
body.nf-redesign .table-flow-grid {
  display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:12px;
}
body.nf-redesign .table-flow-grid article {
  padding:16px; border:1px solid var(--nd-card-line); border-radius:16px; background:var(--nd-inset-bg);
}
body.nf-redesign .table-flow-grid b {
  display:grid; place-items:center; width:34px; height:34px; border-radius:12px;
  background:linear-gradient(135deg,var(--nd-primary),var(--nd-cyan)); color:#fff;
}
body.nf-redesign .table-flow-grid strong { display:block; margin:10px 0 5px; }
body.nf-redesign .table-qr-grid {
  display:grid; grid-template-columns:repeat(auto-fit,minmax(290px,1fr)); gap:16px;
}
body.nf-redesign .table-qr-card {
  display:grid; grid-template-columns:132px minmax(0,1fr); gap:18px;
  padding:18px; border:1px solid var(--nd-card-line); border-radius:20px; background:var(--nd-card-bg);
}
body.nf-redesign .table-qr-canvas {
  width:132px; height:132px; padding:8px; border-radius:16px; background:#fff;
  image-rendering:pixelated; box-shadow:0 10px 25px rgba(5,40,80,.12);
}
body.nf-redesign .table-qr-copy { min-width:0; }
body.nf-redesign .table-qr-copy h3 { margin:0 0 4px; }
body.nf-redesign .table-qr-copy code {
  display:block; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
  margin:9px 0; color:var(--nd-muted); font-size:11px;
}
body.nf-redesign .table-qr-actions { display:flex; gap:8px; flex-wrap:wrap; }
body.nf-redesign .table-status-row { display:flex; gap:10px; align-items:center; margin-top:10px; }
body.nf-redesign .table-selected-notice {
  display:flex; gap:12px; align-items:flex-start; padding:14px 16px; margin-bottom:18px;
  border-radius:16px; background:#e8f7ff; color:#07517e; border:1px solid #a9dcf6;
}
html[data-theme="dark"] body.nf-redesign .table-selected-notice { background:#102d43; color:#c9efff; border-color:#285874; }

/* Ajuda e novidades. */
body.nf-redesign .help-workflow-grid {
  display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:16px;
}
body.nf-redesign .help-workflow-grid article { padding:18px; border:1px solid var(--nd-card-line); border-radius:18px; background:var(--nd-card-bg); }
body.nf-redesign .release-essential-list { display:grid; gap:10px; margin:0; padding:0; list-style:none; }
body.nf-redesign .release-essential-list li { display:flex; gap:10px; align-items:flex-start; color:var(--nd-ink); }
body.nf-redesign .release-essential-list svg { flex:0 0 auto; color:var(--nd-primary); }

/* Responsividade dos novos blocos. */
@media (max-width: 1100px) {
  body.nf-redesign .team-overview-grid,
  body.nf-redesign .team-governance-flow,
  body.nf-redesign .table-flow-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
  body.nf-redesign .team-member-form { grid-template-columns:repeat(2,minmax(0,1fr)) !important; }
}
@media (max-width: 720px) {
  body.nf-redesign .sidebar-logo-text { font-size:18px !important; }
  body.nf-redesign .team-overview-grid,
  body.nf-redesign .team-governance-flow,
  body.nf-redesign .table-flow-grid,
  body.nf-redesign .help-workflow-grid { grid-template-columns:1fr; }
  body.nf-redesign .team-member-form { grid-template-columns:1fr !important; }
  body.nf-redesign .table-qr-card { grid-template-columns:1fr; }
  body.nf-redesign .table-qr-canvas { width:150px; height:150px; }
}
