/* WizPharma Mobile & Desktop POS Styling */

#wpadminbar {
  display: none !important;
}

html {
  margin-top: 0 !important;
}

:root {
  --pos-header-height: 56px;
  --pos-footer-height: 72px;
  --pos-primary: #0284c7;
  --pos-success: #10b981;
  --pos-danger: #ef4444;
  --pos-bg: #f8fafc;
  --pos-card-bg: #ffffff;
  --pos-border: #e2e8f0;

  /* Typography: the platform's own UI font, deliberately, not by omission.
   * A counter is used all day on the same device, so the readable choice is the
   * font that device already optimises and that loads with no network. Bundling a
   * webfont would add a render delay before the first medicine can be searched on
   * a cold, slow till. Change this one value to move the whole app to a brand font. */
  --pos-font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
}

body.pos-viewport {
  background: linear-gradient(135deg, #f8fafc 0%, #eef2f3 100%);
  font-family: var(--pos-font);
  height: 100vh;
  overflow: hidden;
}

/* Sheets are children of body, not of the counter wrapper, so they state the same
 * font instead of inheriting it by luck. */
.modal {
  font-family: var(--pos-font);
}

/* Header Bar
 *
 * Reader-first, like the Lite counter: a light bar on a light page, an eyebrow
 * naming the screen, the shop name as the loudest line, and quiet outlined
 * actions on the right. Nothing here is dark furniture competing with stock.
 */
.pos-top-nav {
  height: var(--pos-header-height);
  background: #ffffff;
  color: #0f172a;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 16px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.07);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.pos-nav-left,
.pos-nav-right {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.pos-nav-left {
  flex: 1 1 auto;
}

.pos-nav-right {
  flex: 0 0 auto;
}

.pos-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  max-width: 100%;
  flex: 0 1 auto;
  color: inherit;
  text-decoration: none;
  /* A label, not a link: no pointer, no hover, nothing to press by accident. */
  cursor: default;
  user-select: none;
}

.pos-brand:hover,
.pos-brand:focus {
  color: inherit;
  text-decoration: none;
}

.pos-brand-mark {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  color: #0284c7;
  background: #e0f2fe;
  border: 1px solid #bae6fd;
}

.pos-brand-text {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-width: 0;
  line-height: 1.15;
}

.pos-eyebrow {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: #94a3b8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pos-brand-name {
  min-width: 0;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #0f172a;
}

/* Quiet actions: an outlined button, not a dark one. */
.pos-top-nav .btn-outline-light {
  color: #475569;
  background: #ffffff;
  border-color: #e2e8f0;
}

.pos-top-nav .btn-outline-light:hover,
.pos-top-nav .btn-outline-light:active {
  color: #0f172a;
  background: #f1f5f9;
  border-color: #cbd5e1;
}

.pos-user-chip {
  max-width: 190px;
  font-size: 0.82rem;
  padding: 4px 12px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  color: #0f172a;
}

.pos-user-chip #current-user-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Connection state. Colour is the quick read, the word appears on wider screens
 * and always appears when something is wrong, so colour is never the only cue. */
.pos-status-dot {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  color: #64748b;
  line-height: 1;
  white-space: nowrap;
}

/* The pill is the connection control now: it opens the note that used to sit on the
 * counter and push the first medicine down the screen. */
button.pos-status-dot {
  cursor: pointer;
  font: inherit;
  -webkit-tap-highlight-color: transparent;
}

button.pos-status-dot:focus-visible {
  outline: 2px solid var(--pos-primary);
  outline-offset: 2px;
}

.conn-sheet-note {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 0.86rem;
  line-height: 1.35;
}

.conn-sheet-note i {
  flex: 0 0 auto;
  font-size: 1.1rem;
  margin-top: 1px;
}

.conn-sheet-meta {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--pos-border);
  font-size: 0.78rem;
  color: #64748b;
}

/* A refused bill is money taken and not filed. It gets the loudest thing in the
 * sheet, because it is the one state a shop cannot discover on its own. */
.conn-sheet-warn {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  font-size: 0.8rem;
  line-height: 1.35;
}

.conn-sheet-warn i {
  flex: 0 0 auto;
  font-size: 1rem;
  margin-top: 1px;
}

.conn-sheet-reason {
  display: inline-block;
  margin-top: 4px;
  color: #b91c1c;
  font-size: 0.76rem;
}

.pos-status-dot .bi-circle-fill {
  font-size: 0.42rem;
}

.pos-status-dot span {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}

/* The word is always shown now, on a phone too. Colour alone is a poor signal in
 * daylight, and this is the only place the till says whether bills have been filed. */
.pos-status-dot .pos-status-text {
  font-size: 0.66rem;
  letter-spacing: 0.03em;
}

@media (max-width: 575.98px) {
  .pos-status-dot .pos-status-text {
    font-size: 0.6rem;
    letter-spacing: 0.02em;
  }
}

.pos-status-dot.bg-success {
  background: #ecfdf5 !important;
  border-color: #a7f3d0 !important;
  color: #047857 !important;
}

.pos-status-dot.bg-warning {
  background: #fffbeb !important;
  border-color: #fde68a !important;
  color: #b45309 !important;
}

.pos-status-dot.bg-danger {
  background: #fef2f2 !important;
  border-color: #fecaca !important;
  color: #b91c1c !important;
}

/* ------------------------------------------------------------- inventory cards
 *
 * The batch list is a table, which is right on a counter monitor and wrong on a
 * phone: eight columns do not fit in 390px, so the expiry date and its status
 * badge were cut off at the right edge and had to be swiped to be read at all.
 *
 * Below 768px each row becomes its own card instead. Same cells, same data, no
 * change to the script: the table is turned into a grid and each cell names
 * itself with a small label.
 */
@media (max-width: 767.98px) {
  #inv-table-card {
    overflow: visible;
  }

  /* The filter chips are a button group, which does not wrap. On a phone the
     fourth chip was cut off by the card edge, so they wrap instead. */
  #main-view-inventory .inv-filter-btn-group {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    width: 100%;
  }

  #main-view-inventory .inv-filter-btn-group .btn {
    flex: 1 1 auto;
    min-height: 36px;
    border-radius: 999px !important;
  }

  /* The KPI tiles were sized for a counter monitor; on a phone the number is
     the point, so it stays loud while the padding and caption shrink. */
  #main-view-inventory [id^="kpi-"] {
    font-size: 1.3rem !important;
  }

  /*
   * The stock value caption holds a long rupee figure. In a 113px tile it ran
   * past the card edge and was cut, so on a phone it wraps instead.
   */
  #main-view-inventory .bg-white .small,
  #main-view-inventory .bg-white .small strong {
    font-size: 0.68rem;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  #inv-table-card .table-responsive {
    overflow: visible;
  }

  #inv-table-card table,
  #inv-table-card tbody,
  #inv-table-card tr,
  #inv-table-card td {
    display: block;
    width: 100%;
  }

  #inv-table-card thead {
    display: none;
  }

  #inv-table-card tbody tr {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 2px 10px;
    padding: 12px 14px;
    border-bottom: 1px solid #eef2f6;
    background: #ffffff;
  }

  #inv-table-card tbody tr:last-child {
    border-bottom: 0;
  }

  #inv-table-card tbody td {
    border: 0 !important;
    padding: 0 !important;
    font-size: 0.86rem;
  }

  #inv-table-card tbody td::before {
    content: attr(data-label);
    display: inline;
    margin-right: 6px;
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #94a3b8;
  }

  /* Medicine name and generic own the whole first line. */
  #inv-table-card tbody td:nth-child(1) {
    grid-column: 1 / -1;
    margin-bottom: 4px;
  }

  #inv-table-card tbody td:nth-child(1)::before {
    content: '';
    display: none;
  }

  #inv-table-card tbody td:nth-child(2),
  #inv-table-card tbody td:nth-child(4),
  #inv-table-card tbody td:nth-child(6) {
    grid-column: 1;
  }

  #inv-table-card tbody td:nth-child(3),
  #inv-table-card tbody td:nth-child(5),
  #inv-table-card tbody td:nth-child(7) {
    grid-column: 2;
    text-align: right;
  }

  /* The two row actions sit together at the bottom of the card. */
  #inv-table-card tbody td:nth-child(8) {
    grid-column: 1 / -1;
    margin-top: 8px;
    text-align: right !important;
  }

  #inv-table-card tbody td:nth-child(8)::before {
    content: '';
    display: none;
  }

  #inv-table-card tbody td:nth-child(8) .btn {
    min-height: 34px;
    min-width: 44px;
  }
}

/*
 * Function keys only help where a keyboard exists. A till PC, a 14 inch laptop or a
 * Chromebook reports a hover and a fine pointer, so it gets the hints and the shortcut
 * row in the account panel. A tablet at the counter reports neither, and the Android
 * app has no function row at all, so both stay hidden there.
 */
.kbd-hint,
.kbd-only {
  display: none;
}

html.has-keyboard .kbd-hint {
  display: inline-block;
}

html.has-keyboard .kbd-only {
  display: flex;
}

/* The Android shell reports itself as in-app on every page, including the desktop
   browser used to check the till, so the opt-out is tied to the missing keyboard and
   not to the shell. */
html.in-app:not(.has-keyboard) .kbd-hint,
html.in-app:not(.has-keyboard) .kbd-only {
  display: none !important;
}

/* The shortcut sheet: the keys on the left, the job on the right. */
.shortcut-grid {
  display: grid;
  gap: 8px;
}

.shortcut-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  font-size: 0.9rem;
  color: #0f172a;
}

.shortcut-keys {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  flex: 0 0 auto;
}

.shortcut-or {
  font-size: 0.75rem;
  color: #94a3b8;
}

