/* WINDEV Dealer Portal v1.6.5 — theme/table harmonization and contrast optimization */
:root{
  --ha-table-bg:#151B23;
  --ha-table-head:#111820;
  --ha-table-hover:#1A222C;
  --ha-table-border:rgba(255,255,255,.105);
  --ha-control-bg:#0F151C;
  --ha-control-hover:#1A222C;
  --ha-gold-ink:#F1CF4B;
  --ha-gold-soft:rgba(216,182,52,.12);
  --ha-info-soft:rgba(85,174,255,.11);
  --ha-success-soft:rgba(55,196,106,.11);
  --ha-danger-soft:rgba(220,53,69,.11);
}
[data-bs-theme="light"]{
  --ha-table-bg:#FFFFFF;
  --ha-table-head:#EEF2F6;
  --ha-table-hover:#F7F9FC;
  --ha-table-border:#D9DEE5;
  --ha-control-bg:#FFFFFF;
  --ha-control-hover:#EEF2F6;
  --ha-gold-ink:#765A00;
  --ha-gold-soft:#FFF8DB;
  --ha-info-soft:#EAF5FB;
  --ha-success-soft:#EAF7EF;
  --ha-danger-soft:#FFF0F1;
}

/* Bootstrap table variables + explicit cell backgrounds prevent white-table leakage in dark mode. */
body.homeaid-system .table,
body.homeaid-system table.dataTable,
body.homeaid-system .dataTable,
body.homeaid-system .premium-table{
  --bs-table-color:var(--ha-text)!important;
  --bs-table-bg:var(--ha-table-bg)!important;
  --bs-table-border-color:var(--ha-table-border)!important;
  --bs-table-accent-bg:transparent!important;
  --bs-table-striped-color:var(--ha-text)!important;
  --bs-table-striped-bg:color-mix(in srgb,var(--ha-table-hover) 74%,transparent)!important;
  --bs-table-active-color:var(--ha-text)!important;
  --bs-table-active-bg:var(--ha-table-hover)!important;
  --bs-table-hover-color:var(--ha-text)!important;
  --bs-table-hover-bg:var(--ha-table-hover)!important;
  width:100%;
  color:var(--ha-text)!important;
  background:var(--ha-table-bg)!important;
  border-color:var(--ha-table-border)!important;
}
body.homeaid-system .table > :not(caption) > * > *,
body.homeaid-system table.dataTable > :not(caption) > * > *,
body.homeaid-system .premium-table > :not(caption) > * > *{
  background-color:var(--ha-table-bg)!important;
  color:var(--ha-text)!important;
  border-color:var(--ha-table-border)!important;
  box-shadow:none!important;
}
body.homeaid-system .table thead > tr > *,
body.homeaid-system table.dataTable thead > tr > *,
body.homeaid-system .premium-table thead > tr > *{
  background:var(--ha-table-head)!important;
  color:var(--ha-muted)!important;
  border-bottom-color:var(--ha-border-strong)!important;
  font-weight:800!important;
}
body.homeaid-system .table tbody > tr:hover > *,
body.homeaid-system table.dataTable tbody > tr:hover > *,
body.homeaid-system .premium-table tbody > tr:hover > *{
  background:var(--ha-table-hover)!important;
  color:var(--ha-text)!important;
}
body.homeaid-system .table tbody > tr:last-child > *,
body.homeaid-system table.dataTable tbody > tr:last-child > *{border-bottom-color:transparent!important}
body.homeaid-system .table-responsive,
body.homeaid-system .dealer-table-wrap,
body.homeaid-system .table-wrap{
  background:var(--ha-table-bg)!important;
  border-color:var(--ha-table-border)!important;
}

