/* =========================================================
   LegMed UI â€” main.css v2.0
   Professional Â· Animated Â· Fully Responsive
   Bootstrap 5 polish Â· Accessible Â· Dark-mode via .theme-dark
   Fonts: Inter (UI) Â· Poppins (headings)
   ========================================================= */

/* ---- Fonts ---- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Poppins:wght@500;600;700;800&display=swap');

/* =========================================================
   Design Tokens
   ========================================================= */
:root {
  /* Brand palette */
  --primary-color:   #0ea5e9;
  --secondary-color: #1e3a8a;
  --accent-color:    #2563eb;
  --accent-2:        #0891b2;

  /* Light variants */
  --primary-light:   #dbeafe;
  --danger-light:    #fecaca;

  /* Surfaces */
  --bg-body:     #eef6ff;
  --surface:     #ffffff;
  --surface-2:   #f3f8ff;
  --surface-3:   #e7f1ff;

  /* Text */
  --ink:         #102a6a;
  --text-color:  #10213f;
  --muted-color: #5b6b8c;

  /* Borders */
  --line-soft:   #dbe9ff;
  --line-medium: #bfd5f8;
  --line-strong: #abc6f1;

  /* State colors */
  --info-color:    #0ea5e9;
  --success-color: #16a34a;
  --warning-color: #f59e0b;
  --danger-color:  #dc2626;

  /* Shadows */
  --shadow-0: none;
  --shadow-1: 0 1px 3px rgba(30,58,138,.08), 0 1px 2px rgba(30,58,138,.04);
  --shadow-2: 0 4px 16px rgba(30,58,138,.10), 0 2px 6px rgba(30,58,138,.06);
  --shadow-3: 0 16px 40px rgba(15,23,42,.16), 0 4px 12px rgba(15,23,42,.08);
  --shadow-4: 0 24px 64px rgba(15,23,42,.22), 0 8px 24px rgba(15,23,42,.12);

  /* Radii */
  --radius-0:  0px;
  --radius-1:  10px;
  --radius-2:  14px;
  --radius-3:  20px;
  --radius-4:  28px;
  --radius-pill: 999px;

  /* Motion */
  --transition:      all .18s ease;
  --transition-fast: all .12s ease;
  --transition-slow: all .3s ease;
  --ring: 0 0 0 .2rem rgba(37,99,235,.25);

  /* Typography */
  --font-sans: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, 'Noto Sans', sans-serif;
  --font-head: 'Poppins', var(--font-sans);
  --fs-11: .6875rem;
  --fs-12: .75rem;
  --fs-13: .8125rem;
  --fs-14: .875rem;
  --fs-15: .9375rem;
  --fs-16: 1rem;

  /* Table density */
  --row-pad-y: 11px;
  --row-pad-x: 13px;

  /* Pagination */
  --page-bg:       #fff;
  --page-hover:    #eaf2ff;
  --page-disabled: #dce9ff;

  /* Badge tints */
  --t-success: rgba(22,163,74,.11);
  --t-danger:  rgba(220,38,38,.11);
  --t-info:    rgba(14,165,233,.11);
  --t-warn:    rgba(245,158,11,.13);
  --t-primary: rgba(37,99,235,.12);
  --t-purple:  rgba(124,58,237,.11);
}

/* =========================================================
   Global Animations
   ========================================================= */
@keyframes fadeIn        { from { opacity:0 } to { opacity:1 } }
@keyframes fadeInUp      { from { opacity:0; transform:translateY(18px) } to { opacity:1; transform:translateY(0) } }
@keyframes fadeInDown    { from { opacity:0; transform:translateY(-14px) } to { opacity:1; transform:translateY(0) } }
@keyframes fadeInLeft    { from { opacity:0; transform:translateX(-18px) } to { opacity:1; transform:translateX(0) } }
@keyframes fadeInRight   { from { opacity:0; transform:translateX(18px) } to { opacity:1; transform:translateX(0) } }
@keyframes scaleIn       { from { opacity:0; transform:scale(.94) } to { opacity:1; transform:scale(1) } }
@keyframes slideDown     { from { opacity:0; transform:translateY(-8px) } to { opacity:1; transform:translateY(0) } }
@keyframes pulseRing     { 0%,100% { transform:scale(1); opacity:1 } 50% { transform:scale(1.15); opacity:.7 } }
@keyframes shimmer       { 0% { background-position:-400px 0 } 100% { background-position:400px 0 } }
@keyframes rot           { to { transform:rotate(360deg) } }
@keyframes bounce        { 0%,100% { transform:translateY(0) } 50% { transform:translateY(-5px) } }
@keyframes w3FocusFlash  { 0%,100% { box-shadow:0 0 0 0 rgba(139,46,58,0) } 20% { box-shadow:0 0 0 5px rgba(139,46,58,.13) } }

/* Utility animation classes */
.anim-fade-in       { animation: fadeIn      .35s ease both }
.anim-fade-in-up    { animation: fadeInUp    .4s  ease both }
.anim-fade-in-down  { animation: fadeInDown  .35s ease both }
.anim-scale-in      { animation: scaleIn     .3s  ease both }
.anim-slide-down    { animation: slideDown   .25s ease both }

/* Staggered children */
.stagger-children > *:nth-child(1)  { animation-delay: .04s }
.stagger-children > *:nth-child(2)  { animation-delay: .08s }
.stagger-children > *:nth-child(3)  { animation-delay: .12s }
.stagger-children > *:nth-child(4)  { animation-delay: .16s }
.stagger-children > *:nth-child(5)  { animation-delay: .20s }
.stagger-children > *:nth-child(6)  { animation-delay: .24s }

/* =========================================================
   Base & Reset
   ========================================================= */
*, *::before, *::after { box-sizing: border-box }

