/* =========================================================
   RESPONSIVE.CSS — адаптив для основных модулей выше (max-width: 900px / 768px). Должен подключаться ПОСЛЕ них, иначе переопределения не сработают.
   ========================================================= */

/* =========================================================
   АДАПТИВ
   ========================================================= */
@media (max-width: 900px) {
  :root {
    --mobile-content-bottom-safe: 156px;
  }

  html, body {
    overflow-x: hidden;
  }

  body {
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + var(--mobile-content-bottom-safe));
    box-sizing: border-box;
  }

  .app-container {
    flex-direction: column;
    padding-bottom: 8px;
  }

  .main-content,
  .tab-content,
  .section-title-row,
  .orders-layout,
  .customers-section,
  .items-section,
  .summary-content,
  .summary-section {
    padding-bottom: var(--mobile-content-bottom-safe);
    box-sizing: border-box;
  }

  .table-container,
  .summary-detail-table,
  .product-table,
  .order-table,
  .table-container table {
    width: 100% !important;
    max-width: 100% !important;
    table-layout: auto !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  .summary-detail-table th,
  .summary-detail-table td,
  .product-table th,
  .product-table td,
  .order-table th,
  .order-table td {
    white-space: normal !important;
    overflow-wrap: normal !important;
    word-break: normal !important;
    text-overflow: clip;
    vertical-align: top;
    line-height: 1.42;
  }

  .summary-detail-table th,
  .product-table th,
  .order-table th {
    white-space: normal !important;
    overflow-wrap: normal !important;
    word-break: normal !important;
    height: auto !important;
    min-height: 0 !important;
    padding: 7px 5px !important;
    font-size: 9px !important;
    line-height: 1.2 !important;
    letter-spacing: 0.02em;
    text-align: left;
  }

  .app-container *,
  .main-content *,
  .tab-content *,
  .toolbar *,
  .orders-layout *,
  .customers-section *,
  .items-section *,
  .summary-settings *,
  .summary-filters *,
  .table-container *,
  .modal-content *,
  .modal-body *,
  .summary-card *,
  .product-card *,
  .customer-dir-card * {
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }

  img, svg, canvas, video, iframe {
    max-width: 100%;
    height: auto;
  }

  input, select, textarea, button,
  .menu-btn, .lock-btn, .btn-primary, .btn-secondary,
  .btn-small, .btn-add, .btn-save, .btn-export,
  .toolbar-left > *, .toolbar-right > *,
  .summary-settings > *, .summary-filters > *,
  .order-meta-row > *, .payment-box > *,
  .modal-footer > * {
    max-width: 100%;
    min-width: 0;
  }

  .btn-small,
  .summary-detail-table .btn-small,
  .product-table .btn-small,
  .order-table .btn-small {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: auto !important;
    max-width: none !important;
    min-width: 88px !important;
    height: auto !important;
    min-height: 32px !important;
    padding: 7px 10px !important;
    font-size: 11px !important;
    line-height: 1.1 !important;
    letter-spacing: -0.01em;
    white-space: nowrap !important;
    overflow-wrap: normal !important;
    word-break: normal !important;
    text-align: center;
  }

  .summary-detail-table td:last-child,
  .product-table td:last-child,
  .order-table td:last-child,
  .summary-detail-table th:last-child,
  .product-table th:last-child,
  .order-table th:last-child {
    min-width: 110px;
    width: 110px;
  }

  .table-container {
    overflow: visible !important;
    max-width: 100% !important;
  }

  .table-container table,
  .table-container thead,
  .table-container tbody,
  .table-container tr,
  .table-container th,
  .table-container td {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box;
  }

  .table-container thead {
    display: none !important;
  }

  .table-container tbody {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 10px;
  }

  .table-container tr {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 12px 10px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    box-shadow: none;
  }

  .table-container th,
  .table-container td {
    padding: 0 !important;
    border: none !important;
    background: transparent !important;
    line-height: 1.45;
  }

  .table-container td {
    display: block;
    width: 100%;
    color: var(--text);
  }

  .table-container .btn-small,
  .table-container .btn-edit,
  .table-container .btn-delete,
  .table-container .btn-primary,
  .table-container .btn-secondary,
  .table-container .btn-cancel {
    align-self: flex-start;
  }

  p, span, div, label, td, th, li, strong, small,
  .summary-order-group-label,
  .all-customers-product-name,
  .comment-preview,
  .price-row-label,
  .price-row-hint,
  .supplier-prices-label,
  .setting-label,
  .order-filter-label,
  .customer-item .editable-name,
  .order-item > span:first-child,
  .customer-item > span:first-child {
    overflow-wrap: normal;
    word-break: normal;
    white-space: normal;
  }

  .table-container,
  table,
  thead, tbody, tr, th, td {
    max-width: 100% !important;
    min-width: 0 !important;
    overflow-wrap: normal;
    word-break: normal;
  }

  .sidebar {
    width: 100%;
    height: auto;
    position: relative;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    padding: 10px 12px;
    gap: 6px;
  }
  .logo { width: 100%; }
  .current-user-info { display: none; }
  .sidebar-footer { flex-direction: row; margin-top: 0; border-top: none; gap: 8px; flex-wrap: wrap; }
  .main-content { padding: 18px 16px; }
  .orders-layout { flex-direction: column; }
  .action-cluster-secondary { grid-template-columns: 1fr 1fr; }
  .orders-sidebar { width: 100%; }
  .summary-tables-grid, .summary-analytics { grid-template-columns: 1fr; }
  /* Кнопки "Сохранить сейчас" и "Откат последнего" в сайдбаре на
     мобильном сжимаются в один ряд с мелкими текстовыми ссылками
     (Экспорт/Импорт/Выйти) и теряются — не годится для таких важных
     действий (особенно отмена случайного ввода — явная просьба сделать
     её заметной именно на мобильном адаптиве). Прячем их здесь и
     показываем отдельные плавающие кнопки поверх контента. */
  #forceSaveBtn, #undoBtnDesktop, #refreshBtnDesktop, #lastSavedInfo { display: none; }
  .force-save-fab {
    display: block;
    position: fixed;
    right: 14px;
    bottom: 14px;
    left: auto;
    z-index: 60;
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: #fff;
    border: 1px solid rgba(37, 99, 235, 0.4);
    border-radius: 12px;
    padding: 10px 14px;
    min-height: 40px;
    min-width: 88px;
    font-size: 12.5px;
    font-weight: 700;
    letter-spacing: 0.01em;
    box-shadow: 0 10px 22px rgba(37, 99, 235, 0.22);
  }
  .undo-fab {
    display: block;
    position: fixed;
    right: 14px;
    bottom: 62px;
    left: auto;
    z-index: 60;
    background: rgba(255,255,255,0.92);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    padding: 8px 12px;
    min-height: 34px;
    min-width: 66px;
    font-size: 11.5px;
    font-weight: 600;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
    backdrop-filter: blur(6px);
  }
  .refresh-fab {
    display: block;
    position: fixed;
    right: 14px;
    bottom: 104px;
    left: auto;
    z-index: 60;
    background: rgba(255,255,255,0.92);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    padding: 8px 12px;
    min-height: 34px;
    min-width: 66px;
    font-size: 11.5px;
    font-weight: 600;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
    backdrop-filter: blur(6px);
  }
  .force-save-fab:active,
  .undo-fab:active,
  .refresh-fab:active {
    transform: translateY(1px);
  }
  .sidebar-footer {
    gap: 6px;
  }
  .sidebar-footer .action-cluster {
    width: 100%;
  }
}

