/* SafetyCheck AI — "Jobsite inspection board".
 * Charcoal masthead with hi-vis hazard band, safety-orange accent,
 * inspection-tag tabs, clipboard-style checklist cards. */
:root {
  --paper: #f6f4ee;
  --card: #fffdf9;
  --ink: #221c15;
  --ink-soft: #4c4438;
  --muted: #857768;
  --line: #e6dfd2;
  --accent: #ea580c;
  --accent-dark: #c2410c;
  --accent-soft: #fdeede;
  --char: #211d18;
  --char-2: #2c2721;
  --hivis: #f5b301;
  --green: #15803d;
  --green-soft: #e2f4e7;
  --red: #b91c1c;
  --red-soft: #fbe4e2;
  --amber-soft: #fdf0d7;
  --radius: 0;
  --shadow: 0 1px 2px rgba(40, 32, 20, .06), 0 10px 26px rgba(40, 32, 20, .07);
  --shadow-sm: 0 1px 2px rgba(40, 32, 20, .08);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  background: var(--paper);
  color: var(--ink);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
.loading { padding: 3rem; text-align: center; color: var(--muted); }

/* ---------- masthead ---------- */
.mast { background: var(--char); color: #f4efe4; }
.mast-top {
  max-width: 960px; margin: 0 auto; padding: 1.05rem 1.25rem;
  display: flex; align-items: center; justify-content: space-between;
  gap: .8rem; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: .75rem; }
.brand-mark {
  width: 34px; height: 34px; flex-shrink: 0;
  background: var(--hivis);
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
  position: relative;
}
.brand-text strong { display: block; font-size: 1.3rem; font-weight: 800; letter-spacing: -0.01em; }
.brand-text strong em { font-style: normal; color: var(--hivis); }
.brand-sub { display: block; font-size: .72rem; text-transform: uppercase; letter-spacing: .14em; color: #a89e8c; margin-top: .1rem; }
.tradesel { display: flex; align-items: center; gap: .55rem; font-size: .85rem; color: #cfc5b2; font-weight: 600; }
.tradesel span { text-transform: uppercase; letter-spacing: .1em; font-size: .7rem; }
.tradesel select {
  padding: .55rem .7rem; border-radius: 0; border: 1px solid #4a4237;
  background: var(--char-2); color: #fff; font-size: .95rem; font-weight: 600;
  cursor: pointer;
}
.tradesel select:focus { outline: 2px solid var(--accent); outline-offset: 2px; }
.hazard {
  height: 10px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='10'%3E%3Crect width='28' height='10' fill='%23f5b301'/%3E%3Cpolygon points='0,10 10,0 17,0 7,10' fill='%23211d18'/%3E%3Cpolygon points='14,10 24,0 31,0 21,10' fill='%23211d18'/%3E%3C/svg%3E");
  background-repeat: repeat-x;
  background-size: 28px 10px;
}

/* ---------- inspection tabs ---------- */
.tabs {
  max-width: 960px; margin: 0 auto; padding: 1.1rem 1.25rem 0;
  display: flex; gap: .5rem; flex-wrap: wrap;
}
.tab {
  border: 1px solid var(--line); background: var(--card); color: var(--ink-soft);
  padding: .6rem 1rem; border-radius: 0; cursor: pointer;
  font-size: .92rem; font-weight: 700;
  display: inline-flex; align-items: center; gap: .55rem;
  box-shadow: var(--shadow-sm);
  transition: border-color .15s, color .15s, transform .05s;
}
.tab:hover { border-color: var(--accent); color: var(--ink); }
.tab:active { transform: translateY(1px); }
.tab-n {
  font-size: .68rem; font-weight: 800; letter-spacing: .06em;
  background: #efe9db; color: var(--ink-soft);
  border-radius: 0; padding: .18rem .42rem;
}
.tab.active { background: var(--char); border-color: var(--char); color: #fff; }
.tab.active .tab-n { background: var(--accent); color: #fff; }

/* ---------- cards ---------- */
main { padding: 1.1rem 1.25rem 2.5rem; max-width: 960px; margin: 0 auto; display: grid; gap: 1.1rem; }
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.35rem 1.4rem;
  box-shadow: var(--shadow-sm);
  animation: cardIn .25s ease;
}
.card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: .4rem; }
.kicker {
  margin: 0 0 .25rem; font-size: .7rem; font-weight: 800;
  text-transform: uppercase; letter-spacing: .12em; color: var(--accent-dark);
}
.card h2 { margin: 0; font-size: 1.22rem; font-weight: 750; letter-spacing: -0.01em; }
.pct-big { font-size: 1.9rem; font-weight: 800; color: var(--char); line-height: 1; font-variant-numeric: tabular-nums; }
.pct-big span { font-size: 1rem; color: var(--muted); font-weight: 700; }
.muted { color: var(--muted); }
.small { font-size: .84rem; }
.err { color: var(--red); font-weight: 650; margin-top: .5rem; min-height: 1.2em; font-size: .9rem; }

/* ---------- progress ---------- */
.progress {
  position: relative; background: #efe9db; border-radius: 0;
  height: 1.55rem; margin: .8rem 0 1rem; overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(40, 32, 20, .12);
}
.progress .bar {
  background: var(--accent); height: 100%; border-radius: 0;
  transition: width .3s ease;
  box-shadow: inset 0 -3px 6px rgba(0,0,0,.12);
}
.progress span {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: .78rem; font-weight: 800; color: var(--ink);
  text-shadow: 0 1px 0 rgba(255,255,255,.5);
}

/* ---------- checklists ---------- */
.checks { border-top: 1px solid var(--line); }
.checkrow {
  display: flex; gap: .8rem; align-items: flex-start;
  padding: .72rem .2rem; border-bottom: 1px solid var(--line);
  cursor: pointer; font-size: .98rem; color: var(--ink);
  transition: background .12s;
  border-radius: 0;
}
.checkrow:hover { background: rgba(234, 88, 12, .05); }
.checkrow:last-child { border-bottom: none; }
.checkrow input {
  appearance: none; -webkit-appearance: none;
  width: 1.45rem; height: 1.45rem; margin: .1rem 0 0; flex-shrink: 0;
  border: 2px solid #b9ad97; border-radius: 0; background: #fff;
  cursor: pointer; position: relative;
  transition: background .15s, border-color .15s;
}
.checkrow input:checked { background: var(--accent); border-color: var(--accent-dark); }
.checkrow input:checked::after {
  content: "✓"; position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; font-size: 1rem;
}
.checkrow input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.checkrow .box { display: none; }
.checkrow .lbl { padding-top: .1rem; }
.checkrow.done .lbl { text-decoration: line-through; color: var(--muted); }
.complete {
  display: flex; align-items: center; gap: .6rem;
  color: var(--green); font-weight: 700; margin: 1rem 0 0;
  background: var(--green-soft); border-radius: 0; padding: .7rem .9rem;
}
.complete-badge {
  width: 1.6rem; height: 1.6rem; border-radius: 50%;
  background: var(--green); color: #fff; font-weight: 800;
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
}

/* ---------- toolbox talk ---------- */
.briefing { border-top: 4px solid var(--accent); }
.brief-head { display: flex; gap: 1rem; align-items: flex-start; margin-bottom: .6rem; }
.week-badge {
  flex-shrink: 0; font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em;
  background: var(--char); color: var(--hivis);
  padding: .45rem .75rem; border-radius: 0; margin-top: .15rem; white-space: nowrap;
}
.talktitle { font-size: 1.4rem; margin: 0; letter-spacing: -0.01em; }
.talkpts { margin: .9rem 0 0.5rem; padding: 0; display: grid; gap: .55rem; list-style: none; counter-reset: pt; }
.talkpts li {
  counter-increment: pt; position: relative;
  background: #faf7f0; border: 1px solid var(--line); border-radius: 0;
  padding: .75rem .95rem .75rem 3rem; font-size: .96rem;
}
.talkpts li::before {
  content: counter(pt); position: absolute; left: .9rem; top: .72rem;
  width: 1.5rem; height: 1.5rem; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent-dark);
  font-weight: 800; font-size: .8rem;
  display: flex; align-items: center; justify-content: center;
}

/* ---------- buttons / rows ---------- */
.btn {
  background: var(--accent); color: #fff; border: none; border-radius: 0;
  padding: .65rem 1.2rem; font-size: .95rem; font-weight: 700; cursor: pointer;
  box-shadow: 0 1px 2px rgba(194, 65, 12, .35);
  transition: background .15s, transform .05s;
}
.btn:hover { background: var(--accent-dark); }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); box-shadow: none; }
.btn.ghost:hover { border-color: var(--accent); color: var(--accent-dark); }
.row { display: flex; gap: .6rem; margin-top: 1rem; flex-wrap: wrap; }

/* ---------- incident log ---------- */
.statgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .65rem; margin: .9rem 0 1.1rem; }
.stat {
  background: var(--card); border: 1px solid var(--line); border-top: 3px solid var(--accent);
  border-radius: 0; padding: .75rem .5rem; text-align: center;
}
.stat.warn { border-top-color: var(--red); }
.stat.warn b { color: var(--red); }
.stat b { display: block; font-size: 1.65rem; font-weight: 800; color: var(--char); font-variant-numeric: tabular-nums; }
.stat span { font-size: .76rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.incform { display: grid; grid-template-columns: repeat(3, 1fr); gap: .65rem; margin-bottom: .4rem; }
.incform label { display: grid; gap: .3rem; font-size: .82rem; font-weight: 700; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .04em; }
.incform label.full, .incform .btn.full { grid-column: 1 / -1; }
.incform input, .incform select {
  padding: .6rem .65rem; border: 1px solid var(--line); border-radius: 0;
  font-size: .95rem; width: 100%; font-family: inherit; background: #fff; color: var(--ink);
  text-transform: none; letter-spacing: 0; font-weight: 400;
}
.incform input:focus, .incform select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(234, 88, 12, .15); }
.sev { padding: .2rem .6rem; border-radius: 0; font-size: .78rem; font-weight: 750; white-space: nowrap; }
.sev-low { background: var(--green-soft); color: var(--green); }
.sev-medium { background: var(--amber-soft); color: #92400e; }
.sev-high { background: var(--red-soft); color: var(--red); }
.tablewrap { overflow-x: auto; margin-top: .8rem; border: 1px solid var(--line); border-radius: 0; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; background: #fff; }
th, td { text-align: left; padding: .6rem .75rem; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:last-child td { border-bottom: none; }
th { color: var(--muted); font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; background: #faf7f0; }
td.d { font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--ink-soft); }
.emptybox {
  border: 1.5px dashed var(--line); border-radius: 0;
  padding: 1.4rem; text-align: center; margin-top: .8rem; background: #faf7f0;
}
.emptybox p { margin: .2rem 0; }

/* ---------- new: checklist tools, incident filters, trend, print ---------- */
.card-actions { display: flex; align-items: center; gap: .7rem; }
.btn.tiny { padding: .35rem .7rem; font-size: .8rem; }
.checktools { align-items: center; margin: 0 0 1rem; }
.statgrid { grid-template-columns: repeat(4, 1fr); }
.stat.ok { border-top-color: var(--green); }
.stat.ok b { color: var(--green); }
.incfilters {
  display: grid; grid-template-columns: 1fr 180px 170px auto; gap: .6rem;
  margin: .9rem 0 .2rem;
}
.incfilters input, .incfilters select {
  padding: .55rem .65rem; border: 1px solid var(--line); border-radius: 0;
  font-size: .9rem; font-family: inherit; background: #fff; color: var(--ink);
}
.incfilters input:focus, .incfilters select:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(234, 88, 12, .15);
}
.rowdel { text-align: right; white-space: nowrap; }
.trend { margin: .4rem 0 1.1rem; }
.weekbars { display: flex; gap: .5rem; align-items: flex-end; margin-top: .5rem; }
.wbar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: .2rem; }
.wbar span { font-size: .7rem; font-weight: 700; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.wbar i { display: block; width: 100%; background: var(--accent); min-height: 2px; }

@media print {
  .mast, .tabs, .foot, .row, .checktools, .btn, button, .incform, #incErr,
  .incfilters, .statgrid, .trend, .emptybox { display: none !important; }
  body { background: #fff; }
  main { max-width: 100%; padding: 0; margin: 0; }
  .card { box-shadow: none; border: none; padding: 0; margin: 0 0 1.5rem; break-inside: avoid; }
  .card-actions .tiny { display: none; }
  .checkrow .box { border-color: #000; }
}

.foot { text-align: center; color: var(--muted); font-size: .82rem; padding: 0 1rem; max-width: 960px; margin: 0 auto; }

@keyframes cardIn { from { opacity: 0; transform: translateY(8px); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

@media (max-width: 600px) {
  .incform { grid-template-columns: 1fr; }
  .incfilters { grid-template-columns: 1fr; }
  .tabs { flex-wrap: nowrap; overflow-x: auto; padding-bottom: .5rem; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { white-space: nowrap; }
  .statgrid { grid-template-columns: 1fr 1fr 1fr; gap: .5rem; }
  .stat b { font-size: 1.3rem; }
  .brief-head { flex-direction: column; gap: .5rem; }
  .card { padding: 1.1rem; }
  .mast-top { padding: .9rem 1rem; }
  .tabs { padding: 1rem 1rem 0; }
  main { padding: 1rem 1rem 2rem; }
}

/* ---------- corrective actions (sharp edges) ---------- */
.actions-card { border-top: 4px solid var(--ink); }
.action { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem;
  border: 1px solid var(--line); border-left: 4px solid var(--accent); background: #fff;
  padding: .7rem .8rem; margin-bottom: .5rem; }
.action.overdue { border-left-color: var(--red); background: var(--red-soft); }
.action-btns { display: flex; gap: .35rem; flex-shrink: 0; }
.od-badge { display: inline-block; background: var(--red); color: #fff; font-size: .68rem;
  font-weight: 800; text-transform: uppercase; letter-spacing: .08em; padding: .15rem .55rem; }

/* ---------- weekly safety score bars ---------- */
.scorebars { display: flex; gap: .5rem; align-items: flex-end; margin-top: .5rem; }
.sbar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: .2rem; }
.sbar span { font-size: .7rem; font-weight: 700; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.sbar i { display: block; width: 100%; background: var(--ink); min-height: 3px; }
.sbar.cur i { background: var(--accent); }
.sbar em { font-style: normal; font-size: .62rem; color: var(--muted); }

/* ---------- custom checklist items ---------- */
.custom-kind { border: 1px solid var(--line); background: #fff; padding: .6rem .8rem; margin-bottom: .5rem; }
.custom-kind h4 { margin: 0 0 .3rem; font-size: .9rem; }
.custom-kind ul { margin: .2rem 0; padding-left: 1.2rem; }
.custom-kind li { margin-bottom: .25rem; font-size: .88rem; }
.custom-list { margin-top: .8rem; }
.icon-btn.tiny { font-size: .65rem; padding: .1rem .3rem; }

/* ---------- streak banner + attendance ---------- */
.streak-banner {
  display: flex; align-items: center; gap: .6rem;
  border: 2px solid #b45309; background: #fef7e8;
  padding: .6rem .9rem; margin-bottom: 1rem; border-radius: 0;
  font-size: .95rem; color: #7c3f0c;
}
.streak-flame {
  width: 14px; height: 14px; flex: 0 0 14px;
  background: #f59e0b;
  clip-path: polygon(50% 0, 100% 55%, 75% 100%, 25% 100%, 0 55%);
}
.attend { margin-top: 1.2rem; border-top: 1px dashed var(--line); padding-top: 1rem; }
.attlist { list-style: none; margin: .6rem 0; padding: 0; display: flex; flex-wrap: wrap; gap: .4rem; }
.attlist li {
  border: 1px solid var(--line); background: var(--card);
  padding: .3rem .6rem; font-size: .88rem; font-weight: 600; border-radius: 0;
}
.cnt-badge {
  display: inline-block; font-size: .72rem; font-weight: 800; letter-spacing: .06em;
  text-transform: uppercase; color: #fff; background: #0f766e;
  padding: .15rem .5rem; margin-left: .5rem; border-radius: 0; vertical-align: middle;
}
.err.small { color: #b91c1c; min-height: 1.2em; }

/* ---------- redesign pass 2026-10-13: site status strip + inspection runner ---------- */
.statusstrip {
  background: var(--char); color: #f4efe4;
  border-radius: 0; padding: 1.25rem 1.35rem 1.35rem;
  box-shadow: var(--shadow); margin-bottom: 1.1rem;
}
.status-head { display: flex; align-items: baseline; justify-content: space-between; gap: .8rem; flex-wrap: wrap; margin-bottom: .9rem; }
.status-head .kicker { color: var(--hivis); }
.status-head h2 { margin: 0; font-size: 1.1rem; color: #fff; font-weight: 700; }
.statiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .55rem; }
.stile {
  background: var(--char-2); border: 1px solid #3a332b; border-left: 4px solid var(--hivis);
  padding: .7rem .8rem; min-width: 0;
}
.stile b { display: block; font-size: 1.35rem; font-weight: 800; color: #fff; font-variant-numeric: tabular-nums; line-height: 1.2; }
.stile span { font-size: .72rem; color: #a89e8c; text-transform: uppercase; letter-spacing: .06em; font-weight: 700; }
.stile.good { border-left-color: var(--green); }
.stile.good b { color: #7ddf9e; }
.stile.bad { border-left-color: var(--red); }
.stile.bad b { color: #ff9a8f; }
.inc-thumb {
  display: block; width: 72px; height: 54px; object-fit: cover;
  border: 1px solid var(--line); margin-bottom: .4rem; background: #faf7f0;
}
/* inspection runner: bigger field-friendly tap targets */
.card.inspect { padding-top: 0; }
.card.inspect .card-top {
  position: sticky; top: 0; background: var(--card); z-index: 2;
  padding-top: 1.35rem; border-bottom: 2px solid var(--char);
}
.checkrow { padding: 1rem .3rem; font-size: 1.02rem; }
.checkrow input { width: 1.7rem; height: 1.7rem; }
@media (max-width: 700px) {
  .statiles { grid-template-columns: repeat(2, 1fr); }
  .statusstrip { padding: 1rem; }
}
