/* ============================================================================
   main.css — Layout, components & interactions
   ----------------------------------------------------------------------------
   Reads exclusively from the tokens in themes.css. No hard-coded colours.
   Bootstrap supplies the base reset (Reboot) and the JS-component CSS
   (modal, offcanvas, toast, dropdown, tooltip, collapse). Tailwind supplies
   layout utilities (Preflight disabled). This file owns the visual identity.

   Table of contents
   -----------------
   01. Base & helpers          08. Forms
   02. App shell (layout)      09. Tables
   03. Sidebar                 10. Badges / alerts / progress
   04. Header                  11. Timeline / profile / kanban
   05. Buttons                 12. Tabs / pagination / breadcrumb
   06. Cards & stat cards      13. Empty & loading states
   07. Bootstrap JS skins      14. Auth & error pages
                               15. Animations, scrollbar, a11y, responsive
   ========================================================================== */

/* ============================================================================
   01. BASE & HELPERS
   ========================================================================== */
body {
  margin: 0;
  font-family: var(--font-family);
  font-size: var(--fs-md);
  line-height: 1.55;
  color: var(--text-color);
  background-color: var(--bg-color);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color var(--transition), color var(--transition);
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }
hr { border-color: var(--border-color); opacity: 1; }
::selection { background: var(--primary-soft); color: var(--text-strong); }

.text-muted-2 { color: var(--text-muted) !important; }
.text-faint { color: var(--text-faint) !important; }
.mono { font-family: var(--font-mono); font-feature-settings: "tnum" 1; }
.fw-medium { font-weight: 500; }

.glass {
  background: var(--header-bg);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  backdrop-filter: saturate(180%) blur(16px);
}

.section-title { font-size: var(--fs-xl); font-weight: 650; letter-spacing: -0.01em; color: var(--text-strong); }
.eyebrow {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
}

/* ============================================================================
   02. APP SHELL — sidebar rail + main column
   ========================================================================== */
.app-shell { min-height: 100vh; }

.app-main {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-inline-start var(--transition-slow);
}

.app-content {
  flex: 1 1 auto;
  width: 100%;
  max-width: var(--content-max);
  margin-inline: auto;
  padding: clamp(1rem, 2vw, 1.75rem);
}

.app-footer {
  padding: 1rem clamp(1rem, 2vw, 1.75rem);
  border-top: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: var(--fs-sm);
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  align-items: center;
  justify-content: space-between;
}
.app-footer a { color: var(--text-muted); }
.app-footer a:hover { color: var(--primary); }

/* On desktop the rail is fixed; the main column is offset by its width. */
@media (min-width: 992px) {
  .app-main { margin-inline-start: var(--sidebar-width); }
  body.sidebar-collapsed .app-main { margin-inline-start: var(--sidebar-width-collapsed); }
}

/* ============================================================================
   03. SIDEBAR
   ----------------------------------------------------------------------------
   Markup uses Bootstrap's responsive `offcanvas-lg`: static on ≥lg, a real
   offcanvas drawer below lg. The collapsed (80px) state is a desktop concern.
   ========================================================================== */
.app-sidebar {
  background: var(--sidebar-bg);
  border-inline-end: 1px solid var(--border-color);
  width: var(--sidebar-width);
}

@media (min-width: 992px) {
  .app-sidebar.offcanvas-lg {
    position: fixed;
    inset-block: 0;
    inset-inline-start: 0;
    z-index: var(--z-sidebar);
    display: flex;
    flex-direction: column;
    transition: width var(--transition-slow);
  }
  body.sidebar-collapsed .app-sidebar { width: var(--sidebar-width-collapsed); }
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  height: var(--header-height);
  padding-inline: 1.4rem;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}
.sidebar-brand .brand-mark {
  width: 34px; height: 34px;
  border-radius: var(--radius-md);
  display: grid; place-items: center;
  background: var(--primary);
  color: var(--primary-contrast);
  font-size: 1.05rem;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}
.sidebar-brand .brand-text { display: flex; flex-direction: column; line-height: 1.1; overflow: hidden; }
.sidebar-brand .brand-name { font-weight: 700; letter-spacing: -0.01em; color: var(--text-strong); white-space: nowrap; }
.sidebar-brand .brand-sub { font-size: var(--fs-xs); color: var(--text-faint); white-space: nowrap; }

/* Scrollable nav region */
.sidebar-nav {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.85rem 0.75rem 1.25rem;
}
.nav-section-label {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 1.1rem 0.85rem 0.45rem;
}
.sidebar-nav ul { list-style: none; margin: 0; padding: 0; }

/* A nav row (link or submenu toggle) */
.nav-link-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.6rem 0.85rem;
  margin-block: 2px;
  border: 0;
  background: transparent;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: var(--fs-md);
  font-weight: 500;
  text-align: start;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.nav-link-row:hover { background: var(--card-bg-subtle); color: var(--text-color); }
