/* Design tokens pulled directly from hangitrightnow.com's stylesheet so this app
   feels like the same brand, not a bolted-on tool. */
:root {
  --sky: #5bb9e8;
  --sky-dark: #13314f;
  --navy: #0f2a47;
  --navy-soft: #0f2a47cc;
  --orange: #ff8a1f;
  --orange-dark: #e5640f;
  --orange-hover: #f57812;
  --yellow: #f4c51d;
  --bg: #eff8fd;
  --card: #ffffff;
  --border: #d7e6ee;
  --muted: #6b7a86;
  --text: #22303c;
  --green: #1fa971;
  --green-bg: #e6f7ef;
  --red: #dc3545;
  --red-bg: #fdeceb;

  --font-display: "Fredoka", sans-serif;
  --font-body: "Nunito Sans", sans-serif;

  --radius: 1rem;
  --radius-lg: 1.5rem;
  --radius-sm: 0.6rem;
  --shadow: 0 4px 16px rgba(15, 42, 71, 0.08);
  --shadow-lg: 0 10px 30px rgba(15, 42, 71, 0.14);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, .display {
  font-family: var(--font-display);
  color: var(--navy);
  margin: 0;
}
button { font-family: inherit; }
a { color: var(--sky-dark); }

#app { max-width: 560px; margin: 0 auto; min-height: 100vh; padding-bottom: calc(84px + var(--safe-bottom)); }

.boot-loading { display: flex; align-items: center; justify-content: center; height: 100vh; }
.spinner {
  width: 36px; height: 36px; border-radius: 50%;
  border: 4px solid var(--border); border-top-color: var(--sky);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.hidden { display: none !important; }

.offline-banner {
  position: sticky; top: 0; z-index: 50;
  background: var(--navy); color: #fff;
  font-size: 0.85rem; font-weight: 600;
  text-align: center; padding: 8px 12px;
}

/* ---- top bar ------------------------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--bg); padding: 18px 16px 10px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.topbar h1 { font-size: 1.4rem; }
.brand { display: flex; align-items: center; gap: 8px; }
.brand-badge {
  width: 34px; height: 34px; border-radius: 10px; background: var(--orange);
  display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-family: var(--font-display);
  overflow: hidden;
}
.brand-badge img { width: 78%; height: 78%; object-fit: contain; }
.icon-btn {
  border: none; background: var(--card); width: 38px; height: 38px; border-radius: 50%;
  box-shadow: var(--shadow); display: flex; align-items: center; justify-content: center; cursor: pointer;
}

/* ---- search --------------------------------------------------------------*/
.search-wrap { padding: 0 16px 8px; }
.search-input {
  width: 100%; padding: 12px 14px; border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--card); font-size: 1rem; font-family: inherit;
}
.search-input:focus { outline: 2px solid var(--sky); }

.tabs { display: flex; gap: 8px; padding: 4px 16px 14px; }
.tab {
  border: 1px solid var(--border); background: var(--card); color: var(--muted);
  padding: 7px 14px; border-radius: 999px; font-weight: 700; font-size: 0.85rem; cursor: pointer;
}
.tab.active { background: var(--navy); color: #fff; border-color: var(--navy); }

/* ---- job list ------------------------------------------------------------*/
.job-list { list-style: none; margin: 0; padding: 0 16px; display: flex; flex-direction: column; gap: 10px; }
.job-card {
  background: var(--card); border-radius: var(--radius-lg); padding: 14px 16px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 6px; cursor: pointer; border: 1px solid transparent;
}
.job-card:active { border-color: var(--sky); }
.job-card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.job-card-name { font-family: var(--font-display); font-weight: 600; font-size: 1.05rem; color: var(--navy); }
.job-card-sub { font-size: 0.85rem; color: var(--muted); }
.job-card-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.pill {
  display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 999px;
  font-size: 0.72rem; font-weight: 800; letter-spacing: 0.02em; text-transform: uppercase;
}
.pill-new-lead { background: #fdeceb; color: #b3261e; }
.pill-contacted { background: #fff2df; color: #b5650a; }
.pill-scheduled { background: #fff8db; color: #92730a; }
.pill-crew-coordinated { background: #eaf3fd; color: #1a5fa3; }
.pill-job-completed { background: #f2e9fb; color: #6b3fa0; }
.pill-payment-collected { background: var(--green-bg); color: var(--green); }
.pill-review-requested { background: #fdeaf3; color: #b13a75; }
.pill-closed-reviewed { background: #eef1f2; color: #48545c; }

.empty-state { text-align: center; padding: 60px 24px; color: var(--muted); }
.empty-state .display { font-size: 1.2rem; margin-bottom: 6px; }

/* ---- floating action button ------------------------------------------------*/
.fab {
  position: fixed; right: 20px; bottom: calc(24px + var(--safe-bottom));
  width: 58px; height: 58px; border-radius: 50%; border: none;
  background: var(--orange); color: #fff; font-size: 1.8rem; box-shadow: var(--shadow-lg);
  display: flex; align-items: center; justify-content: center; cursor: pointer; z-index: 30;
}
.fab:active { background: var(--orange-hover); }

/* ---- bottom nav ------------------------------------------------------------*/
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: #fff; border-top: 1px solid var(--border);
  display: flex; justify-content: space-around; padding: 8px 8px calc(8px + var(--safe-bottom));
  max-width: 560px; margin: 0 auto;
}
.nav-btn { background: none; border: none; color: var(--muted); font-size: 0.72rem; font-weight: 700;
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 12px; cursor: pointer; }
.nav-btn.active { color: var(--orange); }

/* ---- generic screen/page --------------------------------------------------*/
.screen { padding: 16px 16px 32px; }
.card { background: var(--card); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 18px; margin-bottom: 14px; }
.section-title { font-size: 0.78rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin-bottom: 10px; }

.detail-header { display: flex; align-items: center; gap: 10px; padding: 14px 16px 6px; }
.back-btn { border: none; background: var(--card); width: 38px; height: 38px; border-radius: 50%; box-shadow: var(--shadow); font-size: 1.1rem; cursor: pointer; }

.contact-row { display: flex; gap: 10px; margin-top: 10px; }
.contact-btn {
  flex: 1; text-align: center; padding: 10px 8px; border-radius: var(--radius); border: 1px solid var(--border);
  background: #fff; color: var(--navy); text-decoration: none; font-weight: 700; font-size: 0.85rem;
}
button.contact-btn { cursor: pointer; font-family: inherit; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 0.78rem; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 11px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  font-size: 1rem; font-family: inherit; background: #fff;
}
.field textarea { min-height: 70px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--sky); }

#f-notes {
  width: 100%; min-height: 200px; padding: 12px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); font-size: 1rem; font-family: inherit; background: #fff;
  resize: vertical; line-height: 1.5;
}
#f-notes:focus { outline: 2px solid var(--sky); }

.stepper { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 4px; }
.step-chip {
  border: 1px solid var(--border); background: #fff; padding: 8px 12px; border-radius: 999px;
  font-size: 0.78rem; font-weight: 700; color: var(--muted); cursor: pointer;
}
.step-chip.current { background: var(--navy); color: #fff; border-color: var(--navy); }
.step-chip.done { background: var(--green-bg); color: var(--green); border-color: transparent; }

.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  padding: 14px 16px; border-radius: var(--radius); border: none; font-weight: 800; font-size: 0.98rem;
  cursor: pointer; font-family: var(--font-body);
}
.btn-primary { background: var(--orange); color: #fff; }
.btn-primary:active { background: var(--orange-hover); }
.btn-secondary { background: var(--sky); color: #fff; }
.btn-outline { background: #fff; border: 1.5px solid var(--navy); color: var(--navy); }
.btn-success { background: var(--green); color: #fff; }
.btn-ghost { background: transparent; color: var(--muted); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }

.status-banner { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: var(--radius); font-size: 0.85rem; font-weight: 700; margin-bottom: 12px; }
.status-banner.ok { background: var(--green-bg); color: var(--green); }
.status-banner.warn { background: #fff8db; color: #92730a; }
.status-banner.sync { background: #eaf3fd; color: #1a5fa3; }

.photo-preview { width: 100%; border-radius: var(--radius); margin-top: 10px; display: block; }
.sig-preview { width: 100%; max-height: 140px; object-fit: contain; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); margin-top: 10px; }

/* ---- calendar --------------------------------------------------------------*/
.cal-nav { display: flex; align-items: center; justify-content: space-between; padding: 4px 4px 12px; }
.cal-month-label { font-family: var(--font-display); font-weight: 700; font-size: 1.05rem; color: var(--navy); }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-dow { text-align: center; font-size: 0.65rem; font-weight: 800; color: var(--muted); text-transform: uppercase; padding-bottom: 6px; }
.cal-cell {
  aspect-ratio: 1 / 1; border-radius: 10px; display: flex; flex-direction: column; align-items: center;
  justify-content: flex-start; padding-top: 6px; cursor: pointer; border: 1.5px solid transparent; background: var(--bg);
}
.cal-cell.outside { opacity: 0.35; }
.cal-cell.today { border-color: var(--sky); }
.cal-cell.selected { background: var(--navy); }
.cal-cell.selected .cal-daynum { color: #fff; }
.cal-daynum { font-size: 0.85rem; font-weight: 700; color: var(--navy); }
.cal-dots { display: flex; gap: 2px; margin-top: 4px; flex-wrap: wrap; justify-content: center; max-width: 100%; }
.cal-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--orange); }
.cal-dot-more { font-size: 0.55rem; font-weight: 800; color: var(--muted); }

.cal-day-jobs { display: flex; flex-direction: column; gap: 8px; }
.cal-day-job {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius); background: var(--bg); cursor: pointer;
}

/* ---- login (PIN pad) -------------------------------------------------------*/
.login-screen { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; text-align: center; }
.login-logo { width: 68px; height: 68px; border-radius: 20px; background: var(--orange); display: flex; align-items: center; justify-content: center; color: #fff; font-family: var(--font-display); font-size: 1.6rem; font-weight: 700; margin-bottom: 14px; overflow: hidden; }
.login-logo img { width: 78%; height: 78%; object-fit: contain; }
.pin-dots { display: flex; gap: 12px; margin: 20px 0; }
.pin-dot { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--sky); }
.pin-dot.filled { background: var(--sky); }
.pin-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; width: 100%; max-width: 280px; }
.pin-key { padding: 18px; font-size: 1.3rem; font-weight: 700; border-radius: var(--radius); border: none; background: #fff; box-shadow: var(--shadow); color: var(--navy); }
.pin-key:active { background: var(--bg); }
.pin-error { color: var(--red); font-weight: 700; font-size: 0.9rem; min-height: 20px; margin-top: 8px; }

/* ---- signature modal -------------------------------------------------------*/
.modal-backdrop { position: fixed; inset: 0; background: rgba(15,42,71,0.5); z-index: 60; display: flex; align-items: flex-end; }
.modal-sheet { background: #fff; width: 100%; border-radius: 24px 24px 0 0; padding: 18px; max-width: 560px; margin: 0 auto; }
.sig-canvas { width: 100%; height: 220px; background: #fff; border: 2px dashed var(--border); border-radius: var(--radius); touch-action: none; }

.toast { position: fixed; bottom: calc(100px + var(--safe-bottom)); left: 50%; transform: translateX(-50%); background: var(--navy); color: #fff; padding: 10px 18px; border-radius: 999px; font-weight: 700; font-size: 0.85rem; z-index: 70; box-shadow: var(--shadow-lg); }
