/* ============================================================
   Frest · Legacy Bootstrap-3 Compatibility Layer
   Maps the app's old OneUI/Bootstrap-3 markup onto the Frest
   (Bootstrap 5) visual design. Component geometry, spacing and
   typography are redefined here — not just colors.
   Loaded AFTER frest core.css / theme-default.css.
   ============================================================ */

/* ───────────── Layout / content scaffold ───────────── */
#page-content {
  min-height: 68vh;
  /* Horizontal-scrollbar guard: bare legacy `.row` gutters (-13px) under the
     0-padding #page-content bleed ~5px past the viewport on pages that place
     a `.row` directly in the content area (deliveryReports, showDLRAll, …),
     adding a stray horizontal scrollbar. Clip the gutter bleed only —
     vertical scrolling is untouched. `overflow-x: clip` (modern browsers)
     avoids making this a scroll container so `position: sticky` keeps
     working; `overflow-x: hidden` is the fallback for older browsers. */
  overflow-x: hidden;
  overflow-x: clip;
}

/* ───────────── Page header / titles ───────────── */
.page-header {
  margin: 0 0 1.25rem;
  letter-spacing: 0.4px;
  text-transform: none;
  font-weight: 700;
  font-size: 1.6rem;
  color: #3a4a5a;
  line-height: 1.25;
}
.page-header-top { margin-top: 0.25rem; }
.page-header .btn,
.page-header .pull-right { margin: 0; }
.page-header small { text-transform: none; letter-spacing: 0; font-weight: 400; color: #9aa5b1; }
.primary-head { margin-bottom: 1rem; }
.primary-head .page-header { margin-bottom: 0; }

/* ───────────── Panels → Cards ───────────── */
.panel {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  margin-bottom: 1.25rem;
  background: #fff;
  border: 0;
  border-radius: 0.3125rem;
  box-shadow: 0 2px 14px rgba(38, 60, 85, 0.16);
  background-clip: border-box;
  word-wrap: break-word;
}
.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 1rem 1.375rem;
  margin-bottom: 0;
  border-bottom: 1px solid #e9ecee;
  background: transparent;
  font-weight: 500;
  font-size: 1.06rem;
  color: #516377;
}
.panel-heading .btn { margin: 0; }
.panel-title { margin: 0; font-size: 1.05rem; font-weight: 600; color: #516377; }
.panel-title small { color: #a8b1bb; font-weight: 400; }
.panel-body { flex: 1 1 auto; padding: 1.1rem 1.375rem; }
.panel-body > .table,
.panel-body > .table-responsive > .table { margin: 0; }
.panel-footer {
  padding: 0.9rem 1.375rem;
  border-top: 1px solid #e9ecee;
  background: #fbfbfd;
  border-radius: 0 0 0.3125rem 0.3125rem;
}
.panel-group { margin-bottom: 1.25rem; }
.panel-group .panel { margin-bottom: 0; border-radius: 0; box-shadow: 0 0 0 1px #e9ecee inset; }
.panel-group .panel:first-child { border-top-left-radius: 0.3125rem; border-top-right-radius: 0.3125rem; }
.panel-group .panel:last-child  { border-bottom-left-radius: 0.3125rem; border-bottom-right-radius: 0.3125rem; }
.panel-group .panel-heading { border-bottom: 0; }
.panel-collapse.collapse { display: none; }
.panel-collapse.collapse.in { display: block; }

/* Panel context color headings */
.panel-primary > .panel-heading    { background: #5a8dee; }
.panel-info > .panel-heading       { background: #00cfdd; }
.panel-success > .panel-heading    { background: #39da8a; }
.panel-warning > .panel-heading    { background: #fdac41; }
.panel-danger > .panel-heading     { background: #ff5b5c; }
.panel-secondary > .panel-heading  { background: #69809a; }
.panel-primary > .panel-heading, .panel-info > .panel-heading,
.panel-success > .panel-heading, .panel-warning > .panel-heading,
.panel-danger > .panel-heading, .panel-secondary > .panel-heading {
  color: #fff; border-color: transparent;
}
.panel-primary > .panel-heading .panel-title, .panel-info > .panel-heading .panel-title,
.panel-success > .panel-heading .panel-title, .panel-warning > .panel-heading .panel-title,
.panel-danger > .panel-heading .panel-title, .panel-secondary > .panel-heading .panel-title { color: #fff; }

/* ───────────── Labels → Badges ───────────── */
.label {
  display: inline-block;
  padding: 0.42em 0.78em;
  font-size: 0.79em;
  font-weight: 500;
  line-height: 1.25;
  color: #fff;
  text-align: center;
  white-space: nowrap;
  vertical-align: baseline;
  border-radius: 0.1875rem;
}
.label + .label { margin-left: 0.25rem; }
a.label:hover, a.label:focus { color: #fff; text-decoration: none; cursor: pointer; }
.label-default  { background: #8c9aab; }
.label-primary  { background: #5a8dee; }
.label-secondary{ background: #69809a; }
.label-info     { background: #00cfdd; }
.label-success  { background: #39da8a; }
.label-warning  { background: #fdac41; color: #37220a; }
.label-danger   { background: #ff5b5c; }
.label-dark     { background: #495563; }
.label-light    { background: #eef0f2; color: #516377; }

/* ───────────── Buttons ───────────── */
.btn { display: inline-block; font-weight: 500; line-height: 1.35; border-radius: 0.25rem; }
.btn .label, .btn .badge { top: 0; }
.btn-default, .btn.btn-white, .btn.btn-light {
  color: #677788;
  background: #fff;
  border: 1px solid #d7d9dd;
}
.btn-default:hover, .btn-default:focus,
.btn.btn-white:hover, .btn.btn-light:hover {
  background: #f4f6f8; color: #516377; border-color: #c6cad0;
}
.btn-large { padding: 0.8rem 1.4rem; font-size: 1rem; }
.btn-toolbar .btn-group { margin-right: 0.5rem; }
.btn .caret { margin-left: 0.35rem; }

/* ───────────── Tables ───────────── */
.table { margin-bottom: 1rem; }
.table thead th {
  font-weight: 600;
  color: #516377;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  font-size: 0.78rem;
  white-space: nowrap;
  background: #f8f9fb;
}
.table-bordered > :not(caption) > * > * { border-color: #eceff2; }
.table-striped > tbody > tr:nth-of-type(odd) > * { background: #f8f9fb; }
.table-hover > tbody > tr:hover > * { background: #f0f3f8; }
.table-condensed > :not(caption) > * > * { padding: 0.35rem 0.5rem; }
.table-responsive { overflow-x: auto; }

/* Fixed-height scrollable table body — shows ~3 rows, rest scrolls inside */
.table-scrollable {
  max-height: 18rem;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.table-scrollable thead th { position: sticky; top: 0; z-index: 1; }
.table-scrollable > .table { margin-bottom: 0; }

/* ───────────── Main content spacing (tight, near content-wrapper edges) ───────────── */
#page-content { margin: 0; padding: 0; }
/* Full-width content — kill the centered max-width box so no empty side margins on wide screens */
.content-wrapper > .container-xxl,
.layout-navbar .container-xxl {
  max-width: none !important;
}
.content-wrapper > .container-xxl {
  padding-right: 0.5rem !important;
  padding-left: 0.5rem !important;
}
.content-wrapper .container-p-y:not([class^=pt-]):not([class*=" pt-"]) {
  padding-top: 0.25rem !important;
}
.content-wrapper .container-p-y:not([class^=pb-]):not([class*=" pb-"]) {
  padding-bottom: 0.5rem !important;
}
.breadcrumb { margin-bottom: 0.4rem !important; }
.page-header { margin-bottom: 0.6rem; }

/* ───────────── Wells ───────────── */
.well {
  min-height: 20px;
  margin-bottom: 1.25rem;
  padding: 1.25rem;
  background: #fafafd;
  border: 1px solid #edf0f3;
  border-radius: 0.25rem;
}
.well-lg { padding: 1.75rem; }
.well-sm { padding: 0.9rem; }

/* ───────────── Forms ───────────── */
.form-group { margin-bottom: 1rem; }
.form-horizontal .form-group { display: grid; grid-template-columns: 190px 1fr; align-items: center; gap: 0.25rem 1rem; margin-bottom: 1rem; }
.control-group { margin-bottom: 1rem; display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 0.9rem; }
.control-label {
  display: inline-block;
  margin-bottom: 0.3rem;
  color: #516377;
  font-weight: 500;
  font-size: 0.83rem;
  letter-spacing: 0.2px;
}
.form-horizontal .control-label { margin-bottom: 0; }
.form-control {
  min-height: 2.4rem;
  border-radius: 0.25rem;
  border-color: #d6dae0;
}
.form-control:focus { border-color: #5a8dee; box-shadow: 0 0 0 0.25rem rgba(90,141,238,0.15); }
.help-block, .help-inline { color: #8c9aae; font-size: 0.83rem; }

/* Input prepend/append groups */
.input-prepend, .input-append { display: flex; align-items: center; }
.input-prepend .add-on, .input-append .add-on {
  display: inline-flex; align-items: center;
  padding: 0.55rem 0.8rem;
  font-size: 0.9rem; font-weight: 500; color: #516377;
  background: #f0f2f5;
  border: 1px solid #d6dae0;
  line-height: 1.25; white-space: nowrap;
}
.input-prepend .add-on { border-radius: 0.25rem 0 0 0.25rem; border-right: 0; }
.input-append  .add-on { border-radius: 0 0.25rem 0.25rem 0; border-left: 0; }
.input-prepend > .form-control, .input-prepend > input { border-radius: 0 0.25rem 0.25rem 0 !important; }
.input-append  > .form-control, .input-append  > input { border-radius: 0.25rem 0 0 0.25rem !important; }

/* Radios / checkboxes */
.radio, .checkbox, .radio-inline, .checkbox-inline {
  display: inline-flex; align-items: center; gap: 0.45rem;
  margin-bottom: 0.5rem; min-height: auto;
}
.radio-inline, .checkbox-inline { margin-right: 1rem; }
.radio input[type="radio"], .checkbox input[type="checkbox"],
.radio-inline input[type="radio"], .checkbox-inline input[type="checkbox"] {
  accent-color: #5a8dee; width: 1.05rem; height: 1.05rem; margin: 0;
}
.radio small, .checkbox small, .radio-inline small, .checkbox-inline small { color: #8c9aae; }

/* ───────────── Grid utilities (col-xs-* missing in BS5) ───────────── */
.col-xs-1{flex:0 0 8.33333333%;max-width:8.33333333%}
.col-xs-2{flex:0 0 16.66666667%;max-width:16.66666667%}
.col-xs-3{flex:0 0 25%;max-width:25%}
.col-xs-4{flex:0 0 33.33333333%;max-width:33.33333333%}
.col-xs-5{flex:0 0 41.66666667%;max-width:41.66666667%}
.col-xs-6{flex:0 0 50%;max-width:50%}
.col-xs-7{flex:0 0 58.33333333%;max-width:58.33333333%}
.col-xs-8{flex:0 0 66.66666667%;max-width:66.66666667%}
.col-xs-9{flex:0 0 75%;max-width:75%}
.col-xs-10{flex:0 0 83.33333333%;max-width:83.33333333%}
.col-xs-11{flex:0 0 91.66666667%;max-width:91.66666667%}
.col-xs-12{flex:0 0 100%;max-width:100%}
.col-xs-1, .col-xs-2, .col-xs-3, .col-xs-4, .col-xs-5, .col-xs-6,
.col-xs-7, .col-xs-8, .col-xs-9, .col-xs-10, .col-xs-11, .col-xs-12 {
  padding-right: 0.75rem; padding-left: 0.75rem; margin-bottom: 0.5rem;
}
.pull-right { float: right !important; }
.pull-left  { float: left !important; }
.center-block { display: block; margin-left: auto; margin-right: auto; }
.hidden-xs { } /* media-query grid, harmless */

/* ───────────── Breadcrumbs ───────────── */
.breadcrumb {
  display: flex; flex-wrap: wrap;
  padding: 0.6rem 1rem;
  margin-bottom: 1rem;
  list-style: none;
  background: #fff;
  border-radius: 0.25rem;
  border: 1px solid #edf0f3;
  box-shadow: 0 1px 3px rgba(38,60,85,.05);
}
.breadcrumb > li { display: inline-block; font-size: 0.875rem; }
.breadcrumb > li .divider, .breadcrumb > li > .divider { padding: 0 0.45rem; color: #8c9aae; }
.breadcrumb > .active { color: #516377; font-weight: 600; }
.breadcrumb > li a { color: var(--bs-primary); text-decoration: none; }
.breadcrumb > li a:hover { color: var(--bs-link-hover-color); }

/* ───────────── Tabs / pills ───────────── */
.nav-tabs { border-bottom-color: #e4e7ec; }
.nav-tabs > li { margin-bottom: -1px; }
.nav-tabs > li > a { border-radius: 0.25rem 0.25rem 0 0; color: #677788; font-weight: 500; }
.nav-tabs > li > a:hover { background: #f7f8fa; color: #516377; border-color: #edf0f3; }
.nav-tabs > li.active > a,
.nav-tabs > li.active > a:hover,
.nav-tabs > li.active > a:focus {
  color: #5a8dee;
  background: transparent;
  border: 1px solid transparent;
  box-shadow: inset 0 2px 0 0 #5a8dee;
}
.nav-pills > li > a { color: #677788; border-radius: 0.25rem; font-weight: 500; }
.nav-pills > li.active > a,
.nav-pills > li.active > a:hover,
.nav-pills > li.active > a:focus { background: #5a8dee; color: #fff; }
.tab-content > .tab-pane { display: none; padding-top: 0.75rem; }
.tab-content > .tab-pane.active { display: block; }

/* ───────────── Alerts ───────────── */
.alert { border-radius: 0.3125rem; padding: 0.9rem 1.1rem; }

/* ───────────── Bootstrap-3 state classes → BS5 visual ───────────── */
.dropdown.open > .dropdown-menu,
.btn-group.open > .dropdown-menu,
.open > .dropdown-menu { display: block !important; }
.dropdown-menu.pull-right { right: 0; left: auto; }
.collapse.in { display: block !important; }
.fade.in { opacity: 1; }
.modal.in { display: block !important; }
.modal-backdrop.in { opacity: 0.5; }
.tooltip.in { opacity: 1; }
.popover.in { opacity: 1; }

/* ───────────── Pagination / pager ───────────── */
.pagination { display: inline-flex; padding-left: 0; list-style: none; border-radius: 0.25rem; }
.pagination > li { }
.pagination > li > a, .pagination > li > span {
  position: relative; display: block;
  padding: 0.5rem 0.75rem; margin-left: -1px;
  font-size: 0.875rem; color: #677788; text-decoration: none;
  background: #fff; border: 1px solid #dde0e4;
}
.pagination > li > a:hover, .pagination > li > span:hover { background: #f0f3f8; color: #516377; }
.pagination > li.active > a, .pagination > li.active > span,
.pagination > li.active > a:hover {
  z-index: 3; color: #fff; background: #5a8dee; border-color: #5a8dee;
}
.pagination > li.disabled > a { color: #aab4c0; pointer-events: none; }
.pagination > li:first-child > a, .pagination > li:first-child > span { border-radius: 0.25rem 0 0 0.25rem; margin-left: 0; }
.pagination > li:last-child > a, .pagination > li:last-child > span { border-radius: 0 0.25rem 0.25rem 0; }
.pager { display: flex; gap: 0.5rem; padding-left: 0; list-style: none; }
.pager > li > a { display: block; padding: 0.5rem 0.9rem; border: 1px solid #dde0e4; border-radius: 0.25rem; color: var(--bs-primary); text-decoration: none; }

/* ───────────── DataTables (legacy jQuery DataTables 1.10 + Bootstrap classes) ───────────── */
.dataTables_wrapper { }
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.75rem 1rem; color: #677788; font-size: 0.875rem;
}
.dataTables_wrapper .dataTables_filter { justify-content: flex-end; }
.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
  width: auto; display: inline-block;
  border-radius: 0.25rem; border: 1px solid #d6dae0; padding: 0.375rem 0.75rem;
}
.dataTables_wrapper .dataTables_info {
  padding: 0.75rem 1rem; color: #8c9aae; font-size: 0.875rem;
}
.dataTables_wrapper .dataTables_paginate {
  display: flex; justify-content: flex-end; gap: 0.25rem;
  padding: 0.75rem 1rem;
}
.dataTables_wrapper .paginate_button,
.dataTables_paginate .paginate_button {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 2.2rem; height: 2.2rem; padding: 0 0.6rem;
  color: #677788; font-size: 0.875rem; font-weight: 500;
  background: #fff; border: 1px solid #dde0e4; border-radius: 0.25rem;
  cursor: pointer; text-decoration: none;
}
.dataTables_wrapper .paginate_button:hover,
.dataTables_paginate .paginate_button:hover { background: #f0f3f8; color: #516377; border-color: #c6cad0; }
.dataTables_wrapper .paginate_button.current,
.dataTables_paginate .paginate_button.current,
.dataTables_wrapper .paginate_button.current:hover {
  color: #fff; background: #5a8dee; border-color: #5a8dee;
}
.dataTables_wrapper .paginate_button.disabled,
.dataTables_wrapper .paginate_button.disabled:hover { color: #c3ccd6; background: #fff; pointer-events: none; }
.dataTables_processing { background: rgba(255,255,255,.9) !important; border: 0 !important; }

/* ───────────── Misc legacy components ───────────── */
.list-group { display: flex; flex-direction: column; padding-left: 0; margin-bottom: 1rem; list-style: none; }
.list-group-item {
  position: relative; display: block;
  padding: 0.75rem 1.25rem;
  color: #516377; text-decoration: none;
  background: #fff;
  border: 1px solid #eef0f3;
}
.list-group-item + .list-group-item { border-top-width: 0; }
.list-group-item.active { z-index: 2; color: #fff; background: #5a8dee; border-color: #5a8dee; }
.thumbnail { display: block; padding: 0.35rem; margin-bottom: 1rem; background: #fff; border: 1px solid #edf0f3; border-radius: 0.3125rem; }
.img-responsive { max-width: 100%; height: auto; }
.text-muted { color: #8c9aae !important; }
.text-warning { color: #fdac41 !important; }
.text-error, .text-danger { color: #ff5b5c !important; }
.text-info { color: #00cfdd !important; }
.text-success { color: #28c76f !important; }
hr { border-top: 1px solid #eef0f3; opacity: 1; }
.help-inline { color: #8c9aae; font-size: 0.83rem; }

/* Bare <h3>/<h4> page headings that never had the .page-header class */
h3.page-header { font-size: 1.6rem; }
h3.page-header small,
.page-header small { font-weight: 400; font-size: 0.72em; }

/* ───────────── Brand color (#db4a39) — theme primary ───────────── */
:root,
.dark-style {
  --bs-primary: #db4a39;
  --bs-blue: #db4a39;
  --bs-primary-rgb: 219, 74, 57;
  --bs-link-color: #db4a39;
  --bs-link-color-rgb: 219, 74, 57;
  --bs-link-hover-color: #c13a2b;
  --bs-link-hover-color-rgb: 193, 58, 43;
}
.app-brand-logo .avatar-initial { background-color: #db4a39; }
.content-footer.footer a { color: #db4a39; }
.app-brand-text { color: #db4a39; }
/* Brand-colored plain anchor links inside the page content (#page-content) */
#page-content a[href]:not(.btn):not(.dropdown-item):not(.badge):not(.nav-link):not([class*="text-"]) {
  color: var(--bs-primary);
}
#page-content a[href]:not(.btn):not(.dropdown-item):not(.badge):not(.nav-link):not([class*="text-"]):hover {
  color: var(--bs-link-hover-color);
}

/* ───────────── Dashboard stat tiles → Frest stat cards ───────────── */
.dash-tiles { margin: 0 -0.5rem 0.75rem; }
.dash-tiles > [class*="col-"] { padding: 0 0.5rem 1rem; }
.dash-tile {
  position: relative;
  min-height: 152px;
  border-radius: 0.625rem;
  padding: 1.05rem 1.25rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  color: #fff;
  box-shadow: 0 4px 16px rgba(38, 60, 85, 0.18);
  background: linear-gradient(135deg, #5a8dee, #3569c9);
}
.dash-tile-2x { min-height: 320px; }
.dash-tile-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 0;
  padding: 0 0 0.55rem;
  line-height: 1.35;
  font-weight: 600;
  font-size: 0.8rem;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid rgba(255, 255, 255, 0.28);
}
.dash-tile-options { float: none; height: auto; line-height: 1; }
.dash-tile-options .btn {
  padding: 0.2rem 0.45rem; font-size: 0.85rem; line-height: 1.2;
  color: #fff; background: rgba(255,255,255,0.16); border: 1px solid rgba(255,255,255,0.28);
  border-radius: 0.35rem;
}
.dash-tile-options .btn:hover { background: rgba(255,255,255,0.28); }
.dash-tile-icon {
  position: absolute; left: 1.25rem; bottom: 1.1rem;
  font-size: 2.75rem; line-height: 1; opacity: 0.9; color: #fff; float: none; padding: 0;
}
.dash-tile-text {
  position: absolute; right: 1.25rem; bottom: 1.05rem;
  font-size: 2rem; font-weight: 700; line-height: 1; text-align: right;
  color: #fff; float: none; padding: 0;
}
.dash-tile-content { margin: 0; padding: 0.5rem 0 0; }
.dash-tile-content-inner, .dash-tile-content-inner-fluid { min-height: 60px; }

/* Tile color variants (matching the old palette) as soft gradients */
.dash-tile-leaf     { background: linear-gradient(135deg, #a8d236, #82a823); }
.dash-tile-dark     { background: linear-gradient(135deg, #5b6a7f, #42536a); }
.dash-tile-ocean    { background: linear-gradient(135deg, #2f9be0, #1f74bd); }
.dash-tile-purple   { background: linear-gradient(135deg, #9c6ec8, #7e4fb3); }
.dash-tile-flower   { background: linear-gradient(135deg, #a55eea, #8a38c4); }
.dash-tile-fruit    { background: linear-gradient(135deg, #f5a623, #e07c1b); }
.dash-tile-oil      { background: linear-gradient(135deg, #d9d23a, #b6b02a); }
.dash-tile-balloon  { background: linear-gradient(135deg, #f07746, #e0502f); }
.dash-tile-doll     { background: linear-gradient(135deg, #e35bd1, #c92bb8); }

/* ───────────── Dashboard quick-action icon strip (nav-dash) ───────────── */
ul.nav-dash {
  list-style: none;
  display: flex; flex-wrap: wrap; gap: 0.5rem;
  margin: 0 0 1.25rem; padding: 0;
}
ul.nav-dash > li { margin: 0; }
ul.nav-dash > li > a {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 0.4rem;
  min-width: 3rem; height: 3rem; padding: 0 0.85rem;
  color: #516377; font-size: 1.35rem;
  background: #fff;
  border: 1px solid #e6e9ee;
  border-radius: 0.55rem;
  box-shadow: 0 2px 10px rgba(38, 60, 85, 0.08);
  text-decoration: none;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
ul.nav-dash > li > a:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(38, 60, 85, 0.14); color: #db4a39; }
ul.nav-dash > li > a .badge { position: absolute; margin: -0.9rem 0 0 1.6rem; font-size: 0.68rem; }

/* ───────────── Bootstrap-3 modals → Frest modals (incl. bootbox) ───────────── */
.modal-dialog {
  position: relative; width: auto; margin: 1.75rem auto;
  max-width: 34rem; pointer-events: none;
  padding: 0 0.75rem;
}
.modal-dialog.modal-lg { max-width: 48rem; }
.modal-dialog.modal-sm { max-width: 21rem; }
.modal.fade .modal-dialog { transform: translateY(-20px); transition: transform 0.25s ease-out; }
.modal.in .modal-dialog { transform: none; }
.modal-content {
  position: relative; display: flex; flex-direction: column; width: 100%;
  pointer-events: auto; background: #fff; background-clip: padding-box;
  border: 0; border-radius: 0.5rem;
  box-shadow: 0 10px 30px rgba(38, 60, 85, 0.22); outline: 0;
}
.modal-header {
  display: flex; flex-shrink: 0; align-items: center; justify-content: space-between;
  padding: 1rem 1.25rem; border-bottom: 1px solid #e9ecee;
  border-top-left-radius: 0.5rem; border-top-right-radius: 0.5rem;
}
.modal-header .close { float: none; margin: 0; padding: 0; }
.modal-title { margin-bottom: 0; font-size: 1.05rem; font-weight: 600; color: #516377; }
.modal-body { position: relative; flex: 1 1 auto; padding: 1.25rem; color: #677788; }
.modal-footer {
  display: flex; flex-wrap: wrap; flex-shrink: 0; align-items: center; justify-content: flex-end;
  padding: 0.8rem 1.25rem; gap: 0.5rem; border-top: 1px solid #e9ecee;
  border-bottom-right-radius: 0.5rem; border-bottom-left-radius: 0.5rem;
}
.modal-backdrop { position: fixed; top: 0; left: 0; z-index: 1055; width: 100vw; height: 100vh; background-color: #24324a; }
.modal-backdrop.fade { opacity: 0; }
.modal-backdrop.in { opacity: 0.5; }
.modal-open { overflow: hidden; }

/* ───────────── Progress bars ───────────── */
.progress {
  display: flex; height: 0.65rem; overflow: hidden;
  font-size: 0.75rem; background: #eef0f3; border-radius: 0.25rem;
}
.progress-bar {
  display: flex; flex-direction: column; justify-content: center; overflow: hidden;
  color: #fff; text-align: center; white-space: nowrap;
  background-color: #5a8dee; transition: width 0.6s ease;
}
.progress-bar-success { background-color: #28c76f; }
.progress-bar-info    { background-color: #00cfdd; }
.progress-bar-warning { background-color: #fdac41; }
.progress-bar-danger  { background-color: #ff5b5c; }

/* ───────────── Bootstrap-3 badge context colors ───────────── */
.badge-success { background-color: #28c76f; }
.badge-warning { background-color: #fdac41; color: #37220a; }
.badge-danger  { background-color: #ff5b5c; }
.badge-info    { background-color: #00cfdd; }
.badge-inverse { background-color: #495563; }
.badge-primary { background-color: #5a8dee; }

/* ───────────── Buttons: BS3 sizes / modifiers ───────────── */
.btn-xs { padding: 0.25rem 0.5rem; font-size: 0.75rem; line-height: 1.5; border-radius: 0.2rem; }
.btn-block { display: block; width: 100%; }
.btn-group-xs > .btn { padding: 0.25rem 0.5rem; font-size: 0.75rem; border-radius: 0.2rem; }
.btn-group-sm > .btn { padding: 0.375rem 0.65rem; font-size: 0.875rem; border-radius: 0.25rem; }

/* ───────────── Inline forms & input groups ───────────── */
.form-inline { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.form-inline .form-group { margin-bottom: 0; }
.input-group { position: relative; display: flex; flex-wrap: wrap; align-items: stretch; width: 100%; }
.input-group .form-control { position: relative; flex: 1 1 auto; width: 1%; min-width: 0; }
.input-group-addon {
  display: flex; align-items: center; padding: 0.55rem 0.8rem;
  font-size: 0.9rem; font-weight: 500; line-height: 1.25; color: #516377;
  background: #f0f2f5; border: 1px solid #d6dae0; white-space: nowrap;
}
.input-group .input-group-addon:first-child { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-group .input-group-addon:last-child  { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.input-group-addon:first-child + .form-control { border-top-left-radius: 0; border-bottom-left-radius: 0; }

/* ───────────── BS3 dropdowns (li > a markup) & misc ───────────── */
.dropdown-menu > li > a {
  display: block; width: 100%; padding: 0.45rem 1rem; clear: both;
  font-weight: 400; color: #516377; text-align: inherit;
  white-space: nowrap; background-color: transparent; border: 0;
}
.dropdown-menu > li > a:hover { color: #516377; background: #f0f3f8; }
.img-thumbnail { padding: 0.25rem; background: #fff; border: 1px solid #e9ecee; border-radius: 0.25rem; max-width: 100%; height: auto; }
.img-rounded { border-radius: 0.25rem; }
.nav > li > a { color: #677788; }
.nav > li > a:hover { color: #516377; }

/* ───────────── Dashboard chrome (breadcrumb strip, lists, toolbar) ───────────── */
#nav-info {
  list-style: none; display: flex; align-items: center; flex-wrap: wrap;
  margin: 0 0 1.25rem; padding: 0.55rem 0.95rem;
  background: #fff; border: 1px solid #eef0f3; border-radius: 0.375rem;
  box-shadow: 0 1px 3px rgba(38, 60, 85, 0.05); font-size: 0.875rem;
}
#nav-info > li { display: flex; align-items: center; color: #677788; }
#nav-info > li + li::before { content: "/"; color: #c3ccd6; margin: 0 0.55rem; }
#nav-info a { color: var(--bs-primary); text-decoration: none; }
#nav-info a:hover { color: var(--bs-link-hover-color); }
#nav-info .active { color: #516377; font-weight: 600; }

ol.user_list { list-style: none; margin: 0; padding: 0; }
ol.user_list li { padding: 0.45rem 0.25rem; border-bottom: 1px dashed #eef0f3; color: #516377; font-size: 0.9rem; }
ol.user_list li:last-child { border-bottom: 0; }

.btn-group.pull-right.fixed-btngroup { padding: 0.5rem 0; }
.animation-fadeIn { animation: frestFadeIn 0.5s ease both; }
@keyframes frestFadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ───────────── Sidebar SMS Balance card (AJAX route list) ───────────── */
.menu-header_px { padding: 0.3rem 0.4rem 0.45rem !important; }
.menu-header_px .card { box-shadow: none; }
.menu-header_px .card-body { padding: 0.45rem 0.55rem !important; }
.menu-header_px .routes {
  margin-top: 0.3rem;
  max-height: 8rem;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}
.menu-header_px .routes .route-card {
  margin-bottom: 0.35rem;
  border: 1px solid rgba(255,255,255,0.55);
  border-radius: 0.4rem;
  background: rgba(255,255,255,0.55);
  box-shadow: none;
}
.menu-header_px .routes .route-card .card-body { padding: 0.3rem 0.5rem !important; }
.menu-header_px .route-title {
  font-size: 0.76rem;
  font-weight: 500;
  color: #516377;
  min-width: 0;
  word-break: break-word;
}
.menu-header_px .route-balance {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--bs-primary, #db4a39);
  white-space: nowrap;
}
.menu-header_px .route-unlimited {
  font-size: 0.64rem;
  font-weight: 700;
  color: #39da8a;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  white-space: nowrap;
}
.menu-header_px .route-expiry {
  font-size: 0.64rem;
  color: #8c9aae;
  margin-top: 0.1rem;
}
.menu-header_px .route-balance.text-danger { color: #ff5b5c; }
.menu-header_px .route-empty {
  font-size: 0.74rem;
  color: #8c9aae;
  padding: 0.3rem 0;
}

/* ───────────── Sidebar: .menu-inner must fill the space LEFT by the balance card ───────────── */
/* Stock Frest has .menu-inner as the only large flex child, so height:100%
   (core.css) is fine. Our SMS Balance card (.menu-header_px) is a flex sibling
   above it: with height:100% + min-height:auto the menu-inner refuses to shrink
   below its content height, so it overflows the fixed-height aside by roughly
   the card's height — the bottom menu items get clipped and perfect-scrollbar
   (bound to .menu-inner) never shows because the box is 100vh tall. Letting it
   flex to the remaining height makes it the proper scroll viewport again. */
.menu-vertical .menu-inner {
  height: auto;
  min-height: 0;
}
/* ───────────── Bootstrap-3 popover compatibility (BS3 JS markup on the BS5 base) ───────────── */
/* BS5's .popover relies on Popper inline styles; the app's BS3 plugin needs CSS positioning. */
.popover {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1091;
  display: block;
  max-width: 276px;
  font-size: 0.875rem;
  background-color: #fff;
  background-clip: padding-box;
  border: 1px solid #e6e9ee;
  border-radius: 0.5rem;
  box-shadow: 0 0.25rem 1rem rgba(38, 60, 85, 0.18);
}
.popover .arrow {
  position: absolute;
  display: block;
  width: 1rem;
  height: 0.5rem;
  margin: 0;
}
.popover .arrow::before,
.popover .arrow::after {
  position: absolute;
  display: block;
  content: "";
  border-color: transparent;
  border-style: solid;
}
/* top */
.popover.top .arrow { bottom: -0.5rem; left: 50%; transform: translateX(-50%); }
.popover.top .arrow::before { bottom: 0; left: 50%; transform: translateX(-50%); border-width: 0.5rem 0.5rem 0; border-top-color: #e6e9ee; }
.popover.top .arrow::after { bottom: 1px; left: 50%; transform: translateX(-50%); border-width: 0.5rem 0.5rem 0; border-top-color: #fff; }
/* right */
.popover.right .arrow { left: -0.5rem; top: 50%; transform: translateY(-50%); }
.popover.right .arrow::before { left: 0; top: 50%; transform: translateY(-50%); border-width: 0.5rem 0.5rem 0.5rem 0; border-right-color: #e6e9ee; }
.popover.right .arrow::after { left: 1px; top: 50%; transform: translateY(-50%); border-width: 0.5rem 0.5rem 0.5rem 0; border-right-color: #fff; }
/* bottom */
.popover.bottom .arrow { top: -0.5rem; left: 50%; transform: translateX(-50%); }
.popover.bottom .arrow::before { top: 0; left: 50%; transform: translateX(-50%); border-width: 0 0.5rem 0.5rem; border-bottom-color: #e6e9ee; }
.popover.bottom .arrow::after { top: 1px; left: 50%; transform: translateX(-50%); border-width: 0 0.5rem 0.5rem; border-bottom-color: #fff; }
/* left */
.popover.left .arrow { right: -0.5rem; top: 50%; transform: translateY(-50%); }
.popover.left .arrow::before { right: 0; top: 50%; transform: translateY(-50%); border-width: 0.5rem 0 0.5rem 0.5rem; border-left-color: #e6e9ee; }
.popover.left .arrow::after { right: 1px; top: 50%; transform: translateY(-50%); border-width: 0.5rem 0 0.5rem 0.5rem; border-left-color: #fff; }
/* header / content */
.popover-title {
  padding: 0.75rem 1rem;
  margin-bottom: 0;
  font-size: 1rem;
  font-weight: 600;
  color: #3a4a5a;
  background: transparent;
  border-bottom: 1px solid #eef0f3;
  border-top-left-radius: calc(0.5rem - 1px);
  border-top-right-radius: calc(0.5rem - 1px);
}
.popover-title:empty { display: none; }
.popover-content {
  padding: 0.9rem 1rem;
  color: #677788;
}

/* ───────────── Bootstrap-3 tooltip compatibility ───────────── */
.tooltip {
  position: absolute;
  z-index: 1099;
  display: block;
  font-size: 0.8125rem;
  opacity: 0;
  transition: opacity 0.15s linear;
}
.tooltip.in { opacity: 0.95; }
.tooltip .tooltip-arrow {
  position: absolute;
  width: 0;
  height: 0;
  border-color: transparent;
  border-style: solid;
}
.tooltip.top    { padding: 0.4rem 0; }
.tooltip.top    .tooltip-arrow { bottom: 0; left: 50%; margin-left: -0.4rem; border-width: 0.4rem 0.4rem 0; border-top-color: #495563; }
.tooltip.right  { padding: 0 0.4rem; }
.tooltip.right  .tooltip-arrow { top: 50%; left: 0; margin-top: -0.4rem; border-width: 0.4rem 0.4rem 0.4rem 0; border-right-color: #495563; }
.tooltip.bottom { padding: 0.4rem 0; }
.tooltip.bottom .tooltip-arrow { top: 0; left: 50%; margin-left: -0.4rem; border-width: 0 0.4rem 0.4rem; border-bottom-color: #495563; }
.tooltip.left   { padding: 0 0.4rem; }
.tooltip.left   .tooltip-arrow { top: 50%; right: 0; margin-top: -0.4rem; border-width: 0.4rem 0 0.4rem 0.4rem; border-left-color: #495563; }
.tooltip-inner {
  max-width: 200px;
  padding: 0.35rem 0.7rem;
  color: #fff;
  text-align: center;
  background-color: #495563;
  border-radius: 0.1875rem;
}

/* ───────────── bootstrap-notify: Frest-styled toast ───────────── */
/* bootstrap-notify writes an inline z-index of 1031 by default. That is
   below the fixed layout navbar (z-index 1080) and the modal backdrop
   (1055), so toasts end up hidden under the header. Keep them above the
   header (and modals) like BS5 toasts; inline style cannot beat !important.
   The dismiss/url children keep their relative inline z-indexes inside the
   stacking context this container now establishes.
   The box/typography below style the default markup AND the Frest template
   installed by each footer (notify-icon/notify-body/notify-close classes). */
[data-notify="container"] {
  display: flex !important;
  align-items: flex-start;
  gap: 0.625rem;
  width: auto !important;
  min-width: 300px;
  max-width: 400px;
  padding: 0.875rem 2.75rem 0.875rem 1rem !important;
  margin: 0 !important;
  border: 0 !important;
  border-radius: 0.5rem !important;
  box-shadow: 0 0.25rem 1rem rgba(38, 60, 85, 0.18);
  z-index: 1090 !important;
  font-family: inherit;
}
[data-notify="container"] .notify-icon {
  font-size: 1.375rem;
  line-height: 1.25;
}
[data-notify="container"] .notify-body {
  flex: 1 1 auto;
  min-width: 0;
}
[data-notify="container"] .notify-title {
  display: block;
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.3;
  color: inherit;
}
[data-notify="container"] .notify-message {
  display: block;
  font-size: 0.875rem;
  line-height: 1.45;
  color: #6e6b7b;
}
[data-notify="container"] .notify-title:empty { display: none; }
[data-notify="container"] .notify-title:not(:empty) + .notify-message { margin-top: 0.125rem; }
/* type accents — Frest palette */
[data-notify="container"].alert-primary .notify-icon,
[data-notify="container"].alert-primary .notify-title { color: #7367f0; }
[data-notify="container"].alert-success .notify-icon,
[data-notify="container"].alert-success .notify-title { color: #28c76f; }
[data-notify="container"].alert-danger  .notify-icon,
[data-notify="container"].alert-danger  .notify-title { color: #ff5b5c; }
[data-notify="container"].alert-warning .notify-icon,
[data-notify="container"].alert-warning .notify-title { color: #ff9f43; }
[data-notify="container"].alert-info    .notify-icon,
[data-notify="container"].alert-info    .notify-title { color: #00cfe8; }
[data-notify="container"].alert-dark    .notify-icon,
[data-notify="container"].alert-dark    .notify-title { color: #4b4b4b; }
/* close button (replaces the unstyled BS3 .close glyph) */
[data-notify="container"] .notify-close {
  position: absolute !important;
  top: 0.5rem !important;
  right: 0.5rem !important;
  display: flex !important;
  align-items: center;
  justify-content: center;
  width: 1.5rem !important;
  height: 1.5rem !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 50%;
  background: transparent;
  font-size: 1.125rem;
  font-weight: 300;
  line-height: 1;
  color: #6e6b7b;
  opacity: 0.55;
}
[data-notify="container"] .notify-close:hover {
  opacity: 1;
  background: rgba(38, 60, 85, 0.08);
}
/* the app never uses progress bars — keep the element from rendering */
[data-notify="container"] [data-notify="progressbar"] { display: none !important; }
/* enter/exit animation (animate.css is not loaded by the app) */
@keyframes frestNotifyIn {
  from { opacity: 0; transform: translateY(-0.5rem); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes frestNotifyOut {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(-0.5rem); }
}
[data-notify="container"] {
  animation: frestNotifyIn 0.25s ease-out;
}
[data-notify="container"][data-closing="true"] {
  animation: frestNotifyOut 0.2s ease-in forwards;
}
