:root {
  --bg: #0f1a12;
  --panel: #16241a;
  --panel-2: #1d3022;
  --line: #2c4633;
  --txt: #e7f0e8;
  --muted: #9db8a4;
  --green: #4ade80;
  --green-d: #14532d;
  --yellow: #fbbf24;
  --red: #ef4444;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--txt);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }

header { padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--panel); }
header h1 { margin: 0; font-size: 20px; }
header h1 span { color: var(--muted); font-weight: 400; font-size: 14px; }
header p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }

main { display: grid; grid-template-columns: 380px 1fr; height: calc(100vh - 112px); }
#panel { overflow-y: auto; padding: 14px; background: var(--panel); border-right: 1px solid var(--line); }
#map { height: 100%; }
footer { padding: 6px 16px; color: var(--muted); font-size: 12px; border-top: 1px solid var(--line); }

.step { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; margin-bottom: 12px; }
.step h2, #results h2 { margin: 0 0 8px; font-size: 14px; text-transform: uppercase;
  letter-spacing: .05em; color: var(--green); }
.step label { display: block; margin: 6px 0; color: var(--muted); font-size: 13px; }
.step input[type=date] { width: 100%; margin-top: 2px; padding: 6px; border-radius: 6px;
  border: 1px solid var(--line); background: var(--bg); color: var(--txt); }
.step input[type=range] { width: 100%; }
.hint { color: var(--muted); font-size: 13px; margin: 4px 0 0; }

.presets { display: flex; flex-wrap: wrap; gap: 6px; }
.presets button { flex: 1 1 30%; padding: 8px 6px; font-size: 12px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--bg); color: var(--txt); cursor: pointer; }
.presets button:hover { border-color: var(--green); }

#btn-analyze { width: 100%; margin-top: 10px; padding: 12px; font-size: 15px; font-weight: 700;
  border: 0; border-radius: 10px; background: var(--green); color: #052e12; cursor: pointer; }
#btn-analyze:disabled { background: var(--line); color: var(--muted); cursor: not-allowed; }
.status { min-height: 20px; margin: 8px 0 0; font-size: 13px; color: var(--muted); }
.status.err { color: var(--red); }
.status.ok { color: var(--green); }

#results { margin-top: 4px; }
#results h3 { margin: 14px 0 6px; font-size: 13px; color: var(--yellow); }
.verdict-card { display: flex; gap: 12px; align-items: flex-start; background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.verdict-card .emoji { font-size: 34px; }
.verdict-text { font-weight: 700; font-size: 15px; }
.conf { display: flex; align-items: center; gap: 8px; margin: 6px 0; }
.conf-track { flex: 1; height: 8px; background: var(--bg); border-radius: 4px; overflow: hidden; }
#conf-bar { height: 100%; width: 0; background: linear-gradient(90deg, var(--yellow), var(--green)); transition: width .5s; }
.resumo { color: var(--muted); font-size: 12px; margin: 4px 0 0; }

.rules { list-style: none; padding: 0; margin: 0; font-size: 13px; }
.rules li { padding: 5px 8px; border-radius: 6px; margin-bottom: 4px; background: var(--panel-2); }
.rules li.ok { border-left: 3px solid var(--green); }
.rules li.no { border-left: 3px solid var(--red); }
.rules li.na { border-left: 3px solid var(--muted); color: var(--muted); }

.chart-wrap { height: 240px; background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px; }

#stages { width: 100%; border-collapse: collapse; font-size: 12px; }
#stages th, #stages td { text-align: left; padding: 5px 6px; border-bottom: 1px solid var(--line); }
#stages th { color: var(--muted); font-weight: 600; }

.chk { display: flex; align-items: center; gap: 6px; margin: 6px 0; color: var(--muted); font-size: 13px; }
.chk input { width: auto; }
.step select { width: 100%; padding: 6px; border-radius: 6px; border: 1px solid var(--line);
  background: var(--bg); color: var(--txt); }
.step input[type=text], .step input[type=number] { width: 100%; padding: 6px; margin-top: 2px;
  border-radius: 6px; border: 1px solid var(--line); background: var(--bg); color: var(--txt); }
#btn-calib { width: 100%; margin-top: 8px; padding: 10px; border-radius: 8px; border: 1px solid var(--green-d);
  background: var(--panel); color: var(--txt); cursor: pointer; font-size: 13px; }
