/* ═══════════════════════════════════════════════════
   POWERBIM — Inventario Portuario — Dark Theme CSS
   ═══════════════════════════════════════════════════ */
:root {
  --primary:    #0A1628;
  --secondary:  #111D2E;
  --border:     #1E2D45;
  --accent:     #00D4FF;
  --text:       #E8EDF5;
  --muted:      #8B99B3;   /* QW1: contraste WCAG AA ~4.6:1 (era #6B7A99 ~3.2:1) */
  --granito:    #E69F00;   /* QW4: Okabe-Ito naranja (era #E85D4A) */
  --al-bloque:  #56B4E9;   /* QW4: Okabe-Ito azul cielo (era #4A9EE8) */
  --al-palet:   #009E73;   /* QW4: Okabe-Ito verde azulado (era #A78BFA) */
  --libre:      #2ECC71;
  --sidebar-w:  230px;
  --results-w:  280px;
  --header-h:   0px;
  /* F2.1: 4-step elevation system */
  --l0-canvas:  #080F1C;   /* base page background */
  --l1-sidebar: #0D1525;   /* sidebar nav (already updated to this) */
  --l2-cards:   #111D2E;   /* KPI cards, collapsible panels */
  --l3-modals:  #172438;   /* tooltips, modals, overlays */
}

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

html, body {
  height: 100%;
  background: var(--primary);
  color: var(--text);
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 14px;
  overflow: hidden;
}

/* ── Layout ─────────────────────────────────────────── */
#sidebar {
  position: fixed;
  top: 12px; left: 12px;
  width: var(--sidebar-w);
  max-height: 520px;           /* valor real del panel — evita budget de animación perdido */
  background: rgba(13, 21, 37, 0.82);
  backdrop-filter: blur(12px) saturate(180%) brightness(0.7);
  -webkit-backdrop-filter: blur(12px) saturate(180%) brightness(0.7);
  border: 1px solid rgba(0, 212, 255, 0.25);
  border-radius: 16px;
  box-shadow:
    0 8px 40px rgba(0, 0, 0, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  will-change: width, max-height;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 100;
  padding: 0;
  /* Expand: spring suave — entra con ligero rebote */
  transition: width 0.5s cubic-bezier(0.22, 1, 0.36, 1),
              max-height 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Scrollable inner body */
.sidebar-body {
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1;
  min-height: 0;
  padding-bottom: 24px;
  opacity: 1;
  transition: opacity 0.18s ease;
  scrollbar-width: thin;
  scrollbar-color: rgba(30, 45, 69, 0.8) transparent;
}
.sidebar-body::-webkit-scrollbar        { width: 5px; }
.sidebar-body::-webkit-scrollbar-track  { background: transparent; }
.sidebar-body::-webkit-scrollbar-thumb  { background: var(--border); border-radius: 3px; }
.sidebar-body::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* Collapsed pill */
#sidebar.collapsed {
  width: 82px;
  max-height: 54px;
  /* Collapse: ease-in-out más rápido y sin rebote */
  transition: width 0.32s cubic-bezier(0.4, 0, 0.6, 1),
              max-height 0.32s cubic-bezier(0.4, 0, 0.6, 1);
}
#sidebar.collapsed .sidebar-body {
  opacity: 0;
  transition: opacity 0.1s ease;
}
#sidebar.collapsed .sidebar-header {
  border-bottom: none;
  padding: 10px 14px;
  gap: 10px;
}
#sidebar.collapsed .sidebar-header #btn-collapse { margin-left: 0; }
#sidebar.collapsed .sidebar-header .logo-name,
#sidebar.collapsed .sidebar-header .logo-sub { display: none; }

#viewer-container {
  position: fixed;
  top: 0; right: 0; bottom: 0; left: 0;
  /* Explicit dimensions prevent CLS: when .adsk-viewing-viewer is injected
     dynamically, its width/height:100% resolves against a parent that already
     has known pixel dimensions (100vw × 100vh). Without this, the browser may
     compute the parent as 0×0 at injection time, causing a large layout shift. */
  width: 100vw;
  height: 100vh;
  transition: none;
}

/* ── Sidebar Header ─────────────────────────────────── */
.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 14px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.logo-mark {
  font-size: 1.5rem;
  color: var(--accent);
  flex-shrink: 0;
}
.logo-name {
  font-family: 'Space Mono', monospace;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.04em;
}
.logo-sub {
  font-size: 0.65rem;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
#btn-collapse {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.7rem;
  padding: 4px;
  flex-shrink: 0;
}
#btn-collapse:hover { color: var(--text); }

