/* Built for a phone in direct sun: light ground, dark text, big tap targets. */
:root {
  --navy: #161213;
  --blue: #185ca7;
  --blue-dark: #124a87;
  --gold: #f6b81a;
  --light-blue: #81a9d4;
  --bg: #eef1f5;
  --card: #ffffff;
  --text: #161213;
  --muted: #535c68;
  --line: #cfd6df;
  --red: #b42318;
  --red-bg: #fdecea;
  --green: #1e7b45;
  --green-bg: #e6f4ea;
  --radius: 12px;
  --tap: 52px;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font: 17px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}

h1 { font-size: 1.5rem; line-height: 1.2; margin: 0 0 4px; }
h2 { font-size: 1.15rem; margin: 20px 0 10px; }
h3 { font-size: 1.05rem; margin: 0; }
p { margin: 0 0 8px; }
a { color: var(--blue); }

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.loading, .empty { color: var(--muted); padding: 32px 0; text-align: center; }

/* ---------- chrome ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(8px + env(safe-area-inset-top)) 16px 8px;
  background: var(--navy);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 10;
}
.logo { height: 30px; width: auto; }
.app-name { font-weight: 700; letter-spacing: 0.02em; }
.user { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: 0.9rem; }
.user-name { opacity: 0.85; }

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

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  background: var(--card);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 10;
}
.tabbar a {
  flex: 1;
  text-align: center;
  padding: 18px 0;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  border-top: 3px solid transparent;
}
.tabbar a.active { color: var(--blue); border-top-color: var(--blue); }

/* ---------- controls ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  padding: 0 20px;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.btn:disabled { opacity: 0.45; cursor: default; }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-primary:active:not(:disabled) { background: var(--blue-dark); }
.btn-block { display: flex; width: 100%; margin-top: 12px; }
.btn-small { min-height: 44px; padding: 0 14px; font-size: 0.95rem; }

.link {
  background: none;
  border: none;
  padding: 8px 4px;
  color: var(--blue);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.link-light { color: #fff; opacity: 0.85; font-size: 0.9rem; }
.link:disabled { color: var(--muted); cursor: default; }

.input {
  display: block;
  width: 100%;
  min-height: var(--tap);
  padding: 10px 14px;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  font: inherit;
}
.input:focus { outline: none; border-color: var(--blue); }
textarea.input { resize: vertical; }
.label { display: block; font-size: 0.8rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin-bottom: 6px; }
.hint { margin: 6px 0 0; font-size: 0.9rem; color: var(--muted); }

.alert {
  background: var(--red-bg);
  color: var(--red);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin: 8px 0 12px;
  font-weight: 600;
}

.chip {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--navy);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
  white-space: nowrap;
}
.chip-muted { background: var(--line); color: var(--muted); }

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  margin: 12px 0;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.06);
}

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 4px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--navy);
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-weight: 600;
  z-index: 20;
}

/* ---------- sign in ---------- */

.signin { padding-top: 40px; text-align: center; }
.signin p:not(.alert) { color: var(--muted); }

/* ---------- today ---------- */

.job-list, .result-list, .items, .edit-items { list-style: none; margin: 0; padding: 0; }

.job {
  display: block;
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin: 10px 0;
  color: var(--text);
  text-decoration: none;
  border-left: 5px solid var(--blue);
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.06);
}
.job:active { background: #f4f7fb; }
.job-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.job-time { font-weight: 700; color: var(--blue); }
.job-title { font-size: 1.1rem; font-weight: 700; margin: 4px 0 2px; }
.job-addr { color: var(--muted); }
.job-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 6px; }
.badge-done { background: var(--green-bg); color: var(--green); font-size: 0.8rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; }

/* ---------- a check ---------- */

.job-header { margin-bottom: 8px; }
.back { display: inline-block; padding: 6px 0 10px; font-weight: 600; text-decoration: none; }

.stage-picker { display: grid; gap: 12px; }
.stage-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  width: 100%;
  min-height: 96px;
  padding: 18px 20px;
  border: 2px solid var(--blue);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.stage-btn strong { font-size: 1.3rem; color: var(--blue); }
