:root {
  --azul: #1e3a5f;
  --azul-claro: #2c5282;
  --bg: #f0f2f5;
  --card: #ffffff;
  --texto: #1a1a1a;
  --cinza: #6b7280;
  --borda: #e2e8f0;
  --ok: #16a34a;
  --erro: #dc2626;
  --amarelo: #d97706;
  --sombra: 0 1px 4px rgba(0, 0, 0, .08);
}

* { 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(--texto);
  min-height: 100vh;
  line-height: 1.5;
}

a { color: var(--azul-claro); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- topo ---------- */
.topbar {
  background: var(--azul);
  color: #fff;
  padding: 14px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}
.topbar .brand { font-weight: 700; font-size: 1.05rem; }
.topbar .brand small { display: block; font-weight: 400; opacity: .7; font-size: .72rem; }
.topbar nav { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.topbar nav a {
  color: #fff; padding: 6px 12px; border-radius: 6px; font-size: .9rem;
  opacity: .85;
}
.topbar nav a:hover { background: rgba(255,255,255,.12); opacity: 1; text-decoration: none; }
.topbar nav a.ativo { background: rgba(255,255,255,.18); opacity: 1; }
.topbar .usuario { font-size: .82rem; opacity: .85; margin-right: 4px; }
.btn-logout {
  background: rgba(255,255,255,.15); color: #fff; border: none; cursor: pointer;
  padding: 6px 12px; border-radius: 6px; font-size: .85rem;
}
.btn-logout:hover { background: rgba(255,255,255,.28); }

/* ---------- layout ---------- */
.container { max-width: 960px; margin: 26px auto; padding: 0 18px; }
.page-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 18px; }
.page-head h1 { font-size: 1.35rem; }
.subtitulo { color: var(--cinza); font-size: .9rem; margin-top: 2px; }

/* ---------- cards ---------- */
.card {
  background: var(--card); border-radius: 10px; box-shadow: var(--sombra);
  padding: 18px 20px; margin-bottom: 16px; border: 1px solid var(--borda);
}
.card h2 { font-size: 1.05rem; margin-bottom: 4px; }
.card .meta { color: var(--cinza); font-size: .82rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.stat { background: var(--card); border: 1px solid var(--borda); border-radius: 10px; padding: 16px 18px; box-shadow: var(--sombra); }
.stat .num { font-size: 1.8rem; font-weight: 700; color: var(--azul); }
.stat .lbl { color: var(--cinza); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }

/* ---------- tabelas ---------- */
.tabela-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: var(--card); }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--borda); font-size: .92rem; }
th { font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; color: var(--cinza); }
tr:last-child td { border-bottom: none; }
td.acoes { white-space: nowrap; text-align: right; }

