:root {
  --ink: #1d2433;
  --muted: #6b7385;
  --line: #e3e6ec;
  --bg: #f6f7f9;
  --card: #fff;
  --brand: #0b6e74;
  --brand-dark: #08525a;
  --accent: #0b6e74;
  --accent-bg: #e6f4f3;
  --accent-line: #a9d8d4;
  --star: #f2a516;
  --pass: #e7f4ea;
  --pass-ink: #2f7a45;
  --fail: #c62f3b;
  --fail-bg: #fbe5e7;
  --warn: #9a6400;
  --warn-bg: #fff2d6;
  --na: #f0f1f4;
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.45 "Inter", -apple-system, "Segoe UI", Roboto, Arial, sans-serif; color: var(--ink); background: var(--bg); }
button { font: inherit; cursor: pointer; }
input, select { font: inherit; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }

.topbar { display: flex; align-items: center; gap: 24px; padding: 0 20px; height: 56px; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 800; font-size: 19px; color: var(--ink); letter-spacing: -0.4px; }
.brand img { width: 26px; height: 26px; }
.brand .word b { color: var(--brand); font-weight: 800; }
nav { display: flex; gap: 4px; }
nav button { border: 0; background: none; padding: 8px 12px; border-radius: 6px; color: var(--muted); }
nav button.active { background: var(--accent-bg); color: var(--brand); font-weight: 600; }
.pickers { margin-left: auto; display: flex; gap: 14px; color: var(--muted); }
.pickers select { margin-left: 6px; color: var(--ink); }

main { padding: 20px; }
h2 { margin: 0 0 4px; font-size: 20px; }
.sub { color: var(--muted); margin-bottom: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin-bottom: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.btn { border: 1px solid var(--line); background: #fff; padding: 6px 12px; border-radius: 6px; }
.btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn.danger { color: var(--fail); }
.btn.small { padding: 3px 8px; font-size: 12px; }

table.list { width: 100%; border-collapse: collapse; }
table.list th, table.list td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); }
table.list th { font-size: 12px; text-transform: uppercase; letter-spacing: .3px; color: var(--muted); font-weight: 600; }
table.list td.actions { text-align: right; white-space: nowrap; }

