/* Radar de Campo GP — tokens GP (editáveis conforme manual de marca) */
:root {
  --gp-red: #D71920;
  --gp-red-dark: #A51118;
  --gp-navy: #002B5C;
  --gp-blue: #0057A8;
  --gp-gold: #D6A329;
  --gp-white: #FFFFFF;
  --gp-bg: #F4F6F8;
  --gp-gray: #6B7280;
  --gp-dark: #111827;
  --gp-success: #15803D;
  --gp-warning: #F59E0B;
  --gp-danger: #DC2626;
  --radius: 16px;
  --radius-sm: 12px;
  --shadow: 0 2px 12px rgba(0, 43, 92, 0.06);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --card-bg: var(--gp-white);
  --text: var(--gp-dark);
  --text-muted: var(--gp-gray);
  --border: #E8ECF0;
  --surface: #FAFBFC;
}

html.theme-dark {
  --gp-bg: #0B1220;
  --card-bg: #151D2E;
  --surface: #1A2438;
  --text: #F1F5F9;
  --text-muted: #94A3B8;
  --border: #2A3548;
  --shadow: 0 2px 16px rgba(0, 0, 0, 0.35);
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

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

.app { max-width: 480px; margin: 0 auto; min-height: 100vh; }

/* Header */
.header-gp {
  background: var(--gp-white);
  color: var(--gp-navy);
  padding: 0.85rem 1rem 0.65rem;
  border-bottom: 3px solid var(--gp-red);
}

.header-gp--navy {
  background: linear-gradient(160deg, var(--gp-navy), #003d7a);
  color: var(--gp-white);
  border-bottom-color: var(--gp-gold);
}

.header-gp--navy .subtitle { color: rgba(255,255,255,0.75); }
.header-gp--navy .back-link { color: var(--gp-gold); }

.header-gp h1 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.subtitle {
  margin: 0.15rem 0 0;
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header-meta {
  display: flex;
  gap: 0.35rem;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}

.badge {
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  background: var(--surface);
  color: var(--text-muted);
}

.badge-campo { background: rgba(214, 163, 41, 0.15); color: #92680a; }
html.theme-dark .badge-campo { color: var(--gp-gold); }
.badge-online { color: var(--gp-success); background: rgba(21, 128, 61, 0.1); }
.badge-offline { color: var(--text-muted); }
.badge-sync { color: var(--gp-blue); background: rgba(0, 87, 168, 0.1); cursor: pointer; }

.btn-icon {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-moon::before { content: '◐'; font-size: 0.9rem; }
html.theme-dark .icon-moon::before { content: '☀'; }

.back-link {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
  margin-bottom: 0.5rem;
  color: var(--gp-blue);
}

/* Tabs */
.tabs {
  display: flex;
  padding: 0.5rem 1rem 0;
  gap: 0.35rem;
  background: var(--gp-white);
  border-bottom: 1px solid var(--border);
}

html.theme-dark .tabs { background: var(--card-bg); }

.tab {
  flex: 1;
  padding: 0.6rem;
  border: none;
  background: transparent;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.tab--active {
  background: var(--gp-navy);
  color: var(--gp-white);
}

.tab-panel { display: none; padding: 0.75rem 1rem 1rem; }
.tab-panel--active { display: block; }

main { padding: 0; }

/* Status */
.status-pill {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  border: 1px solid var(--border);
  background: var(--card-bg);
}

.status-pill__label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.status-pill__value {
  font-size: 0.85rem;
  font-weight: 700;
}

.status-oportunidade { border-left: 4px solid var(--gp-success); }
.status-oportunidade .status-pill__value { color: var(--gp-success); }
.status-concorrencia { border-left: 4px solid var(--gp-danger); }
.status-concorrencia .status-pill__value { color: var(--gp-danger); }
.status-execucao { border-left: 4px solid var(--gp-blue); }
.status-execucao .status-pill__value { color: var(--gp-blue); }
.status-atencao { border-left: 4px solid var(--gp-gold); }
.status-atencao .status-pill__value { color: #92680a; }

/* Blocks */
.block { margin-bottom: 1rem; }

.block-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--gp-navy);
  margin-bottom: 0.4rem;
}

html.theme-dark .block-label { color: var(--gp-gold); }

.input-lg,
.select-clean {
  width: 100%;
  padding: 0.9rem 1rem;
  font-size: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card-bg);
  color: var(--text);
}

.input-lg:focus,
.select-clean:focus {
  outline: none;
  border-color: var(--gp-blue);
  box-shadow: 0 0 0 3px rgba(0, 87, 168, 0.12);
}

textarea.select-clean { resize: vertical; min-height: 80px; }

.micro-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin: 0.65rem 0 0.35rem;
}

.hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin: 0 0 0.65rem;
}

/* Accordion */
.accordion {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 0.5rem;
  overflow: hidden;
}

.accordion summary {
  padding: 0.85rem 1rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--gp-navy);
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

html.theme-dark .accordion summary { color: var(--text); }

.accordion summary::-webkit-details-marker { display: none; }

.accordion summary::after {
  content: '▾';
  color: var(--text-muted);
  font-size: 0.75rem;
  transition: transform 0.2s;
}

.accordion[open] summary::after { transform: rotate(180deg); }

.accordion-body { padding: 0 1rem 1rem; }

.accordion--muted { opacity: 0.95; }

.badge-count {
  font-size: 0.7rem;
  background: var(--gp-red);
  color: white;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  font-weight: 700;
}

.badge-count:empty,
.badge-count[data-zero="1"] { background: var(--border); color: var(--text-muted); }

/* Chips */
.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.chip-group--compact .chip {
  min-height: 36px;
  padding: 0.35rem 0.65rem;
  font-size: 0.75rem;
}

.chip {
  min-height: 40px;
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.chip--selected {
  background: var(--gp-navy);
  border-color: var(--gp-navy);
  color: var(--gp-white);
}

.chip--gp.chip--selected {
  background: var(--gp-red);
  border-color: var(--gp-red-dark);
}

/* Segmented */
.segmented {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 0.5rem;
}

.segmented__btn {
  flex: 1;
  padding: 0.65rem;
  border: none;
  background: var(--surface);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-muted);
}

.segmented__btn--active {
  background: var(--gp-navy);
  color: var(--gp-white);
}

.segmented__btn[data-origem="Grupo Petrópolis"].segmented__btn--active {
  background: var(--gp-red);
}

.foto-capture-bar {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* Fotos list */
.fotos-list { display: flex; flex-direction: column; gap: 0.65rem; margin-top: 0.5rem; }

.foto-group-title {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0.25rem 0 0.35rem;
}

.foto-thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.foto-thumb {
  position: relative;
  width: 72px;
  height: 72px;
  border-radius: 10px;
  overflow: hidden;
  border: 2px solid var(--border);
}

.foto-thumb img { width: 100%; height: 100%; object-fit: cover; }

.foto-thumb__badge {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  font-size: 0.55rem;
  padding: 2px 4px;
  text-align: center;
  font-weight: 700;
  color: white;
}

.foto-thumb__badge--gp { background: var(--gp-red); }
.foto-thumb__badge--conc { background: var(--gp-navy); }

.foto-thumb__remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 50%;
  background: var(--gp-danger);
  color: white;
  font-size: 0.75rem;
  cursor: pointer;
  line-height: 1;
}

/* Categorias */
.cat-picker-row {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 0.65rem;
  align-items: stretch;
}

.cat-picker-row #cat-select { flex: 0 0 70%; max-width: 70%; }
.cat-picker-row .btn { flex: 1; white-space: nowrap; }

.cat-editor {
  padding: 0.75rem;
  background: var(--surface);
  border-radius: var(--radius-sm);
  margin-bottom: 0.65rem;
}

.cat-editor__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.cat-editor__head h3 {
  margin: 0;
  font-size: 0.9rem;
  color: var(--gp-red);
}

.tags-list { display: flex; flex-wrap: wrap; gap: 0.4rem; }

.tag-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.6rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.tag-item button {
  border: none;
  background: none;
  color: var(--gp-danger);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0;
}

/* SKU */
.form-compact { display: flex; flex-direction: column; gap: 0.4rem; margin-bottom: 0.65rem; }
.form-compact__row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.4rem; }

.cond-checks {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.35rem 0.6rem;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border, #d7dce3);
  border-radius: 0.6rem;
}
.cond-check { display: flex; align-items: center; gap: 0.4rem; font-size: 0.88rem; cursor: pointer; }
.cond-check input { width: 1rem; height: 1rem; flex-shrink: 0; }

.edit-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  background: #fff7e6;
  border: 1px solid #f0c878;
  color: #8a5a00;
  border-radius: 0.6rem;
  padding: 0.6rem 0.85rem;
  margin-bottom: 0.85rem;
  font-size: 0.88rem;
}
.edit-banner .btn-text { color: #8a5a00; font-weight: 600; }

.sku-list { display: flex; flex-direction: column; gap: 0.4rem; }

.sku-card-item {
  padding: 0.65rem 0.75rem;
  background: var(--surface);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--gp-red);
  font-size: 0.78rem;
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}

