/* ===== CSS Variables ===== */
:root {
  --primary: #1a73e8;
  --primary-dark: #1558b0;
  --primary-light: #e8f0fe;
  --success: #1e8e3e;
  --success-light: #e6f4ea;
  --danger: #d93025;
  --danger-light: #fce8e6;
  --warning: #f9ab00;
  --warning-light: #fef7e0;
  --text: #202124;
  --text-secondary: #5f6368;
  --border: #dadce0;
  --bg: #f8f9fa;
  --white: #ffffff;
  --shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.15);
  --radius: 8px;
  --nav-height: 60px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow-x: hidden;
}

body {
  font-family: var(--font);
  font-size: 16px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

/* ===== App Container ===== */
#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--white);
  padding-bottom: calc(var(--nav-height) + 16px);
  position: relative;
}

/* ===== Page Header ===== */
.page-header {
  background: var(--primary);
  color: var(--white);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.page-title {
  font-size: 20px;
  font-weight: 500;
  flex: 1;
}

.page-subtitle {
  font-size: 13px;
  opacity: 0.85;
}

/* ===== Bottom Navigation ===== */
#bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  height: var(--nav-height);
  background: var(--white);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: stretch;
  z-index: 200;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.08);
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 500;
  padding: 4px 2px;
  transition: color 0.15s;
  cursor: pointer;
  border: none;
  background: none;
  position: relative;
}

.nav-item svg { width: 22px; height: 22px; }

.nav-item.active {
  color: var(--primary);
}

.nav-item.active svg { stroke: var(--primary); }

.nav-badge {
  position: absolute;
  top: 4px;
  right: calc(50% - 18px);
  background: var(--danger);
  color: var(--white);
  font-size: 10px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

/* ===== Cards ===== */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin: 12px 16px;
  box-shadow: var(--shadow);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  text-decoration: none;
  white-space: nowrap;
}

.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-primary {
  background: var(--primary);
  color: var(--white);
}

.btn-primary:hover { background: var(--primary-dark); }

.btn-success {
  background: var(--success);
  color: var(--white);
}

.btn-danger {
  background: var(--danger);
  color: var(--white);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-outline:hover { background: var(--bg); }

.btn-ghost {
  background: transparent;
  color: var(--primary);
  padding: 8px 12px;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

.btn-block {
  width: 100%;
}

/* ===== Big Ponto Button ===== */
.btn-ponto {
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--white);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 1px;
  border: none;
  cursor: pointer;
  box-shadow: 0 6px 24px rgba(26,115,232,0.4);
  transition: transform 0.15s, box-shadow 0.15s;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-transform: uppercase;
  font-family: var(--font);
}

.btn-ponto:active {
  transform: scale(0.95);
  box-shadow: 0 2px 12px rgba(26,115,232,0.3);
}

.btn-ponto:disabled {
  background: var(--text-secondary);
  box-shadow: none;
  cursor: not-allowed;
}

.btn-ponto svg { width: 40px; height: 40px; }

/* ===== Forms ===== */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-control {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 16px;
  font-family: var(--font);
  color: var(--text);
  background: var(--white);
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26,115,232,0.12);
}

.form-control::placeholder { color: #aaa; }

select.form-control { cursor: pointer; }

/* ===== Badges ===== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.badge-valid {
  background: var(--success-light);
  color: var(--success);
}

.badge-warning {
  background: var(--warning-light);
  color: #b06000;
}

.badge-danger {
  background: var(--danger-light);
  color: var(--danger);
}

.badge-in {
  background: var(--success-light);
  color: var(--success);
}

.badge-out {
  background: var(--primary-light);
  color: var(--primary-dark);
}

/* ===== List Items ===== */
.list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}

.list-item:last-child { border-bottom: none; }
.list-item:hover { background: var(--bg); }

.list-item-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.list-item-icon.in-icon {
  background: var(--success-light);
  color: var(--success);
}

.list-item-icon.out-icon {
  background: var(--primary-light);
  color: var(--primary);
}

.list-item-content { flex: 1; min-width: 0; }

.list-item-title {
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-item-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.list-item-meta {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  text-align: right;
  flex-shrink: 0;
}

/* ===== Toast ===== */
#toast {
  position: fixed;
  bottom: calc(var(--nav-height) + 16px);
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  max-width: 400px;
  width: calc(100% - 32px);
  background: #323232;
  color: var(--white);
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  z-index: 999;
  transition: transform 0.3s ease;
  text-align: center;
  pointer-events: none;
}

#toast.show {
  transform: translateX(-50%) translateY(0);
}

#toast.toast-success { background: var(--success); }
#toast.toast-error { background: var(--danger); }
#toast.toast-warning { background: var(--warning); color: var(--text); }

/* ===== Tabs ===== */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
}

.tab-item {
  flex: 1;
  padding: 12px;
  text-align: center;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  border: none;
  background: none;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  font-family: var(--font);
  transition: color 0.15s;
}

.tab-item.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* ===== Section Headers ===== */
.section-header {
  padding: 8px 16px 4px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-secondary);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

/* ===== Status / Info ===== */
.status-text {
  text-align: center;
  padding: 16px;
  font-size: 14px;
  color: var(--text-secondary);
}

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-secondary);
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: 12px;
  display: block;
}