.shortcut-job {
  flex: 1 1 auto;
  text-align: right;
}

.shortcut-grid kbd {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-bottom-width: 2px;
  border-radius: 6px;
  padding: 1px 6px;
  font-size: 0.75rem;
  color: #0f172a;
}

/* The tender buttons carry their own key: the checkout sheet is where a keyboard
   user spends the most time, and the three buttons are the first choice on it. */
.tender-btn {
  position: relative;
}

.tender-key {
  position: absolute;
  top: 5px;
  right: 7px;
  padding: 0 4px;
  border-radius: 4px;
  background: rgba(15, 23, 42, 0.07);
  font-size: 0.6rem;
  font-weight: 700;
  color: #0f172a;
  opacity: 0.65;
  pointer-events: none;
}

/* Search trigger: looks like the field it replaces, and opens the sheet. */
.pos-search-trigger {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1 1 auto;
  min-width: 0;
  height: 46px;
  padding: 0 14px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #ffffff;
  color: #94a3b8;
  font-size: 0.95rem;
  text-align: left;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.pos-search-trigger span {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pos-search-trigger .bi-search {
  color: #0284c7;
  flex: 0 0 auto;
}

.pos-search-trigger kbd {
  font-size: 0.66rem;
  padding: 2px 6px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  color: #64748b;
}

.pos-search-trigger:active {
  background: #f8fafc;
}

/* ---------------------------------------------------------------- search sheet
 *
 * The sheet must sit above the counter's own fixed furniture: the phone dock is
 * at 1045 and the cart bottom sheet at 1060, both higher than Bootstrap's default
 * modal z-index, so without these rules the sheet opened underneath them.
 */
/*
 * Nested sheets. Every modal is on the same rung above, so the one later in the
 * document wins and a sheet opened from another sheet can end up behind it.
 * These two always sit on top: cutting a strip from a medicine list, and any
 * confirmation. The order is deliberate, the banner stays above all of them.
 */
.modal {
  z-index: 1080;
}

#modal-loose-qty {
  z-index: 1086;
}

#modal-confirm {
  z-index: 1092;
}

.modal-backdrop {
  z-index: 1075;
}

.modal-backdrop.show {
  opacity: 0.45;
}

.med-search-sheet {
  border-radius: 18px;
  overflow: hidden;
}

.med-search-sheet .modal-header,
.med-search-sheet .modal-footer {
  background: #ffffff;
}

.med-search-sheet .modal-body {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* The sheet has its own count in the footer, so the list header is a second
 * "14 items" in the same screen. Bootstrap's .d-flex utility is !important, so
 * hiding it needs the same weight. */
.med-search-list > .d-flex:first-child {
  display: none !important;
}

/* The field sits in a group that already draws an outline; the browser ring on
 * top of it painted a box inside a box. */
.med-search-sheet .form-control:focus {
  box-shadow: none;
  border-color: #e2e8f0;
}

.med-search-sheet .input-group:focus-within {
  border-radius: 12px;
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

.med-search-caption {
  font-size: 0.76rem;
  line-height: 1.3;
}

/* The running bill, in the sheet's own footer: what a cashier adds stays in
 * sight without closing the list they are reading. */
.med-search-footer {
  gap: 10px;
  border-top: 1px solid rgba(0, 0, 0, 0.06) !important;
}

.med-search-cart {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid #bae6fd;
  background: #e0f2fe;
  color: #0369a1;
  font-size: 0.86rem;
  font-weight: 700;
  line-height: 1;
}

.med-search-cart .bi-bag-check {
  font-size: 0.95rem;
}

.med-search-cart .med-search-cart-total {
  color: #0f172a;
}

.med-search-cart .bi-chevron-right {
  font-size: 0.68rem;
  opacity: 0.55;
}

.med-search-cart:active {
  transform: scale(0.98);
}

/* One line of confirmation, tappable, that goes straight to the bill. */
.med-search-toast {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 14px 4px 14px;
  padding: 8px 12px;
  border: 1px solid #a7f3d0;
  border-radius: 10px;
  background: #ecfdf5;
  color: #047857;
  font-size: 0.82rem;
  font-weight: 600;
}

.med-search-toast[hidden] {
  display: none;
}

.med-search-toast span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.med-search-toast-action {
  margin-left: auto;
  flex: 0 0 auto;
  border: 0;
  background: transparent;
  color: #0284c7;
  font-size: 0.8rem;
  font-weight: 700;
  text-decoration: underline;
  padding: 0;
}

.med-search-list {
  flex: 1 1 auto;
  min-height: 0;
  max-height: min(64vh, 560px);
  overflow-y: auto;
  padding: 10px 14px 12px 14px;
  background: #f8fafc;
}

.med-search-list .med-item-card {
  background: #ffffff;
  cursor: pointer;
}

.med-search-list .med-item-card:active {
  transform: scale(0.99);
}

/* Cutting a strip is offered where the medicine is picked, next to Add. */
.med-item-card .btn-add-loose {
  border-color: #fcd34d;
  background: #fffbeb;
  color: #b45309;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 4px 10px !important;
  white-space: nowrap;
  flex: 0 0 auto;
}

.med-item-card .btn-add-loose:active {
  background: #fef3c7;
}

.med-item-card .btn-add-loose .bi-scissors {
  font-size: 0.78rem;
}

/* Full-screen sheet on a phone: the list is the point, so nothing else is.
 *
 * Bootstrap's modal-fullscreen-sm-down did not take effect here, and a centred
 * dialog left the dock visible underneath the sheet. These rules place it
 * explicitly instead of relying on the utility class.
 */
@media (max-width: 575.98px) {
  #modal-medicine-search .modal-dialog {
    margin: 0 !important;
    width: 100% !important;
    max-width: none !important;
    height: 100% !important;
    min-height: 100% !important;
    /* Percentage heights on a centred flex item were leaving a strip of counter
     * visible under the sheet, so the content is stretched instead. */
    display: flex !important;
    align-items: stretch !important;
  }

  #modal-medicine-search .modal-content {
    /* dvh follows the visual viewport, so the sheet still fills the screen when
     * the keyboard is open and the layout viewport has not moved. */
    flex: 1 1 auto;
    height: 100dvh;
    max-height: 100dvh;
    border: 0;
    border-radius: 0;
  }

  .med-search-sheet .modal-header {
    padding: 10px 10px 8px 10px;
  }

  .med-search-list {
    max-height: none;
    padding: 8px 10px 12px 10px;
  }

  .med-search-sheet .modal-footer {
    padding: 6px 12px;
    padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px));
  }
}

/* Main Split View */
.pos-workspace {
  height: calc(100vh - var(--pos-header-height));
  display: flex;
  overflow: hidden;
}

/* Catalog / Search Pane */
.pos-catalog-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #ffffff;
  border-right: 1px solid var(--pos-border);
  overflow: hidden;
}

.pos-search-header {
  padding: 12px 16px;
  background: #f8fafc;
  border-bottom: 1px solid var(--pos-border);
}

.pos-results-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
}

/* Search Item Card */
.med-item-card {
  background: #ffffff;
  border: 1px solid var(--pos-border);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: all 0.15s ease-in-out;
}

.med-item-card:hover, .med-item-card:focus {
  border-color: var(--pos-primary);
  box-shadow: 0 4px 6px -1px rgba(2, 132, 199, 0.1);
  background-color: #f0f9ff;
}

.med-badge-h1 {
  background-color: #fee2e2;
  color: #991b1b;
  border: 1px solid #fca5a5;
  font-weight: 700;
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 4px;
}

.med-badge-cold {
  background-color: #e0f2fe;
  color: #0369a1;
  border: 1px solid #bae6fd;
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 4px;
}

/* Cart Pane */
.pos-cart-pane {
  width: 440px;
  display: flex;
  flex-direction: column;
  background: #f8fafc;
  overflow: hidden;
}

.cart-items-container {
  /* A flex child with scroll needs this: without it the list refuses to shrink and
   * the bill below it gets pushed out of the sheet. */
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 12px 16px;
}

/* One line for the Schedule H warning: warn, name the requirement, offer the fix. */
#cart-schedule-alert {
  border-radius: 12px;
}

#cart-schedule-alert .cart-schedule-note {
  font-size: 0.74rem;
  line-height: 1.2;
}

#cart-schedule-alert .btn {
  white-space: nowrap;
}

.cart-item-row {
  background: #ffffff;
  border: 1px solid var(--pos-border);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
}

/* Desktop keeps its conventional bill footer: a labelled row per figure, then the
 * total, then a full width action. The compact two-row version is for small
 * screens only, so the desktop counter is not redesigned by a phone decision. */
@media (min-width: 992px) {
  .cart-summary-meta {
    display: block;
    margin-bottom: 10px;
    font-size: 0.82rem;
  }

  .cart-summary-meta > span {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 2px 0;
  }

  .cart-summary-actions {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding-top: 12px;
  }

  .cart-summary-total {
    font-size: 1.75rem;
  }

  .cart-summary-actions .btn {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1.05rem;
    border-radius: 0.5rem;
  }
}

.cart-footer-summary {
  background: #ffffff;
  border-top: 1px solid var(--pos-border);
  padding: 12px 16px;
  box-shadow: 0 -4px 6px -1px rgba(0, 0, 0, 0.05);
}

/*
 * The bill's footer is two short rows instead of three tall ones: tax on one line,
 * then the total and the button together. Stacked, it took a third of a phone
 * sheet and left the item list showing barely one row.
 */
.cart-summary-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin-bottom: 8px;
  font-size: 0.76rem;
  color: #64748b;
}

.cart-summary-meta strong {
  color: #0f172a;
  font-weight: 600;
}

.cart-summary-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid var(--pos-border);
  padding-top: 8px;
}

