/* Applied only when the page script sets html.tablet-fit or html.phone-fit.
   A desk PC never gets those classes, so these rules do not run there. */
@media screen {
  html.tablet-fit,
  html.tablet-fit body {
    max-width: 100%;
    overflow-x: hidden;
  }

  html.tablet-fit [style*="flex-wrap:nowrap"],
  html.tablet-fit [style*="flex-wrap: nowrap"],
  html.tablet-fit .header-content,
  html.tablet-fit .header-brand,
  html.tablet-fit .branch-selector-row,
  html.tablet-fit .search-bar,
  html.tablet-fit .b2b-toolbar,
  html.tablet-fit .nav {
    flex-wrap: wrap !important;
  }

  html.tablet-fit [style*="flex-wrap:nowrap"] > *,
  html.tablet-fit [style*="flex-wrap: nowrap"] > *,
  html.tablet-fit .header-content > *,
  html.tablet-fit .header-brand > * {
    min-width: 0;
    max-width: 100%;
  }

  html.tablet-fit [style*="white-space:nowrap"]:not(td):not(th):not(button),
  html.tablet-fit [style*="white-space: nowrap"]:not(td):not(th):not(button) {
    white-space: normal !important;
  }

  html.tablet-fit [style*="repeat(2"],
  html.tablet-fit [style*="repeat(3"],
  html.tablet-fit [style*="1fr 1fr"],
  html.tablet-fit .two-cols,
  html.tablet-fit .fields,
  html.tablet-fit .cols,
  html.tablet-fit .facts,
  html.tablet-fit .b2b-summary-grid,
  html.tablet-fit .b2b-finance-summary,
  html.tablet-fit .invoice-layout,
  html.tablet-fit .charts,
  html.tablet-fit .kpi-grid,
  html.tablet-fit .form-row.quote-one-line {
    grid-template-columns: 1fr !important;
  }

  html.tablet-fit input,
  html.tablet-fit select,
  html.tablet-fit textarea {
    max-width: 100%;
    box-sizing: border-box;
  }

  html.tablet-fit .notification,
  html.tablet-fit #customerCardModal,
  html.tablet-fit .map-address-overlay-panel,
  html.tablet-fit [role="dialog"] {
    max-width: calc(100vw - 16px);
    box-sizing: border-box;
  }

  html.tablet-fit .tablet-fit-scroll,
  html.tablet-fit .table-wrap,
  html.tablet-fit .b2b-table-wrap,
  html.tablet-fit .table-scroll,
  html.tablet-fit .table-card {
    display: block;
    overflow-x: auto;
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
  }

  html.tablet-fit .nav-reports {
    position: static;
    transform: none;
  }

  html.phone-fit .header-logo-wrap,
  html.phone-fit .header-logo {
    width: 48px;
    height: 48px;
    min-width: 48px;
    min-height: 48px;
    max-width: 48px;
    max-height: 48px;
  }

  html.phone-fit .dashboard-sticky-bar {
    position: static;
  }

  html.phone-fit .search-bar {
    flex-direction: column;
    align-items: stretch;
  }

  html.phone-fit .search-bar input,
  html.phone-fit input:not([type="checkbox"]):not([type="radio"]):not([type="button"]):not([type="submit"]):not([type="hidden"]):not([type="image"]),
  html.phone-fit select,
  html.phone-fit textarea {
    min-width: 0 !important;
    width: 100%;
    max-width: 100%;
    font-size: 16px;
  }

  html.phone-fit button,
  html.phone-fit .btn-user-menu,
  html.phone-fit .user-menu-dropdown a,
  html.phone-fit .tab-link,
  html.phone-fit .tabs a {
    min-height: 44px;
  }

  html.phone-fit .phone-menu-row {
    display: block;
    width: 100%;
    margin-top: 8px;
  }

  html.phone-fit .phone-menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 44px;
    padding: 0 14px;
    border-radius: 8px;
    border: 1px solid #1565c0;
    background: #1565c0;
    color: #fff;
    font-weight: 800;
    font-size: 15px;
  }

  html.phone-fit .dashboard-sticky-bar:not(.phone-menu-open) .header-toolbar-left,
  html.phone-fit .dashboard-sticky-bar:not(.phone-menu-open) .header-toolbar-right,
  html.phone-fit .dashboard-sticky-bar:not(.phone-menu-open) .header-selectors {
    display: none !important;
  }

  html.phone-fit .dashboard-sticky-bar.phone-menu-open .header-toolbar-left,
  html.phone-fit .dashboard-sticky-bar.phone-menu-open .header-toolbar-right,
  html.phone-fit .dashboard-sticky-bar.phone-menu-open .header-selectors {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    width: 100%;
    gap: 8px;
  }

  html.phone-fit .dashboard-sticky-bar.phone-menu-open .header-toolbar-left > .btn,
  html.phone-fit .dashboard-sticky-bar.phone-menu-open .header-toolbar-right > .btn,
  html.phone-fit .dashboard-sticky-bar.phone-menu-open .header-toolbar-right .management-wrap,
  html.phone-fit .dashboard-sticky-bar.phone-menu-open .header-toolbar-right .btn,
  html.phone-fit .dashboard-sticky-bar.phone-menu-open .branch-selector-row {
    width: 100%;
  }

  html.phone-fit .nav {
    flex-wrap: nowrap !important;
    overflow-x: auto;
    align-items: center;
    gap: 12px;
  }

  html.phone-fit .nav a,
  html.phone-fit .nav .btn-save,
  html.phone-fit .nav .btn-del {
    flex: 0 0 auto;
    white-space: nowrap;
    width: auto;
  }

  html.phone-fit .search-bar {
    flex-direction: row;
    flex-wrap: nowrap !important;
    align-items: center;
  }

  html.phone-fit .search-bar input {
    flex: 1 1 auto;
    width: auto;
  }

  html.phone-fit .search-bar button,
  html.phone-fit .search-bar .btn-neos {
    width: auto;
    flex: 0 0 auto;
  }

  html.phone-fit .b2b-card-actions,
  html.phone-fit .b2b-toolbar,
  html.phone-fit .b2b-card-actions-finance {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-start;
  }

  html.phone-fit .b2b-card-action {
    width: auto;
    flex: 0 0 auto;
  }

  html.phone-fit .notification {
    top: max(12px, env(safe-area-inset-top));
    right: 12px;
    left: 12px;
    max-width: calc(100vw - 24px);
  }

  html.phone-fit .notification,
  html.phone-fit #customerCardModal,
  html.phone-fit .map-address-overlay-panel {
    max-height: 100dvh;
    overflow: auto;
  }

  html.phone-fit .tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
  }

  html.phone-fit .container {
    padding: 10px;
  }

  html.phone-fit body {
    padding-top: env(safe-area-inset-top);
    padding-right: env(safe-area-inset-right);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    zoom: 1;
  }

  html.phone-fit .nav:has(.nav-reports) {
    position: static;
    flex-wrap: wrap !important;
    overflow-x: visible;
    align-items: stretch;
    gap: 8px;
    padding: 8px 10px;
  }

  html.phone-fit .nav:has(.nav-reports) .brand {
    flex: 1 1 100%;
    font-size: 16px;
  }

  html.phone-fit .nav:has(.nav-reports) .brand span {
    font-size: 13px;
  }

  html.phone-fit .nav:has(.nav-reports) .nav-spacer {
    display: none;
  }

  html.phone-fit .nav-reports {
    position: static;
    left: auto;
    top: auto;
    transform: none;
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
    width: 100%;
  }

  html.phone-fit .nav-reports a.btn-report {
    flex: none;
    width: 100%;
    box-sizing: border-box;
    text-align: center;
    justify-content: center;
    font-size: 14px;
    min-height: 44px;
    padding: 10px 8px;
    white-space: normal;
  }

  html.phone-fit .nav:has(.nav-reports) a.link {
    flex: 1 1 100%;
    font-size: 14px;
    padding: 4px 0;
  }

  html.phone-fit .filters {
    flex-direction: column;
    align-items: stretch;
  }

  html.phone-fit .filters > div,
  html.phone-fit .filters > .btn,
  html.phone-fit .period-pills,
  html.phone-fit .export-group,
  html.phone-fit .custom-range {
    width: 100%;
    margin-left: 0;
  }

  html.phone-fit .period-pills {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  html.phone-fit .period-pills .pill {
    width: 100%;
    box-sizing: border-box;
    text-align: center;
    font-size: 14px;
    padding: 8px 4px;
  }

  html.phone-fit .export-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }

  html.phone-fit .export-group .btn,
  html.phone-fit .filters > .btn,
  html.phone-fit .custom-range .btn {
    width: 100%;
    box-sizing: border-box;
    justify-content: center;
    text-align: center;
    font-size: 14px;
    white-space: normal;
    line-height: 1.2;
  }

  html.phone-fit .export-group .btn:last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }

  html.phone-fit .filters label,
  html.phone-fit .custom-range label {
    font-size: 13px;
  }

  html.phone-fit .filters select,
  html.phone-fit .filters input[type="date"],
  html.phone-fit .filters input[type="number"] {
    min-width: 0 !important;
    width: 100%;
  }

  html.phone-fit .kpi-grid {
    grid-template-columns: 1fr 1fr !important;
    gap: 8px;
  }

  html.phone-fit .kpi {
    min-height: 0;
    padding: 10px;
  }

  html.phone-fit .kpi .label {
    font-size: 13px;
  }

  html.phone-fit .kpi .value {
    font-size: 17px;
  }

  html.phone-fit .kpi .sub {
    font-size: 13px;
  }

  html.phone-fit .chart-card h3 {
    font-size: 15px;
  }

  html.phone-fit .chart-insights {
    min-height: 0;
  }

  html.phone-fit .chart-insights .insight-head {
    font-size: 13px;
  }

  html.phone-fit .chart-insights .insight {
    font-size: 14px;
  }

  html.phone-fit .chart-wrap,
  html.phone-fit .chart-card.chart-charges .chart-wrap {
    height: 150px;
  }

  html.phone-fit table.report th,
  html.phone-fit table.report td {
    font-size: 13px;
  }

  html.phone-fit .peg-acc-list {
    grid-template-columns: 1fr 1fr;
  }

  html.phone-fit .peg-acc-item,
  html.phone-fit button.peg-report-card {
    min-height: 44px;
    padding: 8px;
  }

  html.phone-fit .peg-acc-title {
    font-size: 14px;
  }

  html.phone-fit .more-reports-head h2,
  html.phone-fit .peg-group-title,
  html.phone-fit .table-card h2 {
    font-size: 16px;
  }

  /* Manual entry keeps the PC columns, scaled so the whole form fits the tablet. */
  html.tablet-fit:not(.phone-fit) #newConsignmentModalBody,
  html.tablet-fit:not(.phone-fit) .dashboard-manual-inline #newConsignmentModalBody {
    padding: 8px !important;
    overflow-x: hidden !important;
  }

  html.tablet-fit:not(.phone-fit) #manualConsignmentForm .invoice-layout {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 16px !important;
    align-items: start !important;
  }

  html.tablet-fit:not(.phone-fit) #manualConsignmentForm .financial-section.manual-financial-grid {
    display: grid !important;
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  }

  html.tablet-fit:not(.phone-fit) #manualConsignmentForm .manual-submit-actions {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    grid-template-rows: 1fr 1fr !important;
  }

  html.tablet-fit:not(.phone-fit) #manualConsignmentForm .manual-doc-header-fields {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  }

  html.tablet-fit:not(.phone-fit) #manualConsignmentForm {
    width: 1180px;
    max-width: none !important;
    zoom: min(1, calc((100vw - 16px) / 1180));
  }

  /* Phone manual entry: one full-width column, amounts under the parties. */
  html.phone-fit #newConsignmentModalBody,
  html.phone-fit .dashboard-manual-inline #newConsignmentModalBody {
    padding: 8px !important;
    overflow-x: hidden !important;
  }

  html.phone-fit #manualConsignmentForm {
    width: 100% !important;
    max-width: 100% !important;
    zoom: 1 !important;
  }

  html.phone-fit #manualConsignmentForm .invoice-layout,
  html.phone-fit #manualConsignmentForm .manual-doc-header-fields {
    display: grid !important;
    grid-template-columns: 1fr !important;
    width: 100% !important;
    gap: 10px !important;
  }

  html.phone-fit #manualScanBar > div {
    flex-wrap: wrap !important;
  }

  html.phone-fit #manualConsignmentForm .financial-section.manual-financial-grid {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
  }

  html.phone-fit #manualConsignmentForm .manual-fin-cell {
    grid-column: auto !important;
    grid-row: auto !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  html.phone-fit #manualConsignmentForm .manual-fin-cell--left-fill {
    display: none !important;
  }

  html.phone-fit #manualConsignmentForm .manual-fin-cell--amount,
  html.phone-fit #manualConsignmentForm .manual-fin-cell--prev-balance,
  html.phone-fit #manualConsignmentForm .manual-fin-cell--cod-box {
    order: 1;
  }

  html.phone-fit #manualConsignmentForm .manual-fin-cell--col-last {
    order: 2;
  }

  html.phone-fit #manualConsignmentForm .manual-fin-cell--submit-actions {
    order: 3;
  }

  html.phone-fit #manualConsignmentForm .manual-submit-actions {
    display: flex !important;
    flex-direction: column !important;
    height: auto !important;
    min-height: 0 !important;
  }

  html.phone-fit #manualConsignmentForm .manual-fin-amount-caption,
  html.phone-fit #manualConsignmentForm .manual-fin-total-caption {
    white-space: normal !important;
  }

  /* Open card: keep every amount, on tablet and phone, with labels that wrap. */
  html.tablet-fit .cons-pda-financial-scope.financial-section.manual-financial-grid {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    width: 100%;
  }

  html.tablet-fit .cons-pda-financial-scope .manual-fin-cell--amount-split {
    grid-template-columns: minmax(0, 1.45fr) minmax(76px, 0.7fr) !important;
  }

  html.tablet-fit .cons-pda-financial-scope .manual-fin-amount-caption,
  html.tablet-fit .cons-pda-financial-scope .manual-fin-total-caption {
    white-space: normal !important;
    font-size: 13px !important;
    line-height: 1.15;
    overflow: visible;
  }

  /* Phone card: fee rows first, then the totals, each full width. */
  html.phone-fit .cons-pda-financial-scope.financial-section.manual-financial-grid {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
  }

  html.phone-fit .cons-pda-financial-scope .manual-fin-cell {
    width: 100% !important;
    max-width: 100% !important;
  }

  html.phone-fit .cons-pda-financial-scope .manual-fin-cell--amount,
  html.phone-fit .cons-pda-financial-scope .manual-fin-cell--cod-row {
    order: 1;
  }

  html.phone-fit .cons-pda-financial-scope .manual-fin-cell--col-last {
    order: 2;
  }

  html.tablet-fit:not(.phone-fit) .consignment-form-section .invoice-layout {
    gap: 8px;
  }

  html.tablet-fit:not(.phone-fit) .consignment-form-section .blue-box,
  html.tablet-fit:not(.phone-fit) .consignment-form-section .financial-section,
  html.tablet-fit:not(.phone-fit) .consignment-form-section .items-section {
    padding: 8px 10px;
  }

  /* Open card stays the PC split: form on the left, invoice then parcel on the right. */
  html.tablet-fit:not(.phone-fit) .consignment-main-content {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: stretch !important;
    gap: 10px !important;
    width: 100% !important;
    min-width: 0 !important;
  }

  html.tablet-fit:not(.phone-fit) .consignment-main-content > .consignment-form-section {
    flex: 0 0 45% !important;
    width: 45% !important;
    max-width: 45% !important;
    min-width: 0 !important;
  }

  html.tablet-fit:not(.phone-fit) .consignment-main-content > .consignment-pdf-section {
    flex: 1 1 55% !important;
    width: auto !important;
    max-width: none !important;
    min-width: 0 !important;
    align-self: stretch !important;
  }

  html.tablet-fit:not(.phone-fit) .consignment-pdf-original-docs,
  html.tablet-fit:not(.phone-fit) .consignment-pdf-delivery-docs,
  html.tablet-fit:not(.phone-fit) .consignment-pdf-stack {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    min-width: 0 !important;
  }

  /* Phone: opened card is one column. Form, then the document, each full width. */
  html.phone-fit .consignment-main-content {
    flex-direction: column !important;
    flex-wrap: nowrap !important;
    align-items: stretch !important;
    gap: 12px !important;
    width: 100% !important;
  }

  html.phone-fit .consignment-main-content > .consignment-form-section,
  html.phone-fit .consignment-row .consignment-form-section {
    flex: 1 1 auto !important;
    width: 100% !important;
    max-width: 100% !important;
    max-height: none !important;
  }

  html.phone-fit .consignment-main-content > .consignment-pdf-section,
  html.phone-fit .consignment-row .consignment-pdf-section,
  html.phone-fit .consignment-pdf-section {
    flex: 1 1 auto !important;
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    min-height: 70vh !important;
    overflow: auto !important;
  }

  html.phone-fit .consignment-pdf-section iframe {
    width: 100% !important;
    height: 70vh !important;
    min-height: 70vh !important;
  }

  /* Selectors on the left. Main buttons in one line beside Έκδοση από. */
  html.tablet-fit:not(.phone-fit) .header {
    position: relative;
    padding: 4px 10px 6px !important;
  }

  html.tablet-fit:not(.phone-fit) #systemUpdateChip,
  html.tablet-fit:not(.phone-fit) .header-center-stats,
  html.tablet-fit:not(.phone-fit) .header-stats .stat-badge,
  html.tablet-fit:not(.phone-fit) .header-stats .user-menu-wrap {
    display: none !important;
  }

  html.tablet-fit:not(.phone-fit) .header-content {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: flex-end !important;
    gap: 8px !important;
  }

  html.tablet-fit:not(.phone-fit) .header-left,
  html.tablet-fit:not(.phone-fit) .header-right {
    display: contents !important;
  }

  html.tablet-fit:not(.phone-fit) .header-brand {
    order: 1;
    flex: 0 0 auto !important;
    align-self: center !important;
    flex-wrap: nowrap !important;
    width: auto !important;
    min-width: 0 !important;
    gap: 8px !important;
  }

  html.tablet-fit:not(.phone-fit) .header-content::before,
  html.tablet-fit:not(.phone-fit) .header-content::after {
    content: none;
  }

  html.tablet-fit:not(.phone-fit) .header-stats {
    display: none !important;
  }

  html.tablet-fit:not(.phone-fit) .header-logo-wrap,
  html.tablet-fit:not(.phone-fit) .header-logo {
    width: 52px !important;
    height: 52px !important;
    min-width: 52px !important;
    min-height: 52px !important;
    max-width: 52px !important;
    max-height: 52px !important;
  }

  html.tablet-fit:not(.phone-fit) .header-selectors {
    flex: 0 0 auto !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    align-items: stretch !important;
    gap: 4px !important;
  }

  html.tablet-fit:not(.phone-fit) .header-brand .branch-selector-row.header-branch-inline,
  html.tablet-fit:not(.phone-fit) .header-brand .branch-selector-row.header-issue-from-inline {
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    width: auto !important;
    gap: 6px !important;
  }

  html.tablet-fit:not(.phone-fit) .header-brand .branch-selector-row .branch-buttons-label {
    width: auto !important;
    flex: 0 0 auto;
    text-align: left !important;
    white-space: nowrap !important;
    font-size: 12px;
  }

  html.tablet-fit:not(.phone-fit) .header-brand .branch-selector-row .dashboard-branch-select {
    width: 168px !important;
    min-width: 0 !important;
    max-width: 168px !important;
  }

  html.tablet-fit:not(.phone-fit) .header-toolbar-left,
  html.tablet-fit:not(.phone-fit) .header-toolbar-right {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    order: 3;
    flex: 0 0 auto !important;
    align-items: center !important;
    align-self: flex-end !important;
    justify-content: flex-start !important;
    margin-left: 0 !important;
    gap: 6px !important;
  }

  html.tablet-fit:not(.phone-fit) .header-toolbar-left .btn,
  html.tablet-fit:not(.phone-fit) .header-toolbar-right .btn,
  html.tablet-fit:not(.phone-fit) .header-toolbar-right .management-wrap > .btn {
    height: 36px !important;
    width: auto !important;
    padding: 0 12px !important;
    font-size: 13px !important;
    white-space: nowrap !important;
  }

  html.tablet-fit:not(.phone-fit) .header .management-wrap {
    position: relative;
  }

  html.tablet-fit:not(.phone-fit) .header .management-dropdown {
    right: 0 !important;
    left: auto !important;
  }

  html.tablet-fit:not(.phone-fit) .header-toolbar-right .drivers-menu-wrap,
  html.tablet-fit:not(.phone-fit) .header-toolbar-right > .btn-danger {
    display: none !important;
  }
}
