/* ==========================================================================
   Portal de Projetos Consil — Design System
   Paleta oficial: dark wine da Consil (LAYOUT.md do Gestão Administrativo).
   CSS puro (sem build) espelhando os tokens Tailwind dos apps vizinhos.
   ========================================================================== */

:root {
  /* Marca — dark wine da Consil */
  --brand: oklch(0.225 0.082 19);
  --brand-hover: oklch(0.275 0.088 19);
  --brand-accent: oklch(0.315 0.092 19);
  --brand-muted: oklch(0.345 0.095 19);

  /* Superfícies */
  --surface: oklch(0.985 0.002 80);
  --surface-elevated: oklch(1 0 0);
  --surface-sunken: oklch(0.18 0.015 20);
  --surface-hover: oklch(0.99 0.003 80);

  /* Texto */
  --foreground: oklch(0.21 0.006 285);
  --muted-foreground: oklch(0.552 0.016 285);

  /* Linhas / anéis */
  --ring: oklch(0.21 0.006 285 / 0.06);
  --ring-strong: oklch(0.21 0.006 285 / 0.1);

  /* Gradiente de marca (o "degradezinho") */
  --brand-gradient: linear-gradient(135deg, var(--brand) 0%, var(--brand-accent) 60%, var(--brand-muted) 100%);

  /* Raios */
  --r-sm: 0.5rem;
  --r-md: 0.75rem;
  --r-lg: 1rem;
  --r-xl: 1.25rem;
  --r-full: 9999px;

  /* Sombras */
  --shadow-sm: 0 1px 2px rgba(24, 8, 12, 0.06);
  --shadow-md: 0 4px 12px rgba(24, 8, 12, 0.08);
  --shadow-lg: 0 12px 30px rgba(65, 12, 22, 0.12);
  --shadow-brand: 0 12px 28px rgba(65, 12, 22, 0.22);

  --font: "Geist", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--foreground);
  background: var(--surface);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

a { color: inherit; }

button { font-family: inherit; }

