:root {
  --bg: #f3f4f6; --panel: #ffffff; --ink: #1c2024; --muted: #5b6470; --line: #d6d9de;
  --accent: #0d8080; --accent-ink: #ffffff; --warn: #b45309; --err: #b42318; --stage: #202124;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font: 14px/1.4 "Segoe UI", system-ui, sans-serif; background: var(--bg); color: var(--ink);
       display: flex; flex-direction: column; }
button, .btn, select, input, textarea { font: inherit; }
button, .btn { background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 5px 10px;
               cursor: pointer; color: var(--ink); white-space: nowrap; display: inline-block; }
button:hover, .btn:hover { border-color: var(--accent); }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.small { padding: 2px 8px; }
button:disabled { opacity: .5; cursor: default; }
input, select, textarea { border: 1px solid var(--line); border-radius: 6px; padding: 4px 6px; background: #fff; }
.hidden { display: none !important; }
body:not(.admin) .adminonly { display: none !important; }
header { display: flex; align-items: center; gap: 8px; padding: 6px 10px; background: var(--panel);
         border-bottom: 1px solid var(--line); }
header nav button { border: none; border-bottom: 3px solid transparent; border-radius: 0; background: none; padding: 6px 12px; }
header nav button.active { border-bottom-color: var(--accent); font-weight: 600; }
.spacer { flex: 1; }
.badge { color: var(--warn); font-weight: 600; }
.tab { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.toolbar { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 10px; background: var(--panel); border-bottom: 1px solid var(--line); align-items: center; }
.toolbar .group { display: inline-flex; gap: 6px; align-items: center; padding: 0 6px; border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
.chk { display: inline-flex; gap: 4px; align-items: center; }
.work { flex: 1; display: flex; min-height: 0; }
#stage { flex: 1; position: relative; background: var(--stage); min-width: 0; }
#cv { position: absolute; inset: 0; width: 100%; height: 100%; cursor: crosshair; touch-action: none; }
#stageMsg { position: absolute; left: 12px; top: 10px; color: #fff; font-weight: 600; pointer-events: none;
            text-shadow: 0 1px 3px #000; }
#side { width: 380px; overflow: auto; padding: 10px; background: var(--panel); border-left: 1px solid var(--line); }
.row { display: flex; gap: 6px; align-items: center; margin: 4px 0; }
.row label { width: 110px; flex: none; color: var(--muted); }
.row select, .row input { flex: 1; min-width: 0; }
.btnrow { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; align-items: center; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.accent { color: var(--accent); }
.warn { color: var(--warn); }
.err { color: var(--err); }
.lbl { display: block; margin-top: 8px; color: var(--muted); }
textarea { width: 100%; }
#results { width: 100%; border-collapse: collapse; background: #111; color: #eee; margin-top: 6px; font-size: 13px; }
#results th { background: #2a2d31; color: #ccc; font-weight: 500; padding: 3px 6px; text-align: right; }
#results th:first-child, #results td:first-child { text-align: left; }
#results td { padding: 2px 6px; text-align: right; }
.cam { margin-top: 10px; border: 1px solid var(--line); border-radius: 8px; padding: 6px; }
.camhead { display: flex; justify-content: space-between; gap: 6px; align-items: center; margin-bottom: 4px; }
.camhead select { max-width: 220px; }
.camrow { display: flex; gap: 6px; }
#video { width: 240px; height: 135px; background: #111; border-radius: 4px; cursor: pointer; object-fit: contain; }
.camside { display: flex; flex-direction: column; gap: 6px; }
footer { padding: 4px 10px; background: var(--panel); border-top: 1px solid var(--line); color: var(--muted);
         white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.overlay { position: fixed; inset: 0; background: rgba(20, 24, 28, .55); display: flex; align-items: center;
           justify-content: center; z-index: 10; }
.card { background: var(--panel); border-radius: 10px; padding: 18px 20px; width: 340px; max-width: calc(100vw - 32px);
        max-height: calc(100vh - 32px); overflow: auto; box-shadow: 0 10px 40px rgba(0,0,0,.3); }
.card.wide { width: 760px; }
.card h1 { margin: 0 0 6px; font-size: 22px; }
.card input[type=password], .card input[type=text] { width: 100%; margin: 6px 0; }
.card table { width: 100%; border-collapse: collapse; }
.card td, .card th { border-bottom: 1px solid var(--line); padding: 4px 6px; text-align: left; }
.card tr.sel td { background: #e6f2f2; }
.builder { flex: 1; display: flex; gap: 16px; padding: 12px; min-height: 0; overflow: auto; }
.plist { width: 420px; flex: none; }
.pform { flex: 1; min-width: 0; }
.builder table { width: 100%; border-collapse: collapse; background: var(--panel); }
.builder th, .builder td { border-bottom: 1px solid var(--line); padding: 4px 6px; text-align: left; }
#partsTable tbody tr { cursor: pointer; }
#partsTable tr.sel td { background: #e6f2f2; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.grid3 label { display: flex; flex-direction: column; color: var(--muted); gap: 2px; }
#weldsTable td input[type=text] { width: 100%; }
.handle { cursor: grab; color: var(--muted); user-select: none; }
#weldsTable tr.dragging { opacity: .5; }
.calib { padding: 16px 20px; max-width: 760px; }
.calib .row label { width: 160px; }
@media (max-width: 900px) {
  .work { flex-direction: column; }
  #side { width: auto; border-left: none; border-top: 1px solid var(--line); max-height: 50vh; }
  #stage { min-height: 50vh; }
  .builder { flex-direction: column; }
  .plist { width: auto; }
  .grid3 { grid-template-columns: 1fr; }
}
#results tr.sel td { background: #1f3b3b; }
#verdict { margin-top: 6px; font-weight: 600; }

.tech { color: var(--accent, #0d8080); font-weight: 600; margin-right: 10px; }
#loginUser { width: 100%; margin-bottom: 8px; padding: 8px; }
.ulist { width: 100%; border-collapse: collapse; margin-bottom: 8px; }
.ulist th, .ulist td { text-align: left; padding: 3px 6px; border-bottom: 1px solid #ddd; }

/* ---- desktop look: the web page matches the Weld Measure desktop app (Windows look) ---- */
:root { --bg: #f0f0f0; --panel: #f0f0f0; --line: #adadad; --ink: #000; --muted: #333; }
body { font: 13px/1.35 "Segoe UI", system-ui, sans-serif; background: var(--bg); }
button, .btn { background: #fdfdfd; border: 1px solid #adadad; border-radius: 2px; padding: 3px 9px; }
button:hover, .btn:hover { background: #e5f1fb; border-color: #0078d7; }
button.primary { background: #fdfdfd; color: #000; border-color: #adadad; }
button.primary:hover { background: #e5f1fb; border-color: #0078d7; }
#drawBtn.primary, #annBtn.primary, #guidedBtn.primary { background: #cce4f7; border-color: #005499; }
input, select, textarea { border-radius: 0; border-color: #7a7a7a; background: #fff; }
#menubar { display: flex; align-items: center; background: #fff; border-bottom: 1px solid #e5e5e5; padding: 0 2px; }
#menubar .menu { position: relative; }
#menubar .mtop { border: none; background: none; border-radius: 0; padding: 3px 8px; }
#menubar .menu:hover .mtop, #menubar .menu.open .mtop { background: #cce8ff; }
#menubar .mdrop { display: none; position: absolute; left: 0; top: 100%; z-index: 20; min-width: 240px; background: #f2f2f2;
                  border: 1px solid #ccc; box-shadow: 2px 2px 4px rgba(0,0,0,.25); padding: 2px 0; }
#menubar .menu.open .mdrop { display: block; }
#menubar .mdrop a { display: flex; justify-content: space-between; gap: 24px; padding: 4px 24px 4px 28px; cursor: default;
                    color: #000; white-space: nowrap; }
#menubar .mdrop a:hover { background: #91c9f7; }
#menubar .mdrop a span { color: #555; }
#menubar .mdrop a.checked::before { content: "✓"; position: absolute; left: 10px; }
#menubar .mdrop hr { border: none; border-top: 1px solid #ccc; margin: 3px 2px; }
body.admin .lockedonly { display: none !important; }
header { background: var(--bg); border-bottom: none; padding: 2px 4px 0; }
header nav { display: flex; border-bottom: 1px solid #adadad; flex: 1; }
header nav button { border: 1px solid transparent; border-bottom: none; border-radius: 0; padding: 2px 8px; margin-bottom: -1px; }
header nav button.active { background: #fff; border-color: #adadad; font-weight: 400; border-bottom: 1px solid #fff; }
.toolbar { background: var(--bg); border-bottom: none; padding: 4px; gap: 6px; }
.toolbar .group { border: none; padding: 0; }
.tech { color: #0d8080; font-weight: 400; margin-right: 40px; }
#side { width: 48%; min-width: 420px; background: var(--bg); border-left: none; padding: 8px 6px 8px 12px; }
.row label { width: 92px; color: #000; }
#partInfo, #calInfo { color: #555; }
.btnrow { gap: 4px; }
#calInfo { border-top: 1px solid #ccc; border-bottom: 1px solid #ccc; padding: 6px 0; font-size: 13px; }
#results { background: #111; border: 1px solid #828790; min-height: 320px; margin-top: 8px; display: block;
           overflow: auto; }
#results thead, #results tbody { display: table; width: 100%; table-layout: fixed; }
#results th { background: #fff; color: #000; font-weight: 400; text-align: center; padding: 4px 6px;
              border-right: 1px solid #e5e5e5; border-bottom: 1px solid #e5e5e5; }
#results th:first-child { text-align: center; }
#results th:first-child, #results td:first-child { width: 34%; }
.lbl { color: #000; margin-top: 12px; }
.cam { border: 1px solid #dcdcdc; border-radius: 0; padding: 4px 6px 6px; position: relative; margin-top: 12px; }
.cam .legend { position: absolute; top: -9px; left: 6px; background: var(--bg); padding: 0 3px; }
.camhead { margin-top: 6px; }
#video { width: 320px; height: 180px; border-radius: 0; }
footer { background: var(--bg); border-top: 1px solid #adadad; color: #000; box-shadow: inset 0 1px 0 #fff; }
@media (max-width: 900px) { #side { width: auto; min-width: 0; } }
.camhead select { display: none; }   /* cameras are picked from the Camera menu, like the desktop app */
#crackRow { margin-top: 6px; font-weight: 600; }  /* Crack? Yes / No under the Measure box */
#crackRow label { font-weight: 400; margin-left: 10px; }
/* Admin window: one tab per section */
.atabs { display: flex; gap: 0; border-bottom: 1px solid #adadad; margin: 4px 0 8px; }
.atabs button { border: 1px solid transparent; border-bottom: none; border-radius: 0; background: none; padding: 4px 12px; margin-bottom: -1px; }
.atabs button.active { background: #fff; border-color: #adadad; border-bottom: 1px solid #fff; font-weight: 600; }
.atab { min-height: 260px; }
