/* Liga DOOH Frota V9 - correções funcionais sem redesenhar o sistema */
html.liga-modal-open,
body.liga-modal-open {
  overflow: hidden !important;
  overscroll-behavior: none !important;
}

.modal-layer {
  overscroll-behavior: contain !important;
}

.modal.allocation-modal {
  max-height: calc(100dvh - 32px) !important;
  height: min(760px, calc(100dvh - 32px)) !important;
  overflow: hidden !important;
  display: flex !important;
  flex-direction: column !important;
}

.allocation-modal .modal-head,
.allocation-modal .modal-actions {
  flex: 0 0 auto !important;
}

.allocation-modal .allocation-grid {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  overflow: hidden !important;
}

.allocation-modal .allocation-form,
.allocation-modal .bus-picker {
  min-height: 0 !important;
}

.allocation-modal .allocation-form {
  overflow-y: auto !important;
  overscroll-behavior: contain !important;
}

.allocation-modal .bus-picker {
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;
}

.allocation-modal .bus-picker-head,
.allocation-modal .bus-picker-filters {
  flex: 0 0 auto !important;
}

.allocation-modal .bus-picker-list {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  overscroll-behavior: contain !important;
  -webkit-overflow-scrolling: touch;
  scrollbar-gutter: stable;
}

@media (max-width: 900px) {
  .modal.allocation-modal {
    height: calc(100dvh - 16px) !important;
    max-height: calc(100dvh - 16px) !important;
  }
  .allocation-modal .allocation-grid {
    overflow-y: auto !important;
  }
  .allocation-modal .allocation-form,
  .allocation-modal .bus-picker {
    overflow: visible !important;
  }
  .allocation-modal .bus-picker-list {
    max-height: 48dvh !important;
    overflow-y: auto !important;
  }
}


/* V9: a lista de ônibus é o único elemento rolável do painel direito. */
.allocation-modal .bus-picker-list {
  height: 100% !important;
  max-height: clamp(220px, calc(100dvh - 360px), 520px) !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  overscroll-behavior-y: contain !important;
  touch-action: pan-y !important;
}
.allocation-modal .bus-picker-list::-webkit-scrollbar { width: 10px; }
.allocation-modal .bus-picker-list::-webkit-scrollbar-thumb { background: rgba(101,0,104,.28); border-radius: 10px; }

/* V9.1 — financeiro, relatórios e encerramento manual */
.row-actions {
  display: flex !important;
  align-items: center;
  gap: 8px !important;
  flex-wrap: wrap;
}
.row-actions .warning {
  border: 1px solid rgba(101,0,104,.22);
  background: rgba(101,0,104,.08);
  color: #650068;
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 700;
}
.row-actions .warning:hover {
  background: rgba(101,0,104,.14);
}
.finance-inline {
  color: #6b6171 !important;
  font-size: 11px !important;
}
.field-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.file-attach-wrap {
  display: grid;
  gap: 8px;
}
.file-attach-wrap input[type="file"] {
  padding: 10px 12px;
  border: 1px dashed rgba(101,0,104,.28);
  border-radius: 14px;
  background: rgba(101,0,104,.03);
}
.file-attach-name {
  color: #650068;
  font-weight: 600;
}
.report-general-action {
  border: 1px solid rgba(101,0,104,.16);
  background: rgba(101,0,104,.05);
}
@media (max-width: 900px) {
  .field-row {
    grid-template-columns: 1fr;
  }
}