html, body {
  background: linear-gradient(160deg, #f0f7ff 0%, var(--bg-body) 50%, #e5f0ff 100%);
  color: var(--text-color);
  font-family: var(--font-sans);
  font-size: var(--fs-14);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
}

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

a {
  color: var(--secondary-color);
  text-decoration: none;
  transition: var(--transition);
}
a:hover { color: var(--accent-color); }

h1, h2, h3, h4, h5 {
  color: var(--ink);
  font-family: var(--font-head);
  letter-spacing: .15px;
  margin-bottom: .5rem;
  line-height: 1.25;
}
h1 { font-size: clamp(1.4rem, 3vw, 1.7rem); }
h2 { font-size: clamp(1.15rem, 2.5vw, 1.3rem); }
h3 { font-size: 1.1rem; }
p  { margin-bottom: 5px; line-height: 1.65; }

img { max-width: 100%; display: block; }

.container, .container-fluid { padding-left: 14px; padding-right: 14px; }
.text-muted { color: var(--muted-color) !important; }
.divider     { height: 1px; background: var(--line-soft); width: 100%; }

.rounded-1  { border-radius: var(--radius-1) !important; }
.rounded-2  { border-radius: var(--radius-2) !important; }
.rounded-3  { border-radius: var(--radius-3) !important; }
.shadow-1   { box-shadow: var(--shadow-1) !important; }
.shadow-2   { box-shadow: var(--shadow-2) !important; }
:focus-visible { outline: none; box-shadow: var(--ring); }

/* Spacing helpers */
.gap-2 { gap: .5rem }
.gap-3 { gap: .75rem }

/* Table density */
.is-compact { --row-pad-y: 7px; --row-pad-x: 9px; }
.is-comfy   { --row-pad-y: 14px; --row-pad-x: 15px; }

/* =========================================================
   Surfaces / Cards / Panels
   ========================================================= */
.card, .modal-content, .dropdown-menu, .offcanvas, .toast,
.panel, .list-group, .accordion-item, .popover {
  background: var(--surface);
  color: var(--text-color);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-2);
  box-shadow: var(--shadow-2);
}

.card { overflow: auto; transition: box-shadow .22s ease, transform .22s ease; }
.card:hover { box-shadow: var(--shadow-3); }

.card-header, .modal-header, .popover-header {
  background: linear-gradient(170deg, #f4f9ff 0%, #edf5ff 100%);
  border-bottom: 1px solid var(--line-strong);
  color: var(--text-color);
  font-weight: 600;
}

.card-footer, .modal-footer {
  background: #edf5ff;
  border-top: 1px solid var(--line-strong);
}

.panel { padding: 14px; }
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.panel-title {
  font-family: var(--font-head);
  font-weight: 600;
  color: var(--ink);
  margin: 0;
}
.panel-sub { color: var(--muted-color); font-size: var(--fs-13); }

/* =========================================================
   Buttons
   ========================================================= */
.btn {
  --bs-btn-font-weight: 600;
  font-family: var(--font-head);
  font-size: var(--fs-14);
  line-height: 1.25;
  padding: 7px 13px;
  border-radius: var(--radius-1);
  transition: transform .16s ease, box-shadow .16s ease, filter .16s ease, background .16s ease;
  box-shadow: none;
  position: relative;
  overflow: hidden;
}
.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0);
  transition: background .2s ease;
  border-radius: inherit;
}
.btn:hover::after { background: rgba(255,255,255,.08); }
.btn:active { transform: translateY(1px) !important; }
.btn:focus { box-shadow: var(--ring); }

.btn-primary {
  background: linear-gradient(135deg, #0ea5e9 0%, #2563eb 100%);
  border-color: #1d4ed8;
  color: #fff;
  box-shadow: 0 4px 14px rgba(37,99,235,.28);
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 22px rgba(37,99,235,.36);
  background: linear-gradient(135deg, #38bdf8 0%, #3b82f6 100%);
  border-color: #2563eb;
  color: #fff;
}

.btn-secondary {
  background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 100%);
  border-color: var(--secondary-color);
  color: #fff;
  box-shadow: 0 4px 14px rgba(30,58,138,.22);
}
.btn-secondary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(30,58,138,.30);
  color: #fff;
}

.btn-success {
  background: linear-gradient(135deg, #16a34a 0%, #059669 100%);
  border-color: #15803d;
  color: #fff;
  box-shadow: 0 4px 14px rgba(22,163,74,.24);
}
.btn-success:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(22,163,74,.32);
  color: #fff;
}

.btn-danger {
  background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
  border-color: #b91c1c;
  color: #fff;
  box-shadow: 0 4px 14px rgba(220,38,38,.22);
}
.btn-danger:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(220,38,38,.30);
  color: #fff;
}

.btn-light {
  background: #f5f8ff;
  border: 1px solid var(--line-strong);
  color: var(--secondary-color);
}
.btn-light:hover {
  background: #eaf2ff;
  transform: translateY(-1px);
  color: var(--ink);
}

.btn-outline-primary {
  color: var(--primary-color);
  border-color: var(--primary-color);
}
.btn-outline-primary:hover {
  background: var(--primary-color);
  color: #fff;
  transform: translateY(-1px);
}