.sku-card-item strong { display: block; font-size: 0.82rem; }
.sku-card-item .meta { color: var(--text-muted); font-size: 0.72rem; }

/* Link card */
.link-card {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.85rem 1rem;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: inherit;
  margin: 0.75rem 0;
}

.link-card__body { flex: 1; min-width: 0; }
.link-card__title { display: block; font-weight: 700; font-size: 0.88rem; }
.link-card__desc { display: block; font-size: 0.72rem; color: var(--text-muted); margin-top: 0.15rem; }
.link-card__arrow { color: var(--gp-gold); font-weight: 700; font-size: 1.1rem; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0.7rem 1rem;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
}

.btn--primary {
  background: var(--gp-red);
  color: white;
}

.btn--soft {
  background: var(--surface);
  color: var(--gp-navy);
  border: 1px solid var(--border);
}

html.theme-dark .btn--soft { color: var(--text); }

.btn--ghost {
  background: var(--card-bg);
  border: 1px solid var(--border);
  color: var(--text);
}

.btn--sm { min-height: 38px; font-size: 0.78rem; padding: 0.5rem 0.65rem; width: auto; }

.btn--danger-text { color: var(--gp-danger); }

.btn-text {
  background: none;
  border: none;
  color: var(--gp-blue);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0.35rem 0;
}

