/* Shared table theme + mobile stacking for every list page */
.notification-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  flex-wrap: wrap;
  padding: 12px 14px;
  margin: 0 0 14px;
  border-radius: 14px;
  background: rgba(251, 140, 0, 0.12);
  border: 1px solid rgba(251, 140, 0, 0.28);
  color: #c05600;
  font-weight: 700;
}

.notification-bar a {
  font-weight: 800;
  white-space: nowrap;
}

.table-container {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 16px;
}

.table-container > table {
  width: 100%;
  min-width: 0;
  margin-top: 0;
}

.table-container > table thead th {
  background: rgba(255, 255, 255, 0.62) !important;
  font-size: 0.82em;
  letter-spacing: 0;
}

td.is-due {
  color: #c62828;
  font-weight: 800;
}

.view-header > div {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

#customers-table:not(.is-selecting) .col-select {
  display: none;
}

#customers-table.is-selecting .col-select {
  display: table-cell;
}

@media (max-width: 900px) {
  html {
    zoom: 1;
  }
  html,
  body,
  #erp-app-wrapper {
    width: 100% !important;
    min-width: 0 !important;
    min-height: 100dvh !important;
  }
  #sidebar {
    height: 100dvh !important;
    min-height: 100dvh !important;
  }
  #main-content {
    padding: 10px !important;
    overflow-x: hidden;
  }
  .view-container {
    padding: 12px !important;
    overflow: visible !important;
  }
  .view-container > h2 {
    font-size: 1.05em;
  }
  .view-header h2 {
    font-size: 1.05em;
  }
  .view-header > div {
    width: 100%;
  }
  .view-header .btn {
    flex: 1 1 calc(50% - 8px);
  }
  .notification-bar {
    flex-direction: column;
    align-items: flex-start;
  }
  .notification-bar a {
    white-space: normal;
  }
  td:last-child {
    white-space: normal !important;
  }
  .finance-summary-card {
    max-width: 100% !important;
    margin-inline: 0 !important;
  }
  .dashboard-quick-actions {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 8px !important;
  }
  .dashboard-quick-actions .btn-quick {
    flex: none !important;
    width: 100%;
    min-width: 0;
    white-space: normal;
    justify-content: center;
    font-size: 0.82em !important;
    padding: 11px 8px !important;
  }
  .dashboard-kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
  .kpi-card {
    min-height: 108px !important;
    padding: 12px !important;
  }
  .kpi-value {
    font-size: 1.15em !important;
  }
  .finance-summary-card {
    max-width: 100% !important;
    aspect-ratio: auto !important;
    height: auto !important;
  }
  .ai-assistant-card {
    max-height: none;
    min-height: 0;
  }
  .popup-content {
    width: calc(100% - 24px);
    max-width: 480px;
    margin: 12px;
    padding: 18px;
  }
}

@media (max-width: 760px) {
  .table-container {
    overflow: visible;
  }
  .table-container > table thead {
    display: none;
  }
  .table-container > table,
  .table-container > table tbody {
    display: block;
    width: 100%;
  }
  .table-container > table tr {
    display: block;
    width: 100%;
    margin: 0 0 12px;
    padding: 10px 12px;
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.78);
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.05);
    box-sizing: border-box;
  }
  .table-container > table td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    border: none;
    border-bottom: 1px dashed rgba(15, 23, 42, 0.08);
    padding: 8px 0;
    white-space: normal;
    text-align: left;
    box-sizing: border-box;
  }
  .table-container > table td:last-child {
    border-bottom: none;
  }
  .table-container > table td::before {
    content: attr(data-label);
    font-weight: 800;
    font-size: 0.78em;
    color: var(--medium-text);
    flex: 0 0 auto;
    text-align: right;
  }
  .table-container > table td[colspan]::before,
  .table-container > table td:not([data-label])::before {
    display: none;
  }
  .table-container > table td.col-select {
    justify-content: flex-start;
  }
  #customers-table:not(.is-selecting) td.col-select {
    display: none;
  }
  #customers-table.is-selecting td.col-select {
    display: flex;
  }
  .table-container > table td .actions {
    justify-content: flex-end;
    flex-wrap: wrap;
  }
  .form-container {
    max-width: 100%;
  }
  #purchase-form fieldset > div[style*="flex"],
  #order-form fieldset > div[style*="flex"] {
    flex-direction: column;
    align-items: stretch;
  }
  #purchase-form fieldset .form-group,
  #order-form fieldset .form-group {
    width: auto !important;
  }
  .selection-controls {
    flex-wrap: wrap;
  }
  .selection-controls .btn {
    flex: 1 1 calc(50% - 6px);
  }
}

@media (max-width: 420px) {
  .dashboard-kpi-grid {
    gap: 8px;
  }
  .kpi-label {
    font-size: 0.72em;
  }
}