#btn-calib:hover:not(:disabled) { background: var(--green-d); }
#btn-calib:disabled { color: var(--muted); cursor: not-allowed; }
.car-btn { width: 100%; margin: 6px 0; padding: 10px; border-radius: 8px;
  border: 1px solid #b45309; background: var(--panel); color: var(--txt);
  cursor: pointer; font-size: 13px; }
.car-btn:hover { background: #3a2c12; }
.car-btn.active { background: #b45309; color: #fff; font-weight: 600; }
#btn-vectorize { width: 100%; margin-top: 8px; padding: 11px; font-size: 14px;
  font-weight: 700; border: 0; border-radius: 10px; background: var(--yellow);
  color: #452a03; cursor: pointer; }
#btn-vectorize:disabled { background: var(--line); color: var(--muted); cursor: not-allowed; }
.ok-acc { color: var(--green); }
.no-acc { color: var(--red); }
.lim-row { margin: 8px 0; }
.lim-row label { display: flex; justify-content: space-between; font-size: 12px;
  color: var(--muted); margin-bottom: 2px; }
.lim-val { color: var(--yellow); font-weight: 700; font-variant-numeric: tabular-nums; }
.lim-row input[type=range] { width: 100%; accent-color: var(--yellow); }
.lim-btns { display: flex; gap: 8px; margin-top: 10px; }
.lim-btns button { flex: 1; padding: 8px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--bg); color: var(--txt); cursor: pointer; font-size: 12px; }
.lim-btns button:hover { border-color: var(--yellow); }
#dtw-table, #mb-table { width: 100%; border-collapse: collapse; font-size: 12px; margin-bottom: 10px; }
#dtw-table th, #dtw-table td, #mb-table th, #mb-table td {
  text-align: left; padding: 5px 6px; border-bottom: 1px solid var(--line); }
#dtw-table th, #mb-table th { color: var(--muted); font-weight: 600; }
.exports { display: flex; gap: 8px; margin: 12px 0 20px; }
.exports button { flex: 1; padding: 10px; border-radius: 8px; border: 1px solid var(--green-d);
  background: var(--green-d); color: var(--txt); cursor: pointer; font-size: 13px; }
.exports button:hover { filter: brightness(1.2); }

/* --- gauge de progresso da analise --- */
#gauge-overlay { display: none; position: fixed; inset: 0; background: rgba(10,18,12,.82);
  z-index: 9999; align-items: center; justify-content: center; backdrop-filter: blur(3px); }
.gauge-box { position: relative; width: 240px; text-align: center; }
.gauge-svg { width: 240px; height: 240px; transform: rotate(-90deg); }
.gauge-bg { fill: none; stroke: #223428; stroke-width: 10; }
.gauge-fg { fill: none; stroke: #4ade80; stroke-width: 10; stroke-linecap: round;
  transition: stroke-dashoffset .2s linear; }
.gauge-center { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -56%); }
#gauge-pct { font-size: 46px; font-weight: 800; color: #4ade80; font-variant-numeric: tabular-nums; }
.gauge-label { color: #9db8a4; font-size: 13px; margin-top: -4px; }
.gauge-tip { margin-top: 10px; color: #cbdccb; font-size: 13px; min-height: 18px; }

/* --- login + user chip --- */
#login-overlay { position: fixed; inset: 0; z-index: 10000; display: flex;
  align-items: center; justify-content: center; background: linear-gradient(135deg,#0f1a12,#16241a); }
.login-box { background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 28px; width: 320px; display: flex; flex-direction: column; gap: 12px; }
.login-box h2 { margin: 0; color: var(--green); text-align: center; }
.login-box p { margin: 0; color: var(--muted); font-size: 13px; text-align: center; }
.login-box input { padding: 10px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--bg); color: var(--txt); }
.login-box button { padding: 11px; border: 0; border-radius: 8px; background: var(--green);
  color: #052e12; font-weight: 700; cursor: pointer; }
.login-err { color: var(--red); font-size: 12px; min-height: 16px; }
#user-chip { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: 13px; }
#user-chip a { color: var(--yellow); text-decoration: none; }
#user-chip a:hover { text-decoration: underline; }
header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; }

@media (max-width: 900px) {
  main { grid-template-columns: 1fr; grid-template-rows: 55vh 1fr; height: auto; }
  #map-wrap { order: -1; }
  #map { height: 55vh; }
}

.leg-chip { display:inline-block; width:11px; height:11px; border-radius:3px; margin-right:6px; vertical-align:middle; }
