:root {
  --navy: #1B2A5B;
  --red: #E2342B;
  --light: #F2F4F8;
  --mid: #8893A8;
  --text: #1A1F2B;
  --border: #D7DCE7;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--text);
  background: var(--light);
  -webkit-text-size-adjust: 100%;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  background: #fff;
  padding: 12px 16px;
  border-bottom: 3px solid var(--red);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-logo { height: 44px; width: auto; }
.topbar-title { color: var(--navy); font-weight: 800; font-size: 20px; letter-spacing: 1px; }

.wrap { max-width: 760px; margin: 0 auto; padding: 16px; }

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

h1 { color: var(--navy); font-size: 22px; margin: 0 0 8px; }
h2 { color: var(--navy); font-size: 17px; margin: 0 0 12px; }

.muted { color: var(--mid); }
.hint { display: block; color: var(--mid); font-size: 12px; margin-top: 4px; }
.req { color: var(--red); }

label { display: block; font-weight: 600; margin: 12px 0 6px; font-size: 14px; }

input[type="text"], input[type="password"], input[type="date"], textarea {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0; /* allow shrinking inside flex/grid parents */
  box-sizing: border-box;
  padding: 13px 12px;
  font-size: 16px; /* >=16px prevents iOS zoom on focus */
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  -webkit-appearance: none; /* stop iOS giving date inputs an intrinsic, oversized width */
  appearance: none;
}

/* iOS renders date inputs with internal padding that can overflow; keep it boxed. */
input[type="date"] {
  -webkit-appearance: none;
  appearance: none;
  height: 48px;
}
input[type="date"]::-webkit-date-and-time-value { text-align: left; }
input:focus, textarea:focus { outline: 2px solid var(--navy); border-color: var(--navy); }

textarea { resize: vertical; }

button { font-family: inherit; cursor: pointer; }

.btn-primary {
  width: 100%;
  background: var(--navy);
  color: #fff;
  border: none;
  padding: 15px;
  font-size: 17px;
  font-weight: 700;
  border-radius: 8px;
  margin-top: 14px;
}
.btn-primary:active { opacity: 0.9; }
.btn-submit { background: var(--red); }

.btn-secondary {
  background: #fff;
  color: var(--navy);
  border: 2px solid var(--navy);
  padding: 11px 16px;
  font-size: 15px;
  font-weight: 600;
  border-radius: 8px;
}

/* Full-width, less prominent (outlined) button — used for Log out. */
.btn-outline {
  width: 100%;
  background: #fff;
  color: var(--navy);
  border: 2px solid var(--navy);
  padding: 14px;
  font-size: 16px;
  font-weight: 700;
  border-radius: 8px;
  margin-top: 12px;
}
.btn-outline:active { background: var(--light); }

.file-input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.btn-photo {
  display: inline-block;
  background: var(--navy);
  color: #fff;
  padding: 13px 18px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 16px;
}

/* Work rows */
.work-row {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
  background: #fcfcfe;
  position: relative;
}
.work-row .row-remove {
  position: absolute; top: 8px; right: 8px;
  background: none; border: none; color: var(--red); font-size: 20px; line-height: 1;
}

/* Photo grid */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  margin-top: 14px;
}
.photo-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
  display: flex;
  flex-direction: column;
  min-width: 0; /* allow grid items to shrink rather than overflow */
}
.photo-card img { width: 100%; height: 130px; object-fit: cover; display: block; background: #eee; }
.photo-card .cap { border: none; border-top: 1px solid var(--border); padding: 8px; font-size: 13px; width: 100%; }
.photo-card .photo-remove {
  background: var(--red); color: #fff; border: none; padding: 8px; font-size: 13px; font-weight: 600;
}

/* Signature */
.sig-wrap { border: 2px dashed var(--mid); border-radius: 8px; background: #fff; touch-action: none; }
.sig-canvas { width: 100%; height: 180px; display: block; border-radius: 8px; touch-action: none; }

.error {
  background: #fdeceb; border: 1px solid var(--red); color: #a31810;
  padding: 12px; border-radius: 8px; margin-top: 12px; font-size: 14px;
}

.success { text-align: center; }
.success .tick {
  width: 64px; height: 64px; border-radius: 50%; background: #1f9d55; color: #fff;
  font-size: 36px; line-height: 64px; margin: 6px auto 12px;
}

.overlay {
  position: fixed; inset: 0; background: rgba(27,42,91,0.55);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: #fff; gap: 16px; z-index: 100; font-size: 17px;
}
.spinner {
  width: 46px; height: 46px; border: 5px solid rgba(255,255,255,0.35);
  border-top-color: #fff; border-radius: 50%; animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.hidden { display: none !important; }