.stage-btn span { color: var(--muted); }
.stage-btn:active { background: #eaf1fa; }

.stage-row { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.stage-pill { background: var(--gold); color: var(--navy); font-weight: 800; padding: 6px 14px; border-radius: 999px; }
.van-input { font-size: 1.4rem; font-weight: 700; max-width: 180px; }
.legend { font-size: 0.9rem; color: var(--muted); margin-top: 16px; }

.category-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.subtotal { font-weight: 800; color: var(--blue); white-space: nowrap; }

.item { padding: 12px 0; border-top: 1px solid var(--line); }
.item:first-child { border-top: none; }
.item-text { font-weight: 600; margin-bottom: 8px; }

.scores { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.score {
  min-height: var(--tap);
  border: 2px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-size: 1.2rem;
  font-weight: 800;
  cursor: pointer;
  touch-action: manipulation;
}
.score[aria-pressed="true"][data-score="1"],
.score[aria-pressed="true"][data-score="2"] { background: var(--red); border-color: var(--red); color: #fff; }
.score[aria-pressed="true"][data-score="3"] { background: var(--gold); border-color: var(--gold); color: var(--navy); }
.score[aria-pressed="true"][data-score="4"],
.score[aria-pressed="true"][data-score="5"] { background: var(--blue); border-color: var(--blue); color: #fff; }

.submit-bar {
  position: sticky;
  bottom: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px -16px calc(-76px - env(safe-area-inset-bottom));
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: var(--card);
  border-top: 1px solid var(--line);
  box-shadow: 0 -2px 8px rgb(0 0 0 / 0.08);
}
.submit-meta { display: flex; flex-direction: column; line-height: 1.2; flex: 1; min-width: 0; }
.total { font-size: 1.3rem; }
.left { padding: 2px 0; text-align: left; font-size: 0.9rem; }
.submit-btn { min-width: 140px; }

.done { text-align: center; padding-top: 24px; }
.done-mark {
  width: 72px;
  height: 72px;
  margin: 0 auto 12px;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  font-size: 2.4rem;
  line-height: 72px;
}
.done-job { font-weight: 700; font-size: 1.1rem; }
.big-score { font-size: 1.6rem; font-weight: 800; color: var(--blue); margin: 4px 0; }

/* ---------- results ---------- */

.result {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin: 8px 0;
  color: var(--text);
  text-decoration: none;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.06);
}
.result-main { flex: 1; min-width: 0; }
.result-title { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.result-score { text-align: right; white-space: nowrap; font-size: 1.15rem; }
#van-filter { margin-bottom: 8px; }

.detail-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.item-readonly { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.item-readonly .item-text { margin: 0; }
.score-pill { flex: none; width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; font-weight: 800; }
.s1, .s2 { background: var(--red); color: #fff; }
.s3 { background: var(--gold); color: var(--navy); }
.s4, .s5 { background: var(--blue); color: #fff; }
.note { white-space: pre-wrap; margin: 0; }

/* ---------- checklist editor ---------- */

.segmented { display: grid; grid-template-columns: 1fr 1fr; border: 2px solid var(--blue); border-radius: var(--radius); overflow: hidden; margin: 12px 0; }
.segmented a { text-align: center; padding: 12px 0; font-weight: 700; text-decoration: none; color: var(--blue); }
.segmented a.active { background: var(--blue); color: #fff; }

.edit-item { display: flex; gap: 6px; align-items: center; padding: 6px 0; }
.edit-item .input { flex: 1; min-width: 0; }
.edit-actions { display: flex; gap: 4px; }
.icon-btn {
  width: 44px;
  height: 44px;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: #fff;
  font-size: 1.1rem;
  cursor: pointer;
}
.icon-btn:disabled { opacity: 0.35; cursor: default; }
.icon-btn.danger { color: var(--red); }
.add-row { display: flex; gap: 8px; margin-top: 8px; }
.add-row .input { flex: 1; min-width: 0; }

@media (max-width: 380px) {
  .detail-summary { grid-template-columns: 1fr 1fr; }
  .edit-item { flex-wrap: wrap; }
  .edit-actions { margin-left: auto; }
}
