/* Auto Layout AI Field Companion - touch-first styles for iPad Safari */

:root {
  --bg: #f3f4f6;
  --panel: #ffffff;
  --ink: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #1d4ed8;
  --accent-ink: #ffffff;
  --danger: #b91c1c;
  --ok: #15803d;
  --warn: #b45309;
  --radius: 12px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overscroll-behavior: none; }
#app { height: 100%; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.screen { height: 100%; display: flex; flex-direction: column; }

/* Top bar ---------------------------------------------------------------- */
.topbar { display: flex; align-items: center; gap: 12px; padding: calc(8px + var(--safe-top)) 14px 8px;
  background: #000; color: #fff; min-height: 56px; flex: 0 0 auto; border-bottom: 1px solid #1e293b; }
.topbar-title { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.topbar-title .brand { font-weight: 700; font-size: 17px; }
.topbar-title .subtitle { font-size: 13px; opacity: 0.8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-title.compact .title-line { font-weight: 600; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .btn-ghost { color: #fff; border-color: rgba(255,255,255,0.35); }

/* Content ---------------------------------------------------------------- */
.content { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 16px 16px calc(24px + var(--safe-bottom)); }
.content.narrow { max-width: 720px; width: 100%; margin: 0 auto; }
.section-title { font-size: 15px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin: 28px 0 8px; }

/* Fields ----------------------------------------------------------------- */
.field { display: block; margin: 0 0 16px; }
.field-label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.field-label .req { font-weight: 400; }
.select, .input { width: 100%; font-size: 18px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--panel); color: var(--ink); min-height: 50px; appearance: none; -webkit-appearance: none; }
.select { background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 22px) 22px, calc(100% - 16px) 22px; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 40px; }
textarea.input { resize: vertical; min-height: 80px; }
.meta { font-size: 13px; color: var(--muted); margin: -6px 0 14px; min-height: 18px; }
.check { display: flex; align-items: center; gap: 10px; margin: 14px 0; font-size: 15px; }
.check input { width: 22px; height: 22px; }
.check.small { font-size: 13px; margin: 10px 0 0; }

/* Buttons ---------------------------------------------------------------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-size: 16px; font-weight: 600;
  padding: 10px 16px; min-height: 44px; border-radius: var(--radius); border: 1px solid transparent; cursor: pointer;
  text-decoration: none; user-select: none; -webkit-user-select: none; }
.btn:active { transform: translateY(1px); filter: brightness(0.95); }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-secondary { background: var(--panel); color: var(--accent); border-color: var(--accent); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost.small { min-height: 36px; font-size: 14px; padding: 6px 12px; }
.btn-big { width: 100%; min-height: 56px; font-size: 18px; margin: 6px 0; }
.btn[disabled] { opacity: 0.45; pointer-events: none; }
.badge { background: #fff; color: var(--accent); border-radius: 999px; padding: 1px 9px; font-size: 14px; min-width: 24px; text-align: center; }

.segmented { display: flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--panel); }
.seg { flex: 1; min-height: 52px; font-size: 17px; font-weight: 600; background: transparent; border: 0; color: var(--muted); }
.seg + .seg { border-left: 1px solid var(--line); }
.seg[aria-checked="true"] { background: var(--accent); color: #fff; }
#st-completed[aria-checked="true"] { background: var(--ok); }
#st-planned[aria-checked="true"] { background: var(--warn); }

/* Alerts / toast -------------------------------------------------------- */
.alert { background: #fee2e2; color: var(--danger); border: 1px solid #fecaca; border-radius: var(--radius); padding: 10px 14px; margin: 0 0 14px; font-size: 15px; }
/* Busy: a turning circle so a wait never looks frozen. The spin is a CSS transform, which the
   browser animates off the main thread -- it keeps turning while the iPad draws. */
@keyframes el-spin { to { transform: rotate(360deg); } }
.pair { position: fixed; inset: 0; z-index: 2000; display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.55); padding: 16px; }
.pair-box { background: #fff; color: #111827; border-radius: 16px; padding: 22px 24px; width: min(460px, 100%);
  display: flex; flex-direction: column; gap: 8px; box-shadow: 0 10px 30px rgba(0,0,0,0.35); }
.pair-box h2 { margin: 0 0 4px; font-size: 20px; }
.pair-code { font-size: 30px; letter-spacing: 8px; text-align: center; padding: 10px; border: 2px solid #d1d5db;
  border-radius: 10px; font-variant-numeric: tabular-nums; }
.pair-msg { min-height: 18px; color: #b91c1c; }
.pair-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }
/* Sign in: the people as big buttons, then a PIN pad */
.si-box { width: min(520px, 100%); }
.si-people { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; max-height: 40vh; overflow-y: auto; }
.si-person { min-height: 48px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.si-dots { text-align: center; font-size: 26px; letter-spacing: 10px; padding: 6px 0 2px; font-variant-numeric: tabular-nums; }
.si-keys { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; max-width: 300px; margin: 0 auto; }
.si-key { min-height: 52px; font-size: 20px; }
.who-chip { max-width: 160px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; }
.pk-chip.pk-shared { background: #dcfce7; color: #14532d; }
/* the job's licence: a warning before it ends, red once the job is read-only */
.lic-banner { padding: 6px 14px; font-size: 14px; font-weight: 600; background: #fef3c7; color: #92400e; border-bottom: 1px solid #fcd34d; }
.lic-banner.lic-ro { background: #fee2e2; color: #991b1b; border-bottom-color: #fca5a5; }
.pk-chip.pk-private { background: #f3f4f6; color: #374151; }
.busy { position: fixed; inset: 0; z-index: 1900; display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.35); }
.busy-box { display: flex; flex-direction: column; align-items: center; gap: 14px; background: #111827; color: #fff;
  padding: 22px 28px; border-radius: 16px; max-width: 80vw; text-align: center; font-size: 16px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.35); }
.spinner { width: 44px; height: 44px; border-radius: 50%; border: 4px solid rgba(255,255,255,0.22);
  border-top-color: #fff; animation: el-spin 0.8s linear infinite; }
.spin, .vi-status.working::before { content: ''; display: inline-block; width: 13px; height: 13px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent; animation: el-spin 0.8s linear infinite;
  vertical-align: -2px; margin-right: 7px; box-sizing: border-box; }
.toast { position: fixed; left: 50%; bottom: calc(24px + var(--safe-bottom)); transform: translateX(-50%); background: #111827; color: #fff;
  padding: 10px 16px; border-radius: 999px; font-size: 15px; z-index: 2000; box-shadow: 0 6px 20px rgba(0,0,0,0.25); }

/* Cards ------------------------------------------------------------------ */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin: 0 0 16px; }
.card-row { display: flex; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.card-row:last-child { border-bottom: 0; }
.card-row .k { flex: 0 0 90px; color: var(--muted); font-size: 13px; padding-top: 2px; }
.card-row .v { flex: 1; font-size: 16px; }
.columns-text { font-variant-numeric: tabular-nums; line-height: 1.6; }
.card.success { border-color: #bbf7d0; background: #f0fdf4; }
.result-title { font-weight: 700; color: var(--ok); font-size: 17px; }
.result-name { margin: 6px 0; word-break: break-word; }

.report-list .report-item { display: flex; align-items: center; gap: 12px; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 10px 12px; margin-bottom: 8px; }
.report-item .ri-main { flex: 1; min-width: 0; }
.report-item .ri-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.report-item .ri-sub { font-size: 13px; color: var(--muted); }
.status-pill { font-size: 12px; font-weight: 700; text-transform: uppercase; padding: 2px 8px; border-radius: 999px; }
.status-pill.planned { background: #fef3c7; color: var(--warn); }
.status-pill.completed { background: #dcfce7; color: var(--ok); }

/* Drawing screen --------------------------------------------------------- */
.draw-layout { flex: 1; display: flex; min-height: 0; }
.map { flex: 1; min-width: 0; background: #d9dde3; touch-action: none; }
.side { flex: 0 0 300px; background: var(--panel); border-left: 1px solid var(--line); display: flex; flex-direction: column;
  padding: 12px 14px calc(12px + var(--safe-bottom)); min-height: 0; }
.side-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.side-title { font-weight: 700; font-size: 16px; }
.hint { font-size: 13px; color: var(--muted); background: #f9fafb; border: 1px dashed var(--line); border-radius: 10px; padding: 8px 10px; margin: 10px 0; }
.chips { list-style: none; padding: 0; margin: 4px 0 0; display: flex; flex-wrap: wrap; gap: 8px; overflow-y: auto; -webkit-overflow-scrolling: touch; flex: 1; align-content: flex-start; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: #fff7ed; border: 1px solid #fdba74; color: #9a3412; border-radius: 999px;
  padding: 6px 8px 6px 12px; font-weight: 700; font-size: 17px; font-variant-numeric: tabular-nums; }
.chip.unverified { background: #fef2f2; border-color: #fca5a5; color: var(--danger); }
.chip .ok { font-size: 12px; font-weight: 400; color: var(--ok); }
.chip .warn { font-size: 12px; font-weight: 400; color: var(--danger); }
.chip button { border: 0; background: rgba(0,0,0,0.06); color: inherit; border-radius: 999px; width: 30px; height: 30px; font-size: 18px; line-height: 1; }

.leaflet-container { font: inherit; background: #d9dde3; }
.leaflet-control-zoom a { width: 40px; height: 40px; line-height: 40px; font-size: 22px; }
.drawing-tiles { image-rendering: auto; }

/* iPad portrait (768-834 px wide) and phones: selection panel below the drawing. */
@media (max-width: 900px) {
  .draw-layout { flex-direction: column; }
  .side { flex: 0 0 auto; max-height: 34vh; border-left: 0; border-top: 1px solid var(--line); }
  .card-row .k { flex-basis: 76px; }
}

/* Offline / connectivity ------------------------------------------------- */
.conn-pill { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; padding: 4px 10px; border-radius: 999px; background: rgba(255,255,255,0.15); color: #fff; white-space: nowrap; }
.conn-pill.online { background: #16a34a; }
.conn-pill.offline { background: #b45309; }
.alert.warn { background: #fef3c7; color: var(--warn); border-color: #fde68a; }
.offline-box { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; margin: 0 0 14px; }
.offline-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.offline-status { font-weight: 700; font-size: 15px; }
.offline-status.ready { color: var(--ok); }
.offline-status.partial { color: var(--warn); }
.offline-actions { display: flex; gap: 8px; align-items: center; }
.tools { display: flex; flex-wrap: wrap; gap: 10px; }
.file-btn { cursor: pointer; }
.legend { margin: 8px 0 0; }
.lg { display: inline-block; width: 12px; height: 12px; border-radius: 999px; vertical-align: -1px; }
.lg-blue { background: rgba(59,130,246,0.25); border: 2px solid #1d4ed8; }
.lg-orange { background: rgba(249,115,22,0.6); border: 2px solid #b91c1c; }
.lg-green { background: rgba(34,197,94,0.5); border: 2px solid #15803d; }
#btn-clear-done { margin-top: 8px; align-self: flex-start; }
.chip.done { background: #f0fdf4; border-color: #86efac; color: #166534; }

/* ---- project views (aligned drawings together) ---- */
.views-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.view-item { display: flex; gap: 10px; align-items: center; justify-content: space-between; padding: 10px 12px;
  border: 1px solid #d6dce4; border-radius: 10px; background: #fff; flex-wrap: wrap; }
.vi-main { min-width: 220px; flex: 1; }
.vi-title { font-weight: 600; }
.vi-sub { color: #5f6b7a; font-size: 13px; margin-top: 2px; }
.vi-status.ok { color: #15803d; }
.vi-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.view-drawings { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.vd { border: 1px solid #e2e8f0; border-radius: 8px; padding: 8px; background: #fbfcfd; }
.vd-row1, .vd-row2 { display: flex; align-items: center; gap: 8px; }
.vd-row1 { justify-content: space-between; }
.vd-row2 { margin-top: 6px; flex-wrap: wrap; }
.vd-vis { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.vd-vis input { width: 22px; height: 22px; }
.vd-swatch { width: 16px; height: 16px; border-radius: 4px; border: 1px solid rgba(0,0,0,.25); flex: none; }
.vd-meta { margin-top: 2px; word-break: break-all; }
.vd-align.ok { color: #15803d; } .vd-align.warn { color: #b45309; }
.vd-opacity { flex: 1; min-width: 110px; }
.vd-base { display: flex; align-items: center; gap: 4px; }
.vd-base input { width: 18px; height: 18px; }
.field.compact { margin: 6px 0; }
.select.small { font-size: 14px; padding: 6px 30px 6px 8px; width: auto; min-width: 96px; }
#screen-view .side { flex-basis: 340px; overflow-y: auto; }
/* Overlay tiles are transparent: the project view draws them on white paper. */
#vmap, #vmap.leaflet-container { background: #ffffff; }
@media (max-width: 900px) { #screen-view .side { max-height: 46vh; } }

/* Home tabs: Drawings (project views) and Pour reports are separate tools. */
.tabs { display: flex; gap: 6px; padding: 8px 16px 0; background: var(--panel, #fff); border-bottom: 1px solid var(--line, #d6dce4); }
.tab { border: 0; background: transparent; font: inherit; font-size: 17px; font-weight: 600; color: var(--muted, #5f6b7a);
  padding: 10px 16px 12px; border-bottom: 3px solid transparent; cursor: pointer; }
.tab[aria-selected="true"] { color: var(--accent, #2563eb); border-bottom-color: var(--accent, #2563eb); }
.pane-intro { margin: -4px 0 10px; }
.app-version { margin-top: 18px; text-align: center; }

/* Project view: background switch + bulk visibility */
.view-tools { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 8px 0 2px; }
.small-seg .seg { padding: 6px 14px; font-size: 14px; min-height: 0; }
#vmap.dark, #vmap.dark.leaflet-container { background: #0b0f14; }
#vmap.dark .leaflet-control-zoom a { background: #1f2933; color: #e6ecf5; border-color: #334155; }

/* Drawings panel grouped by building */
.vgroup { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-top: 6px;
  padding: 6px 4px; border-bottom: 1px solid var(--line); }
.vg-toggle { display: flex; align-items: baseline; gap: 6px; border: 0; background: transparent; font: inherit;
  font-weight: 700; font-size: 16px; padding: 4px 2px; cursor: pointer; color: inherit; }
.vg-caret { width: 14px; display: inline-block; color: var(--muted); }
.vg-actions { display: flex; gap: 4px; }

.vi-status.warn { color: #b45309; }

/* Project view sidebar: Drawings / Layers / Tools tabs, can be hidden for a full-size map */
.view-layout { position: relative; }
.vside { padding-top: 0; }
/* the tab bar across the top of the drawing screen; a tab opens its section in the right panel */
.view-tabs { display: flex; align-items: stretch; gap: 4px; padding: 0 10px; background: #000; border-bottom: 1px solid #27272a;
  flex: 0 0 auto; min-height: 48px; overflow-x: auto; scrollbar-width: none; }
.view-tabs::-webkit-scrollbar { display: none; }
.vtab { flex: 0 0 auto; border: 0; background: transparent; font: inherit; font-size: 16px; font-weight: 600; color: #9ca3af;
  padding: 10px 16px 9px; border-bottom: 3px solid transparent; cursor: pointer; white-space: nowrap; }
.vtab[aria-selected="true"] { color: #fff; border-bottom-color: #3b82f6; background: #111113; }
.vside-head { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; padding: 10px 0 8px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: var(--panel); z-index: 2; }
.vside-title { font-size: 17px; }
#view-side .vpane > .side-head .side-title { display: none; }   /* the panel head names the section already */
.vside-close { margin-left: auto; border: 0; background: transparent; font: inherit; font-size: 14px; font-weight: 600;
  color: var(--muted); padding: 8px 6px; cursor: pointer; }
.view-layout.side-collapsed .vside { display: none; }
/* PDFs tab + viewer (the PDF takes the drawing area; the sidebar stays) */
#btn-pdf-close { white-space: nowrap; }
.pdf-screen { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.pdf-nav { display: flex; align-items: center; gap: 6px; color: #fff; }
.pdf-pagebar { display: flex; gap: 6px; padding: 8px 10px calc(8px + var(--safe-bottom)); overflow-x: auto;
  background: #111827; }
.pdf-pagebar button { flex: 0 0 auto; min-width: 40px; padding: 6px 10px; border-radius: 8px; border: 1px solid #374151;
  background: #1f2937; color: #fff; font-size: 15px; }
.pdf-pagebar button[aria-current="true"] { background: #2563eb; border-color: #2563eb; }
.pdf-job { margin: 0 0 18px; }
.pdf-job-head { display: flex; align-items: center; gap: 10px; margin: 0 0 8px; }
.pdf-job-head .pdf-job-name { flex: 1; font-weight: 700; font-size: 17px; }
.pdf-group { margin: 12px 0 6px; font-size: 14px; font-weight: 700; letter-spacing: .02em; text-transform: uppercase; color: var(--muted, #6b7280); }
/* PDFs tab: Submittals and PDFs side by side (stacked when narrow), each folds from its header */
.pdf-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 12px; align-items: start; }
.pdf-col { min-width: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); padding: 2px 12px 10px; }
.pdf-col-head { display: flex; align-items: center; gap: 8px; width: 100%; margin: 0; padding: 10px 0; border: 0; background: transparent;
  font: inherit; font-size: 14px; font-weight: 700; letter-spacing: .02em; text-transform: uppercase; color: var(--muted); text-align: left; cursor: pointer; }
.pdf-caret { width: 14px; color: var(--ink); }
.pdf-col-count { margin-left: auto; padding: 1px 9px; border-radius: 999px; background: var(--bg); color: var(--ink); font-size: 12px; }
.pdf-col.folded { padding-bottom: 2px; }
.pdf-col.folded .pdf-list, .pdf-col.folded .align-list { display: none; }
.align-col { margin-top: 12px; }
.req-card { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin: 0 0 16px; background: #fff; }
.req-title { font-weight: 700; font-size: 16px; margin: 0 0 10px; }
.req-field { display: block; margin: 0 0 10px; }
.req-label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin: 0 0 4px; }
.req-input { width: 100%; box-sizing: border-box; font-size: 16px; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.gallery-group { margin: 14px 0 8px; font-size: 14px; font-weight: 700; letter-spacing: .02em; text-transform: uppercase; color: var(--muted); }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 12px; }
.gallery-card { display: flex; flex-direction: column; text-align: left; padding: 0; overflow: hidden; cursor: pointer; font: inherit; color: inherit;
  border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.gallery-card:active { box-shadow: 0 0 0 2px #2563eb inset; }
.gallery-thumb { aspect-ratio: 4 / 3; width: 100%; background: #f3f4f6; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.gallery-thumb img { width: 100%; height: 100%; object-fit: contain; display: block; }
.gallery-thumb .gallery-none { font-size: 12px; color: var(--muted); padding: 8px; text-align: center; }
.gallery-info { padding: 8px 10px 10px; }
.gallery-name { font-weight: 600; font-size: 15px; word-break: break-word; }
.gallery-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.gallery-card.is-base { border-color: #2563eb; }
.req-buttons { display: flex; gap: 10px; flex-wrap: wrap; }
.req-blocks { display: flex; align-items: stretch; gap: 4px; margin: 0 0 14px; }
.req-arrow { align-self: center; color: var(--muted); font-size: 22px; line-height: 1; }
.req-block { flex: 1 1 0; min-width: 0; border: 1px solid var(--line); border-radius: 12px; background: #fff; padding: 10px 4px;
  display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer; font: inherit; color: inherit; }
.req-block-n { font-size: 24px; font-weight: 800; line-height: 1.1; }
.req-block-t { font-size: 12px; font-weight: 600; text-align: center; color: var(--muted); }
.req-block.empty { opacity: .55; }
.req-block-draft .req-block-n { color: #6b7280; }
.req-block-sent .req-block-n { color: #2563eb; }
.req-block-progress .req-block-n { color: #d97706; }
.req-block-ready .req-block-n { color: #059669; }
.req-block.on { box-shadow: 0 0 0 2px #2563eb inset; border-color: #2563eb; }
.req-steps { display: flex; gap: 4px; margin: 0 0 6px; }
.req-step { flex: 1 1 0; text-align: center; font-size: 11px; font-weight: 600; padding: 3px 2px; border-radius: 6px; background: #e5e7eb; color: #6b7280; }
.req-step.past { background: #bfdbfe; color: #1e3a8a; }
.req-step.now { background: #2563eb; color: #fff; }
.req-ready .req-step.now { background: #059669; }
.req-progress .req-step.now { background: #d97706; }
.req-draft .req-step.now { background: #6b7280; }
.req-item .req-note { margin: 0 0 8px; word-break: break-word; }
.req-item.req-progress { border-color: #d97706; }
.req-item.req-ready { border-color: #059669; }
.req-item.req-waiting { border-style: dashed; }
.pdf-pageno { min-width: 92px; text-align: center; font-size: 14px; }
.pdfmap { flex: 1; min-height: 0; background: #6b7280; touch-action: none; }
.pdf-list { list-style: none; margin: 0; padding: 0; }
.pdf-add { cursor: pointer; white-space: nowrap; }
.pdf-item .pdf-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.pdf-item .pdf-actions .btn { white-space: nowrap; flex: 0 0 auto; }      /* a narrow column wraps the buttons, never a word */
.pdf-col .pdf-item { min-width: 0; }
.pdf-item.pending { border-style: dashed; }
.pdf-item { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin: 0 0 10px; }
.pdf-item.open { border-color: #2563eb; box-shadow: 0 0 0 1px #2563eb inset; }
.pdf-item .pdf-name { font-weight: 600; font-size: 15px; word-break: break-word; }
.pdf-item .pdf-meta { margin: 2px 0 8px; }
.pdf-pages { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.pdf-pages button { min-width: 38px; padding: 4px 8px; border-radius: 8px; border: 1px solid var(--line);
  background: #fff; font-size: 14px; }
.pdf-pages button[aria-current="true"] { background: #2563eb; color: #fff; border-color: #2563eb; }
.layers-filter { flex: 1; min-width: 150px; font-size: 15px; padding: 7px 10px; }
.view-layers { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-direction: column; }
.vl { display: flex; align-items: center; gap: 10px; padding: 7px 4px; border-bottom: 1px solid #eef1f5; }
.vl label { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; cursor: pointer; }
.vl input { width: 22px; height: 22px; flex: none; }
.vl-name { font-weight: 600; font-size: 14px; word-break: break-all; }
.vl-count { flex: none; }
.vl.off .vl-name { color: var(--muted); text-decoration: line-through; }
.view-toolslist { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.vtool { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px;
  border: 1px dashed #cbd5e1; border-radius: 8px; }
.vtool-name { font-weight: 600; color: var(--muted); }
@media (max-width: 900px) { .vside-close { font-size: 14px; } }
.vl-group { font-weight: 700; flex: 1; }

/* Measure distance */
.vtool-card { padding: 12px; border: 1px solid #cbd5e1; border-radius: 8px; display: flex; flex-direction: column; gap: 8px; }
.vtool-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.vtool-title { font-weight: 700; }
.measure-snap { display: flex; align-items: center; gap: 8px; }
.measure-snap input { width: 20px; height: 20px; }
.measure-list { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 4px; }
.measure-list li { font-size: 15px; }
.measure-list .ml-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.measure-list .ml-d { font-weight: 700; font-variant-numeric: tabular-nums; }
.measure-list .ml-x { border: 0; background: transparent; font-size: 18px; color: var(--muted); padding: 2px 8px; cursor: pointer; }
.measure-bar { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); z-index: 1000; display: flex; align-items: center;
  gap: 8px; padding: 8px 10px 8px 14px; background: #fff; color: #1f2937; border: 1px solid #cbd5e1; border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,.18); font-weight: 600; max-width: calc(100% - 140px); }
#vmap.dark ~ .measure-bar { background: #1f2933; color: #e6ecf5; border-color: #334155; }
#vmap.measuring { cursor: crosshair; }
.measure-label { background: rgba(17,24,39,.88); color: #fff; border: 1px solid rgba(255,255,255,.85); font-weight: 700; font-size: 14px; padding: 3px 7px; border-radius: 6px;
  white-space: nowrap; box-shadow: 0 1px 4px rgba(0,0,0,.35); transform: translate(-50%, -130%); display: inline-block;
  font-variant-numeric: tabular-nums; }
.measure-snapname { background: rgba(15,23,42,.8); color: #fff; font-size: 12px; padding: 2px 6px; border-radius: 5px;
  white-space: nowrap; transform: translate(10px, -140%); display: inline-block; }
/* keep the measuring bar over the drawing, not over the sidebar (landscape) */
@media (min-width: 901px) {
  .view-layout:not(.side-collapsed) .measure-bar { left: calc((100% - 340px) / 2); max-width: calc(100% - 340px - 120px); }
}
.measure-bar .btn-ghost { color: inherit; border-color: currentColor; }
.measure-bar .btn-ghost:disabled { opacity: .35; }

/* Measure area */
.measure-kind { margin: 6px 0; flex-wrap: wrap; }
/* press-and-hold magnifier: the drawing under the finger, magnified, with a crosshair */
#vmap { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.loupe { position: absolute; z-index: 1200; width: 150px; border-radius: 12px; overflow: hidden; pointer-events: none;
  border: 2px solid #111827; box-shadow: 0 8px 24px rgba(0,0,0,.35); background: #fff; }
.loupe canvas { display: block; width: 150px; height: 150px; }
.loupe-label { background: #111827; color: #fff; font-size: 12px; font-weight: 600; text-align: center; padding: 3px 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hide-box { position: absolute; z-index: 1150; border: 2px dashed #ef4444; background: rgba(239, 68, 68, 0.14); pointer-events: none; }
.hide-box.lockbox { border-color: #2563eb; background: rgba(37, 99, 235, 0.14); }
.vl .vl-lock { margin-left: 6px; padding: 2px 4px; border: 0; background: transparent; color: var(--muted, #6b7280); line-height: 0; cursor: pointer; border-radius: 6px; }
.vl .vl-lock.on { color: #2563eb; background: rgba(37, 99, 235, 0.12); }
.vl.locked .vl-name { font-style: italic; }
.hide-box.sitebox { border-color: #ff2a2a; background: rgba(255, 42, 42, 0.14); }
/* a photo says what it shows: chips in the photo modal */
.ph-kinds { display: flex; flex-wrap: wrap; gap: 6px; }
.ph-kind { border: 1px solid var(--line); background: var(--panel); color: var(--ink); border-radius: 999px; padding: 6px 12px; font: inherit; font-size: 13px; cursor: pointer; }
.ph-kind.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
/* Reports > Field documentation */
.doc-list { list-style: none; margin: 0; padding: 0; }
.doc-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.doc-row img { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; background: var(--bg); flex: 0 0 auto; cursor: pointer; }
.doc-text { flex: 1 1 160px; min-width: 0; }
.doc-note { font-weight: 600; word-break: break-word; }
.links-pdf-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.snapbox { position: absolute; z-index: 1150; width: 14px; height: 14px; margin: -7px 0 0 -7px; pointer-events: none;
  border: 2px solid #f97316; box-shadow: 0 0 0 1px #fff, inset 0 0 0 1px #fff; }
.points-toggles { margin: 4px 0 10px; }
.pt-mark { position: absolute; transform: translate(-50%, -50%); pointer-events: none; }
.pt-mark svg { display: block; }
.pt-name { position: absolute; left: 12px; top: -9px; white-space: nowrap; font-size: 12px; font-weight: 700;
  padding: 1px 5px; border-radius: 4px; color: #fff; }
/* control points: a small triangle, black on a white background and white on black */
.pt-mark.cp { color: #000; }
#vmap.dark .pt-mark.cp { color: #fff; }
.pt-mark.cp .pt-name { background: none; color: currentColor; padding: 0; top: -8px; left: 11px;
  text-shadow: 0 0 2px #fff, 0 0 3px #fff, 0 0 4px #fff; }
#vmap.dark .pt-mark.cp .pt-name { text-shadow: 0 0 2px #000, 0 0 3px #000, 0 0 4px #000; }
.pt-mark.my .pt-name { background: rgba(0,0,0,.92); color: #fff; border: 1px solid rgba(255,255,255,.85); }
.pt-row-name { font-weight: 700; text-decoration: underline dotted; cursor: pointer; }
.measure-label.area { transform: translate(-50%, -50%); background: rgba(17,24,39,.88); }
.measure-label.warn { background: #b91c1c; }
#view-side .measure-snap { margin: 8px 0 2px; }

/* EXACT LAYOUT logo in the top bars (transparent PNGs made from Luke's logo) */
.topbar-title.brand-row { flex-direction: row; align-items: center; gap: 12px; }
.brand-logo { height: 40px; width: auto; display: block; }
.brand-sub { font-size: 13px; font-weight: 600; letter-spacing: 0.18em; text-transform: uppercase; color: #93a4b8;
  border-left: 1px solid #334155; padding-left: 12px; }
.brand-mark { height: 26px; width: auto; flex: none; display: block; }
@media (max-width: 600px) { .brand-mark { display: none; } .brand-logo { height: 32px; } }

/* ---- the job sidebar is black (its own colour set; the iPad draws its controls dark too) ---- */
.vside { --panel: #000000; --ink: #f3f4f6; --muted: #9ca3af; --line: #27272a; --accent: #3b82f6;
  background: #000; color: var(--ink); border-color: #27272a; color-scheme: dark; }
.vside .vd { background: #111113; border-color: #2a2a2e; }
.vside .vl { border-bottom-color: #1c1c1f; }
.vside .vtool-card { border-color: #2a2a2e; background: #0b0b0c; }
.vside .hint { background: #111113; border-color: #2a2a2e; }
.vside .alert.warn { background: #2a1d05; color: #fcd34d; border-color: #5c3d0a; }
.vside .vd-align.ok { color: #4ade80; }
.vside .vd-align.warn { color: #fbbf24; }
.vside .vd-swatch { border-color: rgba(255,255,255,.35); }
.vside input[type="checkbox"], .vside input[type="range"] { accent-color: #3b82f6; }

/* questions to the drawing's author (Questions tab) */
.q-badge { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px; border-radius: 9px; background: #f0883e; color: #111; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; }
.q-list { list-style: none; margin: 8px 0 0; padding: 0; }
.q-item { border: 1px solid #333a44; border-radius: 8px; padding: 8px 10px; margin-bottom: 6px; cursor: pointer; }
.q-item.on { border-color: #f0883e; background: rgba(240, 136, 62, .12); }
.q-top { display: flex; align-items: center; gap: 6px; }
.q-top .ml-x { margin-left: auto; }
.q-id { background: #f0883e; color: #111; font-weight: 700; font-size: 12px; border-radius: 4px; padding: 1px 6px; }
.q-subj { margin-top: 3px; font-size: 13px; }
.q-detail { border: 1px solid #f0883e; border-radius: 8px; padding: 8px 10px; margin-top: 8px; }
.q-img { width: 100%; height: auto; margin: 6px 0; border-radius: 4px; background: #fff; }
.q-found { margin: 4px 0; padding-left: 18px; font-size: 12px; }
.q-ask { color: #f0883e; font-weight: 600; margin: 6px 0; }
.q-mark { position: absolute; transform: translate(8px, -22px); white-space: nowrap; }
.q-mark span { background: rgba(17, 17, 17, .75); color: #f0883e; font: 700 11px/1.2 system-ui, sans-serif; padding: 1px 4px; border-radius: 3px; }
.q-mark.on span { background: #f0883e; color: #111; }

/* blockout details: the snippet card and the full-screen picture */
.det-modal { position: fixed; inset: 0; z-index: 1500; background: rgba(0, 0, 0, .55); display: flex; align-items: center; justify-content: center; padding: 16px; }
.det-modal.hidden, .zoomer.hidden { display: none; }
.det-card { background: #161b22; border: 1px solid #22d3ee; border-radius: 12px; padding: 12px 14px; width: min(760px, 100%); max-height: 100%; overflow: auto; }
.det-head { display: flex; align-items: center; gap: 8px; }
.det-title { font-weight: 700; color: #22d3ee; }
.det-head .ml-x { margin-left: auto; }
.det-img { display: block; width: 100%; height: auto; margin: 8px 0 6px; border-radius: 6px; background: #fff; cursor: zoom-in; }
.q-img { cursor: zoom-in; }
.zoomer { position: fixed; inset: 0; z-index: 1600; background: #0b0e12; }
.zoomer-map { position: absolute; inset: 0; background: #0b0e12; }
.zoomer-title { position: absolute; left: 12px; bottom: 14px; z-index: 1000; color: #e6edf3; font-weight: 700; background: rgba(0, 0, 0, .55); padding: 4px 8px; border-radius: 6px; pointer-events: none; }
.zoomer-close { position: absolute; right: 12px; top: 10px; z-index: 1000; width: 44px; height: 44px; border-radius: 22px; border: 1px solid #444; background: rgba(0, 0, 0, .65); color: #fff; font-size: 26px; line-height: 40px; }

/* Reports page: cards ------------------------------------------------------ */
#pane-reports { max-width: 900px; margin: 0 auto; }
.rcard { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 16px 18px; margin: 14px 0;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04); }
.rcard-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.rcard-head h2 { font-size: 18px; margin: 0; }
.rcard-fold { display: flex; align-items: center; gap: 8px; border: 0; background: transparent; padding: 0; font: inherit; color: var(--ink); cursor: pointer; text-align: left; }
#recent-card.folded #recent-reports, #recent-card.folded #btn-reports-more { display: none; }
#recent-card.folded .rcard-head { margin-bottom: 0; }
.rgrid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
@media (max-width: 600px) { .rgrid2 { grid-template-columns: 1fr; } }
.rcard .offline-box { background: #f9fafb; }
.rcard .check { margin-top: 10px; }
.rcard-quiet { background: transparent; box-shadow: none; }
.rcard-quiet summary { cursor: pointer; font-weight: 600; color: var(--muted); padding: 2px 0; }
.rcard-quiet .tools { margin-top: 12px; }
.empty { padding: 8px 2px; }

.plan-list { list-style: none; margin: 12px 0 0; padding: 0; }
.plan-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px;
  margin-bottom: 8px; background: #fbfbfc; }
.pi-main { flex: 1; min-width: 0; }
.pi-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pi-actions, .ri-actions { display: flex; gap: 8px; align-items: center; }

.report-list .report-item { align-items: flex-start; background: #fbfbfc; }
.report-item .ri-top { display: flex; align-items: center; gap: 8px; min-width: 0; }
.report-item .ri-date { font-size: 14px; margin-top: 2px; }
.report-item .ri-sub { margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.report-item .ri-side { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.type-badge { flex: 0 0 auto; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em;
  padding: 2px 8px; border-radius: 6px; }
.type-badge.pour { background: #dbeafe; color: #1e40af; }
.type-badge.pile { background: #ede9fe; color: #5b21b6; }
.btn.danger { color: var(--danger); border-color: #fecaca; }

/* Reports page: one job, one kind of report, one tap ---------------------- */
.job-field { margin-bottom: 12px; }
.rtype { margin: 0 0 14px; }
.rtype .seg { font-size: 16px; }
.step-hint { font-size: 14px; color: var(--muted); margin: 2px 0 10px; }
.step-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.step-row .step-hint { margin: 2px 0; }
.step-row + .floor-list { margin-top: 10px; }
.fine { margin-top: 10px; }
.floor-list { display: flex; flex-direction: column; gap: 8px; }
.list-group { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin: 8px 2px 0; }
.list-group:first-child { margin-top: 0; }
.list-row { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 12px; background: #fbfbfc;
  padding: 0 10px 0 0; min-height: 60px; }
.list-row.last { border-color: #93c5fd; background: #eff6ff; }
.lr-open { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; border: 0; background: transparent;
  font: inherit; color: var(--ink); text-align: left; padding: 10px 12px; min-height: 60px; justify-content: center; cursor: pointer; }
.lr-open:active { background: rgba(29, 78, 216, 0.06); border-radius: 12px; }
.lr-name { font-size: 17px; font-weight: 600; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lr-name::after { content: " \203A"; color: var(--accent); font-weight: 700; }
.lr-sub { font-size: 13px; color: var(--muted); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.off-ctl { flex: 0 0 auto; display: flex; align-items: center; }
.off-badge { font-size: 13px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.off-badge.ok { color: var(--ok); }
.list-more { margin: -2px 0 0 14px; }
.list-more summary { font-size: 13px; color: var(--accent); cursor: pointer; padding: 4px 2px; }
.list-more .list-row { margin-top: 6px; min-height: 52px; }
.list-more .lr-open { min-height: 52px; }
.list-more .lr-name { font-size: 15px; }
.send-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: #fffbeb;
  border: 1px solid #fde68a; color: #92400e; border-radius: 12px; padding: 8px 12px; margin: 0 0 10px; font-size: 14px; }
.rcard-quiet .sub-h { font-size: 13px; font-weight: 700; color: var(--muted); margin: 14px 0 6px; }
.pack-list { display: flex; flex-direction: column; gap: 6px; }
.pack-row { display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; background: var(--panel); }
.pk-main { flex: 1; min-width: 0; }
.pk-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Report form ------------------------------------------------------------------ */
.date-row { display: flex; gap: 8px; align-items: stretch; }
.date-row .input { flex: 1; min-width: 0; }
.quick-date { flex: 0 0 auto; min-height: 50px; }
.count-pill { display: inline-block; font-size: 13px; font-weight: 700; color: var(--accent); background: #dbeafe; border-radius: 999px;
  padding: 1px 8px; margin-left: 4px; vertical-align: 1px; }
.result-next { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.result-next .btn-big { margin: 6px 0; }
.area-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 4px; }
.area-chip { border: 1px solid var(--line); background: var(--panel); color: var(--ink); font: inherit; font-size: 15px; font-weight: 600;
  border-radius: 999px; padding: 8px 16px; min-height: 40px; cursor: pointer; }
.area-chip[aria-checked="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.list-row.away { opacity: 0.5; }


/* Dark mode: the moon in a job's gallery turns it on for the whole app (kept on this iPad) ------------------- */
.theme-toggle { width: 44px; min-width: 44px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
.theme-toggle[aria-pressed="true"] { background: #fef3c7; color: #1f2937; border-color: #fcd34d; }
:root[data-theme="dark"] { color-scheme: dark;
  --bg: #0b0f17; --panel: #141a24; --ink: #e6ebf2; --muted: #98a2b3; --line: #2b3444;
  --accent: #5b9dff; --accent-ink: #0b1220; --danger: #f87171; --ok: #4ade80; --warn: #fbbf24; }
:root[data-theme="dark"] .req-card, :root[data-theme="dark"] .req-block, :root[data-theme="dark"] .gallery-card,
:root[data-theme="dark"] .req-input, :root[data-theme="dark"] .pdf-item, :root[data-theme="dark"] .view-item,
:root[data-theme="dark"] .report-item, :root[data-theme="dark"] .list-row, :root[data-theme="dark"] .rcard,
:root[data-theme="dark"] .pair-box { background: var(--panel); color: var(--ink); border-color: var(--line); }
:root[data-theme="dark"] .report-list .report-item, :root[data-theme="dark"] .list-row.last,
:root[data-theme="dark"] .rcard .offline-box, :root[data-theme="dark"] .hint, :root[data-theme="dark"] .send-bar { background: #10151e; border-color: var(--line); color: var(--ink); }
:root[data-theme="dark"] .gallery-thumb { background: #0d121a; }
:root[data-theme="dark"] .gallery-thumb img { background: #fff; }                    /* the picture keeps its white paper */
:root[data-theme="dark"] .req-step { background: #243044; color: #9fb0c8; }
:root[data-theme="dark"] .req-step.past { background: #1e3a8a; color: #dbeafe; }
:root[data-theme="dark"] .req-step.now { color: #fff; }
:root[data-theme="dark"] .tabs { background: var(--panel); border-bottom-color: var(--line); }
:root[data-theme="dark"] .alert { background: #3a1417; border-color: #7f1d1d; color: #fecaca; }
:root[data-theme="dark"] .alert.warn { background: #2a1d05; color: #fcd34d; border-color: #5c3d0a; }
:root[data-theme="dark"] .btn-secondary { background: #1b2331; color: var(--ink); border-color: var(--line); }
:root[data-theme="dark"] .btn-ghost { color: var(--ink); border-color: var(--line); }
:root[data-theme="dark"] .topbar .btn-ghost { color: #fff; border-color: rgba(255,255,255,0.35); }
:root[data-theme="dark"] select, :root[data-theme="dark"] input, :root[data-theme="dark"] textarea { background: #10151e; color: var(--ink); border-color: var(--line); }


/* Tools: every tool is a picture button that starts it (no Start button) ------------------------------------ */
.vside .tool-tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 4px 0; }
.vside .tool-tiles.one { grid-template-columns: 1fr; }
.vside .tool-tile { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 10px 6px 8px;
  min-height: 84px; border: 1px solid #2a2a2e; border-radius: 12px; background: #111113; color: #cbd5e1; font: inherit; cursor: pointer; }
.vside .tool-tile svg { width: 64px; height: 44px; flex: 0 0 auto; }
.vside .tool-tile-name { font-size: 13px; font-weight: 700; text-align: center; line-height: 1.15; }
.vside .tool-tile.wide { flex-direction: row; justify-content: flex-start; gap: 14px; padding: 8px 16px; min-height: 64px; }
.vside .tool-tile.wide .tool-tile-name { font-size: 16px; text-align: left; }
.vside .tool-tile:active { background: #1c2230; }
.vside .tool-tile.on { background: #1d4ed8; border-color: #60a5fa; color: #fff; box-shadow: 0 0 0 2px rgba(96,165,250,.45); }


/* ---- Alignment: the PDF page and the drawing side by side, tap matching points ---- */
.align-jobs .pdf-job { margin-bottom: 14px; }
.align-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 8px 12px; margin: 8px 0; }
.align-form label { display: flex; flex-direction: column; gap: 3px; font-size: 13px; color: var(--muted, #6b7280); }
.align-list { list-style: none; margin: 6px 0 0; padding: 0; }
.align-list li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 0; border-top: 1px solid rgba(128,128,128,0.25); }
.align-hint { padding: 6px 12px; font-size: 14px; background: rgba(37,99,235,0.12); }
.align-split { flex: 1; min-height: 0; display: flex; gap: 4px; }
.align-pane { flex: 1 1 0; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.align-label { padding: 4px 8px; font-size: 13px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.align-label .select { max-width: 90px; padding: 2px 4px; }
.alignmap { flex: 1; min-height: 0; background: #6b7280; touch-action: none; }
#align-dwgmap { background: #ffffff; }
.align-pairs { max-height: 28vh; overflow: auto; padding: 6px 10px calc(8px + var(--safe-bottom, 0px)); font-size: 13px; border-top: 1px solid rgba(128,128,128,0.35); }
.align-pairs .al-row { display: flex; gap: 10px; align-items: center; padding: 3px 0; }
.align-pairs .al-sum { font-weight: 600; margin-bottom: 4px; }
.align-pairs .al-bad { color: #b45309; }
.al-mark { background: #2563eb; color: #fff; border: 2px solid #fff; border-radius: 50%; width: 24px; height: 24px; line-height: 20px; text-align: center; font-size: 12px; font-weight: 700; box-shadow: 0 0 0 1px rgba(0,0,0,0.5); }
.al-mark.pend { background: #d97706; }
@media (orientation: portrait) { .align-split { flex-direction: column; } }

.align-scalebar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 6px 12px; border-bottom: 1px solid rgba(128,128,128,0.3); }
.al-scale-status { font-size: 13px; font-weight: 600; }
.al-dist { width: 190px; padding: 6px 8px; }
.al-mark.sc { background: #059669; border-radius: 4px; width: 28px; }

.al-meas-mode[aria-pressed="true"] { background: #2563eb; color: #fff; border-color: #2563eb; }
/* the marker icon is 0 x 0, so the label sizes itself (max-content); without that its box collapsed to the padding
   and the white text ran outside it, unseen on a white drawing */
.al-meas-label { display: inline-block; width: max-content; background: #1d4ed8; color: #fff; font-size: 14px; font-weight: 700;
  line-height: 1.25; padding: 3px 8px; border-radius: 6px; white-space: nowrap; box-shadow: 0 0 0 2px rgba(255,255,255,0.9);
  transform: translate(10px, -50%); pointer-events: none; }
.al-meas-label.left { transform: translate(calc(-100% - 10px), -50%); }


/* ---- Photos pinned to the drawing ---- */
.photo-list { list-style: none; margin: 8px 0 0; padding: 0; }
.photo-row { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-top: 1px solid rgba(128,128,128,0.25); cursor: pointer; }
.photo-row img { width: 64px; height: 48px; object-fit: cover; border-radius: 6px; background: #374151; flex: 0 0 auto; }
.photo-row .ph-note { font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.photo-row .ph-meta { font-size: 12px; color: var(--muted, #6b7280); }
.photo-row .ph-wait { color: #b45309; }
.ph-pin { width: 30px; height: 30px; border-radius: 50%; background: #2563eb; border: 3px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center; color: #fff; transform: translate(-15px, -15px); }
.ph-pin.wait { background: #d97706; }
.ph-pin svg { width: 16px; height: 16px; }
.photo-card { width: min(94vw, 760px); max-height: 92vh; overflow: auto; display: flex; flex-direction: column; gap: 8px; }
.photo-img { width: 100%; max-height: 56vh; object-fit: contain; background: #0b0e12; border-radius: 8px; }
.photo-card textarea { width: 100%; resize: vertical; }
.photo-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* seven tabs across the top of the drawing screen: scroll sideways on a narrow screen rather than cut one off */
@media (max-width: 600px) { .vtab { padding-left: 11px; padding-right: 11px; font-size: 15px; } }

/* Measure: count marks (numbered), the list's Depth / Cut out buttons */
.count-mark { user-select: none; }
.ml-acts { display: inline-flex; gap: 4px; margin-left: auto; margin-right: 6px; }
.ml-act { padding: 2px 8px; min-height: 0; }

/* Points: where the point goes (circle centre / line middle / line end) */
.points-pick { display: grid; gap: 4px; margin: 6px 0; }
.points-pick label { display: flex; align-items: center; gap: 6px; }

/* markups on the PDF screen: the tool buttons carry a little picture */
.tool-ico { flex: none; vertical-align: -3px; }
.pdf-meas-mode, .pk-tool { display: inline-flex; align-items: center; gap: 6px; }
.pk-bar { gap: 8px 14px; }
.pk-tools, .pk-opts, .pk-acts { display: inline-flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.pk-tool[aria-pressed="true"] { background: #2563eb; color: #fff; border-color: #2563eb; }
.pk-swatches { display: inline-flex; gap: 6px; }
.pk-swatch { width: 26px; height: 26px; border-radius: 50%; border: 2px solid rgba(255,255,255,0.8); box-shadow: 0 0 0 1px rgba(0,0,0,0.35); padding: 0; cursor: pointer; }
.pk-swatch[aria-pressed="true"] { box-shadow: 0 0 0 3px #2563eb; }
.pk-lab { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; }
.pk-text-wrap { background: transparent; border: 0; }
.pk-text { box-sizing: border-box; overflow: visible; padding: 2px 3px; line-height: 1.2; font-family: Helvetica, Arial, sans-serif; white-space: pre-wrap; word-break: break-word; pointer-events: none; }

/* measuring / marking up on a PDF sheet: a crosshair over the sheet, also while it is being dragged */
#pdfmap.crosshair, #pdfmap.crosshair .leaflet-grab, #pdfmap.crosshair .leaflet-dragging .leaflet-grab,
#pdfmap.crosshair .leaflet-interactive, #pdfmap.crosshair.leaflet-grab, #pdfmap.crosshair.leaflet-dragging { cursor: crosshair !important; }

/* the markups list: a panel over the right of the PDF screen */
.pdf-screen { position: relative; }
.pk-name { min-height: 34px; font-size: 14px; padding: 4px 8px; width: 130px; }
.pk-list { position: absolute; top: 0; right: 0; bottom: 0; width: min(380px, 94vw); z-index: 1200; display: flex; flex-direction: column;
  background: var(--panel, #fff); color: var(--ink, #111827); border-left: 1px solid var(--line, #d6dce4); box-shadow: -6px 0 18px rgba(0,0,0,0.25); }
.pk-list.hidden { display: none; }
.pk-list-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border-bottom: 1px solid var(--line, #d6dce4); font-size: 17px; }
.pk-list-filters { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 8px 12px; border-bottom: 1px solid var(--line, #d6dce4); }
.pk-list-filters .select, .pk-list-filters .input { min-height: 38px; font-size: 14px; padding: 6px 8px; }
.pk-list-filters .input { grid-column: 1 / -1; }
.pk-sum { padding: 6px 12px; font-size: 13px; color: var(--muted, #6b7280); }
.pk-rows { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; -webkit-overflow-scrolling: touch; }
.pk-row { padding: 8px 12px; border-bottom: 1px solid var(--line, #e5e7eb); }
.pk-row-head { display: flex; align-items: center; gap: 8px; }
.pk-pg { color: var(--muted, #6b7280); font-size: 13px; }
.pk-where { margin-left: auto; font-size: 11px; color: var(--muted, #6b7280); text-transform: uppercase; letter-spacing: .03em; }
.pk-row-text { margin: 4px 0 2px; font-size: 14px; white-space: pre-wrap; word-break: break-word; max-height: 4.2em; overflow: hidden; }
.pk-row-meta { font-size: 12px; color: var(--muted, #6b7280); }
.pk-row-acts { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 6px; }
.pk-status { min-height: 34px; font-size: 13px; padding: 2px 8px; width: auto; }
.pk-chip { font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: #dbeafe; color: #1e3a8a; }
.pk-empty { padding: 16px 12px; color: var(--muted, #6b7280); }
.pk-list-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 8px 12px calc(8px + var(--safe-bottom, 0px)); border-top: 1px solid var(--line, #d6dce4); }
/* the markup bar stays compact: smaller drop-downs, and on a narrow screen the tool buttons are pictures only */
.pk-bar .select { min-height: 38px; font-size: 14px; padding: 4px 8px; width: auto; }
.pk-bar .pk-tool { padding: 6px 10px; min-height: 40px; }
@media (max-width: 700px) { .pk-bar .pk-tool span { display: none; } .pk-bar .pk-tool { padding: 6px 10px; } }
.pk-row-acts .pk-status { min-width: 9.5em; padding-right: 26px; }

/* the takeoff summary: totals table, then every measurement */
#view-layout { position: relative; }
.tk-panel .pk-list-head { gap: 8px; }
.tk-panel .tk-scope { min-height: 34px; font-size: 13px; padding: 2px 8px; width: auto; margin-left: auto; }
.tk-totals { padding: 8px 12px; border-bottom: 1px solid var(--line, #d6dce4); max-height: 40%; overflow-y: auto; }
.tk-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.tk-table th { text-align: left; font-size: 12px; color: var(--muted, #6b7280); font-weight: 600; padding: 2px 4px; }
.tk-table td { padding: 5px 4px; border-top: 1px solid var(--line, #e5e7eb); vertical-align: top; }
.tk-table .tk-num { text-align: right; font-weight: 700; white-space: nowrap; }
.tk-table .muted { color: var(--muted, #6b7280); }
#btn-measure-takeoff { margin-top: 6px; }
.tk-panel .tk-scope { padding-right: 26px; }

/* markups on the drawing map: the tool card, and the camera mark of a markup with a photo */
.mm-tools, .mm-opts { margin: 6px 0; }
.mm-opts .select { min-height: 34px; font-size: 13px; padding: 2px 8px; width: auto; }
#tool-markup .pk-tool { padding: 6px 10px; min-height: 38px; }
#tool-markup .pk-tool span { display: none; }
#tool-markup .pk-tool[aria-pressed="true"] { background: #2563eb; color: #fff; border-color: #2563eb; }
.pk-cam { background: transparent; border: 0; }
.pk-cam-dot { display: flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 50%;
  background: #111827; color: #fff; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.4); box-sizing: border-box; }

/* Tools > Cloud the changes */
.cmp-picks { display: grid; gap: 6px; margin: 6px 0; }
.cmp-picks .select { min-height: 36px; font-size: 14px; padding: 4px 8px; }

/* Measure: the more tools sit under the measuring kinds, the same size of tile */

/* Tools > Layout points */
.lp-form { display: grid; gap: 6px; }
.lp-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 14px; }
.lp-row.hidden { display: none; }
.lp-in { min-height: 36px; font-size: 15px; padding: 4px 8px; width: 7.5em; }
.lp-names .lp-in { width: 3.6em; padding: 4px 6px; }
#lp-prefix { width: 4.2em; }
.lp-row.lp-check { flex-wrap: nowrap; align-items: flex-start; }
.lp-row.lp-check input { flex: none; margin-top: 3px; }
.measure-label.lp-preview { background: #f59e0b; color: #111827; }
.lp-export { margin-top: 6px; padding-top: 8px; border-top: 1px solid var(--line, #2a2a2e); }
.lp-in.lp-wide { width: auto; max-width: 100%; }

/* Sketch > Extend: the box on the map */
.lp-float { position: absolute; left: 56px; top: 12px; z-index: 1100; width: min(300px, calc(100% - 24px)); display: grid; gap: 8px;
  padding: 12px; border-radius: 12px; background: var(--panel, #fff); color: var(--ink, #111827); border: 1px solid var(--line, #d6dce4);
  box-shadow: 0 6px 18px rgba(0,0,0,0.3); }
.lp-float.hidden { display: none; }
.lp-float-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 16px; }
#btn-lp-ext-orient.on { background: #2563eb; color: #fff; border-color: #2563eb; }
#btn-lp-ext-go:disabled { opacity: .5; }

/* the trash can on the drawing map (under the zoom buttons) */
.map-trash { position: absolute; left: 10px; top: 92px; z-index: 1000; width: 44px; height: 44px; border-radius: 10px; display: flex;
  align-items: center; justify-content: center; background: #fff; color: #b91c1c; border: 2px solid rgba(0,0,0,0.25); box-shadow: 0 1px 5px rgba(0,0,0,0.35); cursor: pointer; }
.map-trash[aria-pressed="true"], .map-trash.on { background: #dc2626; color: #fff; border-color: #dc2626; }

/* a picked text box / callout: corner handles and the little bar over it */
.mk-h { background: #fff; border: 2px solid #2563eb; border-radius: 4px; box-sizing: border-box; box-shadow: 0 1px 4px rgba(0,0,0,.35); }
.leaflet-container .mk-selbar.leaflet-control { position: absolute; float: none; clear: none; margin: 0; z-index: 1001; display: flex; gap: 6px;
  padding: 6px; background: #111827; border-radius: 10px; box-shadow: 0 2px 10px rgba(0,0,0,.4); white-space: nowrap; }
.leaflet-container .mk-selbar.hidden { display: none; }
.mk-selbar .btn { color: #fff; border-color: rgba(255,255,255,.35); min-height: 40px; font-size: 15px; }

/* Links > Hyperlinks: a coloured box on the drawing -> a PDF */
.hl-showlab { display: inline-flex; align-items: center; gap: 6px; }
.hl-row { flex-wrap: wrap; align-items: center; row-gap: 6px; }
.hl-name { display: flex; align-items: center; gap: 8px; flex: 1 1 100%; min-width: 0; overflow-wrap: anywhere; font-weight: 600; }
.hl-row .ml-acts { margin-left: 0; flex-wrap: wrap; }
.hl-dot { width: 12px; height: 12px; border-radius: 3px; flex: none; }
.hl-card { display: flex; flex-direction: column; gap: 10px; color: #e6ecf5; }
.hl-q { width: 100%; box-sizing: border-box; }
.hl-pdfs { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; max-height: 46vh; overflow-y: auto; }
.hl-pdf { width: 100%; text-align: left; font: inherit; font-weight: 600; padding: 12px; border-radius: 8px; border: 1px solid #334155;
  background: #0b0f14; color: #e6ecf5; cursor: pointer; }
.hl-pdf[aria-pressed="true"] { border-color: #3b82f6; background: #172554; }
.hl-opts { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; }
.hl-acts { display: flex; justify-content: flex-end; gap: 8px; }

.hl-auto { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding-top: 6px; border-top: 1px solid var(--line, #27272a); }
.hl-auto-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

/* overlay check (PDF screen): boxes round the spots, then the report form */
.oc-panel .oc-form { display: flex; flex-direction: column; gap: 10px; padding: 10px 12px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.oc-lab { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; }
.oc-lab .input, .oc-lab .select { min-height: 38px; font-size: 15px; font-weight: 400; }
.oc-lab textarea.input { min-height: 110px; resize: vertical; }
.oc-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.oc-dot.red { background: #dc2626; }
.oc-dot.blue { background: #2563eb; }
.oc-acts { display: flex; gap: 8px; flex-wrap: wrap; }
.oc-num span { position: absolute; transform: translate(-50%, -50%); width: 26px; height: 26px; border-radius: 50%; display: flex;
  align-items: center; justify-content: center; background: #111827; color: #f59e0b; border: 2px solid #f59e0b; font: 700 13px system-ui, sans-serif; }
.type-badge.overlay { background: #fef3c7; color: #92400e; }
