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

:root {
  --black: #1a1a1a;
  --gold: #ee6c4d;        /* brand coral (from ABP logo) */
  --gold-dk: #d4552f;     /* darker coral for active states */
  --white: #ffffff;
  --navy: #3d5a80;        /* brand navy (from ABP logo) */
  --gray-50: #f9f9f8;
  --gray-100: #f1f0ec;
  --gray-200: #e2e1db;
  --gray-400: #9a9890;
  --gray-600: #5f5e5a;
  --gray-800: #2c2c2a;
  --green: #22c55e;
  --green-bg: #dcfce7;
  --green-txt: #166534;
  --amber-bg: #fef3c7;
  --amber-txt: #92400e;
  --red: #ef4444;
  --red-bg: #fee2e2;
  --red-txt: #991b1b;
  --blue-bg: #dbeafe;
  --blue-txt: #1e40af;
  --purple-bg: #ede9fe;
  --purple-txt: #4c1d95;
  --r: 8px;
  --rl: 12px;
  --shadow: 0 1px 4px rgba(0,0,0,0.08);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  background: var(--gray-100);
  color: var(--gray-800);
  min-height: 100vh;
  -webkit-text-size-adjust: 100%;
}

/* SCREENS */
.screen { display: none; }
.screen.active { display: block; }
.hidden { display: none !important; }

/* LOGIN */
.login-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: var(--navy);
  background: linear-gradient(160deg, #3d5a80 0%, #28415f 100%);
}
.login-logo { text-align: center; margin-bottom: 24px; }
.login-logo-img {
  width: auto;
  height: 90px;
  max-width: 280px;
  object-fit: contain;
  filter: brightness(0) invert(1);
}
.login-card {
  background: var(--white);
  border-radius: var(--rl);
  padding: 24px 20px;
  width: 100%; max-width: 340px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  border-top: 4px solid var(--gold);
}
.field-label { font-size: 11px; font-weight: 600; color: var(--gray-600); letter-spacing: 0.5px; display: block; margin-bottom: 6px; }
.field-input {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--gray-200);
  border-radius: var(--r);
  font-size: 14px; color: var(--gray-800);
  background: var(--white);
  outline: none; appearance: none;
  transition: border-color 0.15s;
}
.field-input:focus { border-color: var(--gold); }
.pin-user-name { font-size: 15px; font-weight: 600; text-align: center; margin-bottom: 14px; color: var(--gray-800); }
.pin-dots { display: flex; gap: 12px; justify-content: center; margin-bottom: 20px; }
.pin-dots span {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--gray-200);
  transition: background 0.1s, border-color 0.1s;
}
.pin-dots span.filled { background: var(--gold); border-color: var(--gold); }
.pin-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pin-btn {
  height: 52px; border-radius: var(--r);
  border: 1px solid var(--gray-200);
  background: var(--gray-50);
  font-size: 20px; font-weight: 500;
  color: var(--gray-800); cursor: pointer;
  transition: background 0.1s;
}
.pin-btn:active { background: var(--gray-200); }
.pin-clear { font-size: 18px; }
.pin-back { font-size: 13px; color: var(--gray-400); }
.pin-error { color: var(--red-txt); font-size: 12px; text-align: center; margin-top: 10px; }

/* BUTTONS */
.btn-primary {
  background: var(--gold); color: var(--black);
  border: none; border-radius: var(--r);
  padding: 11px 20px; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: background 0.1s;
}
.btn-primary:active { background: var(--gold-dk); }
.btn-secondary {
  background: var(--white); color: var(--gray-800);
  border: 1px solid var(--gray-200); border-radius: var(--r);
  padding: 10px 18px; font-size: 14px;
  cursor: pointer; transition: background 0.1s;
}
.btn-secondary:active { background: var(--gray-100); }
.btn-xs {
  background: rgba(255,255,255,0.15); color: var(--white);
  border: 1px solid rgba(255,255,255,0.2); border-radius: 6px;
  padding: 4px 10px; font-size: 11px; font-weight: 500;
  cursor: pointer;
}
.btn-danger {
  background: var(--red-bg); color: var(--red-txt);
  border: 1px solid #fca5a5; border-radius: var(--r);
  padding: 10px 18px; font-size: 14px;
  cursor: pointer;
}
.full-width { width: 100%; }
.mt16 { margin-top: 16px; }
.icon-btn {
  width: 32px; height: 32px; border-radius: 50%;
  border: none; background: rgba(255,255,255,0.1);
  color: var(--white); font-size: 14px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}