/* ── Section labels ─────────────────────────────────── */
.section-title {
  font-family: 'Space Mono', monospace;
  font-size: 0.62rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 14px 14px 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.divider { height: 1px; background: var(--border); margin: 8px 0; }

/* ── Status badge ───────────────────────────────────── */
.status-badge {
  display: inline-block;
  margin: 0 14px;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}
.status-ok      { background: rgba(46,204,113,0.15); color: #2ECC71; border: 1px solid rgba(46,204,113,0.3); }
.status-loading { background: rgba(0,212,255,0.12);  color: var(--accent); border: 1px solid rgba(0,212,255,0.25); }
.status-error   { background: rgba(232,93,74,0.15);  color: var(--granito); border: 1px solid rgba(232,93,74,0.3); }

/* ── Drop zone ──────────────────────────────────────── */
.drop-zone {
  display: block;
  margin: 6px 14px;
  padding: 18px 12px;
  border: 2px dashed var(--border);
  border-radius: 10px;
  background: var(--secondary);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.2s, box-shadow 0.2s;
}
.drop-zone:hover,
.drop-zone.dragover {
  border-color: var(--accent);
  background: rgba(0,212,255,0.06);
}
.drop-icon  { font-size: 1.6rem; margin-bottom: 4px; }
.drop-text  { font-size: 0.8rem; color: var(--text); }
.drop-hint  { font-size: 0.7rem; color: var(--muted); margin-top: 2px; }

.file-info {
  margin: 4px 14px 0;
  padding: 8px 10px;
  background: rgba(0,212,255,0.08);
  border: 1px solid rgba(0,212,255,0.2);
  border-radius: 8px;
  font-size: 0.75rem;
  color: var(--accent);
  word-break: break-all;
}

/* ── Buttons ────────────────────────────────────────── */
.btn-primary {
  display: block;
  margin: 10px 14px 0;
  padding: 10px;
  background: var(--accent);
  color: var(--primary);
  border: none;
  border-radius: 8px;
  font-family: 'Space Mono', monospace;
  font-weight: 700;
  font-size: 0.82rem;
  cursor: pointer;
  width: calc(100% - 28px);
  transition: background 0.2s, transform 0.1s;
}
.btn-primary:hover:not(:disabled) { background: #00B8D9; transform: translateY(-1px); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-micro {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 4px;
  font-size: 0.65rem;
  padding: 2px 7px;
  cursor: pointer;
}
.btn-micro:hover { border-color: var(--accent); color: var(--accent); }

/* ── Progress panel ─────────────────────────────────── */
.progress-panel { padding: 6px 14px; }
.step {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  font-size: 0.78rem;
  color: var(--muted);
}
.step.active { color: var(--accent); }
.step.done   { color: #2ECC71; }
.step-icon   { font-size: 0.8rem; width: 16px; text-align: center; }
.progress-bar-wrap {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 4px 0 8px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.3s ease;
}

/* ── Metrics ────────────────────────────────────────── */
.metrics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 4px 14px;
}
.metric-card {
  background: var(--l2-cards);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.metric-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
}
.metric-card.granito::before  { background: var(--granito); }
.metric-card.al-bloque::before{ background: var(--al-bloque); }
.metric-card.al-palet::before { background: var(--al-palet); }
.metric-card.libre::before    { background: var(--libre); }
.metric-card.ocupado::before  { background: var(--accent); }
.metric-label { font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); }
.metric-value { font-family: 'Space Mono', monospace; font-size: 1.5rem; font-weight: 700; margin: 2px 0; }
.metric-sub   { font-size: 0.7rem; color: var(--muted); }
.metric-card.granito  .metric-value { color: var(--granito); }
.metric-card.al-bloque .metric-value{ color: var(--al-bloque); }
.metric-card.al-palet .metric-value { color: var(--al-palet); }
.metric-card.libre  .metric-value   { color: var(--libre); }
.metric-card.ocupado .metric-value  { color: var(--accent); }

/* ── New metric elements (vol-total, chm-info, m-total) ── */
.metric-card.vol-total {
  grid-column: span 2;
  background: linear-gradient(135deg, rgba(0,212,255,0.08), rgba(0,212,255,0.04));
  border-top: 1px solid rgba(0,212,255,0.2);
}

.metric-chm-info {
  font-size: 10px;
  color: var(--muted);
  text-align: center;
  padding: 4px 0 2px;
  letter-spacing: 0.02em;
}

#m-total {
  font-size: 11px;
  color: var(--accent);
  font-weight: 600;
  text-align: center;
  letter-spacing: 0.03em;
}

/* ── Layer toggles ──────────────────────────────────── */
.layers { padding: 4px 14px; display: flex; flex-direction: column; gap: 6px; }
.layer-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  cursor: pointer;
}
.layer-toggle input[type=checkbox] { accent-color: var(--accent); }
.layer-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

/* ── Transform panel ────────────────────────────────── */
.transform-panel { padding: 4px 14px; display: flex; flex-direction: column; gap: 8px; }
.transform-row {
  display: grid;
  grid-template-columns: 52px 1fr 36px;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  color: var(--muted);
}
.transform-row input[type=range] {
  accent-color: var(--accent);
  cursor: pointer;
}
.transform-row .val {
  font-family: 'Space Mono', monospace;
  font-size: 0.7rem;
  color: var(--accent);
  text-align: right;
}

/* ── Export buttons ─────────────────────────────────── */
.export-btns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 4px 14px;
}
.btn-export {
  padding: 8px;
  background: var(--secondary);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  font-size: 0.78rem;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}
.btn-export:hover { border-color: var(--accent); color: var(--accent); }
.btn-export-ifc {
  background: linear-gradient(135deg, rgba(0,212,255,0.10), rgba(167,139,250,0.10));
  border-color: rgba(0,212,255,0.35);
  font-weight: 600;
}
.btn-export-ifc:hover {
  border-color: #00d4ff;
  color: #00d4ff;
  background: linear-gradient(135deg, rgba(0,212,255,0.18), rgba(167,139,250,0.18));
}

