:root {
  --bg: #0b1020;
  --bg2: #10172b;
  --panel: #131b31;
  --panel2: #18213a;
  --line: rgba(148, 163, 214, 0.13);
  --line-strong: rgba(148, 163, 214, 0.26);
  --text: #eef1fb;
  --muted: #95a0c0;
  --dim: #66708f;
  --amber: #fbbf24;
  --orange: #f97316;
  --ok: #34d399;
  --info: #60a5fa;
  --warn: #fbbf24;
  --danger: #fb7185;
  --grad: linear-gradient(120deg, var(--amber), var(--orange));
  --radius: 16px;
  --radius-sm: 10px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --display: 'Space Grotesk', var(--font);
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: radial-gradient(900px 600px at 100% -10%, #2a1d0c 0%, transparent 60%), var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { font-family: var(--display); letter-spacing: -.02em; margin: 0; line-height: 1.2; }
h1 { font-size: 26px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }
.grad-text { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
svg.i { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.hidden { display: none !important; }

.boot { min-height: 100vh; display: grid; place-items: center; }
.boot-logo { width: 64px; height: 64px; border-radius: 18px; background: url(/icons/icon-192.png) center/cover; animation: pulse 1.2s var(--ease) infinite; }
@keyframes pulse { 50% { transform: scale(.9); opacity: .7; } }
.page { animation: page .35s var(--ease); }
@keyframes page { from { opacity: 0; transform: translateY(8px); } }

/* ---------- botões e campos ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 0 16px;
  border-radius: var(--radius-sm); border: 1px solid var(--line-strong); background: var(--panel2); cursor: pointer;
  font-weight: 600; font-size: 14px; white-space: nowrap; transition: background .15s, border-color .15s, transform .1s;
}
.btn:hover { border-color: rgba(251, 191, 36, .5); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--grad); border: 0; color: #1b1203; }
.btn.danger { color: var(--danger); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--panel2); }
.btn.sm { min-height: 34px; padding: 0 12px; font-size: 13px; }
.btn.icon { padding: 0; width: 40px; }
label.field { display: grid; gap: 6px; font-size: 13px; color: var(--muted); font-weight: 500; }
label.field.full { grid-column: 1 / -1; }
.field .hint { font-size: 12px; color: var(--dim); font-weight: 400; }
input, select, textarea {
  width: 100%; min-height: 42px; padding: 9px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: var(--bg2); color: var(--text); outline: none;
}
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--amber); box-shadow: 0 0 0 3px rgba(251, 191, 36, .15); }
input[type=checkbox] { width: 20px; min-height: 20px; accent-color: var(--amber); }
label.check { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--text); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; } }
.error-box { background: rgba(251, 113, 133, .1); border: 1px solid rgba(251, 113, 133, .35); color: #fecdd3; padding: 10px 12px; border-radius: var(--radius-sm); font-size: 14px; }

/* ---------- layout da equipe ---------- */
.shell { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; padding: 20px 14px; border-right: 1px solid var(--line);
  background: rgba(11, 16, 32, .7); display: flex; flex-direction: column; gap: 4px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.brand img { width: 36px; height: 36px; border-radius: 10px; }
.brand b { font: 700 19px var(--display); letter-spacing: -.02em; }
.brand span { display: block; font-size: 11px; color: var(--dim); }
.nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius-sm); color: var(--muted); font-weight: 500; }
.nav a:hover { background: var(--panel); color: var(--text); }
.nav a.on { background: rgba(251, 191, 36, .12); color: var(--amber); }
.side .me { margin-top: auto; padding: 12px; border-top: 1px solid var(--line); font-size: 13px; }
.main { padding: 28px 32px 80px; max-width: 1240px; width: 100%; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.head p { margin: 4px 0 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.topbar, .tabbar { display: none; }
@media (max-width: 900px) {
  .shell { display: block; }
  .side { display: none; }
  .main { padding: 16px 16px calc(96px + var(--safe-b)); }
  .topbar { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; background: rgba(11, 16, 32, .92); backdrop-filter: blur(10px); }
  .topbar .brand { padding: 0; }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
    padding: 6px 4px calc(6px + var(--safe-b)); background: rgba(11, 16, 32, .96); border-top: 1px solid var(--line); backdrop-filter: blur(10px);
  }
  .tabbar a { display: grid; justify-items: center; gap: 2px; font-size: 11px; color: var(--dim); padding: 6px 0; }
  .tabbar a.on { color: var(--amber); }
  h1 { font-size: 22px; }
}

/* ---------- cartões ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.card + .card { margin-top: 14px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.grid { display: grid; gap: 14px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cards { grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }
@media (max-width: 900px) { .grid.two { grid-template-columns: 1fr; } }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
@media (max-width: 900px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat b { display: block; font: 700 28px var(--display); letter-spacing: -.02em; }
.stat span { font-size: 13px; color: var(--muted); }
.stat.hot b { color: var(--ok); }
.stat.alert b { color: var(--warn); }

.list { display: grid; }
.row { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-top: 1px solid var(--line); }
.row:first-child { border-top: 0; }
.row .grow { flex: 1; min-width: 0; }
.row .title { font-weight: 600; }
.row .sub { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.empty { color: var(--dim); padding: 18px 0; text-align: center; font-size: 14px; }
.avatar { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 14px; flex: none; background: rgba(251, 191, 36, .14); color: var(--amber); }
.avatar.on { background: rgba(52, 211, 153, .15); color: var(--ok); box-shadow: 0 0 0 2px rgba(52, 211, 153, .35); }

.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--panel2); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.pill.ok { color: var(--ok); background: rgba(52, 211, 153, .1); border-color: rgba(52, 211, 153, .3); }
.pill.warn { color: var(--warn); background: rgba(251, 191, 36, .1); border-color: rgba(251, 191, 36, .3); }
.pill.danger { color: var(--danger); background: rgba(251, 113, 133, .1); border-color: rgba(251, 113, 133, .3); }
.pill.info { color: var(--info); background: rgba(96, 165, 250, .1); border-color: rgba(96, 165, 250, .3); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.dot.live { animation: live 1.6s infinite; }
@keyframes live { 0% { box-shadow: 0 0 0 0 rgba(52, 211, 153, .6); } 100% { box-shadow: 0 0 0 8px rgba(52, 211, 153, 0); } }

.entity h3 { font-size: 16px; }
.entity .meta { display: grid; gap: 3px; margin: 10px 0 12px; font-size: 13px; color: var(--muted); }
.entity .meta div { overflow-wrap: anywhere; }
.entity.off { opacity: .55; }
.post { display: flex; gap: 10px; align-items: center; padding: 10px 12px; margin-top: 8px; background: var(--bg2); border: 1px solid var(--line); border-radius: var(--radius-sm); }

.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; }
.filters label.field { min-width: 150px; flex: 1; }

/* ---------- tabelas ---------- */
.table-wrap { overflow-x: auto; margin: 0 -18px; padding: 0 18px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; color: var(--dim); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; padding: 8px 10px; border-bottom: 1px solid var(--line-strong); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
td.r, th.r { text-align: right; }
tr.void td { opacity: .45; text-decoration: line-through; }
tr.void td.keep { text-decoration: none; }
tfoot td { font-weight: 700; border-bottom: 0; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: min(400px, 100%); padding: 32px 28px; }
.login-card .logo { width: 72px; height: 72px; border-radius: 20px; display: block; margin: 0 auto 16px; box-shadow: 0 10px 40px rgba(249, 115, 22, .25); }
.login-card h1 { text-align: center; }
.login-card p { text-align: center; margin: 6px 0 22px; }
.login-card form { display: grid; gap: 14px; }

/* ---------- tela do vigilante ---------- */
.punch { max-width: 520px; margin: 0 auto; padding: 16px 16px calc(40px + var(--safe-b)); display: grid; gap: 14px; }
.punch-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.clock { text-align: center; padding: 8px 0 0; }
.clock b { display: block; font: 700 54px/1 var(--display); letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.clock span { display: inline-block; color: var(--muted); font-size: 14px; }
.clock span::first-letter { text-transform: uppercase; }
.state { text-align: center; padding: 20px 16px; }
.state .big { font: 600 20px var(--display); }
.state.on { border-color: rgba(52, 211, 153, .35); background: linear-gradient(180deg, rgba(52, 211, 153, .08), var(--panel)); }
.state .timer { font: 700 34px var(--display); color: var(--ok); font-variant-numeric: tabular-nums; margin-top: 4px; }
.punch-btn {
  width: 100%; min-height: 88px; border-radius: 22px; border: 0; cursor: pointer; font: 700 22px var(--display); letter-spacing: -.01em;
  display: flex; align-items: center; justify-content: center; gap: 12px; color: #1b1203; background: var(--grad);
  box-shadow: 0 14px 40px rgba(249, 115, 22, .28); transition: transform .1s, opacity .2s;
}
.punch-btn.out { background: linear-gradient(120deg, #fb7185, #f43f5e); color: #fff; box-shadow: 0 14px 40px rgba(244, 63, 94, .28); }
.punch-btn:active { transform: scale(.98); }
.punch-btn:disabled { opacity: .55; }
.punch-btn svg.i { width: 28px; height: 28px; stroke-width: 2.2; }
.geo { display: flex; gap: 12px; align-items: center; font-size: 14px; }
.geo .grow { flex: 1; }
.geo-ico { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--panel2); flex: none; }
.geo.ok .geo-ico { color: var(--ok); background: rgba(52, 211, 153, .12); }
.geo.far .geo-ico { color: var(--warn); background: rgba(251, 191, 36, .12); }
.geo.err .geo-ico { color: var(--danger); background: rgba(251, 113, 133, .12); }
.spin { width: 22px; height: 22px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, .25); border-top-color: currentColor; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- modal e avisos ---------- */
.modal-bg { position: fixed; inset: 0; z-index: 50; background: rgba(3, 6, 15, .72); backdrop-filter: blur(4px); display: grid; place-items: center; padding: 16px; animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.modal { width: min(620px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: var(--panel); border: 1px solid var(--line-strong); border-radius: 20px; padding: 22px; animation: page .25s var(--ease); }
.modal.narrow { width: min(440px, 100%); }
.modal h2 { margin-bottom: 4px; }
.modal form { display: grid; gap: 16px; margin-top: 16px; }
.modal .foot { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
@media (max-width: 560px) {
  .modal-bg { place-items: end stretch; padding: 0; }
  .modal { width: 100%; border-radius: 20px 20px 0 0; max-height: 92vh; padding-bottom: calc(22px + var(--safe-b)); }
}
.secret { font: 600 18px ui-monospace, Consolas, monospace; background: var(--bg2); border: 1px dashed var(--line-strong); border-radius: var(--radius-sm); padding: 12px; text-align: center; user-select: all; letter-spacing: .04em; }
#toasts { position: fixed; z-index: 60; left: 50%; bottom: calc(90px + var(--safe-b)); transform: translateX(-50%); display: grid; gap: 8px; width: min(420px, calc(100% - 32px)); pointer-events: none; }
.toast { background: var(--panel2); border: 1px solid var(--line-strong); border-radius: 12px; padding: 12px 14px; font-size: 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, .4); animation: page .25s var(--ease); }
.toast.ok { border-color: rgba(52, 211, 153, .5); }
.toast.err { border-color: rgba(251, 113, 133, .5); }

/* ---------- impressão do relatório ---------- */
.print-only { display: none; }
@media print {
  @page { size: A4; margin: 14mm 12mm; }
  body { background: #fff; color: #111; font-size: 11px; }
  .side, .topbar, .tabbar, .no-print, #toasts { display: none !important; }
  .shell { display: block; }
  .main { padding: 0; max-width: none; }
  .card { background: #fff; border: 0; padding: 0; }
  .print-only { display: block; }
  .pill { border: 1px solid #999; color: #111; background: none; }
  th { color: #444; border-color: #999; }
  td { border-color: #ddd; padding: 5px 6px; }
  .table-wrap { overflow: visible; margin: 0; padding: 0; }
  .muted, .dim { color: #555; }
  h1, h2 { color: #111; }
  .sign { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; margin-top: 60px; }
  .sign div { border-top: 1px solid #111; padding-top: 6px; text-align: center; }
}