/* TOPBAR */
.topbar {
  background: var(--navy);
  padding: 8px 14px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 50;
  min-height: 52px;
}
.topbar-left { display: flex; align-items: center; gap: 8px; }
.topbar-logo {
  height: 36px;
  width: auto;
  max-width: 180px;
  object-fit: contain;
  flex-shrink: 0;
  filter: brightness(0) invert(1);
}
.topbar-role {
  font-size: 10px; color: var(--gold);
  letter-spacing: 0.5px; text-transform: uppercase;
  align-self: center;
}
.topbar-right { display: flex; align-items: center; gap: 8px; }
.topbar-time { font-size: 11px; color: var(--gray-400); }

/* WEATHER BAR */
.weather-bar {
  background: #3d5a80;
  padding: 7px 14px;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  font-size: 12px; color: #c8d8e8;
}
.weather-status { font-weight: 600; color: var(--green); }
.weather-status.warn { color: var(--gold); }
.weather-status.danger { color: var(--red); font-weight: 700; }
.wx-sep { flex: 1; }
.weather-bar-actions { margin-left: auto; }

/* NAV TABS */
.nav-tabs {
  display: flex; overflow-x: auto;
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  scrollbar-width: none;
  position: sticky; top: 50px; z-index: 40;
}
.nav-tabs::-webkit-scrollbar { display: none; }
.nav-tab {
  padding: 10px 14px; white-space: nowrap;
  font-size: 12px; font-weight: 500;
  color: var(--gray-600); cursor: pointer;
  border: none; background: none;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
}
.nav-tab.active { color: var(--gold); border-bottom-color: var(--gold); }

/* PANELS */
#panels-container { padding: 14px; }
.panel { display: none; }
.panel.active { display: block; }

/* CARDS */
.card {
  background: var(--white);
  border-radius: var(--rl);
  border: 1px solid var(--gray-200);
  padding: 14px;
  margin-bottom: 12px;
}
.card-title { font-size: 11px; font-weight: 600; color: var(--gray-600); letter-spacing: 0.5px; text-transform: uppercase; margin-bottom: 10px; }
.metric-num { font-size: 28px; font-weight: 600; color: var(--gray-800); }
.metric-sub { font-size: 12px; color: var(--gray-400); margin-top: 2px; }

/* STAT GRID */
.stat-grid { display: grid; gap: 10px; margin-bottom: 14px; }
.stat-grid-2 { grid-template-columns: 1fr 1fr; }
.stat-grid-3 { grid-template-columns: 1fr 1fr 1fr; }
.stat-card {
  background: var(--gray-50);
  border-radius: var(--r);
  padding: 12px;
  border: 1px solid var(--gray-200);
}

