:root {
  --app-bg: #f4f6f8;
  --app-surface: #ffffff;
  --app-border: #d7dde5;
  --app-ink: #17202a;
  --app-muted: #637083;
  --app-primary: #0f6cbd;
  --app-primary-dark: #0b4f88;
  --app-soft: #edf4fb;
}

body {
  background: var(--app-bg);
  color: var(--app-ink);
  font-size: 15px;
}

body.has-product-picker {
  overflow: hidden;
}

.page-shell {
  max-width: 1360px;
  margin: 0 auto;
}

.app-navbar {
  background: rgba(255, 255, 255, .96);
  border-bottom: 1px solid var(--app-border);
  box-shadow: 0 2px 10px rgba(15, 23, 42, .04);
  backdrop-filter: blur(10px);
}

.brand-mark {
  width: 2rem;
  height: 2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--app-primary);
  color: #fff;
}

.navbar .nav-link {
  border-radius: 8px;
  color: #3b4656;
  padding-inline: .8rem;
}

.navbar .nav-link.active,
.navbar .nav-link:hover {
  color: var(--app-primary-dark);
  background: var(--app-soft);
}

.navbar-actions {
  flex-wrap: wrap;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  min-height: 2rem;
  padding: .25rem .65rem;
  border: 1px solid var(--app-border);
  border-radius: 999px;
  background: #f8fafc;
  color: var(--app-muted);
}

.page-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.page-title {
  margin: 0;
  font-size: clamp(1.45rem, 2vw, 2rem);
  line-height: 1.2;
  letter-spacing: 0;
  font-weight: 750;
}

.page-subtitle {
  color: var(--app-muted);
  margin-top: .25rem;
}

.toolbar-form {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: .6rem;
  min-width: min(100%, 42rem);
}

.toolbar-field {
  flex: 1 1 11rem;
  min-width: 10rem;
}

.toolbar-actions {
  display: flex;
  gap: .5rem;
  flex: 0 0 auto;
}

.dashboard-export-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: .5rem;
}

.dashboard-filter-band {
  border: 1px solid var(--app-border);
  border-radius: 8px;
  background: var(--app-surface);
}

.dashboard-filter-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .85rem 1rem;
  border-bottom: 1px solid var(--app-border);
  background: #fbfcfe;
}

.dashboard-filter-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: .75rem;
  padding: 1rem;
}

.dashboard-filter-grid .form-label {
  margin-bottom: .35rem;
}

.dashboard-filter-actions {
  display: flex;
  justify-content: flex-end;
  gap: .5rem;
  padding: 0 1rem 1rem;
}

.panel {
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, .05);
  overflow: hidden;
}

.panel-header {
  border-bottom: 1px solid var(--app-border);
  padding: 1rem 1.25rem;
  background: #fbfcfe;
}

.panel-body {
  padding: 1.25rem;
}

.panel-sticky {
  top: 5rem;
}

.form-label {
  font-weight: 650;
  color: #344054;
}

.form-control-lg,
.form-select-lg {
  min-height: 3.25rem;
}

.btn {
  border-radius: 8px;
  font-weight: 650;
}

.btn-primary {
  --bs-btn-bg: var(--app-primary);
  --bs-btn-border-color: var(--app-primary);
  --bs-btn-hover-bg: var(--app-primary-dark);
  --bs-btn-hover-border-color: var(--app-primary-dark);
}

.table-fixed {
  table-layout: fixed;
}

.data-table {
  margin-bottom: 0;
}

.data-table thead th {
  color: #586579;
  background: #f8fafc;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .02em;
  border-bottom-color: var(--app-border);
  white-space: nowrap;
}

.data-table tbody td {
  vertical-align: middle;
}

.history-filter-results {
  max-height: min(56vh, 32rem);
  overflow-y: auto;
}

.history-filter-results .list-group-item {
  text-align: left;
}

.tooltip-inner {
  max-width: min(32rem, 90vw);
  text-align: left;
  white-space: pre-line;
}

.admin-product-table {
  min-width: 1050px;
}

.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--app-border);
  background: #fbfcfe;
}

.pagination-summary {
  color: var(--app-muted);
  font-size: .88rem;
  white-space: nowrap;
}

.pagination-bar .page-link {
  min-width: 2.15rem;
  text-align: center;
  color: var(--app-primary-dark);
}

.pagination-bar .page-item.active .page-link {
  color: #fff;
  background: var(--app-primary);
  border-color: var(--app-primary);
}

.numeric-total {
  min-height: 3.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .5rem 1rem;
  border: 1px solid var(--app-border);
  border-radius: 8px;
  background: var(--app-soft);
  color: var(--app-primary-dark);
  font-size: 1.45rem;
  font-weight: 700;
}

.count-block {
  border: 1px solid var(--app-border);
  border-radius: 8px;
  padding: 1rem;
  background: #fbfcfe;
}

.count-lines {
  display: grid;
  gap: .75rem;
}

