:root {
  --green: #1a9c5c;
  --green-bg: #e6f7ee;
  --amber: #b8860b;
  --amber-bg: #fff6e0;
  --red: #d0342c;
  --red-bg: #fdeceb;
  --blue: #1660c9;
  --blue-bg: #eaf1fd;
  --ink: #16181d;
  --ink-soft: #5b616e;
  --line: #e4e6ea;
  --bg: #f5f6f8;
  --card-bg: #ffffff;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 3px rgba(20, 22, 30, 0.08), 0 1px 2px rgba(20, 22, 30, 0.06);
  font-size: 16px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}

.hidden { display: none !important; }

button { font-family: inherit; }

.app-shell {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  padding-bottom: 90px;
}

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 8px;
}
.topbar h1 { font-size: 1.15rem; margin: 0; }
.topbar .icon-btn {
  border: none;
  background: transparent;
  font-size: 1.3rem;
  padding: 8px;
  cursor: pointer;
  color: var(--ink-soft);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 16px 20px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 52px;
  transition: transform 0.05s ease, opacity 0.15s ease;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-secondary { background: #fff; color: var(--ink); border: 1.5px solid var(--line); }
.btn-green { background: var(--green); color: #fff; }
.btn-danger { background: var(--red); color: #fff; }
.btn-ghost { background: transparent; color: var(--blue); font-weight: 600; }
.btn-sm { padding: 10px 14px; min-height: 40px; font-size: 0.9rem; width: auto; }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }

/* ---------- Welcome / Progress ---------- */
.welcome { padding: 4px 20px 8px; }
.welcome h2 { font-size: 1.5rem; margin: 0 0 4px; }
.welcome p { color: var(--ink-soft); margin: 0 0 20px; }

.progress-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  margin: 0 20px 20px;
}
.progress-card .progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--ink-soft);
  margin-bottom: 10px;
}
.progress-track {
  height: 12px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--green), #22b56e);
  border-radius: 999px;
  transition: width 0.4s ease;
}
.progress-count {
  margin-top: 10px;
  font-weight: 700;
  font-size: 1.05rem;
}

/* ---------- Checklist ---------- */
.checklist { padding: 0 20px; display: flex; flex-direction: column; gap: 12px; }

.step-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  border: 1.5px solid transparent;
}
.step-card:active { transform: scale(0.99); }
.step-card.complete { border-color: rgba(26, 156, 92, 0.25); }
.step-card.warning { border-color: rgba(184, 134, 11, 0.35); }

.step-status {
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 700;
  background: var(--line);
  color: var(--ink-soft);
}
.step-card.complete .step-status { background: var(--green-bg); color: var(--green); }
.step-card.warning .step-status { background: var(--amber-bg); color: var(--amber); }

.step-body { flex: 1; min-width: 0; }
.step-title { font-weight: 700; font-size: 1rem; }
.step-meta { font-size: 0.85rem; color: var(--ink-soft); margin-top: 2px; }
.step-chevron { color: var(--ink-soft); font-size: 1.2rem; }

/* ---------- Panels (full step detail) ---------- */
.panel-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 50;
  overflow-y: auto;
}
.panel-inner { max-width: 560px; margin: 0 auto; padding: 0 0 40px; }
.panel-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 20px 10px;
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 2;
}
.panel-header .back-btn {
  border: none;
  background: #fff;
  box-shadow: var(--shadow);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 1.1rem;
  cursor: pointer;
}
.panel-header h2 { font-size: 1.2rem; margin: 0; }
.panel-body { padding: 8px 20px 20px; display: flex; flex-direction: column; gap: 16px; }
.panel-time {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--ink-soft);
  background: #fff;
  border-radius: 999px;
  padding: 6px 12px;
  width: fit-content;
}

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 0.88rem; font-weight: 600; color: var(--ink); }
.field .hint { font-size: 0.78rem; color: var(--ink-soft); font-weight: 400; }
.field input, .field select, .field textarea {
  padding: 14px 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--line);
  font-size: 1rem;
  background: #fff;
  width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--ink);
}
.section-title { font-weight: 700; font-size: 0.95rem; margin: 6px 0 -6px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.03em; font-size: 0.75rem; }