/* ── BIM Parameters section ─────────────────────────── */
.bim-params-section { margin: 0; }
.bim-params-section > summary { list-style: none; cursor: pointer; }
.bim-params-section > summary::-webkit-details-marker { display: none; }
.bim-params-summary {
  justify-content: space-between;
  user-select: none;
}
.bim-params-section[open] > .bim-params-summary {
  color: var(--accent);
}
.bim-params-panel {
  padding: 4px 0;
}
.bim-params-group {
  padding: 0 14px;
}
.bim-group-label {
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
  font-weight: 600;
}
.bim-param-row {
  display: grid;
  grid-template-columns: 62px 1fr;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 4px;
}
.bim-input {
  background: var(--secondary);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text);
  font-size: 0.72rem;
  font-family: inherit;
  padding: 5px 8px;
  width: 100%;
  outline: none;
  transition: border-color 0.2s;
}
.bim-input:focus {
  border-color: var(--accent);
}
.bim-input::placeholder {
  color: rgba(139, 153, 179, 0.5);
}
.bim-custom-row {
  display: grid;
  grid-template-columns: 1fr 1fr 72px 20px;
  gap: 4px;
  align-items: center;
  margin-bottom: 4px;
}
.bim-select {
  background: var(--secondary);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text);
  font-size: 0.65rem;
  font-family: inherit;
  padding: 4px 2px;
  outline: none;
  cursor: pointer;
}
.bim-select:focus {
  border-color: var(--accent);
}
.bim-custom-remove {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.75rem;
  padding: 0;
  line-height: 1;
  text-align: center;
}
.bim-custom-remove:hover {
  color: #f87171;
}
.bim-add-btn {
  margin-top: 6px;
  width: 100%;
  text-align: center;
  padding: 4px 0;
}
.bim-params-badge {
  background: var(--accent);
  color: var(--primary);
  font-size: 0.58rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

/* ── Element Editor (per-detection editing) ─────────────── */
.element-editor {
  margin: 0;
  padding: 0 0 4px 0;
  background: linear-gradient(135deg, rgba(0,212,255,0.04), rgba(167,139,250,0.04));
  border-radius: 8px;
  border: 1px solid rgba(0,212,255,0.15);
  margin: 4px 8px;
}
.editor-title {
  padding: 10px 14px 4px !important;
  color: var(--accent) !important;
}
.editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 14px 6px;
}
.editor-badge {
  background: var(--accent);
  color: var(--primary);
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  font-family: 'Space Mono', monospace;
}
.editor-conf {
  font-size: 0.68rem;
  color: var(--muted);
  font-family: 'Space Mono', monospace;
}
.editor-fields {
  padding: 0 14px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.editor-row {
  display: grid;
  grid-template-columns: 62px 1fr;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  color: var(--muted);
}
.editor-select {
  width: 100%;
  padding: 5px 6px;
}
.editor-num {
  width: 100%;
  padding: 5px 8px;
  font-family: 'Space Mono', monospace;
  font-size: 0.72rem;
}
.editor-num::-webkit-inner-spin-button,
.editor-num::-webkit-outer-spin-button {
  opacity: 1;
}
.editor-metrics {
  display: flex;
  justify-content: space-between;
  padding: 6px 14px;
  font-size: 0.68rem;
  color: var(--muted);
  font-family: 'Space Mono', monospace;
}
.editor-custom {
  padding: 4px 14px 0;
}
.editor-custom .bim-group-label {
  margin-bottom: 4px;
}
.editor-custom-row {
  display: grid;
  grid-template-columns: 1fr 1fr 20px;
  gap: 4px;
  align-items: center;
  margin-bottom: 4px;
}
.editor-custom-remove {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.75rem;
  padding: 0;
  line-height: 1;
  text-align: center;
}
.editor-custom-remove:hover {
  color: #f87171;
}
.btn-editor-delete {
  display: block;
  width: calc(100% - 28px);
  margin: 8px 14px 6px;
  padding: 7px 0;
  background: rgba(248, 113, 113, 0.08);
  border: 1px solid rgba(248, 113, 113, 0.25);
  border-radius: 6px;
  color: #f87171;
  font-size: 0.72rem;
  font-family: 'Space Mono', monospace;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: background 0.2s, border-color 0.2s;
}
.btn-editor-delete:hover {
  background: rgba(248, 113, 113, 0.18);
  border-color: #f87171;
}
.btn-editor-delete:focus-visible {
  outline: 2px solid #f87171;
  outline-offset: 2px;
}

/* ── BIM Viewer button + status ──────────────────────── */
.btn-bim {
  margin: 4px 14px;
  font-size: 0.82rem;
}
.bim-status {
  font-size: 0.72rem;
  padding: 4px 14px;
  border-radius: 6px;
  margin: 4px 14px;
}
.bim-status-progress { color: var(--accent); }
.bim-status-ok       { color: #4ade80; }
.bim-status-error    { color: #f87171; }

/* ── Tooltip ────────────────────────────────────────── */
.tooltip {
  position: fixed;
  background: var(--secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.78rem;
  pointer-events: none;
  z-index: 1000;
  max-width: 220px;
  line-height: 1.6;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}
.tooltip b { color: var(--accent); }

/* ── Toast ──────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--secondary);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 0.82rem;
  z-index: 2000;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  animation: slide-in 0.3s ease;
}
@keyframes slide-in {
  from { transform: translateX(120%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ── APS Viewer overrides ───────────────────────────── */
.adsk-viewing-viewer {
  background: var(--primary) !important;
  /* Pre-size the div APS injects so it never starts at 0×0.
     Prevents the CLS=0.888 caused by .adsk-viewing-viewer expanding
     from 0px to full viewport on viewer init. */
  width: 100% !important;
  height: 100% !important;
}
.adsk-button, .toolbar-button {
  background: var(--secondary) !important;
  border-color: var(--border) !important;
}

/* ── Utilities ──────────────────────────────────────── */
.hidden { display: none !important; }

/* ── QW5: Focus states para navegación por teclado ─── */
.btn-primary:focus-visible,
.btn-export:focus-visible,
.btn-micro:focus-visible,
#btn-collapse:focus-visible,
#btn-reset-transform:focus-visible,
#btn-analyze:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
input[type=checkbox]:focus-visible,
input[type=range]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.drop-zone:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-color: var(--accent);
}

/* ── Charts panel ─────────────────────────────────────────────── */
#charts-root {
  margin-top: 4px;
}
.chart-label {
  font-size: 10px;
  color: #6b7a99;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 8px 0 4px;
}
.charts-empty {
  font-size: 11px;
  color: #4a5568;
  text-align: center;
  padding: 16px 0;
}
.recharts-tooltip-wrapper {
  outline: none;
}
.recharts-default-tooltip {
  background: #0b1525 !important;
  border: 1px solid #2e4a6a !important;
  border-radius: 4px !important;
  font-size: 11px !important;
  box-shadow: 0 2px 10px rgba(0,0,0,0.6) !important;
}
.recharts-tooltip-item {
  color: #e2e8f0 !important;
}
.recharts-tooltip-label {
  color: #7ec8e3 !important;
}

/* ── F2.6: Responsive mobile ────────────────────────────────── */
@media (max-width: 768px) {
  :root {
    --sidebar-w: 100vw;
  }

  html, body {
    overflow: auto;
  }

  #sidebar {
    position: fixed;
    top: 0; left: 0; right: 0;
    bottom: auto;
    width: 100vw;
    height: auto;
    max-height: 60px;
    border-radius: 0;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: rgba(13, 21, 37, 0.96);
    flex-direction: row;
    align-items: center;
    overflow: hidden;
    border: none;
    border-bottom: 1px solid var(--border);
    padding: 0;
    z-index: 200;
  }

  #sidebar .sidebar-header {
    padding: 10px 14px;
    border-bottom: none;
    border-right: 1px solid var(--border);
    flex-shrink: 0;
  }

  /* Hide all sidebar content except header on mobile */
  #sidebar .section-title,
  #sidebar .drop-zone,
  #sidebar .file-info,
  #sidebar #btn-analyze,
  #sidebar .progress-panel,
  #sidebar #metrics-panel,
  #sidebar .divider,
  #sidebar #charts-root {
    display: none !important;
  }

  #viewer-container {
    top: 60px;
    left: 0;
    right: 0;
  }

}