.product-lines {
  display: grid;
  gap: .75rem;
}

.js-quick-qty {
  caret-color: transparent;
  background: #fff;
}

.js-quick-qty.is-keypad-active {
  border-color: var(--app-primary);
  box-shadow: 0 0 0 .2rem rgba(15, 108, 189, .15);
}

.quantity-keypad {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1060;
  display: none;
  padding: .75rem;
  border-top: 1px solid var(--app-border);
  background: rgba(255, 255, 255, .98);
  box-shadow: 0 -12px 30px rgba(15, 23, 42, .16);
}

.quantity-keypad.is-open {
  display: block;
}

.quantity-keypad-bar {
  max-width: 34rem;
  margin: 0 auto .55rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
}

.quantity-keypad-title {
  font-weight: 750;
  color: var(--app-ink);
}

.quantity-keypad-preview {
  color: var(--app-muted);
  font-size: .9rem;
  min-height: 1.25rem;
  word-break: break-word;
}

.quantity-keypad-close {
  width: 2.6rem;
  height: 2.6rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--app-border);
  border-radius: 8px;
  background: #fff;
  color: var(--app-ink);
}

.quantity-keypad-grid {
  max-width: 34rem;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: .45rem;
}

.quantity-keypad-grid button {
  min-height: 3.25rem;
  border: 1px solid var(--app-border);
  border-radius: 8px;
  background: #fff;
  color: var(--app-ink);
  font-size: 1.25rem;
  font-weight: 750;
}

.quantity-keypad-grid button:active {
  border-color: var(--app-primary);
  background: var(--app-soft);
}

.quantity-keypad-grid .quantity-keypad-next {
  color: #fff;
  background: var(--app-primary);
  border-color: var(--app-primary);
  font-size: 1rem;
}

.quantity-keypad-grid .quantity-keypad-save {
  grid-column: 1 / -1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  color: #fff;
  background: #198754;
  border-color: #198754;
  font-size: 1.05rem;
}

.product-picker {
  position: fixed;
  inset: 0;
  z-index: 1080;
  display: none;
  background: rgba(15, 23, 42, .35);
}

.product-picker.is-open {
  display: flex;
  align-items: stretch;
  justify-content: center;
}

.product-picker-panel {
  width: min(100%, 44rem);
  height: 100%;
  display: flex;
  flex-direction: column;
  background: #fff;
}

.product-picker-header {
  min-height: 3.8rem;
  display: grid;
  grid-template-columns: 3rem 1fr 3rem;
  align-items: center;
  gap: .5rem;
  padding: .5rem .75rem;
  border-bottom: 1px solid var(--app-border);
}

.product-picker-title {
  text-align: center;
  font-size: 1.05rem;
  font-weight: 750;
}

.product-picker-back,
.product-picker-close {
  width: 2.65rem;
  height: 2.65rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--app-border);
  border-radius: 8px;
  background: #fff;
  color: var(--app-ink);
}

.product-picker-search {
  min-height: 3.5rem;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: .65rem;
  margin: .85rem;
  padding: 0 .85rem;
  border: 1px solid var(--app-border);
  border-radius: 8px;
  background: #f8fafc;
}

.product-picker-search i {
  color: var(--app-muted);
  font-size: 1.15rem;
}

.product-picker-search input {
  min-width: 0;
  height: 3.25rem;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 1.05rem;
}

#productPickerClear {
  display: none;
  border: 0;
  background: transparent;
  color: var(--app-muted);
  padding: .25rem;
}

#productPickerClear.is-visible {
  display: inline-flex;
}

.product-picker-list {
  flex: 1 1 auto;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: .55rem;
  padding: 0 .85rem .85rem;
}

.product-picker-item {
  display: grid;
  grid-template-columns: minmax(5.5rem, auto) 1fr auto;
  gap: .6rem;
  align-items: center;
  min-height: 4rem;
  padding: .75rem;
  border: 1px solid var(--app-border);
  border-radius: 8px;
  background: #fff;
  color: var(--app-ink);
  text-align: left;
}

.product-picker-code {
  font-weight: 800;
}

.product-picker-name {
  min-width: 0;
  color: #334155;
}

.product-picker-unit {
  color: var(--app-muted);
  font-size: .88rem;
}

.product-picker-item mark {
  padding: 0 .05rem;
  border-radius: 4px;
  background: #fff3bf;
  color: inherit;
  font-weight: 800;
}

.product-picker-empty {
  color: var(--app-muted);
  text-align: center;
  padding: 2rem 1rem;
}

.count-line {
  border: 1px solid var(--app-border);
  border-radius: 8px;
  background: #fff;
  padding: .85rem;
}

.product-line {
  border: 1px solid var(--app-border);
  border-radius: 8px;
  background: #fff;
  padding: .85rem;
}

.count-line-title {
  color: var(--app-muted);
  font-weight: 750;
  margin-bottom: .55rem;
}

