:root {
  --ink: #111; --muted: #6b6b6b; --line: #e3e3e3; --soft: #f6f6f4; --bg: #fff;
  --camel: #8C5E34; --ok: #2f7d4f; --warn: #b7791f; --bad: #b42318; --info: #1f5fa8;
  --radius: 10px; font-size: 16px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
header#top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 18px; padding: 10px 18px; background: var(--ink); color: #fff; }
.brand { font-weight: 700; letter-spacing: .28em; text-decoration: none; font-size: 15px; }
nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
nav a { text-decoration: none; padding: 8px 12px; border-radius: 8px; white-space: nowrap; font-size: 15px; opacity: .8; }
nav a.on, nav a:hover { background: #2a2a2a; opacity: 1; }
.link { background: none; border: 0; color: inherit; cursor: pointer; text-decoration: underline; font-size: 14px; }
.net { width: 10px; height: 10px; border-radius: 50%; background: var(--ok); flex: none; }
.net.off { background: var(--bad); }
main { max-width: 1280px; margin: 0 auto; padding: 18px; }
.pad { padding: 24px; }
h1 { font-size: 26px; margin: 4px 0 16px; font-weight: 600; letter-spacing: -.01em; }
h2 { font-size: 18px; margin: 26px 0 10px; font-weight: 600; }
h3 { font-size: 15px; margin: 14px 0 6px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.muted { color: var(--muted); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 16px; border-radius: 8px; border: 1px solid var(--ink); background: #fff; cursor: pointer; text-decoration: none; font-size: 15px; min-height: 42px; }
.btn.primary { background: var(--camel); border-color: var(--camel); color: #fff; }
.btn.dark { background: var(--ink); color: #fff; }
.btn.danger { border-color: var(--bad); color: var(--bad); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.big { min-height: 64px; font-size: 19px; padding: 14px 22px; border-radius: 12px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0 14px; }
.chip { padding: 7px 12px; border-radius: 999px; border: 1px solid var(--line); background: #fff; cursor: pointer; font-size: 14px; }
.chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; background: var(--soft); border: 1px solid var(--line); white-space: nowrap; }
.pill.draft { color: var(--muted); }
.pill.released, .pill.ready { color: var(--info); border-color: #c9dbf2; background: #eef4fc; }
.pill.in_production, .pill.in_progress { color: var(--warn); border-color: #f0dcae; background: #fdf6e7; }
.pill.done, .pill.delivered, .pill.booked { color: var(--ok); border-color: #c5e3d0; background: #eef8f2; }
.pill.on_hold, .pill.late, .pill.to_book { color: var(--bad); border-color: #f2cbc7; background: #fdf0ef; }
.pill.skipped, .pill.cancelled { opacity: .5; }
.card { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; background: #fff; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.cardlink { text-decoration: none; display: block; }
.cardlink:hover .card { border-color: #bdbdbd; }
.bar { height: 6px; background: var(--soft); border-radius: 3px; overflow: hidden; margin: 10px 0 6px; }
.bar > i { display: block; height: 100%; background: var(--ink); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-weight: 600; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.form { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px 16px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field.wide { grid-column: 1 / -1; }
.field label { font-size: 13px; color: var(--muted); }
.field label b { color: var(--bad); font-weight: 600; }
input, select, textarea { border: 1px solid #cfcfcf; border-radius: 8px; padding: 9px 10px; background: #fff; min-height: 42px; width: 100%; }
textarea { min-height: 70px; resize: vertical; }
input[type=checkbox] { width: 22px; height: 22px; min-height: 0; }
.check { flex-direction: row; align-items: center; gap: 8px; }
.section { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 14px 0; }
.section > h2:first-child { margin-top: 0; }
.missing { background: #fdf0ef; border: 1px solid #f2cbc7; border-radius: var(--radius); padding: 12px 16px; }
.missing ul { margin: 6px 0 0; padding-left: 20px; }
.okbox { background: #eef8f2; border: 1px solid #c5e3d0; border-radius: var(--radius); padding: 12px 16px; }
.piece { border-left: 4px solid var(--ink); padding-left: 14px; margin: 18px 0; }
#toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 10px; opacity: 0; transition: opacity .2s; pointer-events: none; max-width: 90vw; z-index: 50; }
#toast.show { opacity: 1; }
#toast.err { background: var(--bad); }
.login { max-width: 380px; margin: 9vh auto; }
.login h1 { letter-spacing: .3em; text-align: center; font-weight: 700; }
.running { background: var(--ink); color: #fff; border-radius: 12px; padding: 14px 18px; display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.running .clock { font-size: 28px; font-variant-numeric: tabular-nums; font-weight: 600; }
.task { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; }
.task .meta { font-size: 14px; color: var(--muted); margin-top: 4px; }
.task .acts { display: flex; gap: 8px; }
.task.active { border-color: var(--camel); box-shadow: 0 0 0 2px #e8d8c8 inset; }
.dept { margin-top: 18px; }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; }
.thumbs img { width: 110px; height: 110px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.hours { font-variant-numeric: tabular-nums; }
.over { color: var(--bad); font-weight: 600; }
@media (max-width: 700px) { main { padding: 12px; } h1 { font-size: 22px; } .task { grid-template-columns: 1fr; } }
@media print {
  header#top, .noprint, #toast { display: none !important; }
  main { max-width: none; padding: 0; }
  .section { break-inside: avoid; }
  input, select, textarea { border: 0; padding: 0; min-height: 0; }
}
.scroll { overflow-x: auto; }
table.mats { min-width: 1150px; }
table.mats td { padding: 6px 4px; }
table.mats select { min-width: 92px; }
table.mats input[type=date] { min-width: 140px; }
input.err, select.err { border-color: var(--bad); }
/* job sheet: save bar and approval */
.savebar { position: sticky; bottom: 0; z-index: 5; display: flex; align-items: center; gap: 10px; margin-top: 18px; padding: 12px 16px; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 -4px 16px rgba(0,0,0,.06); }
.savebar.dirty { border-color: #f0dcae; background: #fffaf0; }
.savebar.dirty #savemsg { color: var(--warn); font-weight: 600; }
.pending { padding: 14px 16px; border-radius: 12px; border: 1px solid #f0dcae; background: #fdf6e7; margin: 12px 0; }
.pending ul, .okbox ul { margin: 6px 0 0 18px; }
.sentback { margin: 0 0 8px; padding: 8px 10px; background: #fdf0ef; border: 1px solid #f2cbc7; border-radius: 8px; }
.pill.pending_approval { color: var(--warn); border-color: #f0dcae; background: #fdf6e7; }
@media print { .savebar { display: none; } }
/* workshop tablet: one job per row; the left side opens the job sheet */
.tasklist { display: flex; flex-direction: column; gap: 12px; }
.tasklink { color: inherit; text-decoration: none; display: block; flex: 1; min-width: 0; }
.tasklink:hover .openjob, .tasklink:focus .openjob { text-decoration: underline; }
.openjob { color: var(--info); }
.comments { display: flex; flex-direction: column; gap: 10px; }
.comment { padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--soft); }
/* assign work */
.assignlist { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.assignrow { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.arow-main { flex: 1 1 380px; min-width: 0; }
.arow-who { flex: 0 1 360px; }
.arow-main .row { gap: 8px; flex-wrap: wrap; }
.reason { font-size: 13px; margin-top: 4px; }
.bar.over > i { background: var(--bad); }
.tablewrap { overflow-x: auto; }
details.section > summary { cursor: pointer; list-style: revert; }
/* production list */
.prodlist { display: flex; flex-direction: column; gap: 10px; }
.prodrow .row { gap: 8px; }
/* view mode: fields read like text, not like a form */
.viewmode input:disabled, .viewmode select:disabled, .viewmode textarea:disabled {
  border-color: transparent; background: var(--soft); color: var(--ink); -webkit-text-fill-color: var(--ink); opacity: 1;
  appearance: none; -webkit-appearance: none; resize: none; }
.viewmode input[type=checkbox]:disabled { appearance: auto; -webkit-appearance: checkbox; }
.viewmode input:disabled::placeholder, .viewmode textarea:disabled::placeholder { color: transparent; }
.viewnote { margin: 6px 0 10px; }

/* phones */
@media (max-width: 760px) {
  header#top { flex-wrap: wrap; gap: 8px 12px; padding: 10px 12px 6px; padding-top: max(10px, env(safe-area-inset-top)); }
  header#top .brand { order: 1; }
  header#top .net { order: 2; margin-left: auto; }
  header#top #who { order: 3; font-size: 13px; }
  header#top nav { order: 4; flex: 1 1 100%; margin: 0 -12px; padding: 0 8px 4px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  header#top nav::-webkit-scrollbar { display: none; }
  nav a { padding: 8px 11px; font-size: 15px; }
  main { padding: 12px; }
  h1 { font-size: 22px; margin-bottom: 10px; }
  /* any wide table scrolls inside itself instead of stretching the page */
  main table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  /* the jobs list becomes one card per job */
  table.stack, table.stack tbody { display: block; overflow: visible; }
  table.stack thead { display: none; }
  table.stack tr { display: grid; grid-template-columns: auto 1fr auto; gap: 2px 10px; align-items: center; padding: 10px 2px; border-bottom: 1px solid var(--line); }
  table.stack td { border: 0; padding: 0; }
  table.stack td:nth-child(1) { grid-column: 1; grid-row: 1; }
  table.stack td:nth-child(2) { grid-column: 2; grid-row: 1; }
  table.stack td:nth-child(4) { grid-column: 3; grid-row: 1; text-align: right; }
  table.stack td:nth-child(3) { grid-column: 1 / 3; grid-row: 2; color: var(--muted); font-size: 13px; }
  table.stack td:nth-child(5) { grid-column: 3; grid-row: 2; text-align: right; color: var(--muted); font-size: 13px; }
  table.stack td:nth-child(5):not(:empty)::before { content: 'Due '; }
  table.stack td[colspan] { grid-column: 1 / -1; }
  .noprint-m { display: none; }
  .form { grid-template-columns: 1fr; }
  .section { padding: 12px; }
  .arow-who { flex: 1 1 100%; }
}
/* customer search */
.custfind { position: relative; }
.custresults { border: 1px solid var(--line); border-radius: 8px; margin-top: 4px; background: #fff; overflow: hidden; }
.custhit { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; padding: 10px 12px; border: 0; border-bottom: 1px solid var(--line); background: #fff; text-align: left; cursor: pointer; min-height: 48px; }
.custhit:last-child { border-bottom: 0; }
.custhit:hover, .custhit:focus { background: var(--soft); }
.custhit .muted { font-size: 13px; }
.custnone { padding: 10px 12px; font-size: 14px; }
.matbox { background: var(--soft); border-radius: 8px; padding: 10px 14px 14px; margin-top: 14px; }
.matbox h3 { margin-top: 4px; }
.matbox input:not([type=checkbox]):not(:disabled), .matbox select:not(:disabled) { background: #fff; }
