/* InterlockBay — one stylesheet, no build step. */
:root { --brand: #b91c1c; --bg: #f4f5f7; --card: #fff; --text: #111827; --muted: #6b7280; --line: #e5e7eb; --ok: #16a34a; --warn: #d97706; --bad: #dc2626; --radius: 8px; }
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0 0 .75rem; }
h2 { font-size: 1.1rem; margin: 0 0 .6rem; }
h3 { font-size: 1rem; margin: 1rem 0 .5rem; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .center { text-align: center; } .right { text-align: right; } .r { text-align: right; }
.nowrap { white-space: nowrap; } .grow { flex: 1 1 auto; } .mt { margin-top: .8rem; } .mb { margin-bottom: .6rem; } .pad { padding: .5rem 0; }
.pre { white-space: pre-wrap; } pre.pre { background: #f9fafb; padding: .75rem; border-radius: 6px; overflow-x: auto; }

/* Top bar: brand · search · user on row 1, navigation on row 2 */
[hidden] { display: none !important; }
.top { background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: .4rem 1rem; padding: .5rem 1rem 0; flex-wrap: wrap; position: sticky; top: 0; z-index: 10; }
.brand { font-weight: 800; color: var(--brand); font-size: 1.05rem; white-space: nowrap; }
.topsearch { flex: 1 1 16rem; max-width: 30rem; margin: 0; }
.topsearch input { width: 100%; padding: .4rem .6rem; }
.navuser { margin-left: auto; font-size: .85rem; color: var(--muted); white-space: nowrap; }
.mainnav { display: flex; flex-wrap: wrap; gap: .1rem .2rem; flex-basis: 100%; padding: .35rem 0 .45rem; }
.mainnav a { padding: .4rem .6rem; border-radius: 6px; color: #374151; }
.mainnav a.on { background: var(--brand); color: #fff; }
.mainnav a:hover { text-decoration: none; background: #f3f4f6; } .mainnav a.on:hover { background: var(--brand); }
.mobileonly, .navtoggle, .navbtn { display: none; }
.portal .top { padding-bottom: .5rem; }
@media (max-width: 860px) {
  .top { padding-bottom: .5rem; }
  .navuser { display: none; }
  .navbtn { display: block; margin-left: auto; font-size: 1.5rem; cursor: pointer; padding: 0 .4rem; order: 1; }
  .brand { order: 0; }
  .topsearch { order: 2; flex-basis: 100%; max-width: none; }
  .mainnav { display: none; order: 3; flex-direction: column; }
  .navtoggle:checked ~ .mainnav { display: flex; }
  .mobileonly { display: block; }
}

main { max-width: 1200px; margin: 0 auto; padding: 1rem; }
.narrowmain { max-width: 640px; }
.foot { text-align: center; color: var(--muted); font-size: .8rem; padding: 1.5rem; }

/* Cards & layout */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem; }
.card.hl { border-color: var(--brand); box-shadow: 0 0 0 2px color-mix(in srgb, var(--brand) 12%, transparent); }
.narrow { max-width: 420px; margin: 2rem auto; }
.grid.g2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; align-items: start; }
@media (max-width: 900px) { .grid.g2 { grid-template-columns: 1fr; } }
.spread { display: flex; justify-content: space-between; align-items: center; gap: .75rem; flex-wrap: wrap; margin-bottom: .75rem; }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.row > form { margin: 0; }
.row > input.grow, .row > .grow { width: auto; flex: 1 1 12rem; min-width: 0; }

/* Forms */
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .6rem .8rem; }
.field { margin-bottom: .6rem; }
.field label { display: block; font-size: .8rem; font-weight: 600; color: #374151; margin-bottom: .2rem; }
input, select, textarea { font: inherit; padding: .5rem .6rem; border: 1px solid #d1d5db; border-radius: 6px; background: #fff; color: var(--text); max-width: 100%; }
.field input, .field select, .field textarea { width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--brand) 40%, transparent); border-color: var(--brand); }
input[type=checkbox] { width: auto; }
input[type=color] { padding: 2px; height: 2.3rem; min-width: 3rem; }
label.check { display: inline-flex; gap: .35rem; align-items: center; margin: .2rem .8rem .2rem 0; font-size: .9rem; }
.w5 { width: 5rem; } .w6 { width: 6rem; } .w8 { width: 8rem; } .w10 { width: 10rem; }
details > summary { cursor: pointer; list-style: none; } details > summary::-webkit-details-marker { display: none; }
.vehrow { border-bottom: 1px solid var(--line); padding: .4rem 0; }

/* Buttons */
.btn { display: inline-block; padding: .5rem .85rem; border-radius: 6px; border: 1px solid #d1d5db; background: #fff; color: #111827; cursor: pointer; font: inherit; line-height: 1.2; text-align: center; white-space: nowrap; }
.btn:hover { text-decoration: none; background: #f9fafb; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: color-mix(in srgb, var(--brand) 85%, #000); }
.btn-sm { padding: .3rem .6rem; font-size: .85rem; }
.btn.danger, .linkbtn.danger { color: var(--bad); }
.btn.wide { width: 100%; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--brand); cursor: pointer; font: inherit; font-size: .85rem; }

/* Flash */
.flash { padding: .65rem .9rem; border-radius: 6px; margin-bottom: 1rem; }
.flash.ok { background: #dcfce7; color: #14532d; } .flash.error { background: #fee2e2; color: #7f1d1d; } .flash.warn { background: #fef3c7; color: #78350f; }

/* Tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.tile { display: flex; flex-direction: column; gap: .2rem; border: 2px solid var(--line); border-radius: var(--radius); padding: .8rem; background: #fff; color: var(--text); }
.tile:hover { text-decoration: none; filter: brightness(.98); }
.tile .num { font-size: 1.8rem; font-weight: 800; line-height: 1.1; } .tile .num.sm { font-size: 1rem; font-weight: 600; }
.tile .lbl { font-size: .82rem; color: #374151; }

/* Lists & tables */
.listrow { display: flex; gap: .6rem; align-items: center; padding: .55rem .7rem; border: 1px solid var(--line); border-left: 5px solid var(--line); border-radius: 6px; margin-bottom: .4rem; color: var(--text); background: #fff; flex-wrap: wrap; }
a.listrow:hover { text-decoration: none; background: #f9fafb; }
.tablewrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; }
table.t th, table.t td { padding: .5rem .55rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.t th { font-size: .75rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
table.t th.r, table.t td.r { text-align: right; }
table.compact td, table.compact th { padding: .3rem .45rem; }
.pill { display: inline-block; padding: .12rem .55rem; border-radius: 999px; color: #fff; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.dot { display: inline-block; width: .65rem; height: .65rem; border-radius: 50%; margin-right: .35rem; vertical-align: middle; }
.chip { display: inline-block; background: #eef2ff; border: 1px solid #c7d2fe; border-radius: 6px; padding: .15rem .5rem; margin: .15rem; font-size: .85rem; }
.chips { list-style: none; padding: 0; margin: .4rem 0; } .chips li { display: inline-flex; gap: .3rem; align-items: center; background: #eef2ff; border: 1px solid #c7d2fe; border-radius: 6px; padding: .2rem .5rem; margin: .15rem; font-family: ui-monospace, monospace; }
.chips button { border: 0; background: none; color: var(--bad); cursor: pointer; font-size: 1rem; }
.log { padding: .3rem 0; border-bottom: 1px solid #f3f4f6; }

/* Due badges */
.due { font-size: .85rem; white-space: nowrap; padding: .1rem .45rem; border-radius: 5px; }
.due-ok { background: #dcfce7; color: #14532d; } .due-soon { background: #fef3c7; color: #78350f; } .due-overdue { background: #fee2e2; color: #7f1d1d; font-weight: 600; }
.bigdue { border-radius: var(--radius); padding: 1rem; text-align: center; margin-bottom: .8rem; }
.bigdue .bigdate { font-size: 1.35rem; font-weight: 800; margin: .2rem 0; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: .3rem .9rem; margin: 0; } .kv dt { color: var(--muted); } .kv dd { margin: 0; }

/* Calendar */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-head { text-align: center; font-size: .78rem; font-weight: 700; color: var(--muted); padding: .3rem; }
.cal-day { min-height: 105px; background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 4px; overflow: hidden; }
.cal-day.today { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.cal-day.empty { background: transparent; border: 0; }
.daynum { display: flex; justify-content: space-between; font-weight: 700; font-size: .82rem; margin-bottom: 3px; }
.duecount { font-size: .7rem; background: #fef3c7; color: #78350f; border-radius: 4px; padding: 0 .3rem; font-weight: 600; }
.cal-job { display: block; color: #fff; font-size: .72rem; padding: 2px 4px; border-radius: 3px; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-job.req { opacity: .65; outline: 2px dashed #fff; outline-offset: -2px; }
.cal-job:hover { text-decoration: none; filter: brightness(1.1); }
@media (max-width: 700px) { .cal-day { min-height: 70px; } .cal-job { font-size: .62rem; } }

/* Scan station */
.modes { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .8rem; }
.mode input { position: absolute; opacity: 0; }
.mode span { display: inline-block; padding: .55rem .9rem; border: 2px solid var(--line); border-radius: 8px; cursor: pointer; font-weight: 600; }
.mode input:checked + span { border-color: var(--brand); background: var(--brand); color: #fff; }
.mode input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }
.scanbox { display: flex; gap: .5rem; }
.scanbox input { flex: 1; font-size: 1.4rem; padding: .8rem; border-width: 2px; }
.scanlog { list-style: none; padding: 0; margin: 0; max-height: 60vh; overflow-y: auto; }
.scanlog li { padding: .5rem .7rem; border-radius: 6px; margin-bottom: .35rem; display: flex; gap: .6rem; align-items: center; }
.scanlog li.ok { background: #dcfce7; } .scanlog li.err { background: #fee2e2; } .scanlog li.wait { background: #f3f4f6; color: var(--muted); }
.cam { margin-top: .8rem; } .cam video { width: 100%; max-width: 480px; border-radius: 8px; background: #000; display: block; margin-bottom: .5rem; }

/* Files */
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: .6rem; margin-top: .6rem; }
.thumb img { width: 100%; height: 90px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); }
.fileicon { display: flex; align-items: center; justify-content: center; height: 90px; background: #f3f4f6; border-radius: 6px; font-weight: 800; color: var(--muted); }

/* Invoice document */
.invdoc { max-width: 760px; margin: 0 auto; background: #fff; }
.invhead { display: flex; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.invco { font-size: 1.3rem; font-weight: 800; color: var(--brand); }
.invtitle { font-size: 1.4rem; font-weight: 800; letter-spacing: .05em; }
.billto { margin-bottom: 1rem; }
.invtable tr.tot td { border-bottom: 0; padding-top: .25rem; padding-bottom: .25rem; }
.invtable tr.big td { font-weight: 800; font-size: 1.05rem; }
.stamp { display: inline-block; margin-top: .4rem; padding: .2rem .7rem; border: 3px solid; border-radius: 6px; font-weight: 800; transform: rotate(-4deg); }
.stamp.paid { color: var(--ok); } .stamp.void { color: var(--bad); } .stamp.draft { color: var(--muted); }
.printpage { background: #fff; padding: 1rem; }

/* Portal */
.portal .top { position: static; }
.portal .top form { margin: 0; }

/* Labels */
.labels { background: #fff; }
.labelbar { padding: 1rem; display: flex; gap: .5rem; flex-wrap: wrap; flex-basis: 100%; }
.label { text-align: center; overflow: hidden; page-break-inside: avoid; }
.label .ltitle { font: 700 9pt/1.1 Arial, sans-serif; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.label .lsub { font: 7.5pt/1.1 Arial, sans-serif; white-space: nowrap; overflow: hidden; }
.label .lbar svg { max-width: 100%; height: auto; }
.thermal .label { width: 2.25in; height: 1.25in; padding: .06in .1in; page-break-after: always; }
.thermal .label .lbar svg { height: .72in; width: auto; max-width: 2.05in; }
.sheet { display: flex; flex-wrap: wrap; }
.sheet .label { width: 2.625in; height: 1in; padding: .05in .12in; }
.sheet .label .lbar svg { height: .55in; width: auto; max-width: 2.4in; }

@media print {
  .noprint, .top, .foot, .mainnav { display: none !important; }
  body { background: #fff; }
  main { padding: 0; max-width: none; }
  .card { border: 0; padding: 0; }
  @page { margin: .5in; }
  .thermal { margin: 0; } .labels.thermal { padding: 0; }
}
