/* ── Variables ─────────────────────────────────────────────────────────── */
:root {
  --primary:     #7FB97F;
  --primary-dark:#5A8F5A;
  --primary-light:#E8F5E9;
  --secondary:   #2c3e50;
  --accent:      #1a56db;
  --accent-light:#EBF2FF;
  --green:       #7FB97F;
  --green-light: #E8F5E9;
  --orange:      #F97316;
  --orange-light:#FEF3C7;
  --red:         #DC2626;
  --red-light:   #FEE2E2;
  --blue:        #1a56db;
  --blue-light:  #EBF2FF;
  --yellow:      #EAB308;
  --yellow-light:#FEF3C7;
  --bg:          #fafbfc;
  --card:        #ffffff;
  --border:      #e5e7eb;
  --text:        #1f2937;
  --text-light:  #6b7280;
  --muted:       #9ca3af;
  --radius:      6px;
  --shadow:      0 1px 2px rgba(0,0,0,.04);
  --shadow-md:   0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.05);
}

/* ── Reset ─────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: linear-gradient(135deg, #fafbfc 0%, #f9fbfa 100%);
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
}
button, input, select, textarea { font-family: inherit; font-size: inherit; }

/* ── Header ────────────────────────────────────────────────────────────── */
.header {
  background: var(--primary);
  color: #fff;
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  max-width: 1440px;
  margin: 0 auto;
  padding: .7rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.header-brand  { display: flex; align-items: center; gap: 0; }
.header-logo { max-height: 50px; height: auto; width: auto; flex-shrink: 0; }
.btn-ghost-w {
  background: rgba(255,255,255,.18);
  border: 1px solid rgba(255,255,255,.3);
  color: #fff;
  padding: .45rem 1rem;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: .875rem;
  font-weight: 500;
  white-space: nowrap;
}
.btn-ghost-w:hover { background: rgba(255,255,255,.28); }

/* ── Main ──────────────────────────────────────────────────────────────── */
.main { max-width: 1440px; margin: 0 auto; padding: 1.5rem; }

/* ── Views ─────────────────────────────────────────────────────────────── */
.view { display: none; }
.view.active { display: block; }

/* ── Cards ─────────────────────────────────────────────────────────────── */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.card {
  background: linear-gradient(135deg, #ffffff 0%, #fafbfc 100%);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.25rem;
  border: 1px solid rgba(229, 231, 235, 0.6);
}
.card-kpi         { border-left: 4px solid var(--primary); }
.card-kpi.orange  { border-left-color: var(--orange); }
.card-kpi.green   { border-left-color: var(--green); }
.card-kpi.red     { border-left-color: var(--red); }
.card-kpi.yellow  { border-left-color: var(--yellow); }
.card-label {
  font-size: .7rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
}
.card-value {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text);
  margin-top: .2rem;
}

/* ── Color helpers ─────────────────────────────────────────────────────── */
.c-blue   { color: var(--primary); }
.c-orange { color: var(--orange); }
.c-green  { color: var(--green); }
.c-red    { color: var(--red); }
.c-muted  { color: var(--muted); }
.c-yellow { color: var(--yellow); }

/* ── Section header ────────────────────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .75rem;
  margin-bottom: 1rem;
}
.section-header h2, .section-header h3 { font-size: 1.05rem; font-weight: 700; }
.section-actions { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }

/* ── Buttons ───────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .5rem 1.05rem;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-weight: 500;
  font-size: .875rem;
  transition: all .15s ease-in-out;
  white-space: nowrap;
  line-height: 1.4;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 1px 2px rgba(127,185,127,.12); }
.btn-primary:hover { background: var(--primary-dark); box-shadow: 0 4px 6px rgba(127,185,127,.15); }
.btn-outline { background: var(--card); border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); background: #f0f4f8; }
.btn-ghost  { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: #f3f4f6; color: var(--text); }
.btn-danger { background: var(--red); color: #fff; box-shadow: 0 1px 2px rgba(220,38,38,.12); }
.btn-danger:hover { background: #b91c1c; box-shadow: 0 4px 6px rgba(220,38,38,.15); }
.btn-success { background: var(--green); color: #fff; }
.btn-sm { padding: .35rem .8rem; font-size: .8rem; }

/* ── Dropdown ──────────────────────────────────────────────────────────── */
.dropdown { position: relative; }
.dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  background: linear-gradient(135deg, #ffffff 0%, #fafbfc 100%);
  border: 1px solid rgba(229, 231, 235, 0.6);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  z-index: 200;
  min-width: 230px;
  display: none;
  overflow: hidden;
}
.dropdown.open .dropdown-menu { display: block; }
.dropdown-menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: .65rem 1rem;
  background: none;
  border: none;
  cursor: pointer;
  font-size: .875rem;
  color: var(--text);
  border-bottom: 1px solid var(--border);
}
.dropdown-menu button:last-child { border-bottom: none; }
.dropdown-menu button:hover { background: var(--primary-light); color: var(--primary); }