.btn-row { display: flex; gap: 0.4rem; flex-wrap: wrap; }

.geo-inline {
  margin-top: 0.5rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.geo-inline a { color: var(--gp-blue); font-weight: 600; }

/* Ações de salvar (em fluxo, ao final do conteúdo) */
.sticky-actions {
  max-width: 480px;
  margin: 0 auto;
  padding: 0.85rem 1rem calc(0.85rem + var(--safe-bottom));
  background: var(--card-bg);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  align-items: center;
}

.sticky-actions.hidden { display: none; }

/* Dashboard */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}

.kpi-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.4rem;
  text-align: center;
}

.kpi-card .value {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--gp-red);
}

.kpi-card .label {
  font-size: 0.58rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.list-title {
  font-size: 0.85rem;
  font-weight: 700;
  margin: 1rem 0 0.5rem;
  color: var(--gp-navy);
}

.visit-list { display: flex; flex-direction: column; gap: 0.4rem; }

.visit-row {
  padding: 0.75rem;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.visit-row-header {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: flex-start;
}

.visit-row h4 { margin: 0; font-size: 0.88rem; }

.visit-meta { font-size: 0.72rem; color: var(--text-muted); margin-top: 0.2rem; }

.visit-badge {
  font-size: 0.6rem;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-weight: 700;
  color: white;
  white-space: nowrap;
}

.visit-actions { display: flex; gap: 0.35rem; margin-top: 0.5rem; }
.visit-actions .btn { flex: 1; min-height: 36px; font-size: 0.75rem; }

.export-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0.75rem 0;
}

.agregados-list {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.resumo-text { font-size: 0.82rem; line-height: 1.55; margin: 0; }

.privacy-note {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-align: center;
  padding: 0.75rem 1rem 1.5rem;
}

.main-cidade { padding: 1rem; }

.rating-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.rating-row span { font-size: 0.75rem; flex: 1; }

.rating-btns { display: flex; gap: 0.2rem; }

.rating-btn {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card-bg);
  font-weight: 700;
  font-size: 0.8rem;
  cursor: pointer;
}

.rating-btn--active {
  background: var(--gp-gold);
  border-color: #b8860b;
  color: var(--gp-dark);
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 20, 40, 0.5);
  z-index: 200;
  display: none;
  align-items: flex-end;
}

