/* =====================================================================
   Agro Software — Design System
   Built on Bootstrap 4.0 beta. One source of truth for tokens, layout,
   and components. Loaded after Bootstrap / Select2 / DataTables so it
   can restyle them without !important.
   ===================================================================== */

/* ---------------------------------------------------------------------
   1. Tokens
   --------------------------------------------------------------------- */
:root {
  /* brand — green scheme (matches the login page: #2e8b3d / #1f6b2e / #4caf50) */
  --rp-primary: #2e8b3d;
  --rp-primary-600: #257534;
  --rp-primary-700: #1f6b2e;
  --rp-primary-100: #e1f2e4;
  --rp-primary-50: #f1f9f2;
  --rp-accent: #7ab929;
  --rp-accent-600: #659c1f;
  --rp-accent-100: #ebf5da;

  /* semantic */
  --rp-success: #16a34a;
  --rp-success-100: #dcfce7;
  --rp-warning: #d97706;
  --rp-warning-100: #fef3c7;
  --rp-danger: #dc2626;
  --rp-danger-100: #fee2e2;
  --rp-info: #0e7490;
  --rp-info-100: #cffafe;

  /* neutrals */
  --rp-bg: #f3f5f9;
  --rp-surface: #ffffff;
  --rp-surface-2: #f8fafc;
  --rp-border: #e3e8ef;
  --rp-border-strong: #cbd5e1;
  --rp-text: #1b2a3b;
  --rp-text-2: #334155;
  --rp-muted: #64748b;
  --rp-muted-2: #94a3b8;

  /* sidebar */
  --rp-sidebar-bg: #1c4f2a;
  --rp-sidebar-bg-2: #153d20;
  --rp-sidebar-text: #c3dcc8;
  --rp-sidebar-hover: rgba(255, 255, 255, 0.06);
  --rp-sidebar-active: rgba(122, 185, 41, 0.22);

  /* geometry */
  --rp-radius: 10px;
  --rp-radius-sm: 6px;
  --rp-radius-lg: 14px;
  --rp-shadow-xs: 0 1px 2px rgba(16, 24, 40, 0.05);
  --rp-shadow-sm: 0 1px 3px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.04);
  --rp-shadow: 0 4px 12px rgba(16, 24, 40, 0.08);
  --rp-shadow-lg: 0 20px 40px rgba(16, 24, 40, 0.16);
  --rp-focus: 0 0 0 3px rgba(46, 139, 61, 0.22);

  --rp-sidebar-w: 264px;
  --rp-sidebar-mini-w: 76px;
  --rp-topbar-h: 64px;
  --rp-gutter: 24px;

  --rp-font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --rp-t-fast: 140ms ease;
  --rp-t: 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* ---------------------------------------------------------------------
   2. Base
   --------------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 14px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--rp-font);
  font-size: 0.9286rem; /* 13px */
  line-height: 1.55;
  color: var(--rp-text);
  background: var(--rp-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
  color: var(--rp-text);
  font-weight: 600;
  line-height: 1.3;
  margin: 0 0 0.5rem;
}

h1 { font-size: 1.5rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.125rem; }
h4 { font-size: 1rem; }
h5 { font-size: 0.9286rem; }
h6 { font-size: 0.8571rem; }

a {
  color: var(--rp-primary);
  text-decoration: none;
  transition: color var(--rp-t-fast);
}
a:hover { color: var(--rp-primary-600); text-decoration: none; }
a:focus { outline: none; }

hr {
  border: 0;
  border-top: 1px solid var(--rp-border);
  margin: 1rem 0;
}

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

small, .small { font-size: 0.8571rem; }

::selection { background: var(--rp-primary-100); color: var(--rp-primary-700); }

/* Keyboard focus — visible ring for every focusable control */
a:focus-visible,
button:focus-visible,
[tabindex]:focus-visible {
  outline: none;
  box-shadow: var(--rp-focus);
  border-radius: var(--rp-radius-sm);
}

/* Screen-reader only */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* ---------------------------------------------------------------------
   3. App shell: sidebar + topbar + content
   --------------------------------------------------------------------- */
.app-shell { min-height: 100vh; }

/* Sidebar ----------------------------------------------------------- */
.app-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--rp-sidebar-w);
  background: linear-gradient(180deg, var(--rp-sidebar-bg) 0%, var(--rp-sidebar-bg-2) 100%);
  color: var(--rp-sidebar-text);
  z-index: 1030;
  display: flex;
  flex-direction: column;
  transition: width var(--rp-t), transform var(--rp-t);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  height: var(--rp-topbar-h);
  padding: 0 16px;
  background: rgba(0, 0, 0, 0.12);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.18);
  flex: 0 0 auto;
}
.sidebar-brand a {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #fff;
  min-width: 0;
  padding: 4px;
  margin: -4px;
  border-radius: var(--rp-radius);
  transition: background var(--rp-t-fast);
}
.sidebar-brand a:hover { color: #fff; background: var(--rp-sidebar-hover); }
.sidebar-brand a:hover .brand-mark { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.3); }
.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(145deg, var(--rp-accent) 0%, var(--rp-primary) 100%);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.3);
  color: #fff;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  overflow: hidden;
  transition: transform var(--rp-t), box-shadow var(--rp-t);
}
.brand-mark svg { width: 22px; height: 22px; fill: currentColor; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.2)); }
.brand-mark img { width: 100%; height: 100%; object-fit: contain; }
.brand-text { line-height: 1.15; min-width: 0; }
.brand-text strong {
  display: block;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand-text span {
  display: block;
  margin-top: 2px;
  font-size: 0.6786rem;
  font-weight: 500;
  color: rgba(195, 220, 200, 0.7);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-close {
  margin-left: auto;
  background: transparent;
  border: 0;
  color: var(--rp-sidebar-text);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: none;
  place-items: center;
  cursor: pointer;
}
.sidebar-close:hover { background: var(--rp-sidebar-hover); color: #fff; }

.sidebar-scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 12px 24px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}
.sidebar-scroll::-webkit-scrollbar { width: 6px; }
.sidebar-scroll::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.15); border-radius: 6px; }

.nav-section {
  font-size: 0.6786rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(182, 197, 216, 0.55);
  padding: 18px 12px 6px;
  white-space: nowrap;
}

.side-menu,
.side-menu ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.side-menu > li { margin: 2px 0; }
.side-menu a {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--rp-sidebar-text);
  font-weight: 500;
  white-space: nowrap;
  transition: background var(--rp-t-fast), color var(--rp-t-fast);
}
.side-menu a:hover { background: var(--rp-sidebar-hover); color: #fff; }
.side-menu a:focus-visible { box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.35); }
.side-menu .nav-icon {
  width: 22px;
  flex: 0 0 22px;
  text-align: center;
  font-size: 1.05rem;
  color: rgba(182, 197, 216, 0.85);
  transition: color var(--rp-t-fast);
}
.side-menu a:hover .nav-icon { color: #fff; }
.side-menu .nav-label {
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
}
.side-menu .nav-count {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--rp-accent);
  color: var(--rp-sidebar-bg-2);
  font-size: 0.7143rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.side-menu .nav-count:empty,
.side-menu .nav-count[data-zero="1"] { display: none; }
.side-menu .nav-arrow {
  font-size: 0.8571rem;
  color: rgba(182, 197, 216, 0.7);
  transition: transform var(--rp-t);
}
.side-menu > li.open > a .nav-arrow { transform: rotate(90deg); }

.side-menu > li > a.active,
.side-menu > li.open > a {
  color: #fff;
}
.side-menu > li > a.active {
  background: var(--rp-sidebar-active);
}
.side-menu > li > a.active::before {
  content: "";
  position: absolute;
  left: -12px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--rp-accent);
}
.side-menu > li > a.active .nav-icon { color: var(--rp-accent); }

.side-menu .nav-sub {
  display: none;
  padding: 4px 0 4px 0;
  margin-left: 22px;
  border-left: 1px solid rgba(255, 255, 255, 0.08);
}
.side-menu > li.open > .nav-sub { display: block; }
.side-menu .nav-sub a {
  padding: 7px 12px 7px 20px;
  font-weight: 400;
  font-size: 0.8929rem;
  color: rgba(182, 197, 216, 0.85);
}
.side-menu .nav-sub a::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 50%;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0;
  transform: translateY(-50%);
  transition: opacity var(--rp-t-fast);
}
.side-menu .nav-sub a.active {
  color: #fff;
  background: var(--rp-sidebar-hover);
}
.side-menu .nav-sub a.active::before,
.side-menu .nav-sub a:hover::before { opacity: 1; }
.side-menu .nav-sub .nav-icon { display: none; }

.sidebar-foot {
  flex: 0 0 auto;
  padding: 12px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 0.75rem;
  color: rgba(182, 197, 216, 0.6);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(21, 61, 32, 0.5);
  backdrop-filter: blur(2px);
  z-index: 1029;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--rp-t), visibility var(--rp-t);
}

/* Topbar ------------------------------------------------------------ */
.topbar {
  position: fixed;
  top: 0;
  right: 0;
  left: var(--rp-sidebar-w);
  height: var(--rp-topbar-h);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--rp-border);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 var(--rp-gutter);
  z-index: 1020;
  transition: left var(--rp-t);
}
.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1 1 auto;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 0;
  background: transparent;
  color: var(--rp-text-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.0714rem;
  cursor: pointer;
  position: relative;
  transition: background var(--rp-t-fast), color var(--rp-t-fast);
}
.icon-btn:hover { background: var(--rp-primary-50); color: var(--rp-primary); }
.icon-btn .dot {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--rp-danger);
  box-shadow: 0 0 0 2px #fff;
}