/* ── Inputs ────────────────────────────────────────────────────────────── */
.input {
  width: 100%;
  padding: .5rem .75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
.input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(127,185,127,.13);
}
textarea.input { resize: vertical; }
.input-sm { padding: .4rem .65rem; font-size: .875rem; }
.input-search {
  padding: .46rem .75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--text);
  min-width: 240px;
  font-size: .875rem;
}
.input-search:focus { outline: none; border-color: var(--primary); }

/* ── Form ──────────────────────────────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  align-items: start;
}
.form-group { display: flex; flex-direction: column; gap: .3rem; }
.form-group label { font-size: .78rem; font-weight: 600; color: var(--muted); }
.req { color: var(--red); }
.fg-wide { grid-column: 1 / -1; }
.form-preview {
  grid-column: 1 / -1;
  padding: .7rem 1rem;
  background: var(--primary-light);
  border-radius: var(--radius);
  font-size: .875rem;
  color: var(--primary-dark);
  min-height: 2.5rem;
  font-weight: 500;
}
.form-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: .75rem;
  padding-top: .25rem;
}

/* ── Autocomplete ──────────────────────────────────────────────────────── */
.autocomplete-wrap { position: relative; }
.ac-list {
  position: absolute;
  top: calc(100% + 3px);
  left: 0; right: 0;
  background: linear-gradient(135deg, #ffffff 0%, #fafbfc 100%);
  border: 1px solid rgba(229, 231, 235, 0.6);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  max-height: 260px;
  overflow-y: auto;
  z-index: 400;
  display: none;
}
.ac-list.open { display: block; }
.ac-item {
  padding: .55rem .85rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  font-size: .845rem;
  line-height: 1.4;
}
.ac-item:last-child { border-bottom: none; }
.ac-item:hover { background: var(--primary-light); }
.ac-cod { font-size: .72rem; color: var(--muted); margin-top: .1rem; }

/* ── Table ─────────────────────────────────────────────────────────────── */
.table-wrapper {
  background: linear-gradient(135deg, #ffffff 0%, #fafbfc 100%);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow-x: auto;
  margin-bottom: .25rem;
  border: 1px solid rgba(229, 231, 235, 0.6);
}
.table { width: 100%; border-collapse: collapse; font-size: .855rem; }
.table th {
  background: #f8fafc;
  padding: .65rem .9rem;
  text-align: left;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
.table td {
  padding: .6rem .9rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #f8fafc; }
.num { text-align: right; white-space: nowrap; }

/* ── Badges ────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: .18rem .58rem;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge-pronto        { background: var(--green-light);  color: var(--green); }
.badge-afazer        { background: var(--primary-light);   color: var(--primary); }
.badge-refazimento   { background: var(--red-light);    color: var(--red); }
.badge-identificada  { background: #f1f5f9;             color: var(--muted); }
.badge-orcada        { background: var(--green-light);  color: var(--green); }
.badge-pendorç       { background: var(--yellow-light); color: var(--yellow); }
.badge-naoiniciado   { background: #f1f5f9;             color: var(--muted); }
.badge-emandamento   { background: var(--yellow-light); color: var(--yellow); }
.badge-finalizado    { background: var(--green-light);  color: var(--green); }
.badge-revisar       { background: var(--orange-light); color: var(--orange); }

/* ── Apt header ────────────────────────────────────────────────────────── */
.apt-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}
.apt-header-actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: flex-start; }
.apt-title  { font-size: 1.15rem; font-weight: 700; }
.apt-meta   { font-size: .84rem; color: var(--muted); margin-top: .25rem; display: flex; gap: .75rem; flex-wrap: wrap; align-items: center; }

/* ── Ambiente accordion ────────────────────────────────────────────────── */
.ambiente-card {
  background: linear-gradient(135deg, #ffffff 0%, #fafbfc 100%);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: .75rem;
  overflow: hidden;
  border: 1px solid rgba(229, 231, 235, 0.6);
}
.ambiente-card.open { border-color: var(--primary); }

.ambiente-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .85rem 1.1rem;
  cursor: pointer;
  user-select: none;
  background: #f5f7f6;
  transition: background .12s;
}
.ambiente-card.open .ambiente-header { background: var(--primary-light); }
.ambiente-header:hover { background: #f0f3f1; }
.ambiente-card.open .ambiente-header:hover { background: #e0f2e1; }

.ambiente-name {
  font-weight: 700;
  font-size: .95rem;
  min-width: 120px;
}
.ambiente-stats {
  flex: 1;
  font-size: .8rem;
  color: var(--muted);
  display: flex;
  gap: .75rem;
  flex-wrap: wrap;
}
.ambiente-stat { display: flex; align-items: center; gap: .3rem; }
.ambiente-toggle {
  font-size: .85rem;
  color: var(--muted);
  margin-left: auto;
  transition: transform .2s;
}
.ambiente-card.open .ambiente-toggle { transform: rotate(180deg); }

.ambiente-body {
  padding: 1rem 1.1rem 1.1rem;
  border-top: 1px solid var(--border);
}

/* ── Obs row inside ambiente ───────────────────────────────────────────── */
.obs-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .75rem;
  margin-bottom: 1rem;
}
.obs-row .form-group { margin: 0; }

/* ── Pendências columns ────────────────────────────────────────────────── */
.pend-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: .75rem;
}
.pend-col-header {
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  margin-bottom: .5rem;
  padding-bottom: .35rem;
  border-bottom: 2px solid var(--border);
}
.pend-col-header.afazer { border-bottom-color: var(--orange); color: var(--orange); }
.pend-col-header.refaz  { border-bottom-color: var(--red);    color: var(--red); }

.pend-add {
  display: flex;
  gap: .4rem;
  margin-bottom: .5rem;
}
.pend-add input { flex: 1; }

.pend-list { display: flex; flex-direction: column; gap: .35rem; }

.pend-item {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .5rem .65rem;
}
.pend-item.has-orc {
  border-color: var(--green);
  background: #f0fdf4;
}
.pend-item-top {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
}
.pend-dot { font-size: .75rem; flex-shrink: 0; }
.pend-dot.afazer { color: var(--orange); }
.pend-dot.refaz  { color: var(--red); }
.pend-desc { flex: 1; font-size: .875rem; font-weight: 500; word-break: break-word; }
.pend-custo {
  font-size: .78rem;
  font-weight: 700;
  padding: .15rem .45rem;
  border-radius: 4px;
  background: var(--green-light);
  color: var(--green);
}
.pend-actions { display: flex; gap: .3rem; margin-left: auto; }
.pend-empty { font-size: .8rem; color: var(--muted); font-style: italic; padding: .4rem 0; }

/* ── Ambiente footer ───────────────────────────────────────────────────── */
.ambiente-footer {
  display: flex;
  justify-content: flex-end;
  padding-top: .75rem;
  border-top: 1px solid var(--border);
  margin-top: .75rem;
}

/* ── Orc ref label ─────────────────────────────────────────────────────── */
.orc-ref-label {
  background: var(--primary-light);
  color: var(--primary-dark);
  border-radius: var(--radius);
  padding: .6rem .9rem;
  font-size: .875rem;
  font-weight: 500;
  margin-bottom: .5rem;
}

/* ── Pagination ────────────────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  gap: .35rem;
  padding: .65rem 0;
  justify-content: flex-end;
  flex-wrap: wrap;
}
.page-btn {
  padding: .35rem .7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  cursor: pointer;
  font-size: .845rem;
  color: var(--text);
}
.page-btn:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-btn:disabled { opacity: .38; cursor: default; }

/* ── Modal ─────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.46);
  z-index: 500;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-overlay.open { display: flex; }
.modal {
  background: linear-gradient(135deg, #ffffff 0%, #fafbfc 100%);
  border-radius: 12px;
  padding: 1.5rem;
  width: 100%;
  max-width: 680px;
  max-height: 92vh;
  overflow-y: auto;
  box-shadow: 0 24px 64px rgba(0,0,0,.15);
}
.modal-sm { max-width: 420px; }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}
.modal-header h3 { font-size: 1.05rem; font-weight: 700; }
.modal-close {
  background: none;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  color: var(--muted);
  padding: .25rem .5rem;
  border-radius: 6px;
}
.modal-close:hover { background: var(--border); color: var(--text); }

/* ── Empty state ───────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 3.5rem 1rem;
  color: var(--muted);
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}
.empty-icon { font-size: 2.5rem; opacity: .4; }

/* ── Toast ─────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: #1e293b;
  color: #fff;
  padding: .7rem 1.2rem;
  border-radius: var(--radius);
  font-size: .875rem;
  z-index: 999;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity .22s, transform .22s;
  pointer-events: none;
  max-width: 340px;
  font-weight: 500;
}
.toast.show    { opacity: 1; transform: translateY(0); }
.toast.success { background: var(--green); }
.toast.error   { background: var(--red); }

/* ── Vistoria Individual ────────────────────────────────────────────── */
#vistoria-title {
  margin-bottom: 1.5rem;
}
.vistoria-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 1rem 0 1rem 1.25rem;
  border-left: 4px solid var(--primary);
  gap: 1rem;
}
.vistoria-header > div:first-child {
  flex: 1;
}
.vistoria-title {
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: .4rem;
  color: var(--text);
}
.vistoria-sub {
  font-size: .875rem;
  color: var(--muted);
  margin-bottom: .5rem;
}
.vistoria-meta {
  font-size: .8rem;
  color: var(--muted);
  letter-spacing: .02em;
  display: grid;
  grid-template-columns: auto auto;
  gap: .75rem 1.5rem;
  margin-top: .5rem;
}
.vistoria-status {
  background: var(--primary);
  color: #fff;
  padding: .5rem 1rem;
  border-radius: var(--radius);
  font-size: .8rem;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
  height: fit-content;
}
.vistoria-actions {
  display: flex;
  gap: .5rem;
  margin-bottom: 1.5rem;
}

