:root {
  --bg: #0e1116;
  --panel: #161b22;
  --panel-2: #1c232d;
  --border: #2a3340;
  --text: #e6edf3;
  --muted: #8b98a8;
  --accent: #3b82f6;
  --accent-2: #60a5fa;
  --ok: #22c55e;
  --err: #ef4444;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 14px/1.4 system-ui, Segoe UI, Roboto, sans-serif; }
.hidden { display: none !important; }

.topbar { height: 56px; display: flex; align-items: center; gap: 24px; padding: 0 18px; border-bottom: 1px solid var(--border); background: var(--panel); }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; letter-spacing: .3px; white-space: nowrap; user-select: none; }
.brand-logo { width: 30px; height: 30px; object-fit: contain; display: block; filter: drop-shadow(0 0 6px rgba(96, 165, 250, 0.35)); }
.brand-name { color: var(--text); }
.brand-name span { color: var(--accent-2); }
.stepper { display: flex; gap: 6px; }
.step { background: transparent; color: var(--muted); border: 1px solid var(--border); border-radius: 20px; padding: 6px 14px; cursor: pointer; }
.step b { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--panel-2); margin-right: 6px; font-size: 12px; }
.step.active { color: var(--text); border-color: var(--accent); }
.step.active b { background: var(--accent); }
.step.done b { background: var(--ok); }
.step:disabled { opacity: .45; cursor: not-allowed; }
.status { margin-left: auto; color: var(--muted); font-size: 13px; max-width: 45%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status.err { color: var(--err); }

main { height: calc(100% - 56px); }
.step-panel { display: none; height: 100%; }
.step-panel.active { display: flex; }

.sidebar { width: 360px; min-width: 360px; padding: 16px; overflow-y: auto; border-right: 1px solid var(--border); background: var(--panel); }
.sidebar h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin: 18px 0 8px; }
.sidebar h2:first-child { margin-top: 0; }
.sidebar h3 { font-size: 14px; margin: 18px 0 6px; }
label { display: block; margin-bottom: 10px; color: var(--muted); font-size: 12px; }
label.inline { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 13px; }
input[type=text], input[type=email], input[type=password], input[type=number], select, textarea {
  width: 100%; margin-top: 4px; padding: 7px 9px; background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px; font: inherit;
}
span.hint { display: block; margin-top: 4px; }
textarea { resize: vertical; }
input[type=range] { flex: 1; }
.row { display: flex; gap: 8px; align-items: center; margin-top: 4px; }
.row input[type=text] { margin-top: 0; }
output { min-width: 40px; text-align: right; color: var(--text); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.checks { display: flex; gap: 14px; margin-bottom: 10px; }
.checks label { color: var(--text); font-size: 13px; display: flex; gap: 6px; align-items: center; }
.actions { display: flex; gap: 8px; margin: 14px 0 6px; }
.actions .btn { flex: 1; }
.hint { color: var(--muted); font-size: 12px; }
.muted { color: var(--muted); font-size: 12px; }

.btn { background: var(--panel-2); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 8px 14px; cursor: pointer; font: inherit; }
.btn:hover:not(:disabled) { border-color: var(--accent-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); }
.btn.primary:hover:not(:disabled) { background: var(--accent-2); }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.geo-results { list-style: none; margin: 0 0 10px; padding: 0; max-height: 160px; overflow-y: auto; }
.geo-results li { padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; margin-bottom: 4px; cursor: pointer; font-size: 12px; }
.geo-results li:hover, .geo-results li.sel { border-color: var(--accent); background: var(--panel-2); }

.workspace { flex: 1; display: flex; flex-direction: column; gap: 8px; padding: 10px; overflow: hidden; min-width: 0; height: 100%; }
.pane { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; display: flex; flex-direction: column; min-height: 80px; }
.pane.grow { flex: 1; }
.pane-title { display: flex; align-items: center; gap: 8px; padding: 6px 12px; border-bottom: 1px solid var(--border); font-weight: 600; font-size: 13px; min-height: 38px; }
.spacer { flex: 1; }

/* Controles de split e tamanho */
.split-preset-btns, .view-size-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}
.size-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* Splitter horizontal interativo */
.splitter-h {
  height: 10px;
  min-height: 10px;
  background: var(--panel-2);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  cursor: row-resize;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  position: relative;
  z-index: 10;
  transition: background 0.15s ease;
  margin: 1px 0;
  border-radius: 4px;
  flex-shrink: 0;
}
.splitter-h:hover, .splitter-h.dragging {
  background: var(--accent);
}
.splitter-handle {
  width: 48px;
  height: 4px;
  background: var(--muted);
  border-radius: 2px;
  transition: background 0.15s ease;
}
.splitter-h:hover .splitter-handle, .splitter-h.dragging .splitter-handle {
  background: #fff;
}