.btn-outline-danger  { color: #b91c1c; border-color: #ef4444; }
.btn-outline-danger:hover { background: #ef4444; color: #fff; transform: translateY(-1px); }

.btn-sm  { padding: 5px 10px; font-size: var(--fs-13); border-radius: 8px; }
.btn-lg  { padding: 10px 18px; font-size: var(--fs-15); border-radius: 12px; }
.btn i, .btn .fa { margin-right: 5px; }

/* Icon-only button */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-1);
  background: var(--surface);
  color: var(--secondary-color);
  transition: var(--transition);
}
.icon-btn:hover { background: #edf7f5; transform: translateY(-1px); box-shadow: var(--shadow-1); }

/* Loading state */
.btn-loading { pointer-events: none; opacity: .85 }
.btn-loading .btn-label { visibility: hidden }
.btn-loading .btn-spinner { display: inline-block !important }
.btn-spinner {
  display: none;
  width: 1rem; height: 1rem;
  border: .2rem solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  vertical-align: -.125em;
  animation: rot .8s linear infinite;
}

/* =========================================================
   Forms
   ========================================================= */
.form-control, .form-select, .input-group-text, .form-control-plaintext {
  background: #fff;
  color: var(--text-color);
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-1);
  box-shadow: 0 1px 2px rgba(30,58,138,.04);
  transition: var(--transition);
  font-size: var(--fs-14);
  padding: 9px 12px;
}
.form-control:focus, .form-select:focus {
  border-color: var(--accent-color);
  box-shadow: var(--ring);
  background: #fff;
}
.form-control::placeholder { color: #9aa3b2; }
.form-label {
  font-weight: 600;
  font-size: var(--fs-13);
  color: var(--ink);
  margin-bottom: 5px;
}
.input-group-text {
  background: var(--surface-2);
  color: var(--muted-color);
}

/* Checkbox */
.form-check-input {
  width: 1.1rem; height: 1.1rem;
  border: 1.5px solid var(--line-strong);
  background-color: #fff;
  accent-color: var(--accent-color);
  appearance: none; -webkit-appearance: none;
  position: relative;
  border-radius: 6px;
  transition: border-color .15s ease, background-color .15s ease, box-shadow .15s ease;
  background-clip: padding-box;
}
.form-check-input:focus { box-shadow: var(--ring); border-color: var(--accent-color); }
.form-check-input:disabled { opacity: .6; cursor: not-allowed; }

.form-check:not(.form-switch) .form-check-input[type="checkbox"] { background-image: none !important; }
.form-check:not(.form-switch) .form-check-input[type="checkbox"]::after {
  content: ""; position: absolute; inset: 0;
  background-color: #fff;
  opacity: 0; transition: opacity .12s ease;
  -webkit-mask: url("data:image/svg+xml,%3Csvg width='16' height='12' viewBox='0 0 16 12' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1.5 6.5L5.5 10.5L14.5 1.5' stroke='%23000' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/12px 12px no-repeat;
          mask: url("data:image/svg+xml,%3Csvg width='16' height='12' viewBox='0 0 16 12' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1.5 6.5L5.5 10.5L14.5 1.5' stroke='%23000' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/12px 12px no-repeat;
}
.form-check:not(.form-switch) .form-check-input[type="checkbox"]:checked {
  background-color: var(--accent-color);
  border-color: var(--accent-color);
}
.form-check:not(.form-switch) .form-check-input[type="checkbox"]:checked::after { opacity: 1; }

.form-check-input[type="radio"] { border-radius: 50%; background-image: none; }
.form-check-input[type="radio"]::after {
  content: ""; position: absolute; top: 50%; left: 50%;
  width: .54rem; height: .54rem; border-radius: 50%;
  transform: translate(-50%, -50%);
  background: var(--accent-color);
  opacity: 0; transition: opacity .15s ease;
}
.form-check-input[type="radio"]:checked { border-color: var(--accent-color); background-color: #fff; }
.form-check-input[type="radio"]:checked::after { opacity: 1; }

.form-switch .form-check-input {
  width: 2.4rem; height: 1.35rem; border-radius: 1.35rem;
  background-color: #dde8f5;
  border-color: var(--line-strong);
  background-image: none !important;
  position: relative;
}
.form-switch .form-check-input::before {
  content: ""; position: absolute; top: 50%; left: 3px;
  width: 1rem; height: 1rem; border-radius: 50%;
  transform: translateY(-50%);
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.22);
  transition: left .2s ease;
}
.form-switch .form-check-input:checked { background-color: var(--accent-color); border-color: var(--accent-color); }
.form-switch .form-check-input:checked::before { left: calc(100% - 1rem - 3px); }

/* =========================================================
   Tables â€” Fully Responsive
   ========================================================= */
.table,
.table-striped,
.table-hover,
.table-bordered {
  width: 100%;
  background: var(--surface);
  color: var(--text-color);
  border: none;
  border-radius: var(--radius-0);
  font-size: var(--fs-13);
  border-collapse: separate;
  border-spacing: 0;
}

.table caption { caption-side: top; color: var(--muted-color); padding: 8px 0; }

.table > :not(caption) > * > * {
  background: transparent;
  border: none;
  padding: var(--row-pad-y) var(--row-pad-x);
  box-shadow: inset 0 -1px 0 var(--line-strong);
  transition: background .12s ease;
}

.table thead th {
  background: linear-gradient(170deg, #f0f8ff 0%, #eaf4ff 100%);
  color: var(--ink);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  font-size: var(--fs-12);
  position: sticky; top: 0; z-index: 1;
  box-shadow: inset 0 -2px 0 var(--line-medium);
}

.table tbody th { color: var(--text-color); font-weight: 600; }
.table tbody td a:hover { color: var(--accent-color); }

.table-hover tbody tr:hover > * {
  background: rgba(37,99,235,.04);
  box-shadow: inset 0 -1px 0 var(--line-strong), inset 0 1px 0 var(--line-soft);
}

.table tbody tr.is-selected > * {
  background: rgba(37,99,235,.07);
  box-shadow: inset 0 -1px 0 var(--line-strong), inset 0 1px 0 var(--line-soft);
}

.table.table-sm > :not(caption) > * > * { padding: 7px 10px; }

/* Responsive table wrapper */
.table-responsive,
.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-2);
}

/* Mobile card-table: hide regular table, show cards instead */
@media (max-width: 639px) {
  .table-card-mobile thead { display: none; }
  .table-card-mobile tbody tr {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-2);
    margin-bottom: 10px;
    background: var(--surface);
    box-shadow: var(--shadow-1);
    overflow: hidden;
    animation: fadeInUp .3s ease both;
  }
  .table-card-mobile tbody td {
    padding: 10px 12px;
    border: none !important;
    box-shadow: none !important;
    display: block;
    position: relative;
  }
  .table-card-mobile tbody td:before {
    content: attr(data-label);
    display: block;
    font-size: var(--fs-11);
    font-weight: 700;
    color: var(--muted-color);
    text-transform: uppercase;
    letter-spacing: .05em;
    margin-bottom: 3px;
  }
  .table-card-mobile tbody td:last-child {
    grid-column: 1 / -1;
    border-top: 1px solid var(--line-soft) !important;
    background: var(--surface-2);
  }
}

/* =========================================================
   Pagination
   ========================================================= */
.pagination { display: inline-flex; gap: 5px; align-items: center; flex-wrap: wrap; }

.page-link {
  padding: 6px 12px;
  font-size: var(--fs-13);
  font-weight: 600;
  line-height: 1.3;
  border: 1.5px solid var(--line-strong);
  background: var(--page-bg);
  color: var(--text-color);
  border-radius: var(--radius-1);
  transition: var(--transition);
  min-width: 36px;
  text-align: center;
}
.page-link:hover {
  background: var(--page-hover);
  color: var(--secondary-color);
  transform: translateY(-1px);
  box-shadow: var(--shadow-1);
}
.page-link:focus { box-shadow: var(--ring); border-color: var(--accent-color); }
.page-item.active .page-link {
  background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
  color: #fff;
  border-color: var(--accent-color);
  box-shadow: 0 4px 12px rgba(37,99,235,.26);
}
.page-item.disabled .page-link { color: #9aa3b2; background: var(--page-disabled); }

/* =========================================================
   Nav / Tabs / Pills
   ========================================================= */
.nav-tabs { border-bottom: 2px solid var(--line-strong); background: transparent; }
.nav-tabs .nav-link {
  border: none; border-bottom: 2.5px solid transparent;
  color: var(--muted-color); background: transparent !important;
  padding: 10px 14px; transition: var(--transition);
  border-radius: 0; font-weight: 600; font-size: var(--fs-13);
  margin-bottom: -2px;
}
.nav-tabs .nav-link:hover { color: var(--secondary-color); background: #f4faf9 !important; }
.nav-tabs .nav-link.active {
  color: var(--accent-color);
  border-bottom-color: var(--accent-color);
  background: transparent !important;
}

.nav-pills .nav-link {
  background: #fff; border: 1.5px solid var(--line-strong);
  color: var(--text-color); border-radius: var(--radius-pill);
  margin-right: 6px; padding: 7px 14px; font-weight: 600;
  font-size: var(--fs-13); transition: var(--transition);
}
.nav-pills .nav-link.active {
  background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
  color: #fff; border-color: var(--accent-color);
  box-shadow: 0 4px 12px rgba(37,99,235,.22);
}

/* =========================================================
   Dropdowns / Popovers / Tooltips
   ========================================================= */
.dropdown-menu {
  border: 1.5px solid var(--line-strong);
  box-shadow: var(--shadow-3);
  border-radius: var(--radius-2);
  padding: 6px;
  background: var(--surface);
  animation: slideDown .18s ease both;
}
.dropdown-item {
  border-radius: var(--radius-1);
  color: var(--text-color);
  font-size: var(--fs-14);
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: .55rem;
  transition: var(--transition-fast);
}
.dropdown-item i { width: 16px; text-align: center; }
.dropdown-item:hover { background: #edf7f5; color: var(--secondary-color); }
.dropdown-item.text-danger { color: var(--danger-color) !important; }

.popover { border: 1.5px solid var(--line-strong); box-shadow: var(--shadow-2); }
.popover-header { font-weight: 600; background: #f4faf9; border-bottom: 1px solid var(--line-strong); }
.popover-body { color: var(--text-color); }

.tooltip .tooltip-inner { background: #0f172a; color: #fff; border-radius: 8px; padding: 6px 10px; font-size: var(--fs-12); }
.tooltip .tooltip-arrow::before { border-top-color: #0f172a !important; }

/* =========================================================
   List Group / Accordion / Breadcrumb / Progress
   ========================================================= */
.list-group { border: 1px solid var(--line-strong); border-radius: var(--radius-2); overflow: hidden; background: var(--surface); }
.list-group-item { background: transparent; color: var(--text-color); border-color: var(--line-strong); transition: background .12s ease; }
.list-group-item:hover { background: #f4faf9; }
.list-group-item.active { background: var(--accent-color); border-color: var(--accent-color); color: #fff; }

.accordion-item { border: 1px solid var(--line-strong); background: var(--surface); }
.accordion-button { background: var(--surface); color: var(--text-color); font-weight: 600; transition: background .15s ease, color .15s ease; }
.accordion-button:hover { background: #f4faf9; }
.accordion-button:not(.collapsed) { background: rgba(37,99,235,.06); color: var(--accent-color); box-shadow: inset 0 -1px 0 var(--line-strong); }
.accordion-button::after {
  flex-shrink: 0; width: 1rem; height: 1rem; margin-left: auto;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg width='20' height='20' viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M5.75 7.5L10 11.75L14.25 7.5' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat center / 100% 100%;
          mask: url("data:image/svg+xml,%3Csvg width='20' height='20' viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M5.75 7.5L10 11.75L14.25 7.5' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat center / 100% 100%;
  background-image: none !important;
}
.accordion-button:not(.collapsed)::after { transform: rotate(180deg); }

.breadcrumb {
  background: var(--surface); border: 1px solid var(--line-strong);
  padding: 8px 14px; border-radius: var(--radius-2);
  box-shadow: var(--shadow-1); font-size: var(--fs-13);
}
.breadcrumb .breadcrumb-item { color: var(--text-color); }
.breadcrumb .breadcrumb-item > a { color: var(--secondary-color); }
.breadcrumb .breadcrumb-item > a:hover { color: var(--accent-color); }
.breadcrumb .breadcrumb-item.active { color: var(--text-color); }
.breadcrumb .breadcrumb-item + .breadcrumb-item::before { color: #94a3b8; }

.progress { background: #e5eff0; border-radius: 8px; height: 8px; overflow: hidden; }
.progress-bar { background: linear-gradient(90deg, var(--primary-color), var(--accent-color)); transition: width .4s ease; }

/* =========================================================
   Badges
   ========================================================= */
.badge {
  font-size: var(--fs-11);
  font-weight: 700;
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  line-height: 1.2;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid transparent;
  letter-spacing: .02em;
  white-space: nowrap;
}
.badge i, .badge .fa { font-size: var(--fs-11); }

.badge-success { background-color: var(--success-color) !important; color: #fff !important; }
.badge-danger  { background-color: var(--danger-color)  !important; color: #fff !important; }
.badge-info    { background-color: var(--info-color)    !important; color: #fff !important; }
.badge-warning { background-color: var(--warning-color) !important; color: #0b1324 !important; }
.badge-primary { background-color: var(--accent-color)  !important; color: #fff !important; }

.badge-soft-success { background: var(--t-success); color: #15803d; border-color: rgba(22,163,74,.2); }
.badge-soft-danger  { background: var(--t-danger);  color: #b91c1c; border-color: rgba(220,38,38,.2); }
.badge-soft-info    { background: var(--t-info);    color: #0369a1; border-color: rgba(14,165,233,.2); }
.badge-soft-warning { background: var(--t-warn);    color: #92400e; border-color: rgba(245,158,11,.24); }
.badge-soft-primary { background: var(--t-primary); color: #1d4ed8; border-color: rgba(37,99,235,.22); }
.badge-soft-purple  { background: var(--t-purple);  color: #6d28d9; border-color: rgba(124,58,237,.2); }

.badge-outline-success { background: transparent; color: #16a34a; border-color: #16a34a; }
.badge-outline-danger  { background: transparent; color: #dc2626; border-color: #dc2626; }
.badge-outline-info    { background: transparent; color: #0ea5e9; border-color: #0ea5e9; }
.badge-outline-warning { background: transparent; color: #f59e0b; border-color: #f59e0b; }
.badge-outline-primary { background: transparent; color: var(--primary-color); border-color: var(--primary-color); }

.badge.bg-warning, .badge.text-bg-warning { color: #0b1324 !important; }

/* =========================================================
   Navbar
   ========================================================= */
.navbar { border-bottom: 1px solid var(--line-strong); background: var(--surface) !important; }
.navbar .navbar-brand, .navbar .nav-link { color: var(--text-color) !important; }
.navbar .nav-link:hover { color: var(--accent-color) !important; }

/* =========================================================
   Modals
   ========================================================= */
.modal-content {
  border-radius: var(--radius-3);
  border: 1.5px solid var(--line-strong);
  background: var(--surface);
  animation: scaleIn .22s ease both;
}
.modal-header { border-bottom: 1px solid var(--line-strong); }
.modal-footer { border-top: 1px solid var(--line-strong); }
.modal-title i { opacity: .9; }

/* =========================================================
   Alerts
   ========================================================= */
.alert { border-radius: var(--radius-2); font-size: var(--fs-14); }
.alert-info    { background: rgba(14,165,233,.08);  border-color: rgba(14,165,233,.18);  color: #0369a1; }
.alert-success { background: rgba(22,163,74,.08);   border-color: rgba(22,163,74,.18);   color: #15803d; }
.alert-warning { background: rgba(245,158,11,.10);  border-color: rgba(245,158,11,.22);  color: #92400e; }
.alert-danger  { background: rgba(220,38,38,.08);   border-color: rgba(220,38,38,.18);   color: #b91c1c; }

/* =========================================================
   Empty State
   ========================================================= */
.empty {
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius-2);
  padding: 28px 20px;
  text-align: center;
  color: var(--muted-color);
  background: var(--surface);
}

/* =========================================================
   Skeleton Loader
   ========================================================= */
.skeleton {
  background: linear-gradient(90deg, #e8f0fe 25%, #f3f8ff 50%, #e8f0fe 75%);
  background-size: 400px 100%;
  animation: shimmer 1.4s ease infinite;
  border-radius: var(--radius-1);
}
.skeleton-line { height: 14px; margin-bottom: 10px; }
.skeleton-line.thin { height: 10px; width: 60%; }
.skeleton-circle { border-radius: 50%; }
.skeleton-avatar { width: 42px; height: 42px; border-radius: 12px; flex-shrink: 0; }

/* =========================================================
   Spinner
   ========================================================= */
.spin {
  width: 20px; height: 20px;
  border: 3px solid rgba(37,99,235,.15);
  border-top-color: var(--accent-color);
  border-radius: 50%;
  animation: rot .7s linear infinite;
}
.dim {
  position: absolute; inset: 0;
  display: none; align-items: center; justify-content: center;
  background: rgba(255,255,255,.7); z-index: 2;
  border-radius: inherit;
  backdrop-filter: blur(2px);
}
.dim.show { display: flex; }

.err { font-size: var(--fs-12); color: var(--danger-color); display: none; margin-top: 5px; }
.err:not(:empty) { display: block; }

/* =========================================================
   Dropzone / File Upload
   ========================================================= */
.dropzone {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center;
  border: 2px dashed var(--line-strong);
  border-radius: var(--radius-2);
  background: var(--surface-2);
  padding: 24px;
  transition: border-color .18s ease, background .18s ease, box-shadow .18s ease;
  cursor: pointer;
}
.dropzone:hover, .dropzone.drag {
  border-color: var(--accent-color);
  background: rgba(37,99,235,.04);
  box-shadow: 0 0 0 4px rgba(37,99,235,.08);
}
.drop-icon {
  width: 56px; height: 56px; border-radius: var(--radius-pill);
  border: 1.5px dashed var(--line-strong);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 12px; opacity: .85;
  transition: var(--transition);
}
.dropzone:hover .drop-icon { border-color: var(--accent-color); }
.dropzone .hint { color: var(--muted-color); font-size: var(--fs-13); }

.file-list { margin-top: 10px; }
.file-row {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  align-items: center; gap: 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-2);
  background: var(--surface-2);
  padding: 10px 14px;
  margin-bottom: 10px;
  transition: var(--transition);
}
.file-row:hover { background: var(--surface-3); border-color: var(--line-medium); }
.file-row .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; color: var(--ink); }
.file-row .size { color: var(--muted-color); font-size: var(--fs-12); min-width: 70px; text-align: right; }

/* =========================================================
   Shared Panel / Card Wrappers
   ========================================================= */
.sm-wrap    { max-width: 1100px; margin: 16px auto 40px; }
.sm.card    { border: 1px solid var(--line-strong); border-radius: var(--radius-3); background: var(--surface); box-shadow: var(--shadow-2); overflow: hidden; }
.sm .card-header { background: var(--surface); border-bottom: 1px solid var(--line-strong); padding: 16px 20px; }
.sm-head    { display: flex; align-items: center; gap: 10px; }
.sm-head i  { color: var(--accent-color); }
.sm-head strong { color: var(--ink); font-family: var(--font-head); font-weight: 700; }
.sm-head .hint  { color: var(--muted-color); font-size: var(--fs-13); }

.section-title { font-weight: 700; color: var(--ink); font-family: var(--font-head); margin: 12px 2px 14px; }
.divider-soft  { height: 1px; background: var(--line-soft); margin: 10px 0 16px; }

/* Table action group */
.btn-group  { display: flex; gap: 6px; align-items: center; }
.btn-action {
  border: none; background: transparent;
  padding: 6px 10px; border-radius: 8px;
  transition: var(--transition); cursor: pointer;
  font-size: var(--fs-13); display: flex; align-items: center; gap: 4px;
  border: 1px solid transparent;
}
.btn-preview   { color: var(--primary-color); border-color: var(--primary-light); }
.btn-preview:hover { background: var(--primary-color); color: #fff; transform: translateY(-1px); }
.btn-delete    { color: var(--danger-color); border-color: var(--danger-light); }
.btn-delete:hover  { background: var(--danger-color); color: #fff; transform: translateY(-1px); }

/* Preview modal */
.preview-container { max-height: 70vh; overflow: auto; }
.preview-image { max-width: 100%; max-height: 60vh; border-radius: 10px; }
.preview-pdf   { width: 100%; height: 500px; border: 1px solid var(--line-strong); border-radius: 10px; }
.preview-text  { text-align: left; background: var(--surface-2); padding: 1rem; border-radius: 10px; max-height: 60vh; overflow: auto; font-family: monospace; }

/* Media item */
.media-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.media-head .meta .title { font-weight: 700; color: var(--ink); font-family: var(--font-head); line-height: 1.2; }
.media-head .meta .sub   { color: var(--muted-color); font-size: 13px; }
.modal .section-label    { font-weight: 600; color: var(--ink); margin-top: 6px; }

.media-list { margin-top: 8px; }
.media-item {
  display: grid; grid-template-columns: 28px 1fr auto;
  align-items: center; gap: 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-2);
  background: var(--surface-2);
  padding: 10px 12px; margin-bottom: 8px;
}
.media-item .handle { cursor: grab; opacity: .7; }
.media-item.dragging { opacity: .5; }
.media-item .url   { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 52vw; }
.media-item .kind  { font-size: 12px; color: var(--muted-color); }
.media-item .btn-icon { border: none; background: transparent; padding: .25rem .4rem; color: #6b7280; }
.media-item .btn-icon:hover { color: var(--ink); }
.media-item .icon  { width: 28px; height: 28px; border-radius: 8px; display: flex; align-items: center; justify-content: center; border: 1px solid var(--line-strong); background: #fff; }

/* Dropdown inside table */
.table-wrap .dropdown { position: relative; }
.table-wrap .dropdown-menu { z-index: 2050; }

/* =========================================================
   Dark Theme
   ========================================================= */
.theme-dark {
  --bg-body:     #020b1f;
  --surface:     #061634;
  --surface-2:   #082044;
  --surface-3:   #0a2854;
  --ink:         #e0edff;
  --text-color:  #dbeafe;
  --muted-color: #9fb3d1;
  --line-strong: #1d376b;
  --line-soft:   #142954;
  --line-medium: #1e3d74;
  --page-bg:     #061634;
  --page-hover:  #0a2854;
  --page-disabled: #041128;
}

.theme-dark .card,
.theme-dark .panel,
.theme-dark .breadcrumb,
.theme-dark .dropdown-menu,
.theme-dark .modal-content,
.theme-dark .offcanvas,
.theme-dark .toast,
.theme-dark .list-group,
.theme-dark .accordion-item,
.theme-dark .popover {
  background: var(--surface) !important;
  color: var(--text-color) !important;
  border-color: var(--line-strong) !important;
  box-shadow: 0 4px 16px rgba(0,0,0,.36);
}
.theme-dark .card-header,
.theme-dark .modal-header,
.theme-dark .popover-header { background: #04111f; border-bottom-color: var(--line-strong); }
.theme-dark .card-footer,
.theme-dark .modal-footer   { background: #04151f; border-top-color: var(--line-strong); }

/* Dark forms */
.theme-dark .form-control,
.theme-dark .form-select,
.theme-dark .input-group-text { background: #04151f; color: var(--text-color); border-color: var(--line-strong); }
.theme-dark .form-control::placeholder { color: #8b93a7; }
.theme-dark .form-control:focus,
.theme-dark .form-select:focus { border-color: var(--accent-color); box-shadow: var(--ring); }

.theme-dark .form-check-input { background: #020b13; border-color: var(--line-strong); }
.theme-dark .form-check:not(.form-switch) .form-check-input[type="checkbox"]:checked { background-color: var(--accent-color); border-color: var(--accent-color); }
.theme-dark .form-switch .form-check-input { background: #06202b; }
.theme-dark .form-switch .form-check-input:checked { background-color: var(--accent-color); border-color: var(--accent-color); }

/* Dark tables */
.theme-dark .table,
.theme-dark .table-striped,
.theme-dark .table-hover,
.theme-dark .table-bordered { background: var(--surface); color: var(--text-color); }
.theme-dark .table > :not(caption) > * > * {
  background: transparent !important;
  box-shadow: inset 0 -1px 0 var(--line-strong) !important;
}
.theme-dark .table thead th { background: #04111f !important; color: #94a3b8 !important; box-shadow: inset 0 -2px 0 var(--line-strong) !important; }
.theme-dark .table tbody td, .theme-dark .table tbody th { color: var(--text-color) !important; }
.theme-dark .table-hover tbody tr:hover > * { background: rgba(37,99,235,.10) !important; }

/* Dark pagination */
.theme-dark .page-link  { background: var(--page-bg); color: var(--text-color); border-color: var(--line-strong); }
.theme-dark .page-link:hover { background: var(--page-hover); color: var(--accent-color); }
.theme-dark .page-item.active .page-link { background: linear-gradient(135deg, var(--primary-color), var(--accent-color)); border-color: var(--accent-color); color: #fff; }
.theme-dark .page-item.disabled .page-link { color: #8b93a7; background: var(--page-disabled); }

/* Dark tabs/pills */
.theme-dark .nav-tabs { border-bottom-color: var(--line-strong); }
.theme-dark .nav-tabs .nav-link { color: var(--text-color); background: transparent !important; }
.theme-dark .nav-tabs .nav-link:hover { background: #04151f !important; color: var(--accent-color); }
.theme-dark .nav-tabs .nav-link.active { color: var(--accent-color); border-bottom-color: var(--accent-color) !important; }
.theme-dark .nav-pills .nav-link { background: #04151f; border-color: var(--line-strong); color: var(--text-color); }
.theme-dark .nav-pills .nav-link.active { background: linear-gradient(135deg, var(--primary-color), var(--accent-color)); border-color: var(--accent-color); color: #fff; }

/* Dark dropdowns */
.theme-dark .dropdown-menu { background: #04151f; }
.theme-dark .dropdown-item { color: var(--text-color); }
.theme-dark .dropdown-item:hover { background: #06202b; color: var(--accent-color); }
.theme-dark .popover { background: #04151f; }
.theme-dark .popover-body { color: var(--text-color); }

/* Dark list/accordion */
.theme-dark .list-group { border-color: var(--line-strong); }
.theme-dark .list-group-item { background: transparent; color: var(--text-color); border-color: var(--line-strong); }
.theme-dark .list-group-item:hover { background: #06202b; }
.theme-dark .list-group-item.active { background: var(--accent-color); border-color: var(--accent-color); color: #fff; }
.theme-dark .accordion-item { background: var(--surface); }
.theme-dark .accordion-button { background: #04151f; color: var(--text-color); }
.theme-dark .accordion-button:hover { background: #06202b; }
.theme-dark .accordion-button:not(.collapsed) { background: rgba(37,99,235,.12); color: var(--accent-color); }

/* Dark navbar */
.theme-dark .navbar { background: var(--surface) !important; border-bottom: 1px solid var(--line-strong); }
.theme-dark .navbar .navbar-brand, .theme-dark .navbar .nav-link { color: var(--text-color) !important; }
.theme-dark .navbar .nav-link:hover { color: var(--accent-color) !important; }

/* Dark breadcrumb */
.theme-dark .breadcrumb { background: var(--surface); border-color: var(--line-strong); }
.theme-dark .breadcrumb .breadcrumb-item { color: var(--text-color); }
.theme-dark .breadcrumb .breadcrumb-item > a { color: var(--text-color); }
.theme-dark .breadcrumb .breadcrumb-item > a:hover { color: var(--accent-color); }
.theme-dark .breadcrumb .breadcrumb-item + .breadcrumb-item::before { color: #8fa3c2; }

/* Dark alerts */
.theme-dark .alert { background: var(--surface); color: var(--text-color); border-color: var(--line-strong); }
.theme-dark .alert-info    { color: #93c5fd; background: #0c203f; }
.theme-dark .alert-success { color: #34d399; background: #0b2b22; }
.theme-dark .alert-warning { color: #fbbf24; background: #2a1f07; }
.theme-dark .alert-danger  { color: #fca5a5; background: #2a0d0f; }

/* Dark empty */
.theme-dark .empty { background: var(--surface); border-color: var(--line-strong); color: var(--muted-color); }

/* Dark skeleton */
.theme-dark .skeleton { background: linear-gradient(90deg, #061634 25%, #0a2854 50%, #061634 75%); background-size: 400px 100%; }

/* Dark dropzone/media */
html.theme-dark .dropzone { background: #020b13; border-color: var(--line-strong); }
html.theme-dark .file-row { background: #020b13; border-color: var(--line-strong); }
html.theme-dark .file-row:hover { background: #071f2b; }
html.theme-dark .preview-text { background: #071f2b; }
html.theme-dark .media-item { background: #020b13; border-color: var(--line-strong); }
html.theme-dark .panel,
html.theme-dark .table-wrap.card,
html.theme-dark .modal-content { background: #04151f; border-color: var(--line-strong); }
html.theme-dark .table thead th { background: #04151f; border-color: var(--line-strong); color: #94a3b8; }
html.theme-dark .dropdown-menu { background: #04151f; border-color: var(--line-strong); }

/* Dark scrollbar */
html.theme-dark ::-webkit-scrollbar        { width: 8px !important; height: 6px !important; }
html.theme-dark ::-webkit-scrollbar-track  { background: #1e293b !important; border-radius: 4px !important; }
html.theme-dark ::-webkit-scrollbar-thumb  { background: #475569 !important; border-radius: 4px !important; }
html.theme-dark ::-webkit-scrollbar-thumb:hover { background: #64748b !important; }

/* =========================================================
   Dashboard Module â€” Global Enhancements
   ========================================================= */

/* Page-level entrance â€” targets all module wrap classes */
.panel > section,
.bdash-wrap,
.abk-wrap,
.mbk-wrap,
.hm-wrap,
.cm-wrap,
.dept-scope,
[class$="-wrap"],
[class*="-wrap "] {
  animation: fadeInUp .36s .06s ease both;
}

/* Table-responsive scroll-fade hint on mobile */
.table-responsive {
  position: relative;
}

/* Scrollable table edge mask (left-right) */
.table-responsive::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 32px;
  background: linear-gradient(to right, transparent, rgba(255,255,255,.88));
  pointer-events: none;
  border-radius: 0 var(--radius-2) var(--radius-2) 0;
  opacity: 0;
  transition: opacity .2s ease;
}

.table-responsive.is-scrollable::after { opacity: 1; }

/* Enhanced hover for all custom module tables */
.hm-table tbody tr,
.abk-table tbody tr,
.mbk-table tbody tr,
.bdash-table tbody tr,
.dept-scope .table tbody tr {
  transition: background .14s ease;
}

.hm-table tbody tr:hover,
.abk-table tbody tr:hover,
.mbk-table tbody tr:hover {
  background: var(--page-hover);
}

/* ---- Stat card micro-animation ---- */
.bdash-stat,
.abk-stat,
.mbk-stat {
  transition: transform .2s ease, box-shadow .2s ease;
}

.bdash-stat:hover,
.abk-stat:hover,
.mbk-stat:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-2);
}

/* ---- Panel entrance stagger for stats ---- */
.bdash-grid .bdash-stat:nth-child(1),
.abk-stats .abk-stat:nth-child(1),
.mbk-stats .mbk-stat:nth-child(1) { animation: fadeInUp .32s .05s ease both; }
.bdash-grid .bdash-stat:nth-child(2),
.abk-stats .abk-stat:nth-child(2),
.mbk-stats .mbk-stat:nth-child(2) { animation: fadeInUp .32s .10s ease both; }
.bdash-grid .bdash-stat:nth-child(3),
.abk-stats .abk-stat:nth-child(3),
.mbk-stats .mbk-stat:nth-child(3) { animation: fadeInUp .32s .15s ease both; }
.bdash-grid .bdash-stat:nth-child(4),
.abk-stats .abk-stat:nth-child(4),
.mbk-stats .mbk-stat:nth-child(4) { animation: fadeInUp .32s .20s ease both; }
.bdash-grid .bdash-stat:nth-child(5),
.abk-stats .abk-stat:nth-child(5),
.mbk-stats .mbk-stat:nth-child(5) { animation: fadeInUp .32s .24s ease both; }
.bdash-grid .bdash-stat:nth-child(6),
.abk-stats .abk-stat:nth-child(6),
.mbk-stats .mbk-stat:nth-child(6) { animation: fadeInUp .32s .28s ease both; }

/* ---- Card panels ---- */
.bdash-card,
.abk-card,
.mbk-card {
  transition: box-shadow .2s ease;
}

/* ---- Mobile table scroll indicator JS helper ---- */
/* Add .has-scroll-hint to table-responsive wrapper to show the indicator */
.table-responsive.has-scroll-hint {
  --scroll-shadow: 24px;
  box-shadow: inset calc(-1 * var(--scroll-shadow)) 0 var(--scroll-shadow) calc(-1 * var(--scroll-shadow)) rgba(15,23,42,.08);
}

/* ---- Mobile: action buttons should be full-width ---- */
@media (max-width: 575.98px) {
  .abk-actions-top .btn,
  .mbk-actions-top .btn,
  .hm-head-actions .btn:not(.w3-icon-btn) {
    flex: 1 1 auto;
  }

  .hm-head-actions,
  .abk-actions-top,
  .mbk-actions-top {
    width: 100%;
  }

  /* Smaller stat values on mobile */
  .abk-stat strong,
  .mbk-stat strong {
    font-size: 20px;
  }
}

/* =========================================================
   Responsive Polish
   ========================================================= */
@media (max-width: 991.98px) {
  .card:hover { transform: none; }
  .bdash-stat:hover,
  .abk-stat:hover,
  .mbk-stat:hover { transform: none; box-shadow: none; }
}

@media (max-width: 575.98px) {
  h1 { font-size: 1.35rem; }
  h2 { font-size: 1.1rem; }
  .btn { font-size: var(--fs-13); padding: 7px 11px; }
  .btn-sm { padding: 5px 9px; font-size: var(--fs-12); }
  .modal-content { border-radius: var(--radius-2); }
  .pagination { gap: 3px; }
  .page-link { padding: 5px 9px; font-size: var(--fs-12); min-width: 30px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}