.topbar-titles { min-width: 0; }
.breadcrumb-rp {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.7857rem;
  color: var(--rp-muted);
  margin: 0;
  padding: 0;
  list-style: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.breadcrumb-rp li { display: inline-flex; align-items: center; gap: 6px; }
.breadcrumb-rp li + li::before {
  content: "/";
  color: var(--rp-border-strong);
}
.breadcrumb-rp a { color: var(--rp-muted); }
.breadcrumb-rp a:hover { color: var(--rp-primary); }
.topbar-title {
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
  color: var(--rp-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar .dropdown-menu {
  margin-top: 8px;
  min-width: 240px;
}
.user-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 4px 4px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  color: var(--rp-text);
  transition: background var(--rp-t-fast), border-color var(--rp-t-fast);
}
.user-btn:hover,
.user-btn[aria-expanded="true"] { background: var(--rp-primary-50); border-color: var(--rp-border); }
/* Bootstrap's reboot paints a dark `outline: 5px auto` ring on plain :focus and
   dropdown.js focuses the toggle on open — keep the ring for keyboard only. */
.user-btn:focus,
.icon-btn:focus { outline: 0; box-shadow: none; }
.user-btn:focus-visible { box-shadow: var(--rp-focus); border-radius: 12px; }
.icon-btn:focus-visible { box-shadow: var(--rp-focus); border-radius: 10px; }
.user-btn::after { display: none; }
.avatar {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--rp-primary) 0%, var(--rp-accent) 140%);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8571rem;
  flex: 0 0 auto;
}
.avatar-lg { width: 56px; height: 56px; border-radius: 14px; font-size: 1.2rem; }
.user-btn .user-meta {
  text-align: left;
  line-height: 1.2;
}
.user-btn .user-meta strong { display: block; font-size: 0.8571rem; }
.user-btn .user-meta span { display: block; font-size: 0.7143rem; color: var(--rp-muted); }
.user-btn .fa-angle-down { color: var(--rp-muted); }

.dropdown-header-rp {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--rp-border);
}
.dropdown-header-rp > div { min-width: 0; }
.dropdown-header-rp strong { display: block; font-size: 0.9286rem; }
.dropdown-header-rp > div span { display: block; color: var(--rp-muted); font-size: 0.7857rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.notif-list { max-height: 360px; overflow-y: auto; }
.notif-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  color: var(--rp-text);
  transition: background var(--rp-t-fast);
}
.notif-item:hover { background: var(--rp-primary-50); color: var(--rp-text); }
.notif-item .notif-icon {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--rp-primary-100);
  color: var(--rp-primary);
  flex: 0 0 auto;
}
.notif-item .notif-body { flex: 1 1 auto; min-width: 0; }
.notif-item .notif-body strong { display: block; font-size: 0.8571rem; font-weight: 600; }
.notif-item .notif-body span { display: block; font-size: 0.7857rem; color: var(--rp-muted); }
.notif-item .badge { flex: 0 0 auto; }
.notif-empty {
  padding: 28px 16px;
  text-align: center;
  color: var(--rp-muted);
  font-size: 0.8571rem;
}
.notif-empty i { display: block; font-size: 1.6rem; margin-bottom: 6px; color: var(--rp-muted-2); }

/* Content ------------------------------------------------------------ */
.content-wrapper {
  margin-left: var(--rp-sidebar-w);
  padding-top: var(--rp-topbar-h);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left var(--rp-t);
}
.page-content {
  flex: 1 0 auto;
  padding: var(--rp-gutter);
  max-width: 1600px;
  width: 100%;
}
.app-footer {
  flex: 0 0 auto;
  padding: 14px var(--rp-gutter);
  border-top: 1px solid var(--rp-border);
  color: var(--rp-muted);
  font-size: 0.7857rem;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  justify-content: space-between;
  background: transparent;
}
.app-footer a { color: var(--rp-text-2); font-weight: 500; }

/* Collapsed sidebar (desktop) */
@media (min-width: 992px) {
  body.sidebar-mini .app-sidebar { width: var(--rp-sidebar-mini-w); }
  body.sidebar-mini .topbar { left: var(--rp-sidebar-mini-w); }
  body.sidebar-mini .content-wrapper { margin-left: var(--rp-sidebar-mini-w); }
  body.sidebar-mini .brand-text,
  body.sidebar-mini .nav-section,
  body.sidebar-mini .sidebar-foot,
  body.sidebar-mini .side-menu .nav-label,
  body.sidebar-mini .side-menu .nav-arrow,
  body.sidebar-mini .side-menu > li > a .nav-count { display: none; }
  body.sidebar-mini .sidebar-brand { padding: 0; justify-content: center; }
  body.sidebar-mini .sidebar-scroll { padding: 12px 10px; overflow: visible; }
  body.sidebar-mini .side-menu a { justify-content: center; padding: 11px 0; }
  body.sidebar-mini .side-menu > li > a.active::before { left: -10px; }
  body.sidebar-mini .side-menu > li { position: relative; }
  body.sidebar-mini .side-menu .nav-sub {
    display: none;
    position: absolute;
    left: calc(100% + 6px);
    top: 0;
    min-width: 220px;
    margin: 0;
    padding: 8px;
    border: 0;
    border-radius: 10px;
    background: var(--rp-sidebar-bg);
    box-shadow: var(--rp-shadow-lg);
  }
  body.sidebar-mini .side-menu .nav-sub::before {
    content: "";
    position: absolute;
    left: -8px;
    top: 0;
    bottom: 0;
    width: 8px;
  }
  body.sidebar-mini .side-menu > li:hover > .nav-sub { display: block; }
  body.sidebar-mini .side-menu .nav-sub a { justify-content: flex-start; padding: 8px 12px 8px 22px; }
  body.sidebar-mini .side-menu .nav-sub a .nav-label,
  body.sidebar-mini .side-menu .nav-sub a .nav-count { display: inline-flex; }
  body.sidebar-mini .side-menu > li > a[data-tip]:hover::after {
    content: attr(data-tip);
    position: absolute;
    left: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%);
    background: var(--rp-sidebar-bg);
    color: #fff;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 0.7857rem;
    white-space: nowrap;
    box-shadow: var(--rp-shadow);
    pointer-events: none;
  }
  body.sidebar-mini .side-menu > li.has-sub > a[data-tip]:hover::after { display: none; }
}

/* Mobile drawer */
@media (max-width: 991.98px) {
  :root { --rp-gutter: 16px; }
  .app-sidebar { transform: translateX(-100%); width: min(300px, 86vw); box-shadow: none; }
  body.sidebar-open .app-sidebar { transform: translateX(0); box-shadow: var(--rp-shadow-lg); }
  body.sidebar-open .sidebar-backdrop { opacity: 1; visibility: visible; }
  body.sidebar-open { overflow: hidden; }
  .sidebar-close { display: grid; }
  .topbar { left: 0; }
  .content-wrapper { margin-left: 0; }
  .user-btn .user-meta,
  .user-btn .fa-angle-down { display: none; }
  .user-btn { padding: 2px; }
}

/* ---------------------------------------------------------------------
   4. Page header + cards (ibox is the legacy card name used by views)
   --------------------------------------------------------------------- */
.page-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px 16px;
  margin-bottom: 20px;
}
.page-header .page-title {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0;
  font-size: 1.2857rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  flex: 1 1 auto;
  min-width: 0;
}
.page-title .title-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--rp-primary-100);
  color: var(--rp-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex: 0 0 auto;
}
.page-title .title-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.page-header .page-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
/* page header placed inside the card acts as the card head */
.ibox > .page-header,
.card > .page-header {
  margin: 0;
  padding: 14px 20px;
  border-bottom: 1px solid var(--rp-border);
}
.ibox > .page-header .page-title { font-size: 1.1429rem; }
.ibox > .page-header .title-icon { width: 36px; height: 36px; border-radius: 9px; }
.ibox > .page-header + .alert { margin-top: 16px; }

.ibox,
.card {
  position: relative;
  background: var(--rp-surface);
  border: 1px solid var(--rp-border);
  border-radius: var(--rp-radius);
  box-shadow: var(--rp-shadow-xs);
  margin-bottom: 20px;
}
.ibox { padding: 0; }
.card { padding: 0; }
.ibox-head,
.card-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 16px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--rp-border);
}
.ibox-title,
.card-head .card-title {
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 auto;
}
.ibox-title .fa { color: var(--rp-primary); }
.ibox-head > div:last-child,
.card-head .card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-left: auto;
}
.ibox-body,
.card-body {
  padding: 20px;
}
.card-sub {
  color: var(--rp-muted);
  font-size: 0.8571rem;
  margin: 2px 0 0;
}
.card-body > .row > .card { margin-bottom: 0; }
/* legacy "card2" filter wrapper */
.card2 { background: transparent; border: 0; }

.section-title {
  font-size: 0.7857rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--rp-muted);
  margin: 4px 0 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--rp-border);
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-title .fa { color: var(--rp-primary); }

/* Entrance animation used on every page-content (keeps legacy class) */
.fade-in-up { animation: rpFadeUp 0.28s ease-out; }
@keyframes rpFadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .fade-in-up { animation: none; }
  * { transition-duration: 0.01ms !important; }
}