@media (max-width: 480px) {
  .metric-value {
    font-size: 1.2rem;
  }

  .drop-icon {
    font-size: 1.2rem;
  }
}

/* ── F2.4: Viewer skeleton loader ─────────────────────────── */
.viewer-skeleton {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  background: var(--primary);
  gap: 16px;
}

.viewer-skeleton .skeleton-pulse {
  width: 120px;
  height: 120px;
  background: var(--border);
  border-radius: 12px;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
}

.viewer-skeleton .skeleton-text {
  font-size: 0.85rem;
  color: var(--muted);
  letter-spacing: 0.05em;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
  animation-delay: 0.3s;
}

@keyframes skeleton-shimmer {
  0%, 100% { opacity: 0.4; }
  50%       { opacity: 1;   }
}

/* ── F3.1: Confidence threshold slider ─────────────────────── */
.conf-slider-row {
  padding: 4px 14px;
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  color: var(--muted);
}
.conf-slider-row input[type=range] {
  accent-color: var(--accent);
  cursor: pointer;
}
.conf-slider-row .val {
  font-family: 'Space Mono', monospace;
  font-size: 0.7rem;
  color: var(--accent);
  min-width: 32px;
  text-align: right;
}

/* Enhanced drop zone hover feedback */
.drop-zone:hover {
  border-color: var(--accent);
  background: rgba(0,212,255,0.12);
  transform: scale(1.01);
  box-shadow: 0 0 12px rgba(0,212,255,0.15);
}

.drop-zone.dragover {
  border-color: var(--accent);
  background: rgba(0,212,255,0.16);
  transform: scale(1.02);
  box-shadow: 0 0 20px rgba(0,212,255,0.25);
}

.drop-zone.dragover .drop-icon {
  animation: bounce-icon 0.6s ease infinite;
}

@keyframes bounce-icon {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-4px); }
}

/* ── Prefers-reduced-motion: solid fallback for backdrop-filter ── */
@media (prefers-reduced-motion: reduce) {
  #sidebar {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: rgba(13, 21, 37, 0.96);
  }
}

/* ── Nueva Captura secondary button ──────────────────────────────────────── */
.btn-secondary {
  display: block;
  margin: 12px 14px 0;
  padding: 8px 12px;
  background: transparent;
  color: var(--accent);
  border: 1px solid rgba(0, 212, 255, 0.35);
  border-radius: 8px;
  font-family: 'Space Mono', monospace;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  width: calc(100% - 28px);
  text-align: left;
  transition: background 0.2s, border-color 0.2s;
}
.btn-secondary:hover {
  background: rgba(0, 212, 255, 0.08);
  border-color: var(--accent);
}
.btn-secondary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ── Panel 2: Results ─────────────────────────────────────────────────────── */
#panel-results {
  position: fixed;
  top: 12px;
  left: calc(12px + var(--sidebar-w) + 8px);
  height: calc(100vh - 24px);
  width: var(--results-w);
  background: rgba(13, 21, 37, 0.82);
  backdrop-filter: blur(12px) saturate(180%) brightness(0.7);
  -webkit-backdrop-filter: blur(12px) saturate(180%) brightness(0.7);
  border: 1px solid rgba(0, 212, 255, 0.25);
  border-radius: 16px;
  box-shadow:
    0 8px 40px rgba(0, 0, 0, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  will-change: transform, opacity;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 100;
  padding: 0 0 24px 0;
  /* Slide-in from left */
  transform: translateX(-20px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.3s ease, opacity 0.3s ease;
  scrollbar-width: thin;
  scrollbar-color: rgba(30, 45, 69, 0.8) transparent;
}
#panel-results::-webkit-scrollbar        { width: 5px; }
#panel-results::-webkit-scrollbar-track  { background: transparent; }
#panel-results::-webkit-scrollbar-thumb  { background: var(--border); border-radius: 3px; }
#panel-results::-webkit-scrollbar-thumb:hover { background: var(--muted); }

#panel-results.visible {
  transform: translateX(0);
  opacity: 1;
  pointer-events: auto;
}

