*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --laranja:       #E8611A;
  --laranja-dark:  #C04A0A;
  --laranja-light: #FDE8D8;
  --preto:         #111111;
  --cinza-bg:      #F4F4F4;
  --cinza-card:    #FFFFFF;
  --texto:         #222222;
  --texto-sub:     #666666;
  --verde:         #2ECC71;
  --vermelho:      #E74C3C;
  --amarelo:       #F39C12;
  --radius:        14px;
  --sombra:        0 2px 16px rgba(0,0,0,0.10);
}

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--cinza-bg);
  color: var(--texto);
  min-height: 100vh;
  max-width: 480px;
  margin: 0 auto;
}

/* ── Ecrãs ── */
.screen { display: none; min-height: 100vh; flex-direction: column; }
.screen.active { display: flex; }

/* ── Header ── */
.app-header {
  background: var(--preto);
  color: white;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}
.app-header .logo { height: 32px; }
.app-header h1 { font-size: 16px; font-weight: 600; flex: 1; text-align: center; }
.btn-icon { background: none; border: none; color: white; cursor: pointer; padding: 4px; font-size: 20px; }

/* ── Status bar ── */
.status-bar {
  padding: 6px 20px;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  letter-spacing: 0.5px;
}
.status-bar.online  { background: #d4edda; color: #155724; }
.status-bar.offline { background: #fff3cd; color: #856404; }

/* ── Login ── */
.login-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  background: var(--preto);
}
.login-logo { width: 140px; margin-bottom: 32px; }
.login-title { color: white; font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.login-sub { color: #aaa; font-size: 13px; margin-bottom: 40px; }
.login-form { width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: 14px; }
.input-group { display: flex; flex-direction: column; gap: 6px; }
.input-group label { color: #ccc; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.input-group input {
  padding: 14px 16px;
  border-radius: 10px;
  border: 1.5px solid #333;
  background: #1a1a1a;
  color: white;
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s;
}
.input-group input:focus { border-color: var(--laranja); }
.login-error { color: #ff6b6b; font-size: 13px; text-align: center; min-height: 18px; }

/* ── Botões ── */
.btn {
  padding: 15px 24px;
  border-radius: var(--radius);
  border: none;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary  { background: var(--laranja); color: white; }
.btn-primary:hover:not(:disabled)  { background: var(--laranja-dark); }
.btn-secondary { background: white; color: var(--laranja); border: 2px solid var(--laranja); }
.btn-danger   { background: var(--vermelho); color: white; }
.btn-success  { background: var(--verde); color: white; }
.btn-full     { width: 100%; }
.btn-sm       { padding: 9px 16px; font-size: 13px; border-radius: 9px; }

/* ── Dashboard ── */
.dashboard-body { flex: 1; padding: 20px; display: flex; flex-direction: column; gap: 16px; }

.card {
  background: var(--cinza-card);
  border-radius: var(--radius);
  box-shadow: var(--sombra);
  padding: 20px;
}
.card-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px; color: var(--texto-sub); margin-bottom: 14px; }

/* ── Card utilizador ── */
.user-card { background: var(--preto); color: white; }
.user-name  { font-size: 20px; font-weight: 700; }
.user-role  { font-size: 13px; color: #aaa; margin-top: 2px; }
.user-date  { font-size: 12px; color: var(--laranja); margin-top: 8px; font-weight: 600; }

/* ── Estado do registo ── */
.registo-estado {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 14px;
}
.registo-estado.sem-registo  { background: var(--cinza-bg); color: var(--texto-sub); }
.registo-estado.checked-in   { background: #d4edda; color: #155724; }
.registo-estado.checked-out  { background: #cce5ff; color: #004085; }
.estado-icon { font-size: 24px; }
.estado-info { display: flex; flex-direction: column; }
.estado-hora { font-size: 12px; font-weight: 400; opacity: 0.8; }

/* ── Modos de trabalho ── */
.modos-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.modo-btn {
  padding: 16px 8px;
  border-radius: 12px;
  border: 2px solid #eee;
  background: white;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.modo-btn:hover { border-color: var(--laranja); background: var(--laranja-light); }
.modo-btn.selected { border-color: var(--laranja); background: var(--laranja-light); }
.modo-btn .modo-icon { font-size: 26px; }
.modo-btn .modo-label { font-size: 11px; font-weight: 700; color: var(--texto); line-height: 1.2; }

/* ── Select actividade ── */
.form-select {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1.5px solid #ddd;
  font-size: 14px;
  background: white;
  color: var(--texto);
  outline: none;
}
.form-select:focus { border-color: var(--laranja); }

/* ── QR Scanner ── */
.qr-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.95);
  z-index: 200;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.qr-overlay.active { display: flex; }
.qr-title { color: white; font-size: 18px; font-weight: 700; margin-bottom: 8px; }
.qr-sub { color: #aaa; font-size: 13px; margin-bottom: 24px; text-align: center; }
#qr-video { width: 280px; height: 280px; border-radius: 16px; object-fit: cover; border: 3px solid var(--laranja); }
.qr-frame {
  position: relative;
  width: 280px;
  height: 280px;
  margin-bottom: 24px;
}
.qr-corner {
  position: absolute;
  width: 30px;
  height: 30px;
  border-color: var(--laranja);
  border-style: solid;
}
.qr-corner.tl { top: -3px; left: -3px; border-width: 4px 0 0 4px; }
.qr-corner.tr { top: -3px; right: -3px; border-width: 4px 4px 0 0; }
.qr-corner.bl { bottom: -3px; left: -3px; border-width: 0 0 4px 4px; }
.qr-corner.br { bottom: -3px; right: -3px; border-width: 0 4px 4px 0; }
.qr-status { color: white; font-size: 14px; min-height: 20px; margin-bottom: 20px; }

/* ── Sync badge ── */
.sync-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}
.sync-badge.pendente    { background: #fff3cd; color: #856404; }
.sync-badge.sincronizado { background: #d4edda; color: #155724; }
.sync-badge.erro        { background: #f8d7da; color: #721c24; }

/* ── Histórico ── */
.historico-list { display: flex; flex-direction: column; gap: 10px; }
.historico-item {
  background: white;
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: 0 1px 6px rgba(0,0,0,0.07);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.hist-data { font-size: 13px; font-weight: 700; color: var(--texto); }
.hist-horas { font-size: 12px; color: var(--texto-sub); margin-top: 2px; }
.hist-modo {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 20px;
  text-transform: uppercase;
}
.hist-modo.escritorio { background: var(--laranja-light); color: var(--laranja-dark); }
.hist-modo.remoto     { background: #cce5ff; color: #004085; }
.hist-modo.campo      { background: #d4edda; color: #155724; }

/* ── Nav bottom ── */
.bottom-nav {
  background: white;
  border-top: 1px solid #eee;
  display: flex;
  position: sticky;
  bottom: 0;
}
.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 0;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 10px;
  font-weight: 600;
  color: var(--texto-sub);
  gap: 3px;
  transition: color 0.2s;
}
.nav-item .nav-icon { font-size: 22px; }
.nav-item.active { color: var(--laranja); }

/* ── Loading spinner ── */
.spinner {
  width: 22px; height: 22px;
  border: 3px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Toast ── */
.toast-container { position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%); z-index: 300; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  color: white;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  animation: fadeInUp 0.3s ease;
  white-space: nowrap;
}
.toast.success { background: var(--verde); }
.toast.error   { background: var(--vermelho); }
.toast.info    { background: var(--preto); }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.hist-extra {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 4px;
}
.hist-act {
  font-size: 12px;
  color: #E8821A;
  font-weight: 500;
}
.hist-obs {
  font-size: 12px;
  color: #888;
  font-style: italic;
}