/* ── Reset & base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0a0e13;
  --surface:   #0d1420;
  --surface2:  #131c28;
  --border:    #1d2a3a;
  --accent:    #00c2a8;
  --accent2:   #e8a838;
  --danger:    #ff5a5a;
  --text:      #d4dce6;
  --muted:     #6b7f93;
  --head:      #ffffff;
  --font:      -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono:      "IBM Plex Mono", "Fira Code", monospace;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ── Layout principal ── */
.app-layout {
  display: grid;
  grid-template-columns: 360px 1fr;
  flex: 1;
  overflow: hidden;
}

/* ── Topbar ── */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 20px;
  font-size: 13px;
}
.topbar .brand {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--accent);
  font-weight: 600;
  letter-spacing: .05em;
  white-space: nowrap;
}
.topbar select, .topbar input {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 5px 10px;
  border-radius: 3px;
  font-size: 12px;
  font-family: var(--font);
}
.topbar select:focus, .topbar input:focus {
  outline: none;
  border-color: var(--accent);
}
.topbar label { font-size: 11px; color: var(--muted); }
.topbar .filter-group { display: flex; align-items: center; gap: 8px; }
.topbar .spacer { flex: 1; }
.topbar .stats {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}
.topbar .stats b { color: var(--accent); }

/* ── Painel esquerdo ── */
.panel {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.panel-title {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  font-family: var(--mono);
  color: var(--muted);
  letter-spacing: .1em;
  text-transform: uppercase;
}

/* ── Tabela ── */
.tbl-wrap {
  overflow-y: auto;
  flex: 1;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
thead th {
  background: var(--surface2);
  color: var(--muted);
  padding: 8px 12px;
  text-align: left;
  font-size: 10px;
  letter-spacing: .1em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 1;
  font-weight: 500;
}
th.r, td.r { text-align: right; }
tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid #11192460;
  white-space: nowrap;
  cursor: pointer;
}
.lote-row:hover td { background: var(--surface2); }
.lote-row.active td { background: rgba(0,194,168,.08) !important; }
.lote-row.active td:first-child {
  border-left: 2px solid var(--accent);
  padding-left: 10px;
}

/* ── Badges ── */
.badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 3px;
  font-family: var(--mono);
}
.badge-ok      { background: #0d2a22; color: var(--accent); }
.badge-parcial { background: #1e1800; color: var(--accent2); }

/* ── Células especiais ── */
.mono  { font-family: var(--mono); font-size: 11.5px; }
.yaw   { font-family: var(--mono); font-weight: 700; color: var(--accent); }
.score-hi { color: var(--accent);  font-weight: 600; font-family: var(--mono); }
.score-md { color: var(--accent2); font-weight: 600; font-family: var(--mono); }
.muted { color: var(--muted); }

/* ── Info bar ── */
.info-bar {
  padding: 10px 14px;
  background: #060c12;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--muted);
  min-height: 44px;
  line-height: 1.6;
  font-family: var(--mono);
}
.info-bar b { color: var(--accent); }
.info-bar .err { color: var(--danger); }

/* ── Viewer ── */
.viewer-side {
  display: flex;
  flex-direction: column;
  background: #060c12;
  overflow: hidden;
}
.viewer-header {
  padding: 10px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  min-height: 44px;
  flex-wrap: wrap;
}
.viewer-header .vkey   { color: var(--head); font-weight: 700; font-size: 13px; }
.viewer-header .vparam { color: var(--accent); }
.viewer-header .hint   { margin-left: auto; font-size: 11px; color: #3d5060; }

/* Galeria de alternativas */
.gallery {
  display: flex;
  gap: 8px;
  padding: 8px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}
.gallery-item {
  flex-shrink: 0;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 3px;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  background: var(--surface2);
  white-space: nowrap;
}
.gallery-item:hover { border-color: var(--accent2); color: var(--accent2); }
.gallery-item.active { border-color: var(--accent); color: var(--accent); background: rgba(0,194,168,.08); }
.gallery-item .g-score { color: var(--head); font-weight: 600; }
.gallery.hidden { display: none; }

/* Pannellum container */
#pano-container {
  flex: 1;
  min-height: 0;
  position: relative;
}

/* Placeholder */
.placeholder {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #2a3a4f;
  gap: 12px;
}
.placeholder .ph-icon { font-size: 48px; opacity: .4; }
.placeholder p { font-size: 13px; }

/* Loading overlay */
.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(6,12,18,.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--muted);
  gap: 10px;
}
.loading-overlay.hidden { display: none; }
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--surface); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* Atribuição Mapillary (licença CC-BY-SA — obrigatória) */
.viewer-header .attrib {
  color: var(--accent);
  text-decoration: none;
  font-size: 12px;
  white-space: nowrap;
}
.viewer-header .attrib:hover { text-decoration: underline; }
.map-credit {
  position: absolute;
  right: 8px;
  bottom: 8px;
  z-index: 20;
  background: rgba(0, 0, 0, .6);
  color: #fff;
  padding: 3px 8px;
  border-radius: 3px;
  font-size: 11px;
  text-decoration: none;
  pointer-events: auto;
}
.map-credit:hover { background: rgba(0, 0, 0, .8); }