/* Shift results panel when sidebar collapses */
#sidebar.collapsed ~ #panel-results {
  left: calc(12px + 52px + 8px);
}

.panel-results-header {
  padding: 12px 14px 4px;
  flex-shrink: 0;
}

/* Mobile: hide results panel (not enough space) */
@media (max-width: 768px) {
  #panel-results { display: none; }
}

/* ── Keyboard shortcuts panel (Feature 3) ─────────────────────────────────── */
.shortcuts-panel {
  position: fixed;
  bottom: 72px;
  right: 24px;
  width: 280px;
  background: var(--l3-modals);
  border: 1px solid rgba(0, 212, 255, 0.3);
  border-radius: 12px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.55);
  z-index: 2000;
  animation: slide-in 0.2s ease;
  overflow: hidden;
}
.shortcuts-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-family: 'Space Mono', monospace;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
}
.shortcuts-close {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0;
}
.shortcuts-close:hover {
  color: var(--text);
}
.shortcuts-list {
  padding: 8px 0;
}
.shortcut-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 14px;
  font-size: 0.75rem;
  color: var(--text);
}
.shortcut-row span {
  color: var(--muted);
  font-size: 0.7rem;
}
.shortcut-row kbd {
  display: inline-block;
  background: var(--secondary);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  font-family: 'Space Mono', monospace;
  font-size: 0.65rem;
  color: var(--accent);
  min-width: 20px;
  text-align: center;
}

/* ── Detection Search & Filter Toolbar ────────────────────────────────────── */
.det-toolbar {
  display: flex;
  gap: 4px;
  padding: 4px 6px 2px;
  align-items: center;
}
.det-search {
  flex: 1;
  background: var(--l2-cards);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 4px 8px;
  font-size: 0.68rem;
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
}
.det-search::placeholder { color: var(--muted); opacity: 0.6; }
.det-search:focus { border-color: var(--accent); }
.det-filter-select {
  background: var(--l2-cards);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 4px 4px;
  font-size: 0.62rem;
  color: var(--text);
  cursor: pointer;
  max-width: 80px;
}
.det-btn-fly {
  background: var(--l2-cards);
  border: 1px solid var(--border);
  border-radius: 5px;
  width: 26px;
  height: 26px;
  font-size: 0.72rem;
  color: var(--accent);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, border-color 0.2s;
  flex-shrink: 0;
}
.det-btn-fly:hover {
  background: rgba(0, 212, 255, 0.12);
  border-color: var(--accent);
}
.det-filter-stats {
  font-size: 0.6rem;
  color: var(--accent);
  text-align: center;
  padding: 2px 6px;
}
.det-row.det-filtered {
  display: none;
}

/* ── Detection Inventory List ─────────────────────────────────────────────── */
.detection-list-section { margin: 0; }
.detection-list-section > summary { list-style: none; cursor: pointer; }
.detection-list-section > summary::-webkit-details-marker { display: none; }
.detection-list-summary {
  justify-content: space-between;
  user-select: none;
}
.detection-list-section[open] > .detection-list-summary {
  color: var(--accent);
}
.detection-list-badge {
  background: var(--accent);
  color: var(--primary);
  font-size: 0.58rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}
.detection-list {
  max-height: 240px;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 2px 6px 4px;
  scrollbar-width: thin;
  scrollbar-color: rgba(30, 45, 69, 0.8) transparent;
}
.detection-list::-webkit-scrollbar       { width: 4px; }
.detection-list::-webkit-scrollbar-track { background: transparent; }
.detection-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.detection-list::-webkit-scrollbar-thumb:hover { background: var(--muted); }