/* ---------------------------------------------------------------------
   5. Buttons
   --------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 36px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 0.8571rem;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.005em;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition: background var(--rp-t-fast), color var(--rp-t-fast), border-color var(--rp-t-fast), box-shadow var(--rp-t-fast), transform var(--rp-t-fast);
}
.btn .fa { font-size: 0.9286rem; }
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:focus,
.btn.focus { outline: 0; box-shadow: var(--rp-focus); }
.btn:disabled,
.btn.disabled { opacity: 0.55; cursor: not-allowed; transform: none; box-shadow: none; }

.btn-sm { height: 30px; padding: 0 10px; font-size: 0.7857rem; border-radius: 7px; }
.btn-lg { height: 44px; padding: 0 20px; font-size: 0.9286rem; border-radius: 10px; }
.btn-block { width: 100%; display: flex; }
.btn-icon { width: 36px; padding: 0; }
.btn-icon.btn-sm { width: 30px; }

.btn-primary { background: var(--rp-primary); color: #fff; border-color: var(--rp-primary); }
.btn-primary:hover { background: var(--rp-primary-600); border-color: var(--rp-primary-600); color: #fff; }
.btn-primary:not(:disabled):not(.disabled):active,
.btn-primary:not(:disabled):not(.disabled).active { background: var(--rp-primary-700); border-color: var(--rp-primary-700); color: #fff; }

.btn-secondary { background: #e9eef5; color: var(--rp-text-2); border-color: #e9eef5; }
.btn-secondary:hover { background: #dde5ef; border-color: #dde5ef; color: var(--rp-text); }

.btn-success { background: var(--rp-success); color: #fff; border-color: var(--rp-success); }
.btn-success:hover { background: #15803d; border-color: #15803d; color: #fff; }

.btn-danger { background: var(--rp-danger); color: #fff; border-color: var(--rp-danger); }
.btn-danger:hover { background: #b91c1c; border-color: #b91c1c; color: #fff; }

.btn-warning { background: var(--rp-warning); color: #fff; border-color: var(--rp-warning); }
.btn-warning:hover { background: #b45309; border-color: #b45309; color: #fff; }

.btn-info { background: var(--rp-info); color: #fff; border-color: var(--rp-info); }
.btn-info:hover { background: #155e75; border-color: #155e75; color: #fff; }

.btn-accent { background: var(--rp-accent); color: #fff; border-color: var(--rp-accent); }
.btn-accent:hover { background: var(--rp-accent-600); border-color: var(--rp-accent-600); color: #fff; }

.btn-light { background: var(--rp-surface); color: var(--rp-text-2); border-color: var(--rp-border); }
.btn-light:hover { background: var(--rp-surface-2); color: var(--rp-text); border-color: var(--rp-border-strong); }

.btn-outline-primary { background: transparent; color: var(--rp-primary); border-color: var(--rp-primary); }
.btn-outline-primary:hover { background: var(--rp-primary); color: #fff; }
.btn-outline-secondary { background: var(--rp-surface); color: var(--rp-text-2); border-color: var(--rp-border-strong); }
.btn-outline-secondary:hover { background: var(--rp-surface-2); color: var(--rp-text); border-color: var(--rp-muted-2); }
.btn-outline-success { background: transparent; color: var(--rp-success); border-color: var(--rp-success); }
.btn-outline-success:hover { background: var(--rp-success); color: #fff; }
.btn-outline-danger { background: transparent; color: var(--rp-danger); border-color: var(--rp-danger); }
.btn-outline-danger:hover { background: var(--rp-danger); color: #fff; }
.btn-outline-info { background: transparent; color: var(--rp-info); border-color: var(--rp-info); }
.btn-outline-info:hover { background: var(--rp-info); color: #fff; }
.btn-outline-warning { background: transparent; color: var(--rp-warning); border-color: var(--rp-warning); }
.btn-outline-warning:hover { background: var(--rp-warning); color: #fff; }

.btn-link { background: transparent; color: var(--rp-primary); border-color: transparent; padding: 0 4px; }
.btn-link:hover { color: var(--rp-primary-600); text-decoration: underline; }

/* soft (tinted) buttons */
.btn-soft-primary { background: var(--rp-primary-100); color: var(--rp-primary); border-color: transparent; }
.btn-soft-primary:hover { background: var(--rp-primary); color: #fff; }
.btn-soft-success { background: var(--rp-success-100); color: #15803d; border-color: transparent; }
.btn-soft-success:hover { background: var(--rp-success); color: #fff; }
.btn-soft-danger { background: var(--rp-danger-100); color: #b91c1c; border-color: transparent; }
.btn-soft-danger:hover { background: var(--rp-danger); color: #fff; }
.btn-soft-info { background: var(--rp-info-100); color: var(--rp-info); border-color: transparent; }
.btn-soft-info:hover { background: var(--rp-info); color: #fff; }

/* Legacy "btn bg-*" buttons (used in modals rendered by controllers) */
.btn.bg-primary { background: var(--rp-primary) !important; color: #fff; }
.btn.bg-primary:hover { background: var(--rp-primary-600) !important; }
.btn.bg-success { background: var(--rp-success) !important; color: #fff; }
.btn.bg-success:hover { background: #15803d !important; }
.btn.bg-danger { background: var(--rp-danger) !important; color: #fff; }
.btn.bg-danger:hover { background: #b91c1c !important; }
/* …but "Close" buttons in modal footers should always be quiet */
.modal-footer .btn[data-dismiss="modal"] {
  background: var(--rp-surface) !important;
  color: var(--rp-text-2);
  border-color: var(--rp-border-strong);
}
.modal-footer .btn[data-dismiss="modal"]:hover { background: var(--rp-surface-2) !important; color: var(--rp-text); }
.modal-footer .btn-sm { height: 36px; padding: 0 14px; font-size: 0.8571rem; }

/* loading state: <button class="btn btn-primary is-loading"> */
.btn.is-loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-loading::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: #fff;
  border-radius: 50%;
  animation: rpSpin 0.7s linear infinite;
}
.btn-outline-primary.is-loading::after,
.btn-outline-secondary.is-loading::after,
.btn-light.is-loading::after { border-color: rgba(46, 139, 61, 0.25); border-top-color: var(--rp-primary); }
@keyframes rpSpin { to { transform: rotate(360deg); } }

.btn-group .btn + .btn { margin-left: -1px; }

/* ---------------------------------------------------------------------
   6. Forms
   --------------------------------------------------------------------- */
label,
.form-label {
  display: inline-block;
  margin-bottom: 7px;
  font-size: 0.8214rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--rp-text-2);
}
/* Required marker: `<label>Text <span class="text-danger">*</span></label>` (489 labels).
   Must stay inline — the inline-validation rule further down makes stray
   span.text-danger blocks, so every marker selector here is deliberately more
   specific than that one. */
label > .text-danger,
label > .req,
label > .text-Reporting,
label > span > .text-danger,
label > #required > .text-danger {
  display: inline;
  margin: 0 0 0 2px;
  padding: 0;
  font-size: inherit;
  font-weight: 700;
  line-height: inherit;
  color: var(--rp-danger);
}
label > #required { display: inline; }

.form-control,
.custom-select,
select.form-control,
textarea.form-control {
  display: block;
  width: 100%;
  height: 38px;
  padding: 0 12px;
  font-family: inherit;
  font-size: 0.8929rem;
  font-weight: 400;
  line-height: 1.4;
  color: var(--rp-text);
  background: var(--rp-surface);
  border: 1px solid var(--rp-border-strong);
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
  transition: border-color var(--rp-t-fast), box-shadow var(--rp-t-fast), background var(--rp-t-fast);
  -webkit-appearance: none;
  appearance: none;
}
textarea.form-control { height: auto; min-height: 96px; padding: 10px 12px; line-height: 1.5; resize: vertical; }
.form-control::placeholder { color: var(--rp-muted-2); opacity: 1; }
.form-control:hover:not(:disabled):not([readonly]):not(:focus) { border-color: var(--rp-muted-2); }
.form-control:focus,
.custom-select:focus {
  border-color: var(--rp-primary);
  box-shadow: var(--rp-focus);
  outline: 0;
  background: #fff;
  color: var(--rp-text);
}.form-control:disabled,
.form-control[readonly] {
  background: var(--rp-surface-2);
  color: var(--rp-muted);
  border-color: var(--rp-border);
  cursor: not-allowed;
}
.form-control[readonly]:not(:disabled) { cursor: default; }
.form-control-sm { height: 32px; padding: 0 10px; font-size: 0.8214rem; border-radius: 7px; }
.form-control-lg { height: 44px; padding: 0 14px; font-size: 0.9643rem; border-radius: 10px; }

select.form-control:not([multiple]),
.custom-select {
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='none' stroke='%2364748b' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' d='M2.5 4.5l3.5 3.5 3.5-3.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px;
}
select.form-control[multiple] { height: auto; min-height: 96px; padding: 6px; }
select.form-control option { padding: 6px 8px; }

input[type="date"].form-control,
input[type="time"].form-control,
input[type="datetime-local"].form-control { padding-right: 8px; cursor: pointer; }
input[type="date"].form-control[readonly],
input[type="time"].form-control[readonly],
input[type="datetime-local"].form-control[readonly] { cursor: default; }
input[type="date"].form-control::-webkit-calendar-picker-indicator,
input[type="time"].form-control::-webkit-calendar-picker-indicator {
  opacity: 0.6;
  cursor: pointer;
  width: 16px;
  height: 16px;
}
input[type="number"].form-control { -moz-appearance: textfield; }

/* native file input (fallback before RP.forms.fileInputs() upgrades it) */
input[type="file"].form-control {
  padding: 0;
  height: 38px;
  line-height: 36px;
  overflow: hidden;
  cursor: pointer;
  color: var(--rp-muted);
}
input[type="file"].form-control::file-selector-button,
input[type="file"].form-control::-webkit-file-upload-button {
  height: 36px;
  margin: 0 12px 0 0;
  padding: 0 14px;
  border: 0;
  border-right: 1px solid var(--rp-border-strong);
  background: var(--rp-surface-2);
  color: var(--rp-text-2);
  font-family: inherit;
  font-size: 0.8214rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--rp-t-fast);
}
input[type="file"].form-control:hover::file-selector-button,
input[type="file"].form-control:hover::-webkit-file-upload-button { background: var(--rp-primary-100); color: var(--rp-primary); }

/* Upload drop-zone: RP.forms.fileInputs() wraps `input[type=file].form-control`
   as  .file-drop > input + .file-drop-body + .file-drop-file
   The real input stays in the DOM, stretched invisibly over the zone, so
   click-to-browse, drag & drop, `required` validation and the form post all
   remain native. */
.file-drop {
  position: relative;
  border: 1.5px dashed var(--rp-border-strong);
  border-radius: var(--rp-radius);
  background: var(--rp-surface-2);
  transition: border-color var(--rp-t-fast), background var(--rp-t-fast), box-shadow var(--rp-t-fast);
}
.file-drop > input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  opacity: 0;
  border: 0;
  cursor: pointer;
  z-index: 2;
}
.file-drop > input[type="file"]:disabled { cursor: not-allowed; }
.file-drop:hover,
.file-drop.is-dragover { border-color: var(--rp-primary); background: var(--rp-primary-50); }
.file-drop.is-dragover { box-shadow: var(--rp-focus); border-style: solid; }
.file-drop:focus-within { border-color: var(--rp-primary); box-shadow: var(--rp-focus); }
.file-drop.is-invalid,
.file-drop.has-error { border-color: var(--rp-danger); }
.file-drop.is-disabled { opacity: 0.6; }

.file-drop-body {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 62px;
  padding: 10px 14px;
  pointer-events: none;
}
.file-drop-icon {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: var(--rp-primary-100);
  color: var(--rp-primary);
  font-size: 1.1rem;
  transition: transform var(--rp-t-fast);
}
.file-drop:hover .file-drop-icon,
.file-drop.is-dragover .file-drop-icon { transform: translateY(-1px) scale(1.04); }
.file-drop-text { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.file-drop-text strong { font-size: 0.8571rem; font-weight: 600; color: var(--rp-text); }
.file-drop-text strong em { font-style: normal; color: var(--rp-primary); }
.file-drop-hint { font-size: 0.75rem; color: var(--rp-muted); }

/* selected file */
.file-drop-file {
  display: none;
  align-items: center;
  gap: 12px;
  min-height: 62px;
  padding: 10px 14px;
  position: relative;
  z-index: 3;
  pointer-events: none; /* clicks/drops fall through to the input… */
}
.file-drop-actions { pointer-events: auto; } /* …except on the buttons */
.file-drop.has-file { border-style: solid; background: var(--rp-surface); }
.file-drop.has-file .file-drop-body { display: none; }
.file-drop.has-file .file-drop-file { display: flex; }
.file-drop-thumb {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  border: 1px solid var(--rp-border);
  background: var(--rp-surface-2) center / cover no-repeat;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--rp-muted);
  font-size: 1.1rem;
  overflow: hidden;
}
.file-drop-thumb.is-image { color: transparent; }
.file-drop-meta { min-width: 0; flex: 1 1 auto; display: flex; flex-direction: column; gap: 2px; }
.file-drop-name {
  font-size: 0.8571rem;
  font-weight: 600;
  color: var(--rp-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-drop-size { font-size: 0.75rem; color: var(--rp-muted); }
.file-drop-size .fa-check-circle { color: var(--rp-success); margin-right: 3px; }
.file-drop-actions { display: flex; gap: 4px; flex: 0 0 auto; }
.file-drop-btn {
  height: 30px;
  padding: 0 10px;
  border: 1px solid var(--rp-border);
  border-radius: 7px;
  background: var(--rp-surface);
  color: var(--rp-text-2);
  font-family: inherit;
  font-size: 0.7857rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: background var(--rp-t-fast), color var(--rp-t-fast), border-color var(--rp-t-fast);
}
.file-drop-btn:hover { background: var(--rp-primary-50); color: var(--rp-primary); border-color: var(--rp-primary-100); }
.file-drop-btn.is-remove:hover { background: var(--rp-danger-100); color: var(--rp-danger); border-color: var(--rp-danger-100); }
.file-drop-btn:focus-visible { outline: 0; box-shadow: var(--rp-focus); }
@media (max-width: 575.98px) {
  .file-drop-body, .file-drop-file { padding: 10px 12px; }
  .file-drop-hint { display: none; }
}

.form-group { margin-bottom: 16px; }
.form-group.row { margin-bottom: 0; }
.form-group.row > [class*="col-"] { margin-bottom: 18px; }
.form-group.row > [class*="col-"].mb-4 { margin-bottom: 18px !important; }
.form-text,
.help-text { display: block; margin-top: 5px; font-size: 0.7857rem; color: var(--rp-muted); }

/* inline validation messages emitted by page scripts (span.text-danger placed
   next to an input — never the marker inside a <label>, see label rules above) */
.form-group > span.text-danger:not(:empty),
[class*="col-"] > span.text-danger:not(:empty),
[class*="col-"] > span:not(.text-danger) > span.text-danger:not(:empty),
label.error,
.help-block {
  display: block;
  margin-top: 5px;
  font-size: 0.7857rem;
  font-weight: 500;
  color: var(--rp-danger);
}
label.error { font-weight: 500; }
.has-error .form-control,
.form-control.error,
.form-control.is-invalid { border-color: var(--rp-danger); }
.has-error .form-control:focus,
.form-control.error:focus,
.form-control.is-invalid:focus { box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.16); }
.form-control.is-valid { border-color: var(--rp-success); }

/* input with leading icon: .input-icon-wrap > .fa + .form-control */
.input-icon-wrap { position: relative; }
.input-icon-wrap > .fa {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--rp-muted-2);
  pointer-events: none;
  transition: color var(--rp-t-fast);
}
.input-icon-wrap > .form-control { padding-left: 36px; }
.input-icon-wrap > .form-control:focus ~ .fa,
.input-icon-wrap:focus-within > .fa { color: var(--rp-primary); }
.input-icon-wrap .input-suffix-btn {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--rp-muted);
  cursor: pointer;
}
.input-icon-wrap .input-suffix-btn:hover { background: var(--rp-primary-50); color: var(--rp-primary); }

.input-group .form-control { border-radius: 8px; }
.input-group > .form-control:not(:last-child) { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-group > .form-control:not(:first-child) { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.input-group-append .btn,
.input-group-prepend .btn { height: 38px; }
.input-group-text {
  background: var(--rp-surface-2);
  border: 1px solid var(--rp-border-strong);
  color: var(--rp-muted);
  border-radius: 8px;
  font-size: 0.8571rem;
}

/* checkbox / radio / switch */
input[type="checkbox"],
input[type="radio"] {
  width: 16px;
  height: 16px;
  accent-color: var(--rp-primary);
  vertical-align: -3px;
  margin-right: 6px;
  cursor: pointer;
}
.check-inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  color: var(--rp-text-2);
  cursor: pointer;
  margin: 0;
}
.check-inline input { margin: 0; }
.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-weight: 500;
  margin: 0;
}
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track {
  width: 38px;
  height: 22px;
  border-radius: 999px;
  background: var(--rp-border-strong);
  position: relative;
  transition: background var(--rp-t-fast);
  flex: 0 0 auto;
}
.switch .track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--rp-shadow-sm);
  transition: transform var(--rp-t-fast);
}
.switch input:checked + .track { background: var(--rp-primary); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { box-shadow: var(--rp-focus); }

/* form footer */
.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  padding-top: 18px;
  margin-top: 6px;
  border-top: 1px solid var(--rp-border);
}
.form-actions .btn { min-width: 110px; }
/* every add/edit form sits directly in an .ibox-body → render the actions as a
   footer bar that spans the card */
.ibox-body > form > .form-actions,
.card-body > form > .form-actions {
  margin: 8px -20px -20px;
  padding: 14px 20px;
  background: var(--rp-surface-2);
  border-radius: 0 0 var(--rp-radius) var(--rp-radius);
}
.form-actions .form-required-note {
  margin-left: auto;
  font-size: 0.7857rem;
  color: var(--rp-muted);
}
.form-actions .form-required-note .text-danger { font-weight: 700; margin-right: 2px; }
@media (max-width: 575.98px) {
  .form-actions .btn { flex: 1 1 auto; }
  .form-actions .form-required-note { flex-basis: 100%; margin-left: 0; text-align: center; }
}

/* form grid: a touch more breathing room between fields than the 15px gutter */
.ibox-body > form > .form-group.row { margin-left: -12px; margin-right: -12px; }
.ibox-body > form > .form-group.row > [class*="col-"] { padding-left: 12px; padding-right: 12px; }

/* legacy: "lable" typo in state modal, and .textarea used in remark modals */
lable { display: block; margin-bottom: 6px; font-size: 0.8214rem; font-weight: 600; color: var(--rp-text-2); }
textarea.textarea {
  display: block;
  width: 100%;
  min-height: 120px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 0.8929rem;
  color: var(--rp-text);
  border: 1px solid var(--rp-border-strong);
  border-radius: 8px;
  resize: vertical;
  transition: border-color var(--rp-t-fast), box-shadow var(--rp-t-fast);
}
textarea.textarea:focus { outline: 0; border-color: var(--rp-primary); box-shadow: var(--rp-focus); }

/* Import button: hidden file input triggered by a label */
.import-form { display: inline-flex; align-items: center; gap: 8px; margin: 0; }
.import-form input[type="file"] { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; pointer-events: none; }
.import-form label { margin: 0; cursor: pointer; }
.import-form label:focus-within { box-shadow: var(--rp-focus); }

/* tables inside forms (repeaters) */
form .table-bordered.mt-0 { margin-top: 0; }
form .table-bordered th { background: var(--rp-surface-2); }
form .table-bordered td { vertical-align: middle; }
form .table-bordered .btn-sm { height: 30px; }

/* ---------------------------------------------------------------------
   7. Toolbar: import / export / date filters
   --------------------------------------------------------------------- */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--rp-border);
  background: var(--rp-surface-2);
}
.toolbar-group {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px;
}
.toolbar-group.toolbar-io { margin-left: auto; }
.toolbar .filter-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px 12px;
  margin: 0;
}
.toolbar .filter-field { min-width: 150px; flex: 1 1 150px; }
.toolbar .filter-field label {
  display: block;
  font-size: 0.7143rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--rp-muted);
  margin-bottom: 4px;
}
.toolbar .filter-field .form-control { height: 36px; }
.toolbar .filter-actions { display: flex; gap: 6px; }

