:root {
  --bg: #f7f7f7;
  --panel: #ffffff;
  --ink: #171717;
  --muted: #6f6f6f;
  --line: #e3e3e3;
  --brand: #db0b15;
  --brand-dark: #a3090f;
  --brand-soft: #fdecec;
  --danger: #b42318;
  --warn: #b54708;
  --radius: 10px;
  --top-h: 64px;
  --shadow: 0 1px 2px rgba(16, 32, 24, .06), 0 8px 24px rgba(16, 32, 24, .06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

a { color: var(--brand); }

header.top {
  display: flex;
  align-items: center;
  gap: 16px;
  height: var(--top-h);
  padding: 0 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: -.01em;
}

.brand .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--brand);
  box-shadow: 0 0 0 4px var(--brand-soft);
}

.brand small {
  font-weight: 500;
  color: var(--muted);
  font-size: 12px;
}

.spacer { flex: 1; }

.search {
  flex: 0 1 320px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
}

.search input {
  border: 0;
  outline: 0;
  width: 100%;
  height: 34px;
  font: inherit;
  background: transparent;
}

nav.tabs {
  display: flex;
  gap: 4px;
  padding: 10px 20px 0;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}

nav.tabs button {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 10px 14px;
  font: inherit;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
}

nav.tabs button.active {
  color: var(--brand);
  border-bottom-color: var(--brand);
}

main { padding: 20px; max-width: 1600px; margin: 0 auto; }

.view { display: none; }
.view.active { display: block; }

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.toolbar h2 {
  margin: 0;
  font-size: 18px;
  letter-spacing: -.01em;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}

.card .label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  font-weight: 600;
}

.card .value {
  font-size: 24px;
  font-weight: 700;
  margin-top: 4px;
  letter-spacing: -.02em;
}

.card .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }

button.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 8px 14px;
  border-radius: 8px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

button.btn:hover { border-color: #c9d3ca; }

button.btn.primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

button.btn.primary:hover { background: var(--brand-dark); }

button.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }

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

button.btn.small { padding: 5px 10px; font-size: 13px; }

/* Kanban */
.board {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  overflow-x: auto;
  padding-bottom: 12px;
}

.column {
  flex: 0 0 280px;
  background: #eef1ee;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 250px);
}

.column header {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 8px;
}

.column header .name { font-weight: 700; font-size: 13px; }
.column header .count {
  margin-left: auto;
  font-size: 12px;
  color: var(--muted);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 1px 8px;
}

.column header .bar {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.column .sum {
  font-size: 11px;
  color: var(--muted);
  padding: 6px 12px 0;
}

.column .dropzone {
  padding: 8px;
  overflow-y: auto;
  min-height: 80px;
  flex: 1;
}

.column.dragover { outline: 2px dashed var(--brand); outline-offset: -4px; }

.deal {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 8px;
  cursor: grab;
  box-shadow: 0 1px 1px rgba(16, 32, 24, .04);
}

.deal:active { cursor: grabbing; }
.deal .title { font-weight: 600; font-size: 14px; }
.deal .company { color: var(--muted); font-size: 12px; margin-top: 2px; }
.deal .meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
  font-size: 11px;
  color: var(--muted);
}

.chip {
  background: var(--brand-soft);
  color: var(--brand-dark);
  border-radius: 999px;
  padding: 2px 8px;
  font-weight: 600;
  font-size: 11px;
}

.chip.warn { background: #fef3c7; color: var(--warn); }
.chip.danger { background: #fee4e2; color: var(--danger); }

/* Tabelas */
.table-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: auto;
  box-shadow: var(--shadow);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

thead th {
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfb;
  white-space: nowrap;
}

tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid #eef1ee;
  vertical-align: top;
}

tbody tr:hover { background: #fafcf9; }
tbody tr:last-child td { border-bottom: 0; }

td.actions { white-space: nowrap; text-align: right; }

.empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--muted);
}

/* Atividades */
.act {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 14px;
  border-bottom: 1px solid #eef1ee;
}

.act:last-child { border-bottom: 0; }
.act.done { opacity: .55; }
.act .mark {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 1.5px solid #c7d2c9;
  display: grid;
  place-items: center;
  cursor: pointer;
  flex: 0 0 22px;
  margin-top: 2px;
}
.act.done .mark { background: var(--brand); border-color: var(--brand); color: #fff; }
.act .subject { font-weight: 600; }
.act .line { color: var(--muted); font-size: 12px; margin-top: 2px; }

/* Modal */
.modal-bg {
  position: fixed;
  inset: 0;
  background: rgba(12, 24, 18, .45);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  overflow-y: auto;
  z-index: 50;
}

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

.modal {
  background: #fff;
  border-radius: 12px;
  width: 100%;
  max-width: 640px;
  box-shadow: 0 20px 60px rgba(10, 25, 18, .25);
}

.modal header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
}

.modal header h3 { margin: 0; font-size: 17px; }
.modal header button { margin-left: auto; }

.modal .body { padding: 16px 20px; }

.modal footer {
  padding: 14px 20px;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.grid3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

label.field { display: block; margin-bottom: 12px; }
/* Separador de bloco dentro do formulário (Identificação, Barra e seções,
   Monitor, GNSS, Uso). Deixa a ficha técnica longa legível. */
.form-sep {
  margin: 18px 0 10px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
}
.form-sep:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
label.field span {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 4px;
}

input, select, textarea {
  width: 100%;
  font: inherit;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--brand-soft);
  border-color: var(--brand);
}

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

/* Caixa de seleção não é campo de texto: sem largura total nem padding,
   senão ela estica e empurra o rótulo para a direita. */
input[type="checkbox"], input[type="radio"] {
  width: 16px;
  height: 16px;
  min-width: 16px;
  flex: 0 0 auto;
  margin: 0;
  padding: 0;
  border-radius: 4px;
  accent-color: var(--brand);
}

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #1a1a1a;
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 14px;
  opacity: 0;
  transition: .2s ease;
  pointer-events: none;
  z-index: 100;
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.login {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 28px;
  width: 100%;
  max-width: 360px;
  box-shadow: var(--shadow);
}

.login h1 { font-size: 20px; margin: 0 0 4px; }
.login p { color: var(--muted); margin: 0 0 20px; font-size: 14px; }
.login .err { color: var(--danger); font-size: 13px; min-height: 18px; }

@media (max-width: 640px) {
  .grid2, .grid3 { grid-template-columns: 1fr; }
  header.top { flex-wrap: wrap; }
  .search { flex: 1 1 100%; order: 3; }
  main { padding: 14px; }
}

