/* =========================================================================
   Portrait Point Cloud Portal - stylesheet
   Brand: navy #253c58, amber #ffbf00, deep dark #0b1221
   ========================================================================= */

:root {
  --navy:        #253c58;
  --navy-2:      #1d3047;
  --navy-3:      #152236;
  --amber:       #ffbf00;
  --amber-soft:  #ffdf80;
  --amber-bg:    #fff7db;
  --dark:        #0b1221;
  --text:        #1f2733;
  --text-muted:  #5d6a7e;
  --text-soft:   #8693a6;
  --surface:     #ffffff;
  --surface-alt: #f6f8fb;
  --surface-2:   #eef2f8;
  --border:      #dde4ef;
  --border-strong:#c1cbd9;
  --danger:      #b33131;
  --danger-bg:   #fdecec;
  --success:     #1f7a4c;
  --success-bg:  #e7f7ee;
  --warn:        #a55a00;
  --warn-bg:     #fff3db;

  --shadow-xs: 0 1px 2px rgba(18, 32, 53, 0.06);
  --shadow-sm: 0 1px 3px rgba(18, 32, 53, 0.08), 0 1px 2px rgba(18, 32, 53, 0.04);
  --shadow-md: 0 4px 10px rgba(18, 32, 53, 0.08), 0 2px 4px rgba(18, 32, 53, 0.04);
  --shadow-lg: 0 12px 32px rgba(18, 32, 53, 0.12);

  --radius-sm: 4px;
  --radius:    6px;
  --radius-lg: 10px;

  --font-sans: "Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue",
               Arial, "Noto Sans", sans-serif;
  --font-mono: "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--surface-alt);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--navy); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0 0 0.5em; color: var(--navy); font-weight: 600; }
h1 { font-size: 1.75rem; letter-spacing: -0.01em; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
h4 { font-size: 0.9rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); }

p { margin: 0 0 0.75em; }

code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--surface-2);
  padding: 1px 5px;
  border-radius: 3px;
  color: var(--navy);
}

small, .small { font-size: 0.85em; }
.muted { color: var(--text-muted); }
.hint { display: block; color: var(--text-muted); font-size: 0.82rem; margin-top: 4px; }
.hidden { display: none !important; }
.block { display: block; }
.link { color: var(--navy); font-size: 0.88rem; }

