:root {
  --bg: #eef0f2;
  --card: #ffffff;
  --ink: #16191d;
  --muted: #5d6670;
  --line: #d9dde2;
  --accent: #e8590c;
  --go: #1f8a4c;
  --go-ink: #fff;
  --stop: #c92a2a;
  --warn: #c77700;
  --warn-bg: #fff4e0;
  --info: #1c6dd0;
  --bad: #c92a2a;
  --bad-bg: #ffe9e9;
  --ok: #1f8a4c;
  --radius: 14px;
  --logo-filter: none;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 14px rgba(0,0,0,.05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101316; --card: #1a1e23; --ink: #eef1f4; --muted: #9aa4ae; --line: #2c3239;
    --warn-bg: #3a2a0c; --bad-bg: #3a1616; --shadow: none; color-scheme: dark; --logo-filter: invert(1);
  }
}
:root[data-theme="dark"] {
    --bg: #101316; --card: #1a1e23; --ink: #eef1f4; --muted: #9aa4ae; --line: #2c3239;
    --warn-bg: #3a2a0c; --bad-bg: #3a1616; --shadow: none; color-scheme: dark; --logo-filter: invert(1);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: env(safe-area-inset-bottom);
}
body.no-scroll { overflow: hidden; }
h2, h3 { margin: 0 0 .25rem; }
h3 { font-size: 1.05rem; }
p { margin: .4rem 0; }
a { color: var(--info); }
code { background: var(--bg); padding: 1px 5px; border-radius: 5px; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.center { text-align: center; }
.pad-lg { padding: 3rem 1rem; }
.ok { color: var(--ok); } .bad { color: var(--bad); }
.row { display: flex; align-items: center; gap: .5rem; }
.row.between { justify-content: space-between; }
.row.gap { gap: .6rem; }
.row.end, td.end { justify-content: flex-end; text-align: right; }
.grow { flex: 1; }
.col { display: flex; flex-direction: column; gap: .35rem; }

/* header */
.top {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5;
  display: flex; justify-content: space-between; align-items: center;
  padding: .6rem max(16px, env(safe-area-inset-right, 0px)) .6rem max(16px, env(safe-area-inset-left, 0px));
  background: #16191d; color: #fff;
}
.top .btn.ghost { color: #fff; border-color: #3a4048; background: transparent; }
.brand { display: flex; align-items: center; gap: .65rem; }
.brand b { display: block; line-height: 1.1; }
.brand small { display: block; opacity: .7; font-size: .8rem; }
.logo {
  width: 38px; height: 38px; border-radius: 10px; background: var(--accent); color: #fff;
  display: grid; place-items: center; font-weight: 800; letter-spacing: -.5px; flex: none;
}

.wrap { max-width: 560px; margin: 0 auto; padding: 1rem; display: flex; flex-direction: column; gap: .85rem; }
.wrap.wide { max-width: 1200px; }
.card { background: var(--card); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); border: 1px solid var(--line); }
.warn-card { background: var(--warn-bg); border-color: transparent; }

/* buttons */
.btn {
  appearance: none; border: 1px solid var(--line); background: var(--card); color: var(--ink);
  border-radius: 12px; padding: .8rem 1rem; font: inherit; font-weight: 600; cursor: pointer;
  text-decoration: none; text-align: center; display: inline-block;
}
.btn:active { transform: translateY(1px); }
.btn.sm { padding: .4rem .7rem; font-size: .88rem; border-radius: 9px; }
.btn.wide { width: 100%; }
.btn.go { background: var(--go); color: var(--go-ink); border-color: var(--go); }
.btn.stop { background: var(--stop); color: #fff; border-color: var(--stop); }
.btn.alt { background: transparent; border: 2px solid var(--accent); color: var(--accent); width: 100%; }
.btn.ghost { background: transparent; }
.btn.xl { width: 100%; font-size: 1.35rem; padding: 1.15rem; border-radius: 16px; letter-spacing: .3px; }
.link { background: none; border: 0; color: var(--info); font: inherit; padding: .5rem 0 0; cursor: pointer; text-decoration: underline; }

/* forms */
.label { display: block; font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: .75rem 0 .3rem; }
input, select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px; padding: .7rem .8rem;
}
select { appearance: auto; }
textarea { resize: vertical; }
form .row.gap { margin-top: 1rem; }
.hint { font-size: .85rem; color: var(--muted); margin: .6rem 0 0; }
.checks { display: grid; grid-template-columns: 1fr 1fr; gap: .35rem .75rem; }
.checks label, .confirm { display: flex; align-items: center; gap: .5rem; }
.checks input, .confirm input { width: 22px; height: 22px; flex: none; }
.confirm { margin-top: 1rem; font-weight: 600; }
.formrow { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 .8rem; margin-bottom: .8rem; }

/* status */
.status { text-align: center; padding: 1.2rem 1rem; }
.state { font-size: 1.4rem; font-weight: 800; display: inline-flex; align-items: center; gap: .5rem; }
.state .dot { width: 14px; height: 14px; border-radius: 50%; background: var(--muted); }
.state.on .dot { background: var(--go); box-shadow: 0 0 0 5px color-mix(in srgb, var(--go) 25%, transparent); }
.state.trailer .dot { background: var(--accent); box-shadow: 0 0 0 5px color-mix(in srgb, var(--accent) 25%, transparent); }
.since { color: var(--muted); margin-top: .2rem; }
.big { font-size: 2.6rem; font-weight: 800; font-variant-numeric: tabular-nums; margin-top: .2rem; }
.actions { display: flex; flex-direction: column; gap: .7rem; }
.actions .label { margin-top: 0; }

/* punch list */
.punches { list-style: none; margin: .6rem 0 0; padding: 0; }
.punches li { display: flex; gap: .75rem; align-items: flex-start; padding: .65rem 0; border-top: 1px solid var(--line); }
.punches li:first-child { border-top: 0; }
.punches .t { width: 5.2rem; flex: none; font-weight: 700; font-variant-numeric: tabular-nums; }
.punches .t s { display: block; font-weight: 400; color: var(--muted); font-size: .85rem; }
.punches .what { flex: 1; min-width: 0; }
.punches .what small { display: block; color: var(--muted); }
.punches li.voided { opacity: .5; }
.punches li.voided .t { text-decoration: line-through; }
.chip { display: inline-block; font-size: .75rem; font-weight: 700; padding: .15rem .5rem; border-radius: 99px; background: var(--bg); margin: .25rem .25rem 0 0; }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.ok { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.chip.info { background: color-mix(in srgb, var(--info) 14%, transparent); color: var(--info); }
.chip.bad { background: var(--bad-bg); color: var(--bad); }
details summary { cursor: pointer; }
.corr { font-size: .85rem; margin-top: .4rem; padding: .4rem .6rem; border-left: 3px solid var(--warn); background: var(--bg); border-radius: 0 8px 8px 0; }
.corr.approved { border-color: var(--info); }
.corr.rejected { border-color: var(--bad); opacity: .7; }
.corr small { display: block; color: var(--muted); }
.corr .st { text-transform: uppercase; font-weight: 700; }

/* login */
.login { max-width: 440px; margin: 0 auto; padding: calc(2rem + env(safe-area-inset-top)) 1rem 2rem; display: flex; flex-direction: column; gap: 1rem; }
.login .brand { justify-content: center; margin-bottom: .5rem; }
.login .brand b { font-size: 1.3rem; }
.who { display: flex; flex-direction: column; gap: .5rem; }
.name-btn {
  font: inherit; font-size: 1.1rem; font-weight: 700; text-align: left; padding: 1rem 1.1rem;
  border-radius: 14px; border: 1px solid var(--line); background: var(--card); color: var(--ink);
  display: flex; justify-content: space-between; align-items: center; cursor: pointer;
}
.name-btn small { color: var(--muted); font-weight: 500; font-size: .85rem; }
.name-btn.last { border: 2px solid var(--accent); }
.dots { display: flex; justify-content: center; gap: .8rem; margin: 1rem 0; }
.dots i { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--muted); }
.dots i.on { background: var(--ink); border-color: var(--ink); }
.pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; margin-bottom: .5rem; }
.pad button { font: inherit; font-size: 1.6rem; font-weight: 600; padding: .9rem 0; border-radius: 14px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); cursor: pointer; }
.pad button:active { background: var(--line); }

