:root {
  --ink: #1f2933; --muted: #62707d; --line: #d9dee3; --bg: #f3f4f1; --card: #fff;
  --accent: #f2a900; --accent-ink: #1f2933; --good: #1d7a46; --bad: #b3261e;
  --nav-h: 62px;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 17px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 16px);
}
a { color: inherit; }
h1 { font-size: 1.5rem; margin: 0 0 .6rem; line-height: 1.2; }
h2 { font-size: 1.05rem; margin: 0 0 .4rem; }
p { margin: 0 0 .6rem; }
small { color: var(--muted); font-size: .85rem; display: block; }
.muted { color: var(--muted); }
.center { text-align: center; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---- header and navigation */
.top { background: var(--ink); color: #fff; }
.brand { display: flex; align-items: center; gap: .55rem; padding: .75rem 1rem; font-weight: 700; text-decoration: none; letter-spacing: .01em; }
.mark { width: 22px; height: 22px; border-radius: 5px; background: repeating-linear-gradient(135deg, var(--accent) 0 6px, var(--ink) 6px 12px); border: 2px solid var(--accent); }
.mainnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex;
  background: var(--ink); padding-bottom: env(safe-area-inset-bottom);
  border-top: 1px solid #000;
}
.mainnav a {
  flex: 1; min-height: var(--nav-h); display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 3px; font-size: .72rem; text-decoration: none; color: #b8c1c9;
}
.mainnav a.on { color: var(--accent); }
.ic { display: inline-block; width: 24px; height: 24px; background: currentColor; -webkit-mask: var(--i) center/contain no-repeat; mask: var(--i) center/contain no-repeat; }
.ic-log   { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20zm1 5v4.6l3.5 2-1 1.7L11 12.7V7h2z'/%3E%3C/svg%3E"); }
.ic-hist  { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4 5h16v3H4zm0 5.5h16v3H4zM4 16h16v3H4z'/%3E%3C/svg%3E"); }
.ic-rep   { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4 20V10h4v10zm6 0V4h4v16zm6 0v-7h4v7z'/%3E%3C/svg%3E"); }
.ic-site  { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2a7 7 0 0 0-7 7c0 5 7 13 7 13s7-8 7-13a7 7 0 0 0-7-7zm0 9.5a2.5 2.5 0 1 1 0-5 2.5 2.5 0 0 1 0 5z'/%3E%3C/svg%3E"); }
.ic-users { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9 11a4 4 0 1 0 0-8 4 4 0 0 0 0 8zm8 0a3 3 0 1 0 0-6 3 3 0 0 0 0 6zM1 20c0-4 4-6 8-6s8 2 8 6v1H1zm17.5 1v-1c0-1.8-.7-3.2-1.8-4.3 3 .2 6.3 1.6 6.3 4.3v1z'/%3E%3C/svg%3E"); }
.ic-acct  { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 12a5 5 0 1 0 0-10 5 5 0 0 0 0 10zm-9 9c0-5 5-7 9-7s9 2 9 7v1H3z'/%3E%3C/svg%3E"); }
.ic-cam   { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9 4 7.5 6H4a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-3.500L15 4zm3 5a4 4 0 1 1 0 8 4 4 0 0 1 0-8z'/%3E%3C/svg%3E"); width: 20px; height: 20px; }

main { max-width: 960px; margin: 0 auto; padding: 1rem; }
.narrow main { max-width: 560px; }

/* ---- building blocks */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 1rem; margin: 0 0 .9rem; }
.stack > * + * { margin-top: .8rem; }
form.stack { display: block; }
label { display: block; font-weight: 600; font-size: .92rem; }
input, select, textarea {
  display: block; width: 100%; margin-top: .3rem; padding: .75rem .8rem; font: inherit; color: inherit;
  background: #fff; border: 1.5px solid #b9c1c9; border-radius: 10px; min-height: 50px;
}
textarea { min-height: 0; resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible, .btn:focus-visible, a:focus-visible, summary:focus-visible, button:focus-visible {
  outline: 3px solid var(--accent); outline-offset: 2px;
}
input:disabled, select:disabled { background: #eceeee; color: var(--muted); }
label.check { display: flex; align-items: center; gap: .6rem; font-weight: 500; min-height: 44px; }
label.check input { width: 24px; height: 24px; min-height: 0; margin: 0; flex: none; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem; min-height: 50px;
  padding: .6rem 1.1rem; font: inherit; font-weight: 700; color: var(--ink); background: #fff;
  border: 1.5px solid var(--ink); border-radius: 10px; text-decoration: none; cursor: pointer;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.ghost { border-color: #b9c1c9; font-weight: 600; }
.btn.big { width: 100%; min-height: 62px; font-size: 1.2rem; }
.btn.small { min-height: 40px; padding: .3rem .8rem; font-size: .88rem; }
.btn:disabled { background: #e3e5e3; border-color: #e3e5e3; color: #8a949d; cursor: not-allowed; }
.linkbtn { background: none; border: 0; padding: .8rem; font: inherit; font-size: .92rem; color: var(--muted); text-decoration: underline; cursor: pointer; }
.linkbtn.danger { color: var(--bad); padding-left: 0; }

.flash { padding: .75rem 1rem; border-radius: 10px; font-weight: 600; }
.flash.good { background: #dff3e6; color: var(--good); }
.flash.bad { background: #fbe4e2; color: var(--bad); }

.tag { display: inline-block; padding: .05rem .5rem; border-radius: 99px; background: #e8ebed; color: var(--muted); font-size: .75rem; font-weight: 600; vertical-align: middle; }
.tag.must { background: #fff1c9; color: #6b4a00; }

details > summary { cursor: pointer; font-weight: 600; min-height: 32px; display: flex; align-items: center; list-style: none; }
details > summary::-webkit-details-marker { display: none; }
details > summary::after { content: "+"; margin-left: auto; font-size: 1.3rem; color: var(--muted); }
details[open] > summary::after { content: "–"; }
details[open] > summary { margin-bottom: .7rem; }

.sticky { position: sticky; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 8px); z-index: 5; padding-top: .3rem; }
.sticky .btn { box-shadow: 0 6px 18px rgba(31, 41, 51, .25); }
.sticky p { margin: 0 0 .4rem; background: var(--bg); border-radius: 8px; }

/* ---- worksite picker */
.sitelist { display: grid; gap: .5rem; }
.site { position: relative; display: block; font-weight: 400; font-size: 1rem; cursor: pointer; }
.site input { position: absolute; opacity: 0; width: 1px; height: 1px; min-height: 0; margin: 0; }
.sitebody { display: block; padding: .85rem 1rem .85rem 3rem; min-height: 60px; background: var(--card); border: 2px solid var(--line); border-radius: 12px; position: relative; }
.sitebody b { display: block; font-size: 1.05rem; }
.sitebody::before { content: ""; position: absolute; left: 1rem; top: 50%; width: 22px; height: 22px; margin-top: -11px; border: 2px solid #9aa5af; border-radius: 50%; background: #fff; }
.site input:checked + .sitebody { border-color: var(--ink); background: #fff8e1; }
.site input:checked + .sitebody::before { border: 7px solid var(--ink); background: var(--accent); }
.site input:focus-visible + .sitebody { outline: 3px solid var(--accent); outline-offset: 2px; }
.site[hidden] { display: none; }

/* ---- on-site card */
.onsite { background: var(--ink); color: #fff; border-color: var(--ink); border-left: 8px solid var(--accent); }
.onsite .muted { color: #b8c1c9; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: .6rem 1rem; margin: .6rem 0 0; }
.facts dt { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.onsite .facts dt { color: #b8c1c9; }
.facts dd { margin: 0; font-size: 1.15rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.note { white-space: pre-wrap; margin: .8rem 0 0; padding-top: .7rem; border-top: 1px solid var(--line); }

/* ---- photos */
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: .5rem; margin-bottom: .6rem; }
.thumbs:empty { display: none; }
.thumb { position: relative; aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: #dfe3e6; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb.busy img { opacity: .45; }
.thumb .del { position: absolute; top: 4px; right: 4px; width: 32px; height: 32px; border-radius: 50%; border: 0; background: rgba(31, 41, 51, .85); color: #fff; font-size: 1.2rem; line-height: 1; cursor: pointer; }
.upbtns { display: flex; flex-wrap: wrap; gap: .5rem; }
.upbtns .btn { flex: 1 1 140px; }
.upstatus { margin: .5rem 0 0; font-size: .9rem; color: var(--muted); min-height: 1.3em; }
.upstatus.bad { color: var(--bad); font-weight: 600; }

/* ---- lists */
.rows { display: grid; gap: .5rem; }
.row { display: flex; align-items: center; justify-content: space-between; gap: .8rem; padding: .8rem 1rem; min-height: 60px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; text-decoration: none; }
.row .grow { flex: 1; text-decoration: none; }
.row b { display: block; }
.row.off { opacity: .6; }
.rows.flat .row { border: 0; border-top: 1px solid var(--line); border-radius: 0; padding: .6rem 0; min-height: 0; }
.rows.flat .row:first-child { border-top: 0; }
.quickadd { display: flex; gap: .5rem; margin-bottom: .5rem; }
.quickadd input { margin: 0; flex: 1; }

.langswitch { display: flex; gap: .5rem; justify-content: center; margin-top: 1rem; }
.card .langswitch { justify-content: flex-start; margin-top: 0; }
.langswitch button { min-height: 44px; padding: .3rem 1rem; font: inherit; background: #fff; border: 1.5px solid #b9c1c9; border-radius: 99px; cursor: pointer; }
.langswitch button.on { background: var(--ink); border-color: var(--ink); color: #fff; }

/* ---- reports */
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; align-items: end; }
.filters > * { min-width: 0; }
.filters label:first-child, .filters .chips, .filters .btn { grid-column: 1 / -1; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip { display: inline-flex; align-items: center; gap: .35rem; min-height: 40px; padding: .2rem .85rem; border: 1.5px solid #b9c1c9; border-radius: 99px; background: #fff; font-size: .9rem; text-decoration: none; }
.chip.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip.static { min-height: 30px; border-color: var(--line); background: #f6f7f5; }
.grand { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; margin: 0 .2rem .8rem; }
.grand b { white-space: nowrap; font-size: 1.4rem; font-variant-numeric: tabular-nums; }
.report header { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.report header b { font-size: 1.15rem; }
.byworker { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; margin: .3rem 0 .4rem; font-size: .9rem; }
.dayblock { border-top: 1px solid var(--line); padding: .6rem 0 .2rem; }
.dayhead { display: flex; justify-content: space-between; font-weight: 700; background: #f6f7f5; margin: 0 -.4rem .3rem; padding: .3rem .4rem; border-radius: 6px; }
.workerline { display: grid; grid-template-columns: 1fr auto; gap: .1rem .8rem; padding: .35rem 0; }
.workerline .wname { font-weight: 600; }
.workerline .wvisits { grid-column: 1 / -1; grid-row: 2; display: flex; flex-wrap: wrap; gap: .3rem .5rem; }
.wvisits a { display: inline-flex; align-items: center; gap: .4rem; min-height: 36px; padding: .1rem .6rem; border: 1px solid var(--line); border-radius: 8px; font-size: .9rem; font-variant-numeric: tabular-nums; text-decoration: none; }
.wvisits small { display: inline; }
.wvisits em { color: #6b4a00; font-style: normal; font-weight: 600; }

/* ---- computer: navigation moves to the top bar */
@media (min-width: 800px) {
  body { padding-bottom: 2rem; }
  .top { display: flex; align-items: center; justify-content: space-between; padding: 0 1rem; }
  .mainnav { position: static; border: 0; padding: 0; gap: .25rem; }
  .mainnav a { flex: none; flex-direction: row; gap: .45rem; min-height: 54px; padding: 0 .9rem; font-size: .95rem; }
  .mainnav .ic { width: 18px; height: 18px; }
  .sticky { position: static; }
  .sticky .btn { box-shadow: none; }
  .filters { grid-template-columns: 2fr 1fr 1fr auto; }
  .filters label:first-child, .filters .btn { grid-column: auto; }
  .workerline { grid-template-columns: 180px 1fr auto; }
  .workerline .wvisits { grid-column: auto; grid-row: auto; }
}