/* JOB ROWS */
.job-row {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 12px;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--r);
  margin-bottom: 8px;
  cursor: pointer;
  transition: border-color 0.1s;
}
.job-row:active { border-color: var(--gold); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.dot-green { background: var(--green); }
.dot-amber { background: var(--gold); }
.dot-blue { background: #3b82f6; }
.dot-gray { background: var(--gray-400); }
.dot-red { background: var(--red); }
.job-body { flex: 1; min-width: 0; }
.job-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.job-sub { font-size: 11px; color: var(--gray-400); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.job-right { text-align: right; flex-shrink: 0; }
.job-val { font-size: 13px; font-weight: 600; }

/* BADGES */
.badge {
  display: inline-block; padding: 2px 8px;
  border-radius: 20px; font-size: 10px; font-weight: 600;
  letter-spacing: 0.3px;
}
.badge-green { background: var(--green-bg); color: var(--green-txt); }
.badge-amber { background: var(--amber-bg); color: var(--amber-txt); }
.badge-red { background: var(--red-bg); color: var(--red-txt); }
.badge-blue { background: var(--blue-bg); color: var(--blue-txt); }
.badge-purple { background: var(--purple-bg); color: var(--purple-txt); }
.badge-gray { background: var(--gray-100); color: var(--gray-600); }

/* FORMS */
.form-group { margin-bottom: 12px; }
.form-group label { font-size: 11px; font-weight: 600; color: var(--gray-600); display: block; margin-bottom: 5px; letter-spacing: 0.4px; }
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%; padding: 9px 11px;
  border: 1px solid var(--gray-200); border-radius: var(--r);
  font-size: 13px; color: var(--gray-800); background: var(--white);
  outline: none; font-family: inherit;
  transition: border-color 0.15s;
  appearance: none;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { border-color: var(--gold); }
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-actions { display: flex; gap: 8px; margin-top: 16px; }
.form-actions .btn-primary,
.form-actions .btn-secondary { flex: 1; }

/* WORKER CARD */
.worker-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--r);
  padding: 12px;
  margin-bottom: 8px;
}
.worker-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--black); color: var(--gold);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; flex-shrink: 0;
}
.worker-info { flex: 1; }
.worker-name { font-size: 13px; font-weight: 600; }
.worker-role { font-size: 11px; color: var(--gray-400); }
.duty-chip {
  display: inline-block; background: var(--gray-100);
  border: 1px solid var(--gray-200); border-radius: 4px;
  padding: 2px 7px; font-size: 11px; margin: 2px;
}