/* ---------- Top bar ---------- */
.topbar {
  background: var(--navy);
  border-bottom: 3px solid var(--amber);
  color: #fff;
}
.topbar-inner {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 12px 24px;
}
.brand { display: flex; align-items: center; gap: 14px; color: #fff; }
.brand:hover { text-decoration: none; }
.brand-mark {
  height: 30px;
  width: auto;
  display: block;
}
.brand-divider {
  width: 1px;
  height: 28px;
  background: rgba(255, 255, 255, 0.18);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-title { font-size: 0.98rem; font-weight: 600; }
.brand-sub {
  font-size: 0.72rem; color: var(--amber);
  letter-spacing: 0.06em; text-transform: uppercase; margin-top: 2px;
}

.top-nav { display: flex; gap: 4px; margin-left: 12px; }
.nav-link {
  color: rgba(255, 255, 255, 0.82);
  padding: 8px 14px;
  border-radius: var(--radius);
  font-size: 0.92rem;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}
.nav-link:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff; text-decoration: none;
}
.nav-link.active {
  background: rgba(255, 191, 0, 0.15);
  color: var(--amber);
}

.top-user { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.user-chip { display: flex; flex-direction: column; text-align: right; line-height: 1.15; }
.user-chip-role {
  font-size: 0.7rem; color: var(--amber);
  letter-spacing: 0.08em; text-transform: uppercase;
}
.user-chip-name { font-size: 0.88rem; color: #fff; }

/* ---------- Main + footer ---------- */
.main { max-width: 1280px; margin: 0 auto; padding: 28px 24px 48px; }
.main-public { max-width: 100%; padding: 0; min-height: 100vh; }

/* ---------- Page header + breadcrumbs ---------- */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}
.page-header h1 { margin-bottom: 2px; }
.page-header p.muted { margin: 0; }
.page-header-actions { display: flex; gap: 8px; flex-shrink: 0; }

.breadcrumbs { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 10px; }
.breadcrumbs a { color: var(--text-muted); }
.breadcrumbs a:hover { color: var(--navy); }
.breadcrumbs span { color: var(--text); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1.2;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-primary { background: var(--navy); color: #fff; border-color: var(--navy); }
.btn-primary:hover { background: var(--navy-2); border-color: var(--navy-2); color: #fff; }

.btn-secondary { background: #fff; color: var(--navy); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-alt); border-color: var(--navy); }

.btn-ghost { background: transparent; color: var(--navy); border-color: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.topbar .btn-ghost { color: rgba(255, 255, 255, 0.85); }
.topbar .btn-ghost:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }

.btn-danger { background: #fff; color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }

.btn-sm { padding: 5px 10px; font-size: 0.82rem; }
.btn-xs { padding: 3px 8px; font-size: 0.75rem; }
.btn-block { width: 100%; }

.btn.is-active {
  background: var(--amber); color: var(--navy); border-color: var(--amber);
}

.danger-link { color: var(--danger) !important; }
.danger-link:hover { background: var(--danger-bg); }

.btn-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 8px; }
.btn-row-tight { gap: 4px; margin: 0; }
.inline-form { display: inline-flex; gap: 6px; }

/* ---------- Panels ---------- */
.panel {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
}
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 14px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.panel-header h2 { margin: 0; }

.stack-panels > .panel { margin-bottom: 16px; }
.stack-panels > .panel:last-child { margin-bottom: 0; }

.notice {
  background: var(--amber-bg);
  border-left: 3px solid var(--amber);
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 0.92rem;
}

.empty { color: var(--text-muted); font-style: italic; margin: 0; padding: 8px 0; }

/* ---------- Stat cards ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.stat-card {
  background: #fff;
  border: 1px solid var(--border);
  border-left: 3px solid var(--amber);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  box-shadow: var(--shadow-xs);
}
.stat-label {
  font-size: 0.75rem; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--text-muted); margin-bottom: 6px;
}
.stat-value {
  font-size: 1.85rem; font-weight: 600;
  color: var(--navy); line-height: 1.1;
}
.stat-value:empty::after { content: "0"; color: var(--text-soft); }

/* ---------- Grids ---------- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-sidebar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 16px;
  align-items: start;
}
@media (max-width: 900px) {
  .grid-2, .grid-sidebar { grid-template-columns: 1fr; }
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}

.property-card {
  display: block;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  color: var(--text);
  transition: box-shadow 0.15s, border-color 0.15s;
}
.property-card:hover {
  text-decoration: none;
  border-color: var(--navy);
  box-shadow: var(--shadow-md);
}
.property-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 6px;
}
.property-card-head strong { color: var(--navy); font-size: 1rem; }
.property-card p { margin: 0 0 10px; font-size: 0.88rem; }
.property-card-foot {
  font-size: 0.82rem; color: var(--text-muted);
  padding-top: 8px; border-top: 1px solid var(--border);
}

/* ---------- Tables ---------- */
.table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.table thead th {
  text-align: left;
  background: var(--surface-alt);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
}
.table tbody td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-alt); }
.row-actions { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }

/* ---------- Forms ---------- */
.stack { display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field > span { font-size: 0.82rem; font-weight: 500; color: var(--text); }

input[type="text"], input[type="email"], input[type="password"],
input[type="search"], input[type="datetime-local"], input:not([type]),
textarea, select {
  font-family: inherit;
  font-size: 0.92rem;
  padding: 9px 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(37, 60, 88, 0.15);
}
input[type="file"] { padding: 6px; background: var(--surface-alt); }
input[type="range"] { padding: 0; }
textarea { resize: vertical; min-height: 64px; }

.narrow-form { max-width: 520px; }

.search-form {
  display: flex;
  gap: 6px;
  align-items: center;
  flex: 1;
  max-width: 420px;
  margin-left: auto;
}
.search-form input { flex: 1; min-width: 0; width: auto; }

/* ---------- Flash ---------- */
.flash {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  margin-bottom: 18px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  border-left: 3px solid;
  animation: flash-in 0.2s ease-out;
}
@keyframes flash-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.flash-fade { opacity: 0; transition: opacity 0.6s; }
.flash-success { background: var(--success-bg); color: var(--success); border-color: var(--success); }
.flash-error   { background: var(--danger-bg);  color: var(--danger);  border-color: var(--danger); }
.flash-info    { background: var(--surface-2);  color: var(--navy);    border-color: var(--navy); }
.flash-warning { background: var(--warn-bg);    color: var(--warn);    border-color: var(--warn); }

.flash-close {
  background: none; border: 0; font-size: 1.2rem;
  cursor: pointer; color: inherit; opacity: 0.6; line-height: 1; padding: 0 4px;
}
.flash-close:hover { opacity: 1; }

/* On viewer pages, flash messages must not push content down because
   the viewer-layout is sized to fill the available height exactly. Float
   the flash over the breadcrumbs instead. */
body.page-viewer .flash {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  margin: 0;
  max-width: 600px;
  width: calc(100% - 40px);
}

/* ---------- Badges + pills ---------- */
.badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.badge-ready      { background: var(--success-bg); color: var(--success); border-color: rgba(31, 122, 76, 0.25); }
.badge-processing { background: var(--warn-bg);    color: var(--warn);    border-color: rgba(165, 90, 0, 0.25); }
.badge-failed     { background: var(--danger-bg);  color: var(--danger);  border-color: rgba(179, 49, 49, 0.25); }
.badge-pending    { background: var(--surface-2);  color: var(--text-muted); }

.pill {
  display: inline-block;
  padding: 2px 8px;
  background: var(--amber-bg);
  color: var(--warn);
  font-size: 0.74rem;
  font-weight: 600;
  border-radius: 10px;
}
.pill-dark { background: var(--navy); color: #fff; }

/* ---------- Copy-to-clipboard code ---------- */
.copy-code {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  padding: 4px 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--navy);
  cursor: pointer;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.copy-code:hover { background: #fff; border-color: var(--navy); }
.copy-code.block {
  display: block;
  margin: 6px 0;
  padding: 8px 10px;
  overflow-x: auto;
}
.copy-code.copied {
  background: var(--success-bg);
  color: var(--success);
  border-color: var(--success);
  text-align: center;
}

/* ---------- Share list ---------- */
.share-list { list-style: none; padding: 0; margin: 0; }
.share-list li { padding: 14px 0; border-bottom: 1px solid var(--border); }
.share-list li:last-child { border-bottom: 0; }
.share-list.compact li { padding: 8px 0; }
.share-item .share-head { display: flex; flex-direction: column; gap: 2px; margin-bottom: 8px; }
.share-title-line { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.share-title { font-weight: 500; color: var(--navy); }
.share-meta { line-height: 1.4; }
.share-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.share-edit-form { margin-top: 12px; padding: 12px; background: rgba(0,0,0,0.025); border: 1px solid var(--border); border-radius: 4px; display: flex; flex-direction: column; gap: 10px; }
.share-edit-form.hidden { display: none; }
.share-edit-form .field { margin: 0; }
.share-edit-form .checkbox-field { display: flex; align-items: center; gap: 8px; font-size: 0.9em; color: var(--text-muted); }
.share-create-form .field-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
@media (max-width: 720px) { .share-create-form .field-row { grid-template-columns: 1fr; } }
/* Status badges */
.badge-share-active   { background: #d4edda; color: #155724; border-color: #c3e6cb; }
.badge-share-revoked  { background: #f8d7da; color: #721c24; border-color: #f5c6cb; }
.badge-share-expired  { background: #e2e3e5; color: #383d41; border-color: #d6d8db; }
.badge-share-exhausted { background: #fff3cd; color: #856404; border-color: #ffeeba; }
/* Dim revoked/expired rows so attention goes to active ones */
.share-item[data-share-status="revoked"],
.share-item[data-share-status="expired"],
.share-item[data-share-status="exhausted"] { opacity: 0.7; }
.viewer-sidebar .share-list li { border-color: rgba(255, 255, 255, 0.08); }
.viewer-sidebar .share-title { color: #fff; }
.viewer-sidebar .share-meta { color: rgba(255,255,255,0.65); }
.viewer-sidebar .share-edit-form { background: rgba(255,255,255,0.04); border-color: rgba(255,255,255,0.1); }

/* ---------- Upload progress ---------- */
.upload-progress {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-top: 4px;
}
.upload-progress-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 8px;
}
.upload-progress-filename {
  font-weight: 500;
  color: var(--navy);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 70%;
}
.upload-progress-percent {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--navy);
}
.upload-progress-track {
  background: var(--surface-2);
  border-radius: 100px;
  height: 10px;
  overflow: hidden;
  margin-bottom: 8px;
}
.upload-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--navy), var(--amber));
  border-radius: 100px;
  transition: width 0.25s ease;
}
.upload-progress-stats {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  flex-wrap: wrap;
}
.upload-progress-status {
  margin-top: 6px;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.upload-progress-status.is-error   { color: var(--danger); }
.upload-progress-status.is-success { color: var(--success); }

/* ---------- Login page ---------- */
.page-login { background: var(--dark); }
.page-login > main.main,
.page-login .main { max-width: 100%; padding: 0; min-height: 100vh; }

.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  background: linear-gradient(160deg, var(--navy) 0%, var(--dark) 100%);
  position: relative;
}
.login-shell::after {
  content: "";
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 4px;
  background: var(--amber);
}

.login-inner {
  width: 100%;
  max-width: 420px;
  text-align: center;
}

.login-logo {
  width: 220px;
  max-width: 80%;
  height: auto;
  margin: 0 auto 28px;
  display: block;
}
.login-heading {
  color: #fff;
  font-size: 1.75rem;
  margin-bottom: 10px;
  letter-spacing: -0.01em;
}
.login-strapline {
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.98rem;
  line-height: 1.55;
  margin: 0 auto 32px;
  max-width: 380px;
}

.login-card {
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 32px;
  text-align: left;
}
.login-card h2 { margin-bottom: 4px; font-size: 1.25rem; }
.login-card .muted { margin-bottom: 20px; font-size: 0.9rem; }
.login-card .btn-block { margin-top: 6px; }

.login-footnote {
  margin-top: 24px;
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.5);
  text-align: center;
}

@media (max-width: 500px) {
  .login-shell { padding: 32px 16px; }
  .login-card { padding: 24px; }
  .login-heading { font-size: 1.45rem; }
}

/* ---------- Public gate + public view ---------- */
.page-public-gate { background: var(--dark); }
.page-public-gate .main { padding: 0; min-height: 100vh; max-width: 100%; }
.gate-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  background: linear-gradient(160deg, var(--navy) 0%, var(--dark) 100%);
}
.gate-card {
  background: #fff;
  padding: 36px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 420px;
}
.gate-card h1 { font-size: 1.5rem; margin-bottom: 4px; }
.gate-card .muted { margin-bottom: 24px; font-size: 0.9rem; }
.gate-logo { max-width: 180px; height: auto; margin: 0 auto 24px; display: block; }

.public-head { display: flex; align-items: center; gap: 20px; margin-bottom: 24px; }
.public-mark {
  height: 42px;
  width: auto;
  display: block;
}
.public-head h1 { margin-bottom: 2px; }
.public-footnote { margin-top: 24px; font-size: 0.85rem; color: var(--text-muted); }

/* ---------- Error pages ---------- */
.error-card {
  max-width: 480px;
  margin: 48px auto;
  text-align: center;
  padding: 32px;
}
.error-code {
  font-size: 5rem; font-weight: 700;
  color: var(--amber); line-height: 1;
  margin-bottom: 8px; letter-spacing: -0.03em;
}
.error-card h1 { margin-bottom: 10px; }

/* ---------- 3D viewer ---------- */
.page-viewer { background: var(--dark); }
.page-viewer .main {
  max-width: 100%;
  padding: 0;
  min-height: calc(100vh - 58px);
  color: #fff;
}
.page-viewer .breadcrumbs {
  color: rgba(255, 255, 255, 0.7);
  padding: 0 24px;
  margin: 0;
  background: var(--navy-3);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  height: 36px;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}
.page-viewer .breadcrumbs a { color: rgba(255, 255, 255, 0.75); }
.page-viewer .breadcrumbs a:hover { color: var(--amber); }
.page-viewer .breadcrumbs span { color: #fff; }

.viewer-layout {
  /* The viewer-stage takes the full width of the layout - the sidebar
     overlays on top of it as a drawer rather than occupying its own
     column. This means resizing the sidebar never changes the canvas
     dimensions, so the model never reflows. */
  position: relative;
  flex: 1;
  min-height: 0;
  background: var(--dark);
}
body.page-viewer { overflow: hidden; height: 100vh; height: 100dvh; margin: 0; display: flex; flex-direction: column; }
body.page-viewer > .topbar { flex-shrink: 0; }
body.page-viewer main.main {
  min-height: 0;
  max-width: none;
  flex: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: auto;
  padding: 0;
  margin: 0;
}

/* BRE-3 Phase 3.6 - splat training progress (admin scan row + viewer). */
.splat-progress { margin-top: 6px; max-width: 320px; }
.splat-progress-track {
  height: 5px;
  border-radius: 3px;
  background: rgba(37, 60, 88, 0.18);
  overflow: hidden;
}
.splat-progress-bar {
  height: 100%;
  width: 0;
  background: var(--amber);
  border-radius: 3px;
  transition: width 0.4s ease;
}
.splat-progress.is-indeterminate .splat-progress-bar {
  background: linear-gradient(90deg,
    rgba(255, 191, 0, 0.15) 0%, var(--amber) 50%, rgba(255, 191, 0, 0.15) 100%);
  animation: splat-progress-sweep 1.6s linear infinite;
}
@keyframes splat-progress-sweep {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}
.splat-progress-msg { margin-top: 3px; }
.viewer-splat-progress {
  position: absolute;
  top: 52px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 6;
  background: rgba(11, 18, 33, 0.86);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 8px 12px;
  color: #fff;
}
.viewer-splat-progress .splat-progress-track { background: rgba(255, 255, 255, 0.16); }

/* BRE-3 Phase 3.3 - headless render mode (?render=1).
   The chrome is HIDDEN, not removed: viewer.js reads #style-select and
   #bg-select to change display style, so the render harness needs those
   controls in the DOM even though no human will ever see them. */
body.page-render { overflow: hidden; }
body.page-render .topbar,
body.page-render .breadcrumbs,
body.page-render .viewer-sidebar,
body.page-render .sidebar-toggle,
body.page-render .viewer-loading,
body.page-render .canvas-controls,
body.page-render .viewer-mode-switch,
body.page-render .flash,
body.page-render .viewer-splat-progress,
body.page-render .walk-hint { display: none !important; }
body.page-render main.main { height: 100vh; }
body.page-render .viewer-layout { height: 100vh; }

.viewer-sidebar {
  /* Sidebar overlays the top-left of the viewer area as a drawer. */
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 280px;
  background: var(--navy-3);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  color: #fff;
  z-index: 10;
  transition: transform 0.25s ease;
  overflow: visible;
}
/* Slide the whole panel offscreen to the left when collapsed - the canvas
   underneath is never affected, no reflow happens. */
.viewer-sidebar.is-collapsed {
  transform: translateX(-100%);
  border-right: 0;
}
.viewer-sidebar-inner {
  padding: 14px 14px 18px;
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 191, 0, 0.3) transparent;
}
.viewer-sidebar-inner::-webkit-scrollbar { width: 6px; }
.viewer-sidebar-inner::-webkit-scrollbar-track { background: transparent; }
.viewer-sidebar-inner::-webkit-scrollbar-thumb {
  background: rgba(255, 191, 0, 0.25);
  border-radius: 3px;
}
.viewer-sidebar-inner::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 191, 0, 0.5);
}
.viewer-sidebar h3 { color: #fff; font-size: 0.98rem; margin-bottom: 2px; }
.viewer-sidebar .muted { color: rgba(255, 255, 255, 0.6); }
.viewer-sidebar a { color: var(--amber); }
.viewer-sidebar a:hover { color: var(--amber-soft); }

/* ---------- Slide toggle ---------- */
/* Lives outside the sidebar visually, anchored to the viewport. Its left
   position tracks the sidebar's right edge: 280px when open, 0 when
   collapsed. Always visible. */
.sidebar-toggle {
  position: absolute;
  top: calc(50% - 32px);
  left: 280px;
  width: 22px; height: 64px;
  background: var(--amber);
  color: var(--navy);
  border: 0;
  border-radius: 0 6px 6px 0;
  cursor: pointer;
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  box-shadow: 2px 0 6px rgba(0, 0, 0, 0.3);
  transition: left 0.25s ease, background 0.15s;
}
.sidebar-toggle:hover { background: var(--amber-soft); }
.sidebar-toggle:focus-visible { outline: 2px solid #fff; outline-offset: 1px; }
.sidebar-toggle-icon {
  display: inline-block;
  transition: transform 0.25s ease;
}
/* When sidebar is collapsed, slide the toggle left to the browser edge */
.viewer-layout:has(.viewer-sidebar.is-collapsed) ~ * .sidebar-toggle,
.viewer-layout .viewer-sidebar.is-collapsed ~ .sidebar-toggle {
  left: 0;
}
/* Simpler version using a body-level state attribute - set via JS */
body[data-sidebar="collapsed"] .sidebar-toggle { left: 0; }
body[data-sidebar="collapsed"] .sidebar-toggle .sidebar-toggle-icon {
  transform: rotate(180deg);
}

/* ---------- Always-visible header section ---------- */
.viewer-section-fixed {
  flex: 0 0 auto;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 4px;
}

/* ---------- Collapsible (details) sections ---------- */
.viewer-sidebar details.viewer-section {
  flex: 0 0 auto;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding: 0;
  margin: 0;
}
.viewer-sidebar details.viewer-section:last-of-type { border-bottom: 0; }
.viewer-sidebar details.viewer-section > summary {
  cursor: pointer;
  list-style: none;
  padding: 9px 4px 9px 22px;
  position: relative;
  user-select: none;
  outline: none;
}
.viewer-sidebar details.viewer-section > summary::-webkit-details-marker { display: none; }
.viewer-sidebar details.viewer-section > summary::before {
  content: "\25B8";  /* right-pointing triangle */
  position: absolute;
  left: 6px; top: 50%;
  transform: translateY(-50%);
  color: var(--amber);
  font-size: 0.85rem;
  transition: transform 0.18s ease;
}
.viewer-sidebar details.viewer-section[open] > summary::before {
  transform: translateY(-50%) rotate(90deg);
}
.viewer-sidebar details.viewer-section > summary:hover .section-title {
  color: var(--amber-soft);
}
.section-title {
  font-size: 0.74rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--amber);
  font-weight: 600;
  transition: color 0.15s;
}
.section-body {
  padding: 4px 4px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.viewer-section { padding: 0; margin: 0; }   /* override old section spacing */
.viewer-section h4 { display: none; }        /* old h4 markers no longer used */

/* ---------- Compact form rows ---------- */
.field-row {
  flex-direction: row !important;
  align-items: center;
  gap: 10px !important;
}
.field-row > span {
  flex: 0 0 70px;
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.78);
}
.field-row select, .field-row input { flex: 1; }

.viewer-sidebar .field > span {
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.78rem;
}
.viewer-sidebar .field input,
.viewer-sidebar .field select {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.15);
  color: #fff;
}
.viewer-sidebar .field input:focus,
.viewer-sidebar .field select:focus {
  border-color: var(--amber);
  box-shadow: 0 0 0 3px rgba(255, 191, 0, 0.2);
}
/* <option> elements inherit the OS native dropdown panel, which on Windows
   is white by default. Chrome/Edge honour background+color on options, so
   this rescues dark-theme dropdowns from white-on-white unreadability. */
.viewer-sidebar .field select option {
  background: #152236;
  color: #ffffff;
}
.viewer-sidebar .field select option:checked {
  background: #ffbf00;
  color: #253c58;
}
.viewer-sidebar .btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.18);
}
.viewer-sidebar .btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--amber);
}
.viewer-sidebar .btn-ghost { color: rgba(255, 255, 255, 0.8); }
.viewer-sidebar .btn-ghost:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.viewer-sidebar .btn.is-active {
  background: var(--amber); color: var(--navy); border-color: var(--amber);
}
.viewer-sidebar .hint { color: rgba(255, 255, 255, 0.55); font-size: 0.78rem; }

