/* APK Visual Polish 2027
   Final design layer loaded last. Purpose: beautiful consistent colors, readable light/dark,
   stable rounded buttons, and contrast guard for legacy pages. */
:root{
  --apk-font-main:'Nunito','Inter','Plus Jakarta Sans',system-ui,-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif;
  --apk-bg:#f4f8ff;
  --apk-bg-soft:#eef5ff;
  --apk-surface:#ffffff;
  --apk-surface-2:#f8fbff;
  --apk-surface-3:#eef6ff;
  --apk-card:#ffffff;
  --apk-card-2:#fbfdff;
  --apk-line:#d9e6fb;
  --apk-line-strong:#bfd2f2;
  --apk-text:#17233c;
  --apk-heading:#07152f;
  --apk-muted:#5d6f8e;
  --apk-label:#33415f;
  --apk-primary:#2563eb;
  --apk-primary-2:#7c3aed;
  --apk-primary-3:#ec4899;
  --apk-success:#16a34a;
  --apk-danger:#dc2626;
  --apk-warning:#d97706;
  --apk-info:#0284c7;
  --apk-table-head:#edf5ff;
  --apk-table-row:#ffffff;
  --apk-table-row-alt:#f8fbff;
  --apk-table-hover:#eef6ff;
  --apk-shadow:0 20px 55px rgba(37,99,235,.10);
  --apk-shadow-soft:0 12px 30px rgba(15,23,42,.07);
  --apk-radius:22px;
  --apk-radius-sm:14px;
  --apk-pill:999px;
}
html[data-apk-theme="dark"]{
  --apk-bg:#07111f;
  --apk-bg-soft:#0b1728;
  --apk-surface:#0f1b2f;
  --apk-surface-2:#14243b;
  --apk-surface-3:#1a2d49;
  --apk-card:#101d32;
  --apk-card-2:#13243b;
  --apk-line:#2b4165;
  --apk-line-strong:#3b5a88;
  --apk-text:#e8f1ff;
  --apk-heading:#ffffff;
  --apk-muted:#a9bad8;
  --apk-label:#d5e2f6;
  --apk-primary:#6ea8ff;
  --apk-primary-2:#a78bfa;
  --apk-primary-3:#f472b6;
  --apk-success:#34d399;
  --apk-danger:#fb7185;
  --apk-warning:#fbbf24;
  --apk-info:#38bdf8;
  --apk-table-head:#172742;
  --apk-table-row:#0f1c31;
  --apk-table-row-alt:#13243a;
  --apk-table-hover:#1c3150;
  --apk-shadow:0 22px 60px rgba(0,0,0,.34);
  --apk-shadow-soft:0 14px 36px rgba(0,0,0,.26);
}

html,body{
  min-height:100%!important;
  background:var(--apk-bg)!important;
  color:var(--apk-text)!important;
  font-family:var(--apk-font-main)!important;
  font-weight:700!important;
  letter-spacing:0!important;
  -webkit-font-smoothing:antialiased;
  text-rendering:geometricPrecision;
}
body{
  background-image:
    radial-gradient(circle at 9% 12%, rgba(236,72,153,.12), transparent 27%),
    radial-gradient(circle at 92% 8%, rgba(37,99,235,.12), transparent 28%),
    linear-gradient(135deg,var(--apk-bg) 0%, var(--apk-bg-soft) 100%)!important;
}
html[data-apk-theme="dark"] body{
  background-image:
    radial-gradient(circle at 14% 9%, rgba(244,114,182,.18), transparent 25%),
    radial-gradient(circle at 90% 12%, rgba(96,165,250,.18), transparent 26%),
    linear-gradient(135deg,#07111f 0%,#0b1728 48%,#120b20 100%)!important;
}
#app,#main,#main-content,.page-content,.apk-page-content,#main[style],.apk-page-content[style]{
  background:transparent!important;
  color:var(--apk-text)!important;
}

