/* ==========================================================================
   Comnex — admin skin on top of CoreUI 5 (public/vendor/coreui, used as the JS/markup engine only).
   Look = shadcn/ui with the Shopify Polaris palette, exactly as adlux-promax (apps/web/src/styles/globals.css):
   neutral off-white app background, white cards, near-black primary, 36px buttons (4px corners),
   40px inputs (6px), 8px cards, soft pastel status chips, system font, 14px text.
   Change colours / radius in section 1 only.
   ========================================================================== */

/* 1. Design tokens (shadcn names, Polaris values) --------------------------- */
:root,
[data-coreui-theme="light"] {
  --th-bg: #f6f6f7;            /* app background */
  --th-card: #ffffff;
  --th-fg: #202223;            /* text */
  --th-muted-fg: #6d7175;      /* subdued text */
  --th-secondary: #f1f2f4;     /* secondary button, muted surfaces, tab list */
  --th-accent: #f1f5f9;        /* hover of ghost / outline controls */
  --th-accent-fg: #0f172a;
  --th-border: #e1e3e5;
  --th-input: #e1e3e5;
  --th-primary: #1a1a1a;
  --th-primary-fg: #ffffff;
  --th-primary-hover: #333333;
  --th-destructive: #c91c1c;
  --th-ring: #1a1a1a;
  --th-link: #2563eb;

  --th-sidebar: #fafafa;
  --th-sidebar-fg: #3f3f46;
  --th-sidebar-muted: rgba(63, 63, 70, .7);
  --th-sidebar-accent: #f0f0f2;
  --th-sidebar-accent-fg: #18181b;
  --th-sidebar-border: #e5e7eb;

  --th-radius: 8px;            /* cards, dialogs */
  --th-radius-md: 6px;         /* inputs, menus, sidebar items */
  --th-radius-sm: 4px;         /* buttons, tab triggers, checkboxes */
  --th-radius-xl: 12px;        /* data tables, auth card */

  --th-shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, .05);
  --th-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, .1), 0 2px 4px -2px rgba(0, 0, 0, .1);
  --th-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, .1), 0 4px 6px -4px rgba(0, 0, 0, .1);
  --th-focus: 0 0 0 2px var(--th-card), 0 0 0 4px var(--th-ring);

  /* status chips (adlux STATUS_TONE "S3 soft pastel": solid pastel, no border, small dot) */
  --th-success-bg: #ecfdf5; --th-success-fg: #065f46; --th-success-dot: #10b981;
  --th-warning-bg: #fffbeb; --th-warning-fg: #92400e; --th-warning-dot: #f59e0b;
  --th-danger-bg: #fef2f2;  --th-danger-fg: #991b1b;  --th-danger-dot: #ef4444;
  --th-info-bg: #eff6ff;    --th-info-fg: #1e40af;    --th-info-dot: #3b82f6;
  --th-accent-bg: #f5f3ff;  --th-accent-fg2: #5b21b6; --th-accent-dot: #8b5cf6;
  --th-neutral-bg: #f4f4f5; --th-neutral-fg: #3f3f46; --th-neutral-dot: #a1a1aa;

  --th-font: -apple-system, BlinkMacSystemFont, "San Francisco", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --th-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* names used by the kept component styles (media library, dialog, editor…) */
  --mbt-red: var(--th-primary);
  --mbt-red-rgb: 26, 26, 26;
  --mbt-red-dark: var(--th-primary-hover);
  --mbt-radius-xs: var(--th-radius-sm);
  --mbt-radius: var(--th-radius-md);
  --mbt-radius-lg: var(--th-radius);
  --mbt-danger: var(--th-destructive);
  --mbt-danger-dark: #a51616;
  --mbt-success: #059669;
  --mbt-success-dark: #047857;
  --mbt-focus-ring: var(--th-focus);
  --mbt-page-bg: var(--th-bg);
  --mbt-card-shadow: var(--th-shadow-sm);
  --mbt-card-shadow-hover: var(--th-shadow-lg);
  --mbt-font-display: var(--th-font);

  /* CoreUI */
  --cui-primary: var(--th-primary);
  --cui-primary-rgb: 26, 26, 26;
  --cui-primary-text-emphasis: var(--th-fg);
  --cui-primary-bg-subtle: var(--th-secondary);
  --cui-primary-border-subtle: var(--th-border);
  --cui-link-color: var(--th-link);
  --cui-link-color-rgb: 37, 99, 235;
  --cui-link-hover-color: #1d4ed8;
  --cui-link-hover-color-rgb: 29, 78, 216;
  --cui-body-font-family: var(--th-font);
  --cui-font-monospace: var(--th-mono);
  --cui-body-font-size: .875rem;
  --cui-body-line-height: 1.5;
  --cui-body-color: var(--th-fg);
  --cui-body-color-rgb: 32, 34, 35;
  --cui-emphasis-color: var(--th-fg);
  --cui-secondary-color: var(--th-muted-fg);
  --cui-secondary-color-rgb: 109, 113, 117;
  --cui-tertiary-color: var(--th-muted-fg);
  --cui-body-bg: var(--th-card);
  --cui-secondary-bg: var(--th-secondary);
  --cui-tertiary-bg: var(--th-secondary);
  --cui-border-color: var(--th-border);
  --cui-border-color-translucent: rgba(0, 0, 0, .08);
  --cui-border-radius: var(--th-radius-md);
  --cui-border-radius-sm: var(--th-radius-sm);
  --cui-border-radius-lg: var(--th-radius);
  --cui-border-radius-xl: var(--th-radius-xl);
  --cui-border-radius-xxl: var(--th-radius-xl);
  --cui-success: #059669;
  --cui-success-rgb: 5, 150, 105;
  --cui-danger: var(--th-destructive);
  --cui-danger-rgb: 201, 28, 28;
  --cui-warning: #d97706;
  --cui-warning-rgb: 217, 119, 6;
  --cui-info: #2563eb;
  --cui-info-rgb: 37, 99, 235;
}

[data-coreui-theme="dark"] {
  --th-bg: #0f0f11;
  --th-card: #1a1a1e;
  --th-fg: #e3e3e7;
  --th-muted-fg: #8d9096;
  --th-secondary: #26262b;
  --th-accent: #26262b;
  --th-accent-fg: #f4f4f5;
  --th-border: #2f3137;
  --th-input: #2f3137;
  --th-primary: #e3e3e7;
  --th-primary-fg: #0f0f11;
  --th-primary-hover: #c9c9cf;
  --th-destructive: #e5484d;
  --th-ring: #e3e3e7;
  --th-link: #7aa2ff;

  --th-sidebar: #141416;
  --th-sidebar-fg: #c8c8ce;
  --th-sidebar-muted: rgba(200, 200, 206, .6);
  --th-sidebar-accent: #26262b;
  --th-sidebar-accent-fg: #f4f4f5;
  --th-sidebar-border: #2a2b30;

  --th-shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, .4);
  --th-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, .5), 0 2px 4px -2px rgba(0, 0, 0, .5);
  --th-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, .6), 0 4px 6px -4px rgba(0, 0, 0, .6);

  --th-success-bg: rgba(16, 185, 129, .1); --th-success-fg: #6ee7b7;
  --th-warning-bg: rgba(245, 158, 11, .1); --th-warning-fg: #fcd34d;
  --th-danger-bg: rgba(239, 68, 68, .1);   --th-danger-fg: #fca5a5;
  --th-info-bg: rgba(59, 130, 246, .12);   --th-info-fg: #93c5fd;
  --th-accent-bg: rgba(139, 92, 246, .12); --th-accent-fg2: #c4b5fd;
  --th-neutral-bg: rgba(161, 161, 170, .12); --th-neutral-fg: #d4d4d8;

  --mbt-red-rgb: 227, 227, 231;
  --cui-primary-rgb: 227, 227, 231;
  --cui-body-color-rgb: 227, 227, 231;
  --cui-secondary-color-rgb: 141, 144, 150;
  --cui-link-color-rgb: 122, 162, 255;
  --cui-border-color-translucent: rgba(255, 255, 255, .08);
}

/* 2. Base ------------------------------------------------------------------ */
html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background: var(--th-bg);
  color: var(--th-fg);
  font-family: var(--th-font);
  font-size: .875rem;
  font-feature-settings: "rlig" 1, "calt" 1;
}

.wrapper {
  background: var(--th-bg);
}

h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 {
  color: var(--th-fg);
  font-family: var(--th-font);
  font-weight: 600;
  letter-spacing: -.01em;
}

code, kbd, samp, pre, .font-monospace {
  font-family: var(--th-mono);
}

a {
  text-underline-offset: 4px;
}

::selection {
  background: rgba(37, 99, 235, .18);
}

* {
  scrollbar-width: thin;
  scrollbar-color: rgba(156, 163, 175, .35) transparent;
}

.text-body-secondary { color: var(--th-muted-fg) !important; }
.text-body-tertiary { color: var(--th-muted-fg) !important; }
.text-primary { color: var(--th-fg) !important; }
.text-danger { color: var(--th-destructive) !important; }
.min-w-0 { min-width: 0; }
.small, small { font-size: .8125rem; }
.fw-semibold { font-weight: 600 !important; }

/* 3. Sidebar --------------------------------------------------------------- */
.sidebar {
  --cui-sidebar-width: 16rem;
  --cui-sidebar-bg: var(--th-sidebar);
  --cui-sidebar-color: var(--th-sidebar-fg);
  --cui-sidebar-border-width: 0;
  --cui-sidebar-header-bg: transparent;
  --cui-sidebar-footer-bg: transparent;
  --cui-sidebar-nav-padding-x: .5rem;
  --cui-sidebar-nav-padding-y: .25rem;
  --cui-sidebar-nav-title-color: var(--th-sidebar-muted);
  --cui-sidebar-nav-link-color: var(--th-sidebar-fg);
  --cui-sidebar-nav-link-icon-color: var(--th-sidebar-fg);
  --cui-sidebar-nav-link-hover-color: var(--th-sidebar-accent-fg);
  --cui-sidebar-nav-link-hover-bg: var(--th-sidebar-accent);
  --cui-sidebar-nav-link-hover-icon-color: var(--th-sidebar-accent-fg);
  --cui-sidebar-nav-link-active-color: var(--th-sidebar-accent-fg);
  --cui-sidebar-nav-link-active-bg: var(--th-sidebar-accent);
  --cui-sidebar-nav-link-active-icon-color: var(--th-sidebar-accent-fg);
  --cui-sidebar-nav-group-bg: transparent;
  --cui-sidebar-nav-group-toggle-show-color: var(--th-sidebar-fg);
  --cui-sidebar-nav-link-border-radius: var(--th-radius-md);
  border-right: 1px solid var(--th-sidebar-border);
  box-shadow: none;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 3.5rem;
  padding: .75rem 1rem .5rem;
  border: 0;
}