.viewer-meta {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 8px;
  font-size: 0.78rem;
  margin: 4px 0 0;
}
.viewer-meta dt { color: rgba(255, 255, 255, 0.55); }
.viewer-meta dd { margin: 0; color: #fff; }

.viewer-stage {
  position: absolute;
  inset: 0;
  background: var(--dark);
  overflow: hidden;
  width: 100%;
  height: 100%;
}
.viewer-stage > #viewer-app {
  width: 100%;
  height: 100%;
  position: relative;
}
.viewer-stage canvas {
  display: block;
  /* Force the canvas to fit the stage exactly. Three.js manages width/height
     pixel attributes; CSS pins the displayed size so any disagreement
     between attribute and style can never overflow the container. */
  width: 100% !important;
  height: 100% !important;
  max-width: 100%;
  max-height: 100%;
}
#viewer-app { width: 100%; height: 100%; position: relative; }
#viewer-app canvas { display: block; width: 100% !important; height: 100% !important; }

.viewer-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(11, 18, 33, 0.92);
  color: #fff;
  z-index: 10;
  gap: 14px;
  transition: opacity 0.3s;
}
.viewer-loading.hidden { opacity: 0; pointer-events: none; }
#viewer-loading-text { font-size: 0.95rem; text-align: center; padding: 0 20px; }
.viewer-loading-track {
  width: 240px; height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px; overflow: hidden;
}
.viewer-loading-bar {
  width: 0%; height: 100%;
  background: linear-gradient(90deg, var(--amber), var(--amber-soft));
  transition: width 0.2s;
}