.cart-summary-label {
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: #94a3b8;
}

.cart-summary-total {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.1;
  color: #0284c7;
}

.cart-summary-actions .btn {
  flex: 0 0 auto;
  padding: 0.6rem 1rem;
  font-size: 0.95rem;
  border-radius: 12px;
}

/* ==========================================================
   Receipt printing: 80mm / 58mm thermal roll support
   ========================================================== */

/* The receipt and the report both print on the roll with no page margins.
   size:auto keeps the page box equal to whatever paper the printer driver
   reports, which is what a thermal driver does for a continuous roll.
   The slip width is set per roll further down (72mm / 48mm printable). */
@page wiz-roll { size: auto; margin: 0; }

/* Receipt Print Preview Modal */
@media print {
  body * {
    visibility: hidden;
  }
  #thermal-print-area, #thermal-print-area * {
    visibility: visible;
  }
  #main-view-reports.printing, #main-view-reports.printing * {
    visibility: visible;
  }

  /* The bill must never be cut by a scroll container, and the modal chrome
     is not part of the printed slip. */
  .modal, .modal-dialog, .modal-content, .modal-body {
    overflow: visible !important;
    max-height: none !important;
  }
  .modal-dialog {
    transform: none !important;
    margin: 0 !important;
    max-width: none !important;
  }
  #modal-receipt-view {
    display: block !important;
    opacity: 1 !important;
  }
  #modal-receipt-view .modal-header,
  #modal-receipt-view .modal-footer,
  .modal-backdrop {
    display: none !important;
  }
  body.printing-report #modal-receipt-view {
    display: none !important;
  }

  #thermal-print-area {
    position: absolute;
    left: 0;
    top: 0;
    page: wiz-roll;
    width: 72mm;
    padding: 0 !important;
  }
  #thermal-print-area.receipt-58 {
    page: wiz-roll;
    width: 48mm;
  }

  #main-view-reports.printing {
    position: absolute;
    left: 0;
    top: 0;
    page: wiz-roll;
    width: 72mm;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    display: block !important;
  }
  body.receipt-58 #main-view-reports.printing {
    width: 48mm;
  }
}

/* The claim note prints on a plain sheet, not on the receipt roll. */
.claim-note {
  display: none;
}

@media print {
  .claim-note.printing {
    display: block !important;
    visibility: visible !important;
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    padding: 12mm;
    background: #ffffff;
    color: #000000;
    font-family: Arial, Helvetica, sans-serif;
  }

  .claim-note.printing * {
    visibility: visible !important;
  }
}

/* Receipt line rows: the medicine name wraps, quantities and amounts keep their columns */
.rcpt-row {
  display: flex;
  gap: 2mm;
  padding: 1px 0;
  border-bottom: 1px solid #dee2e6;
}
.rcpt-row:last-child {
  border-bottom: 0;
}
.rcpt-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow-wrap: anywhere;
}
.rcpt-qty {
  flex: 0 0 7mm;
  text-align: right;
}
.rcpt-amt {
  flex: 0 0 17mm;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.rcpt-meta {
  font-size: 0.68rem;
  color: #6c757d;
}
.rcpt-head {
  display: flex;
  gap: 2mm;
  border-bottom: 1px solid #adb5bd;
  padding-bottom: 1px;
  font-weight: 600;
}
.rcpt-head .rcpt-name {
  flex: 1 1 auto;
}
.rcpt-warn {
  border: 1px solid #212529;
  padding: 2px 3px;
  margin-top: 3px;
  font-size: 0.68rem;
  line-height: 1.3;
}
#thermal-print-area.receipt-58 .rcpt-amt {
  flex-basis: 15mm;
}

/* Comparison Badges & Metrics */
.growth-badge-up {
  background-color: #dcfce7;
  color: #15803d;
  font-weight: 700;
  font-size: 0.75rem;
  padding: 3px 8px;
  border-radius: 9999px;
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.growth-badge-down {
  background-color: #fee2e2;
  color: #b91c1c;
  font-weight: 700;
  font-size: 0.75rem;
  padding: 3px 8px;
  border-radius: 9999px;
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

/* Hourly Mini Bar Chart */
.hourly-bar-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 80px;
  padding: 8px 4px 0 4px;
}

.hourly-bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
}

.hourly-bar-fill {
  width: 100%;
  min-height: 4px;
  background: linear-gradient(180deg, #38bdf8 0%, #0284c7 100%);
  border-radius: 4px 4px 0 0;
  transition: height 0.3s ease;
}

.hourly-bar-label {
  font-size: 0.65rem;
  color: #64748b;
  margin-top: 4px;
  white-space: nowrap;
}

/* Max Container for Wide Dashboards */
.max-w-1400 {
  max-width: 1400px;
  margin-left: auto;
  margin-right: auto;
}

/* Quick Cash Tender Pills */
.btn-quick-cash {
  transition: all 0.15s ease;
}
.btn-quick-cash:hover, .btn-quick-cash:active {
  transform: translateY(-1px);
}

/* ======================================================== */
/* MOBILE & TABLET RESPONSIVE SYSTEM (Phones & iPads)      */
/* ======================================================== */

:root {
  --pos-mob-dock-height: 62px;
}

@media (max-width: 991px) {
  body.pos-viewport {
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
  }

  /* Compact & Clean Top Nav on Mobile */
  :root {
    --pos-header-height: 56px;
  }

  .pos-top-nav {
    height: var(--pos-header-height);
    padding: 0 10px;
  }

  .pos-top-nav #current-user-name {
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-block;
    vertical-align: middle;
  }

  /* The bottom dock is gone: workspaces are reached from Settings now, so the
     screens no longer reserve 62px at the bottom for it. */
  #main-view-inventory,
  #main-view-bills,
  #main-view-reports,
  #main-view-staff {
    height: calc(100dvh - var(--pos-header-height)) !important;
    padding-bottom: 24px;
  }

  /* The counter ends in its own footer line, so no reserved strip below it. */
  .pos-workspace {
    height: calc(100dvh - var(--pos-header-height)) !important;
    padding-bottom: 0;
  }

  /* Catalog Pane on Mobile */
  .pos-catalog-pane {
    border-right: none;
    width: 100%;
  }

  .pos-search-header {
    padding: 10px 12px 6px 12px;
  }

  .pos-search-header .input-group {
    border-radius: 12px;
  }

  /* Horizontal Category Chips Swiper */
  #category-filter-chips {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    ms-overflow-style: none;
    padding-bottom: 2px;
  }

  #category-filter-chips::-webkit-scrollbar {
    display: none;
  }

  #category-filter-chips button {
    flex-shrink: 0;
    white-space: nowrap;
    font-size: 0.78rem;
    font-weight: 600;
    padding: 5px 12px;
    border-radius: 9999px;
    touch-action: manipulation;
  }

  /* Clearance so the floating cart strip never covers the last medicine card. */
  .pos-results-list {
    padding: 10px 12px calc(85px + env(safe-area-inset-bottom, 0px)) 12px;
  }

  /* Touch Cards for Medicines */
  .med-item-card {
    padding: 13px 14px;
    margin-bottom: 10px;
    border-radius: 16px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 2px 5px rgba(15, 23, 42, 0.04);
    touch-action: manipulation;
  }

  .med-item-card:active {
    transform: scale(0.985);
  }

  .med-item-card .btn-add-cart {
    min-height: 38px;
    min-width: 68px;
    padding: 6px 16px !important;
    font-size: 0.88rem !important;
    font-weight: 700;
    flex: 0 0 auto;
  }

  /*
   * Batch and expiry on the left, Add on the right. The left half used to refuse
   * to shrink below the width of the longest batch code, so a long one ran under
   * the Add button and the button covered the expiry date it was next to.
   */
  .med-item-card > .d-flex:last-child {
    gap: 8px;
  }

  .med-item-card > .d-flex:last-child > span {
    flex: 1 1 auto;
    min-width: 0;
  }

  /* Mobile Cart Bottom Sheet Drawer */
  .pos-cart-pane {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100vw !important;
    height: 92dvh !important;
    z-index: 1060 !important;
    border-radius: 24px 24px 0 0 !important;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.3) !important;
    transform: translateY(105%) !important;
    transition: transform 0.3s cubic-bezier(0.2, 0.9, 0.3, 1) !important;
    background: #ffffff !important;
    display: flex !important;
    flex-direction: column !important;
  }

  .pos-cart-pane.mobile-expanded {
    transform: translateY(0) !important;
  }

  /* The bill's own footer was taking a third of the sheet, leaving barely one
   * line visible in the list above it. */
  .cart-footer-summary {
    padding: 10px 14px calc(10px + env(safe-area-inset-bottom, 0px)) !important;
  }

  .cart-footer-summary #btn-open-payment {
    padding-top: 0.6rem !important;
    padding-bottom: 0.6rem !important;
    font-size: 0.95rem !important;
  }

  .cart-summary-total {
    font-size: 1.35rem;
  }

  /* The sheet's own header was also eating the list: one line, smaller title. */
  .pos-cart-pane > div.p-3 {
    padding: 8px 14px !important;
  }

  .pos-cart-pane > div.p-3 .fs-5 {
    font-size: 1rem !important;
  }

  /* Backdrop Overlay for Mobile Sheet */
  .pos-cart-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(2px);
    z-index: 1055;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
  }

  .pos-cart-backdrop.show {
    opacity: 1;
    pointer-events: auto;
  }

  /* Cart Items Touch Buttons */
  .btn-qty-dec, .btn-qty-inc {
    width: 36px !important;
    height: 36px !important;
    font-size: 1.15rem !important;
    font-weight: bold !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 8px !important;
    touch-action: manipulation;
  }

  .btn-toggle-loose {
    padding: 6px 12px !important;
    font-size: 0.78rem !important;
  }

  /* Floating Sticky Mobile Cart Strip: the total sits on the bottom edge now. */
  .pos-mobile-cart-strip {
    position: fixed;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 10px);
    left: 12px;
    right: 12px;
    z-index: 1040;
    pointer-events: auto;
    animation: slideUpFade 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  }

  .mobile-cart-strip-inner {
    background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
    border-radius: 18px;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 10px 25px -5px rgba(2, 132, 199, 0.45);
  }

  .cart-pill-icon {
    position: relative;
    color: #ffffff;
    display: flex;
    align-items: center;
  }

  .cart-pill-icon .badge {
    position: absolute;
    top: -6px;
    right: -10px;
    font-size: 0.68rem;
    padding: 2px 6px;
  }

  /* Mobile Bottom Dock Navigation */
  .pos-mobile-bottom-dock {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--pos-mob-dock-height);
    background: #ffffff;
    border-top: 1px solid rgba(0, 0, 0, 0.07);
    display: flex;
    align-items: center;
    justify-content: space-around;
    z-index: 1045;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    box-shadow: 0 -2px 14px rgba(15, 23, 42, 0.06);
  }

  .mob-dock-btn {
    flex: 1;
    height: 100%;
    background: none;
    border: none;
    color: #94a3b8;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 4px 0;
    transition: color 0.15s ease, transform 0.1s ease;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }

  .mob-dock-btn:active {
    transform: scale(0.92);
  }

  .mob-dock-btn.active {
    color: #0284c7;
    font-weight: 700;
  }

  .mob-dock-icon {
    position: relative;
    font-size: 1.3rem;
    line-height: 1;
  }

  .mob-dock-label {
    font-size: 0.7rem;
    letter-spacing: 0.02em;
  }

  .cart-badge-dot {
    position: absolute;
    top: -2px;
    right: -4px;
    width: 8px;
    height: 8px;
    padding: 0;
  }

  /* Workspaces Touch Layout & Spacing */
  #main-view-inventory,
  #main-view-bills,
  #main-view-reports,
  #main-view-staff {
    padding: 12px 10px calc(24px + env(safe-area-inset-bottom, 0px)) 10px !important;
  }

  /*
   * Inventory filters wrap on a phone. They used to be a sideways scroller with
   * the scrollbar hidden, so "Quarantined" sat off the edge and looked missing.
   * The report period is a dropdown now, so only its old group still scrolls.
   */
  .inv-filter-btn-group {
    display: flex !important;
    flex-wrap: wrap !important;
    overflow-x: visible !important;
    gap: 6px !important;
  }

  .inv-filter-btn-group .inv-filter-btn {
    flex: 1 1 auto !important;
    min-height: 36px;
  }

  .report-period-btn-group {
    display: flex !important;
    overflow-x: auto !important;
    flex-wrap: nowrap !important;
    scrollbar-width: none !important;
    -webkit-overflow-scrolling: touch !important;
    gap: 4px !important;
  }

  .inv-filter-btn-group::-webkit-scrollbar,
  .report-period-btn-group::-webkit-scrollbar {
    display: none !important;
  }

  .inv-filter-btn,
  .report-period-btn,
  .bill-filter-btn {
    flex-shrink: 0 !important;
    white-space: nowrap !important;
    font-size: 0.78rem !important;
    padding: 6px 12px !important;
    border-radius: 9999px !important;
  }

  /* Prevent thin squished hourly bars on small screens */
  #rep-hourly-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  #rep-hourly-bars {
    min-width: 440px;
  }

  /* Tables horizontal scroll optimization on Mobile */
  .table-responsive {
    -webkit-overflow-scrolling: touch;
    border-radius: 14px;
    border: 1px solid var(--pos-border);
  }

  /* Modal full-sheet optimization on Mobile */
  .modal-dialog {
    margin: 8px;
    max-width: calc(100% - 16px);
  }

  .modal-content {
    border-radius: 20px !important;
    max-height: 92dvh;
  }

  .modal-body {
    padding: 14px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Prevent unwanted iOS Safari auto-zoom on input focus */
  input, select, textarea {
    font-size: 16px !important;
  }
}

