/* K Design Survey — dark mode admin portal styling.
 * Palette: bg #1a1a2e, card #16213e, border #0f3460, accent #2563eb, text #ffffff.
 * Brand secondary: #16a34a (green), danger: #dc2626 (red).
 */

:root {
  --bg: #1a1a2e;
  --bg-2: #14142b;
  --card: #16213e;
  --card-2: #1c2a4f;
  --border: #0f3460;
  --border-2: #1a4380;
  --accent: #2563eb;
  --accent-2: #1d4ed8;
  --text: #ffffff;
  --muted: #9aa3b8;
  --ok: #22c55e;
  --warn: #f59e0b;
  --error: #ef4444;
  --info: #3b82f6;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
  --radius: 12px;
  --radius-sm: 8px;
  --gap: 16px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, "Helvetica Neue", sans-serif;
  font-size: 16px;
  line-height: 1.4;
  overscroll-behavior: none;
}

body { overflow: hidden; }                /* full-screen app */
.app { height: 100dvh; display: flex; flex-direction: column; }

input, textarea, select, button { font: inherit; color: inherit; }
button { cursor: pointer; }

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-2); }

/* --- Buttons -------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  font-weight: 600;
  font-size: 15px;
  min-height: 44px;
  transition: background 0.15s, transform 0.05s, border-color 0.15s;
  user-select: none;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--accent); }
.btn-primary:hover { background: var(--accent-2); }
.btn-ghost { background: var(--card-2); border-color: var(--border); }
.btn-ghost:hover { background: var(--border); }
.btn-danger { background: var(--error); }
.btn-danger:hover { background: #dc2626; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-icon { padding: 8px; min-height: 36px; min-width: 36px; }
.btn-sm { padding: 8px 12px; min-height: 36px; font-size: 14px; }

/* --- Inputs --------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; color: var(--muted); }
.input,
.textarea,
.select {
  background: var(--bg-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 15px;
  outline: none;
  width: 100%;
}
.input:focus, .textarea:focus, .select:focus { border-color: var(--accent); }
.textarea { resize: vertical; min-height: 90px; }
.required::after { content: ' *'; color: var(--accent); }

/* --- Toggle group --------------------------------------------------- */
.toggle-group { display: inline-flex; background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 3px; }
.toggle-group .toggle {
  background: transparent; border: 0; color: var(--muted);
  padding: 8px 14px; border-radius: 6px; min-width: 48px; font-weight: 600;
}
.toggle-group .toggle.active { background: var(--accent); color: #fff; }

/* --- Header --------------------------------------------------------- */
.appbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  gap: 12px;
}
.appbar h1 { margin: 0; font-size: 18px; font-weight: 700; }
.appbar h1 .accent { color: var(--accent); }
.appbar-right { display: flex; align-items: center; gap: 12px; }
.user-chip {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: 999px; padding: 4px 12px 4px 4px;
  font-size: 13px;
}
.user-chip img { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; }
.user-chip .email { color: var(--muted); max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn { background: transparent; border: 0; color: var(--text); padding: 8px; border-radius: 6px; }
.icon-btn:hover { background: var(--bg-2); }

/* --- Online/offline badge ------------------------------------------ */
.net-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; letter-spacing: 0.2px;
}
.net-badge .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 3px rgba(255,255,255,0.05); }
.net-online { color: var(--ok); background: rgba(34,197,94,0.12); }
.net-offline { color: var(--error); background: rgba(239,68,68,0.12); }

/* --- Main area ------------------------------------------------------ */
.screen {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 20px 16px 80px;
}
.screen.no-scroll { overflow: hidden; padding: 0; }
.container { max-width: 720px; margin: 0 auto; }
.container-wide { max-width: 1080px; margin: 0 auto; }

.section-title { font-size: 14px; color: var(--muted); margin: 24px 0 8px; text-transform: uppercase; letter-spacing: 0.5px; }

