/* Roanoke Excavating Field App — Matte Charcoal / Tri-Color Precision */
:root {
  --primary: #1a2332;
  --primary-light: #243044;
  --bg: #1c1f26;
  --bg-card: #252830;
  --bg-input: #2e3138;
  --text: #e8eaed;
  --text-light: #9aa0a6;
  --text-muted: #5f6368;
  --border: #363940;
  --shadow: 0 2px 12px rgba(0,0,0,0.4);

  /* Tri-Color Precision System */
  --safety-yellow: #f5c842;
  --safety-yellow-glow: rgba(245,200,66,0.15);
  --electric-cyan: #00d4ff;
  --electric-cyan-glow: rgba(0,212,255,0.15);
  --vibrant-emerald: #00c853;
  --vibrant-emerald-glow: rgba(0,200,83,0.15);

  /* Mapped to functions */
  --accent: var(--safety-yellow);
  --accent-hover: #d4a830;
  --success: var(--vibrant-emerald);
  --success-hover: #00a844;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --info: var(--electric-cyan);
  --warning: #f59e0b;
  --xp-gold: var(--safety-yellow);

  /* Gauge glow */
  --gauge-glow: var(--electric-cyan);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 18px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

/* Header — Instrument Panel Style */
.header {
  background: linear-gradient(180deg, #1a2332 0%, #151921 100%);
  color: white;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 16px rgba(0,0,0,0.6);
  border-bottom: 1px solid rgba(0,212,255,0.1);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-brand img {
  height: 36px;
  width: auto;
}

.header-brand h1 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.5px;
  line-height: 1.2;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-badge {
  background: var(--accent);
  color: white;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 700;
}

.xp-badge {
  background: linear-gradient(135deg, rgba(0,212,255,0.2), rgba(0,212,255,0.05));
  border: 1px solid rgba(0,212,255,0.4);
  color: var(--electric-cyan);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 800;
  text-shadow: 0 0 8px rgba(0,212,255,0.5);
}
.xp-badge.perfect {
  background: linear-gradient(135deg, rgba(245,200,66,0.25), rgba(245,200,66,0.05));
  border-color: var(--safety-yellow);
  color: var(--safety-yellow);
  text-shadow: 0 0 8px rgba(245,200,66,0.5);
}

.sync-badge {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 10px;
  font-weight: 600;
}
.sync-badge.online { background: rgba(39,174,96,0.3); color: #27ae60; }
.sync-badge.offline { background: rgba(231,76,60,0.3); color: #e74c3c; }

.btn-logout {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  color: white;
  padding: 5px 12px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
}

/* Container */
.container { max-width: 600px; margin: 0 auto; padding: 12px; }
.container.wide { max-width: 900px; }

/* Login Screen */
.login-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 80vh;
  padding: 20px;
}

.login-logo { height: 80px; margin-bottom: 16px; }

.login-screen h2 {
  font-size: 26px;
  color: var(--accent);
  margin-bottom: 6px;
}

.login-screen p {
  color: var(--text-light);
  margin-bottom: 20px;
  font-size: 15px;
}

.crew-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  width: 100%;
  max-width: 420px;
}

.crew-btn {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 18px 10px;
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
  transition: all 0.12s;
  text-align: center;
  box-shadow: var(--shadow);
}

.crew-btn:active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  transform: scale(0.96);
}

/* Cards */
.card {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}

.card h3 {
  font-size: 12px;
  color: var(--electric-cyan);
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 12px;
  font-weight: 700;
}
.card h3.yellow { color: var(--safety-yellow); }
.card h3.green { color: var(--vibrant-emerald); }

/* Status Banner */
.status-banner {
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
  text-align: center;
}

.status-banner.active {
  background: linear-gradient(135deg, #1a6b3c, #27ae60);
  color: white;
  border: 1px solid rgba(39,174,96,0.3);
}

.status-banner.inactive {
  background: var(--bg-card);
  border: 2px dashed var(--border);
  color: var(--text-light);
}

.status-banner .status-text { font-size: 18px; font-weight: 800; }
.status-banner .status-detail { font-size: 13px; margin-top: 2px; opacity: 0.9; }
.status-banner .status-time {
  font-size: 32px; font-weight: 800; margin-top: 4px;
  font-variant-numeric: tabular-nums;
}

/* Buttons — minimum 48x48 tap target */
.btn {
  display: block;
  width: 100%;
  padding: 16px 20px;
  border: none;
  border-radius: 12px;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.12s;
  text-align: center;
  min-height: 48px;
}

.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--safety-yellow); color: #1a1a1a; }
.btn-primary:active { background: var(--accent-hover); }
.btn-success { background: var(--vibrant-emerald); color: white; }
.btn-success:active { background: var(--success-hover); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:active { background: var(--danger-hover); }
.btn-cyan { background: var(--electric-cyan); color: #1a1a1a; font-weight: 800; }
.btn-cyan:active { background: #00b8d9; }
.btn-outline { background: transparent; color: var(--text); border: 2px solid var(--border); }
.btn-outline:active { background: var(--bg-input); }
.btn-xp {
  background: linear-gradient(135deg, #ffd700, #ffb800);
  color: #1a1a1a;
  font-weight: 800;
}
.btn + .btn { margin-top: 8px; }

/* Form Elements */
.form-group { margin-bottom: 12px; }

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

select, input, textarea {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid var(--border);
  border-radius: 10px;
  font-size: 16px;
  color: var(--text);
  background: var(--bg-input);
  -webkit-appearance: none;
  min-height: 48px;
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%239aa0a6' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  padding-right: 40px;
}

select:focus, input:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
}

textarea { resize: vertical; min-height: 70px; }

/* Log entries */
.log-entry {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.log-entry:last-child { border-bottom: none; }
.log-job { font-weight: 700; font-size: 15px; }
.log-time { font-size: 13px; color: var(--text-light); }
.log-hours { font-weight: 800; font-size: 17px; color: var(--accent); white-space: nowrap; }
.log-active { color: var(--success); font-size: 12px; font-weight: 700; }
.log-sync { font-size: 10px; color: var(--text-muted); }

/* Photo upload */
.photo-upload {
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.12s;
  color: var(--text-light);
}
.photo-upload:active { border-color: var(--accent); }
.photo-upload input[type="file"] { display: none; }
.photo-upload .upload-icon { font-size: 36px; margin-bottom: 6px; }

/* Voice note */
.voice-btn {
  background: var(--bg-input);
  border: 2px solid var(--border);
  border-radius: 50%;
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  cursor: pointer;
  margin: 0 auto;
  transition: all 0.12s;
}
.voice-btn:active, .voice-btn.recording {
  background: var(--danger);
  border-color: var(--danger);
  transform: scale(1.05);
}

/* OEI Gauge Bar */
.xp-bar-container {
  background: var(--bg-input);
  border-radius: 8px;
  height: 10px;
  overflow: hidden;
  margin: 8px 0;
  border: 1px solid var(--border);
}
.xp-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--electric-cyan), var(--vibrant-emerald));
  border-radius: 8px;
  transition: width 0.5s ease;
  box-shadow: 0 0 12px rgba(0,212,255,0.3);
}
.xp-bar.gold {
  background: linear-gradient(90deg, var(--safety-yellow), #ffb800);
  box-shadow: 0 0 12px rgba(245,200,66,0.4);
}

.xp-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  align-items: center;
}
.xp-row:last-child { border-bottom: none; }
.xp-name { font-weight: 700; }
.xp-points { color: var(--xp-gold); font-weight: 800; font-size: 17px; }
.xp-rank { font-size: 22px; margin-right: 8px; }

/* Checklist */
.checklist-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--bg-input);
  border-radius: 10px;
  margin-bottom: 8px;
  cursor: pointer;
  min-height: 48px;
  transition: background 0.12s;
}
.checklist-item:active { background: var(--border); }
.checklist-item .check-box {
  width: 28px; height: 28px;
  border: 2px solid var(--border);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.checklist-item.checked .check-box {
  background: var(--success);
  border-color: var(--success);
  color: white;
}
.checklist-item .check-label { font-size: 15px; font-weight: 600; }

/* Material counter */
.material-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px;
  background: var(--bg-input);
  border-radius: 10px;
  margin-bottom: 8px;
}
.material-name { font-weight: 700; font-size: 15px; flex: 1; }
.material-controls { display: flex; align-items: center; gap: 12px; }
.material-count {
  font-size: 24px; font-weight: 800; color: var(--accent);
  min-width: 40px; text-align: center;
  font-variant-numeric: tabular-nums;
}
.material-btn {
  width: 44px; height: 44px;
  border-radius: 10px;
  border: 2px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  font-size: 22px; font-weight: 700;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.material-btn:active { background: var(--accent); border-color: var(--accent); color: white; }

/* Admin styles */
.admin-header {
  background: var(--primary);
  color: white;
  padding: 12px 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(0,0,0,0.4);
}
.admin-header h1 { font-size: 18px; }
.admin-header .subtitle { font-size: 12px; opacity: 0.7; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}

.stat-card {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 14px;
  text-align: center;
  box-shadow: var(--shadow);
}
.stat-number { font-size: 32px; font-weight: 800; color: var(--text); line-height: 1; }
.stat-label { font-size: 11px; color: var(--text-light); text-transform: uppercase; letter-spacing: 1px; margin-top: 2px; }
.stat-card.highlight .stat-number { color: var(--accent); }
.stat-card.xp .stat-number { color: var(--xp-gold); }

.active-crew-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  background: rgba(39,174,96,0.1);
  border-left: 4px solid var(--success);
  border-radius: 8px;
  margin-bottom: 6px;
}
.active-crew-name { font-weight: 700; font-size: 16px; }
.active-crew-job { font-size: 13px; color: var(--text-light); }
.active-crew-time { font-weight: 800; color: var(--success); font-size: 14px; font-variant-numeric: tabular-nums; }

.completion-item {
  padding: 12px;
  background: rgba(230,126,34,0.1);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  margin-bottom: 6px;
}
.completion-job { font-weight: 700; }
.completion-meta { font-size: 13px; color: var(--text-light); }

.hours-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.hours-row:last-child { border-bottom: none; }
.hours-job-name { font-weight: 700; }
.hours-job-client { font-size: 13px; color: var(--text-light); }
.hours-value { font-size: 18px; font-weight: 800; color: var(--accent); }
.hours-crew-count { font-size: 11px; color: var(--text-light); }

.admin-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.admin-actions .btn { flex: 1; padding: 10px; font-size: 13px; }

.empty-state { text-align: center; padding: 24px; color: var(--text-muted); font-size: 14px; }

.nav-tabs {
  display: flex;
  background: var(--bg-card);
  border-radius: 12px;
  padding: 3px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.nav-tab {
  flex: 1;
  padding: 10px;
  text-align: center;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-light);
  cursor: pointer;
  border: none;
  background: none;
}
.nav-tab.active { background: var(--electric-cyan); color: #1a1a1a; font-weight: 800; }

/* Expense Entry */
.expense-amount {
  font-size: 24px;
  font-weight: 800;
  text-align: center;
  padding: 16px;
}

/* Modal */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.7);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-overlay.active { display: flex; }
.modal {
  background: var(--bg-card);
  border-radius: 16px;
  padding: 20px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal h3 { font-size: 18px; margin-bottom: 14px; color: var(--accent); }
.modal-actions { display: flex; gap: 8px; margin-top: 14px; }
.modal-actions .btn { flex: 1; padding: 12px; }

/* Screen toggle */
.screen { display: none; }
.screen.active { display: block; }
.tab-content { display: none; }
.tab-content.active-tab { display: block; }

/* Animations */
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.6} }
.pulse { animation: pulse 2s ease-in-out infinite; }

/* Responsive */
@media (max-width: 380px) {
  .crew-grid { grid-template-columns: repeat(2, 1fr); }
}
