/* The Cadbury Crew
   Built for a phone held in one hand, outdoors, possibly in the rain.
   Big tap targets, high contrast, nothing that needs precision. */

:root {
  --green: #4C7A1F;
  --orange: #E07A34;
  --char: #33312D;
  --muted: #8B8680;
  --line: #E5E1D8;
  --faint: #FAF9F6;
  --paper: #FFFFFF;
  --red: #B4442A;
  --tap: 48px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding-bottom: calc(68px + env(safe-area-inset-bottom));
  background: var(--faint);
  color: var(--char);
  font: 16px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

main { padding: 16px; max-width: 640px; margin: 0 auto; }

/* Visible to a screen reader, not to the eye. */
.sr {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------------------------------------------------------------- topbar */

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 12px 16px;
  background: var(--paper); border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 9px; text-decoration: none; color: inherit; }
.brand .leaf { width: 28px; height: 28px; }
.brand small { display: block; font-size: 12px; color: var(--muted); line-height: 1.2; }
.brand strong { display: block; font-size: 21px; font-weight: 600; line-height: 1.1; }

/* ---------------------------------------------------------------- account menu */

.avatar {
  display: flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--green); color: #fff;
  font-weight: 600; font-size: 16px; line-height: 1;
}
.avatar.lg { width: 42px; height: 42px; font-size: 18px; }

.usermenu { position: relative; }

.usermenu summary {
  list-style: none; cursor: pointer;
  display: flex; align-items: center;
  min-height: var(--tap); padding: 5px;
}
.usermenu summary::-webkit-details-marker { display: none; }
.usermenu summary::marker { content: ''; }
.usermenu summary:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; border-radius: 50%; }

.usermenu-panel {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 30;
  min-width: 210px; padding: 6px;
  background: var(--paper); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: 0 10px 28px rgba(51, 49, 45, .13);
}

.usermenu-who {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px;
}
.usermenu-who strong { display: block; font-size: 15px; line-height: 1.2; }
.usermenu-who small { display: block; font-size: 12px; color: var(--muted); }

.usermenu-panel a,
.usermenu-panel .signout {
  display: flex; align-items: center; width: 100%;
  min-height: 42px; padding: 8px 10px;
  border: 0; border-radius: 8px; background: none;
  color: var(--char); font: inherit; font-size: 15px;
  text-align: left; text-decoration: none; cursor: pointer;
}
.usermenu-panel a:hover,
.usermenu-panel .signout:hover { background: var(--faint); }
.usermenu-panel .signout { color: var(--red); }

/* ---------------------------------------------------------------- blocks */

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

h1 { font-size: 21px; font-weight: 600; margin: 0 0 14px; }
h2 { font-size: 17px; font-weight: 600; margin: 0 0 10px; }
h3 { font-size: 15px; font-weight: 600; margin: 0 0 6px; }

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

.flash {
  margin: 12px 16px 0; padding: 12px 14px;
  background: #EDF3E4; border: 1px solid #CBDDB4; border-left: 3px solid var(--green);
  border-radius: 0 8px 8px 0; font-size: 14px;
}

.envnote {
  max-width: 640px; margin: 0 auto 14px; padding: 0 16px;
  color: var(--orange); font-size: 13px; text-align: center;
}

.empty { padding: 28px 16px; text-align: center; color: var(--muted); }

/* ---------------------------------------------------------------- forms */

label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }

input[type=text], input[type=password], input[type=number],
input[type=file], select, textarea {
  width: 100%; min-height: var(--tap); padding: 11px 12px;
  border: 1px solid var(--line); border-radius: 9px;
  background: var(--paper); color: var(--char);
  font: inherit; font-size: 16px; /* 16px stops iOS zooming on focus */
}

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

.field { margin-bottom: 13px; }

input:focus-visible, select:focus-visible, textarea:focus-visible,
button:focus-visible, a:focus-visible {
  outline: 2px solid var(--green); outline-offset: 2px;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: var(--tap); padding: 12px 18px;
  border: 1px solid var(--line); border-radius: 9px;
  background: var(--paper); color: var(--char);
  font: inherit; font-weight: 500; cursor: pointer; text-decoration: none;
}

.btn.go { background: var(--green); border-color: var(--green); color: #fff; }
.btn.stop { background: var(--orange); border-color: var(--orange); color: #fff; }
.btn.link { border: 0; background: none; color: var(--muted); min-height: 36px; padding: 6px 2px; font-size: 13px; }
.btn.danger { color: var(--red); }
.btn.wide { width: 100%; }
.btn[disabled] { opacity: .55; cursor: default; }

.row { display: flex; gap: 9px; flex-wrap: wrap; }
.row > * { flex: 1; }

/* ---------------------------------------------------------------- job tiles */

.jobgrid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px;
  margin-top: 12px;
}
.jobgrid-full { grid-column: 1 / -1; margin-bottom: 0; }

@media (min-width: 520px) {
  .jobgrid { grid-template-columns: repeat(3, 1fr); }
}

.jobtile {
  display: flex; flex-direction: column; align-items: flex-start; gap: 3px;
  min-height: 86px; padding: 14px;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--paper); color: var(--char);
  font: inherit; text-align: left; cursor: pointer;
  transition: transform .06s ease, border-color .12s ease;
}
.jobtile:active { transform: scale(.985); }
.jobtile .jobtile-name { font-size: 16px; font-weight: 600; line-height: 1.25; }
.jobtile .jobtile-rate { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }

