:root {
  --bg: #f4f5f2; --card: #ffffff; --ink: #1d2420; --muted: #66706a; --line: #dfe3dc;
  --accent: #1f6f5c; --accent-ink: #ffffff; --accent-soft: #e3f1ec;
  --bad: #b3261e; --bad-soft: #fbe9e7; --warn: #8a5a00; --warn-soft: #fdf1d6; --ok: #1f6f5c;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #141815; --card: #1d2320; --ink: #e9eeea; --muted: #9aa69f; --line: #303a34;
    --accent: #58b79e; --accent-ink: #0d1512; --accent-soft: #1f342d;
    --bad: #ff8a80; --bad-soft: #3a1f1d; --warn: #f2c35c; --warn-soft: #3a3018; --ok: #58b79e; }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
[hidden] { display: none !important; }
h1 { font-size: 24px; margin: 0 0 4px; } h2 { font-size: 17px; margin: 0 0 10px; } h3 { font-size: 15px; margin: 0; }
.muted { color: var(--muted); } .small { font-size: 13px; }
a { color: var(--accent); }

.app { display: grid; grid-template-columns: 200px 1fr; min-height: 100vh; }
.nav { background: var(--card); border-right: 1px solid var(--line); padding: 18px 12px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.brand { font-weight: 700; padding: 4px 10px 14px; }
.nav a { padding: 9px 10px; border-radius: 8px; color: var(--ink); text-decoration: none; }
.nav a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-foot { margin-top: auto; padding: 10px; font-size: 13px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
main { padding: 24px 28px 60px; max-width: 1200px; width: 100%; outline: none; }

.head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.head h1 { margin-right: auto; }
.btn { font: inherit; border: 1px solid var(--line); background: var(--card); color: var(--ink); padding: 8px 14px; border-radius: 8px; cursor: pointer; min-height: 38px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.small { padding: 4px 10px; min-height: 30px; font-size: 13px; }
.btn.danger { color: var(--bad); }
.link { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; cursor: pointer; text-decoration: underline; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; align-items: start; }
.grid .card { margin: 0; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--line); }
td { padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; } tr.click:hover td { background: var(--accent-soft); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.scroll { overflow-x: auto; }
.cat td { background: var(--bg); font-weight: 600; font-size: 13px; }
.sub td { font-weight: 600; font-size: 12px; color: var(--muted); padding-top: 10px; padding-bottom: 2px; border-bottom: 0; }
input.linenote { min-width: 150px; }

.pill { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--line); white-space: nowrap; }
.pill.confirmed { background: var(--accent-soft); color: var(--ok); }
.pill.tentative { background: var(--warn-soft); color: var(--warn); }
.pill.cancelled, .pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: var(--bg); border: 1px solid var(--line); border-radius: 99px; padding: 3px 10px; font-size: 13px; }
.chip.bad { border-color: var(--bad); color: var(--bad); }

.alert { border-radius: var(--radius); padding: 10px 14px; margin-bottom: 10px; background: var(--bad-soft); color: var(--bad); border: 1px solid transparent; }
.alert.warn { background: var(--warn-soft); color: var(--warn); }
.alert strong { display: block; }
.alert ul { margin: 4px 0 0; padding-left: 18px; }
.allgood { background: var(--accent-soft); color: var(--ok); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 16px; }

.daybar { display: flex; gap: 8px; align-items: center; }
.daybar input { width: auto; }
.jobcard h3 a { color: var(--ink); text-decoration: none; } .jobcard h3 a:hover { text-decoration: underline; }
.jobcard .meta { color: var(--muted); font-size: 13px; margin: 2px 0 10px; }
.jobcard .sec { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 12px 0 6px; font-weight: 600; }
.gearline { display: flex; justify-content: space-between; gap: 10px; padding: 3px 0; font-size: 14px; }
.gearline span:last-child { color: var(--muted); white-space: nowrap; }

label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 12px; }
input, select, textarea { display: block; width: 100%; margin-top: 4px; font: inherit; color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; min-height: 38px; }
td input, td select, .inline input, .inline select { margin-top: 0; }
input.qty { width: 74px; text-align: right; }
.inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline select { width: auto; flex: 1 1 180px; } .inline input { width: auto; flex: 1 1 120px; } .inline input.qty { flex: 0 0 74px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.facts div span { display: block; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

dialog { border: 1px solid var(--line); border-radius: 14px; padding: 0; width: min(520px, calc(100vw - 32px)); background: var(--card); color: var(--ink); }
dialog::backdrop { background: rgba(0,0,0,.45); }
dialog form { padding: 20px; }
.dlg-foot { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; flex-wrap: wrap; }
.dlg-foot .left { margin-right: auto; }
.error { color: var(--bad); min-height: 1.2em; margin: 0 0 8px; font-size: 14px; }

.login { max-width: 360px; margin: 12vh auto; padding: 24px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; }
.toast { position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 8px; z-index: 10; max-width: calc(100vw - 32px); }
.empty { color: var(--muted); padding: 18px 0; text-align: center; }

.nav { overflow-y: auto; }
a.btn { text-decoration: none; display: inline-flex; align-items: center; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs a { padding: 8px 14px; border-radius: 8px 8px 0 0; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.on { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.filters { margin-bottom: 12px; } .filters input[type=search] { max-width: 320px; }
.gap { margin-top: 12px; }
.line { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.line:last-of-type { border-bottom: 0; }
.stats { display: flex; gap: 20px; flex-wrap: wrap; margin-bottom: 8px; }
.stats div { color: var(--muted); font-size: 13px; } .stats b { display: block; font-size: 24px; color: var(--ink); }
.stats b.badnum { color: var(--bad); }
.grid.two-up { grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); margin-bottom: 16px; }
h2.gap { margin-top: 16px; }
label.check { display: flex; gap: 8px; align-items: center; font-weight: 400; font-size: 15px; }
label.check input, label.pickrow input { width: auto; min-height: 0; margin: 0; }
label.check input { width: 18px; height: 18px; flex: none; }
label.plain { margin: 0; font-weight: 400; display: flex; gap: 8px; align-items: center; } label.plain select { width: auto; margin: 0; }
ul.tasks { list-style: none; margin: 0 0 10px; padding: 0; }
.task { padding: 7px 0; border-bottom: 1px solid var(--line); } .task:last-child { border-bottom: 0; }
.task label { margin: 0; } .task.done label span { text-decoration: line-through; color: var(--muted); }
.task > .small { display: block; margin-left: 26px; } .late { color: var(--bad); font-weight: 600; }
.pickbox { max-height: 260px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; padding: 4px 10px; margin-bottom: 12px; }
label.pickrow { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-weight: 400; font-size: 14px; margin: 0; padding: 4px 0; border-bottom: 1px solid var(--line); }
label.pickrow:last-child { border-bottom: 0; }
pre.example { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; overflow-x: auto; font-size: 12px; margin: 0 0 8px; }
progress { width: 100%; min-width: 80px; accent-color: var(--accent); }
details.card summary { cursor: pointer; font-weight: 600; }
.step { display: flex; gap: 14px; align-items: flex-start; } .step h2 { margin-bottom: 4px; } .step p { margin: 0 0 10px; }
.tick { flex: none; width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; font-weight: 700; }
.tick.done { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* Planner */
.tl-wrap { min-width: 860px; }
.tl { display: grid; grid-template-columns: 170px repeat(14, minmax(0, 1fr)); grid-auto-flow: row dense; gap: 3px 0; padding: 5px 0; border-bottom: 1px solid var(--line); align-items: center; }
.tl-label { grid-column: 1; grid-row: 1; padding-right: 10px; font-size: 14px; overflow: hidden; } .tl-label span { display: block; }
.tl-label a { color: var(--ink); text-decoration: none; font-weight: 600; }
.tl-day { text-align: center; font-size: 12px; color: var(--muted); } .tl-day b { display: block; font-size: 14px; color: var(--ink); }
.tl-day.wkend { opacity: .65; } .tl-day.now b { background: var(--accent); color: var(--accent-ink); border-radius: 99px; width: 26px; margin: 0 auto; }
.tl-sec { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: 14px 0 4px; }
.bar { display: block; padding: 4px 8px; margin: 0 2px; border-radius: 6px; font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-decoration: none; background: var(--line); color: var(--ink); }
.bar.confirmed { background: var(--accent); color: var(--accent-ink); }
.bar.tentative { background: var(--warn-soft); color: var(--warn); border: 1px dashed var(--warn); }
.bar.done { background: var(--line); color: var(--muted); }
.bar.off { background: repeating-linear-gradient(45deg, var(--bad-soft), var(--bad-soft) 6px, transparent 6px, transparent 12px); color: var(--bad); border: 1px solid var(--bad); }
table.heat td.num { min-width: 34px; } table.heat td.bad { background: var(--bad-soft); color: var(--bad); font-weight: 700; }
table.heat td.warn { background: var(--warn-soft); color: var(--warn); font-weight: 700; } table.heat td.idle { color: var(--muted); } table.heat th.now { color: var(--accent); }

/* Dashboard calendar */
.cal-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; } .cal-head h2 { margin: 0; } .cal-head .daybar { flex-wrap: wrap; } .cal-head .btn { white-space: nowrap; }
.cal-dow, .cal-week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-dow div { text-align: center; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: 4px 0; }
.cal-week { grid-template-rows: 30px repeat(3, 24px) 18px; border-top: 1px solid var(--line); padding-bottom: 4px; }
.cal-day { grid-row: 1 / -1; border: 0; border-left: 1px solid var(--line); border-radius: 0; background: none; font: inherit; color: var(--ink); cursor: pointer; display: flex; justify-content: space-between; align-items: flex-start; padding: 4px; min-width: 0; margin-bottom: -4px; }
.cal-day.cs0 { border-left: 0; } .cal-day:hover { background: var(--accent-soft); } .cal-day.dim { background: var(--bg); color: var(--muted); }
.cal-day b { font-size: 13px; font-weight: 600; width: 24px; height: 24px; display: grid; place-items: center; border-radius: 99px; }
.cal-day.now b { background: var(--accent); color: var(--accent-ink); }
.cal-flag { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--bad); } .cal-flag.warn { background: var(--warn); } .cal-day .cal-flag { margin: 8px 4px 0 0; }
.cal-bar { z-index: 1; align-self: center; padding: 1px 6px; line-height: 18px; } .cal-bar:hover { filter: brightness(1.08); text-decoration: underline; }
.cal-bar.contl { margin-left: 0; border-top-left-radius: 0; border-bottom-left-radius: 0; border-left: 0; } .cal-bar.contr { margin-right: 0; border-top-right-radius: 0; border-bottom-right-radius: 0; border-right: 0; }
.cal-more { z-index: 1; grid-row: 5; border: 0; background: none; font: inherit; font-size: 12px; color: var(--muted); cursor: pointer; text-align: left; padding: 0 6px; white-space: nowrap; overflow: hidden; }
.cs0 { grid-column-start: 1; } .cs1 { grid-column-start: 2; } .cs2 { grid-column-start: 3; } .cs3 { grid-column-start: 4; } .cs4 { grid-column-start: 5; } .cs5 { grid-column-start: 6; } .cs6 { grid-column-start: 7; }
.cn1 { grid-column-end: span 1; } .cn2 { grid-column-end: span 2; } .cn3 { grid-column-end: span 3; } .cn4 { grid-column-end: span 4; } .cn5 { grid-column-end: span 5; } .cn6 { grid-column-end: span 6; } .cn7 { grid-column-end: span 7; }
.cl0 { grid-row: 2; } .cl1 { grid-row: 3; } .cl2 { grid-row: 4; }
.cal-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: 10px; }
.cal-key { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; } .cal-key .bar { margin: 0; padding: 1px 8px; }
@media (max-width: 760px) { .cal-bar { padding: 1px 3px; font-size: 11px; } .cal-more { padding: 0 2px; font-size: 11px; } }

/* Messages */
.msg { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 16px; align-items: start; }
.msg .card { margin: 0; } .msg-list { padding: 6px; max-height: calc(100vh - 150px); overflow-y: auto; }
.msg-item { display: block; padding: 10px; border-radius: 8px; color: var(--ink); text-decoration: none; } .msg-item:hover, .msg-item.on { background: var(--accent-soft); }
.msg-top { display: flex; justify-content: space-between; gap: 8px; align-items: center; } .msg-top strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-snip { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-pane { display: flex; flex-direction: column; height: calc(100vh - 150px); min-height: 380px; }
.msg-head { display: flex; gap: 10px; align-items: center; border-bottom: 1px solid var(--line); padding-bottom: 10px; } .msg-head h2 { margin: 0; } .msg-head > div { min-width: 0; margin-right: auto; }
.msg-tools { display: flex; gap: 6px; flex: none; } .msg-head .msg-back { display: none; text-decoration: none; }
.msg-scroll { flex: 1; overflow-y: auto; padding: 12px 4px; display: flex; flex-direction: column; gap: 8px; }
.msg-row { max-width: 78%; align-self: flex-start; } .msg-row.me { align-self: flex-end; text-align: right; }
.msg-meta { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.bubble { display: inline-block; text-align: left; background: var(--bg); border: 1px solid var(--line); border-radius: 14px; padding: 8px 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-row.me .bubble { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.msg-day { align-self: center; font-size: 12px; color: var(--muted); padding: 4px 0; }
.msg-form { display: flex; gap: 8px; align-items: flex-end; border-top: 1px solid var(--line); padding-top: 10px; } .msg-form textarea { margin: 0; resize: none; }
.nav .pill { margin-left: 4px; }
@media (max-width: 760px) {
  .msg { grid-template-columns: 1fr; } .msg.has-open .msg-list, .msg:not(.has-open) .msg-pane { display: none; }
  .msg-head .msg-back { display: inline-grid; place-items: center; } .msg-pane { height: calc(100vh - 210px); } .msg-row { max-width: 90%; }
}

/* Packing list */
.sheet th.box, .sheet td.box { width: 44px; text-align: center; font-size: 18px; } .sheet .sign { margin-top: 28px; }
@media print {
  .nav, .noprint, .toast { display: none !important; }
  .app { display: block; } main { padding: 0; max-width: none; } body { background: #fff; color: #000; }
  .card { border: 0; padding: 0; }
}

@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .nav { position: fixed; bottom: 0; top: auto; left: 0; right: 0; height: auto; flex-direction: row; justify-content: flex-start; overflow-x: auto; overflow-y: hidden; white-space: nowrap; padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--line); z-index: 5; }
  .brand, .nav-foot span { display: none; }
  .nav-foot { margin: 0; padding: 9px 6px; }
  .nav a { padding: 9px 10px; flex: none; }
  .nav-foot { flex: none; }
  main { padding: 16px 16px 96px; }
  .two { grid-template-columns: 1fr; }
}

/* Company switcher for a master sign-in */
.orgpick { display: block; font-size: 12px; color: var(--muted); padding: 0 10px 12px; }
.orgpick select { width: 100%; margin-top: 4px; }
/* Job files and the 3D viewer */
.filebtns { white-space: nowrap; } .filebtns .btn { margin-left: 6px; }
.fileimg { max-width: 100%; height: auto; display: block; margin: 0 auto; }
.fileframe { width: 100%; height: 78vh; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.viewer { width: 100%; height: min(68vh, 640px); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; touch-action: none; }
.viewer canvas { display: block; width: 100%; height: 100%; }
.parts { margin-top: 10px; } .parts summary { cursor: pointer; font-weight: 600; }
.partlist { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 4px 12px; margin-top: 8px; max-height: 260px; overflow: auto; }
@media (max-width: 760px) { .filebtns { white-space: normal; } .filebtns .btn { margin: 2px 0 2px 6px; } }
