/* ==========================================================================
   Agency Virtual Tour Builder — admin.css
   Clean, fast, self-contained. No external fonts (system stack for speed).
   ========================================================================== */

:root {
  --bg:        #f4f5f8;
  --panel:     #ffffff;
  --ink:       #1c2331;
  --ink-soft:  #5a6473;
  --line:      #e3e7ee;
  --line-2:    #d4dae4;
  --brand:     #3b5bdb;
  --brand-ink: #ffffff;
  --brand-50:  #eef2ff;
  --live:      #2f9e44;
  --live-bg:   #e8f6ec;
  --draft:     #b88300;
  --draft-bg:  #fbf3df;
  --danger:    #d6336c;
  --danger-bg: #fdecf2;
  --radius:    12px;
  --radius-sm: 8px;
  --shadow:    0 1px 2px rgba(18,28,45,.06), 0 6px 20px rgba(18,28,45,.06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.55;
  font-size: 15px;
}

h1 { font-size: 1.5rem; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- Top bar --------------------------------------------------------------- */
.topbar {
  display: flex; align-items: center; gap: 20px;
  padding: 0 24px; height: 60px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 30;
}
.brand {
  display: inline-flex; align-items: center; gap: 9px;
  font-weight: 700; color: var(--ink); text-decoration: none; letter-spacing: -.01em;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  display: inline-grid; place-items: center;
  width: 28px; height: 28px; border-radius: 8px;
  background: var(--brand); color: #fff; font-size: 16px; line-height: 1;
}
.topnav { display: flex; gap: 6px; margin-left: 8px; }
.topnav a {
  padding: 7px 12px; border-radius: var(--radius-sm);
  color: var(--ink-soft); font-weight: 500;
}
.topnav a:hover { background: var(--bg); color: var(--ink); text-decoration: none; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.who { color: var(--ink-soft); font-size: .9rem; }

/* --- Layout ---------------------------------------------------------------- */
.wrap { max-width: 960px; margin: 0 auto; padding: 28px 24px 64px; }
.page-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; margin-bottom: 20px; flex-wrap: wrap;
}

/* --- Cards ----------------------------------------------------------------- */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}
.card-title { margin: 0 0 12px; font-size: 1.02rem; }
.divider { height: 1px; background: var(--line); margin: 18px 0; border: 0; }

/* --- Buttons --------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-2); background: #fff; color: var(--ink);
  font: inherit; font-weight: 600; font-size: .92rem; cursor: pointer;
  transition: background .12s, border-color .12s, transform .04s;
  text-decoration: none; line-height: 1.1;
}
.btn:hover { background: var(--bg); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn-primary:hover { background: #314fc4; border-color: #314fc4; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-soft); }
.btn-ghost:hover { background: var(--panel); color: var(--ink); }
.btn-danger { color: var(--danger); border-color: var(--danger-bg); background: var(--danger-bg); }
.btn-danger:hover { background: #fbd9e6; }
.btn-sm { padding: 6px 11px; font-size: .85rem; }
.btn-block { width: 100%; }

/* --- Forms ----------------------------------------------------------------- */
label { display: block; font-size: .85rem; font-weight: 600; color: var(--ink-soft); }
.input {
  display: block; width: 100%; margin-top: 5px;
  padding: 9px 11px; font: inherit; font-size: .95rem; color: var(--ink);
  background: #fff; border: 1px solid var(--line-2); border-radius: var(--radius-sm);
}
.input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-50); }
select.input { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%235a6473' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 32px; }
textarea.input { resize: vertical; }
.mono { font-family: var(--mono); font-size: .85rem; }
.check { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; color: var(--ink); }
.check input { width: 16px; height: 16px; margin: 0; accent-color: var(--brand); }
.checks { display: flex; flex-direction: column; gap: 8px; }

/* --- Flex helpers ---------------------------------------------------------- */
.row { display: flex; align-items: center; gap: 10px; }
.row.gap { gap: 14px; }
.row.between { justify-content: space-between; }
.row.center { align-items: center; }
.row.end { align-items: flex-end; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1 1 200px; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.gap { gap: 14px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* --- Tiles ----------------------------------------------------------------- */
.tile {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px; border: 1px solid var(--line);
  border-radius: var(--radius); background: #fff; color: var(--ink);
}
.tile:hover { border-color: var(--brand); text-decoration: none; box-shadow: var(--shadow); }
.tile > .muted { font-size: .85rem; font-weight: 500; text-align: right; }

/* --- Tables ---------------------------------------------------------------- */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-soft); }
.table tr:last-child td { border-bottom: 0; }
.ta-r { text-align: right; }
.nowrap { white-space: nowrap; }
.link-strong { font-weight: 700; color: var(--ink); }
.link-strong:hover { color: var(--brand); }

/* --- Badges ---------------------------------------------------------------- */
.badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: .74rem; font-weight: 700; letter-spacing: .02em;
}
.badge-live { background: var(--live-bg); color: var(--live); }
.badge-draft { background: var(--draft-bg); color: var(--draft); }
.badge-info { background: #eef2ff; color: #314fc4; }

/* --- Misc text ------------------------------------------------------------- */
.muted { color: var(--ink-soft); }
.small { font-size: .85rem; }
.empty {
  text-align: center; padding: 48px 20px; color: var(--ink-soft);
  background: var(--panel); border: 1px dashed var(--line-2); border-radius: var(--radius);
}

/* --- Flash ----------------------------------------------------------------- */
.flash {
  padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 16px;
  font-size: .92rem; border: 1px solid transparent;
}
.flash-success { background: var(--live-bg); color: #1b6e2d; border-color: #bfe6c8; }
.flash-error { background: var(--danger-bg); color: #a01a4d; border-color: #f3c6d8; }
.flash a { color: inherit; font-weight: 700; text-decoration: underline; }

/* --- Floor / scene rows ---------------------------------------------------- */
.floor-row { display: grid; grid-template-columns: 120px 1fr auto; gap: 18px; align-items: start; }
.floor-thumb {
  width: 120px; height: 90px; border-radius: var(--radius-sm); overflow: hidden;
  background: var(--bg); border: 1px solid var(--line); display: grid; place-items: center;
}
.floor-thumb img { width: 100%; height: 100%; object-fit: cover; }
.noimg { font-size: .78rem; color: var(--ink-soft); }
.floor-form { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.floor-actions { display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.reorder { display: flex; gap: 6px; }
.reorder form { margin: 0; }

/* --- Structure list (project edit) ----------------------------------------- */
.structure { display: flex; flex-direction: column; gap: 14px; }
.struct-floor { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; }
.struct-floor-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 8px; }
.struct-scenes { display: flex; flex-direction: column; gap: 6px; }
.struct-scene { display: flex; align-items: center; gap: 10px; font-size: .9rem; color: var(--ink-soft); }

/* --- Copy fields ----------------------------------------------------------- */
.copyfield { display: flex; gap: 8px; align-items: stretch; }
.copyfield .input { margin-top: 0; }
.copyfield .btn { white-space: nowrap; }

/* --- Auth / install -------------------------------------------------------- */
.auth-body { display: grid; place-items: center; min-height: 100vh; background: linear-gradient(160deg, #eef1f8, #f6f7fb); }
.auth-card {
  width: 100%; max-width: 400px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 16px; padding: 32px;
  box-shadow: var(--shadow);
}
.auth-title { text-align: center; margin: 0 0 4px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.checklist { list-style: none; margin: 0 0 18px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.checklist li { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: var(--radius-sm); font-size: .92rem; }
.checklist li::before { font-weight: 700; }
.checklist .ok { background: var(--live-bg); color: #1b6e2d; }
.checklist .ok::before { content: "✓"; }
.checklist .bad { background: var(--danger-bg); color: #a01a4d; }
.checklist .bad::before { content: "✕"; }
.checklist .info { background: #eef2ff; color: #314fc4; }
.checklist .info::before { content: "i"; display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; background: #314fc4; color: #fff; font-size: .7rem; }

/* --- Editors (pins / hotspots) --------------------------------------------- */
.editor-grid { display: grid; grid-template-columns: 1fr 320px; gap: 20px; align-items: start; }
.editor-stage { min-width: 0; }
.editor-side { border-left: 1px solid var(--line); padding-left: 20px; }

.floorplan-edit {
  position: relative; display: inline-block; max-width: 100%;
  border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden;
  background: var(--bg); cursor: crosshair; user-select: none;
}
.floorplan-edit img { display: block; max-width: 100%; height: auto; }
.hs-pano { width: 100%; aspect-ratio: 16 / 9; border-radius: var(--radius-sm); overflow: hidden; background: #11151c; }

/* AI hotspot suggestions (in the 360 view) */
.pin-row.is-moving { outline: 2px solid var(--brand); outline-offset: 1px; }
.hs-suggest.pnlm-hotspot { height: auto; width: auto; }
.hs-suggest-tip {
  background: #fff8e1; border: 1px solid #ffe066; border-radius: 8px;
  padding: 7px 9px; box-shadow: 0 4px 14px rgba(0,0,0,.3);
  transform: translate(-50%, -115%); cursor: default; min-width: 130px;
}
.hs-suggest-tip::after {
  content: ""; position: absolute; left: 50%; bottom: -7px; transform: translateX(-50%);
  border: 7px solid transparent; border-top-color: #ffe066; border-bottom: 0;
}
.hs-suggest-name { font-size: .8rem; font-weight: 700; color: #7a5c00; }
.hs-suggest-reason { font-size: .7rem; color: #8a6d00; margin-top: 2px; max-width: 200px; }
.hs-suggest-actions { display: flex; gap: 5px; margin-top: 6px; }
.hs-suggest-actions .hs-ok { background: var(--live-bg); color: #1b6e2d; }
.hs-suggest-actions .hs-no { background: var(--danger-bg); color: #a01a4d; }

/* pin markers (editor) — zero-size wrapper at (x%,y%); only .pin-aim rotates */
.pins { position: absolute; inset: 0; pointer-events: none; }
.pin {
  position: absolute; width: 0; height: 0;
  transform: translate(-50%, -50%);
  pointer-events: none; --pin: var(--brand);
}
.pin .pin-dot {
  position: absolute; left: 0; top: 0;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--pin); border: 3px solid #fff; box-shadow: 0 1px 5px rgba(0,0,0,.4);
  transform: translate(-50%, -50%); z-index: 4;
  pointer-events: auto; cursor: grab;
}
.pin .pin-dot.dragging { cursor: grabbing; }
.pin.is-active { --pin: #d6336c; z-index: 6; }
.pin .pin-tag {
  position: absolute; left: 0; top: 0;
  transform: translate(-50%, calc(-100% - 16px));
  white-space: nowrap; font-size: .72rem; font-weight: 600;
  background: rgba(28,35,49,.92); color: #fff; padding: 2px 7px; border-radius: 5px;
  pointer-events: none; opacity: 0; transition: opacity .12s; z-index: 5;
}
.pin:hover .pin-tag, .pin.is-active .pin-tag { opacity: 1; }

/* viewing-direction cone + rotate handle (editor: always shown) */
.pin-aim {
  position: absolute; left: 0; top: 0; width: 0; height: 0;
  transform-origin: 0 0; transform: rotate(var(--ang, 0deg));
  pointer-events: none; z-index: 1;
}
.pin-cone {
  position: absolute; left: 0; top: 0;
  width: 70px; height: 64px;
  transform: translate(-50%, -100%);
  background: linear-gradient(to top, rgba(59,91,219,.42), rgba(59,91,219,0));
  clip-path: polygon(50% 100%, 14% 0, 86% 0);
  pointer-events: none;
}
.pin.is-active .pin-cone { background: linear-gradient(to top, rgba(214,51,108,.45), rgba(214,51,108,0)); }
.pin-rot {
  position: absolute; left: 0; top: 0;
  width: 20px; height: 20px; border-radius: 50%;
  background: #fff; border: 3px solid var(--brand); box-shadow: 0 1px 4px rgba(0,0,0,.35);
  transform: translate(-50%, -50%) translateY(-58px);
  pointer-events: auto; cursor: grab; z-index: 3;
}
.pin-rot:hover { background: var(--brand-50); }
.pin.is-active .pin-rot { border-color: var(--danger); }

.pin-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.pin-row { display: flex; flex-direction: column; gap: 6px; padding: 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.pin-row.is-active { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-50); }
.pin-row .input { margin-top: 0; }
.dir-control { display: flex; align-items: center; gap: 6px; }
.dir-label { font-size: .78rem; font-weight: 600; color: var(--ink-soft); margin-right: auto; }
.dir-deg { width: 64px; text-align: center; padding: 5px 6px !important; }
.dir-control .btn { padding: 4px 9px; font-size: 1rem; line-height: 1; }

/* --- Settings preview ------------------------------------------------------ */
.brand-preview { display: inline-flex; align-items: center; gap: 6px; padding: 10px 16px; background: #11151c; color: #fff; border-radius: 999px; font-size: .9rem; }
.brand-preview strong { font-weight: 700; }

.adminfoot { text-align: center; color: var(--ink-soft); font-size: .82rem; padding: 24px; }

/* --- Set point-of-view page ------------------------------------------------ */
.povwrap { position: relative; }
.pov-reticle { position: absolute; inset: 0; pointer-events: none; display: grid; place-items: center; }
.pov-reticle::before, .pov-reticle::after {
  content: ""; position: absolute; background: rgba(255,255,255,.9);
  box-shadow: 0 0 0 1px rgba(0,0,0,.4);
}
.pov-reticle::before { width: 2px; height: 34px; }
.pov-reticle::after  { width: 34px; height: 2px; }
.pov-readout { white-space: nowrap; }

/* --- Hotspot style chooser (project edit) ---------------------------------- */
.hs-style { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; margin: 4px 0 14px; }
.hs-style legend { font-size: .85rem; font-weight: 700; padding: 0 6px; color: var(--ink); }
.hs-style-opt { display: block; cursor: pointer; margin: 6px 0; }
.hs-style-opt > input { position: absolute; opacity: 0; }
.hs-style-card {
  display: flex; align-items: center; gap: 12px; padding: 10px;
  border: 1.5px solid var(--line); border-radius: var(--radius-sm); background: var(--card);
  transition: border-color .12s, background .12s;
}
.hs-style-opt > input:checked + .hs-style-card { border-color: var(--brand); background: rgba(59,91,219,.06); }
.hs-style-opt > input:focus-visible + .hs-style-card { outline: 2px solid var(--brand); outline-offset: 2px; }
.hs-style-demo {
  flex: 0 0 84px; height: 56px; border-radius: 8px; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #2b2f3a, #4a4030); /* mimics a dim room floor */
  overflow: visible;
}
.hs-style-text { font-size: .82rem; color: var(--muted); line-height: 1.35; }
.hs-style-text strong { color: var(--ink); }
/* floor-pin demo */
.hs-demo-floor {
  position: relative; width: 26px; height: 26px; border-radius: 50%; border: 2px solid #fff;
  background: radial-gradient(circle at 50% 38%, rgba(255,255,255,.96), rgba(96,150,255,.9) 70%, rgba(64,110,230,.92));
  box-shadow: 0 2px 6px rgba(0,0,0,.5);
}
.hs-demo-floor::after {
  content: ""; position: absolute; left: 50%; top: 46%; width: 7px; height: 7px;
  border-right: 2px solid #2c4ea8; border-bottom: 2px solid #2c4ea8;
  transform: translate(-50%, -50%) rotate(45deg);
}
/* tooltip-marker demo: the real Pannellum default scene-hotspot sprite + hover-label bubble */
.hs-demo-marker {
  position: relative; width: 26px; height: 26px;
  background-image: url('data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2226%22%20height%3D%22208%22%3E%0A%3Ccircle%20fill-opacity%3D%22.78%22%20cy%3D%22117%22%20cx%3D%2213%22%20r%3D%2211%22%20fill%3D%22%23fff%22%2F%3E%0A%3Ccircle%20fill-opacity%3D%22.78%22%20cy%3D%22143%22%20cx%3D%2213%22%20r%3D%2211%22%20fill%3D%22%23fff%22%2F%3E%0A%3Ccircle%20cy%3D%22169%22%20cx%3D%2213%22%20r%3D%227%22%20fill%3D%22none%22%20stroke%3D%22%23000%22%20stroke-width%3D%222%22%2F%3E%0A%3Ccircle%20cy%3D%22195%22%20cx%3D%2213%22%20r%3D%227%22%20fill%3D%22none%22%20stroke%3D%22%23000%22%20stroke-width%3D%222%22%2F%3E%0A%3Ccircle%20cx%3D%2213%22%20cy%3D%22195%22%20r%3D%222.5%22%2F%3E%0A%3Cpath%20d%3D%22m5%2083v6h2v-4h4v-2zm10%200v2h4v4h2v-6zm-5%205v6h6v-6zm-5%205v6h6v-2h-4v-4zm14%200v4h-4v2h6v-6z%22%2F%3E%0A%3Cpath%20d%3D%22m13%20110a7%207%200%200%200%20-7%207%207%207%200%200%200%207%207%207%207%200%200%200%207%20-7%207%207%200%200%200%20-7%20-7zm-1%203h2v2h-2zm0%203h2v5h-2z%22%2F%3E%0A%3Cpath%20d%3D%22m5%2057v6h2v-4h4v-2zm10%200v2h4v4h2v-6zm-10%2010v6h6v-2h-4v-4zm14%200v4h-4v2h6v-6z%22%2F%3E%0A%3Cpath%20d%3D%22m17%2038v2h-8v-2z%22%2F%3E%0A%3Cpath%20d%3D%22m12%209v3h-3v2h3v3h2v-3h3v-2h-3v-3z%22%2F%3E%0A%3Cpath%20d%3D%22m13%20136-6.125%206.125h4.375v7.875h3.5v-7.875h4.375z%22%2F%3E%0A%3Cpath%20d%3D%22m10.428%20173.33v-5.77l5-2.89v5.77zm1-1.73%203-1.73-3.001-1.74z%22%2F%3E%0A%3C%2Fsvg%3E%0A');
  background-repeat: no-repeat; background-position: 0 -130px; background-size: 26px 208px;
}
.hs-demo-tip {
  position: absolute; left: 50%; bottom: 28px; transform: translateX(-50%);
  background: rgba(0,0,0,.78); color: #fff; font-size: .62rem; font-weight: 700;
  padding: 3px 7px; border-radius: 4px; white-space: nowrap;
}
.hs-demo-tip::after {
  content: ""; position: absolute; left: 50%; bottom: -5px; transform: translateX(-50%);
  border: 5px solid transparent; border-top-color: rgba(0,0,0,.78); border-bottom: 0;
}

/* --- Toasts (bottom-right) -------------------------------------------------- */
.toast-wrap {
  position: fixed; right: 18px; bottom: 18px; z-index: 200;
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.toast {
  pointer-events: auto; min-width: 200px; max-width: 340px;
  padding: 11px 14px; border-radius: 10px; font-size: .9rem; font-weight: 600;
  color: #fff; background: #1c2331; box-shadow: 0 8px 24px rgba(0,0,0,.22);
  opacity: 0; transform: translateY(8px); transition: opacity .18s, transform .18s;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.ok { background: #1b7a3d; }
.toast.bad { background: #b02a4f; }

/* --- Bulk scene upload ----------------------------------------------------- */
.bulk-zone {
  border: 2px dashed var(--line); border-radius: var(--radius-sm);
  background: var(--bg); padding: 26px; text-align: center; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.bulk-zone:hover { border-color: var(--brand); }
.bulk-zone.drag { border-color: var(--brand); background: var(--brand-50); }
.bulk-zone-inner { display: flex; flex-direction: column; gap: 4px; pointer-events: none; }
.bulk-zone-inner .linklike { pointer-events: auto; }
.linklike { background: none; border: 0; padding: 0; color: var(--brand); cursor: pointer; text-decoration: underline; font: inherit; }
.bulk-list { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.bulk-row {
  display: flex; justify-content: space-between; gap: 12px; align-items: center;
  padding: 7px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  font-size: .86rem; background: var(--card, #fff);
}
.bulk-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bulk-status { white-space: nowrap; color: var(--ink-soft); }
.bulk-status.working { color: #314fc4; }
.bulk-status.ok { color: #1b6e2d; }
.bulk-status.bad { color: #a01a4d; }

/* --- Tour map editor ------------------------------------------------------- */
.tourmap-edit {
  position: relative; width: 100%; height: 460px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background:
    linear-gradient(var(--line) 1px, transparent 1px) 0 0 / 28px 28px,
    linear-gradient(90deg, var(--line) 1px, transparent 1px) 0 0 / 28px 28px,
    var(--bg);
  overflow: hidden; touch-action: none;
}
.tm-edges { position: absolute; inset: 0; width: 100%; height: 100%; }
.tourmap-edit .tm-edge { stroke: rgba(59,91,219,.5); stroke-width: .5; }
.tm-nodes { position: absolute; inset: 0; }
.tm-bubble {
  position: absolute; transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  cursor: grab; user-select: none;
}
.tm-bubble.dragging { cursor: grabbing; z-index: 5; }
.tm-bubble-dot {
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--brand); border: 3px solid #fff; box-shadow: 0 1px 5px rgba(0,0,0,.3);
}
.tm-bubble-label {
  font-size: .74rem; font-weight: 600; color: var(--ink);
  background: #fff; border: 1px solid var(--line); padding: 1px 7px; border-radius: 5px;
  white-space: nowrap; box-shadow: 0 1px 3px rgba(0,0,0,.08);
}

/* --- Floor zones + AI pin suggestions -------------------------------------- */
.floorplan-edit.zones-mode { cursor: crosshair; }
.zones { position: absolute; inset: 0; pointer-events: none; }
.zone {
  position: absolute; box-sizing: border-box;
  border: 2px dashed rgba(59,91,219,.7); background: rgba(59,91,219,.07);
  border-radius: 6px; pointer-events: none;
}
.zone.drawing { background: rgba(59,91,219,.16); }
.zone-label {
  position: absolute; left: 5px; top: 4px; font-size: .68rem; font-weight: 700;
  color: #2c3a8c; background: rgba(255,255,255,.85); padding: 1px 6px; border-radius: 4px;
}
.suggestions { position: absolute; inset: 0; pointer-events: none; }
.suggest-pin { position: absolute; width: 0; height: 0; pointer-events: none; z-index: 7; }
.suggest-pin .sp-dot {
  position: absolute; left: 0; top: 0; transform: translate(-50%, -50%);
  width: 18px; height: 18px; border-radius: 50%;
  background: #ffd43b; border: 2px dashed #b8860b; box-shadow: 0 1px 4px rgba(0,0,0,.35);
  pointer-events: auto; cursor: move;
}
.suggest-pin .sp-label {
  position: absolute; left: 0; top: 0; transform: translate(-50%, calc(-100% - 16px));
  white-space: nowrap; font-size: .68rem; font-weight: 700;
  background: #fff3bf; color: #8a6d00; border: 1px solid #ffe066;
  padding: 2px 7px; border-radius: 5px; pointer-events: none;
}
.suggest-pin .sp-actions {
  position: absolute; left: 0; top: 0; transform: translate(-50%, 14px);
  display: flex; gap: 4px; pointer-events: auto;
}
.suggest-pin .sp-actions .btn { padding: 1px 8px; line-height: 1.5; }
.suggest-pin .sp-ok { background: var(--live-bg); color: #1b6e2d; }
.suggest-pin .sp-no { background: var(--danger-bg); color: #a01a4d; }

/* --- Privacy blur editor --------------------------------------------------- */
.blur-stage {
  position: relative; display: inline-block; max-width: 100%;
  border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden;
  background: var(--bg); user-select: none;
}
.blur-stage.drawing-mode { cursor: crosshair; }
.blur-stage img { display: block; max-width: 100%; height: auto; }
.blur-regions { position: absolute; inset: 0; }
.blur-region {
  position: absolute; box-sizing: border-box;
  border: 2px solid rgba(59,91,219,.9); background: rgba(59,91,219,.08);
  cursor: move; touch-action: none;
}
.blur-region.ellipse { border-radius: 50%; }
.blur-region.ai { border-color: rgba(214,51,108,.9); }
.blur-region.inactive { border-style: dashed; opacity: .45; backdrop-filter: none !important; -webkit-backdrop-filter: none !important; }
.blur-region.selected { outline: 2px solid #fff; box-shadow: 0 0 0 3px rgba(59,91,219,.5); }
.blur-region.hover { box-shadow: 0 0 0 3px rgba(59,91,219,.35); }
.blur-region.drawing { pointer-events: none; background: rgba(59,91,219,.18); }
.br-resize {
  position: absolute; right: -7px; bottom: -7px; width: 14px; height: 14px;
  background: #fff; border: 2px solid var(--brand); border-radius: 50%;
  cursor: nwse-resize; touch-action: none;
}
.region-name { font-size: .82rem; font-weight: 600; }

/* --- Calibration page ------------------------------------------------------ */
.calib-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.calib-pane { min-width: 0; }
.calib-pane .floorplan-edit { width: 100%; cursor: default; }
.calib-pane .floorplan-edit img { width: 100%; }
@media (max-width: 760px) { .calib-grid { grid-template-columns: 1fr; } }

/* --- Advanced (collapsible) ------------------------------------------------ */
.advanced { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 0 12px; }
.advanced summary { cursor: pointer; padding: 10px 0; font-size: .85rem; font-weight: 600; color: var(--ink-soft); list-style-position: inside; }
.advanced summary:hover { color: var(--ink); }
.advanced[open] summary { border-bottom: 1px solid var(--line); margin-bottom: 10px; }
.advanced .row label { flex: 1 1 90px; }
.advanced p { padding-bottom: 10px; }

/* --- Responsive ------------------------------------------------------------ */
@media (max-width: 760px) {
  .floor-row { grid-template-columns: 1fr; }
  .floor-thumb { width: 100%; height: 160px; }
  .floor-actions { flex-direction: row; align-items: center; justify-content: space-between; }
  .editor-grid { grid-template-columns: 1fr; }
  .editor-side { border-left: 0; padding-left: 0; border-top: 1px solid var(--line); padding-top: 18px; }
  .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  /* Tighter chrome */
  .topbar { padding: 0 14px; gap: 8px; height: 56px; }
  .topnav { margin-left: 0; gap: 2px; }
  .topnav a { padding: 6px 9px; }
  .who { display: none; }
  .brand span:last-child { font-size: 1rem; }
  .wrap { padding: 18px 14px 56px; }
  .card { padding: 16px; }
  .page-head { gap: 10px; }
  .page-head h1 { font-size: 1.3rem; }
  .page-head .btn { flex: 0 0 auto; }

  /* Forms: stack the inline rows */
  .row.gap.wrap.end { gap: 12px; }

  /* Copy fields stack so the button isn't squeezed */
  .copyfield { flex-wrap: wrap; }
  .copyfield .input { flex: 1 1 100%; }

  /* Project list table -> stacked cards */
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table thead { display: none; }
  .table tr {
    border: 1px solid var(--line); border-radius: var(--radius-sm);
    padding: 12px 14px; margin-bottom: 12px;
  }
  .table tr:last-child td { border-bottom: 0; }
  .table td { border: 0; padding: 5px 0; display: flex; align-items: center; justify-content: space-between; gap: 14px; }
  .table td[data-label]::before {
    content: attr(data-label); font-weight: 600; color: var(--ink-soft);
    font-size: .82rem; flex: 0 0 auto;
  }
  .table td.cell-main { display: block; padding-bottom: 10px; margin-bottom: 6px; border-bottom: 1px solid var(--line); }
  .table td.cell-main .link-strong { font-size: 1.05rem; }
  .table td.cell-actions {
    display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
    margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line);
    white-space: normal; text-align: center;
  }
  .table td.cell-actions .btn { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