.nav-link-row .nav-icon { font-size: 1.15rem; flex-shrink: 0; width: 1.25rem; text-align: center; }
.nav-link-row .nav-label { flex: 1 1 auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-link-row .nav-caret { font-size: 0.9rem; transition: transform var(--transition); color: var(--text-faint); }
.nav-link-row[aria-expanded="true"] .nav-caret { transform: rotate(90deg); }

/* Active states */
.nav-link-row.active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
}
[data-theme="dark"] .nav-link-row.active { color: #c9d4ff; }
[data-accent="green"][data-theme="dark"] .nav-link-row.active { color: #8ff0cf; }
[data-accent="purple"][data-theme="dark"] .nav-link-row.active { color: #d7c6ff; }
[data-accent="orange"][data-theme="dark"] .nav-link-row.active { color: #ffc89a; }

.nav-link-row.active .nav-icon { color: var(--primary); }

/* Submenu (Bootstrap collapse) */
.nav-submenu { padding-inline-start: 0.6rem; }
.nav-submenu .nav-link-row {
  padding-block: 0.45rem;
  font-weight: 500;
  font-size: var(--fs-sm);
}
.nav-submenu .nav-label { position: relative; padding-inline-start: 1.55rem; }
.nav-submenu .nav-label::before {
  content: "";
  position: absolute;
  inset-inline-start: 0.4rem;
  inset-block: 0;
  width: 1.5px;
  background: var(--border-strong);
}
.nav-submenu .nav-link-row.active .nav-label::before { background: var(--primary); }

/* Badge counter */
.nav-badge {
  margin-inline-start: auto;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 600;
  line-height: 1;
  padding: 0.28em 0.5em;
  border-radius: var(--radius-pill);
  background: var(--primary-soft);
  color: var(--primary);
}
.nav-badge.danger { background: rgba(var(--danger-rgb), 0.14); color: var(--danger-color); }

/* User profile footer in rail */
.sidebar-profile {
  flex-shrink: 0;
  border-top: 1px solid var(--border-color);
  padding: 0.75rem;
}
.sidebar-profile .profile-row {
  display: flex; align-items: center; gap: 0.7rem;
  padding: 0.5rem; border-radius: var(--radius-md);
}
.sidebar-profile .profile-meta { overflow: hidden; line-height: 1.2; }
.sidebar-profile .profile-name { font-weight: 600; color: var(--text-strong); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-profile .profile-role { font-size: var(--fs-xs); color: var(--text-faint); white-space: nowrap; }

.avatar {
  --size: 38px;
  width: var(--size); height: var(--size);
  border-radius: var(--radius-pill);
  object-fit: cover;
  display: grid; place-items: center;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
  flex-shrink: 0;
}
.avatar.sm { --size: 30px; font-size: var(--fs-xs); }
.avatar.lg { --size: 64px; font-size: var(--fs-xl); }

/* ---- Collapsed rail (desktop ≥lg only) ---------------------------------- */
@media (min-width: 992px) {
  body.sidebar-collapsed .app-sidebar .brand-text,
  body.sidebar-collapsed .app-sidebar .nav-label,
  body.sidebar-collapsed .app-sidebar .nav-caret,
  body.sidebar-collapsed .app-sidebar .nav-badge,
  body.sidebar-collapsed .app-sidebar .nav-section-label,
  body.sidebar-collapsed .app-sidebar .profile-meta { display: none; }

  body.sidebar-collapsed .app-sidebar .sidebar-brand,
  body.sidebar-collapsed .app-sidebar .nav-link-row,
  body.sidebar-collapsed .app-sidebar .profile-row { justify-content: center; }

  body.sidebar-collapsed .app-sidebar .nav-link-row { padding-inline: 0; }

  /* keep nested submenus closed visually when collapsed */
  body.sidebar-collapsed .app-sidebar .nav-submenu.collapse:not(.collapsing) { display: none !important; }

  /* Flyout label on hover when collapsed */
  body.sidebar-collapsed .app-sidebar .has-flyout { position: relative; }
  body.sidebar-collapsed .app-sidebar .has-flyout > .nav-link-row::after {
    content: attr(data-title);
    position: absolute;
    inset-inline-start: calc(100% + 8px);
    top: 50%;
    transform: translateY(-50%);
    background: var(--text-strong);
    color: var(--bg-color);
    padding: 0.35rem 0.6rem;
    border-radius: var(--radius-sm);
    font-size: var(--fs-xs);
    white-space: nowrap;
    box-shadow: var(--shadow-md);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-fast);
    z-index: 5;
  }
  body.sidebar-collapsed .app-sidebar .has-flyout:hover > .nav-link-row::after { opacity: 1; }
}

/* ============================================================================
   04. HEADER
   ========================================================================== */
.app-header {
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  height: var(--header-height);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding-inline: clamp(0.75rem, 1.5vw, 1.25rem);
  border-bottom: 1px solid var(--border-color);
}

.header-search {
  position: relative;
  flex: 1 1 320px;
  max-width: 440px;
}
.header-search .bi {
  position: absolute;
  inset-inline-start: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-faint);
  pointer-events: none;
}
.header-search input {
  width: 100%;
  height: 40px;
  padding: 0 2.7rem 0 2.4rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-color);
  color: var(--text-color);
  font-size: var(--fs-sm);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.header-search input::placeholder { color: var(--text-faint); }
.header-search input:focus { outline: 0; border-color: var(--primary); box-shadow: var(--shadow-focus); }
.header-search kbd {
  position: absolute;
  inset-inline-end: 0.6rem;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-faint);
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.1rem 0.35rem;
}

/* Round icon button used across header & card actions */
.icon-btn {
  position: relative;
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-muted);
  font-size: 1.15rem;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}
.icon-btn:hover { background: var(--card-bg-subtle); color: var(--text-color); border-color: var(--border-color); }
.icon-btn .dot {
  position: absolute;
  top: 7px; inset-inline-end: 8px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--danger-color);
  border: 2px solid var(--card-bg);
}