.sidebar-brand-logo {
  display: block;
  width: auto;
  height: 20px;
}

/* Dark mode: Comnex logo with light "COM" (logo-dark.png has navy "COM" for light backgrounds) */
[data-coreui-theme="dark"] .sidebar-brand-logo,
[data-coreui-theme="dark"] .mobile-bar-logo,
[data-coreui-theme="dark"] .auth-brand img,
[data-coreui-theme="dark"] .auth-logo-mobile {
  content: url("../img/logo-light.png");
}

.sidebar-close {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 0;
  border-radius: var(--th-radius-md);
  background: transparent;
  color: var(--th-sidebar-fg);
}

.sidebar-close:hover { background: var(--th-sidebar-accent); }

.sidebar-search {
  padding: .25rem .5rem .5rem;
}

.sidebar-nav {
  padding: 0 .5rem .75rem;
}

.sidebar-nav .nav-title {
  display: flex;
  align-items: center;
  height: 2rem;
  margin: .5rem 0 0;
  padding: 0 .5rem;
  color: var(--th-sidebar-muted);
  font-size: .75rem;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
}

.sidebar-nav .nav-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: .5rem;
  min-height: 2rem;
  margin: 0 0 1px;
  padding: .375rem .5rem;
  border-radius: var(--th-radius-md);
  font-size: .875rem;
  font-weight: 400;
  line-height: 1.25rem;
  transition: background .15s, color .15s;
}

.sidebar-nav .nav-link.active {
  font-weight: 500;
}

.sidebar-nav .nav-icon {
  flex: 0 0 1rem;
  width: 1rem;
  height: 1rem;
  margin: 0;
  font-size: 1rem;
}

.sidebar-nav .nav-group-toggle::after {
  flex: none;
  width: 1rem;
  height: 1rem;
  margin-left: auto;
  background-image: none;
  background-color: currentColor;
  -webkit-mask: url("../icons/chevron-right.svg") center / contain no-repeat;
  mask: url("../icons/chevron-right.svg") center / contain no-repeat;
  opacity: .7;
  transition: transform .2s;
}

.sidebar-nav .nav-group.show > .nav-group-toggle::after {
  transform: rotate(90deg);
}

.sidebar-nav .nav-group-items {
  margin: 0 .875rem !important;
  padding: .125rem 0 .125rem .625rem !important;
  border-left: 1px solid var(--th-sidebar-border);
}

.sidebar-nav .nav-group-items .nav-link {
  min-height: 1.75rem;
  padding: .25rem .5rem !important;
}

.sidebar-nav .nav-group-items .nav-icon {
  display: none;
}

.sidebar-nav .nav-link .badge {
  margin-left: auto;
  min-width: 1.25rem;
  padding: .1rem .375rem;
  border-radius: var(--th-radius-md);
  background: var(--th-primary) !important;
  color: var(--th-primary-fg) !important;
  font-size: .75rem;
  font-weight: 500;
}

.sidebar-nav .nav-link .badge::before { display: none; }

.sidebar-footer {
  padding: .5rem;
  border: 0;
}

/* Account (shadcn NavUser) */
.nav-user { width: 100%; }

.nav-user-trigger {
  display: flex;
  align-items: center;
  gap: .5rem;
  width: 100%;
  padding: .5rem;
  border: 0;
  border-radius: var(--th-radius-md);
  background: transparent;
  color: var(--th-sidebar-fg);
  text-align: left;
  transition: background .15s;
}

.nav-user-trigger:hover,
.nav-user-trigger[aria-expanded="true"] {
  background: var(--th-sidebar-accent);
  color: var(--th-sidebar-accent-fg);
}

.nav-user-trigger > .icon {
  margin-left: auto;
  color: var(--th-muted-fg);
}

.nav-user .user-avatar {
  flex: none;
  width: 2rem;
  height: 2rem;
  border-radius: var(--th-radius);
  font-size: .75rem;
}

.nav-user-text {
  display: grid;
  flex: 1;
  min-width: 0;
  line-height: 1.25;
}

.nav-user-name {
  overflow: hidden;
  color: var(--th-fg);
  font-size: .875rem;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-user-email {
  overflow: hidden;
  color: var(--th-muted-fg);
  font-size: .75rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-user .dropdown-menu {
  width: 100%;
  min-width: 14rem;
}

.nav-user-head {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .375rem .25rem;
}

.theme-segment {
  display: flex;
  gap: .25rem;
  padding: 0 .25rem .25rem;
}

.theme-segment button {
  display: grid;
  flex: 1;
  place-items: center;
  height: 2rem;
  border: 1px solid var(--th-border);
  border-radius: var(--th-radius-sm);
  background: var(--th-card);
  color: var(--th-muted-fg);
}

.theme-segment button:hover { background: var(--th-accent); color: var(--th-fg); }
.theme-segment button.active { border-color: var(--th-fg); color: var(--th-fg); }

/* 4. Mobile bar (no header on desktop) ------------------------------------ */
.mobile-bar {
  position: sticky;
  top: 0;
  z-index: 1020;
  display: flex;
  align-items: center;
  gap: .5rem;
  height: 3rem;
  padding: 0 .75rem;
  border-bottom: 1px solid var(--th-border);
  background: var(--th-card);
}

.mobile-bar-logo {
  display: block;
  width: auto;
  height: 18px;
}

.btn-icon {
  display: inline-grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: 0;
  border-radius: var(--th-radius-sm);
  background: transparent;
  color: var(--th-fg);
}

.btn-icon:hover { background: var(--th-accent); }

/* 5. Page ------------------------------------------------------------------ */
.admin-container {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.5rem 1.5rem 2rem;
}

.page-crumbs .breadcrumb {
  --cui-breadcrumb-divider: "/";
  --cui-breadcrumb-divider-color: var(--th-muted-fg);
  --cui-breadcrumb-item-padding-x: .5rem;
  --cui-breadcrumb-item-active-color: var(--th-fg);
  margin: 0 0 .5rem;
  font-size: .875rem;
}

.page-crumbs a {
  color: var(--th-muted-fg);
  text-decoration: none;
  transition: color .15s;
}

.page-crumbs a:hover { color: var(--th-fg); }

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .75rem .5rem;
  margin-bottom: 1.25rem;
}

.page-title {
  margin: 0;
  overflow: hidden;
  color: var(--th-fg);
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -.025em;
  line-height: 1.75rem;
  text-overflow: ellipsis;
}

.page-subtitle {
  max-width: 48rem;
  margin: .125rem 0 0;
  color: var(--th-muted-fg);
  font-size: .8125rem;
  line-height: 1.4;
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
  max-width: 100%;
}

/* 6. Cards ----------------------------------------------------------------- */
.card {
  --cui-card-bg: var(--th-card);
  --cui-card-color: var(--th-fg);
  --cui-card-border-color: var(--th-border);
  --cui-card-border-radius: var(--th-radius);
  --cui-card-inner-border-radius: calc(var(--th-radius) - 1px);
  --cui-card-cap-bg: transparent;
  --cui-card-cap-padding-x: 1.25rem;
  --cui-card-cap-padding-y: .875rem;
  --cui-card-spacer-x: 1.25rem;
  --cui-card-spacer-y: 1.25rem;
  box-shadow: var(--th-shadow-sm);
}

.card-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  min-height: 3.25rem;
  border-bottom: 1px solid var(--th-border);
  color: var(--th-fg);
  font-size: .9375rem;
  font-weight: 600;
  letter-spacing: -.01em;
}

.card-header > span > .icon:first-child {
  margin-right: .5rem !important;
  color: var(--th-muted-fg) !important;
}

.card-footer {
  border-top: 1px solid var(--th-border);
  background: transparent;
}

.card-footer:has(.pagination) {
  padding: .75rem 1rem;
}

/* Dashboard KPI cards (adlux kpi-stat-card) */
.stat-card {
  display: block;
  min-height: 92px;
  color: inherit;
  text-decoration: none;
  transition: border-color .15s, box-shadow .15s;
}

.stat-card:hover {
  border-color: #c9cccf;
  box-shadow: var(--th-shadow-md);
}

.stat-card .card-body { padding: 1rem 1.125rem; }

