:root {
  --bg: #eef2f7;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --col-bg: #e6eaf1;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 14px rgba(0,0,0,.05);
  --shadow-lg: 0 20px 60px rgba(0,0,0,.25);
  --hover: #f1f5f9;
  --chip-bg: #f1f5f9;
  --danger: #dc2626;
  --danger-bg: #fee2e2;
}

body.dark {
  --bg: #0b1220;
  --surface: #111a2c;
  --surface-2: #16203a;
  --border: #24304a;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --primary: #3b82f6;
  --primary-dark: #2563eb;
  --col-bg: #0e1729;
  --shadow: 0 1px 3px rgba(0,0,0,.5), 0 4px 14px rgba(0,0,0,.35);
  --shadow-lg: 0 20px 60px rgba(0,0,0,.6);
  --hover: #1c2842;
  --chip-bg: #1c2842;
  --danger: #f87171;
  --danger-bg: #450a0a;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition: background .25s, color .25s;
}

/* ===== LOGIN ===== */
.tela-login {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  z-index: 500;
  padding: 20px;
}
.login-card {
  background: var(--surface);
  border-radius: 18px;
  padding: 32px 28px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 24px 70px rgba(0,0,0,.4);
}
.login-logo { font-size: 44px; text-align: center; }
.login-card h1 { font-size: 22px; text-align: center; margin-top: 8px; }
.login-sub { text-align: center; color: var(--muted); font-size: 14px; margin: 6px 0 22px; }
.login-card label { display: block; font-size: 13px; font-weight: 600; margin: 12px 0 5px; }
.login-card input, .login-card select {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 9px;
  font-size: 15px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
}
.login-card input:focus, .login-card select:focus { outline: 2px solid var(--primary); border-color: transparent; }
.btn-block { width: 100%; margin-top: 20px; padding: 12px; font-size: 16px; }
.login-erro { background: var(--danger-bg); color: var(--danger); padding: 10px 12px; border-radius: 8px; font-size: 13px; margin-top: 12px; }

