:root {
  --primary: #1976d2;
  --primary-dark: #124a86;
  --danger: #d32f2f;
  --bg: #f2f4f7;
  --card: #ffffff;
  --text: #1c1f26;
  --muted: #6b7280;
  --border: #e1e4e9;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.hidden { display: none !important; }

/* ---------- auth views ---------- */

.view { min-height: 100vh; }

#view-login, #view-otp {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  text-align: center;
}

.auth-card h1 { margin: 0 0 4px; color: var(--primary-dark); }
.auth-card label { display: block; text-align: left; margin: 14px 0 4px; font-size: 13px; color: var(--muted); }
.auth-links { display: flex; justify-content: space-between; margin-top: 10px; }

/* ---------- card ---------- */

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.muted { color: var(--muted); font-size: 13px; }

/* ---------- inputs & buttons ---------- */

input[type="text"], input[type="tel"], select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 16px; /* >=16px stops iOS Safari auto-zooming the page on focus */
  background: #fff;
  color: var(--text);
}

.btn {
  display: inline-block;
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: #f5f6f8; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.link { background: none; border: none; color: var(--primary); }
.btn.full { width: 100%; margin-top: 16px; }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn:disabled:hover { background: #fff; }
.btn.primary:disabled { background: var(--primary); }

/* ---------- top bar ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--primary-dark);
  color: #fff;
  padding: 0 20px;
  height: 56px;
}
.brand { font-weight: 600; font-size: 16px; }
.spacer { flex: 1; }
.user-box { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.user-box .btn.small { background: transparent; color: #fff; border-color: rgba(255,255,255,0.4); }

.content { max-width: 720px; margin: 0 auto; padding: 20px; }

/* ---------- toolbar ---------- */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
}
.toolbar select { width: auto; min-width: 160px; }

/* ---------- list / row cards ---------- */

.list { display: flex; flex-direction: column; gap: 10px; }

.row-card {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
}
.row-main { flex: 1; min-width: 0; }
.row-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 4px; }
.row-detail { font-size: 13.5px; margin-top: 2px; }
.row-actions { display: flex; flex-direction: column; gap: 6px; flex-shrink: 0; }

.loading, .empty {
  text-align: center;
  color: var(--muted);
  padding: 40px 0;
}

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: #eceff3;
  color: #44505c;
}
.badge.assigned { background: #fff3cd; color: #8a6400; }
.badge.inprogress { background: #d8ecff; color: #0b5fab; }
.badge.completed { background: #dcf3e1; color: #1a7a38; }

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 18px;
}

/* ---------- modal ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 18, 24, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 50;
}

.modal {
  background: #fff;
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 420px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal h2 { margin-top: 0; }
.modal label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 4px; }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

/* ---------- toast ---------- */

.toast {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 18px;
  border-radius: 8px;
  color: #fff;
  font-size: 14px;
  z-index: 100;
  box-shadow: 0 4px 10px rgba(0,0,0,0.15);
}
.toast.success { background: #1a7a38; }
.toast.error { background: var(--danger); }

@media (max-width: 480px) {
  .content { padding: 14px; }
  .toolbar select { min-width: 0; flex: 1 1 140px; }
  .row-card { flex-direction: column; }
  .row-actions { flex-direction: row; flex-wrap: wrap; align-self: stretch; }
  .row-actions .btn { flex: 1; text-align: center; }
  .modal { padding: 18px; }
}