/* Tablet Optimizations (iPad / Android Tablet: 768px - 1024px) */
@media (min-width: 768px) and (max-width: 1024px) {
  .pos-cart-pane {
    width: 370px;
  }

  .pos-search-header .input-group-lg {
    font-size: 1rem;
  }

  .hourly-bar-wrapper {
    height: 90px;
  }

  .med-item-card {
    padding: 14px 16px;
  }
}

@keyframes slideUpFade {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes scanLaser {
  0% {
    top: 15%;
    opacity: 0.3;
  }
  50% {
    opacity: 1;
  }
  100% {
    top: 85%;
    opacity: 0.3;
  }
}

/* ------------------------------------------------------------------
   Phone touch and readability pass.
   Measured at 320, 360, 390, 397, 414 and 480 px: category chips were
   30 px tall, the dock label 11.2 px, and at 320 px the top bar pushed
   the patient button past the right edge.
   ------------------------------------------------------------------ */

@media (max-width: 991.98px) {
  /* A chip a thumb cannot hit is a mis-tap at counter speed. Scoped to the
     chip row, because .btn-xs also styles the trial pill, which must stay
     compact enough to fit the bar it sits in. */
  #category-filter-chips .btn-xs {
    min-height: 44px;
    padding: 0 0.9rem;
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
  }

  #category-filter-chips {
    gap: 0.5rem;
  }

  /* Top bar controls keep their look, gain a finger-sized hit area. */
  .pos-top-nav .btn-sm,
  .pos-top-nav .rounded-pill,
  .pos-top-nav > div:first-child > a {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }

  /* Readable floor. 11.2 px was the smallest text on the phone. */
  .mob-dock-label {
    font-size: 0.85rem;
  }

  .mob-dock-icon {
    font-size: 1.35rem;
  }

  #cart-item-count {
    font-size: 0.82rem;
  }

  /* Icon-only buttons need width as much as height. */
  #btn-patient-modal,
  #btn-clear-cart,
  #btn-toggle-cart-mobile {
    min-width: 44px;
    min-height: 44px;
    justify-content: center;
  }

  /* Labels that sat at 12 px in the top bar. */
  .pos-top-nav .badge {
    font-size: 0.82rem;
  }

  #btn-sync-offline {
    min-width: 44px;
  }

  /* A two-line button label is hard to scan at a glance. */
  .pos-top-nav .btn,
  .pos-top-nav a {
    white-space: nowrap;
  }
}

/* The trial pill must fit the bar it sits in at every width. It used to grow to
   64 px inside a 56 px bar and spill over the header edges. */
#subscription-status-pill,
#subscription-status-pill * {
  white-space: nowrap;
}

#subscription-status-pill > div {
  min-height: 0;
  padding: 0.2rem 0.55rem;
  font-size: 0.82rem !important;
}

#subscription-status-pill .btn {
  min-height: 44px;
  padding: 0 0.6rem;
  font-size: 0.82rem;
}

/* The bar stays on ONE row on a phone, like the Lite counter. It used to wrap to
   two rows of 44px targets, which cost 116px of screen before any stock was
   visible; the lockup is two small lines instead, and what does not fit is
   dropped by length rather than pushed to a second row. */
@media (max-width: 575.98px) {
  :root {
    --pos-header-height: 56px;
  }

  .pos-top-nav {
    height: var(--pos-header-height);
    min-height: 52px;
    flex-wrap: nowrap;
    gap: 6px;
    padding: 0 10px;
  }

  /* The countdown text is the first thing to go when the row runs out of room.
     The day count stays reachable in the button tooltip and the modal. */
  #subscription-status-pill .trial-days {
    display: none;
  }
}

/* At 320 px the row is down to a few pixels of slack, so the shop name gives way
   before the controls do. */
@media (max-width: 360px) {
  .pos-nav-right {
    gap: 0.35rem !important;
  }

  .pos-brand-name {
    max-width: 72px;
  }

  #subscription-status-pill > div {
    padding: 0.2rem 0.4rem;
  }

  #subscription-status-pill .btn {
    padding: 0 0.45rem;
  }
}

/* ---------------------------------------------------------------- touch input
 *
 * A finger on the counter is a tap, never a selection. Without these rules a slow
 * tap or a slight drag highlights a label, the phone shows a magnifier and copy
 * handles, and the next tap lands on a handle instead of the button underneath.
 * That costs the operator a whole extra tap on every other item.
 *
 * Selection stays available where it is actually useful: typing fields, the
 * receipt preview and report tables, so a bill number or a total can still be
 * copied out when someone asks for it.
 */