@media (max-width: 1280px) {
  .page-viewer .topbar-inner { flex-wrap: wrap; gap: 8px; padding: 8px 12px; }
  .page-viewer .brand { flex: 1; min-width: 0; gap: 8px; }
  .page-viewer .brand-text { min-width: 0; }
  .page-viewer .brand-title { font-size: .78rem; }
  .page-viewer .brand-sub { font-size: .6rem; }
  .page-viewer .brand-mark { height: 24px; }
  .page-viewer .top-user { margin-left: auto; gap: 6px; }
  .page-viewer .user-chip { max-width: 84px; }
  .page-viewer .user-chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .page-viewer .top-user button { min-height: 44px; }
  .page-viewer .top-nav { order: 3; flex: 0 0 100%; min-width: 0; margin: 0; overflow-x: auto; }
  .page-viewer .nav-link { flex-shrink: 0; min-height: 44px; white-space: nowrap; }
  .page-viewer .breadcrumbs { overflow-x: auto; white-space: nowrap; padding: 0 12px; gap: 4px; }
  .page-viewer .breadcrumbs > * { flex-shrink: 0; }
  .viewer-sidebar { width: min(280px, calc(100vw - 44px)); }
  .sidebar-toggle { top: 72px; left: min(280px, calc(100vw - 44px)); width: 44px; height: 64px; }
}

/* ---------- Splat viewer extras ---------- */
.splat-layout .viewer-stage { cursor: default; }

.viewer-help {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  background: rgba(11, 18, 33, 0.85);
  color: #fff;
  padding: 10px 14px;
  border-radius: var(--radius);
  border: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  max-width: 480px;
  z-index: 8;
  pointer-events: auto;
  backdrop-filter: blur(6px);
  transition: opacity 0.4s;
}
.viewer-help.hidden { opacity: 0; pointer-events: none; }
.viewer-help-inner { display: flex; flex-direction: column; gap: 4px; }
.viewer-help-inner strong { color: var(--amber); font-size: 0.95rem; }
.viewer-help-inner .hint { color: rgba(255, 255, 255, 0.78); font-size: 0.82rem; }
.viewer-help-close {
  background: none; border: 0; color: rgba(255, 255, 255, 0.6);
  font-size: 1.2rem; line-height: 1; cursor: pointer; padding: 0 4px;
}
.viewer-help-close:hover { color: #fff; }

.kbd {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  padding: 2px 7px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 4px;
  color: #fff;
  min-width: 22px;
  text-align: center;
}
.kbd-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 5px 10px;
  align-items: center;
  font-size: 0.82rem;
  color: rgba(255, 255, 255, 0.8);
  margin-top: 6px;
}

.checkbox-field {
  flex-direction: row !important;
  align-items: center;
  gap: 8px !important;
}
.checkbox-field input[type="checkbox"] { width: auto; margin: 0; }

/* Staff management - grant lists */
.grant-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 320px;
  overflow-y: auto;
  padding: 8px 4px 8px 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.015);
  padding-left: 8px;
}
.grant-list .checkbox-field {
  padding: 4px 6px;
  border-radius: 3px;
}
.grant-list .checkbox-field:hover { background: rgba(255, 191, 0, 0.06); }
.grant-group { border: 1px solid var(--border); border-radius: 3px; margin-bottom: 6px; background: #fff; }
.grant-group-summary { padding: 8px 10px; cursor: pointer; font-weight: 600; color: var(--navy); }
.grant-group-body { padding: 6px 10px 10px 24px; display: flex; flex-direction: column; gap: 4px; }

/* Compact key/value table for account info panels */
.kv-table { width: 100%; border-collapse: collapse; }
.kv-table th, .kv-table td { padding: 6px 0; border-bottom: 1px dashed var(--border); text-align: left; vertical-align: top; }
.kv-table th { color: var(--text-muted); font-weight: 500; width: 40%; }
.kv-table tr:last-child th, .kv-table tr:last-child td { border-bottom: 0; }

.tour-list {
  list-style: none;
  padding: 0;
  margin: 0 0 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 240px;
  overflow-y: auto;
}
.tour-list.is-empty::before {
  content: attr(data-empty);
  display: block;
  color: rgba(255, 255, 255, 0.45);
  font-size: 0.82rem;
  font-style: italic;
  padding: 6px 0;
}
.tour-list li {
  display: flex;
  align-items: stretch;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.tour-name {
  flex: 1;
  text-align: left;
  background: transparent;
  border: 0;
  color: #fff;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 0.85rem;
  font-family: inherit;
}
.tour-name:hover { background: rgba(255, 191, 0, 0.12); color: var(--amber); }
.tour-del {
  background: transparent;
  border: 0;
  color: rgba(255, 255, 255, 0.45);
  font-size: 1rem;
  cursor: pointer;
  padding: 0 10px;
  border-left: 1px solid rgba(255, 255, 255, 0.08);
}
.tour-del:hover { color: var(--danger); background: rgba(179, 49, 49, 0.15); }

/* ---------- Clipping box UI ---------- */
.clip-axes {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 8px 0 12px;
}
.clip-axis {
  display: grid;
  /* axis label | slider | numeric value, on each row */
  grid-template-columns: 16px 1fr 38px;
  gap: 4px 8px;
  align-items: center;
  font-size: 0.78rem;
}
/* Each axis has TWO sliders (min and max) stacked - one row each. The
   axis label spans both rows. */
.clip-axis > .clip-axis-label { grid-row: span 2; align-self: center; }
.clip-axis > input[type="range"] { width: 100%; min-width: 0; }
.clip-axis-label {
  font-weight: 600;
  color: var(--amber);
  text-align: center;
}
.clip-val {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.7);
  text-align: right;
  min-width: 38px;
}
.clip-note {
  margin-top: 8px;
  padding: 8px 10px;
  background: rgba(255, 191, 0, 0.08);
  border-left: 2px solid var(--amber);
  border-radius: 4px;
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.85);
  line-height: 1.45;
}
.clip-note em { color: var(--amber); font-style: normal; }
#clip-ui:not(.is-active) .clip-axes,
#clip-ui:not(.is-active) .btn-row { opacity: 0.4; pointer-events: none; }

/* ---------- Canvas movement controls (joystick + vertical slider) ---------- */
.canvas-controls {
  /* Anchored to the viewport bottom-left so the joystick stays visible
     regardless of sidebar state, scroll position, or stage size. */
  position: fixed;
  left: 36px;
  bottom: 20px;
  z-index: 30;
  display: flex;
  align-items: flex-end;
  gap: 12px;
  pointer-events: none;
  user-select: none;
  touch-action: none;
  /* Slide horizontally in sync with the sidebar so the controls don't
     get covered when the sidebar is open. The 0.25s timing matches the
     sidebar's own slide transition. */
  transition: left 0.25s ease;
}
/* When the sidebar is open (default state, or explicitly data-sidebar="open"),
   shift the controls to clear the 280px sidebar plus a 16px gap. The
   :not([data-sidebar="collapsed"]) selector covers both the explicit "open"
   value and the initial render before the JS sets the attribute. */
body.page-viewer:not([data-sidebar="collapsed"]) .canvas-controls {
  left: 296px;
}
.canvas-controls.is-collapsed .joystick,
.canvas-controls.is-collapsed .vslider {
  display: none;
}

/* Joystick base - frosted glass disc with subtle inner ring */
.joystick {
  position: relative;
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 50%,
              rgba(255, 255, 255, 0.10) 0%,
              rgba(255, 255, 255, 0.06) 60%,
              rgba(11, 18, 33, 0.40) 100%);
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35),
              inset 0 0 0 1px rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  pointer-events: auto;
  cursor: grab;
}
.joystick:active { cursor: grabbing; }

/* Cross-hair guides inside the base */
.joystick-axis-h, .joystick-axis-v {
  position: absolute;
  left: 50%; top: 50%;
  background: rgba(255, 255, 255, 0.12);
  pointer-events: none;
}
.joystick-axis-h { width: 70%; height: 1px; transform: translate(-50%, -50%); }
.joystick-axis-v { height: 70%; width: 1px; transform: translate(-50%, -50%); }

/* The thumb */
.joystick-knob {
  position: absolute;
  left: 50%; top: 50%;
  width: 48px; height: 48px;
  margin: -24px 0 0 -24px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%,
              rgba(255, 255, 255, 0.95),
              rgba(220, 226, 234, 0.85) 60%,
              rgba(170, 180, 195, 0.75) 100%);
  border: 1px solid rgba(0, 0, 0, 0.2);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4),
              inset 0 1px 1px rgba(255, 255, 255, 0.6);
  transition: transform 0.18s ease;  /* smooth snap-back */
  pointer-events: none;
}
.joystick-knob.is-active { transition: none; }

