/* PlotPin — estilos. Mobile-first; tema claro (bege suave) ou escuro (marrom quente), à escolha do usuário (ou automático). */
:root {
  --bg: #f4ede0;            /* bege suave: fundo das telas */
  --surface: #fbf7ef;       /* cartões e janelas: bege bem claro */
  --surface-2: #ece3d1;     /* áreas rebaixadas: cabeçalho da tabela, chips, campos */
  --bar: #ebe1cc;           /* barra superior e barra de abas (celular) */
  --ink: #2e2820;
  --muted: #6d6252;
  --line: #ddd1ba;
  --brand: #b4552d;         /* terracota: botões, seleção, destaques */
  --brand-2: #97431f;
  --brand-ink: #ffffff;
  --pin: #b4552d;           /* pino padrão (número) — mesma cor nos dois temas, o número é branco */
  --ok: #3a7343;
  --ok-bg: #e3ecd6;
  --warn: #8a5a00;
  --warn-bg: #f8e7bd;
  --bad: #b3332a;
  --bad-bg: #f6ddd6;
  --shadow: 0 1px 2px rgb(70 50 20 / .10), 0 6px 20px rgb(70 50 20 / .08);
  --radius: 12px;
  --topbar-h: 56px;
  --tabbar-h: 62px;
  color-scheme: light;
}
/* Escuro: js/theme.js põe data-theme="dark" quando o usuário escolhe Escuro ou, em Automático, quando o aparelho está no modo escuro. */
:root[data-theme="dark"] {
  --bg: #18140f;
  --surface: #221d16;
  --surface-2: #2d261d;
  --bar: #262019;
  --ink: #eee4d2;
  --muted: #b3a58d;
  --line: #3b3226;
  --brand: #e0895b;
  --brand-2: #ec9d73;
  --brand-ink: #2b1305;
  --ok: #a6d08a;
  --ok-bg: #26301c;
  --warn: #f2c260;
  --warn-bg: #3a2f12;
  --bad: #ff9a8a;
  --bad-bg: #40211c;
  --shadow: 0 1px 2px rgb(0 0 0 / .4), 0 6px 20px rgb(0 0 0 / .3);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}