.modal-overlay.open { display: flex; }

.modal {
  width: 100%;
  max-width: 480px;
  max-height: 88vh;
  background: var(--card-bg);
  border-radius: var(--radius) var(--radius) 0 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.85rem 1rem;
  background: var(--gp-navy);
  color: white;
}

.modal-header h3 { margin: 0; font-size: 0.95rem; }

.modal-close {
  border: none;
  background: rgba(255,255,255,0.15);
  color: white;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
}

.modal-body {
  padding: 1rem;
  overflow-y: auto;
  font-size: 0.82rem;
}

.modal-body h4 {
  color: var(--gp-red);
  font-size: 0.78rem;
  margin: 0.75rem 0 0.35rem;
}

.modal-fotos { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.modal-fotos img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; }

.hidden { display: none !important; }
input[type="file"] { display: none; }

.empty-state {
  text-align: center;
  padding: 1.5rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.toast {
  position: fixed;
  bottom: calc(24px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--gp-navy);
  color: white;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  z-index: 300;
  opacity: 0;
  transition: 0.25s ease;
  max-width: 90%;
  text-align: center;
  border-left: 3px solid var(--gp-gold);
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast--success { border-left-color: var(--gp-success); }
.toast--error { border-left-color: var(--gp-danger); }

/* MVP — login, snapshot, métricas, sync */
.login-page .login-card { padding: 1rem 0 2rem; }
.login-card label { display: block; margin: 0.75rem 0 0.25rem; font-size: 0.8rem; color: var(--text-muted); }
.btn--block { width: 100%; margin-top: 1rem; }
.alert-error { background: #ffebee; color: #c62828; padding: 0.65rem; border-radius: 8px; margin-bottom: 0.75rem; font-size: 0.85rem; }
.badge-user { font-size: 0.7rem; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn-text--light { color: #fff; font-size: 0.75rem; margin-left: 0.25rem; }
.snapshot-card { margin-top: 0.5rem; padding: 0.65rem; background: var(--surface-muted, #f0f4f8); border-radius: 8px; font-size: 0.78rem; line-height: 1.4; }
.share-result { font-weight: 600; color: var(--gp-navy); margin: 0.5rem 0; }
.bool-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-bottom: 0.5rem; }
.chip--tristate.chip--no { background: #ffebee; border-color: var(--gp-danger); }
.chip--tristate.chip--selected { background: #e8f5e9; border-color: var(--gp-success); }
.rating-row { display: flex; gap: 0.35rem; }
.rating-btn { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface); font-weight: 600; }
.rating-btn--active { background: var(--gp-red); color: #fff; border-color: var(--gp-red); }
.tag-item--gp { border-left: 3px solid var(--gp-red); }
.tag-item--conc { border-left: 3px solid var(--gp-blue); }
.rec-list { margin: 0.35rem 0 0.75rem; padding-left: 1.1rem; font-size: 0.8rem; color: var(--text-muted); }
.sync-pill { font-size: 0.7rem; padding: 0.1rem 0.4rem; border-radius: 4px; background: #fff3e0; }
.sync-pill--sincronizado { background: #e8f5e9; }
.sync-pill--erro_sync { background: #ffebee; }
.foto-sync { position: absolute; bottom: 2px; left: 2px; font-size: 0.55rem; background: rgba(0,0,0,.6); color: #fff; padding: 1px 3px; border-radius: 3px; }
.foto-sync--ok { background: var(--gp-success); }
.foto-thumb { position: relative; }
.warn-text { color: var(--gp-danger); font-size: 0.85rem; }