.stat-label {
  display: flex;
  align-items: center;
  gap: .375rem;
  color: var(--th-muted-fg);
  font-size: .6875rem;
  font-weight: 500;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.stat-label .icon { width: .875rem; height: .875rem; }

.stat-value {
  margin-top: .5rem;
  color: var(--th-fg);
  font-size: 1.5rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
  line-height: 2rem;
}

.stat-note {
  margin-top: .125rem;
  color: var(--th-muted-fg);
  font-size: .75rem;
}

/* Icon tiles (quick actions, empty states): neutral, as in shadcn */
.stat-icon {
  display: inline-grid;
  flex: none;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: var(--th-radius-md);
  background: var(--th-secondary);
  color: var(--th-fg);
}

.soft-primary, .soft-info, .soft-success, .soft-warning, .soft-danger, .soft-secondary {
  background: var(--th-secondary);
  color: var(--th-fg);
}

.quick-action {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .625rem .75rem;
  border: 1px solid var(--th-border);
  border-radius: var(--th-radius-md);
  color: var(--th-fg);
  font-weight: 500;
  text-decoration: none;
  transition: background .15s;
}

.quick-action:hover {
  background: var(--th-accent);
  color: var(--th-fg);
}

.quick-action > .icon:last-child { color: var(--th-muted-fg); }

/* 7. Tables (shadcn Table) -------------------------------------------------- */
.table {
  --cui-table-bg: transparent;
  --cui-table-color: var(--th-fg);
  --cui-table-hover-bg: rgba(241, 242, 244, .6);
  --cui-table-hover-color: var(--th-fg);
  --cui-table-border-color: var(--th-border);
  margin: 0;
  font-size: .875rem;
}

[data-coreui-theme="dark"] .table { --cui-table-hover-bg: rgba(255, 255, 255, .03); }

.table > thead th {
  height: 3rem;
  padding: 0 1rem;
  border-bottom: 1px solid var(--th-border);
  background: transparent;
  color: var(--th-muted-fg);
  font-size: .875rem;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  vertical-align: middle;
  white-space: nowrap;
}

.table > tbody > tr > td {
  padding: .75rem 1rem;
  border-color: var(--th-border);
  vertical-align: middle;
}

.table > tbody > tr:last-child > td { border-bottom: 0; }

.table a.text-body { color: var(--th-fg) !important; }
.table a.text-body:hover { text-decoration: underline !important; }

.thumb {
  display: block;
  width: 2.75rem;
  height: 2.25rem;
  border-radius: var(--th-radius-md);
  background: var(--th-secondary);
  object-fit: cover;
}

/* 8. Buttons (shadcn Button: 36px, 4px corners, 14px medium, 16px icons) ---- */
.btn {
  --cui-btn-padding-x: .75rem;
  --cui-btn-padding-y: 0;
  --cui-btn-font-size: .875rem;
  --cui-btn-font-weight: 500;
  --cui-btn-line-height: 1.25rem;
  --cui-btn-border-radius: var(--th-radius-sm);
  --cui-btn-border-width: 1px;
  --cui-btn-focus-box-shadow: var(--th-focus);
  --cui-btn-disabled-opacity: .5;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  height: 2.25rem;
  white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s;
}

.btn > .icon { margin: 0 !important; }
.btn.w-100, .btn.d-block, .d-grid > .btn { display: flex; }
.btn-lg { --cui-btn-padding-x: 1.25rem; height: 2.25rem; }
.btn-sm { --cui-btn-padding-x: .625rem; --cui-btn-font-size: .8125rem; height: 2rem; }
.btn-sm.btn-link { height: auto; }

/* default */
.btn-primary,
[data-coreui-theme] .btn-primary {
  --cui-btn-color: var(--th-primary-fg);
  --cui-btn-bg: var(--th-primary);
  --cui-btn-border-color: var(--th-primary);
  --cui-btn-hover-color: var(--th-primary-fg);
  --cui-btn-hover-bg: var(--th-primary-hover);
  --cui-btn-hover-border-color: var(--th-primary-hover);
  --cui-btn-active-color: var(--th-primary-fg);
  --cui-btn-active-bg: var(--th-primary-hover);
  --cui-btn-active-border-color: var(--th-primary-hover);
  --cui-btn-disabled-color: var(--th-primary-fg);
  --cui-btn-disabled-bg: var(--th-primary);
  --cui-btn-disabled-border-color: var(--th-primary);
  box-shadow: none;
}

/* outline (also used for the former outline-primary / light / secondary buttons) */
.btn-outline-secondary, .btn-outline-primary, .btn-light, .btn-outline-dark,
[data-coreui-theme] .btn-outline-secondary, [data-coreui-theme] .btn-outline-primary, [data-coreui-theme] .btn-light {
  --cui-btn-color: var(--th-fg);
  --cui-btn-bg: var(--th-card);
  --cui-btn-border-color: var(--th-input);
  --cui-btn-hover-color: var(--th-accent-fg);
  --cui-btn-hover-bg: var(--th-accent);
  --cui-btn-hover-border-color: var(--th-input);
  --cui-btn-active-color: var(--th-accent-fg);
  --cui-btn-active-bg: var(--th-accent);
  --cui-btn-active-border-color: var(--th-input);
  --cui-btn-disabled-color: var(--th-fg);
  --cui-btn-disabled-bg: var(--th-card);
  --cui-btn-disabled-border-color: var(--th-input);
  box-shadow: none;
}

/* secondary */
.btn-secondary,
[data-coreui-theme] .btn-secondary {
  --cui-btn-color: var(--th-fg);
  --cui-btn-bg: var(--th-secondary);
  --cui-btn-border-color: var(--th-secondary);
  --cui-btn-hover-color: var(--th-fg);
  --cui-btn-hover-bg: #e6e7ea;
  --cui-btn-hover-border-color: #e6e7ea;
  --cui-btn-active-bg: #e6e7ea;
  --cui-btn-active-border-color: #e6e7ea;
}

/* destructive / success */
.btn-danger,
[data-coreui-theme] .btn-danger {
  --cui-btn-color: #fff; --cui-btn-bg: var(--th-destructive); --cui-btn-border-color: var(--th-destructive);
  --cui-btn-hover-color: #fff; --cui-btn-hover-bg: #b01818; --cui-btn-hover-border-color: #b01818;
  --cui-btn-active-color: #fff; --cui-btn-active-bg: #b01818; --cui-btn-active-border-color: #b01818;
}

.btn-success,
[data-coreui-theme] .btn-success {
  --cui-btn-color: #fff; --cui-btn-bg: #059669; --cui-btn-border-color: #059669;
  --cui-btn-hover-color: #fff; --cui-btn-hover-bg: #047857; --cui-btn-hover-border-color: #047857;
  --cui-btn-active-color: #fff; --cui-btn-active-bg: #047857; --cui-btn-active-border-color: #047857;
}

.btn-warning, .btn-info {
  --cui-btn-color: var(--th-fg); --cui-btn-bg: var(--th-card); --cui-btn-border-color: var(--th-input);
  --cui-btn-hover-color: var(--th-fg); --cui-btn-hover-bg: var(--th-accent); --cui-btn-hover-border-color: var(--th-input);
}

/* outline-danger / success / warning / info = outline with tinted text */
.btn-outline-danger, .btn-outline-success, .btn-outline-warning, .btn-outline-info,
[data-coreui-theme] .btn-outline-danger, [data-coreui-theme] .btn-outline-success {
  --cui-btn-bg: var(--th-card);
  --cui-btn-border-color: var(--th-input);
  --cui-btn-hover-bg: var(--th-accent);
  --cui-btn-hover-border-color: var(--th-input);
  --cui-btn-active-bg: var(--th-accent);
  --cui-btn-active-border-color: var(--th-input);
  --cui-btn-disabled-bg: var(--th-card);
  --cui-btn-disabled-border-color: var(--th-input);
}

.btn-outline-danger, [data-coreui-theme] .btn-outline-danger { --cui-btn-color: var(--th-destructive); --cui-btn-hover-color: var(--th-destructive); --cui-btn-active-color: var(--th-destructive); }
.btn-outline-success { --cui-btn-color: #047857; --cui-btn-hover-color: #047857; --cui-btn-active-color: #047857; }
.btn-outline-warning { --cui-btn-color: #b45309; --cui-btn-hover-color: #b45309; --cui-btn-active-color: #b45309; }
.btn-outline-info    { --cui-btn-color: #1d4ed8; --cui-btn-hover-color: #1d4ed8; --cui-btn-active-color: #1d4ed8; }

/* ghost icon buttons of the list rows (every one of them has a title: Sửa, Xoá…) */
.btn-sm[title]:has(> .icon:only-child) {
  --cui-btn-bg: transparent;
  --cui-btn-border-color: transparent;
  --cui-btn-color: var(--th-muted-fg);
  --cui-btn-hover-bg: var(--th-accent);
  --cui-btn-hover-border-color: transparent;
  --cui-btn-hover-color: var(--th-fg);
  --cui-btn-active-bg: var(--th-accent);
  --cui-btn-active-border-color: transparent;
  width: 2rem;
  height: 2rem;
  padding: 0;
}

.btn-outline-danger.btn-sm[title]:has(> .icon:only-child):hover,
form[data-confirm] > .btn-sm:has(> .icon.i-trash:only-child):hover {
  --cui-btn-hover-color: var(--th-destructive);
}

form[data-confirm] > .btn-sm:has(> .icon:only-child) {
  --cui-btn-bg: transparent;
  --cui-btn-border-color: transparent;
  --cui-btn-color: var(--th-muted-fg);
  --cui-btn-hover-bg: var(--th-accent);
  --cui-btn-hover-border-color: transparent;
  width: 2rem;
  height: 2rem;
  padding: 0;
}

.btn-link {
  --cui-btn-color: var(--th-fg);
  --cui-btn-hover-color: var(--th-fg);
  height: auto;
  padding-inline: 0;
  text-decoration: underline;
  text-underline-offset: 4px;
}

/* 9. Forms (shadcn Input / Select / Textarea / Label) ----------------------- */
.form-label {
  margin-bottom: .5rem;
  color: var(--th-fg);
  font-size: .875rem;
  font-weight: 500;
  line-height: 1;
}

.form-control,
.form-select {
  min-height: 2.5rem;
  padding: .5rem .75rem;
  border: 1px solid var(--th-input);
  border-radius: var(--th-radius-md);
  background-color: var(--th-card);
  color: var(--th-fg);
  font-size: .875rem;
  line-height: 1.25rem;
  box-shadow: none;
  transition: box-shadow .15s;
}

.form-select { padding-right: 2.25rem; }

.form-control:focus,
.form-select:focus {
  border-color: var(--th-input);
  box-shadow: var(--th-focus);
  outline: 0;
}

.form-control::placeholder { color: var(--th-muted-fg); }

.form-control:disabled,
.form-select:disabled {
  opacity: .5;
}

.form-control-lg {
  min-height: 2.5rem;
  border-radius: var(--th-radius-md);
  font-size: 1rem;
  font-weight: 500;
}

.form-control-sm, .form-select-sm { min-height: 2.25rem; font-size: .8125rem; }

textarea.form-control { min-height: 5rem; }

.form-text {
  margin-top: .375rem;
  color: var(--th-muted-fg);
  font-size: .8125rem;
}

.invalid-feedback { color: var(--th-destructive); font-size: .8125rem; }

.form-control.is-invalid, .form-select.is-invalid { border-color: var(--th-destructive); }

.input-group-text {
  border-color: var(--th-input);
  border-radius: var(--th-radius-md);
  background: var(--th-secondary);
  color: var(--th-muted-fg);
  font-size: .875rem;
}

.form-check-input {
  width: 1rem;
  height: 1rem;
  border: 1px solid #b8bcc1;
  border-radius: var(--th-radius-sm);
}

.form-check-input:checked {
  border-color: var(--th-primary);
  background-color: var(--th-primary);
}

.form-check-input:focus {
  border-color: var(--th-primary);
  box-shadow: var(--th-focus);
}

.form-switch .form-check-input {
  --cui-form-switch-bg: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3.2' fill='%23fff'/%3e%3c/svg%3e");
  --cui-form-switch-checked-bg: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3.2' fill='%23fff'/%3e%3c/svg%3e");
  --cui-form-switch-focus-bg: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3.2' fill='%23fff'/%3e%3c/svg%3e");
  width: 2.25rem;
  height: 1.25rem;
  border: 0;
  border-radius: 999px;
  background-color: var(--th-input);
}

.form-switch .form-check-input:checked { background-color: var(--th-primary); }
[data-coreui-theme="dark"] .form-switch .form-check-input:checked { background-color: #e3e3e7; }

.form-check-label { font-size: .875rem; }

.mb-3:has(> .form-label) { margin-bottom: 1rem !important; }

details > summary { cursor: pointer; }

/* 10. Badges (adlux StatusBadge: pastel chip + dot), alerts, menus, tabs --- */
.badge {
  --cui-badge-padding-x: .5rem;
  --cui-badge-padding-y: .125rem;
  --cui-badge-font-size: .75rem;
  --cui-badge-font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: .375rem;
  border-radius: var(--th-radius-md);
  line-height: 1.25rem;
  letter-spacing: 0;
}

.badge.bg-primary, .badge.bg-success, .badge.bg-warning, .badge.bg-danger,
.badge.bg-info, .badge.bg-purple, .badge.bg-secondary {
  --chip-bg: var(--th-neutral-bg); --chip-fg: var(--th-neutral-fg); --chip-dot: var(--th-neutral-dot);
  background: var(--chip-bg) !important;
  color: var(--chip-fg) !important;
}

.badge.bg-primary, .badge.bg-info { --chip-bg: var(--th-info-bg); --chip-fg: var(--th-info-fg); --chip-dot: var(--th-info-dot); }
.badge.bg-success { --chip-bg: var(--th-success-bg); --chip-fg: var(--th-success-fg); --chip-dot: var(--th-success-dot); }
.badge.bg-warning { --chip-bg: var(--th-warning-bg); --chip-fg: var(--th-warning-fg); --chip-dot: var(--th-warning-dot); }
.badge.bg-danger { --chip-bg: var(--th-danger-bg); --chip-fg: var(--th-danger-fg); --chip-dot: var(--th-danger-dot); }
.badge.bg-purple { --chip-bg: var(--th-accent-bg); --chip-fg: var(--th-accent-fg2); --chip-dot: var(--th-accent-dot); }

.badge.bg-primary::before, .badge.bg-success::before, .badge.bg-warning::before, .badge.bg-danger::before,
.badge.bg-info::before, .badge.bg-purple::before, .badge.bg-secondary::before {
  content: "";
  flex: none;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--chip-dot);
}

/* counters ("Tất cả 7") and tags: plain neutral pill */
.badge.bg-body-secondary {
  padding: 0 .4rem;
  border-radius: 999px;
  background: var(--th-secondary) !important;
  color: var(--th-muted-fg) !important;
  font-weight: 500;
}

.badge.bg-danger-subtle {
  background: var(--th-danger-bg) !important;
  color: var(--th-danger-fg) !important;
}

.alert {
  --cui-alert-border-radius: var(--th-radius);
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  padding: 1rem;
  border: 1px solid var(--th-border);
  background: var(--th-card);
  color: var(--th-fg);
  font-size: .875rem;
}

.alert > .icon:first-child { margin-top: .125rem; }
.alert-success > .icon:first-child { color: #059669; }
.alert-warning > .icon:first-child { color: #d97706; }
.alert-info > .icon:first-child { color: var(--th-fg); }
.alert-danger { border-color: rgba(201, 28, 28, .5); color: var(--th-destructive); }
.alert-danger > div { color: var(--th-destructive); }
.alert-dismissible .btn-close { padding: 1.1rem 1rem; transform: scale(.8); }

.dropdown-menu {
  --cui-dropdown-bg: var(--th-card);
  --cui-dropdown-color: var(--th-fg);
  --cui-dropdown-border-color: var(--th-border);
  --cui-dropdown-border-radius: var(--th-radius-md);
  --cui-dropdown-link-color: var(--th-fg);
  --cui-dropdown-link-hover-bg: var(--th-accent);
  --cui-dropdown-link-hover-color: var(--th-accent-fg);
  --cui-dropdown-link-active-bg: var(--th-accent);
  --cui-dropdown-link-active-color: var(--th-accent-fg);
  --cui-dropdown-header-color: var(--th-muted-fg);
  padding: .25rem;
  font-size: .875rem;
  box-shadow: var(--th-shadow-lg);
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .375rem .5rem;
  border-radius: var(--th-radius-sm);
}

.dropdown-header {
  padding: .375rem .5rem;
  font-size: .75rem;
  font-weight: 500;
}

.dropdown-divider {
  margin: .25rem -.25rem;
  border-color: var(--th-border);
}

/* Status filter tabs in card headers → shadcn TabsList */
.card-header:has(> .card-header-tabs) {
  padding: .75rem 1rem;
  min-height: 0;
}

.card-header-tabs {
  display: inline-flex !important;
  flex-wrap: wrap;
  gap: 0 !important;
  margin: 0 !important;
  padding: .25rem !important;
  border-radius: var(--th-radius-md);
  background: var(--th-secondary);
}

.card-header-tabs .nav-link {
  display: inline-flex;
  align-items: center;
  gap: .375rem;
  padding: .375rem .75rem !important;
  border: 0 !important;
  border-radius: var(--th-radius-sm);
  color: var(--th-muted-fg) !important;
  font-size: .875rem;
  font-weight: 500 !important;
  white-space: nowrap;
}

.card-header-tabs .nav-link:hover { color: var(--th-fg) !important; }

.card-header-tabs .nav-link.active {
  background: var(--th-card);
  color: var(--th-fg) !important;
  box-shadow: var(--th-shadow-sm);
}

.card-header-tabs .nav-link .badge {
  margin: 0 !important;
  background: transparent !important;
  color: inherit !important;
  padding: 0 !important;
  font-weight: 500;
  opacity: .7;
}

/* Language tabs of translatable forms → the same TabsList */
.nav-tabs.locale-tabs {
  display: inline-flex;
  gap: 0;
  padding: .25rem;
  border: 0;
  border-radius: var(--th-radius-md);
  background: var(--th-secondary);
}

.nav-tabs.locale-tabs .nav-link {
  display: inline-flex;
  align-items: center;
  gap: .375rem;
  margin: 0;
  padding: .375rem .75rem;
  border: 0;
  border-radius: var(--th-radius-sm);
  color: var(--th-muted-fg);
  font-size: .875rem;
  font-weight: 500;
}

.nav-tabs.locale-tabs .nav-link.active {
  background: var(--th-card);
  color: var(--th-fg);
  box-shadow: var(--th-shadow-sm);
}

.nav-tabs.locale-tabs .nav-link .text-uppercase {
  color: inherit !important;
  font-family: var(--th-mono);
  font-size: .75rem;
}

/* 11. Auth (shadcn login card) ---------------------------------------------- */
.auth-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  min-height: 100vh;
  padding: 1.5rem;
  background: var(--th-bg);
}

.auth-brand img {
  display: block;
  width: auto;
  height: 24px;
}

.auth-card {
  width: 100%;
  max-width: 24rem;
  padding: 1.5rem;
  border: 1px solid var(--th-border);
  border-radius: var(--th-radius-xl);
  background: var(--th-card);
  box-shadow: var(--th-shadow-sm);
}

.auth-card h1,
.auth-card .h3 {
  margin-bottom: .375rem !important;
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -.025em;
}

.auth-card h1 + p { font-size: .875rem; }
.auth-card .auth-logo-mobile { display: none; }
.auth-card .btn-primary { width: 100%; }

.auth-foot {
  margin: 0;
  color: var(--th-muted-fg);
  font-size: .75rem;
}

/* 12. Footer --------------------------------------------------------------- */
.footer,
[data-coreui-theme] .footer {
  --cui-footer-bg: transparent;
  background: transparent;
  --cui-footer-border-color: transparent;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: .5rem 1rem;
  min-height: 0;
  padding: 1rem 1.5rem 1.25rem;
  border: 0;
  color: var(--th-muted-fg);
  font-size: .75rem;
}

.footer a { color: var(--th-muted-fg); text-decoration: none; }
.footer a:hover { color: var(--th-fg); }

/* 13. Responsive ----------------------------------------------------------- */
@media (max-width: 767.98px) {
  .admin-container { padding: 1rem 1rem 1.5rem; }
  .footer { padding: 1rem; }
}

/* 14. Header quick search & avatars (kept) ------------------------------------ */
/* Quick search: icon that expands into an input */
.header-search {
  position: relative;
  display: flex;
  align-items: center;
}

.header-search-toggle {
  border: 0;
  background: transparent;
  padding-inline: .5rem !important;
}

.header-search-box {
  display: flex;
  align-items: center;
  gap: .5rem;
  width: 0;
  height: 2.4rem;
  padding: 0;
  opacity: 0;
  overflow: hidden;
  visibility: hidden;
  border: 1px solid transparent;
  border-radius: var(--cui-border-radius);
  background: var(--cui-tertiary-bg);
  transition: width .25s ease, opacity .2s ease, padding .25s ease, border-color .2s ease, box-shadow .2s ease;
}

.header-search.is-open .header-search-toggle {
  display: none;
}

.header-search.is-open .header-search-box {
  width: 22rem;
  padding: 0 .4rem 0 .9rem;
  opacity: 1;
  visibility: visible;
  border-color: var(--cui-border-color);
}

.header-search-box:focus-within {
  border-color: rgba(var(--cui-primary-rgb), .55) !important;
  box-shadow: var(--mbt-focus-ring);
  background: var(--cui-body-bg);
}

.header-search-icon {
  color: var(--cui-secondary-color);
  flex-shrink: 0;
}

.header-search-input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--cui-body-color);
  font-size: .9rem;
}

.header-search-input::-webkit-search-cancel-button {
  display: none;
}

.header-search-kbd {
  flex-shrink: 0;
  padding: .1rem .4rem;
  font-family: inherit;
  font-size: .68rem;
  font-weight: 700;
  color: var(--cui-secondary-color);
  background: var(--cui-body-bg);
  border: 1px solid var(--cui-border-color);
  border-radius: var(--mbt-radius-xs);
}

.header-search-close {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.8rem;
  height: 1.8rem;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--cui-secondary-color);
}

.header-search-close:hover {
  background: var(--cui-tertiary-bg);
  color: var(--cui-body-color);
}

.header-search-results {
  position: absolute;
  top: calc(100% + .6rem);
  right: 0;
  z-index: 1060;
  width: 24rem;
  max-height: min(26rem, 70vh);
  overflow-y: auto;
  padding: .4rem;
  background: var(--cui-body-bg);
  border: 1px solid var(--cui-border-color);
  border-radius: var(--cui-border-radius-lg);
  box-shadow: var(--mbt-card-shadow-hover);
}

.search-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .55rem .6rem;
  border-radius: var(--cui-border-radius);
  color: var(--cui-body-color);
  text-decoration: none;
  cursor: pointer;
}

.search-item:hover,
.search-item.is-active {
  background: rgba(var(--cui-primary-rgb), .08);
  color: var(--cui-body-color);
}

.search-item.is-disabled {
  opacity: .5;
  cursor: not-allowed;
}

.search-item .stat-icon {
  width: 2rem;
  height: 2rem;
  font-size: 1rem;
  border-radius: var(--cui-border-radius);
}

.search-item-title {
  font-weight: 600;
  font-size: .9rem;
  line-height: 1.2;
}

.search-item-title mark {
  padding: 0;
  background: transparent;
  color: var(--cui-primary);
}

.search-item-section {
  font-size: .75rem;
  color: var(--cui-secondary-color);
}

.search-item-tag {
  margin-inline-start: auto;
  font-size: .65rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--cui-secondary-color);
}