h1, h2, h3 { margin: 0; line-height: 1.2; }
h2 { font-size: 1.05rem; }
p { margin: .4em 0; }
code { font: 0.85em ui-monospace, "SF Mono", Consolas, monospace; background: var(--surface-2); padding: .1em .4em; border-radius: 5px; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.mono, td.num { font-family: ui-monospace, "SF Mono", Consolas, "Liberation Mono", monospace; font-variant-numeric: tabular-nums; }
.grow { flex: 1; }
[hidden] { display: none !important; }

.ico { width: 1.25em; height: 1.25em; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.ico.big { width: 3rem; height: 3rem; opacity: .5; }

/* ---------- barra superior / abas ---------- */
.topbar {
  position: sticky; top: 0; z-index: 1000;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 1rem;
  padding: 0 max(16px, env(safe-area-inset-left)) 0 max(16px, env(safe-area-inset-right));
  background: var(--bar); color: var(--ink);
  box-shadow: 0 1px 0 var(--line);
}
.brand { display: flex; align-items: center; gap: .5rem; font-weight: 700; letter-spacing: .01em; font-size: 1.1rem; }
.brand-ico { width: 1.5rem; height: 1.5rem; stroke: var(--brand); }
.tabs { display: flex; gap: .25rem; margin-left: auto; }
.tabs button {
  display: inline-flex; align-items: center; gap: .45rem;
  border: 0; background: transparent; color: var(--muted);
  padding: .5rem .85rem; border-radius: 999px; font: inherit; font-weight: 600; cursor: pointer;
  position: relative;
}
.tabs button:hover { background: color-mix(in srgb, var(--brand) 9%, transparent); color: var(--ink); }
.tabs button[aria-selected="true"] { background: color-mix(in srgb, var(--brand) 17%, transparent); color: var(--brand-2); }
.tabs button:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.badge { font-size: .7rem; background: var(--brand); color: var(--brand-ink); border-radius: 999px; padding: .05rem .45rem; font-weight: 800; }

@media (max-width: 720px) {
  .tabs {
    position: fixed; left: 0; right: 0; bottom: 0; margin: 0; z-index: 1001;
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
    padding: 0 0 env(safe-area-inset-bottom);
    background: var(--bar); box-shadow: 0 -1px 0 var(--line);
    justify-content: space-around; gap: 0;
  }
  .tabs button { flex-direction: column; gap: .15rem; font-size: .72rem; padding: .4rem .6rem; border-radius: 12px; flex: 1; justify-content: center; }
  .tabs .badge { position: absolute; top: 4px; right: 22%; }
  body { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); }
  /* O body tem altura fixa (100%), então o padding acima não aumenta a rolagem: sem isto a barra de abas cobria o fim de
     qualquer tela comprida (o último item da lista de trilhas, por exemplo, ficava com os botões escondidos). */
  .view:not(.view-full) { padding-bottom: calc(16px + var(--tabbar-h) + env(safe-area-inset-bottom)); }
}

/* ---------- estrutura das telas ---------- */
main { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.view { padding: 16px max(16px, env(safe-area-inset-left)); max-width: 1240px; width: 100%; margin: 0 auto; }
.view-full { max-width: none; padding: 0; flex: 1; min-height: 0; position: relative; }

/* ---------- botões, chips ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: 40px; padding: .5rem 1rem;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: 10px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
  transition: background .15s, border-color .15s, transform .05s;
  user-select: none;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible, select:focus-visible, input:focus-visible, summary:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { background: var(--brand-2); border-color: var(--brand-2); }
.btn.danger { color: var(--bad); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.small { min-height: 32px; padding: .25rem .65rem; font-size: .85rem; }
.btn.round { width: 44px; min-height: 44px; padding: 0; border-radius: 50%; }
.btn[disabled] { opacity: .5; pointer-events: none; }

.chips { display: flex; gap: .4rem; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: .35rem; padding: .2rem .65rem; border-radius: 999px; font-size: .82rem; font-weight: 600; background: var(--surface-2); color: var(--muted); }
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.bad { background: var(--bad-bg); color: var(--bad); }

.toolbar { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin-bottom: 14px; }

/* ---------- progresso ---------- */
.progress { display: flex; align-items: center; gap: .8rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .7rem 1rem; margin-bottom: 14px; }
.progress-track { flex: 1; height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: var(--brand); transition: width .2s; }
#progress-msg { font-size: .85rem; color: var(--muted); min-width: 12ch; text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- vazio / soltar ---------- */
.empty {
  text-align: center; padding: 56px 24px; border: 2px dashed var(--line); border-radius: 16px; background: var(--surface);
  display: grid; justify-items: center; gap: .4rem;
}
.empty h2 { font-size: 1.3rem; margin-top: .4rem; }
.empty p { max-width: 62ch; }
.drop-overlay { position: fixed; inset: 0; z-index: 3000; display: grid; place-items: center; background: rgb(58 40 20 / .78); color: #fff; font-size: 1.5rem; font-weight: 700; pointer-events: none; backdrop-filter: blur(2px); }
.drop-overlay > div { border: 3px dashed #f0d9b0; border-radius: 20px; padding: 2.5rem 3.5rem; }

/* ---------- tabela ---------- */
.table-wrap { overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
th, td { padding: .5rem .75rem; text-align: left; white-space: nowrap; border-bottom: 1px solid var(--line); }
th { position: sticky; top: 0; background: var(--surface-2); font-size: .74rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); z-index: 1; }
td.num, th.num { text-align: right; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: color-mix(in srgb, var(--brand) 7%, transparent); }
tbody tr:last-child td { border-bottom: 0; }
td.c-thumb { width: 64px; padding: .25rem .5rem; }
td.c-thumb img { width: 48px; height: 48px; object-fit: cover; border-radius: 8px; display: block; background: var(--surface-2); }
td.file { max-width: 34ch; overflow: hidden; text-overflow: ellipsis; }
td.origin { color: var(--muted); font-size: .82rem; }
.status { display: inline-flex; align-items: center; gap: .3rem; font-size: .8rem; font-weight: 700; padding: .12rem .55rem; border-radius: 999px; }
.status.ok { background: var(--ok-bg); color: var(--ok); }
.status.revisar { background: var(--warn-bg); color: var(--warn); }
.status.sem { background: var(--bad-bg); color: var(--bad); }
.status .ico { width: 1em; height: 1em; stroke-width: 2.4; }

/* tabela em cartões no celular: miniatura | ID zona X Y / arquivo / data hora situação */
@media (max-width: 720px) {
  #tbl thead { display: none; }
  #tbl, #tbl tbody { display: block; }
  #tbl tbody tr { display: grid; grid-template-columns: 56px auto auto auto 1fr; column-gap: .65rem; row-gap: .15rem; align-items: center; padding: .6rem .75rem; border-bottom: 1px solid var(--line); }
  #tbl tbody tr:last-child { border-bottom: 0; }
  #tbl td { padding: 0; border: 0; text-align: left; min-width: 0; }
  #tbl td.c-thumb { grid-area: 1 / 1 / 5 / 2; width: auto; }
  #tbl td.c-thumb img { width: 56px; height: 56px; }
  #tbl td:nth-child(2) { grid-area: 1 / 2; font-weight: 800; }
  #tbl td:nth-child(5) { grid-area: 1 / 3; }
  #tbl td:nth-child(3) { grid-area: 1 / 4; }
  #tbl td:nth-child(4) { grid-area: 1 / 5; }
  #tbl td:nth-child(6) { grid-area: 2 / 2 / 3 / 6; max-width: none; color: var(--muted); font-size: .78rem; overflow: hidden; text-overflow: ellipsis; }
  #tbl td:nth-child(7) { grid-area: 3 / 2 / 4 / 4; font-size: .85rem; }
  #tbl td:nth-child(8) { grid-area: 3 / 4; font-size: .85rem; }
  #tbl td:nth-child(9) { grid-area: 3 / 5; justify-self: end; }
  #tbl td.origin { grid-area: 4 / 2 / 5 / 6; font-size: .75rem; color: var(--muted); }
}

/* ---------- mapa ---------- */
#map { position: absolute; inset: 0; background: var(--surface-2); }
.map-empty { position: absolute; z-index: 500; left: 50%; top: 20px; transform: translateX(-50%); background: var(--surface); padding: .6rem 1rem; border-radius: 10px; box-shadow: var(--shadow); max-width: 90%; text-align: center; }
.map-tools button { width: 34px; height: 34px; border: 0; background: #fff; color: #222; font-size: 1.1rem; cursor: pointer; display: block; }
.map-tools button + button { border-top: 1px solid #ccc; }
.map-tools button.on { background: #ffe38a; }
/* botão de texto "Pins" (ver todos os pins): caixa própria, para não desalinhar a coluna de ícones de 34 px */
.map-pins button { width: auto; height: 34px; padding: 0 .7rem 0 .55rem; display: flex; align-items: center; gap: .4rem; font: 700 .82rem/1 system-ui, sans-serif; }
.map-pins .ico { width: 1.05rem; height: 1.05rem; }
.map-pins-count { min-width: 1.35rem; padding: .12rem .35rem; border-radius: 99px; background: #eee; color: #222; font: 700 .72rem/1.2 system-ui, sans-serif; text-align: center; font-variant-numeric: tabular-nums; }
.map-readout { background: rgb(255 255 255 / .9); color: #222; padding: 2px 8px; border-radius: 6px; font: 12px ui-monospace, Consolas, monospace; box-shadow: 0 1px 4px rgb(0 0 0 / .25); }
/* pins: círculo na cor do ícone escolhido (--ic) ou do pino padrão, com o número ou o desenho; badge = ID (só com ícone), contador = nº de fotos, "!" = há algo a conferir */
.pin .pin-body {
  display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%;
  font: 700 12px system-ui, sans-serif; color: #fff; border: 2px solid #fff; box-shadow: 0 1px 4px rgb(0 0 0 / .5);
  background: var(--ic, var(--pin));
}
.pin .pin-flag { position: absolute; top: -7px; left: -9px; width: 17px; height: 17px; border-radius: 50%; background: #d98e04; color: #fff; border: 1.5px solid #fff; box-shadow: 0 1px 3px rgb(0 0 0 / .45); font: 800 11px/14px system-ui, sans-serif; font-style: normal; text-align: center; }
.pin.multi .pin-body { box-shadow: 0 0 0 3px rgb(255 255 255 / .55), 0 1px 4px rgb(0 0 0 / .5); }
.pin .pin-glyph { display: block; }
.pin .pin-num, .pin .pin-cnt {
  position: absolute; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; text-align: center;
  font: 800 10px/17px system-ui, sans-serif; font-style: normal; box-shadow: 0 1px 3px rgb(0 0 0 / .45);
}
.pin .pin-num { top: -7px; right: -9px; background: #fff; color: #2e2820; }
.pin .pin-cnt { bottom: -7px; right: -9px; background: #2e2820; color: #fff; border: 1.5px solid #fff; line-height: 14px; }
.z-low .pin .pin-body { width: 12px; height: 12px; margin: 9px; border-width: 1.5px; font-size: 0; }
.z-low .pin .pin-body > *, .z-low .pin .pin-num, .z-low .pin .pin-cnt, .z-low .pin .pin-flag { display: none; }
.z-low .pin-warn .pin-body { background: #d98e04; } /* de longe, os pontos com algo a conferir ficam âmbar */
.z-low .pin.multi .pin-body { width: 15px; height: 15px; margin: 7.5px; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--surface); color: var(--ink); }
.leaflet-container a.leaflet-popup-close-button { color: var(--muted); }
.leaflet-popup-content { margin: 10px 12px; }

/* janela do pin no mapa: as fotos deslizam (arrastar o dedo/mouse, setas ou pontinhos) */
.popup { display: grid; gap: .5rem; width: 240px; }
.pp-stage { position: relative; border-radius: 8px; overflow: hidden; background: #120e0a; }
.pp-track { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; cursor: grab; outline: none; touch-action: none; }
.pp-track::-webkit-scrollbar { display: none; }
.pp-track.dragging { scroll-snap-type: none; cursor: grabbing; user-select: none; }
.pp-track:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.pp-slide { flex: 0 0 100%; scroll-snap-align: center; scroll-snap-stop: always; margin: 0; height: 190px; display: grid; place-items: center; }
.pp-slide img { width: 100%; height: 100%; object-fit: contain; user-select: none; -webkit-user-drag: none; pointer-events: none; }
.pp-noimg { color: #a89c86; font-size: .8rem; }
.pp-count { position: absolute; top: 6px; right: 6px; background: rgb(0 0 0 / .62); color: #fff; font: 700 11px system-ui; padding: 2px 8px; border-radius: 99px; pointer-events: none; }
.pp-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 28px; height: 44px; border: 0; background: rgb(0 0 0 / .45); color: #fff; font: 400 26px/1 system-ui; cursor: pointer; padding: 0 0 3px; }
.pp-nav.prev { left: 0; border-radius: 0 10px 10px 0; }
.pp-nav.next { right: 0; border-radius: 10px 0 0 10px; }
.pp-nav:disabled { opacity: .2; cursor: default; }
.pp-dots { display: flex; justify-content: center; gap: 7px; flex-wrap: wrap; }
.pp-dot { width: 9px; height: 9px; padding: 0; border: 0; border-radius: 50%; background: color-mix(in srgb, var(--muted) 45%, transparent); cursor: pointer; transition: transform .15s, background .15s; }
.pp-dot.on { background: var(--brand); transform: scale(1.3); }
.popup-body { display: grid; gap: .1rem; font-size: 13px; }
.pp-file { word-break: break-all; }
.popup-body .btn { justify-self: start; margin-top: .3rem; min-height: 28px; font-size: 12px; }

/* ---------- câmera ---------- */
.cam { position: absolute; inset: 0; display: flex; flex-direction: column; background: #000; }
.cam-stage { position: relative; flex: 1; min-height: 0; overflow: hidden; background: #080604; display: grid; place-items: center; }
.cam-frame { position: relative; overflow: hidden; background: #000; width: 100%; height: 100%; }
.cam-frame video { width: 100%; height: 100%; object-fit: fill; display: block; }
/* Mesmo layout do carimbo gravado na foto (stamp-render.js): fonte 4% da largura, margem 0,3 fonte, entrelinha 1,13 */
.stamp-preview {
  position: absolute; right: 0; bottom: 0; margin: 0; text-align: right; color: #fff; white-space: pre;
  font: 400 16px/1.13 Roboto, "Segoe UI", "Helvetica Neue", Arial, sans-serif; text-shadow: .04em .04em .09em rgb(0 0 0 / .95); pointer-events: none;
}
.cam-flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.cam-flash.go { animation: flash .35s ease-out; }
@keyframes flash { from { opacity: .85; } to { opacity: 0; } }
.cam-chips { position: absolute; left: 10px; right: 10px; top: 10px; display: flex; flex-wrap: wrap; gap: .4rem; z-index: 2; }
.cam-msg { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; padding: 2rem; color: #fff; background: rgb(0 0 0 / .65); gap: .6rem; }
.cam-controls { background: #17120d; color: #fff; padding: 10px 16px calc(12px + env(safe-area-inset-bottom)); display: grid; gap: 10px; }
.cam-opts { display: flex; gap: .8rem; align-items: center; flex-wrap: wrap; }
.cam-opts input[type=text] { flex: 1; min-width: 180px; }
.cam-opts .check { color: #dccfb8; font-size: .85rem; }
/* Trilha e ficha ficam bem ao lado do botão de disparo (antes ficavam em cima, sobre o vídeo, e passavam despercebidos). */
.cam-row { display: flex; align-items: center; justify-content: center; gap: 16px; }
.cam-side {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .25rem;
  width: 64px; min-height: 56px; padding: .3rem .2rem; flex: none;
  border: 1px solid #463c2f; border-radius: 14px; background: #2a231b; color: #fff; font: inherit; cursor: pointer;
}
.cam-side .ico { width: 1.3rem; height: 1.3rem; }
.cam-side span { font-size: .68rem; font-weight: 700; max-width: 60px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cam-side.rec { background: #b3261e; border-color: #b3261e; }
.cam-side.on { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
/* último clique fica sobre o vídeo (canto inferior esquerdo), como num app de câmera comum */
.cam-last { position: absolute; left: 10px; bottom: 10px; z-index: 2; display: flex; align-items: center; gap: .5rem; background: rgb(0 0 0 / .55); backdrop-filter: blur(3px); padding: 6px; border-radius: 14px; }
.cam-last img { width: 56px; height: 56px; object-fit: cover; border-radius: 10px; border: 2px solid #fff; }
.cam-last-actions { display: grid; gap: .3rem; }
.cam-last .btn { background: #2a231b; color: #fff; border-color: #463c2f; }
.cam-flip-float { position: absolute; top: 10px; right: 10px; z-index: 2; background: rgb(0 0 0 / .55); color: #fff; border-color: transparent; backdrop-filter: blur(3px); }
.shutter { width: 72px; height: 72px; border-radius: 50%; border: 4px solid #fff; background: transparent; padding: 4px; cursor: pointer; }
.shutter span { display: block; width: 100%; height: 100%; border-radius: 50%; background: #fff; transition: transform .1s, background .15s; }
.shutter:active span { transform: scale(.88); }
.shutter[disabled] { opacity: .45; }

/* ---------- formulários ---------- */
input, select, textarea {
  font: inherit; color: inherit; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: .5rem .65rem; min-height: 40px; width: 100%;
}
textarea { resize: vertical; min-height: 4.5rem; line-height: 1.4; }
.cam-opts input[type=text] { background: #221c15; color: #fff; border-color: #463c2f; }
label { display: grid; gap: .25rem; font-size: .82rem; font-weight: 600; color: var(--muted); }
label.check { display: inline-flex; align-items: center; gap: .5rem; width: auto; }
label.check input { width: 1.1rem; min-height: 0; height: 1.1rem; }
input[type=checkbox], input[type=radio] { accent-color: var(--brand); }
.btn input { display: none; }

/* ---------- exportar ---------- */
.export-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); margin-bottom: 14px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); display: grid; gap: .6rem; align-content: start; }
.card.accent { border-color: var(--brand); }
.btn-row { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .3rem; }
details.card { margin-bottom: 14px; }
summary { cursor: pointer; font-weight: 700; }
.opts-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); margin-top: .8rem; }
#tbl-prev td, #tbl-prev th { padding: .35rem .7rem; }
#tbl-prev tbody tr { cursor: default; }

/* ---------- diálogo de foto ---------- */
dialog { border: 0; border-radius: 16px; padding: 0; width: min(1020px, 96vw); max-height: 94dvh; background: var(--surface); color: var(--ink); box-shadow: 0 20px 60px rgb(0 0 0 / .45); overflow: hidden; }
dialog[open] { display: flex; flex-direction: column; }
dialog::backdrop { background: rgb(34 22 10 / .55); backdrop-filter: blur(2px); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; padding: .7rem .9rem .7rem 1.1rem; border-bottom: 1px solid var(--line); gap: .6rem; }
.dlg-head h2 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- menu lateral (☰): projeto · navegar · fotos · aplicativo ---------- */
dialog.dlg-drawer { position: fixed; inset: 0 auto 0 0; margin: 0; width: min(320px, 88vw); height: 100dvh; max-height: 100dvh; border-radius: 0 16px 16px 0; }
dialog.dlg-drawer[open] { animation: drawer-in .2s ease-out; }
dialog.dlg-drawer::backdrop { animation: drawer-fade .2s ease-out; }
@keyframes drawer-in { from { transform: translateX(-28px); opacity: 0; } }
@keyframes drawer-fade { from { opacity: 0; } }
.drawer-head { flex: none; padding: .55rem .6rem .55rem 1rem; }
.drawer-brand { display: flex; align-items: center; gap: .5rem; min-width: 0; }
.drawer-brand h2 { font-size: 1.1rem; letter-spacing: .01em; }
.drawer-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 2px 0 calc(14px + env(safe-area-inset-bottom)); }
.drawer-sec { padding: 6px 10px 10px; }
.drawer-sec + .drawer-sec { border-top: 1px solid var(--line); }
.drawer-h { margin: .5rem .5rem .3rem; font-size: .7rem; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); }
.side-menu-list { display: grid; gap: 2px; align-content: start; }
.side-menu-item {
  display: flex; align-items: center; gap: .8rem; width: 100%; min-height: 46px; padding: .55rem .7rem;
  border: 0; border-radius: 10px; background: transparent; color: var(--ink); font: inherit; font-size: .95rem; font-weight: 600; text-align: left; cursor: pointer;
}
.side-menu-item:hover { background: var(--surface-2); }
.side-menu-item .ico { flex: none; color: var(--muted); }
.side-menu-item.on { background: color-mix(in srgb, var(--brand) 14%, transparent); color: var(--brand-2); }
.side-menu-item.on .ico { color: var(--brand); }
.side-menu-item:focus-visible, .sm-card:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.sm-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sm-badge { flex: none; }
.sm-rec { display: inline-flex; align-items: center; gap: .3rem; flex: none; font-size: .72rem; font-weight: 800; color: var(--bad); }
.sm-rec i { width: 8px; height: 8px; border-radius: 50%; background: currentColor; animation: pulse 1.2s ease-in-out infinite; }
.sm-project { display: grid; gap: 4px; }
.sm-card { display: flex; align-items: center; gap: .7rem; width: 100%; padding: .6rem .7rem; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); color: var(--ink); font: inherit; text-align: left; cursor: pointer; }
.sm-card:hover { border-color: var(--brand); }
.sm-card-ico { display: grid; place-items: center; flex: none; width: 36px; height: 36px; border-radius: 10px; background: color-mix(in srgb, var(--brand) 16%, var(--surface)); color: var(--brand); }
.sm-text { display: grid; min-width: 0; flex: 1; }
.sm-text b, .sm-text small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sm-text small { color: var(--muted); font-size: .76rem; font-weight: 500; }
.sm-card .chev { flex: none; color: var(--muted); transform: rotate(90deg); transition: transform .15s; }
.sm-card[aria-expanded="true"] .chev { transform: rotate(-90deg); }
.sm-panel { display: grid; gap: 2px; margin: 2px 0 2px .6rem; padding-left: .4rem; border-left: 2px solid var(--line); }
.sm-proj { min-height: 44px; }
.sm-proj > .ico:last-child { color: var(--brand); }
.sm-sep { height: 1px; margin: .3rem .4rem; background: var(--line); }
.sm-alert { color: var(--brand-2); }
.sm-account { min-height: 52px; }
.drawer-version { margin: .6rem .5rem 0; font-size: .74rem; color: var(--muted); }
/* botão ☰ na barra superior (e a bolinha de aviso) */
.topbtn.menu-btn { position: relative; margin-left: -8px; margin-right: -.3rem; }
.menu-dot { position: absolute; top: 7px; right: 7px; width: 10px; height: 10px; border-radius: 50%; background: var(--brand); border: 2px solid var(--bar); }
@media (max-width: 400px) { .topbar { gap: .5rem; } .topbtn.menu-btn { margin-right: 0; } }
.dlg-body { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 18px; padding: 16px; overflow: auto; }
@media (max-width: 760px) { .dlg-body { grid-template-columns: 1fr; } }
.dlg-photo { display: grid; gap: .6rem; align-content: start; }
.dlg-photo img { width: 100%; max-height: 62dvh; object-fit: contain; border-radius: 10px; background: #000; }
#dlg-crop { max-height: none; background: #222; }
.dlg-form { display: grid; gap: .8rem; align-content: start; }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.notes { background: var(--warn-bg); color: var(--warn); border-radius: 10px; padding: .6rem .8rem; font-size: .88rem; }
.notes ul { margin: .2rem 0 0 1.1rem; padding: 0; }
.alts { display: grid; gap: .4rem; font-size: .85rem; }
.alts .btn { justify-content: flex-start; font-family: ui-monospace, Consolas, monospace; font-weight: 500; min-height: 34px; }
.dlg-actions, .dlg-nav { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.dlg-nav { justify-content: space-between; border-top: 1px solid var(--line); padding-top: .7rem; }

/* ---------- toasts ---------- */
.toasts { position: fixed; z-index: 4000; left: 50%; transform: translateX(-50%); bottom: calc(16px + env(safe-area-inset-bottom)); display: grid; gap: .5rem; width: min(92vw, 460px); pointer-events: none; }
@media (max-width: 720px) { .toasts { bottom: calc(var(--tabbar-h) + 14px + env(safe-area-inset-bottom)); } }
.toast { background: #33291e; color: #fff; padding: .7rem 1rem; border-radius: 10px; box-shadow: var(--shadow); font-size: .9rem; transition: opacity .3s, transform .3s; }
.toast.error { background: #8f2a22; }
.toast.ok { background: #4a7a3d; }
.toast.out { opacity: 0; transform: translateY(8px); }

/* ---------- barra superior: gravação, ajustes, aviso de atualização ---------- */
.topbtn { display: inline-grid; place-items: center; width: 40px; height: 40px; flex: none; border: 0; border-radius: 50%; background: transparent; color: var(--muted); cursor: pointer; margin-left: .4rem; }
.topbtn:hover { background: color-mix(in srgb, var(--brand) 12%, transparent); color: var(--ink); }
.topbtn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.rec-pill { display: inline-flex; align-items: center; gap: .45rem; margin-left: .3rem; padding: .3rem .75rem; border: 0; border-radius: 99px; background: #b3261e; color: #fff; font: 700 .82rem system-ui, sans-serif; cursor: pointer; min-width: 0; }
.rec-pill span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 16ch; font-variant-numeric: tabular-nums; }
.rec-pill { flex: none; } /* a gravação em curso nunca é espremida: o que cede espaço é o nome do projeto */
.rec-dot { flex: none; width: 9px; height: 9px; border-radius: 50%; background: #fff; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; } }
.update-bar { position: sticky; top: var(--topbar-h); z-index: 999; display: flex; align-items: center; justify-content: center; gap: .8rem; padding: .5rem 1rem; background: var(--brand); color: var(--brand-ink); font-weight: 600; font-size: .9rem; }
.update-bar .btn.primary { background: var(--brand-ink); color: var(--brand); border-color: var(--brand-ink); }
@media (max-width: 980px) { .tabs button { padding: .5rem .6rem; gap: .3rem; } }
@media (max-width: 720px) {
  .topbtn { margin-left: auto; }
  .rec-pill { margin-left: .6rem; }
  .update-bar { top: var(--topbar-h); }
}


/* ---------- pins na tabela e seleção para agrupar ---------- */
tbody tr.grouped { box-shadow: inset 3px 0 0 var(--brand); }
.grp-badge { margin-left: .4rem; font: 700 .68rem system-ui, sans-serif; padding: .05rem .38rem; border-radius: 99px; background: color-mix(in srgb, var(--brand) 14%, transparent); color: var(--brand); vertical-align: middle; font-variant-numeric: tabular-nums; }
td.c-thumb { position: relative; }
.sel-box { display: none; position: absolute; top: 3px; left: 4px; width: 20px; height: 20px; border-radius: 6px; background: rgb(255 255 255 / .94); border: 2px solid var(--brand); color: #fff; font: 800 13px/16px system-ui, sans-serif; text-align: center; }
.selecting .sel-box { display: block; }
tbody tr.picked { background: color-mix(in srgb, var(--brand) 11%, transparent); }
tr.picked .sel-box { background: var(--brand); color: var(--brand-ink); }
#btn-select.on, #btn-select-tbl.on { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.sel-bar { position: fixed; z-index: 1200; left: 12px; right: 12px; bottom: calc(14px + env(safe-area-inset-bottom)); max-width: 620px; margin: 0 auto; display: flex; flex-wrap: wrap; align-items: center; gap: .45rem .6rem; padding: .6rem .8rem; background: var(--surface); border: 1px solid var(--brand); border-radius: 14px; box-shadow: var(--shadow), 0 8px 30px rgb(0 0 0 / .25); font-weight: 600; }
@media (max-width: 720px) { .sel-bar { bottom: calc(var(--tabbar-h) + 12px + env(safe-area-inset-bottom)); } }
/* barra de seleção: no computador cabe numa linha; no celular os dois botões de ação dividem a segunda linha */
.sel-bar { max-width: 780px; }
#btn-clear { margin-left: auto; } /* quando a barra de ferramentas quebra de linha (celular), "Limpar tudo" fica à direita */
@media (max-width: 720px) { #sel-group, #sel-export { flex: 1 1 45%; justify-content: center; } }

/* ---------- barra de navegação: botão Importar (ação) ao lado das áreas ---------- */
.tabs-list { display: contents; } /* as áreas (role=tablist) continuam filhas diretas da barra, só para o layout */
.tabs .tab-action { color: var(--brand-2); border: 1px solid color-mix(in srgb, var(--brand) 38%, transparent); margin-right: .35rem; }
.tabs .tab-action:hover { background: color-mix(in srgb, var(--brand) 14%, transparent); color: var(--brand-2); }
.tabs .tab-action .ico { stroke: currentColor; }
.tabs .tab-action.locked { opacity: .5; }
.tabs .tab-action::after { display: none; }
@media (max-width: 720px) {
  .tabs .tab-action { border-color: transparent; margin-right: 0; }
  .tabs .tab-action::after { display: block; content: ''; position: absolute; right: -1px; top: 24%; bottom: 24%; width: 1px; background: var(--line); }
}

/* ---------- aba Exportar: o que exportar (todas ou só as selecionadas) ---------- */
.card.scope { margin-bottom: 14px; }
.scope-row { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1.2rem; margin: .5rem 0 .2rem; }
.scope-opt { display: inline-flex; align-items: center; gap: .5rem; font-weight: 600; cursor: pointer; }
.scope-opt input { width: 1.15rem; height: 1.15rem; accent-color: var(--brand); margin: 0; }
#scope-pick { margin-left: auto; }
.scope .small { margin: .3rem 0 0; }

/* ---------- janelas pequenas (agrupar, ícones, ajustes) ---------- */
dialog.dlg-small { width: min(560px, 94vw); }
dialog.dlg-small.dlg-icons { width: min(660px, 96vw); }
dialog.dlg-small.dlg-props { width: min(620px, 96vw); }
.dlg-body-small { padding: 14px 16px 16px; display: grid; gap: .8rem; overflow: auto; align-content: start; }
.dlg-body-small p { margin: 0; }
.dlg-actions.pad { padding: .7rem 1rem; border-top: 1px solid var(--line); }
.grp-compare { display: flex; align-items: center; justify-content: center; gap: .9rem; }
.grp-fig { margin: 0; text-align: center; font-size: .8rem; color: var(--muted); display: grid; gap: .3rem; justify-items: center; }
.pp-thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 8px; background: var(--surface-2); flex: none; }
.pp-thumb.big { width: 104px; height: 104px; }
.pp-thumb.empty { display: inline-block; }
.grp-dist { font-weight: 800; background: var(--warn-bg); color: var(--warn); padding: .25rem .7rem; border-radius: 99px; white-space: nowrap; }
.grp-list { display: grid; gap: .4rem; max-height: 46dvh; overflow: auto; }
.grp-item { display: flex; align-items: center; gap: .7rem; padding: .5rem .65rem; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; background: var(--surface); font-weight: 400; color: var(--ink); font-size: .9rem; }
.grp-item:has(input:checked) { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 8%, var(--surface)); }
.grp-item input { width: 1.15rem; height: 1.15rem; min-height: 0; flex: none; }
.grp-thumbs { display: flex; align-items: center; gap: 4px; flex: none; }
.grp-more { font-weight: 800; color: var(--muted); font-size: .8rem; }
.grp-text { display: grid; min-width: 0; }
.grp-text b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grp-text small { color: var(--muted); }
.grp-tools { display: flex; gap: .4rem; }
.icons-scroll { max-height: 62dvh; }
.icon-group h3, .set-sec h3 { font-size: .76rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: .55rem 0 .35rem; }
.icon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: .4rem; }
.icon-opt { display: grid; justify-items: center; gap: .25rem; padding: .5rem .2rem; border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 10px; cursor: pointer; font: inherit; }
.icon-opt small { font-size: .7rem; color: var(--muted); text-align: center; line-height: 1.15; }
.icon-opt:hover { background: var(--surface-2); }
.icon-opt.on { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 12%, var(--surface)); outline: 2px solid var(--brand); }
.icon-search { position: sticky; top: 0; z-index: 1; background: var(--surface); }
.icon-search-empty { text-align: center; padding: 1rem 0; }
.pin-mini { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--ic, var(--pin)); color: #fff; font: 700 12px system-ui, sans-serif; flex: none; }
.pin-mini svg { width: 18px; height: 18px; }
.btn .pin-mini { width: 24px; height: 24px; font-size: 11px; }
.btn .pin-mini svg { width: 14px; height: 14px; }
.set-body { gap: 1rem; grid-template-columns: minmax(0, 1fr); }   /* coluna que encolhe: sem isto a janela alarga além da tela em 320 px */
.set-sec { display: grid; grid-template-columns: minmax(0, 1fr); gap: .5rem; padding-bottom: .5rem; border-bottom: 1px solid var(--line); }
.set-sec h3 { margin: 0; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; font-size: .9rem; font-weight: 500; color: var(--ink); }
.set-row input, .set-row select { width: 11ch; min-height: 38px; }
.set-row select { width: auto; max-width: 60%; min-width: 0; }   /* min-width 0: o seletor encolhe em vez de alargar a janela em telas de 320 px */
/* escolha entre poucas opções, lado a lado (Ajustes › Aparência): o botão marcado fica em destaque; o <input> radio é invisível mas continua acessível (setas do teclado) */
.seg { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .35rem; min-width: 0; }
.seg-opt { position: relative; display: block; cursor: pointer; }
.seg-opt input { position: absolute; inset: 0; width: 100%; height: 100%; min-height: 0; margin: 0; opacity: 0; cursor: pointer; }
.seg-face { display: flex; align-items: center; justify-content: center; gap: .4rem; min-height: 42px; padding: .35rem .5rem; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); font-size: .88rem; font-weight: 600; text-align: center; }
/* celular: ícone em cima do nome, três colunas iguais (a janela é estreita; assim nada estoura nem em 320 px) */
@media (max-width: 430px) { .seg-face { flex-direction: column; gap: .15rem; min-height: 56px; padding: .35rem .25rem; font-size: .82rem; overflow-wrap: anywhere; } }
.seg-opt:hover .seg-face { background: var(--surface-2); }
.seg-opt input:checked + .seg-face { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.seg-opt input:focus-visible + .seg-face { outline: 2px solid var(--brand); outline-offset: 2px; }
.set-hint { margin: 0; }

/* bloco "Pin" no diálogo da foto */
.dlg-pin { display: grid; gap: .5rem; padding: .6rem .7rem; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }
.dlg-pin-head { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.dlg-pin-strip { display: flex; gap: 6px; overflow-x: auto; padding: 2px 2px 4px; }
.strip-thumb { flex: none; width: 54px; height: 54px; padding: 0; border: 2px solid transparent; border-radius: 9px; overflow: hidden; background: #000; cursor: pointer; }
.strip-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.strip-thumb.on { border-color: var(--brand); }
.strip-thumb.anchor { outline: 2px dashed var(--warn); outline-offset: 1px; }
.dlg-pin-actions { display: flex; gap: .4rem; flex-wrap: wrap; }

/* ---------- aba Trilha ---------- */
.trail-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 440px), 1fr)); align-items: start; }
.trail-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(88px, 1fr)); gap: .6rem; }
.trail-stats > div { background: var(--surface-2); border-radius: 10px; padding: .55rem .65rem; display: grid; }
.trail-stats b { font: 700 1.2rem ui-monospace, "SF Mono", Consolas, monospace; font-variant-numeric: tabular-nums; }
.trail-stats span { font-size: .7rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
#ts-acc.ok { color: var(--ok); } #ts-acc.warn { color: var(--warn); } #ts-acc.bad { color: var(--bad); }
.btn.big { min-height: 52px; font-size: 1.05rem; padding: .6rem 1.4rem; }
.btn.danger-solid { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.danger-solid:hover { background: color-mix(in srgb, var(--bad) 85%, #000); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: .6rem; flex-wrap: wrap; }
#trail-list-card { scroll-margin-top: calc(var(--topbar-h) + 12px); }
@keyframes card-flash { from { box-shadow: 0 0 0 3px var(--brand), var(--shadow); } to { box-shadow: 0 0 0 3px transparent, var(--shadow); } }
.card.flash { animation: card-flash 1.4s ease-out; }
.trail-list { display: grid; gap: .5rem; }
.trail-item { display: flex; align-items: center; justify-content: space-between; gap: .8rem; flex-wrap: wrap; padding: .65rem .75rem; border: 1px solid var(--line); border-radius: 10px; }
.trail-item.live { border-color: var(--bad); background: var(--bad-bg); }
.trail-main { min-width: 0; display: grid; gap: .1rem; }
.trail-actions { display: flex; gap: .3rem; flex-wrap: wrap; }
.rec-chip { margin-left: .5rem; }
#trail-note[data-kind] { margin: 0; }

/* ---------- fichas (formulários do pin) ---------- */
.fic-badge { display: inline-grid; place-items: center; width: 20px; height: 20px; margin-left: .35rem; border-radius: 6px; background: color-mix(in srgb, var(--brand) 14%, transparent); color: var(--brand); vertical-align: middle; }
.fic-badge .ico { width: 13px; height: 13px; }
.fic-col { min-width: 8rem; max-width: 18rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dlg-ficha { display: grid; gap: .6rem; padding: .7rem .8rem; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.dlg-ficha-head { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.ficha-title { display: grid; min-width: 0; }
.ficha-title strong { overflow: hidden; text-overflow: ellipsis; }
.ficha-fields, .ficha-body { display: grid; gap: .85rem; }
.ficha-field { display: grid; gap: .3rem; font-size: .9rem; font-weight: 400; color: var(--ink); }
.ficha-label { font-size: .84rem; font-weight: 700; color: var(--ink); }
.ficha-hint { font-size: .74rem; color: var(--muted); font-weight: 400; }
.ficha-num { display: flex; align-items: center; gap: .5rem; }
.ficha-num input { flex: 1; min-width: 0; }
.ficha-unit { color: var(--muted); font-size: .85rem; white-space: nowrap; }
.opt-chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.opt-chip { min-height: 38px; padding: .3rem .85rem; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--ink); font: inherit; font-size: .86rem; cursor: pointer; }
.opt-chip:hover { background: var(--surface-2); }
.opt-chip[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); font-weight: 700; }
.stars { display: flex; gap: .1rem; }
.star { width: 42px; height: 42px; padding: 0; border: 0; background: transparent; font-size: 1.7rem; line-height: 1; color: var(--line); cursor: pointer; }
.star.on { color: #e0a100; }
.ficha-kept { display: grid; grid-template-columns: max-content 1fr; gap: .2rem .8rem; margin: 0; font-size: .88rem; }
.ficha-kept dt { color: var(--muted); } .ficha-kept dd { margin: 0; }
.pp-ficha { margin-top: .35rem; padding-top: .35rem; border-top: 1px solid var(--line); font-size: 12px; }
.pp-ficha-title { display: block; margin-bottom: .15rem; }
.pp-ficha dl { display: grid; grid-template-columns: max-content 1fr; gap: 1px .6rem; margin: 0; }
.pp-ficha dt { color: var(--muted); } .pp-ficha dd { margin: 0; overflow-wrap: anywhere; }

/* depois da foto: o que fazer agora (em vez de abrir a ficha direto) */
dialog.dlg-small.dlg-after-shot { width: min(400px, 92vw); }
.after-shot { gap: .6rem; }
.after-shot .btn { justify-content: flex-start; gap: .8rem; }

/* modelos: escolha, gerenciador e editor */
dialog.dlg-small.dlg-tpl, dialog.dlg-small.dlg-tpl-mgr, dialog.dlg-small.dlg-tpl-edit { width: min(640px, 96vw); }
dialog.dlg-small.dlg-sheet { width: min(560px, 96vw); }
.tpl-scroll { max-height: 66dvh; }
.tpl-group h3 { font-size: .76rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: .4rem 0 .35rem; }
.tpl-list { display: grid; gap: .45rem; }
.tpl-card { display: flex; align-items: flex-start; gap: .75rem; width: 100%; text-align: left; padding: .6rem .75rem; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); font: inherit; cursor: pointer; }
.tpl-card:hover { background: var(--surface-2); }
.tpl-card.on { border-color: var(--brand); outline: 2px solid var(--brand); background: color-mix(in srgb, var(--brand) 9%, var(--surface)); }
.tpl-text { display: grid; gap: .1rem; min-width: 0; }
.tpl-text small { color: var(--muted); font-size: .78rem; line-height: 1.3; }
.tpl-text .tpl-count { font-weight: 700; }
.tpl-row { display: flex; align-items: center; gap: .7rem; flex-wrap: wrap; padding: .5rem .65rem; border: 1px solid var(--line); border-radius: 10px; }
.tpl-row .tpl-text { flex: 1 1 12rem; }
.tpl-actions { display: flex; gap: .3rem; flex-wrap: wrap; }
.sheet-head { display: flex; align-items: center; gap: .6rem; min-width: 0; }
.sheet-tools { display: flex; gap: .4rem; flex-wrap: wrap; }
.sheet-body { max-height: 58dvh; }
.edit-body { max-height: 68dvh; }
.edit-h { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-top: .3rem; }
.edit-fields { display: grid; gap: .6rem; }
.edit-field { display: grid; gap: .5rem; padding: .6rem .7rem; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }
.edit-field-head { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, .8fr); gap: .5rem; }
.edit-num { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .5rem; }
.edit-field-tools { display: flex; align-items: center; gap: .3rem; }
@media (max-width: 460px) { .edit-field-head { grid-template-columns: 1fr; } }

/* ---------- investigar e localizar ---------- */
.dlg-invest { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.dlg-invest > summary { display: flex; align-items: center; gap: .5rem; padding: .7rem .8rem; cursor: pointer; font-weight: 700; }
.invest-body { display: grid; gap: 1rem; padding: 0 .8rem .9rem; }
.inv-sec { display: grid; gap: .5rem; }
.inv-sec h4 { margin: 0; font-size: .76rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
details.inv-sub { display: block; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
details.inv-sub > summary { padding: .55rem .7rem; cursor: pointer; font-weight: 600; font-size: .9rem; }
details.inv-sub > :not(summary) { margin: 0 .7rem .7rem; }
.inv-clock { display: grid; gap: .3rem; font-size: .88rem; font-weight: 600; color: var(--ink); }
.inv-clock input { width: 10ch; }
.inv-inferred { margin: 0; padding: .5rem .7rem; border-radius: 10px; background: var(--warn-bg); color: var(--warn); font-size: .88rem; }
.inv-q { display: flex; gap: .5rem; }
.inv-q input { flex: 1; min-width: 0; }
.cand-list { display: grid; gap: .45rem; }
.cand-card { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; padding: .5rem .6rem; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }
.cand-n { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; font: 800 12px system-ui, sans-serif; color: #fff; flex: none; }
.conf-alta { background: #3f7a48; } .conf-media { background: #c98200; } .conf-baixa { background: #b3332a; } .conf-txt, .conf-exif { background: #5561c9; }
.cand-text { display: grid; min-width: 0; flex: 1 1 12rem; font-size: .9rem; }
.cand-text small { color: var(--muted); font-size: .78rem; line-height: 1.3; }
.cand-actions { display: flex; gap: .3rem; }
.mini-map { height: 280px; border-radius: 10px; border: 1px solid var(--line); overflow: hidden; background: var(--surface-2); }
.cand-mk { display: grid !important; place-items: center; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 1px 4px rgb(0 0 0 / .5); color: #fff; font: 800 12px system-ui, sans-serif; }
.cand-mk b { font-weight: 800; }
.cand-cur { background: #2563eb; }
.pick-mk { background: var(--brand); cursor: grab; }
.inv-table { border-collapse: collapse; width: 100%; font-size: .85rem; }
.inv-table th, .inv-table td { position: static; padding: .28rem .5rem .28rem 0; border-bottom: 1px solid var(--line); text-align: left; white-space: normal; overflow-wrap: anywhere; vertical-align: top; }
.inv-table th { background: transparent; text-transform: none; letter-spacing: 0; font-size: .85rem; font-weight: 600; color: var(--muted); width: 38%; }
.inv-table tr:last-child th, .inv-table tr:last-child td { border-bottom: 0; }
.inv-alerts { list-style: none; margin: 0 0 .5rem; padding: 0; display: grid; gap: .3rem; }
.inv-alert { padding: .4rem .6rem; border-radius: 8px; font-size: .85rem; }
.inv-alert.aviso { background: var(--warn-bg); color: var(--warn); }
.inv-alert.info { background: var(--surface-2); color: var(--muted); }
a.opt-chip { display: inline-flex; align-items: center; text-decoration: none; }
/* links de texto dentro das janelas (ex.: Política de privacidade): cor do tema, não o azul padrão do navegador */
dialog a:not(.btn):not(.opt-chip) { color: var(--brand-2); text-underline-offset: 2px; }
dialog a:not(.btn):not(.opt-chip):hover { text-decoration-thickness: 2px; }
.inv-links { display: grid; gap: .5rem; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- projetos e colaboração ---------- */
.proj-chip { display: inline-flex; align-items: center; gap: .4rem; max-width: min(240px, 34vw); min-height: 36px; min-width: 0; padding: .25rem .7rem; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--ink); font: 600 .85rem system-ui, sans-serif; cursor: pointer; }
.proj-chip:hover { background: var(--surface-2); }
.proj-chip:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.pj-chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.pj-chip-badge { flex: none; }
.pj-dot { display: inline-block; flex: none; width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.pj-dot.ok { background: var(--ok); } .pj-dot.busy { background: #d99a1e; } .pj-dot.off { background: #8c8272; } .pj-dot.bad { background: var(--bad); }
@media (max-width: 720px) { .proj-chip { max-width: 46vw; } }
@media (max-width: 400px) { .brand span { display: none; } }

dialog.dlg-small.dlg-projects, dialog.dlg-small.dlg-projset { width: min(660px, 96vw); }
dialog.dlg-small.dlg-signin, dialog.dlg-small.dlg-invite, dialog.dlg-small.dlg-newproject, dialog.dlg-small.dlg-joinlink, dialog.dlg-small.dlg-account { width: min(460px, 94vw); }
.pj-body { gap: .9rem; grid-template-columns: minmax(0, 1fr); }
.pj-body .set-sec:last-child { border-bottom: 0; }
.pj-account { display: flex; align-items: center; gap: .7rem; padding: .6rem .8rem; background: var(--surface-2); border-radius: 12px; }
.pj-account.out { flex-wrap: wrap; justify-content: space-between; }
.pj-account.out p { flex: 1 1 14rem; }
.pj-account-text { display: grid; min-width: 0; flex: 1; }
.pj-account-text small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.pj-avatar { flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--brand); color: var(--brand-ink); font-weight: 800; }
.pj-row { display: flex; align-items: stretch; gap: .3rem; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.pj-row.on { border-color: var(--brand); box-shadow: inset 3px 0 0 var(--brand); }
.pj-row-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: .7rem; padding: .6rem .8rem; border: 0; background: transparent; color: var(--ink); font: inherit; text-align: left; cursor: pointer; border-radius: 12px; }
.pj-row-main:hover { background: var(--surface-2); }
.pj-row-main:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.pj-row-text { display: grid; min-width: 0; flex: 1; }
.pj-row-text b, .pj-row-text small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pj-row-text small { color: var(--muted); font-size: .78rem; }
.pj-sync { display: inline-flex; align-items: center; gap: .35rem; color: var(--muted); font-size: .75rem; flex: none; max-width: 40%; }
.pj-sync small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pj-check { color: var(--brand); display: inline-flex; flex: none; }
.pj-gear { align-self: center; margin-right: .2rem; flex: none; }
.pj-invite { display: flex; align-items: center; gap: .7rem; padding: .5rem .7rem; border: 1px dashed var(--brand); border-radius: 12px; }
.pj-form, .pj-fields, .pj-details, .pj-member, .pj-choices, .pj-perms, .pj-results { display: grid; grid-template-columns: minmax(0, 1fr); gap: .7rem; }   /* colunas que encolhem: sem isto o conteúdo alarga a janela em 320 px */
.pj-form input, .pj-form textarea, .pj-form select, .pj-fields input, .pj-fields textarea, .pj-details input, .pj-details textarea, .pj-details select { min-width: 0; }
.pj-err { margin: 0; padding: .5rem .7rem; border-radius: 10px; background: var(--bad-bg); color: var(--bad); font-size: .88rem; }
.pj-code { font: 700 1.8rem ui-monospace, Consolas, monospace; letter-spacing: .4em; text-align: center; }
.pj-choices { gap: .5rem; }
.pj-choice { display: flex; gap: .6rem; align-items: flex-start; padding: .6rem .8rem; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); cursor: pointer; color: var(--ink); font-size: .9rem; }
.pj-choice input { flex: none; width: 1.1rem; height: 1.1rem; min-height: 0; margin-top: .15rem; }
.pj-choice:has(input:checked) { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 8%, var(--surface)); }
.pj-choice span { display: grid; min-width: 0; }
.pj-choice small { color: var(--muted); font-weight: 400; }
.pj-carry { align-items: flex-start; color: var(--ink); font-size: .88rem; }
.pj-carry input { flex: none; margin-top: .15rem; }
.pj-member { gap: .45rem; padding: .6rem .7rem; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.pj-member[data-status="pending"] { border-color: var(--warn); background: var(--warn-bg); }
.pj-m-head { display: flex; align-items: center; gap: .6rem; }
.pj-m-text { display: grid; min-width: 0; flex: 1; }
.pj-m-text b, .pj-m-text small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pj-m-text small { color: var(--muted); }
.pj-m-controls { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; }
.pj-m-controls select { flex: 1 1 9rem; width: auto; min-width: 0; max-width: 100%; }
.pj-icon-btn { flex: none; }
.pj-details > summary { cursor: pointer; font-weight: 600; font-size: .9rem; padding: .35rem 0; }
.pj-details[open] > summary { margin-bottom: .4rem; }
.pj-perm-details[open] { padding-bottom: .3rem; }
.pj-perm-details .btn { margin-top: .3rem; }
.pj-perms { gap: .35rem; padding: .4rem 0 .2rem; }
.pj-perm { align-items: flex-start; font-size: .88rem; color: var(--ink); }
.pj-perm input { flex: none; margin-top: .1rem; }
.pj-perm-details summary { cursor: pointer; font-size: .85rem; color: var(--muted); }
.pj-results { gap: .25rem; }
.pj-res { margin: 0; font-size: .86rem; overflow-wrap: anywhere; }
.pj-res.ok { color: var(--ok); } .pj-res.warn { color: var(--warn); } .pj-res.bad { color: var(--bad); }
.pj-inline { display: inline-flex; gap: .4rem; }
.pj-sync-line { display: inline-flex; align-items: center; gap: .45rem; min-width: 0; }
.pj-danger .dlg-actions { gap: .5rem; }
td.file .by { display: block; font-size: .72rem; color: var(--muted); font-weight: 500; }
.dlg-by { margin: 0; font-size: .82rem; }

/* projeto só para visualizar: o disparo e os botões de envio ficam com ar de travados (o toque explica o motivo) */
.shutter.locked { opacity: .4; }
.cam-side.locked, .side-menu-item.locked, #trail-toggle.locked { opacity: .5; }
@media (max-width: 480px) { .pj-sync small { display: none; } }
/* telas estreitas: durante a gravação a pílula mostra só o tempo e a logo sai de cena (o ☰ e o projeto identificam o app) */
@media (max-width: 400px) { #rec-pill-d { display: none; } .topbar:has(#rec-pill:not([hidden])) .brand { display: none; } }

/* ---------- trilha com as fotos: escolher fotos e ordem, rota pelas ruas (janela com lista + mapa) ---------- */
dialog.dlg-small.dlg-route { width: min(1040px, 97vw); height: min(780px, 94dvh); }
.rt-body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(150px, 28dvh) minmax(0, 1fr); }
.rt-mapbox { position: relative; order: -1; background: var(--surface-2); border-bottom: 1px solid var(--line); } /* celular: o mapa fica em cima */
.rt-map { position: absolute; inset: 0; }
.rt-side { min-height: 0; overflow: auto; padding: 12px 14px 16px; display: grid; grid-template-columns: minmax(0, 1fr); gap: .7rem; align-content: start; }
.rt-side > * { min-width: 0; }
.rt-foot { flex: none; justify-content: flex-end; }
@media (min-width: 780px) {
  .rt-body { grid-template-columns: minmax(340px, 5fr) minmax(0, 6fr); grid-template-rows: minmax(0, 1fr); }
  .rt-side { order: 1; }
  .rt-mapbox { order: 2; border-bottom: 0; border-left: 1px solid var(--line); }
}
@media (max-width: 779px) { dialog.dlg-small.dlg-route { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 0; } }
.rt-hint { margin: 0; }
.seg.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.seg.two .seg-opt .seg-face { flex-direction: row; min-height: 44px; }   /* dois botões grandes lado a lado, mesmo no celular */
.rt-s { display: none; }
.rt-h { display: flex; align-items: center; justify-content: space-between; gap: .6rem; margin-top: .2rem; }
.rt-h h3 { margin: 0; font-size: .76rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.rt-tools { display: flex; flex-wrap: wrap; gap: .35rem; }
.rt-tools .btn { flex: 1 1 auto; justify-content: center; padding-inline: .5rem; }
.rt-empty { margin: 0; padding: .8rem; border: 1px dashed var(--line); border-radius: 10px; text-align: center; font-size: .9rem; }
.rt-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .35rem; }
.rt-row { position: relative; display: grid; grid-template-columns: auto auto auto minmax(0, 1fr) auto; align-items: center; gap: .45rem; padding: .35rem .4rem .35rem .2rem; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.rt-row.out { grid-template-columns: auto minmax(0, 1fr) auto; padding-left: .4rem; }
.rt-row.flagged { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 7%, var(--surface)); }
.rt-handle { display: grid; place-items: center; width: 30px; height: 40px; padding: 0; border: 0; background: transparent; color: var(--muted); cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; border-radius: 8px; }
.rt-handle:hover { background: var(--surface-2); }
.rt-handle:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.rt-num { display: inline-grid; place-items: center; min-width: 26px; height: 26px; padding: 0 .25rem; border-radius: 99px; background: var(--brand); color: var(--brand-ink); font: 800 .78rem system-ui, sans-serif; }
.rt-row:first-child .rt-num { background: #3f7a48; color: #fff; }
.rt-row:last-child .rt-num { background: #7a2e27; color: #fff; }
.rt-row:only-child .rt-num { background: var(--brand); }
.rt-thumb { width: 40px; height: 40px; }
.rt-text { display: grid; min-width: 0; font-size: .88rem; }
.rt-text b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rt-text b em { font-style: normal; font-weight: 500; color: var(--muted); }
.rt-text small { color: var(--muted); font-size: .74rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rt-notime { color: var(--warn); font-weight: 600; }
.rt-flag { color: var(--bad) !important; font-weight: 700; white-space: normal !important; }
.rt-btns { display: inline-flex; gap: 0; }
.rt-act { min-height: 34px; width: 34px; padding: 0; }
.rt-act[disabled] { opacity: .25; }
.rt-list.dragging { user-select: none; }
.rt-row.drag { z-index: 3; box-shadow: 0 6px 18px rgb(0 0 0 / .3); opacity: .95; background: var(--surface-2); cursor: grabbing; pointer-events: none; }
.rt-row.drop-before::before, .rt-row.drop-after::after { content: ""; position: absolute; left: 0; right: 0; height: 3px; border-radius: 3px; background: var(--brand); }
.rt-row.drop-before::before { top: -3px; }
.rt-row.drop-after::after { bottom: -3px; }
.rt-out > summary, .rt-legs > summary, .rt-fallback > summary { cursor: pointer; font-weight: 600; font-size: .9rem; padding: .3rem 0; }
.rt-out-body { display: grid; gap: .5rem; padding-top: .3rem; }
.rt-out-body .btn { justify-self: start; }
.notes.bad { background: var(--bad-bg); color: var(--bad); }
.notes p { margin: 0; }
.notes p + p { margin-top: .3rem; }
.rt-loading { display: grid; justify-items: center; gap: .8rem; padding: 1.6rem .5rem; text-align: center; }
.rt-loading p { margin: 0; }
.rt-loading-ico { width: 34px; height: 34px; color: var(--brand); animation: rt-bob 1.2s ease-in-out infinite; }
@keyframes rt-bob { 50% { transform: translateY(-4px); } }
.rt-prog { width: min(360px, 100%); accent-color: var(--brand); }
.rt-sum { display: flex; align-items: center; gap: .75rem; padding: .7rem .8rem; border-radius: 12px; background: color-mix(in srgb, var(--brand) 10%, var(--surface)); border: 1px solid color-mix(in srgb, var(--brand) 35%, var(--line)); }
.rt-sum-ico { display: grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: 12px; background: var(--brand); color: var(--brand-ink); }
.rt-sum > div { display: grid; min-width: 0; }
.rt-sum span:not(.rt-sum-ico) { font-size: .95rem; font-variant-numeric: tabular-nums; }
.rt-ok { display: flex; align-items: center; gap: .5rem; padding: .55rem .7rem; border-radius: 10px; background: var(--ok-bg); color: var(--ok); font-size: .88rem; }
.rt-check { display: flex; align-items: flex-start; gap: .6rem; padding: .55rem .7rem; border: 1px solid var(--line); border-radius: 10px; font-weight: 400; color: var(--ink); cursor: pointer; }
.rt-check input { flex: none; width: 1.15rem; height: 1.15rem; min-height: 0; margin-top: .15rem; }
.rt-check span { display: grid; gap: .1rem; font-size: .88rem; }
.rt-legs-list { margin: .2rem 0 0; padding-left: 1.3rem; display: grid; gap: .25rem; font-size: .86rem; font-variant-numeric: tabular-nums; }
.rt-credit { margin: 0; }
.rt-credit a { color: inherit; }
.rt-fallback p { margin: .2rem 0 .5rem; }
/* marcadores numerados do mapa: verde = começo, vinho = fim, aro amarelo/vermelho = foto longe da rua */
.rt-mk { display: grid !important; place-items: center; border-radius: 50%; border: 2px solid #fff; background: #b4552d; color: #fff; box-shadow: 0 1px 4px rgb(0 0 0 / .5); font: 800 11px system-ui, sans-serif; }
.rt-mk b { font-weight: 800; }
.rt-mk.start { background: #3f7a48; }
.rt-mk.end { background: #7a2e27; }
.rt-mk.warn { box-shadow: 0 0 0 3px #f2c260, 0 1px 4px rgb(0 0 0 / .5); }
.rt-mk.bad { box-shadow: 0 0 0 3px #e2574c, 0 1px 4px rgb(0 0 0 / .5); }
/* celular estreito: sem miniatura (o número do pin, o arquivo e o horário bastam) e botões mais juntos */
@media (max-width: 400px) { .rt-l { display: none; } .rt-s { display: inline; } .rt-foot { flex-wrap: nowrap; } .rt-foot .btn { padding-inline: .8rem; } }
@media (max-width: 430px) {
  .rt-row { grid-template-columns: auto auto minmax(0, 1fr) auto; }
  .rt-row.out { grid-template-columns: minmax(0, 1fr) auto; }
  .rt-thumb { display: none; }
  .rt-act { width: 30px; }
  .rt-handle { width: 26px; }
}

/* ---------- uso sem internet (Ajustes) ---------- */
.off-list { display: grid; gap: .55rem; }
.off-row { display: flex; align-items: flex-start; gap: .6rem; }
.off-ico { flex: none; margin-top: .15rem; }
.off-ico.ok { color: var(--ok); } .off-ico.warn { color: var(--warn); } .off-ico.off { color: var(--muted); }
.off-text { display: grid; min-width: 0; font-size: .9rem; }
.off-text small { color: var(--muted); font-size: .8rem; overflow-wrap: anywhere; }
.off-progress { margin: 0; }