/* Vertical slider - thinner column with a thumb */
.vslider {
  position: relative;
  width: 50px;
  height: 110px;
  border-radius: 25px;
  background: radial-gradient(ellipse at 50% 50%,
              rgba(255, 255, 255, 0.10) 0%,
              rgba(11, 18, 33, 0.40) 100%);
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  pointer-events: auto;
  cursor: ns-resize;
}
.vslider-track {
  position: absolute;
  inset: 10px 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
}
.vslider-tick {
  font-size: 0.6rem;
  color: rgba(255, 255, 255, 0.55);
  line-height: 1;
}
.vslider-tick.mid { width: 60%; height: 1px; background: rgba(255, 255, 255, 0.15); }
.vslider-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 38px; height: 26px;
  margin: -13px 0 0 -19px;
  border-radius: 13px;
  background: radial-gradient(circle at 35% 30%,
              rgba(255, 255, 255, 0.95),
              rgba(220, 226, 234, 0.85) 60%,
              rgba(170, 180, 195, 0.75) 100%);
  border: 1px solid rgba(0, 0, 0, 0.2);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.4),
              inset 0 1px 1px rgba(255, 255, 255, 0.6);
  transition: transform 0.18s ease;
  pointer-events: none;
}
.vslider-knob.is-active { transition: none; }

/* Tiny "hide" toggle button */
.canvas-controls-toggle {
  pointer-events: auto;
  background: rgba(11, 18, 33, 0.6);
  color: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 50%;
  width: 28px; height: 28px;
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  align-self: flex-start;
  margin-bottom: 6px;
  transition: background 0.15s, color 0.15s;
}
.canvas-controls-toggle:hover {
  background: var(--amber);
  color: var(--navy);
}
.canvas-controls.is-collapsed .canvas-controls-toggle {
  background: rgba(11, 18, 33, 0.6);
}
.canvas-controls.is-collapsed .canvas-controls-toggle::after {
  content: " Move";
  font-size: 0.72rem;
  margin-left: 4px;
  font-weight: 600;
}
.canvas-controls.is-collapsed .canvas-controls-toggle {
  width: auto;
  border-radius: 14px;
  padding: 0 10px 0 8px;
}

/* Mobile / narrow screens - smaller, snug to corner */
@media (max-width: 700px) {
  .canvas-controls,
  body.page-viewer:not([data-sidebar="collapsed"]) .canvas-controls {
    left: 12px; bottom: 12px; gap: 8px;
  }
  .joystick { width: 90px; height: 90px; }
  .joystick-knob { width: 40px; height: 40px; margin: -20px 0 0 -20px; }
  .vslider { width: 42px; height: 90px; }
}

/* ---------- Small screens ---------- */
@media (max-width: 700px) {
  .topbar-inner { flex-wrap: wrap; gap: 10px; padding: 10px 16px; }
  .top-nav { order: 3; width: 100%; overflow-x: auto; }
  .top-user { order: 2; margin-left: auto; }
  .main { padding: 18px 16px 40px; }
  .page-header { flex-direction: column; align-items: stretch; }
  h1 { font-size: 1.4rem; }
}

/* =========================================================================
   R1: Customer tools entitlement panel (admin customer detail)
   ========================================================================= */

.badge-muted { background: var(--surface-2); color: var(--text-muted); border-color: var(--border); }

.ent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.ent-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}
.ent-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px;
  background: var(--navy);
  color: #fff;
}
.ent-card-title { font-weight: 600; font-size: 0.95rem; }
.ent-list { list-style: none; margin: 0; padding: 4px 0; }
.ent-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 14px;
  border-top: 1px solid var(--surface-2);
}
.ent-row:first-child { border-top: none; }
.ent-row.is-inert .ent-label { opacity: 0.45; }
.ent-label { display: flex; align-items: center; gap: 8px; font-size: 0.92rem; }

/* Amber slider switch */
.switch { position: relative; display: inline-block; width: 40px; height: 22px; flex: 0 0 auto; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch-track {
  position: absolute; inset: 0;
  background: var(--border-strong);
  border-radius: 22px;
  transition: background 0.15s ease;
  pointer-events: none;
}
.switch-track::after {
  content: "";
  position: absolute; top: 3px; left: 3px;
  width: 16px; height: 16px;
  background: #fff;
  border-radius: 50%;
  box-shadow: var(--shadow-xs);
  transition: transform 0.15s ease;
}
.switch input:checked + .switch-track { background: var(--amber); }
.switch input:checked + .switch-track::after { transform: translateX(18px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--navy); outline-offset: 2px; }
.ent-card-head .switch-track { background: rgba(255, 255, 255, 0.25); }
.ent-card-head .switch input:checked + .switch-track { background: var(--amber); }

/* =========================================================================
   R1: viewer TOOLS section, instruction strip, labels, snap indicator
   ========================================================================= */

.tool-group { margin-bottom: 10px; }
.tool-group-label {
  margin: 0 0 6px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-soft);
}
.tool-btn-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 6px;
}
.tool-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-height: 52px;
  padding: 7px 4px;
  font-size: 0.78rem;
  font-family: inherit;
  color: #dfe6f2;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.tool-btn:hover { background: rgba(255, 255, 255, 0.12); }
.tool-btn.is-active {
  background: rgba(255, 191, 0, 0.18);
  border-color: var(--amber);
  color: var(--amber);
}
.tool-btn-icon { font-size: 1.05rem; line-height: 1; }

.tool-readout {
  margin-top: 8px;
  padding: 8px 10px;
  font-size: 0.82rem;
  line-height: 1.5;
  color: #eaf0f9;
  background: rgba(255, 191, 0, 0.08);
  border: 1px solid rgba(255, 191, 0, 0.35);
  border-radius: var(--radius);
}
.tool-readout b { color: var(--amber); }

.tool-instruction {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  max-width: min(92%, 560px);
  padding: 8px 16px;
  font-size: 0.88rem;
  text-align: center;
  color: #fff;
  background: rgba(23, 36, 55, 0.92);
  border: 1px solid rgba(255, 191, 0, 0.5);
  border-radius: 999px;
  box-shadow: var(--shadow-md);
  pointer-events: none;
}
.tool-instruction b, .tool-instruction .kbd { color: var(--amber); }

.tool-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  overflow: hidden;
  pointer-events: none;
}
.ls-label {
  --ls-label-color: #ffbf00;
  position: absolute;
  top: 0; left: 0;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 600;
  white-space: pre;
  color: var(--ls-label-color);
  background: rgba(23, 36, 55, 0.88);
  border: 1px solid var(--ls-label-color);
  border-radius: 4px;
  will-change: transform;
}
.ls-snap {
  position: absolute;
  top: 0; left: 0;
  width: 16px; height: 16px;
  border: 2px solid var(--amber);
  border-radius: 50%;
  box-shadow: 0 0 6px rgba(255, 191, 0, 0.8);
  will-change: transform;
}
.ls-snap.hidden, .tool-instruction.hidden, .tool-readout.hidden { display: none; }
body.ls-tool-active #viewer-app canvas { cursor: crosshair; }

/* =========================================================================
   R1: annotations panel, pins, text labels
   ========================================================================= */

