/*!
 * Huda's Technologies ERP - modern-ui.css  (v1.0)
 * Presentation-only layer. Loaded LAST, after Bootstrap 3 / Angle / plugin CSS.
 * Does not touch markup, behaviour, sidebar structure or theme colours.
 * Remove the <link> to revert completely.
 */

/* ---------- 1. Design tokens ---------- */
:root {
  --mu-primary: #4f46e5;
  --mu-primary-dark: #4338ca;
  --mu-primary-soft: #eef2ff;
  --mu-success: #16a34a;
  --mu-info: #0284c7;
  --mu-warning: #d97706;
  --mu-danger: #dc2626;
  --mu-text: #1f2937;
  --mu-muted: #6b7280;
  --mu-border: #e5e7eb;
  --mu-border-strong: #d1d5db;
  --mu-bg: #f4f6fb;
  --mu-surface: #fff;
  --mu-row-hover: #f8faff;
  --mu-th-bg: #f9fafb;
  --mu-radius-sm: 6px;
  --mu-radius: 10px;
  --mu-radius-lg: 14px;
  --mu-shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
  --mu-shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 4px 14px rgba(16, 24, 40, .05);
  --mu-shadow-lg: 0 20px 48px rgba(16, 24, 40, .22);
  --mu-space: 16px;
  --mu-ring: 0 0 0 3px rgba(79, 70, 229, .18);
  --mu-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mu-ease: .15s ease;
}

/* ---------- 2. Base ---------- */
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--mu-font);
  color: var(--mu-text);
  background-color: var(--mu-bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;               /* never scroll the page sideways */
}
.wrapper { max-width: 100%; }
.content-wrapper { background: var(--mu-bg); }
h1, h2, h3, h4, h5, h6 { font-family: var(--mu-font); color: var(--mu-text); font-weight: 600; }
a { transition: color var(--mu-ease); }
img, video, iframe { max-width: 100%; }
::selection { background: rgba(79, 70, 229, .18); }
:focus-visible { outline: 2px solid var(--mu-primary); outline-offset: 2px; }
.btn:focus-visible, .form-control:focus-visible { outline: 0; }

/* ---------- 3. Page heading / breadcrumbs ---------- */
.content-wrapper > .content-heading,
.content-heading {
  font-size: 20px;
  font-weight: 600;
  color: var(--mu-text);
  background: var(--mu-surface);
  border-bottom: 1px solid var(--mu-border);
  box-shadow: var(--mu-shadow-sm);
}
.breadcrumb { background: transparent; }

/* ---------- 4. Cards / panels ---------- */
.panel {
  border: 1px solid var(--mu-border);
  border-radius: var(--mu-radius);
  box-shadow: var(--mu-shadow-sm);
  /* colour set below so .bg-primary/.bg-purple... widgets keep theirs */
}
.panel:not([class*="bg-"]) { background-color: var(--mu-surface); }
.panel-heading {
  border-top-left-radius: var(--mu-radius);
  border-top-right-radius: var(--mu-radius);
  border-bottom: 1px solid var(--mu-border);
  font-weight: 600;
}
.panel-footer {
  border-top: 1px solid var(--mu-border);
  background: var(--mu-th-bg);
  border-bottom-left-radius: var(--mu-radius);
  border-bottom-right-radius: var(--mu-radius);
}
.panel-title { font-weight: 600; }
.panel-custom, .panel-default { border-color: var(--mu-border); }
.well { border-radius: var(--mu-radius); border-color: var(--mu-border); box-shadow: none; background: var(--mu-th-bg); }
.list-group-item:first-child { border-top-left-radius: var(--mu-radius-sm); border-top-right-radius: var(--mu-radius-sm); }
.list-group-item:last-child { border-bottom-left-radius: var(--mu-radius-sm); border-bottom-right-radius: var(--mu-radius-sm); }