body.pos-viewport {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/*
 * Descendants need the rule too. iOS Safari does not reliably inherit
 * -webkit-user-select from the body, so a slow drag on a label still raises the
 * selection handles there even when the body says none.
 */
body.pos-viewport * {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

body.pos-viewport input,
body.pos-viewport textarea,
body.pos-viewport select,
body.pos-viewport option,
body.pos-viewport [contenteditable="true"],
body.pos-viewport .pos-receipt-preview,
body.pos-viewport .pos-receipt-preview *,
body.pos-viewport .selectable,
body.pos-viewport .selectable *,
body.pos-viewport table,
body.pos-viewport table * {
  -webkit-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
}

/* No grey flash on tap, and no 300ms wait for a double tap that never comes. */
body.pos-viewport a,
body.pos-viewport button,
body.pos-viewport .btn,
body.pos-viewport [role="button"],
body.pos-viewport .med-item-card,
body.pos-viewport .pos-cart-item,
body.pos-viewport .pos-nav-item {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* Labels inside a button must never be picked up as text on a long press. */
body.pos-viewport button *,
body.pos-viewport .btn * {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/* ---------------------------------------------------------------- phone density
 *
 * On a phone the frame around the counter took close to half the screen before a
 * single medicine was visible, and it got worse with the keyboard open. These rules
 * only remove chrome and padding; nothing about behaviour changes.
 */
@media (max-width: 575.98px) {
  .pos-top-nav {
    flex-wrap: nowrap;
    gap: 6px;
    padding: 0 10px;
  }

  /* ---- result density -------------------------------------------------
   *
   * A 220px card put two results on the screen at once, so a term with 14
   * matches meant scrolling six times to compare prices. Same information,
   * tighter: the generic name is reference and gets one line, the batch line
   * keeps its own row, and the padding comes down. Four results now fit.
   */
  .pos-results-list > .d-flex:first-child {
    margin-bottom: 8px !important;
  }

  .pos-results-list > .d-flex:first-child .small {
    font-size: 0.72rem !important;
  }

  .pos-results-list > .d-flex:first-child .badge {
    font-size: 0.7rem;
    padding: 3px 8px;
  }

  .med-item-card {
    padding: 10px 12px;
    margin-bottom: 8px;
    border-radius: 14px;
  }

  .med-item-card > .d-flex:first-child > div:first-child {
    flex: 1 1 auto;
    min-width: 0;
    padding-right: 8px;
  }

  .med-item-card > .d-flex:first-child > div:last-child {
    flex: 0 0 auto;
  }

  .med-item-card .fw-bold.text-dark.fs-6 {
    font-size: 0.95rem !important;
    line-height: 1.2;
  }

  .med-item-card .fs-5.fw-bold.text-primary {
    font-size: 1.02rem !important;
  }

  .med-item-card .text-muted.small.mt-1 {
    margin-top: 2px !important;
    font-size: 0.76rem !important;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .med-item-card > .d-flex:last-child {
    margin-top: 6px !important;
    padding-top: 6px !important;
    font-size: 0.76rem !important;
    line-height: 1.3;
  }

  .med-item-card .btn-add-cart {
    min-height: 34px;
    min-width: 60px;
    padding: 4px 12px !important;
    font-size: 0.82rem !important;
  }

  .pos-brand-mark {
    width: 30px;
    height: 30px;
    border-radius: 9px;
    font-size: 14px;
  }

  .pos-eyebrow {
    font-size: 0.54rem;
    letter-spacing: 0.07em;
  }

  /* The shop name takes whatever the controls on the right leave, so a long name
     is trimmed at the real boundary instead of at a guessed 108px. */
  .pos-brand-name {
    max-width: none;
    font-size: 0.82rem;
  }

  .pos-status-dot {
    height: 24px;
    padding: 0 6px;
  }

  .pos-user-chip {
    max-width: 104px;
    padding: 4px 8px;
    font-size: 0.78rem;
  }

  /* Icon-only controls read as circles, so the bar is one shape language. */
  .pos-nav-right .btn {
    min-height: 34px;
    border-radius: 999px;
  }

  .pos-search-header {
    padding-top: 6px;
    padding-bottom: 6px;
  }

  .pos-search-header .form-control {
    min-height: 44px;
    font-size: 0.95rem;
  }

  #category-filter-chips button {
    min-height: 32px;
    padding: 4px 10px !important;
    font-size: 0.74rem !important;
  }
}





/* ---------------------------------------------------------------- loose tablet sheet
 *
 * Cutting a strip is a counted action: the customer asks for six tablets, and six
 * is chosen and priced here before anything reaches the bill.
 */
.loose-qty-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
}

.loose-qty-row .btn {
  width: 64px;
  height: 56px;
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

.loose-qty-mid {
  min-width: 96px;
  text-align: center;
}

.loose-qty-number {
  font-size: 2.2rem;
  font-weight: 700;
  line-height: 1;
  color: #0f172a;
}

.loose-qty-amount {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-top: 16px;
  padding-top: 10px;
  border-top: 1px solid #e2e8f0;
  font-size: 1.05rem;
}

/* ---------------------------------------------------------------- settings sheet */
.settings-section {
  padding: 4px 16px 16px 16px;
}

.settings-head {
  padding: 4px 2px 10px 2px;
}

.settings-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
}

.settings-form .form-control {
  font-size: 0.88rem;
  min-height: 40px;
}

.settings-form .form-control:nth-child(3) {
  grid-column: 1 / -1;
}

.settings-form button {
  grid-column: 1 / -1;
  min-height: 40px;
  font-size: 0.9rem;
}

.settings-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.settings-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #ffffff;
}

.settings-row-main {
  flex: 1 1 auto;
  min-width: 0;
}

.settings-row .btn {
  flex: 0 0 auto;
}

.settings-empty {
  padding: 10px 12px;
  border: 1px dashed #cbd5e1;
  border-radius: 12px;
}

/* Prescriber chips inside the Schedule H dialog. */
.doctor-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.doctor-chip {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  padding: 6px 10px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #f8fafc;
  color: #0f172a;
  line-height: 1.15;
  text-align: left;
}

.doctor-chip-name {
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}

.doctor-chip-reg {
  font-size: 0.68rem;
  color: #64748b;
  white-space: nowrap;
}

.doctor-chip.active {
  border-color: #0284c7;
  background: #e0f2fe;
}

@media (max-width: 575.98px) {
  .settings-form {
    grid-template-columns: 1fr;
  }
}

/* ---------------------------------------------------------------- session panel
 *
 * The bar shows one account icon. The panel it opens answers the four questions a
 * cashier actually asks: who am I signed in as, which shop is this, what is its
 * statutory identity, and is the till connected.
 */
.session-panel {
  width: 290px;
  overflow: hidden;
  font-size: 0.82rem;
}

.session-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}

.session-avatar {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #e0f2fe;
  color: #0284c7;
  font-size: 1rem;
}

.session-id {
  min-width: 0;
}

.session-user {
  font-weight: 700;
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.session-role {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #94a3b8;
}

.session-rows {
  padding: 8px 14px;
}

.session-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 3px 0;
  font-size: 0.78rem;
}

.session-row span {
  color: #64748b;
  flex: 0 0 auto;
}

.session-row strong {
  color: #0f172a;
  font-weight: 600;
  text-align: right;
  min-width: 0;
  /* A drug licence number is long and is the one value here an inspector may ask
   * for, so it wraps rather than turning into "DL-20 KL-REG-20-PENDI...". */
  overflow-wrap: anywhere;
}

.session-actions {
  border-top: 1px solid #e2e8f0;
  padding: 6px 0;
}

.session-actions .dropdown-item {
  font-size: 0.84rem;
  padding: 8px 14px;
}

/* An icon-only chip: the name lives in the panel, not in the bar. */
.pos-user-chip {
  padding: 4px 9px;
  gap: 0;
}

/* ---------------------------------------------------------------- settings sections */
.settings-pane {
  padding: 2px 0 8px 0;
}

.settings-nav {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 16px;
  border: 0;
  border-bottom: 1px solid #eef2f6;
  background: #ffffff;
  text-align: left;
}

.settings-nav:active {
  background: #f8fafc;
}

.settings-nav > .bi:first-child {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #e0f2fe;
  color: #0284c7;
  font-size: 0.95rem;
}

.settings-nav-main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.settings-nav-title {
  font-weight: 700;
  font-size: 0.9rem;
  color: #0f172a;
}

.settings-nav-sub {
  font-size: 0.74rem;
  color: #64748b;
  line-height: 1.25;
}

.settings-nav-go {
  flex: 0 0 auto;
  color: #cbd5e1;
  font-size: 0.8rem;
}

.settings-block {
  padding: 14px 16px;
}

.settings-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #94a3b8;
  margin: 10px 0 4px 0;
}

.settings-label:first-child {
  margin-top: 0;
}

.settings-hint {
  font-size: 0.75rem;
  color: #64748b;
  line-height: 1.3;
}

/* Monthly subscribers */
.subscriber-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #ffffff;
}

.subscriber-main {
  flex: 1 1 auto;
  min-width: 0;
}