/* --- Cards ---------------------------------------------------------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 12px; }

/* --- Banner --------------------------------------------------------- */
.banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.4);
  color: #fde68a;
  padding: 12px 16px; border-radius: var(--radius-sm);
  margin-bottom: 16px;
}
.banner-error { background: rgba(239,68,68,0.12); border-color: rgba(239,68,68,0.4); color: #fecaca; }
.banner-info { background: rgba(59,130,246,0.12); border-color: rgba(59,130,246,0.4); color: #bfdbfe; }

/* --- Survey list rows ---------------------------------------------- */
.survey-list { list-style: none; margin: 0; padding: 0; }
.survey-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 10px;
  text-align: left;
}
.survey-row:hover { border-color: var(--border-2); }
.survey-row .meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 4px; color: var(--muted); font-size: 13px; }
.survey-row .name { font-weight: 600; font-size: 16px; }
.survey-row .addr { color: var(--muted); font-size: 13px; margin-top: 2px; }

/* --- Badges --------------------------------------------------------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; letter-spacing: 0.4px; text-transform: uppercase; }
.badge-draft   { background: rgba(154,163,184,0.18); color: #cbd5e1; }
.badge-complete{ background: rgba(59,130,246,0.18); color: #93c5fd; }
.badge-synced  { background: rgba(34,197,94,0.18); color: #86efac; }
.badge-pending { background: rgba(245,158,11,0.18); color: #fde68a; }
.badge-error   { background: rgba(239,68,68,0.18); color: #fca5a5; }

/* --- Footer --------------------------------------------------------- */
.app-footer {
  position: sticky; bottom: 0;
  font-size: 12px; color: var(--muted);
  background: var(--card);
  border-top: 1px solid var(--border);
  padding: 6px 16px;
  text-align: center;
}