@media (max-width: 768px) {
  .toolbar-left { flex-wrap: wrap; }
  #categoryFilter, #sortFilter {
    font-size: 11px;
    padding: 4px 8px;
  }
  .profile-container {
    padding: 14px;
    margin: 0 10px;
  }

  .orders-layout {
    flex-direction: column;
  }

  .orders-sidebar,
  .orders-main {
    width: 100%;
    max-width: 100%;
  }

  .orders-sidebar {
    min-height: 0;
  }

  .orders-sidebar-header {
    padding: 8px 10px;
    font-size: 12px;
    display: block;
  }

  .orders-sidebar-header .btn-new-order {
    display: block;
    width: 100%;
    min-height: 40px;
    padding: 10px 12px;
    font-size: 15px;
    font-weight: 700;
    text-align: center;
  }

  .orders-list {
    max-height: 210px;
  }

  .order-item, .customer-item {
    padding: 8px 10px;
    font-size: 12px;
  }

  .order-item > span:first-child {
    font-size: 12px;
  }

  .order-item > span:nth-child(2) {
    display: none;
  }

  .order-header {
    flex-wrap: wrap;
    align-items: flex-start;
  }

  .order-header > * {
    width: 100%;
  }

  .order-dates-row {
    grid-template-columns: 1fr 1fr;
  }

  .summary-settings,
  .summary-filters {
    flex-direction: column;
    align-items: stretch;
  }

  .summary-order-group-body {
    display: grid;
    grid-template-columns: 1fr;
  }

  .table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