/* Etapa 1 */
#pane-cesium {
  height: 50%;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
#cesium-wrap {
  position: relative;
  flex: 1;
  height: 100%;
  min-height: 80px;
  background: #000;
  overflow: hidden;
}
#cesium { position: absolute; inset: 0; }
#cesium-wrap.capturing #cesium { inset: auto; left: 0; top: 0; }
.cesium-viewer-bottom { opacity: .8; }

#pane-pano1 {
  flex: 1;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}
#pane-pano1 .pano {
  flex: 1;
  height: 100%;
  width: 100%;
  min-height: 80px;
}

/* Etapa 2 */
#pane-pano2 {
  height: 40%;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
  position: relative;
}
#pane-pano2 .pano {
  flex: 1;
  height: 100%;
  width: 100%;
  min-height: 80px;
}
#pane-results {
  flex: 1;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.tab-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.pano { height: 420px; background: #000; }
.pano.tall { height: 100%; min-height: 420px; }
.pano.empty { display: grid; place-items: center; color: var(--muted); }
.flat {
  display: none;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
  flex: 1;
}
.thumb { width: 100%; border-radius: 6px; border: 1px solid var(--border); background: #000; min-height: 60px; }

/* Galeria de Opções */
.results {
  flex: 1;
  min-height: 0;
  height: 100%;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  padding: 16px;
  overflow-y: auto;
  overflow-x: hidden;
  align-content: flex-start;
  align-items: flex-start;
  scrollbar-width: thin;
  scrollbar-color: var(--border) var(--bg);
}
.results.size-compact {
  gap: 12px;
  padding: 12px;
}
.results.size-large {
  gap: 16px;
  padding: 16px;
}
.results::-webkit-scrollbar {
  width: 10px;
}
.results::-webkit-scrollbar-track {
  background: var(--bg);
  border-radius: 5px;
}
.results::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 5px;
  border: 2px solid var(--bg);
}
.results::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}

.card {
  width: 460px;
  max-width: 100%;
  border: 2px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--panel-2);
  cursor: pointer;
  position: relative;
  transition: border-color .15s ease, transform .15s ease, box-shadow .15s ease;
  flex-shrink: 0;
  flex-grow: 0;
  display: flex;
  flex-direction: column;
}
.results.size-compact .card {
  width: 330px;
}
.results.size-large .card {
  width: 460px;
}
.card:hover {
  border-color: var(--accent-2);
}
.card.sel {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}
.card img {
  width: 100%;
  aspect-ratio: 2 / 1;
  height: 230px;
  object-fit: cover;
  display: block;
  background: #000;
  flex-shrink: 0;
}
.results.size-compact .card img {
  height: 165px;
}
.results.size-large .card img {
  height: 230px;
}
.card .meta {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  font-size: 12px;
  background: var(--panel-2);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.card .meta .spacer { flex: 1; }
.card.loading img { opacity: .25; }
.card .err { color: var(--err); padding: 8px; font-size: 12px; }
.card .badge { position: absolute; top: 6px; left: 6px; background: rgba(0,0,0,.75); padding: 3px 8px; border-radius: 10px; font-size: 11px; backdrop-filter: blur(4px); z-index: 4; font-weight: 500; }
.card .spin { position: absolute; inset: 0; display: grid; place-items: center; z-index: 3; }

/* Botão de deletar opção */
.card-del-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 24px;
  height: 24px;
  background: rgba(0, 0, 0, 0.75);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 14px;
  cursor: pointer;
  z-index: 5;
  transition: all .15s ease;
  line-height: 1;
}
.card-del-btn:hover {
  background: var(--err);
  color: #fff;
  border-color: var(--err);
  transform: scale(1.1);
}
.delete-btn {
  padding: 3px 6px;
  font-size: 12px;
  color: var(--muted);
}
.delete-btn:hover {
  color: var(--err);
  border-color: var(--err);
}