.search-empty {
  padding: 1rem;
  text-align: center;
  font-size: .875rem;
  color: var(--cui-secondary-color);
}

@media (max-width: 575.98px) {
  .header-search.is-open .header-search-box {
    position: fixed;
    top: .8rem;
    left: 1rem;
    right: 1rem;
    z-index: 1061;
    width: auto;
  }

  .header-search-results {
    position: fixed;
    top: 3.9rem;
    left: 1rem;
    right: 1rem;
    width: auto;
  }
}

.user-avatar {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .9rem;
  color: #fff;
  background: linear-gradient(135deg, var(--mbt-red) 0%, #ef6b3b 100%);
  box-shadow: 0 2px 6px rgba(var(--mbt-red-rgb), .35);
  flex-shrink: 0;
  object-fit: cover;
  user-select: none;
}

/* Sizes (<x-admin.avatar size="...">) */
.user-avatar-sm { width: 2rem; height: 2rem; font-size: .75rem; }
.user-avatar-md { width: 2.25rem; height: 2.25rem; font-size: .85rem; }
.user-avatar-lg { width: 2.75rem; height: 2.75rem; font-size: 1rem; }
.user-avatar-xl { width: 5.5rem; height: 5.5rem; font-size: 1.75rem; }

/* Photo: neutral ring instead of the brand glow */
img.user-avatar {
  background: var(--cui-tertiary-bg);
  box-shadow: 0 0 0 2px var(--cui-body-bg), 0 1px 3px rgba(16, 24, 40, .2);
}

/* Initials: stable per-account hue, readable white text (AA) */
.user-avatar.is-initials {
  background: linear-gradient(135deg, hsl(var(--avatar-hue, 355) 62% 42%), hsl(calc(var(--avatar-hue, 355) + 28) 64% 36%));
  box-shadow: none;
  letter-spacing: .02em;
}

/* Avatar picker */
.avatar-input-drop {
  position: relative;
  display: inline-flex;
  border-radius: 50%;
  cursor: pointer;
  margin: 0;
}

.avatar-input-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(15, 23, 42, .5);
  color: #fff;
  font-size: 1.4rem;
  opacity: 0;
  transition: opacity .15s;
}