/* ============================ Utilidades ============================ */
.hidden { display: none !important; }
.spin { animation: spin 120s linear infinite; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes float {
  0%, 100% { transform: translateY(0) rotate(45deg); }
  50% { transform: translateY(-14px) rotate(45deg); }
}
@keyframes fade-in-up {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes scale-in {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}
@keyframes shimmer {
  100% { background-position: 200% 0; }
}

.fade-up { animation: fade-in-up 0.5s ease-out both; }

/* ============================ Gate de senha ============================ */
#gate {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--brand-gradient);
  overflow: hidden;
}
#gate::before {
  content: "";
  position: absolute;
  width: 620px; height: 620px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 50%;
  top: -180px; right: -160px;
  animation: spin 120s linear infinite;
}
#gate::after {
  content: "";
  position: absolute;
  width: 180px; height: 180px;
  background: rgba(255, 255, 255, 0.05);
  bottom: -40px; left: -30px;
  transform: rotate(45deg);
  animation: float 15s ease-in-out infinite;
}
.gate-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 400px;
  background: var(--surface-elevated);
  border-radius: var(--r-lg);
  padding: 40px 32px;
  box-shadow: var(--shadow-lg);
  animation: scale-in 0.4s ease-out both;
}
.gate-brand {
  text-align: center;
  margin-bottom: 28px;
}
.gate-logo {
  width: 56px; height: 56px;
  margin: 0 auto 16px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--r-md);
  background: var(--brand-gradient);
  color: #fff;
  font-size: 26px;
  box-shadow: var(--shadow-brand);
}
.gate-brand h1 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--brand);
}
.gate-brand p {
  margin: 6px 0 0;
  font-size: 0.8rem;
  color: var(--muted-foreground);
}
.field { display: flex; flex-direction: column; gap: 8px; }
.field label { font-size: 0.85rem; font-weight: 500; }
.input {
  height: 44px;
  padding: 0 14px;
  border-radius: var(--r-md);
  border: 1px solid oklch(0.9 0.004 285);
  background: #fff;
  font-size: 0.95rem;
  color: var(--foreground);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus {
  border-color: color-mix(in oklch, var(--brand) 40%, transparent);
  box-shadow: 0 0 0 4px color-mix(in oklch, var(--brand) 10%, transparent);
}
textarea.input { height: auto; padding: 12px 14px; resize: vertical; min-height: 76px; line-height: 1.4; }
select.input { cursor: pointer; }

/* ============================ Ícones (sprite SVG) ============================
   Substituíram os emojis: renderizam igual em Windows, Mac e Android, aceitam
   a cor da marca e não dependem da fonte do sistema. O sprite fica no topo do
   index.html; aqui só o dimensionamento. Tamanho em `em` para acompanhar o
   texto ao lado, e `currentColor` para herdar a cor de quem os contém. */
.sprite { display: none; }
.ic {
  width: 1.05em; height: 1.05em;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: -0.16em;
}
.ic-lg { width: 1.15em; height: 1.15em; }
/* Usado dentro de `.big`, que já define o tamanho em px. */
.ic-xl { width: 1em; height: 1em; stroke-width: 1.5; vertical-align: middle; }

.btn {
  height: 44px;
  padding: 0 20px;
  border: none;
  border-radius: var(--r-md);
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.12s, box-shadow 0.15s, background 0.15s, color 0.15s;
  white-space: nowrap;
}
.btn:active { transform: scale(0.98); }
.btn-primary {
  background: var(--brand);
  color: #fff;
  box-shadow: var(--shadow-brand);
}
.btn-primary:hover { background: var(--brand-hover); }
.btn-ghost {
  background: transparent;
  color: var(--foreground);
  border: 1px solid var(--ring-strong);
}
.btn-ghost:hover { background: var(--surface-hover); }
.btn-soft {
  background: color-mix(in oklch, var(--brand) 8%, white);
  color: var(--brand);
}
.btn-soft:hover { background: color-mix(in oklch, var(--brand) 14%, white); }
.btn-danger {
  background: transparent;
  color: #b91c1c;
  border: 1px solid rgba(185, 28, 28, 0.25);
}
.btn-danger:hover { background: rgba(185, 28, 28, 0.08); }
.btn-sm { height: 34px; padding: 0 12px; font-size: 0.82rem; border-radius: var(--r-sm); }
.btn-block { width: 100%; }

.gate-error {
  margin-top: 12px;
  font-size: 0.82rem;
  color: #b91c1c;
  background: rgba(185, 28, 28, 0.08);
  border: 1px solid rgba(185, 28, 28, 0.15);
  border-radius: var(--r-sm);
  padding: 8px 12px;
  display: none;
}
.gate-error.show { display: block; }

/* ============================ Topbar ============================ */
.topbar {
  position: relative;
  background: var(--brand-gradient);
  color: #fff;
  padding: 0 clamp(16px, 4vw, 40px);
  overflow: hidden;
}
.topbar::after {
  content: "";
  position: absolute;
  width: 420px; height: 420px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 50%;
  top: -260px; right: 4%;
  pointer-events: none;
  animation: spin 120s linear infinite;
}
.topbar-inner {
  position: relative;
  z-index: 1;
  max-width: 1680px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 16px 0 0;
  flex-wrap: wrap;
}
.brand-block { display: flex; align-items: center; gap: 12px; margin-right: auto; }
.brand-logo {
  width: 42px; height: 42px;
  border-radius: var(--r-md);
  background: rgba(255, 255, 255, 0.12);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  backdrop-filter: blur(4px);
}
.brand-text .t1 { font-size: 1rem; font-weight: 700; letter-spacing: 0.02em; }
.brand-text .t2 { font-size: 0.75rem; color: rgba(255, 255, 255, 0.55); }

.topbar-actions { display: flex; align-items: center; gap: 10px; }
.btn-onbrand {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(4px);
}
.btn-onbrand:hover { background: rgba(255, 255, 255, 0.2); }
.btn-onbrand.active {
  background: #fff;
  color: var(--brand);
  border-color: #fff;
}

/* Abas de navegação */
.nav-tabs {
  position: relative;
  z-index: 1;
  max-width: 1680px;
  margin: 0 auto;
  display: flex;
  gap: 4px;
  padding-top: 14px;
}
.nav-tab {
  appearance: none;
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.65);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 12px 18px;
  cursor: pointer;
  border-radius: var(--r-md) var(--r-md) 0 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: color 0.15s, background 0.15s;
}
.nav-tab:hover { color: #fff; background: rgba(255, 255, 255, 0.06); }
.nav-tab.active {
  color: var(--brand);
  background: var(--surface);
}
.nav-tab .count {
  font-size: 0.72rem;
  background: rgba(255, 255, 255, 0.16);
  padding: 1px 8px;
  border-radius: var(--r-full);
}
.nav-tab.active .count { background: color-mix(in oklch, var(--brand) 10%, white); color: var(--brand); }

/* ============================ Layout de conteúdo ============================ */
main {
  max-width: 1680px;
  margin: 0 auto;
  padding: 24px clamp(16px, 4vw, 40px) 60px;
}

.page-head { margin-bottom: 20px; }
.page-head h2 { margin: 0; font-size: 1.4rem; font-weight: 600; letter-spacing: -0.01em; }
.page-head p { margin: 6px 0 0; color: var(--muted-foreground); font-size: 0.9rem; }

/* KPIs */
.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}
.kpi {
  background: var(--surface-elevated);
  border-radius: var(--r-lg);
  padding: 16px 18px;
  box-shadow: inset 0 0 0 1px var(--ring), var(--shadow-sm);
  animation: fade-in-up 0.5s ease-out both;
}
.kpi .v { font-size: 1.7rem; font-weight: 700; line-height: 1; }
.kpi .l { margin-top: 6px; font-size: 0.78rem; color: var(--muted-foreground); font-weight: 500; }
.kpi.alert .v { color: #dc2626; }

/* Chips de filtro por área */
.area-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 22px;
}
.chip {
  border: 1px solid var(--ring-strong);
  background: var(--surface-elevated);
  color: var(--foreground);
  padding: 7px 14px;
  border-radius: var(--r-full);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: all 0.15s;
}
.chip:hover { background: var(--surface-hover); }
.chip .dot { width: 9px; height: 9px; border-radius: 50%; }
.chip.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.chip.active .dot { box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.5); }

