:root {
  --bg: #0b1120;
  --bg-elev: #111827;
  --bg-card: #162033;
  --border: #26334d;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #0ea5e9;
  --accent-strong: #0284c7;
  --pass: #22c55e;
  --pass-bg: rgba(34, 197, 94, 0.14);
  --fail: #ef4444;
  --fail-bg: rgba(239, 68, 68, 0.14);
  --warn: #f59e0b;
  --warn-bg: rgba(245, 158, 11, 0.14);
  --mono: "JetBrains Mono", "Consolas", monospace;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  max-width: 100%;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.45;
}

a {
  color: #38bdf8;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* Top Header */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 54px;
  padding: 8px 14px;
  background: #090e1a;
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 50;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex-wrap: wrap;
}

.brand-logo {
  font-weight: 800;
  font-size: 1.08rem;
  letter-spacing: -0.02em;
  color: #f8fafc;
}

.brand-pill {
  font-family: var(--mono);
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(14, 165, 233, 0.16);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.35);
  white-space: nowrap;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  min-width: 0;
}

.drawer-toggle {
  display: none;
}

.demo-banner {
  background: linear-gradient(90deg, rgba(14, 165, 233, 0.18), rgba(16, 185, 129, 0.14));
  border-bottom: 1px solid rgba(56, 189, 248, 0.3);
  padding: 6px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.82rem;
}

.hidden {
  display: none !important;
}

/* Buttons & Inputs */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 7px 12px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease;
  color: var(--text);
  background: #1e293b;
}

.btn:hover {
  background: #283548;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent-strong);
  color: #ffffff;
}

.btn-primary:hover {
  background: #0369a1;
}

.btn-accent {
  background: #059669;
  color: #ffffff;
}

.btn-accent:hover {
  background: #047857;
}

.btn-secondary {
  background: #1e293b;
  border-color: var(--border);
}

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--muted);
}

.btn-sm {
  padding: 5px 9px;
  font-size: 0.76rem;
}

.full-w {
  width: 100%;
}

.ctrl-input, .ctrl-range {
  width: 100%;
  background: #0b1222;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 9px;
  font-size: 0.82rem;
  min-width: 0;
}

.ctrl-range {
  padding: 0;
  border: none;
  background: transparent;
}

label {
  display: block;
  font-size: 0.76rem;
  color: var(--muted);
  margin-bottom: 3px;
}

.form-row {
  margin-bottom: 10px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.checkbox-row input {
  width: auto;
}

.checkbox-row label {
  margin: 0;
  color: var(--text);
}

/* Main 3-Column Desktop CAD Workspace (> 1440px) */
.workspace-grid {
  display: grid;
  grid-template-columns: 295px minmax(0, 1fr) 335px;
  min-height: calc(100vh - 86px);
  width: 100%;
  max-width: 100%;
}

.drawer-panel {
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  padding: 12px;
  overflow-y: auto;
  min-width: 0;
}

.drawer-right {
  border-right: none;
  border-left: 1px solid var(--border);
}

.panel-header-mobile {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 8px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.section-block {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 10px;
}

.section-block h3 {
  margin: 0 0 8px 0;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #93c5fd;
}

.fixture-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 230px;
  overflow-y: auto;
}

.fixture-item {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 8px;
  background: #0f172a;
  cursor: pointer;
  font-size: 0.78rem;
}

.fixture-item.selected {
  border-color: var(--accent);
  background: rgba(14, 165, 233, 0.12);
}

.fixture-item .sku-title {
  font-weight: 700;
  color: #f8fafc;
}

.fixture-item .sku-meta {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.72rem;
}

/* Center Canvas Area */
.center-stage {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: #070b14;
}

.compliance-ribbon {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding: 8px 12px;
  background: #0d1424;
  border-bottom: 1px solid var(--border);
}

.badge-card {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 9px;
  background: var(--bg-card);
  min-width: 0;
}

.badge-card.status-pass {
  border-color: rgba(34, 197, 94, 0.5);
  background: var(--pass-bg);
}

.badge-card.status-fail {
  border-color: rgba(239, 68, 68, 0.55);
  background: var(--fail-bg);
}

.badge-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  font-size: 0.72rem;
  color: var(--muted);
}