/* V9.3 — filtros agrupados + grade de disponibilidade */
.inventory-card {
  overflow: hidden;
}
.inventory-commandbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  border-bottom: 1px solid rgba(101,0,104,.08);
  background: #fff;
}
.inventory-command-left,
.inventory-command-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.filter-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(101,0,104,.14);
  background: #fff;
  color: #433947;
  border-radius: 12px;
  min-height: 40px;
  padding: 0 14px;
  font-weight: 700;
  position: relative;
}
.filter-toggle.active {
  border-color: rgba(101,0,104,.28);
  color: #650068;
  background: rgba(101,0,104,.05);
}
.filter-active-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #650068;
  display: inline-block;
}
.view-segment {
  display: inline-flex;
  padding: 4px;
  border-radius: 12px;
  background: #f3eff5;
}
.view-segment button {
  border: 0;
  background: transparent;
  color: #746a78;
  border-radius: 9px;
  padding: 8px 12px;
  font-weight: 700;
}
.view-segment button.active {
  background: #fff;
  color: #650068;
  box-shadow: 0 1px 4px rgba(32,18,38,.08);
}
.compact-select {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #776e7a;
  font-size: 12px;
  font-weight: 700;
}
.compact-select select {
  border: 1px solid rgba(101,0,104,.13);
  border-radius: 10px;
  background: #fff;
  padding: 8px 30px 8px 10px;
  color: #332b35;
}
.inventory-filter-panel {
  display: grid;
  grid-template-columns: minmax(180px,.8fr) minmax(340px,1.45fr) minmax(220px,1fr) minmax(180px,.75fr) auto;
  gap: 14px;
  align-items: end;
  padding: 16px 18px 18px;
  background: linear-gradient(180deg,#fbf9fc 0%,#f8f5fa 100%);
  border-bottom: 1px solid rgba(101,0,104,.08);
}
.filter-block {
  display: grid;
  gap: 8px;
  min-width: 0;
}
.filter-block-title {
  color: #766b79;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.filter-block-controls {
  display: grid;
  grid-template-columns: repeat(2,minmax(0,1fr));
  gap: 8px;
}
.filter-panel-actions {
  display: flex;
  justify-content: flex-end;
  align-items: end;
}
.available-lines-strip {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 18px;
  border-bottom: 1px solid rgba(101,0,104,.08);
  background: #fbfffc;
}
.available-lines-strip > strong {
  white-space: nowrap;
  color: #257a4f;
  font-size: 13px;
}
.available-line-chips {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.available-line-chips button {
  min-width: 36px;
  height: 34px;
  padding: 0 11px;
  border-radius: 10px;
  border: 1px solid rgba(38,139,87,.16);
  background: #eef9f2;
  color: #20784b;
  font-weight: 800;
}
.available-line-chips button:hover {
  background: #e1f5e8;
  border-color: rgba(38,139,87,.28);
}
.availability-legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid rgba(101,0,104,.08);
  color: #6f6673;
  font-size: 12px;
  font-weight: 700;
}
.availability-legend span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.availability-legend i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}
.legend-free { background: #35a968; }
.legend-campaign { background: #c92c58; }
.legend-maintenance { background: #c58b2e; }
.availability-matrix-scroll {
  width: 100%;
  overflow-x: auto;
  overflow-y: visible;
  scrollbar-gutter: stable;
  background: #fff;
}
.availability-matrix {
  width: max-content;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
}
.availability-matrix th,
.availability-matrix td {
  border-right: 1px solid #eee9f0;
  border-bottom: 1px solid #eee9f0;
}
.availability-matrix thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  width: 86px;
  min-width: 86px;
  padding: 10px 6px;
  background: #faf8fb;
  text-align: center;
  color: #6f6673;
}
.availability-matrix thead th strong {
  display: block;
  color: #2e2630;
  font-size: 12px;
}
.availability-matrix thead th small {
  display: block;
  margin-top: 3px;
  color: #948a98;
  font-size: 10px;
  text-transform: capitalize;
}
.availability-matrix thead th.today {
  background: #f2e8f5;
  color: #650068;
}
.matrix-bus-col {
  position: sticky;
  left: 0;
  z-index: 4 !important;
  width: 96px !important;
  min-width: 96px !important;
  background: #fff !important;
  text-align: left !important;
}
.matrix-line-col {
  position: sticky;
  left: 96px;
  z-index: 4 !important;
  width: 150px !important;
  min-width: 150px !important;
  background: #fff !important;
  text-align: left !important;
  color: #443a47;
  font-weight: 700;
}
.availability-matrix thead .matrix-bus-col,
.availability-matrix thead .matrix-line-col {
  z-index: 6 !important;
  background: #f7f3f8 !important;
}
.availability-matrix tbody .matrix-bus-col,
.availability-matrix tbody .matrix-line-col {
  padding: 10px 12px;
}
.matrix-bus-col button {
  border: 0;
  background: transparent;
  color: #650068;
  font-weight: 800;
  padding: 0;
}
.matrix-cell {
  width: 86px;
  min-width: 86px;
  height: 48px;
  padding: 5px;
  text-align: center;
  background: #fff;
}
.matrix-cell span {
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 34px;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 800;
}
.matrix-cell.free span {
  background: #e9f7ef;
  color: #218552;
  border: 1px solid #d6efdf;
}
.matrix-cell.campaign span {
  background: #fff0f3;
  color: #c42b55;
  border: 1px solid #f7dce4;
}
.matrix-cell.maintenance span {
  background: #fff7e8;
  color: #a66d12;
  border: 1px solid #f4e3c3;
}
.availability-matrix tbody tr:hover .matrix-bus-col,
.availability-matrix tbody tr:hover .matrix-line-col {
  background: #fbf8fc !important;
}
@media (max-width: 1200px) {
  .inventory-filter-panel {
    grid-template-columns: repeat(2,minmax(0,1fr));
  }
  .filter-panel-actions {
    justify-content: flex-start;
  }
}
@media (max-width: 760px) {
  .inventory-commandbar {
    align-items: stretch;
    flex-direction: column;
  }
  .inventory-command-left,
  .inventory-command-right {
    justify-content: space-between;
  }
  .inventory-filter-panel {
    grid-template-columns: 1fr;
  }
  .filter-block-controls {
    grid-template-columns: 1fr;
  }
  .available-lines-strip {
    align-items: flex-start;
    flex-direction: column;
  }
}