/* Flag grid */
.grid-wrap { overflow: auto; max-height: calc(100vh - 170px); border: 1px solid var(--line); border-radius: 10px; background: #fff; }
table.grid { border-collapse: separate; border-spacing: 0; font-size: 12px; }
table.grid th, table.grid td { border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); }
table.grid thead th { position: sticky; background: #fafbfc; z-index: 2; }
table.grid thead tr.sections th { top: 0; height: 30px; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .3px; padding: 0 6px; }
table.grid thead tr.checks th { top: 30px; height: 96px; vertical-align: bottom; padding: 4px; font-weight: 600; min-width: 46px; max-width: 46px; }
table.grid thead tr.checks th div { writing-mode: vertical-rl; transform: rotate(180deg); white-space: nowrap; margin: 0 auto; }
table.grid .fac { position: sticky; left: 0; background: #fff; z-index: 1; min-width: 260px; max-width: 260px; padding: 6px 10px; text-align: left; }
table.grid thead .fac { z-index: 3; background: #fafbfc; }
table.grid .fac a { color: var(--ink); font-weight: 600; text-decoration: none; }
table.grid .fac a:hover { color: var(--brand); }
table.grid .fac small { display: block; color: var(--muted); }
table.grid .tot { min-width: 54px; text-align: center; font-weight: 700; }
td.cell { text-align: center; cursor: pointer; height: 38px; font-weight: 700; }
td.cell.pass { background: var(--pass); color: var(--pass-ink); font-weight: 400; }
td.cell.fail { background: var(--fail-bg); color: var(--fail); }
td.cell.warn { background: var(--warn-bg); color: var(--warn); }
td.cell.na { background: var(--na); color: #aab; font-weight: 400; }
td.cell:hover { outline: 2px solid var(--brand); outline-offset: -2px; }
.legend { display: flex; gap: 14px; color: var(--muted); font-size: 12px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -2px; margin-right: 4px; }

/* Facility detail */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-bottom: 16px; }
.tile { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.tile .k { font-size: 12px; color: var(--muted); }
.tile .v { font-size: 22px; font-weight: 700; margin-top: 2px; }
.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); font-weight: 700; margin: 18px 0 6px; }
.check { background: #fff; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 6px; }
.check-head { display: flex; align-items: center; gap: 10px; padding: 9px 12px; cursor: pointer; }
.check-head .name { flex: 1; }
.check-head .note { color: var(--muted); font-size: 12px; }
.badge { min-width: 70px; text-align: center; padding: 2px 8px; border-radius: 20px; font-size: 12px; font-weight: 700; }
.badge.pass { background: var(--pass); color: var(--pass-ink); }
.badge.fail { background: var(--fail-bg); color: var(--fail); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.na { background: var(--na); color: var(--muted); }
.check-body { display: none; padding: 0 12px 12px; max-height: 360px; overflow: auto; }
.check.open .check-body { display: block; }
.check.flash { outline: 2px solid var(--brand); }
.empty { color: var(--muted); padding: 30px; text-align: center; }

#toast { position: fixed; bottom: 20px; right: 20px; background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 8px; display: none; max-width: 480px; z-index: 50; }
#toast.err { background: var(--fail); }

/* Login + users */
.who { color: var(--muted); font-size: 13px; white-space: nowrap; }
#scopePick { max-width: 280px; }
.login { max-width: 380px; margin: 10vh auto; }
.login .brand { font-size: 28px; margin-bottom: 6px; }
.login input { width: 100%; margin-bottom: 10px; padding: 9px 10px; }
.login .btn { width: 100%; padding: 9px; }
.role { display: inline-block; padding: 1px 8px; border-radius: 20px; font-size: 12px; font-weight: 600; background: #eef0f4; }
.role.admin { background: #e5eefa; color: var(--brand); }
.role.staff { background: var(--pass); color: var(--pass-ink); }
.grant { display: inline-flex; gap: 6px; align-items: center; background: #f3f4f7; border-radius: 6px; padding: 2px 4px 2px 8px; margin: 2px 4px 2px 0; font-size: 12px; }
.grant b { font-weight: 600; }
.grant button { border: 0; background: none; color: var(--fail); padding: 0 4px; }
.readonly { display: inline-block; margin-left: 8px; font-size: 12px; color: var(--warn); background: var(--warn-bg); padding: 2px 8px; border-radius: 20px; }

/* keep the top bar on one line */
nav button, .pickers label, .who, #logout { white-space: nowrap; }
.pickers { align-items: center; gap: 10px; }
.pickers label { display: flex; align-items: center; }
.topbar { gap: 16px; }
nav button { padding: 8px 10px; }
@media (max-width: 1350px) { .who { display: none; } }

/* Employee shift calendar */
table.cal { width: 100%; border-collapse: collapse; table-layout: fixed; }
table.cal th { font-size: 12px; color: var(--muted); font-weight: 600; padding: 4px; text-align: center; }
table.cal td { border: 1px solid var(--line); padding: 4px 6px 6px; vertical-align: top; height: 58px; }
table.cal td.out { background: #fafbfc; }
table.cal td.wk { text-align: right; font-weight: 700; color: var(--muted); vertical-align: middle; width: 80px; }
table.cal .dn { font-size: 11px; color: var(--muted); }
table.cal input.hrs { width: 100%; text-align: right; padding: 4px 6px; }
table.cal input.hrs:disabled { background: #fff; color: var(--ink); border-color: transparent; }

.bulk { border-color: var(--brand); background: #f7faff; }
.bulk label.day { font-size: 13px; color: var(--muted); }
.card.excluded { background: #fafafa; }
.card.excluded td { color: var(--muted); text-decoration: line-through; }

/* Popup */
.modal-back { position: fixed; inset: 0; background: rgba(20, 28, 45, .45); display: flex; align-items: flex-start; justify-content: center; padding-top: 8vh; z-index: 40; }
.modal { background: #fff; border-radius: 10px; width: 600px; max-width: 94vw; box-shadow: 0 20px 50px rgba(0,0,0,.25); overflow: hidden; }
.modal-head { background: var(--brand); color: #fff; font-size: 18px; padding: 14px 18px; display: flex; justify-content: space-between; align-items: center; }
.modal-head .x { background: none; border: 0; color: #fff; font-size: 24px; line-height: 1; }
.modal-body { padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.modal-body label { display: flex; flex-direction: column; font-size: 12px; color: var(--muted); gap: 4px; }
.modal-body label.inline { flex-direction: row; align-items: center; gap: 8px; font-size: 14px; color: var(--ink); }
.modal-body input, .modal-body select { padding: 9px 10px; font-size: 14px; color: var(--ink); }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); }
.modal-body label { min-width: 0; }
.modal-body input, .modal-body select { width: 100%; box-sizing: border-box; }
.modal-body label.inline input { width: auto; }

/* Quarterly Totals tables */
table.tot th, table.tot td { padding: 6px 8px; font-size: 13px; white-space: nowrap; }
table.tot th { text-transform: none; letter-spacing: 0; color: var(--ink); background: #fafbfc; border: 1px solid var(--line); }
table.tot td { border: 1px solid var(--line); }
table.tot .r { text-align: right; }
table.tot .c { text-align: center; }
table.tot .b, table.tot tr.b td { font-weight: 700; }

/* single calendar with stacked job/pay rows */
.swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
table.cal.one th.lblc, table.cal.one td.lblc { width: 240px; text-align: left; }
table.cal.one th.wkh { width: 80px; }
table.cal.one input.hrs { display: block; margin-top: 3px; height: 29px; box-sizing: border-box; }
table.cal.one .clbl { height: 29px; line-height: 29px; margin-top: 3px; font-size: 12px; padding-left: 6px; border-left: 3px solid; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
table.cal.one td.wk { vertical-align: top; }
table.cal.one .wkv { height: 29px; line-height: 29px; margin-top: 3px; }
table.cal.one .wkt { border-top: 1px solid var(--line); margin-top: 3px; color: var(--ink); }

/* Line Item Detail */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }
.seg button { border: 0; background: none; padding: 7px 11px; font-size: 13px; cursor: pointer; color: var(--muted); border-right: 1px solid var(--line); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--accent, var(--accent)); color: #fff; }
table.lines th, table.lines td { white-space: nowrap; }
table.lines td.r, table.lines th.r { text-align: right; }
table.lines thead tr:first-child th { cursor: pointer; user-select: none; }
table.lines thead th { position: sticky; background: #fff; z-index: 1; }
table.lines thead tr:nth-child(1) th { top: 0; }
table.lines thead tr.filt th { top: 34px; padding: 4px 6px; }
table.lines thead tr.tot td { position: sticky; top: 72px; background: #f3f6fb; z-index: 1; border-bottom: 2px solid var(--line); }
table.lines tr.filt input { width: 100%; min-width: 60px; padding: 4px 6px; font-size: 12px; box-sizing: border-box; }

/* Five-Star */
.stars { color: var(--star); letter-spacing: 1px; }
.stars .off { color: #d1d5db; }
.bigstars .stars { font-size: 40px; }
.fsTop { display: grid; grid-template-columns: 1fr 2fr 1fr; gap: 14px; }
.fsTop .k { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; }
.fsTop .v { font-size: 20px; font-weight: 700; }
.fsTop .big { font-size: 56px; font-weight: 700; line-height: 1; }
.fsTop .of { font-size: 22px; color: var(--muted); }
table.cuts td { padding: 4px 8px; }
table.cuts tr.on td { background: #ecfdf5; font-weight: 700; }
.mcards { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; margin: 14px 0; }
.mcard { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 10px; }
.mcard.off { opacity: .5; }
.mcard .mh { font-weight: 600; font-size: 13px; display: flex; justify-content: space-between; gap: 6px; min-height: 34px; }
.mcard .exl { font-weight: 400; font-size: 12px; white-space: nowrap; }
.mcard .mp b { font-size: 34px; }
.mcard .mp span { color: var(--muted); font-size: 16px; }
table.mt { width: 100%; font-size: 12px; margin-top: 6px; }
table.mt th { color: var(--muted); font-weight: 600; font-size: 11px; text-align: left; }
table.mt td { font-weight: 600; vertical-align: top; }
table.mt .sub { font-weight: 400; font-size: 11px; margin: 0; }
.sbar { display: flex; gap: 2px; margin-top: 8px; }
.sbar span { flex: 1; height: 10px; background: var(--brand); border-radius: 2px; }
.sbar span.on { outline: 2px solid #111; outline-offset: 1px; opacity: 1 !important; }
table.fs td.r, table.fs th.r, table.fsall td.r, table.fsall th.r { text-align: right; }
table.fs input.wi, .card label input.wi { width: 110px; text-align: right; padding: 4px 6px; }
input.wi.changed { background: #fef9c3; border-color: #eab308; }
table.fs tr.adj td { background: #f0fdf4; }
.wibox { background: #fef9c3; border-color: #eab308; }
.warnbox { background: var(--warn-bg); border-color: var(--warn); color: var(--warn); }
@media (max-width: 1200px) { .mcards { grid-template-columns: repeat(3, 1fr); } .fsTop { grid-template-columns: 1fr; } }

/* topbar wraps when there are many tabs */
.topbar { height: auto; min-height: 56px; flex-wrap: wrap; row-gap: 4px; padding-top: 4px; padding-bottom: 4px; }
.topbar .pickers { margin-left: auto; flex-wrap: wrap; }
.topbar #scopePick { max-width: 260px; }
.sbar span { cursor: pointer; }
.sbar span:hover { outline: 1px solid #555; outline-offset: 1px; }
.sbar span.tgt { outline: 2px dashed var(--accent); outline-offset: 2px; opacity: 1 !important; }
.tgtnote { font-size: 12px; color: var(--accent); font-weight: 600; margin-top: 6px; }
input.wage { width: 60px; text-align: right; padding: 3px 5px; }
table.fs tr.proj td { background: var(--accent-bg); }
.planbox { background: var(--accent-bg); border: 1px solid var(--accent-line); border-radius: 8px; padding: 10px; margin-bottom: 10px; }
details.collap > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 12px; }
details.collap > summary::before { content: "▸"; font-size: 14px; color: var(--muted); }
details.collap[open] > summary::before { content: "▾"; }
details.collap .sumline { margin-left: auto; text-transform: none; font-weight: 700; color: var(--accent); letter-spacing: 0; }
table.fs tr.turned td { color: #b91c1c; }
table.ratings { margin-top: 10px; font-size: 13px; }
table.ratings td, table.ratings th { padding: 4px 8px; }
table.ratings tr.proj td { background: var(--accent-bg); }
.sub .cur { font-weight: 700; color: var(--accent); }
.up { color: #16a34a; } .down { color: #dc2626; }
.info { display: inline-flex; align-items: center; justify-content: center; width: 15px; height: 15px; border-radius: 50%;
  background: var(--accent); color: #fff; font-size: 10px; font-weight: 700; font-style: italic; cursor: help; vertical-align: middle; }

/* PBJ files + Submit */
.duebar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; background: var(--accent-bg); border: 1px solid var(--accent-line); border-radius: 8px; padding: 8px 12px; margin: 8px 0 12px; font-size: 14px; }
.duebar.soon { background: var(--warn-bg); border-color: var(--warn); }
.duebar.over { background: var(--fail-bg); border-color: var(--fail); color: var(--fail); }
.fchip { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 10px; background: #f1f5f9; color: var(--muted); text-decoration: none; white-space: nowrap; }
.fchip.created { background: #e0f2fe; color: #0369a1; }
.fchip.submitted { background: #fef9c3; color: #854d0e; }
.fchip.accepted { background: #dcfce7; color: #166534; }
.fchip.rejected { background: var(--fail-bg); color: var(--fail); }
table.grid th.sel, table.grid td.sel { width: 26px; text-align: center; }
table.grid th.file, table.grid td.file { width: 110px; text-align: center; }
.steps { display: flex; gap: 4px; flex-wrap: wrap; margin: 4px 0; }
.steps span { font-size: 11px; padding: 3px 8px; border-radius: 10px; background: #f1f5f9; color: var(--muted); white-space: nowrap; }
.steps span.done { background: #dcfce7; color: #166534; }
.steps span.now { background: var(--accent); color: #fff; font-weight: 600; }
.rvitem { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin-top: 8px; }
.rvitem.ok { background: #f0fdf4; border-color: #bbf7d0; }
.rvitem .rvNote { width: 100%; margin-top: 6px; padding: 4px 8px; font-size: 13px; box-sizing: border-box; }
.rvitem .rvDetail { margin-top: 8px; max-height: 320px; overflow: auto; }
.card.locked { opacity: .55; }
.modal.wide { width: min(1100px, 95vw); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.fail { background: var(--fail-bg); color: var(--fail); }
.settings { position: relative; }
.settings .menu { position: absolute; right: 0; top: 110%; background: #fff; border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12); min-width: 180px; z-index: 50; padding: 4px; }
.settings .menu button { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 8px 10px; border-radius: 6px; cursor: pointer; font-size: 14px; }
.settings .menu button:hover { background: #f1f5f9; }

/* ClearPBJ look */
.btn.primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
nav button:hover { color: var(--ink); }
h2 { letter-spacing: -0.3px; }
.login .brand { font-size: 24px; margin-bottom: 14px; }
.login .tag { color: var(--muted); margin: -8px 0 16px; font-size: 13px; }
.role.cmaster { background: #f3e8ff; color: #6d28d9; }
#actingBar { background: #fef3c7; border-bottom: 1px solid #f59e0b; color: #92400e; padding: 6px 20px; display: flex; gap: 10px; align-items: center; font-size: 13px; position: sticky; top: 56px; z-index: 19; }
#actingBar .btn { margin-left: auto; }

/* login-page PBJ deadline countdown */
.ticker { max-width: 520px; margin: 50px auto 18px; text-align: center; background: linear-gradient(135deg, #0b6e74, #08525a);
  color: #fff; border-radius: 14px; padding: 18px 20px 16px; box-shadow: 0 10px 30px rgba(8, 82, 90, .25); }
.ticker.urgent { background: linear-gradient(135deg, #b4232f, #7f1d1d); box-shadow: 0 10px 30px rgba(127, 29, 29, .3); }
.tk-head { font-size: 13px; font-weight: 600; letter-spacing: .3px; opacity: .9; }
.tk-clock { display: flex; justify-content: center; gap: 12px; margin: 12px 0 8px; }
.tk-cell { background: rgba(255, 255, 255, .12); border-radius: 10px; min-width: 86px; padding: 10px 6px 6px; }
.tk-cell span { display: block; font-size: 38px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1; }
.tk-cell small { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 1px; opacity: .8; margin-top: 6px; }
.tk-foot { font-size: 13px; opacity: .9; }
.login { margin-top: 0 !important; }