/* Alternador de visualização (aba Todos) */
.view-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: -8px 0 22px;
}
.view-toggle-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted-foreground);
  margin-right: 2px;
}
.seg {
  border: 1px solid var(--ring-strong);
  background: var(--surface-elevated);
  color: var(--foreground);
  padding: 7px 14px;
  border-radius: var(--r-full);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s;
}
.seg:hover { background: var(--surface-hover); }
.seg.active { background: var(--brand); color: #fff; border-color: var(--brand); }

/* Resumo por área (visualização compacta) */
.board-compact { grid-auto-columns: minmax(210px, 1fr); }
.area-status {
  width: 100%;
  text-align: left;
  border: none;
  background: var(--surface-elevated);
  border-radius: var(--r-md);
  padding: 12px 14px;
  box-shadow: inset 0 0 0 1px var(--ring), var(--shadow-sm);
  border-left: 3px solid var(--area-color, var(--brand));
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 3px;
  transition: transform 0.15s, box-shadow 0.15s;
  animation: scale-in 0.3s ease-out both;
}
.area-status:hover {
  transform: translateY(-2px);
  box-shadow: inset 0 0 0 1px var(--ring-strong), var(--shadow-md);
}
.area-status-name {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--area-color, var(--brand));
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.area-status-proj {
  font-size: 0.78rem;
  color: var(--muted-foreground);
  font-weight: 500;
}

/* ============================ Esteira (kanban) ============================ */
.board {
  --col-oculta: 58px;
  display: grid;
  /* `--cols` vem do JS, uma trilha por fase, para a coluna recolhida virar
     faixa fina e devolver a largura às demais. */
  grid-template-columns: var(--cols, repeat(6, minmax(0, 1fr)));
  gap: 12px;
  padding-bottom: 12px;
}
/* Abaixo desta largura a coluna ficaria estreita demais para ler o card:
   aí sim volta a rolar na horizontal, que é o comportamento útil no celular. */
@media (max-width: 1180px) {
  .board {
    grid-template-columns: none;
    grid-auto-flow: column;
    grid-auto-columns: minmax(240px, 1fr);
    gap: 16px;
    overflow-x: auto;
    scroll-snap-type: x proximity;
  }
}
.column {
  scroll-snap-align: start;
  background: color-mix(in oklch, var(--surface) 60%, white);
  border-radius: var(--r-lg);
  box-shadow: inset 0 0 0 1px var(--ring);
  display: flex;
  flex-direction: column;
  min-height: 120px;
}
.column-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px 10px;
  font-weight: 700;
  font-size: 0.88rem;
  border-bottom: 1px solid var(--ring);
  position: sticky;
  top: 0;
}
.column-head .phase-dot { width: 10px; height: 10px; border-radius: 50%; }
.column-head .count {
  margin-left: auto;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted-foreground);
  background: var(--surface-hover);
  padding: 1px 9px;
  border-radius: var(--r-full);
  box-shadow: inset 0 0 0 1px var(--ring);
}
.column-body {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
}
.column-empty {
  color: var(--muted-foreground);
  font-size: 0.8rem;
  text-align: center;
  padding: 18px 8px;
  border: 1px dashed var(--ring-strong);
  border-radius: var(--r-md);
}

