:root {
  --bg: #faf7f2; --card: #fff; --ink: #1f2933; --muted: #6b7280; --line: #e7e1d6;
  --brand: #c2410c; --brand-dark: #9a3412; --ok: #15803d; --warn: #b45309; --bad: #b91c1c;
  --ok-bg: #dcfce7; --warn-bg: #fef3c7; --bad-bg: #fee2e2; --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #17140f; --card: #221e17; --ink: #f3efe7; --muted: #a39e92; --line: #3a342a;
    --brand: #f97316; --brand-dark: #fb923c; --ok: #4ade80; --warn: #fbbf24; --bad: #f87171;
    --ok-bg: #14301e; --warn-bg: #3a2c0c; --bad-bg: #3b1616; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; }
.wrap { max-width: min(1400px, 100%); margin: 0 auto; padding: 0 16px 48px; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 14px 16px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.topbar .store { font-weight: 700; flex: 1; }
.topbar .sub { color: var(--muted); font-size: 13px; font-weight: 400; display: block; }
h1 { font-size: 22px; margin: 24px 0 4px; }
.lead { color: var(--muted); margin: 0 0 20px; }
.back { color: var(--brand); text-decoration: none; font-weight: 600; display: inline-block; margin-top: 16px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 14px; text-align: center; text-decoration: none; color: inherit; font-weight: 600; display: flex; flex-direction: column; align-items: center; gap: 8px; min-height: 112px; justify-content: center; transition: transform .1s, box-shadow .1s; }
.tile:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0,0,0,.08); border-color: var(--brand); }
.tile .ico { font-size: 30px; }
.tile small { color: var(--muted); font-weight: 400; font-size: 12px; }
.tile.soon { opacity: .6; }
.grid.wide { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
input, select { font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--ink); width: 100%; }
input:focus, select:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
button, .btn { font: inherit; font-weight: 600; padding: 10px 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--ink); cursor: pointer; text-decoration: none; display: inline-block; }
button.primary, .btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
button.primary:hover, .btn.primary:hover { background: var(--brand-dark); }
button.link { border: 0; background: none; color: var(--brand); padding: 4px 8px; }
button.danger { color: var(--bad); }
button:disabled { opacity: .5; cursor: not-allowed; }
.row { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.row > * { flex: 1 1 120px; }
.row > button, .row > .fit { flex: 0 0 auto; }
.login { max-width: 360px; margin: 12vh auto 0; padding: 0 16px; }
.login h1 { text-align: center; margin-bottom: 20px; }
.login .card > * + * { margin-top: 14px; }
.err { color: var(--bad); font-size: 14px; min-height: 20px; }
.shift { display: grid; grid-template-columns: 1fr auto auto auto; gap: 8px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.shift:first-child { border-top: 0; }
.shift input { width: 135px; }
.shift .who span { color: var(--muted); font-size: 13px; display: block; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: 13px; font-weight: 600; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.none { background: var(--line); color: var(--muted); }
.mark { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; padding: 12px 0; border-top: 1px solid var(--line); }
.mark:first-child { border-top: 0; }
.mark .who { flex: 1 1 160px; }
.mark .who span { color: var(--muted); font-size: 13px; display: block; }
.mark img { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; }
.preview { width: 100%; max-width: 280px; border-radius: 12px; display: block; margin: 8px auto; }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 20; }
.modal .card { max-width: 380px; width: 100%; margin: 0; text-align: center; }
.modal .card > * + * { margin-top: 12px; }
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
table.master { border-collapse: collapse; font-size: 13px; width: 100%; }
.master th, .master td { border: 1px solid var(--line); padding: 5px 3px; text-align: center; min-width: 30px; }
.master th { background: #fde047; color: #1f2933; }
.master th.title { font-size: 16px; padding: 8px; }
.master td.nm { text-align: left; white-space: nowrap; min-width: 120px; padding-left: 8px; font-weight: 600; }
.master tr.bot td.nm { font-weight: 400; color: var(--muted); }
.master td.P { font-weight: 600; }
.master td.P.late { color: var(--warn); text-decoration: underline; }
.master td.OFF { background: #16a34a; color: #fff; font-weight: 700; font-size: 11px; }
.master td.A { background: var(--bad-bg); color: var(--bad); font-weight: 700; }
.master td.S { color: var(--muted); }
.master td.neg, .negtxt { color: var(--bad); }
.master td.left { background: #fde047; color: #1f2933; font-weight: 800; font-size: 20px; }
.master td.tot { background: #fde047; color: #1f2933; font-weight: 700; min-width: 90px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--muted); margin: 10px 0; }
.empty { color: var(--muted); text-align: center; padding: 24px 0; }
#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 99px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 30; }
#toast.show { opacity: 1; }
@media (max-width: 520px) {
  .shift { grid-template-columns: 1fr 1fr; }
  .shift .who { grid-column: 1 / -1; }
  .shift input { width: 100%; }
}

@media print {
  @page { size: A4 landscape; margin: 8mm; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  body { background: #fff; color: #000; }
  .noprint, #toast, .legend { display: none !important; }
  .wrap { max-width: none; padding: 0; }
  .tablewrap { border: 0; overflow: visible; }
  table.master { font-size: 8px; }
  .master th, .master td { padding: 2px 1px; min-width: 0; border-color: #666; }
  .master td.nm { min-width: 0; white-space: nowrap; }
  .master th.title { font-size: 12px; }
  .master td.tot { min-width: 0; }
  .master tr { break-inside: avoid; }
}

h2.sec { font-size: 16px; margin: 0 0 6px; }
.prog { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; margin-bottom: 8px; }
.prog > div { height: 100%; background: var(--ok); }
.card.flag { border-color: var(--bad); background: var(--bad-bg); }
.card.flag summary { font-weight: 700; color: var(--bad); cursor: pointer; }
.card.flag ul { margin: 10px 0 0; padding-left: 18px; }
.card.flag a { color: var(--brand); font-weight: 600; }
.okcard { color: var(--ok); font-weight: 600; }
.ci { padding: 12px 0 12px 10px; border-top: 1px solid var(--line); border-left: 4px solid transparent; }
.ci:first-of-type { border-top: 0; }
.ci.bad { border-left-color: var(--bad); background: var(--bad-bg); }
.ci.good { border-left-color: var(--ok); }
.ci-text { margin-bottom: 8px; }
.ci-text b { color: var(--muted); margin-right: 4px; }
.need { font-size: 12px; color: var(--muted); background: var(--line); padding: 1px 8px; border-radius: 99px; white-space: nowrap; }
.ci-ctl { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.chk { display: inline-flex; align-items: center; gap: 8px; font-size: 16px; color: var(--ink); margin: 0; min-height: 44px; cursor: pointer; }
.chk input { width: 24px; height: 24px; padding: 0; accent-color: var(--ok); }
input.num { width: 120px; }
.unit { color: var(--muted); }
.btn.small { padding: 8px 12px; font-size: 14px; min-height: 40px; }
.why { color: var(--bad); font-size: 13px; margin-top: 4px; }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.th { position: relative; }
.th img, .th .vid { width: 64px; height: 64px; border-radius: 10px; object-fit: cover; display: flex; align-items: center; justify-content: center; background: var(--line); font-size: 26px; text-decoration: none; }
.th .x { position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; padding: 0; border-radius: 50%; font-size: 11px; line-height: 1; }
.grp { margin-top: 10px; }
.flaglist { margin: 4px 0 0; padding-left: 18px; }
@media print { .ci-ctl, .thumbs { break-inside: avoid; } }

.topbar select { font-weight: 700; font-size: 16px; padding: 4px 8px; width: auto; max-width: 100%; }
.master.daily td.yes { background: #22c55e; color: #052e16; font-weight: 600; }
.master.daily td.no { background: #ef4444; }
.master.daily td.oil { color: var(--warn); font-weight: 600; white-space: nowrap; }
.master.daily td.use { color: var(--muted); }
.master.daily th { white-space: nowrap; padding: 5px 8px; }
.master.daily th.title { border-left: 2px solid #1f2933; }
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: middle; }
.swatch.yes { background: #22c55e; } .swatch.no { background: #ef4444; }

table.ov { border-collapse: collapse; width: 100%; font-size: 14px; }
.ov th, .ov td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.ov th { color: var(--muted); font-weight: 600; font-size: 13px; }
.mut { color: var(--muted); }

textarea { font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--ink); width: 100%; resize: vertical; }
textarea:focus { outline: 2px solid var(--brand); outline-offset: 2px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; background: var(--card); }
.seg button.on { background: var(--brand); color: #fff; }
.card.tk { display: flex; gap: 12px; align-items: center; text-decoration: none; color: inherit; }
a.card.tk:hover { border-color: var(--brand); }
.tk img, .tk .noimg { width: 72px; height: 72px; border-radius: 10px; object-fit: cover; flex: none; background: var(--line); display: flex; align-items: center; justify-content: center; font-size: 28px; }
.tk-title { font-weight: 700; }
.gallery { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.gallery img, .gallery video { width: 100%; max-height: 420px; object-fit: contain; border-radius: 10px; background: #000; display: block; }
.note { padding: 8px 0; border-top: 1px solid var(--line); }
.note:first-of-type { border-top: 0; }
.note.resolved { color: var(--ok); }

.big { font-size: 26px; font-weight: 700; }
h3.sub { font-size: 14px; color: var(--muted); margin: 16px 0 6px; }
.chip { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 10px 12px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; }
.results { display: grid; gap: 4px; margin-top: 6px; }
.hit { text-align: left; display: flex; justify-content: space-between; gap: 8px; width: 100%; font-weight: 500; }
.bar { display: grid; grid-template-columns: minmax(90px, 36%) 1fr auto; gap: 8px; align-items: center; font-size: 14px; margin: 4px 0; }
.bar .track { background: var(--line); border-radius: 99px; height: 8px; overflow: hidden; }
.bar .track div { background: var(--brand); height: 100%; }
.menurow { display: grid; grid-template-columns: 2fr 90px 1.2fr 36px; gap: 6px; align-items: center; padding: 4px 0; }
.menurow.head { color: var(--muted); font-size: 13px; font-weight: 600; }
.menurow input { padding: 8px; }
@media (max-width: 520px) { .menurow { grid-template-columns: 1.6fr 74px 36px; } .menurow .mc, .menurow #ac, .menurow.head span:nth-child(3) { display: none; } }
details > summary { cursor: pointer; }

.strow { display: grid; grid-template-columns: minmax(0, 2.4fr) 90px 100px 56px; gap: 8px; align-items: center; padding: 6px 0; border-top: 1px solid var(--line); font-size: 14px; }
.strow.rcv { grid-template-columns: minmax(0, 2.4fr) 50px 90px 90px; }
.strow.head { color: var(--muted); font-size: 12px; font-weight: 600; border-top: 0; position: sticky; top: 56px; background: var(--card); z-index: 2; }
.strow input { padding: 8px; width: 100%; text-align: right; }
.strow .nm { font-weight: 600; overflow-wrap: anywhere; }
.strow .cl, .strow .now { text-align: right; }
.strow .sv { text-align: right; display: flex; flex-direction: column; align-items: flex-end; }
.strow .sv small { font-size: 12px; }
.strow.touched { background: var(--ok-bg); }
.strow.isempty { background: var(--bad-bg); }
.strow.invalid { background: var(--bad-bg); outline: 1px solid var(--bad); }
.strow[hidden] { display: none; }
.warncard { background: var(--warn-bg); border-color: var(--warn); } .warncard b { color: var(--warn); }
.card.flag ul, .warncard ul { margin: 8px 0 0; padding-left: 18px; }
.mv { display: flex; justify-content: space-between; gap: 8px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.itrow { display: grid; grid-template-columns: 1fr 90px 36px; gap: 6px; align-items: center; padding: 4px 0; }
.itrow.head { color: var(--muted); font-size: 13px; font-weight: 600; }
.itrow input { padding: 8px; }


@media (max-width: 520px) {
  .strow, .strow.rcv { grid-template-columns: 1fr 1fr 1fr; }
  .strow .nm { grid-column: 1 / -1; }
  .strow.head span:first-child { display: none; }
}

.presets { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.presets button { padding: 6px 12px; font-size: 14px; }
details.rep > summary { cursor: pointer; }
table.rep td, table.rep th { white-space: nowrap; text-align: left; padding: 4px 8px; }
table.rep td { max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
@media print { details.rep:not([open]) > *:not(summary) { display: none; } table.rep { font-size: 8px; } table.rep td { max-width: none; white-space: normal; } }
/* comfortable touch targets */
.menurow input, .itrow input, .strow input, .shift input { min-height: 40px; }
button, .btn, select, input:not([type=checkbox]):not([type=radio]) { min-height: 40px; }
button.link, .th .x { min-height: 0; }
@media (pointer: coarse) { button, .btn, select, input:not([type=checkbox]):not([type=radio]) { min-height: 44px; } button.link, .th .x { min-height: 0; } }

.bgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; margin-top: 8px; }
.bcard { border: 1px solid var(--line); border-radius: 12px; padding: 12px; background: var(--bg); }
.bcard dl { margin: 8px 0 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; font-size: 14px; }
.bcard dt { color: var(--muted); } .bcard dd { margin: 0; text-align: right; }
/* schedule rows: big checkbox beside the name */
.shift .who { display: grid; grid-template-columns: 30px 1fr; column-gap: 10px; align-items: center; cursor: pointer; }
.shift .who input[type=checkbox] { grid-row: 1 / 3; width: 26px !important; height: 26px; margin: 0 !important; accent-color: var(--ok); min-height: 0; }
.shift .who b, .shift .who span { grid-column: 2; }
@media (max-width: 520px) { .shift .rm { grid-column: 1 / -1; justify-self: end; margin-top: -4px; } }

/* attendance roster rows */
.srow { display: grid; grid-template-columns: minmax(0, 1.4fr) 130px 120px 112px 112px 32px; gap: 8px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.srow:first-child { border-top: 0; }
.srow .who { display: flex; flex-direction: column; }
.srow .who span { color: var(--muted); font-size: 13px; }
.srow.locked { opacity: .65; }
.srow select, .srow input { width: 100%; }
.srow2 { display: grid; grid-template-columns: minmax(0, 1.4fr) 112px 112px 36px; gap: 8px; align-items: center; padding: 6px 0; }
@media (max-width: 760px) {
  .srow { grid-template-columns: 1fr 1fr; }
  .srow .who { grid-column: 1 / -1; flex-direction: row; gap: 8px; align-items: baseline; }
  .srow .rm { grid-column: 1 / -1; justify-self: end; margin-top: -4px; }
  .srow2 { grid-template-columns: 1fr 1fr 1fr 36px; }
  .srow2 .tn, .srow2 #nn { grid-column: 1 / -1; }
}
.master td.LV { background: #dbeafe; color: #1d4ed8; font-weight: 600; }
.master td.WO { background: #16a34a; color: #fff; font-weight: 700; font-size: 11px; }
.master td.HOL { background: #ede9fe; color: #6d28d9; font-weight: 600; font-size: 11px; }
@media (prefers-color-scheme: dark) { .master td.LV { background: #1e3a8a; color: #bfdbfe; } .master td.HOL { background: #4c1d95; color: #ddd6fe; } }
.srow2 input, .srow input, .srow select { min-width: 0; }
@media (max-width: 760px) { .srow2 { grid-template-columns: 1fr 1fr 36px; } }

/* live camera */
.card.cam { max-width: 440px; text-align: left; }
.camwrap { position: relative; background: #000; border-radius: 12px; overflow: hidden; min-height: 200px; display: flex; align-items: center; justify-content: center; margin: 10px 0; }
.camwrap video, .camwrap canvas { width: 100%; max-height: 60vh; display: block; object-fit: contain; }
.camwrap video.mirror { transform: scaleX(-1); }
.camwrap canvas[hidden], .camwrap video[hidden] { display: none; }
.camerr { color: #fff; padding: 24px 16px; text-align: center; }
.camerr[hidden] { display: none; }
[hidden] { display: none !important; }

/* checklist editor */
.edsec .stt { font-weight: 700; }
.edi { border-top: 1px solid var(--line); padding: 10px 0; }
.edi:first-of-type { border-top: 0; }
.edrow { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; margin-top: 8px; }
.edl { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink); margin: 0; }
.edl select, .edl input { width: auto; min-width: 0; }
.edbtns { margin-left: auto; display: inline-flex; gap: 2px; }
.edbtns button { font-size: 18px; min-height: 36px; min-width: 36px; }
@media (max-width: 520px) { .edbtns { margin-left: 0; } .edl select { max-width: 100%; } }

.stickybar { position: sticky; bottom: 0; background: var(--bg); padding: 10px 0 12px; border-top: 1px solid var(--line); z-index: 4; margin-top: 8px; }

/* owner review + month calendar */
.redo { margin: 0 0 8px; padding: 8px 10px; border-radius: 8px; background: var(--bad-bg); color: var(--bad); }
.apv { margin: 0 0 8px; color: var(--ok); font-size: 13px; font-weight: 600; }
.rv .rc { flex: 1; min-width: 0; }
.cm-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; max-width: 480px; }
.cm-h { text-align: center; font-size: 12px; color: var(--muted); }
.cm { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 44px; border-radius: 8px; font-size: 14px; text-decoration: none; color: var(--ink); border: 1px solid var(--line); }
.cm small { font-size: 10px; line-height: 1; }
.cm-ok { background: var(--ok-bg); color: var(--ok); }
.cm-warn { background: var(--warn-bg); color: var(--warn); }
.cm-bad { background: var(--bad-bg); color: var(--bad); }
.cm-miss { background: var(--bad); color: #fff; }
.cm-none, .cm-future { color: var(--muted); opacity: .6; }
.dumpimg { position: relative; background: #000; border-radius: 10px; min-height: 220px; display: flex; align-items: center; justify-content: center; overflow: hidden; touch-action: pan-y; }
.dumpimg img, .dumpimg video { max-width: 100%; max-height: 62vh; display: block; }
.dumpimg .empty { color: #fff; }
.dnav { position: absolute; top: 50%; transform: translateY(-50%); width: 40px; height: 56px; border: 0; border-radius: 8px; background: rgba(0,0,0,.45); color: #fff; font-size: 28px; line-height: 1; padding: 0; }
.dnav.l { left: 6px; } .dnav.r { right: 6px; }
.cm-key { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -1px; margin: 0 2px 0 8px; }