/* Replace old playful/legacy typography with a cleaner production UI feel. */
.text,.neon,.apk-topbar h1,.apk-topbar h2,h1,h2,h3,h4,h5,h6{
  font-family:var(--apk-font-main)!important;
  color:var(--apk-heading)!important;
  -webkit-text-fill-color:var(--apk-heading)!important;
  text-shadow:none!important;
  filter:none!important;
  mix-blend-mode:normal!important;
}
html[data-apk-theme="dark"] .text,
html[data-apk-theme="dark"] .neon,
html[data-apk-theme="dark"] .apk-topbar h1,
html[data-apk-theme="dark"] .apk-topbar h2,
html[data-apk-theme="dark"] h1,
html[data-apk-theme="dark"] h2,
html[data-apk-theme="dark"] h3,
html[data-apk-theme="dark"] h4,
html[data-apk-theme="dark"] h5,
html[data-apk-theme="dark"] h6{
  color:#fff!important;
  -webkit-text-fill-color:#fff!important;
}
.text{background:transparent!important;text-transform:none!important;letter-spacing:0!important;}
.text::before,.gradient,.spotlight{display:none!important;content:none!important;}

/* Cards, topbar, sidebar. */
.sidebar-wrapper,#sidebar,.card,.card-body,.apk-topbar,.apk-user-card,.apk-menu-shell,.apk-panel,.apk-list-panel,.apk-filter-panel,.apk-form-panel,.apk-table-shell,.dataTables_wrapper,.modal-content,.dropdown-menu{
  background:rgba(255,255,255,.88)!important;
  color:var(--apk-text)!important;
  border-color:var(--apk-line)!important;
  box-shadow:var(--apk-shadow-soft)!important;
}
html[data-apk-theme="dark"] .sidebar-wrapper,
html[data-apk-theme="dark"] #sidebar,
html[data-apk-theme="dark"] .card,
html[data-apk-theme="dark"] .card-body,
html[data-apk-theme="dark"] .apk-topbar,
html[data-apk-theme="dark"] .apk-user-card,
html[data-apk-theme="dark"] .apk-menu-shell,
html[data-apk-theme="dark"] .apk-panel,
html[data-apk-theme="dark"] .apk-list-panel,
html[data-apk-theme="dark"] .apk-filter-panel,
html[data-apk-theme="dark"] .apk-form-panel,
html[data-apk-theme="dark"] .apk-table-shell,
html[data-apk-theme="dark"] .dataTables_wrapper,
html[data-apk-theme="dark"] .modal-content,
html[data-apk-theme="dark"] .dropdown-menu{
  background:rgba(15,27,47,.94)!important;
  color:var(--apk-text)!important;
  border-color:var(--apk-line)!important;
  box-shadow:var(--apk-shadow)!important;
}
.apk-topbar{
  border-radius:28px!important;
  border:1px solid var(--apk-line)!important;
  padding:24px 28px!important;
  background-image:linear-gradient(135deg,rgba(255,255,255,.96),rgba(239,246,255,.92),rgba(255,241,248,.78))!important;
}
html[data-apk-theme="dark"] .apk-topbar{
  background-image:linear-gradient(135deg,rgba(15,27,47,.98),rgba(18,36,64,.94),rgba(36,20,52,.72))!important;
}
.apk-pill,.apk-system-badge{
  border-radius:var(--apk-pill)!important;
  background:rgba(236,72,153,.10)!important;
  color:var(--apk-primary-3)!important;
  -webkit-text-fill-color:var(--apk-primary-3)!important;
  border:1px solid rgba(236,72,153,.25)!important;
  font-weight:900!important;
}
html[data-apk-theme="dark"] .apk-pill,html[data-apk-theme="dark"] .apk-system-badge{
  background:rgba(244,114,182,.16)!important;
  border-color:rgba(244,114,182,.34)!important;
}

/* Global text contrast normalization. */
p,span,small,div,li,a,label,.form-label,.form-group label,.text-muted,.dataTables_info,.dataTables_length label,.dataTables_filter label{
  color:inherit;
}
label,.form-label,.form-group label,.control-label{
  color:var(--apk-label)!important;
  -webkit-text-fill-color:var(--apk-label)!important;
  font-weight:900!important;
}
.text-muted,small,.small,.apk-date,.apk-welcome,.apk-topbar p{
  color:var(--apk-muted)!important;
  -webkit-text-fill-color:var(--apk-muted)!important;
}
html[data-apk-theme="light"] .text-white:not(.btn):not(button):not(.badge):not(.apk-action-btn):not(.apk-top-action){
  color:var(--apk-text)!important;
  -webkit-text-fill-color:var(--apk-text)!important;
}
html[data-apk-theme="dark"] .text-dark,html[data-apk-theme="dark"] .text-body,html[data-apk-theme="dark"] .text-black{
  color:var(--apk-text)!important;
  -webkit-text-fill-color:var(--apk-text)!important;
}

