/* ============================================================================
   Falatex Kardex Design System - Dark Mode & Glassmorphism
   ============================================================================ */

:root {
  --font-primary: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-display: 'Outfit', sans-serif;

  /* Color Palette */
  --bg-dark: #0b0f19;
  --bg-card: rgba(18, 24, 38, 0.75);
  --bg-card-hover: rgba(26, 34, 53, 0.85);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-highlight: rgba(99, 102, 241, 0.3);

  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --text-dim: #6b7280;

  /* Accent Colors */
  --accent-primary: #6366f1;
  --accent-primary-hover: #4f46e5;
  --accent-glow: rgba(99, 102, 241, 0.35);

  --color-ent: #10b981; /* Emerald for ENT */
  --color-ent-bg: rgba(16, 185, 129, 0.12);
  --color-sal: #f43f5e; /* Crimson for SAL */
  --color-sal-bg: rgba(244, 63, 94, 0.12);
  --color-aju: #f59e0b; /* Amber for AJU */
  --color-aju-bg: rgba(245, 158, 11, 0.12);

  --sidebar-width: 260px;
  --sidebar-width-collapsed: 72px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-primary);
  background-color: var(--bg-dark);
  color: var(--text-main);
  line-height: 1.5;
  overflow-x: hidden;
}

/* App Layout */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* Sidebar Backdrop */
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 45;
  animation: fadeIn 0.2s ease-out;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: rgba(15, 21, 35, 0.95);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  backdrop-filter: blur(12px);
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 50;
  transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1), transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-x: hidden;
}

.sidebar-header {
  padding: 1.25rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  min-height: 72px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  overflow: hidden;
  white-space: nowrap;
}

.brand-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
  flex-shrink: 0;
}

.brand-text h2 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.02em;
}

.brand-text span {
  font-size: 0.75rem;
  color: var(--accent-primary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.sidebar-toggle-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.sidebar-toggle-btn:hover {
  background: rgba(99, 102, 241, 0.2);
  color: #fff;
  border-color: rgba(99, 102, 241, 0.4);
}

.sidebar-toggle-btn i {
  width: 18px;
  height: 18px;
  transition: transform 0.25s ease;
}

.sidebar-nav {
  padding: 1.25rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.8rem 1rem;
  border-radius: 10px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-primary);
  font-size: 0.92rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
  position: relative;
  white-space: nowrap;
}

.nav-item:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.04);
}

.nav-item.active {
  color: #fff;
  background: linear-gradient(90deg, rgba(99, 102, 241, 0.2) 0%, rgba(99, 102, 241, 0.05) 100%);
  border-left: 3px solid var(--accent-primary);
}

.nav-item i {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 1.25rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  overflow: hidden;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  border-radius: 10px;
  font-family: var(--font-primary);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  border: none;
}

.btn-primary {
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  color: #fff;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #4f46e5 0%, #4338ca 100%);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.45);
  transform: translateY(-1px);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-main);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.btn-glow {
  position: relative;
  overflow: hidden;
}

.btn-glow::after {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(255,255,255,0.2) 0%, transparent 60%);
  opacity: 0;
  transition: opacity 0.3s;
}

.btn-glow:hover::after {
  opacity: 1;
}

.db-status-badge {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.85rem;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #6b7280;
  flex-shrink: 0;
}

.status-dot.online {
  background-color: #10b981;
  box-shadow: 0 0 8px #10b981;
}

.status-dot.offline {
  background-color: #ef4444;
}