.badge-state {
  font-family: var(--mono);
  font-weight: 800;
  font-size: 0.72rem;
}

.status-pass .badge-state { color: #4ade80; }
.status-fail .badge-state { color: #f87171; }

.badge-metric {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 0.84rem;
  color: #f8fafc;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.canvas-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px 12px;
  background: #0b1120;
  border-bottom: 1px solid var(--border);
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.canvas-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 440px;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  overflow: hidden;
}

#photometric-canvas {
  width: 100%;
  height: 100%;
  min-height: 440px;
  display: block;
  touch-action: none;
  cursor: crosshair;
}

.canvas-hud {
  position: absolute;
  bottom: 10px;
  left: 10px;
  right: 10px;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px;
  pointer-events: none;
}

.hud-pill {
  background: rgba(9, 14, 26, 0.88);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: #cbd5e1;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.kpi-box {
  background: #0f172a;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
}

.kpi-box small {
  display: block;
  font-size: 0.68rem;
  color: var(--muted);
}

.kpi-box strong {
  font-family: var(--mono);
  font-size: 0.85rem;
}

.diag-list {
  margin: 0;
  padding-left: 16px;
  font-size: 0.76rem;
  color: #cbd5e1;
}

.pass-disclaimer {
  font-size: 0.71rem;
  color: var(--muted);
  margin-top: 8px;
  line-height: 1.35;
}

/* Modal & Backdrop */
.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.72);
  z-index: 35;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}

.modal-box {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 10px;
  width: 100%;
  max-width: 580px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 16px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.05rem;
}

.pricing-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.price-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
}

.price-card strong {
  font-size: 1.1rem;
  display: block;
  margin: 4px 0;
}

/* Subpages (Tools / Ordinances / Legal) */
.subpage-body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.subpage-nav {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.nav-link {
  font-size: 0.82rem;
  color: #cbd5e1;
  padding: 4px 8px;
  border-radius: 5px;
}

.nav-link:hover {
  background: #1e293b;
  text-decoration: none;
}

.subpage-main {
  flex: 1 0 auto;
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 20px 16px 40px;
}

.seo-hero {
  margin-bottom: 20px;
}

.eyebrow {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: #38bdf8;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}

.seo-hero h1 {
  margin: 0 0 8px 0;
  font-size: clamp(1.35rem, 3vw, 1.95rem);
  color: #f8fafc;
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 330px), 1fr));
  gap: 16px;
}

.card, .tool-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  min-width: 0;
}

.tool-card h2 {
  margin: 0 0 12px 0;
  font-size: 1rem;
}

.bug-banner {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.bug-banner > div {
  background: #0b1120;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px;
}

.bug-banner small {
  display: block;
  font-size: 0.7rem;
  color: var(--muted);
}

.bug-banner strong {
  font-family: var(--mono);
  font-size: 0.92rem;
}

.warn-callout {
  background: var(--fail-bg);
  border: 1px solid rgba(239, 68, 68, 0.5);
  color: #fecaca;
  border-radius: 6px;
  padding: 8px 10px;
  margin-bottom: 12px;
  font-size: 0.8rem;
}

.svg-wrap {
  background: #0b1120;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  margin-bottom: 12px;
}

.polar-svg {
  width: 100%;
  height: auto;
  display: block;
}

.table-scroll {
  overflow-x: auto;
  max-width: 100%;
  margin-bottom: 12px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}

.data-table th, .data-table td {
  border-bottom: 1px solid var(--border);
  padding: 6px 8px;
  text-align: left;
}

.ord-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
  gap: 12px;
}

.ord-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0 12px;
}

.ord-meta span {
  font-family: var(--mono);
  font-size: 0.7rem;
  background: #0b1120;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 6px;
}

