:root {
  --bg: #0f172a;
  --panel: #1e293b;
  --panel-2: #263449;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --accent: #3b82f6;
  --ok: #22c55e;
  --notok: #ef4444;
  --pending: #f59e0b;
  --border: #334155;
  --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);
  min-height: 100vh;
}

.wrap {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px;
  padding-bottom: calc(96px + env(safe-area-inset-bottom));
}

header.topbar {
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

header.topbar h1 {
  font-size: 16px;
  margin: 0;
}

header.topbar .sub {
  font-size: 12px;
  color: var(--muted);
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}

h2 { font-size: 15px; margin: 0 0 12px; color: var(--text); }
h3 { font-size: 13px; margin: 0 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
  margin-top: 10px;
}

input[type=text], input[type=date], input[type=password], input[type=tel], select, textarea {
  width: 100%;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font-size: 16px; /* 16px stops iOS Safari auto-zooming the page on focus */
  min-height: 46px;
}

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

button {
  font-size: 16px;
  padding: 13px 18px;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: white;
  font-weight: 600;
  cursor: pointer;
  min-height: 46px; /* comfortable thumb target on phones */
}

button.secondary {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
}

button.ghost {
  background: transparent;
  color: var(--accent);
  padding: 8px 10px;
}

button:disabled { opacity: .5; cursor: not-allowed; }

button.full { width: 100%; }

.btn-row { display: flex; gap: 10px; margin-top: 14px; }

.status-pill {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.status-ok { background: rgba(34,197,94,.15); color: var(--ok); }
.status-not_ok { background: rgba(239,68,68,.15); color: var(--notok); }
.status-pending { background: rgba(245,158,11,.15); color: var(--pending); }
.status-na { background: rgba(148,163,184,.15); color: var(--muted); }

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

.stage-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-2);
  cursor: pointer;
}
.stage-row.done { border-color: rgba(34,197,94,.4); }
.stage-thumb {
  width: 48px; height: 48px; border-radius: 6px; object-fit: cover;
  background: #0b1220; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; color: var(--muted);
}
.stage-thumb img { width: 100%; height: 100%; object-fit: cover; border-radius: 6px; }
.stage-info { flex: 1; min-width: 0; }
.stage-info .label { font-size: 14px; font-weight: 600; }
.stage-info .group { font-size: 11px; color: var(--muted); }
.stage-badge { font-size: 11px; color: var(--muted); }
.stage-badge.done { color: var(--ok); }
.stage-badge.required { color: var(--pending); }

.group-heading { font-size: 12px; color: var(--muted); text-transform: uppercase; margin: 18px 0 8px; letter-spacing: .04em; }
.group-heading:first-child { margin-top: 0; }

.checklist-section { margin-bottom: 18px; }
.checklist-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 8px;
  background: var(--panel-2);
}
.checklist-item .row1 {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}
.checklist-item .desc { font-size: 14px; line-height: 1.4; }
.checklist-item .num { color: var(--muted); font-size: 12px; margin-right: 4px; }
.checklist-item .notes { font-size: 12px; color: var(--muted); margin-top: 6px; }
.checklist-item .controls { display: flex; gap: 6px; margin-top: 10px; }
.checklist-item .controls button {
  flex: 1;
  padding: 8px 4px;
  font-size: 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--muted);
}
.checklist-item .controls button.active.ok { background: rgba(34,197,94,.2); color: var(--ok); border-color: var(--ok); }
.checklist-item .controls button.active.not_ok { background: rgba(239,68,68,.2); color: var(--notok); border-color: var(--notok); }
.checklist-item .controls button.active.na { background: rgba(148,163,184,.2); color: var(--muted); border-color: var(--muted); }
.checklist-item .ai-tag { font-size: 10px; color: var(--accent); margin-top: 4px; }

.tabs {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  display: flex;
  background: var(--panel);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 20;
}
.tabs button {
  flex: 1;
  background: transparent;
  border-radius: 0;
  color: var(--muted);
  font-weight: 600;
  font-size: 13px;
  padding: 14px 4px;
  min-height: 48px;
}
.tabs button.active { color: var(--accent); }

.hidden { display: none !important; }

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  padding: 4px 0;
  cursor: pointer;
  color: var(--text);
  font-size: 14px;
}
.checkbox-row input[type=checkbox] {
  width: 22px;
  height: 22px;
  min-height: 0;
  flex-shrink: 0;
  accent-color: var(--accent);
}

.progress-bar {
  height: 6px;
  background: var(--panel-2);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 4px;
}
.progress-bar .fill {
  height: 100%;
  background: var(--accent);
}

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

.banner {
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 14px;
}
.banner.info { background: rgba(59,130,246,.12); color: #93c5fd; }
.banner.warn { background: rgba(245,158,11,.12); color: #fcd34d; }
.banner.error { background: rgba(239,68,68,.12); color: #fca5a5; }
.banner.success { background: rgba(34,197,94,.12); color: #86efac; }

.yn-group { display: flex; gap: 8px; margin-top: 6px; }
.yn-group button { flex: 1; padding: 8px; font-size: 13px; background: var(--panel); border: 1px solid var(--border); color: var(--muted); }
.yn-group button.active { background: rgba(59,130,246,.2); color: var(--accent); border-color: var(--accent); }

.camera-modal {
  position: fixed; inset: 0; background: black; z-index: 50;
  display: flex; flex-direction: column;
}
.camera-modal video, .camera-modal img.preview { flex: 1; width: 100%; object-fit: contain; background: black; }
.camera-modal .cam-controls {
  padding: 16px; display: flex; justify-content: space-between; align-items: center; gap: 10px;
  background: #000;
}

.spinner {
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  width: 22px; height: 22px;
  animation: spin 0.8s linear infinite;
  display: inline-block;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------- LOGIN --- */
.login-screen {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 20px calc(24px + env(safe-area-inset-bottom));
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px 24px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, .35);
}

.login-badge {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: rgba(59, 130, 246, .15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  margin: 0 auto 16px;
}

.login-title {
  text-align: center;
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 2px;
}

.login-subtitle {
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  margin: 0 0 28px;
}

.login-card label {
  margin-top: 0;
  font-size: 13px;
}

.password-field {
  position: relative;
}

.password-field input {
  padding-right: 52px;
  font-size: 18px;
  min-height: 54px;
  letter-spacing: .04em;
}

.password-toggle {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 18px;
  padding: 0;
  min-height: 0;
  cursor: pointer;
}

.login-card .btn-row { margin-top: 22px; }

.login-card button.full {
  min-height: 54px;
  font-size: 17px;
}