.empty-state-text {
  font-size: 16px;
  font-weight: 500;
  margin-bottom: 8px;
}

.empty-state-hint { font-size: 14px; }

/* ===== Home View ===== */
.home-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px 24px;
  gap: 24px;
}

.home-status {
  font-size: 15px;
  color: var(--text-secondary);
  text-align: center;
}

.home-last-record {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 20px;
  text-align: center;
  width: 100%;
}

.home-flow-status {
  width: 100%;
  background: var(--primary-light);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  font-size: 14px;
  color: var(--primary-dark);
  font-weight: 500;
}

/* ===== Camera Overlay ===== */
.camera-overlay {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 500;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.camera-overlay video {
  width: 100%;
  max-width: 480px;
  height: 100vh;
  object-fit: cover;
}

.camera-controls {
  position: absolute;
  bottom: 32px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  gap: 16px;
}

.camera-label {
  position: absolute;
  top: 24px;
  left: 0;
  right: 0;
  text-align: center;
  color: white;
  font-size: 18px;
  font-weight: 600;
  text-shadow: 0 1px 4px rgba(0,0,0,0.5);
}

.camera-countdown {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 80px;
  font-weight: 700;
  color: white;
  text-shadow: 0 2px 8px rgba(0,0,0,0.5);
}

.qr-guide {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 240px;
  height: 240px;
  border: 3px solid rgba(255,255,255,0.8);
  border-radius: 12px;
  box-shadow: 0 0 0 4000px rgba(0,0,0,0.4);
}

/* ===== Timesheet Table ===== */
.timesheet-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.timesheet-table th {
  background: var(--bg);
  padding: 10px 8px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  border-bottom: 2px solid var(--border);
}

.timesheet-table td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.timesheet-table tr:last-child td { border-bottom: none; }
.timesheet-table tr.weekend td { background: var(--bg); color: var(--text-secondary); }
.timesheet-table .total-row td { font-weight: 700; background: var(--primary-light); }

/* ===== Invite Box ===== */
.invite-box {
  background: var(--success-light);
  border: 1px solid var(--success);
  border-radius: var(--radius);
  padding: 16px;
  margin: 12px 16px;
}

.invite-box-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--success);
  margin-bottom: 8px;
}

.invite-link {
  font-family: monospace;
  font-size: 13px;
  color: var(--text);
  word-break: break-all;
  background: rgba(255,255,255,0.7);
  padding: 8px;
  border-radius: 4px;
  margin-bottom: 8px;
}

.invite-pin {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 6px;
  text-align: center;
  color: var(--success);
  padding: 8px 0;
}

/* ===== PIN Input ===== */
.pin-display {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin: 24px 0;
}

.pin-digit {
  width: 52px;
  height: 64px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 28px;
  font-weight: 700;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  transition: border-color 0.15s;
}

.pin-digit.filled { border-color: var(--primary); }

.pin-input-hidden {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

/* ===== Loading Spinner ===== */
.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid rgba(255,255,255,0.3);
  border-top-color: var(--white);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}

.spinner-dark {
  border-color: rgba(26,115,232,0.2);
  border-top-color: var(--primary);
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Auth / Login Page ===== */
.auth-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 0;
  background: var(--white);
}

.auth-hero {
  background: var(--primary);
  color: var(--white);
  padding: 48px 24px 32px;
  text-align: center;
}

.auth-logo {
  font-size: 48px;
  margin-bottom: 12px;
}

.auth-title {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 6px;
}

.auth-tagline {
  font-size: 15px;
  opacity: 0.85;
}

.auth-body {
  padding: 24px 20px;
  flex: 1;
}

/* ===== Misc Utilities ===== */
.text-center { text-align: center; }
.text-muted { color: var(--text-secondary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-sm { font-size: 13px; }
.fw-bold { font-weight: 700; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.p-16 { padding: 16px; }
.flex { display: flex; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.divider {
  height: 1px;
  background: var(--border);
  margin: 16px 0;
}

/* ===== Notification Item ===== */
.notification-item {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
}

.notification-item:hover { background: var(--bg); }
.notification-item.unread { background: var(--primary-light); }

.notification-message {
  font-size: 15px;
  font-weight: 500;
  margin-bottom: 4px;
}

.notification-item.unread .notification-message { font-weight: 700; }

.notification-time {
  font-size: 12px;
  color: var(--text-secondary);
}

/* ===== Filter Bar ===== */
.filter-bar {
  padding: 12px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 8px;
  align-items: center;
}

.filter-bar .form-control {
  flex: 1;
  padding: 8px 12px;
  font-size: 14px;
}

/* ===== Confirm Banner ===== */
.confirm-banner {
  background: var(--warning-light);
  border-top: 3px solid var(--warning);
  padding: 16px;
  text-align: center;
}

.confirm-banner p {
  font-size: 14px;
  color: var(--text);
  margin-bottom: 12px;
}

/* ===== Danger Zone ===== */
.danger-zone {
  border: 1px solid var(--danger);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin: 8px 16px;
}

/* ===== GPS Auto-fill ===== */
.gps-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.gps-row .form-group { flex: 1; margin-bottom: 0; }
