/* ============================================================================
   Rendeu Hoje — design system (mobile-first, paleta oficial)
   ---------------------------------------------------------------------------- */
:root {
  --verde: #3CA819;
  --verde-2: #44AE1D;
  --verde-acao: #18820E;
  --bg: #0F1115;
  --card: #15181D;
  --card-2: #1B1F26;
  --texto: #FFFFFF;
  --texto-2: #A0A7B1;
  --texto-3: #6B7180;
  --borda: #23272F;
  --erro: #E53935;
  --aviso: #F2B400;
  --info: #3B82F6;
  --r: 12px;
  --r-sm: 8px;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
  --bottom-nav-h: 64px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--texto);
  font-family: Inter, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
}

.muted      { color: var(--texto-2); }
.muted-xs   { color: var(--texto-3); font-size: 13px; }
.inline     { display: inline; }
.hidden     { display: none !important; }
.center     { text-align: center; }
.flex       { display: flex; gap: 12px; align-items: center; }
.flex-col   { display: flex; flex-direction: column; gap: 12px; }
.spacer     { flex: 1; }
.mt-16      { margin-top: 16px; }
.mt-24      { margin-top: 24px; }

/* ------- Containers ------- */
.container {
  padding: 16px;
  padding-bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom) + 24px);
  max-width: 720px;
  margin: 0 auto;
}

/* ------- Topbar ------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  padding-top: calc(14px + env(safe-area-inset-top));
  background: rgba(15,17,21,.92);
  border-bottom: 1px solid var(--borda);
  backdrop-filter: saturate(140%) blur(10px);
}
.topbar .title   { font-weight: 600; font-size: 15px; }
.topbar .sub     { color: var(--texto-2); font-size: 12px; margin-top: 2px; }

/* ------- Auth (card central) ------- */
body.auth { display: flex; min-height: 100vh; align-items: center; justify-content: center; padding: 16px; }
.card {
  width: 100%; max-width: 420px;
  background: var(--card);
  border-radius: var(--r);
  padding: 24px;
  border: 1px solid var(--borda);
  box-shadow: var(--shadow);
}
.card h1 { margin: 0 0 4px; font-size: 24px; font-weight: 700; }

/* ------- Cards genéricos ------- */
.panel {
  background: var(--card);
  border: 1px solid var(--borda);
  border-radius: var(--r);
  padding: 16px;
  margin-top: 12px;
}
.panel h3 { margin: 0 0 8px; font-size: 16px; font-weight: 600; }
.panel + .panel { margin-top: 12px; }

/* ------- Forms ------- */
form label,
.field {
  display: block; margin-top: 14px;
  color: var(--texto-2); font-size: 14px;
}
form input[type="text"],
form input[type="password"],
form input[type="email"],
form input[type="tel"],
form input[type="number"],
form input[type="time"],
form input[type="date"],
form select,
form textarea {
  display: block; width: 100%;
  margin-top: 6px;
  padding: 12px 14px;
  min-height: 48px;
  border-radius: 10px;
  border: 1px solid var(--borda);
  background: #0B0D12;
  color: var(--texto);
  font-size: 16px; font-family: inherit;
}
form textarea { resize: vertical; min-height: 96px; }
form input:focus,
form select:focus,
form textarea:focus { outline: 2px solid var(--verde); outline-offset: 1px; }
form .row { display: flex; gap: 10px; }
form .row > * { flex: 1; }

/* ------- Botões (mínimo 48px, regra de ouro mobile) ------- */
button { font-family: inherit; }
.btn, .btn-primary, .btn-danger, .btn-ghost, .btn-link {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 48px; padding: 0 18px;
  border: 0; border-radius: 10px;
  font-weight: 600; font-size: 15px; cursor: pointer;
  transition: background 150ms, transform 80ms;
  gap: 8px;
}
.btn-primary { background: var(--verde); color: #fff; width: 100%; margin-top: 20px; }
.btn-primary:hover { background: var(--verde-2); }
.btn-primary:active { background: var(--verde-acao); transform: scale(.98); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }

.btn-danger { background: var(--erro); color: #fff; }
.btn-ghost  { background: transparent; color: var(--texto); border: 1px solid var(--borda); }
.btn-ghost:hover { background: var(--card-2); }
.btn-link   { background: none; color: var(--texto-2); text-decoration: underline; padding: 8px 0; min-height: auto; }

.fab {
  position: fixed; right: 16px;
  bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom) + 16px);
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--verde); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; border: 0; cursor: pointer;
  box-shadow: 0 8px 24px rgba(60,168,25,.4);
  z-index: 30;
}

