body {
  background-color: #f4f6f9;
}
.card-header {
  font-weight: 600;
}
table input.form-control, table select.form-select {
  min-width: 100px;
}

/* Used on report pages (and anywhere else with a .no-print element) so the
   navbar, filter form, and action buttons disappear when printing, leaving
   just the report title and results table. */
@media print {
  .no-print {
    display: none !important;
  }
  body {
    background-color: #fff;
  }
}

/* Opposite of .no-print: hidden on screen, shown only when printing. Used
   for "print everything that matches the filter" tables on reports that
   are paginated on screen (e.g. the Member Report) — the on-screen table
   only shows the current page, but this one holds every matching row. */
.print-only {
  display: none;
}
@media print {
  .print-only {
    display: block !important;
  }
}

/* Small "(i)" info icon used next to a form label instead of a long
   helper-text paragraph underneath the field — keeps forms compact and
   readable on mobile. Full explanation shows as a tooltip on tap/hover. */
.field-info-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background-color: #6c757d;
  color: #fff;
  font-size: 11px;
  font-style: normal;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  cursor: help;
  margin-left: 4px;
  vertical-align: middle;
}

/* Member Tree report: highlights a row that matches the search box, and
   makes sure it's visible even when its parent nodes are printed/expanded. */
.tree-highlight {
  background-color: #fff3cd;
  border-radius: 4px;
}
.tree-toggle {
  line-height: 1;
}

/* =====================================================
   Mobile / tablet friendliness
   =====================================================
   This app is mostly used on phones and tablets in the field (salesmen
   taking orders, staff at a counter), so touch targets and form inputs
   need to be comfortably tappable rather than optimized for a mouse. */

/* iOS Safari zooms the page in when a focused input's font-size is below
   16px — keeping form controls at 16px on small screens avoids that jarring
   zoom-in/zoom-out every time someone taps into a field. Also raises the
   minimum tap target height close to the ~44px Apple/Google guideline. */
@media (max-width: 767.98px) {
  .form-control, .form-select, .btn, .form-check-input {
    font-size: 16px;
  }
  .form-control, .form-select {
    min-height: 44px;
  }
  .btn {
    min-height: 44px;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
  }
  .form-control-sm, .form-select-sm {
    min-height: 38px;
    font-size: 15px;
  }
  .btn-sm {
    min-height: 36px;
  }
  /* Bootstrap's default checkbox/radio boxes are tiny targets on a
     touchscreen — enlarge just the box, not the label text. */
  .form-check-input {
    width: 1.35em;
    height: 1.35em;
    margin-top: 0.1em;
  }
  h4.card-title, h4 {
    font-size: 1.15rem;
  }
}

/* Bigger, easier-to-tap nav links and dropdown items on any touch-sized
   screen (also applies to tablets in the Bootstrap "md" range). */
@media (max-width: 991.98px) {
  .navbar-nav .nav-link, .dropdown-item {
    padding-top: 0.65rem;
    padding-bottom: 0.65rem;
  }
  .navbar-toggler {
    padding: 0.5rem 0.65rem;
  }
}

/* Generic sticky bottom action bar for long entry forms (Sales Order,
   etc.) — keeps Save reachable with a thumb without scrolling back up,
   while staying out of the way of the normal in-flow layout on desktop.
   Usage: wrap the primary action button(s) in <div class="mobile-action-bar">. */
@media (max-width: 767.98px) {
  .mobile-action-bar {
    position: sticky;
    bottom: 0;
    z-index: 5;
    background: #fff;
    margin: 0 -0.75rem -0.75rem;
    padding: 0.6rem 0.75rem calc(0.6rem + env(safe-area-inset-bottom));
    border-top: 1px solid #dee2e6;
    box-shadow: 0 -2px 6px rgba(0,0,0,0.06);
  }
  .mobile-action-bar .btn {
    width: 100%;
  }
}

/* Typing-select ("combobox") widget used on the Sales Order form to pick a
   Customer or Item by typing — a plain text input plus a results list that
   drops down beneath it. Kept generic so it can be reused anywhere else a
   "must pick one from a big table" field is needed. */
.typeahead-wrap {
  position: relative;
}
.typeahead-results {
  position: absolute;
  z-index: 20;
  top: 100%;
  left: 0;
  right: 0;
  max-height: 320px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid #dee2e6;
  border-top: none;
  border-radius: 0 0 0.375rem 0.375rem;
  box-shadow: 0 6px 12px rgba(0,0,0,0.12);
}
.typeahead-item {
  padding: 0.6rem 0.75rem;
  cursor: pointer;
  border-bottom: 1px solid #f1f1f1;
}
.typeahead-item:last-child {
  border-bottom: none;
}
.typeahead-item:hover, .typeahead-item.active {
  background-color: #eef4ff;
}
.typeahead-item .item-photo-thumb {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 4px;
  margin-right: 8px;
  flex-shrink: 0;
}
/* Shown in place of .item-photo-thumb in the item search results when
   Photo Need is on for this organization but this particular item has no
   photo uploaded yet — so the row still has a consistent thumbnail slot
   instead of the text jumping left. */
