html {
  font-size: 14px;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

html {
  position: relative;
  min-height: 100%;
}

body {
  margin-bottom: 60px;
}

/* Keep navigation in normal flow, above page content but below modal dialogs. */
.site-header {
  position: sticky;
  top: 0;
  z-index: 1020;
  margin-bottom: 1rem;
  background: #fff;
  max-height: 100vh;
  max-height: 100dvh;
  overflow-y: auto;
}

@media print {
  .site-header {
    position: static;
    max-height: none;
    overflow: visible;
  }
}

.setup-shell { max-width: 1180px; margin: 0 auto; }
.setup-section { margin-top: 1.25rem; padding: 1rem; border: 1px solid #d8dee5; border-radius: .5rem; background: #fff; }
.setting-row { display: grid; grid-template-columns: minmax(16rem, 1fr) 12rem auto; gap: .75rem; align-items: center; padding: .65rem 0; border-bottom: 1px solid #edf0f2; }
.setting-row small, .permission-option small, .setup-user-list small { display: block; color: #68737d; font-weight: 400; }
.setup-user-layout { display: grid; grid-template-columns: minmax(13rem, 18rem) 1fr; gap: 1rem; }
.setup-user-list { border-right: 1px solid #d8dee5; padding-right: .75rem; }
.setup-user-list a { display: block; padding: .55rem .65rem; color: inherit; text-decoration: none; border-radius: .35rem; overflow-wrap: anywhere; }
.setup-user-list a:hover, .setup-user-list a.active { background: #eaf3fb; color: #075b9b; }
.permission-grid { display: grid; grid-template-columns: repeat(2, minmax(16rem, 1fr)); gap: .75rem; }
.permission-grid fieldset { border: 1px solid #d8dee5; border-radius: .4rem; padding: .65rem; }
.permission-grid legend { float: none; width: auto; padding: 0 .25rem; margin: 0; font-size: .95rem; font-weight: 700; }
.permission-option { display: flex; gap: .5rem; align-items: flex-start; margin: .45rem 0; }
.permission-option input { margin-top: .25rem; }
@media (max-width: 767px) {
  .setting-row, .setup-user-layout, .permission-grid { grid-template-columns: 1fr; }
  .setup-user-list { border-right: 0; border-bottom: 1px solid #d8dee5; padding: 0 0 .75rem; }
}

.quote-shell {
  max-width: 980px;
  margin: 0 auto;
}

.quote-toolbar,
.quote-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  margin-bottom: .7rem;
}

.quote-number-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
}

.photo-link {
  border: 0;
  border-left: 1px solid #c9d0d5;
  padding: 0 0 0 .45rem;
  color: #176aa6;
  background: transparent;
  font-size: .75rem;
}

.photo-preview {
  display: block;
  max-width: 100%;
  max-height: 45vh;
  margin: .75rem auto 0;
  border: 1px solid #d7dce0;
  border-radius: .35rem;
  object-fit: contain;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr));
  gap: .75rem;
}

.photo-card {
  padding: .5rem;
  border: 1px solid #d7dce0;
  border-radius: .4rem;
}

.photo-card img {
  width: 100%;
  height: 10rem;
  object-fit: contain;
  background: #f5f6f7;
}

.photo-card small,
.photo-card > a:last-child {
  display: block;
}

.mobile-photo-shell {
  max-width: 34rem;
  margin: 0 auto;
}

.photo-qr {
  width: min(19rem, 80vw);
  margin: 0 auto .5rem;
}

.photo-qr svg {
  display: block;
  width: 100%;
  height: auto;
}

.quote-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.utility-heading,
.quote-number {
  border: 0;
  padding: 0;
  color: #176aa6;
  background: transparent;
  font-weight: 600;
  cursor: pointer;
}

.utility-heading:disabled {
  color: #6c757d;
  cursor: default;
}

a.utility-heading {
  text-decoration: none;
}

.branch-badge {
  padding: .15rem .45rem;
  border-radius: .25rem;
  color: #fff;
  background: #176aa6;
  font-size: .8rem;
  font-weight: 700;
}

.quote-status-row {
  display: grid;
  grid-template-columns: 2fr 3fr 2fr 2fr 3fr;
  text-align: center;
  border-bottom: 1px solid #d7dce0;
  padding-bottom: .65rem;
}

.quote-entry-grid,
.quote-line {
  display: grid;
  grid-template-columns: 12% 34% 18% 24% 12%;
  align-items: center;
  gap: 0;
  text-align: center;
}

.quote-entry-grid > * {
  margin: .2rem .35rem;
}

.weight-input {
  display: flex;
  gap: .2rem;
}

.weight-input .btn {
  min-width: 2rem;
}

.quote-add-button {
  visibility: hidden;
}

.quote-add-button.is-ready {
  visibility: visible;
}

.quote-line-edit-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: .2rem;
}

.quote-line-edit-actions[hidden] {
  display: none;
}

.quote-lines {
  margin-top: .7rem;
  border: 1px solid #adb8c4;
  border-radius: .4rem;
  padding: .35rem .5rem;
  background: #fff;
}

.quote-shell.branch-BNP { background: #e5f0fc; }
.quote-shell.branch-PRN { background: #fce8ef; }
.quote-shell.branch-CNT { background: #e6f4e8; }
.quote-shell[class*="branch-"] { padding: .75rem; border-radius: .5rem; }
.branch-selector { display: inline-flex; align-items: center; gap: .3rem; margin: 0; }
.quote-lines tr:has(.rep-line-select) { cursor: pointer; }
.quote-lines tr:has(.rep-line-select):hover { background: #eaf3fb; }

.quote-line {
  grid-template-columns: 10% 32% 16% 16% 26%;
  min-height: 2rem;
  border-top: 1px solid #d7dce0;
}

.quote-line-select {
  width: 100%;
  padding: 0;
  border-right: 0;
  border-bottom: 0;
  border-left: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.quote-line-select:hover,
.quote-line-select:focus-visible,
.quote-line-select.is-selected {
  background: #eaf3fb;
}

.quote-line-heading {
  border-top: 0;
  font-weight: 700;
}

.quote-line span:last-child,
.quote-total,
.quote-output,
.summary-table td {
  text-align: right;
}

.quote-total {
  padding: .6rem 0;
  border-top: 2px solid #9ca5ab;
}

.empty-state {
  padding: 2rem;
  color: #6c757d;
  text-align: center;
  border-top: 1px solid #d7dce0;
}

.loan-shell {
  max-width: 1320px;
  margin: 0 auto;
}

.loan-toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: .7rem;
}

.loan-toolbar > div:first-child {
  display: flex;
  align-items: center;
  gap: .6rem;
}

.loan-filter {
  display: grid;
  grid-template-columns: minmax(15rem, 23rem) 9rem auto auto;
  gap: .4rem;
}

.loan-toolbar > div:first-child { flex-wrap: wrap; }
.customer-table { font-size: .9rem; }
.customer-table th, .customer-table td { padding: .35rem .5rem; }
#customerModal .form-label { margin-bottom: .15rem; font-size: .85rem; }

.loan-table-wrap {
  overflow-x: auto;
}

.loan-table {
  min-width: 920px;
  margin-bottom: 0;
  font-size: .86rem;
  white-space: nowrap;
}

.loan-table th,
.loan-table td {
  padding: .28rem .38rem;
  vertical-align: middle;
}

.loan-row {
  cursor: pointer;
}

.loan-row:focus {
  outline: 2px solid #258cfb;
  outline-offset: -2px;
}

.loan-row.loan-status-active td:first-child { border-left: .35rem solid #198754; }
.loan-row.loan-status-renewal td:first-child { border-left: .35rem solid #d8a400; }
.loan-row.loan-status-paid-up td:first-child { border-left: .35rem solid #0d6efd; }
.loan-row.loan-status-lapsed td:first-child { border-left: .35rem solid #dc3545; }

/* Preserve the familiar legacy status colours on the payable amount. */
.loan-table td.loan-payable.loan-status-active { background-color: #a9d08e; color: #000; }
.loan-table td.loan-payable.loan-status-renewal { background-color: #ffe699; color: #000; }
.loan-table td.loan-payable.loan-status-paid-up { background-color: #bdd7ee; color: #000; }
.loan-table td.loan-payable.loan-status-lapsed { background-color: #ff6464; color: #000; }

.loan-status {
  font-weight: 600;
}

.loan-status-active { color: #146c43; }
.loan-status-renewal { color: #8a6800; }
.loan-status-paid-up { color: #084298; }
.loan-status-lapsed { color: #b02a37; }

.loan-expiry.is-overdue {
  color: #000;
  background-color: #ff6464;
}

.cash-denom-grid {
  display: grid;
  grid-template-columns: minmax(4rem, 1fr) 7rem;
  gap: .4rem .75rem;
  align-items: center;
  max-width: 20rem;
}

.cash-count-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: .75rem;
  margin-bottom: .5rem;
}

.cash-count-heading strong {
  white-space: nowrap;
  text-align: right;
}

.cash-denom-grid input {
  text-align: right;
}


.loan-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
}

.loan-detail-grid h3 {
  font-size: 1rem;
}

.loan-detail-grid dl {
  display: grid;
  grid-template-columns: 9rem 1fr;
  gap: .25rem .7rem;
  margin: 0;
}

.loan-detail-grid dt,
.loan-detail-grid dd {
  margin: 0;
}

.loan-detail-grid dd {
  overflow-wrap: anywhere;
}

.loan-goods {
  white-space: pre-wrap;
}

.loan-photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(8rem, 1fr));
  gap: .6rem;
}

.loan-photo-grid a {
  display: grid;
  gap: .2rem;
  font-size: .8rem;
  text-decoration: none;
}

.loan-photo-grid img {
  display: block;
  width: 100%;
  height: 7rem;
  object-fit: contain;
  border: 1px solid #cbd2d9;
  background: #fff;
}

.loan-documents {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}

.loan-calculation {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .25rem .75rem;
  padding-top: .75rem;
  border-top: 1px solid #d7dce0;
}

.loan-calculation dt,
.loan-calculation dd {
  margin: 0;
}

.loan-calculation dd {
  text-align: right;
}

@media (max-width: 767px) {
  .loan-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .loan-filter,
  .loan-detail-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .quote-toolbar,
  .quote-actions {
    gap: .45rem;
  }

  .quote-status-row {
    grid-template-columns: 2fr 3fr 2fr 2fr 3fr;
    gap: .15rem;
    font-size: .9rem;
  }

  .quote-entry-grid {
    grid-template-columns: 14% 30% 20% 24% 12%;
  }

  .quote-entry-grid > * {
    margin: .15rem;
  }
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
  color: var(--bs-secondary-color);
  text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
  text-align: start;
}

.password-reveal {
  min-width: 44px;
  min-height: 44px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.password-hold-group input::-ms-reveal {
  display: none;
}