.subscriber-name {
  font-weight: 700;
  font-size: 0.86rem;
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.subscriber-meta {
  font-size: 0.76rem;
  color: #64748b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.subscriber-actions {
  flex: 0 0 auto;
  display: flex;
  gap: 4px;
}

.subscriber-actions .btn {
  width: 36px;
  height: 34px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Customer entry, sitting with the money it belongs to. */
.cart-customer {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  padding: 2px 8px;
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  background: #f8fafc;
  color: #0f172a;
  font-size: 0.74rem;
  font-weight: 600;
}

.cart-customer span {
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cart-customer .bi-person-circle {
  color: #0284c7;
}

.cart-customer .bi-chevron-right {
  font-size: 0.6rem;
  color: #94a3b8;
}

@media (min-width: 992px) {
  .cart-summary-meta > .cart-customer {
    margin-top: 6px;
    width: auto;
  }
}

/* ---------------------------------------------------------------- design tokens
 * One spacing and radius scale, applied last so it wins without touching every
 * rule that came before. 4 / 8 / 12 / 16 / 24 for space, 12 / 16 / 999 for corners.
 */
:root {
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-6: 24px;
  --r-sm: 12px; --r-md: 16px; --r-pill: 999px;
}

/* Tap targets: 44px is the guideline, 40px the floor for a dense cashier bar. */
.pos-top-nav .btn,
.mob-dock-btn,
.cart-summary-actions .btn,
.settings-nav {
  min-height: 44px;
}

@media (max-width: 991px) {
  .pos-nav-right .btn { min-height: 40px; min-width: 40px; }
}

/* Card actions follow the same floor. */
.med-item-card .btn-add-cart,
.med-item-card .btn-add-loose { min-height: 40px; }

/* Corners: the odd 10px legacy card rule and 14px phone cards move to the scale. */
.med-item-card { border-radius: var(--r-sm) !important; }
.cart-item-row, .settings-row, .subscriber-row, .doctor-chip { border-radius: var(--r-sm) !important; }
.float-card, .kpi-card { border-radius: var(--r-md) !important; }
.loose-qty-row .btn { border-radius: var(--r-md) !important; }

/* ---------------------------------------------------------------- card action row
 *
 * Add sat outside the card border on a phone. The last row held two flex items:
 * the batch text, which was allowed to shrink, and the Loose/Add pair, which was
 * also allowed to shrink while its buttons refused to. So the pair lost width,
 * the buttons kept theirs, and Add spilled over the border by the card padding.
 *
 * The pair is fixed now and the text gives way. If the text cannot give any more,
 * the pair drops to its own line right aligned instead of leaving the card.
 */
.med-item-card > .d-flex:last-child {
  flex-wrap: wrap;
  row-gap: 6px;
}

.med-item-card > .d-flex:last-child > span {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  column-gap: 6px;
  row-gap: 2px;
}

.med-item-card > .d-flex:last-child > div {
  flex: 0 0 auto;
  margin-left: auto;
}

/* Nothing inside a card may draw outside its own box. */
.med-item-card {
  overflow: hidden;
}

/* ---------------------------------------------------------------- in-app banner
 *
 * Replaces the native alert(). It sits above every sheet (1090 vs the modal 1080)
 * so a failure raised from inside the bill is still readable, and it never blocks
 * the till the way a system dialog did.
 */
.pos-notify-host {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 86px);
  z-index: 1090;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  pointer-events: none;
}

@media (min-width: 992px) {
  .pos-notify-host {
    bottom: 24px;
    align-items: flex-end;
    padding-right: 24px;
  }
}

.pos-notify {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(100%, 420px);
  padding: 10px 10px 10px 12px;
  border-radius: var(--r-sm);
  background: #0f172a;
  color: #ffffff;
  font-size: 0.86rem;
  line-height: 1.3;
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.22);
  animation: posNotifyIn 0.18s ease-out;
}

.pos-notify > i {
  flex: 0 0 auto;
  font-size: 1rem;
}

.pos-notify > span {
  flex: 1 1 auto;
  min-width: 0;
}

.pos-notify-error { background: #991b1b; }
.pos-notify-success { background: #166534; }

.pos-notify-action {
  flex: 0 0 auto;
  padding: 5px 10px;
  border: 0;
  border-radius: var(--r-pill);
  background: rgba(255, 255, 255, 0.92);
  color: #0f172a;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
}

.pos-notify-close {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: var(--r-pill);
  background: rgba(255, 255, 255, 0.16);
  color: inherit;
  font-size: 0.72rem;
}

.pos-notify.is-out {
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.18s ease-in, transform 0.18s ease-in;
}

@keyframes posNotifyIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------------------------------------------------------------- loading rows
 *
 * Three grey rows while a search is in flight. A slow fetch used to look like an
 * empty shop, which is the one thing a cashier must never be told by accident.
 */
.med-skeleton {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.med-skeleton-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 10px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--pos-border);
  border-radius: var(--r-sm);
  background: #ffffff;
}

.sk-line {
  display: block;
  height: 10px;
  border-radius: var(--r-pill);
  background: linear-gradient(90deg, #eef2f7 0%, #dfe6ee 45%, #eef2f7 90%);
  background-size: 220% 100%;
  animation: medSkeleton 1.1s linear infinite;
}

.sk-title { grid-column: 1; width: 62%; height: 12px; }
.sk-price { grid-column: 2; width: 54px; height: 12px; }
.sk-meta  { grid-column: 1 / -1; width: 84%; }

@keyframes medSkeleton {
  from { background-position: 120% 0; }
  to { background-position: -120% 0; }
}

@media (prefers-reduced-motion: reduce) {
  .sk-line { animation: none; }
  .pos-notify { animation: none; }
}

/* Group heading in the settings menu. The menu now carries the workspaces that used
 * to sit in the bottom dock, so the two lists need telling apart. */
.settings-group-label {
  padding: 14px 16px 6px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #94a3b8;
}

.settings-group-label:first-child {
  padding-top: 10px;
}

/* ---------------------------------------------------------------- category browser
 *
 * A page of category cards instead of a horizontal strip of pills: a shop with a
 * thumb on a phone can hit a card far more reliably than a 28px chip, and the
 * categories are visible all at once instead of scrolled off the edge.
 */
#category-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 14px;
}

/* Step one: two wide rows, because there are only two things to choose. */
.category-root {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.category-choice {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--pos-border);
  border-radius: var(--r-md);
  background: #ffffff;
  color: #0f172a;
  text-align: left;
  -webkit-tap-highlight-color: transparent;
}

.category-choice:active {
  border-color: var(--pos-primary);
  transform: scale(0.99);
}

.category-choice-icon {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: #eff6ff;
  color: var(--pos-primary);
  font-size: 1.1rem;
}

.category-choice-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1 1 auto;
}

.category-choice-title {
  font-weight: 700;
  font-size: 0.95rem;
}

.category-choice-sub {
  font-size: 0.76rem;
  line-height: 1.3;
  color: #64748b;
}

.category-choice-go {
  flex: 0 0 auto;
  color: #94a3b8;
}

@media (min-width: 576px) {
  #category-cards {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.category-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  min-height: 96px;
  padding: 14px;
  border: 1px solid var(--pos-border);
  border-radius: var(--r-md);
  background: #ffffff;
  color: #0f172a;
  text-align: left;
  font-weight: 600;
  font-size: 0.9rem;
  line-height: 1.2;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.12s ease, border-color 0.12s ease;
}

.category-card:active {
  transform: scale(0.98);
  border-color: var(--pos-primary);
}

.category-card-icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: #eff6ff;
  color: var(--pos-primary);
  font-size: 1.05rem;
}

.category-card-label {
  min-width: 0;
}

/* ---------------------------------------------------------------- brand browser
 *
 * The same card grid as categories, with a box above it. A shop carries far more
 * companies than it carries dosage forms, so the list is typed into instead of
 * scrolled, and each card says how many medicines sit behind it.
 */
#brand-wrap {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.brand-filter {
  position: relative;
  padding: 14px 14px 0;
}

.brand-filter .bi {
  position: absolute;
  left: 28px;
  top: 26px;
  color: #94a3b8;
  font-size: 0.9rem;
  pointer-events: none;
}

.brand-filter input {
  width: 100%;
  padding: 10px 14px 10px 36px;
  border: 1px solid var(--pos-border);
  border-radius: 999px;
  font-size: 0.86rem;
  color: #0f172a;
  background: #ffffff;
}