.count-line-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(6rem, .8fr) auto;
  gap: .75rem;
  align-items: end;
}

.product-line-grid {
  display: grid;
  grid-template-columns: minmax(8rem, .95fr) minmax(12rem, 1.4fr) minmax(6rem, .55fr) auto;
  gap: .75rem;
  align-items: start;
}

.line-total {
  min-height: 3.25rem;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: .5rem .8rem;
  border: 1px solid var(--app-border);
  border-radius: 8px;
  background: var(--app-soft);
  color: var(--app-primary-dark);
  font-size: 1.15rem;
  font-weight: 750;
}

.count-line-actions {
  display: flex;
  justify-content: flex-end;
}

.product-line-actions {
  display: flex;
  justify-content: flex-end;
  padding-top: 1.8rem;
}

.admin-list {
  display: grid;
}

.admin-list-row {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--app-border);
}

.admin-list-row:last-child {
  border-bottom: 0;
}

.metric-label {
  color: var(--app-muted);
  font-size: .78rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: .02em;
}

.metric-value {
  color: var(--app-ink);
  font-weight: 750;
  line-height: 1.4;
}

.import-map {
  min-height: 3rem;
  display: flex;
  align-items: center;
  padding: .6rem .75rem;
  border: 1px solid var(--app-border);
  border-radius: 8px;
  background: #f8fafc;
  color: var(--app-muted);
  font-size: .9rem;
  line-height: 1.35;
}

.icon-action {
  width: 2.6rem;
  height: 2.6rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.status-dot {
  width: .65rem;
  height: .65rem;
  border-radius: 50%;
  display: inline-block;
}

.status-dot.active {
  background: #198754;
}

.status-dot.inactive {
  background: #6c757d;
}

.btn-danger-soft {
  color: #b42318;
  background: #fff5f5;
  border-color: #f4b8b1;
}

.btn-danger-soft:hover {
  color: #fff;
  background: #b42318;
  border-color: #b42318;
}

@media (max-width: 768px) {
  body.has-quantity-keypad {
    padding-bottom: 20.5rem;
  }

  main.container-fluid {
    padding-top: 1rem !important;
  }

  .page-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .dashboard-export-actions {
    justify-content: stretch;
    width: 100%;
  }

  .dashboard-export-actions .btn {
    flex: 1 1 12rem;
    justify-content: center;
  }

  .dashboard-filter-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-filter-actions {
    flex-direction: column;
  }

  .dashboard-filter-actions .btn {
    justify-content: center;
    width: 100%;
  }

  .toolbar-form {
    width: 100%;
  }

  .toolbar-field,
  .toolbar-actions,
  .toolbar-form .form-select,
  .toolbar-form .form-control {
    flex: 1 1 auto;
    min-width: 0;
  }

  .toolbar-actions .btn {
    flex: 1 1 0;
    justify-content: center;
  }

  .navbar-actions {
    align-items: stretch !important;
    margin-top: .75rem;
  }

  .navbar-actions .btn,
  .navbar-actions .user-chip {
    width: 100%;
    justify-content: center;
  }

  .panel-header,
  .panel-body,
  .admin-list-row {
    padding: 1rem;
  }

  .staff-page .page-shell {
    max-width: 100%;
  }

  .staff-page .panel {
    border-left: 0;
    border-right: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .staff-page .panel-header {
    display: none;
  }

  .staff-page .count-block {
    padding: .85rem;
  }

  .staff-page #inventoryForm .btn[type="submit"] {
    position: static;
    min-height: 3.5rem;
  }

  .table-responsive {
    font-size: .92rem;
  }

  .pagination-bar {
    align-items: stretch;
    flex-direction: column;
    padding: .85rem 1rem;
  }

  .pagination-bar .pagination {
    flex-wrap: wrap;
  }

  .data-table {
    min-width: 740px;
  }

  .numeric-total {
    font-size: 1.7rem;
  }

  .count-line-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .product-line-grid {
    grid-template-columns: 1fr;
    gap: .55rem;
  }

  .count-line-actions,
  .product-line-actions {
    grid-column: 1 / -1;
  }

  .product-line-actions {
    padding-top: 0;
  }

  .product-line {
    padding: .75rem;
  }

  .product-line .form-text {
    margin-top: .3rem;
  }

  .quantity-keypad {
    bottom: 0;
    padding: .65rem;
  }

  .product-picker-item {
    grid-template-columns: 1fr auto;
    gap: .25rem .6rem;
  }

  .product-picker-code,
  .product-picker-name {
    grid-column: 1 / 2;
  }

  .product-picker-unit {
    grid-column: 2 / 3;
    grid-row: 1 / 3;
    align-self: center;
  }

  .modal-dialog {
    margin: .75rem;
  }
}

@media (max-width: 480px) {
  .form-control-lg,
  .form-select-lg {
    min-height: 3.55rem;
    font-size: 1.12rem;
  }

  .btn-lg {
    min-height: 3.25rem;
  }
}