/* ===== TOPBAR ===== */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-inner {
  max-width: 1500px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo { font-size: 26px; }
.brand h1 { font-size: 19px; font-weight: 700; line-height: 1.1; }
.brand-sub { font-size: 12px; color: var(--muted); }
.topbar-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.usuario-atual { font-size: 13px; font-weight: 600; color: var(--primary); background: var(--chip-bg); padding: 6px 12px; border-radius: 20px; }

.container { max-width: 1500px; margin: 0 auto; padding: 20px 24px 60px; }

.projeto-selector-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.projeto-selector { display: flex; flex-direction: column; gap: 5px; flex: 1; min-width: 220px; }
.projeto-selector-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.projeto-selector select {
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  background: var(--surface);
  color: var(--text);
  width: 100%;
}
.projeto-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.projeto-overview {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}
.projeto-overview .po-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.projeto-overview .po-nome { font-size: 20px; font-weight: 700; }
.projeto-overview .po-descricao { color: var(--muted); font-size: 14px; margin-top: 6px; white-space: pre-wrap; line-height: 1.5; }
.projeto-overview .po-stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-top: 16px; }
.stat-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  background: var(--surface-2);
}
.stat-card .stat-num { font-size: 24px; font-weight: 800; }
.stat-card .stat-label { font-size: 12px; color: var(--muted); }
.stat-card.nao_listado .stat-num { color: #94a3b8; }
.stat-card.pendente .stat-num { color: #64748b; }
.stat-card.andamento .stat-num { color: #2563eb; }
.stat-card.aguardando .stat-num { color: #d97706; }
.stat-card.cancelada .stat-num { color: #6b7280; }
.stat-card.concluida .stat-num { color: #16a34a; }
.stat-card.agendada .stat-num { color: #7c3aed; }
.stat-card.rejeitada .stat-num { color: #dc2626; }
.stat-card.em_teste .stat-num { color: #0891b2; }

.toolbar { margin-bottom: 16px; }
.toolbar-row { display: flex; flex-direction: column; gap: 10px; }
.busca {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  background: var(--surface);
  color: var(--text);
}
.busca:focus { outline: 2px solid var(--primary); border-color: transparent; }
.filtros { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filtros select {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  font-size: 13px;
  background: var(--surface);
  color: var(--text);
  flex: 1;
  min-width: 150px;
}

/* ===== KANBAN BOARD ===== */
.board {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
}
.coluna {
  background: var(--col-bg);
  border-radius: 14px;
  padding: 10px;
  min-height: 45vh;
  display: flex;
  flex-direction: column;
}
.coluna-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px 12px;
  font-weight: 700;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
}
.coluna-header .col-titulo { display: flex; align-items: center; gap: 8px; }
.coluna-header .dot { width: 10px; height: 10px; border-radius: 50%; }
.coluna-header .count {
  background: var(--surface);
  border-radius: 20px;
  padding: 2px 10px;
  font-size: 12px;
  color: var(--muted);
  border: 1px solid var(--border);
}
.coluna-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 80px;
  padding: 2px;
  border-radius: 10px;
  transition: background .15s;
}
.coluna-body.drag-over { background: color-mix(in srgb, var(--primary) 12%, transparent); }

.card {
  background: var(--surface);
  border-radius: 12px;
  padding: 13px 15px;
  box-shadow: var(--shadow);
  cursor: pointer;
  border-left: 4px solid #94a3b8;
  position: relative;
  transition: box-shadow .12s;
}
.card:hover { box-shadow: 0 6px 20px rgba(0,0,0,.12); }
.card.atrasada { border-left-color: var(--danger); }
.card.prioridade-baixa { border-left-color: #22c55e; }
.card.prioridade-media { border-left-color: #eab308; }
.card.prioridade-alta { border-left-color: #ef4444; }

.card-titulo { font-weight: 600; font-size: 14px; margin-bottom: 4px; word-break: break-word; padding-right: 30px; }
.card-desc { font-size: 12.5px; color: var(--muted); margin-bottom: 8px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; word-break: break-word; }
.card-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 11.5px; color: var(--muted); }
.card-meta .meta-item { display: inline-flex; align-items: center; gap: 4px; }
.card-projeto { font-size: 10.5px; background: var(--chip-bg); border: 1px solid var(--border); padding: 2px 7px; border-radius: 10px; color: var(--muted); max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-move {
  position: absolute;
  top: 8px;
  right: 8px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 14px;
  color: var(--muted);
  opacity: 0;
  transition: opacity .12s;
}
.card:hover .card-move { opacity: 1; }

.badge {
  padding: 2px 9px;
  border-radius: 12px;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .03em;
  white-space: nowrap;
}
.badge-baixa { background: #dcfce7; color: #15803d; }
.badge-media { background: #fef9c3; color: #a16207; }
.badge-alta { background: #fee2e2; color: #b91c1c; }
body.dark .badge-baixa { background: #14532d; color: #86efac; }
body.dark .badge-media { background: #422006; color: #fde047; }
body.dark .badge-alta { background: #450a0a; color: #fca5a5; }

.status-badge { padding: 3px 10px; border-radius: 12px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.status-nao_listado { background: #e2e8f0; color: #475569; }
.status-pendente { background: #e2e8f0; color: #475569; }
.status-em_andamento { background: #dbeafe; color: #1d4ed8; }
.status-aguardando { background: #fef3c7; color: #b45309; }
.status-cancelada { background: #e5e7eb; color: #4b5563; }
.status-concluida { background: #dcfce7; color: #15803d; }
.status-agendada { background: #ede9fe; color: #6d28d9; }
.status-rejeitada { background: #fee2e2; color: #b91c1c; }
.status-em_teste { background: #cffafe; color: #0e7490; }
body.dark .status-nao_listado { background: #1e293b; color: #cbd5e1; }
body.dark .status-pendente { background: #1e293b; color: #cbd5e1; }
body.dark .status-em_andamento { background: #1e3a8a; color: #93c5fd; }
body.dark .status-aguardando { background: #451a03; color: #fcd34d; }
body.dark .status-cancelada { background: #334155; color: #cbd5e1; }
body.dark .status-concluida { background: #14532d; color: #86efac; }
body.dark .status-agendada { background: #4c1d95; color: #c4b5fd; }
body.dark .status-rejeitada { background: #450a0a; color: #fca5a5; }
body.dark .status-em_teste { background: #164e63; color: #a5f3fc; }

.btn {
  padding: 9px 16px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  transition: background .12s, transform .05s;
}
.btn:hover { background: var(--hover); }
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-icon { width: 40px; padding: 0; font-size: 18px; }
.btn-sm { padding: 7px 12px; font-size: 13px; }
.btn-danger { color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger-bg); }

.empty { text-align: center; color: var(--muted); padding: 30px; font-size: 13px; }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, .55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}
.modal {
  background: var(--surface);
  border-radius: 16px;
  width: 100%;
  max-width: 560px;
  box-shadow: var(--shadow-lg);
  max-height: 94vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-lg { max-width: 680px; }
.modal-xl { max-width: 860px; }
.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 17px; }
.btn-close { border: none; background: none; font-size: 26px; cursor: pointer; color: var(--muted); line-height: 1; }
.modal form { padding: 20px; overflow-y: auto; }
.modal-body { padding: 20px; overflow-y: auto; }
.modal label { display: block; font-size: 13px; font-weight: 600; margin: 14px 0 5px; color: var(--text); }
.modal input, .modal textarea, .modal select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  font-size: 14px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
}
.modal input:focus, .modal textarea:focus, .modal select:focus { outline: 2px solid var(--primary); border-color: transparent; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.modal-actions-between { justify-content: space-between; align-items: center; }
.modal-actions-between > div { display: flex; gap: 10px; }

.checklist-editor { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.checklist-item { display: flex; align-items: center; gap: 8px; }
.checklist-item input[type="checkbox"] { width: auto; cursor: pointer; }
.checklist-item input[type="text"] { flex: 1; }
.checklist-item .icon-btn { flex-shrink: 0; }
.checklist-add {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  cursor: pointer;
  color: var(--primary);
  font-size: 13px;
  font-weight: 600;
  background: none;
  margin-top: 6px;
}
.checklist-add:hover { background: var(--hover); }

.detalhe-header { display: flex; flex-direction: column; gap: 8px; }
.detalhe-badges { display: flex; flex-wrap: wrap; gap: 6px; }
.detalhe-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }

.detalhe-body .secao { margin-bottom: 22px; }
.detalhe-body .secao-titulo { font-size: 14px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); margin-bottom: 10px; display: flex; align-items: center; justify-content: space-between; }
.detalhe-body .secao-desc { font-size: 14px; line-height: 1.6; white-space: pre-wrap; }
.detalhe-body .info-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.detalhe-body .info-item { background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; padding: 10px 12px; }
.detalhe-body .info-item .info-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.detalhe-body .info-item .info-valor { font-size: 14px; font-weight: 600; margin-top: 2px; word-break: break-word; }

.bloqueio-alerta {
  background: var(--danger-bg);
  border: 1px solid var(--danger);
  border-radius: 9px;
  padding: 12px 14px;
  font-size: 14px;
  color: var(--danger);
  margin-bottom: 16px;
}

.checklist-view { display: flex; flex-direction: column; gap: 6px; }
.checklist-view .cl-item { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.checklist-view .cl-item input { width: auto; cursor: pointer; }
.checklist-view .cl-item.concluido span { text-decoration: line-through; color: var(--muted); }

.comentarios-lista { display: flex; flex-direction: column; gap: 10px; }
.comentario {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 12px 14px;
}
.comentario .comentario-topo { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.comentario .comentario-tipo { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
.comentario .comentario-usuario { font-size: 12px; font-weight: 600; color: var(--primary); }
.comentario .comentario-data { font-size: 11px; color: var(--muted); }
.comentario .comentario-texto { font-size: 14px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.comentario .comentario-remover { border: none; background: none; color: var(--muted); cursor: pointer; font-size: 13px; }
.comentario.tipo-decisao { border-left: 3px solid #2563eb; }
.comentario.tipo-dificuldade { border-left: 3px solid #dc2626; }
.comentario.tipo-comentario { border-left: 3px solid #94a3b8; }

.novo-comentario { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.novo-comentario .nc-row { display: flex; gap: 8px; flex-wrap: wrap; }
.novo-comentario textarea { width: 100%; }
.novo-comentario .nc-row input { flex: 1; min-width: 120px; }

.links-lista { display: flex; flex-direction: column; gap: 6px; }
.link-item { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.link-item a { color: var(--primary); text-decoration: none; word-break: break-all; }
.link-item button { border: none; background: none; color: var(--muted); cursor: pointer; }

.historico-lista { display: flex; flex-direction: column; }
.historico-item {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
}
.historico-item:last-child { border-bottom: none; }
.historico-icone { font-size: 18px; flex-shrink: 0; }
.historico-item .acao { font-weight: 600; }
.historico-item .detalhe { color: var(--muted); margin-top: 2px; }
.historico-item .data { color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.historico-item .usuario { font-size: 11.5px; color: var(--primary); font-weight: 600; }
.historico-item .tarefa { font-weight: 600; color: var(--primary); }

.anexos-lista { display: flex; flex-wrap: wrap; gap: 8px; }
.anexo-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--chip-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 12px;
  max-width: 100%;
}
.anexo-chip a { color: var(--primary); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 160px; }
.anexo-chip button { border: none; background: none; cursor: pointer; color: var(--muted); font-size: 13px; }
.anexos-box {
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 14px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  margin-top: 8px;
}
.anexos-box:hover { border-color: var(--primary); color: var(--primary); }

.icon-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 7px;
  width: 28px;
  height: 28px;
  cursor: pointer;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}
.icon-btn:hover { background: var(--hover); color: var(--text); }

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 12px 22px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  z-index: 200;
  box-shadow: var(--shadow-lg);
}

.hidden { display: none !important; }

@media (max-width: 1100px) {
  .board { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .board { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .projeto-overview .po-stats { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
  .container { padding: 16px 12px 60px; }
  .topbar-inner { padding: 12px 14px; }
  .modal { max-width: 100%; }
}
@media (max-width: 480px) {
  .board { grid-template-columns: 1fr; }
}
