:root {
  --primary: #0f766e;
  --primary-dark: #0d9488;
  --danger: #dc2626;
  --bg: #f0fdfa;
  --card: #ffffff;
  --text: #134e4a;
  --border: #99f6e4;
  --muted: #64748b;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: 70px;
}

#app { max-width: 480px; margin: 0 auto; }

/* Header */
.header {
  background: linear-gradient(135deg, #0f766e, #0d9488);
  color: white;
  padding: 12px 14px 10px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.header-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.header h1 { font-size: 1.15rem; font-weight: 700; }
.status {
  display: flex; align-items: center; gap: 6px;
  font-size: 0.75rem; background: rgba(255,255,255,0.15);
  padding: 3px 8px; border-radius: 16px;
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: #fbbf24; animation: pulse 1.5s infinite; }
.dot.ok { background: #4ade80; animation: none; }
.dot.error { background: #f87171; animation: none; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.4} }
.header-info { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.coords { font-size: 0.7rem; opacity: 0.9; font-family: ui-monospace, monospace; }
.worker-badge {
  font-size: 0.7rem; background: rgba(255,255,255,0.2);
  padding: 2px 8px; border-radius: 10px; white-space: nowrap;
}

/* Bottom nav */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  max-width: 480px; margin: 0 auto;
  display: flex; background: white;
  border-top: 1px solid var(--border);
  z-index: 200; box-shadow: 0 -2px 10px rgba(0,0,0,0.06);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.nav-btn {
  flex: 1 0 auto; min-width: 56px; border: none; background: none;
  padding: 8px 4px 6px; font-size: 1.05rem;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: var(--muted); cursor: pointer;
}
.nav-btn span { font-size: 0.58rem; font-weight: 600; white-space: nowrap; }
.nav-btn.active { color: var(--primary); }

/* Screens */
.screen { display: none; padding: 12px; flex-direction: column; gap: 12px; }
.screen.active { display: flex; }

/* Cards */
.card {
  background: var(--card); border-radius: 12px; padding: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06); border: 1px solid var(--border);
}
.card h3 { font-size: 0.95rem; margin-bottom: 10px; color: var(--primary); }

.stats-card {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px;
  text-align: center; padding: 10px 6px;
}
.stat-value { font-size: 1.1rem; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 0.65rem; color: var(--muted); }

.map-card { padding: 0; overflow: hidden; height: 200px; }
#map { width: 100%; height: 200px; background: #e0f2f1; }

/* Buttons */
.btn-row { display: flex; gap: 8px; margin-bottom: 8px; }
.btn-row:last-child { margin-bottom: 0; }
.btn {
  flex: 1; padding: 11px 10px; border-radius: 8px; border: none;
  font-size: 0.88rem; font-weight: 600; cursor: pointer;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-secondary { background: #e0f2f1; color: var(--primary); }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-danger-outline { background: transparent; border: 1px solid #fecaca; color: var(--danger); }
.btn-lg { padding: 13px; font-size: 0.95rem; }
.btn-block { width: 100%; margin-top: 6px; }

/* Forms */
.form-group { margin-bottom: 10px; }
.form-group label { display: block; font-size: 0.8rem; font-weight: 600; margin-bottom: 4px; color: var(--muted); }
.form-row { display: flex; gap: 8px; }
input[type="text"], input[type="number"], select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 0.9rem; background: white; color: var(--text);
}
.full-select { width: 100%; padding: 10px; border-radius: 8px; border: 1px solid var(--border); }

.hint { font-size: 0.78rem; color: var(--muted); text-align: center; margin-top: 6px; }
.result-box {
  background: #f0fdfa; border: 1px dashed var(--primary); border-radius: 8px;
  padding: 10px; text-align: center; font-weight: 600; color: var(--primary);
  margin-top: 8px; font-size: 0.9rem;
}
.report-box {
  margin-top: 12px; background: #f8fafc; border-radius: 8px; padding: 12px;
  font-size: 0.85rem; white-space: pre-wrap; max-height: 320px; overflow-y: auto;
}

/* Lists */
.list { max-height: 220px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.list-item {
  background: #f0fdfa; border-radius: 8px; padding: 9px 11px;
  font-size: 0.82rem; display: flex; justify-content: space-between; align-items: flex-start; gap: 8px;
}
.list-item .meta { font-size: 0.72rem; color: var(--muted); margin-top: 2px; }
.list-item button { background: none; border: none; color: var(--danger); font-size: 0.75rem; cursor: pointer; flex-shrink: 0; }

/* Worker mode: chỉ ẩn tab Báo cáo, vẫn giữ Cài đặt để đổi lại chế độ Quản lý */
body.worker-mode .nav-btn[data-screen="report"] { display: none; }

@media (max-width: 380px) {
  .stats-card { grid-template-columns: repeat(2, 1fr); }
  .nav-btn span { font-size: 0.55rem; }
}