.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: grid; place-items: center; z-index: 1000; }
.overlay.hidden { display: none; }
.overlay-box { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 22px 28px; min-width: 320px; text-align: center; }
.progress { height: 6px; background: var(--bg); border-radius: 3px; margin-top: 12px; overflow: hidden; }
#overlay-bar { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.spinner, .spin::after { width: 34px; height: 34px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: rot 0.9s linear infinite; margin: 0 auto 12px; }
.spin::after { content: ''; margin: 0; }
@keyframes rot { to { transform: rotate(360deg); } }

/* Banner de alerta */
.banner-alert {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: rgba(234, 179, 8, 0.15);
  border: 1px solid #eab308;
  color: #fef08a;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 8px;
}
.banner-alert.hidden { display: none; }

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: grid;
  place-items: center;
  z-index: 1100;
}
.modal.hidden { display: none; }
.modal-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  width: 90%;
  max-width: 520px;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { margin: 0; font-size: 15px; }
.modal-body { padding: 18px; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  background: var(--panel-2);
}
.close-x {
  padding: 2px 8px;
  font-size: 14px;
  line-height: 1;
}

/* Auth & User Menu */
.auth-section { display: flex; align-items: center; position: relative; margin-left: 10px; }
.user-menu { position: relative; }
.user-badge { display: flex; align-items: center; gap: 8px; padding: 5px 12px; border-radius: 20px; font-weight: 500; }
.user-status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 6px rgba(34, 197, 94, 0.6); }
.caret { font-size: 10px; color: var(--muted); margin-left: 2px; }
.user-dropdown { position: absolute; right: 0; top: calc(100% + 8px); width: 220px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 10px 25px rgba(0,0,0,0.5); z-index: 1200; overflow: hidden; }
.dropdown-header { padding: 10px 14px; font-size: 11px; color: var(--muted); border-bottom: 1px solid var(--border); word-break: break-all; }
.dropdown-item { width: 100%; text-align: left; padding: 10px 14px; background: transparent; border: none; color: var(--text); font-size: 13px; cursor: pointer; display: flex; align-items: center; gap: 8px; transition: background .15s; }
.dropdown-item:hover { background: rgba(255, 255, 255, 0.06); }
.dropdown-item.text-danger { color: #f87171; }
.dropdown-item.text-danger:hover { background: rgba(239, 68, 68, 0.12); }
.dropdown-divider { height: 1px; background: var(--border); margin: 4px 0; }

/* Auth Modal Tabs */
.auth-box { width: 380px; max-width: 90vw; }
.auth-box label { display: block; font-size: 12px; color: var(--muted); margin-top: 12px; }
.auth-box label:first-of-type { margin-top: 0; }
.auth-box input { width: 100%; margin-top: 4px; }
.auth-tabs { display: flex; gap: 4px; background: var(--bg); padding: 4px; border-radius: 8px; border: 1px solid var(--border); }
.auth-tab { flex: 1; padding: 6px 14px; background: transparent; border: none; border-radius: 6px; color: var(--muted); font-size: 13px; font-weight: 600; cursor: pointer; transition: all .15s; }
.auth-tab.active { background: var(--accent); color: #fff; }
.auth-alert { padding: 8px 12px; margin-bottom: 12px; border-radius: 6px; font-size: 12px; line-height: 1.4; background: rgba(239, 68, 68, 0.15); border: 1px solid var(--err); color: #fca5a5; }
.auth-alert.success { background: rgba(34, 197, 94, 0.15); border-color: var(--ok); color: #86efac; }
.keys-shield-badge { display: flex; align-items: flex-start; gap: 10px; background: rgba(59, 130, 246, 0.1); border: 1px solid rgba(59, 130, 246, 0.3); border-radius: 8px; padding: 10px 14px; margin-bottom: 14px; font-size: 12px; color: #93c5fd; }
.masked-badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; border-radius: 4px; background: rgba(34, 197, 94, 0.12); color: #4ade80; font-family: monospace; font-size: 11px; margin-top: 4px; }


