/* ClearView builder portal - shared styles for modernized pages (see inc/layout.asp). */

:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --hover: #f3f4f6;
  --brand: #00cd8a;
  --brand-dark: #00a06c;
  --brand-soft: #e6faf3;
  --accent: #99c1c1;
  --danger: #b91c1c;
  --warn-soft: #fff7ed;
  --shadow: 0 6px 18px rgba(0, 0, 0, .08);
  --radius: 14px;
  --sidebar-w: 280px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.4;
  color: var(--text);
  background: var(--bg);
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }

/* ---------- App shell ---------- */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px;
  background: var(--card);
  border-right: 1px solid var(--border);
  overflow: hidden;
  z-index: 30;
}
.sidebar-brand { display: flex; align-items: center; padding: 4px 6px 10px; }
.side-title {
  margin: 10px 8px 6px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}
.side-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border-radius: 10px;
  font-weight: 600;
}
.side-link:hover { background: var(--hover); }
.side-link.active { background: var(--brand-soft); color: #065f46; }
.side-divider { height: 1px; background: var(--border); margin: 8px 6px; flex: 0 0 auto; }

.nei-search { margin: 0 2px 6px; }
.nei-list {
  flex: 1 1 auto;
  min-height: 120px;
  overflow-y: auto;
  padding-right: 2px;
}
.nei-item {
  display: block;
  padding: 8px 10px;
  border-radius: 10px;
}
.nei-item:hover { background: var(--hover); }
.nei-item.active { background: var(--brand-soft); color: #065f46; }
.nei-item.active .meta { color: #047857; }
.nei-item .name { font-weight: 700; }
.nei-item .meta { font-size: 12px; color: var(--muted); }
.nei-empty { padding: 8px 10px; color: var(--muted); font-size: 13px; }

.sidebar-bottom { flex: 0 0 auto; }

.main { display: flex; flex-direction: column; min-width: 0; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { margin: 0; font-size: 18px; font-weight: 800; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.btn.menu-btn { display: none; }
.topbar-logo { display: none; }
.topbar-logo .brand img { height: 26px; }
.topbar-logo .brand-sub { display: none; }

.content {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 16px;
}

.scrim {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .3);
  z-index: 25;
}

/* ---------- Brand ---------- */
.brand { display: inline-flex; align-items: center; gap: 10px; }
.brand img { display: block; height: 34px; width: auto; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name { font-size: 18px; font-weight: 800; letter-spacing: -.01em; }
.brand-sub { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }

/* ---------- Signed-out pages (AuthStart / AuthEnd) ---------- */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 32px 16px;
}
.auth-brand .brand img { height: 52px; }
.auth-brand .brand-name { font-size: 26px; }
.auth-card { width: 100%; max-width: 400px; padding: 24px; }
.auth-card h1 { margin: 0 0 4px; font-size: 22px; font-weight: 800; }
.auth-card .lead { margin: 0 0 18px; color: var(--muted); }
.auth-foot { margin: 0; font-size: 12px; color: var(--muted); text-align: center; }
.auth-foot a { text-decoration: underline; }
.auth-wide { max-width: 560px; }

/* ---------- Controls ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: var(--hover); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #052e1f; }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }

.pill {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}

.input, .select {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  outline: none;
}
.input:focus, .select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(153, 193, 193, .3);
}
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field label { font-size: 12px; font-weight: 600; color: var(--muted); }
.row { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack .btn { width: 100%; }
.hint { font-size: 12px; color: var(--muted); }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--brand-dark); }
.split { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.link { color: #047857; font-weight: 600; }
.link:hover { text-decoration: underline; }

.msg { padding: 10px 12px; border-radius: 10px; font-size: 14px; border: 1px solid; }
.msg-error { background: #fef2f2; border-color: #fecaca; color: var(--danger); }
.msg-ok { background: var(--brand-soft); border-color: #a7f3d0; color: #065f46; }
.msg-info { background: #f0f9ff; border-color: #bae6fd; color: #075985; }

/* ---------- Cards and panels ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
}
.section-title {
  margin: 22px 2px 10px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.stat { display: block; }
.stat:hover { background: #fafafa; }
.stat .k { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.stat .v { margin-top: 4px; font-size: 28px; font-weight: 800; }
.stat .v.alert { color: var(--danger); }

.panels {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}
.panel {
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.count {
  min-width: 24px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--hover);
  font-size: 12px;
  text-align: center;
}
.panel-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  max-height: 420px;
  overflow-y: auto;
}
.item {
  display: block;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
}
.item:hover { background: #f9fafb; border-color: #d1d5db; }
.item .l1 { font-weight: 700; }
.item .l2, .item .l3 { margin-top: 2px; font-size: 13px; color: var(--muted); }
.empty {
  padding: 10px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  font-size: 13px;
  color: var(--muted);
}

.prose { max-width: 760px; }
.prose p { margin: 0 0 12px; }
.prose p:last-child { margin-bottom: 0; }
.prose a { color: #047857; font-weight: 600; text-decoration: underline; }
.doc-frame {
  display: block;
  width: 100%;
  height: min(60vh, 560px);
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
}
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }

.notice {
  padding: 12px 14px;
  border: 1px solid #fed7aa;
  border-radius: var(--radius);
  background: var(--warn-soft);
}

/* ---------- Neighbourhood map (map.asp, js/map.js) ---------- */
.map-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.map-title { margin: 0; font-size: 22px; font-weight: 800; }
.map-tools { display: flex; gap: 8px; flex-wrap: wrap; }
.map-find { display: flex; gap: 6px; }
.map-find .input { width: 78px; }
.map-find.not-found .input { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(185, 28, 28, .15); }
.zoom { display: flex; gap: 4px; }
.zoom .btn { min-width: 40px; padding: 8px 10px; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 0 2px 10px; font-size: 13px; color: var(--muted); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend .pin { position: static; transform: none; width: 14px; height: 14px; border-width: 2px; cursor: default; }

.map-viewport {
  position: relative;
  height: calc(100vh - 230px);
  min-height: 360px;
  padding: 0;
  overflow: auto;
  background: #eef0f3;
  cursor: grab;
  -webkit-overflow-scrolling: touch;
}
.map-viewport.dragging { cursor: grabbing; user-select: none; }
.map-canvas { position: relative; visibility: hidden; }
.map-canvas.ready { visibility: visible; }
.map-img { display: block; max-width: none; user-select: none; }
.map-canvas.no-image { min-width: 100%; min-height: 300px; }
.map-canvas.no-image .map-img { display: none; }
.map-empty { margin: 16px; }

.pin {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 22px;
  height: 22px;
  padding: 0;
  border: 3px solid #fff;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .45);
  cursor: pointer;
  background: #fff;
}
.pin:hover, .pin:focus-visible { transform: translate(-50%, -50%) scale(1.3); z-index: 2; outline: none; }
.pin-empty { background: #fff; border-color: #6b7280; }
.pin-info { background: #3b82f6; }
.pin-app { background: #f59e0b; }
.pin-approved { background: var(--brand-dark); }
.pin-legacy { background: #8b5cf6; }
.pin.flash { animation: pin-flash 1.2s ease-out 2; z-index: 3; }
@keyframes pin-flash {
  0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, .9); }
  100% { box-shadow: 0 0 0 22px rgba(239, 68, 68, 0); }
}

/* Lot popup (native <dialog>) */
.lot-dialog {
  width: min(520px, calc(100vw - 24px));
  max-height: calc(100vh - 48px);
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  box-shadow: 0 20px 50px rgba(0, 0, 0, .25);
  color: var(--text);
}
.lot-dialog.wide { width: min(1000px, calc(100vw - 24px)); }
.lot-dialog[open] { display: flex; flex-direction: column; }
.lot-dialog::backdrop { background: rgba(17, 24, 39, .45); }
.lot-dialog-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.lot-dialog-head h2 { flex: 1; margin: 0; font-size: 16px; font-weight: 800; }
.btn-icon { min-width: 36px; min-height: 36px; padding: 4px 8px; font-size: 18px; }
.lot-dialog-body { padding: 14px; overflow: auto; font-size: 14px; }
.loading { padding: 24px; text-align: center; color: var(--muted); }

/* Lot details (getinfo.asp) */
.lot-info { display: flex; flex-direction: column; gap: 12px; }
.lot-info h3 { margin: 0 0 6px; font-size: 12px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.lot-note { padding: 10px 12px; border-radius: 10px; background: var(--hover); white-space: pre-wrap; }
.lot-status { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; }
.lot-status .what { font-weight: 700; }
.lot-status .who { font-size: 13px; color: var(--muted); }
.chip { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.chip-approved { background: var(--brand-soft); color: #065f46; }
.chip-pending { background: #fef3c7; color: #92400e; }
.chip-draft { background: var(--hover); color: var(--muted); }
.lot-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.spec-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.spec-table th, .spec-table td { padding: 6px 8px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.spec-table th { font-size: 11px; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.spec-table td:first-child { font-weight: 700; }
.table-scroll { overflow-x: auto; }
.thumbs { display: flex; flex-wrap: wrap; gap: 8px; }
.thumbs img { display: block; width: 150px; height: auto; border-radius: 8px; border: 1px solid var(--border); }

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: min(var(--sidebar-w), 85vw);
    transform: translateX(-105%);
    transition: transform .18s ease;
    box-shadow: 20px 0 40px rgba(0, 0, 0, .15);
  }
  body.nav-open .sidebar { transform: translateX(0); }
  body.nav-open .scrim { display: block; }
  .btn.menu-btn { display: inline-flex; }
  .topbar-logo { display: block; }
  .topbar h1 { display: none; }
}
@media (max-width: 640px) {
  .content { padding: 12px; }
  .map-viewport { height: calc(100vh - 260px); }
  .map-tools { width: 100%; }
  .map-find { flex: 1 1 100%; min-width: 0; }
  .map-find .input { flex: 1 1 0; width: 0; min-width: 0; }
  .lot-dialog { max-height: calc(100vh - 24px); }
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .stat { padding: 10px; }
  .stat .v { font-size: 22px; }
  .topbar { padding: 8px 12px; }
  .topbar .pill { display: none; }
}