/* ---------------------------------------------------------------------
   8. Tables + DataTables
   --------------------------------------------------------------------- */
.table-responsive {
  display: block;
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 0 0 var(--rp-radius) var(--rp-radius);
}
.table-responsive > .table { margin-bottom: 0; }

.table {
  width: 100%;
  margin-bottom: 0;
  color: var(--rp-text);
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.8571rem;
}
.table thead th {
  padding: 11px 14px;
  font-size: 0.7143rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--rp-muted);
  background: var(--rp-surface-2);
  border: 0;
  border-bottom: 1px solid var(--rp-border);
  white-space: nowrap;
  vertical-align: middle;
}
.table tbody td {
  padding: 11px 14px;
  border: 0;
  border-bottom: 1px solid var(--rp-border);
  vertical-align: middle;
  white-space: nowrap;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table-hover tbody tr:hover td { background: var(--rp-primary-50); }
.table-striped tbody tr:nth-of-type(odd) td { background: transparent; }
.table-striped.table-hover tbody tr:hover td { background: var(--rp-primary-50); }
.table-bordered { border: 1px solid var(--rp-border); border-radius: var(--rp-radius-sm); }
.table-bordered th,
.table-bordered td { border: 1px solid var(--rp-border) !important; }
.table td.wrap,
.table th.wrap { white-space: normal; }
.table .w-min { width: 1%; }
.table img { border-radius: 6px; }

/* Row action buttons — the controllers emit <a class="text-* h4"> icons;
   app.js wraps them in .table-actions and this makes them tinted icon
   buttons (soft fill at rest, solid fill on hover/focus) */
.table-actions {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  justify-content: center;
}
.table-actions > a,
.table td > a.h4,
.table td.h4 > a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  font-size: 0.8929rem;
  margin: 0;
  line-height: 1;
  color: var(--rp-text-2);
  background: var(--rp-surface-2);
  border: 1px solid var(--rp-border);
  text-decoration: none;
  transition: background var(--rp-t-fast), color var(--rp-t-fast), border-color var(--rp-t-fast), box-shadow var(--rp-t-fast), transform var(--rp-t-fast);
}
.table td > a.h4 .fa,
.table td.h4 > a .fa,
.table-actions > a .fa { font-size: 0.9286rem; }
.table-actions > a:focus { outline: 0; box-shadow: var(--rp-focus); }
.table-actions > a:hover,
.table td > a.h4:hover,
.table td.h4 > a:hover { color: #fff !important; background: var(--rp-primary); border-color: var(--rp-primary); box-shadow: var(--rp-shadow-sm); transform: translateY(-1px); text-decoration: none; }
/* View */
.table-actions > a.text-warning,
.table td > a.h4.text-warning { color: var(--rp-warning) !important; background: var(--rp-warning-100); border-color: transparent; }
.table-actions > a.text-warning:hover,
.table td > a.h4.text-warning:hover { color: #fff !important; background: var(--rp-warning); border-color: var(--rp-warning); }
/* Edit */
.table-actions > a.text-info,
.table-actions > a.text-primary,
.table td > a.h4.text-info,
.table td > a.text-primary { color: var(--rp-primary) !important; background: var(--rp-primary-100); border-color: transparent; }
.table-actions > a.text-info:hover,
.table-actions > a.text-primary:hover,
.table td > a.h4.text-info:hover,
.table td > a.text-primary:hover { color: #fff !important; background: var(--rp-primary); border-color: var(--rp-primary); }
/* Remark / approve */
.table-actions > a.text-success,
.table td > a.h4.text-success { color: var(--rp-success) !important; background: var(--rp-success-100); border-color: transparent; }
.table-actions > a.text-success:hover,
.table td > a.h4.text-success:hover { color: #fff !important; background: var(--rp-success); border-color: var(--rp-success); }
/* Delete / location */
.table-actions > a.text-danger,
.table td > a.h4.text-danger { color: var(--rp-danger) !important; background: var(--rp-danger-100); border-color: transparent; }
.table-actions > a.text-danger:hover,
.table td > a.h4.text-danger:hover { color: #fff !important; background: var(--rp-danger); border-color: var(--rp-danger); }
/* legacy cells in hand-written tables: <td class="text-center h4"> */
.table td.h4 { font-size: inherit; font-weight: inherit; }
.table td.h4 > a { margin: 0 2px; }
/* compact pill buttons that some controllers emit in data cells (status toggles etc.) */
.table td > .btn {
  height: 28px;
  padding: 0 10px;
  font-size: 0.75rem;
  line-height: 1;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* Action column: pinned to the right edge of the scroll container so the
   buttons stay reachable on wide tables; the shadow appears only while
   more columns are hidden behind it (see RP.tables.watchScroll) */
.table th.col-actions,
.table td.col-actions {
  position: -webkit-sticky;
  position: sticky;
  right: 0;
  z-index: 2;
  text-align: center;
  width: 1%;
  background: var(--rp-surface);
  transition: box-shadow var(--rp-t-fast);
}
.table th.col-actions { background: var(--rp-surface-2); z-index: 3; }
table.dataTable thead th.col-actions.sorting_disabled { padding-right: 14px; }
.table-hover tbody tr:hover td.col-actions { background: var(--rp-primary-50); }
.is-scrollable-x .table th.col-actions,
.is-scrollable-x .table td.col-actions { box-shadow: -8px 0 12px -8px rgba(16, 24, 40, 0.18); }
.is-scrollable-x .table th.col-actions::before,
.is-scrollable-x .table td.col-actions::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--rp-border);
}

/* Column picker ("Columns" dropdown next to the search box) */
.dt-top-right {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}
.dt-tools { display: inline-flex; align-items: center; gap: 8px; }
.dt-tools:empty { display: none; }
.dt-colpicker { position: relative; }
.dt-colpicker > .btn {
  height: 36px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8214rem;
  border-radius: 8px;
}
.dt-colpicker > .btn::after { display: none; }
.dt-colpicker .badge {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  font-size: 0.6786rem;
  font-weight: 600;
  background: var(--rp-primary-100);
  color: var(--rp-primary-700);
}
.dt-colpicker .badge:empty { display: none; }
.dt-colpicker .dropdown-menu {
  min-width: 240px;
  max-height: 360px;
  overflow-y: auto;
  padding: 6px 0;
  border: 1px solid var(--rp-border);
  border-radius: var(--rp-radius);
  box-shadow: var(--rp-shadow-lg);
  font-size: 0.8571rem;
}
.dt-colpicker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 14px 8px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--rp-border);
  font-size: 0.7143rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--rp-muted);
}
.dt-colpicker-head a { font-weight: 600; letter-spacing: 0; text-transform: none; font-size: 0.7857rem; }
.dt-colpicker-item {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 7px 14px;
  cursor: pointer;
  color: var(--rp-text);
  font-weight: 500;
  white-space: nowrap;
}
.dt-colpicker-item:hover { background: var(--rp-primary-50); }
.dt-colpicker-item input { margin: 0; accent-color: var(--rp-primary); }
.dt-colpicker-item .is-optional { margin-left: auto; font-size: 0.6786rem; color: var(--rp-muted-2); font-weight: 500; }

/* DataTables chrome */
.dataTables_wrapper {
  padding: 0;
}
.dataTables_wrapper .row { margin: 0; align-items: center; }
.dataTables_wrapper .row > [class*="col-"] { padding: 0; }
.dataTables_wrapper .row:first-child { padding: 14px 20px 6px; gap: 10px 0; }
.dataTables_wrapper .row:last-child { padding: 12px 20px 16px; border-top: 1px solid var(--rp-border); gap: 10px 0; }
.dataTables_wrapper .table { margin-top: 8px; }
.ibox-body-table { overflow-x: auto; }
.dataTables_length label,
.dataTables_filter label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-weight: 500;
  color: var(--rp-muted);
  font-size: 0.8214rem;
}
.dataTables_length select {
  height: 34px;
  padding: 0 28px 0 10px;
  border-radius: 7px;
  border: 1px solid var(--rp-border-strong);
  background-color: #fff;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='none' stroke='%2364748b' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' d='M2.5 4.5l3.5 3.5 3.5-3.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  font-family: inherit;
  font-size: 0.8214rem;
  color: var(--rp-text);
  -webkit-appearance: none;
  appearance: none;
}
.dataTables_filter { text-align: right; }
.dataTables_filter label { position: relative; }
.dataTables_filter label::before {
  content: "\f002";
  font-family: FontAwesome;
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--rp-muted-2);
  font-size: 0.8571rem;
  pointer-events: none;
}
.dataTables_filter input {
  height: 36px;
  width: 240px;
  max-width: 100%;
  padding: 0 12px 0 32px;
  border-radius: 8px;
  border: 1px solid var(--rp-border-strong);
  font-family: inherit;
  font-size: 0.8571rem;
  margin: 0 !important;
  transition: border-color var(--rp-t-fast), box-shadow var(--rp-t-fast);
}
.dataTables_filter input:focus { outline: 0; border-color: var(--rp-primary); box-shadow: var(--rp-focus); }
.dataTables_info { color: var(--rp-muted); font-size: 0.8214rem; padding-top: 0 !important; }
.dataTables_paginate { text-align: right; }
.dataTables_wrapper .pagination { margin: 0; justify-content: flex-end; gap: 4px; flex-wrap: wrap; }
.page-item .page-link,
.page-link {
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px !important;
  border: 1px solid transparent;
  color: var(--rp-text-2);
  font-size: 0.8214rem;
  font-weight: 500;
  background: transparent;
  margin: 0;
  transition: background var(--rp-t-fast), color var(--rp-t-fast);
}
.page-link:hover { background: var(--rp-primary-100); color: var(--rp-primary); border-color: transparent; }
.page-link:focus { box-shadow: var(--rp-focus); outline: 0; }
.page-item.active .page-link { background: var(--rp-primary); color: #fff; border-color: var(--rp-primary); }
.page-item.disabled .page-link { color: var(--rp-muted-2); background: transparent; }
table.dataTable thead .sorting,
table.dataTable thead .sorting_asc,
table.dataTable thead .sorting_desc { background-image: none !important; padding-right: 26px; position: relative; cursor: pointer; }
table.dataTable thead .sorting::after,
table.dataTable thead .sorting_asc::after,
table.dataTable thead .sorting_desc::after {
  content: "\f0dc";
  font-family: FontAwesome;
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--rp-muted-2);
  font-size: 0.7857rem;
}
table.dataTable thead .sorting_asc::after { content: "\f0de"; color: var(--rp-primary); top: 55%; }
table.dataTable thead .sorting_desc::after { content: "\f0dd"; color: var(--rp-primary); top: 45%; }
table.dataTable thead .sorting_disabled { padding-right: 14px; }
table.dataTable.no-footer { border-bottom: 0; }
table.dataTable tbody tr { background: transparent; }
table.dataTable tbody td.dataTables_empty {
  padding: 48px 20px;
  text-align: center;
  color: var(--rp-muted);
  white-space: normal;
}
table.dataTable tbody td.dataTables_empty::before {
  content: "\f1c3";
  font-family: FontAwesome;
  display: block;
  font-size: 2rem;
  color: var(--rp-border-strong);
  margin-bottom: 8px;
}
.dataTables_processing {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: auto;
  height: auto;
  margin: 0 !important;
  padding: 10px 18px;
  border-radius: 8px;
  background: var(--rp-surface);
  border: 1px solid var(--rp-border);
  box-shadow: var(--rp-shadow);
  font-size: 0.8214rem;
  font-weight: 600;
  color: var(--rp-text-2);
  z-index: 5;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.dataTables_processing::before {
  content: "";
  width: 14px;
  height: 14px;
  border: 2px solid var(--rp-primary-100);
  border-top-color: var(--rp-primary);
  border-radius: 50%;
  animation: rpSpin 0.7s linear infinite;
}
.dataTables_wrapper .table-responsive { position: relative; }
.dataTables_wrapper.dt-loading .table tbody { opacity: 0.45; }
table.dataTable.fixedHeader-floating { box-shadow: var(--rp-shadow); }
table.dataTable.fixedHeader-floating thead th { background: var(--rp-surface-2); }

/* scroll hint on narrow screens */
.table-scroll-hint {
  display: none;
  align-items: center;
  gap: 6px;
  padding: 6px 20px 0;
  font-size: 0.7143rem;
  color: var(--rp-muted);
}
@media (max-width: 767.98px) {
  .table-scroll-hint { display: flex; }
  .dataTables_wrapper .row:first-child { padding: 12px 16px 4px; }
  .dataTables_wrapper .row:last-child { padding: 12px 16px; }
  .dataTables_filter,
  .dataTables_paginate { text-align: left; margin-top: 8px; }
  .dataTables_filter label { width: 100%; }
  .dataTables_filter input { width: 100%; }
  .dataTables_wrapper .pagination { justify-content: flex-start; }
  .table thead th,
  .table tbody td { padding: 10px 12px; }
}

/* ---------------------------------------------------------------------
   9. Badges & status
   --------------------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.7143rem;
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: 0.01em;
  vertical-align: middle;
}
.badge-primary { background: var(--rp-primary-100); color: var(--rp-primary-700); }
.badge-success { background: var(--rp-success-100); color: #166534; }
.badge-danger { background: var(--rp-danger-100); color: #991b1b; }
.badge-warning { background: var(--rp-warning-100); color: #92400e; }
.badge-info { background: var(--rp-info-100); color: #155e75; }
.badge-secondary,
.badge-light { background: #e9eef5; color: var(--rp-text-2); }
.badge-dark { background: var(--rp-text); color: #fff; }
.badge-dot::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* ---------------------------------------------------------------------
   10. Alerts & toasts
   --------------------------------------------------------------------- */
.alert {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 40px 12px 14px;
  margin: 0 0 16px;
  border: 1px solid transparent;
  border-radius: var(--rp-radius-sm);
  font-size: 0.8571rem;
  font-weight: 500;
  line-height: 1.45;
}
.alert::before {
  font-family: FontAwesome;
  font-size: 1rem;
  line-height: 1.2;
  flex: 0 0 auto;
}
.alert-success { background: var(--rp-success-100); color: #166534; border-color: #bbf7d0; }
.alert-success::before { content: "\f058"; }
.alert-danger { background: var(--rp-danger-100); color: #991b1b; border-color: #fecaca; }
.alert-danger::before { content: "\f071"; }
.alert-warning { background: var(--rp-warning-100); color: #92400e; border-color: #fde68a; }
.alert-warning::before { content: "\f06a"; }
.alert-info { background: var(--rp-info-100); color: #155e75; border-color: #a5f3fc; }
.alert-info::before { content: "\f05a"; }
.alert p:last-child { margin-bottom: 0; }
.alert .close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: inherit;
  opacity: 0.6;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  text-shadow: none;
  float: none;
}
.alert .close:hover { opacity: 1; background: rgba(0, 0, 0, 0.06); }
/* alerts rendered inside .ibox before the body (flash messages) */
.ibox > .alert { margin: 16px 20px 0; }

/* Toast stack (flash messages are moved here by app.js) */
.toast-stack {
  position: fixed;
  top: calc(var(--rp-topbar-h) + 12px);
  right: 16px;
  z-index: 1080;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(380px, calc(100vw - 32px));
  pointer-events: none;
}
.toast-stack .alert {
  pointer-events: auto;
  margin: 0;
  background: var(--rp-surface);
  box-shadow: var(--rp-shadow-lg);
  border-left-width: 4px;
  animation: rpToastIn 0.25s ease-out;
}
.toast-stack .alert-success { border-left-color: var(--rp-success); color: var(--rp-text); }
.toast-stack .alert-success::before { color: var(--rp-success); }
.toast-stack .alert-danger { border-left-color: var(--rp-danger); color: var(--rp-text); }
.toast-stack .alert-danger::before { color: var(--rp-danger); }
.toast-stack .alert-warning { border-left-color: var(--rp-warning); color: var(--rp-text); }
.toast-stack .alert-warning::before { color: var(--rp-warning); }
.toast-stack .alert-info { border-left-color: var(--rp-info); color: var(--rp-text); }
.toast-stack .alert-info::before { color: var(--rp-info); }
.toast-stack .alert.is-leaving { animation: rpToastOut 0.25s ease-in forwards; }
@keyframes rpToastIn { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }
@keyframes rpToastOut { to { opacity: 0; transform: translateX(16px); } }

/* ---------------------------------------------------------------------
   11. Modals & dropdowns
   --------------------------------------------------------------------- */
.modal-backdrop { background: var(--rp-sidebar-bg-2); }
.modal-backdrop.show { opacity: 0.55; }
.modal-dialog { margin: 1.5rem auto; max-width: 520px; }
.modal-lg { max-width: 860px; }
.modal-sm { max-width: 400px; }
.modal-content {
  border: 0;
  border-radius: var(--rp-radius-lg);
  box-shadow: var(--rp-shadow-lg);
  overflow: hidden;
}
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--rp-border);
  align-items: center;
}
.modal-title { font-size: 1rem; font-weight: 600; margin: 0; }
.modal-header .close {
  margin: -6px -8px -6px auto;
  padding: 0;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--rp-muted);
  font-size: 1.4rem;
  font-weight: 400;
  line-height: 1;
  opacity: 1;
  text-shadow: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background var(--rp-t-fast), color var(--rp-t-fast);
}
.modal-header .close:hover { background: var(--rp-surface-2); color: var(--rp-text); opacity: 1; }
.modal-body {
  padding: 20px !important;
  max-height: calc(100vh - 180px);
  overflow-y: auto;
  font-size: 0.8929rem;
  color: var(--rp-text-2);
}
.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--rp-border);
  background: var(--rp-surface-2);
  gap: 8px;
}
.modal-body .row + .row { margin-top: 12px; }
.modal-body .row > [class*="col-"] { margin-bottom: 0; }
.modal-body label { margin-bottom: 6px; }
.modal-body select.form-control { width: 100% !important; }
.modal-footer > :not(:last-child) { margin-right: 0; }
.modal-footer > :not(:first-child) { margin-left: 0; }
.modal-content > img { display: block; width: 100%; }
.modal.fade .modal-dialog { transform: translateY(-8px) scale(0.98); transition: transform 0.2s ease-out; }
.modal.show .modal-dialog { transform: none; }
@media (max-width: 575.98px) {
  .modal-dialog { margin: 12px; max-width: none; }
  .modal-body { max-height: calc(100vh - 160px); }
  .modal-footer { flex-wrap: wrap; }
  .modal-footer .btn { flex: 1 1 auto; }
}