/* Main Content */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  transition: margin-left 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.top-bar {
  padding: 1.25rem 2rem;
  background: rgba(11, 15, 25, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.85rem;
  position: sticky;
  top: 0;
  z-index: 40;
}

.top-bar-header-row {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  width: 100%;
}

.btn-topbar-sidebar-toggle {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.btn-topbar-sidebar-toggle:hover {
  background: rgba(99, 102, 241, 0.15);
  color: #fff;
  border-color: var(--accent-primary);
}

.btn-topbar-sidebar-toggle i {
  width: 18px;
  height: 18px;
}

.page-title {
  flex: 1;
}

.page-title h1 {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1.3;
}

/* ============================================================================
   Collapsed Sidebar State
   ============================================================================ */
body.sidebar-collapsed .sidebar {
  width: var(--sidebar-width-collapsed);
}

body.sidebar-collapsed .main-content {
  margin-left: var(--sidebar-width-collapsed);
}

body.sidebar-collapsed .brand-text,
body.sidebar-collapsed .nav-item span,
body.sidebar-collapsed .sidebar-footer .btn span,
body.sidebar-collapsed .db-status-badge .status-text,
body.sidebar-collapsed #nav-neg-count {
  display: none !important;
}

body.sidebar-collapsed .sidebar-header {
  padding: 1.25rem 0.5rem;
  justify-content: center;
}

body.sidebar-collapsed .brand {
  display: none;
}

body.sidebar-collapsed .sidebar-toggle-btn {
  margin: 0 auto;
}

body.sidebar-collapsed .sidebar-toggle-btn i {
  transform: rotate(180deg);
}

body.sidebar-collapsed .sidebar-nav {
  padding: 1rem 0.5rem;
  align-items: center;
}

body.sidebar-collapsed .nav-item {
  justify-content: center;
  padding: 0.75rem 0;
  width: 44px;
  height: 44px;
  border-radius: 10px;
}

body.sidebar-collapsed .nav-item.active {
  border-left: none;
  background: var(--accent-primary);
  color: #fff;
}

body.sidebar-collapsed .sidebar-footer {
  padding: 1rem 0.5rem;
  align-items: center;
}

body.sidebar-collapsed .sidebar-footer .btn {
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 10px;
  justify-content: center;
}

body.sidebar-collapsed .sidebar-footer .btn i {
  margin: 0;
}

body.sidebar-collapsed .db-status-badge {
  padding: 0.4rem;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  justify-content: center;
}

/* Mobile off-canvas */
@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-width) !important;
  }

  body.sidebar-mobile-open .sidebar {
    transform: translateX(0);
  }

  .main-content {
    margin-left: 0 !important;
  }
}

.page-title p {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.top-bar-controls {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-wrap: wrap;
  width: 100%;
  padding-top: 0.75rem;
  border-top: 1px dashed rgba(255, 255, 255, 0.08);
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.custom-select, .search-box input, .input-field input {
  background: rgba(18, 24, 38, 0.9);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.6rem 1rem;
  border-radius: 8px;
  font-family: var(--font-primary);
  font-size: 0.88rem;
  outline: none;
  transition: all 0.2s ease;
}

.custom-select:focus, .search-box input:focus, .input-field input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-box i {
  position: absolute;
  left: 0.8rem;
  width: 16px;
  height: 16px;
  color: var(--text-dim);
}

.search-box input {
  padding-left: 2.3rem;
  width: 260px;
}

/* Content Body & Tabs */
.content-body {
  padding: 2rem;
}

.tab-view {
  display: none;
}

.tab-view.active {
  display: block;
  animation: fadeIn 0.25s ease-in-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Metrics Cards Grid */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 1.25rem;
  backdrop-filter: blur(12px);
  position: relative;
  overflow: hidden;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.metric-card:hover {
  transform: translateY(-3px);
  border-color: var(--border-highlight);
}

.metric-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
}

.card-ent::before { background: var(--color-ent); }
.card-sal::before { background: var(--color-sal); }
.card-aju::before { background: var(--color-aju); }
.card-summary::before { background: var(--accent-primary); }

.metric-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.metric-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.metric-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-ent .metric-icon { background: var(--color-ent-bg); color: var(--color-ent); }
.card-sal .metric-icon { background: var(--color-sal-bg); color: var(--color-sal); }
.card-aju .metric-icon { background: var(--color-aju-bg); color: var(--color-aju); }
.card-summary .metric-icon { background: rgba(99, 102, 241, 0.12); color: var(--accent-primary); }

.metric-value {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
}

.metric-sub {
  font-size: 0.9rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-top: 0.2rem;
}

.metric-footer {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 0.75rem;
  padding-top: 0.5rem;
  border-top: 1px dashed rgba(255, 255, 255, 0.05);
}

/* Glass Panels */
.glass-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  backdrop-filter: blur(12px);
  padding: 1.5rem;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.panel-header h3 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.panel-header h3 i {
  color: var(--accent-primary);
  width: 20px;
  height: 20px;
}

/* Charts Grid */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 1.5rem;
}

.chart-container {
  position: relative;
  height: 280px;
  width: 100%;
}

/* Data Tables */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  overflow-y: auto;
  max-height: calc(100vh - 275px);
  min-height: 400px;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 0.25rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(99, 102, 241, 0.6) rgba(15, 23, 42, 0.6);
  position: relative;
}