.ann-saved { margin-left: 8px; font-size: 0.72rem; color: var(--amber); font-weight: 400; }
.ann-saved.is-error { color: #ff8b8b; }

.ann-layer { margin-bottom: 8px; }
.ann-layer-head {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 4px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}
.ann-layer-name { flex: 1; font-size: 0.8rem; font-weight: 600; color: #dfe6f2; }
.ann-count { font-size: 0.75rem; }
.ann-clear {
  padding: 2px 8px;
  font-size: 0.72rem;
  color: #ff9d9d;
  background: none;
  border: 1px solid rgba(255, 141, 141, 0.4);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.ann-clear:hover { background: rgba(229, 72, 77, 0.15); }
.ann-list { list-style: none; margin: 0; padding: 2px 0 0; }
.ann-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 0;
  font-size: 0.82rem;
  color: #cdd7e6;
}
.ann-item.is-hidden .ann-name { opacity: 0.45; }
.ann-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: text;
  min-height: 22px;
  line-height: 22px;
}
.ann-eye, .ann-zoom, .ann-del {
  flex: 0 0 auto;
  width: 24px; height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  color: #aab7cb;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.ann-eye:hover, .ann-zoom:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }
.ann-eye.is-off { color: #5d6a7e; }
.ann-del:hover { background: rgba(229, 72, 77, 0.2); color: #ff9d9d; }
.ann-color {
  flex: 0 0 auto;
  width: 16px; height: 16px;
  padding: 0;
  background: var(--dot, #ffbf00);
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 50%;
  cursor: pointer;
}
.ann-rename, .ls-text-input {
  font-family: inherit;
  font-size: 0.82rem;
  padding: 2px 6px;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--amber);
  border-radius: var(--radius-sm);
}
.ann-rename { flex: 1; min-width: 0; }
.ls-text-input {
  position: absolute;
  z-index: 40;
  width: 180px;
  pointer-events: auto;
}
.ls-label.ls-pin {
  font-size: 13px;
  border-radius: 999px;
  padding: 2px 9px;
}
.ls-label.ls-text {
  background: rgba(23, 36, 55, 0.94);
  font-weight: 500;
  max-width: 260px;
  white-space: normal;
}
.ann-empty { margin: 4px 0 6px; }

/* =========================================================================
   R1: export dialog
   ========================================================================= */

.ls-dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(11, 18, 33, 0.65);
}
.ls-dialog-backdrop.hidden { display: none; }
.ls-dialog {
  width: min(92vw, 380px);
  padding: 18px 20px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}
.ls-dialog h3 { margin-bottom: 12px; }
.ls-dialog .checkbox-field { display: flex; align-items: center; gap: 8px; margin: 8px 0; }

/* =========================================================================
   R1: snapshots tray + report wizard
   ========================================================================= */

.snap-tray { margin-top: 8px; }
.snap-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.snap-thumb {
  width: 52px; height: 34px;
  object-fit: cover;
  border-radius: 3px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  flex: 0 0 auto;
}
.snap-name {
  flex: 1;
  font-size: 0.8rem;
  color: #cdd7e6;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: text;
}
.snap-actions { display: inline-flex; gap: 2px; }
.snap-btn {
  width: 22px; height: 22px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 0.72rem;
  color: #aab7cb;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.snap-btn:hover:not(:disabled) { background: rgba(255, 255, 255, 0.12); color: #fff; }
.snap-btn:disabled { opacity: 0.3; cursor: default; }
.snap-del:hover { background: rgba(229, 72, 77, 0.25) !important; color: #ff9d9d !important; }

.report-list { margin-top: 10px; }
.report-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  font-size: 0.82rem;
}
.report-link { color: var(--amber); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.report-link:hover { text-decoration: underline; }

.ls-wizard { width: min(94vw, 520px); max-height: 88vh; overflow: auto; }
.wiz-steps {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
  font-size: 0.8rem;
  color: var(--text-muted);
}
.wiz-steps .is-active { color: var(--navy); font-weight: 600; border-bottom: 2px solid var(--amber); }
.wiz-page.hidden { display: none; }
.report-preview {
  width: 100%;
  height: 340px;
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* =========================================================================
   R1: rainwater panel
   ========================================================================= */

.rwh-step { margin-bottom: 14px; padding-bottom: 10px; border-bottom: 1px solid rgba(255,255,255,0.08); }
.rwh-step:last-child { border-bottom: none; }
.rwh-amber { color: var(--amber); }
.rwh-warn { color: #ff9d9d; font-weight: 600; }
.rwh-catchment { margin: 6px 0; padding: 6px 8px; background: rgba(255,255,255,0.05); border-radius: var(--radius-sm); }
.rwh-cat-head { display: flex; align-items: center; gap: 8px; color: #dfe6f2; font-size: 0.82rem; }
.rwh-cat-head b { flex: 0 0 auto; }
.rwh-cat-head .muted { flex: 1; }
.rwh-cat-body { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.rwh-cat-body select { flex: 1; font-size: 0.8rem; }
.rwh-e { display: inline-flex; align-items: center; gap: 4px; color: #aab7cb; font-size: 0.8rem; }
.rwh-e input, .rwh-rate { width: 58px; font-size: 0.8rem; }
.rwh-results { width: 100%; border-collapse: collapse; margin: 4px 0 8px; }
.rwh-results td { padding: 3px 0; font-size: 0.82rem; color: #cdd7e6; }
.rwh-results td:last-child { text-align: right; color: #fff; }
.rwh-results tr { border-bottom: 1px solid rgba(255,255,255,0.07); }
#rwh-ui .checkbox-field { display: flex; align-items: center; gap: 6px; color: #cdd7e6; font-size: 0.82rem; margin: 5px 0; }

/* =========================================================================
   R1: coach marks + touch target sizing
   ========================================================================= */

.ls-tip {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  width: min(92%, 380px);
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--amber);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}
.ls-tip h4 { margin: 2px 0 6px; color: var(--navy); }
.ls-tip p { margin: 0 0 10px; font-size: 0.88rem; color: var(--text); }
.ls-tip-step { font-size: 0.72rem; font-weight: 600; letter-spacing: 0.06em; color: var(--amber); text-transform: uppercase; }
.ls-tip b { color: var(--navy); }

@media (pointer: coarse) {
  .ann-eye, .ann-zoom, .ann-del, .snap-btn { width: 44px; height: 44px; font-size: 1rem; }
  .ann-color { width: 24px; height: 24px; }
  .tool-btn { min-height: 60px; }
  .clip-axis input[type="range"] { height: 32px; }
}

/* =========================================================================
   Release 2 — Geospatial: placement wizard, north arrow, context layers
   ========================================================================= */

.place-layout {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 0;
  height: calc(100vh - 150px);
  min-height: 480px;
  border: 1px solid #2a3a55;
  border-radius: 10px;
  overflow: hidden;
  background: #0b1221;
}
.place-sidebar {
  overflow-y: auto;
  padding: 14px;
  background: #111a2c;
  border-right: 1px solid #2a3a55;
}
.place-step { margin-bottom: 18px; }
.place-step h3 {
  font-size: 0.95rem;
  margin: 0 0 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.place-step-no {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: #ffbf00;
  color: #172437;
  font-size: 0.8rem;
  font-weight: 700;
  flex: 0 0 auto;
}
.place-results { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.place-result {
  text-align: left;
  background: #172437;
  color: #e8edf5;
  border: 1px solid #2a3a55;
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 0.85rem;
  cursor: pointer;
}
.place-result:hover { border-color: #ffbf00; }
.place-result.is-active { border-color: #ffbf00; background: #1d3047; }
.place-results { max-height: 264px; overflow-y: auto; }
.place-manual { margin-top: 8px; color: #aab7cb; }
.place-manual input[type="number"] { width: 110px; }

/* HOTFIX-2 FIX B: .place-sidebar is a dark panel but had no scoped ink
   overrides, so the global light-theme tokens (--navy headings, --text
   labels) rendered near-navy on navy. Mirror the .viewer-sidebar override
   pattern: white/light text, amber headings, all >= WCAG AA 4.5:1 on
   #111a2c (verified by scripts/check_contrast.py). */
.place-sidebar { color: #fff; }
.place-sidebar h3 { color: var(--amber); }
.place-sidebar .field > span { color: rgba(255, 255, 255, 0.85); }
.place-sidebar .hint,
.place-sidebar .muted { color: rgba(255, 255, 255, 0.66); }
.place-sidebar input[type="text"], .place-sidebar input[type="search"],
.place-sidebar input[type="number"], .place-sidebar select {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.22);
  color: #fff;
}
.place-sidebar input::placeholder { color: rgba(255, 255, 255, 0.45); }
.place-sidebar .btn-ghost { color: rgba(255, 255, 255, 0.85); }
.place-sidebar .btn-ghost:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }
.place-sidebar .danger-link { color: #ff8f8f !important; }
.place-sidebar .danger-link:hover { background: rgba(229, 72, 77, 0.18); }
.place-map-empty { color: #fff; }
.place-map-empty h3 { color: var(--amber); }
.place-map-empty p { color: rgba(255, 255, 255, 0.78); }
.place-save-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.place-map-wrap { position: relative; }
#place-map { position: absolute; inset: 0; }
.place-map-empty {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  text-align: center;
  background: repeating-linear-gradient(45deg, #0b1221, #0b1221 14px, #101a2e 14px, #101a2e 28px);
  z-index: 5;
  padding: 24px;
}
.place-map-empty > div { max-width: 420px; }
.place-basemap-switch {
  position: absolute; top: 10px; left: 10px; z-index: 6;
  display: flex; gap: 6px;
}
/* HOTFIX-2 FIX C: honest per-style states on the basemap pills. */
.btn.is-unavailable {
  opacity: 0.75;
  text-decoration: line-through;
  cursor: not-allowed;
}
.place-attribution,
.context-attribution {
  position: absolute; bottom: 6px; right: 8px; z-index: 6;
  font-size: 10px;
  color: #cbd5e3;
  background: rgba(11, 18, 33, 0.65);
  padding: 2px 8px;
  border-radius: 4px;
  pointer-events: none;
  max-width: 70%;
  text-align: right;
}
.place-rotate-handle {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 2px solid #172437;
  background: #ffbf00;
  color: #172437;
  font-size: 18px;
  font-weight: 700;
  cursor: grab;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5);
  touch-action: none;
}
.place-rotate-handle:active { cursor: grabbing; }

.north-arrow {
  position: absolute; top: 12px; right: 12px; z-index: 7;
  pointer-events: none;
}
.context-attribution { bottom: 8px; right: 10px; position: absolute; }

/* CONTEXT sidebar section */
.ctx-group { margin-bottom: 10px; }
.ctx-group-label {
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #8fa0b8;
  margin: 10px 0 6px;
}
.ctx-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.ctx-row label.checkbox-field { flex: 1 1 auto; margin: 0; }
.ctx-row input[type="range"] { width: 74px; flex: 0 0 auto; }
.ctx-legend {
  display: inline-block;
  width: 12px; height: 12px;
  border-radius: 3px;
  flex: 0 0 auto;
}
.ctx-awaiting {
  font-size: 0.75rem;
  color: #d6b04d;
  background: rgba(255, 191, 0, 0.08);
  border: 1px solid rgba(255, 191, 0, 0.35);
  border-radius: 5px;
  padding: 2px 7px;
}
.ctx-chip {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid #2a3a55;
  background: #172437;
  color: #e8edf5;
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 0.8rem;
  cursor: pointer;
}
.ctx-chip.is-active { border-color: #ffbf00; color: #ffbf00; }

@media (max-width: 900px) {
  .place-layout { grid-template-columns: 1fr; grid-template-rows: auto 1fr; height: auto; }
  .place-sidebar { max-height: 45vh; border-right: 0; border-bottom: 1px solid #2a3a55; }
  .place-map-wrap { height: 55vh; }
}

/* =========================================================================
   R4: scan comparison (Phase 16)
   ========================================================================= */
.cmp-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 10px;
  margin: 6px 0 8px;
  font-size: 0.85rem;
  color: #e8edf5;
}
.cmp-swipe {
  position: absolute;
  top: 0; bottom: 0;
  width: 0;
  z-index: 24;
  cursor: ew-resize;
  touch-action: none;
}
.cmp-swipe.hidden { display: none; }
.cmp-swipe-line {
  position: absolute; top: 0; bottom: 0; left: -1px;
  width: 2px;
  background: #ffbf00;
  box-shadow: 0 0 6px rgba(0,0,0,0.6);
}
.cmp-swipe-grip {
  position: absolute; top: 50%; left: 0;
  transform: translate(-50%, -50%);
  width: 34px; height: 34px;
  border-radius: 50%;
  background: #172437;
  border: 2px solid #ffbf00;
  color: #ffbf00;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  user-select: none;
}
.cmp-badge {
  position: absolute;
  top: 12px;
  z-index: 23;
  background: rgba(11, 18, 33, 0.78);
  border: 1px solid #2a3a55;
  color: #e8edf5;
  border-radius: 6px;
  padding: 3px 10px;
  font-size: 0.78rem;
  max-width: 40%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  pointer-events: none;
}
.cmp-badge.hidden { display: none; }
.cmp-badge-l { left: 14px; }
.cmp-badge-r { right: 14px; }
.ls-label.cmp-region-label {
  background: rgba(23, 36, 55, 0.9);
  border: 1px solid #ffbf00;
}

/* =========================================================================
   R4: photo markers & condition schedule (Phase 17)
   ========================================================================= */
.ls-photo-dialog { max-width: 480px; max-height: 86vh; overflow-y: auto; }
.ph-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 8px;
  margin: 6px 0 10px;
}
.ph-cell { position: relative; }
.ph-cell img {
  width: 100%; aspect-ratio: 1; object-fit: cover;
  border-radius: 6px; border: 1px solid #2a3a55;
  cursor: zoom-in; display: block;
}
.ph-del {
  position: absolute; top: -6px; right: -6px;
  width: 22px; height: 22px; border-radius: 50%;
  background: #172437; border: 1px solid #e5484d; color: #e5484d;
  font-size: 0.85rem; line-height: 1; cursor: pointer;
}
#ph-file.hidden { display: none; }
.ph-lightbox {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(5, 9, 18, 0.92);
  display: flex; align-items: center; justify-content: center;
  cursor: zoom-out;
}
.ph-lightbox.hidden { display: none; }
.ph-lightbox img {
  max-width: 92vw; max-height: 92vh;
  border-radius: 6px; box-shadow: 0 12px 40px rgba(0,0,0,0.6);
}
.ph-lightbox-close {
  position: absolute; top: 14px; right: 18px;
  background: none; border: 0; color: #fff; font-size: 2rem; cursor: pointer;
}
.ann-photos {
  background: none; border: 0; cursor: pointer;
  font-size: 0.85rem; position: relative; padding: 2px 4px;
  flex: 0 0 auto;
}
.ann-photos-count {
  font-size: 0.68rem; color: #ffbf00; font-weight: 700; margin-left: 1px;
}
.ann-cond-dot {
  position: absolute; top: 0; right: -1px;
  width: 7px; height: 7px; border-radius: 50%;
  background: #ffbf00;
}

/* =========================================================================
   R4: data export + portfolio dashboard (Phase 19)
   ========================================================================= */
.portfolio-stats { margin-bottom: 16px; }
.portfolio-map {
  width: 100%;
  height: 320px;
  border-radius: 10px;
  border: 1px solid #2a3a55;
  overflow: hidden;
  margin: 4px 0 14px;
  background: #172437;
}
.portfolio-pin {
  width: 22px; height: 22px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  background: #ffbf00;
  border: 2px solid #172437;
  box-shadow: 0 2px 6px rgba(0,0,0,0.45);
  cursor: pointer;
}
/* PROPERTY_AUTOLOCATE: ringed amber = approximate (geocoded) point;
   solid amber = exact (scan-placed or manually pinned). */
.portfolio-pin--approx {
  background: rgba(255, 191, 0, 0.22);
  border: 3px solid #ffbf00;
}
.map-legend {
  display: flex;
  gap: 18px;
  align-items: center;
  margin: -8px 0 14px;
  font-size: 0.78rem;
  color: #9aa8bf;
}
.map-legend .legend-pin {
  display: inline-block;
  width: 13px; height: 13px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg) translateY(2px);
  margin-right: 7px;
  background: #ffbf00;
  border: 2px solid #172437;
}
.map-legend .legend-pin--approx {
  background: rgba(255, 191, 0, 0.22);
  border: 2px solid #ffbf00;
}
.property-map {
  width: 100%;
  height: 260px;
  border-radius: 10px;
  border: 1px solid #2a3a55;
  overflow: hidden;
  margin: 4px 0 8px;
  background: #172437;
}
.property-map.is-adjusting { border-color: #ffbf00; cursor: crosshair; }
.maplibregl-popup-content {
  background: #172437;
  color: #e8edf5;
  border: 1px solid #2a3a55;
  border-radius: 8px;
  font-size: 0.85rem;
  padding: 10px 12px;
}
.maplibregl-popup-content a { color: #ffbf00; }
.maplibregl-popup-tip { border-top-color: #172437 !important; }
.portfolio-search {
  background: #0b1221;
  border: 1px solid #2a3a55;
  color: #e8edf5;
  border-radius: 7px;
  padding: 7px 12px;
  min-width: 210px;
  font-size: 0.85rem;
}
.portfolio-search:focus { outline: none; border-color: #ffbf00; }
#portfolio-no-match.hidden { display: none; }

/* ---- R6 Phase 23: "Ask this scan" chat panel ---- */
.ai-thread {
  max-height: 260px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 8px;
}
.ai-thread:empty { display: none; }
.ai-msg {
  border-radius: 10px;
  padding: 7px 10px;
  font-size: 0.82rem;
  line-height: 1.45;
  max-width: 95%;
  word-wrap: break-word;
}
.ai-msg-user {
  align-self: flex-end;
  background: #2a3a55;
  color: #e8edf5;
}
.ai-msg-assistant {
  align-self: flex-start;
  background: #172437;
  border: 1px solid #2a3a55;
  color: #e8edf5;
}
.ai-msg-wait {
  align-self: flex-start;
  color: #8fa0b8;
  font-style: italic;
  background: transparent;
  padding: 2px 4px;
}
.ai-msg-error {
  align-self: flex-start;
  background: rgba(200, 64, 64, 0.15);
  border: 1px solid rgba(200, 64, 64, 0.5);
  color: #f1b9b9;
}
.ai-msg-info {
  align-self: flex-start;
  color: #ffbf00;
  background: transparent;
  padding: 2px 4px;
  font-size: 0.78rem;
}
.ai-used {
  display: block;
  margin-top: 5px;
  color: #8fa0b8;
  font-size: 0.74rem;
}
.ai-form { display: flex; gap: 6px; }
.ai-form input {
  flex: 1;
  min-width: 0;
  background: #0b1221;
  border: 1px solid #2a3a55;
  color: #e8edf5;
  border-radius: 7px;
  padding: 7px 10px;
  font-size: 0.84rem;
}
.ai-form input:focus { outline: none; border-color: #ffbf00; }
.ai-form.hidden, #ai-describe.hidden { display: none; }

/* =========================================================================
   FJD Release C: dual-mode viewer (Point cloud <-> Photorealistic)
   ========================================================================= */
.viewer-mode-switch {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 31;
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: rgba(11, 18, 33, 0.85);
  border: 1px solid #3a4d6b;
  border-radius: 999px;
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(4px);
}
.vmode-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: #cbd5e3;
  font: 600 0.82rem/1 "Segoe UI", Arial, sans-serif;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: background 0.15s, color 0.15s;
}
.vmode-btn:hover:not(:disabled):not(.is-active) { color: #ffffff; }
.vmode-btn.is-active {
  background: var(--amber, #ffbf00);
  color: #172437;
}
.vmode-btn:disabled {
  color: #64748b;
  cursor: not-allowed;
}
.vmode-btn.is-loading {
  color: #ffdf80;
  cursor: progress;
}
.vmode-btn.is-loading::after {
  content: "…";
}
.vmode-note {
  position: absolute;
  top: 54px;
  left: 12px;
  z-index: 31;
  max-width: min(80%, 460px);
  padding: 5px 12px;
  font-size: 0.76rem;
  color: #ffdf80;
  background: rgba(11, 18, 33, 0.8);
  border: 1px solid rgba(255, 191, 0, 0.35);
  border-radius: 8px;
  pointer-events: none;
}
.vmode-note.hidden { display: none; }

/* BRE-11 FR5: the splat's measured grade, shown while photorealistic mode
   is on. Three severities, because "full fidelity" and "indicative only"
   are not the same news and should not look the same. */
.vmode-grade {
  position: absolute;
  top: 54px;
  left: 12px;
  z-index: 31;
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-width: min(84%, 520px);
  padding: 6px 12px;
  font-size: 0.78rem;
  color: #eaf2ff;
  background: rgba(11, 18, 33, 0.86);
  border: 1px solid rgba(143, 208, 255, 0.4);
  border-left-width: 4px;
  border-radius: 8px;
  pointer-events: none;
}
.vmode-grade .small { font-size: 0.7rem; color: #b9c8dd; }
.vmode-grade.is-ok { border-left-color: #5fd39a; }
.vmode-grade.is-warn { border-left-color: #ffbf00; }
.vmode-grade.is-bad { border-left-color: #ff8a7a; }
.vmode-grade.hidden { display: none; }

/* The same grade as a chip on the admin scan row / imagery panel. */
.splat-grade-chip {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  border-radius: 999px;
  color: #172437;
  background: #8fd0ff;
}
.splat-grade-chip.is-ok { background: #5fd39a; }
.splat-grade-chip.is-warn { background: #ffd257; }
.splat-grade-chip.is-bad { background: #ff8a7a; }
.splat-grade-chip[hidden] { display: none; }

/* Annotation provenance badge: created in photorealistic mode (FR11) */
.ann-mode-badge {
  flex: 0 0 auto;
  margin-left: 4px;
  padding: 1px 5px;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #172437;
  background: #8fd0ff;
  border-radius: 4px;
}

@media (max-width: 760px) {
  .viewer-mode-switch { top: 8px; left: 8px; }
  .vmode-btn { padding: 6px 10px; font-size: 0.76rem; }
  .vmode-note { top: 46px; left: 8px; }
  .vmode-grade { top: 46px; left: 8px; }
}

/* =========================================================================
   FJD Release D: admin Edit/Clean mode (crop / trim / clean)
   ========================================================================= */
.staff-pill {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #172437;
  background: #ffbf00;
  border-radius: 999px;
  vertical-align: 1px;
}
#edit-clean-panel .edit-clean-body { display: none; }
#edit-clean-panel.is-editing .edit-clean-body { display: block; margin-top: 8px; }
#edit-clean-panel .field-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin: 6px 0;
  flex-wrap: wrap;
}
#edit-clean-panel .field-inline { flex: 0 1 auto; }
#edit-clean-panel .field-inline input { width: 76px; }
#edit-clean-panel [data-clean-tool].is-active {
  background: #ffbf00;
  color: #172437;
}
.edit-clean-list {
  margin: 6px 0;
  padding-left: 18px;
  font-size: 0.78rem;
  color: #cbd5e3;
  max-height: 140px;
  overflow-y: auto;
}
.edit-clean-list li.is-undone {
  color: #64748b;
  text-decoration: line-through;
}
/* BRE-2: dilapidation / exclusion regions (viewer-assessment.js) */
.assessment-region-list {
  list-style: none;
  margin: 6px 0;
  padding: 0;
  font-size: 0.78rem;
  color: #cbd5e3;
  max-height: 190px;
  overflow-y: auto;
}
.assessment-region-list li {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 4px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.assessment-region-list li:last-child { border-bottom: 0; }
.assessment-region-list li > span:nth-child(2) { flex: 1 1 auto; }
.assessment-region-list small { color: #94a3b8; }
.assessment-swatch {
  flex: 0 0 auto;
  width: 10px;
  height: 10px;
  margin-top: 3px;
  border-radius: 2px;
}
.edit-lasso-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 30;
  pointer-events: none;
}

/* =========================================================================
   KIMI-3 (2026-08-19) - the polish pass. Every rule here answers a
   screenshot in D:\portrait-bre\samples\kimi-ui\ (before/after pairs).
   ========================================================================= */

/* The grade badge floats over the sidebar's fixed header in photoreal mode;
   reserve exactly its height rather than let it cover the scan's name and
   stats. The var is measured at runtime (viewer-photoreal.js). */
.viewer-sidebar.vmode-grade-on .viewer-section-fixed {
  margin-top: var(--vmode-grade-h, 0px);
  transition: margin-top 0.15s ease;
}

/* A failed training's reason, in the sidebar's flow (it used to be an
   overlay on the stats, and before that only a tooltip). */
.vmode-failed {
  margin-top: 8px;
  padding: 6px 10px;
  font-size: 0.76rem;
  color: #ffdf80;
  background: rgba(11, 18, 33, 0.55);
  border: 1px solid rgba(255, 191, 0, 0.35);
  border-radius: 8px;
  overflow-wrap: anywhere;
}
.vmode-failed .small { color: #b9c8dd; }

/* The viewer's key hints: two deliberate lines, not a ragged wrap. */
.viewer-keys-hint { display: flex; flex-direction: column; gap: 2px; }
.viewer-keys-hint .hint-line { white-space: nowrap; }

/* The admin scan table: the title cell stacks title / pills / filename
   deliberately, and the numeric columns never wrap ("1.9 GB" stays one
   line). */
#scan-table .scan-title { display: block; font-weight: 600; margin-bottom: 3px; }
#scan-table td:first-child .pill { margin: 0 4px 2px 0; }
#scan-table td:first-child small { display: inline-block; margin-top: 2px; overflow-wrap: anywhere; }
#scan-table td[data-points],
#scan-table td[data-size],
#scan-table td[data-uploaded] { white-space: nowrap; }
#scan-table .row-actions { min-width: 220px; }

/* Property cards: the name wraps cleanly beside an unshrinkable pill. */
.property-card-head strong { min-width: 0; overflow-wrap: anywhere; }
.property-card-head .pill { flex-shrink: 0; }

/* AIA-1: AI Assist panel */
.assist-stages { list-style: none; margin: 8px 0 0; padding: 0; }
.assist-stages .assist-stage { padding: 2px 0; font-size: 12.5px; color: #8fa0b8; }
.assist-stages .assist-stage-running { color: #ffbf00; }
.assist-stages .assist-stage-done { color: #7bd88f; }
.assist-stages .assist-stage-failed,
.assist-stages .assist-stage-needs_attention { color: #ff8f8f; }
.assist-stages .assist-stage-skipped { color: #8fa0b8; font-style: italic; }
.assist-stage-mark { display: inline-block; width: 14px; font-weight: 700; }
.assist-result-card { margin-top: 8px; }
.assist-result-card p { margin: 4px 0; }
.assist-transcript-list details { margin: 4px 0; }
.assist-transcript-list ul { margin: 4px 0 8px; padding-left: 18px; }

/* Ticket203: visible provider logo and per-visible-tile copyright. */
.context-attribution{display:flex;align-items:center;gap:10px;flex-wrap:wrap;max-width:calc(100% - 20px);padding:10px 10px 5px;background:#fff;color:#20242b;font:12px/1.5 system-ui;text-align:left;overflow-wrap:anywhere}
.context-attribution img{height:18px;width:auto;flex:none}.context-attribution [hidden]{display:none!important}

/* Keep provider credits readable alongside the existing viewer controls. */
.context-attribution{z-index:61}
.viewer-layout .ls-tip{bottom:calc(24px + var(--map-credit-height,0px))}
.viewer-layout .canvas-controls{bottom:calc(12px + var(--map-credit-height,0px))}
.viewer-sidebar-inner{padding-bottom:calc(18px + var(--map-credit-height,0px))}
#context-body select,#context-body input[type=range]{min-width:44px;min-height:44px;font-size:16px}
#context-body select{width:100%;min-width:0}
#context-body .checkbox-field{min-height:44px;font-size:16px;align-items:center}
#context-body input[type=checkbox]{flex:none}
#context-body .ctx-row{min-width:0}
