/**
 * ZaPotente | 2026-10-27 User Dark Contrast Hotfix
 * Scoped exclusively to body.theme-user.layout-sidebar. Loaded after v3.
 * Repairs white sidebar headers, alternating table rows and unreadable dark text.
 * Does not change display, visibility, content, events, sizes or backend behavior.
 */
body.theme-user.layout-sidebar {
  --bg-base: #15161a;
  --bg-surface: #1b1c21;
  --bg-card: #202127;
  --text-main: #f1f1f4;
  --text-muted: #b0b2bf;
  --border-subtle: #343640;
  --border-highlight: #575b69;
  --input-bg: #17181d;
  --table-header-bg: #1b1c21;
  --btn-secondary-bg: #292b32;
  --btn-secondary-text: #f1f1f4;
  --green-accent: #a9b1ff;
  --green-accent-bright: #aeb5ff;
  color: var(--text-main);
  background-color: var(--bg-base);
  color-scheme: dark;
}

/* 1. The real header is INSIDE the left sidebar. A global header rule or
   server-specific customization must never turn only this region white. */
body.theme-user.layout-sidebar > .app-sidebar,
body.theme-user.layout-sidebar > .app-sidebar > header,
body.theme-user.layout-sidebar > .app-sidebar > header .header-actions {
  background-color: #1b1c21 !important;
  color: #f1f1f4 !important;
  border-color: #343640 !important;
}
body.theme-user.layout-sidebar > .app-sidebar > header .brand,
body.theme-user.layout-sidebar > .app-sidebar > header .brand .icon {
  color: #f1f1f4 !important;
}
body.theme-user.layout-sidebar > .app-sidebar > header #user-name-display {
  color: #b0b2bf !important;
}
body.theme-user.layout-sidebar > .app-sidebar > header .credit-badge {
  background: #262830 !important;
  color: #f1f1f4 !important;
  border: 1px solid #3a3e49 !important;
}
body.theme-user.layout-sidebar > .app-sidebar > header .credit-badge :is(span,.icon) {
  color: #f1f1f4 !important;
}
body.theme-user.layout-sidebar > .app-sidebar > header .header-actions .btn,
body.theme-user.layout-sidebar > .app-sidebar > header .header-actions a.btn {
  background-color: #2b2d36 !important;
  color: #e9eaf1 !important;
  border-color: #454853 !important;
  opacity: 1;
}
body.theme-user.layout-sidebar > .app-sidebar > header .header-actions .btn:disabled {
  opacity: .55;
}
body.theme-user.layout-sidebar > .app-sidebar > header .header-actions .btn:hover {
  background-color: #393c47 !important;
}
body.theme-user.layout-sidebar .tabs-nav {
  background-color: var(--bg-surface) !important;
  color: var(--text-main);
}

/* 2. Main KPI numbers and panel headings cannot inherit old light-theme ink. */
body.theme-user.layout-sidebar > main,
body.theme-user.layout-sidebar > main .tab-content,
body.theme-user.layout-sidebar > main .stat-card,
body.theme-user.layout-sidebar > main .panel,
body.theme-user.layout-sidebar > main .form-card {
  color: #f1f1f4;
}
body.theme-user.layout-sidebar > main .stat-card {
  background-color: #202127 !important;
  border-color: #343640 !important;
}
body.theme-user.layout-sidebar > main .stat-card .stat-value,
body.theme-user.layout-sidebar > main :is(#kpi-total-sent,#kpi-delivered,#kpi-rate) {
  color: #f1f1f4 !important;
  -webkit-text-fill-color: #f1f1f4;
  opacity: 1;
}
body.theme-user.layout-sidebar > main #kpi-avail-credits {
  color: #b4bcff !important;
  -webkit-text-fill-color: #b4bcff;
  opacity: 1;
}
body.theme-user.layout-sidebar > main .stat-card .stat-title,
body.theme-user.layout-sidebar > main .stat-card .input-help {
  color: #b0b2bf !important;
}
body.theme-user.layout-sidebar > main .panel-header {
  background-color: transparent !important;
  color: #f1f1f4 !important;
  border-bottom-color: #343640 !important;
  opacity: 1;
}
body.theme-user.layout-sidebar > main .panel-header > :is(span,strong,h2,h3,div) {
  color: #f1f1f4 !important;
}
body.theme-user.layout-sidebar > main .panel-desc {
  color: #b0b2bf !important;
}
body.theme-user.layout-sidebar > main .learn-more-link {
  color: #b4bcff !important;
}