.table-responsive::-webkit-scrollbar {
  height: 9px;
  width: 8px;
}

.table-responsive::-webkit-scrollbar-track {
  background: rgba(15, 23, 42, 0.7);
  border-radius: 6px;
}

.table-responsive::-webkit-scrollbar-thumb {
  background: rgba(99, 102, 241, 0.6);
  border-radius: 6px;
  border: 1px solid rgba(15, 23, 42, 0.7);
}

.table-responsive::-webkit-scrollbar-thumb:hover {
  background: rgba(99, 102, 241, 0.9);
}

.data-table {
  width: 100%;
  min-width: 1600px;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.88rem;
  text-align: left;
}

.data-table th {
  background: #0f172a;
  color: var(--text-muted);
  font-weight: 600;
  padding: 0.65rem 0.85rem;
  border-bottom: 2px solid var(--border-color);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  line-height: 1.25;
  vertical-align: middle;
  white-space: normal;
  position: sticky;
  top: 0;
  z-index: 20;
}

.data-table th .th-sub {
  font-size: 0.7rem;
  text-transform: none;
  color: var(--text-dim);
}

/* Sticky Frozen Columns: 1 (Bodega), 2 (Código), 3 (Descripción) */
.sticky-col-1 {
  position: sticky !important;
  left: 0px !important;
  width: 110px !important;
  min-width: 110px !important;
  max-width: 110px !important;
}

.sticky-col-2 {
  position: sticky !important;
  left: 110px !important;
  width: 120px !important;
  min-width: 120px !important;
  max-width: 120px !important;
}

.sticky-col-3 {
  position: sticky !important;
  left: 230px !important;
  width: 280px !important;
  min-width: 280px !important;
  max-width: 320px !important;
  border-right: 2px solid rgba(99, 102, 241, 0.4) !important;
  box-shadow: 4px 0 10px rgba(0, 0, 0, 0.4);
}

/* Backgrounds & Layering for Sticky Columns */
th.sticky-col-1,
th.sticky-col-2,
th.sticky-col-3 {
  z-index: 40 !important;
  background: #0f172a !important;
}

th.sticky-col-1.active-sort,
th.sticky-col-2.active-sort,
th.sticky-col-3.active-sort {
  background: #1e1b4b !important;
}

