/* Layout only: keep identifiers intact and give detailed values the remaining space. */
.workspace, main, main > *, .panel, .panel-body { min-width: 0; }
main { max-width: none; padding-bottom: 90px; }
.table-scroll, [class$="-table-scroll"], .orders-list-scroll, .flg-table-scroll,
.of-monthly-scroll, .sailing-table-full { max-width: 100%; scrollbar-width: auto; }
.table-navigation-dock {
  position: fixed; bottom: 12px; z-index: 300; display: flex; align-items: center;
  gap: 10px; padding: 8px 12px; border: 1px solid #c7d9d0; border-radius: 9px;
  background: #fffffff5; box-shadow: 0 3px 18px #17212f26; color: #365247;
  font-size: 12px; pointer-events: auto;
}
.table-navigation-dock button { flex: 0 0 36px; min-height: 32px; border: 1px solid #ccd9d3; border-radius: 5px; background: #eef6f1; color: #176b50; }
.table-navigation-dock button:disabled { cursor: default; }
.table-navigation-dock input { min-width: 40px; flex: 1; width: 0; accent-color: #176b50; padding: 0; cursor: ew-resize; }
.table-navigation-hint { white-space: nowrap; }
.of-root .of-ledger-summary.of-ledger-nine-summary {
  grid-template-columns: repeat(auto-fit,minmax(165px,1fr)); gap: 14px 8px; overflow: visible;
}
.of-root .of-ledger-nine-summary .of-ledger-metric:nth-child(n) { min-width: 0; padding: 0 8px; }
.of-root .of-ledger-nine-summary .of-ledger-metric-value { flex-wrap: wrap; }
.of-root .of-ledger-table { min-width: 1500px; }
.of-ledger-table .of-ledger-invoice-cell > .of-ledger-invoice,
.of-ledger-table .of-ledger-invoice-cell > strong,
.of-ledger-table .of-ledger-invoice-cell > small:not(.of-order-entry-stage) {
  white-space: nowrap !important; overflow-wrap: normal !important; max-width: none !important;
}
.factory-table { min-width: 1390px; }
.factory-col-invoice { width: 142px; }
.factory-col-vo { width: 120px; }
.factory-col-container { width: 118px; }
.factory-col-mark { width: 80px; }
.factory-col-quantities { width: 350px; }
.factory-col-goods { width: 136px; }
.factory-col-fees { width: 162px; }
.factory-col-total { width: 150px; }
.factory-col-status { width: 100px; }
.factory-col-action { width: 92px; }
/* Fixed identifier widths reserve room for detailed cost cells. */
.factory-table { table-layout: fixed; }
.factory-table > thead > tr > th:first-child,
.factory-table > tbody > tr:not(.factory-editor-row) > td:first-child {
  position: sticky; left: 0; z-index: 2; background: #fff;
  box-shadow: 1px 0 #e2e7ed;
}
.factory-table > thead > tr > th:first-child { z-index: 4; background: #f7f9fb; }
.factory-table > tbody > tr.selected > td:first-child { background: #edf6f2; }
.factory-filters, .page-head, .panel-head, .toolbar { flex-wrap: wrap; }
.factory-filters { gap: 12px; }
.factory-filters > *, .toolbar > * { max-width: 100%; }
.of-root .of-ledger-filters { flex-wrap: wrap; }
@media (min-width: 761px) and (max-width: 1440px) {
  .sidebar { width: 184px; }
  .workspace { margin-left: 184px; }
  .sidebar .brand { font-size: 21px; padding: 14px 16px 20px; }
  .sidebar .brand span { font-size: 10px; }
  .sidebar .nav-item { padding-left: 10px; padding-right: 8px; gap: 10px; }
  .sidebar .nav-item small { font-size: 10px; }
  main, main.orders-main, main.factory-main, main.ledger-main, main.sailing-main { padding: 20px 18px 90px; }
  .topbar { padding-left: 18px; padding-right: 18px; }
}
@media (max-width: 760px) {
  main { padding-bottom: 90px; }
  .table-navigation-dock { gap: 6px; padding: 7px; }
  .table-navigation-hint { font-size: 11px; }
  .of-root .of-ledger-summary.of-ledger-nine-summary { grid-template-columns: repeat(auto-fit,minmax(140px,1fr)); }
  .factory-filters label { flex-wrap: wrap; gap: 6px; max-width: 100%; }
  .factory-filters label select { max-width: 100%; }
  .page-head > div { min-width: 0; }
}
@media print { .table-navigation-dock { display: none; } }

/* Reserve native scrollbar space before hover or focus changes on Windows/macOS. */
.factory-table-scroll { scrollbar-gutter: stable; }

.of-ledger-table .of-ledger-invoice-cell { position: sticky; left: 0; z-index: 2; background: white; box-shadow: 1px 0 #e2e7ed; }
.of-ledger-table thead .of-ledger-invoice-cell { background: #f6f8fa; z-index: 4; }
dialog:has(.table-navigation-dock) { padding-bottom: 0; }

/* Every finance tab remains reachable with a regular mouse on narrow windows. */
main [role="tablist"], .of-tabs { flex-wrap: wrap; }

/* Content-sized tables: identifiers and amount digits determine their own minima. */
.of-root .of-ledger-table[data-content-fit], .factory-table[data-content-fit] {
  width: var(--content-table-width); min-width: 0 !important; table-layout: fixed;
}
.of-ledger-table[data-content-fit] th, .of-ledger-table[data-content-fit] td {
  padding-left: 6px; padding-right: 6px;
}
.of-ledger-table[data-content-fit] th { white-space: normal; overflow-wrap: anywhere; }
.of-ledger-table[data-content-fit] .of-ledger-group-bar { flex-wrap: wrap; }
.of-ledger-table[data-content-fit="compact"] .finance-money-code { display: block; }
.of-ledger-table[data-content-fit="compact"] .of-ledger-collection strong { white-space: normal; }
.of-ledger-table[data-content-fit="compact"] .of-ledger-collection .finance-money { display: flex; }
.of-ledger-table[data-content-fit] .of-ledger-invoice-cell > .of-ledger-warning { white-space: normal !important; overflow-wrap: anywhere !important; }
.factory-table[data-content-fit] > tbody > tr > td, .factory-table[data-content-fit] > thead th { padding-left: 6px; padding-right: 6px; }
.factory-table[data-content-fit] > thead th { white-space: normal; }
.factory-table[data-content-fit] .factory-quantity-cell, .factory-table[data-content-fit] .factory-price,
.factory-table[data-content-fit] .factory-cost-summary, .factory-table[data-content-fit] .factory-extra-costs { min-width: 0; }
.factory-table[data-content-fit="compact"] .factory-grade-prices { grid-template-columns: minmax(0,1fr); }
.factory-table[data-content-fit] .factory-grade-price-line { grid-template-columns: max-content max-content minmax(max-content,1fr); column-gap: 0; }
.factory-table[data-content-fit] .factory-grade-price-line > :nth-child(n+2) { margin-left: 4px; padding-left: 4px; }
.factory-table[data-content-fit] .factory-invoice { white-space: nowrap; }
.factory-table[data-content-fit] > tbody > tr > td:first-child small { white-space: normal; overflow-wrap: anywhere; }
.factory-table[data-content-fit] .factory-cost-entry { white-space: nowrap; }
.factory-table[data-content-fit] .factory-price > small { white-space: normal; overflow-wrap: anywhere; }
.of-ledger-table[data-content-fit] col:nth-child(1), .factory-table[data-content-fit] col:nth-child(1) { width: var(--fit-col-1) !important; }
.of-ledger-table[data-content-fit] col:nth-child(2), .factory-table[data-content-fit] col:nth-child(2) { width: var(--fit-col-2) !important; }
.of-ledger-table[data-content-fit] col:nth-child(3), .factory-table[data-content-fit] col:nth-child(3) { width: var(--fit-col-3) !important; }
.of-ledger-table[data-content-fit] col:nth-child(4), .factory-table[data-content-fit] col:nth-child(4) { width: var(--fit-col-4) !important; }
.of-ledger-table[data-content-fit] col:nth-child(5), .factory-table[data-content-fit] col:nth-child(5) { width: var(--fit-col-5) !important; }
.of-ledger-table[data-content-fit] col:nth-child(6), .factory-table[data-content-fit] col:nth-child(6) { width: var(--fit-col-6) !important; }
.of-ledger-table[data-content-fit] col:nth-child(7), .factory-table[data-content-fit] col:nth-child(7) { width: var(--fit-col-7) !important; }
.of-ledger-table[data-content-fit] col:nth-child(8), .factory-table[data-content-fit] col:nth-child(8) { width: var(--fit-col-8) !important; }
.of-ledger-table[data-content-fit] col:nth-child(9), .factory-table[data-content-fit] col:nth-child(9) { width: var(--fit-col-9) !important; }
.of-ledger-table[data-content-fit] col:nth-child(10), .factory-table[data-content-fit] col:nth-child(10) { width: var(--fit-col-10) !important; }
.of-ledger-table[data-content-fit] col:nth-child(11), .factory-table[data-content-fit] col:nth-child(11) { width: var(--fit-col-11) !important; }
.of-ledger-table[data-content-fit] col:nth-child(12), .factory-table[data-content-fit] col:nth-child(12) { width: var(--fit-col-12) !important; }
.of-ledger-table[data-content-fit] col:nth-child(13), .factory-table[data-content-fit] col:nth-child(13) { width: var(--fit-col-13) !important; }

.of-root .of-ledger-table[data-content-fit] td { white-space: normal; }
.of-root .of-ledger-table[data-content-fit] .of-ledger-order-date { white-space: nowrap; }
.of-ledger-table[data-content-fit] td small { white-space: normal; overflow-wrap: anywhere; }
.of-ledger-table[data-content-fit] .of-ledger-group-totals { flex-wrap: wrap; min-width: 0; }
.of-ledger-table[data-content-fit] thead th { word-break: keep-all; overflow-wrap: normal; }
.factory-table[data-content-fit] small { white-space: normal; overflow-wrap: anywhere; }
.factory-table[data-content-fit] .factory-cost-summary > strong { white-space: nowrap; }

.of-ledger-table[data-content-fit] th, .of-ledger-table[data-content-fit] td,
.factory-table[data-content-fit] > tbody > tr > td, .factory-table[data-content-fit] > thead th {
  padding-left: var(--fit-cell-padding,6px); padding-right: var(--fit-cell-padding,6px);
}