.avatar-input-drop:hover .avatar-input-overlay,
.avatar-input-drop.is-dragover .avatar-input-overlay,
.avatar-input:focus-within .avatar-input-overlay {
  opacity: 1;
}

.avatar-input-drop.is-dragover {
  outline: 2px dashed var(--mbt-red);
  outline-offset: 3px;
}

/* 15. CRUD building blocks -------------------------------------------------- */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  align-items: center;
}

.filter-search {
  flex: 1 1 18rem;
  max-width: 28rem;
}

.filter-select {
  flex: 0 1 14rem;
  width: auto;
}

.card-header-tabs {
  margin: -1rem 0 -1rem;
}

.card-header-tabs .nav-link {
  padding-block: 1rem;
  font-weight: 600;
  color: var(--cui-secondary-color);
}

.card-header-tabs .nav-link.active {
  color: var(--cui-primary);
  border-bottom-color: var(--cui-primary);
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 3rem 1rem;
}

.check-list {
  max-height: 14rem;
  overflow-y: auto;
  padding: .5rem .75rem;
  border: 1px solid var(--cui-border-color);
  border-radius: var(--cui-border-radius);
}

.check-list .form-check {
  margin-bottom: .35rem;
}

/* Single image input with preview */
.image-input {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-start;
}

.image-input > .flex-grow-1 {
  flex-basis: 13rem;
}

.image-input-preview {
  width: 7.5rem;
  height: 5.5rem;
  flex-shrink: 0;
  border-radius: var(--cui-border-radius);
  overflow: hidden;
  border: 1px solid var(--cui-border-color);
  background: var(--cui-tertiary-bg);
  display: flex;
  align-items: center;
  justify-content: center;
}

.image-input-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-input-placeholder {
  font-size: 1.75rem;
  color: var(--cui-secondary-color);
  opacity: .6;
}

/* Product gallery / certificate grid */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr));
  gap: .75rem;
}

.gallery-item {
  position: relative;
  border-radius: var(--cui-border-radius);
  overflow: hidden;
  border: 1px solid var(--cui-border-color);
  background: var(--cui-tertiary-bg);
}

.gallery-item img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
}

.gallery-item .gallery-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .25rem;
  padding: .35rem .45rem;
  font-size: .78rem;
  background: var(--cui-body-bg);
}

.gallery-item .gallery-tools input[type="number"] {
  width: 3.6rem;
  padding: .1rem .3rem;
  font-size: .78rem;
}

.gallery-item.is-removed img {
  opacity: .3;
  filter: grayscale(1);
}

.gallery-item.is-new {
  border-color: rgba(var(--cui-primary-rgb), .5);
}

.gallery-tag {
  position: absolute;
  top: .4rem;
  left: .4rem;
  padding: .1rem .45rem;
  border-radius: var(--cui-border-radius);
  font-size: .68rem;
  font-weight: 700;
  color: #fff;
  background: var(--cui-primary);
}

.cert-card img {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: contain;
  background: var(--cui-tertiary-bg);
  padding: .5rem;
}

.cert-card.is-hidden img {
  opacity: .4;
}

/* Tree rows (categories) */
.tree-indent {
  display: inline-block;
  width: calc(var(--depth, 0) * 1.5rem);
}

.tree-branch {
  color: var(--cui-secondary-color);
  margin-inline-end: .35rem;
}

/* Pagination */
.pagination {
  margin: 0;
  --cui-pagination-active-bg: var(--cui-primary);
  --cui-pagination-active-border-color: var(--cui-primary);
  --cui-pagination-focus-box-shadow: var(--mbt-focus-ring);
}

.pagination .page-link {
  border-radius: var(--mbt-radius-xs) !important;
  margin: 0 2px;
  font-size: .85rem;
}

.dropzone-hint {
  border: 2px dashed var(--cui-border-color);
  border-radius: var(--cui-border-radius-lg);
  padding: 1.5rem;
  text-align: center;
  color: var(--cui-secondary-color);
  background: var(--cui-tertiary-bg);
}

/* 16. Confirmation dialog (<x-admin.confirm-dialog>, confirm.js) ------------- */
.confirm-dialog {
  --dlg-tone: var(--mbt-red-rgb);
  --dlg-shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 12px 16px -4px rgba(16, 24, 40, .08), 0 32px 64px -12px rgba(16, 24, 40, .2);
}

.confirm-dialog.is-warning { --dlg-tone: var(--cui-warning-rgb); }
.confirm-dialog.is-info { --dlg-tone: 10, 102, 194; }
.confirm-dialog.is-success { --dlg-tone: 21, 128, 61; }

.confirm-dialog .modal-dialog {
  max-width: 25rem;
}

/* Short rise-in instead of CoreUI's slide-down. Translate only (no scale) so text never resamples,
   and the dialog rests at transform: none → pixel-sharp. Also disables CoreUI's static "bounce" scale. */
.confirm-dialog.fade .modal-dialog {
  transform: translateY(8px);
  transition: transform .18s ease-out;
}

.confirm-dialog.show .modal-dialog,
.confirm-dialog.modal-static .modal-dialog {
  transform: none;
}

.confirm-dialog.fade {
  transition: opacity .15s linear;
}

.confirm-dialog .modal-content {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--cui-border-color-translucent);
  border-radius: var(--mbt-radius-lg);
  background: var(--cui-body-bg);
  box-shadow: var(--dlg-shadow);
}