td.sticky-col-1,
td.sticky-col-2,
td.sticky-col-3 {
  z-index: 5 !important;
  background: #0b0f19 !important;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.data-table tbody tr:hover td.sticky-col-1,
.data-table tbody tr:hover td.sticky-col-2,
.data-table tbody tr:hover td.sticky-col-3 {
  background: #1e293b !important;
}

/* Sortable Table Headers */
.sortable-th {
  cursor: pointer;
  user-select: none;
  transition: background-color 0.15s ease, color 0.15s ease;
  position: relative;
}

.sortable-th:hover {
  background: #1e293b !important;
  color: #fff !important;
}

.sortable-th .sort-icon {
  display: inline-block;
  margin-left: 0.35rem;
  font-size: 0.75rem;
  opacity: 0.5;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.sortable-th:hover .sort-icon {
  opacity: 1;
}

.sortable-th.active-sort {
  color: #818cf8 !important;
  background: #1e1b4b !important; /* solid opaque dark indigo */
  border-bottom: 2px solid var(--accent-primary) !important;
}

.sortable-th.active-sort .sort-icon {
  opacity: 1;
  color: #818cf8;
  font-weight: bold;
}

.data-table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  color: var(--text-main);
  white-space: nowrap;
}

.data-table tbody tr {
  transition: background-color 0.15s ease;
}

.data-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.text-right { text-align: right; }
.text-center { text-align: center; }

/* Opaque Solid Highlight for Headers, subtle for body cells */
th.highlight-col {
  background: #172033 !important;
  font-weight: 700;
}

td.highlight-col {
  background: rgba(99, 102, 241, 0.05);
  font-weight: 600;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-ent { background: var(--color-ent-bg); color: var(--color-ent); border: 1px solid rgba(16, 185, 129, 0.3); }
.badge-sal { background: var(--color-sal-bg); color: var(--color-sal); border: 1px solid rgba(244, 63, 94, 0.3); }
.badge-aju { background: var(--color-aju-bg); color: var(--color-aju); border: 1px solid rgba(245, 158, 11, 0.3); }
.badge-dev { background: rgba(168, 85, 247, 0.12); color: #c084fc; border: 1px solid rgba(168, 85, 247, 0.3); }
.badge-negative { background: rgba(239, 68, 68, 0.2); color: #f87171; border: 1px solid rgba(239, 68, 68, 0.4); }
.badge-warning { background: #f59e0b; color: #000; padding: 0.15rem 0.45rem; border-radius: 10px; font-size: 0.7rem; }

/* Audit Document Type Filter Pills */
.audit-type-filters {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: rgba(15, 23, 42, 0.7);
  padding: 0.25rem 0.35rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.btn-audit-type-filter {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-family: var(--font-primary);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 0.25rem 0.65rem;
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1.2;
  user-select: none;
}

.btn-audit-type-filter:hover {
  transform: translateY(-1px);
}

/* TODOS */
.btn-audit-type-filter[data-type="TODOS"] {
  border-color: rgba(99, 102, 241, 0.25);
  color: #94a3b8;
  background: rgba(99, 102, 241, 0.05);
}
.btn-audit-type-filter[data-type="TODOS"]:hover {
  color: #c7d2fe;
  border-color: rgba(99, 102, 241, 0.5);
  background: rgba(99, 102, 241, 0.15);
}
.btn-audit-type-filter[data-type="TODOS"].active {
  background: rgba(99, 102, 241, 0.25);
  color: #818cf8;
  border: 1px solid #6366f1;
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.4);
}

/* ENT */
.btn-audit-type-filter.filter-ent,
.btn-audit-type-filter[data-type="ENT"] {
  border-color: rgba(16, 185, 129, 0.3);
  color: #10b981;
  background: rgba(16, 185, 129, 0.06);
}
.btn-audit-type-filter[data-type="ENT"]:hover {
  color: #34d399;
  border-color: rgba(16, 185, 129, 0.6);
  background: rgba(16, 185, 129, 0.15);
}
.btn-audit-type-filter[data-type="ENT"].active {
  background: rgba(16, 185, 129, 0.25);
  color: #34d399;
  border: 1px solid #10b981;
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.4);
}

/* SAL */
.btn-audit-type-filter.filter-sal,
.btn-audit-type-filter[data-type="SAL"] {
  border-color: rgba(244, 63, 94, 0.3);
  color: #f43f5e;
  background: rgba(244, 63, 94, 0.06);
}
.btn-audit-type-filter[data-type="SAL"]:hover {
  color: #fb7185;
  border-color: rgba(244, 63, 94, 0.6);
  background: rgba(244, 63, 94, 0.15);
}
.btn-audit-type-filter[data-type="SAL"].active {
  background: rgba(244, 63, 94, 0.25);
  color: #fb7185;
  border: 1px solid #f43f5e;
  box-shadow: 0 0 10px rgba(244, 63, 94, 0.4);
}

/* DEV */
.btn-audit-type-filter.filter-dev,
.btn-audit-type-filter[data-type="DEV"] {
  border-color: rgba(168, 85, 247, 0.3);
  color: #c084fc;
  background: rgba(168, 85, 247, 0.06);
}
.btn-audit-type-filter[data-type="DEV"]:hover {
  color: #d8b4fe;
  border-color: rgba(168, 85, 247, 0.6);
  background: rgba(168, 85, 247, 0.15);
}
.btn-audit-type-filter[data-type="DEV"].active {
  background: rgba(168, 85, 247, 0.25);
  color: #d8b4fe;
  border: 1px solid #a855f7;
  box-shadow: 0 0 10px rgba(168, 85, 247, 0.4);
}

/* AJU */
.btn-audit-type-filter.filter-aju,
.btn-audit-type-filter[data-type="AJU"] {
  border-color: rgba(245, 158, 11, 0.3);
  color: #f59e0b;
  background: rgba(245, 158, 11, 0.06);
}
.btn-audit-type-filter[data-type="AJU"]:hover {
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.6);
  background: rgba(245, 158, 11, 0.15);
}
.btn-audit-type-filter[data-type="AJU"].active {
  background: rgba(245, 158, 11, 0.25);
  color: #fbbf24;
  border: 1px solid #f59e0b;
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.4);
}

/* Excel Export Button */
.btn-export-excel {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.3rem 0.8rem;
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.15), rgba(5, 150, 105, 0.25));
  border: 1px solid rgba(16, 185, 129, 0.4);
  color: #34d399;
  font-family: var(--font-primary);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.15);
  user-select: none;
  line-height: 1.2;
}