.jobtile.on {
  border-color: var(--green); border-width: 2px; padding: 13px;
  background: #EDF3E4; cursor: default;
}
.jobtile.on .jobtile-rate { color: #4A6A28; }
.jobtile.on .pill { margin-top: 4px; }

.clockout { margin-top: 16px; }

/* ---------------------------------------------------------------- photos */

.shots { display: grid; gap: 16px; }
@media (min-width: 520px) { .shots { grid-template-columns: 1fr 1fr; } }

.thumbs { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 10px; }

/* The camera button with the gallery picker tucked into its bottom-left
   corner, so both ways in are one tap and neither needs explaining. */
.shot-actions { position: relative; }
.shot-actions .picker.btn { padding-left: 58px; }

.picker.gallery {
  position: absolute; left: 6px; bottom: 6px;
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; margin: 0;
  border-radius: 8px; cursor: pointer;
  background: rgba(255, 255, 255, .2); color: #fff;
}
.picker.gallery:hover { background: rgba(255, 255, 255, .32); }
.picker.gallery svg { width: 21px; height: 21px; display: block; }

/* ---------------------------------------------------------------- timer */

.timer { text-align: center; padding: 8px 0 4px; }
.timer .clock {
  font-size: 42px; font-weight: 600; line-height: 1.1;
  font-variant-numeric: tabular-nums; letter-spacing: -.02em;
}
.timer .earned { color: var(--green); font-size: 17px; font-weight: 500; margin-top: 3px; }
.timer .what { color: var(--muted); font-size: 14px; margin-bottom: 10px; }

/* ---------------------------------------------------------------- lists */

.item {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--line);
}
.item:last-child { border-bottom: 0; }
.item .when { color: var(--muted); font-size: 13px; }
.item .amount { font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }

.pill {
  display: inline-block; padding: 2px 9px; border-radius: 99px;
  font-size: 12px; font-weight: 500; border: 1px solid;
}
.pill.ok     { background: #EDF3E4; border-color: #CBDDB4; color: #35540F; }
.pill.low    { background: #FDF2E6; border-color: #F3D6B4; color: #8A4A12; }
.pill.high   { background: #FDF2E6; border-color: #F3D6B4; color: #8A4A12; }
.pill.danger { background: #FBEAE6; border-color: #F0C4B8; color: #8C2F18; }
.pill.unknown{ background: var(--faint); border-color: var(--line); color: var(--muted); }

/* ---------------------------------------------------------------- tables */

table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td { text-align: left; padding: 9px 6px; border-bottom: 1px solid var(--line); }
th { font-size: 13px; color: var(--muted); font-weight: 500; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tfoot td { font-weight: 600; border-bottom: 0; border-top: 2px solid var(--char); }

/* ---------------------------------------------------------------- readings */

.readings { display: grid; grid-template-columns: repeat(2, 1fr); gap: 11px; }
@media (min-width: 480px) { .readings { grid-template-columns: repeat(3, 1fr); } }

.advice { border-left: 3px solid var(--orange); padding: 3px 0 3px 13px; margin-bottom: 14px; }
.advice .dose { font-weight: 500; margin-top: 5px; }

.verdict { padding: 13px 14px; border-radius: 9px; margin-bottom: 14px; font-weight: 500; }
.verdict.safe { background: #EDF3E4; color: #35540F; }
.verdict.unsafe { background: #FBEAE6; color: #8C2F18; }

.thumb { width: 54px; height: 54px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.thumb.sm { width: 34px; height: 34px; border-radius: 6px; }

/* ---------------------------------------------------------------- pickers */

/* The real file inputs sit behind these labels so they can look like every
   other button — still reachable by keyboard, just not drawn. */
.picker { margin-bottom: 0; }
.picker input[type=file] {
  position: absolute; width: 1px; height: 1px;
  min-height: 0; padding: 0; border: 0;
  opacity: 0; pointer-events: none;
}
.picker:focus-within { outline: 2px solid var(--green); outline-offset: 2px; }
.picker:has(input:disabled) { opacity: .55; cursor: default; }

.strip-preview {
  display: block; width: 100%; max-width: 200px;
  margin-top: 10px; border-radius: 9px; border: 1px solid var(--line);
}

/* ---------------------------------------------------------------- tabs */

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; background: var(--paper); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}

.tabs a {
  flex: 1; padding: 13px 4px 14px; text-align: center;
  font-size: 12px; color: var(--muted); text-decoration: none;
  border-top: 2px solid transparent; margin-top: -1px;
}
.tabs a.on { color: var(--green); border-top-color: var(--green); font-weight: 500; }

/* ---------------------------------------------------------------- login */

.loginwrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 20px; background: var(--faint);
}
.loginwrap form { width: 100%; max-width: 340px; }
.loginwrap .brand { justify-content: center; margin-bottom: 24px; }
.error { color: var(--red); font-size: 14px; margin-bottom: 12px; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
