/*
  Invoice Tables Master Skin
  ------------------------------------------------------------
  Source of truth: invoices.php table after the corrected billing skin.
  This file is intentionally loaded last from footer.php so all program tables
  share the same invoice table palette, borders and rounded wrapper.
  It does not change business logic, columns, queries or print layouts.
*/

body.ua-authed:not(.ua-p-print-invoice):not(.ua-p-print-preview):not(.ua-p-vouchers-print):not(.ua-p-settings-print){
  --ua-invtbl-panel: rgba(5,14,27,.62);
  --ua-invtbl-cell: rgba(9,22,39,.58);
  --ua-invtbl-head-1: rgba(17,35,60,.98);
  --ua-invtbl-head-2: rgba(10,24,43,.98);
  --ua-invtbl-border: rgba(145,180,45,.24);
  --ua-invtbl-border-strong: rgba(145,180,45,.28);
  --ua-invtbl-wrap-border: rgba(255,210,92,.12);
  --ua-invtbl-text: #eef7ff;
  --ua-invtbl-head-text: #fff;
  --ua-invtbl-hover: rgba(87,220,255,.075);
  --ua-invtbl-radius: 14px;
}

/* wrappers around tables: Bootstrap, old AdminLTE boxes, and custom security/network wrappers */
body.ua-authed:not(.ua-p-print-invoice):not(.ua-p-print-preview):not(.ua-p-vouchers-print):not(.ua-p-settings-print)
  :where(
    .content-wrapper,
    .content,
    .card,
    .box,
    .panel,
    .ua-page,
    .ua-extracted-page,
    .ua-manual-page,
    .sec-alerts-page,
    .secmon-page,
    .mtw-card,
    .nocx-panel,
    .ua-studio-body
  )
  :where(
    .table-responsive,
    .box-body.table-responsive,
    .card-body.table-responsive,
    .sec-table-wrap,
    .secmon-table-wrap,
    .mtw-table-wrap,
    .nocx-table-wrap
  ):not(.ua-keep-plain){
  border: 1px solid var(--ua-invtbl-wrap-border) !important;
  border-radius: var(--ua-invtbl-radius) !important;
  background: var(--ua-invtbl-panel) !important;
  overflow: auto !important;
  box-shadow: none !important;
}

/* tables themselves, including raw tables generated by JS */
body.ua-authed:not(.ua-p-print-invoice):not(.ua-p-print-preview):not(.ua-p-vouchers-print):not(.ua-p-settings-print)
  :where(
    .content-wrapper,
    .content,
    .card,
    .box,
    .panel,
    .ua-page,
    .ua-extracted-page,
    .ua-manual-page,
    .sec-alerts-page,
    .secmon-page,
    .mtw-card,
    .nocx-panel,
    .ua-studio-body,
    #cwTestResults
  )
  :where(table, table.table, .ua-table, .sec-table, .secmon-table, .mtw-table, .nocx-table):not(.ua-keep-plain){
  width: 100%;
  margin: 0 !important;
  color: var(--ua-invtbl-text) !important;
  background: transparent !important;
  border-color: var(--ua-invtbl-border-strong) !important;
  border-collapse: collapse;
  border-spacing: 0;
  --bs-table-bg: transparent;
  --bs-table-color: var(--ua-invtbl-text);
  --bs-table-border-color: var(--ua-invtbl-border);
  --bs-table-striped-bg: transparent;
  --bs-table-striped-color: var(--ua-invtbl-text);
  --bs-table-hover-bg: var(--ua-invtbl-hover);
  --bs-table-hover-color: var(--ua-invtbl-text);
}

/* cells: exact invoice palette, keeping existing page widths/min-widths */
body.ua-authed:not(.ua-p-print-invoice):not(.ua-p-print-preview):not(.ua-p-vouchers-print):not(.ua-p-settings-print)
  :where(
    .content-wrapper,
    .content,
    .card,
    .box,
    .panel,
    .ua-page,
    .ua-extracted-page,
    .ua-manual-page,
    .sec-alerts-page,
    .secmon-page,
    .mtw-card,
    .nocx-panel,
    .ua-studio-body,
    #cwTestResults
  )
  :where(table, table.table, .ua-table, .sec-table, .secmon-table, .mtw-table, .nocx-table):not(.ua-keep-plain) :where(th,td){
  background: var(--ua-invtbl-cell) !important;
  color: var(--ua-invtbl-text) !important;
  border-color: var(--ua-invtbl-border) !important;
  border-style: solid !important;
  border-width: 1px !important;
  text-align: center !important;
  vertical-align: middle !important;
}

body.ua-authed:not(.ua-p-print-invoice):not(.ua-p-print-preview):not(.ua-p-vouchers-print):not(.ua-p-settings-print)
  :where(
    .content-wrapper,
    .content,
    .card,
    .box,
    .panel,
    .ua-page,
    .ua-extracted-page,
    .ua-manual-page,
    .sec-alerts-page,
    .secmon-page,
    .mtw-card,
    .nocx-panel,
    .ua-studio-body,
    #cwTestResults
  )
  :where(table, table.table, .ua-table, .sec-table, .secmon-table, .mtw-table, .nocx-table):not(.ua-keep-plain) thead :where(th,td){
  background: linear-gradient(180deg, var(--ua-invtbl-head-1), var(--ua-invtbl-head-2)) !important;
  color: var(--ua-invtbl-head-text) !important;
  font-weight: 950 !important;
  white-space: nowrap !important;
  border-color: var(--ua-invtbl-border) !important;
}

body.ua-authed:not(.ua-p-print-invoice):not(.ua-p-print-preview):not(.ua-p-vouchers-print):not(.ua-p-settings-print)
  :where(
    .content-wrapper,
    .content,
    .card,
    .box,
    .panel,
    .ua-page,
    .ua-extracted-page,
    .ua-manual-page,
    .sec-alerts-page,
    .secmon-page,
    .mtw-card,
    .nocx-panel,
    .ua-studio-body,
    #cwTestResults
  )
  :where(table, table.table, .ua-table, .sec-table, .secmon-table, .mtw-table, .nocx-table):not(.ua-keep-plain) tbody tr:hover > *{
  background: var(--ua-invtbl-hover) !important;
}

/* first/last visible cells are clipped by wrapper; keep checkbox size tidy without touching logic */
body.ua-authed:not(.ua-p-print-invoice):not(.ua-p-print-preview):not(.ua-p-vouchers-print):not(.ua-p-settings-print)
  :where(table, table.table, .ua-table, .sec-table, .secmon-table, .mtw-table, .nocx-table):not(.ua-keep-plain) input[type="checkbox"]{
  width: 15px !important;
  height: 15px !important;
  accent-color: #ffd45a !important;
}

/* compact tables keep their compact class, but share invoice borders/colors */
body.ua-authed:not(.ua-p-print-invoice):not(.ua-p-print-preview):not(.ua-p-vouchers-print):not(.ua-p-settings-print)
  table.table-sm:not(.ua-keep-plain) :where(th,td){
  padding-top: .52rem !important;
  padding-bottom: .52rem !important;
}