/* Form controls. */
input:not([type="checkbox"]):not([type="radio"]),select,textarea,.form-control,.custom-select,.select2-container--default .select2-selection--single,.select2-container--default .select2-selection--multiple{
  background:var(--apk-surface)!important;
  color:var(--apk-text)!important;
  -webkit-text-fill-color:var(--apk-text)!important;
  border:1.5px solid var(--apk-line)!important;
  border-radius:18px!important;
  box-shadow:none!important;
  font-weight:800!important;
}
input::placeholder,textarea::placeholder,.select2-selection__placeholder{
  color:var(--apk-muted)!important;
  -webkit-text-fill-color:var(--apk-muted)!important;
  opacity:1!important;
}
input:focus,select:focus,textarea:focus,.form-control:focus,.select2-container--focus .select2-selection{
  border-color:var(--apk-primary)!important;
  box-shadow:0 0 0 4px rgba(37,99,235,.14)!important;
  outline:0!important;
}
html[data-apk-theme="dark"] input:focus,
html[data-apk-theme="dark"] select:focus,
html[data-apk-theme="dark"] textarea:focus,
html[data-apk-theme="dark"] .form-control:focus,
html[data-apk-theme="dark"] .select2-container--focus .select2-selection{
  box-shadow:0 0 0 4px rgba(110,168,255,.18)!important;
}
select option{background:var(--apk-surface)!important;color:var(--apk-text)!important;}

/* Select2 and datepicker. */
.select2-dropdown,.select2-container--default .select2-results>.select2-results__options,.select2-search--dropdown,.Zebra_DatePicker,.Zebra_DatePicker table{
  background:var(--apk-surface)!important;
  color:var(--apk-text)!important;
  border-color:var(--apk-line)!important;
}
.select2-results__option,.select2-results__option[aria-selected],.Zebra_DatePicker td,.Zebra_DatePicker th{
  background:var(--apk-surface)!important;
  color:var(--apk-text)!important;
  -webkit-text-fill-color:var(--apk-text)!important;
}
.select2-results__option--highlighted,.select2-container--default .select2-results__option--highlighted[aria-selected],.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;
}
.select2-container--default .select2-selection--multiple .select2-selection__choice{
  background:var(--apk-surface-3)!important;
  color:var(--apk-text)!important;
  -webkit-text-fill-color:var(--apk-text)!important;
  border-color:var(--apk-line-strong)!important;
  border-radius:var(--apk-pill)!important;
}