/* --- Login screen --------------------------------------------------- */
.login-screen {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px; text-align: center; gap: 28px;
}
.brand { line-height: 1; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.brand .logo-mark { display: inline-block; background: #ffffff; border-radius: 8px; padding: 4px; box-shadow: 0 4px 12px rgba(0,0,0,0.2); }
.brand .logo-mark img { display: block; max-width: 220px; height: auto; }
.brand .survey { font-size: 28px; font-weight: 600; color: var(--text); letter-spacing: 4px; text-transform: uppercase; }
.appbar .logo-mark { display: inline-block; background: #ffffff; border-radius: 6px; padding: 3px; }
.appbar .logo-mark img { display: block; height: 30px; width: auto; }
.subtitle { color: var(--muted); font-size: 14px; }
.login-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px; max-width: 360px; width: 100%; box-shadow: var(--shadow); }
.login-error { color: #fca5a5; background: rgba(239,68,68,0.12); border: 1px solid rgba(239,68,68,0.4); border-radius: var(--radius-sm); padding: 12px; margin-bottom: 14px; font-size: 14px; }

.gbtn {
  display: inline-flex; align-items: center; justify-content: center; gap: 12px;
  width: 100%;
  background: #fff; color: #1f1f1f;
  border: 0; border-radius: var(--radius-sm);
  padding: 12px 16px; font-weight: 600; font-size: 15px; min-height: 48px;
}
.gbtn:hover { background: #f1f3f4; }
.gbtn svg { width: 20px; height: 20px; }

/* --- Toasts --------------------------------------------------------- */
#toast-root { position: fixed; left: 0; right: 0; bottom: 16px; z-index: 9999; pointer-events: none; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 0 16px; }
.toast { pointer-events: auto; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 14px; box-shadow: var(--shadow); opacity: 0; transform: translateY(8px); transition: opacity 0.2s, transform 0.2s; max-width: 480px; width: 100%; text-align: center; font-size: 14px; }
.toast-in { opacity: 1; transform: translateY(0); }
.toast-out { opacity: 0; transform: translateY(8px); }
.toast-info { border-color: var(--info); }
.toast-success { border-color: var(--ok); }
.toast-warn { border-color: var(--warn); }
.toast-error { border-color: var(--error); }

/* --- Modals --------------------------------------------------------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.55); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; padding: 16px; opacity: 0; transition: opacity 0.2s; z-index: 9000; }
.modal-in { opacity: 1; }
.modal-out { opacity: 0; }
.modal-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); width: 100%; max-width: 480px; box-shadow: var(--shadow); display: flex; flex-direction: column; max-height: 90dvh; }
.modal-head { padding: 16px 18px; border-bottom: 1px solid var(--border); }
.modal-title { margin: 0; font-size: 17px; }
.modal-body { padding: 16px 18px; overflow-y: auto; }
.modal-foot { padding: 12px 16px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

/* --- Loading overlay ----------------------------------------------- */
.loading-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.55); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; z-index: 9500; }
.loading-message { color: var(--text); font-size: 14px; }
.spinner { width: 40px; height: 40px; border-radius: 50%; border: 3px solid var(--border); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* --- CRM client picker --------------------------------------------- */
.client-search { position: sticky; top: 0; padding-bottom: 8px; background: var(--card); }
.client-list { list-style: none; padding: 0; margin: 0; }
.client-row { padding: 10px 8px; border-bottom: 1px solid var(--border); cursor: pointer; }
.client-row:hover { background: var(--card-2); }
.client-row .name { font-weight: 600; }
.client-row .addr { color: var(--muted); font-size: 13px; }

/* --- Canvas screen -------------------------------------------------- */
.canvas-screen { flex: 1; display: grid; grid-template-rows: auto 1fr auto; min-height: 0; }
.floor-tabs { display: flex; gap: 6px; padding: 8px 12px; background: var(--card); border-bottom: 1px solid var(--border); overflow-x: auto; }
.floor-tab { background: var(--bg-2); color: var(--muted); border: 1px solid var(--border); padding: 8px 14px; border-radius: 8px; white-space: nowrap; font-weight: 600; }
.floor-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.floor-tab-add { background: transparent; border: 1px dashed var(--border-2); color: var(--accent); padding: 8px 12px; border-radius: 8px; font-weight: 700; }
.floor-tab.site-plan { font-style: italic; }

/* Pre-departure checklist */
.check-section { margin-bottom: 14px; }
.check-section h4 { margin: 0 0 8px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.4px; }
.check-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; font-size: 13px; }
.check-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: 0 0 10px; }
.dot-red   { background: #ef4444; }
.dot-amber { background: #f59e0b; }
.dot-green { background: #22c55e; }
.check-text { flex: 1; color: var(--text); }
.check-row .btn-sm { margin-left: auto; }

.canvas-body { display: grid; grid-template-columns: 72px 1fr; min-height: 0; position: relative; }
.toolbar { background: var(--card); border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 8px 6px; gap: 4px; overflow-y: auto; }
.tool {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  padding: 8px 4px; border-radius: 8px; background: transparent; border: 1px solid transparent; color: var(--muted);
  font-size: 10px; font-weight: 600; min-height: 56px; text-align: center;
}
.tool .tool-ico { font-size: 18px; }
.tool.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.tool:hover:not(.active) { background: var(--bg-2); color: var(--text); }
.tool[disabled] { opacity: 0.4; cursor: not-allowed; }

.canvas-area { position: relative; min-width: 0; min-height: 0; background: #0f1117; }
.legend { position: absolute; right: 12px; bottom: 12px; background: rgba(15,17,23,0.85); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-size: 11px; color: var(--muted); z-index: 5; pointer-events: none; line-height: 1.4; }
.legend .row { display: flex; align-items: center; gap: 8px; }
.legend .swatch { display: inline-block; width: 28px; height: 8px; }
.legend .swatch.ext { background: #ffffff; height: 4px; }
.legend .swatch.lb  { background: #ffffff; height: 4px; background-image: repeating-linear-gradient(45deg, rgba(0,0,0,0) 0 2px, rgba(0,0,0,0.4) 2px 4px); }
.legend .swatch.int { background: #ffffff; height: 2px; }
.tool.tool-sub { min-height: 38px; font-size: 10px; }
.tool.tool-sub.active { background: var(--accent); color: #fff; }

/* Door + Window must own touch gestures so the browser doesn't convert
   the press into a scroll. Long-press iOS callout and text selection are
   also suppressed. */
.tool[data-tool="door"],
.tool[data-tool="window"] {
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

/* Inline floating dimension input — overlays the canvas. */
.inline-edit {
  position: absolute; z-index: 30;
  background: rgba(0, 0, 0, 0.85);
  color: #fff;
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 4px 6px;
  display: flex; gap: 4px; align-items: center;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  transform: translate(-50%, -50%);
  min-width: 132px;
}
.inline-edit input {
  background: transparent;
  border: 0;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  outline: 0;
  width: 80px;
  padding: 4px 2px;
  min-height: 36px;
}
.inline-edit .unit { color: var(--muted); font-size: 11px; padding-right: 4px; }
.inline-edit .ok { background: var(--accent); border: 0; color: #fff; border-radius: 4px; padding: 4px 8px; font-weight: 700; min-height: 32px; min-width: 32px; }

/* Touch-friendly tap target wrapper for the on-canvas dimension labels. */
.dim-tap {
  position: absolute; z-index: 6;
  transform: translate(-50%, -50%);
  min-width: 44px; min-height: 44px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  background: transparent;       /* hit area only — visual is on Konva */
  border: 0;
  padding: 0;
}
.dim-tap.opening-from-left   { color: #fff; }
.dim-tap.opening-from-right  { color: #fff; }
.dim-tap.opening-width       { color: #fff; }
.dim-tap .dim-pill {
  background: rgba(0,0,0,0.55);
  border: 1px solid rgba(255,255,255,0.15);
  color: #fff; font-size: 11px; font-weight: 600;
  padding: 3px 8px; border-radius: 999px;
  white-space: nowrap;
}
.dim-tap.selected .dim-pill { background: var(--accent); border-color: var(--accent); }

/* Drag ghost element — follows pointer when dragging from the toolbar. */
.drag-ghost {
  position: fixed; z-index: 9999;
  pointer-events: none;
  transform: translate(-50%, -50%);
  background: var(--card);
  border: 1px solid var(--accent);
  color: #fff; font-size: 12px; font-weight: 700;
  padding: 6px 10px; border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  opacity: 0.9;
}

/* Contextual top bar (Section 4) */
.canvas-topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  height: 44px;
  padding: 0 8px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.canvas-topbar.tb-fade-in { animation: tb-fade 0.1s ease-out; }
@keyframes tb-fade { from { opacity: 0.5; } to { opacity: 1; } }
.canvas-topbar .tb-group { display: flex; align-items: center; gap: 4px; }
.tb-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 36px; min-width: 44px;
  padding: 0 10px;
  background: transparent;
  color: var(--text);
  border: 1px solid transparent;
  border-radius: 6px;
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
}
.tb-btn:hover:not(.disabled) { background: var(--bg-2); }
.tb-btn:active:not(.disabled) { transform: scale(0.96); }
.tb-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.tb-btn.disabled, .tb-btn[disabled] { opacity: 0.35; pointer-events: none; }
.tb-btn.tb-danger { color: #fecaca; }
.tb-btn.tb-danger:hover { background: rgba(239, 68, 68, 0.18); }
.tb-btn.tb-done { background: var(--accent); color: #fff; }
.tb-btn.tb-zoom { color: var(--muted); min-width: 56px; }
.tb-btn.tb-unit { background: var(--bg-2); border: 1px solid var(--border); color: var(--text); min-width: 56px; text-transform: uppercase; }
.tb-readout { color: var(--muted); font-size: 12px; padding: 0 6px; min-width: 90px; text-align: center; }
.tb-sep { width: 1px; height: 24px; background: var(--border); margin: 0 4px; flex: 0 0 1px; }

/* Drawing preview pill (Section 5) */
.dim-pill.draw-preview {
  background: rgba(37, 99, 235, 0.85);
  color: #fff;
  font-size: 12px; font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--accent);
  box-shadow: 0 4px 14px rgba(0,0,0,0.4);
}

/* Close-Room button (Section 3) */
.close-room-btn {
  position: absolute; z-index: 9;
  width: 56px; height: 56px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: #22c55e;
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  border: 3px solid #fff;
  box-shadow: 0 8px 24px rgba(34, 197, 94, 0.45), 0 0 0 8px rgba(34, 197, 94, 0.18);
  animation: close-pulse 1.2s ease-in-out infinite;
}
@keyframes close-pulse {
  0%, 100% { box-shadow: 0 8px 24px rgba(34, 197, 94, 0.45), 0 0 0 8px rgba(34, 197, 94, 0.18); }
  50%      { box-shadow: 0 8px 24px rgba(34, 197, 94, 0.55), 0 0 0 14px rgba(34, 197, 94, 0.10); }
}

/* Mobile toolbar (Section 6) */
@media (max-width: 768px) {
  .canvas-body { grid-template-columns: 64px 1fr; }
  .toolbar { padding: 6px 4px; }
  .tool { min-height: 52px; font-size: 10px; padding: 6px 2px; }
  .tool .tool-ico { font-size: 22px; }
  .tool.tool-sub { min-height: 38px; font-size: 11px; }
  .canvas-topbar { padding: 0 4px; }
  .tb-btn { padding: 0 8px; font-size: 12px; min-width: 40px; }
  .tb-readout { min-width: 60px; font-size: 11px; }
}

/* Setup wizard — stepper, chip groups, compass rose, numeric stepper. */
.stepper { display: flex; gap: 8px; margin-bottom: 16px; }
.stepper .step { flex: 1; display: flex; align-items: center; gap: 8px; padding: 10px 12px; background: var(--bg-2); border: 1px solid var(--border); border-radius: 8px; color: var(--muted); font-size: 13px; font-weight: 600; }
.stepper .step.active { border-color: var(--accent); color: #fff; }
.stepper .step.done { color: var(--ok); }
.stepper .num { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 50%; background: var(--card); color: #fff; font-size: 12px; }
.stepper .step.active .num { background: var(--accent); }
.stepper .step.done .num { background: var(--ok); }
.stepper .lbl { display: inline; }
@media (max-width: 600px) { .stepper .lbl { display: none; } .stepper .step { justify-content: center; } }

.chip-group { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: var(--bg-2); color: var(--text); border: 1px solid var(--border); border-radius: 999px; padding: 8px 14px; font-size: 13px; font-weight: 600; min-height: 36px; }
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.stepper-num { display: inline-flex; align-items: center; gap: 12px; }
.stepper-num-val { display: inline-flex; align-items: center; justify-content: center; min-width: 56px; padding: 8px 0; background: var(--bg-2); border: 1px solid var(--border); border-radius: 8px; font-weight: 700; font-size: 18px; }

.compass { display: grid; grid-template-columns: repeat(3, 56px); grid-template-rows: repeat(3, 56px); gap: 6px; justify-content: center; align-content: center; padding: 12px; background: var(--bg-2); border: 1px solid var(--border); border-radius: 12px; width: fit-content; }
.compass-btn { background: var(--card); border: 1px solid var(--border); border-radius: 8px; color: var(--muted); font-weight: 700; font-size: 12px; min-height: 44px; min-width: 44px; }
.compass-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.compass-n  { grid-column: 2; grid-row: 1; }
.compass-ne { grid-column: 3; grid-row: 1; }
.compass-e  { grid-column: 3; grid-row: 2; }
.compass-se { grid-column: 3; grid-row: 3; }
.compass-s  { grid-column: 2; grid-row: 3; }
.compass-sw { grid-column: 1; grid-row: 3; }
.compass-w  { grid-column: 1; grid-row: 2; }
.compass-nw { grid-column: 1; grid-row: 1; }

.check-row { display: flex; gap: 8px; align-items: center; cursor: pointer; padding: 8px 0; color: var(--text); }

/* Select-tool action buttons (Edit + Delete) — anchored to selected element. */
.select-action {
  position: absolute; z-index: 8;
  transform: translate(-50%, -50%);
  width: 36px; height: 36px;
  min-width: 44px; min-height: 44px;     /* touch target */
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--card);
  color: #fff;
  font-size: 14px; font-weight: 700;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}
.select-action-delete { background: var(--error); border-color: var(--error); }
.select-action-edit { background: var(--accent); border-color: var(--accent); }

/* Real-time HUD shown while dragging an opening across a wall. */
.drag-hud {
  position: absolute;
  right: 12px; top: 48px;
  z-index: 7;
  background: rgba(0,0,0,0.7);
  border: 1px solid var(--border);
  color: #fff;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 12px; line-height: 1.4;
  min-width: 180px;
  pointer-events: none;
}
.drag-hud .hud-title { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
.drag-hud .hud-line { display: flex; justify-content: space-between; gap: 12px; }
.drag-hud .hud-snapped { color: var(--accent); font-weight: 700; }
.drag-hud .hud-centre { color: #fbbf24; font-weight: 700; }
.konva-wrap { position: absolute; inset: 0; }
.save-pill { position: absolute; top: 12px; right: 12px; background: var(--bg-2); border: 1px solid var(--border); border-radius: 999px; padding: 4px 10px; font-size: 12px; color: var(--muted); }
.save-pill.dirty { color: var(--warn); }
.save-pill.saved { color: var(--ok); }

.canvas-bottombar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px;
  background: var(--card); border-top: 1px solid var(--border);
  font-size: 13px; color: var(--muted);
}
.counts span + span::before { content: ' · '; color: var(--border-2); }

/* Side panel for door/window/dimension input */
.side-panel { position: absolute; right: 12px; top: 60px; bottom: 60px; width: 300px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); overflow-y: auto; z-index: 10; }
.side-panel h4 { margin: 0 0 12px; }
.side-panel .row { display: flex; gap: 8px; margin-bottom: 10px; }
.side-panel .row .field { flex: 1; }
.side-panel .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }

/* --- Review screen -------------------------------------------------- */
.review-floor-block { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.kv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; margin-top: 6px; }
.kv { background: var(--bg-2); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; }
.kv .k { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.4px; }
.kv .v { color: var(--text); font-weight: 600; font-size: 14px; margin-top: 2px; }
.review-floor-block h3 { margin-top: 0; }
.review-plan-img { width: 100%; height: auto; background: #0c0c1a; border-radius: 8px; border: 1px solid var(--border); }
.dim-table { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 14px; }
.dim-table th { text-align: left; padding: 8px 10px; background: var(--bg-2); border-bottom: 1px solid var(--border); }
.dim-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); }
.dim-table tr:nth-child(even) td { background: rgba(255,255,255,0.02); }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin-top: 12px; }
.photo-tile { background: var(--bg-2); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.photo-tile img { width: 100%; height: 140px; object-fit: cover; display: block; }
.photo-tile .cap { padding: 6px 8px; font-size: 12px; color: var(--muted); }
.notes-box { background: var(--bg-2); border: 1px solid var(--border); border-radius: 8px; padding: 12px; margin-top: 12px; white-space: pre-wrap; }

.review-actionbar {
  position: sticky; bottom: 0;
  display: flex; gap: 8px; padding: 12px 16px;
  background: var(--card); border-top: 1px solid var(--border);
  flex-wrap: wrap; justify-content: flex-end;
}

/* --- Utilities ------------------------------------------------------ */
.row { display: flex; gap: 12px; }
.row > * { flex: 1; }
.stack > * + * { margin-top: 12px; }
.muted { color: var(--muted); }
.center { text-align: center; }
.spacer { flex: 1; }
.hidden { display: none !important; }
.tap { -webkit-user-select: none; user-select: none; }
.scroll { overflow-y: auto; -webkit-overflow-scrolling: touch; }

/* --- Mobile tweaks ------------------------------------------------- */
@media (max-width: 600px) {
  .user-chip .email { max-width: 80px; }
  .side-panel { left: 12px; right: 12px; width: auto; }
  .canvas-body { grid-template-columns: 60px 1fr; }
  .tool { min-height: 50px; font-size: 9px; }
}