/* ---------- Upload tiles ---------- */
.upload-grid { display: flex; flex-direction: column; gap: 10px; }
.upload-tile {
  background: #fff;
  border-radius: var(--radius-sm);
  border: 1.5px dashed var(--line);
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.upload-tile.has-file { border-style: solid; }
.upload-thumb {
  width: 48px; height: 48px; border-radius: 8px; background: var(--bg);
  display: flex; align-items: center; justify-content: center; font-size: 1.3rem; overflow: hidden; flex: 0 0 48px;
}
.upload-thumb img { width: 100%; height: 100%; object-fit: cover; }
.upload-info { flex: 1; min-width: 0; }
.upload-info .name { font-weight: 600; font-size: 0.92rem; }
.upload-info .status-pill { margin-top: 4px; }
.upload-actions { display: flex; gap: 6px; flex-shrink: 0; }
.upload-actions button {
  border: none; background: var(--bg); border-radius: 8px; padding: 8px 10px; font-size: 0.8rem; cursor: pointer; font-weight: 600;
}
.upload-actions input[type=file] { display: none; }

.status-pill {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 0.72rem; font-weight: 700; padding: 3px 9px; border-radius: 999px;
  text-transform: uppercase; letter-spacing: 0.02em;
}
.status-pill.pending { background: var(--amber-bg); color: var(--amber); }
.status-pill.approved { background: var(--green-bg); color: var(--green); }
.status-pill.rejected, .status-pill.replacement_required { background: var(--red-bg); color: var(--red); }
.status-pill.not_started { background: var(--line); color: var(--ink-soft); }
.status-pill.started, .status-pill.completed_by_driver { background: var(--amber-bg); color: var(--amber); }
.status-pill.verified_by_admin, .status-pill.approvedplatform { background: var(--green-bg); color: var(--green); }

/* ---------- External platform card ---------- */
.platform-card {
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 12px;
}
.platform-card h3 { margin: 0 0 4px; font-size: 1rem; }
.platform-card p { margin: 0 0 12px; color: var(--ink-soft); font-size: 0.9rem; }

/* ---------- Checkbox list ---------- */
.check-list { display: flex; flex-direction: column; gap: 10px; }
.check-item {
  display: flex; align-items: flex-start; gap: 12px; background: #fff; border-radius: var(--radius-sm);
  padding: 14px; border: 1.5px solid var(--line); cursor: pointer;
}
.check-item input { width: 20px; height: 20px; margin-top: 1px; flex-shrink: 0; }
.check-item span { font-size: 0.92rem; }

/* ---------- Signature pad ---------- */
.sig-wrap { background: #fff; border-radius: var(--radius-sm); border: 1.5px solid var(--line); padding: 8px; }
.sig-wrap canvas { width: 100%; height: 160px; touch-action: none; border-radius: 8px; background: #fbfbfc; display: block; }
.sig-actions { display: flex; justify-content: flex-end; padding-top: 8px; }

/* ---------- Card / misc ---------- */
.card {
  background: var(--card-bg); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px;
}
.muted { color: var(--ink-soft); }
.center { text-align: center; }
.big-icon { font-size: 2.6rem; margin-bottom: 6px; }

/* ---------- Auth screen ---------- */
.auth-wrap { max-width: 420px; margin: 0 auto; padding: 60px 24px; display: flex; flex-direction: column; gap: 16px; min-height: 100vh; justify-content: center; }
.auth-wrap h1 { text-align: center; margin-bottom: 4px; }
.auth-wrap p.sub { text-align: center; color: var(--ink-soft); margin-top: 0; margin-bottom: 12px; }
.auth-toggle { text-align: center; color: var(--ink-soft); font-size: 0.9rem; }
.auth-toggle a { color: var(--blue); font-weight: 600; cursor: pointer; text-decoration: none; }
.error-banner { background: var(--red-bg); color: var(--red); padding: 12px 14px; border-radius: var(--radius-sm); font-size: 0.9rem; }
.success-banner { background: var(--green-bg); color: var(--green); padding: 12px 14px; border-radius: var(--radius-sm); font-size: 0.9rem; }

/* ---------- Dashboard ---------- */
.greeting { padding: 4px 20px; }
.greeting h2 { margin: 0 0 2px; font-size: 1.4rem; }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 0 20px; margin-bottom: 20px; }
.stat-tile { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.stat-tile .label { font-size: 0.78rem; color: var(--ink-soft); font-weight: 600; text-transform: uppercase; letter-spacing: 0.02em; }
.stat-tile .value { font-size: 1.4rem; font-weight: 800; margin-top: 4px; }
.stat-tile.wide { grid-column: span 2; }

.quick-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; padding: 0 20px; margin-bottom: 24px; }
.quick-btn {
  background: #fff; border-radius: var(--radius-sm); box-shadow: var(--shadow); border: none; padding: 16px 6px;
  display: flex; flex-direction: column; align-items: center; gap: 6px; cursor: pointer; font-size: 0.78rem; font-weight: 600; color: var(--ink);
}
.quick-btn .emoji { font-size: 1.5rem; }

.section { padding: 0 20px; margin-bottom: 24px; }
.section h3 { font-size: 1rem; margin: 0 0 12px; }

/* ---------- Table-ish rows ---------- */
.row-list { display: flex; flex-direction: column; gap: 10px; }
.row-item { background: #fff; border-radius: var(--radius-sm); box-shadow: var(--shadow); padding: 12px 14px; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.row-item .main { font-weight: 600; font-size: 0.92rem; }
.row-item .sub { font-size: 0.78rem; color: var(--ink-soft); }
.row-item .amount { font-weight: 700; }

/* ---------- Bottom nav ---------- */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; background: #fff; border-top: 1px solid var(--line);
  display: flex; justify-content: center; z-index: 40;
}
.bottom-nav-inner { max-width: 560px; width: 100%; display: flex; }
.bottom-nav button {
  flex: 1; border: none; background: transparent; padding: 10px 4px 14px; display: flex; flex-direction: column;
  align-items: center; gap: 2px; font-size: 0.68rem; font-weight: 600; color: var(--ink-soft); cursor: pointer;
}
.bottom-nav button.active { color: var(--ink); }
.bottom-nav button .emoji { font-size: 1.2rem; }

/* ---------- Toast ---------- */
#toast {
  position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px; font-size: 0.85rem; z-index: 100;
  box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: opacity 0.2s ease;
}
#toast.show { opacity: 1; }

/* ---------- PDF viewer ---------- */
.pdf-frame-wrap { background: #fff; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.pdf-frame-wrap iframe { width: 100%; height: 60vh; border: none; display: block; }

::-webkit-scrollbar { width: 0; height: 0; }

@media (min-width: 640px) {
  .step-card { padding: 18px 22px; }
}