/* Blueprint grid across the header: tone glow from the top edge, fading down and toward the sides */
.confirm-dialog-deco {
  position: absolute;
  inset: 0 0 auto;
  height: 9rem;
  pointer-events: none;
  background:
    linear-gradient(90deg, transparent, rgba(var(--dlg-tone), .5) 50%, transparent) top / 100% 1px no-repeat,
    radial-gradient(75% 90% at 50% 0, rgba(var(--dlg-tone), .06), transparent 85%),
    linear-gradient(to right, rgba(var(--dlg-tone), .07) 1px, transparent 1px) center top / 1.25rem 1.25rem,
    linear-gradient(to bottom, rgba(var(--dlg-tone), .07) 1px, transparent 1px) center top / 1.25rem 1.25rem;
  -webkit-mask-image: radial-gradient(110% 100% at 50% 0, #000 30%, rgba(0, 0, 0, .35) 65%, transparent 100%);
  mask-image: radial-gradient(110% 100% at 50% 0, #000 30%, rgba(0, 0, 0, .35) 65%, transparent 100%);
}

.confirm-dialog-close {
  position: absolute;
  top: .875rem;
  right: .875rem;
  z-index: 2;
  width: 2rem;
  height: 2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: var(--mbt-radius);
  background: transparent;
  color: var(--cui-secondary-color);
  transition: background-color .15s, color .15s;
}

.confirm-dialog-close:hover {
  background: var(--cui-tertiary-bg);
  color: var(--cui-body-color);
}

.confirm-dialog-close:focus-visible {
  outline: 0;
  box-shadow: var(--mbt-focus-ring);
}

.confirm-dialog-body {
  position: relative;
  padding: 2.75rem 1.5rem 0;
}

.confirm-dialog-title {
  margin: 0;
  padding-right: 2rem; /* clear the close button */
  font-size: 1.0625rem;
  font-weight: 600;
  letter-spacing: -.01em;
  line-height: 1.4;
}

.confirm-dialog-message {
  margin: .375rem 0 0;
  color: var(--cui-secondary-color);
  font-size: .875rem;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.confirm-dialog-subject {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-top: 1rem;
  padding: .625rem .75rem;
  border: 1px solid var(--cui-border-color);
  border-radius: var(--mbt-radius);
  background: var(--cui-tertiary-bg);
}

.confirm-dialog-subject[hidden],
.confirm-dialog-note[hidden],
.confirm-dialog [hidden] {
  display: none;
}

.confirm-dialog-subject-icon {
  flex-shrink: 0;
  width: 2.25rem;
  height: 2.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--cui-border-color);
  border-radius: var(--mbt-radius-xs);
  background: var(--cui-body-bg);
  color: var(--cui-secondary-color);
  font-size: 1rem;
}

.confirm-dialog-subject strong,
.confirm-dialog-subject small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.confirm-dialog-subject strong {
  font-size: .875rem;
  font-weight: 600;
}

.confirm-dialog-subject small {
  margin-top: .125rem;
  color: var(--cui-secondary-color);
  font-size: .75rem;
}

.confirm-dialog-note {
  display: flex;
  gap: .5rem;
  margin: .875rem 0 0;
  color: rgb(var(--dlg-tone));
  font-size: .8125rem;
  line-height: 1.5;
}

.confirm-dialog-note i {
  margin-top: .2rem;
}

.confirm-dialog-footer {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .75rem;
  padding: 1.5rem;
}

.confirm-dialog-footer .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  min-height: 2.625rem;
  border-radius: var(--mbt-radius);
  font-size: .875rem;
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .05);
}

.confirm-dialog-footer .btn:focus-visible {
  box-shadow: 0 0 0 .2rem rgba(var(--dlg-tone), .25);
}

.confirm-dialog .confirm-dialog-cancel {
  border: 1px solid var(--cui-border-color);
  background: var(--cui-body-bg);
  color: var(--cui-body-color);
}

.confirm-dialog .confirm-dialog-cancel:hover,
.confirm-dialog .confirm-dialog-cancel:focus-visible {
  border-color: var(--cui-border-color);
  background: var(--cui-tertiary-bg);
  color: var(--cui-body-color);
}

.confirm-dialog .confirm-dialog-cancel:focus-visible {
  border-color: rgba(var(--cui-body-color-rgb), .35);
  box-shadow: 0 0 0 .2rem rgba(var(--cui-body-color-rgb), .08);
}

/* Solid button colours come from section 3 (white text on danger / success / info) */

.confirm-dialog [data-confirm-ok] .spinner-border {
  display: none;
}

.confirm-dialog.is-busy [data-confirm-ok] .spinner-border {
  display: inline-block;
}

.confirm-dialog.is-busy .btn:disabled {
  opacity: 1;
}

.confirm-dialog.is-busy .confirm-dialog-cancel:disabled,
.confirm-dialog.is-busy .confirm-dialog-close:disabled {
  opacity: .55;
}

/* Backdrop: plain navy veil. No backdrop-filter: blurring the whole page is costly (janky open)
   and makes everything behind look out of focus. */
.modal-backdrop {
  background-color: rgba(15, 23, 42, .5);
}

.modal-backdrop.fade {
  opacity: 0;
  transition: opacity .15s linear;
}

.modal-backdrop.show {
  opacity: 1;
}

[data-coreui-theme="dark"] .modal-backdrop {
  background-color: rgba(3, 7, 18, .6);
}

[data-coreui-theme="dark"] .confirm-dialog {
  --dlg-shadow: 0 0 0 1px rgba(255, 255, 255, .04), 0 32px 64px -12px rgba(0, 0, 0, .6);
}

[data-coreui-theme="dark"] .confirm-dialog .modal-content {
  background: var(--cui-tertiary-bg);
}

[data-coreui-theme="dark"] .confirm-dialog-subject-icon,
[data-coreui-theme="dark"] .confirm-dialog .confirm-dialog-cancel {
  background: var(--cui-body-bg);
}

[data-coreui-theme="dark"] .confirm-dialog-subject {
  background: rgba(255, 255, 255, .03);
}

@media (max-width: 575.98px) {
  .confirm-dialog .modal-dialog {
    margin: 1rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .confirm-dialog.fade,
  .confirm-dialog.fade .modal-dialog,
  .modal-backdrop.fade {
    transition: none;
  }
}

/* 17. Rich-text editor (CKEditor 5, admin.partials.editor) ------------------- */
/* html:root (0,1,1) beats ckeditor5.css :root, which is loaded after this file */
html:root {
  --ck-border-radius: var(--mbt-radius);
  --ck-font-face: var(--cui-body-font-family);
  --ck-font-size-base: 13px;
  --ck-color-focus-border: rgb(var(--mbt-red-rgb));
  --ck-color-focus-outer-shadow: rgba(var(--mbt-red-rgb), .15);
  --ck-focus-ring: 1px solid var(--ck-color-focus-border);
  --ck-color-button-on-color: var(--mbt-red);
  --ck-color-button-on-background: rgba(var(--mbt-red-rgb), .08);
  --ck-color-button-on-hover-background: rgba(var(--mbt-red-rgb), .14);
  --ck-color-link-default: var(--mbt-red);
  --ck-z-default: 1;
  --ck-z-panel: 1060; /* above the sticky header */
}

/* Dark theme: html[...] beats ckeditor5.css's :root (loaded later) */
html[data-coreui-theme="dark"] {
  --ck-color-base-foreground: #1f2838;
  --ck-color-base-background: var(--cui-body-bg);
  --ck-color-base-border: var(--cui-border-color);
  --ck-color-base-action: #3fb97a;
  --ck-color-base-active: #6f93ff;
  --ck-color-base-active-focus: #6f93ff;
  --ck-color-text: var(--cui-body-color);
  --ck-color-shadow-drop: rgba(0, 0, 0, .35);
  --ck-color-shadow-inner: rgba(0, 0, 0, .2);
  --ck-color-toolbar-background: var(--cui-tertiary-bg);
  --ck-color-toolbar-border: var(--cui-border-color);
  --ck-color-button-default-hover-background: #263045;
  --ck-color-button-default-active-background: #2c3750;
  --ck-color-button-on-background: rgba(111, 147, 255, .16);
  --ck-color-button-on-hover-background: rgba(111, 147, 255, .24);
  --ck-color-button-on-color: #f3a1a9;
  --ck-color-button-action-background: #6f93ff;
  --ck-color-dropdown-panel-background: var(--cui-body-bg);
  --ck-color-dropdown-panel-border: var(--cui-border-color);
  --ck-color-input-background: var(--cui-tertiary-bg);
  --ck-color-input-border: var(--cui-border-color);
  --ck-color-input-text: var(--cui-body-color);
  --ck-color-input-disabled-background: #1f2838;
  --ck-color-panel-background: var(--cui-body-bg);
  --ck-color-panel-border: var(--cui-border-color);
  --ck-color-list-background: var(--cui-body-bg);
  --ck-color-list-button-hover-background: #263045;
  --ck-color-list-button-on-background: rgba(111, 147, 255, .2);
  --ck-color-list-button-on-text: #f3a1a9;
  --ck-color-labeled-field-label-background: var(--cui-body-bg);
  --ck-color-tooltip-background: #0b1220;
  --ck-color-link-default: #f07884;
  --ck-color-widget-blurred-border: #3a465e;
  --ck-color-widget-hover-border: #6f93ff;
  --ck-color-widget-editable-focus-background: var(--cui-tertiary-bg);
  --ck-color-focus-border: #6f93ff;
}

.ck.ck-editor {
  width: 100%;
}

.ck.ck-editor__main > .ck-editor__editable {
  min-height: 26rem;
  max-height: 70vh;
  padding: .5rem 1.25rem;
  font-family: var(--cui-body-font-family);
  font-size: 1rem;
  line-height: 1.7;
}

.ck-preset-simple.ck.ck-editor .ck-editor__main > .ck-editor__editable {
  min-height: 12rem;
}

.ck.ck-editor__main > .ck-editor__editable:not(.ck-focused) {
  border-color: var(--cui-border-color);
}

.ck-content img {
  max-width: 100%;
  height: auto;
}

/* Legacy WordPress content carries fixed widths (width="1600", style="width:…px", chart iframes,
   wide tables): keep every block inside the editing area. */
.ck-content figure,
.ck-content iframe,
.ck-content video,
.ck-content embed,
.ck-content object,
.ck-content table,
.ck-content pre,
.ck-content [style*="width"],
.ck-content .html-object-embed,
.ck-content .raw-html-embed {
  max-width: 100%;
  box-sizing: border-box;
}

.ck-content figure.image {
  display: block;
}

.ck-content figure.table {
  overflow-x: auto;
}

.ck-content pre {
  white-space: pre-wrap;
}

.ck-content table td,
.ck-content table th {
  border: 1px solid var(--cui-border-color);
  padding: .4rem .6rem;
}

.ck.ck-editor__editable.ck-fullscreen {
  max-height: none;
}

/* Word count + lazy-activation bar under a field */
.editor-wordcount {
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
  padding: .3rem .75rem;
  border: 1px solid var(--cui-border-color);
  border-top: 0;
  border-radius: 0 0 var(--mbt-radius) var(--mbt-radius);
  background: var(--cui-tertiary-bg);
  color: var(--cui-secondary-color);
  font-size: .8125rem;
}

.editor-notice {
  margin-bottom: .75rem;
  font-size: .875rem;
}

textarea[data-editor] {
  font-family: SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: .8125rem;
}

/* In-place save feedback */
.btn.is-saving {
  pointer-events: none;
  opacity: .75;
}

.admin-toast {
  --cui-toast-bg: var(--cui-body-bg);
  min-width: 18rem;
  border-left: 3px solid var(--cui-success) !important;
  box-shadow: 0 12px 28px rgba(16, 24, 40, .16);
}

.admin-toast.is-success { border-left-color: var(--mbt-success) !important; }
.admin-toast.is-success .icon { color: var(--mbt-success); }
.admin-toast.is-danger { border-left-color: var(--mbt-danger) !important; }
.admin-toast.is-danger .icon { color: var(--mbt-danger); }
.admin-toast.is-warning { border-left-color: var(--cui-warning) !important; }
.admin-toast .icon { margin-top: .15rem; flex-shrink: 0; }

#admin-toasts {
  z-index: 1090;
}