/* CLOCK */
.clock-row {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 12px;
  background: var(--white); border: 1px solid var(--gray-200);
  border-radius: var(--r); margin-bottom: 8px;
}
.clock-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--gray-400); flex-shrink: 0; }
.clock-dot.in { background: var(--green); }
.clock-info { flex: 1; }
.clock-name { font-size: 13px; font-weight: 600; }
.clock-time { font-size: 11px; color: var(--gray-400); }
.punch-btn {
  padding: 6px 12px; border-radius: var(--r); font-size: 12px; font-weight: 600;
  border: 1px solid var(--gray-200); cursor: pointer; background: var(--white);
}
.punch-btn.punch-in { background: var(--green-bg); color: var(--green-txt); border-color: #86efac; }
.punch-btn.punch-out { background: var(--red-bg); color: var(--red-txt); border-color: #fca5a5; }

/* MORNING BRIEF */
.brief-card {
  background: var(--navy); border-radius: var(--rl);
  padding: 16px; margin-bottom: 14px; color: var(--white);
}
.brief-label { font-size: 10px; font-weight: 600; color: var(--gold); letter-spacing: 1px; text-transform: uppercase; margin-bottom: 4px; }
.brief-date { font-size: 18px; font-weight: 600; margin-bottom: 12px; }
.brief-line { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 7px; font-size: 12px; color: #dde5ef; }
.brief-bullet { color: var(--gold); flex-shrink: 0; }

/* AI BRIEF BOX */
.ai-brief {
  background: linear-gradient(135deg, #3d5a80 0%, #28415f 100%);
  border: 1px solid #333;
  border-radius: var(--rl);
  padding: 16px;
  margin-bottom: 14px;
  color: var(--white);
}
.ai-brief-label {
  display: flex; align-items: center; gap: 6px;
  font-size: 10px; font-weight: 600; color: var(--gold);
  letter-spacing: 1px; text-transform: uppercase; margin-bottom: 10px;
}
.ai-brief-label::before {
  content: '';
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--gold);
  animation: pulse-dot 2s infinite;
}
@keyframes pulse-dot { 0%,100%{opacity:1} 50%{opacity:0.4} }
.ai-brief-body { font-size: 13px; line-height: 1.7; color: #ddd; }
.ai-brief-body strong { color: var(--gold); font-weight: 600; }
.ai-brief-loading { font-size: 12px; color: var(--gray-400); font-style: italic; }

/* WARRANTY PROGRESS */
.w-bar { background: var(--gray-200); border-radius: 4px; height: 4px; margin-top: 4px; overflow: hidden; }
.w-fill { height: 100%; border-radius: 4px; }

/* LEAD SOURCE BARS */
.source-bar-wrap { margin-bottom: 10px; }
.source-bar-label { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 3px; }
.source-bar { background: var(--gray-200); border-radius: 4px; height: 8px; overflow: hidden; }
.source-fill { height: 100%; border-radius: 4px; }

/* STAT ROW */
.stat-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 0; border-bottom: 1px solid var(--gray-100);
  font-size: 13px;
}
.stat-row:last-child { border-bottom: none; }
.stat-label { color: var(--gray-600); }

/* MONEY LEAK */
.money-leak-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 7px 0; border-bottom: 1px solid var(--gray-100);
  font-size: 12px;
}
.money-leak-item:last-child { border-bottom: none; }

/* SEVERITY SELECTOR */
.sev-group { display: flex; gap: 6px; margin-top: 5px; }
.sev-opt {
  flex: 1; padding: 7px; text-align: center;
  border: 1px solid var(--gray-200); border-radius: var(--r);
  font-size: 12px; font-weight: 600; cursor: pointer; background: var(--white);
  transition: all 0.1s;
}
.sev-opt.sel-low { background: var(--green-bg); color: var(--green-txt); border-color: #86efac; }
.sev-opt.sel-med { background: var(--amber-bg); color: var(--amber-txt); border-color: #fcd34d; }
.sev-opt.sel-high { background: var(--red-bg); color: var(--red-txt); border-color: #fca5a5; }

/* MODAL */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex; align-items: flex-end;
  z-index: 200;
}
.modal-box {
  background: var(--white);
  border-radius: 16px 16px 0 0;
  padding: 20px 16px 32px;
  width: 100%; max-height: 85vh;
  overflow-y: auto;
}
.modal-title { font-size: 16px; font-weight: 700; margin-bottom: 16px; color: var(--gray-800); }

/* TOAST */
.toast {
  position: fixed; bottom: 80px; left: 50%;
  transform: translateX(-50%);
  background: var(--gray-800); color: var(--white);
  padding: 10px 20px; border-radius: 20px;
  font-size: 13px; font-weight: 500;
  z-index: 300; white-space: nowrap;
  animation: toast-in 0.2s ease;
}
@keyframes toast-in { from { opacity:0; transform: translateX(-50%) translateY(10px); } }

/* SECTION TITLE */
.section-title {
  font-size: 13px; font-weight: 600;
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 10px;
}
.section-title-sm { font-size: 11px; font-weight: 600; color: var(--gray-600); letter-spacing: 0.4px; text-transform: uppercase; margin-bottom: 8px; }

/* RANGE SLIDER */
input[type="range"] {
  -webkit-appearance: none; width: 100%; height: 4px;
  background: var(--gray-200); border-radius: 2px; outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 18px; height: 18px;
  border-radius: 50%; background: var(--gold); cursor: pointer;
}

/* RESPONSIVE */
@media (min-width: 600px) {
  .modal-overlay { align-items: center; }
  .modal-box { border-radius: 16px; max-width: 500px; }
  #panels-container { max-width: 700px; margin: 0 auto; }
}

/* PRODUCTION FORM */
.prod-form { background: var(--gray-50); border-radius: var(--r); padding: 14px; border: 1px solid var(--gray-200); }

/* EMPTY STATE */
.empty-state { text-align: center; padding: 32px 16px; color: var(--gray-400); font-size: 13px; }

/* SCROLL FIX */
.scroll-x { overflow-x: auto; scrollbar-width: none; }
.scroll-x::-webkit-scrollbar { display: none; }

/* ── Address autocomplete dropdown ───────────────────────── */
.addr-ac-dropdown {
  z-index: 99999;
  background: #2a2a2a;
  border: 1px solid #444;
  border-radius: 8px;
  max-height: 230px;
  overflow-y: auto;
  box-shadow: 0 8px 24px rgba(0,0,0,.45);
}
.addr-ac-item {
  padding: 10px 12px;
  cursor: pointer;
  color: #eee;
  font-size: 14px;
  line-height: 1.3;
  border-bottom: 1px solid #333;
}
.addr-ac-item:last-child { border-bottom: none; }
.addr-ac-item:hover,
.addr-ac-item.active { background: #f5a623; color: #1a1a1a; }