/* ---------- 5. Buttons ---------- */
.btn {
  border-radius: var(--mu-radius-sm);
  font-weight: 500;
  transition: background-color var(--mu-ease), border-color var(--mu-ease), box-shadow var(--mu-ease), transform var(--mu-ease);
}
.btn:focus, .btn:active:focus { box-shadow: var(--mu-ring); outline: 0; }
.btn:active { transform: translateY(1px); }
.btn-primary { background-color: var(--mu-primary); border-color: var(--mu-primary); }
.btn-primary:hover, .btn-primary:focus, .btn-primary:active, .btn-primary.active,
.open > .dropdown-toggle.btn-primary { background-color: var(--mu-primary-dark); border-color: var(--mu-primary-dark); }
.btn-default { border-color: var(--mu-border-strong); background: var(--mu-surface); color: var(--mu-text); }
.btn-default:hover, .btn-default:focus { background: var(--mu-th-bg); border-color: var(--mu-border-strong); }
.btn-xs { border-radius: 5px; }
.btn-group > .btn:not(:first-child):not(:last-child) { border-radius: 0; }
.btn-group > .btn:first-child:not(:last-child) { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.btn-group > .btn:last-child:not(:first-child) { border-top-left-radius: 0; border-bottom-left-radius: 0; }

/* ---------- 6. Forms ---------- */
label, .control-label { font-weight: 600; color: #374151; }
.form-control {
  border-radius: var(--mu-radius-sm);
  border: 1px solid var(--mu-border-strong);
  box-shadow: none;
  color: var(--mu-text);
  transition: border-color var(--mu-ease), box-shadow var(--mu-ease);
}
.form-control:focus {
  border-color: var(--mu-primary);
  box-shadow: var(--mu-ring);
}
.form-control[disabled], .form-control[readonly], fieldset[disabled] .form-control { background-color: #f3f4f6; }
.input-group-addon { border-color: var(--mu-border-strong); background: var(--mu-th-bg); color: var(--mu-muted); }
.input-group .form-control:first-child, .input-group-addon:first-child { border-top-left-radius: var(--mu-radius-sm); border-bottom-left-radius: var(--mu-radius-sm); }
.input-group .form-control:last-child, .input-group-addon:last-child { border-top-right-radius: var(--mu-radius-sm); border-bottom-right-radius: var(--mu-radius-sm); }
.has-error .form-control, .parsley-error { border-color: var(--mu-danger) !important; }
.has-error .form-control:focus, .parsley-error:focus { box-shadow: 0 0 0 3px rgba(220, 38, 38, .18); }
.has-success .form-control { border-color: var(--mu-success); }
.parsley-errors-list { margin: 4px 0 0; padding: 0; list-style: none; color: var(--mu-danger); font-size: 12px; }
.help-block { color: var(--mu-muted); font-size: 12px; }
.checkbox, .radio { min-height: 22px; }
legend { border-bottom: 1px solid var(--mu-border); font-weight: 600; }
/* Select2 / bootstrap-select / Chosen */
.select2-container--bootstrap .select2-selection,
.select2-container .select2-selection--single,
.select2-container .select2-selection--multiple {
  border-radius: var(--mu-radius-sm) !important;
  border-color: var(--mu-border-strong) !important;
}
.select2-container--bootstrap.select2-container--focus .select2-selection,
.select2-container--bootstrap.select2-container--open .select2-selection {
  border-color: var(--mu-primary) !important; box-shadow: var(--mu-ring) !important;
}
.select2-dropdown { border-radius: var(--mu-radius-sm) !important; border-color: var(--mu-border-strong) !important; box-shadow: var(--mu-shadow); }
.bootstrap-select > .dropdown-toggle { border-radius: var(--mu-radius-sm); }
.select2-container { max-width: 100%; }

/* ---------- 7. Tables ---------- */
.table { color: var(--mu-text); }
.table > thead > tr > th {
  background: var(--mu-th-bg);
  color: var(--mu-muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .03em;
  border-bottom: 1px solid var(--mu-border);
  white-space: nowrap;
  vertical-align: middle;
}
.table > tbody > tr > td { border-top: 1px solid var(--mu-border); vertical-align: middle; }
.table > tbody > tr { transition: background-color var(--mu-ease); }
.table-hover > tbody > tr:hover, .table > tbody > tr:hover > td.sorting_1 { background-color: var(--mu-row-hover); }
.table-striped > tbody > tr:nth-of-type(odd) { background-color: #fbfcfe; }
.table-bordered, .table-bordered > thead > tr > th, .table-bordered > tbody > tr > td { border-color: var(--mu-border); }
.table-responsive { border: 0; -webkit-overflow-scrolling: touch; }
/* DataTables */
.dataTables_wrapper { padding-top: 4px; }
.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
  border: 1px solid var(--mu-border-strong); border-radius: var(--mu-radius-sm); padding: 4px 10px; height: 34px; background: var(--mu-surface);
}
.dataTables_wrapper .dataTables_filter input:focus { border-color: var(--mu-primary); box-shadow: var(--mu-ring); outline: 0; }
.dataTables_wrapper .dataTables_info { color: var(--mu-muted); font-size: 12px; }
.pagination > li > a, .pagination > li > span { border-color: var(--mu-border); color: var(--mu-text); }
.pagination > li:first-child > a { border-radius: var(--mu-radius-sm) 0 0 var(--mu-radius-sm); }
.pagination > li:last-child > a { border-radius: 0 var(--mu-radius-sm) var(--mu-radius-sm) 0; }
.pagination > .active > a, .pagination > .active > span, .pagination > .active > a:hover {
  background-color: var(--mu-primary); border-color: var(--mu-primary); color: #fff;
}
.pagination > li > a:hover { background: var(--mu-primary-soft); }
table.dataTable thead .sorting, table.dataTable thead .sorting_asc, table.dataTable thead .sorting_desc { background-color: var(--mu-th-bg); }
.dataTables_empty, .no-records, td[colspan].text-center:only-child { color: var(--mu-muted); padding: 28px 12px !important; text-align: center; }

/* ---------- 8. Dropdowns ---------- */
.dropdown-menu {
  border: 1px solid var(--mu-border);
  border-radius: var(--mu-radius);
  box-shadow: var(--mu-shadow);
  padding: 6px;
}
.dropdown-menu > li > a { border-radius: var(--mu-radius-sm); padding: 7px 12px; }
.dropdown-menu > li > a:hover, .dropdown-menu > li > a:focus { background: var(--mu-primary-soft); color: var(--mu-primary-dark); }
.dropdown-menu .divider { background: var(--mu-border); margin: 6px 0; }

/* ---------- 9. Tabs / pills ---------- */
.nav-tabs { border-bottom: 1px solid var(--mu-border); }
.nav-tabs > li > a { border: 0; border-bottom: 2px solid transparent; border-radius: 0; color: var(--mu-muted); font-weight: 500; margin-right: 0; }
.nav-tabs > li > a:hover { background: transparent; border-color: var(--mu-border-strong); color: var(--mu-text); }
.nav-tabs > li.active > a, .nav-tabs > li.active > a:hover, .nav-tabs > li.active > a:focus {
  border: 0; border-bottom: 2px solid var(--mu-primary); color: var(--mu-primary); background: transparent;
}
.nav-pills > li > a { border-radius: var(--mu-radius-sm); }
.nav-pills > li.active > a, .nav-pills > li.active > a:hover { background: var(--mu-primary); }
.tab-content { background: transparent; }

/* ---------- 10. Modals ---------- */
.modal-content {
  border: 0;
  border-radius: var(--mu-radius-lg);
  box-shadow: var(--mu-shadow-lg);
  overflow: hidden;
}
.modal-header { border-bottom: 1px solid var(--mu-border); padding: 14px 20px; }
.modal-title { font-weight: 600; }
.modal-footer { border-top: 1px solid var(--mu-border); background: var(--mu-th-bg); padding: 12px 20px; }
.modal-backdrop.in { opacity: .45; }
.close { opacity: .5; text-shadow: none; }
.close:hover { opacity: .9; }

/* ---------- 11. Alerts / labels / badges / toasts ---------- */
.alert { border-radius: var(--mu-radius); border-width: 1px; box-shadow: none; }
.label { border-radius: 999px; padding: .3em .75em; font-weight: 600; letter-spacing: .01em; }
.badge { border-radius: 999px; font-weight: 600; }
#toast-container > div { border-radius: var(--mu-radius); box-shadow: var(--mu-shadow); opacity: .97; }
.progress { border-radius: 999px; box-shadow: none; background: #eef0f4; }
.progress-bar { box-shadow: none; }
.tooltip-inner { border-radius: var(--mu-radius-sm); }
.popover { border-radius: var(--mu-radius); border-color: var(--mu-border); box-shadow: var(--mu-shadow); }

/* ---------- 12. Loaders / empty states ---------- */
#loader-wrapper { background: rgba(255, 255, 255, .85); }
.mu-empty { text-align: center; color: var(--mu-muted); padding: 32px 16px; }
@keyframes mu-spin { to { transform: rotate(360deg); } }
.dataTables_processing { border-radius: var(--mu-radius); box-shadow: var(--mu-shadow); border: 1px solid var(--mu-border); }

/* ---------- 13. Date/time pickers ---------- */
.datepicker, .bootstrap-timepicker-widget { border-radius: var(--mu-radius); }
.datepicker table tr td.active, .datepicker table tr td.active:hover,
.datepicker table tr td span.active { background: var(--mu-primary) !important; background-image: none !important; text-shadow: none; }
.datepicker table tr td, .datepicker table tr td span { border-radius: var(--mu-radius-sm); }

/* ---------- 14. Scrollbars (thin, non-intrusive) ---------- */
@media (min-width: 768px) {
  .table-responsive, .dataTables_wrapper, .modal { scrollbar-width: thin; }
}

/* ---------- 15. Login / lock screen ---------- */
.block-center .panel, .wrapper > .block-center .panel-body { border-radius: var(--mu-radius-lg); }
.block-center .panel { box-shadow: var(--mu-shadow); }

/* =====================================================================
   RESPONSIVE
   ===================================================================== */

/* ---- Tablet & below (<= 991px) ---- */
@media (max-width: 991px) {
  .content-wrapper { padding: 16px; }
  .content-heading { height: auto; min-height: 0; line-height: 1.35; padding: 14px 16px; }
  .content-heading .pull-right, .content-heading > .breadcrumb { float: none !important; display: block; margin-top: 8px; }
  .dataTables_wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .panel-body { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .panel-body .dropdown-menu, .panel-body .select2-dropdown { max-width: 92vw; }
}

/* ---- Mobile (<= 767px) ---- */
@media (max-width: 767px) {
  body { font-size: 14px; line-height: 1.5; }
  .content-wrapper { padding: 10px 10px 24px; }
  .content-heading { font-size: 17px; padding: 12px; margin: -10px -10px 12px; }

  /* Touch-friendly controls (>=44px target, 16px text prevents iOS zoom) */
  .form-control, .input-group-addon, select.form-control, textarea.form-control {
    font-size: 16px; min-height: 44px; padding: 8px 12px;
  }
  textarea.form-control { min-height: 88px; }
  .btn { min-height: 40px; padding: 8px 14px; }
  .btn-xs { min-height: 32px; min-width: 32px; padding: 5px 9px; }
  .btn-sm { min-height: 36px; }
  .btn-block-xs { display: block; width: 100%; }
  .input-group-btn .btn { min-height: 44px; }
  .select2-container .select2-selection--single { min-height: 44px; }
  .select2-container--bootstrap .select2-selection--single { height: 44px; line-height: 30px; padding-top: 6px; }
  .select2-container--bootstrap .select2-selection--single .select2-selection__arrow { height: 42px; }
  .checkbox label, .radio label { min-height: 30px; padding-top: 4px; }
  .dropdown-menu > li > a { padding: 10px 14px; }

  /* Stack horizontal form layouts */
  .form-horizontal .control-label { text-align: left; padding-top: 0; margin-bottom: 4px; }
  .form-horizontal .form-group { margin-left: 0; margin-right: 0; }
  .form-group { margin-bottom: 14px; }
  .btn-toolbar > .btn, .btn-toolbar > .btn-group { margin-bottom: 6px; }
  .panel-heading .pull-right { float: none !important; display: block; margin-top: 8px; }
  .panel-body { padding: 12px; }

  /* Tables: scroll inside container, compact cells */
  .table > thead > tr > th, .table > tbody > tr > td { padding: 8px 10px; font-size: 13px; }
  .table-responsive { width: 100%; margin-bottom: 12px; border: 0; }
  .dataTables_wrapper .dataTables_filter, .dataTables_wrapper .dataTables_length,
  .dataTables_wrapper .dataTables_info, .dataTables_wrapper .dataTables_paginate {
    float: none !important; text-align: left !important; display: block; margin: 6px 0;
  }
  .dataTables_wrapper .dataTables_filter input { width: 100% !important; margin-left: 0 !important; height: 44px; font-size: 16px; }
  .dataTables_wrapper .dt-buttons, .dataTables_wrapper .DTTT_container { float: none; margin-bottom: 8px; }
  .pagination > li > a, .pagination > li > span { padding: 8px 12px; }

  /* Modals fit the screen and scroll internally */
  .modal-dialog, .modal-lg, .modal-xl, .modal-sm {
    width: auto !important; max-width: none; margin: 8px !important;
  }
  .modal-content { max-height: calc(100vh - 16px); display: flex; flex-direction: column; }
  .modal-body { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 14px; }
  .modal-footer .btn { margin-bottom: 4px; }
  .modal-header { padding: 12px 14px; }
  .close { font-size: 28px; padding: 4px 8px; }

  /* Tabs scroll horizontally instead of wrapping messily */
  .nav-tabs { display: block; white-space: nowrap; overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch; border-bottom: 1px solid var(--mu-border); }
  .nav-tabs > li { float: none; display: inline-block; margin-bottom: 0; }
  .nav-tabs > li > a { padding: 10px 14px; }

  /* Keep pickers & menus inside viewport */
  .datepicker, .bootstrap-timepicker-widget { max-width: 94vw; }
  .dropdown-menu { max-width: 94vw; }
  .navbar-nav .open .dropdown-menu { box-shadow: var(--mu-shadow); }
  #toast-container > div { width: auto; max-width: 92vw; margin: 0 8px 8px; }

  /* Long words / numbers never force page-wide overflow */
  .content-wrapper pre { white-space: pre-wrap; }
  .fc-toolbar { display: block; }
  .fc-toolbar .fc-left, .fc-toolbar .fc-right, .fc-toolbar .fc-center { float: none; text-align: center; margin: 4px 0; }
  .btn-group-justified-xs { display: block; }
}

/* ---- Very small phones (<= 360px) ---- */
@media (max-width: 360px) {
  .content-wrapper { padding: 8px 8px 20px; }
  .content-heading { font-size: 16px; margin: -8px -8px 10px; }
  .panel-body { padding: 10px; }
  .btn { padding: 8px 10px; }
  .modal-dialog { margin: 4px !important; }
}

/* ---------- Pass 2 ---------- */
@media (max-width: 767px) {
  .content-wrapper > .content-heading { color: var(--mu-text); }
  .content-heading > .pull-right {
    display: flex !important; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
    float: none !important; margin-top: 10px; width: 100%;
  }
  .content-heading > .pull-right > small { color: var(--mu-muted); font-size: 12px; line-height: 1.3; flex: 1 1 140px; }
  .content-heading > .pull-right > .btn { flex: 0 0 auto; margin: 0; }
}
/* Dropdown lifted out of scrolling table (positioned by modern-ui.js) */
.mu-dd-fixed { position: fixed !important; z-index: 1060; max-height: 70vh; overflow-y: auto; margin: 0; }

/* ---------- Pass 3: mobile fixes ---------- */
@media (max-width: 767px) {
  /* Six-up summary strips (dashboard footer etc.) -> 3 per row */
  .panel-footer .row.text-center > [class*="col-xs-2"],
  .panel-footer .row.text-center > [class*="col-xs-1"] {
    width: 33.3333%; float: left; padding: 8px 4px; border-bottom: 1px solid var(--mu-border);
  }
  .panel-footer .row.text-center .h4 { font-size: 16px; margin-top: 4px; word-break: normal; }
  .panel-footer .row.text-center small { font-size: 11px; line-height: 1.25; word-break: normal; }
  /* Tables inside cards: keep text wrapping naturally, never break mid-word */
  .table td, .table th { word-break: normal; overflow-wrap: normal; }
  .table > tbody > tr > td { white-space: normal; }
  .table-responsive > .table:not(:has(> thead > tr > th:nth-child(5))) > tbody > tr > td { white-space: normal; }
  .table-responsive > .table:not(:has(> thead > tr > th:nth-child(5))) > tbody > tr > td:not(:first-child) { white-space: nowrap; }
  .table .label, .table .btn, .table .badge { white-space: nowrap; }
  .table-responsive > .table { margin-bottom: 0; }
  .panel > .table-responsive { border: 0; }
  /* Toolbars: neat wrapping button rows */
  .dt-buttons, .DTTT_container, .btn-toolbar { display: flex; flex-wrap: wrap; gap: 6px; }
  .dataTables_wrapper .dataTables_length select { width: auto; }
  .dataTables_wrapper .dataTables_filter label { display: block; width: 100%; }
  /* Pull-right clusters become full-width rows instead of overlapping */
  .content-wrapper .panel-heading .pull-right,
  .content-wrapper .panel-body > .pull-right { float: none !important; margin-bottom: 8px; }
}

/* Pass 4: heading must never shrink beside the (hidden) sidebar float on phones/tablets */
@media (max-width: 991px) {
  .content-wrapper > .content-heading, .content-heading { overflow: visible; clear: both; }
}
@media (max-width: 767px) {
  .content-wrapper > .content-heading { margin: -10px -10px 12px; width: auto; }
}
@media (max-width: 360px) {
  .content-wrapper > .content-heading { margin: -8px -8px 10px; }
}

/* ---- Reduced motion ---- */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation-duration: .01ms !important; }
}

/* ---- Print: leave existing print layouts untouched ---- */
@media print {
  body { background: #fff !important; overflow: visible; }
  .panel, .content-heading { box-shadow: none !important; }
  .table > thead > tr > th { background: #fff; color: #000; }
}

/* =====================================================================
   PASS 5: PHONE-FIRST SHELL  (<= 767px)  - bottom tab bar, top bar,
   off-canvas menu, auto card view for tables. Presentation only.
   ===================================================================== */
@media (max-width: 767px) {
  body { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }

  /* ---- Top bar: slim, sticky, big tap targets ---- */
  .topnavbar-wrapper { position: sticky; top: 0; z-index: 1030; }
  .topnavbar { box-shadow: 0 1px 0 var(--mu-border), var(--mu-shadow-sm); }
  .topnavbar .navbar-nav > li > a { min-width: 44px; min-height: 44px; display: flex; align-items: center; justify-content: center; }
  .topnavbar .navbar-nav > li > a > em, .topnavbar .navbar-nav > li > a > i { font-size: 18px; }
  .topnavbar .navbar-form { display: none !important; }            /* desktop search box */
  .topnavbar .dropdown-menu { max-height: 75vh; overflow-y: auto; }

  /* ---- Off-canvas menu: roomy touch rows + dimmed page ---- */
  .wrapper > .aside .nav > li > a,
  .wrapper > .aside .sidebar-nav > li > a { min-height: 48px; display: flex; align-items: center; font-size: 15px; }
  .wrapper > .aside { overflow-y: auto; -webkit-overflow-scrolling: touch; }
  .aside-toggled::after {
    content: ""; position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 1025; pointer-events: none;
  }

  /* ---- Page headings: clear hierarchy, clock row tucked away ---- */
  .content-heading { font-size: 18px; letter-spacing: -.01em; }
  .content-heading small.text-sm { display: none; }                 /* date/time line: noise on phones */
  .content-heading > .pull-right { justify-content: flex-end; }
  .content-heading > .pull-right > .btn { width: 100%; min-height: 46px; font-size: 15px; }

  /* ---- Cards feel like app cards ---- */
  .panel { border-radius: var(--mu-radius-lg); margin-bottom: 12px; }
  .panel-heading { padding: 12px 14px; }

  /* ---- Primary action buttons: full-width, thumb-friendly in forms/modals ---- */
  .modal-footer { display: flex; flex-direction: column-reverse; gap: 8px; }
  .modal-footer .btn { width: 100%; margin: 0; min-height: 46px; }
  form .btn-primary[type="submit"], form button.btn-primary[type="submit"] { min-height: 46px; }
  .btn-group.btn-group-justified-xs > .btn { flex: 1; }

  /* ---- Bottom tab bar (injected by modern-ui.js) ---- */
  .mu-tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 1035; display: flex;
    background: var(--mu-surface); border-top: 1px solid var(--mu-border);
    box-shadow: 0 -4px 16px rgba(16, 24, 40, .08);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .mu-tabbar a {
    flex: 1 1 0; min-width: 0; min-height: 58px; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px; color: var(--mu-muted); font-size: 11px; font-weight: 600; text-decoration: none; -webkit-tap-highlight-color: transparent;
  }
  .mu-tabbar a i { font-size: 20px; line-height: 1; }
  .mu-tabbar a.active { color: var(--mu-primary); }
  .mu-tabbar a.active i { transform: translateY(-1px); }
  .mu-tabbar a:active { background: var(--mu-primary-soft); }
  .mu-tabbar span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 2px; }
  .modal-open .mu-tabbar, .offsidebar-open .mu-tabbar { display: none; }
  #toast-container { bottom: 72px !important; top: auto !important; }

  /* ---- Auto card view for plain DataTables (class added by modern-ui.js) ---- */
  table.mu-stack, table.mu-stack > tbody, table.mu-stack > tbody > tr, table.mu-stack > tbody > tr > td { display: block; width: 100% !important; }
  table.mu-stack > thead { display: none; }
  table.mu-stack > tbody > tr {
    background: var(--mu-surface); border: 1px solid var(--mu-border); border-radius: var(--mu-radius-lg);
    box-shadow: var(--mu-shadow-sm); margin: 0 0 12px; padding: 6px 14px;
  }
  table.mu-stack > tbody > tr:hover { background: var(--mu-surface); }
  table.mu-stack > tbody > tr > td {
    border: 0 !important; padding: 8px 0; white-space: normal !important; text-align: right;
    display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; word-break: break-word;
    border-bottom: 1px dashed var(--mu-border) !important;
  }
  table.mu-stack > tbody > tr > td:last-child { border-bottom: 0 !important; }
  table.mu-stack > tbody > tr > td[data-label]:not([data-label=""])::before {
    content: attr(data-label); flex: 0 0 36%; text-align: left; color: var(--mu-muted);
    font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding-top: 2px;
  }
  table.mu-stack > tbody > tr > td[colspan] { display: block; text-align: center; }
  table.mu-stack > tbody > tr > td:empty { display: none; }
  table.mu-stack > tbody > tr > td .btn { margin-left: 4px; }
  .dataTables_wrapper:has(table.mu-stack) { overflow-x: visible; }
}

/* Tabs/pills row: fade hint that it scrolls */
@media (max-width: 767px) {
  .nav-tabs { scrollbar-width: none; }
  .nav-tabs::-webkit-scrollbar { display: none; }
}
@media (min-width: 768px) { .mu-tabbar { display: none !important; } }

/* =====================================================================
   PASS 6: PHONE MENU DRAWER + ONE-ROW TOP BAR  (<= 767px)
   The menu now slides OVER the page (dimmed) instead of pushing it
   off-screen, and the top bar icons stay on a single row.
   ===================================================================== */
@media (max-width: 767px) {
  /* drawer: fixed, above the page, tab bar and top bar */
  html .wrapper > .aside,
  html.csstransforms3d .wrapper > .aside {
    position: fixed; top: 0; bottom: 0; left: 0; margin-left: 0;
    width: 270px; max-width: 86vw; z-index: 1040;
    transform: translate3d(-105%, 0, 0); -webkit-transform: translate3d(-105%, 0, 0);
    transition: transform .25s ease; overflow-y: auto; -webkit-overflow-scrolling: touch;
  }
  html .wrapper > .aside > .aside-inner,
  html.aside-collapsed .wrapper > .aside > .aside-inner { width: 100%; }
  html body.aside-toggled .wrapper > .aside,
  html.csstransforms3d body.aside-toggled .wrapper > .aside {
    transform: translate3d(0, 0, 0); -webkit-transform: translate3d(0, 0, 0);
    box-shadow: 6px 0 28px rgba(15, 23, 42, .35);
  }
  /* page stays put behind the dimmed layer */
  html body.aside-toggled .wrapper > section,
  html body.aside-toggled .wrapper > footer,
  html.csstransforms3d body.aside-toggled .wrapper > section,
  html.csstransforms3d body.aside-toggled .wrapper > footer {
    margin-left: 0; transform: none; -webkit-transform: none;
  }
  body.aside-toggled { overflow: hidden; }
  .aside-toggled .mu-tabbar { display: none; }

  /* top bar: one row, icons only */
  .topnavbar .nav-wrapper { display: flex; flex-wrap: nowrap; align-items: center; justify-content: space-between; }
  .topnavbar .nav-wrapper > .nav.navbar-nav { display: flex; flex-wrap: nowrap; float: none; margin: 0; }
  .topnavbar .nav-wrapper > .nav.navbar-nav.navbar-right { margin-left: auto; }
  .topnavbar .nav-wrapper .nav > li { float: none; }
  .topnavbar .navbar-nav > li > a { min-width: 40px; padding-left: 8px; padding-right: 8px; }
  .topnavbar .navbar-nav > li.dropdown > a.dropdown-toggle { font-size: 0; }          /* hides the "Languages" word */
  .topnavbar .navbar-nav > li.dropdown > a.dropdown-toggle > i,
  .topnavbar .navbar-nav > li.dropdown > a.dropdown-toggle > em,
  .topnavbar .navbar-nav > li.dropdown > a.dropdown-toggle > img,
  .topnavbar .navbar-nav > li.dropdown > a.dropdown-toggle > span { font-size: 18px; }
}