.item-photo-thumb-empty {
  background-color: #f1f3f5;
  border: 1px solid #dee2e6;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 7px;
  line-height: 1.1;
  color: #6c757d;
  padding: 2px;
}

/* =====================================================
   Table -> stacked cards on mobile
   =====================================================
   A wide table (Sales Orders list, Recent Orders, etc.) squeezed onto a
   phone either scrolls sideways or shrinks unreadably. Below the tablet
   breakpoint, any <table class="table-mobile-cards"> instead turns each
   row into its own bordered card, one field per line — nothing to scroll,
   nothing squinted at. Add data-label="Column Name" to each <td> so its
   value gets a label; leave data-label off a cell (e.g. the actions cell,
   given class="mobile-actions" instead) to have it span full width. */
@media (max-width: 767.98px) {
  table.table-mobile-cards {
    border: none;
  }
  table.table-mobile-cards thead {
    display: none;
  }
  table.table-mobile-cards, table.table-mobile-cards tbody, table.table-mobile-cards tr, table.table-mobile-cards td {
    display: block;
    width: 100%;
  }
  table.table-mobile-cards tr {
    margin-bottom: 0.6rem;
    border: 1px solid #dee2e6;
    border-radius: 0.5rem;
    padding: 0.6rem 0.85rem;
    background: #fff;
  }
  table.table-mobile-cards tr:last-child {
    margin-bottom: 0;
  }
  table.table-mobile-cards td {
    border: none !important;
    padding: 0.25rem 0 !important;
    text-align: left !important;
  }
  table.table-mobile-cards td[data-label] {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
  }
  table.table-mobile-cards td[data-label]::before {
    content: attr(data-label);
    font-weight: 600;
    color: #6c757d;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    flex-shrink: 0;
  }
  table.table-mobile-cards td.mobile-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    padding-top: 0.5rem !important;
    margin-top: 0.35rem;
    border-top: 1px solid #f1f1f1 !important;
  }
  table.table-mobile-cards td.mobile-actions .btn {
    flex: 1 1 auto;
  }
}

/* =====================================================
   Sales Order — Order Items table on phones
   =====================================================
   This table (Item / Unit / Qty / Rate / Amount / remove) is an active
   entry grid, not a report — it stays a real table (not the stacked-card
   pattern above) so Qty/Rate stay visible and editable side by side. But
   the generic "table input min-width: 100px" rule further up this file is
   far too wide for Qty/Rate here on a narrow phone, forcing the whole
   table into horizontal scroll. Below the phone breakpoint, override that
   specifically for this table: every column except Item shrinks to just
   what its content needs, so Item gets the rest of the row's width and the
   table fits the screen with no side-scrolling. */
@media (max-width: 575.98px) {
  #linesTable {
    table-layout: fixed;
    font-size: 0.76rem;
  }
  #linesTable th, #linesTable td {
    padding: 0.3rem 0.3rem;
    overflow-wrap: break-word;
  }
  #linesTable th:first-child, #linesTable td:first-child {
    width: auto;
    white-space: normal;
  }
  #linesTable th:nth-child(2), #linesTable td:nth-child(2) {
    width: 44px;
    white-space: normal;
    font-size: 0.68rem;
  }
  #linesTable th:nth-child(3), #linesTable td:nth-child(3),
  #linesTable th:nth-child(4), #linesTable td:nth-child(4) {
    width: 50px;
  }
  #linesTable th:nth-child(5), #linesTable td:nth-child(5) {
    width: 48px;
    white-space: normal;
  }
  #linesTable th:last-child, #linesTable td:last-child {
    width: 26px;
    padding-left: 0;
    padding-right: 0.15rem;
  }
  /* Overrides the generic "table input min-width: 100px" rule and the
     .form-control-sm min-height:38px/font-size:15px mobile default further
     up this file — both are correct for normal forms, but far too roomy for
     a 5-numbers-in-a-row entry grid. */
  #linesTable input.form-control {
    min-width: 0;
    width: 100%;
    padding: 0.2rem 0.25rem;
    font-size: 0.76rem;
    min-height: 30px;
  }
  #linesTable .remove-line {
    padding: 0.1rem 0.3rem;
    font-size: 0.8rem;
    min-height: 26px;
    line-height: 1;
  }
}
