/* APK Final Safe UI 2027
   One clean layer after all legacy/theme CSS. Fixes action buttons, pagination, modals, Select2, repeat-order, and click targets. */
:root{
  --apk-radius-pill:999px;
  --apk-radius-card:24px;
  --apk-primary:#2563eb;
  --apk-primary-2:#7c3aed;
  --apk-pink:#ec4899;
  --apk-green:#16a34a;
  --apk-red:#dc2626;
  --apk-orange:#f97316;
  --apk-panel:#ffffff;
  --apk-panel-soft:#f8fbff;
  --apk-line:#d9e5f8;
  --apk-text:#13233f;
  --apk-muted:#60708a;
  --apk-shadow:0 14px 36px rgba(15,23,42,.10);
}
html[data-apk-theme="dark"]{
  --apk-panel:#101827;
  --apk-panel-soft:#172036;
  --apk-line:#2d3d5e;
  --apk-text:#edf4ff;
  --apk-muted:#a9b8d0;
  --apk-shadow:0 18px 48px rgba(0,0,0,.32);
}

/* never let old absolute button rules break click targets */
button,.btn,.button,input[type="submit"],input[type="button"],input[type="reset"],a.btn,a.button,.dt-button,.apk-action-btn{
  position:relative!important;left:auto!important;right:auto!important;top:auto!important;bottom:auto!important;float:none!important;inset:auto!important;
  display:inline-flex!important;align-items:center!important;justify-content:center!important;gap:8px!important;
  min-height:42px!important;min-width:42px!important;padding:0 18px!important;border-radius:var(--apk-radius-pill)!important;
  border:1px solid transparent!important;text-decoration:none!important;line-height:1!important;font-weight:900!important;font-size:13px!important;
  cursor:pointer!important;pointer-events:auto!important;z-index:30!important;white-space:nowrap!important;box-shadow:0 10px 22px rgba(37,99,235,.16)!important;
  transform:none!important;opacity:1!important;visibility:visible!important;color:#fff!important;-webkit-text-fill-color:#fff!important;
  background:linear-gradient(135deg,var(--apk-primary),var(--apk-primary-2))!important;
}
button:hover,.btn:hover,.button:hover,input[type="submit"]:hover,input[type="button"]:hover,a.btn:hover,.apk-action-btn:hover{transform:translateY(-1px)!important;filter:brightness(1.04)!important;}
button::before,button::after,.btn::before,.btn::after,.button::before,.button::after{display:none!important;content:none!important;}