/* DataTables 3 / compatibility controls follow the active theme. */
body.homeaid-system .dt-container,
body.homeaid-system .dataTables_wrapper,
body.homeaid-system .dt-local-container{color:var(--ha-muted)!important}
body.homeaid-system .dt-container .dt-layout-row,
body.homeaid-system .dataTables_wrapper .row{color:var(--ha-muted)!important}
body.homeaid-system .dt-container label,
body.homeaid-system .dataTables_wrapper label,
body.homeaid-system .dt-local-toolbar,
body.homeaid-system .dt-local-footer,
body.homeaid-system .dt-container .dt-info,
body.homeaid-system .dataTables_info{color:var(--ha-muted)!important}
body.homeaid-system .dt-container .dt-input,
body.homeaid-system .dataTables_wrapper input,
body.homeaid-system .dataTables_wrapper select,
body.homeaid-system .dt-local-container input,
body.homeaid-system .dt-local-container select{
  background:var(--ha-control-bg)!important;
  color:var(--ha-text)!important;
  border:1px solid var(--ha-border-strong)!important;
  box-shadow:none!important;
}
body.homeaid-system .dt-container .dt-input:focus,
body.homeaid-system .dataTables_wrapper input:focus,
body.homeaid-system .dataTables_wrapper select:focus,
body.homeaid-system .dt-local-container input:focus,
body.homeaid-system .dt-local-container select:focus{
  border-color:var(--ha-primary)!important;
  box-shadow:0 0 0 .2rem rgba(216,182,52,.15)!important;
  outline:0!important;
}
body.homeaid-system .dt-container .dt-paging .dt-paging-button,
body.homeaid-system .dataTables_paginate .paginate_button,
body.homeaid-system .dt-local-paging .btn,
body.homeaid-system .pagination .page-link{
  background:var(--ha-control-bg)!important;
  border:1px solid var(--ha-border)!important;
  color:var(--ha-muted)!important;
  box-shadow:none!important;
}
body.homeaid-system .dt-container .dt-paging .dt-paging-button:not(.disabled):hover,
body.homeaid-system .dataTables_paginate .paginate_button:not(.disabled):hover,
body.homeaid-system .dt-local-paging .btn:hover,
body.homeaid-system .pagination .page-link:hover{
  background:var(--ha-control-hover)!important;
  border-color:var(--ha-border-strong)!important;
  color:var(--ha-text)!important;
}
body.homeaid-system .dt-container .dt-paging .dt-paging-button.current,
body.homeaid-system .dataTables_paginate .paginate_button.current,
body.homeaid-system .dt-local-paging .btn.btn-primary,
body.homeaid-system .pagination .page-item.active .page-link{
  background:linear-gradient(135deg,var(--ha-primary),var(--ha-accent))!important;
  border-color:var(--ha-primary)!important;
  color:#17130A!important;
  font-weight:850!important;
}
body.homeaid-system .dt-container .dt-paging .dt-paging-button.disabled,
body.homeaid-system .dataTables_paginate .paginate_button.disabled,
body.homeaid-system .pagination .page-item.disabled .page-link{opacity:.48!important}