/* ---- Coluna recolhida ----
   Em notebook as 6 fases espremem todos os cards. Recolher as que não estão
   em acompanhamento devolve essa largura para as que importam. A escolha é
   de quem olha, então fica no navegador (localStorage), não no banco. */
.col-toggle {
  flex: none;
  margin-left: 2px;
  width: 24px; height: 24px;
  display: inline-flex; align-items: center; justify-content: center;
  border: none; background: transparent; cursor: pointer;
  color: var(--muted-foreground);
  border-radius: var(--r-sm);
  transition: background 0.15s, color 0.15s;
}
.col-toggle:hover { background: var(--surface-hover); color: var(--foreground); }

.column.oculta { width: var(--col-oculta); }
.column.oculta .column-head {
  flex-direction: column;
  gap: 8px;
  padding: 12px 4px;
  border-bottom: none;
}
.column.oculta .col-label { display: none; }
.column.oculta .count { margin-left: 0; }
/* O corpo permanece, vazio: assim ainda dá para arrastar um módulo para uma
   fase recolhida, sem precisar abri-la antes. */
.column.oculta .column-body > * { display: none; }
.column.oculta .column-body { padding: 6px; }

/* ---- Arrastar módulo entre fases ---- */
.pcard[draggable="true"] { cursor: grab; }
.pcard.arrastando { opacity: 0.4; cursor: grabbing; transform: none; }
.column-body.solta-aqui {
  background: color-mix(in oklch, var(--brand) 7%, transparent);
  outline: 2px dashed var(--brand);
  outline-offset: -4px;
  border-radius: var(--r-md);
}
/* A coluna vazia continua sendo alvo de soltura mesmo sem nenhum card. */
.column-body { min-height: 72px; }

/* Card de projeto */
.pcard {
  background: var(--surface-elevated);
  border-radius: var(--r-md);
  padding: 14px;
  box-shadow: inset 0 0 0 1px var(--ring), var(--shadow-sm);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  animation: scale-in 0.35s ease-out both;
  border-left: 3px solid var(--area-color, var(--brand));
}
.pcard:hover {
  transform: translateY(-3px);
  box-shadow: inset 0 0 0 1px var(--ring-strong), var(--shadow-lg);
}
.pcard-top { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.pcard h3 { margin: 0 0 8px; font-size: 0.95rem; font-weight: 600; letter-spacing: -0.01em; }
.pcard .desc {
  font-size: 0.8rem;
  color: var(--muted-foreground);
  margin: 0 0 12px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.pcard-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

.area-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: var(--r-full);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--area-color, var(--brand));
  background: color-mix(in oklch, var(--area-color, var(--brand)) 12%, white);
}
.area-badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* Barra de progresso */
.progress {
  height: 7px;
  background: var(--surface);
  border-radius: var(--r-full);
  overflow: hidden;
  box-shadow: inset 0 0 0 1px var(--ring);
}
.progress > span {
  display: block;
  height: 100%;
  border-radius: var(--r-full);
  background: linear-gradient(90deg, var(--brand), var(--brand-accent));
  transition: width 0.4s ease;
}
.progress-label { font-size: 0.72rem; color: var(--muted-foreground); margin-top: 5px; font-weight: 500; }