.dropdown-menu {
  border: 1px solid var(--rp-border);
  border-radius: 12px;
  box-shadow: var(--rp-shadow-lg);
  padding: 6px;
  font-size: 0.8571rem;
  min-width: 200px;
}
.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--rp-text-2);
  font-weight: 500;
  transition: background var(--rp-t-fast), color var(--rp-t-fast);
}
.dropdown-item .fa { width: 16px; text-align: center; color: var(--rp-muted); }
.dropdown-item:hover,
.dropdown-item:focus { background: var(--rp-primary-50); color: var(--rp-primary); }
.dropdown-item:hover .fa { color: var(--rp-primary); }
.dropdown-item.active,
.dropdown-item:active { background: var(--rp-primary-100); color: var(--rp-primary); }
.dropdown-item.text-danger:hover { background: var(--rp-danger-100); color: var(--rp-danger) !important; }
.dropdown-item.text-danger .fa { color: inherit; }
.dropdown-divider { margin: 6px 0; border-top-color: var(--rp-border); }
.dropdown-menu .dropdown-header {
  padding: 8px 12px 4px;
  font-size: 0.7143rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--rp-muted);
  font-weight: 700;
}
.dropdown-menu-right { right: 0; left: auto; }

/* Tooltips */
.tooltip { font-family: var(--rp-font); font-size: 0.7857rem; }
.tooltip-inner { background: var(--rp-text); border-radius: 6px; padding: 5px 9px; }
.tooltip.bs-tooltip-top .arrow::before { border-top-color: var(--rp-text); }
.tooltip.bs-tooltip-bottom .arrow::before { border-bottom-color: var(--rp-text); }