/* Responsive DataTables child rows / detail control. */
body.homeaid-system table.dataTable.dtr-inline.collapsed>tbody>tr>td.dtr-control:before,
body.homeaid-system table.dataTable.dtr-inline.collapsed>tbody>tr>th.dtr-control:before{
  color:#17130A!important;
  background:var(--ha-primary)!important;
  border-color:color-mix(in srgb,var(--ha-primary) 80%,#000)!important;
  box-shadow:none!important;
}
body.homeaid-system table.dataTable>tbody>tr.child ul.dtr-details,
body.homeaid-system table.dataTable>tbody>tr.child ul.dtr-details>li{
  color:var(--ha-text)!important;
  border-color:var(--ha-table-border)!important;
}
body.homeaid-system table.dataTable>tbody>tr.child span.dtr-title{color:var(--ha-muted)!important}

/* Table content hierarchy. */
body.homeaid-system .table-primary-text,
body.homeaid-system .dealer-cell-title,
body.homeaid-system .table td strong{color:var(--ha-text)!important}
body.homeaid-system .premium-email,
body.homeaid-system .table a:not(.btn){color:var(--ha-gold-ink)!important;font-weight:700}
body.homeaid-system .table-date,
body.homeaid-system .table td small,
body.homeaid-system .request-ref-line,
body.homeaid-system .dealer-identity small{color:var(--ha-subtle)!important}
body.homeaid-system .request-ref-line b{color:var(--ha-muted)!important}

/* Identifiers stay prominent but harmonized with each theme. */
body.homeaid-system .machine-code-emphasis,
body.homeaid-system .activation-code-emphasis,
body.homeaid-system .machine-inline code,
body.homeaid-system .table-machine-code,
body.homeaid-system .machine-code,
body.homeaid-system .machine-code-large,
body.homeaid-system .machine-emphasis,
body.homeaid-system [data-machine-code],
body.homeaid-system .activation-code{
  background:var(--ha-gold-soft)!important;
  border-color:color-mix(in srgb,var(--ha-primary) 62%,var(--ha-border))!important;
  color:var(--ha-gold-ink)!important;
}
[data-bs-theme="dark"] body.homeaid-system .machine-code-emphasis,
[data-bs-theme="dark"] body.homeaid-system .activation-code-emphasis,
[data-bs-theme="dark"] body.homeaid-system .machine-inline code,
[data-bs-theme="dark"] body.homeaid-system .table-machine-code,
[data-bs-theme="dark"] body.homeaid-system .machine-code,
[data-bs-theme="dark"] body.homeaid-system .activation-code{
  text-shadow:0 0 18px rgba(241,207,75,.06);
}

/* Semantic badges have theme-native surfaces and readable text. */
body.homeaid-system .badge.text-bg-success,
body.homeaid-system .status-success,
body.homeaid-system .access-allowed,
body.homeaid-system .dealer-badge-allowed{background:var(--ha-success-soft)!important;color:#45D17A!important;border-color:rgba(69,209,122,.28)!important}
body.homeaid-system .badge.text-bg-warning,
body.homeaid-system .status-warning{background:var(--ha-gold-soft)!important;color:var(--ha-gold-ink)!important;border-color:rgba(216,182,52,.32)!important}
body.homeaid-system .badge.text-bg-danger,
body.homeaid-system .status-danger,
body.homeaid-system .access-blocked,
body.homeaid-system .dealer-badge-blocked{background:var(--ha-danger-soft)!important;color:#FF7380!important;border-color:rgba(255,115,128,.26)!important}
[data-bs-theme="light"] body.homeaid-system .badge.text-bg-success,
[data-bs-theme="light"] body.homeaid-system .status-success,
[data-bs-theme="light"] body.homeaid-system .access-allowed,
[data-bs-theme="light"] body.homeaid-system .dealer-badge-allowed{color:#17633B!important}
[data-bs-theme="light"] body.homeaid-system .badge.text-bg-danger,
[data-bs-theme="light"] body.homeaid-system .status-danger,
[data-bs-theme="light"] body.homeaid-system .access-blocked,
[data-bs-theme="light"] body.homeaid-system .dealer-badge-blocked{color:#A52834!important}

/* Cards and toolbars: theme-consistent, compact and premium. */
body.homeaid-system .premium-card,
body.homeaid-system .table-card,
body.homeaid-system .dealer-table-card,
body.homeaid-system .installation-table-card{
  background:var(--ha-surface)!important;
  border-color:var(--ha-border)!important;
  box-shadow:var(--ha-shadow)!important;
}
body.homeaid-system .premium-card-head,
body.homeaid-system .dealer-table-toolbar,
body.homeaid-system .dt-local-toolbar,
body.homeaid-system .dt-local-footer{
  background:color-mix(in srgb,var(--ha-surface) 92%,var(--ha-soft))!important;
  border-color:var(--ha-border)!important;
}
[data-bs-theme="dark"] body.homeaid-system .premium-card,
[data-bs-theme="dark"] body.homeaid-system .table-card,
[data-bs-theme="dark"] body.homeaid-system .dealer-table-card,
[data-bs-theme="dark"] body.homeaid-system .installation-table-card{box-shadow:0 12px 28px rgba(0,0,0,.16)!important}
[data-bs-theme="light"] body.homeaid-system .premium-card,
[data-bs-theme="light"] body.homeaid-system .table-card,
[data-bs-theme="light"] body.homeaid-system .dealer-table-card,
[data-bs-theme="light"] body.homeaid-system .installation-table-card{box-shadow:0 7px 22px rgba(31,42,55,.055)!important}

/* Inputs, tabs, filters and secondary controls harmonize with theme. */
body.homeaid-system .form-control,
body.homeaid-system .form-select,
body.homeaid-system input:not([type="checkbox"]):not([type="radio"]),
body.homeaid-system textarea{
  background:var(--ha-input)!important;
  color:var(--ha-text)!important;
  border-color:var(--ha-border-strong)!important;
}
body.homeaid-system .form-control::placeholder,
body.homeaid-system textarea::placeholder{color:var(--ha-subtle)!important;opacity:.82}
body.homeaid-system .nav-tabs{border-color:var(--ha-border)!important}
body.homeaid-system .nav-tabs .nav-link{color:var(--ha-muted)!important;border-color:transparent!important}
body.homeaid-system .nav-tabs .nav-link:hover{color:var(--ha-text)!important;background:var(--ha-soft)!important}
body.homeaid-system .nav-tabs .nav-link.active{color:var(--ha-gold-ink)!important;background:var(--ha-surface)!important;border-color:var(--ha-border) var(--ha-border) var(--ha-surface)!important}
body.homeaid-system .dealer-filter-group{background:var(--ha-soft)!important;border-color:var(--ha-border)!important}
body.homeaid-system .dealer-filter-group .btn-outline-secondary{color:var(--ha-muted)!important}
body.homeaid-system .dealer-filter-group .btn.active,
body.homeaid-system .dealer-filter-group .btn.btn-dark{background:linear-gradient(135deg,var(--ha-primary),var(--ha-accent))!important;color:#17130A!important}

/* Keep dark mode truly dark even when legacy selectors have hard-coded white backgrounds. */
[data-bs-theme="dark"] body.homeaid-system table,
[data-bs-theme="dark"] body.homeaid-system .premium-table,
[data-bs-theme="dark"] body.homeaid-system .dealer-admin-v150 .table,
[data-bs-theme="dark"] body.homeaid-system .request-table-card .table,
[data-bs-theme="dark"] body.homeaid-system .installation-table-card .table,
[data-bs-theme="dark"] body.homeaid-system .rbac-admin-v160 .table,
[data-bs-theme="dark"] body.homeaid-system .product-admin-v160 .table{background:#151B23!important;color:#E6EAF0!important}
[data-bs-theme="dark"] body.homeaid-system table thead th,
[data-bs-theme="dark"] body.homeaid-system .premium-table thead th{background:#111820!important;color:#AAB4BF!important}
[data-bs-theme="dark"] body.homeaid-system table tbody td,
[data-bs-theme="dark"] body.homeaid-system .premium-table tbody td{background:#151B23!important;color:#E6EAF0!important}
[data-bs-theme="dark"] body.homeaid-system table tbody tr:hover td,
[data-bs-theme="dark"] body.homeaid-system .premium-table tbody tr:hover td{background:#1A222C!important;color:#F3F6F9!important}

/* Light mode remains warm-neutral rather than clinical white. */
[data-bs-theme="light"] body.homeaid-system .app-content{
  background:linear-gradient(180deg,#F7F9FC 0,#F5F7FA 210px,#F4F6F9 100%)!important;
}
[data-bs-theme="light"] body.homeaid-system .table-primary-text,
[data-bs-theme="light"] body.homeaid-system .dealer-cell-title{color:#26313C!important}
[data-bs-theme="light"] body.homeaid-system .premium-email,
[data-bs-theme="light"] body.homeaid-system .table a:not(.btn){color:#725800!important}

@media(max-width:767.98px){
  body.homeaid-system .table-card,body.homeaid-system .premium-card{border-radius:.86rem!important}
  body.homeaid-system .dt-container .dt-layout-row{gap:.65rem!important}
}
@media(prefers-reduced-motion:reduce){
  body.homeaid-system *,body.homeaid-system *::before,body.homeaid-system *::after{transition-duration:.01ms!important;animation-duration:.01ms!important;animation-iteration-count:1!important;scroll-behavior:auto!important}
}


/* v1.6.7 — Dealer audit log DataTable */
body.homeaid-system .dealer-audit-card{margin-top:18px;overflow:hidden}
body.homeaid-system .dealer-audit-head{align-items:center}
body.homeaid-system .dealer-audit-table-wrap{padding:0 16px 16px;background:var(--ha-table-bg)!important}
body.homeaid-system .audit-data-table td{vertical-align:middle!important}
body.homeaid-system .audit-time strong,
body.homeaid-system .audit-subject strong{display:block;color:var(--ha-text)!important;font-size:.76rem;font-weight:800}
body.homeaid-system .audit-time small,
body.homeaid-system .audit-subject small{display:block;color:var(--ha-subtle)!important;font-size:.64rem;margin-top:2px}
body.homeaid-system .audit-subject-id{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono",monospace;letter-spacing:.01em}
body.homeaid-system .audit-action-badge{display:inline-flex;align-items:center;gap:.45rem;max-width:100%;padding:.38rem .58rem;border:1px solid color-mix(in srgb,var(--ha-primary) 36%,var(--ha-border));border-radius:.65rem;background:var(--ha-gold-soft);color:var(--ha-gold-ink);font-size:.68rem;font-weight:800;line-height:1.25}
body.homeaid-system .audit-action-badge i{font-size:.65rem;opacity:.85}
body.homeaid-system .audit-actor{display:inline-flex;align-items:center;gap:.42rem;color:var(--ha-muted);font-size:.7rem;font-weight:700}
body.homeaid-system .audit-actor i{color:var(--ha-gold-ink)}
body.homeaid-system .audit-ip{display:inline-block;padding:.3rem .45rem;border:1px solid var(--ha-border);border-radius:.5rem;background:var(--ha-soft);color:var(--ha-muted);font-size:.64rem;white-space:nowrap}
body.homeaid-system .dealer-policy-wide{margin-top:18px}
body.homeaid-system .dealer-policy-wide .policy-list{grid-template-columns:repeat(3,minmax(0,1fr))}
[data-bs-theme="dark"] body.homeaid-system .audit-action-badge{box-shadow:inset 0 0 0 1px rgba(241,207,75,.025)}
@media(max-width:991.98px){body.homeaid-system .dealer-policy-wide .policy-list{grid-template-columns:1fr}}
@media(max-width:767.98px){
 body.homeaid-system .dealer-audit-table-wrap{padding:0 .65rem .8rem}
 body.homeaid-system .audit-action-badge{white-space:normal}
 body.homeaid-system .dealer-audit-card .dt-container .dt-layout-row,
 body.homeaid-system .dealer-audit-card .dt-local-toolbar,
 body.homeaid-system .dealer-audit-card .dt-local-footer{width:100%}
}


/* v1.6.8 — Company & system settings */
.system-settings-page .settings-card .premium-card-body{padding:1.15rem 1.25rem 1.3rem}
.system-settings-page .settings-form .form-label{font-weight:700;color:var(--ha-text)}
.system-settings-page .settings-form .form-text{color:var(--ha-muted);line-height:1.45}
.system-settings-page .settings-form textarea{resize:vertical;min-height:88px}
.settings-save-bar{position:sticky;bottom:.75rem;z-index:20;margin-top:1.25rem;padding:.9rem 1rem;border:1px solid var(--ha-border-strong);border-radius:1rem;background:color-mix(in srgb,var(--ha-surface) 94%,transparent);backdrop-filter:blur(14px);box-shadow:0 12px 30px rgba(0,0,0,.12);display:flex;align-items:center;justify-content:space-between;gap:1rem}
.settings-save-bar>div{display:flex;flex-direction:column;gap:.15rem}.settings-save-bar span{font-size:.82rem;color:var(--ha-muted)}
@media(max-width:575.98px){.settings-save-bar{bottom:.4rem;align-items:stretch;flex-direction:column}.settings-save-bar .btn{width:100%}.system-settings-page .settings-card .premium-card-body{padding:1rem}}