/* 18. Media library (media.js: page + picker modal) ---------------------------- */
.media-browser {
  --media-tile: 9.5rem;
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.media-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem .75rem;
  padding: .875rem 1rem;
  border-bottom: 1px solid var(--cui-border-color);
}

.media-search { width: 16rem; max-width: 100%; }
.media-filter { width: auto; }

.media-uploads:empty { display: none; }
.media-uploads {
  display: grid;
  gap: .35rem;
  padding: .6rem 1rem;
  border-bottom: 1px solid var(--cui-border-color);
  background: var(--cui-tertiary-bg);
}

.media-upload {
  display: grid;
  grid-template-columns: minmax(0, 14rem) 1fr auto;
  align-items: center;
  gap: .75rem;
  font-size: .8125rem;
}

.media-upload .progress { height: .375rem; }
.media-upload-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-upload.is-done .progress-bar { background: var(--mbt-success); }
.media-upload.is-failed .progress-bar { width: 100% !important; background: var(--mbt-danger); }
.media-upload.is-failed .media-upload-status { color: var(--mbt-danger); }

.media-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 19rem;
  min-height: 0;
  flex: 1;
}

.media-pane {
  position: relative;
  padding: 1rem;
  min-height: 24rem;
}

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--media-tile), 1fr));
  gap: .75rem;
}

.media-item {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 0;
  border: 1px solid var(--cui-border-color);
  border-radius: var(--mbt-radius);
  background: var(--cui-tertiary-bg);
  overflow: hidden;
  text-align: left;
  transition: border-color .12s, box-shadow .12s;
}

.media-item img,
.media-item .media-doc {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
  background: repeating-conic-gradient(var(--cui-tertiary-bg) 0 25%, var(--cui-body-bg) 0 50%) 0 0 / 16px 16px;
}

.media-doc {
  display: flex !important;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .25rem;
  color: var(--cui-secondary-color);
  font-size: 1.75rem;
}

.media-doc strong { font-size: .75rem; letter-spacing: .05em; }

.media-item-name {
  padding: .35rem .5rem;
  font-size: .75rem;
  color: var(--cui-secondary-color);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: var(--cui-body-bg);
  border-top: 1px solid var(--cui-border-color);
}

.media-item:hover { border-color: rgba(var(--mbt-red-rgb), .45); }
.media-item:focus-visible { outline: 0; box-shadow: var(--mbt-focus-ring); }
.media-item.is-active { border-color: var(--mbt-red); box-shadow: 0 0 0 1px var(--mbt-red); }
.media-item.is-selected { border-color: var(--mbt-red); box-shadow: 0 0 0 2px var(--mbt-red); }

.media-check {
  position: absolute;
  top: .4rem;
  right: .4rem;
  width: 1.4rem;
  height: 1.4rem;
  display: none;
  align-items: center;
  justify-content: center;
  border-radius: var(--mbt-radius-xs);
  background: var(--mbt-red);
  color: #fff;
  font-size: .8rem;
}

.media-item.is-selected .media-check { display: inline-flex; }

.media-empty {
  padding: 3rem 1rem;
  text-align: center;
  color: var(--cui-secondary-color);
}

.media-sentinel { height: 1px; }
.media-browser.is-loading .media-sentinel { height: 3rem; background: center / 1.5rem no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='12' r='9' fill='none' stroke='%23d02030' stroke-width='3' stroke-dasharray='42 20'%3E%3CanimateTransform attributeName='transform' type='rotate' from='0 12 12' to='360 12 12' dur='.8s' repeatCount='indefinite'/%3E%3C/circle%3E%3C/svg%3E"); }

.media-drop {
  position: absolute;
  inset: .5rem;
  z-index: 5;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  border: 2px dashed var(--mbt-red);
  border-radius: var(--mbt-radius-lg);
  background: rgba(var(--mbt-red-rgb), .06);
  color: var(--mbt-red);
  font-weight: 600;
  font-size: 1.05rem;
  pointer-events: none;
}

.media-drop .icon { font-size: 2rem; }
.media-browser.is-dragging .media-drop { display: flex; }

.media-details {
  border-left: 1px solid var(--cui-border-color);
  padding: 1rem;
  background: var(--cui-tertiary-bg);
  overflow-y: auto;
}

.media-details-empty {
  height: 100%;
  min-height: 12rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--cui-secondary-color);
  font-size: .875rem;
}

.media-details-empty .icon { font-size: 2rem; opacity: .5; margin-bottom: .5rem; }

.media-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 4 / 3;
  margin-bottom: .875rem;
  border: 1px solid var(--cui-border-color);
  border-radius: var(--mbt-radius);
  background: repeating-conic-gradient(var(--cui-tertiary-bg) 0 25%, var(--cui-body-bg) 0 50%) 0 0 / 16px 16px;
  overflow: hidden;
}

.media-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }

.media-meta {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: .2rem .75rem;
  margin: 0 0 .875rem;
  font-size: .8125rem;
}

.media-meta dt { color: var(--cui-secondary-color); font-weight: 500; }
.media-meta dd { margin: 0; overflow-wrap: anywhere; }

.media-usages { margin-top: .5rem; padding-top: .75rem; border-top: 1px solid var(--cui-border-color); }
.media-usage { margin-bottom: .25rem; overflow-wrap: anywhere; }

/* Page: the browser fills the card */
.media-page .media-pane { max-height: calc(100vh - 17rem); overflow-y: auto; }
.media-page .media-details { max-height: calc(100vh - 17rem); }

/* Picker modal: fixed height, grid scrolls */
.media-picker .modal-body { display: flex; height: min(72vh, 46rem); }
.media-picker .media-browser { flex: 1; }
.media-picker .media-pane { overflow-y: auto; }
.media-picker .media-browser { --media-tile: 8.5rem; }