.btn-export-excel i {
  width: 15px;
  height: 15px;
  stroke-width: 2.2;
}

.btn-export-excel:hover {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.25), rgba(5, 150, 105, 0.4));
  border-color: #10b981;
  color: #a7f3d0;
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.3);
}

.btn-export-excel:active {
  transform: translateY(0);
}

/* Pagination */
.pagination-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
}

/* Filter Panel & Audit Banner */
.filter-panel {
  margin-bottom: 1.25rem;
}

.audit-selector {
  display: flex;
  align-items: flex-end;
  gap: 1.25rem;
}

.input-field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.input-field label {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 500;
}

.audit-info-banner {
  display: flex;
  align-items: center;
  gap: 2rem;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.15) 0%, rgba(15, 21, 35, 0.9) 100%);
  border: 1px solid var(--border-highlight);
  border-radius: 12px;
  padding: 1rem 1.5rem;
  margin-top: 1rem;
}

.info-block {
  display: flex;
  flex-direction: column;
}

.info-block .lbl {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.info-block .val {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
}

.info-block .val.highlight {
  color: var(--accent-primary);
}

/* Alert Banners */
.alert-banner {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-radius: 12px;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
}

.alert-banner.warning {
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: #fbbf24;
}

.alert-banner.info {
  background: rgba(99, 102, 241, 0.1);
  border: 1px solid rgba(99, 102, 241, 0.3);
  color: #a5b4fc;
}

.grid-2-cols {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 1.5rem;
}

/* Loading Overlay */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(11, 15, 25, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.loading-overlay.hidden, .hidden {
  display: none !important;
}

.spinner-box {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 2rem 3rem;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
}

.spinner {
  width: 44px;
  height: 44px;
  border: 4px solid rgba(99, 102, 241, 0.2);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============================================================================
   Matrix Table Interactivity & Comparison Filter
   ============================================================================ */
.matrix-row-clickable {
  cursor: pointer;
  user-select: none;
  transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.matrix-row-clickable:hover {
  background: rgba(99, 102, 241, 0.14) !important;
  transform: translateX(3px);
}

.matrix-row-clickable.active-matrix-row {
  background: rgba(99, 102, 241, 0.24) !important;
  box-shadow: inset 3px 0 0 var(--accent-primary), inset 0 0 16px rgba(99, 102, 241, 0.15);
}

.matrix-row-clickable.active-matrix-row td {
  color: #fff;
  font-weight: 500;
}

.matrix-count-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.06);
  padding: 0.2rem 0.6rem;
  border-radius: 6px;
  font-weight: 700;
  border: 1px solid rgba(255, 255, 255, 0.08);
  transition: all 0.18s ease;
}

.matrix-row-clickable:hover .matrix-count-tag {
  background: rgba(99, 102, 241, 0.25);
  border-color: rgba(99, 102, 241, 0.4);
  color: #fff;
}

.matrix-row-clickable.active-matrix-row .matrix-count-tag {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: #fff;
}

.filter-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.35rem 0.8rem;
  border-radius: 20px;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(139, 92, 246, 0.2));
  border: 1px solid rgba(99, 102, 241, 0.4);
  color: #e0e7ff;
  font-size: 0.82rem;
  font-weight: 500;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.2);
}

