/* ==========================================================================
   Referral Program - theme layer over AdminLTE 4 / Bootstrap 5.3
   Compact density, brand colours from the logo (UAE green + crimson).
   ========================================================================== */

/* Theme = data-bs-theme (light|dark) + data-accent + data-density + sidebar style,
   chosen in the navbar "Customize" panel and stored in the at_ui cookie. */
:root {
  --brand: #157347;
  --brand-rgb: 21, 115, 71;
  --brand-dark: #0f5434;
  --brand-light: #5fc18f;
  --brand-accent: #b02a37;
  --brand-accent-rgb: 176, 42, 55;
  --bs-primary: var(--brand);
  --bs-primary-rgb: var(--brand-rgb);
  --bs-link-color: #13653f;
  --bs-link-color-rgb: 19, 101, 63;
  --bs-link-hover-color: var(--brand-dark);
  --bs-body-font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --bs-body-font-size: .875rem;
  --bs-border-radius: .5rem;
  --bs-border-radius-sm: .375rem;
  --bs-border-radius-lg: .75rem;
  --app-card-shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .04);
  --bs-indigo-rgb: 102, 16, 242;
  --bs-teal-rgb: 32, 201, 151;
}
:root[data-accent="blue"]    { --brand: #2563eb; --brand-rgb: 37, 99, 235;  --brand-dark: #1d4ed8; --brand-light: #7aa7ff; --bs-link-color: #1d4ed8; --bs-link-color-rgb: 29, 78, 216; }
:root[data-accent="indigo"]  { --brand: #4f46e5; --brand-rgb: 79, 70, 229;  --brand-dark: #4338ca; --brand-light: #a5a1ff; --bs-link-color: #4338ca; --bs-link-color-rgb: 67, 56, 202; }
:root[data-accent="teal"]    { --brand: #0d9488; --brand-rgb: 13, 148, 136; --brand-dark: #0f766e; --brand-light: #5eead4; --bs-link-color: #0f766e; --bs-link-color-rgb: 15, 118, 110; }
:root[data-accent="crimson"] { --brand: #be123c; --brand-rgb: 190, 18, 60;  --brand-dark: #9f1239; --brand-light: #fb7185; --bs-link-color: #9f1239; --bs-link-color-rgb: 159, 18, 57; }
:root[data-accent="orange"]  { --brand: #ea580c; --brand-rgb: 234, 88, 12;  --brand-dark: #c2410c; --brand-light: #fdba74; --bs-link-color: #c2410c; --bs-link-color-rgb: 194, 65, 12; }

[data-bs-theme="dark"] {
  --bs-link-color: var(--brand-light);
  --bs-link-color-rgb: var(--brand-rgb);
  --bs-link-hover-color: var(--brand-light);
  --bs-body-bg: #111827;
  --bs-tertiary-bg: #0b1220;
  --bs-secondary-bg: #1a2233;
  --app-card-shadow: none;
}

.text-brand-accent { color: var(--brand-accent) !important; }
.text-primary { color: var(--brand) !important; }
[data-bs-theme="dark"] .text-primary { color: var(--brand-light) !important; }
.bg-primary, .text-bg-primary { background-color: var(--brand) !important; color: #fff !important; }
.text-bg-indigo { background-color: #6610f2 !important; color: #fff !important; }
.text-bg-teal { background-color: #0f9f76 !important; color: #fff !important; }

.btn-primary {
  --bs-btn-bg: var(--brand); --bs-btn-border-color: var(--brand);
  --bs-btn-hover-bg: var(--brand-dark); --bs-btn-hover-border-color: var(--brand-dark);
  --bs-btn-active-bg: var(--brand-dark); --bs-btn-active-border-color: var(--brand-dark);
  --bs-btn-disabled-bg: var(--brand); --bs-btn-disabled-border-color: var(--brand);
}
.btn-outline-primary {
  --bs-btn-color: var(--brand); --bs-btn-border-color: var(--brand);
  --bs-btn-hover-bg: var(--brand); --bs-btn-hover-border-color: var(--brand);
  --bs-btn-active-bg: var(--brand-dark); --bs-btn-active-border-color: var(--brand-dark);
}
[data-bs-theme="dark"] .btn-outline-primary { --bs-btn-color: var(--brand-light); --bs-btn-border-color: var(--brand-light); }
.btn-accent { --bs-btn-color: #fff; --bs-btn-bg: var(--brand-accent); --bs-btn-border-color: var(--brand-accent); --bs-btn-hover-bg: #8f2230; --bs-btn-hover-color: #fff; --bs-btn-hover-border-color: #8f2230; }
.form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }
.form-control:focus, .form-select:focus { border-color: rgba(var(--brand-rgb), .55); box-shadow: 0 0 0 .2rem rgba(var(--brand-rgb), .15); }
.nav-pills .nav-link.active, .page-item.active .page-link { background-color: var(--brand); border-color: var(--brand); }
.page-link { color: var(--bs-link-color); }
.progress-bar { background-color: var(--brand); }

/* --------------------------------------------------------------- density */
body { font-size: var(--bs-body-font-size); -webkit-font-smoothing: antialiased; }
.app-content-header { padding: .85rem 0 .55rem; }
.app-content { padding-bottom: 1.5rem; }
.app-content-header .breadcrumb { --bs-breadcrumb-divider: '›'; }
.breadcrumb-item a { text-decoration: none; }
.card { border: 1px solid var(--bs-border-color-translucent); box-shadow: var(--app-card-shadow); border-radius: var(--bs-border-radius-lg); }
.card > .card-header { padding: .6rem 1rem; background: transparent; border-bottom: 1px solid var(--bs-border-color-translucent); }
.card-title { font-size: .9rem; font-weight: 600; margin: 0; }
.card-body { padding: 1rem; }
.card-footer { background: transparent; padding: .6rem 1rem; }
.table { --bs-table-bg: transparent; font-size: .8375rem; }
.table > :not(caption) > * > * { padding: .5rem .6rem; vertical-align: middle; }
.table thead th { font-size: .72rem; text-transform: uppercase; letter-spacing: .03em; color: var(--bs-secondary-color); font-weight: 600; white-space: nowrap; border-bottom-width: 1px; }
.table-hover tbody tr { cursor: default; }
.form-label { font-size: .78rem; font-weight: 600; color: var(--bs-secondary-color); margin-bottom: .25rem; }
.form-control, .form-select { font-size: .875rem; }
.form-text { font-size: .75rem; }
.btn { font-weight: 500; }
.btn-sm { font-size: .8rem; }
.min-w-0 { min-width: 0; }
.fs-7 { font-size: .8rem !important; }
.fw-medium { font-weight: 500 !important; }
.cursor-pointer { cursor: pointer; }

/* --------------------------------------------------------------- sidebar */
/* Shared */
.app-sidebar .brand-link .brand-image { padding: 2px; }
.app-sidebar .brand-text { letter-spacing: .01em; }
.app-sidebar .nav-header { font-size: .66rem; letter-spacing: .08em; text-transform: uppercase; padding: .9rem 1rem .3rem; }
.sidebar-menu .nav-link { font-size: .85rem; padding-top: .45rem; padding-bottom: .45rem; border-radius: .5rem; }
.sidebar-menu .nav-treeview .nav-link { font-size: .82rem; padding-top: .35rem; padding-bottom: .35rem; }
.sidebar-menu .nav-treeview .nav-icon { font-size: .85rem; }
.sidebar-menu .nav-badge { float: right; font-size: .66rem; margin-top: .15rem; font-weight: 600; padding: .2em .55em; border-radius: 1rem; }
.sidebar-menu .nav-badge.nb-warn { background: rgba(245, 159, 0, .18); color: #9a6700; }
.sidebar-menu .nav-badge.nb-alert { background: rgba(var(--brand-accent-rgb), .16); color: #b02a37; }
body.sidebar-collapse .sidebar-search { display: none; }
body.sidebar-collapse .app-sidebar:not(:hover) .nav-badge { display: none; }

/* Light (default): follows the page theme, so it is white in light mode and slate in dark mode */
.app-sidebar.sb-light { background: var(--bs-body-bg) !important; border-right: 1px solid var(--bs-border-color-translucent); box-shadow: none !important; }
.app-sidebar.sb-light .sidebar-brand { border-bottom: 1px solid var(--bs-border-color-translucent); }
.app-sidebar.sb-light .brand-text { color: var(--bs-emphasis-color); }
.app-sidebar.sb-light .nav-header { color: var(--bs-secondary-color); opacity: .75; }
.app-sidebar.sb-light .sidebar-menu .nav-link { color: var(--bs-body-color); }
.app-sidebar.sb-light .sidebar-menu .nav-link .nav-icon { color: var(--bs-secondary-color); }
.app-sidebar.sb-light .sidebar-menu .nav-link:hover:not(.active) { background: var(--bs-tertiary-bg); }
.app-sidebar.sb-light .sidebar-menu .nav-link.active { background: rgba(var(--brand-rgb), .1) !important; color: var(--brand) !important; font-weight: 600; box-shadow: inset 3px 0 0 var(--brand); }
.app-sidebar.sb-light .sidebar-menu .nav-link.active .nav-icon { color: var(--brand); }
.app-sidebar.sb-light .sidebar-menu .nav-item.menu-open > .nav-link:not(.active) { color: var(--bs-emphasis-color); font-weight: 600; }
.app-sidebar.sb-light .sidebar-menu .nav-item.menu-open > .nav-link.active { background: transparent !important; box-shadow: none; }
[data-bs-theme="dark"] .app-sidebar.sb-light { background: #0f172a !important; }
[data-bs-theme="dark"] .app-sidebar.sb-light .sidebar-menu .nav-link.active, [data-bs-theme="dark"] .app-sidebar.sb-light .sidebar-menu .nav-link.active .nav-icon { color: var(--brand-light) !important; }
[data-bs-theme="dark"] .sidebar-menu .nav-badge.nb-warn { color: #ffd566; }
[data-bs-theme="dark"] .sidebar-menu .nav-badge.nb-alert { color: #ff8f9a; }

/* Dark: neutral slate */
.app-sidebar.sb-dark { background: #111827 !important; }
/* Brand: deep gradient tinted by the accent colour */
.app-sidebar.sb-brand { background: linear-gradient(180deg, rgba(var(--brand-rgb), .55) 0%, #0f1a15 45%, #0b1210 100%), #0b1210 !important; }
.app-sidebar.sb-dark .sidebar-brand, .app-sidebar.sb-brand .sidebar-brand { border-bottom: 1px solid rgba(255, 255, 255, .08); }
.app-sidebar.sb-dark .brand-text, .app-sidebar.sb-brand .brand-text { color: #fff; }
.app-sidebar.sb-dark .nav-header, .app-sidebar.sb-brand .nav-header { color: rgba(255, 255, 255, .42); }
.app-sidebar.sb-dark .sidebar-menu .nav-link.active, .app-sidebar.sb-brand .sidebar-menu .nav-link.active { background: var(--brand) !important; color: #fff !important; }
.app-sidebar.sb-dark .sidebar-menu .nav-item.menu-open > .nav-link.active, .app-sidebar.sb-brand .sidebar-menu .nav-item.menu-open > .nav-link.active { background: rgba(255, 255, 255, .06) !important; }
.app-sidebar.sb-dark .sidebar-menu .nav-link:hover:not(.active), .app-sidebar.sb-brand .sidebar-menu .nav-link:hover:not(.active) { background: rgba(255, 255, 255, .06); }
.app-sidebar.sb-dark .sidebar-search .form-control, .app-sidebar.sb-brand .sidebar-search .form-control { color: #fff; }
.app-sidebar.sb-dark .nav-badge.nb-warn, .app-sidebar.sb-brand .nav-badge.nb-warn { color: #ffd566; }
.app-sidebar.sb-dark .nav-badge.nb-alert, .app-sidebar.sb-brand .nav-badge.nb-alert { color: #ff9aa4; }
.app-sidebar:not(.sb-light) .text-brand-accent { color: #ff8a95 !important; }

/* ------------------------------------------------------------ customizer */
.ui-choice { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }
.ui-choice button { border: 1.5px solid var(--bs-border-color); background: var(--bs-body-bg); border-radius: .6rem; padding: .55rem .25rem; font-size: .78rem; color: var(--bs-body-color); display: flex; flex-direction: column; align-items: center; gap: .3rem; }
.ui-choice button i { font-size: 1.1rem; }
.ui-choice button.active { border-color: var(--brand); background: rgba(var(--brand-rgb), .08); color: var(--brand); font-weight: 600; }
.ui-swatches { display: flex; gap: .6rem; flex-wrap: wrap; }
.ui-swatches button { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--bs-body-bg); box-shadow: 0 0 0 1.5px var(--bs-border-color); }
.ui-swatches button.active { box-shadow: 0 0 0 2.5px var(--bs-emphasis-color); }
.ui-preview-sb { width: 100%; height: 28px; border-radius: .35rem; display: block; border: 1px solid var(--bs-border-color); }

/* ---------------------------------------------------------------- navbar */
.app-header { border-bottom: 1px solid var(--bs-border-color-translucent); }
.btn-search-trigger { background: var(--bs-tertiary-bg); border: 1px solid var(--bs-border-color); color: var(--bs-secondary-color); min-width: 300px; text-align: left; border-radius: 2rem; padding: .3rem .9rem; white-space: nowrap; display: inline-flex; align-items: center; }
.btn-search-trigger span { flex: 1; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 991.98px) { .btn-search-trigger { min-width: 0; } .btn-search-trigger span, .btn-search-trigger kbd { display: none; } }
.btn-search-trigger:hover { border-color: rgba(var(--brand-rgb), .5); color: var(--bs-body-color); }
.btn-search-trigger kbd { background: var(--bs-secondary-bg); color: var(--bs-secondary-color); font-size: .65rem; border: 1px solid var(--bs-border-color); }
.navbar-badge { position: absolute; top: 4px; right: 2px; font-size: .6rem; padding: 2px 5px; }
.notif-menu { width: 360px; max-width: 94vw; }
.notif-list { max-height: 380px; overflow-y: auto; }
.notif-item { display: flex; gap: .65rem; padding: .6rem .9rem; border-bottom: 1px solid var(--bs-border-color-translucent); text-decoration: none; color: inherit; }
.notif-item:hover { background: var(--bs-tertiary-bg); }
.notif-item.unread { background: rgba(var(--brand-rgb), .06); }
.notif-item .ni-icon { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; flex: 0 0 32px; background: rgba(var(--brand-rgb), .12); color: var(--brand); }
[data-bs-theme="dark"] .notif-item .ni-icon { color: var(--brand-light); }
.notif-item .ni-title { font-weight: 600; font-size: .8rem; }
.notif-item .ni-body { font-size: .78rem; color: var(--bs-secondary-color); }
.notif-item .ni-time { font-size: .7rem; color: var(--bs-secondary-color); }

.avatar-initials { display: inline-grid; place-items: center; border-radius: 50%; color: #fff; font-weight: 600; flex-shrink: 0; letter-spacing: .02em; }

/* ------------------------------------------------------------------ KPIs */
/* Tones: soft tinted icon chips instead of solid colour blocks. */
.tone-primary { --tone: var(--brand); --tone-rgb: var(--brand-rgb); }
.tone-success { --tone: #198754; --tone-rgb: 25, 135, 84; }
.tone-info { --tone: #0891b2; --tone-rgb: 8, 145, 178; }
.tone-warning { --tone: #d97706; --tone-rgb: 217, 119, 6; }
.tone-danger { --tone: #c0392b; --tone-rgb: 192, 57, 43; }
.tone-secondary { --tone: #64748b; --tone-rgb: 100, 116, 139; }
.tone-dark { --tone: #334155; --tone-rgb: 51, 65, 85; }
.tone-indigo { --tone: #6366f1; --tone-rgb: 99, 102, 241; }
.tone-teal { --tone: #0d9488; --tone-rgb: 13, 148, 136; }
[data-bs-theme="dark"] .tone-dark { --tone: #cbd5e1; --tone-rgb: 203, 213, 225; }

.kpi-tile { position: relative; display: flex; flex-direction: column; gap: .35rem; padding: .9rem 1rem; margin-bottom: 1rem;
  background: var(--bs-body-bg); border: 1px solid var(--bs-border-color-translucent); border-radius: var(--bs-border-radius-lg);
  box-shadow: var(--app-card-shadow); color: var(--bs-body-color); text-decoration: none; transition: border-color .15s, box-shadow .15s, transform .15s; min-width: 0; }
a.kpi-tile:hover { border-color: rgba(var(--tone-rgb), .45); box-shadow: 0 6px 16px rgba(16, 24, 40, .07); transform: translateY(-1px); color: var(--bs-body-color); }
.kpi-tile .kpi-head { display: flex; align-items: center; gap: .55rem; min-width: 0; padding-right: 1rem; }
.kpi-tile .kpi-icon { flex: 0 0 32px; width: 32px; height: 32px; border-radius: .6rem; display: grid; place-items: center; font-size: 1rem;
  background: rgba(var(--tone-rgb), .12); color: var(--tone); }
.kpi-tile .kpi-label { font-size: .72rem; font-weight: 600; color: var(--bs-secondary-color); text-transform: uppercase; letter-spacing: .04em; line-height: 1.2;
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.kpi-tile .kpi-value { font-size: clamp(1.2rem, 1.1rem + .6vw, 1.55rem); font-weight: 700; line-height: 1.15; color: var(--bs-emphasis-color); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-tile .kpi-sub { font-size: .75rem; color: var(--bs-secondary-color); line-height: 1.3; }
.kpi-tile .kpi-go { position: absolute; top: .75rem; right: .75rem; font-size: .8rem; color: var(--bs-secondary-color); opacity: .35; transition: opacity .15s, color .15s; }
a.kpi-tile:hover .kpi-go { opacity: 1; color: var(--tone); }
/* Tiles inside a grid row: equal heights, the row carries the spacing instead of each tile. */
.row > [class*="col"] > .kpi-tile, .row > [class*="col"] > .info-box { margin-bottom: 0; height: 100%; }
.row:has(> [class*="col"] > .kpi-tile), .row:has(> [class*="col"] > .info-box) { margin-bottom: 1rem; }

.info-box { min-height: 72px; padding: .7rem; border-radius: var(--bs-border-radius-lg); box-shadow: var(--app-card-shadow); border: 1px solid var(--bs-border-color-translucent); margin-bottom: 1rem; }
.info-box .info-box-icon { width: 44px; height: 44px; font-size: 1.2rem; border-radius: .7rem; box-shadow: none !important; }
/* Soften solid icon squares used by pages (text-bg-*) into tinted chips. */
.info-box .info-box-icon[class*="text-bg-"] { background: rgba(var(--tone-rgb, var(--brand-rgb)), .12) !important; color: var(--tone, var(--brand)) !important; }
.info-box .info-box-icon.text-bg-primary { --tone: var(--brand); --tone-rgb: var(--brand-rgb); }
.info-box .info-box-icon.text-bg-success { --tone: #198754; --tone-rgb: 25, 135, 84; }
.info-box .info-box-icon.text-bg-info { --tone: #0891b2; --tone-rgb: 8, 145, 178; }
.info-box .info-box-icon.text-bg-warning { --tone: #d97706; --tone-rgb: 217, 119, 6; }
.info-box .info-box-icon.text-bg-danger { --tone: #c0392b; --tone-rgb: 192, 57, 43; }
.info-box .info-box-icon.text-bg-secondary { --tone: #64748b; --tone-rgb: 100, 116, 139; }
.info-box .info-box-icon.text-bg-dark { --tone: #334155; --tone-rgb: 51, 65, 85; }
.info-box .info-box-icon.text-bg-indigo { --tone: #6366f1; --tone-rgb: 99, 102, 241; }
.info-box .info-box-icon.text-bg-teal { --tone: #0d9488; --tone-rgb: 13, 148, 136; }
.info-box .info-box-text { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--bs-secondary-color); font-weight: 600; }
.info-box .info-box-number { font-size: 1.2rem; font-weight: 700; }
.stat-link:hover { border-color: rgba(var(--brand-rgb), .45); }

/* Comfortable density (Customize panel): roomier spacing and slightly larger text. */
[data-density="comfortable"] { --bs-body-font-size: .9375rem; }
[data-density="comfortable"] .card-body { padding: 1.25rem; }
[data-density="comfortable"] .card > .card-header { padding: .8rem 1.25rem; }
[data-density="comfortable"] .table > :not(caption) > * > * { padding: .7rem .75rem; }
[data-density="comfortable"] .table { font-size: .875rem; }
[data-density="comfortable"] .form-control, [data-density="comfortable"] .form-select { font-size: .9375rem; padding-top: .45rem; padding-bottom: .45rem; }
[data-density="comfortable"] .sidebar-menu .nav-link { font-size: .9rem; padding-top: .55rem; padding-bottom: .55rem; }
[data-density="comfortable"] .kpi-tile { padding: 1.15rem 1.2rem; }
[data-density="comfortable"] .app-content-header { padding: 1.2rem 0 .8rem; }

/* -------------------------------------------------------- soft badges */
.badge { font-weight: 600; letter-spacing: .01em; }
[class*="badge-soft-"] { border: 1px solid transparent; font-weight: 600; font-size: .72rem; padding: .3em .6em; border-radius: 2rem; }
.badge-soft-primary { background: rgba(var(--brand-rgb), .12); color: var(--brand-dark); }
.badge-soft-secondary { background: rgba(108, 117, 125, .14); color: #5c636a; }
.badge-soft-success { background: rgba(25, 135, 84, .14); color: #146c43; }
.badge-soft-danger { background: rgba(var(--brand-accent-rgb), .12); color: #a02331; }
.badge-soft-warning { background: rgba(255, 193, 7, .2); color: #8a6100; }
.badge-soft-info { background: rgba(13, 202, 240, .16); color: #087990; }
.badge-soft-dark { background: rgba(33, 37, 41, .12); color: #343a40; }
.badge-soft-indigo { background: rgba(102, 16, 242, .12); color: #520dc2; }
.badge-soft-teal { background: rgba(32, 201, 151, .16); color: #13795b; }
[data-bs-theme="dark"] .badge-soft-primary { color: var(--brand-light); }
[data-bs-theme="dark"] .badge-soft-secondary { color: #b6bcc3; }
[data-bs-theme="dark"] .badge-soft-success { color: #75d6a5; }
[data-bs-theme="dark"] .badge-soft-danger { color: #ff8f9a; }
[data-bs-theme="dark"] .badge-soft-warning { color: #ffd566; }
[data-bs-theme="dark"] .badge-soft-info { color: #6fdcf3; }
[data-bs-theme="dark"] .badge-soft-dark { color: #ced4da; background: rgba(255, 255, 255, .1); }
[data-bs-theme="dark"] .badge-soft-indigo { color: #b490ff; }
[data-bs-theme="dark"] .badge-soft-teal { color: #6fe0bd; }

/* ---------------------------------------------------------- empty state */
.empty-state { text-align: center; padding: 2.2rem 1rem; }
.empty-state .empty-icon { width: 64px; height: 64px; border-radius: 50%; margin: 0 auto .75rem; display: grid; place-items: center; font-size: 1.7rem; background: rgba(var(--brand-rgb), .08); color: var(--brand); }

/* -------------------------------------------------------------- timeline */
.tl { list-style: none; padding: 0; margin: 0; position: relative; }
.tl::before { content: ""; position: absolute; left: 13px; top: 4px; bottom: 4px; width: 2px; background: var(--bs-border-color); }
.tl li { position: relative; padding-left: 40px; padding-bottom: 1rem; }
.tl li:last-child { padding-bottom: 0; }
.tl .tl-dot { position: absolute; left: 0; top: 0; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-size: .8rem; box-shadow: 0 0 0 3px var(--bs-body-bg); }
.tl .tl-text { font-size: .85rem; font-weight: 500; }
.tl .tl-meta { font-size: .72rem; color: var(--bs-secondary-color); }

/* ------------------------------------------------------ filters & tables */
.filter-card > .card-header { cursor: pointer; user-select: none; }
.filter-card .card-body .form-label { margin-bottom: .15rem; }
.dt-container .dt-search input, .dt-container .dt-length select { font-size: .8rem; }
.dt-container .dt-info, .dt-container .dt-paging { font-size: .78rem; }
.dt-buttons .btn { font-size: .75rem; }
/* DataTables adds btn-secondary to every export button; keep them as light outline buttons. */
.dt-buttons .btn.btn-secondary { --bs-btn-bg: var(--bs-body-bg); --bs-btn-color: var(--bs-secondary-color); --bs-btn-border-color: var(--bs-border-color);
  --bs-btn-hover-bg: var(--bs-tertiary-bg); --bs-btn-hover-color: var(--bs-emphasis-color); --bs-btn-hover-border-color: var(--bs-border-color);
  --bs-btn-active-bg: var(--bs-secondary-bg); --bs-btn-active-color: var(--bs-emphasis-color); --bs-btn-active-border-color: var(--bs-border-color); }
div.dt-container div.dt-layout-row { margin: .4rem 0; }
table.dataTable > tbody > tr.child ul.dtr-details { width: 100%; }
.table-actions { white-space: nowrap; text-align: right; }
.table-actions .btn { padding: .15rem .45rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .82em; }
.ref-link { font-weight: 600; text-decoration: none; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .82rem; }

/* select2 on BS5 in compact mode */
.select2-container--bootstrap-5 .select2-selection { font-size: .875rem; min-height: calc(1.5em + .75rem + 2px); }
.select2-container--bootstrap-5 .select2-selection--single .select2-selection__rendered { line-height: 1.5; }
.select2-container--bootstrap-5.select2-container--focus .select2-selection, .select2-container--bootstrap-5.select2-container--open .select2-selection { border-color: rgba(var(--brand-rgb), .55); box-shadow: 0 0 0 .2rem rgba(var(--brand-rgb), .15); }
.select2-container--bootstrap-5 .select2-dropdown .select2-results__options .select2-results__option.select2-results__option--highlighted { background-color: var(--brand); color: #fff; }
.select2-container--bootstrap-5 .select2-dropdown .select2-results__options .select2-results__option.select2-results__option--selected { background-color: rgba(var(--brand-rgb), .15); color: inherit; }
.select2-container--bootstrap-5 .select2-selection--multiple .select2-selection__rendered .select2-selection__choice { font-size: .78rem; }
.form-select-sm + .select2-container--bootstrap-5 .select2-selection, .select2-sm .select2-selection { font-size: .8rem; min-height: calc(1.5em + .5rem + 2px); }
[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-selection,
[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-dropdown { background-color: var(--bs-body-bg); color: var(--bs-body-color); border-color: var(--bs-border-color); }
[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-selection--single .select2-selection__rendered { color: var(--bs-body-color); }
[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-dropdown .select2-search .select2-search__field { background: var(--bs-secondary-bg); color: var(--bs-body-color); border-color: var(--bs-border-color); }
.iti { width: 100%; }
.iti__country-list { font-size: .82rem; }
[data-bs-theme="dark"] .iti__dropdown-content { background: var(--bs-body-bg); }
.flatpickr-calendar { font-size: .85rem; }
.flatpickr-day.selected, .flatpickr-day.startRange, .flatpickr-day.endRange { background: var(--brand); border-color: var(--brand); }
[data-bs-theme="dark"] .flatpickr-calendar { background: #1a2233; box-shadow: 0 6px 20px rgba(0,0,0,.5); }
[data-bs-theme="dark"] .flatpickr-day, [data-bs-theme="dark"] .flatpickr-weekday, [data-bs-theme="dark"] .flatpickr-current-month, [data-bs-theme="dark"] .flatpickr-monthDropdown-months { color: #e5e7eb; }

/* SweetAlert2 brand */
.swal2-popup { font-family: var(--bs-body-font-family); border-radius: .9rem; font-size: .9rem; }
.swal2-styled.swal2-confirm { background-color: var(--brand) !important; }
.swal2-styled.swal2-deny { background-color: var(--brand-accent) !important; }
[data-bs-theme="dark"] .swal2-popup { background: #1a2233; color: #e5e7eb; }
[data-bs-theme="dark"] .swal2-input, [data-bs-theme="dark"] .swal2-textarea { background: #111827; color: #e5e7eb; border-color: #374151; }

/* ---------------------------------------------------------------- kanban */
.kanban { display: flex; gap: .75rem; overflow-x: auto; padding-bottom: .5rem; align-items: flex-start; }
.kanban-col { flex: 0 0 260px; background: var(--bs-tertiary-bg); border: 1px solid var(--bs-border-color-translucent); border-radius: .7rem; max-height: 72vh; display: flex; flex-direction: column; }
.kanban-col > header { padding: .55rem .75rem; font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; display: flex; justify-content: space-between; border-bottom: 1px solid var(--bs-border-color-translucent); }
.kanban-col > .kanban-items { padding: .5rem; overflow-y: auto; min-height: 60px; }
.kanban-card { background: var(--bs-body-bg); border: 1px solid var(--bs-border-color-translucent); border-radius: .55rem; padding: .55rem .65rem; margin-bottom: .5rem; font-size: .8rem; box-shadow: var(--app-card-shadow); display: block; color: inherit; text-decoration: none; }
.kanban-card:hover { border-color: rgba(var(--brand-rgb), .5); }
.kanban-card.sla-late { border-left: 3px solid var(--brand-accent); }

/* ----------------------------------------------------- quick access tiles */
.quick-links { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: .6rem; }
.quick-link { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .35rem; padding: .85rem .5rem; border: 1px solid var(--bs-border-color-translucent); border-radius: .7rem; background: var(--bs-body-bg); color: var(--bs-body-color); text-decoration: none; text-align: center; font-size: .78rem; font-weight: 500; transition: all .15s; position: relative; }
.quick-link i { font-size: 1.35rem; color: var(--brand); }
[data-bs-theme="dark"] .quick-link i { color: var(--brand-light); }
.quick-link:hover { border-color: rgba(var(--brand-rgb), .5); transform: translateY(-2px); box-shadow: 0 6px 16px rgba(16, 24, 40, .08); }
.quick-link .badge { position: absolute; top: 6px; right: 6px; }

.task-list .list-group-item { display: flex; align-items: center; gap: .75rem; padding: .6rem .9rem; font-size: .83rem; }
.task-list .task-icon { width: 34px; height: 34px; border-radius: .55rem; display: grid; place-items: center; flex: 0 0 34px; }

.activity-feed { list-style: none; margin: 0; padding: 0; }
.activity-feed li { display: flex; gap: .6rem; padding: .5rem 0; border-bottom: 1px dashed var(--bs-border-color-translucent); font-size: .8rem; }
.activity-feed li:last-child { border-bottom: 0; }
.activity-feed .af-icon { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; flex: 0 0 28px; font-size: .8rem; }

/* ------------------------------------------------------------ profile */
.profile-cover { height: 110px; border-radius: var(--bs-border-radius-lg) var(--bs-border-radius-lg) 0 0; background: linear-gradient(120deg, var(--brand) 0%, #1f8a5a 45%, var(--brand-accent) 140%); }
.profile-avatar { margin-top: -48px; border: 4px solid var(--bs-body-bg); border-radius: 50%; display: inline-block; background: var(--bs-body-bg); }
.avatar-upload { position: relative; display: inline-block; }
.avatar-upload label { position: absolute; right: 0; bottom: 4px; width: 30px; height: 30px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; cursor: pointer; border: 2px solid var(--bs-body-bg); }
.pw-meter { height: 5px; border-radius: 3px; background: var(--bs-border-color); overflow: hidden; margin-top: .35rem; }
.pw-meter > span { display: block; height: 100%; width: 0; transition: width .2s, background .2s; }

/* ------------------------------------------------------------ banners */
.claim-banner { background: linear-gradient(110deg, #fff4cc 0%, #ffe9a8 100%); border: 1px solid #f5d46b; color: #5c4400; border-radius: var(--bs-border-radius-lg); }
[data-bs-theme="dark"] .claim-banner { background: linear-gradient(110deg, #3a2f0c, #4a3a0c); border-color: #6b5412; color: #ffe08a; }
.hero-banner { background: linear-gradient(120deg, var(--brand) 0%, #1c8653 60%, #2a9d67 100%); color: #fff; border-radius: var(--bs-border-radius-lg); }
.checklist .list-group-item { font-size: .83rem; }
.checklist .done { text-decoration: line-through; color: var(--bs-secondary-color); }

/* ------------------------------------------------------ public pages */
.public-body { background: radial-gradient(1200px 500px at 10% -10%, rgba(var(--brand-rgb), .12), transparent 60%), radial-gradient(900px 400px at 110% 10%, rgba(var(--brand-accent-rgb), .08), transparent 60%), var(--bs-tertiary-bg); min-height: 100vh; display: flex; flex-direction: column; }
.public-topbar { background: rgba(var(--bs-body-bg-rgb), .8); backdrop-filter: blur(6px); border-bottom: 1px solid var(--bs-border-color-translucent); position: sticky; top: 0; z-index: 10; }
.public-main { flex: 1; }
.auth-card { max-width: 420px; margin: 3rem auto; }
.auth-card .card { border-radius: 1rem; }
.wizard-steps { display: flex; gap: .35rem; margin-bottom: 1rem; }
.wizard-steps .ws { flex: 1; height: 5px; border-radius: 3px; background: var(--bs-border-color); }
.wizard-steps .ws.done { background: var(--brand); }
.wizard-steps .ws.current { background: rgba(var(--brand-rgb), .5); }
.choice-card { border: 2px solid var(--bs-border-color); border-radius: .8rem; padding: 1rem; cursor: pointer; transition: all .15s; display: block; }
.choice-card:hover { border-color: rgba(var(--brand-rgb), .5); }
.btn-check:checked + .choice-card, .choice-card.active { border-color: var(--brand); background: rgba(var(--brand-rgb), .06); }
.doc-drop { border: 2px dashed var(--bs-border-color); border-radius: .8rem; padding: 1.5rem; text-align: center; cursor: pointer; }
.doc-drop.has-file { border-style: solid; border-color: var(--brand); }
.field-low { background: rgba(255, 193, 7, .12) !important; border-color: #e0a800 !important; }
.field-changed { background: rgba(13, 110, 253, .08) !important; border-color: #6ea8fe !important; }

/* -------------------------------------------- partner mobile bottom nav */
.bottom-nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 1040; display: flex; background: var(--bs-body-bg); border-top: 1px solid var(--bs-border-color); padding: .25rem .25rem calc(.25rem + env(safe-area-inset-bottom)); box-shadow: 0 -4px 14px rgba(0,0,0,.06); }
.bottom-nav a { flex: 1; text-align: center; font-size: .66rem; color: var(--bs-secondary-color); text-decoration: none; padding: .3rem 0; display: flex; flex-direction: column; align-items: center; gap: .1rem; }
.bottom-nav a i { font-size: 1.15rem; }
.bottom-nav a.active { color: var(--brand); font-weight: 600; }
.bottom-nav a.is-cta i { background: var(--brand); color: #fff; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; margin-top: -18px; box-shadow: 0 4px 12px rgba(var(--brand-rgb), .4); }
@media (max-width: 991.98px) {
  body.portal-partner .app-footer { margin-bottom: 64px; }
  body.portal-partner .app-main { padding-bottom: 56px; }
}

/* --------------------------------------------------------- responsive */
@media (max-width: 575.98px) {
  .app-content-header h1 { font-size: 1.1rem; }
  .card-body { padding: .8rem; }
  .kpi-tile { padding: .75rem .8rem; }
  .page-actions { width: 100%; }
  .page-actions > .btn, .page-actions > .btn-group { flex: 1; }
  .btn-search-trigger { min-width: 0; }
}

/* print */
@media print {
  .app-sidebar, .app-header, .app-footer, .page-actions, .filter-card, .bottom-nav, .dt-buttons, .dt-search, .dt-paging { display: none !important; }
  .app-main { margin: 0 !important; }
}