/* ---------------------------------------------------------------------
   12. Select2 (default theme restyled to match .form-control)
   --------------------------------------------------------------------- */
.select2-container { width: 100% !important; font-family: var(--rp-font); }
.select2-container .select2-selection--single,
.select2-container .select2-selection--multiple {
  min-height: 38px;
  border: 1px solid var(--rp-border-strong) !important;
  border-radius: 8px !important;
  background: var(--rp-surface);
  transition: border-color var(--rp-t-fast), box-shadow var(--rp-t-fast);
}
.select2-container .select2-selection--single { height: 38px; }
.select2-container--default .select2-selection--single .select2-selection__rendered {
  line-height: 36px;
  padding-left: 12px;
  padding-right: 34px;
  color: var(--rp-text);
  font-size: 0.8929rem;
}
.select2-container--default .select2-selection--single .select2-selection__placeholder { color: var(--rp-muted-2); }
.select2-container--default .select2-selection--single .select2-selection__arrow { height: 36px; right: 8px; width: 20px; }
.select2-container--default .select2-selection--single .select2-selection__arrow b {
  border: 0;
  width: 12px;
  height: 12px;
  margin: -6px 0 0 -6px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='none' stroke='%2364748b' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' d='M2.5 4.5l3.5 3.5 3.5-3.5'/%3E%3C/svg%3E") no-repeat center;
}
.select2-container--default .select2-selection--single .select2-selection__clear {
  margin-right: 8px;
  color: var(--rp-muted);
  font-size: 1.1rem;
}
.select2-container--default .select2-selection--multiple { padding: 3px 8px 0; }
.select2-container--default .select2-selection--multiple .select2-selection__rendered { padding: 0; display: flex; flex-wrap: wrap; gap: 4px; }
.select2-container--default .select2-selection--multiple .select2-selection__choice {
  margin: 0 0 3px;
  padding: 2px 8px;
  border: 0;
  border-radius: 6px;
  background: var(--rp-primary-100);
  color: var(--rp-primary-700);
  font-size: 0.7857rem;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.select2-container--default .select2-selection--multiple .select2-selection__choice__remove {
  color: var(--rp-primary);
  margin-right: 2px;
  font-weight: 700;
}
.select2-container--default .select2-search--inline .select2-search__field {
  margin: 0 0 3px;
  height: 26px;
  font-family: inherit;
  font-size: 0.8571rem;
}
.select2-container--default.select2-container--focus .select2-selection--multiple,
.select2-container--default.select2-container--open .select2-selection--single,
.select2-container--default.select2-container--open .select2-selection--multiple {
  border-color: var(--rp-primary) !important;
  box-shadow: var(--rp-focus);
}
.select2-container--default.select2-container--disabled .select2-selection--single,
.select2-container--default.select2-container--disabled .select2-selection--multiple {
  background: var(--rp-surface-2);
  border-color: var(--rp-border) !important;
}
.select2-dropdown {
  border: 1px solid var(--rp-border);
  border-radius: 10px;
  box-shadow: var(--rp-shadow-lg);
  overflow: hidden;
  z-index: 1085;
}
.select2-container--open .select2-dropdown--below { margin-top: 4px; }
.select2-container--open .select2-dropdown--above { margin-top: -4px; }
.select2-search--dropdown { padding: 8px; }
.select2-container--default .select2-search--dropdown .select2-search__field {
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--rp-border-strong);
  border-radius: 7px;
  font-family: inherit;
  font-size: 0.8571rem;
}
.select2-container--default .select2-search--dropdown .select2-search__field:focus { outline: 0; border-color: var(--rp-primary); box-shadow: var(--rp-focus); }
.select2-results__option {
  padding: 8px 12px;
  font-size: 0.8571rem;
  color: var(--rp-text-2);
}
.select2-container--default .select2-results__option--highlighted[aria-selected] { background: var(--rp-primary-50); color: var(--rp-primary); }
.select2-container--default .select2-results__option[aria-selected="true"] { background: var(--rp-primary-100); color: var(--rp-primary-700); }
.select2-results__message,
.select2-container--default .select2-results__option.loading-results { color: var(--rp-muted); }