.header-divider { width: 1px; height: 26px; background: var(--border-color); margin-inline: 0.35rem; }

/* ============================================================================
   05. BUTTONS
   ========================================================================== */
.btn-x {
  --btn-bg: var(--card-bg);
  --btn-fg: var(--text-color);
  --btn-bd: var(--border-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  height: 40px;
  padding-inline: 1rem;
  border: 1px solid var(--btn-bd);
  border-radius: var(--radius-md);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-family: inherit;
  font-size: var(--fs-md);
  font-weight: 550;
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
  transition: filter var(--transition-fast), background var(--transition-fast),
              border-color var(--transition-fast), box-shadow var(--transition-fast), color var(--transition-fast);
}
.btn-x:hover { filter: brightness(0.97); }
.btn-x:active { transform: translateY(0.5px); }
.btn-x:focus-visible { outline: 0; box-shadow: var(--shadow-focus); }
.btn-x:disabled { opacity: 0.55; cursor: not-allowed; filter: none; }

/* Sizes */
.btn-x.sm { height: 32px; padding-inline: 0.7rem; font-size: var(--fs-sm); border-radius: var(--radius-sm); }
.btn-x.lg { height: 48px; padding-inline: 1.35rem; font-size: var(--fs-lg); }
.btn-x.icon-only { width: 40px; padding-inline: 0; }
.btn-x.icon-only.sm { width: 32px; }
.btn-x.pill { border-radius: var(--radius-pill); }
.btn-x.block { width: 100%; }

/* Solid variants */
.btn-x.primary   { --btn-bg: var(--primary); --btn-fg: var(--primary-contrast); --btn-bd: var(--primary); box-shadow: var(--shadow-sm); }
.btn-x.primary:hover   { --btn-bg: var(--primary-hover); --btn-bd: var(--primary-hover); filter: none; }
.btn-x.secondary { --btn-bg: var(--secondary-color); --btn-fg: #fff; --btn-bd: var(--secondary-color); }
.btn-x.success   { --btn-bg: var(--success-color); --btn-fg: #fff; --btn-bd: var(--success-color); }
.btn-x.danger    { --btn-bg: var(--danger-color); --btn-fg: #fff; --btn-bd: var(--danger-color); }
.btn-x.warning   { --btn-bg: var(--warning-color); --btn-fg: #1f2937; --btn-bd: var(--warning-color); }
.btn-x.info      { --btn-bg: var(--info-color); --btn-fg: #fff; --btn-bd: var(--info-color); }

/* Outline = transparent bg, coloured text+border */
.btn-x.outline { --btn-bg: transparent; --btn-fg: var(--primary); --btn-bd: var(--primary); }
.btn-x.outline:hover { --btn-bg: var(--primary-soft); filter: none; }
.btn-x.outline.danger { --btn-fg: var(--danger-color); --btn-bd: var(--danger-color); }
.btn-x.outline.danger:hover { --btn-bg: rgba(var(--danger-rgb), 0.1); }

/* Ghost = no border, hover fill */
.btn-x.ghost { --btn-bg: transparent; --btn-bd: transparent; --btn-fg: var(--text-color); }
.btn-x.ghost:hover { --btn-bg: var(--card-bg-subtle); filter: none; }

/* ============================================================================
   06. CARDS & STAT CARDS
   ========================================================================== */
.card-x {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), transform var(--transition), border-color var(--transition);
}
.card-x.hoverable:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }

.card-x-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.05rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
}
.card-x-header .ttl { font-weight: 600; color: var(--text-strong); letter-spacing: -0.01em; }
.card-x-header .sub { font-size: var(--fs-sm); color: var(--text-muted); }
.card-x-header .actions { margin-inline-start: auto; display: flex; align-items: center; gap: 0.25rem; }
.card-x-body { padding: 1.25rem; }
.card-x-body.collapsing, .card-x-body.collapse { padding-block: 0; }
.card-x-body.collapse.show, .card-x-body.collapsing { padding-block: 1.25rem; }
.card-x-footer { padding: 0.9rem 1.25rem; border-top: 1px solid var(--border-color); }

/* Stat card — "instrument panel" look with mono numerals */
.stat-card {
  position: relative;
  overflow: hidden;
  padding: 1.25rem;
}
.stat-card .stat-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.75rem; }
.stat-card .stat-icon {
  width: 44px; height: 44px;
  border-radius: var(--radius-md);
  display: grid; place-items: center;
  font-size: 1.3rem;
  background: var(--primary-soft);
  color: var(--primary);
}
.stat-card .stat-icon.success { background: rgba(var(--success-rgb), 0.12); color: var(--success-color); }
.stat-card .stat-icon.warning { background: rgba(var(--warning-rgb), 0.14); color: var(--warning-color); }
.stat-card .stat-icon.info    { background: rgba(var(--info-rgb), 0.12); color: var(--info-color); }
.stat-card .stat-label { font-size: var(--fs-sm); color: var(--text-muted); margin-top: 1rem; }
.stat-card .stat-value {
  font-family: var(--font-mono);
  font-feature-settings: "tnum" 1;
  font-size: var(--fs-3xl);
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-strong);
  line-height: 1.1;
  margin-top: 0.2rem;
}
.stat-trend {
  display: inline-flex; align-items: center; gap: 0.25rem;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 600;
  padding: 0.2rem 0.45rem;
  border-radius: var(--radius-sm);
  margin-top: 0.6rem;
}
.stat-trend.up { background: rgba(var(--success-rgb), 0.12); color: var(--success-color); }
.stat-trend.down { background: rgba(var(--danger-rgb), 0.12); color: var(--danger-color); }

/* Chart placeholder (so the template ships without a chart lib) */
.chart-placeholder {
  position: relative;
  height: 240px;
  border-radius: var(--radius-md);
  background:
    linear-gradient(var(--border-color) 1px, transparent 1px) 0 0 / 100% 48px,
    var(--card-bg-subtle);
  overflow: hidden;
}
.chart-placeholder .spark {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(to top, var(--primary-soft), transparent 70%);
  -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='100' height='40' preserveAspectRatio='none'><path d='M0,32 C12,30 18,10 28,14 C38,18 44,4 56,8 C68,12 74,26 84,20 C92,15 96,18 100,12 L100,40 L0,40 Z' fill='black'/></svg>") no-repeat center / 100% 100%;
          mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='100' height='40' preserveAspectRatio='none'><path d='M0,32 C12,30 18,10 28,14 C38,18 44,4 56,8 C68,12 74,26 84,20 C92,15 96,18 100,12 L100,40 L0,40 Z' fill='black'/></svg>") no-repeat center / 100% 100%;
}
.chart-placeholder .spark-line {
  position: absolute; inset: 0;
  background: var(--primary);
  -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='100' height='40' preserveAspectRatio='none'><path d='M0,32 C12,30 18,10 28,14 C38,18 44,4 56,8 C68,12 74,26 84,20 C92,15 96,18 100,12' fill='none' stroke='black' stroke-width='1.4'/></svg>") no-repeat center / 100% 100%;
          mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='100' height='40' preserveAspectRatio='none'><path d='M0,32 C12,30 18,10 28,14 C38,18 44,4 56,8 C68,12 74,26 84,20 C92,15 96,18 100,12' fill='none' stroke='black' stroke-width='1.4'/></svg>") no-repeat center / 100% 100%;
}

/* ============================================================================
   07. BOOTSTRAP JS-COMPONENT SKINS
   Re-skin Bootstrap's modal / offcanvas / toast / dropdown / tooltip so they
   match the token system instead of Bootstrap's default blue/grey.
   ========================================================================== */
.modal-content,
.offcanvas {
  background: var(--card-bg);
  color: var(--text-color);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}
.offcanvas { border-radius: 0; }
.modal-header, .offcanvas-header { border-bottom: 1px solid var(--border-color); }
.modal-footer { border-top: 1px solid var(--border-color); }
.modal-title, .offcanvas-title { font-weight: 650; color: var(--text-strong); letter-spacing: -0.01em; }
.modal-backdrop { background-color: #0b1020; }
.modal-backdrop.show { opacity: 0.55; }
[data-theme="dark"] .btn-close { filter: invert(1) grayscale(1) brightness(1.6); }

.dropdown-menu {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 0.4rem;
  font-size: var(--fs-md);
  min-width: 220px;
}
.dropdown-menu .dropdown-item {
  display: flex; align-items: center; gap: 0.6rem;
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.6rem;
  color: var(--text-color);
}
.dropdown-menu .dropdown-item:hover,
.dropdown-menu .dropdown-item:focus { background: var(--card-bg-subtle); color: var(--text-strong); }
.dropdown-menu .dropdown-item.text-danger:hover { background: rgba(var(--danger-rgb), 0.1); color: var(--danger-color); }
.dropdown-menu .dropdown-header { color: var(--text-faint); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.06em; }
.dropdown-divider { border-color: var(--border-color); }
.dropdown-item .bi { font-size: 1rem; color: var(--text-muted); }

/* Notification list inside dropdowns */
.dd-notify { min-width: 340px; padding: 0; overflow: hidden; }
.dd-notify .dd-head { display: flex; align-items: center; justify-content: space-between; padding: 0.85rem 1rem; border-bottom: 1px solid var(--border-color); }
.dd-notify .dd-item { display: flex; gap: 0.75rem; padding: 0.75rem 1rem; border-bottom: 1px solid var(--border-color); cursor: pointer; }
.dd-notify .dd-item:hover { background: var(--card-bg-subtle); }
.dd-notify .dd-item .ic { width: 34px; height: 34px; border-radius: var(--radius-md); display: grid; place-items: center; flex-shrink: 0; }
.dd-notify .dd-foot { padding: 0.6rem; text-align: center; }
.dd-notify .dd-item p { margin: 0; font-size: var(--fs-sm); }
.dd-notify .dd-item .t { font-size: var(--fs-xs); color: var(--text-faint); }

.tooltip-inner {
  background: var(--text-strong);
  color: var(--bg-color);
  border-radius: var(--radius-sm);
  font-size: var(--fs-xs);
  padding: 0.4rem 0.6rem;
}
.tooltip.bs-tooltip-top .tooltip-arrow::before { border-top-color: var(--text-strong); }
.tooltip.bs-tooltip-bottom .tooltip-arrow::before { border-bottom-color: var(--text-strong); }
.tooltip.bs-tooltip-start .tooltip-arrow::before { border-left-color: var(--text-strong); }
.tooltip.bs-tooltip-end .tooltip-arrow::before { border-right-color: var(--text-strong); }

/* Toast container + cards (positions set via JS) */
.toast-stack { position: fixed; z-index: var(--z-loader); display: flex; flex-direction: column; gap: 0.6rem; padding: 1rem; max-width: 380px; pointer-events: none; }
.toast-stack.top-right { top: 0; inset-inline-end: 0; }
.toast-stack.top-left { top: 0; inset-inline-start: 0; }
.toast-stack.bottom-right { bottom: 0; inset-inline-end: 0; }
.toast-stack.bottom-left { bottom: 0; inset-inline-start: 0; }
.toast-stack.top-center { top: 0; inset-inline: 0; margin-inline: auto; }
.toast-x {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-inline-start: 3px solid var(--primary);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 0.85rem 1rem;
}
.toast-x.success { border-inline-start-color: var(--success-color); }
.toast-x.error { border-inline-start-color: var(--danger-color); }
.toast-x.info { border-inline-start-color: var(--info-color); }
.toast-x .t-ic { font-size: 1.2rem; line-height: 1.4; }
.toast-x.success .t-ic { color: var(--success-color); }
.toast-x.error .t-ic { color: var(--danger-color); }
.toast-x.info .t-ic { color: var(--info-color); }
.toast-x .t-body { flex: 1 1 auto; }
.toast-x .t-title { font-weight: 600; color: var(--text-strong); font-size: var(--fs-md); }
.toast-x .t-msg { font-size: var(--fs-sm); color: var(--text-muted); }
.toast-x .t-close { background: none; border: 0; color: var(--text-faint); cursor: pointer; font-size: 1rem; padding: 0; line-height: 1; }

/* ============================================================================
   08. FORMS
   ========================================================================== */
.field { margin-bottom: 1.1rem; }
.field-label { display: block; font-size: var(--fs-sm); font-weight: 600; color: var(--text-color); margin-bottom: 0.4rem; }
.field-hint { font-size: var(--fs-xs); color: var(--text-faint); margin-top: 0.35rem; }
.field-error { font-size: var(--fs-xs); color: var(--danger-color); margin-top: 0.35rem; display: none; }

.input-x, .select-x, .textarea-x {
  width: 100%;
  font-family: inherit;
  font-size: var(--fs-md);
  color: var(--text-color);
  background: var(--card-bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 0.6rem 0.85rem;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.input-x { height: 42px; }
.textarea-x { min-height: 96px; resize: vertical; }
.input-x::placeholder, .textarea-x::placeholder { color: var(--text-faint); }
.input-x:focus, .select-x:focus, .textarea-x:focus { outline: 0; border-color: var(--primary); box-shadow: var(--shadow-focus); }
.input-x:disabled, .select-x:disabled, .textarea-x:disabled { background: var(--card-bg-subtle); color: var(--text-faint); cursor: not-allowed; }

.select-x {
  height: 42px;
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%23667085' viewBox='0 0 16 16'><path d='M4 6l4 4 4-4'/></svg>");
  background-repeat: no-repeat;
  background-position: right 0.8rem center;
  padding-inline-end: 2.2rem;
}

/* Validation states */
.field.is-valid .input-x, .field.is-valid .select-x, .field.is-valid .textarea-x { border-color: var(--success-color); }
.field.is-invalid .input-x, .field.is-invalid .select-x, .field.is-invalid .textarea-x { border-color: var(--danger-color); }
.field.is-invalid .field-error { display: block; }

/* Input group */
.input-group-x { display: flex; }
.input-group-x .addon {
  display: grid; place-items: center;
  padding-inline: 0.85rem;
  background: var(--card-bg-subtle);
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
  font-size: var(--fs-sm);
}
.input-group-x .addon:first-child { border-inline-end: 0; border-radius: var(--radius-md) 0 0 var(--radius-md); }
.input-group-x .addon:last-child { border-inline-start: 0; border-radius: 0 var(--radius-md) var(--radius-md) 0; }
.input-group-x .input-x:not(:first-child) { border-start-start-radius: 0; border-end-start-radius: 0; }
.input-group-x .input-x:not(:last-child) { border-start-end-radius: 0; border-end-end-radius: 0; }

/* Checkbox & radio */
.check-x { display: inline-flex; align-items: center; gap: 0.55rem; cursor: pointer; font-size: var(--fs-md); }
.check-x input { width: 18px; height: 18px; accent-color: var(--primary); cursor: pointer; }

/* Switch (pure CSS) */
.switch-x { display: inline-flex; align-items: center; gap: 0.6rem; cursor: pointer; }
.switch-x input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-x .track {
  width: 42px; height: 24px;
  border-radius: var(--radius-pill);
  background: var(--border-strong);
  position: relative;
  transition: background var(--transition);
  flex-shrink: 0;
}
.switch-x .track::after {
  content: "";
  position: absolute; top: 3px; inset-inline-start: 3px;
  width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: var(--shadow-sm);
  transition: transform var(--transition);
}
.switch-x input:checked + .track { background: var(--primary); }
.switch-x input:checked + .track::after { transform: translateX(18px); }
.switch-x input:focus-visible + .track { box-shadow: var(--shadow-focus); }

/* File upload (dropzone style) */
.file-x {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  text-align: center;
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}
.file-x:hover, .file-x.dragover { border-color: var(--primary); background: var(--primary-soft); color: var(--text-color); }
.file-x .bi { font-size: 1.6rem; color: var(--primary); }
.file-x input { display: none; }

/* Range slider */
.range-x { width: 100%; accent-color: var(--primary); height: 6px; }

/* ============================================================================
   09. TABLES
   ========================================================================== */
.table-x { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--fs-sm); }
.table-x thead th {
  text-align: start;
  font-weight: 600;
  font-size: var(--fs-xs);
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
  background: var(--card-bg-subtle);
}
.table-x tbody td { padding: 0.85rem 1rem; border-bottom: 1px solid var(--border-color); color: var(--text-color); vertical-align: middle; }
.table-x tbody tr:last-child td { border-bottom: 0; }
.table-x tbody tr { transition: background var(--transition-fast); }
.table-x tbody tr:hover { background: var(--card-bg-subtle); }
.table-x .cell-strong { font-weight: 600; color: var(--text-strong); }
.table-x .cell-mono { font-family: var(--font-mono); font-feature-settings: "tnum" 1; }
.table-wrap { overflow-x: auto; }

/* ============================================================================
   10. BADGES / ALERTS / PROGRESS
   ========================================================================== */
.badge-x {
  display: inline-flex; align-items: center; gap: 0.3rem;
  font-size: var(--fs-xs);
  font-weight: 600;
  line-height: 1;
  padding: 0.35em 0.6em;
  border-radius: var(--radius-pill);
  background: var(--card-bg-subtle);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
}
.badge-x .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-x.primary { background: var(--primary-soft); color: var(--primary); border-color: transparent; }
.badge-x.success { background: rgba(var(--success-rgb), 0.12); color: var(--success-color); border-color: transparent; }
.badge-x.danger  { background: rgba(var(--danger-rgb), 0.12); color: var(--danger-color); border-color: transparent; }
.badge-x.warning { background: rgba(var(--warning-rgb), 0.14); color: #b45309; border-color: transparent; }
[data-theme="dark"] .badge-x.warning { color: var(--warning-color); }
.badge-x.info    { background: rgba(var(--info-rgb), 0.12); color: var(--info-color); border-color: transparent; }

.alert-x {
  display: flex; gap: 0.75rem; align-items: flex-start;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--card-bg-subtle);
  color: var(--text-color);
}
.alert-x .a-ic { font-size: 1.2rem; line-height: 1.4; flex-shrink: 0; }
.alert-x .a-body { flex: 1 1 auto; font-size: var(--fs-sm); }
.alert-x .a-title { font-weight: 600; color: var(--text-strong); }
.alert-x.primary { background: var(--primary-soft); border-color: transparent; } .alert-x.primary .a-ic { color: var(--primary); }
.alert-x.success { background: rgba(var(--success-rgb), 0.1); border-color: transparent; } .alert-x.success .a-ic { color: var(--success-color); }
.alert-x.danger  { background: rgba(var(--danger-rgb), 0.1); border-color: transparent; } .alert-x.danger .a-ic { color: var(--danger-color); }
.alert-x.warning { background: rgba(var(--warning-rgb), 0.12); border-color: transparent; } .alert-x.warning .a-ic { color: var(--warning-color); }
.alert-x .a-close { background: none; border: 0; color: var(--text-faint); cursor: pointer; font-size: 1rem; padding: 0; }

.progress-x { height: 8px; border-radius: var(--radius-pill); background: var(--border-color); overflow: hidden; }
.progress-x .bar {
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
  width: 0;
  transition: width var(--transition-slow);
}
.progress-x .bar.success { background: var(--success-color); }
.progress-x .bar.warning { background: var(--warning-color); }
.progress-x .bar.danger { background: var(--danger-color); }
.progress-x .bar.striped {
  background-image: linear-gradient(45deg, rgba(255,255,255,0.2) 25%, transparent 25%, transparent 50%, rgba(255,255,255,0.2) 50%, rgba(255,255,255,0.2) 75%, transparent 75%);
  background-size: 1rem 1rem;
  animation: progress-stripes 1s linear infinite;
}
@keyframes progress-stripes { from { background-position: 1rem 0; } to { background-position: 0 0; } }

/* ============================================================================
   11. TIMELINE / PROFILE / KANBAN
   ========================================================================== */
.timeline { position: relative; padding-inline-start: 1.5rem; }
.timeline::before { content: ""; position: absolute; inset-inline-start: 5px; inset-block: 6px; width: 2px; background: var(--border-color); }
.timeline-item { position: relative; padding-bottom: 1.4rem; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-item .tl-dot {
  position: absolute; inset-inline-start: -1.5rem; top: 3px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--card-bg); border: 2px solid var(--primary);
}
.timeline-item.success .tl-dot { border-color: var(--success-color); }
.timeline-item.warning .tl-dot { border-color: var(--warning-color); }
.timeline-item .tl-title { font-weight: 600; color: var(--text-strong); font-size: var(--fs-md); }
.timeline-item .tl-meta { font-size: var(--fs-xs); color: var(--text-faint); font-family: var(--font-mono); }
.timeline-item .tl-text { font-size: var(--fs-sm); color: var(--text-muted); margin-top: 0.15rem; }

.profile-card { text-align: center; padding: 1.75rem 1.25rem; }
.profile-card .cover { height: 72px; border-radius: var(--radius-md) var(--radius-md) 0 0; background: linear-gradient(120deg, var(--primary), var(--primary-hover)); margin: -1.75rem -1.25rem 0; }
.profile-card .avatar.lg { margin: -38px auto 0.75rem; border: 4px solid var(--card-bg); }
.profile-card .p-name { font-weight: 700; font-size: var(--fs-lg); color: var(--text-strong); }
.profile-card .p-role { color: var(--text-muted); font-size: var(--fs-sm); }
.profile-card .p-social { display: flex; justify-content: center; gap: 0.5rem; margin-top: 1rem; }
.profile-card .p-stats { display: flex; justify-content: space-around; margin-top: 1.25rem; padding-top: 1.25rem; border-top: 1px solid var(--border-color); }
.profile-card .p-stats .n { font-family: var(--font-mono); font-weight: 600; font-size: var(--fs-lg); color: var(--text-strong); }
.profile-card .p-stats .l { font-size: var(--fs-xs); color: var(--text-faint); }

.kanban-col { background: var(--card-bg-subtle); border: 1px solid var(--border-color); border-radius: var(--radius-lg); padding: 0.85rem; }
.kanban-col .k-head { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.85rem; font-weight: 600; color: var(--text-strong); font-size: var(--fs-sm); }
.kanban-col .k-head .count { margin-inline-start: auto; font-family: var(--font-mono); color: var(--text-faint); }
.kanban-card { background: var(--card-bg); border: 1px solid var(--border-color); border-radius: var(--radius-md); padding: 0.85rem; margin-bottom: 0.7rem; box-shadow: var(--shadow-sm); cursor: grab; }
.kanban-card:last-child { margin-bottom: 0; }
.kanban-card .kc-title { font-weight: 600; font-size: var(--fs-sm); color: var(--text-strong); }
.kanban-card .kc-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 0.7rem; }

/* ============================================================================
   12. TABS / PAGINATION / BREADCRUMB
   ========================================================================== */
.tabs-x { display: flex; gap: 0.25rem; border-bottom: 1px solid var(--border-color); }
.tabs-x .tab {
  border: 0; background: none; cursor: pointer;
  padding: 0.7rem 0.95rem;
  font-size: var(--fs-md); font-weight: 550;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color var(--transition-fast), border-color var(--transition-fast);
}
.tabs-x .tab:hover { color: var(--text-color); }
.tabs-x .tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-panel { display: none; padding-top: 1.25rem; }
.tab-panel.active { display: block; }

.pagination-x { display: flex; align-items: center; gap: 0.3rem; }
.pagination-x .pg {
  min-width: 36px; height: 36px;
  display: grid; place-items: center;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--card-bg);
  color: var(--text-muted);
  font-size: var(--fs-sm);
  font-family: var(--font-mono);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.pagination-x .pg:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.pagination-x .pg.active { background: var(--primary); border-color: var(--primary); color: var(--primary-contrast); }
.pagination-x .pg:disabled { opacity: 0.45; cursor: not-allowed; }

.breadcrumb-x { display: flex; align-items: center; gap: 0.4rem; font-size: var(--fs-sm); color: var(--text-muted); }
.breadcrumb-x a { color: var(--text-muted); }
.breadcrumb-x a:hover { color: var(--primary); }
.breadcrumb-x .sep { color: var(--text-faint); }
.breadcrumb-x .current { color: var(--text-strong); font-weight: 600; }

/* ============================================================================
   13. EMPTY & LOADING STATES
   ========================================================================== */
.empty-state { text-align: center; padding: 2.5rem 1.5rem; }
.empty-state .es-art {
  width: 76px; height: 76px; margin: 0 auto 1rem;
  border-radius: var(--radius-xl);
  display: grid; place-items: center;
  background: var(--card-bg-subtle);
  border: 1px solid var(--border-color);
  font-size: 2rem; color: var(--text-faint);
}
.empty-state .es-title { font-weight: 650; color: var(--text-strong); font-size: var(--fs-lg); }
.empty-state .es-text { color: var(--text-muted); font-size: var(--fs-sm); max-width: 360px; margin: 0.35rem auto 1.25rem; }

/* Skeleton loaders */
.skeleton {
  background: linear-gradient(90deg, var(--card-bg-subtle) 25%, var(--border-color) 37%, var(--card-bg-subtle) 63%);
  background-size: 400% 100%;
  animation: skeleton-shine 1.4s ease infinite;
  border-radius: var(--radius-sm);
}
.skeleton.line { height: 12px; margin-bottom: 0.6rem; }
.skeleton.line.w-60 { width: 60%; }
.skeleton.line.w-40 { width: 40%; }
.skeleton.circle { width: 44px; height: 44px; border-radius: 50%; }
.skeleton.block { height: 140px; }
@keyframes skeleton-shine { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* Global loader overlay */
.loader-overlay {
  position: fixed; inset: 0;
  z-index: var(--z-loader);
  display: none;
  place-items: center;
  background: var(--overlay-bg);
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
}
.loader-overlay.show { display: grid; }
.spinner {
  width: 42px; height: 42px;
  border: 3px solid rgba(255,255,255,0.25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.spinner-sm { width: 18px; height: 18px; border-width: 2px; border-color: currentColor transparent currentColor transparent; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================================
   14. AUTH & ERROR PAGES
   ========================================================================== */
.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background:
    radial-gradient(60vw 60vw at 100% 0%, var(--primary-soft), transparent 60%),
    radial-gradient(50vw 50vw at 0% 100%, rgba(var(--primary-rgb), 0.08), transparent 60%),
    var(--bg-color);
}
.auth-card {
  width: 100%; max-width: 420px;
  background: var(--header-bg);
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: 2rem;
}
.auth-card .auth-brand { display: flex; align-items: center; gap: 0.65rem; margin-bottom: 1.5rem; }
.auth-card h1 { font-size: var(--fs-2xl); font-weight: 700; letter-spacing: -0.02em; color: var(--text-strong); margin: 0 0 0.25rem; }
.auth-card .sub { color: var(--text-muted); font-size: var(--fs-sm); margin-bottom: 1.5rem; }
.auth-divider { display: flex; align-items: center; gap: 0.75rem; color: var(--text-faint); font-size: var(--fs-xs); margin: 1.25rem 0; }
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--border-color); }

.error-page { min-height: 100vh; display: grid; place-items: center; text-align: center; padding: 2rem; background: var(--bg-color); }
.error-page .code {
  font-family: var(--font-mono);
  font-size: clamp(5rem, 18vw, 10rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.04em;
  background: linear-gradient(120deg, var(--primary), var(--primary-hover));
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
}
.error-page h1 { font-size: var(--fs-2xl); font-weight: 700; color: var(--text-strong); margin: 0.5rem 0 0.5rem; }
.error-page p { color: var(--text-muted); max-width: 420px; margin: 0 auto 1.75rem; }

/* ============================================================================
   15. ANIMATIONS, SCROLLBAR, A11Y, RESPONSIVE
   ========================================================================== */
.fade-in { animation: fadeIn var(--transition-slow) both; }
.slide-up { animation: slideUp var(--transition-slow) both; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
/* small stagger helper for grids */
.stagger > * { animation: slideUp var(--transition-slow) both; }
.stagger > *:nth-child(2) { animation-delay: 40ms; }
.stagger > *:nth-child(3) { animation-delay: 80ms; }
.stagger > *:nth-child(4) { animation-delay: 120ms; }

/* Custom scrollbar */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 99px; border: 2px solid var(--bg-color); }
*::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

/* Visible keyboard focus everywhere */
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
a:focus-visible, button:focus-visible, [tabindex]:focus-visible { border-radius: var(--radius-sm); }

/* Respect reduced-motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}

/* Mobile: header search collapses, offcanvas takes over for the rail */
@media (max-width: 991.98px) {
  .header-search { display: none; }
  .app-sidebar.offcanvas-lg { width: var(--sidebar-width); }
  .hide-mobile { display: none !important; }
}
@media (max-width: 575.98px) {
  .hide-xs { display: none !important; }
}