.det-row {
  display: grid;
  grid-template-columns: 10px 28px 1fr 42px 32px 38px;
  align-items: center;
  gap: 4px;
  padding: 4px 6px;
  border-radius: 5px;
  font-size: 0.68rem;
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s;
  border: 1px solid transparent;
}
.det-row:hover {
  background: rgba(0, 212, 255, 0.06);
  border-color: rgba(0, 212, 255, 0.15);
}
.det-row.det-selected {
  background: rgba(0, 212, 255, 0.1);
  border-color: rgba(0, 212, 255, 0.3);
}
.det-row.det-deleted {
  opacity: 0.35;
  text-decoration: line-through;
  pointer-events: none;
}
.det-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.det-id {
  font-family: 'Space Mono', monospace;
  font-size: 0.62rem;
  color: var(--muted);
}
.det-material {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.det-area, .det-height, .det-conf {
  font-family: 'Space Mono', monospace;
  font-size: 0.6rem;
  color: var(--muted);
  text-align: right;
}
.det-edited-badge {
  display: inline-block;
  font-size: 0.52rem;
  color: var(--accent);
  margin-left: 2px;
  vertical-align: middle;
  opacity: 0.8;
}

/* ── Restore Analysis Banner ──────────────────────────────────────────────── */
.restore-banner {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--l3-modals);
  border: 1px solid rgba(0, 212, 255, 0.35);
  border-radius: 10px;
  padding: 8px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 300;
  box-shadow: 0 6px 30px rgba(0, 0, 0, 0.5);
  animation: slide-in-top 0.3s ease;
}
@keyframes slide-in-top {
  from { transform: translateX(-50%) translateY(-40px); opacity: 0; }
  to   { transform: translateX(-50%) translateY(0);     opacity: 1; }
}
.restore-text {
  font-size: 0.78rem;
  color: var(--text);
}
.btn-restore {
  background: var(--accent);
  color: var(--primary);
  border: none;
  border-radius: 6px;
  padding: 5px 12px;
  font-family: 'Space Mono', monospace;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-restore:hover {
  background: #00B8D9;
}
.btn-dismiss-restore {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0 2px;
}
.btn-dismiss-restore:hover {
  color: var(--text);
}

/* ── Auto-save indicator in sidebar ───────────────────────────────────────── */
.autosave-indicator {
  font-size: 0.62rem;
  color: var(--muted);
  text-align: center;
  padding: 4px 14px 0;
  letter-spacing: 0.04em;
  opacity: 0.7;
}

/* ── 2D Map Panel (Leaflet) ─────────────────────────────────────────────────── */
.map2d-panel {
  position: fixed;
  bottom: 16px;
  right: 16px;
  width: 420px;
  height: 340px;
  background: var(--l1-sidebar);
  border: 1px solid rgba(0, 212, 255, 0.3);
  border-radius: 12px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.55);
  z-index: 200;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* Hidden by default */
  transform: translateY(20px) scale(0.95);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.25s ease, opacity 0.2s ease;
}
.map2d-panel.map2d-visible {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: auto;
}
/* Resize handle (CSS resize) */
.map2d-panel.map2d-visible {
  resize: both;
  min-width: 300px;
  min-height: 220px;
  max-width: 80vw;
  max-height: 80vh;
}
.map2d-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--l2-cards);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  cursor: default;
}
.map2d-title {
  font-family: 'Space Mono', monospace;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
}
.map2d-header-controls {
  display: flex;
  gap: 6px;
}
.map2d-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 4px;
  width: 24px;
  height: 24px;
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, border-color 0.15s;
}
.map2d-btn:hover {
  color: var(--text);
  border-color: var(--accent);
}
.map2d-container {
  flex: 1;
  min-height: 0;
  z-index: 1;
}
/* Override Leaflet tile background for dark theme */
.map2d-container .leaflet-container {
  background: var(--primary);
}

/* Toggle button (bottom-right of viewer) */
.map2d-toggle-btn {
  position: fixed;
  bottom: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  background: rgba(13, 21, 37, 0.85);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(0, 212, 255, 0.3);
  border-radius: 10px;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 150;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}
.map2d-toggle-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}
.map2d-toggle-btn.active {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(0, 212, 255, 0.1);
}
/* Hide toggle when map panel is visible (panel replaces the button position) */
.map2d-toggle-btn.active {
  bottom: auto;
  top: 16px;
  right: 16px;
}

/* Leaflet tooltip styling */
.map2d-tooltip {
  background: var(--l3-modals) !important;
  color: var(--text) !important;
  border: 1px solid rgba(0, 212, 255, 0.3) !important;
  border-radius: 6px !important;
  font-size: 0.72rem !important;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4) !important;
  padding: 6px 10px !important;
}
.map2d-tooltip::before {
  border-top-color: rgba(0, 212, 255, 0.3) !important;
}

/* Mobile: enlarge map panel */
@media (max-width: 768px) {
  .map2d-panel {
    width: calc(100vw - 32px);
    height: 280px;
    bottom: 8px;
    right: 8px;
  }
}

/* ── Snapshot Manager + Temporal Comparison ──────────────────────────────────── */
.snapshot-actions {
  display: flex;
  gap: 6px;
  padding: 4px 14px 6px;
}
.btn-snapshot-save, .btn-snapshot-compare {
  flex: 1;
  font-size: 0.68rem !important;
  padding: 5px 6px !important;
}
.btn-snapshot-compare {
  background: rgba(0, 212, 255, 0.12) !important;
  border-color: rgba(0, 212, 255, 0.35) !important;
  color: var(--accent) !important;
}
.btn-snapshot-compare:hover:not(:disabled) {
  background: rgba(0, 212, 255, 0.2) !important;
}
.snapshot-list {
  padding: 2px 14px 4px;
  max-height: 120px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(30, 45, 69, 0.8) transparent;
}
.snapshot-empty {
  font-size: 0.68rem;
  color: var(--muted);
  text-align: center;
  padding: 6px 0;
}
.snapshot-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 4px;
  border-radius: 4px;
  font-size: 0.68rem;
  color: var(--text);
  transition: background 0.15s;
}
.snapshot-row:hover {
  background: rgba(0, 212, 255, 0.06);
}
.snapshot-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}
.snapshot-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.snapshot-meta {
  font-size: 0.6rem;
  color: var(--muted);
  white-space: nowrap;
}
.snapshot-delete {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1;
  padding: 0 2px;
  opacity: 0;
  transition: opacity 0.15s;
}
.snapshot-row:hover .snapshot-delete {
  opacity: 1;
}
.snapshot-delete:hover {
  color: #e85d4a;
}