@media (max-width: 560px) {
  .items-section .table-container,
  #orderSubtab-receiving .table-container,
  .table-container {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  #orderSubtab-receiving .order-table,
  #orderSubtab-receiving .order-table thead,
  #orderSubtab-receiving .order-table tbody,
  #orderSubtab-receiving .order-table tr,
  #orderSubtab-receiving .order-table th,
  #orderSubtab-receiving .order-table td {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box;
  }

  #orderSubtab-receiving .order-table thead {
    display: none !important;
  }

  #orderSubtab-receiving .order-table tbody {
    display: flex !important;
    flex-direction: column;
    gap: 8px;
  }

  #orderSubtab-receiving .order-table tr {
    display: flex !important;
    flex-direction: column;
    gap: 6px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 8px 10px;
    box-shadow: var(--shadow-sm);
  }

  #orderSubtab-receiving .order-table tr:has(.receiving-breakdown-cell) {
    display: block !important;
    width: 100% !important;
    flex: 0 0 100% !important;
    margin-top: 8px;
    padding: 8px 10px 10px;
    box-sizing: border-box;
  }

  #orderSubtab-receiving .order-table tr:has(.receiving-breakdown-cell) > td {
    width: 100% !important;
    flex: 1 1 100% !important;
  }

  #orderSubtab-receiving .receiving-breakdown-cell {
    padding: 0 !important;
    box-sizing: border-box;
  }

  #orderSubtab-receiving .order-table td {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    padding: 2px 0;
    border: none;
  }

  #orderSubtab-receiving .order-table td:nth-child(1):not(.receiving-breakdown-cell) {
    display: none !important;
  }

  #orderSubtab-receiving .order-table td:nth-child(2) {
    display: block !important;
    width: 100%;
    color: var(--text);
    font-size: 14px;
    font-weight: 600;
    line-height: 1.4;
  }

  #orderSubtab-receiving .order-table td:nth-child(3) {
    justify-content: flex-start;
    font-size: 11px;
    color: var(--text-muted);
  }

  #orderSubtab-receiving .order-table td:nth-child(4),
  #orderSubtab-receiving .order-table td:nth-child(5),
  #orderSubtab-receiving .order-table td:nth-child(6),
  #orderSubtab-receiving .order-table td:nth-child(7) {
    width: 100%;
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }

  #orderSubtab-receiving .order-table td:nth-child(4) > *,
  #orderSubtab-receiving .order-table td:nth-child(5) > *,
  #orderSubtab-receiving .order-table td:nth-child(6) > *,
  #orderSubtab-receiving .order-table td:nth-child(7) > * {
    flex: 1 1 auto;
    width: 100%;
    max-width: 100%;
  }

  #orderSubtab-receiving .order-table td:nth-child(2) > div,
  #orderSubtab-receiving .order-table td:nth-child(2) > select,
  #orderSubtab-receiving .order-table td:nth-child(2) > button,
  #orderSubtab-receiving .order-table td:nth-child(2) > * {
    width: 100%;
    max-width: 100%;
  }

  #orderSubtab-receiving .order-table .order-input,
  #orderSubtab-receiving .order-table .order-select,
  #orderSubtab-receiving .order-table .weight-input {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    min-height: 34px;
    box-sizing: border-box;
    font-size: 12px;
  }

  #orderSubtab-receiving .order-table .btn-small {
    width: 100%;
    min-height: 32px;
    padding: 6px 8px;
    font-size: 11px;
  }

  #orderSubtab-receiving .order-table td.receiving-breakdown-cell {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    height: auto !important;
    min-height: 18px;
    margin-top: 0;
    padding: 0 !important;
    background: transparent;
    border: none;
    overflow: visible !important;
    position: relative;
    z-index: 1;
  }

  #orderSubtab-receiving .receiving-breakdown-cell {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    height: auto !important;
    min-height: 18px;
    margin-top: 0;
    padding: 0 !important;
    background: transparent;
    border: none;
    overflow: visible !important;
    position: relative;
    z-index: 1;
  }

  #orderSubtab-receiving .receiving-breakdown-row {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) minmax(84px, 100px);
    align-items: center;
    gap: 6px 8px;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    min-height: 28px;
    height: auto !important;
    padding: 8px 0 6px;
    border-bottom: 1px dashed var(--border);
    box-sizing: border-box;
  }

  #orderSubtab-receiving .receiving-breakdown-name,
  #orderSubtab-receiving .receiving-breakdown-sum,
  #orderSubtab-receiving .receiving-breakdown-weight,
  #orderSubtab-receiving .receiving-breakdown-status {
    display: block;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }

  #orderSubtab-receiving .receiving-breakdown-name {
    grid-column: 1;
    grid-row: 1;
    min-width: 0;
    font-size: 12px;
    line-height: 1.25;
    font-weight: 500;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
  }

  #orderSubtab-receiving .receiving-breakdown-sum {
    grid-column: 1;
    grid-row: 2;
    justify-self: start;
    width: auto;
    font-size: 11px;
    line-height: 1.3;
    color: var(--text-muted);
  }

  #orderSubtab-receiving .receiving-breakdown-weight {
    grid-column: 2;
    grid-row: 1;
    width: 100% !important;
    max-width: 100% !important;
    min-height: 28px !important;
    height: 28px !important;
    padding: 4px 6px !important;
    font-size: 11px !important;
    justify-self: stretch;
  }

  #orderSubtab-receiving .receiving-breakdown-status {
    grid-column: 2;
    grid-row: 2;
    justify-self: stretch;
    width: 100%;
    min-width: 0;
    min-height: 28px;
    font-size: 11px;
    line-height: 1.3;
  }

  #orderSubtab-receiving .receiving-breakdown-cell > * {
    display: block;
    width: 100%;
    max-width: 100%;
  }

  #orderSubtab-receiving .comment-cell {
    display: flex !important;
    align-items: center;
    gap: 6px;
    width: 100%;
    max-width: 100%;
  }

  #orderSubtab-receiving .comment-preview {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .add-item-bar {
    padding: 8px;
  }

  .add-item-bar .btn-add-centered,
  .btn-add-centered {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box;
  }
  html, body {
    overflow-x: hidden;
    -webkit-tap-highlight-color: transparent;
  }

  .main-content {
    padding: 12px 10px 20px;
    max-width: 100%;
  }

  .toolbar,
  .section-title-row,
  .order-header,
  .orders-layout {
    gap: 10px;
  }

  .orders-layout {
    gap: 12px;
  }

  .orders-main,
  .orders-sidebar,
  .customers-section,
  .items-section,
  .table-container,
  .section-title-row,
  .order-extra-costs,
  .order-header,
  .toolbar,
  .toolbar-left,
  .toolbar-right,
  .summary-settings,
  .summary-filters {
    max-width: 100%;
    overflow: hidden;
  }

  .section-title-row {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .section-title-row > * {
    width: 100%;
  }

  .toolbar,
  .toolbar-left,
  .toolbar-right {
    display: flex;
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar-left > *,
  .toolbar-right > * {
    width: 100%;
  }

  .customer-add-btn,
  .btn-add-centered,
  .btn-primary,
  .btn-secondary {
    width: 100%;
    justify-content: center;
  }

  .items-section .order-table .btn-small,
  .items-section .order-table .btn-delete-small {
    width: auto;
    min-width: 0;
    justify-content: center;
    flex: 0 0 auto;
  }

  .orders-main,
  .orders-sidebar {
    width: 100%;
    min-width: 0;
  }

  .order-header {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: stretch;
  }

  .order-header > * {
    width: 100%;
  }

  .mobile-inline-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: fit-content;
    max-width: 140px;
    min-height: 30px;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text);
    font-size: 11px;
    font-weight: 600;
    align-self: flex-start;
  }

  .order-meta-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .order-meta-field {
    width: 100%;
    justify-content: space-between;
    padding: 8px 10px;
  }

  .order-meta-field input[type="text"] {
    width: 100%;
    max-width: 90px;
  }

  .order-meta-field.checkbox-field {
    justify-content: center;
  }

  #orderCloseToggleBtn,
  #deliveryFactBtn,
  #bulkStatusOrderBtn,
  #bulkStatusCustomerBtn {
    display: none !important;
  }

  .order-dates-row {
    display: none;
    grid-template-columns: 1fr;
    gap: 10px;
    margin-top: 6px;
  }

  .order-dates-row.expanded {
    display: grid;
  }

  .order-subtabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .order-subtab-btn {
    width: 100%;
    font-size: 11.5px;
    padding: 8px 6px;
    text-align: center;
  }

  .modal-content {
    width: min(92vw, 420px);
    max-width: 92vw;
    max-height: 82vh;
    border-radius: 16px;
    margin: 16px auto;
  }

  .modal-header {
    padding: 14px 16px;
  }

  .modal-body {
    padding: 14px 16px;
    gap: 12px;
  }

  .modal-body input[type="text"],
  .modal-body input[type="number"],
  .modal-body input[type="password"],
  .modal-body input[type="email"],
  .modal-body select {
    min-height: 42px;
    font-size: 16px;
  }

  .modal-footer {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 12px 14px 14px;
  }

  .modal-footer > * {
    width: 100%;
  }

  .price-row,
  .supplier-price-row {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .price-row-label,
  .price-row-hint,
  .supplier-prices-label {
    width: 100%;
    white-space: normal;
  }

  #deliveryFactBtn,
  #bulkStatusOrderBtn,
  #bulkStatusCustomerBtn {
    display: none;
  }

  .customers-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .items-section .order-table {
    display: block;
    width: 100%;
    border: none;
  }

  .items-section .order-table thead {
    display: none;
  }

  .items-section .order-table tbody {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .items-section .order-table tr {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px 10px 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: none;
  }

  .items-section .order-table td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 2px 0;
    border: none;
    min-width: 0;
  }

  .items-section .order-table td::before {
    content: attr(data-label);
    flex: 0 0 auto;
    min-width: 68px;
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 600;
    line-height: 1.2;
    text-transform: uppercase;
    letter-spacing: 0.04em;
  }

  .items-section .order-table td > * {
    flex: 1 1 auto;
    width: 100%;
  }

  .items-section .order-table td[data-label="Ещё"] > * {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .items-section .order-table .order-select,
  .items-section .order-table .order-input,
  .items-section .order-table .weight-input {
    min-width: 0;
    width: 100%;
    min-height: 32px;
    font-size: 12.5px;
    padding: 6px 8px;
  }

  .items-section .order-table .delivery-status-summary {
    width: 100%;
    justify-content: space-between;
  }

  .items-section .order-table .btn-small,
  .items-section .order-table .btn-delete-small {
    min-height: 28px;
    padding: 5px 8px;
    font-size: 10.5px;
  }

  .items-section .order-table td[data-label="Ещё"] {
    align-items: flex-start;
  }

  .items-section .order-table td[data-label="Ещё"] > div {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: flex-start;
  }

  .delivery-status-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    width: 100%;
  }

  .delivery-status-pill {
    display: inline-flex;
    align-items: center;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .delivery-status-panel {
    width: 100%;
  }

  .delivery-status-panel .order-select {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    font-size: 11px;
    padding: 5px 7px;
  }

  .payment-box {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: stretch;
  }

  .payment-box > * {
    width: 100%;
  }

  .customers-list .customer-item {
    width: 100%;
    justify-content: space-between;
    border-radius: 10px;
    padding: 10px 12px;
    flex-wrap: wrap;
  }

  .customer-item .editable-name {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .items-section .order-table,
  .items-section .order-table thead,
  .items-section .order-table tbody,
  .items-section .order-table tr,
  .items-section .order-table th,
  .items-section .order-table td {
    display: block;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box;
  }

  .items-section .order-table thead {
    display: none;
  }

  .items-section .order-table tbody {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100% !important;
    max-width: 100% !important;
  }

  .items-section .order-table tr {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    padding: 10px;
    box-shadow: var(--shadow-sm);
    width: 100% !important;
    max-width: 100% !important;
  }

  .items-section .order-table td {
    padding: 6px 0;
    border: none;
    width: 100% !important;
    max-width: 100% !important;
  }

  .items-section .order-table td:before {
    content: attr(data-label);
    display: block;
    font-size: 10.5px;
    color: var(--text-muted);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
  }

  .items-section .order-table td:nth-child(1):before { content: 'Товар'; }
  .items-section .order-table td:nth-child(2):before { content: 'Цена'; }
  .items-section .order-table td:nth-child(3):before { content: 'Вес'; }
  .items-section .order-table td:nth-child(4):before { content: 'Сумма'; }
  .items-section .order-table td:nth-child(5):before { content: 'Доставка'; }
  .items-section .order-table td:nth-child(6):before { content: 'Оплата'; }
  .items-section .order-table td:nth-child(7):before { content: 'Ещё'; }

  .items-section .order-table td:nth-child(2),
  .items-section .order-table td:nth-child(6) {
    display: none;
  }

  .items-section .order-table td:nth-child(1),
  .items-section .order-table td:nth-child(3),
  .items-section .order-table td:nth-child(4),
  .items-section .order-table td:nth-child(5),
  .items-section .order-table td:nth-child(7) {
    width: 100%;
    max-width: 100%;
  }

  .items-section .order-table td[data-label="Товар"] .order-select,
  .items-section .order-table td[data-label="Вес"] .order-input,
  .items-section .order-table td[data-label="Сумма"] .order-input,
  .items-section .order-table td[data-label="Доставка"] .order-select,
  .items-section .order-table td[data-label="Ещё"] > div {
    min-width: 0;
    width: 100%;
    max-width: 100%;
  }

  .items-section .order-table td:first-child,
  .items-section .order-table th:first-child {
    min-width: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  .items-section .order-table td,
  .items-section .order-table th,
  .items-section .order-table tr {
    max-width: 100% !important;
    box-sizing: border-box;
  }

  .items-section .order-table td[data-label="Товар"] .order-select {
    min-width: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    font-size: 12px;
  }

  .items-section .order-table td[data-label="Товар"] > * {
    overflow-wrap: normal;
    word-break: normal;
  }

  .items-section .order-table td[data-label="Ещё"] > div {
    justify-content: flex-start;
    flex-wrap: wrap;
    max-width: 100%;
  }

  .items-section .order-table .delivery-status-summary {
    flex-wrap: wrap;
    gap: 6px;
  }

  .items-section .order-table .delivery-status-pill {
    font-size: 9px;
    padding: 4px 7px;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  #receivingIntro {
    display: none;
  }

  #receivingIntro.expanded {
    display: block;
  }

  .items-section .order-table .order-price-col,
  .items-section .order-table .order-total-col,
  .items-section .order-table .order-paid-col {
    display: none;
  }

  .items-section .order-table td:nth-child(1),
  .items-section .order-table td:nth-child(2),
  .items-section .order-table td:nth-child(3),
  .items-section .order-table td:nth-child(4),
  .items-section .order-table td:nth-child(5),
  .items-section .order-table td:nth-child(6),
  .items-section .order-table td:nth-child(7) {
    min-width: 0;
  }

  .items-section .order-table .weight-input,
  .items-section .order-table .order-input,
  .items-section .order-table .order-select {
    font-size: 12px;
    min-width: 0;
    width: 100%;
  }

  .delivery-status-summary {
    justify-content: flex-start;
  }

  .delivery-status-pill {
    font-size: 10px;
    min-height: 20px;
  }

  .payment-box {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .payment-box label,
  .payment-box > * {
    width: 100%;
  }

  .action-cluster-secondary {
    grid-template-columns: 1fr;
  }

  .summary-grid {
    grid-template-columns: 1fr;
  }

  .summary-tables-grid,
  .summary-analytics {
    grid-template-columns: 1fr;
  }

  .summary-card {
    padding: 12px 14px;
  }

  .summary-value {
    font-size: 18px;
  }

  .sidebar {
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow-sm);
    padding: 10px;
    gap: 8px;
  }

  .menu-btn {
    min-height: 42px;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 12.5px;
  }

  .toolbar {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    padding: 10px;
  }

  .section-title-row {
    padding: 0 2px;
  }

  .table-container,
  .profile-container,
  .customer-dir-card,
  .product-card,
  .order-item,
  .customer-item,
  .summary-card {
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
  }

  .summary-grid,
  .summary-tables-grid,
  .summary-analytics {
    gap: 10px;
  }

  .tab-content {
    padding-bottom: 12px;
  }
}

@media (max-width: 390px) {
  .items-section .order-table tbody {
    gap: 6px;
  }

  .items-section .order-table tr {
    padding: 8px;
    gap: 4px;
  }

  .items-section .order-table td {
    display: grid;
    grid-template-columns: 56px minmax(0, 1fr);
    gap: 6px;
    padding: 3px 0;
    align-items: center;
  }

  .items-section .order-table td::before {
    min-width: 0;
    width: auto;
    font-size: 9.5px;
    margin: 0;
  }

  .items-section .order-table td[data-label="Товар"] {
    grid-column: 1 / -1;
  }

  .items-section .order-table td[data-label="Товар"] > * {
    width: 100%;
    max-width: 100%;
  }

  .items-section .order-table td[data-label="Вес"],
  .items-section .order-table td[data-label="Сумма"],
  .items-section .order-table td[data-label="Доставка"],
  .items-section .order-table td[data-label="Ещё"] {
    display: grid;
    grid-template-columns: 56px minmax(0, 1fr);
    align-items: center;
  }

  .items-section .order-table .btn-small,
  .items-section .order-table .btn-delete-small {
    padding: 4px 6px;
    font-size: 9.5px;
    min-height: 24px;
  }

  .items-section .order-table td[data-label="Ещё"] > div {
    gap: 4px;
    display: flex;
    flex-wrap: wrap;
  }

  .items-section .order-table .delivery-status-summary {
    gap: 4px;
  }

  .items-section .order-table .delivery-status-pill {
    font-size: 8.5px;
    padding: 3px 6px;
  }
}