/* modal */
.modal-wrap { position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.5); display: flex; align-items: flex-end; justify-content: center; }
.modal {
  background: var(--card); width: 100%; max-width: 520px; max-height: 92vh; overflow: auto;
  border-radius: 18px 18px 0 0; padding: 1.2rem 1.2rem calc(1.2rem + env(safe-area-inset-bottom));
}
.modal.modal-wide { max-width: 720px; }
@media (min-width: 640px) { .modal-wrap { align-items: center; } .modal { border-radius: 18px; } }

/* toast + busy */
#toast {
  position: fixed; left: 50%; bottom: calc(1rem + env(safe-area-inset-bottom)); transform: translate(-50%, 150%);
  background: #16191d; color: #fff; padding: .8rem 1.1rem; border-radius: 12px; z-index: 40; max-width: 92vw;
  font-weight: 600; transition: transform .25s; pointer-events: none; text-align: center;
}
#toast.show { transform: translate(-50%, 0); }
#toast.ok { background: var(--go); } #toast.bad { background: var(--stop); }
#busy { position: fixed; inset: 0; z-index: 30; background: rgba(0,0,0,.45); display: grid; place-items: center; color: #fff; font-weight: 700; text-align: center; }
.spinner { width: 44px; height: 44px; margin: 0 auto .6rem; border: 4px solid rgba(255,255,255,.3); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* admin */
.tabs { display: flex; gap: .25rem; padding: .5rem 1rem 0; background: #16191d; overflow-x: auto; }
.tabs button { font: inherit; font-weight: 700; color: #b9c1c9; background: transparent; border: 0; padding: .6rem .9rem; border-radius: 10px 10px 0 0; cursor: pointer; white-space: nowrap; }
.tabs button.on { background: var(--bg); color: var(--ink); }
.badge { background: var(--accent); color: #fff; border-radius: 99px; padding: 0 .45rem; font-size: .75rem; margin-left: .2rem; }
.weeknav { flex-wrap: wrap; gap: .6rem; }
.legend { display: flex; flex-wrap: wrap; gap: .4rem 1rem; font-size: .82rem; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: .3rem; }
.flag { width: 9px; height: 9px; border-radius: 50%; display: inline-block; background: var(--muted); }
.flag.bad { background: var(--bad); } .flag.warn { background: var(--warn); } .flag.info { background: var(--info); }
.table-scroll { overflow-x: auto; background: var(--card); border-radius: var(--radius); border: 1px solid var(--line); }
table { border-collapse: collapse; width: 100%; }
.grid th, .grid td { padding: .55rem .5rem; border-bottom: 1px solid var(--line); text-align: center; white-space: nowrap; }
.grid thead th { font-size: .78rem; color: var(--muted); font-weight: 700; }
.grid tbody th { text-align: left; position: sticky; left: 0; background: var(--card); }
.grid tbody th span { display: block; }
.grid tbody th small, .grid td small { display: block; color: var(--muted); font-size: .75rem; font-weight: 500; }
.grid .cell { cursor: pointer; position: relative; min-width: 76px; }
.grid .cell:hover { background: var(--bg); }
.grid .cell.empty { color: var(--line); }
.grid .cell .flag { position: absolute; top: 6px; right: 6px; }
.grid .live { color: var(--go) !important; font-weight: 700 !important; }
.grid .tot { background: var(--bg); }
.list th, .list td { padding: .55rem .4rem; border-bottom: 1px solid var(--line); text-align: left; }
.list th { font-size: .78rem; color: var(--muted); }
.list select { width: auto; padding: .35rem .5rem; }
.list tr.off { opacity: .55; }
.sum { display: flex; gap: 1.5rem; margin: .8rem 0; }
.sum small { display: block; color: var(--muted); font-size: .8rem; }
.sum b { font-size: 1.6rem; }
.dayhead { margin: .6rem 0 0; color: var(--muted); }
.report .label { margin: .3rem 0 .1rem; }
.edit p { margin: .35rem 0; }
.modal .report { margin-top: .8rem; }

body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: #16191d; }

/* daily report crew list */
.crewlist { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; margin-bottom: .5rem; }
.crewrow { display: flex; align-items: center; gap: .6rem; padding: .55rem .7rem; border-top: 1px solid var(--line); background: var(--card); }
.crewrow:first-child { border-top: 0; }
.crewrow .who-chk { flex: 1; min-width: 0; display: flex; align-items: center; gap: .6rem; }
.crewrow .who-chk input { width: 22px; height: 22px; flex: none; }
.crewrow .who-chk span { min-width: 0; }
.crewrow .who-chk b, .crewrow .who-chk small { display: block; }
.crewrow .who-chk small { color: var(--muted); font-size: .8rem; }
.crewrow .hrs { display: flex; align-items: center; gap: .3rem; flex: none; }
.crewrow .hrs input { width: 4.6rem; text-align: right; padding: .5rem; font-variant-numeric: tabular-nums; }
.crewrow .hrs small { color: var(--muted); }

/* lunch, 8-hour stop, overtime */
.state.cap .dot { background: var(--warn); }
.state.ot .dot { background: var(--info); box-shadow: 0 0 0 5px color-mix(in srgb, var(--info) 25%, transparent); }
.capnote { background: var(--warn-bg); border-radius: 12px; padding: .8rem .9rem; }
.lunch-opts { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; margin: 1rem 0; }
.lunch-opts .btn { font-size: 1.1rem; padding: 1.1rem .4rem; display: flex; flex-direction: column; align-items: center; gap: .2rem; }
.lunch-opts .btn small { font-size: .7rem; font-weight: 500; }
.lunch-opts .btn:disabled { opacity: .45; cursor: not-allowed; }
.chip.ot { background: color-mix(in srgb, var(--info) 14%, transparent); color: var(--info); }
.grid small.ot-pending, .sum .ot-pending { color: var(--warn) !important; font-weight: 700 !important; }
.grid small.ot-approved, .sum .ot-approved { color: var(--info) !important; font-weight: 700 !important; }
.grid small.ot-rejected, .sum .ot-rejected { color: var(--bad) !important; text-decoration: line-through; }
.sum { flex-wrap: wrap; }
.otbox { margin-bottom: .6rem; }

/* Weld Works logo */
.logo-img { display: block; height: auto; max-width: 100%; }
.top .logo-img { height: 32px; width: auto; filter: invert(1); }
.top .brand > div { border-left: 1px solid #3a4048; padding-left: .65rem; }
.login-brand { display: flex; flex-direction: column; align-items: center; gap: .4rem; margin-bottom: .5rem; }
.login-brand .logo-img { width: min(280px, 72vw); filter: var(--logo-filter); }
.login-brand small { color: var(--muted); font-weight: 700; letter-spacing: .08em; text-transform: uppercase; font-size: .8rem; }

.small-btns .btn { width: auto; padding: .6rem .5rem; font-size: .9rem; }

.pick-list { display: flex; flex-direction: column; gap: .5rem; margin: 1rem 0; }
.pick-list .btn { display: flex; justify-content: space-between; align-items: center; text-align: left; padding: .9rem 1rem; }
.pick-list .btn b { font-variant-numeric: tabular-nums; }

.punches li.replaced { opacity: .6; }
.punches li.replaced .t { text-decoration: line-through; }

.list td:nth-child(2) { white-space: nowrap; font-variant-numeric: tabular-nums; }

/* report: progress + photos */
[hidden] { display: none !important; }
.progress-opts { display: flex; flex-direction: column; gap: .4rem; margin-bottom: .5rem; }
.progress-opts label { display: flex; align-items: center; gap: .55rem; font-weight: 600; }
.progress-opts input { width: 22px; height: 22px; flex: none; }
.photo-row { display: flex; gap: .6rem; flex-wrap: wrap; }
.photo-row:empty { display: none; }
.photo-thumb { position: relative; width: 110px; height: 110px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); }
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-thumb button { position: absolute; top: 4px; right: 4px; width: 28px; height: 28px; border-radius: 50%; border: 0; background: rgba(0,0,0,.65); color: #fff; font-size: 1.1rem; line-height: 1; cursor: pointer; }
.photo-add { margin-top: .5rem; cursor: pointer; }
.rphotos { display: flex; gap: .5rem; margin-top: .5rem; }
.rphotos img { width: 90px; height: 90px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.help-steps { padding-left: 1.2rem; margin: .6rem 0; display: flex; flex-direction: column; gap: .45rem; }

/* crew: this week */
.table-scroll.flat { border: 0; background: transparent; }
.weektbl { width: 100%; font-variant-numeric: tabular-nums; }
.weektbl th, .weektbl td { padding: .45rem .3rem; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
.weektbl th:first-child { text-align: left; font-weight: 600; }
.weektbl thead th { font-size: .75rem; color: var(--muted); font-weight: 700; }
.weektbl th small { color: var(--go); font-weight: 700; margin-left: .2rem; }
.weektbl td small { display: block; font-size: .7rem; font-weight: 700; }
.weektbl td small.warn { color: var(--warn); } .weektbl td small.bad { color: var(--bad); }
.weektbl tfoot th, .weektbl tfoot td { font-weight: 800; border-bottom: 0; }
.weektbl .chip { margin: 0; }

.weektbl tr.wk-day { cursor: pointer; }
.weektbl .wk-arrow { display: inline-block; width: 1em; color: var(--muted); transition: transform .15s; }
.weektbl tr.wk-day.open .wk-arrow { transform: rotate(90deg); }
.weektbl tr.wk-detail td { text-align: left; white-space: normal; background: var(--bg); font-size: .88rem; line-height: 1.6; padding: .5rem .7rem; }
.weektbl tr.wk-detail b { font-variant-numeric: tabular-nums; display: inline-block; min-width: 4.6rem; }

/* new hire orientation */
.ob-progress { height: 5px; background: var(--line); }
.ob-progress i { display: block; height: 100%; background: var(--accent); transition: width .2s; }
.ob-card h2 { font-size: 1.4rem; text-wrap: balance; margin-bottom: .6rem; }
.ob-step { margin: 0 0 .2rem; font-size: .78rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.ob-points { margin: 0 0 1rem; padding-left: 1.15rem; display: flex; flex-direction: column; gap: .6rem; line-height: 1.45; }
.ob-points li::marker { color: var(--accent); }
.ob-ok { margin: 0 0 1rem; padding: .8rem; border-radius: 12px; background: var(--bg); font-size: 1.05rem; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.ob-card .capnote { margin-bottom: .8rem; }

/* prevailing wage */
.chip.pwchip { background: color-mix(in srgb, #7c3aed 14%, transparent); color: #7c3aed; }
.pwtxt { color: #7c3aed; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .chip.pwchip, :root:not([data-theme="light"]) .pwtxt { color: #b794f6; } }
.pwchk { margin: .2rem 0 0; font-weight: 600; }
.weektbl td.pwtxt small { color: #7c3aed; }