/* ── Compare Modal ────────────────────────────────────────────────────────────── */
.compare-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fade-in 0.2s ease;
}
.compare-modal.hidden {
  display: none;
}
@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.compare-modal-inner {
  background: var(--l1-sidebar);
  border: 1px solid rgba(0, 212, 255, 0.3);
  border-radius: 16px;
  box-shadow: 0 12px 60px rgba(0, 0, 0, 0.6);
  width: 480px;
  max-width: 92vw;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.compare-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.compare-title {
  font-family: 'Space Mono', monospace;
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
}
.compare-body {
  padding: 16px;
  overflow-y: auto;
  flex: 1;
  scrollbar-width: thin;
  scrollbar-color: rgba(30, 45, 69, 0.8) transparent;
}

/* Selector */
.compare-instruction {
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 12px;
}
.compare-select-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.compare-select-row label {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.compare-select {
  width: 100%;
  font-size: 0.72rem;
}
.compare-arrow {
  font-size: 1.2rem;
  color: var(--accent);
  flex-shrink: 0;
  padding-top: 16px;
}
.compare-label-old {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #56B4E9;
  font-weight: 600;
}
.compare-label-new {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #E69F00;
  font-weight: 600;
}
.btn-compare-run {
  width: 100%;
  font-size: 0.78rem !important;
}

/* Results */
.compare-dates {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 14px;
  font-size: 0.75rem;
}
.compare-kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}
.compare-kpi {
  background: var(--l2-cards);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 6px;
  text-align: center;
}
.compare-kpi-value {
  font-family: 'Space Mono', monospace;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}
.compare-kpi-label {
  font-size: 0.6rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 2px;
}
.compare-appeared   { color: #2ECC71 !important; }
.compare-disappeared { color: #E85D4A !important; }
.compare-grew       { color: #E69F00 !important; }
.compare-shrank     { color: #56B4E9 !important; }

.compare-delta-row {
  display: flex;
  justify-content: space-around;
  font-size: 0.72rem;
  color: var(--muted);
  padding: 6px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  margin-bottom: 10px;
}

.compare-section-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  margin: 8px 0 4px;
  padding-left: 4px;
  color: var(--muted);
}

.compare-diff-list {
  margin-bottom: 6px;
}
.compare-diff-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 6px;
  font-size: 0.7rem;
  color: var(--text);
  border-radius: 4px;
}
.compare-diff-row span:nth-child(2) {
  flex: 1;
}
.compare-row-appeared {
  border-left: 3px solid #2ECC71;
  background: rgba(46, 204, 113, 0.06);
}
.compare-row-disappeared {
  border-left: 3px solid #E85D4A;
  background: rgba(232, 93, 74, 0.06);
  opacity: 0.7;
}
.compare-row-grew {
  border-left: 3px solid #E69F00;
  background: rgba(230, 159, 0, 0.06);
}
.compare-row-shrank {
  border-left: 3px solid #56B4E9;
  background: rgba(86, 180, 233, 0.06);
}

.compare-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}
.compare-actions .btn-secondary,
.compare-actions .btn-primary {
  flex: 1;
  font-size: 0.72rem !important;
}

/* ── Presentation Mode ──────────────────────────────────────────────────────── */
.btn-presentation {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.8rem;
  padding: 4px;
  transition: color 0.2s;
  flex-shrink: 0;
}
.btn-presentation:hover { color: var(--accent); }
.btn-presentation.active { color: var(--accent); }

body.presentation-mode #sidebar,
body.presentation-mode #panel-results,
body.presentation-mode .map2d-toggle-btn,
body.presentation-mode .map2d-panel,
body.presentation-mode .restore-banner,
body.presentation-mode #toast {
  opacity: 0 !important;
  pointer-events: none !important;
  transition: opacity 0.4s ease;
}
body.presentation-mode #viewer-container {
  left: 0 !important;
}
/* Show a small exit hint */
body.presentation-mode::after {
  content: 'P o Esc para salir';
  position: fixed;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(10, 22, 40, 0.7);
  backdrop-filter: blur(6px);
  color: var(--muted);
  font-size: 0.65rem;
  padding: 4px 14px;
  border-radius: 20px;
  border: 1px solid rgba(0, 212, 255, 0.2);
  z-index: 9999;
  pointer-events: none;
  opacity: 0.6;
  animation: fade-hint 4s ease forwards;
}
@keyframes fade-hint {
  0%, 60% { opacity: 0.6; }
  100% { opacity: 0; }
}

/* Compare map legend */
.map2d-compare-legend {
  background: rgba(13, 21, 37, 0.9);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(0, 212, 255, 0.25);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 0.65rem;
  color: var(--muted);
  line-height: 1.6;
}
.map2d-compare-legend span {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-right: 5px;
  vertical-align: middle;
}

/* ── @thatopen IFC Viewer Modal ──────────────────────────────────────────── */

