/**
 * Legacy Powerapp styles still used by .legacy-ui forms, .data-table in batch/detail,
 * and a few Tabler-adjacent helpers. Tabler + powerapp-tabler-bridge.css own shell UI.
 */

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  color: #1a1a1a;
}

/* Public pages (/bmi) — pre-Tabler shell; Tabler main.html does not use these. */
.public-shell {
  background: #b4d6fa;
}
.public-shell .topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1.25rem;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}
.public-shell .brand {
  font-weight: 700;
  color: #172b4a;
}
.public-shell .topbar nav a {
  margin-left: 1rem;
  color: #4285f4;
  text-decoration: none;
}
.public-shell .content {
  padding: 1.5rem;
  max-width: 960px;
  margin: 0 auto;
}
.public-shell .content-full {
  max-width: none;
  padding: 0;
  margin: 0;
  width: 100%;
}
.public-shell .card {
  background: #fff;
  border-radius: 8px;
  padding: 1.5rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}
.card.narrow { max-width: 400px; margin: 2rem auto; }
.legacy-ui label { display: block; margin-bottom: 1rem; font-size: 0.9rem; }
.legacy-ui input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="file"]) {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.5rem 0.65rem;
  border: 1px solid #ccc;
  border-radius: 4px;
}
.legacy-ui input[type="date"] {
  max-width: 14rem;
  font: inherit;
}
/* Bare buttons only inside legacy batch/forms — Tabler/Bootstrap .btn elsewhere */
.legacy-ui button:not(.btn):not(.btn-close):not(.navbar-toggler):not(.hq-active-toggle):not(.hq-modal-close):not(.hq-ac-item):not([class*="swal2-"]) {
  background: var(--tblr-primary, #4263eb);
  color: #fff;
  border: none;
  padding: 0.55rem 1.25rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1rem;
}
.msg { padding: 0.65rem 1rem; border-radius: 4px; }
.msg.ok { background: #e6f4ea; color: #137333; }
.msg.err { background: #fce8e6; color: #c5221f; }
.msg.warn { background: #fef7e0; color: #8a5700; margin-bottom: 1rem; }
.msg.info { background: #e8f0fe; color: #174ea6; margin-bottom: 1rem; }

.hq-card { max-width: 1400px; }
.hq-page-head h1 { margin: 0 0 0.25rem; font-size: 1.35rem; color: #172b4a; }
.hq-page-head-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 0.5rem;
}
.hq-page-head-row .hq-muted { margin-bottom: 0; }
.legacy-ui .btn {
  display: inline-block;
  text-decoration: none;
  text-align: center;
  padding: 0.55rem 1.1rem;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.25;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  vertical-align: middle;
  font-family: inherit;
}
.legacy-ui button.btn {
  margin: 0;
}
.legacy-ui a.btn:hover { text-decoration: none; }
.legacy-ui .btn-primary {
  background: #4285f4;
  color: #fff;
  border-color: #4285f4;
}
.legacy-ui a.btn-primary,
.legacy-ui a.btn-primary:visited {
  color: #fff;
}
.legacy-ui .btn-primary:hover {
  background: #3367d6;
  border-color: #3367d6;
}
.legacy-ui button.btn-primary {
  color: #fff;
}
.legacy-ui .btn-secondary {
  background: #fff;
  color: #172b4a;
  border-color: #dadce0;
}
.legacy-ui a.btn-secondary,
.legacy-ui a.btn-secondary:visited {
  color: #172b4a;
}
.legacy-ui .btn-secondary:hover {
  background: #f1f3f4;
  border-color: #bdc1c6;
}
.legacy-ui .btn-danger {
  background: #fff;
  color: #c5221f;
  border-color: #f5c2c0;
}
.legacy-ui button.btn-danger {
  color: #c5221f;
}
.legacy-ui a.btn-danger,
.legacy-ui a.btn-danger:visited {
  color: #c5221f;
}
.legacy-ui .btn-danger:hover {
  background: #fce8e6;
  border-color: #f5c2c0;
}
.legacy-ui .btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.8125rem;
  font-weight: 600;
  border-radius: 4px;
}
/* legacy alias */
.legacy-ui .btn-outline {
  background: #fff;
  color: #172b4a;
  border: 1px solid #dadce0;
}
.legacy-ui .btn-outline:hover {
  background: #f1f3f4;
}
.legacy-ui .btn-warning {
  background: #f9ab00;
  color: #172b4a;
  border-color: #e37400;
}
.legacy-ui a.btn-warning,
.legacy-ui a.btn-warning:visited {
  color: #172b4a;
}
.legacy-ui .btn-warning:hover {
  background: #f29900;
  border-color: #d56e00;
  color: #172b4a;
}
.data-table th.col-row-num,
.data-table td.col-row-num {
  width: 2.75rem;
  text-align: right;
  color: #5f6368;
}
.data-table th.col-supplier-items,
.data-table td.hq-supplier-items {
  width: 11rem;
  white-space: nowrap;
}
.hq-supplier-items {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
}
.hq-supplier-items .item-count {
  flex: 0 0 4.5rem;
  text-align: right;
  color: #4285f4;
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
}
.hq-supplier-items .item-count:hover {
  text-decoration: underline;
}
.hq-supplier-items .btn-sm {
  flex: 0 0 auto;
  min-width: 4.75rem;
}
.hq-page-head-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}
.hq-po-doc-actions {
  margin-top: 0.75rem;
  padding: 0.65rem 0.75rem;
  background: #f4f6f9;
  border: 1px solid #dfe1e6;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 42rem;
}
.hq-po-doc-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.65rem;
}
.hq-po-doc-label {
  flex: 0 0 2.25rem;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #172b4a;
  text-transform: uppercase;
}
.hq-po-doc-btns {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  flex: 1 1 12rem;
  min-width: 0;
}
.hq-po-doc-form {
  display: contents;
}
.hq-po-doc-btns .btn-sm {
  white-space: nowrap;
}
.data-table .actions { white-space: nowrap; text-align: right; }
.hq-inline-form {
  display: inline;
  margin: 0;
}
.btn-row-wrap {
  flex-wrap: wrap;
  gap: 0.35rem;
}
.data-table .actions .btn-row {
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.35rem;
}
.data-table .actions .btn-sm {
  min-width: 0;
  padding-left: 0.55rem;
  padding-right: 0.55rem;
}
.hq-form-danger { margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid #e8eaed; }
.hq-muted { margin: 0 0 1rem; color: #5f6368; font-size: 0.9rem; }
.hq-search {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 1rem;
}
.hq-search label {
  margin: 0;
}
.hq-search input[type="search"] {
  flex: 1;
  min-width: 200px;
  max-width: 400px;
  margin: 0;
  display: block;
  height: 2.375rem;
  padding: 0.5rem 0.65rem;
  box-sizing: border-box;
}
.hq-search input[type="date"] {
  margin: 0;
  height: 2.375rem;
  padding: 0 0.65rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  box-sizing: border-box;
  font: inherit;
}
.hq-search .btn { flex: 0 0 auto; }
.hq-search .hq-search-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}
.hq-search .btn-sm {
  height: 2.375rem;
  padding-top: 0;
  padding-bottom: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}
.hq-search select {
  margin: 0;
  padding: 0 0.65rem;
  height: 2.375rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fff;
  font: inherit;
  font-size: 0.9rem;
  box-sizing: border-box;
}
.hq-inline-label {
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  white-space: nowrap;
}
.legacy-ui .btn-link {
  color: #4285f4;
  text-decoration: none;
  font-size: 0.875rem;
  padding: 0;
  background: none;
  border: none;
  cursor: pointer;
  font-weight: inherit;
  line-height: inherit;
}
.legacy-ui a.btn-link:hover,
.legacy-ui button.btn-link:hover {
  text-decoration: underline;
}
/* Bare legacy button reset for link-style controls inside batch UI */
.legacy-ui button.btn-link {
  display: inline;
}
.data-table .invoice-pdf-actions > a,
.data-table .invoice-pdf-actions > form {
  margin-left: 0.65rem;
}
.data-table .invoice-pdf-actions > a:first-child {
  margin-left: 0;
}
.data-table .invoice-pdf-actions > a,
.data-table .invoice-pdf-actions .btn-link {
  color: #4285f4;
  text-decoration: none;
  font-size: 0.875rem;
}
.data-table .invoice-pdf-actions > a:hover,
.data-table .invoice-pdf-actions .btn-link:hover {
  text-decoration: underline;
}
.table-wrap {
  overflow-x: auto;
  border: 1px solid #e8eaed;
  border-radius: 6px;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
.data-table th,
.data-table td {
  padding: 0.5rem 0.65rem;
  border-bottom: 1px solid #e8eaed;
  text-align: left;
  vertical-align: top;
}
.data-table th {
  background: #f8f9fa;
  font-weight: 600;
  white-space: nowrap;
}
.data-table th a { color: #172b4a; text-decoration: none; }
.data-table th a:hover { color: #4285f4; }
.data-table tr:hover td { background: #f8fbff; }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table .col-name { max-width: 220px; }
.data-table .empty { text-align: center; color: #80868b; padding: 2rem; }
.pager {
  display: flex;
  gap: 1rem;
  align-items: center;
  margin-top: 1rem;
  font-size: 0.9rem;
}
.pager a {
  color: #4285f4;
  text-decoration: none;
  padding: 0.35rem 0.65rem;
  border-radius: 4px;
  border: 1px solid #dadce0;
  background: #fff;
  font-size: 0.875rem;
  font-weight: 500;
}
.pager a:hover {
  background: #f1f3f4;
  text-decoration: none;
}

.hq-form-card { max-width: 720px; }
.hq-form label { margin-bottom: 0.75rem; }
.hq-req {
  color: #c5221f;
  font-weight: 600;
}
.hq-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 1rem;
}
.hq-form-grid .hq-fieldset-span {
  grid-column: 1 / -1;
}
@media (max-width: 640px) {
  .hq-form-grid { grid-template-columns: 1fr; }
}
.hq-form select {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.5rem 0.65rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fff;
}
.hq-fieldset {
  border: 1px solid #e8eaed;
  border-radius: 6px;
  padding: 1rem;
  margin: 0 0 1rem;
}
.hq-fieldset legend { font-weight: 600; color: #172b4a; padding: 0 0.25rem; }
.hq-label { font-size: 0.85rem; color: #5f6368; margin-bottom: 0.35rem; }
.hq-ac-list {
  list-style: none;
  margin: 0.25rem 0 0;
  padding: 0;
  border: 1px solid #e8eaed;
  border-radius: 4px;
  max-height: 220px;
  overflow-y: auto;
  background: #fff;
}
.hq-ac-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.5rem 0.65rem;
  border: none;
  border-bottom: 1px solid #f1f3f4;
  background: #fff;
  cursor: pointer;
  font-size: 0.9rem;
  color: #1a1a1a;
}
.hq-ac-item:hover { background: #e8f0fe; }
.hq-ac-item-with-icon {
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 0.5rem;
}
.hq-ac-item-label {
  flex: 1;
  min-width: 0;
  text-align: left;
}
.hq-ac-stock-icon {
  flex-shrink: 0;
  font-weight: 700;
  font-size: 1rem;
  line-height: 1.35;
  width: 1.1rem;
  text-align: center;
}
.hq-ac-stock-ok { color: #137333; }
.hq-ac-stock-none { color: #c5221f; }
.hq-ac-item--no-stock { cursor: not-allowed; }
.hq-ac-item--no-stock:hover { background: #fce8e6; }
.hq-ac-item--listed { cursor: not-allowed; opacity: 0.85; }
.hq-ac-item--listed:hover { background: #fef7e0; }
.hq-ac-stock-listed { color: #b06000; font-weight: 700; }
.hq-stamp-preview {
  margin-top: 0.5rem;
  padding: 0.5rem;
  background: #f8f9fa;
  border: 1px solid #e8eaed;
  border-radius: 4px;
  max-width: 220px;
}
.hq-stamp-preview img {
  display: block;
  max-width: 100%;
  max-height: 140px;
  object-fit: contain;
}
.hq-drug-summary {
  margin-top: 0.75rem;
  padding: 0.75rem;
  background: #f8f9fa;
  border-radius: 4px;
}
.hidden { display: none !important; }
.hq-qty-input-wrap {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.hq-qty-input-wrap input {
  flex: 1 1 6rem;
  min-width: 0;
}
.hq-qty-unit-suffix {
  color: #5f6368;
  font-size: 0.875rem;
  font-weight: 600;
  white-space: nowrap;
}
.hq-drug-summary.hidden { display: none; }
.hq-batch-form .hq-drug-summary.hq-batch-selected {
  margin-top: 0.65rem;
}
.legacy-ui .btn-text {
  background: none;
  border: none;
  color: #4285f4;
  cursor: pointer;
  padding: 0;
  margin-top: 0.35rem;
  font-size: 0.85rem;
}
.hq-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  margin-bottom: 1rem;
  border-bottom: 1px solid #e8eaed;
}
.hq-tab {
  padding: 0.5rem 1rem;
  text-decoration: none;
  color: #5f6368;
  border-radius: 6px 6px 0 0;
  font-size: 0.9rem;
  border-right: 1px solid #dadce0;
}
.hq-tab:last-child {
  border-right: none;
}
.hq-tab:hover { color: #172b4a; background: #f8f9fa; }
.hq-tab.active {
  color: #172b4a;
  font-weight: 600;
  border-bottom: 2px solid #4285f4;
  margin-bottom: -1px;
}
.hq-po-detail-tabs {
  margin-top: 0.5rem;
}
.hq-po-issued-intro {
  margin-top: 0;
  margin-bottom: 0.75rem;
}
.hq-issued-edit-table tbody td {
  vertical-align: middle;
}
.hq-issued-edit-table .hq-issued-field {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.45rem;
  flex-wrap: nowrap;
}
.hq-issued-edit-table .hq-input-sm {
  display: inline-block;
  width: 5.5rem;
  max-width: none;
  margin: 0;
  padding: 0.35rem 0.45rem;
  font-size: 0.875rem;
  text-align: right;
  box-sizing: border-box;
}
.hq-issued-edit-table .hq-issued-qty {
  width: 5.25rem;
}
.hq-issued-edit-table .hq-issued-price {
  width: 5.75rem;
}
.hq-issued-edit-table .hq-issued-unit {
  flex: 0 0 3.5rem;
  font-size: 0.8125rem;
  line-height: 1.2;
  text-align: left;
  white-space: nowrap;
}
.hq-issued-edit-table .hq-issued-col-qty {
  min-width: 10.5rem;
}
.hq-issued-edit-table .hq-issued-col-price {
  min-width: 7rem;
}
.hq-issued-edit-table .hq-issued-col-action {
  vertical-align: middle;
  text-align: right;
}
.hq-issued-edit-table .hq-issued-col-action .btn-sm {
  min-width: 3.75rem;
}
.hq-date-filter { max-width: 220px !important; flex: 0 1 220px !important; }

.legacy-ui .btn-loading {
  opacity: 0.85;
  cursor: wait;
}
.legacy-ui .btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.legacy-ui .btn-primary.hq-save-awaiting-po {
  opacity: 0.72;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}
.page .swal2-container {
  z-index: 20000;
}
.swal2-popup {
  font-family: inherit;
  border-radius: 8px;
}
.swal2-title {
  color: #172b4a;
  font-size: 1.15rem;
}
.swal2-html-container,
.swal2-content {
  color: #5f6368;
  font-size: 0.95rem;
}
.legacy-ui .data-table th,
.legacy-ui .data-table tbody td:not(.empty) {
  text-transform: uppercase;
}
.legacy-ui .hq-form input[type="text"],
.legacy-ui .hq-form input[type="search"],
.legacy-ui .hq-form textarea,
.legacy-ui .hq-batch-picker input[type="search"] {
  text-transform: uppercase;
}
.legacy-ui .hq-form input[type="date"],
.legacy-ui .hq-form input[type="email"] {
  text-transform: none;
}
.hq-form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid #e8eaed;
}
.hq-kpi-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.hq-kpi {
  flex: 1;
  min-width: 140px;
  background: #f8f9fa;
  border-radius: 8px;
  padding: 1rem;
  border: 1px solid #e8eaed;
}
.hq-kpi-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: #172b4a;
}
.hq-kpi-label {
  font-size: 0.85rem;
  color: #5f6368;
  margin-top: 0.25rem;
}
.hq-subhead {
  font-size: 1rem;
  color: #172b4a;
  margin: 1.25rem 0 0.5rem;
}
.hq-home-section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  margin: 1.25rem 0 0.5rem;
}
.hq-home-section-head .hq-subhead {
  margin: 0;
}
.hq-home-section-head .hq-muted {
  margin: 0.25rem 0 0;
  font-size: 0.875rem;
}
.hq-home-section-head:first-of-type {
  margin-top: 0.5rem;
}