.filter-pill button {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: #fff;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: all 0.15s ease;
}

.filter-pill button:hover {
  background: rgba(239, 68, 68, 0.8);
  transform: scale(1.1);
}

.filter-pill button i {
  width: 12px;
  height: 12px;
}

/* Double clickable rows for opening Kardex Audit */
.row-clickable-audit {
  cursor: pointer;
  user-select: none;
  transition: background-color 0.15s ease;
}

.row-clickable-audit:hover {
  background: rgba(99, 102, 241, 0.12) !important;
}

.row-clickable-audit:active {
  background: rgba(99, 102, 241, 0.2) !important;
}

/* ============================================================================
   Recalculate Date Range Modal
   ============================================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 12, 22, 0.85);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 120;
  padding: 1.5rem;
  animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-card {
  background: rgba(18, 24, 38, 0.95);
  border: 1px solid rgba(99, 102, 241, 0.25);
  border-radius: 18px;
  width: 100%;
  max-width: 580px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6), 0 0 30px rgba(99, 102, 241, 0.15);
  overflow: hidden;
  animation: slideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUp {
  from { transform: translateY(20px) scale(0.97); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.modal-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
}

.modal-icon i {
  width: 20px;
  height: 20px;
}

.modal-title h3 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
}

.modal-title p {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.modal-close:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.modal-body {
  padding: 1.5rem;
}

.form-group-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.form-field label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.form-field label i {
  width: 14px;
  height: 14px;
  color: var(--accent-primary);
}

.form-input {
  background: rgba(11, 15, 25, 0.85);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.65rem 0.9rem;
  border-radius: 10px;
  font-family: var(--font-primary);
  font-size: 0.88rem;
  outline: none;
  transition: all 0.2s ease;
  width: 100%;
}

.form-input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25);
  background: rgba(15, 21, 35, 0.95);
}

/* Date input calendar icon color */
.form-input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(0.8) sepia(1) saturate(5) hue-rotate(200deg);
  cursor: pointer;
}

.presets-container {
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.presets-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.presets-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.btn-preset {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
  padding: 0.3rem 0.65rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-preset:hover {
  background: rgba(99, 102, 241, 0.15);
  border-color: rgba(99, 102, 241, 0.35);
  color: #fff;
}

.btn-preset.active {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: #fff;
}

.modal-footer {
  padding: 1.25rem 1.5rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  background: rgba(11, 15, 25, 0.4);
}

/* Helper utility classes */
.text-success { color: #10b981 !important; }
.text-danger { color: #ef4444 !important; }
.text-info { color: #38bdf8 !important; }
.text-muted { color: var(--text-muted, #9ca3af) !important; }
.font-weight-bold { font-weight: 600 !important; }

/* Table Totals Styles (tfoot) */
.data-table tfoot td,
.data-table tfoot th {
  background: #0f172a;
  color: #f8fafc;
  font-weight: 700;
  padding: 0.75rem 0.85rem;
  border-top: 2px solid rgba(99, 102, 241, 0.4);
  border-bottom: 2px solid var(--border-color);
  position: sticky;
  bottom: 0;
  z-index: 15;
  font-size: 0.84rem;
}

.data-table tfoot tr.tr-totals td.sticky-col-1 {
  background: #0f172a !important;
  z-index: 16;
}
