:root {
  --navy: #1a365d;
  --navy-dark: #0f2440;
  --accent: #2b6cb0;
  --danger: #c53030;
  --success: #2f855a;
  --border: #cbd5e0;
  --bg: #f7fafc;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: #1a202c;
  -webkit-user-select: none;
  user-select: none;
}

input, textarea { -webkit-user-select: text; user-select: text; }

.hidden { display: none !important; }

.screen { min-height: 100vh; }

/* ---------------- Login ---------------- */
#loginScreen {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--navy);
}
.login-card {
  background: white;
  padding: 2.5rem;
  border-radius: 12px;
  width: 320px;
  text-align: center;
}
.login-card h1 { color: var(--navy); margin: 0 0 0.25rem; font-size: 1.5rem; }
.subtitle { color: #718096; margin: 0 0 1.5rem; }
#pinInput {
  width: 100%;
  font-size: 2rem;
  text-align: center;
  letter-spacing: 0.5rem;
  padding: 0.75rem;
  border: 2px solid var(--border);
  border-radius: 8px;
  margin-bottom: 1rem;
}
.error { color: var(--danger); margin-bottom: 1rem; }
#forgotPinLink { display: block; margin-top: 1rem; color: var(--accent); }
#offlineNotice { margin-top: 1rem; color: #718096; font-size: 0.9rem; }

/* ---------------- Buttons ---------------- */
.btn-primary {
  background: var(--navy);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 0.9rem 1.5rem;
  font-size: 1rem;
  cursor: pointer;
  width: 100%;
}
.btn-primary:disabled { background: #a0aec0; cursor: not-allowed; }
.btn-secondary {
  background: white;
  color: var(--navy);
  border: 2px solid var(--navy);
  border-radius: 8px;
  padding: 0.7rem 1.2rem;
  font-size: 0.95rem;
  cursor: pointer;
}
.btn-link { background: none; border: none; color: var(--accent); cursor: pointer; padding: 0.5rem; }

/* ---------------- App shell ---------------- */
#appHeader {
  background: var(--navy);
  color: white;
  padding: 1rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.banner {
  background: #fefcbf;
  padding: 0.75rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.banner-subtle {
  background: #ebf8ff;
  padding: 0.5rem 1.5rem;
  font-size: 0.9rem;
  color: #2c5282;
}

.view { padding: 1rem 1.5rem 4rem; }
.view-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

#runsList { list-style: none; padding: 0; }
#runsList li {
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 0.75rem;
  cursor: pointer;
}
#runsList .run-status { font-size: 0.85rem; color: #718096; }
#runsList .run-status.pending { color: #b7791f; }
#runsList .run-status.synced { color: var(--success); }

/* ---------------- Tabs ---------------- */
.tabs { display: flex; gap: 0.5rem; margin-bottom: 1rem; overflow-x: auto; }
.tab-btn {
  background: white;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.6rem 1.2rem;
  white-space: nowrap;
  cursor: pointer;
}
.tab-btn.active { background: var(--navy); color: white; border-color: var(--navy); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---------------- Form fields ---------------- */
label {
  display: block;
  margin-bottom: 0.9rem;
  font-weight: 600;
  font-size: 0.9rem;
  color: #2d3748;
}
input[type="text"], input[type="date"], input[type="time"], input[type="tel"],
input[type="number"], input[type="password"], textarea {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.65rem;
  font-weight: 400;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: 6px;
}
textarea { min-height: 4rem; }
fieldset { border: 1px solid var(--border); border-radius: 8px; margin-bottom: 0.9rem; }
fieldset label { display: inline-block; margin-right: 1rem; font-weight: 400; }
h3, h4, h5 { color: var(--navy); }
.hint { color: #718096; font-size: 0.9rem; }

/* ---------------- Signature scenario Q&A ---------------- */
.scenario-question { background: white; border: 1px solid var(--border); border-radius: 8px; padding: 1rem; margin-bottom: 1rem; }
.scenario-question p { font-weight: 600; margin-top: 0; }
.scenario-question button { margin-right: 0.5rem; }

/* ---------------- Signature slots ---------------- */
.signature-slot { background: white; border: 1px solid var(--border); border-radius: 8px; padding: 1rem; margin-bottom: 1rem; }
.slot-label { font-weight: 600; margin: 0 0 0.5rem; }
canvas.signature-pad {
  width: 100%;
  max-width: 600px;
  height: 200px;
  border: 2px dashed var(--border);
  border-radius: 6px;
  background: white;
  touch-action: none;
  display: block;
}
.signature-actions { margin-top: 0.75rem; display: flex; gap: 0.75rem; }
.locked-note { color: var(--success); font-weight: 600; }
.signature-slot.accepted canvas.signature-pad { border-style: solid; border-color: var(--success); }