.brand-filter input:focus {
  outline: none;
  border-color: var(--pos-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

#brand-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 14px;
}

@media (min-width: 576px) {
  #brand-cards {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.brand-card {
  min-height: 74px;
  justify-content: center;
  gap: 6px;
}

.brand-card-count {
  font-size: 0.72rem;
  font-weight: 600;
  color: #64748b;
}

.brand-loading {
  grid-column: 1 / -1;
  padding: 18px 4px;
  text-align: center;
  font-size: 0.8rem;
  color: #94a3b8;
}

.brand-empty {
  padding: 0 14px 18px;
  text-align: center;
  font-size: 0.8rem;
  color: #94a3b8;
}

/* ---------------------------------------------------------------- footer credit
 *
 * One quiet line at the end of every workspace screen. The old footers ran three
 * lines of positioning copy and a shop location, which is marketing copy inside a
 * till. Year and brand only.
 */
.pos-footer-credit {
  margin: 18px 12px 10px;
  text-align: center;
  font-size: 0.72rem;
  letter-spacing: 0.01em;
  color: #94a3b8;
}

/* On the counter the credit line is pinned under the product list, so it does
   not scroll away with the catalogue and cannot be wiped by a search. */
.pos-catalog-footer {
  flex: 0 0 auto;
  margin: 0;
  padding: 8px 12px;
  border-top: 1px solid var(--pos-border);
  background: #ffffff;
}


/* ---------------------------------------------------------------- account panel
 *
 * Every screen lives behind the account chip: the workspaces first, then Settings.
 * Nothing new in the bar, because what a person may reach depends on who is signed
 * in, and one panel is the one place that question is answered.
 *
 * Rows are 52px tall with a 34px icon tile. The old panel rows were 36px at 13px
 * text, which is a mis-tap at counter speed.
 */
.session-panel {
  width: min(94vw, 330px);
  max-height: calc(100vh - 72px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.workspace-list {
  padding: 4px 0 6px;
  border-top: 1px solid #e2e8f0;
}

.workspace-menu-head {
  padding: 10px 14px 6px;
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: #94a3b8;
}

.workspace-link {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  min-height: 52px;
  padding: 8px 14px;
  border: 0;
  background: #ffffff;
  text-align: left;
}

.workspace-link:hover,
.workspace-link:focus-visible {
  background: #f8fafc;
}

.workspace-link.active {
  background: #eff6ff;
}

.workspace-ico {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #e0f2fe;
  color: #0284c7;
  font-size: 0.95rem;
}

.workspace-link.active .workspace-ico {
  background: #0284c7;
  color: #ffffff;
}

.workspace-txt {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.workspace-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.2;
}

.workspace-link.active .workspace-title {
  color: #0369a1;
}

.workspace-sub {
  font-size: 0.74rem;
  color: #64748b;
  line-height: 1.25;
}

/* Settings and Sign Out sit at the bottom of the same panel. */
.session-actions .dropdown-item {
  min-height: 48px;
  font-size: 0.88rem;
}

/* Phones: the bar stays one row and everything in it is a 44px target. */
@media (max-width: 991.98px) {
  .pos-nav-right .btn,
  .pos-nav-right .rounded-pill,
  .pos-status-dot {
    min-height: 44px;
    min-width: 44px;
  }
}

@media (max-width: 575.98px) {
  /* 34px was a real mis-tap: the bar is the most touched strip on the screen. */
  .pos-nav-right .btn {
    min-height: 44px;
  }

  .pos-status-dot {
    height: 44px;
    padding: 0 10px;
  }

  .session-panel {
    width: min(96vw, 340px);
  }
}

/* ---------------------------------------------------------------- PDT count sheet
 *
 * One row per batch being counted: what it is, what the system says, and the box
 * the counter types the shelf count into. Two lines per row rather than five
 * columns, because on a phone a five-column row leaves the number box too narrow
 * to type into with a gloved thumb.
 */
.pdt-lines {
  max-height: 52vh;
  overflow-y: auto;
}

.pdt-row {
  padding: 10px 14px;
  border-bottom: 1px solid #eef2f6;
}

.pdt-row:last-child {
  border-bottom: 0;
}

.pdt-row-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.pdt-name {
  font-weight: 700;
  font-size: 0.92rem;
  color: #0f172a;
  line-height: 1.2;
}

.pdt-meta {
  font-size: 0.75rem;
  color: #64748b;
}

.pdt-row-tail {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
}

.pdt-system {
  font-size: 0.78rem;
  color: #64748b;
  margin-right: auto;
}

.pdt-count {
  width: 88px;
  min-height: 44px;
  text-align: center;
  font-weight: 700;
  font-size: 1rem;
}

.pdt-diff {
  min-width: 76px;
  text-align: right;
}

/* The chooser shown when a name matches more than one batch. */
.pdt-pick {
  display: flex;
  flex-direction: column;
  width: 100%;
  padding: 10px 12px;
  margin-bottom: 6px;
  min-height: 52px;
  text-align: left;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
}

.pdt-pick:hover,
.pdt-pick:focus-visible {
  background: #eff6ff;
  border-color: #bae6fd;
}

.pdt-pick-main {
  font-weight: 700;
  font-size: 0.9rem;
  color: #0f172a;
}

.pdt-pick-sub {
  font-size: 0.76rem;
  color: #64748b;
}

/* The list of orders a delivery can be matched against, inside PDT. */
.pdt-order {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 64px;
  padding: 10px 14px;
  border: 0;
  border-bottom: 1px solid #eef2f6;
  background: #ffffff;
  text-align: left;
}

.pdt-order:last-child {
  border-bottom: 0;
}

.pdt-order:hover,
.pdt-order:focus-visible {
  background: #f8fafc;
}

.pdt-order-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.pdt-order-title {
  font-weight: 700;
  font-size: 0.92rem;
  color: #0f172a;
}

.pdt-order-sub {
  font-size: 0.76rem;
  color: #64748b;
  line-height: 1.3;
}

.pdt-order-go {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #cbd5e1;
  flex: 0 0 auto;
}

/* The counted number is stepped, not typed: a thumb on a 40px minus and plus
   beside the box, because an aisle is counted while holding a box. */
.pdt-step {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  color: #0f172a;
  font-weight: 800;
  font-size: 1.05rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.pdt-step:hover,
.pdt-step:focus-visible {
  background: #e2e8f0;
}

.pdt-row-tail {
  flex-wrap: wrap;
}

.pdt-count {
  width: 72px;
}

.pdt-post-line {
  margin-left: auto;
  min-height: 40px;
}

/* ---------------------------------------------------------------- offers
 *
 * The one line under the totals that says what the schemes took off, and the rows
 * on the settings screen. Green, because it is money the customer kept, and small,
 * because it must never compete with the grand total.
 */
.cart-offer-line {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #dcfce7;
  color: #15803d;
  font-size: 0.74rem;
  font-weight: 700;
}

.offer-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid #eef2f6;
}

.offer-row:last-child {
  border-bottom: 0;
}

.offer-row-main {
  min-width: 0;
}

.offer-name {
  font-weight: 700;
  font-size: 0.9rem;
  color: #0f172a;
}

.offer-detail {
  font-size: 0.76rem;
  color: #64748b;
  line-height: 1.3;
}

.offer-row-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

/* A tap target for a search result inside the settings sheet. */
.settings-list-row {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
  min-height: 48px;
  padding: 8px 12px;
  border: 0;
  border-bottom: 1px solid #eef2f6;
  background: #f8fafc;
  text-align: left;
}

.settings-list-row:hover,
.settings-list-row:focus-visible {
  background: #eff6ff;
}

/* ---------------------------------------------------------------- products and labels
 *
 * The products page inside Settings: one row per medicine, its barcode, and a small
 * preview of the label so the staff can see what will print before they print it.
 */
.product-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid #eef2f6;
}

.product-row:last-child {
  border-bottom: 0;
}

.product-row-main {
  min-width: 0;
  flex: 1 1 auto;
}

.product-name {
  font-weight: 700;
  font-size: 0.9rem;
  color: #0f172a;
}

.product-detail {
  font-size: 0.76rem;
  color: #64748b;
}

.product-barcode {
  margin-top: 4px;
  font-size: 0.78rem;
}

.product-barcode code {
  color: #0f172a;
}

.product-label-preview {
  max-width: 190px;
  margin-top: 6px;
  padding: 4px;
  border: 1px dashed #e2e8f0;
  border-radius: 8px;
  background: #fff;
}

.product-row-actions {
  flex: 0 0 auto;
  display: flex;
  gap: 6px;
}

.barcode-svg {
  display: block;
}

/* The label sheet only exists for the printer. */
.barcode-print-area {
  display: none;
}

@media print {
  body > *:not(.barcode-print-area) {
    display: none !important;
  }

  .barcode-print-area {
    display: block !important;
    padding: 0;
    margin: 0;
  }

  .barcode-label {
    width: 50mm;
    min-height: 30mm;
    padding: 2mm;
    margin: 0 2mm 2mm 0;
    display: inline-block;
    vertical-align: top;
    border: 1px solid #cbd5e1;
    page-break-inside: avoid;
    font-family: Arial, Helvetica, sans-serif;
    color: #000;
  }

  .barcode-label-name {
    font-size: 8pt;
    font-weight: 700;
    line-height: 1.1;
  }

  .barcode-label-meta {
    font-size: 6.5pt;
    line-height: 1.2;
  }

  .barcode-label-value {
    font-size: 7pt;
    letter-spacing: 0.5pt;
    text-align: center;
  }
}

/* ==========================================================================
   Control shapes on a phone.

   A pill button that is allowed to wrap stops being a pill: the text breaks
   over two lines, the box grows taller than it is wide and rounded-pill turns
   it into a blob. Labels never wrap, and every control keeps a thumb height.
   ========================================================================== */
.modal .btn,
#main-view-pos .btn,
#main-view-inventory .btn,
#main-view-pdt .btn,
#main-view-purchases .btn,
#main-view-reports .btn,
#main-view-bills .btn,
#main-view-staff .btn {
  white-space: nowrap;
}

.modal-header .btn {
  align-self: center;
  flex: 0 0 auto;
}

.modal .btn-sm,
#main-view-pdt .btn-sm,
#main-view-purchases .btn-sm,
#main-view-inventory .btn-sm,
#main-view-bills .btn-sm {
  min-height: 40px;
}

.modal .btn-sm.btn-icon,
#main-view-pdt .btn-sm.btn-icon {
  min-width: 40px;
  padding-left: 0;
  padding-right: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Two equal actions per row. Reads as a grid instead of a ragged stack.
   minmax(0,1fr) matters: a plain 1fr column cannot shrink below the label,
   which pushed the second button out through the card edge. */
.action-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0.5rem;
}

.action-grid > .btn {
  width: 100%;
  min-height: 44px;
  padding-left: 0.5rem;
  padding-right: 0.5rem;
  font-size: 0.95rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
}

@media (max-width: 400px) {
  .action-grid > .btn {
    font-size: 0.88rem;
    gap: 0.25rem;
  }
}

.action-grid .span-2 {
  grid-column: 1 / -1;
}

/* Filter chips scroll sideways instead of squeezing each other. */
.chip-row {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
  scrollbar-width: none;
}

.chip-row::-webkit-scrollbar {
  display: none;
}

.chip-row > .btn {
  flex: 0 0 auto;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
}

/* ==========================================================
   Bills history: one compact header, then the list

   The screen used to spend a third of a phone viewport on a title block and three
   large counters before the first invoice, and the filter pills were clipped by a
   horizontal scroller. The numbers are chips in the header now, and the filters are a
   segmented control that wraps instead of hiding.
   ========================================================== */
.bills-head {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px;
  margin-bottom: 14px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
}

.bills-head-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.bills-title h4 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 800;
  color: #0f172a;
}

.bills-eyebrow {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #0284c7;
}

.bills-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-left: auto;
}

.bill-stat {
  padding: 4px 10px;
  border-radius: 999px;
  background: #f1f5f9;
  font-size: 0.8rem;
  color: #334155;
  white-space: nowrap;
}

.bill-stat strong {
  color: #0f172a;
  font-weight: 800;
}

.bill-stat-cancelled strong {
  color: #b91c1c;
}

.bills-counter-btn {
  white-space: nowrap;
}

.bills-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.bills-filter {
  display: inline-flex;
  padding: 3px;
  border-radius: 999px;
  background: #f1f5f9;
}

.bills-filter .btn {
  border: 0;
  border-radius: 999px;
  padding: 4px 12px;
  font-weight: 600;
  color: #475569;
}

.bills-filter .btn.active {
  background: #ffffff;
  color: #0284c7;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.12);
}