/* Etiqueta de prazo (semáforo) */
.deadline {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: var(--r-full);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.deadline .dot { width: 6px; height: 6px; border-radius: 50%; }
.deadline.vencido { background: #fef2f2; color: #b91c1c; }
.deadline.vencido .dot { background: #ef4444; }
.deadline.proximo { background: #fff7ed; color: #c2410c; }
.deadline.proximo .dot { background: #f97316; }
.deadline.ok { background: #ecfdf5; color: #047857; }
.deadline.ok .dot { background: #10b981; }
.deadline.neutro { background: #f3f4f6; color: #4b5563; }
.deadline.neutro .dot { background: #9ca3af; }

/* Badge de fase / pausado */
.phase-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: var(--r-full);
  color: var(--phase-color, var(--muted-foreground));
  background: color-mix(in oklch, var(--phase-color, gray) 12%, white);
}

/* ============================ Detalhe do projeto ============================ */
.back-link {
  background: none; border: none; cursor: pointer;
  color: var(--muted-foreground);
  font-size: 0.85rem; font-weight: 600;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 0; margin-bottom: 12px;
}
.back-link:hover { color: var(--brand); }

.detail-head {
  background: var(--surface-elevated);
  border-radius: var(--r-lg);
  padding: 24px;
  box-shadow: inset 0 0 0 1px var(--ring), var(--shadow-sm);
  margin-bottom: 20px;
  border-left: 4px solid var(--area-color, var(--brand));
}
.detail-head h2 { margin: 0 0 8px; font-size: 1.5rem; letter-spacing: -0.02em; }
.detail-meta { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 12px 0; }
.detail-desc { color: var(--muted-foreground); font-size: 0.92rem; margin: 6px 0 0; max-width: 70ch; }
.detail-progress { margin-top: 18px; max-width: 420px; }

.pause-note {
  margin-top: 14px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: #9a3412;
  border-radius: var(--r-md);
  padding: 10px 14px;
  font-size: 0.85rem;
}

.task-section-title { font-weight: 600; font-size: 1rem; margin: 24px 0 12px; }

.task-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface-elevated);
  border-radius: var(--r-md);
  padding: 12px 14px;
  box-shadow: inset 0 0 0 1px var(--ring);
  margin-bottom: 8px;
  transition: background 0.15s;
}
.task-row:hover { background: var(--surface-hover); }
.task-check {
  appearance: none;
  width: 20px; height: 20px;
  border-radius: 6px;
  border: 2px solid oklch(0.8 0.01 285);
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  transition: all 0.15s;
}
.task-check:checked { background: var(--brand); border-color: var(--brand); }
.task-check:checked::after {
  content: "";
  position: absolute;
  left: 5px; top: 1px;
  width: 5px; height: 10px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
/* Selecionável de propósito: copiar o texto do passo é uso corrente, e antes
   o clique para selecionar acabava marcando o passo como concluído. */
.task-text { flex: 1; font-size: 0.9rem; cursor: text; user-select: text; }
.task-row.done .task-text { text-decoration: line-through; color: var(--muted-foreground); }
.task-check[disabled] { cursor: default; opacity: 0.9; }

/* ============================ Ideias ============================ */
.ideas-group { margin-bottom: 32px; }
.ideas-group-head {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 14px;
}
.ideas-group-head h3 { margin: 0; font-size: 1.05rem; font-weight: 600; }
.ideas-group-head .count {
  font-size: 0.72rem; font-weight: 700;
  padding: 2px 9px; border-radius: var(--r-full);
  color: var(--status-color, var(--muted-foreground));
  background: color-mix(in oklch, var(--status-color, gray) 12%, white);
}
.ideas-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.idea-card {
  background: var(--surface-elevated);
  border-radius: var(--r-lg);
  padding: 18px;
  box-shadow: inset 0 0 0 1px var(--ring), var(--shadow-sm);
  border-top: 3px solid var(--status-color, var(--brand));
  animation: scale-in 0.35s ease-out both;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.idea-card h4 { margin: 0; font-size: 0.98rem; font-weight: 600; }
.idea-card .desc { font-size: 0.85rem; color: var(--muted-foreground); margin: 0; }
.status-badge {
  align-self: flex-start;
  font-size: 0.7rem; font-weight: 700;
  padding: 3px 10px; border-radius: var(--r-full);
  color: var(--status-color, var(--muted-foreground));
  background: color-mix(in oklch, var(--status-color, gray) 12%, white);
}
.idea-motivo {
  margin-top: 4px;
  font-size: 0.82rem;
  background: #fef2f2;
  border: 1px solid #fee2e2;
  color: #991b1b;
  border-radius: var(--r-md);
  padding: 10px 12px;
}
.idea-motivo strong { display: block; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 3px; }
.idea-actions { display: flex; gap: 8px; margin-top: 4px; }

/* ============================ Modal ============================ */
.modal-overlay {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(24, 8, 12, 0.4);
  backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: fade-in-up 0.2s ease-out both;
}
.modal {
  background: var(--surface-elevated);
  border-radius: var(--r-lg);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: scale-in 0.25s ease-out both;
}
.modal-head {
  padding: 20px 24px;
  border-bottom: 1px solid var(--ring);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-head h3 { margin: 0; font-size: 1.1rem; font-weight: 600; }
.modal-close { background: none; border: none; cursor: pointer; font-size: 1.3rem; color: var(--muted-foreground); line-height: 1; }
.modal-body { padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.modal-foot {
  padding: 16px 24px;
  border-top: 1px solid var(--ring);
  display: flex; justify-content: flex-end; gap: 10px;
}
.form-row { display: flex; flex-direction: column; gap: 8px; }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* Editor de tarefas dentro do modal */
.task-editor { display: flex; flex-direction: column; gap: 8px; }
.task-edit-row { display: flex; gap: 8px; align-items: center; }
.task-edit-row .input { flex: 1; }
.task-edit-row .input.prazo { flex: 0 0 130px; }
.icon-btn {
  width: 34px; height: 34px;
  border-radius: var(--r-sm);
  border: 1px solid var(--ring-strong);
  background: var(--surface-elevated);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted-foreground);
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--surface-hover); color: #b91c1c; }

/* ============================ Modo edição — controles nos cards ============================ */
.edit-actions {
  display: flex; gap: 6px; margin-top: 10px;
  padding-top: 10px; border-top: 1px dashed var(--ring-strong);
}
.editing .edit-only { display: inline-flex; }
.edit-only { display: none; }
.add-card {
  border: 1px dashed var(--ring-strong);
  border-radius: var(--r-md);
  background: transparent;
  color: var(--muted-foreground);
  font-weight: 600;
  font-size: 0.85rem;
  padding: 12px;
  cursor: pointer;
  transition: all 0.15s;
}
.add-card:hover { border-color: var(--brand); color: var(--brand); background: color-mix(in oklch, var(--brand) 5%, white); }

.toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-bottom: 18px;
}
.toolbar.edit-only { display: none; }
.editing .toolbar.edit-only { display: flex; }

/* ============================ Toast ============================ */
#toast {
  position: fixed;
  bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--surface-sunken);
  color: #fff;
  padding: 12px 20px;
  border-radius: var(--r-md);
  font-size: 0.88rem;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 200;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.err { background: #7f1d1d; }

/* ============================ Estado vazio ============================ */
.empty-state {
  text-align: center;
  color: var(--muted-foreground);
  padding: 60px 20px;
}
.empty-state .big { font-size: 40px; margin-bottom: 10px; }

/* ============================ Loader ============================ */
.loader {
  display: flex; align-items: center; justify-content: center;
  gap: 10px; padding: 60px; color: var(--muted-foreground);
}
.loader .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--brand); animation: pulse-dot 1s ease-in-out infinite; }
.loader .dot:nth-child(2) { animation-delay: 0.15s; }
.loader .dot:nth-child(3) { animation-delay: 0.3s; }

/* ============================ Responsivo ============================ */
@media (max-width: 640px) {
  .board { grid-auto-columns: 82%; }
  .form-grid-2 { grid-template-columns: 1fr; }
  .nav-tab { padding: 10px 12px; font-size: 0.82rem; }
  .brand-text .t2 { display: none; }
  .topbar-actions .label { display: none; }
}

/* ==========================================================================
   v2 — Supabase, modelo Projeto › Módulo › Passo, permissões e auditoria.
   Este bloco vem por último de propósito: sobrescreve o que precisou mudar.
   ========================================================================== */

/* ---- Correções apontadas no parecer de produto ---- */

/* 1. Contraste: texto colorido sobre fundo claro reprovava em 9 de 14
      combinações. Escurecendo o texto e subindo o corpo da fonte. */
.area-badge, .phase-badge { font-size: 0.75rem; }
.area-badge  { color: color-mix(in oklch, var(--area-color, var(--brand)) 68%, black); }
.phase-badge { color: color-mix(in oklch, var(--phase-color, gray) 68%, black); }

/* 2. As 6 fases cabem juntas na largura da tela — a barra de rolagem
      horizontal escondia metade do quadro. O layout está em `.board`;
      aqui fica só a rolagem suave, usada na faixa estreita/celular. */
.board { scroll-behavior: smooth; }
.column-head { background: color-mix(in oklch, var(--surface) 92%, white); z-index: 1; }

/* 3. O card virou <button>: navegavel por teclado, com nome acessivel. */
.pcard {
  display: flex; flex-direction: column; align-items: stretch;
  width: 100%; text-align: left; border: none; font: inherit; color: inherit;
  border-left: 3px solid var(--area-color, var(--brand));
  gap: 6px;
  /* Quadrado e com folga. É um piso, não um teto: título longo faz o card
     crescer em vez de cortar o conteúdo. O `min-height` segura o formato
     quando a coluna fica estreita — sem ele o quadrado vira um selo. */
  aspect-ratio: 1 / 1;
  min-height: 232px;
  padding: 18px;
  justify-content: space-between;
}
/* Com mais espaço vertical, a descrição pode respirar em 3 linhas. */
.pcard .desc { -webkit-line-clamp: 3; }
.pcard .progress { margin-top: auto; }
.pcard-title { line-height: 1.32; }

/* Aviso de somente-leitura no detalhe do módulo. */
.nota-leitura {
  display: flex; align-items: center; gap: 8px;
  margin: 0 0 14px;
  padding: 10px 14px;
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--muted-foreground);
  font-size: 0.84rem;
  box-shadow: inset 0 0 0 1px var(--ring);
}
.pcard-title { font-size: 0.95rem; font-weight: 600; letter-spacing: -0.01em; margin: 4px 0 6px; }
.pcard .desc { font-size: 0.8rem; color: var(--muted-foreground); margin: 0 0 10px; }
.pcard-foot { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.pcard .progress { display: block; }
.pcard-top { width: 100%; }

/* 4. Foco visivel — antes nao havia nenhum indicador de teclado. */
:where(button, a, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--brand-accent);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

/* 5. O modo edicao agora e so um cinto de seguranca visual (quem pode
      editar e decidido pela RLS, nao por senha no navegador). */
.editando .edit-only { display: inline-flex; }

/* ---- Cabecalho: identidade do usuario ---- */
.user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 5px 12px 5px 5px; border-radius: var(--r-full);
  background: rgba(255,255,255,0.12); cursor: default;
}
.user-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: rgba(255,255,255,0.9); color: var(--brand);
  display: grid; place-items: center; font-weight: 800; font-size: 0.85rem;
}
.user-meta { display: flex; flex-direction: column; line-height: 1.15; }
.user-nome  { font-size: 0.82rem; font-weight: 700; color: #fff; }
.user-papel { font-size: 0.68rem; color: rgba(255,255,255,0.78); }

/* ---- Barra de offline / erro de carga ---- */
.offline-bar {
  background: #7f1d1d; color: #fff; text-align: center;
  padding: 8px 14px; font-size: 0.82rem; font-weight: 600;
}
.erro-carga {
  max-width: 460px; margin: 60px auto; text-align: center;
  background: var(--surface-elevated); padding: 32px 24px;
  border-radius: var(--r-lg); box-shadow: inset 0 0 0 1px var(--ring), var(--shadow-md);
}
.erro-carga .big { font-size: 40px; margin-bottom: 8px; }
.erro-carga h3 { margin: 0 0 6px; font-size: 1rem; }
.erro-carga p  { margin: 0 0 18px; color: var(--muted-foreground); font-size: 0.88rem; }

/* ---- Rodape ---- */
.rodape {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  max-width: 1320px; margin: 32px auto 0; padding: 14px 24px 28px;
  font-size: 0.78rem; color: var(--muted-foreground);
  border-top: 1px solid var(--ring);
}
.link-btn {
  background: none; border: none; cursor: pointer; font: inherit;
  color: var(--brand); font-weight: 700; text-decoration: underline;
}

/* ---- Trilha de navegacao ---- */
.breadcrumb { font-size: 0.8rem; color: var(--muted-foreground); margin-bottom: 12px; }
.breadcrumb a { font-weight: 600; text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }

/* ---- Lista de modulos dentro do projeto ---- */
.mod-list { display: flex; flex-direction: column; gap: 8px; }
.mod-row {
  display: flex; align-items: center; gap: 12px; width: 100%;
  background: var(--surface-elevated); border: none; font: inherit; color: inherit;
  text-align: left; cursor: pointer; padding: 12px 16px;
  border-radius: var(--r-md); box-shadow: inset 0 0 0 1px var(--ring);
  flex-wrap: wrap;
}
.mod-row:hover { box-shadow: inset 0 0 0 1px var(--ring-strong), var(--shadow-sm); }
.mod-ordem {
  width: 26px; height: 26px; flex: none; border-radius: 50%;
  background: var(--surface); display: grid; place-items: center;
  font-size: 0.75rem; font-weight: 700; color: var(--muted-foreground);
}
.mod-main { flex: 1; display: flex; flex-direction: column; min-width: 140px; }
.mod-nome { font-weight: 600; font-size: 0.9rem; }
.mod-sub  { font-size: 0.75rem; color: var(--muted-foreground); }

/* ---- Cards de projeto (visao portfolio) ---- */
.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.proj-card {
  display: flex; flex-direction: column; gap: 4px; text-align: left;
  background: var(--surface-elevated); border: none; font: inherit; color: inherit;
  cursor: pointer; padding: 16px; border-radius: var(--r-md);
  box-shadow: inset 0 0 0 1px var(--ring), var(--shadow-sm);
  border-left: 3px solid var(--area-color, var(--brand));
  transition: transform 0.15s, box-shadow 0.15s;
}
.proj-card:hover { transform: translateY(-3px); box-shadow: inset 0 0 0 1px var(--ring-strong), var(--shadow-lg); }
.proj-card .area-badge { align-self: flex-start; }
.proj-card .progress { display: block; margin-top: 8px; }

/* ---- Modulo restrito ---- */
.badge-restrito { margin-left: auto; font-size: 0.85rem; }
.badge-restrito-full {
  font-size: 0.72rem; font-weight: 700; padding: 3px 9px; border-radius: var(--r-full);
  background: #fef3c7; color: #92400e;
}

/* ---- Passos ---- */
.task-row.somente-leitura { cursor: default; }
.task-row.somente-leitura:hover { background: transparent; }
.task-check[disabled] { opacity: 0.4; cursor: not-allowed; }
.deadline.alerta { background: #fef3c7; color: #92400e; }
.deadline.alerta .dot { background: #f59e0b; }
.loader-inline { color: var(--muted-foreground); font-size: 0.85rem; padding: 16px 0; }

/* ---- Formularios ---- */
.hint { color: var(--muted-foreground); font-weight: 400; font-size: 0.78rem; }
.form-nota {
  font-size: 0.8rem; color: var(--muted-foreground);
  background: var(--surface); padding: 10px 12px; border-radius: var(--r-sm);
  margin: 12px 0 0;
}
.check-row {
  display: flex; gap: 10px; align-items: flex-start; margin-top: 14px;
  padding: 12px; background: var(--surface); border-radius: var(--r-sm);
  font-size: 0.85rem; cursor: pointer;
}
.detail-actions { margin-top: 16px; display: flex; gap: 10px; flex-wrap: wrap; }
.input-sm { padding: 6px 10px; font-size: 0.82rem; }
body.modal-aberto { overflow: hidden; }

/* ---- Tabelas da administracao ---- */
.tabela-wrap { overflow-x: auto; border-radius: var(--r-md); box-shadow: inset 0 0 0 1px var(--ring); background: var(--surface-elevated); }
.tabela { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.tabela th, .tabela td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--ring); vertical-align: middle; }
.tabela th { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted-foreground); }
.tabela tr:last-child td { border-bottom: none; }
.tabela .num { text-align: right; font-variant-numeric: tabular-nums; }
.linha-off { opacity: 0.55; }
.aviso-inline { color: #92400e; font-size: 0.78rem; font-weight: 600; }
.legenda { margin-top: 14px; font-size: 0.8rem; color: var(--muted-foreground); display: grid; gap: 4px; }
.filtros { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.nivel-badge { font-size: 0.72rem; font-weight: 700; padding: 3px 9px; border-radius: var(--r-full); }
.nivel-leitura { background: #eff6ff; color: #1e40af; }
.nivel-edicao  { background: #ecfdf5; color: #065f46; }

/* Interruptor de acesso */
.switch { display: inline-block; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-ui {
  display: block; width: 40px; height: 22px; border-radius: var(--r-full);
  background: #cbd5e1; position: relative; transition: background 0.18s;
}
.switch-ui::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 16px; height: 16px; border-radius: 50%; background: #fff;
  transition: transform 0.18s; box-shadow: var(--shadow-sm);
}
.switch input:checked + .switch-ui { background: #059669; }
.switch input:checked + .switch-ui::after { transform: translateX(18px); }
.switch input:focus-visible + .switch-ui { outline: 2px solid var(--brand-accent); outline-offset: 2px; }

/* ---- Linha do tempo da auditoria ---- */
.timeline { display: flex; flex-direction: column; gap: 10px; }
.tl-item {
  background: var(--surface-elevated); padding: 12px 16px; border-radius: var(--r-md);
  box-shadow: inset 0 0 0 1px var(--ring); border-left: 3px solid var(--muted-foreground);
  font-size: 0.85rem;
}
.tl-novo { border-left-color: #059669; }
.tl-alt  { border-left-color: #2563eb; }
.tl-del  { border-left-color: #dc2626; }
.tl-head { display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; }
.tl-tipo { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; color: var(--muted-foreground); }
.tl-quando { margin-left: auto; font-size: 0.75rem; color: var(--muted-foreground); font-variant-numeric: tabular-nums; }
.diff { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 3px; font-size: 0.8rem; }
.diff li { display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; }
.diff .campo { font-weight: 700; min-width: 90px; }
.diff .de   { color: #b91c1c; text-decoration: line-through; }
.diff .para { color: #047857; font-weight: 600; }

/* ---- Login ---- */
.gate-hint { margin-top: 16px; font-size: 0.78rem; color: var(--muted-foreground); text-align: center; line-height: 1.6; }
.gate-error { display: none; }
.gate-error.show { display: block; }

/* ---- Ideias ---- */
.idea-link { font-size: 0.8rem; font-weight: 600; color: var(--brand); text-decoration: none; }
.idea-link:hover { text-decoration: underline; }

#toast.ok { background: #065f46; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