/* 3. One table row must not remain white while its neighbors are dark.
   Apply to dynamically rendered rows, including legacy striped styles. */
body.theme-user.layout-sidebar > main .table-responsive-wrapper,
body.theme-user.layout-sidebar > main .table-responsive-wrapper table,
body.theme-user.layout-sidebar > main table,
body.theme-user.layout-sidebar > main table > thead,
body.theme-user.layout-sidebar > main table > tbody {
  background-color: #202127 !important;
  color: #f1f1f4 !important;
}
body.theme-user.layout-sidebar > main table tr,
body.theme-user.layout-sidebar > main table tbody tr:nth-child(odd),
body.theme-user.layout-sidebar > main table tbody tr:nth-child(even),
body.theme-user.layout-sidebar > main table tbody tr[style] {
  background: #202127 !important;
  color: #f1f1f4 !important;
}
body.theme-user.layout-sidebar > main table tbody tr:nth-child(even) {
  background: #25262d !important;
}
body.theme-user.layout-sidebar > main table tbody tr:hover {
  background: #30323b !important;
}
body.theme-user.layout-sidebar > main table thead tr,
body.theme-user.layout-sidebar > main table thead th {
  background: #1b1c21 !important;
  color: #b6b8c5 !important;
  border-color: #343640 !important;
}
body.theme-user.layout-sidebar > main table tbody td,
body.theme-user.layout-sidebar > main table tbody td > :is(span,div,small,strong,b) {
  color: #f1f1f4 !important;
  border-color: #343640;
}
body.theme-user.layout-sidebar > main table tbody td :is(.badge,.tag-pill),
body.theme-user.layout-sidebar > main table tbody td :is(.badge,.tag-pill) * {
  color: inherit;
}
/* Preserve meaningful red/amber/green semantics for delivery statuses. */
body.theme-user.layout-sidebar > main table tbody td .badge-red {
  color: #ffc0c4 !important;
  background-color: #51262c !important;
}
body.theme-user.layout-sidebar > main table tbody td .badge-amber {
  color: #f3d6a1 !important;
  background-color: #453119 !important;
}
body.theme-user.layout-sidebar > main table tbody td .badge-green {
  color: #93e2bb !important;
  background-color: #17372c !important;
}

/* 4. Buttons and panels; retain original primary-button contrast. */
body.theme-user.layout-sidebar > main .panel,
body.theme-user.layout-sidebar > main .form-card,
body.theme-user.layout-sidebar .modal-card,
body.theme-user.layout-sidebar .auth-card {
  background-color: #202127 !important;
  border-color: #343640 !important;
  color: #f1f1f4 !important;
}
body.theme-user.layout-sidebar > main .btn:not(.btn-primary):not(.btn-danger),
body.theme-user.layout-sidebar > main a.btn:not(.btn-primary):not(.btn-danger) {
  background-color: #2b2d36 !important;
  border-color: #41444f !important;
  color: #f1f1f4 !important;
}
body.theme-user.layout-sidebar > main .btn-primary {
  color: #fff !important;
  background-color: #6978d8 !important;
  border-color: #6978d8 !important;
}
body.theme-user.layout-sidebar > main .btn-danger {
  color: #ffd4d6 !important;
  background-color: #4a2226 !important;
  border-color: #74363c !important;
}
body.theme-user.layout-sidebar :is(input,select,textarea):not([type="checkbox"]):not([type="radio"]) {
  color: #f1f1f4 !important;
  background-color: #17181d !important;
  border-color: #41444f !important;
}
body.theme-user.layout-sidebar :is(input,textarea)::placeholder {
  color: #a5a7b3 !important;
}

/* Keep the established responsive flow; only reinforce text contrast. */
@media (max-width: 980px) {
  body.theme-user.layout-sidebar > .mobile-topbar {
    background-color: #1b1c21 !important;
    color: #f1f1f4 !important;
    border-color: #343640 !important;
  }
  body.theme-user.layout-sidebar .mobile-brand,
  body.theme-user.layout-sidebar .sidebar-toggle {
    color: #f1f1f4 !important;
  }
}