.bills-search {
  max-width: 260px;
}

.bills-icon-btn {
  width: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.bills-print-shown {
  margin-left: auto;
}

/* Row actions as small square buttons, so three of them fit a phone. */
.bill-act {
  width: 34px;
  height: 30px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
}

.bill-lock {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: #94a3b8;
  font-size: 0.85rem;
  white-space: nowrap;
}

/* An invoice number is one token. Letting it break put "ALSH/26-" on one line and
   "27/00207" on the next, which reads like two different bills. */
#bills-table .bill-c-invoice code {
  white-space: nowrap;
  font-size: 0.86rem;
}

#bills-table .bill-c-date .small {
  white-space: nowrap;
}

.bill-clock {
  font-size: 0.78rem;
  color: #64748b;
}

@media (max-width: 767.98px) {
  .bills-stats {
    margin-left: 0;
  }

  .bills-search {
    max-width: none;
    flex: 1 1 160px;
  }

  .bills-print-shown {
    margin-left: 0;
    flex: 1 1 auto;
  }

  .bills-counter-btn {
    width: 100%;
  }
}

/* A till is often a phone. Nine columns cannot live in 350px, so under the tablet
   breakpoint every bill becomes one card instead of a sideways scroll. */
@media (max-width: 767.98px) {

  #bills-table thead {
    display: none;
  }

  #bills-table,
  #bills-table tbody,
  #bills-table tr,
  #bills-table td {
    display: block;
    width: auto;
  }

  #bills-table tbody tr.bill-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 8px;
    padding: 10px 12px;
    margin-bottom: 8px;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    background: #ffffff;
  }

  #bills-table tr.bill-row > td {
    padding: 0;
    border: 0;
    text-align: left;
  }

  #bills-table .bill-c-invoice {
    order: 1;
    flex: 1 1 auto;
    min-width: 0;
  }

  #bills-table .bill-c-status {
    order: 2;
  }

  #bills-table .bill-c-date {
    order: 3;
    flex: 1 1 100%;
    display: flex;
    align-items: baseline;
    gap: 6px;
  }

  #bills-table .bill-c-staff {
    order: 4;
  }

  #bills-table .bill-c-payment {
    order: 5;
  }

  #bills-table .bill-c-items {
    order: 6;
  }

  #bills-table .bill-c-customer {
    order: 7;
    flex: 1 1 auto;
    min-width: 0;
  }

  #bills-table .bill-c-total {
    order: 8;
    margin-left: auto;
  }

  #bills-table .bill-c-actions {
    order: 9;
    flex: 1 1 100%;
  }

  #bills-table .bill-c-actions > div {
    justify-content: flex-start;
    flex-wrap: wrap;
  }
}

/* Between phone and desktop the three secondary columns go, so the action buttons
   stay on screen without a horizontal scroll. */
@media (min-width: 768px) and (max-width: 991.98px) {

  #bills-table .bill-c-staff,
  #bills-table .bill-c-payment,
  #bills-table .bill-c-items,
  #bills-table th:nth-child(4),
  #bills-table th:nth-child(5),
  #bills-table th:nth-child(6) {
    display: none;
  }

  .bill-lock-text {
    display: none;
  }

  #bills-table .bill-c-actions > div {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  #bills-table .bill-c-actions .btn {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }
}

/* Line entry inside the order and receiving sheets. */
.line-fields {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0.5rem;
  align-items: start;
}

.line-fields > * {
  min-width: 0;
}

.line-fields .form-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: #64748b;
  margin-bottom: 0.15rem;
  white-space: nowrap;
}

.line-fields .form-control,
.line-fields .form-select {
  min-height: 40px;
}

.line-fields .span-2 {
  grid-column: 1 / -1;
}

.line-fields .field-hint {
  font-size: 0.78rem;
  color: #64748b;
  line-height: 1.35;
}

@media (min-width: 768px) {
  .line-fields {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

/* Two big jobs on the PDT, side by side with one line each. */
.pdt-tabs {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.pdt-tabs .btn {
  min-height: 66px;
  padding: 0.5rem 0.35rem;
  font-size: 0.84rem;
  line-height: 1.15;
  text-align: center;
  white-space: normal;
  flex-direction: column;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
}

.pdt-tabs .btn i {
  font-size: 1.05rem;
}

@media (max-width: 480px) {
  .pdt-tabs .btn {
    font-size: 0.8rem;
  }
}

/* The order row is a button: the label block may shrink, the badge may not. */
.pdt-order-main {
  min-width: 0;
  overflow: hidden;
}

/* Dates and money never break in the middle of the value. */
.nowrap,
.pur-order-date,
.bill-when {
  white-space: nowrap;
}

/* Purchases totals. One label and one number per line, so a long label can
   never push its number below the other column's number. */
.pur-kpi-grid {
  display: flex;
  flex-direction: column;
}

.pur-kpi {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.4rem 0;
  border-bottom: 1px dashed #e8eef5;
}

.pur-kpi:last-child {
  border-bottom: 0;
}

.pur-kpi .text-muted.small {
  font-size: 0.8rem;
  line-height: 1.25;
}

/* Claim figures: two equal columns so the numbers share a baseline. */
.pur-claim-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0.75rem;
}

.pur-claim-grid .text-muted.small {
  font-size: 0.8rem;
  line-height: 1.25;
  min-height: 2.5em;
}

/* A seven column table cannot live inside 397px. On a phone each row becomes
   a stacked card: the label is gone, the value carries its own meaning. */
@media (max-width: 767.98px) {
  .table-stack thead {
    display: none;
  }

  .table-stack tbody tr {
    display: block;
    padding: 0.75rem 1rem 0.875rem;
    border-bottom: 1px solid #e2e8f0;
  }

  .table-stack tbody tr:last-child {
    border-bottom: 0;
  }

  .table-stack tbody td {
    display: block;
    width: 100%;
    padding: 0.125rem 0;
    border: 0;
    text-align: left !important;
  }

  .table-stack tbody td:empty,
  .table-stack tbody td.d-none {
    display: none;
  }

  .table-stack tbody td .btn {
    width: 100%;
    margin-top: 0.25rem;
  }

  .table-stack tbody td > .d-flex {
    flex-wrap: wrap;
    gap: 0.375rem;
  }
}

/* ==========================================================================
   The offline watch.

   A square panel in the middle of the screen, because it has to be noticed by
   somebody holding a strip of tablets, and a corner toast is not noticed.

   Below 48 hours it offers a way out. At 48 hours the buttons are gone and only
   the connection action is left, so the warning cannot be waved away while the
   shop keeps trading on a copy of the data.
   ========================================================================== */
.offline-window {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(15, 23, 42, 0.62);
  backdrop-filter: blur(2px);
}

.offline-box {
  /* Square, but a minimum rather than a fixed ratio: a hard 1:1 clipped the icon
     and the title when the text ran to three lines on a narrow phone. */
  width: min(92vw, 340px);
  min-height: min(92vw, 340px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 1.15rem 1.1rem;
  border-radius: 22px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  box-shadow: 0 24px 60px -20px rgba(15, 23, 42, 0.55);
  text-align: center;
}

.offline-box-icon {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  background: #fef3c7;
  color: #b45309;
  flex: 0 0 auto;
}

.offline-box-kicker {
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #94a3b8;
}

.offline-box-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: #0f172a;
  margin: 0;
  line-height: 1.2;
}

.offline-box-body {
  font-size: 0.8rem;
  line-height: 1.35;
  color: #475569;
  max-width: 27ch;
}

.offline-box-meter {
  width: 100%;
  margin-top: 0.15rem;
}

.offline-box-meter-bar {
  height: 6px;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
}

.offline-box-meter-bar > span {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: #f59e0b;
  transition: width 0.3s ease;
}

.offline-box-meter-text {
  margin-top: 0.25rem;
  font-size: 0.68rem;
  color: #94a3b8;
}

.offline-box-actions {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-top: 0.35rem;
}

.offline-box-actions .btn {
  min-height: 42px;
  font-size: 0.85rem;
}

.offline-box-foot {
  font-size: 0.66rem;
  color: #94a3b8;
  line-height: 1.3;
  min-height: 1.6em;
}

/* The 48 hour state: red, and the panel refuses to close. */
.offline-window.is-blocked .offline-box {
  border-color: #fecaca;
  box-shadow: 0 24px 60px -18px rgba(185, 28, 28, 0.5);
}

.offline-window.is-blocked .offline-box-icon {
  background: #fee2e2;
  color: #b91c1c;
}

.offline-window.is-blocked .offline-box-meter-bar > span {
  background: #dc2626;
}

.offline-window.is-blocked .offline-box-title {
  color: #991b1b;
}

/* A reminder that can wait: softer edge, so it reads as a notice and not a stop. */
.offline-window.is-reminder .offline-box {
  border-color: #fde68a;
}

.offline-window.is-reminder .offline-box-meter-bar > span {
  background: #f59e0b;
}

/* ==========================================================
   A sheet is never taller than the window

   The footer carries the one button the sheet exists for: Save and validate on the
   prescription form, Confirm and print on the bill. On a 15 inch monitor the form ran
   past the bottom of the window and that button sat out of reach, with nothing on
   screen to say the sheet continued. Above the phone breakpoint the sheet is capped and
   the body scrolls, so the title stays at the top and the button stays at the bottom.
   ========================================================== */
@media (min-width: 576px) {
  /* Bootstrap gives the dialog 1.75rem of margin above and below from this width up,
     so the content has to leave that much room or the footer edge hangs off screen. */
  .modal-content {
    max-height: calc(100vh - 3.5rem);
    max-height: calc(100dvh - 3.5rem);
  }
}

.modal-body {
  overflow-y: auto;
  overscroll-behavior: contain;
}