/* ---------------------------------------------------------------------
   13. Dashboard widgets
   --------------------------------------------------------------------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
@media (max-width: 575.98px) { .stat-grid { gap: 12px; } }
.stat-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px 18px 16px;
  background: var(--rp-surface);
  border: 1px solid var(--rp-border);
  border-radius: var(--rp-radius);
  box-shadow: var(--rp-shadow-xs);
  color: var(--rp-text);
  transition: transform var(--rp-t-fast), box-shadow var(--rp-t-fast), border-color var(--rp-t-fast);
  overflow: hidden;
}
a.stat-card:hover { transform: translateY(-2px); box-shadow: var(--rp-shadow); border-color: var(--rp-primary-100); color: var(--rp-text); }
.stat-card .stat-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.stat-card .stat-label {
  font-size: 0.7857rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--rp-muted);
}
.stat-card .stat-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  flex: 0 0 auto;
}
.stat-card .stat-value {
  font-size: 1.7143rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.stat-card .stat-value small {
  font-size: 0.8214rem;
  color: var(--rp-muted);
  font-weight: 500;
}
.stat-card .stat-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.7857rem;
  color: var(--rp-muted);
}
.stat-card .stat-foot .fa-arrow-right { transition: transform var(--rp-t-fast); }
a.stat-card:hover .stat-foot .fa-arrow-right { transform: translateX(3px); }
.progress-thin {
  height: 6px;
  border-radius: 999px;
  background: var(--rp-surface-2);
  overflow: hidden;
}
.progress-thin > span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--rp-primary);
  transition: width 0.6s ease;
}

.tone-primary .stat-icon { background: var(--rp-primary-100); color: var(--rp-primary); }
.tone-primary .progress-thin > span { background: var(--rp-primary); }
.tone-accent .stat-icon { background: var(--rp-accent-100); color: var(--rp-accent-600); }
.tone-accent .progress-thin > span { background: var(--rp-accent); }
.tone-warning .stat-icon { background: var(--rp-warning-100); color: var(--rp-warning); }
.tone-warning .progress-thin > span { background: var(--rp-warning); }
.tone-info .stat-icon { background: var(--rp-info-100); color: var(--rp-info); }
.tone-info .progress-thin > span { background: var(--rp-info); }
.tone-danger .stat-icon { background: var(--rp-danger-100); color: var(--rp-danger); }
.tone-danger .progress-thin > span { background: var(--rp-danger); }
.tone-success .stat-icon { background: var(--rp-success-100); color: var(--rp-success); }
.tone-success .progress-thin > span { background: var(--rp-success); }

.mini-stat {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--rp-border);
  border-radius: var(--rp-radius-sm);
  background: var(--rp-surface);
  color: var(--rp-text);
  transition: border-color var(--rp-t-fast), background var(--rp-t-fast);
}
a.mini-stat:hover { border-color: var(--rp-primary); background: var(--rp-primary-50); color: var(--rp-text); }
.mini-stat .mini-icon {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--rp-primary-100);
  color: var(--rp-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}
.mini-stat .mini-body { min-width: 0; flex: 1 1 auto; }
.mini-stat .mini-body span { display: block; font-size: 0.75rem; color: var(--rp-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-stat .mini-body strong { display: block; font-size: 1.0714rem; font-weight: 700; line-height: 1.2; }
.mini-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 12px;
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}
.quick-action {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  padding: 14px;
  border: 1px dashed var(--rp-border-strong);
  border-radius: var(--rp-radius-sm);
  color: var(--rp-text-2);
  font-weight: 600;
  font-size: 0.8214rem;
  transition: border-color var(--rp-t-fast), background var(--rp-t-fast), color var(--rp-t-fast);
}
.quick-action .fa {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--rp-primary-100);
  color: var(--rp-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.quick-action:hover { border-style: solid; border-color: var(--rp-primary); background: var(--rp-primary-50); color: var(--rp-primary); }

.pending-list { list-style: none; margin: 0; padding: 0; }
.pending-list li a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--rp-border);
  color: var(--rp-text);
}
.pending-list li:last-child a { border-bottom: 0; }
.pending-list li a:hover { color: var(--rp-primary); }
.pending-list .p-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--rp-surface-2);
  color: var(--rp-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}
.pending-list li a:hover .p-icon { background: var(--rp-primary-100); color: var(--rp-primary); }
.pending-list .p-label { flex: 1 1 auto; font-weight: 500; }
.pending-list .p-label small { display: block; font-weight: 400; font-size: 0.75rem; color: var(--rp-muted); }
.pending-list-compact li a { padding: 7px 0; font-size: 0.8571rem; }
.pending-list-compact .p-icon { width: 28px; height: 28px; font-size: 0.8571rem; }
.chart-box { position: relative; height: 260px; }
.chart-box-lg { height: 300px; }
@media (max-width: 575.98px) { .chart-box, .chart-box-lg { height: 220px; } }

/* Period switch (dashboard header) */
.range-switch {
  display: inline-flex;
  padding: 3px;
  background: var(--rp-surface);
  border: 1px solid var(--rp-border);
  border-radius: 999px;
  box-shadow: var(--rp-shadow-xs);
}
.range-switch a {
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 0.7857rem;
  font-weight: 600;
  color: var(--rp-muted);
  white-space: nowrap;
  transition: background var(--rp-t-fast), color var(--rp-t-fast);
}
.range-switch button { border: 0; background: transparent; cursor: pointer; font-family: inherit; }
.range-switch a:hover, .range-switch button:hover { color: var(--rp-primary); }
.range-switch a.active, .range-switch button.active { background: var(--rp-primary); color: #fff; }
.custom-range-form {
  border: 1px solid var(--rp-border);
  border-radius: var(--rp-radius);
  margin-bottom: 16px;
  box-shadow: var(--rp-shadow-xs);
}
.custom-range-form .filter-form { flex: 1 1 auto; }
.custom-range-form .filter-field { flex: 0 1 180px; }
@media (max-width: 575.98px) {
  .range-switch { display: flex; flex-wrap: wrap; width: 100%; border-radius: 12px; }
  .range-switch a, .range-switch button { flex: 1 1 auto; text-align: center; }
  .chart-legend { justify-content: flex-start; }
}
.section-title .section-sub { margin-left: 8px; font-weight: 400; font-size: 0.7857rem; color: var(--rp-muted); text-transform: none; letter-spacing: 0; }

/* Chart legend chips */
.chart-legend { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.legend-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border: 1px solid var(--rp-border);
  border-radius: 999px;
  background: var(--rp-surface);
  color: var(--rp-text-2);
  font-size: 0.7143rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity var(--rp-t-fast), border-color var(--rp-t-fast);
}
.legend-chip i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.legend-chip:hover { border-color: var(--rp-border-strong); }
.legend-chip.is-off { opacity: 0.4; text-decoration: line-through; }

/* Recent visits feed */
.feed-list { list-style: none; margin: 0; padding: 0; }
.feed-list li a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--rp-border);
  color: var(--rp-text);
}
.feed-list li:last-child a { border-bottom: 0; }
.feed-list li a:hover strong { color: var(--rp-primary); }
.feed-icon {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  font-size: 0.9286rem;
}
.feed-icon.is-farmer { background: var(--rp-primary-100); color: var(--rp-primary); }
.feed-icon.is-dealer { background: var(--rp-accent-100); color: var(--rp-accent-600); }
.feed-body { flex: 1 1 auto; min-width: 0; }
.feed-body strong { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.feed-body span { display: block; font-size: 0.75rem; color: var(--rp-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.feed-time { flex: 0 0 auto; text-align: right; font-size: 0.75rem; font-weight: 600; color: var(--rp-text-2); }
.feed-time small { display: block; font-weight: 400; color: var(--rp-muted); }

/* Top staff leaderboard */
.leader-list { list-style: none; margin: 0; padding: 0; counter-reset: leader; }
.leader-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--rp-border);
}
.leader-list li:last-child { border-bottom: 0; }
.leader-rank {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--rp-surface-2);
  color: var(--rp-muted);
  font-size: 0.75rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}