/* Library tiles appended to gallery / certificate forms */
.media-tile { position: relative; }
.media-tile-remove {
  position: absolute;
  top: .35rem;
  right: .35rem;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.media-tile-badge {
  position: absolute;
  left: .35rem;
  bottom: .35rem;
  padding: .1rem .4rem;
  border-radius: var(--mbt-radius-xs);
  background: rgba(15, 23, 42, .7);
  color: #fff;
  font-size: .7rem;
}

@media (max-width: 991.98px) {
  .media-main { grid-template-columns: 1fr; }
  .media-details { border-left: 0; border-top: 1px solid var(--cui-border-color); }
  .media-picker .modal-body { height: auto; min-height: 70vh; }
  .media-browser { --media-tile: 7rem; }
}

.activity-props { max-width: 28rem; white-space: normal; }

/* 19. Polish: shadcn look over the kept component styles above ------------ */

/* Quick search in the sidebar: an input-looking trigger ("Tìm kiếm… Ctrl K"), full-width box when open */
.sidebar .header-search {
  position: relative;
  display: block;
}

.sidebar .header-search-toggle {
  display: flex;
  align-items: center;
  gap: .5rem;
  width: 100%;
  height: 2.25rem;
  padding: 0 .5rem 0 .625rem !important;
  border: 1px solid var(--th-sidebar-border);
  border-radius: var(--th-radius-md) !important;
  background: var(--th-card);
  color: var(--th-muted-fg);
  font-size: .875rem;
  box-shadow: var(--th-shadow-sm);
  transition: border-color .15s;
}

.sidebar .header-search-toggle:hover {
  border-color: #c9cccf;
  color: var(--th-fg);
}

.sidebar .header-search-toggle kbd {
  margin-left: auto;
  padding: .05rem .35rem;
  border: 1px solid var(--th-border);
  border-radius: var(--th-radius-sm);
  background: var(--th-secondary);
  color: var(--th-muted-fg);
  font-size: .6875rem;
  box-shadow: none;
}

.sidebar .header-search.is-open .header-search-toggle {
  display: none;
}

.sidebar .header-search-box {
  height: 2.25rem;
  border-color: var(--th-input) !important;
  border-radius: var(--th-radius-md) !important;
  background: var(--th-card);
}

.sidebar .header-search.is-open .header-search-box {
  width: 100%;
  padding: 0 .25rem 0 .625rem;
  box-shadow: var(--th-focus);
}

.sidebar .header-search-results {
  top: calc(100% + .375rem);
  right: auto;
  left: 0;
  width: 20rem;
  padding: .25rem;
  border-color: var(--th-border);
  border-radius: var(--th-radius-md);
  box-shadow: var(--th-shadow-lg);
}

.header-search-results .search-item {
  border-radius: var(--th-radius-sm) !important;
}

.header-search-results .search-item.is-active,
.header-search-results .search-item:hover {
  background: var(--th-accent) !important;
  color: var(--th-fg) !important;
}

/* CRUD blocks */
.filter-bar { gap: .5rem; }

.filter-bar .input-group-text {
  border-right: 0;
  background: var(--th-card);
  color: var(--th-muted-fg);
}

.filter-bar .input-group .form-control {
  border-left: 0;
  padding-left: .125rem;
}

.filter-bar .input-group:focus-within {
  border-radius: var(--th-radius-md);
  box-shadow: var(--th-focus);
}

.filter-bar .input-group:focus-within .form-control { box-shadow: none; }

.card-body.border-bottom:has(> .filter-bar) {
  padding: .75rem 1rem;
}

.empty-state {
  padding: 3rem 1rem;
  color: var(--th-muted-fg);
}

.empty-state .fw-semibold {
  color: var(--th-fg);
  font-size: .9375rem;
}

.empty-state .stat-icon {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: var(--th-radius);
}

.check-list {
  padding: .5rem .75rem;
  border-color: var(--th-input);
  border-radius: var(--th-radius-md);
  background: var(--th-card);
}

.image-input-preview {
  border-color: var(--th-border);
  border-radius: var(--th-radius-md);
  background: var(--th-secondary);
}

/* Pagination (shadcn: ghost 36px, current page outlined) */
.pagination {
  --cui-pagination-color: var(--th-fg);
  --cui-pagination-bg: transparent;
  --cui-pagination-border-color: transparent;
  --cui-pagination-hover-color: var(--th-fg);
  --cui-pagination-hover-bg: var(--th-accent);
  --cui-pagination-hover-border-color: transparent;
  --cui-pagination-active-color: var(--th-fg);
  --cui-pagination-active-bg: var(--th-card);
  --cui-pagination-active-border-color: var(--th-input);
  --cui-pagination-disabled-color: var(--th-muted-fg);
  --cui-pagination-disabled-bg: transparent;
  --cui-pagination-disabled-border-color: transparent;
  --cui-pagination-focus-box-shadow: var(--th-focus);
  gap: .25rem;
}

.pagination .page-link {
  display: grid;
  place-items: center;
  min-width: 2.25rem;
  height: 2.25rem;
  margin: 0;
  padding: 0 .5rem;
  border-radius: var(--th-radius-sm) !important;
  font-size: .875rem;
}

/* Lists inside cards (dashboard, settings tabs) */
.card .list-group-item {
  border-color: var(--th-border);
  color: var(--th-fg);
}

.card .list-group-item:not(.active) { background: transparent; }

.list-group-item.active,
.list-group-item-action.active {
  border-color: var(--th-border);
  background: var(--th-secondary);
  color: var(--th-fg);
  font-weight: 500;
}

.list-group-item-action:hover:not(.active) {
  background: var(--th-accent);
  color: var(--th-fg);
}

.progress {
  --cui-progress-height: .5rem;
  --cui-progress-bg: var(--th-secondary);
  --cui-progress-border-radius: 999px;
  --cui-progress-bar-bg: var(--th-primary);
}

/* Dialogs (shadcn Dialog) */
.modal {
  --cui-modal-bg: var(--th-card);
  --cui-modal-border-color: var(--th-border);
  --cui-modal-border-radius: var(--th-radius);
  --cui-modal-inner-border-radius: calc(var(--th-radius) - 1px);
  --cui-modal-header-border-color: var(--th-border);
  --cui-modal-footer-border-color: var(--th-border);
  --cui-modal-box-shadow: var(--th-shadow-lg);
}

.modal-backdrop { --cui-backdrop-bg: #000; --cui-backdrop-opacity: .8; }

.modal-title { font-size: 1.125rem; font-weight: 600; letter-spacing: -.01em; }

/* Toast */
.admin-toast {
  border: 1px solid var(--th-border) !important;
  border-radius: var(--th-radius) !important;
  background: var(--th-card) !important;
  box-shadow: var(--th-shadow-lg) !important;
}

/* Avatars */
.user-avatar { border-radius: var(--th-radius); }

/* Kbd */
kbd {
  border-radius: var(--th-radius-sm);
}

.sidebar .header-search:not(.is-open) .header-search-box { display: none; }
.card-header-tabs .badge::before { display: none !important; }
.card-footer:not(:has(*)) { display: none; }

/* Input groups: buttons take the input height (40px) */
.input-group > .btn {
  height: auto;
  border-color: var(--th-input);
}

/* Switch: wider track than CoreUI's default, so the label moves right */
.form-switch {
  min-height: 1.25rem;
  padding-left: 2.75rem;
}

.form-switch .form-check-input {
  margin-top: .05rem;
  margin-left: -2.75rem;
}

/* 20. DatePicker (datepicker.js) = shadcn DatePicker + Calendar, as in adlux-promax ------------------ */
.dp {
  position: relative;
  display: block;
}

.filter-bar .dp { display: inline-block; flex: 0 1 11rem; }

.dp-trigger {
  display: flex;
  align-items: center;
  gap: .5rem;
  width: 100%;
  height: 2.5rem;
  padding: 0 .5rem 0 .75rem;
  border: 1px solid var(--th-input);
  border-radius: var(--th-radius-md);
  background: var(--th-card);
  color: var(--th-fg);
  font-size: .875rem;
  font-weight: 400;
  text-align: left;
  white-space: nowrap;
  transition: background .15s, box-shadow .15s;
}

.dp-trigger:hover { background: var(--th-accent); }
.dp-trigger:focus-visible, .dp-trigger[aria-expanded="true"] { outline: 0; box-shadow: var(--th-focus); }
.dp-trigger.is-invalid { border-color: var(--th-destructive); }
.dp-trigger > .icon:first-child { opacity: .6; }
.dp-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.dp-trigger.is-empty .dp-label { color: var(--th-muted-fg); }

.dp-clear {
  display: grid;
  place-items: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: var(--th-radius-sm);
  color: var(--th-muted-fg);
}

.dp-clear:hover { background: var(--th-secondary); color: var(--th-fg); }
.dp-trigger.is-empty .dp-clear { display: none; }
.dp-clear .icon { width: .875rem; height: .875rem; }

.dp:has(.is-invalid) ~ .invalid-feedback { display: block; }

.dp-pop {
  position: absolute;
  top: calc(100% + .25rem);
  left: 0;
  z-index: 1080;
  width: max-content;
  padding: .75rem;
  border: 1px solid var(--th-border);
  border-radius: var(--th-radius-md);
  background: var(--th-card);
  color: var(--th-fg);
  box-shadow: var(--th-shadow-md);
}

.dp-pop.is-up { top: auto; bottom: calc(100% + .25rem); }

.dp-head {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 1.75rem;
  margin-bottom: 1rem;
}

.dp-caption { font-size: .875rem; font-weight: 500; }

.dp-nav {
  position: absolute;
  top: 0;
  display: grid;
  place-items: center;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  border: 1px solid var(--th-input);
  border-radius: var(--th-radius-sm);
  background: transparent;
  color: var(--th-fg);
  opacity: .5;
  transition: opacity .15s, background .15s;
}

.dp-nav:hover { background: var(--th-accent); opacity: 1; }
.dp-prev { left: .25rem; }
.dp-next { right: .25rem; }

.dp-grid {
  display: grid;
  grid-template-columns: repeat(7, 2.25rem);
  row-gap: .5rem;
}

.dp-dow {
  color: var(--th-muted-fg);
  font-size: .8rem;
  text-align: center;
}

.dp-day {
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: 0;
  border-radius: var(--th-radius-md);
  background: transparent;
  color: var(--th-fg);
  font-size: .875rem;
  font-variant-numeric: tabular-nums;
  transition: background .1s;
}

.dp-day:hover { background: var(--th-accent); color: var(--th-accent-fg); }
.dp-day:focus-visible { outline: 0; box-shadow: var(--th-focus); }
.dp-day.is-today { background: var(--th-accent); color: var(--th-accent-fg); }
.dp-day.is-outside { color: var(--th-muted-fg); opacity: .5; }

.dp-day.is-selected,
.dp-day.is-selected:hover {
  background: var(--th-primary);
  color: var(--th-primary-fg);
  opacity: 1;
}

.dp-time {
  display: flex;
  align-items: center;
  gap: .375rem;
  margin-top: .75rem;
  padding-top: .75rem;
  border-top: 1px solid var(--th-border);
}

.dp-time > .icon { color: var(--th-muted-fg); }
.dp-time-label { margin-right: auto; color: var(--th-muted-fg); font-size: .8125rem; }
.dp-time-sep { color: var(--th-muted-fg); }

.dp-time .form-select {
  width: 4.25rem;
  min-height: 2rem;
  height: 2rem;
  padding: 0 1.75rem 0 .5rem;
  background-position: right .4rem center;
  font-variant-numeric: tabular-nums;
}

.dp-foot {
  display: flex;
  justify-content: space-between;
  gap: .5rem;
  margin-top: .75rem;
}

/* ---- Admin language switch EN / VI (layouts/app, top right of every page) ---- */
.admin-lang {
  display: flex;
  justify-content: flex-end;
  gap: 2px;
  width: max-content;
  margin: 0 0 .5rem auto;
  padding: 2px;
  border: 1px solid var(--th-border);
  border-radius: 6px;
  background: var(--th-card);
}
.admin-lang button {
  min-width: 2.25rem;
  height: 1.75rem;
  padding: 0 .5rem;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--cui-secondary-color);
  font-size: .75rem;
  font-weight: 600;
}
.admin-lang button:hover { color: var(--cui-body-color); }
.admin-lang button.is-active { background: var(--cui-body-color); color: var(--th-card); }


/* ---- "Dịch sang tiếng Anh" at the right end of the language tabs (translate.js): black, inverted on hover ---- */
.locale-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1rem; }
.locale-row > .locale-tabs { margin-bottom: 0 !important; }
.translate-btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  height: 2rem;
  padding: 0 .85rem;
  border: 1px solid var(--cui-body-color);
  border-radius: 4px;
  background: var(--cui-body-color);
  color: var(--th-card);
  font-size: .8125rem;
  font-weight: 600;
  transition: background .15s, color .15s;
}
.translate-btn:hover:not(:disabled) { background: var(--th-card); color: var(--cui-body-color); }
.translate-btn:disabled { opacity: .6; cursor: progress; }
.translate-status:empty { display: none; }
.translate-status { margin: -.5rem 0 .75rem; color: var(--cui-secondary-color); }
.ck.ck-editor.is-invalid { outline: 1px solid var(--cui-form-invalid-border-color, #dc3545); border-radius: 4px; }
