/* Life Spot Estimating — a working tool, so: dense, high contrast, no decoration
   that costs a row of data. Numbers are tabular-figure aligned everywhere. */

:root {
  --ink:        #16191d;
  --ink-soft:   #5b636e;
  --ink-faint:  #8b939e;
  --line:       #dfe3e8;
  --line-soft:  #eef1f4;
  --bg:         #ffffff;
  --bg-soft:    #f6f8fa;
  --navy:       #1f3864;
  --navy-soft:  #e8edf6;
  --accent:     #b45309;
  --ok:         #15803d;
  --ok-bg:      #eafaf0;
  --err:        #b91c1c;
  --err-bg:     #fdeceb;
  --warn:       #92400e;
  --warn-bg:    #fdf6e3;
  --radius:     6px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 14px/1.45 -apple-system, "Segoe UI", Roboto, system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg-soft);
}

/* ─── nav ─── */
.nav {
  display: flex; align-items: center; gap: 4px; flex-wrap: nowrap;
  background: var(--navy); color: #fff;
  /* Matches the content padding so the logo lines up with the page. */
  padding: 0 28px; height: 46px;
  /* Above the scrim (50). The nav creates a stacking context, so the drawer
     inside it can never paint higher than this number — set it below the
     scrim and the drawer opens invisibly behind it. */
  position: sticky; top: 0; z-index: 60;
}
.nav a {
  color: #c7d3e8; text-decoration: none;
  padding: 6px 11px; border-radius: var(--radius); font-size: 13px;
}
.nav a:hover { background: rgba(255,255,255,.12); color: #fff; }
.nav a.on { background: rgba(255,255,255,.18); color: #fff; font-weight: 600; }
.nav .brand { display: flex; align-items: center; margin-right: 16px; padding: 0 4px 0 0; }
.nav .brand:hover { background: none; }
/* Sized off the 46px bar rather than a fixed height, so the lockup keeps its
   proportions and stays clear of the nav's own padding. */
.brand-logo { height: 26px; width: auto; display: block; }
.nav .spacer { flex: 1; }
.nav .who { color: #fff; }
.nav .muted { color: #93a4c4; }

/* The links live in a container so they can become a drawer on a phone. On a
   desktop that container has to behave like the bar it replaced — without a
   layout of its own it is a block div inside a flex row, and every link wraps
   underneath the logo. */
.nav .nav-links {
  display: flex; align-items: center; gap: 4px;
  flex: 1; min-width: 0;
}
.nav .nav-links .spacer { flex: 1; }
.nav .nav-links .drawer-head { display: none; }

/* ─── layout ─── */
/* Full width. This is a table app on a desk monitor: the job list, the price
   book and the catalogue all have columns worth showing, and a 1180px column
   centred on a 1920px screen threw away a third of the display and pushed
   money columns off to the right. Padding, not a max-width, keeps it from
   touching the edges. */
.wrap { max-width: 100%; margin: 0; padding: 22px 28px 60px; }
.wide { max-width: 100%; margin: 0; padding: 18px 28px 60px; }

/* Prose pages are the exception — a sign-in form or a rules page stretched
   across a wide monitor is unreadable, so those keep a comfortable measure. */
.wrap.reading { max-width: 900px; margin: 0 auto; }

h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: -.2px; }
h2 { font-size: 16px; margin: 26px 0 10px; }
h3 { font-size: 13px; margin: 0 0 8px; text-transform: uppercase;
     letter-spacing: .5px; color: var(--ink-soft); }
p  { margin: 0 0 10px; }
a  { color: var(--navy); }

.sub { color: var(--ink-soft); font-size: 13px; margin: 0 0 18px; }
.muted { color: var(--ink-faint); }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }

.row  { display: flex; gap: 14px; align-items: flex-start; flex-wrap: wrap; }
.row.tight { gap: 8px; }
.row.between { justify-content: space-between; align-items: center; }
.grow { flex: 1; min-width: 0; }

.card {
  background: var(--bg); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; margin-bottom: 16px;
}
.card.pad0 { padding: 0; overflow: hidden; }
.card > h3:first-child { margin-top: 0; }

/* ─── tables ─── */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .4px;
  color: var(--ink-soft); font-weight: 600;
  padding: 8px 9px; border-bottom: 1.5px solid var(--line);
  background: var(--bg-soft);
}

/* Headers stick only where a table is long enough to scroll past its own head
   — the price book and the estimate grid. On a short list a sticky header
   detaches and floats over the first rows, which reads as a broken page. */
.sticky-head th { position: sticky; top: 46px; z-index: 10; }
td { padding: 6px 9px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
tbody tr:hover { background: #fbfcfd; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12px; }
tr.group-head td {
  background: var(--navy-soft); font-weight: 700; font-size: 12px;
  text-transform: uppercase; letter-spacing: .5px; color: var(--navy);
  border-bottom: 1px solid #c9d6ea;
}
tr.group-sub td { background: #f4f7fb; font-weight: 600; border-bottom: 1.5px solid var(--line); }
tr.empty td { color: var(--ink-faint); font-style: italic; padding: 14px 9px; }

/* ─── forms ─── */
input, select, textarea, button {
  font: inherit; color: inherit;
}
input[type=text], input[type=email], input[type=password], input[type=date],
input[type=number], input[type=search], input[type=file], select, textarea {
  padding: 6px 8px; border: 1px solid var(--line); border-radius: var(--radius);
  background: #fff; width: 100%; max-width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--navy); outline-offset: -1px; border-color: var(--navy);
}
textarea { min-height: 66px; resize: vertical; }
label { display: block; font-size: 11px; font-weight: 600; color: var(--ink-soft);
        text-transform: uppercase; letter-spacing: .4px; margin-bottom: 3px; }
.field { margin-bottom: 12px; }
.field.inline { display: flex; align-items: center; gap: 8px; }
.field.inline label { margin: 0; text-transform: none; letter-spacing: 0; font-size: 13px; }
.hint { font-size: 12px; color: var(--ink-faint); margin-top: 3px; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 14px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0 14px; }
@media (max-width: 760px) { .grid2, .grid3, .grid4 { grid-template-columns: 1fr; } }

/* cells that edit in place */
input.cell {
  border: 1px solid transparent; background: transparent;
  padding: 3px 5px; border-radius: 4px; width: 100%;
  font-variant-numeric: tabular-nums;
}
input.cell:hover { border-color: var(--line); background: #fff; }
input.cell:focus { border-color: var(--navy); background: #fff; }
input.cell.num { text-align: right; }
input.cell.saved { animation: flash-ok .7s ease-out; }
@keyframes flash-ok { from { background: #d9f5e3; } to { background: transparent; } }

button, .btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 13px; border-radius: var(--radius);
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  cursor: pointer; text-decoration: none; font-size: 13px; white-space: nowrap;
}
button:hover, .btn:hover { background: var(--bg-soft); border-color: #c6ccd4; }
.btn-primary, button.primary {
  background: var(--navy); border-color: var(--navy); color: #fff; font-weight: 600;
}
.btn-primary:hover, button.primary:hover { background: #17294a; border-color: #17294a; }
.btn-sm { padding: 3px 8px; font-size: 12px; }
.btn-danger { color: var(--err); border-color: #f0c9c7; }
.btn-danger:hover { background: var(--err-bg); }
.btn-link { border: none; background: none; padding: 2px 4px; color: var(--navy);
            text-decoration: underline; }

/* ─── chips, badges, flashes ─── */
.badge {
  display: inline-block; padding: 1px 7px; border-radius: 999px;
  font-size: 11px; font-weight: 600; letter-spacing: .2px;
  background: var(--bg-soft); color: var(--ink-soft); border: 1px solid var(--line);
}
.badge.baseline { background: var(--warn-bg); color: var(--warn); border-color: #f0dcae; }
.badge.supplier { background: #eaf2fd; color: #1d4ed8; border-color: #cbdcf7; }
.badge.manual   { background: var(--ok-bg); color: var(--ok); border-color: #bfe6cd; }
.badge.history  { background: #f3ecfb; color: #6d28d9; border-color: #ddd0f2; }
.badge.quickbooks { background: #e7f6ec; color: #146c43; border-color: #bfe3cc; }
.badge.none     { background: #f4f5f6; color: var(--ink-faint); }
.badge.unitprice { background: #ede9fe; color: #5b21b6; border-color: #d6ccf5; margin-left: 6px; }
.badge.pw       { background: #fee9d6; color: #9a3412; border-color: #f5cfae; }
.badge.warn     { background: var(--warn-bg); color: var(--warn); border-color: #f0dcae; }

/* Bid-check severities. Red reads as "do not send", amber as "answer this",
   grey as "recorded so it can be defended if challenged". */
.badge.sev-critical { background: #fde8e6; color: #b3261e; border-color: #f3c4bf; }
.badge.sev-high     { background: #fdeee0; color: #9a3412; border-color: #f5cfae; }
.badge.sev-medium   { background: var(--warn-bg); color: var(--warn); border-color: #f0dcae; }
.badge.sev-low      { background: #f4f5f6; color: var(--ink-faint); }
.badge.sev-info     { background: #eef3f8; color: #3f5b76; border-color: #d3e0ec; }
tr.row-bad > td { background: #fdf5f4; }

tr.unit-price-row td[data-c="material_cost"],
tr.unit-price-row td[data-c="labor_cost"] { background: #fbfbfd; }

.status { display: inline-block; padding: 1px 8px; border-radius: 999px;
          font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
.status.intake      { background: #eef1f4; color: #4b5563; }
.status.in_progress { background: #fef3c7; color: #92400e; }
.status.submitted   { background: #dbeafe; color: #1d4ed8; }
.status.won         { background: var(--ok-bg); color: var(--ok); }
.status.lost        { background: var(--err-bg); color: var(--err); }
.status.withdrawn, .status.no_bid { background: #f4f5f6; color: var(--ink-faint); }
.status.draft { background: #eef1f4; color: #4b5563; }
.status.final { background: var(--ok-bg); color: var(--ok); }
.status.superseded { background: #f4f5f6; color: var(--ink-faint); }

.flash { padding: 9px 13px; border-radius: var(--radius); margin-bottom: 14px;
         font-size: 13px; border: 1px solid; }
.flash.ok    { background: var(--ok-bg);  color: var(--ok);  border-color: #bfe6cd; }
.flash.error { background: var(--err-bg); color: var(--err); border-color: #f0c9c7; }
.flash.warn  { background: var(--warn-bg); color: var(--warn); border-color: #f0dcae; }

.note {
  border-left: 3px solid var(--accent); background: var(--warn-bg);
  padding: 10px 13px; border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 13px; margin-bottom: 16px; color: #6b4a12;
}

/* ─── the number strip on an estimate ─── */
.figures { display: flex; gap: 0; flex-wrap: wrap; border: 1px solid var(--line);
           border-radius: var(--radius); overflow: hidden; background: #fff; }
.fig { flex: 1; min-width: 128px; padding: 11px 14px; border-right: 1px solid var(--line-soft); }
.fig:last-child { border-right: none; }
.fig .k { font-size: 10.5px; text-transform: uppercase; letter-spacing: .5px;
          color: var(--ink-faint); font-weight: 600; }
.fig .v { font-size: 19px; font-weight: 650; font-variant-numeric: tabular-nums;
          letter-spacing: -.3px; margin-top: 1px; }
.fig.total { background: var(--navy); }
.fig.total .k { color: #a9bcdd; }
.fig.total .v { color: #fff; }

/* ─── recap build-up ─── */
.buildup { max-width: 560px; }
.buildup tr td:first-child { color: var(--ink-soft); }
.buildup tr.sum td { font-weight: 700; color: var(--ink);
                     border-top: 1.5px solid var(--line); border-bottom: none; }
.buildup tr.grand td { font-size: 17px; font-weight: 750; padding-top: 12px;
                       border-top: 2.5px solid var(--navy); }
.buildup tr.gap td { height: 10px; border: none; padding: 0; }

/* ─── search dropdown ─── */
.picker { position: relative; }
.picker-results {
  position: absolute; top: calc(100% + 3px); left: 0; right: 0; z-index: 60;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(20,25,35,.13); max-height: 340px; overflow-y: auto;
}
.picker-results:empty { display: none; }
.pick { padding: 7px 11px; cursor: pointer; border-bottom: 1px solid var(--line-soft);
        display: flex; gap: 10px; align-items: baseline; }
.pick:last-child { border-bottom: none; }
.pick:hover, .pick.active { background: var(--navy-soft); }
.pick .code { font-family: ui-monospace, Consolas, monospace; font-size: 11.5px;
              font-weight: 600; color: var(--navy); min-width: 108px; }
.pick .desc { flex: 1; font-size: 12.5px; }
.pick .cost { font-size: 11.5px; color: var(--ink-faint);
              font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ─── misc ─── */
.tabs { display: flex; gap: 4px; border-bottom: 1.5px solid var(--line); margin-bottom: 16px; }
.tabs a { padding: 7px 13px; text-decoration: none; color: var(--ink-soft);
          font-size: 13px; border-bottom: 2.5px solid transparent; margin-bottom: -1.5px; }
.tabs a.on { color: var(--navy); font-weight: 650; border-bottom-color: var(--navy); }
.tabs a:hover { color: var(--ink); }

details.drop > summary { cursor: pointer; font-size: 13px; color: var(--navy);
                         padding: 4px 0; user-select: none; }
details.drop[open] > summary { margin-bottom: 10px; font-weight: 600; }

.remember {
  display: flex; align-items: center; gap: 8px; margin: -2px 0 14px;
  font-size: 13px; font-weight: 400; color: var(--ink-soft);
  text-transform: none; letter-spacing: 0; cursor: pointer;
}
.remember input { width: auto; margin: 0; }

.login-page { max-width: 340px; margin: 12vh auto; }
.login-page h1 { text-align: center; margin-bottom: 4px; }
.login-page .sub { text-align: center; }

.pager { display: flex; gap: 8px; align-items: center; justify-content: center;
         margin-top: 16px; font-size: 13px; }

/* Job section tabs. Counts sit in the tab so a PM can see at a glance that a
   job has 48 documents without opening the page. */
.job-tabs { margin-top: 14px; }
.tab-n {
  display: inline-block; margin-left: 5px; padding: 0 6px;
  border-radius: 999px; background: var(--bg-soft); border: 1px solid var(--line);
  font-size: 11px; font-weight: 600; color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}
.tabs a.on .tab-n { background: var(--navy-soft); border-color: #c9d6ea; color: var(--navy); }
.tab-n.warn { background: var(--warn-bg); border-color: #f0dcae; color: var(--warn); }

.login-brand { text-align: center; margin: 0 0 6px; }
.login-brand img { width: 100%; max-width: 260px; height: auto; }

/* Site photo thumbnails — fixed height so a row lines up regardless of which
   way the phone was held. */
.thumb {
  height: 104px; width: auto; max-width: 170px; object-fit: cover;
  border-radius: var(--radius); border: 1px solid var(--line); display: block;
}
.thumb:hover { border-color: var(--navy); }

.back-caret { font-weight: 700; margin-right: 1px; }

/* ─────────────────────────── phones ───────────────────────────
   The field opens this on a phone, standing up, one-handed. Rules:
   tap targets big enough to hit, inputs at 16px so iOS does not zoom on
   focus, tab strips that scroll sideways instead of wrapping into a wall,
   and wide tables that scroll inside their own card. */
@media (max-width: 720px) {
  body { font-size: 15px; }
  .wrap, .wide { padding: 14px 12px 80px; }

  /* The links live in the drawer now — the bar holds only the button, the
     logo and the account link, so it must not scroll or clip. */
  .nav { height: 52px; padding: 0 10px; gap: 2px; }
  .brand-logo { height: 22px; }

  /* Tabs scroll rather than stacking — the strip stays one line. */
  .tabs { overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs a { white-space: nowrap; padding: 10px 12px; }

  /* Forms: one column, and 16px inputs so iOS does not zoom in on focus. */
  .grid2, .grid3, .grid4 { grid-template-columns: 1fr; }
  input[type=text], input[type=email], input[type=password], input[type=date],
  input[type=time], input[type=number], input[type=search], input[type=file],
  select, textarea { font-size: 16px; padding: 10px; }
  label { font-size: 12px; }
  button, .btn { padding: 11px 15px; font-size: 15px; }
  button.primary, .btn-primary { width: 100%; justify-content: center; }

  /* A table wider than the screen scrolls in its card, never the page. */
  .card.pad0 { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { font-size: 13px; }
  th, td { padding: 9px 8px; }
  .sticky-head th { position: static; }

  .figures { flex-wrap: wrap; }
  .fig { min-width: 45%; }
  .thumb { height: 88px; }

  h1 { font-size: 19px; }
  .row.between { flex-direction: column; align-items: flex-start; gap: 10px; }
}

@media (max-width: 420px) {
  .fig { min-width: 100%; }
  .thumb { height: 76px; max-width: 46%; }
}

/* ─── document viewer ───
   Full-bleed, because a drawing needs every pixel. The bar is sticky so the
   way back never scrolls off — on a phone this is the only Back there is. */
.viewer-page { max-width: 100%; margin: 0; padding: 0; }

.viewer-bar {
  position: sticky; top: 46px; z-index: 30;
  display: flex; align-items: center; gap: 10px;
  background: var(--bg); border-bottom: 1px solid var(--line);
  padding: 8px 12px;
}
.viewer-back {
  display: inline-flex; align-items: center; gap: 4px;
  font-weight: 650; color: var(--navy); text-decoration: none;
  padding: 7px 12px 7px 8px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--bg-soft);
  white-space: nowrap;
}
.viewer-back:hover { background: var(--navy-soft); border-color: #c9d6ea; }
.viewer-caret { font-size: 20px; line-height: 1; margin-top: -2px; }
.viewer-title {
  flex: 1; min-width: 0; font-size: 13px; color: var(--ink-soft);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.viewer-open { font-size: 13px; white-space: nowrap; }

.viewer-body { background: #52565c; min-height: calc(100vh - 46px - 49px); }
.viewer-frame {
  width: 100%; height: calc(100vh - 46px - 49px); border: 0; display: block;
}
.viewer-image { display: block; max-width: 100%; height: auto; margin: 0 auto; }
.viewer-fallback {
  background: var(--bg); margin: 22px auto; max-width: 460px;
  padding: 22px; border-radius: var(--radius); text-align: center;
}

@media (max-width: 720px) {
  .viewer-bar { top: 52px; padding: 7px 9px; }
  .viewer-back { padding: 9px 12px 9px 8px; }
  /* The filename is the least useful thing on a small screen — the back
     control and the document matter more. */
  .viewer-title { display: none; }
  .viewer-body, .viewer-frame { min-height: calc(100vh - 52px - 50px); height: calc(100vh - 52px - 50px); }
}

/* ── Mobile drawer ────────────────────────────────────────────────────────
   On a phone the nav used to be a horizontally-scrolling strip, which hides
   most of the app behind a swipe nobody thinks to try — a menu you cannot see
   is a menu that does not exist. On a phone it becomes a left drawer instead:
   every destination listed, one tap, nothing hidden.

   Pure CSS off a hidden checkbox. No JavaScript, so it works before scripts
   run and cannot break if one fails. */

/* ── The menu ──────────────────────────────────────────────────────────────
   One drawer, every width, opened by a real button. The previous version was
   a CSS-only checkbox that only existed below a breakpoint, so on a slightly
   wider window there was no button at all and the menu appeared to do
   nothing. Driven now by a `menu-open` class the script puts on <html>. */

.menu-btn {
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; margin-right: 8px; flex: none;
  background: none; border: none; padding: 0;
  border-radius: var(--radius); cursor: pointer; color: #fff;
}
.menu-btn:hover { background: rgba(255,255,255,.14); }
.menu-btn svg { width: 21px; height: 21px; }

.drawer-scrim { display: none; }
.drawer-scrim.on {
  display: block; position: fixed; inset: 0;
  background: rgba(0,0,0,.45); z-index: 50;
}

/* Off-screen until opened, at any width. */
.nav .nav-links {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: 280px; max-width: 82%;
  background: var(--navy); z-index: 60;
  display: flex; flex-direction: column; align-items: stretch;
  padding: 14px 0 24px; gap: 2px;
  transform: translateX(-102%);
  transition: transform .2s ease;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  box-shadow: 2px 0 18px rgba(0,0,0,.35);
}
/* The state lives on the drawer itself. Driving it from a class on <html>
   left the browser holding the closed value even though the open rule
   matched and sat later with higher specificity — not worth fighting when
   the element can simply carry its own state. */
.nav .nav-links.on { transform: translateX(0) !important; }

.nav .nav-links a {
  padding: 13px 20px; font-size: 15px; border-radius: 0;
  white-space: nowrap; color: #c7d3e8;
}
.nav .nav-links a:hover { background: rgba(255,255,255,.12); color: #fff; }
.nav .nav-links a.on {
  background: rgba(255,255,255,.16); color: #fff; font-weight: 600;
  box-shadow: inset 3px 0 0 #d9a441;
}
.nav .nav-links .spacer { flex: 1; min-height: 12px; }
.nav .nav-links .drawer-head {
  display: block; padding: 6px 20px 12px; color: #93a4c4;
  font-size: 11px; text-transform: uppercase; letter-spacing: .08em;
}


/* ── The way back out of a drawing ────────────────────────────────────────
   On a phone a drawing fills the screen and the bar can scroll away or be
   covered. This is a second, unmissable way back: fixed to the bottom-left,
   thumb-height, always on top. Belt and braces on purpose — being stranded
   in a document is the complaint, and one control that cannot fail is worth
   more than a tidier layout. */
.viewer-escape { display: none; }

@media (max-width: 900px) {
  .viewer-bar { top: 52px; z-index: 55; }

  .viewer-escape {
    display: inline-flex; align-items: center; gap: 6px;
    position: fixed; left: 14px; bottom: 16px; z-index: 70;
    padding: 12px 18px 12px 14px; border-radius: 999px;
    background: var(--navy); color: #fff; text-decoration: none;
    font-size: 15px; font-weight: 650;
    box-shadow: 0 3px 14px rgba(0,0,0,.34);
  }
  .viewer-escape:active { background: #17294a; }
  .viewer-escape .viewer-caret { font-size: 19px; margin-top: -2px; }
}


/* ── Product photos ───────────────────────────────────────────────────────
   A catalogue photo is how you tell a 4-square box from a 4-11/16, so on a
   phone it has to be big enough to actually look at. On a desktop the list is
   scanned by name and a small thumbnail keeps more rows on screen; on a phone
   there is one row at a time anyway, so the picture gets the room. */
.cat-thumb {
  height: 38px; width: 50px; object-fit: contain;
  border-radius: 4px; background: #fff; display: block;
}
.cat-thumb-inline { display: inline-block; vertical-align: middle; margin-left: 6px; height: 28px; }

@media (max-width: 900px) {
  /* Roughly three times the area it had — big enough to recognise a fitting
     without opening anything. */
  .cat-thumb {
    height: 118px; width: 150px; padding: 4px;
    border: 1px solid var(--line-soft);
  }
  .cat-thumb-inline { height: 64px; width: 82px; }

  /* The picture column has to grow with it, or the photo is cropped by a
     column still sized for a 50px thumbnail. */
  td:has(> .cat-thumb), th:first-child:empty { width: 162px !important; }
}

/* ── Drawings, shown as images ────────────────────────────────────────────
   The browser's own PDF viewer is not usable here: iOS will not render one in
   an iframe, and opening it full-screen takes the app away entirely — the
   complaint was having to sign out to get back to the job. Pages are rendered
   server-side and shown as plain images, so the app's bar and Back button
   stay on screen the whole time. */
.viewer-pages { padding: 10px 8px 90px; display: flex; flex-direction: column; gap: 14px; }
.viewer-page-img { margin: 0; background: #fff; border-radius: 6px; overflow: hidden;
               box-shadow: 0 1px 6px rgba(0,0,0,.35); }
.viewer-page-img img { width: 100%; height: auto; display: block; }

/* Zoomed. The width is set on the IMAGE rather than a transform on the page,
   so the browser resamples from the 5400-pixel original instead of magnifying
   what it already painted — a transform would enlarge the blur along with the
   drawing. align-items keeps a page left-aligned once it is wider than the
   screen; centred, its left edge scrolls off and the title block goes with it. */
.viewer-pages.zoomed { overflow-x: auto; align-items: flex-start; }
.viewer-pages.zoomed .viewer-page-img { width: var(--page-zoom, 100%); flex: none; }
.viewer-pages.zoomed .viewer-page-img img { width: 100%; }

/* The zoom bar sits above the pages and scrolls away with them: a drawing is
   read one screenful at a time and a fixed bar would cover part of every one. */
.zoombar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; margin: 8px 8px 0;
  background: rgba(255,255,255,.94); border-radius: 8px;
}
.zoom-btn {
  min-width: 38px; height: 34px; padding: 0 11px;
  border: 1px solid var(--line); background: #fff; border-radius: 7px;
  font-size: 16px; font-weight: 700; line-height: 1; color: var(--ink);
  cursor: pointer;
}
.zoom-btn:hover { border-color: #c9d6ea; background: var(--bg-soft); }
.zoom-btn:active { background: var(--navy-soft); }
.zoom-fit { font-size: 13px; font-weight: 600; }
.zoom-level {
  min-width: 52px; text-align: center;
  font-size: 13px; font-weight: 700; color: var(--ink);
}
.zoom-hint { font-size: 12px; color: var(--ink-soft); margin-left: auto; }

@media (max-width: 700px) {
  /* A phone already pinches, so the bar is only clutter there — but the
     buttons stay for anyone who prefers them. The keyboard hint goes. */
  .zoom-hint { display: none; }
  .zoombar { margin: 8px 8px 0; padding: 6px 8px; }
}
.viewer-page-img figcaption {
  padding: 6px 10px; font-size: 12px; color: var(--ink-soft);
  background: var(--bg-soft); border-top: 1px solid var(--line);
}

/* ── Picking material for an order ────────────────────────────────────────
   A table cannot do this job on a phone. Four columns in 380px turned product
   names into one letter per line and cut the size dropdown off mid-word, so
   the whole thing had to be scrolled sideways to use. A list that reflows
   costs nothing on a desktop and is the only usable shape on a phone. */
.pick-list { list-style: none; margin: 0; padding: 0; }
.pick-item {
  display: flex; gap: 14px; align-items: flex-start;
  padding: 12px 14px; border-bottom: 1px solid var(--line-soft);
}
.pick-item:last-child { border-bottom: 0; }

/* Every photo is now square, trimmed to the product and laid on white, so a
   square frame fits them all and the grid lines up. The old landscape box
   left a wide band of nothing above and below each fitting. */
.pick-photo { flex: none; width: 88px; }
.pick-photo img {
  width: 88px; height: 88px; object-fit: contain;
  background: #fff; border: 1px solid var(--line-soft); border-radius: 6px;
}
.pick-body { flex: 1; min-width: 0; }
.pick-name { font-weight: 650; line-height: 1.3; }
.pick-sub  { color: var(--ink-soft); font-size: 13px; margin-top: 1px; }
.pick-cat  { font-size: 12px; margin-top: 2px; }

.pick-add { display: flex; gap: 8px; align-items: center; margin-top: 9px; flex-wrap: wrap; }
.pick-add select { width: 190px; }
.pick-add input[type=text] { width: 74px; }

/* Wire colour, painted rather than spelled.
   A dropdown listing the word "Brown" is a list of words; a man ordering wire
   wants to touch the brown one. The radio itself is hidden from sight but not
   from a keyboard or a screen reader — the coloured chip is its label, so a
   tap on the chip is a tap on the radio, and Tab still walks the group. */
.swatches {
  display: flex; flex-wrap: wrap; gap: 6px;
  width: 100%; margin: 2px 0 4px;
}
.swatch-in {
  position: absolute; opacity: 0; pointer-events: none;
  width: 1px; height: 1px;
}
.swatch {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px 5px 6px; border-radius: 999px;
  border: 1px solid var(--line); background: #fff;
  cursor: pointer; font-size: 13px; font-weight: 600; line-height: 1;
  color: var(--ink-soft); user-select: none;
}
.swatch-dot {
  width: 17px; height: 17px; border-radius: 50%;
  /* White wire on a white chip needs an edge or it reads as an empty hole. */
  border: 1px solid rgba(0,0,0,.28); flex: none;
}
.swatch:hover { border-color: #c9d6ea; }
/* The chosen one is unmistakable across a sunlit site — a filled navy chip,
   not a one-pixel outline. */
.swatch-in:checked + .swatch {
  background: var(--navy); border-color: var(--navy); color: #fff;
}
.swatch-in:checked + .swatch .swatch-dot { border-color: rgba(255,255,255,.75); }
/* Keyboard focus has to survive the radio being invisible. */
.swatch-in:focus-visible + .swatch { outline: 2px solid var(--navy); outline-offset: 2px; }

@media (max-width: 560px) {
  /* Eight chips wrap to two rows at 375px and stay thumb-sized. */
  .swatch { padding: 7px 12px 7px 8px; font-size: 13.5px; }
  .swatch-dot { width: 19px; height: 19px; }
}

/* Categories as buttons rather than a dropdown. A thumb hits these; nothing
   opens, nothing scrolls inside itself. */
.cat-chips {
  display: flex; flex-wrap: wrap; gap: 7px;
  margin: 0 0 14px;
}
.cat-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 12px; border-radius: 999px;
  background: #fff; border: 1px solid var(--line);
  color: var(--ink); text-decoration: none;
  font-size: 13.5px; font-weight: 600; line-height: 1;
}
.cat-chip span {
  font-weight: 600; font-size: 12px; color: var(--ink-soft);
  background: var(--navy-soft); border-radius: 999px; padding: 2px 7px;
}
.cat-chip:hover { border-color: #c9d6ea; }
.cat-chip.on { background: var(--navy); border-color: var(--navy); color: #fff; }
.cat-chip.on span { background: rgba(255,255,255,.22); color: #fff; }

@media (max-width: 900px) {
  .pick-add { margin-top: 11px; }
  .pick-add select { flex: 1; min-width: 150px; width: auto; }
  .pick-add input[type=text] { width: 68px; }
  .pick-add button { flex: none; }
}

@media (max-width: 560px) {
  /* The picture stays beside the name — it is how you tell one fitting from
     another, and stacking it full-width pushed the Add button off the first
     screen. A square thumb keeps both on one line. */
  .pick-item { gap: 11px; padding: 11px 12px; }
  .pick-photo { width: 76px; }
  .pick-photo img { width: 76px; height: 76px; }
  .pick-name { font-size: 15px; }
  .pick-add { width: 100%; margin-top: 10px; }
  .pick-add select { width: 100%; flex: none; }
  .pick-add input[type=text] { width: 72px; }
  .pick-add button { flex: 1; justify-content: center; min-height: 42px; }
  .cat-chip { padding: 9px 13px; font-size: 14px; }
}

/* The foot of a document viewer. The bar at the top is fixed to the layout,
   not to the glass — pinch a page to read it and the bar goes with it. These
   two are where the thumb already is once the document has been scrolled. */
.viewer-foot {
  display: flex; gap: 10px; flex-wrap: wrap; justify-content: center;
  padding: 18px 12px 96px;
}
.viewer-foot .btn { background: #fff; }
.viewer-foot .btn.primary { background: var(--navy); color: #fff; border-color: var(--navy); }

/* A section that starts something, rather than a heading that ends the last
   thing. The catalogue on a purchase order read as the bottom of the page. */
.section-head {
  background: var(--navy); color: #fff; border-radius: var(--radius);
  padding: 14px 16px; margin: 26px 0 12px;
}
.section-head h2 { margin: 0; color: #fff; border: 0; padding: 0; font-size: 20px; }
.section-head p  { margin: 5px 0 0; font-size: 13.5px; color: #d7e0f0; }
.section-head strong { color: #fff; }

/* ── Circuits page ───────────────────────────────────────────────────────
   The step list is deliberately plain: what is done, what is not, and what is
   still in the way of a number. A takeoff that hides an incomplete step
   produces a figure that looks exactly like a finished one. */
.steps { list-style: none; margin: 0; padding: 0; }
.steps li { padding: 7px 0; border-bottom: 1px solid #e6e6e6;
            display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.steps li:last-child { border-bottom: 0; }
.steps .tick { display: inline-block; width: 18px; font-weight: 700; }
.steps li.done .tick { color: #1a7f37; }
.steps li.todo .tick { color: #b0b0b0; }
.steps li.todo b { color: #666; }
.steps .sub { margin-left: auto; }

.rulelist { list-style: none; margin: 0; padding: 0; columns: 2; }
.rulelist li { padding: 3px 0; break-inside: avoid; }
.rulelist li.warn { color: #b3261e; }
.rulelist code { margin-right: 8px; font-weight: 700; }

table.tight th, table.tight td { padding: 4px 8px; font-size: 13px; }

@media (max-width: 700px) {
  .rulelist { columns: 1; }
  .steps .sub { margin-left: 28px; width: 100%; }
}

/* A disabled button that looks live is a trap: it invites the tap it will
   refuse. "Send to office to confirm" sat there in full navy while it was
   still waiting for a vendor. */
button[disabled], .btn[disabled], button.primary[disabled] {
  background: #e6eaf1; border-color: #d6dce6; color: #8a93a3;
  cursor: not-allowed; box-shadow: none;
}

/* Inside a chosen category, printing that category under every single row is
   noise on a 375px screen. */
.cat-picked .pick-cat { display: none; }

/* Tap a part photo to see it properly. A thumbnail says "connector"; it does
   not say squeeze type or set screw type, and that is the whole question when
   a foreman is ordering from a phone. */
.pick-photo img, .cat-thumb { cursor: zoom-in; }
body.photo-open { overflow: hidden; }
.photo-zoom {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(12, 18, 30, .93);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; padding: 20px; cursor: zoom-out;
}
.photo-zoom img {
  max-width: 100%; max-height: 74vh; object-fit: contain;
  background: #fff; border-radius: 10px; padding: 10px;
}
.photo-zoom-name {
  color: #fff; font-weight: 650; font-size: 16px; text-align: center;
  max-width: 640px; line-height: 1.35;
}
.photo-zoom-hint { color: #9fb0c9; font-size: 13px; }

/* The end of a long list. Thirty-seven conduit bodies is a long scroll back,
   so the way out is where you finish reading rather than only at the top. */
.list-foot { display: flex; justify-content: center; padding: 14px; }
.list-foot .btn { background: #fff; }