.leader-list li:first-child .leader-rank { background: var(--rp-accent); color: var(--rp-sidebar-bg-2); }
.leader-body { flex: 1 1 auto; min-width: 0; }
.leader-body strong { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.leader-body small { display: block; font-size: 0.7143rem; color: var(--rp-muted); margin-top: 3px; }
.leader-bar { display: block; height: 5px; border-radius: 999px; background: var(--rp-surface-2); overflow: hidden; margin-top: 5px; }
.leader-bar > span { display: block; height: 100%; background: var(--rp-primary); border-radius: 999px; }
.leader-total { flex: 0 0 auto; font-size: 1.0714rem; font-weight: 700; }

/* Upcoming events */
.event-list { list-style: none; margin: 0; padding: 0; }
.event-list li a { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--rp-border); color: var(--rp-text); }
.event-list li:last-child a { border-bottom: 0; }
.event-date {
  width: 40px;
  border-radius: 8px;
  background: var(--rp-danger-100);
  color: var(--rp-danger);
  text-align: center;
  padding: 3px 0;
  line-height: 1.1;
  flex: 0 0 auto;
}
.event-date b { display: block; font-size: 1rem; }
.event-date small { display: block; font-size: 0.6429rem; text-transform: uppercase; font-weight: 600; }
.event-body { min-width: 0; }
.event-body strong { display: block; font-weight: 600; font-size: 0.8571rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.event-body small { display: block; font-size: 0.7143rem; color: var(--rp-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.event-list li a:hover strong { color: var(--rp-primary); }

/* ---------------------------------------------------------------------
   14. Detail / view pages
   --------------------------------------------------------------------- */
.detail-card .card-body { padding: 8px 20px; }
.detail-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  padding: 11px 0;
  border-bottom: 1px solid var(--rp-border);
}
.detail-row:last-child { border-bottom: 0; }
.detail-label {
  flex: 0 0 220px;
  max-width: 100%;
  font-size: 0.7857rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--rp-muted);
  padding-top: 2px;
}
.detail-value {
  flex: 1 1 240px;
  min-width: 0;
  color: var(--rp-text);
  font-weight: 500;
  word-break: break-word;
}
.detail-value strong { font-weight: 600; }
.detail-value select { border: 0; background: transparent; padding: 0; font: inherit; color: inherit; }
@media (max-width: 575.98px) {
  .detail-label { flex-basis: 100%; }
  .detail-row { padding: 9px 0; }
}
.media-card {
  background: var(--rp-surface-2);
  border: 1px dashed var(--rp-border-strong);
  border-radius: var(--rp-radius);
  padding: 14px;
  text-align: center;
  color: var(--rp-muted);
}
.media-card img { border-radius: 8px; box-shadow: var(--rp-shadow-sm); max-height: 420px; object-fit: contain; }
.media-card .media-empty { padding: 40px 10px; }
.media-card .media-empty .fa { font-size: 2rem; color: var(--rp-border-strong); display: block; margin-bottom: 8px; }
/* legacy view markup: <div class="col-md-4 card mb-4"> holding an image */
.row > .col-md-4.card,
.row > .col-sm-4.card {
  padding: 12px;
  background: var(--rp-surface-2);
  border: 1px dashed var(--rp-border-strong);
  box-shadow: none;
  align-self: flex-start;
}
.row > .col-md-4.card .bg-light,
.row > .col-sm-4.card .bg-light { background: transparent !important; margin-top: 0 !important; }
.row > .col-md-4.card img,
.row > .col-sm-4.card img { border-radius: 8px; width: 100%; max-height: 420px; object-fit: contain; box-shadow: var(--rp-shadow-sm); background: #fff; }
.row > .col-md-4.card .bg-light.p-5,
.row > .col-sm-4.card .bg-light.p-5 { color: var(--rp-muted); }
.row > .col-md-4.card .bg-light.p-5 h6,
.row > .col-sm-4.card .bg-light.p-5 h6 { color: var(--rp-muted); font-weight: 500; }
.row > .col-md-4.card .bg-light.p-5 h6::before,
.row > .col-sm-4.card .bg-light.p-5 h6::before {
  content: "\f03e";
  font-family: FontAwesome;
  display: block;
  font-size: 2rem;
  color: var(--rp-border-strong);
  margin-bottom: 8px;
}
@media (min-width: 768px) {
  .row > .col-md-4.card { flex: 0 0 calc(33.333% - 30px); max-width: calc(33.333% - 30px); margin-left: 15px; margin-right: 15px; }
}
@media (max-width: 767.98px) {
  .row > .col-md-4.card { margin-left: 15px; margin-right: 15px; }
}
.ibox-body-table { padding: 0; }
.ibox-body-table > .table:not(.dataTable) { margin: 0; }
.ibox-body-table > .dataTables_wrapper { padding: 0; }
/* legacy <div class="card col-sm-12"> inside .form-group.row */
.form-group.row > .card {
  padding: 0;
  margin: 0 15px;
  flex: 0 0 calc(100% - 30px);
  max-width: calc(100% - 30px);
}
.form-group.row > .card > .card-body { padding: 4px 20px; }
.form-group.row > .card .row { padding: 10px 0; margin: 0; }
.form-group.row > .card .row > [class*="col-"] { padding: 0; }
.form-group.row > .card .row > .col-sm-3,
.form-group.row > .card .row > .col-sm-4 {
  font-size: 0.7857rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--rp-muted);
}
.form-group.row > .card .row > .col-sm-3 h6,
.form-group.row > .card .row > .col-sm-4 h6 { font: inherit; margin: 0; color: inherit; }
.form-group.row > .card .row > .col-sm-9,
.form-group.row > .card .row > .col-sm-8 { color: var(--rp-text) !important; font-weight: 500; word-break: break-word; }
.form-group.row > .card hr { margin: 0; }
.form-group.row > .card .row > .col-sm-9 select,
.form-group.row > .card .row > .col-sm-8 select { border: 0; background: transparent; font: inherit; color: inherit; padding: 0; }
@media (min-width: 576px) {
  .form-group.row > .card .row > .col-sm-3 { flex: 0 0 25%; max-width: 25%; padding-right: 12px; }
  .form-group.row > .card .row > .col-sm-9 { flex: 0 0 75%; max-width: 75%; }
  .form-group.row > .card .row > .col-sm-4 { flex: 0 0 33.333%; max-width: 33.333%; padding-right: 12px; }
  .form-group.row > .card .row > .col-sm-8 { flex: 0 0 66.667%; max-width: 66.667%; }
}

/* key/value tables (Task detail etc.) */
.kv-table th {
  width: 18%;
  min-width: 160px;
  font-size: 0.7857rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--rp-muted);
  background: var(--rp-surface-2);
  border-bottom: 1px solid var(--rp-border);
  vertical-align: top;
  padding: 11px 14px;
  white-space: nowrap;
}
.kv-table td { white-space: normal; font-weight: 500; vertical-align: top; }
.kv-table tbody tr:last-child th,
.kv-table tbody tr:last-child td { border-bottom: 0; }
.kv-block + .kv-block { border-top: 4px solid var(--rp-bg); }
.thumb-row { display: flex; flex-wrap: wrap; gap: 8px; }
.thumb {
  max-height: 110px;
  max-width: 200px;
  border-radius: 8px;
  border: 1px solid var(--rp-border);
  background: #fff;
  object-fit: cover;
}
.media-video { width: 100%; max-width: 320px; border-radius: 8px; background: #000; }
.scroll-panel { max-height: 360px; overflow-y: auto; padding-right: 4px; }

/* Map pages */
.map-frame {
  border-radius: var(--rp-radius-sm);
  overflow: hidden;
  border: 1px solid var(--rp-border);
  background: var(--rp-surface-2);
}
#map { width: 100%; height: min(70vh, 640px); min-height: 320px; }

/* ---------------------------------------------------------------------
   15. Empty / error / loading states
   --------------------------------------------------------------------- */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--rp-muted);
}
.empty-state .empty-icon {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  background: var(--rp-surface-2);
  color: var(--rp-muted-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  margin-bottom: 14px;
}
.empty-state h4 { margin-bottom: 4px; color: var(--rp-text); }
.empty-state p { margin: 0 0 14px; font-size: 0.8571rem; }

.skeleton {
  display: block;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--rp-surface-2) 25%, #eef2f7 50%, var(--rp-surface-2) 75%);
  background-size: 200% 100%;
  animation: rpShimmer 1.2s infinite;
}
@keyframes rpShimmer { to { background-position: -200% 0; } }

.page-loader {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: var(--rp-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}
.page-loader.is-done { opacity: 0; visibility: hidden; }
.page-loader .spinner {
  width: 34px;
  height: 34px;
  border: 3px solid var(--rp-primary-100);
  border-top-color: var(--rp-primary);
  border-radius: 50%;
  animation: rpSpin 0.7s linear infinite;
}

.to-top {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--rp-surface);
  border: 1px solid var(--rp-border);
  color: var(--rp-primary);
  box-shadow: var(--rp-shadow);
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 1010;
}
.to-top:hover { background: var(--rp-primary); color: #fff; border-color: var(--rp-primary); }

/* ---------------------------------------------------------------------
   16. Utilities (small, purposeful)
   --------------------------------------------------------------------- */
.text-muted { color: var(--rp-muted) !important; }
.text-secondary { color: var(--rp-text-2) !important; }
.text-primary { color: var(--rp-primary) !important; }
.text-success { color: var(--rp-success) !important; }
.text-danger { color: var(--rp-danger) !important; }
.text-warning { color: var(--rp-warning) !important; }
.text-info { color: var(--rp-info) !important; }
.bg-light { background: var(--rp-surface-2) !important; }
.fw-600 { font-weight: 600; }
.fs-sm { font-size: 0.8214rem; }
.gap-2 { gap: 8px; }
.d-flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.align-center { align-items: center; }
.text-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.divider-v { width: 1px; height: 22px; background: var(--rp-border); margin: 0 6px; }
.width { white-space: nowrap; }

/* legacy dashboard/theme leftovers referenced by a few views */
.myInput { min-width: 0; }
.selectpicker { width: 100%; }

/* Print */
@media print {
  .app-sidebar, .topbar, .app-footer, .to-top, .toast-stack, .page-actions, .toolbar, .dataTables_length, .dataTables_filter, .dataTables_paginate { display: none !important; }
  .content-wrapper { margin: 0; padding: 0; }
  .ibox, .card { box-shadow: none; border-color: #ccc; }
}