.cta-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.legal-footer {
  background: #070b14;
  border-top: 1px solid var(--border);
  padding: 10px 14px;
  font-size: 0.75rem;
  color: var(--muted);
}

.legal-footer-inner {
  max-width: 1560px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

/* Responsive Breakpoints (1366x850, 1200x850, 1024x768, 390x844 -> Slide-over Drawers, 0px Horizontal Overflow) */
@media (max-width: 1440px) {
  .drawer-toggle {
    display: inline-flex;
  }

  .workspace-grid {
    grid-template-columns: minmax(0, 1fr);
    min-height: calc(100vh - 96px);
  }

  .drawer-panel {
    position: fixed;
    top: 0;
    bottom: 0;
    width: min(340px, 92vw);
    max-width: 92vw;
    z-index: 60;
    transition: transform 0.2s ease;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
  }

  .drawer-left {
    left: 0;
    transform: translateX(-105%);
  }

  .drawer-right {
    right: 0;
    left: auto;
    transform: translateX(105%);
  }

  .drawer-left.open {
    transform: translateX(0);
  }

  .drawer-right.open {
    transform: translateX(0);
  }

  .panel-header-mobile {
    display: flex;
  }
}

@media (max-width: 760px) {
  .compliance-ribbon {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .canvas-wrap, #photometric-canvas {
    min-height: 360px;
  }

  .topbar {
    padding: 8px 10px;
  }
}

/* Interactive CAD Mode Toolbar */
.cad-mode-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: #0b1120;
  border-bottom: 1px solid var(--border);
  max-width: 100%;
}

.btn-xs {
  padding: 4px 8px;
  font-size: 0.72rem;
}

.grade-inline {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 0;
  font-size: 0.72rem;
  color: var(--muted);
}

.grade-input {
  width: 54px;
  background: #0f172a;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 3px 5px;
  font-family: var(--mono);
  font-size: 0.72rem;
}

/* Floating AI Permit Copilot Launcher & Drawer */
.copilot-fab {
  position: fixed;
  right: 14px;
  bottom: 14px;
  z-index: 70;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, #0284c7, #0369a1);
  color: #ffffff;
  border: 1px solid rgba(56, 189, 248, 0.55);
  border-radius: 999px;
  padding: 9px 14px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 10px 26px rgba(2, 6, 23, 0.55);
  max-width: calc(100vw - 24px);
}

.copilot-fab:hover {
  background: linear-gradient(135deg, #0ea5e9, #0284c7);
}

.copilot-badge {
  font-family: var(--mono);
  font-size: 0.68rem;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.65);
  color: #bae6fd;
  border: 1px solid rgba(186, 230, 253, 0.35);
  white-space: nowrap;
}

.copilot-drawer {
  position: fixed;
  right: 12px;
  bottom: 12px;
  width: min(380px, calc(100vw - 24px));
  max-height: min(560px, calc(100vh - 84px));
  z-index: 75;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  box-shadow: 0 18px 40px rgba(2, 6, 23, 0.72);
  overflow-y: auto;
}

.copilot-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
}

.copilot-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.copilot-messages {
  flex: 1 1 auto;
  min-height: 110px;
  max-height: 210px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: #0b1222;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
}

.copilot-msg {
  font-size: 0.78rem;
  line-height: 1.4;
  padding: 6px 8px;
  border-radius: 6px;
  white-space: pre-wrap;
  word-break: break-word;
}

.copilot-msg.assistant {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
}

.copilot-msg.user {
  background: rgba(14, 165, 233, 0.18);
  color: #f8fafc;
  border: 1px solid rgba(56, 189, 248, 0.35);
  align-self: flex-end;
  max-width: 90%;
}

.copilot-composer {
  display: flex;
  align-items: center;
  gap: 6px;
}

.copilot-support {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 0.76rem;
}

.copilot-support summary {
  cursor: pointer;
  color: #93c5fd;
  font-weight: 600;
}

.inq-status {
  margin-top: 6px;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: #4ade80;
}