/* ── KPI Cards ────────────────────────────────────────────────────── */
.card-kpi {
  background: linear-gradient(135deg, #ffffff 0%, #fafbfc 100%);
  border: 1px solid rgba(229, 231, 235, 0.6);
  border-radius: var(--radius);
  padding: 1.25rem 1rem;
  text-align: center;
  box-shadow: var(--shadow);
  border-left: 5px solid var(--muted);
}
.card-kpi.blue   { border-left-color: var(--primary); }
.card-kpi.orange { border-left-color: var(--orange); }
.card-kpi.green  { border-left-color: var(--green); }
.card-kpi.red    { border-left-color: var(--red); }
.card-kpi-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: .35rem;
}
.card-kpi-label {
  font-size: .8rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .02em;
}

/* ── Ambiente Cards ─────────────────────────────────────────────────── */
#ambientes-list {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}
.amb-card {
  background: linear-gradient(135deg, #ffffff 0%, #fafbfc 100%);
  border: 1px solid rgba(229, 231, 235, 0.6);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.amb-nome {
  padding: 0.9rem 1.25rem;
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  font-size: .9rem;
  letter-spacing: .02em;
}
.amb-body {
  padding: 1.5rem;
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
}
.amb-section {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.amb-section-title {
  font-size: .85rem;
  font-weight: 700;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: .03em;
  padding-bottom: .5rem;
  border-bottom: 1px solid var(--border);
}
.amb-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.amb-row {
  display: flex;
  flex-direction: column;
}
.amb-row label {
  font-size: .8rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .02em;
  margin-bottom: .35rem;
}
.amb-input {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .65rem;
  font-size: .9rem;
  resize: vertical;
  min-height: 70px;
  font-family: inherit;
  background: #fafbfc;
}
.amb-input:focus {
  outline: none;
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(127,185,127,.1);
}

/* ── Lançamento Form ────────────────────────────────────────────────── */
.lanc-form-wrap {
  margin-bottom: 1.5rem;
}
.lanc-empty {
  color: var(--muted);
  font-style: italic;
  font-size: .9rem;
  padding: 1rem 0;
  text-align: center;
}
.lanc-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1rem;
  font-size: .85rem;
}
.lanc-table thead {
  background: #f8fafc;
  border-bottom: 2px solid var(--border);
}
.lanc-table th {
  padding: .6rem .5rem;
  text-align: left;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .02em;
  font-size: .75rem;
}
.lanc-table th.num {
  text-align: right;
  padding-right: 1rem;
}
.lanc-table td {
  padding: .65rem .5rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.lanc-table td.num {
  text-align: right;
  font-weight: 500;
  padding-right: 1rem;
}
.lanc-table td.sinapi {
  font-family: 'Courier New', monospace;
  font-size: .8rem;
  color: var(--primary);
}
.lanc-table tr:hover {
  background: #f8fafc;
}
.lanc-table .badge {
  display: inline-block;
  padding: .3rem .5rem;
  border-radius: 4px;
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .01em;
}
.badge-green { background: var(--green-light); color: var(--green); }
.badge-orange { background: var(--orange-light); color: var(--orange); }
.badge-red { background: var(--red-light); color: var(--red); }
.lanc-table .actions {
  white-space: nowrap;
  padding: .65rem;
}
.btn-xs {
  padding: .35rem .5rem;
  font-size: .75rem;
}

/* ── Lançamento Totals ────────────────────────────────────────────────── */
.lanc-totals {
  display: flex;
  gap: 1.5rem;
  padding: 1rem;
  background: #f8fafc;
  border-radius: 6px;
  border: 1px solid var(--border);
  font-size: .85rem;
  flex-wrap: wrap;
}
.lanc-total {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-weight: 600;
  color: var(--text);
}

/* ── Filter Bar ────────────────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  background: linear-gradient(135deg, #ffffff 0%, #fafbfc 100%);
  border-radius: var(--radius);
  border: 1px solid rgba(229, 231, 235, 0.6);
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  box-shadow: var(--shadow);
}
.filter-select,
.filter-input {
  padding: .5rem .75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--text);
  font-size: .875rem;
}
.filter-select {
  min-width: 150px;
}
.filter-input {
  flex: 1;
  min-width: 200px;
}
.filter-select:focus,
.filter-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(127,185,127,.13);
}
.filter-result-count {
  font-size: .85rem;
  color: var(--muted);
  white-space: nowrap;
  margin-left: auto;
  font-weight: 500;
}

/* ── Block-grouped Apartments ─────────────────────────────────────────── */
#dash-blocos-list {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}
.bloco-group {
  background: linear-gradient(135deg, #ffffff 0%, #fafbfc 100%);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid rgba(229, 231, 235, 0.6);
}
.bloco-header {
  padding: 1rem 1.25rem;
  background: linear-gradient(135deg, #ffffff 0%, #f9fbfa 100%);
  border-bottom: 2px solid var(--primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  color: var(--text);
}
.bloco-count {
  font-size: .8rem;
  color: var(--muted);
  background: var(--primary-light);
  padding: .25rem .65rem;
  border-radius: 12px;
  font-weight: 500;
}
.bloco-apts {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.apt-item {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  transition: background .12s;
}
.apt-item:last-child {
  border-bottom: none;
}
.apt-item:hover {
  background: #f9fafb;
}
.apt-info {
  flex: 1;
}
.apt-name {
  font-weight: 600;
  color: var(--text);
  margin-bottom: .25rem;
}
.apt-meta {
  font-size: .8rem;
  color: var(--muted);
}
.apt-actions {
  display: flex;
  gap: .4rem;
  flex-shrink: 0;
}

/* ── Responsive ────────────────────────────────────────────────────────── */
@media (max-width: 860px) {
  .main { padding: 1rem; }
  .cards-grid { grid-template-columns: repeat(2, 1fr); }
  .pend-cols  { grid-template-columns: 1fr; }
  .obs-row    { grid-template-columns: 1fr; }
  .form-grid  { grid-template-columns: 1fr; }
  .fg-wide    { grid-column: 1; }
  .section-header { flex-direction: column; align-items: flex-start; }
  .apt-header { flex-direction: column; }
  .input-search { min-width: 0; width: 100%; }
  .header-title { font-size: .9rem; }
  .amb-card { margin-bottom: 1rem; }
  .amb-body { grid-template-columns: 1fr; }
  .amb-row { grid-column: 1; }
  .vistoria-header { flex-direction: column; align-items: flex-start; gap: 1rem; }
  .vistoria-status { min-width: auto; width: 100%; }
  .vistoria-actions { flex-direction: column; }
  .vistoria-actions .btn { width: 100%; }
  .amb-fields { grid-template-columns: 1fr; }
  .amb-body { gap: 1.5rem; }
  .lanc-totals { flex-direction: column; gap: .75rem; }
  .lanc-table { font-size: .75rem; }
  .lanc-table th, .lanc-table td { padding: .4rem .3rem; }
  .apt-item { flex-direction: column; align-items: flex-start; }
  .apt-actions { width: 100%; }
  .apt-actions .btn { width: 100%; }
}
@media (max-width: 480px) {
  .cards-grid { grid-template-columns: 1fr; }
  .amb-fields { grid-template-columns: 1fr; }
  .amb-body { gap: 1rem; padding: 1rem; }
  .vistoria-actions { flex-direction: column; }
  .vistoria-actions .btn { width: 100%; }
  .lanc-table { font-size: .7rem; overflow-x: auto; }
  .lanc-table th.num, .lanc-table td.num { padding-right: .3rem; }
  .lanc-totals { flex-direction: column; gap: .5rem; font-size: .8rem; padding: .75rem; }
}

/* ════════════════════════════════════════════════════════════════════════
   New / corrected styles
   ════════════════════════════════════════════════════════════════════════ */

/* ── Secondary button ──────────────────────────────────────────────────── */
.btn-secondary {
  background: var(--secondary);
  color: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,.12);
}
.btn-secondary:hover { background: #1a2a3a; box-shadow: 0 4px 6px rgba(0,0,0,.15); }

/* ── Bloco header ──────────────────────────────────────────────────────── */
.bloco-header {
  padding: .85rem 1.25rem;
  background: linear-gradient(135deg, #ffffff 0%, #f9fbfa 100%);
  border-bottom: 2px solid var(--primary);
  display: flex;
  align-items: center;
  gap: 1rem;
  cursor: pointer;
  user-select: none;
  flex-wrap: wrap;
}
.bloco-header:hover { background: var(--primary-light); }
.bloco-header-left {
  display: flex;
  align-items: center;
  gap: .65rem;
  flex-shrink: 0;
}
.bloco-name { font-size: 1rem; font-weight: 700; color: var(--text); }
.bloco-count {
  font-size: .78rem;
  background: var(--primary-light);
  color: var(--primary-dark);
  padding: .2rem .6rem;
  border-radius: 12px;
  font-weight: 600;
}
.bloco-header-kpis {
  flex: 1;
  display: flex;
  gap: .65rem;
  flex-wrap: wrap;
  align-items: center;
}
.bloco-kpi {
  font-size: .78rem;
  font-weight: 600;
  padding: .15rem .5rem;
  border-radius: 10px;
  white-space: nowrap;
}
.bloco-kpi.green  { background: var(--green-light);  color: var(--primary-dark); }
.bloco-kpi.orange { background: var(--orange-light); color: #c2410c; }
.bloco-kpi.muted  { background: #f3f4f6;             color: var(--muted); }
.bloco-kpi.blue   { background: var(--blue-light);   color: var(--blue); }
.bloco-toggle { font-size: .8rem; color: var(--muted); margin-left: auto; }

/* ── Apt item (in block list) ──────────────────────────────────────────── */
.apt-item {
  padding: .85rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  transition: background .1s;
}
.apt-item:last-child { border-bottom: none; }
.apt-item:hover { background: #f9fbfa; }
.apt-info { flex: 1; min-width: 0; }
.apt-name { font-weight: 600; color: var(--text); font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.apt-meta { font-size: .78rem; color: var(--muted); margin-top: .15rem; }
.apt-status-wrap { flex-shrink: 0; }
.apt-actions { display: flex; gap: .35rem; flex-shrink: 0; }

/* ── No results ────────────────────────────────────────────────────────── */
.no-results {
  padding: 2rem 1.5rem;
  text-align: center;
  color: var(--muted);
  font-size: .9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .75rem;
  flex-wrap: wrap;
}

/* ── Empty state ───────────────────────────────────────────────────────── */
.empty-state {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 4rem 1.5rem;
  text-align: center;
}
.empty-icon  { font-size: 3rem; opacity: .35; }
.empty-title { font-size: 1.2rem; font-weight: 700; color: var(--text); margin: 0; }
.empty-text  { color: var(--muted); max-width: 380px; line-height: 1.6; margin: 0; }
.empty-actions { display: flex; gap: .75rem; flex-wrap: wrap; justify-content: center; }

/* ── Modal lg ──────────────────────────────────────────────────────────── */
.modal-lg { max-width: 820px; }

/* ── Lote modal extras ─────────────────────────────────────────────────── */
.lote-separator { padding-top: 1rem; border-top: 1px solid var(--border); }
.lote-replicar-section {
  grid-column: 1 / -1;
  background: var(--primary-light);
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.lote-tmpl-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .75rem;
}
.lote-tmpl-grid .form-group { margin: 0; }
.lote-tmpl-grid p { grid-column: 1 / -1; margin: 0; font-size: .83rem; color: var(--text); }
.lote-hint {
  font-size: .82rem;
  color: var(--muted);
  font-style: italic;
  margin: 0;
  padding: .5rem 0;
}
.form-hint {
  display: block;
  font-size: .78rem;
  color: var(--muted);
  margin-top: .3rem;
}
.checkbox-label {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
}
.checkbox-label input[type="checkbox"] { width: 15px; height: 15px; cursor: pointer; accent-color: var(--primary); }

/* ── Lanc table wrapper (scrollable) ──────────────────────────────────── */
.lanc-table-wrap { overflow-x: auto; margin-bottom: .5rem; }

/* ── Badge fixes ───────────────────────────────────────────────────────── */
.badge-afazer     { background: var(--orange-light); color: #c2410c; }
.badge-refazimento{ background: var(--red-light);    color: var(--red); }

/* ── Vistoria header badge fix ─────────────────────────────────────────── */
.vistoria-header .badge {
  font-size: .85rem;
  padding: .4rem .85rem;
  align-self: flex-start;
}

/* ── Responsive additions ──────────────────────────────────────────────── */
@media (max-width: 860px) {
  .lote-tmpl-grid { grid-template-columns: 1fr; }
  .bloco-header   { flex-direction: column; align-items: flex-start; }
  .bloco-toggle   { display: none; }
  .apt-item       { flex-wrap: wrap; }
  .apt-status-wrap{ order: -1; }
}
@media (max-width: 480px) {
  .apt-actions { width: 100%; justify-content: flex-start; }
  .apt-actions .btn { flex: 1; }
  .empty-actions .btn { width: 100%; }
}