/* ---------- badges ---------- */
.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: .74rem; font-weight: 600; }
.badge.admin { background: #e0e7ff; color: #3730a3; }
.badge.usuario { background: #dcfce7; color: #166534; }

/* ---------- barra de progresso ---------- */
.progress { background: #e5e7eb; border-radius: 20px; height: 12px; overflow: hidden; min-width: 90px; }
.progress > span { display: block; height: 100%; background: var(--ok); border-radius: 20px; transition: width .3s; }
.progress.baixo > span { background: var(--erro); }
.progress.medio > span { background: var(--amarelo); }
.progress-linha { display: flex; align-items: center; gap: 10px; }
.progress-linha .pct { font-weight: 600; font-size: .85rem; min-width: 42px; text-align: right; }

/* ---------- botões ---------- */
.btn {
  display: inline-block; background: var(--azul); color: #fff; border: none;
  padding: 8px 16px; border-radius: 7px; font-size: .9rem; cursor: pointer;
  font-family: inherit;
}
.btn:hover { background: var(--azul-claro); text-decoration: none; }
.btn.sm { padding: 5px 11px; font-size: .82rem; }
.btn.secundario { background: #eef2f7; color: var(--azul); }
.btn.secundario:hover { background: #e2e8f0; }
.btn.perigo { background: #fee2e2; color: var(--erro); }
.btn.perigo:hover { background: #fecaca; }
.btn-inline { display: inline; }

/* ---------- formulários ---------- */
form.stack { max-width: 460px; }
.campo { margin-bottom: 15px; }
.campo label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: 5px; }
.campo input[type=text], .campo input[type=password], .campo input[type=number],
.campo textarea, .campo select {
  width: 100%; padding: 9px 11px; border: 1px solid #cbd5e1; border-radius: 7px;
  font-size: .95rem; font-family: inherit; background: #fff;
}
.campo input:focus, .campo textarea:focus, .campo select:focus {
  outline: none; border-color: var(--azul-claro); box-shadow: 0 0 0 3px rgba(44,82,130,.12);
}
.campo .ajuda { color: var(--cinza); font-size: .78rem; margin-top: 4px; }
.form-acoes { display: flex; gap: 10px; align-items: center; margin-top: 8px; }

/* ---------- flash ---------- */
.flashes { margin-bottom: 16px; }
.flash { padding: 11px 15px; border-radius: 8px; font-size: .9rem; margin-bottom: 8px; border: 1px solid transparent; }
.flash.ok { background: #dcfce7; color: #166534; border-color: #bbf7d0; }
.flash.erro { background: #fee2e2; color: #991b1b; border-color: #fecaca; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-box { background: var(--card); border-radius: 12px; box-shadow: 0 6px 24px rgba(0,0,0,.12); padding: 32px 30px; width: 100%; max-width: 380px; }
.login-box .logo { text-align: center; margin-bottom: 22px; }
.login-box .logo h1 { color: var(--azul); font-size: 1.3rem; }
.login-box .logo p { color: var(--cinza); font-size: .82rem; margin-top: 3px; }
.login-box .btn { width: 100%; padding: 11px; font-size: 1rem; }

/* ---------- vínculos ---------- */
.vinculo-item { display: flex; align-items: center; gap: 12px; padding: 11px 4px; border-bottom: 1px solid var(--borda); }
.vinculo-item:last-child { border-bottom: none; }
.vinculo-item input[type=checkbox] { width: 18px; height: 18px; flex-shrink: 0; }
.vinculo-item .info { flex: 1; }
.vinculo-item .info .nome { font-weight: 600; }
.vinculo-item .info .desc { color: var(--cinza); font-size: .82rem; }

.vazio { color: var(--cinza); font-style: italic; padding: 14px 0; }
.update-form { display: flex; gap: 8px; align-items: center; }
.update-form input[type=number] { width: 90px; }

/* ---------- prazo / atrasado ---------- */
.badge.atrasado { background: #fee2e2; color: #991b1b; }
.prazo {
  display: inline-block; font-size: .78rem; font-weight: 600; color: var(--cinza);
  background: #eef2f7; border-radius: 20px; padding: 2px 11px; white-space: nowrap;
}
.prazo.atrasado { background: #fee2e2; color: #991b1b; }
.obrigatorio { color: var(--erro); }

/* ---------- status automático ---------- */
.status {
  display: inline-block; font-size: .72rem; font-weight: 700; padding: 2px 10px;
  border-radius: 20px; vertical-align: middle; margin-left: 4px; white-space: nowrap;
}
.status.finalizado   { background: #dcfce7; color: #166534; }
.status.em_andamento { background: #dbeafe; color: #1e40af; }
.status.atrasado     { background: #fee2e2; color: #991b1b; }

/* ---------- filtro por status ---------- */
.filtros { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.pill {
  display: inline-flex; align-items: center; gap: 7px; padding: 6px 14px;
  border-radius: 20px; background: #fff; border: 1px solid var(--borda);
  font-size: .86rem; color: var(--texto); box-shadow: var(--sombra);
}
.pill:hover { border-color: var(--azul); text-decoration: none; }
.pill.ativo { background: var(--azul); color: #fff; border-color: var(--azul); }
.pill .n { font-size: .74rem; font-weight: 700; background: rgba(0,0,0,.08); padding: 0 7px; border-radius: 12px; }
.pill.ativo .n { background: rgba(255,255,255,.25); }

/* ---------- item de projeto (dentro do card do profissional) ---------- */
.proj-item { padding: 14px 0; border-bottom: 1px solid var(--borda); }
.proj-item:last-child { border-bottom: none; padding-bottom: 0; }
.proj-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.proj-nome { font-weight: 600; font-size: 1rem; }

/* ---------- blocos "feito / faltando" ---------- */
.notas { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.nota { background: #f8fafc; border: 1px solid var(--borda); border-radius: 8px; padding: 9px 12px; }
.nota .rot { display: block; font-size: .7rem; text-transform: uppercase; letter-spacing: .04em; color: var(--cinza); font-weight: 700; margin-bottom: 3px; }
.nota p { font-size: .88rem; white-space: pre-wrap; word-break: break-word; }

/* ---------- histórico ---------- */
.historico { margin-top: 12px; }
.historico > summary { cursor: pointer; font-size: .82rem; font-weight: 600; color: var(--azul-claro); padding: 4px 0; user-select: none; }
.historico > summary:hover { text-decoration: underline; }
.hist-item { border-left: 3px solid var(--borda); padding: 8px 0 8px 12px; margin-top: 10px; }
.hist-top { font-size: .82rem; font-weight: 600; color: var(--azul); margin-bottom: 6px; }
.hist-item .notas { grid-template-columns: 1fr 1fr; margin-top: 6px; }

/* ---------- formulário de atualização (painel do profissional) ---------- */
.form-atualizar { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--borda); max-width: 560px; }

@media (max-width: 560px) {
  .page-head { align-items: flex-start; }
  td.acoes { text-align: left; }
  .notas, .hist-item .notas { grid-template-columns: 1fr; }
}
