/* 9.7.0 / v21 — desktop board grid, filter 3-col, modal metrics, phone scroll */

html body.bu-board-page,
html body.bu-nalog-page {
  font-family: Inter, "Plus Jakarta Sans", "SF Pro Display", system-ui, sans-serif;
}

/* —— PHONE: native document scroll —— */
@media (max-width: 1023px) {
  html,
  html body.bu-board-page:not(.bu-nalog-page) {
    height: auto !important;
    max-height: none !important;
    min-height: 100vh !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    touch-action: pan-y !important;
    -webkit-overflow-scrolling: touch !important;
    background: #f8fafc !important;
  }

  html body.bu-board-page:not(.bu-nalog-page) .bu-board-shell-wrap,
  html body.bu-board-page:not(.bu-nalog-page) .bu-board-main-col,
  html body.bu-board-page:not(.bu-nalog-page) .bu-board,
  html body.bu-board-page:not(.bu-nalog-page) .bu-term-grid,
  html body.bu-board-page:not(.bu-nalog-page) .bu-board-body {
    display: block !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    flex: none !important;
    grid-template-columns: none !important;
  }

  html body.bu-board-page #bu-map-pane:not(.is-on) {
    display: none !important;
    pointer-events: none !important;
    position: absolute !important;
    width: 0 !important;
    height: 0 !important;
  }

  html body.bu-board-page #bu-list-pane,
  html body.bu-board-page .bu-board-list-scroll,
  html body.bu-board-page #bu-feed {
    display: block !important;
    height: auto !important;
    min-height: 0 !important;
    overflow: visible !important;
    padding-bottom: 110px !important;
    touch-action: pan-y !important;
    -webkit-overflow-scrolling: touch !important;
  }

  html body.bu-board-page #bu-feed .bu-item.compact {
    display: block !important;
    grid-template-columns: none !important;
    background: transparent !important;
    border: 0 !important;
    padding: 0 !important;
    margin: 0 0 10px !important;
  }

  html body.bu-board-page #bu-feed .bu-item.compact > :not(.bu-mload) {
    display: none !important;
  }

  html body.bu-board-page #bu-feed .bu-mload {
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
    padding: 14px !important;
    background: #fff !important;
    color: #0f172a !important;
    border: 1px solid rgba(226, 232, 240, 0.9) !important;
    border-radius: 16px !important;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05) !important;
  }

  html body.bu-board-page #bu-feed .bu-mload-route,
  html body.bu-board-page #bu-feed .bu-mload-end,
  html body.bu-board-page #bu-feed .bu-mload-end b {
    color: #0f172a !important;
    font-size: 14px !important;
    font-weight: 700 !important;
  }

  html body.bu-board-page #bu-feed .bu-mload-chip {
    background: #f1f5f9 !important;
    color: #334155 !important;
    font-size: 11px !important;
  }

  html body.bu-board-page #bu-feed .bu-mload-price {
    font-size: 20px !important;
    font-weight: 800 !important;
    color: #0f172a !important;
  }

  html body.bu-board-page #bu-dispo-fab {
    z-index: 60 !important;
    right: 16px !important;
    bottom: calc(80px + env(safe-area-inset-bottom, 0px)) !important;
  }

  html body #bu-mdetail-map,
  html body .bu-mdetail-map {
    height: 180px !important;
    max-height: 180px !important;
  }

  html body.bu-mobile-detail-open #bu-mobile-detail-sheet:not([hidden]) {
    background: #f8fafc !important;
    color: #0f172a !important;
  }

  html body #bu-mobile-detail-body,
  html body #bu-mobile-detail-body b,
  html body #bu-mobile-detail-body .bu-ccflag {
    color: #0f172a !important;
  }

  html body #bu-mobile-detail-foot {
    background: rgba(255, 255, 255, 0.92) !important;
    backdrop-filter: blur(12px) !important;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px)) !important;
    border-top: 1px solid #f1f5f9 !important;
  }

  html body.bu-nalog-page {
    background: #f8fafc !important;
    overflow-y: auto !important;
    height: auto !important;
    color: #0f172a !important;
  }

  html body.bu-nalog-page .bu-dash-main {
    padding: 12px 12px 110px !important;
    color: #0f172a !important;
  }

  html body.bu-nalog-page .bu-account-panel,
  html body.bu-nalog-page [data-prof-panel],
  html body.bu-nalog-page .bu-form-settings {
    background: #fff !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 16px !important;
    padding: 16px !important;
    margin-bottom: 12px !important;
    color: #0f172a !important;
  }

  html body.bu-nalog-page .bu-dash-main .bu-btn {
    min-height: 44px !important;
  }
}