/* "Ver IFC" button in export panel */
.btn-view-ifc {
  background: linear-gradient(135deg, #0a2a3a 0%, #0e3a4e 100%);
  border-color: rgba(0, 212, 255, 0.5);
  color: var(--accent);
  font-weight: 600;
  position: relative;
  overflow: hidden;
}
.btn-view-ifc:not(:disabled):hover {
  background: linear-gradient(135deg, #0e3a4e 0%, #1a5f7a 100%);
  border-color: var(--accent);
  box-shadow: 0 0 12px rgba(0, 212, 255, 0.3);
}
.btn-view-ifc:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ── IFC Completo button (Revit base + inventory merged) ──────────────────── */
.btn-export-ifc-combined {
  grid-column: 1 / -1;  /* spans full width of the 2-col export grid */
  background: linear-gradient(135deg, rgba(16,185,129,0.12), rgba(5,150,105,0.08));
  border-color: rgba(16,185,129,0.45);
  color: #6ee7b7;
  font-weight: 600;
}
.btn-export-ifc-combined:hover {
  border-color: #10b981;
  color: #10b981;
  background: linear-gradient(135deg, rgba(16,185,129,0.22), rgba(5,150,105,0.16));
  box-shadow: 0 0 10px rgba(16,185,129,0.25);
}

/* Full-screen modal overlay */
.modal-ifc {
  position: fixed;
  inset: 12px;
  left: calc(var(--sidebar-w) + 24px);
  right: calc(var(--results-w) + 24px);
  z-index: 600;
  display: flex;
  flex-direction: column;
  background: rgba(8, 15, 28, 0.96);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border: 1px solid rgba(0, 212, 255, 0.35);
  border-radius: 16px;
  box-shadow:
    0 24px 80px rgba(0, 0, 0, 0.7),
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 0 0 1px rgba(0, 212, 255, 0.05);
  overflow: hidden;
  animation: modalSlideIn 0.25s ease-out;
}
.modal-ifc.hidden {
  display: none;
}
@keyframes modalSlideIn {
  from { opacity: 0; transform: translateY(-8px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0)    scale(1);    }
}

/* Header bar */
.modal-ifc-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid rgba(0, 212, 255, 0.15);
  flex-shrink: 0;
  background: rgba(13, 21, 37, 0.6);
}
.modal-ifc-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}
.modal-ifc-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.03em;
  white-space: nowrap;
}
.badge-oss {
  font-size: 0.62rem;
  font-weight: 600;
  color: #009E73;
  background: rgba(0, 158, 115, 0.12);
  border: 1px solid rgba(0, 158, 115, 0.35);
  border-radius: 10px;
  padding: 2px 8px;
  white-space: nowrap;
}
.ifc-model-info {
  font-size: 0.68rem;
  color: var(--muted);
  font-family: 'Space Mono', monospace;
  flex: 1;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.btn-close-modal {
  background: none;
  border: 1px solid rgba(248, 113, 113, 0.35);
  color: #f87171;
  border-radius: 8px;
  width: 28px;
  height: 28px;
  cursor: pointer;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s;
}
.btn-close-modal:hover {
  background: rgba(248, 113, 113, 0.12);
  border-color: #f87171;
}

/* 3D viewport area — Three.js canvas fills this */
.ifc-viewer-container {
  flex: 1;
  position: relative;
  overflow: hidden;
}
.ifc-viewer-container canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

/* Loading overlay — fades out once model is ready */
.ifc-loading-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(8, 15, 28, 0.85);
  z-index: 10;
  transition: opacity 0.4s ease;
}
.ifc-loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}
.ifc-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(0, 212, 255, 0.15);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
.ifc-loading-msg {
  font-size: 0.75rem;
  color: var(--text);
  font-weight: 500;
}
.ifc-loading-pct {
  font-size: 0.65rem;
  color: var(--accent);
  font-family: 'Space Mono', monospace;
  letter-spacing: 0.05em;
}

/* Footer bar */
.modal-ifc-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 16px;
  border-top: 1px solid rgba(0, 212, 255, 0.10);
  flex-shrink: 0;
  background: rgba(13, 21, 37, 0.5);
}
.ifc-footer-tip {
  font-size: 0.62rem;
  color: var(--muted);
}
.ifc-footer-powered {
  font-size: 0.62rem;
  color: var(--muted);
}
.ifc-link {
  color: var(--accent);
  text-decoration: none;
}
.ifc-link:hover {
  text-decoration: underline;
}

/* Responsive: full width on narrow screens (when sidebars collapse) */
@media (max-width: 800px) {
  .modal-ifc {
    left: 12px;
    right: 12px;
  }
}

/* ── Modelo Base Revit — sidebar section ─────────────────────────────────── */

.rvt-status-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 0.68rem;
  font-weight: 600;
  margin: 0 14px 6px;
  border: 1px solid transparent;
}
.rvt-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.rvt-status-none .rvt-status-dot  { background: var(--muted); }
.rvt-status-none                   { color: var(--muted); border-color: rgba(139,153,179,0.2); background: rgba(139,153,179,0.06); }
.rvt-status-running .rvt-status-dot { background: #F59E0B; animation: pulse 1.2s ease-in-out infinite; }
.rvt-status-running                 { color: #F59E0B; border-color: rgba(245,158,11,0.3); background: rgba(245,158,11,0.08); }
.rvt-status-ok .rvt-status-dot    { background: #10B981; }
.rvt-status-ok                     { color: #10B981; border-color: rgba(16,185,129,0.3); background: rgba(16,185,129,0.08); }
.rvt-status-error .rvt-status-dot { background: #f87171; }
.rvt-status-error                  { color: #f87171; border-color: rgba(248,113,113,0.3); background: rgba(248,113,113,0.08); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.35; }
}

.rvt-drop-zone {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 0 14px 6px;
  padding: 7px 12px;
  border: 1px dashed rgba(0, 212, 255, 0.3);
  border-radius: 8px;
  cursor: pointer;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 500;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}
.rvt-drop-zone:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(0, 212, 255, 0.05);
}
.rvt-drop-icon { font-size: 0.85rem; color: var(--accent); }

.rvt-progress {
  margin: 0 14px 4px;
}
.rvt-progress-bar-wrap {
  background: rgba(255,255,255,0.06);
  border-radius: 4px;
  height: 3px;
  overflow: hidden;
  margin-bottom: 4px;
}
.rvt-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #00FF9D);
  border-radius: 4px;
  width: 0%;
  transition: width 0.5s ease;
  animation: shimmer 2s linear infinite;
}
@keyframes shimmer {
  0%   { filter: brightness(1); }
  50%  { filter: brightness(1.3); }
  100% { filter: brightness(1); }
}
.rvt-progress-msg {
  font-size: 0.62rem;
  color: var(--muted);
  line-height: 1.3;
  text-align: center;
}