/* Painel e indicadores de operação */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}
.panel h3 {
  margin: 0 0 10px;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
}
.partner-row {
  display: grid;
  grid-template-columns: minmax(160px, 1.4fr) minmax(120px, 1fr) auto auto;
  gap: 12px;
  align-items: center;
  padding: 8px 0;
  border-top: 1px solid var(--line);
  font-size: 13px;
}
.partner-row:first-of-type { border-top: 0; }
.partner-row .name { font-weight: 600; }
.bar-track {
  height: 8px;
  background: #ededed;
  border-radius: 999px;
  overflow: hidden;
}
.bar-track > span {
  display: block;
  height: 100%;
  background: var(--brand);
}
.chip.info { background: #e8f1fb; color: #1d4ed8; }
.chip.ok { background: #e7f6ec; color: #067647; }
.chip.muted { background: #efefef; color: #525252; }
.money { font-variant-numeric: tabular-nums; white-space: nowrap; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
@media (max-width: 760px) {
  .partner-row { grid-template-columns: 1fr auto; }
  .partner-row .bar-track { grid-column: 1 / -1; }
}

.late { color: var(--danger); font-weight: 600; }
td .money { font-variant-numeric: tabular-nums; }

/* ---------- Layout com barra lateral ---------- */
.layout {
  display: flex;
  min-height: calc(100vh - var(--top-h));
  align-items: stretch;
}

.sidebar {
  width: 300px;
  flex: 0 0 300px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: var(--top-h);
  height: calc(100vh - var(--top-h));
}

.side-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px 8px;
}

.side-head strong { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.side-head .btn { margin-left: auto; }

.side-filter {
  margin: 0 12px 8px;
  width: calc(100% - 24px);
  padding: 7px 10px;
  font-size: 13px;
}

.client-list { flex: 1; overflow-y: auto; border-top: 1px solid var(--line); }

.client-item {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  border-bottom: 1px solid #eef1ee;
  background: transparent;
  padding: 10px 14px;
  cursor: pointer;
  font: inherit;
  color: inherit;
}

.client-item:hover { background: #fafcf9; }
.client-item.active { background: var(--brand-soft); box-shadow: inset 3px 0 0 var(--brand); }
.client-item .num { display: block; font-size: 11px; font-weight: 700; letter-spacing: .05em; color: var(--brand); }
.client-item .name { display: block; font-weight: 600; font-size: 14px; }
.client-item .meta { display: block; font-size: 12px; color: var(--muted); }

.side-foot {
  padding: 10px 14px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
}

.content { flex: 1; min-width: 0; padding: 20px; max-width: none; }

/* Nas telas de todos os clientes e mapa geral a lista lateral é redundante */
body.wide .sidebar { display: none; }

.client-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.client-num { font-size: 12px; font-weight: 700; letter-spacing: .08em; color: var(--brand); }
.client-head h1 { margin: 2px 0 4px; font-size: 22px; letter-spacing: -.02em; }
.client-sub { color: var(--muted); font-size: 13px; }

#clientTabs { background: transparent; padding: 0; margin-bottom: 16px; }

.empty-state { max-width: 820px; }
.empty-state h2 { margin: 0 0 6px; font-size: 22px; }
.empty-state p { color: var(--muted); margin: 0 0 16px; }
.hint { color: var(--muted); font-size: 13px; }

.farm-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.farm-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid #eef1ee; flex-wrap: wrap; }
.farm-head h3 { margin: 0; font-size: 15px; }
.muted { color: var(--muted); font-size: 12px; }

.help { display: block; color: var(--muted); font-size: 11px; margin-top: 3px; }

.checks {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  max-height: 190px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
}

.checks label { font-size: 13px; display: flex; gap: 6px; align-items: center; }

.map {
  width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: #eef1ee;
}
.map-small { height: 340px; }
.map-big { height: calc(100vh - 260px); min-height: 420px; }

nav.tabs { background: transparent; border-bottom: 1px solid var(--line); padding: 0; margin-bottom: 14px; }

@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; flex: none; position: static; height: auto; max-height: 320px; border-right: 0; border-bottom: 1px solid var(--line); }
  .content { padding: 14px; }
  .map-big { height: 60vh; }
}

/* ---------- Códigos e fotos ---------- */
.code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12px; letter-spacing: .02em; }
.client-item .num .code { color: var(--brand); font-weight: 700; font-size: 12px; }
.code-chip { font-family: ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: .04em; }

.photos { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 6px; }
.dongle-info { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin: 4px 0 12px; font-size: 13px; }
.dongle-info .muted { font-size: 12px; }
.photos-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.photos-head strong { font-size: 13px; }
.upload { position: relative; display: inline-flex; align-items: center; }
.upload.busy { opacity: .6; pointer-events: none; }

.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.photo { position: relative; margin: 0; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); background: #f6f7f6; aspect-ratio: 4 / 3; }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-del {
  position: absolute; top: 4px; right: 4px; width: 22px; height: 22px;
  border: 0; border-radius: 50%; background: rgba(0,0,0,.62); color: #fff;
  font-size: 14px; line-height: 1; cursor: pointer;
}
.photo-del:hover { background: var(--danger); }

.thumb {
  position: relative; width: 46px; height: 34px; padding: 0; border: 1px solid var(--line);
  border-radius: 6px; overflow: hidden; background: #f6f7f6; cursor: pointer;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb span {
  position: absolute; bottom: 0; right: 0; background: rgba(0,0,0,.65); color: #fff;
  font-size: 10px; padding: 0 3px; border-top-left-radius: 4px;
}

/* ---------- Blindagem do mapa contra sobreposição ---------- */
.map-wrap {
  position: relative;
  z-index: 0;
  overflow: hidden;
  border-radius: var(--radius);
}
.map {
  position: relative;
  z-index: 0;
  overflow: hidden;
  isolation: isolate;
  height: 340px;
}
.cards, .card, .farm-card, .table-wrap {
  position: relative;
  z-index: 1;
}
.leaflet-container { z-index: 0; }

/* ---------- Tela de todos os clientes ---------- */
.topnav { display: flex; gap: 4px; margin-left: 14px; }
.topnav button {
  border: 0; background: transparent; font: inherit; font-size: 13px; font-weight: 600;
  color: var(--muted); padding: 6px 10px; border-radius: 7px; cursor: pointer;
}
.topnav button:hover { background: #f2f4f2; color: var(--ink); }
.topnav button.active { background: var(--brand-soft); color: var(--brand-dark); }

.all-clients { max-width: 100%; }
.all-clients .toolbar { align-items: flex-end; }
.all-clients h2 { margin: 0 0 2px; }
.table-filter {
  padding: 7px 10px; font-size: 13px; border: 1px solid var(--line);
  border-radius: 8px; min-width: 260px;
}

.clients-table tr.clickable { cursor: pointer; }
.clients-table tr.clickable:hover { background: #fafcf9; }
.clients-table .num-col { text-align: right; white-space: nowrap; }
.clients-table tfoot td { font-weight: 600; border-top: 2px solid var(--line); background: #fafbfa; }

@media (max-width: 900px) {
  .table-filter { min-width: 0; width: 100%; }
  .all-clients .toolbar { flex-wrap: wrap; }
}

/* ---------- Mapa geral (dentro da aba de clientes) ---------- */
.map-clients { height: 440px; }
.map-summary-line {
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between;
  gap: 6px; margin: -2px 0 14px; font-size: 12.5px;
}

/* ---------- Aba Trabalhos ---------- */
.jf-flag {
  display: inline-block; margin-left: 6px; padding: 1px 5px;
  border-radius: 5px; background: var(--brand-soft); color: var(--brand-dark);
  font-size: 9.5px; font-weight: 700; letter-spacing: .04em;
}
.job-files {
  border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; margin: 4px 0 14px; background: #fbfcfb;
}
.jf-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px; margin-bottom: 8px; }
.jf-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.jf-item { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 13px; }
.jf-item a { color: var(--brand-dark); font-weight: 600; }
.jf-item .btn { margin-left: auto; }
.jf-pick { position: relative; cursor: pointer; }

/* Lista de arquivos na ficha do cliente */
.file-list { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.file-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--panel);
}
.file-row a { color: var(--brand-dark); font-weight: 600; font-size: 13.5px; }
.file-row .btn { margin-left: auto; }

.works-counts { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 14px; }
.works-count {
  display: flex; align-items: baseline; gap: 6px; padding: 7px 11px;
  border: 1px solid var(--line); background: var(--panel); border-radius: 10px;
  font: inherit; cursor: pointer; color: var(--ink);
}
.works-count:hover { border-color: var(--brand); }
.works-count.on { border-color: var(--brand); background: var(--brand-soft); }
.works-count-n { font-weight: 700; font-size: 14px; }
.works-count-l { font-size: 12px; color: var(--muted); }
.works-count-note { font-size: 12.5px; }
.works-table tr.works-row { cursor: pointer; }
.works-table tr.works-row:hover { background: #fafcf9; }
.works-table .num-col { text-align: right; white-space: nowrap; }
.works-table tfoot td { font-weight: 600; border-top: 2px solid var(--line); background: #fafbfa; }

.map-filters {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px;
  margin: 0 0 12px;
}
.map-filters-right { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-left: auto; }
.map-client-picker { position: relative; }
.map-client-picker .caret { margin-left: 6px; font-size: 10px; opacity: .55; }
.map-client-panel {
  position: absolute; z-index: 1200; top: calc(100% + 6px); left: 0; right: auto;
  width: 310px; max-height: 360px;
  display: flex; flex-direction: column; gap: 8px;
  padding: 10px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 14px 34px rgba(16, 24, 16, .16);
}
.map-client-panel[hidden] { display: none; }
.map-client-panel input[type="search"] {
  width: 100%; padding: 7px 9px; font-size: 13px;
  border: 1px solid var(--line); border-radius: 8px;
}
.map-client-actions { display: flex; gap: 12px; }
.map-client-actions button {
  border: 0; background: none; padding: 0; font: inherit; font-size: 12px;
  color: var(--brand-dark); cursor: pointer; text-decoration: underline;
}
.map-client-list { overflow: auto; max-height: 250px; display: flex; flex-direction: column; }
.map-client-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 4px; border-radius: 6px; font-size: 13px; cursor: pointer;
}
.map-client-item:hover { background: #f4f7f4; }
.map-client-item strong { font-weight: 600; margin-right: 2px; }
.map-client-empty { font-size: 13px; color: var(--muted); padding: 6px 4px; }
.map-legend {
  display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 12px;
}
.legend-item {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--line); background: var(--panel); border-radius: 999px;
  padding: 5px 12px; font: inherit; font-size: 13px; cursor: pointer;
}
.legend-item:hover { border-color: #c9cdc9; background: #fafbfa; }
.legend-item.key { cursor: default; background: #fbfcfb; }
.legend-item.key:hover { border-color: var(--line); background: #fbfcfb; }
.map-filters .map-legend { margin: 0; }
.legend-item[data-map-kind] { cursor: pointer; }
.legend-item.off { opacity: .45; }
.legend-item.off .legend-dot { background: #c3c8c3 !important; }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.legend-item .muted { font-size: 12px; }

@media (max-width: 700px) {
  .map-client-panel { width: min(88vw, 310px); }
  .map-filters { gap: 6px; }
}

/* ---------- Marca ---------- */
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; }
.brand .logo { height: 26px; width: auto; display: block; }
.brand small { font-size: 12px; color: var(--muted); letter-spacing: .02em; }
.brand:hover { opacity: .9; }

.login-logo { height: 38px; width: auto; display: block; margin: 0 auto 18px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* ---------- Cultivos, prestadores e área declarada ---------- */
.lang-switch { display: flex; gap: 4px; align-items: center; }
.lang-switch button {
  border: 1px solid var(--line);
  background: #fff;
  padding: 3px;
  border-radius: 6px;
  cursor: pointer;
  line-height: 0;
  opacity: .6;
  transition: opacity .12s, border-color .12s, box-shadow .12s;
}
.lang-switch button:hover { opacity: 1; }
.lang-switch button.active {
  opacity: 1;
  border-color: var(--brand);
  box-shadow: 0 0 0 2px var(--brand-soft);
}
.lang-switch svg { width: 20px; height: 14px; border-radius: 2px; display: block; }
.login-lang { position: fixed; top: 16px; right: 16px; }

.toolbar .table-filter { width: auto; }
#clientsTableFilter { flex: 1 1 300px; max-width: 380px; min-width: 220px; }
#clientsCropFilter { flex: 0 0 190px; width: 190px; max-width: 190px; min-width: 190px; }
.crops-cell { white-space: normal; min-width: 140px; }
.crops-cell .chip { display: inline-block; margin: 0 4px 4px 0; }
.chip.crop { background: #eef3ee; color: #2b3a2f; }
tr.plot-only td { background: #fcfcfa; }
.area-note { margin: 0 0 12px; font-size: 12px; }

/* Tabela larga: aperta um pouco para caber sem rolagem lateral */
.clients-table { font-size: 13px; }
.clients-table thead th, .clients-table tbody td { padding: 9px 9px; }
.clients-table .crops-cell { max-width: 170px; }

/* Aviso de falha no carregamento inicial (não deixa a tela vazia sem explicação) */
.boot-error {
  position: sticky;
  top: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: #fdecec;
  border-bottom: 1px solid #f3c2c2;
  color: #7a1414;
  font-size: 14px;
}

/* Etiqueta de versão: serve para conferir na hora se o navegador está com o build novo */
.build-tag {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--muted, #6b7280);
  background: var(--chip, #f1f3f5);
  border-radius: 999px;
  padding: 2px 7px;
  margin-right: 8px;
}
.login-build {
  position: fixed;
  top: 16px;
  right: 108px;
  z-index: 60;
}

/* ------------------------------------------------------------------ */
/* Calendário global                                                   */
/* ------------------------------------------------------------------ */

.calendar-view { padding-bottom: 28px; }
.cal-client-filter { width: 210px; }
.cal-nav { display: flex; gap: 4px; align-items: center; }

.cal-legend {
  display: flex; flex-wrap: wrap; gap: 14px;
  margin: 0 0 10px; font-size: 12px; color: #5b6470;
}
.cal-legend span { display: inline-flex; align-items: center; gap: 6px; }
.cal-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

.cal-wrap {
  border: 1px solid #e3e6ea; border-radius: 12px; background: #fff; overflow: hidden;
}
.cal-weekdays {
  display: grid; grid-template-columns: repeat(7, 1fr);
  background: #f6f7f9; border-bottom: 1px solid #e3e6ea;
}
.cal-weekdays span {
  padding: 8px 10px; font-size: 11px; font-weight: 600; letter-spacing: .04em;
  text-transform: uppercase; color: #6b7280;
}
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-day {
  min-height: 108px; padding: 6px 7px 8px; border-right: 1px solid #eef0f3; border-bottom: 1px solid #eef0f3;
  display: flex; flex-direction: column; gap: 4px; cursor: pointer; background: #fff;
  transition: background .12s;
}
.cal-day:nth-child(7n) { border-right: none; }
.cal-day:hover { background: #fcfcfd; }
.cal-day.other { background: #fafbfc; color: #a3a9b3; }
.cal-day.today { box-shadow: inset 0 0 0 2px #DB0B15; border-radius: 6px; }
.cal-day .day-num { font-size: 12px; font-weight: 600; color: #414852; display: flex; justify-content: space-between; }
.cal-day.other .day-num { color: #a3a9b3; }
.cal-day .day-ha { font-size: 10.5px; font-weight: 500; color: #7b8492; }
.cal-chips { display: flex; flex-direction: column; gap: 3px; overflow: hidden; }
.cal-chip {
  font-size: 11px; line-height: 1.25; padding: 3px 6px; border-radius: 6px;
  border-left: 3px solid #9aa3ad; background: #f3f5f7; color: #2f3742;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cal-chip b { font-weight: 700; }
.cal-chip.planejado { background: #eef2ff; border-left-color: #4f46e5; color: #2a2f6b; }
.cal-chip.agendado { background: #e8f4fd; border-left-color: #0b74c4; color: #124467; }
.cal-chip.em-campo { background: #fff6e6; border-left-color: #c47f0b; color: #6b4708; }
.cal-chip.processando { background: #f3ecfd; border-left-color: #7c3aed; color: #45247a; }
.cal-chip.entregue { background: #e9f7ef; border-left-color: #067647; color: #0c5b39; }
.cal-chip.cancelado { background: #f4f5f6; border-left-color: #98a1ac; color: #6b7280; text-decoration: line-through; }
.cal-more { font-size: 10.5px; color: #6b7280; padding-left: 2px; }
.cal-hint { margin: 8px 0 0; }
.cal-empty { padding: 40px; text-align: center; color: #6b7280; }

/* Desenho e importação de mapas */
.map-toolbar { flex-wrap: wrap; gap: 8px; }
.map-farm-select { width: 200px; }
.draw-cta { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.imp-list { max-height: 220px; overflow: auto; border: 1px solid #e3e6ea; border-radius: 8px; padding: 8px; margin-top: 6px; }
.imp-row { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 3px 2px; }
.imp-row .muted { margin-left: auto; }

/* Seletor de ponto no mapa dentro do formulário */
.pick-wrap { margin-top: 8px; }
.pick-search { display: flex; gap: 8px; margin-bottom: 8px; }
.pick-search input { flex: 1; }
.map-pick { height: 240px; border-radius: 10px; border: 1px solid #e3e6ea; }

/* Controle financeiro */
.fin-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin-bottom: 14px; }
.fin-cards .card { background: #fff; border: 1px solid #e3e6ea; border-radius: 10px; padding: 10px 12px; }
.fin-cards .card .label { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: #6b7280; }
.fin-cards .card .value { font-size: 18px; font-weight: 700; color: #1f2937; margin-top: 4px; }
.finance-table td.num-col, .finance-table th.num-col { text-align: right; }
.fin-client-filter { width: 200px; }
.fin-status-filter { width: 170px; }

/* Recursos */
.resources-view { padding: 0 0 40px; }
.res-columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 14px; }
.res-block { background: #fff; border: 1px solid #e3e6ea; border-radius: 10px; padding: 12px 14px; margin-bottom: 14px; }
.res-block h3 { margin: 0 0 8px; font-size: 15px; }
.res-toolbar { margin-bottom: 8px; align-items: flex-start; }
.res-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.res-table th, .res-table td { padding: 7px 8px; border-bottom: 1px solid #eef0f3; text-align: left; vertical-align: top; }
.res-table th { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: #6b7280; background: #f8f9fa; }
.res-table td.num-col, .res-table th.num-col { text-align: right; }
.res-table tr.inactive-row td { opacity: .55; }
.row-actions { display: flex; gap: 6px; white-space: nowrap; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { background: #eef2ff; color: #3730a3; border-radius: 999px; padding: 1px 8px; font-size: 11px; }

/* Planejamento por recurso */
.cal-res { overflow-x: auto; }
.res-plan { display: grid; grid-template-columns: 190px repeat(var(--res-days, 30), minmax(92px, 1fr)); min-width: 100%; border: 1px solid #e3e6ea; border-radius: 10px; overflow: hidden; background: #fff; }
.res-row { display: contents; }
.res-name { padding: 8px 10px; border-bottom: 1px solid #eef0f3; background: #fbfbfc; position: sticky; left: 0; z-index: 1; }
.res-head .res-name, .res-head .res-cell { background: #f3f5f7; font-weight: 600; }
.res-cell { padding: 6px; border-bottom: 1px solid #eef0f3; border-left: 1px solid #f2f4f6; display: flex; flex-direction: column; gap: 3px; min-height: 42px; }
.res-cell.head { display: flex; flex-direction: column; align-items: center; font-size: 11px; color: #4b5563; }
.res-cell.head.today { background: #e8f1ff; }
.res-cell.head b { font-size: 12px; }
.cal-chip.sm { font-size: 10px; padding: 2px 5px; }
.res-plan-summary { margin-top: 16px; }

/* Rota */
.route-box, .weather-box { margin-top: 16px; background: #fff; border: 1px solid #e3e6ea; border-radius: 10px; padding: 12px 14px; }

/* Clima */
.weather-panel { display: grid; grid-template-columns: repeat(auto-fit, minmax(430px, 1fr)); gap: 12px; }
.weather-card { border: 1px solid #e3e6ea; border-radius: 10px; padding: 10px 12px; background: #fcfcfd; }
.weather-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 8px; }
.w-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.w-table th, .w-table td { padding: 4px 6px; border-bottom: 1px solid #f0f2f4; text-align: left; }
.w-table th { font-size: 10px; text-transform: uppercase; color: #6b7280; }
.w-table td.num-col, .w-table th.num-col { text-align: right; }
.w-table tbody tr[data-wday] { cursor: pointer; }
.w-table tbody tr[data-wday]:hover { background: #f5f8ff; }
.w-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.w-dot.sun { background: #f59e0b; }
.w-dot.part { background: #93c5fd; }
.w-dot.cloud { background: #9ca3af; }
.w-dot.rain { background: #2563eb; }
.w-dot.storm { background: #7c3aed; }
.rain-text { color: #1d4ed8; font-weight: 600; }
.w-hours { margin: 8px 0 4px 8px; border-left: 3px solid #dbeafe; padding-left: 8px; }
.w-hours-head { font-size: 12px; font-weight: 600; color: #1f2937; margin-bottom: 4px; }
.w-table tr.wet td { background: #eff6ff; }
.cal-mode-filter { width: 160px; }
.cal-range-filter { width: 110px; }

/* Pessoas */
.people-view { padding: 0 0 40px; }
.people-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 1080px; }
.people-table th, .people-table td { padding: 8px 9px; border-bottom: 1px solid #eef0f3; text-align: left; vertical-align: top; }
.people-table th { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: #6b7280; background: #f8f9fa; position: sticky; top: 0; }
.people-table tbody tr:hover { background: #f9fbff; }
.chip.warn { background: #fef3c7; color: #92400e; }

/* ------------------------------------------------------------------ */
/* Mobile: mesma ferramenta, leitura e toque adequados                 */
/* ------------------------------------------------------------------ */

@media (max-width: 820px) {
  :root { --top-h: 56px; }

  header.top {
    height: auto;
    min-height: var(--top-h);
    padding: 8px 12px;
    gap: 8px 10px;
    flex-wrap: wrap;
  }
  .brand img.logo { height: 24px; }
  .brand small { display: none; }
  .topnav {
    order: 4;
    margin: 0;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 2px;
    scrollbar-width: none;
  }
  .topnav::-webkit-scrollbar { display: none; }
  .topnav button { flex: 0 0 auto; padding: 8px 12px; font-size: 13px; white-space: nowrap; }

  .search { order: 5; flex: 1 1 100%; padding: 8px 12px; }
  .search input { font-size: 16px; }

  main.content {
    padding: 12px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: hidden;
  }
  .layout { max-width: 100vw; overflow-x: hidden; }
  .content > section { max-width: 100%; min-width: 0; }

  /* Sidebar vira lista curta acima do conteúdo */
  .layout { flex-direction: column; }
  .sidebar {
    position: static;
    width: 100%;
    flex: 0 0 auto;
    height: auto;
    max-height: 34vh;
    overflow-y: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .client-list { max-height: none; }
  body.wide .sidebar { display: none; }

  /* Barra de ações: campos em largura cheia e alvo de toque confortável */
  .toolbar { gap: 8px; }
  .toolbar h2 { font-size: 17px; }
  .toolbar .spacer { display: none; }
  .toolbar > .btn, .toolbar > a.btn { min-height: 38px; }
  .table-filter, .cal-mode-filter, .cal-range-filter, .fin-client-filter, .fin-status-filter, .cal-client-filter {
    width: 100%;
    min-width: 0;
    font-size: 16px;
    padding: 9px 10px;
  }
  .btn { min-height: 36px; }

  /* Tabelas: rolagem horizontal com coluna de ação fixa */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table-wrap table { font-size: 12.5px; }
  .table-wrap th, .table-wrap td { padding: 7px 8px; }

  /* Cards e blocos em coluna única */
  .res-columns, .weather-panel { grid-template-columns: minmax(0, 1fr); }
  .res-block { padding: 10px; }
  .res-plan { --res-days: 7; }
  .res-name { width: 140px; }

  /* Calendário: rolagem horizontal em vez de esmagar 7 colunas */
  .cal-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .cal-weekdays, .cal-grid { min-width: 640px; }
  .cal-day { min-height: 84px; }
  .cal-chip { font-size: 10px; }

  /* Mapa */
  .map-wrap .map, #allMap.map-big, .map-clients { height: 56vh !important; min-height: 320px !important; }
  #routeMap { height: 300px !important; }

  /* Modal ocupa a tela e o rodapé fica acessível */
  .modal-bg { padding: 0; align-items: stretch; }
  .modal { max-width: none; border-radius: 0; min-height: 100%; display: flex; flex-direction: column; }
  .modal header { position: sticky; top: 0; background: #fff; z-index: 2; padding: 12px 14px; }
  .modal .body { padding: 14px; flex: 1; }
  .modal footer {
    position: sticky; bottom: 0; background: #fff; z-index: 2;
    padding: 10px 14px; border-top: 1px solid var(--line);
  }
  .modal footer .btn { flex: 1; min-height: 42px; }
  .field input, .field select, .field textarea { font-size: 16px; }
  .map-pick { height: 240px; }

  .login { padding: 22px; }
}

@media (max-width: 640px) {
  /* Lista de clientes: só o essencial */
  /* Mantém Código, Cliente, Culturas, Área e Status */
  .clients-table th:nth-child(4), .clients-table td:nth-child(4),
  .clients-table th:nth-child(5), .clients-table td:nth-child(5),
  .clients-table th:nth-child(6), .clients-table td:nth-child(6),
  .clients-table th:nth-child(7), .clients-table td:nth-child(7),
  .clients-table th:nth-child(9), .clients-table td:nth-child(9),
  .clients-table th:nth-child(10), .clients-table td:nth-child(10) { display: none; }

  /* Pessoas: pessoa, função, WhatsApp e abrir */
  .people-table { min-width: 0; }
  /* Pessoas: pessoa, empresa, quem atende, WhatsApp e abrir */
  .people-table th:nth-child(2), .people-table td:nth-child(2),
  .people-table th:nth-child(5), .people-table td:nth-child(5),
  .people-table th:nth-child(6), .people-table td:nth-child(6),
  .people-table th:nth-child(7), .people-table td:nth-child(7),
  .people-table th:nth-child(8), .people-table td:nth-child(8),
  .people-table th:nth-child(10), .people-table td:nth-child(10),
  .people-table th:nth-child(11), .people-table td:nth-child(11) { display: none; }

  /* Contatos do cliente: nome, WhatsApp e abrir */
  #tab-contacts table th:nth-child(2), #tab-contacts table td:nth-child(2),
  #tab-contacts table th:nth-child(3), #tab-contacts table td:nth-child(3),
  #tab-contacts table th:nth-child(4), #tab-contacts table td:nth-child(4),
  #tab-contacts table th:nth-child(6), #tab-contacts table td:nth-child(6),
  #tab-contacts table th:nth-child(7), #tab-contacts table td:nth-child(7),
  #tab-contacts table th:nth-child(8), #tab-contacts table td:nth-child(8) { display: none; }

  /* Prestadores: serviço, prestador, WhatsApp, abrir */
  #tab-providers table th:nth-child(3), #tab-providers table td:nth-child(3),
  #tab-providers table th:nth-child(4), #tab-providers table td:nth-child(4),
  #tab-providers table th:nth-child(6), #tab-providers table td:nth-child(6),
  #tab-providers table th:nth-child(7), #tab-providers table td:nth-child(7),
  #tab-providers table th:nth-child(8), #tab-providers table td:nth-child(8),
  #tab-providers table th:nth-child(9), #tab-providers table td:nth-child(9) { display: none; }

  /* Financeiro: trabalho, cliente, valor, status, abrir */
  .finance-table th:nth-child(3), .finance-table td:nth-child(3),
  .finance-table th:nth-child(4), .finance-table td:nth-child(4),
  .finance-table th:nth-child(5), .finance-table td:nth-child(5),
  .finance-table th:nth-child(7), .finance-table td:nth-child(7),
  .finance-table th:nth-child(8), .finance-table td:nth-child(8) { display: none; }

  /* Recursos */
  #allocBody td:nth-child(3), #allocBody td:nth-child(4),
  #allocBody td:nth-child(6) { display: none; }

  .fin-cards { grid-template-columns: 1fr 1fr; }
  .cards { grid-template-columns: 1fr 1fr; }
  .cal-hint { display: none; }
  .weather-card { padding: 8px; }
  .w-table th:nth-child(3), .w-table td:nth-child(3),
  .w-table th:nth-child(6), .w-table td:nth-child(6) { display: none; }
}

/* Resultados da busca de lugar */
.place-results {
  border: 1px solid #e3e6ea; border-radius: 10px; background: #fff;
  margin: -4px 0 8px; overflow: hidden; box-shadow: 0 10px 24px rgba(10, 25, 18, .10);
}
.place-results-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
  color: #6b7280; padding: 8px 10px 4px;
}
.place-item {
  display: flex; flex-direction: column; gap: 2px; width: 100%;
  text-align: left; border: 0; border-top: 1px solid #f0f2f4; background: #fff;
  padding: 8px 10px; cursor: pointer; font: inherit; font-size: 13px;
}
.place-item:hover { background: #f5f8ff; }
.place-item small { color: #6b7280; font-size: 12px; }

/* Clima e janela de voo no trabalho planejado */
.job-weather {
  margin-top: 14px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}
.jw-head {
  display: flex;
  gap: 8px;
  align-items: baseline;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.jw-grid { display: flex; flex-direction: column; gap: 6px; }
.jw-row {
  display: grid;
  grid-template-columns: 92px minmax(110px, 1fr) 88px 66px 62px 72px 104px minmax(140px, 1.2fr);
  gap: 10px;
  align-items: center;
  font-size: 13px;
}
.jw-num { text-align: right; font-variant-numeric: tabular-nums; }
.jw-reason { font-size: 12px; }
.jw-foot { margin-top: 8px; font-size: 11.5px; line-height: 1.4; }
.jw-slots { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 5px; }
.jw-slot {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 25px; height: 18px; border-radius: 4px;
  font-size: 9.5px; font-variant-numeric: tabular-nums; font-weight: 600;
}
.jw-slot.ok { background: #dcfce7; color: #166534; }
.jw-slot.warn { background: #fef3c7; color: #92400e; }
.jw-slot.bad { background: #fee2e2; color: #991b1b; }
.jw-best { margin-top: 4px; font-size: 11.5px; }
@media (max-width: 700px) {
  .jw-row { grid-template-columns: 1fr 1fr; }
  .jw-reason { grid-column: 1 / -1; }
}

/* Rota terrestre: trechos e ações */
.route-legs { margin-top: 10px; }
.route-table { min-width: 640px; font-size: 12.5px; }
.route-table tfoot td { font-weight: 600; border-top: 2px solid var(--line); background: #fafbfa; }
.route-actions { display: flex; justify-content: flex-end; margin-top: 8px; }

/* Celular: previsão do dia com o essencial e hora a hora sem rolagem lateral */
@media (max-width: 640px) {
  .weather-card { padding: 8px; }
  .weather-card > .table-wrap > .w-table { font-size: 10.5px; }
  .weather-card > .table-wrap > .w-table th,
  .weather-card > .table-wrap > .w-table td { padding: 4px 2px; }
  .weather-card .w-dot { margin-right: 3px; }
  .weather-card > .table-wrap > .w-table th:nth-child(5),
  .weather-card > .table-wrap > .w-table td:nth-child(5),
  .weather-card > .table-wrap > .w-table th:nth-child(8),
  .weather-card > .table-wrap > .w-table td:nth-child(8) { display: none; }
  .weather-card .w-hours .w-table th:nth-child(7),
  .weather-card .w-hours .w-table td:nth-child(7),
  .weather-card .w-hours .w-table th:nth-child(8),
  .weather-card .w-hours .w-table td:nth-child(8) { display: none; }
}
@media (max-width: 640px) {
  .weather-head { flex-direction: column; gap: 2px; }
  .weather-head > .muted { font-size: 10.5px; }
}

/* Celular: operações do calendário com contraste alto e sem texto cortado */
@media (max-width: 640px) {
  .cal-day { min-height: 96px; }
  .cal-chip {
    font-size: 11px; line-height: 1.2; padding: 4px 6px;
    white-space: normal; overflow: visible; text-overflow: clip;
    border-left-width: 4px; font-weight: 600;
  }
  .cal-chip.sm { font-size: 10.5px; padding: 3px 5px; }
  .cal-chip.planejado { background: #4338ca; color: #fff; border-left-color: #312e81; }
  .cal-chip.agendado { background: #0b74c4; color: #fff; border-left-color: #075985; }
  .cal-chip.em-campo { background: #b45309; color: #fff; border-left-color: #7c2d12; }
  .cal-chip.processando { background: #6d28d9; color: #fff; border-left-color: #4c1d95; }
  .cal-chip.entregue { background: #047857; color: #fff; border-left-color: #065f46; }
  .cal-chip.cancelado { background: #6b7280; color: #fff; border-left-color: #374151; }
}

/* Admin: cadastros auxiliares */
.admin-view { padding: 0 0 40px; }
.admin-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.admin-card { border: 1px solid #e3e6ea; border-radius: 10px; background: #fff; padding: 12px; }
.admin-card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; gap: 8px; }
.admin-rows { display: flex; flex-direction: column; gap: 6px; max-height: 340px; overflow: auto; }
.admin-row { display: flex; gap: 6px; align-items: center; }
.admin-input { flex: 1; min-width: 0; padding: 7px 8px; border: 1px solid #dfe3e8; border-radius: 8px; font-size: 13px; background: #fff; }
.admin-row.off .admin-input { color: #98a1ac; text-decoration: line-through; }
.admin-add { display: flex; gap: 6px; margin-top: 10px; }
.admin-add input { flex: 1; min-width: 0; padding: 8px; border: 1px solid #dfe3e8; border-radius: 8px; font-size: 13px; }
.admin-empty { padding: 6px 0; font-size: 12px; }

@media (max-width: 640px) {
  .admin-cards { grid-template-columns: 1fr; }
}

/* Admin: alça de arraste e setas no celular */
.admin-grip { cursor: grab; color: #9aa3ad; font-size: 14px; line-height: 1; padding: 0 2px; user-select: none; }
.admin-row.dragging { opacity: .55; }
.admin-row.dragging .admin-grip { cursor: grabbing; }
.admin-move { display: none; padding: 4px 6px; min-height: 0; }
@media (max-width: 640px) {
  .admin-move { display: inline-flex; }
  .admin-grip { display: none; }
}

/* Máquinas alocadas dentro do cartão da fazenda */
.farm-machines { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.farm-machines .chip { font-size: 11px; }

/* Ordenação por coluna */
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--ink); }
th .sort-ind { font-size: 9px; margin-left: 4px; color: var(--accent); vertical-align: 1px; }

/* Operações da semana com previsão */
.weather-jobs { display: flex; flex-direction: column; gap: 8px; margin: 10px 0 14px; }
.wjob { border: 1px solid var(--line); border-radius: 10px; background: #fff; padding: 10px 12px; }
.wjob-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 13px; }
.wjob-head .spacer { flex: 1; }
.wjob-days { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.wday {
  display: flex; flex-direction: column; gap: 2px; min-width: 118px;
  border: 1px solid var(--line); border-left-width: 4px; border-radius: 8px;
  padding: 6px 8px; font-size: 12px; background: #fbfcfd;
}
.wday b { font-size: 12px; }
.wday-weather { display: flex; align-items: center; gap: 4px; color: var(--muted); }
.wday.lvl-ok { border-left-color: #16a34a; }
.wday.lvl-atencao { border-left-color: #d97706; }
.wday.lvl-nao { border-left-color: #dc2626; }
.weather-lookup { border-top: 1px solid var(--line); padding-top: 12px; }
.weather-lookup h4 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.weather-filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
@media (max-width: 640px) {
  .wjob-days { display: grid; grid-template-columns: 1fr 1fr; }
  .wday { min-width: 0; }
  .weather-filters select { flex: 1 1 100%; }
}

/* Horas de voo no chip do calendário */
.cal-hours { display: inline-block; margin-left: 4px; padding: 0 4px; border-radius: 6px; background: rgba(255,255,255,.28); font-size: 10px; font-weight: 600; }
.cal-hours.warn { background: #f59e0b; color: #1f2937; }
.cal-hours.bad { background: #dc2626; color: #fff; }

/* Detalhe hora a hora dentro da operação da semana */
.wjob-head { cursor: pointer; }
.wjob.open { border-color: var(--accent); }
.wjob-hours { margin-top: 10px; border-top: 1px dashed var(--line); padding-top: 8px; }
.hours-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.hours-table th, .hours-table td { padding: 5px 7px; border-bottom: 1px solid #eef0f3; text-align: left; white-space: nowrap; }
.hours-table th { font-size: 10px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: #f8f9fa; }
.hours-table td.num-col, .hours-table th.num-col { text-align: right; }
.hours-table tr.wh-day td { background: #f2f7fd; font-size: 12px; }
.wh-note { margin-top: 6px; font-size: 11px; }

/* ------------------------------------------------------------------ */
/* Página do trabalho (tela cheia)                                     */
/* ------------------------------------------------------------------ */

.job-view { padding: 4px 0 40px; }

/* Lista lateral de trabalhos, no molde da lista de clientes */
.job-shell { display: grid; grid-template-columns: 292px minmax(0, 1fr); gap: 18px; align-items: start; }
.job-detail { min-width: 0; }
.job-menu {
  position: sticky; top: calc(var(--top-h) + 12px);
  display: flex; flex-direction: column;
  max-height: calc(100vh - var(--top-h) - 28px);
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
}
.job-menu-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
  padding: 12px 14px 8px;
}
.job-menu-head strong { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.job-menu .side-filter { margin: 0 12px 10px; width: calc(100% - 24px); }
.job-menu-list { position: relative; flex: 1; overflow-y: auto; border-top: 1px solid var(--line); }
.job-item {
  display: block; width: 100%; text-align: left; border: 0;
  border-bottom: 1px solid #eef1ee; background: transparent;
  padding: 9px 14px; cursor: pointer; font: inherit; color: inherit;
}
.job-item:hover { background: #fafcf9; }
.job-item.active { background: var(--brand-soft); box-shadow: inset 3px 0 0 var(--brand); }
.job-item .num { display: block; font-size: 11px; font-weight: 700; letter-spacing: .05em; color: var(--brand); }
.job-item .name { display: block; font-weight: 600; font-size: 13.5px; }
.job-item .meta { display: block; font-size: 12px; color: var(--muted); }
.job-menu-empty { padding: 14px; }
.job-head {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px;
  padding: 4px 0 16px; border-bottom: 1px solid var(--line); margin-bottom: 16px;
}
.job-back {
  border: 0; background: none; padding: 0; font: inherit; font-size: 13px;
  color: var(--brand-dark); cursor: pointer; font-weight: 600;
}
.job-back:hover { text-decoration: underline; }
.job-title { display: flex; flex-direction: column; gap: 2px; }
.job-num { font-size: 12px; font-weight: 700; letter-spacing: .04em; color: var(--muted); }
.job-title h1 { margin: 0; font-size: 22px; font-weight: 700; }
.job-sub { font-size: 13px; color: var(--muted); }

.job-kpis {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px; margin-bottom: 20px;
}
.job-kpi {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px;
}
.jk-label { font-size: 11.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.jk-value { font-size: 20px; font-weight: 700; margin-top: 4px; }
.jk-note { font-size: 12px; color: var(--muted); margin-top: 2px; }

.job-cols { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 22px; align-items: start; }
.job-sec { margin-bottom: 22px; }
.job-sec h3 {
  margin: 0 0 10px; font-size: 13px; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; color: var(--muted);
}
.job-form {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0 18px; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px 16px 6px;
}
.job-form .field.wide { grid-column: 1 / -1; }
.job-side { display: flex; flex-direction: column; gap: 14px; }
.job-side .job-files, .job-side .job-weather {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px;
}

@media (max-width: 1100px) {
  .job-shell { grid-template-columns: 250px minmax(0, 1fr); }
}
@media (max-width: 980px) {
  .job-cols { grid-template-columns: minmax(0, 1fr); }
  .job-shell { grid-template-columns: minmax(0, 1fr); }
  .job-menu { position: static; max-height: 300px; }
  .job-menu-list { max-height: 210px; }
}
@media (max-width: 640px) {
  .job-head { align-items: flex-start; }
  .job-title h1 { font-size: 19px; }
  .job-head .btn { width: auto; }
  .job-form { grid-template-columns: 1fr; padding: 14px 14px 4px; }
  .job-kpis { grid-template-columns: 1fr 1fr; }
}

/* ---------- Mapa em tela cheia ---------- */
.map-fs-btn {
  position: absolute; bottom: 10px; left: 10px; z-index: 900;
  width: 34px; height: 34px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255, 255, 255, .95); color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px; cursor: pointer;
  box-shadow: 0 2px 10px rgba(16, 24, 16, .14);
}
.map-fs-btn:hover { background: #fff; color: var(--brand-dark); border-color: var(--brand); }
.map-fs-btn svg { width: 16px; height: 16px; }
.map-wrap.fs {
  position: fixed; inset: 0; z-index: 3000;
  border-radius: 0; background: #fff;
  height: 100vh; width: 100vw;
}
.map-wrap.fs .map { height: 100% !important; min-height: 0 !important; max-height: none !important; }
.map-wrap.fs .map-fs-btn { bottom: 14px; left: 14px; }
body.map-fullscreen { overflow: hidden; }

/* ---------- Diagnóstico de máquina (documento de campo) ---------- */
.diag-doc {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 26px 30px 30px;
}
.diag-head {
  display: flex; gap: 24px; justify-content: space-between; align-items: flex-start;
  border-bottom: 2px solid var(--ink);
  padding-bottom: 14px; margin-bottom: 20px;
}
.diag-brand { font-size: 12px; font-weight: 800; letter-spacing: .16em; color: var(--muted); }
.diag-head h2 { margin: 4px 0 6px; font-size: 20px; line-height: 1.2; }
.diag-farm { min-width: 240px; }
.diag-sec { margin-bottom: 24px; }
.diag-sec h3 {
  font-size: 12px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--ink); margin: 0 0 10px;
}
.diag-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 18px; }
.diag-grid .field.wide { grid-column: 1 / -1; }
.diag-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.diag-table th {
  text-align: left; font-size: 10px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); border-bottom: 1px solid var(--line); padding: 6px 8px; font-weight: 700;
}
.diag-table td { border-bottom: 1px solid var(--line); padding: 6px 8px; vertical-align: middle; }
.diag-table input, .diag-table select {
  width: 100%; padding: 5px 7px; border: 1px solid var(--line);
  border-radius: 6px; font-size: 13px; background: #fff; font-family: inherit;
}
.diag-state select { max-width: 130px; }
.diag-calc { font-weight: 600; white-space: nowrap; }
.diag-doc .field input[readonly] { background: #f4f6f4; color: var(--ink); }

@media (max-width: 780px) {
  .diag-doc { padding: 16px 14px; }
  .diag-head { flex-direction: column; }
  .diag-grid { grid-template-columns: 1fr; }
  .diag-table { font-size: 12px; }
}

/* Impressão: sai só o documento, com as respostas em linha, sem cara de tela. */
@media print {
  .top, .topnav, .sidebar, .no-print, .tabs, .toasts { display: none !important; }
  body { background: #fff; }
  .job-view { display: block !important; padding: 0; }
  .job-shell { display: block; }
  .diag-doc { border: 0; padding: 0; border-radius: 0; }
  .diag-sec { break-inside: avoid; page-break-inside: avoid; }
  .diag-table input, .diag-table select,
  .diag-doc .field input, .diag-doc .field select, .diag-doc .field textarea {
    border: 0; border-bottom: 1px solid #999; border-radius: 0;
    background: transparent; padding: 1px 0; appearance: none; -webkit-appearance: none;
    font-size: 12px;
  }
  .diag-doc .field input[readonly] { background: transparent; font-weight: 600; }
  .diag-head h2 { font-size: 18px; }
}

/* ---------- Filtro de culturas (múltipla escolha) ---------- */
.crop-picker { position: relative; }
.crop-picker .caret { margin-left: 6px; font-size: 10px; opacity: .55; }
.crop-panel {
  position: absolute; z-index: 1200; top: calc(100% + 6px); right: 0;
  width: 250px; max-height: 330px;
  display: flex; flex-direction: column; gap: 8px;
  padding: 10px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 14px 34px rgba(16, 24, 16, .16);
}
.crop-panel[hidden] { display: none; }
.crop-panel-head { display: flex; align-items: center; justify-content: space-between; }
.crop-panel-list { overflow: auto; display: flex; flex-direction: column; gap: 2px; }
.crop-item {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 6px; border-radius: 6px; cursor: pointer; font-size: 13px;
}
.crop-item:hover { background: rgba(0, 0, 0, .04); }
.crop-item input { margin: 0; }
.crop-item .crop-count { margin-left: auto; color: var(--muted); font-size: 11px; }
.link-btn {
  border: 0; background: none; padding: 0; cursor: pointer;
  color: var(--brand-dark); font-size: 12px; text-decoration: underline;
}
.crop-panel.crop-panel-map { left: 0; right: auto; }