/* —— DESKTOP BOARD: map | list | chat —— */
@media (min-width: 1024px) {
  html body.bu-board-page:not(.bu-nalog-page) {
    height: 100dvh !important;
    max-height: 100dvh !important;
    overflow: hidden !important;
    background: #f8fafc !important;
  }

  html body.bu-board-page:not(.bu-nalog-page) .bu-board-shell-wrap,
  html body.bu-board-page:not(.bu-nalog-page) .bu-board-main-col {
    display: flex !important;
    flex-direction: column !important;
    height: 100% !important;
    min-height: 0 !important;
    overflow: hidden !important;
  }

  html body.bu-board-page:not(.bu-nalog-page) .bu-board {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) 320px !important;
    grid-template-rows: auto minmax(0, 1fr) !important;
    flex: 1 1 auto !important;
    height: 100% !important;
    min-height: 0 !important;
    overflow: hidden !important;
    align-items: stretch !important;
  }

  html body.bu-board-page:not(.bu-nalog-page) .bu-board-bar,
  html body.bu-board-page:not(.bu-nalog-page) .bu-filter-chrome {
    grid-column: 1 / -1 !important;
    grid-row: 1 !important;
    z-index: 200 !important;
  }

  html body.bu-board-page:not(.bu-nalog-page) .bu-term-grid,
  html body.bu-board-page:not(.bu-nalog-page) .bu-board-body.bu-term-grid {
    grid-column: 1 !important;
    grid-row: 2 !important;
    display: grid !important;
    grid-template-columns: minmax(280px, 2fr) minmax(380px, 3fr) !important;
    grid-template-rows: minmax(0, 1fr) !important;
    height: 100% !important;
    min-height: 0 !important;
    overflow: hidden !important;
    gap: 12px !important;
  }

  html body.bu-board-page:not(.bu-nalog-page) #bu-map-pane {
    grid-column: 1 !important;
    display: flex !important;
    height: 100% !important;
    min-height: 0 !important;
    z-index: 0 !important;
  }

  html body.bu-board-page:not(.bu-nalog-page) #bu-list-pane {
    grid-column: 2 !important;
    display: flex !important;
    flex-direction: column !important;
    height: 100% !important;
    min-height: 0 !important;
    overflow: hidden !important;
    background: #f8fafc !important;
  }

  html body.bu-board-page:not(.bu-nalog-page) .bu-board-list-scroll,
  html body.bu-board-page:not(.bu-nalog-page) #bu-feed {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow: auto !important;
  }

  html body.bu-board-page:not(.bu-nalog-page) .bu-board > #bu-dispo,
  html body.bu-board-page:not(.bu-nalog-page) .bu-board > #bu-dispo.hidden-m {
    grid-column: 2 !important;
    grid-row: 2 !important;
    position: relative !important;
    inset: auto !important;
    top: auto !important;
    left: auto !important;
    right: auto !important;
    bottom: auto !important;
    width: 320px !important;
    max-width: 320px !important;
    height: 100% !important;
    max-height: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    transform: none !important;
    z-index: 2 !important;
    background: #fff !important;
    border-left: 1px solid #e2e8f0 !important;
    visibility: visible !important;
    pointer-events: auto !important;
  }

  html body.bu-board-page:not(.bu-nalog-page) #bu-dispo .bu-dispo-log {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow-y: auto !important;
  }

  html body.bu-board-page:not(.bu-nalog-page) #bu-dispo .bu-dispo-form {
    flex: 0 0 auto !important;
  }

  html body.bu-board-page #bu-dispo-fab {
    display: none !important;
  }

  html body.bu-board-page #bu-feed .bu-item.compact {
    display: block !important;
    grid-template-columns: none !important;
    width: 100% !important;
    margin: 0 0 6px !important;
    padding: 0 !important;
    background: transparent !important;
    border: 0 !important;
  }

  html body.bu-board-page #bu-feed .bu-mload {
    display: none !important;
  }

  html body.bu-board-page #bu-feed .bu-desk-row,
  html body.bu-board-page #bu-feed .bu-cols-head {
    display: grid !important;
    grid-template-columns: 36px minmax(160px, 1.3fr) minmax(110px, .7fr) minmax(160px, 1.3fr) minmax(110px, .7fr) minmax(110px, 1fr) minmax(64px, .4fr) minmax(64px, .4fr) minmax(88px, .5fr) !important;
    width: 100% !important;
    min-width: 920px !important;
    align-items: center !important;
    gap: 8px !important;
  }

  html body.bu-board-page #bu-feed .bu-desk-row {
    padding: 8px 10px !important;
    background: #fff !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 10px !important;
  }

  html body.bu-board-page #bu-feed .bu-desk-row > .bu-c {
    display: flex !important;
    min-width: 0 !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    color: #0f172a !important;
    font-size: 13px !important;
  }

  /* Filters: 3 equal columns */
  html body.bu-board-page #bu-filter-fold.open {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr) !important;
    grid-template-areas: "head head head" "load unload specs" "foot foot foot" !important;
    gap: 16px !important;
    padding: 18px 20px !important;
    max-width: min(1080px, calc(100vw - 48px)) !important;
    left: 50% !important;
    right: auto !important;
    transform: translateX(-50%) !important;
    width: min(1080px, calc(100vw - 48px)) !important;
  }

  html body.bu-board-page #bu-filter-fold.open .bu-filter-sheet-head {
    grid-area: head !important;
  }

  html body.bu-board-page #bu-filter-fold.open .bu-lanes {
    display: contents !important;
  }

  html body.bu-board-page #bu-filter-fold.open .bu-lane-load {
    grid-area: load !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
    padding: 14px !important;
    background: #f8fafc !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 14px !important;
  }

  html body.bu-board-page #bu-filter-fold.open .bu-lane-unload {
    grid-area: unload !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
    padding: 14px !important;
    background: #f8fafc !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 14px !important;
  }

  html body.bu-board-page #bu-filter-fold.open .bu-metrics-row {
    grid-area: specs !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
    padding: 14px !important;
    background: #f8fafc !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 14px !important;
    margin: 0 !important;
  }

  html body.bu-board-page #bu-filter-fold.open .bu-search-row {
    grid-area: foot !important;
    display: flex !important;
    justify-content: flex-end !important;
    gap: 10px !important;
    margin: 0 !important;
  }

  /* Detail modal: one shell, inner scroll */
  html body .bu-detail-stage {
    display: block !important;
    width: min(72rem, calc(100vw - 48px)) !important;
    max-height: 85vh !important;
  }

  html body .bu-detail-modal-sheet {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    max-height: 85vh !important;
    overflow: hidden !important;
    background: #fff !important;
    border-radius: 24px !important;
  }

  html body .bu-detail-modal-head {
    flex: 0 0 auto !important;
  }

  html body .bu-detail-modal-body {
    display: grid !important;
    grid-template-columns: minmax(0, 8fr) minmax(260px, 4fr) !important;
    gap: 16px !important;
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    padding: 16px 20px 20px !important;
  }

  html body .bu-detail-fuel-aside {
    position: sticky !important;
    top: 0 !important;
    align-self: start !important;
    height: auto !important;
    background: #f8fafc !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 16px !important;
    box-shadow: none !important;
  }

  html body .bu-spec-grid {
    display: grid !important;
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    gap: 10px !important;
  }

  html body .bu-spec-tile {
    background: #f8fafc !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 12px !important;
    padding: 10px 12px !important;
  }

  html body .bu-spec-tile small {
    display: block !important;
    font-size: 11px !important;
    font-weight: 600 !important;
    color: #64748b !important;
    margin-bottom: 4px !important;
  }

  html body .bu-spec-tile b {
    display: block !important;
    font-size: 13px !important;
    font-weight: 700 !important;
    color: #0f172a !important;
  }

  html body #bu-detail-map {
    height: 200px !important;
    border-radius: 14px !important;
  }
}

@media (max-width: 1023px) {
  html body .bu-spec-grid {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
  }

  html body .bu-spec-tile {
    background: #fff !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 12px !important;
    padding: 10px !important;
  }

  html body .bu-spec-tile small {
    display: block;
    font-size: 11px;
    color: #64748b;
    font-weight: 600;
  }

  html body .bu-spec-tile b {
    display: block;
    font-size: 13px;
    color: #0f172a;
    font-weight: 700;
  }
}
