/* CNI Portal Theme Engine v13 - intentionally lightweight */
html { scroll-behavior:smooth; }
body.cni-portal-theme {
  background: var(--cni-bg) !important;
  color: var(--cni-text) !important;
  font-family: var(--cni-font) !important;
  letter-spacing:.01em;
}
body.cni-portal-theme .content-wrapper,
body.cni-portal-theme .right-side { background:var(--cni-bg) !important; }
body.cni-portal-theme .content { padding:calc(16px * var(--cni-density)) !important; }
body.cni-portal-theme .content-header h1 { color:var(--cni-text); font-weight:800; letter-spacing:-.02em; }
body.cni-portal-theme .content-header small,
body.cni-portal-theme .breadcrumb,
body.cni-portal-theme .text-muted { color:var(--cni-muted) !important; }

/* AdminLTE shell */
body.cni-portal-theme .main-header .navbar {
  background:linear-gradient(100deg,var(--cni-header),var(--cni-secondary)) !important;
  box-shadow:0 8px 28px rgba(20,55,95,.16);
}
body.cni-portal-theme .main-header .logo {
  background:linear-gradient(135deg,var(--cni-primary),var(--cni-secondary)) !important;
  color:#fff !important;
  font-weight:800;
}
body.cni-portal-theme .main-sidebar,
body.cni-portal-theme .left-side { background:var(--cni-sidebar) !important; }
body.cni-portal-theme .sidebar-menu>li.header {
  color:rgba(255,255,255,.62) !important;
  background:rgba(0,0,0,.08) !important;
  font-size:10px;
  font-weight:800;
  letter-spacing:.12em;
}
body.cni-portal-theme .sidebar a,
body.cni-portal-theme .sidebar-menu>li>a { color:rgba(255,255,255,.9) !important; }
body.cni-portal-theme .sidebar-menu>li:hover>a,
body.cni-portal-theme .sidebar-menu>li.active>a,
body.cni-portal-theme .sidebar-menu>li.menu-open>a {
  background:rgba(255,255,255,.12) !important;
  border-left-color:var(--cni-accent) !important;
  color:#fff !important;
}
body.cni-portal-theme .treeview-menu { background:rgba(0,0,0,.12) !important; }
body.cni-portal-theme .treeview-menu>li>a { color:rgba(255,255,255,.78) !important; }
body.cni-portal-theme .treeview-menu>li.active>a,
body.cni-portal-theme .treeview-menu>li>a:hover { color:#fff !important; background:rgba(255,255,255,.08) !important; }
body.cni-portal-theme .user-panel { margin:10px; padding:12px !important; background:rgba(255,255,255,.09); border-radius:14px; }
body.cni-portal-theme .user-panel>.info>p { color:#fff; font-weight:700; }

/* Cards, boxes, forms */
body.cni-portal-theme .box,
body.cni-portal-theme .info-box,
body.cni-portal-theme .small-box,
body.cni-portal-theme .panel,
body.cni-portal-theme .card,
body.cni-portal-theme .card-product,
body.cni-portal-theme .card-detail,
body.cni-portal-theme .card-customer,
body.cni-portal-theme .modal-content,
body.cni-portal-theme .stat-card-new {
  background:var(--cni-surface) !important;
  border:1px solid rgba(114,139,166,.16) !important;
  border-radius:var(--cni-radius) !important;
  box-shadow:0 12px 34px rgba(36,72,110,.08) !important;
}
body.cni-portal-theme .box { border-top:0 !important; overflow:hidden; }
body.cni-portal-theme .box-header { padding:18px 20px; border-bottom:1px solid rgba(114,139,166,.12); }
body.cni-portal-theme .box-title,
body.cni-portal-theme .modal-title,
body.cni-portal-theme h1,body.cni-portal-theme h2,body.cni-portal-theme h3,
body.cni-portal-theme h4,body.cni-portal-theme h5 { color:var(--cni-text); }
body.cni-portal-theme .form-control,
body.cni-portal-theme .select2-container--default .select2-selection--single,
body.cni-portal-theme .select2-container--default .select2-selection--multiple {
  min-height:42px;
  border-radius:12px !important;
  border:1px solid rgba(112,132,155,.28) !important;
  background:var(--cni-surface) !important;
  color:var(--cni-text) !important;
  box-shadow:none !important;
}
body.cni-portal-theme .form-control:focus { border-color:var(--cni-primary) !important; box-shadow:0 0 0 3px color-mix(in srgb,var(--cni-primary) 15%,transparent) !important; }
body.cni-portal-theme label.control-title,
body.cni-portal-theme .control-label { color:var(--cni-text) !important; font-weight:700 !important; }

/* Buttons */
body.cni-portal-theme .btn-primary,
body.cni-portal-theme .btn-success,
body.cni-portal-theme .bg-theme {
  background:linear-gradient(135deg,var(--cni-primary),var(--cni-secondary)) !important;
  border-color:transparent !important;
  color:#fff !important;
}
body.cni-portal-theme .btn { border-radius:11px; font-weight:700; transition:transform .18s ease,box-shadow .18s ease; }
body.cni-portal-theme .btn:hover { transform:translateY(-1px); box-shadow:0 8px 18px rgba(28,82,135,.16); }
body.cni-portal-theme .btn-warning { background:var(--cni-accent) !important; border-color:var(--cni-accent) !important; color:#172033 !important; }

/* Tables */
body.cni-portal-theme .table { background:var(--cni-surface) !important; color:var(--cni-text) !important; border-radius:14px !important; overflow:hidden; }
body.cni-portal-theme .table>thead>tr>th,
body.cni-portal-theme .table>tfoot>tr>th {
  background:linear-gradient(110deg,var(--cni-primary),var(--cni-secondary)) !important;
  color:#fff !important;
  border-color:transparent !important;
  white-space:nowrap;
}
body.cni-portal-theme .table>tbody>tr>td { color:var(--cni-text) !important; border-color:rgba(114,139,166,.12) !important; }
body.cni-portal-theme .table>tbody>tr:nth-child(even) { background:rgba(125,157,190,.045) !important; }
body.cni-portal-theme .table>tbody>tr:hover { background:color-mix(in srgb,var(--cni-primary) 6%,var(--cni-surface)) !important; }

/* Member portal */
body.cni-portal-theme.member-theme .sidebar { background:linear-gradient(160deg,var(--cni-sidebar),var(--cni-primary)) !important; }
body.cni-portal-theme.member-theme .header,
body.cni-portal-theme.member-theme header.header { background:var(--cni-surface) !important; box-shadow:0 8px 24px rgba(33,66,105,.07); }
body.cni-portal-theme.member-theme .footer {
  background:color-mix(in srgb,var(--cni-surface) 94%,transparent) !important;
  border-top:1px solid rgba(114,139,166,.14);
  box-shadow:0 -8px 30px rgba(30,68,110,.08);
}
body.cni-portal-theme.member-theme .footer .nav-link.active,
body.cni-portal-theme.member-theme .footer .nav-link:hover { color:var(--cni-primary) !important; }
body.cni-portal-theme.member-theme .sidebar-profile-card { border-radius:var(--cni-radius) !important; }
body.cni-portal-theme.member-theme .nav-pills .nav-link { border-radius:12px; }
body.cni-portal-theme.member-theme .nav-pills .nav-link.active { background:rgba(255,255,255,.13) !important; }
body.cni-portal-theme.member-theme .stat-icon-wrapper.blue,
body.cni-portal-theme.member-theme .stat-icon-wrapper.indigo,
body.cni-portal-theme.member-theme .stat-icon-wrapper.cyan { background:linear-gradient(135deg,var(--cni-primary),var(--cni-secondary)) !important; }
body.cni-portal-theme.member-theme .hero-profile-card { border-radius:calc(var(--cni-radius) + 8px) !important; border-color:color-mix(in srgb,var(--cni-accent) 55%,transparent) !important; }

/* Login pages */
body.cni-login-theme {
  --primary-red:var(--cni-primary);
  --cni-maroon-main:var(--cni-primary);
  --cni-maroon:var(--cni-primary);
  --cni-maroon-dark:var(--cni-sidebar);
  --dark-black:var(--cni-sidebar);
  --cni-black:var(--cni-sidebar);
  --gold-accent:var(--cni-accent);
  --cni-gold:var(--cni-accent);
  --gold-hover:var(--cni-secondary);
}
body.cni-login-theme .login-side-info,
body.cni-login-theme .logo-section,
body.cni-login-theme .login-visual { background:linear-gradient(145deg,var(--cni-sidebar),var(--cni-primary),var(--cni-secondary)) !important; }
body.cni-login-theme .btn-bca,
body.cni-login-theme .btn-login,
body.cni-login-theme button[type="submit"] { background:linear-gradient(135deg,var(--cni-primary),var(--cni-secondary)) !important; color:#fff !important; border-color:transparent !important; }
body.cni-login-theme .form-header h3,
body.cni-login-theme .form-container h2,
body.cni-login-theme .header-title h3 { color:var(--cni-primary) !important; }

/* Mobile */
@media (max-width:767px){
  body.cni-portal-theme .content { padding:12px !important; }
  body.cni-portal-theme .content-header { padding:12px 14px 0; }
  body.cni-portal-theme .box-header { padding:14px 15px; }
  body.cni-portal-theme .table-responsive { border:0 !important; border-radius:14px; }
  body.cni-portal-theme .main-header .logo { display:none; }
  body.cni-portal-theme .main-header .navbar { margin-left:0 !important; }
}

/* =========================================================
   CNI Portal Theme Engine v14 — Contrast + ERP/MLM Dashboard
   ========================================================= */
body.cni-portal-theme {
  --cni-border: color-mix(in srgb,var(--cni-text) 12%,transparent);
  --cni-soft: color-mix(in srgb,var(--cni-primary) 7%,var(--cni-surface));
  --cni-soft-2: color-mix(in srgb,var(--cni-secondary) 9%,var(--cni-surface));
  --cni-shadow: 0 14px 34px rgba(15,23,42,.08);
  background:var(--cni-bg)!important;
  color:var(--cni-text)!important;
}
body.cni-portal-theme a { color:var(--cni-primary); }
body.cni-portal-theme p,
body.cni-portal-theme span,
body.cni-portal-theme td,
body.cni-portal-theme label,
body.cni-portal-theme li { text-shadow:none; }
body.cni-portal-theme .text-dark { color:var(--cni-text)!important; }
body.cni-portal-theme .text-muted,
body.cni-portal-theme .text-gray,
body.cni-portal-theme small { color:var(--cni-muted)!important; }
body.cni-portal-theme .text-primary { color:var(--cni-primary)!important; }
body.cni-portal-theme .text-success { color:#07875d!important; }
body.cni-portal-theme .text-danger { color:#c62828!important; }
body.cni-portal-theme .text-warning { color:#9a6700!important; }

/* Dynamic foreground colors: never assume white is readable. */
body.cni-portal-theme .bg-theme,
body.cni-portal-theme .btn-primary,
body.cni-portal-theme .btn-success,
body.cni-portal-theme .btn-default {
  color:var(--cni-on-primary)!important;
}
body.cni-portal-theme .bg-theme *,
body.cni-portal-theme .btn-primary *,
body.cni-portal-theme .btn-success *,
body.cni-portal-theme .btn-default * { color:inherit!important; }
body.cni-portal-theme .btn-warning { color:var(--cni-on-accent)!important; }
body.cni-portal-theme .main-header .navbar,
body.cni-portal-theme .main-header .navbar a,
body.cni-portal-theme .main-header .navbar i { color:var(--cni-on-header)!important; }
body.cni-portal-theme .main-header .logo,
body.cni-portal-theme .main-header .logo * { color:var(--cni-on-primary)!important; }
body.cni-portal-theme .main-sidebar,
body.cni-portal-theme .main-sidebar a,
body.cni-portal-theme .main-sidebar i,
body.cni-portal-theme .sidebar,
body.cni-portal-theme .sidebar a,
body.cni-portal-theme .sidebar i { color:var(--cni-on-sidebar)!important; }
body.cni-portal-theme .sidebar-menu>li.header { color:color-mix(in srgb,var(--cni-on-sidebar) 68%,transparent)!important; }
body.cni-portal-theme .treeview-menu>li>a { color:color-mix(in srgb,var(--cni-on-sidebar) 80%,transparent)!important; }
body.cni-portal-theme .treeview-menu>li.active>a,
body.cni-portal-theme .treeview-menu>li>a:hover { color:var(--cni-on-sidebar)!important; }

/* Member header is a surface, not a colored banner. */
body.cni-portal-theme.member-theme header.header,
body.cni-portal-theme.member-theme .header.position-fixed {
  background:color-mix(in srgb,var(--cni-surface) 96%,transparent)!important;
  border-bottom:1px solid var(--cni-border)!important;
  color:var(--cni-text)!important;
  backdrop-filter:blur(16px);
}
body.cni-portal-theme.member-theme header.header h1,
body.cni-portal-theme.member-theme header.header h2,
body.cni-portal-theme.member-theme header.header h3,
body.cni-portal-theme.member-theme header.header h4,
body.cni-portal-theme.member-theme header.header h5,
body.cni-portal-theme.member-theme header.header h6,
body.cni-portal-theme.member-theme header.header a,
body.cni-portal-theme.member-theme header.header i,
body.cni-portal-theme.member-theme header.header .text-light,
body.cni-portal-theme.member-theme header.header .text-white { color:var(--cni-text)!important; }
body.cni-portal-theme.member-theme header.header .btn-transparent:hover { background:var(--cni-soft)!important; }

/* Surface content must never inherit white utility text from legacy templates. */
body.cni-portal-theme .card:not(.hero-profile-card):not(.replika-banner):not(.sidebar-profile-card):not(.bg-theme) .text-white,
body.cni-portal-theme .card:not(.hero-profile-card):not(.replika-banner):not(.sidebar-profile-card):not(.bg-theme) .text-light,
body.cni-portal-theme .box .text-white,
body.cni-portal-theme .panel .text-white { color:var(--cni-text)!important; }
body.cni-portal-theme .card:not(.hero-profile-card):not(.replika-banner):not(.sidebar-profile-card):not(.bg-theme) .text-white-50 { color:var(--cni-muted)!important; }

/* Modern application shell */
body.cni-portal-theme .content-wrapper { min-height:100vh; }
body.cni-portal-theme .content-header {
  padding:22px 24px 8px!important;
}
body.cni-portal-theme .content-header h1 {
  font-size:clamp(22px,2vw,30px);
  font-weight:800;
}
body.cni-portal-theme .box,
body.cni-portal-theme .card,
body.cni-portal-theme .panel,
body.cni-portal-theme .info-box,
body.cni-portal-theme .small-box {
  border:1px solid var(--cni-border)!important;
  box-shadow:var(--cni-shadow)!important;
  overflow:hidden;
}
body.cni-portal-theme .box-header,
body.cni-portal-theme .card-header,
body.cni-portal-theme .panel-heading { background:var(--cni-surface)!important; color:var(--cni-text)!important; }
body.cni-portal-theme .box-body,
body.cni-portal-theme .card-body,
body.cni-portal-theme .panel-body { color:var(--cni-text)!important; }

/* Admin/Stokis KPI cards: neutral surfaces with readable content. */
body.cni-portal-theme.admin-theme .small-box,
body.cni-portal-theme.stokis-theme .small-box {
  background:linear-gradient(145deg,var(--cni-surface),var(--cni-soft))!important;
  color:var(--cni-text)!important;
  border-left:4px solid var(--cni-primary)!important;
  min-height:128px;
}
body.cni-portal-theme.admin-theme .small-box .inner h3,
body.cni-portal-theme.admin-theme .small-box .inner h4,
body.cni-portal-theme.admin-theme .small-box .inner p,
body.cni-portal-theme.stokis-theme .small-box .inner h3,
body.cni-portal-theme.stokis-theme .small-box .inner h4,
body.cni-portal-theme.stokis-theme .small-box .inner p { color:var(--cni-text)!important; position:relative; z-index:2; }
body.cni-portal-theme.admin-theme .small-box .icon,
body.cni-portal-theme.stokis-theme .small-box .icon { color:color-mix(in srgb,var(--cni-primary) 18%,transparent)!important; }
body.cni-portal-theme.admin-theme .small-box .small-box-footer,
body.cni-portal-theme.stokis-theme .small-box .small-box-footer {
  background:color-mix(in srgb,var(--cni-primary) 10%,var(--cni-surface))!important;
  color:var(--cni-primary)!important;
  font-weight:800;
}

/* ERP side navigation: denser grouping but generous click targets. */
body.cni-portal-theme .sidebar-menu>li>a {
  min-height:46px;
  display:flex;
  align-items:center;
  gap:4px;
  padding:11px 14px!important;
  border-radius:10px;
  margin:2px 8px;
}
body.cni-portal-theme .sidebar-menu>li>a>i:first-child { width:24px; text-align:center; font-size:15px; }
body.cni-portal-theme .sidebar-menu>li.header { margin-top:12px; padding:11px 16px 7px!important; }
body.cni-portal-theme .treeview-menu { margin:0 8px 6px!important; border-radius:10px; padding:5px 0!important; }
body.cni-portal-theme .treeview-menu>li>a { padding:8px 12px 8px 34px!important; border-radius:8px; }

/* Forms and tables for office users */
body.cni-portal-theme .form-control,
body.cni-portal-theme input,
body.cni-portal-theme select,
body.cni-portal-theme textarea { color:var(--cni-text)!important; }
body.cni-portal-theme .form-control::placeholder,
body.cni-portal-theme input::placeholder,
body.cni-portal-theme textarea::placeholder { color:color-mix(in srgb,var(--cni-muted) 78%,transparent)!important; opacity:1; }
body.cni-portal-theme .table-responsive { background:var(--cni-surface); border-radius:14px; }
body.cni-portal-theme .table>tbody>tr>td a:not(.btn) { color:var(--cni-primary)!important; font-weight:650; }
body.cni-portal-theme .dataTables_wrapper .dataTables_info,
body.cni-portal-theme .dataTables_wrapper .dataTables_length,
body.cni-portal-theme .dataTables_wrapper .dataTables_filter,
body.cni-portal-theme .dataTables_wrapper label { color:var(--cni-text)!important; }

/* Member business dashboard */
body.cni-portal-theme.member-theme .main-container { max-width:1240px; }
body.cni-portal-theme.member-theme .hero-profile-card {
  background:linear-gradient(125deg,var(--cni-primary),var(--cni-secondary))!important;
  color:var(--cni-on-primary)!important;
  border:0!important;
  box-shadow:0 22px 44px color-mix(in srgb,var(--cni-primary) 24%,transparent)!important;
}
body.cni-portal-theme.member-theme .hero-profile-card,
body.cni-portal-theme.member-theme .hero-profile-card * { color:var(--cni-on-primary)!important; }
body.cni-portal-theme.member-theme .hero-profile-card .text-warning { color:var(--cni-accent)!important; }
body.cni-portal-theme.member-theme .hero-quick-stat {
  background:color-mix(in srgb,var(--cni-surface) 18%,transparent)!important;
  border:1px solid color-mix(in srgb,var(--cni-on-primary) 25%,transparent)!important;
}
body.cni-portal-theme.member-theme .stat-card-new {
  background:var(--cni-surface)!important;
  border:1px solid var(--cni-border)!important;
  box-shadow:0 12px 28px rgba(15,23,42,.07)!important;
}
body.cni-portal-theme.member-theme .stat-card-new:hover { transform:translateY(-4px); }
body.cni-portal-theme.member-theme .stat-label-new,
body.cni-portal-theme.member-theme .stat-dual-label { color:var(--cni-muted)!important; }
body.cni-portal-theme.member-theme .stat-value-new,
body.cni-portal-theme.member-theme .stat-dual-value { color:var(--cni-text)!important; }
body.cni-portal-theme.member-theme .stat-badge {
  background:var(--cni-soft)!important;
  color:var(--cni-primary)!important;
  border:1px solid color-mix(in srgb,var(--cni-primary) 14%,transparent)!important;
}
body.cni-portal-theme.member-theme .replika-banner {
  background:linear-gradient(120deg,var(--cni-sidebar),var(--cni-primary))!important;
  color:var(--cni-on-sidebar)!important;
  border:0!important;
}
body.cni-portal-theme.member-theme .replika-banner,
body.cni-portal-theme.member-theme .replika-banner * { color:var(--cni-on-sidebar)!important; }
body.cni-portal-theme.member-theme .replika-banner strong { color:var(--cni-accent)!important; }
body.cni-portal-theme.member-theme .replika-banner .rb-btn {
  background:var(--cni-accent)!important;
  color:var(--cni-on-accent)!important;
}

/* Navigation footer */
body.cni-portal-theme.member-theme .footer .nav-link,
body.cni-portal-theme.member-theme .footer .nav-link i,
body.cni-portal-theme.member-theme .footer .nav-link span { color:var(--cni-muted)!important; }
body.cni-portal-theme.member-theme .footer .nav-link.active,
body.cni-portal-theme.member-theme .footer .nav-link.active i,
body.cni-portal-theme.member-theme .footer .nav-link.active span { color:var(--cni-primary)!important; }

/* Operational chips */
.cni-kpi-strip { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:12px; margin-bottom:20px; }
.cni-kpi-card { background:var(--cni-surface); border:1px solid var(--cni-border); border-radius:var(--cni-radius); padding:16px; box-shadow:var(--cni-shadow); }
.cni-kpi-card small { display:block; font-weight:800; letter-spacing:.04em; text-transform:uppercase; color:var(--cni-muted)!important; }
.cni-kpi-card strong { display:block; margin-top:5px; font-size:22px; color:var(--cni-text); }
.cni-kpi-card i { color:var(--cni-primary); margin-right:6px; }
.cni-quick-actions { display:grid; grid-template-columns:repeat(auto-fit,minmax(150px,1fr)); gap:10px; }
.cni-quick-actions a { display:flex; align-items:center; gap:10px; min-height:54px; padding:12px 14px; background:var(--cni-surface); border:1px solid var(--cni-border); border-radius:14px; color:var(--cni-text)!important; font-weight:800; text-decoration:none; }
.cni-quick-actions a:hover { border-color:var(--cni-primary); background:var(--cni-soft); transform:translateY(-1px); }
.cni-quick-actions i { width:28px; height:28px; display:grid; place-items:center; border-radius:9px; background:var(--cni-soft); color:var(--cni-primary)!important; }

@media(max-width:991px){ .cni-kpi-strip{grid-template-columns:repeat(2,minmax(0,1fr));} }
@media(max-width:575px){
  .cni-kpi-strip{grid-template-columns:1fr 1fr;gap:8px;}
  .cni-kpi-card{padding:12px;border-radius:14px;}
  .cni-kpi-card strong{font-size:17px;}
  body.cni-portal-theme .sidebar-menu>li>a{min-height:48px;}
}