/* Buttons: all rounded, beautiful, high contrast, clickable. */
button,.btn,.button,input[type="submit"],input[type="button"],input[type="reset"],a.btn,a.button,.dt-button,.apk-action-btn,.apk-top-action,.apk-secondary-action,.apk-theme-toggle,[data-apk-theme-toggle],.dataTables_wrapper .dt-buttons .dt-button{
  position:relative!important;
  inset:auto!important;
  z-index:auto!important;
  pointer-events: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;
  width:auto!important;
  border-radius:var(--apk-pill)!important;
  padding:10px 18px!important;
  border:1px solid transparent!important;
  background:linear-gradient(135deg,var(--apk-primary),var(--apk-primary-2))!important;
  color:#fff!important;
  -webkit-text-fill-color:#fff!important;
  box-shadow:0 12px 26px rgba(37,99,235,.20)!important;
  font-family:var(--apk-font-main)!important;
  font-weight:900!important;
  letter-spacing:0!important;
  text-decoration:none!important;
  line-height:1.1!important;
  cursor:pointer!important;
  transform:none!important;
}
button::before,button::after,.btn::before,.btn::after,.button::before,.button::after{display:none!important;content:none!important;}
button:hover,.btn:hover,.button:hover,input[type="submit"]:hover,input[type="button"]:hover,a.btn:hover,.apk-action-btn:hover,.apk-top-action:hover,.dt-button:hover{
  transform:translateY(-1px)!important;
  filter:saturate(1.04) brightness(1.02)!important;
  box-shadow:0 16px 32px rgba(37,99,235,.24)!important;
}
.btn-danger,.delete button,input[value="Delete"],input[value="Reject"],.apk-action-btn--danger{background:linear-gradient(135deg,#dc2626,#f43f5e)!important;color:#fff!important;-webkit-text-fill-color:#fff!important;}
.btn-success,.approve button,.approvex button,.process button,.donememo button,input[value="Approve"],input[value="Done"],input[value="Ready!"],.apk-action-btn--success{background:linear-gradient(135deg,#16a34a,#22c55e)!important;color:#fff!important;-webkit-text-fill-color:#fff!important;}
.detail button,.checks button,.btn-info,.apk-action-btn--info{background:linear-gradient(135deg,#0284c7,#2563eb)!important;color:#fff!important;-webkit-text-fill-color:#fff!important;}
.edit button,.btn-primary{background:linear-gradient(135deg,#2563eb,#7c3aed)!important;color:#fff!important;-webkit-text-fill-color:#fff!important;}
.print button,.apk-action-btn--print{background:linear-gradient(135deg,#0f766e,#06b6d4)!important;color:#fff!important;-webkit-text-fill-color:#fff!important;}
.btn-warning,.apk-action-btn--warning{background:linear-gradient(135deg,#f59e0b,#fbbf24)!important;color:#111827!important;-webkit-text-fill-color:#111827!important;}
button:disabled,.btn:disabled,input:disabled,select:disabled,textarea:disabled{opacity:.62!important;cursor:not-allowed!important;filter:grayscale(.1)!important;}

/* Theme button should look premium and stay readable in both themes. */
.apk-theme-toggle,[data-apk-theme-toggle]{
  background:var(--apk-surface-2)!important;
  color:var(--apk-text)!important;
  -webkit-text-fill-color:var(--apk-text)!important;
  border:1px solid var(--apk-line-strong)!important;
  box-shadow:none!important;
  min-width:118px!important;
}
.apk-theme-toggle .apk-theme-dot,[data-apk-theme-toggle] .apk-theme-dot{width:10px!important;height:10px!important;border-radius:50%!important;background:var(--apk-primary-3)!important;box-shadow:0 0 0 4px rgba(236,72,153,.14)!important;}
html[data-apk-theme="dark"] .apk-theme-toggle,html[data-apk-theme="dark"] [data-apk-theme-toggle]{background:var(--apk-surface-3)!important;border-color:var(--apk-line-strong)!important;color:#fff!important;-webkit-text-fill-color:#fff!important;}

/* Tables: fix white-on-white and black-on-black across DataTables sorting/odd/even cells. */
.table-responsive,.apk-table-shell,.dataTables_wrapper,#table1_wrapper{background:var(--apk-surface)!important;color:var(--apk-text)!important;border-radius:24px!important;}
table,.table,table.table,table.dataTable,.dataTable,.apk-data-table{
  background:var(--apk-surface)!important;
  color:var(--apk-text)!important;
  border-color:var(--apk-line)!important;
  border-collapse:separate!important;
  border-spacing:0!important;
}
table thead,table thead tr,table thead th,.table thead th,table.dataTable thead th,table.dataTable thead td{
  background:var(--apk-table-head)!important;
  color:#1f4f8f!important;
  -webkit-text-fill-color:#1f4f8f!important;
  border-color:var(--apk-line)!important;
  font-weight:1000!important;
  text-transform:uppercase!important;
  letter-spacing:.025em!important;
}
html[data-apk-theme="dark"] table thead,
html[data-apk-theme="dark"] table thead tr,
html[data-apk-theme="dark"] table thead th,
html[data-apk-theme="dark"] .table thead th,
html[data-apk-theme="dark"] table.dataTable thead th,
html[data-apk-theme="dark"] table.dataTable thead td{
  color:#cfe0ff!important;
  -webkit-text-fill-color:#cfe0ff!important;
}
table tbody,table tbody tr,.table tbody tr,table.dataTable tbody tr,table.dataTable.display tbody tr,table.dataTable.stripe tbody tr{
  background:var(--apk-table-row)!important;
  color:var(--apk-text)!important;
}
table tbody tr:nth-child(even),.table-striped tbody tr:nth-of-type(odd),table.dataTable.stripe tbody tr.odd,table.dataTable.display tbody tr.odd{
  background:var(--apk-table-row-alt)!important;
}
table tbody td,.table tbody td,table.dataTable tbody td,table.dataTable.display tbody td,table.dataTable.stripe tbody td,table.dataTable.display tbody tr.odd>.sorting_1,table.dataTable.order-column.stripe tbody tr.odd>.sorting_1,table.dataTable.display tbody tr.even>.sorting_1,table.dataTable.order-column.stripe tbody tr.even>.sorting_1{
  background:inherit!important;
  color:var(--apk-text)!important;
  -webkit-text-fill-color:var(--apk-text)!important;
  border-color:var(--apk-line)!important;
}
table tbody tr:hover,table tbody tr:hover td,.table tbody tr:hover td,table.dataTable tbody tr:hover,table.dataTable tbody tr:hover td,table.dataTable.display tbody tr:hover>.sorting_1{
  background:var(--apk-table-hover)!important;
  color:var(--apk-heading)!important;
  -webkit-text-fill-color:var(--apk-heading)!important;
}
.table a:not(.btn):not(.button),table.dataTable a:not(.btn):not(.button){color:var(--apk-primary)!important;-webkit-text-fill-color:var(--apk-primary)!important;}
.table .text-white,table.dataTable .text-white{color:inherit!important;-webkit-text-fill-color:inherit!important;}

/* DataTables controls and pagination. */
.dataTables_length select,.dataTables_filter input{
  background:var(--apk-surface)!important;
  color:var(--apk-text)!important;
  border:1.5px solid var(--apk-line)!important;
  border-radius:var(--apk-pill)!important;
  min-height:42px!important;
}
.dataTables_paginate,.pagination{display:flex!important;align-items:center!important;gap:8px!important;flex-wrap:wrap!important;margin-top:18px!important;}
.dataTables_paginate .paginate_button,.pagination .page-link{
  border-radius:var(--apk-pill)!important;
  background:var(--apk-surface)!important;
  color:var(--apk-primary)!important;
  -webkit-text-fill-color:var(--apk-primary)!important;
  border:1px solid var(--apk-line-strong)!important;
  min-width:42px!important;
  height:42px!important;
  padding:10px 15px!important;
  box-shadow:none!important;
  font-weight:1000!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;
}
.dataTables_paginate .paginate_button.disabled,.pagination .page-item.disabled .page-link{opacity:.48!important;pointer-events:none!important;}

/* Contrast guard classes set by apk-visual-polish-2027.js. */
.apk-contrast-fix-light{color:#f8fbff!important;-webkit-text-fill-color:#f8fbff!important;}
.apk-contrast-fix-dark{color:#10213d!important;-webkit-text-fill-color:#10213d!important;}
.apk-contrast-bg-light{background:#f8fbff!important;}
.apk-contrast-bg-dark{background:#0f1b2f!important;}

@media(max-width:900px){
  .apk-topbar{padding:20px!important;border-radius:22px!important;}
  .apk-top-actions{width:100%!important;display:flex!important;flex-wrap:wrap!important;gap:10px!important;}
  .apk-top-action,.apk-secondary-action,.apk-theme-toggle{min-width:0!important;flex:1 1 145px!important;}
  .table-responsive,.dataTables_wrapper{overflow-x:auto!important;}
  table.dataTable{min-width:780px!important;}
}

/* APK 2027 reload guard notices */
.apk-inline-notice{
  margin:10px 0 14px;
  padding:12px 14px;
  border-radius:16px;
  border:1px solid rgba(245,158,11,.28);
  background:#fffbeb;
  color:#78350f;
  font-weight:800;
  line-height:1.45;
  box-shadow:0 10px 26px rgba(15,23,42,.06);
}
html[data-apk-theme="dark"] .apk-inline-notice{
  background:rgba(251,191,36,.12);
  border-color:rgba(251,191,36,.35);
  color:#fde68a;
}
.apk-inline-notice--info{
  border-color:rgba(37,99,235,.25);
  background:#eff6ff;
  color:#1d4ed8;
}
html[data-apk-theme="dark"] .apk-inline-notice--info{
  background:rgba(37,99,235,.14);
  border-color:rgba(96,165,250,.35);
  color:#bfdbfe;
}
