:root {
  --bg: #0f1117;
  --panel: #1a1d27;
  --panel2: #222633;
  --text: #e6e8ef;
  --muted: #8b90a2;
  --accent: #4f8cff;
  --green: #35c76d;
  --orange: #f0b429;
  --magenta: #c355f5;
  --red: #e5484d;
  --border: #2c3142;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px 22px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 18px; margin: 0; }
.meta { display: flex; gap: 14px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.meta a { color: var(--accent); }

main { max-width: 1100px; margin: 0 auto; padding: 22px; }

.card, .upload-card, .result, .history, .live {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 18px;
}

h3 { margin: 0 0 10px; font-size: 15px; }
.hint { color: var(--muted); font-size: 13px; }

.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 34px 20px;
  text-align: center;
  transition: border-color .15s, background .15s;
}
.dropzone.dragover {
  border-color: var(--accent);
  background: rgba(79,140,255,.06);
}
.dropzone p { margin: 6px 0; }

.btn {
  display: inline-block;
  padding: 9px 16px;
  margin: 4px;
  background: var(--panel2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  transition: filter .12s;
}
.btn:hover { filter: brightness(1.15); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.preview-wrap { text-align: center; margin-top: 14px; }
.preview-wrap img {
  max-width: 100%;
  max-height: 60vh;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.hidden { display: none !important; }

.processing { text-align: center; padding: 18px; margin-top: 10px; }
.spinner {
  width: 34px; height: 34px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  margin: 0 auto;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat {
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  text-align: center;
}
.stat .k { display: block; font-size: 12px; color: var(--muted); }
.stat .v { display: block; font-size: 26px; font-weight: 700; margin-top: 4px; }

.canvas-wrap { position: relative; }
#annotated {
  width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: #000;
}

.tools { margin: 14px 0; }

.save-status { margin-left: 10px; font-size: 13px; color: var(--green); }

.volume-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.vol-card {
  background: var(--panel2);
  border: 1px solid var(--border);
  border-left: 4px solid var(--green);
  border-radius: 8px;
  padding: 10px 12px;
  cursor: pointer;
  transition: transform .1s, border-color .1s;
}
.vol-card:hover { transform: translateY(-2px); }
.vol-card.uncertain { border-left-color: var(--orange); }
.vol-card.manual { border-left-color: var(--magenta); }
.vol-card.selected { outline: 2px solid var(--accent); }
.vol-card .vcode { font-weight: 700; }
.vol-card .vstats { font-size: 12px; color: var(--muted); margin-top: 4px; }
.vol-card .vbtns { margin-top: 8px; display: flex; gap: 6px; flex-wrap: wrap; }
.vol-card .vbtns .btn { padding: 4px 8px; font-size: 12px; margin: 0; }

.history-list { display: flex; flex-direction: column; gap: 8px; }
.hist-item {
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  cursor: pointer;
}
.hist-item:hover { border-color: var(--accent); }
.hist-item .dim { color: var(--muted); font-size: 13px; }

.live-form { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
input[type="text"] {
  flex: 1;
  min-width: 260px;
  padding: 9px 12px;
  background: var(--panel2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
}
input:disabled { opacity: .5; }

.toast {
  position: fixed; bottom: 18px; right: 18px;
  background: var(--panel2);
  border: 1px solid var(--border);
  border-left: 4px solid var(--red);
  padding: 12px 16px;
  border-radius: 8px;
  max-width: 340px;
  z-index: 50;
  box-shadow: 0 6px 20px rgba(0,0,0,.4);
}
.toast.ok { border-left-color: var(--green); }
/* ---- Captura por celular: abas, botões, grade de prévia, lote ---- */
.tabs { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.tab {
  padding: 9px 14px; border-radius: 8px; cursor: pointer;
  background: var(--panel2); border: 1px solid var(--border);
  color: var(--muted); font-weight: 600;
}
.tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.guide {
  background: var(--panel2); border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: 8px; padding: 10px 14px; margin-bottom: 14px;
}
.guide ul { margin: 6px 0 0; padding-left: 18px; color: var(--muted); font-size: 13px; }
.guide.train { border-left-color: var(--green); }

.capture-buttons { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }

.preview-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; margin: 14px 0; }
.preview-tile { position: relative; background: var(--panel2); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.preview-tile img { width: 100%; height: 110px; object-fit: cover; display: block; }
.preview-tile .pcap { font-size: 11px; color: var(--muted); padding: 6px 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.preview-close {
  position: absolute; top: 4px; right: 4px; width: 22px; height: 22px;
  border-radius: 50%; border: none; cursor: pointer;
  background: rgba(0,0,0,.65); color: #fff; font-size: 12px; line-height: 1;
}

.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; }

.batch-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.batch-item {
  background: var(--panel2); border: 1px solid var(--border);
  border-left: 4px solid var(--green);
  border-radius: 8px; padding: 10px 14px; cursor: pointer;
}
.batch-item:hover { border-color: var(--accent); }
.batch-item.err { border-left-color: var(--red); }
.batch-item .bhead { font-size: 13px; }
.batch-item .dim { color: var(--muted); font-size: 12px; margin-top: 4px; }
.batch-item .dim b { color: var(--text); }