/* ------- Alertas ------- */
.alert {
  margin-top: 14px; padding: 12px 14px;
  border-radius: 10px;
  background: rgba(229,57,53,.1);
  border: 1px solid rgba(229,57,53,.4);
  color: #ffb3b2; font-size: 14px;
}
.alert.warn { background: rgba(242,180,0,.08); border-color: rgba(242,180,0,.4); color: #ffdd80; }
.alert.ok   { background: rgba(60,168,25,.12); border-color: rgba(60,168,25,.45); color: #b7f098; }
.alert.info { background: rgba(59,130,246,.12); border-color: rgba(59,130,246,.45); color: #bfd8ff; }
.hint { margin-top: 20px; color: var(--texto-2); font-size: 13px; }

/* ------- Badges ------- */
.badge {
  display: inline-block; padding: 2px 10px;
  font-size: 12px; font-weight: 600; border-radius: 999px;
  background: var(--card-2); color: var(--texto-2);
  border: 1px solid var(--borda);
}
.badge.ok      { background: rgba(60,168,25,.15); color: #8fd668; border-color: rgba(60,168,25,.4); }
.badge.warn    { background: rgba(242,180,0,.12); color: #ffdd80; border-color: rgba(242,180,0,.4); }
.badge.danger  { background: rgba(229,57,53,.12); color: #ffb3b2; border-color: rgba(229,57,53,.4); }
.badge.info    { background: rgba(59,130,246,.15); color: #bfd8ff; border-color: rgba(59,130,246,.4); }

/* ------- Stat cards ------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px,1fr)); gap: 10px; margin-top: 12px; }
.stat {
  background: var(--card);
  border: 1px solid var(--borda);
  border-radius: var(--r);
  padding: 14px;
}
.stat .label { font-size: 12px; color: var(--texto-2); text-transform: uppercase; letter-spacing: .5px; }
.stat .value { font-size: 24px; font-weight: 700; margin-top: 4px; }
.stat .trend { font-size: 12px; margin-top: 4px; }
.stat .trend.up   { color: #8fd668; }
.stat .trend.down { color: #ffb3b2; }

/* ------- Lista de itens (task, funcionário, setor…) ------- */
.list { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-direction: column; gap: 10px; }
.item {
  display: flex; align-items: center; gap: 12px;
  background: var(--card);
  border: 1px solid var(--borda);
  border-radius: var(--r);
  padding: 14px;
  min-height: 64px;
  text-decoration: none; color: inherit;
  transition: background 120ms, transform 80ms;
}
.item:hover, .item:focus-visible { background: var(--card-2); }
.item:active { transform: scale(.99); }
.item .main { flex: 1; min-width: 0; }
.item .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .sub { color: var(--texto-2); font-size: 13px; margin-top: 2px; }
.item .right { color: var(--texto-2); font-size: 13px; text-align: right; }

/* item concluído */
.item.done { opacity: .6; }
.item.done .title { text-decoration: line-through; text-decoration-color: var(--texto-2); }

/* Radio list (reaproveitado) */
.list-radio { list-style: none; padding: 0; margin: 16px 0 0; }
.list-radio li { margin-bottom: 10px; }
.list-radio label {
  display: flex; align-items: center; gap: 10px;
  padding: 14px; border: 1px solid var(--borda); border-radius: 10px;
  background: #0B0D12; cursor: pointer;
}
.list-radio input[type="radio"] { accent-color: var(--verde); width: 20px; height: 20px; }

/* ------- Bottom navigation (gestor / admin) ------- */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  background: var(--card);
  border-top: 1px solid var(--borda);
  padding-bottom: env(safe-area-inset-bottom);
  height: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom));
}
.bottom-nav a {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--texto-2); text-decoration: none; font-size: 11px; gap: 2px;
  min-height: 48px;
}
.bottom-nav a .icon { font-size: 20px; line-height: 1; }
.bottom-nav a.active { color: var(--verde-2); }
.bottom-nav a:active { background: var(--card-2); }

/* ------- Skeleton loading (feedback imediato) ------- */
.skel {
  background: linear-gradient(90deg, #1a1d24 25%, #23272f 37%, #1a1d24 63%);
  background-size: 400% 100%;
  animation: skel 1.4s ease-in-out infinite;
  border-radius: var(--r-sm);
}
.skel.h-16 { height: 16px; }
.skel.h-24 { height: 24px; }
.skel.h-64 { height: 64px; }
.skel.w-50 { width: 50%; }
.skel + .skel { margin-top: 10px; }
@keyframes skel {
  0%   { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

/* ------- Modal (bloqueante) ------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,.72);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.modal {
  width: 100%; max-width: 480px;
  background: var(--card);
  border: 1px solid var(--borda);
  border-radius: var(--r);
  padding: 20px;
  max-height: 90vh; overflow: auto;
}
.modal h2 { margin: 0 0 8px; font-size: 18px; }

/* ------- Check animado ao concluir ------- */
.check-anim {
  width: 72px; height: 72px; border-radius: 50%;
  background: var(--verde); display: flex; align-items: center; justify-content: center;
  margin: 16px auto;
  animation: pop 300ms cubic-bezier(.2,1.2,.3,1);
}
.check-anim svg { width: 38px; height: 38px; }
@keyframes pop { from { transform: scale(.2); opacity: 0 } to { transform: scale(1); opacity: 1 } }

/* ------- Câmera ------- */
.camera-wrap {
  position: fixed; inset: 0; z-index: 90;
  background: #000; display: flex; flex-direction: column;
}
.camera-video, .camera-preview {
  flex: 1; width: 100%; object-fit: cover; background: #000;
}
.camera-bar {
  display: flex; align-items: center; justify-content: space-around;
  padding: 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
  background: #000;
}
.camera-shoot {
  width: 72px; height: 72px; border-radius: 50%;
  background: #fff; border: 4px solid rgba(60,168,25,.9);
  cursor: pointer;
}
.camera-close {
  color: #fff; background: none; border: 0; font-size: 16px; padding: 12px; cursor: pointer;
}

/* Offline indicator */
.offline-banner {
  position: fixed; left: 0; right: 0; top: 0; z-index: 200;
  background: var(--aviso); color: #000;
  text-align: center; padding: 8px; font-weight: 600; font-size: 13px;
}

/* Tabs simples */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--borda); margin-top: 8px; }
.tabs a {
  flex: 1; text-align: center; padding: 12px; text-decoration: none;
  color: var(--texto-2); font-weight: 500;
  border-bottom: 2px solid transparent;
}
.tabs a.active { color: var(--verde-2); border-bottom-color: var(--verde-2); }