.apk-action-cell{min-width:160px!important;width:160px!important;position:relative!important;z-index:20!important;white-space:normal!important;vertical-align:top!important;}
.apk-actions-head{min-width:160px!important;width:160px!important;}
.apk-action-form{display:flex!important;position:relative!important;float:none!important;margin:5px 0!important;padding:0!important;z-index:35!important;pointer-events:auto!important;clear:both!important;}
.apk-action-form .apk-action-btn{width:100%!important;min-height:38px!important;padding:0 14px!important;font-size:12px!important;box-shadow:0 8px 18px rgba(37,99,235,.14)!important;}
.apk-action-btn--danger,.delete button,input[value="Delete"],input[value="Reject"]{background:linear-gradient(135deg,#dc2626,#f43f5e)!important;box-shadow:0 8px 18px rgba(220,38,38,.20)!important;}
.apk-action-btn--success,.approve button,.approvex button,.process button,.donememo button,input[value="Approve"],input[value="Done"],input[value="Ready!"]{background:linear-gradient(135deg,#15803d,#22c55e)!important;box-shadow:0 8px 18px rgba(21,128,61,.20)!important;}
.apk-action-btn--info,.detail button,.checks button{background:linear-gradient(135deg,#0369a1,#2563eb)!important;box-shadow:0 8px 18px rgba(3,105,161,.20)!important;}
.apk-action-btn--print,.print button{background:linear-gradient(135deg,#0f766e,#06b6d4)!important;box-shadow:0 8px 18px rgba(15,118,110,.18)!important;}
.apk-status-pill{display:inline-flex!important;align-items:center!important;justify-content:center!important;border-radius:var(--apk-radius-pill)!important;padding:8px 12px!important;margin:4px 0!important;font-size:12px!important;font-weight:900!important;line-height:1.25!important;border:1px solid var(--apk-line)!important;background:var(--apk-panel-soft)!important;color:var(--apk-text)!important;-webkit-text-fill-color:var(--apk-text)!important;}
.apk-status-pill--success{background:#ecfdf5!important;color:#047857!important;-webkit-text-fill-color:#047857!important;border-color:#bbf7d0!important;}
.apk-status-pill--warning{background:#fff7ed!important;color:#c2410c!important;-webkit-text-fill-color:#c2410c!important;border-color:#fed7aa!important;}
.apk-status-pill--info{background:#eff6ff!important;color:#1d4ed8!important;-webkit-text-fill-color:#1d4ed8!important;border-color:#bfdbfe!important;}

/* keep legacy hidden controls hidden unless server actually renders new action forms */
form.detail:not(.apk-action-form),form.checks:not(.apk-action-form),form.approve:not(.apk-action-form){display:none!important;}

/* Unified tables */
.apk-table-shell,.table-responsive{overflow-x:auto!important;overflow-y:visible!important;background:var(--apk-panel)!important;border:1px solid var(--apk-line)!important;border-radius:24px!important;box-shadow:var(--apk-shadow)!important;padding:10px!important;}
.table,.apk-data-table{width:100%!important;border-collapse:separate!important;border-spacing:0!important;background:var(--apk-panel)!important;color:var(--apk-text)!important;}
.table thead th,.apk-data-table thead th{background:linear-gradient(180deg,var(--apk-panel-soft),var(--apk-panel))!important;color:var(--apk-text)!important;-webkit-text-fill-color:var(--apk-text)!important;border-bottom:1px solid var(--apk-line)!important;font-size:12px!important;font-weight:950!important;text-transform:uppercase!important;white-space:nowrap!important;}
.table td,.table th{color:var(--apk-text)!important;-webkit-text-fill-color:var(--apk-text)!important;border-color:var(--apk-line)!important;vertical-align:top!important;}
.table tbody tr:hover td{background:rgba(37,99,235,.06)!important;}

/* Pagination: single rounded model */
.dataTables_wrapper{position:relative!important;z-index:5!important;padding:12px!important;overflow:visible!important;}
.apk-dt-top,.apk-dt-bottom{display:flex!important;align-items:center!important;justify-content:space-between!important;gap:12px!important;flex-wrap:wrap!important;margin:10px 0!important;}
.dataTables_filter input,.dataTables_length select{min-height:40px!important;border-radius:var(--apk-radius-pill)!important;border:1.5px solid var(--apk-line)!important;background:var(--apk-panel)!important;color:var(--apk-text)!important;-webkit-text-fill-color:var(--apk-text)!important;padding:0 14px!important;box-shadow:none!important;}
.dataTables_paginate{display:flex!important;align-items:center!important;gap:8px!important;overflow-x:auto!important;max-width:100%!important;padding:6px 0!important;}
.dataTables_paginate .paginate_button,.pagination .page-link{position:relative!important;display:inline-flex!important;align-items:center!important;justify-content:center!important;min-width:42px!important;height:42px!important;padding:0 14px!important;border-radius:var(--apk-radius-pill)!important;border:1.5px solid var(--apk-line)!important;background:var(--apk-panel)!important;color:var(--apk-primary)!important;-webkit-text-fill-color:var(--apk-primary)!important;font-weight:950!important;box-shadow:none!important;cursor:pointer!important;text-decoration:none!important;margin:0!important;}
.dataTables_paginate .paginate_button.current,.dataTables_paginate .paginate_button.current:hover,.pagination .page-item.active .page-link{background:linear-gradient(135deg,var(--apk-primary),var(--apk-primary-2))!important;color:#fff!important;-webkit-text-fill-color:#fff!important;border-color:transparent!important;box-shadow:0 10px 22px rgba(37,99,235,.20)!important;}
.dataTables_paginate .paginate_button.disabled{opacity:.46!important;cursor:not-allowed!important;pointer-events:none!important;}

/* Select2 and popup safety */
.select2-container{z-index:60!important;color:var(--apk-text)!important;-webkit-text-fill-color:var(--apk-text)!important;}
.select2-container--open{z-index:260000!important;}
.select2-dropdown{z-index:260000!important;background:var(--apk-panel)!important;color:var(--apk-text)!important;-webkit-text-fill-color:var(--apk-text)!important;border:1px solid var(--apk-line)!important;border-radius:18px!important;box-shadow:0 24px 70px rgba(15,23,42,.24)!important;overflow:hidden!important;}
.select2-results__option,.select2-search__field{color:var(--apk-text)!important;-webkit-text-fill-color:var(--apk-text)!important;background:var(--apk-panel)!important;}
.select2-results__option--highlighted{background:linear-gradient(135deg,var(--apk-primary),var(--apk-primary-2))!important;color:#fff!important;-webkit-text-fill-color:#fff!important;}
.select2-container .select2-selection{border-radius:18px!important;border:1.5px solid var(--apk-line)!important;background:var(--apk-panel)!important;color:var(--apk-text)!important;min-height:44px!important;}
.select2-container--default .select2-selection--single .select2-selection__rendered{line-height:42px!important;color:var(--apk-text)!important;-webkit-text-fill-color:var(--apk-text)!important;}

.apk-entry-modal,.modal{z-index:240000!important;}
.apk-entry-modal.is-open{display:flex!important;pointer-events:auto!important;visibility:visible!important;opacity:1!important;}
.apk-entry-dialog,.modal-dialog,.modal-content{position:relative!important;z-index:240010!important;pointer-events:auto!important;background:var(--apk-panel)!important;color:var(--apk-text)!important;-webkit-text-fill-color:var(--apk-text)!important;}
.Zebra_DatePicker{z-index:270000!important;background:var(--apk-panel)!important;color:var(--apk-text)!important;-webkit-text-fill-color:var(--apk-text)!important;border:1px solid var(--apk-line)!important;border-radius:18px!important;box-shadow:0 24px 70px rgba(15,23,42,.24)!important;}
.Zebra_DatePicker *{color:var(--apk-text)!important;-webkit-text-fill-color:var(--apk-text)!important;}
.Zebra_DatePicker .dp_selected,.Zebra_DatePicker .dp_current{background:linear-gradient(135deg,var(--apk-primary),var(--apk-primary-2))!important;color:#fff!important;-webkit-text-fill-color:#fff!important;}

/* Repeat order must be searchable but never jump to page top. */
select[name="repeat_order"] + .select2-container{display:block!important;width:100%!important;}
select[name="repeat_order"].select2-hidden-accessible{position:absolute!important;width:1px!important;height:1px!important;overflow:hidden!important;clip:rect(0 0 0 0)!important;}

/* Theme toggle fixed */
.apk-theme-toggle,[data-apk-theme-toggle]{background:linear-gradient(135deg,#0f172a,#334155)!important;color:#fff!important;-webkit-text-fill-color:#fff!important;border-color:transparent!important;pointer-events:auto!important;z-index:100!important;}
html[data-apk-theme="dark"] .apk-theme-toggle,html[data-apk-theme="dark"] [data-apk-theme-toggle]{background:linear-gradient(135deg,#f8fafc,#cbd5e1)!important;color:#0f172a!important;-webkit-text-fill-color:#0f172a!important;}

@media(max-width:900px){
  .apk-action-cell,.apk-actions-head{min-width:135px!important;width:135px!important;}
  .apk-action-form .apk-action-btn{min-height:40px!important;font-size:12px!important;padding:0 12px!important;}
  .apk-dt-top,.apk-dt-bottom{align-items:stretch!important;flex-direction:column!important;}
  .dataTables_filter input,.dataTables_length select{width:100%!important;margin-left:0!important;margin-top:6px!important;}
}
