/* Signage Module — styles */
:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --ink: #1c2430;
  --muted: #6b7686;
  --line: #e2e6ec;
  --accent: #2f6fed;
  --accent-ink: #ffffff;
  --danger: #d64545;
  --radius: 10px;
  font-size: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg); color: var(--ink);
  overflow: hidden;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.spacer { flex: 1; }
.pad-h { padding: 0 12px; }

/* ---------- buttons ---------- */
.btn {
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  padding: 7px 14px; border-radius: 8px; cursor: pointer; font-size: 13px;
}
.btn:hover { border-color: #c6cdd8; background: #fafbfc; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: #245cd0; border-color: #245cd0; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: #eef1f5; border-color: transparent; }
.btn-lg { padding: 12px 22px; font-size: 15px; border-radius: 10px; }
.btn-sm { padding: 4px 9px; font-size: 12px; border-radius: 6px; }
.btn-block { display: block; width: calc(100% - 24px); margin: 12px; }

/* ---------- screens ---------- */
.screen { height: 100vh; }

/* home */
.home-wrap {
  max-width: 560px; margin: 0 auto; padding-top: 12vh; text-align: center;
}
.logo-dot { width: 42px; height: 42px; border-radius: 12px; background: var(--accent); margin: 0 auto 14px; }
.home-brand h1 { margin: 0 0 8px; font-size: 26px; }
.home-actions { display: flex; gap: 12px; justify-content: center; margin: 28px 0; }
.recents { text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 18px; }
.recents h3 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.recent-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 6px; border-radius: 8px; cursor: pointer;
}
.recent-row:hover { background: #f0f4fb; }
.recent-row .rname { font-weight: 600; }
.recent-row .rpath { font-size: 11px; color: var(--muted); max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- workspace layout ---------- */
#screen-workspace { display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 16px;
  background: var(--panel); border-bottom: 1px solid var(--line);
  padding: 8px 14px; flex: 0 0 auto;
}
.topbar-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.project-title { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.project-title strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-tabs { display: flex; gap: 4px; margin: 0 auto; }
.tab {
  border: none; background: transparent; padding: 8px 18px; border-radius: 8px;
  cursor: pointer; font-size: 13px; font-weight: 600; color: var(--muted);
}
.tab.active { background: #e9effc; color: var(--accent); }
.topbar-right { margin-left: auto; }

.view { flex: 1; display: flex; min-height: 0; }
#view-db { flex-direction: column; }

/* left/right sidebars */
.sidebar-left, .sidebar-right {
  width: 240px; flex: 0 0 auto; background: var(--panel);
  display: flex; flex-direction: column; min-height: 0;
}
.sidebar-left { border-right: 1px solid var(--line); }
.sidebar-right { border-left: 1px solid var(--line); width: 260px; }
.side-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 12px 8px;
}
.side-head h3 { margin: 0; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
#tree { flex: 1; overflow-y: auto; padding: 0 8px; }
.tree-building { margin-bottom: 6px; }
.tree-bname {
  font-weight: 700; font-size: 13px; padding: 6px 8px; display: flex; align-items: center; gap: 6px;
}
.tree-floor {
  padding: 6px 8px 6px 22px; border-radius: 7px; cursor: pointer; font-size: 13px;
  display: flex; align-items: center; justify-content: space-between;
}
.tree-floor:hover { background: #f0f4fb; }
.tree-floor.active { background: #e9effc; color: var(--accent); font-weight: 600; }
.tree-floor .count { font-size: 11px; color: var(--muted); }

/* canvas area */
.canvas-area { flex: 1; display: flex; flex-direction: column; min-width: 0; background: #eceef2; position: relative; }

/* artwork viewer — sits exactly over the inventory panel so the whole plan stays visible */
#view-plan { position: relative; }
.art-viewer {
  position: absolute; top: 0; right: 0; bottom: 0; left: auto;
  width: 260px; z-index: 20;
  background: #f7f8fa; display: flex; flex-direction: column;
  border-left: 1px solid var(--line); box-shadow: -10px 0 28px rgba(20, 30, 50, .18);
}
.art-viewer.marking { width: min(940px, 96vw); }      /* room to draw — temporary, snaps back on save/cancel */
.art-viewer.comments-open { width: min(620px, 96vw); } /* room for the thread — temporary */
.av-foot {
  display: flex; gap: 8px; align-items: center; justify-content: center;
  padding: 10px 10px; background: var(--panel); border-top: 1px solid var(--line);
}
.av-foot .btn { flex: 1 1 0; min-width: 0; padding-left: 4px; padding-right: 4px; white-space: nowrap; }
.av-foot #av-approve { background: #e9f7e9; border-color: #b9e0b9; color: #1d7a1d; font-weight: 700; }
.av-foot #av-approve.btn-approved { background: #d2f0d2; }
.av-head {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--panel); border-bottom: 1px solid var(--line); padding: 8px 10px;
}
.av-head strong { font-size: 14px; }
.av-slots { display: flex; gap: 5px; }
.av-slot {
  border: 1px solid var(--line); background: #fff; border-radius: 7px;
  padding: 4px 10px; font-size: 12px; font-weight: 700; cursor: pointer; color: var(--muted);
}
.av-slot.has-img { color: var(--ink); }
.av-slot.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.av-slot:disabled { opacity: .45; cursor: default; }
.av-main { flex: 1; display: flex; min-height: 0; }
.av-comments {
  width: 290px; flex: 0 0 auto; border-left: 1px solid var(--line); background: var(--panel);
  display: flex; flex-direction: column; padding: 10px 12px; min-height: 0;
}
.av-comments h4 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
#av-comments-list { flex: 1; overflow-y: auto; margin-bottom: 8px; }
.av-comments textarea {
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; font-size: 12px;
  font-family: inherit; resize: vertical; margin-bottom: 6px;
}
.av-body {
  flex: 1; display: flex; align-items: center; justify-content: center;
  overflow: hidden; padding: 18px; cursor: zoom-out; position: relative;
}
.av-body img {
  max-width: 100%; max-height: 100%; object-fit: contain;
  box-shadow: 0 4px 24px rgba(20,30,50,.25); border-radius: 6px; background: #fff; cursor: default;
}
.av-body canvas {
  max-width: 100%; max-height: 100%; object-fit: contain;
  box-shadow: 0 4px 24px rgba(20,30,50,.25); border-radius: 6px; background: #fff;
  cursor: crosshair; touch-action: none;
}
.av-empty { color: var(--muted); text-align: center; }
.av-empty .btn { margin: 4px; }
.markup-chip { font-size: 10px; background: #fdf1df; color: #b06c00; border-radius: 5px; padding: 1px 6px; margin-left: 6px; vertical-align: middle; }

/* markup toolbar */
.av-markup-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: #fffbeb; border-bottom: 1px solid #f0e2bb; padding: 6px 14px;
}
.mk-tool {
  border: 1px solid var(--line); background: #fff; border-radius: 7px;
  padding: 4px 10px; font-size: 12px; cursor: pointer;
}
.mk-tool.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.mk-colors { display: flex; gap: 5px; }
.mk-color { width: 20px; height: 20px; border-radius: 50%; cursor: pointer; border: 2px solid transparent; }
.mk-color.active { border-color: #111; }
.mk-width { border: 1px solid var(--line); border-radius: 6px; padding: 3px 6px; font-size: 12px; }
.mk-text-input {
  position: absolute; z-index: 30; border: 2px solid var(--accent); border-radius: 6px;
  padding: 4px 8px; font-size: 14px; font-weight: 700; background: #fff;
}

/* placeholder designer */
.ph-wrap { display: flex; gap: 18px; }
.ph-tools { width: 190px; flex: 0 0 auto; }
.ph-lab { display: block; font-weight: 700; color: #3c4657; margin: 8px 0 4px; }
.ph-tools input[type="text"] {
  width: 100%; border: 1px solid var(--line); border-radius: 7px; padding: 6px 8px; font-size: 13px;
}
.ph-tools input[type="range"] { width: 100%; }
.ph-canvas-outer {
  flex: 1; display: flex; align-items: center; justify-content: center;
  background: #eceef2; border-radius: 10px; padding: 16px; min-width: 340px; min-height: 380px;
}
#ph-canvas {
  position: relative; background: #eee; box-shadow: 0 2px 12px rgba(20,30,50,.2);
  overflow: hidden; user-select: none;
}
.ph-text {
  position: absolute; transform: translate(-50%, -50%); cursor: grab;
  font-weight: 800; white-space: pre; line-height: 1.2; text-align: center; padding: 2px;
}
.ph-text.bulleted { text-align: left; }
.ph-text.selected { outline: 2px dashed rgba(0,0,0,.45); }
.ph-text:active { cursor: grabbing; }
.ph-glyph { line-height: 0; font-size: 0; padding: 0; white-space: normal; }
.ph-glyph svg { display: block; width: 100%; height: 100%; }
.ph-rs {
  position: absolute; right: -7px; bottom: -7px; width: 13px; height: 13px;
  background: var(--accent); border: 2px solid #fff; border-radius: 3px;
  cursor: nwse-resize; box-shadow: 0 1px 3px rgba(0,0,0,.35);
}
.color-row .color-sm { width: 22px; height: 22px; }

/* tap-to-place banner (touch devices have no drag & drop) */
.place-banner {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
  z-index: 30; display: flex; align-items: center; gap: 10px;
  background: #1c2430; color: #fff; border-radius: 24px; padding: 8px 10px 8px 16px;
  font-size: 13px; font-weight: 600; box-shadow: 0 4px 18px rgba(10,20,40,.35);
  max-width: 92%; white-space: nowrap;
}
.place-banner .btn { border-radius: 16px; }
.inv-item.armed { border-color: var(--accent); box-shadow: 0 0 0 2px #bcd0f7; background: #eef3fe; }
.overlay.placing { cursor: copy; }

/* ---------- responsive: tablet & phone ---------- */
.mobile-only { display: none !important; }
.marker { touch-action: none; } /* dragging a sign must not scroll the plan */

@media (max-width: 920px) {
  .mobile-only { display: inline-block !important; }
  /* sidebars become slide-in drawers */
  .sidebar-left, .sidebar-right {
    position: fixed; top: 0; bottom: 0; z-index: 45;
    transition: transform .22s ease; box-shadow: 0 0 30px rgba(10,20,40,.25);
    padding-top: 8px;
  }
  .sidebar-left { left: 0; transform: translateX(-105%); width: 270px; }
  .sidebar-right { right: 0; transform: translateX(105%); width: 285px; }
  .sidebar-left.open, .sidebar-right.open { transform: translateX(0); }
  .art-viewer { width: min(440px, 94vw); }
  .comments-panel {
    position: fixed; right: 0; top: 0; bottom: 0; z-index: 44;
    width: 86vw; max-width: 330px; box-shadow: 0 0 30px rgba(10,20,40,.25);
  }
  .topbar { flex-wrap: wrap; gap: 8px; padding: 6px 8px; }
  .topbar-tabs { margin: 0; }
  .project-title strong { max-width: 40vw; }
  #ws-project-meta { display: none; }
  .btn, .tab { padding-top: 9px; padding-bottom: 9px; } /* bigger touch targets */
  .modal { width: 94vw !important; max-width: 94vw; padding: 16px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span2 { grid-column: span 1; }
  .home-wrap { padding: 8vh 16px 0; }
  .home-actions { flex-direction: column; }
  .sign-grid { grid-template-columns: 1fr; }
  .ph-wrap { flex-direction: column; }
  .ph-tools { width: auto; }
  .ph-canvas-outer { min-width: 0; min-height: 280px; }
  .db-toolbar { flex-wrap: wrap; padding: 10px; }
  .db-body { padding: 10px; }
  table.db th, table.db td { padding: 6px 6px; font-size: 12px; }
  .av-head { padding: 6px 8px; }
  .av-comments { position: absolute; right: 0; top: 0; bottom: 0; z-index: 26; width: 85vw; max-width: 300px; }
  .plan-stage { margin: 10px auto; }
}
.ph-add-row { margin-bottom: 6px; }
.ph-sym-row { display: flex; gap: 5px; flex-wrap: wrap; }
.ph-sym {
  width: 30px; height: 30px; border: 1px solid var(--line); border-radius: 7px; background: #fff;
  font-size: 15px; font-weight: 800; cursor: pointer; color: #1c2430;
}
.ph-sym:hover { border-color: var(--accent); }
.ph-sym-red { color: #d62828; }
.ph-sym-green { color: #2f9d3a; }
.ph-tools textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 7px; padding: 6px 8px;
  font-size: 13px; font-family: inherit; resize: vertical; margin-bottom: 5px;
}
.plan-empty { margin: auto; color: var(--muted); }
.plan-toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; row-gap: 4px;
  background: var(--panel); border-bottom: 1px solid var(--line); padding: 6px 12px;
}
.plan-label { font-weight: 700; font-size: 13px; }
.divider { width: 1px; height: 18px; background: var(--line); }
.toggle { display: flex; align-items: center; gap: 5px; cursor: pointer; }
.plan-scroll { flex: 1; overflow: auto; }
.plan-stage { position: relative; margin: 24px auto; width: fit-content; box-shadow: 0 2px 14px rgba(20,30,50,.15); }
#pdf-canvas { display: block; background: #fff; }
.overlay { position: absolute; inset: 0; z-index: 3; } /* signs always sit above area lines */
.overlay.droppable { outline: 3px dashed var(--accent); outline-offset: -3px; }
.overlay.calibrating { cursor: crosshair; }

/* scale calibration line */
.cal-svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 5; }
.cal-svg line { stroke: #d6336c; stroke-width: 2.5; stroke-dasharray: 7 5; }
.cal-svg circle { fill: #d6336c; }
.cal-svg text { fill: #d6336c; font-size: 12px; font-weight: 700; paint-order: stroke; stroke: #fff; stroke-width: 3px; }

/* markers on the plan — the marker div is a 0-size anchor at the exact point */
.marker {
  position: absolute; width: 0; height: 0; overflow: visible;
  cursor: grab; user-select: none;
}
.marker:active { cursor: grabbing; }
.marker.selected .mk-shape { outline: 3px solid #111; outline-offset: 1px; }
.mk-shape {
  position: absolute; transform: translate(-50%, -50%);
  width: 26px; height: 26px; display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 9px; font-weight: 800; letter-spacing: .02em;
  box-shadow: 0 1px 4px rgba(0,0,0,.35);
}
.mk-circle { border-radius: 50%; }
.mk-square { border-radius: 4px; }
.mk-diamond { transform: translate(-50%, -50%) rotate(45deg); border-radius: 4px; }
.mk-diamond > span { transform: rotate(-45deg); }
.mk-triangle {
  width: 0 !important; height: 0 !important; background: transparent !important; box-shadow: none;
  border-left: 14px solid transparent; border-right: 14px solid transparent;
  border-bottom: 24px solid currentColor;
}
.mk-triangle > span { position: absolute; text-align: center; color: #fff; }
.mk-label {
  position: absolute; transform: translateX(-50%);
  font-size: 9px; font-weight: 700; background: rgba(255,255,255,.9); color: #111;
  padding: 0 4px; border-radius: 3px; white-space: nowrap; box-shadow: 0 1px 2px rgba(0,0,0,.2);
}

/* standalone symbol icon — no badge behind it */
.mk-glyph {
  position: absolute; transform: translate(-50%, -50%); display: block; line-height: 0;
  filter: drop-shadow(0 0 1px rgba(255,255,255,.95)) drop-shadow(0 1px 3px rgba(0,0,0,.4));
}
.mk-glyph svg { width: 100%; height: 100%; fill: currentColor; }
.marker.selected .mk-glyph { outline: 3px solid #111; outline-offset: 1px; border-radius: 6px; }

/* inventory swatch keeps its mini shape centred */
.inv-swatch { position: relative; }
.inv-swatch .mk-shape { position: absolute; left: 50%; top: 50%; box-shadow: none; }
.inv-swatch .mk-glyph { position: absolute; left: 50%; top: 50%; filter: none; }

/* floor rows: settings button + drag-reorder indicators */
.tree-floor-edit {
  border: none; background: none; cursor: pointer; color: var(--muted);
  font-size: 12px; padding: 1px 4px; visibility: hidden;
}
.tree-floor:hover .tree-floor-edit { visibility: visible; }
.tree-floor-edit:hover { color: var(--accent); }
.tree-floor.drop-above { box-shadow: inset 0 3px 0 var(--accent); }
.tree-floor.drop-below { box-shadow: inset 0 -3px 0 var(--accent); }

/* inventory list */
#inventory-list { flex: 1; overflow-y: auto; padding: 6px 10px 14px; }
.inv-item {
  display: flex; align-items: center; gap: 10px;
  border: 1px solid var(--line); border-radius: 9px; background: #fff;
  padding: 8px 10px; margin-bottom: 8px; cursor: grab;
}
.inv-item:hover { border-color: #b9c6dd; box-shadow: 0 1px 4px rgba(30,50,90,.08); }
.inv-swatch {
  width: 22px; height: 22px; flex: 0 0 auto; display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 8px; font-weight: 800;
}
.inv-main { min-width: 0; flex: 1; }
.inv-code { font-weight: 800; font-size: 12px; }
.inv-desc { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inv-meta { font-size: 10px; color: var(--muted); }
.inv-edit { border: none; background: none; cursor: pointer; color: var(--muted); font-size: 13px; padding: 2px 4px; }
.inv-edit:hover { color: var(--accent); }

/* ---------- database view ---------- */
.db-toolbar {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 22px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.db-toolbar h2 { margin: 0; font-size: 17px; }
.db-body { flex: 1; overflow-y: auto; padding: 18px 22px; }
.db-summary { display: flex; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.sum-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 18px; min-width: 140px;
}
.sum-card .k { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.sum-card .v { font-size: 20px; font-weight: 800; margin-top: 2px; }
table.db {
  width: 100%; border-collapse: collapse; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
}
table.db th, table.db td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--line); font-size: 13px; }
table.db th { background: #f7f8fa; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
table.db tr:last-child td { border-bottom: none; }
table.db td.num, table.db th.num { text-align: right; }
.row-del { border: none; background: none; color: var(--danger); cursor: pointer; font-size: 13px; }
.group-row td { background: #eef1f6; font-weight: 700; }

/* ---------- modals ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15,22,35,.45);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.modal {
  background: var(--panel); border-radius: 14px; padding: 22px 26px;
  width: 560px; max-width: 92vw; max-height: 88vh; overflow-y: auto;
  box-shadow: 0 10px 40px rgba(10,20,40,.3);
}
.modal h2 { margin: 0 0 16px; font-size: 18px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.form-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: #3c4657; }
.form-grid .span2 { grid-column: span 2; }
.form-grid input, .form-grid select {
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 13px;
  font-family: inherit; width: 100%;
}
.form-grid input:focus, .form-grid select:focus { outline: 2px solid #bcd0f7; border-color: var(--accent); }
.inline { display: flex; gap: 8px; align-items: center; }
.inline input { flex: 1; }
.prefix { color: var(--muted); }
.hint { font-weight: 400; font-size: 11px; color: var(--muted); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; align-items: center; }

/* shape & color pickers */
.shape-row { display: flex; gap: 10px; }
.shape-opt {
  width: 44px; height: 44px; border: 2px solid var(--line); border-radius: 9px; background: #fff;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.shape-opt.selected { border-color: var(--accent); background: #e9effc; }
.sh { display: block; width: 20px; height: 20px; background: #55627a; }
.sh-circle { border-radius: 50%; }
.sh-square { border-radius: 3px; }
.sh-diamond { transform: rotate(45deg); border-radius: 3px; width: 17px; height: 17px; }
.sh-triangle {
  width: 0; height: 0; background: transparent;
  border-left: 11px solid transparent; border-right: 11px solid transparent; border-bottom: 19px solid #55627a;
}
.color-row { display: flex; gap: 8px; flex-wrap: wrap; }
.color-opt {
  width: 30px; height: 30px; border-radius: 50%; cursor: pointer; border: 3px solid transparent;
}
.color-opt.selected { border-color: #111; }

/* ---------- cloud & auth ---------- */
.login-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 22px 24px; text-align: left;
}
.login-card input {
  width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px;
  font-size: 14px; margin-bottom: 10px;
}
.login-error { color: var(--danger); font-size: 12px; margin: 2px 0 0; }
.login-card a, .home-wrap a { color: var(--accent); text-decoration: none; }
/* facing arrows on placed signs */
.mk-dir { position: absolute; overflow: visible; pointer-events: none; }
.mk-dir line { stroke: #1c2430; stroke-width: 2.5; }
.mk-dir polygon { fill: #1c2430; }
.mk-dir .dir-halo line { stroke: #fff; stroke-width: 5; }
.mk-dir .dir-halo polygon { fill: #fff; stroke: #fff; stroke-width: 3; }
.mk-dir text {
  fill: #1c2430; font-size: 10px; font-weight: 800;
  paint-order: stroke; stroke: #fff; stroke-width: 3px; text-anchor: middle;
}
.mk-dir .dir-hit { pointer-events: auto; cursor: grab; }
.mk-dir .dir-hit:active { cursor: grabbing; }

/* area drawing layer */
.anno-svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 2; }
.anno-svg.editing { pointer-events: auto; cursor: crosshair; }
.anno-svg.editing.sel-mode { cursor: default; }
.anno-svg path.a-path { fill: none; }
.anno-svg path.a-fill { stroke: none; }
.anno-svg path.a-hit { fill: none; stroke: transparent; stroke-width: 14; pointer-events: stroke; cursor: pointer; }
.anno-svg path.a-hit.closed-hit { pointer-events: all; }
.anno-svg .a-node { fill: #fff; stroke: #2f6fed; stroke-width: 2; cursor: move; pointer-events: all; }
.anno-svg .a-node.curved { fill: #2f6fed; }
.anno-svg .a-first { stroke: #d6336c; }
.anno-svg text.a-label {
  font-weight: 800; paint-order: stroke; stroke: rgba(255,255,255,.92); stroke-width: 4px;
  text-anchor: middle; pointer-events: all; cursor: pointer;
}
.anno-svg.editing.sel-mode text.a-label { cursor: move; } /* labels drag in Select mode */
/* selection glow for shapes and symbols — text boxes use the dashed rect instead,
   so plain text (outline off) never carries a shadow */
.anno-svg path.a-selected, .anno-svg .a-stamp.a-selected { filter: drop-shadow(0 0 3px rgba(47,111,237,.8)); }
.anno-svg .a-boxsel { fill: none; stroke: #2f6fed; stroke-dasharray: 5 4; stroke-width: 1.4; pointer-events: none; }
.anno-svg .a-boxw { fill: #2f6fed; stroke: #fff; stroke-width: 2; cursor: ew-resize; pointer-events: all; }

/* in-place text editing on the plan */
.txt-editor {
  position: absolute; z-index: 8; min-height: 1.3em;
  outline: 2px dashed #2f6fed; outline-offset: 2px;
  background: rgba(255,255,255,.75); padding: 0; white-space: pre-wrap;
  overflow-wrap: break-word; cursor: text;
}
.txt-editor:focus { outline-style: solid; }
.txt-dragbox {
  position: absolute; z-index: 8; pointer-events: none;
  border: 2px dashed #2f6fed; background: rgba(47,111,237,.06);
}
.anno-fontsel { max-width: 130px; }
.txt-editor .ted-line { min-height: 1em; }
.halo-demo { text-shadow: 0 0 2px #fff, 0 0 3px #fff; font-weight: 800; }
.halo-swatch {
  display: inline-block; width: 13px; height: 13px; border-radius: 3px;
  border: 1px solid #b6c0cf; background: #fff; vertical-align: -2px;
}
.halo-swatch.bg-none {
  background: repeating-linear-gradient(45deg, #fff 0 3px, #e3e8f0 3px 6px); /* "no background" checker */
}
.bg-op { width: 64px; accent-color: var(--accent); }
.anno-svg rect.a-bg { pointer-events: all; cursor: pointer; }
.anno-svg.editing.sel-mode rect.a-bg { cursor: move; }
#anno-pt { width: 58px; border: 1px solid var(--line); border-radius: 7px; padding: 4px 6px; font-size: 12px; }
.anno-svg.editing.sel-mode path.a-hit { cursor: move; }
.anno-svg .a-stamp-hit { pointer-events: all; cursor: pointer; }
.anno-svg.editing.sel-mode .a-stamp-hit { cursor: move; }
.anno-svg .a-stamp-box { fill: none; stroke: #2f6fed; stroke-dasharray: 4 3; stroke-width: 1.5; pointer-events: none; }
.anno-svg .a-stamp-rs { fill: #2f6fed; stroke: #fff; stroke-width: 2; cursor: nwse-resize; pointer-events: all; }
.anno-prim {
  border: 1px solid var(--line); background: #fff; border-radius: 7px;
  padding: 4px 9px; font-size: 13px; cursor: pointer; line-height: 1;
}
.anno-prim:hover { border-color: var(--accent); color: var(--accent); }
.anno-stamps { display: inline-flex; gap: 4px; }
.anno-stampbtn { padding: 3px 6px; line-height: 0; }
.anno-stampbtn svg { width: 17px; height: 17px; fill: #3c4658; }
.anno-stampbtn.active svg { fill: #fff; }
.anno-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: #eef6ff; border-bottom: 1px solid #cfe0f5; padding: 6px 14px;
}
.anno-tool {
  border: 1px solid var(--line); background: #fff; border-radius: 7px;
  padding: 4px 10px; font-size: 12px; cursor: pointer;
}
.anno-tool.active { background: var(--accent); border-color: var(--accent); color: #fff; }
#anno-label { border: 1px solid var(--line); border-radius: 7px; padding: 5px 9px; font-size: 12px; width: 160px; }

/* colour picker */
.cp-tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.cp-tab {
  border: 1px solid var(--line); background: #fff; border-radius: 8px;
  padding: 5px 14px; font-size: 12.5px; cursor: pointer;
}
.cp-tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.cp-row { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.cp-row label { font-size: 11px; color: var(--muted); display: flex; flex-direction: column; gap: 3px; }
.cp-row input[type=number] { width: 58px; border: 1px solid var(--line); border-radius: 7px; padding: 5px 7px; }
.cp-row input[type=text] { border: 1px solid var(--line); border-radius: 7px; padding: 5px 7px; }
#cp-native { width: 56px; height: 40px; border: 1px solid var(--line); border-radius: 8px; padding: 2px; background: #fff; cursor: pointer; }
.cp-stops { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.cp-stop { position: relative; display: inline-flex; }
.cp-stop input[type=color] { width: 44px; height: 36px; border: 1px solid var(--line); border-radius: 8px; padding: 2px; background: #fff; cursor: pointer; }
.cp-del {
  position: absolute; top: -7px; right: -7px; width: 17px; height: 17px;
  border-radius: 50%; border: none; background: #d6336c; color: #fff;
  font-size: 10px; line-height: 1; cursor: pointer;
}
.cp-preview-wrap { margin-top: 14px; }
.cp-preview { height: 34px; border-radius: 9px; border: 1px solid var(--line); margin-top: 4px; }
.mk-color-add, .color-add {
  display: inline-flex; align-items: center; justify-content: center;
  background: #fff !important; border: 1px dashed #9aa4b2 !important;
  color: #5b6472; font-weight: 700; cursor: pointer;
}
.mk-color-add:hover, .color-add:hover { border-color: var(--accent) !important; color: var(--accent); }

/* select-tool icon + alignment buttons */
.sel-ico { width: 15px; height: 15px; vertical-align: -3px; }
.anno-align { display: inline-flex; gap: 3px; }
.anno-alignbtn {
  border: 1px solid var(--line); background: #fff; border-radius: 6px;
  padding: 3px 6px; cursor: pointer; line-height: 0; color: #3c4658;
}
.anno-alignbtn svg { width: 14px; height: 12px; }
.anno-alignbtn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.anno-alignbtn:disabled { opacity: .4; cursor: default; }

/* right-click menu on placed signs */
.ctx-menu {
  position: fixed; z-index: 90; background: #fff; border: 1px solid var(--line);
  border-radius: 10px; box-shadow: 0 6px 24px rgba(20,30,50,.18); padding: 5px;
  min-width: 150px;
}
.ctx-menu button {
  display: block; width: 100%; text-align: left; border: none; background: none;
  padding: 8px 12px; font-size: 13px; border-radius: 7px; cursor: pointer;
}
.ctx-menu button:hover { background: #eef4ff; }
.ctx-menu button.danger:hover { background: #ffe8ee; color: #c22; }

/* configurable export + production lists */
.exp-presets { display: flex; gap: 8px; margin-bottom: 12px; }
.exp-cols {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px 14px;
  max-height: 40vh; overflow-y: auto; border: 1px solid var(--line);
  border-radius: 10px; padding: 12px 14px;
}
.exp-col { font-size: 13px; display: flex; align-items: center; gap: 7px; }
.exp-col input { width: auto; }
#modal-prodopts textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; font: inherit; font-size: 12.5px; resize: vertical;
}

/* help */
.help-search {
  width: 100%; border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 12px; font-size: 13px; margin-bottom: 10px;
}
.help-list { max-height: 55vh; overflow-y: auto; }
.help-item { border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; overflow: hidden; }
.help-item summary {
  padding: 10px 14px; font-weight: 700; font-size: 13px; cursor: pointer;
  background: #f7f8fa; list-style: none;
}
.help-item summary::before { content: '▸ '; color: var(--muted); }
.help-img {
  display: block; width: 100%; margin-top: 10px;
  border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 1px 6px rgba(20,30,50,.08);
}
.help-item[open] summary::before { content: '▾ '; }
.help-item .h-body { padding: 10px 14px; font-size: 13px; line-height: 1.55; }
.help-item .h-body b { color: var(--accent); }

/* approvals */
.av-slot.approved { background: #e5f2e5; border-color: #bfe0bf; color: #2c7a2c !important; }
.av-slot.approved.active { background: #2f9d3a; border-color: #2f9d3a; color: #fff !important; }
.btn-approved { background: #2f9d3a !important; border-color: #2f9d3a !important; color: #fff !important; }
.slot.slot-approved { border-color: #2f9d3a; box-shadow: 0 0 0 1px #2f9d3a; }
.slot.slot-approved .slot-name { background: #e5f2e5; color: #2c7a2c; }

/* notifications */
.notif-badge {
  display: inline-block; min-width: 17px; height: 17px; border-radius: 9px;
  background: #d64545; color: #fff; font-size: 11px; font-weight: 800;
  line-height: 17px; text-align: center; padding: 0 4px; vertical-align: top;
}
.notifs-list { max-height: 50vh; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; }
.notifs-list:empty { display: none; }
.notif-row { padding: 9px 12px; border-bottom: 1px solid var(--line); font-size: 13px; }
.notif-row:last-child { border-bottom: none; }
.notif-row.unread { background: #eef3fe; }
.notif-row .n-meta { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* person tags */
.tag-pill {
  font-size: 10px; border-radius: 4px; padding: 1px 6px; font-weight: 700;
  background: #f0e9fb; color: #6f42c1; white-space: nowrap;
}

/* live presence: one dot per teammate currently in the project */
.presence-row { display: inline-flex; align-items: center; margin-right: 8px; }
.presence-chip {
  width: 26px; height: 26px; border-radius: 50%; color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 800; border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(10,20,40,.3); margin-left: -6px;
}
.presence-chip:first-child { margin-left: 0; }
.presence-chip { cursor: pointer; }
.presence-chip:hover { transform: scale(1.12); }

/* person profile popup */
.person-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.person-avatar {
  width: 44px; height: 44px; border-radius: 50%; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; font-size: 16px;
}
#person-msg { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font: inherit; font-size: 13px; resize: vertical; }

/* clickable notifications + private messages */
.notif-row.clickable { cursor: pointer; }
.notif-row.clickable:hover { background: #f0f5ff; }
.notif-row.dm { border-left: 3px solid #7048e8; }

.user-chip {
  font-size: 12px; background: #e9effc; color: var(--accent); font-weight: 700;
  border-radius: 20px; padding: 4px 12px; margin-right: 10px; white-space: nowrap;
  cursor: pointer;
}
.user-chip:hover { background: #dbe6fb; }
#home-user-line a { font-size: 12px; margin-left: 6px; }
.role-pill {
  font-size: 10px; border-radius: 4px; padding: 1px 6px; font-weight: 800;
  text-transform: uppercase; letter-spacing: .03em;
}
.role-admin { background: #ffe9e0; color: #b34700; }
.role-editor { background: #e5f2e5; color: #2c7a2c; }
.role-reviewer { background: #e9effc; color: #245cd0; }
.role-none { background: #eee; color: #888; }
.users-h { margin: 16px 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.users-list { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.users-list:empty { display: none; }
.user-row {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  border-bottom: 1px solid var(--line); font-size: 13px;
}
.user-row:last-child { border-bottom: none; }
.user-row select { border: 1px solid var(--line); border-radius: 6px; padding: 3px 6px; font-size: 12px; }
.user-row .u-mail { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.cloud-row-del { border: none; background: none; color: var(--danger); cursor: pointer; }

/* ---------- v0.2 additions ---------- */
.mono { font-family: ui-monospace, Menlo, monospace; font-size: 11px; background: #f0f2f6; padding: 1px 5px; border-radius: 4px; }
.mode-select {
  border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px; font-size: 12px;
  background: #fff; margin-right: 10px; cursor: pointer;
}
body.review-mode .edit-only { display: none !important; }
.form-grid textarea {
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 13px;
  font-family: inherit; width: 100%; resize: vertical;
}
.chk-line { font-weight: 400 !important; }

/* inventory tabs */
.inv-tabs { display: flex; gap: 4px; padding: 0 10px 6px; }
.inv-tab {
  flex: 1; border: 1px solid var(--line); background: #fff; padding: 5px 4px;
  font-size: 12px; border-radius: 7px; cursor: pointer; color: var(--muted);
}
.inv-tab.active { background: #e9effc; color: var(--accent); border-color: #bcd0f7; font-weight: 600; }
.inv-add-btn { border: none; background: #eef6ee; color: #2c7a2c; border-radius: 6px; cursor: pointer; font-size: 11px; padding: 3px 7px; }
.inv-add-btn:hover { background: #ddeedd; }

/* icon type + glyph pickers */
.icontype-row { display: flex; gap: 8px; }
.icontype-opt {
  flex: 1; border: 2px solid var(--line); background: #fff; border-radius: 8px;
  padding: 7px 4px; font-size: 12px; cursor: pointer;
}
.icontype-opt.selected { border-color: var(--accent); background: #e9effc; font-weight: 600; }
.glyph-row { display: flex; gap: 8px; flex-wrap: wrap; }
.glyph-opt {
  width: 40px; height: 40px; border: 2px solid var(--line); border-radius: 8px; background: #55627a;
  display: flex; align-items: center; justify-content: center; cursor: pointer; padding: 0;
}
.glyph-opt svg { width: 24px; height: 24px; fill: #fff; }
.glyph-opt.selected { border-color: var(--accent); box-shadow: 0 0 0 2px #bcd0f7; }
.iconimg-preview {
  width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center; overflow: hidden; background: #fff;
}
.iconimg-preview img { max-width: 100%; max-height: 100%; }

/* image markers */
.mk-img {
  position: absolute; transform: translate(-50%, -50%);
  object-fit: contain; box-shadow: 0 1px 4px rgba(0,0,0,.35);
  background: #fff; border-radius: 4px;
}
.marker.selected .mk-img { outline: 3px solid #111; outline-offset: 1px; }
.mk-shape svg { fill: #fff; width: 62%; height: 62%; }
.mk-badges {
  position: absolute; display: flex; gap: 2px; transform: translateX(-50%);
}
.mk-badge {
  width: 10px; height: 10px; border-radius: 50%; font-size: 7px; line-height: 10px;
  text-align: center; color: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.3);
}
.mk-badge.art { background: #3f9d3a; }
.mk-badge.cmt { background: #f08c00; }

/* comments panel */
.comments-panel {
  width: 300px; flex: 0 0 auto; background: var(--panel); border-left: 1px solid var(--line);
  display: flex; flex-direction: column; min-height: 0;
}
.comment-add { padding: 8px 12px; border-bottom: 1px solid var(--line); }
.comment-add textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px;
  font-size: 12px; font-family: inherit; margin: 6px 0; resize: vertical;
}
#comments-list { flex: 1; overflow-y: auto; padding: 8px 12px; }
.comment-card {
  border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; margin-bottom: 8px; background: #fff;
}
.comment-card.done { opacity: .55; }
.comment-card .c-head { display: flex; align-items: center; gap: 6px; margin-bottom: 3px; }
.comment-card .c-id { font-weight: 800; font-size: 11px; color: var(--accent); cursor: pointer; }
.comment-card .c-author { font-weight: 600; font-size: 11px; }
.comment-card .c-time { font-size: 10px; color: var(--muted); }
.comment-card .c-text { font-size: 12px; white-space: pre-wrap; }
.comment-card .c-text .mention { color: var(--accent); font-weight: 700; }
.comment-card .c-actions { display: flex; gap: 10px; margin-top: 5px; align-items: center; }
.comment-card .c-actions button, .comment-card .c-actions label {
  border: none; background: none; font-size: 11px; color: var(--muted); cursor: pointer; padding: 0;
  display: flex; align-items: center; gap: 3px;
}
.comment-card .c-actions button:hover { color: var(--accent); }
.c-reply { border-left: 2px solid var(--line); margin: 6px 0 0 8px; padding: 4px 0 0 8px; }
.c-replybox { display: flex; gap: 6px; margin-top: 6px; }
.c-replybox input { flex: 1; border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; font-size: 12px; }

/* sign details modal */
.sign-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.sign-grid h4 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.sign-slots { display: flex; flex-wrap: wrap; gap: 8px; }
.slot {
  width: 106px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff;
}
.slot .slot-name { font-size: 10px; font-weight: 800; text-align: center; padding: 2px; background: #f4f6f9; }
.slot .slot-img {
  width: 100%; height: 64px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; background: #fafbfc; overflow: hidden;
}
.slot .slot-img img { max-width: 100%; max-height: 100%; }
.slot .slot-img .noimg { font-size: 10px; color: var(--muted); }
.slot .slot-actions { display: flex; }
.slot .slot-actions button {
  flex: 1; border: none; border-top: 1px solid var(--line); background: #fff;
  font-size: 11px; padding: 4px 0; cursor: pointer; color: var(--muted);
  white-space: nowrap; overflow: hidden;
}
.slot .slot-actions button + button { border-left: 1px solid var(--line); }
.slot .slot-actions button:hover { color: var(--accent); }
.sign-comments { max-height: 260px; overflow-y: auto; margin-bottom: 8px; }
#modal-sign textarea { margin-bottom: 6px; }

/* lightbox */
.lightbox { width: auto; max-width: 80vw; }
.lightbox img { max-width: 76vw; max-height: 70vh; display: block; margin: 0 auto; border-radius: 8px; }

/* database selects */
table.db select {
  border: 1px solid var(--line); border-radius: 6px; padding: 3px 6px; font-size: 12px; background: #fff;
}
td.art-cell { display: flex; align-items: center; gap: 6px; }
.art-chip { font-size: 10px; background: #eef6ee; color: #2c7a2c; border-radius: 5px; padding: 1px 5px; }
.art-link { border: none; background: none; cursor: pointer; padding: 2px 4px; border-radius: 6px; }
.art-link:hover { background: #e9effc; }

/* suppliers & price lists */
.sup-table { width: 100%; margin-bottom: 6px; }
.sup-table input, .sup-table select { width: 100%; box-sizing: border-box; padding: 4px 6px; }
#modal-suppliers h3 { font-weight: 700; }

/* frozen database dashboard */
.db-summary { position: sticky; top: -18px; z-index: 5; background: var(--bg, #f7f6f3); padding: 18px 0 10px; margin-top: -18px; }

/* master library supplier folders */
.inv-folder { margin: 2px 6px; }
.inv-folder > summary { cursor: pointer; font-weight: 700; font-size: 12.5px; padding: 6px 8px; border-radius: 6px; user-select: none; }
.inv-folder > summary:hover { background: rgba(0,0,0,.05); }

/* marquee multi-select */
.sel-rect { position: absolute; border: 1.5px dashed #2f6fed; background: rgba(47,111,237,.08); z-index: 40; pointer-events: none; }
.marker.multi-selected { outline: 2px dashed #d6336c; outline-offset: 3px; border-radius: 6px; }

/* label rotate handle — visible when the sign is selected */
.mk-lrot {
  display: none; position: absolute; right: -18px; top: 50%; transform: translateY(-50%);
  width: 15px; height: 15px; line-height: 15px; text-align: center; font-size: 10px;
  background: #2f6fed; color: #fff; border-radius: 50%; cursor: grab; user-select: none;
}
.mk-lrot::before { content: '⟳'; } /* pseudo-element so the glyph never joins the label's text */
.marker.selected .mk-label .mk-lrot { display: block; }
