/* ============================================================
   INVENTICKETS - Design System (Enterprise Slate & Blue)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* --- Tokens ----------------------------------------------- */
:root {
  /* Colors */
  --bg-deep:        #080b11;
  --bg-base:        #0d111a;
  --bg-surface:     #131924;
  --bg-elevated:    #192130;
  --bg-hover:       #202a3d;
  --bg-topbar:      rgba(13, 17, 26, 0.85);

  --border:         rgba(255, 255, 255, 0.06);
  --border-active:  #3b82f6; /* Enterprise Blue Accent (No Purple) */

  --accent:         #3b82f6;
  --accent-glow:    rgba(59, 130, 246, 0.15);
  --accent-dim:     #2563eb;

  --cyan:           #0ea5e9;
  --cyan-glow:      rgba(14, 165, 233, 0.15);
  --violet:         #0284c7; /* Royal sky blue */
  --violet-glow:    rgba(2, 132, 199, 0.15);
  --success:        #10b981; /* Emerald */
  --warning:        #f59e0b; /* Amber */
  --danger:         #ef4444; /* Rose/Red */

  --text-primary:   #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted:     #64748b;

  --primary:        var(--accent);
  --primary-rgb:    59, 130, 246;

  /* Shadows */
  --shadow-sm:  0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md:  0 4px 12px -2px rgba(0, 0, 0, 0.3), 0 2px 6px -1px rgba(0, 0, 0, 0.2);
  --shadow-lg:  0 12px 24px -4px rgba(0, 0, 0, 0.4), 0 4px 12px -2px rgba(0, 0, 0, 0.3);
  --shadow-glow: none;

  /* Radii */
  --r-sm: 8px;
  --r-md: 10px;
  --r-lg: 12px;
  --r-xl: 14px;

  /* Sidebar width */
  --sidebar-w: 240px;
  --topbar-h: 60px;

  /* Transitions */
  --t: 0.2s ease;
}

:root[data-theme="light"] {
  --bg-deep:        #94a3b8;
  --bg-base:        #cbd5e1;
  --bg-surface:     #e2e8f0;
  --bg-elevated:    #f1f5f9;
  --bg-hover:       #cbd5e1;
  --bg-topbar:      rgba(203, 213, 225, 0.85);

  --border:         rgba(15, 23, 42, 0.15);
  --border-active:  #2563eb;

  --accent:         #2563eb;
  --accent-glow:    rgba(37, 99, 235, 0.1);
  --accent-dim:     #1d4ed8;

  --cyan:           #0284c7;
  --cyan-glow:      rgba(2, 132, 199, 0.1);
  --violet:         #0369a1;
  --violet-glow:    rgba(3, 105, 161, 0.1);
  --success:        #059669;
  --warning:        #d97706;
  --danger:         #dc2626;

  --text-primary:   #0f172a;
  --text-secondary: #475569;
  --text-muted:     #64748b;

  --primary:        var(--accent);
  --primary-rgb:    37, 99, 235;

  --shadow-sm:      0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md:      0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg:      0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.08);
  --shadow-glow:    none;
}

/* --- Reset ------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; scroll-behavior: smooth; }

body {
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  background: transparent;
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  overflow: hidden;
  position: relative;
  transition: background var(--t), color var(--t);
}

/* --- Active, moving background orbs (Enterprise Blue Theme - No Purple) --- */
.bg-animation-container {
  position: fixed;
  inset: 0;
  background-color: var(--bg-deep);
  z-index: -10;
  overflow: hidden;
  pointer-events: none;
  transition: background-color var(--t);
}

.orb {
  position: absolute;
  width: 850px;
  height: 850px;
  border-radius: 50%;
  filter: blur(180px);
  opacity: 0.22; /* More visual, glowing dark mode background */
  mix-blend-mode: screen;
  pointer-events: none;
  transition: opacity var(--t);
}

.orb-1 {
  background: var(--accent); /* Cobalt Blue */
  top: -250px;
  left: -150px;
  animation: floatOrb1 32s infinite alternate ease-in-out;
}

.orb-2 {
  background: var(--cyan); /* Cyan */
  bottom: -300px;
  right: -150px;
  animation: floatOrb2 38s infinite alternate ease-in-out;
}

.orb-3 {
  background: rgba(16, 185, 129, 0.65); /* Soft Emerald Green for a 3-color mesh gradient */
  width: 650px;
  height: 650px;
  top: 25%;
  left: 35%;
  animation: floatOrb3 42s infinite alternate ease-in-out;
}

@keyframes floatOrb1 {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(200px, 100px) scale(1.15); }
  100% { transform: translate(80px, 220px) scale(0.9); }
}

@keyframes floatOrb2 {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(-180px, -160px) scale(0.85); }
  100% { transform: translate(-80px, 40px) scale(1.15); }
}

@keyframes floatOrb3 {
  0% { transform: translate(-50%, -20%) scale(0.9); }
  50% { transform: translate(-20%, 15%) scale(1.1); }
  100% { transform: translate(-60%, -5%) scale(0.95); }
}

:root[data-theme="light"] .orb {
  opacity: 0.28;
  mix-blend-mode: normal;
}

:root[data-theme="light"] .orb-3 {
  opacity: 0.25;
}

#topbar, .table-wrap, .btn-primary, .btn-secondary, .btn-icon, .form-control, .modal, .toast, th, td, tr, input, select {
  transition: background-color var(--t), border-color var(--t), color var(--t), box-shadow var(--t);
}

/* --- Scrollbar -------------------------------------------- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.05); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-active); }

:root[data-theme="light"] ::-webkit-scrollbar-thumb { background: rgba(0, 0, 0, 0.1); }

/* --- Sidebar (Menu Lateral) ------------------------------- */
#sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: fixed;
  left: 0; top: 0;
  z-index: 100;
  overflow: hidden;
  /* Smooth sliding animation on open/close */
  transition: transform 0.25s cubic-bezier(0.25, 1, 0.5, 1), background-color var(--t);
}

.sidebar-logo {
  padding: 24px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.brand-logo {
  width: 100%;
  max-width: 150px;
  height: auto;
}

:root[data-theme="light"] .brand-logo {
  filter: brightness(0.1);
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-section-label {
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 12px 12px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 40px; /* Fixed height for absolute stability */
  padding: 0 12px;
  border-radius: var(--r-sm);
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  white-space: nowrap;
  transition: background-color var(--t), color var(--t), border-color var(--t);
  transform: none !important;
  scale: 1 !important;
}
.nav-item .icon { font-size: 0.95rem; width: 18px; text-align: center; display: flex; align-items: center; justify-content: center; }
.nav-item:hover { 
  background: var(--bg-hover); 
  color: var(--text-primary);
}

/* Staggered Vertical Glow Animation for Active Item */
.nav-item.active {
  background: var(--bg-hover);
  color: var(--accent);
  font-weight: 600;
  position: relative;
  overflow: hidden;
  transform: none !important;
  scale: 1 !important;
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: linear-gradient(180deg, var(--accent), var(--cyan), var(--accent));
  background-size: 100% 200%;
  animation: verticalShine 4s linear infinite;
}
@keyframes verticalShine {
  0% { background-position: 50% 0%; }
  100% { background-position: 50% 200%; }
}

.nav-item.active .icon { color: var(--accent); }

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
}

/* --- Main Content Layout ---------------------------------- */
#app {
  margin-left: var(--sidebar-w);
  flex: 1;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  /* Smooth layout shifting on desktop */
  transition: margin-left 0.25s cubic-bezier(0.25, 1, 0.5, 1), background-color var(--t);
}

/* --- Topbar ----------------------------------------------- */
#topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: var(--topbar-h);
  background: var(--bg-topbar);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
  flex-shrink: 0;
}

#page-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
}

.topbar-title { 
  font-family: inherit;
  font-size: 1.15rem; 
  font-weight: 700; 
  color: var(--text-primary); 
  letter-spacing: -0.3px;
}
/* Shimmer indicator bar below page title */
.topbar-title::after {
  content: '';
  display: block;
  width: 45px;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--cyan), var(--accent));
  margin-top: 4px;
  border-radius: 99px;
  background-size: 200% 200%;
  animation: borderShine 4s linear infinite;
}

.topbar-subtitle { 
  font-size: 0.8rem; 
  color: var(--text-secondary); 
}

.topbar-right { display: flex; align-items: center; gap: 12px; }

/* --- Topbar Sub-components ------------------------------- */
.status-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: help;
}
.status-indicator:hover {
  background: var(--bg-hover);
}

/* Pulsing Status Dot */
.status-dot {
  width: 8px; height: 8px; border-radius: 50%; 
  background: var(--success);
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.5);
  animation: pulseDot 2s infinite;
}
@keyframes pulseDot {
  0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.6); }
  70% { box-shadow: 0 0 0 5px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* Slowly rotating icons in topbar */
.topbar-right .fa-sync, .topbar-right .fa-cog, .status-indicator .fa-circle-notch {
  animation: slowSpin 16s linear infinite;
}
@keyframes slowSpin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.topbar-clock { 
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem; 
  font-weight: 600; 
  color: var(--text-primary); 
}
.topbar-date { 
  font-family: inherit;
  font-size: 0.7rem; 
  color: var(--text-secondary); 
}

.notif-container { position: relative; display: flex; align-items: center; }
.notif-btn {
  background: transparent; 
  border: 1px solid var(--border);
  width: 32px; height: 32px; border-radius: 50%;
  color: var(--text-secondary); cursor: pointer; display: flex; align-items: center; justify-content: center;
  position: relative; transition: all var(--t);
}
.notif-btn:hover { color: var(--text-primary); border-color: var(--border-active); background: var(--bg-hover); }
.notif-badge {
  position: absolute; top: -1px; right: -1px;
  background: var(--danger); color: #fff;
  font-size: 0.65rem; font-weight: 700;
  width: 14px; height: 14px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.notif-dropdown-panel {
  position: absolute; top: 100%; right: 0; margin-top: 8px;
  width: 300px; background: var(--bg-surface);
  border: 1px solid var(--border); border-radius: var(--r-md);
  box-shadow: var(--shadow-lg); z-index: 100;
  opacity: 0; visibility: hidden; transform: translateY(-5px);
  overflow: hidden; display: flex; flex-direction: column;
}
.notif-container.open .notif-dropdown-panel {
  opacity: 1; visibility: visible; transform: translateY(0);
}
.notif-header {
  padding: 10px 14px; font-weight: 700; font-size: 0.8rem; color: var(--text-primary);
  border-bottom: 1px solid var(--border); background: var(--bg-elevated);
}
.notif-items { max-height: 260px; overflow-y: auto; }
.notif-item {
  padding: 10px 14px; border-bottom: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 2px; transition: background var(--t);
  text-decoration: none; cursor: pointer;
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--bg-hover); }
.notif-item-title { font-size: 0.78rem; font-weight: 700; color: var(--text-primary); }
.notif-item-body { font-size: 0.75rem; color: var(--text-secondary); line-height: 1.25; }
.notif-item-time { font-size: 0.65rem; color: var(--text-muted); text-align: right; }
.notif-footer {
  padding: 8px; text-align: center; font-size: 0.75rem; font-weight: 600;
  color: var(--primary); background: var(--bg-elevated); border-top: 1px solid var(--border);
  cursor: pointer;
}

/* --- Buttons ---------------------------------------------- */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: var(--accent);
  color: #fff;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  border-radius: var(--r-sm);
  border: none;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover { 
  background: var(--accent-dim);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  cursor: pointer;
}
.btn-secondary:hover { 
  background: var(--bg-hover);
}

/* Hard reset: Keep all button active click states completely stable (no scale/squish) */
.btn-primary:active, .btn-secondary:active, .btn-icon:active, .page-btn:active, .nav-item:active, button:active, a:active {
  transform: none !important;
  scale: 1 !important;
}

.btn-outline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  cursor: pointer;
}
.btn-outline:hover { background: var(--bg-hover); color: var(--text-primary); }

.btn-outline-success {
  color: var(--success);
  border-color: rgba(16, 185, 129, 0.2);
}
.btn-outline-success:hover { background: rgba(16, 185, 129, 0.05); color: var(--success); }

.btn-outline-danger {
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.2);
}
.btn-outline-danger:hover { background: rgba(239, 68, 68, 0.05); color: var(--danger); }

.btn-danger {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.2);
  font-weight: 600;
}
.btn-danger:hover { background: rgba(239, 68, 68, 0.2); }

.btn-icon {
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  cursor: pointer;
  color: var(--text-secondary);
}
.btn-icon:hover { color: var(--text-primary); background: var(--bg-hover); }

/* --- Card Panels & Stat Cards with dynamic flowing border glows --- */
.card-panel, .stat-card {
  position: relative;
  transition: background-color var(--t), border-color var(--t), box-shadow 0.3s ease, transform 0.3s cubic-bezier(0.25, 1, 0.5, 1);
}

/* Shining, flowing border indicator for Cards (Enterprise Glow - No Purple) */
.card-panel::before, .stat-card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(90deg, var(--card-accent, var(--accent)), var(--cyan), rgba(255,255,255,0.02), var(--card-accent, var(--accent)));
  background-size: 200% 200%;
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0.12; /* Subtle constant flow */
  transition: opacity 0.3s;
  animation: borderShine 8s linear infinite;
  pointer-events: none;
}

/* Hover effects for Cards */
.stat-card:hover, .card-panel:hover {
  transform: translateY(-5px) !important;
  box-shadow: 0 12px 28px rgba(59, 130, 246, 0.12) !important;
  border-color: rgba(59, 130, 246, 0.3) !important;
}
.stat-card:hover::before, .card-panel:hover::before {
  opacity: 0.95; /* Bright flow on hover */
}

/* --- Card Panels ------------------------------------------ */
.card-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-md);
  padding: 20px;
}

/* --- Stat Cards (Dashboard) ------------------------------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: relative;
  overflow: hidden;
}

/* Staggered floating & soft tilting for stat cards (Dashboard & My Tickets) */
.dash-stats-grid > div:nth-child(1), .stat-cards-grid > div:nth-child(1) { animation: floatStatCard1 8s infinite ease-in-out; }
.dash-stats-grid > div:nth-child(2), .stat-cards-grid > div:nth-child(2) { animation: floatStatCard2 9s infinite ease-in-out; animation-delay: 1.5s; }
.dash-stats-grid > div:nth-child(3), .stat-cards-grid > div:nth-child(3) { animation: floatStatCard1 8.5s infinite ease-in-out; animation-delay: 3s; }
.dash-stats-grid > div:nth-child(4), .stat-cards-grid > div:nth-child(4) { animation: floatStatCard2 9.5s infinite ease-in-out; animation-delay: 4.5s; }
.stat-cards-grid > div:nth-child(5) { animation: floatStatCard1 9s infinite ease-in-out; animation-delay: 5.5s; }

@keyframes floatStatCard1 {
  0%, 100% { 
    transform: translateY(0) rotate(0deg); 
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
  }
  50% { 
    transform: translateY(-8px) rotate(0.7deg); 
    box-shadow: 0 12px 24px rgba(6, 182, 212, 0.12);
  }
}

@keyframes floatStatCard2 {
  0%, 100% { 
    transform: translateY(0) rotate(0deg); 
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
  }
  50% { 
    transform: translateY(-8px) rotate(-0.7deg); 
    box-shadow: 0 12px 24px rgba(59, 130, 246, 0.12);
  }
}

.stat-icon {
  width: 42px; height: 42px;
  background: var(--card-accent-bg, rgba(59, 130, 246, 0.1));
  border: 1px solid rgba(59, 130, 246, 0.1);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
  color: var(--card-accent, var(--accent));
  transition: all 0.3s ease;
  flex-shrink: 0;
}
.stat-card:hover .stat-icon {
  background: var(--card-accent, var(--accent)) !important;
  color: #fff !important;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.25);
}
.stat-value { 
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.6rem; 
  font-weight: 900; 
  color: var(--card-accent, var(--text-primary)) !important; 
  line-height: 1.1; 
  margin-bottom: 2px;
}
.stat-label { font-size: 0.68rem; color: var(--text-muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.6px; }
.stat-meta { font-size: 0.72rem; color: var(--text-muted); }

/* --- Alert Cards ------------------------------------------ */
.alert-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

/* Pulsing border animation for alert panels */
.alert-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  padding: 20px;
  animation: borderPulse 4s infinite ease-in-out;
}
@keyframes borderPulse {
  0%, 100% { border-color: var(--border); }
  50% { border-color: rgba(59, 130, 246, 0.20); }
}

.alert-panel-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.8rem; font-weight: 700;
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
}
.alert-panel-title .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--panel-color, var(--warning));
}

.alert-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 12px;
  border-radius: var(--r-sm);
  background: var(--bg-base);
  border: 1px solid var(--border);
  margin-bottom: 6px;
  font-size: 0.8rem;
}
.alert-item:last-child { margin-bottom: 0; }
.alert-item:hover { border-color: var(--border-active); }
.alert-item .name { color: var(--text-primary); font-weight: 600; }
.alert-item .meta { color: var(--text-muted); font-size: 0.72rem; }

/* --- Filters / Toolbar ------------------------------------ */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.search-wrapper {
  position: relative;
  flex: 1;
  min-width: 180px;
  max-width: 300px;
}
.search-wrapper .icon {
  position: absolute;
  left: 10px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.8rem;
  pointer-events: none;
}
input[type="search"], input.search-input {
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 7px 10px 7px 30px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.82rem;
  outline: none;
}
input[type="search"]:focus, input.search-input:focus { border-color: var(--accent); }

select.filter-select {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 7px 10px;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.82rem;
  outline: none;
  cursor: pointer;
}
select.filter-select:focus { border-color: var(--accent); }
select.filter-select:disabled { opacity: 0.5; }

/* --- Empty States ----------------------------------------- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 20px;
  text-align: center;
  color: var(--text-muted);
  width: 100%;
}
.empty-state .icon {
  margin-bottom: 12px;
  opacity: 0.6;
  color: var(--accent);
}
.empty-state p {
  font-size: 0.88rem;
  font-weight: 500;
  margin: 0;
}

.loading-row td {
  text-align: center !important;
  padding: 48px 20px !important;
  color: var(--accent);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82rem;
}

/* --- Table ------------------------------------------------ */
.table-wrap {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  overflow: auto;
  flex: 1;
  min-height: 0;
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead {
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
}

th {
  text-align: left;
  padding: 10px 14px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  white-space: nowrap;
}

th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--text-secondary); }

tbody tr {
  border-bottom: 1px solid var(--border);
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg-base); }
tbody tr { cursor: pointer; }

td {
  padding: 11px 14px;
  font-size: 0.82rem;
  color: var(--text-primary);
  vertical-align: middle;
}

td.muted { color: var(--text-secondary); }
td.actions { display: flex; gap: 6px; }

/* --- Badges ----------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid transparent;
}

.badge-success { background: rgba(16, 185, 129, 0.1); color: var(--success); border-color: rgba(16, 185, 129, 0.2); }
.badge-warning { background: rgba(245, 158, 11, 0.1); color: var(--warning); border-color: rgba(245, 158, 11, 0.2); }
.badge-danger  { background: rgba(239, 68, 68, 0.1); color: var(--danger); border-color: rgba(239, 68, 68, 0.2); }
.badge-info    { background: rgba(14, 165, 233, 0.1); color: var(--cyan); border-color: rgba(14, 165, 233, 0.2); }
.badge-violet  { background: rgba(2, 132, 199, 0.1); color: var(--violet); border-color: rgba(2, 132, 199, 0.2); }
.badge-cyan    { background: rgba(14, 165, 233, 0.1); color: var(--cyan); border-color: rgba(14, 165, 233, 0.2); }
.badge-gray    { background: rgba(100, 116, 139, 0.1); color: var(--text-secondary); border-color: rgba(100, 116, 139, 0.15); }

/* --- Pagination ------------------------------------------- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  font-size: 0.78rem;
  color: var(--text-muted);
}
.pagination-btns { display: flex; gap: 4px; }
.page-btn {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  cursor: pointer;
  font-size: 0.78rem;
  color: var(--text-secondary);
}
.page-btn:hover, .page-btn.active { border-color: var(--accent); color: var(--text-primary); background: var(--bg-hover); }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* --- Modals ----------------------------------------------- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
}
.modal-overlay.open { opacity: 1; visibility: visible; }

.modal {
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  width: 95%;
  max-width: 500px;
  max-height: 85vh;
  overflow-y: auto;
  transform: scale(0.98);
  transition: all 0.2s ease-out;
}
.modal-wide { max-width: 800px; }
.modal-wider { max-width: 1000px; }
.modal-overlay.open .modal { transform: scale(1); }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 0.95rem; font-weight: 700; color: var(--text-primary); letter-spacing: -0.2px; text-transform: uppercase; }
.modal-close {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.8rem;
  color: var(--text-secondary);
}
.modal-close:hover { color: var(--danger); border-color: var(--danger); background: rgba(239, 68, 68, 0.08); }

.modal-body { padding: 18px 20px; }

.modal-footer {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 12px 20px 16px;
  border-top: 1px solid var(--border);
}

/* --- Form Fields ------------------------------------------ */
.form-group { margin-bottom: 14px; }
.form-group label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 4px;
}
.form-control {
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 8px 12px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.82rem;
  outline: none;
}
.form-control:focus { border-color: var(--accent); background: var(--bg-elevated); }
.form-control::placeholder { color: var(--text-muted); }

/* --- Toast Notifications ---------------------------------- */
#toast-container {
  position: fixed;
  bottom: 20px; right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  --glow-color: var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 24px;
  background: var(--bg-surface);
  border: 2px solid var(--glow-color);
  border-radius: var(--r-md);
  box-shadow: 0 0 10px var(--glow-color);
  font-size: 1rem;
  font-weight: 600;
  min-width: 300px;
  animation: slideIn 0.3s ease-out both, pulseGlow 0.8s infinite alternate;
}
.toast.success { --glow-color: var(--success); }
.toast.error   { --glow-color: var(--danger); }
.toast.info    { --glow-color: var(--accent); }

@keyframes pulseGlow {
  0%   { box-shadow: 0 0 5px var(--glow-color); }
  100% { box-shadow: 0 0 25px var(--glow-color), inset 0 0 10px var(--glow-color); }
}

@keyframes slideIn {
  from { transform: translateX(40px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}
@keyframes slideOut {
  from { transform: translateX(0);    opacity: 1; max-height: 80px; }
  to   { transform: translateX(40px); opacity: 0; max-height: 0; }
}
.toast.out {
  animation: slideOut 0.25s ease both;
  pointer-events: none;
}

/* --- Dashboard Grid --------------------------------------- */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.recent-table-panel {
  grid-column: span 2;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

/* --- Dynamic continuous floating & breathing charts animation --- */
#chart-tickets-status, #chart-tickets-tech,
#rep-tickets-tipo, #rep-tickets-tech, #rep-tickets-trend, #rep-it-tech, #rep-tickets-heatmap {
  animation: floatChart 7s infinite ease-in-out;
}

#chart-tickets-tech, #rep-tickets-tech, #rep-it-tech {
  animation-delay: 1.5s;
}

#rep-tickets-trend {
  animation-delay: 3s;
}

#rep-tickets-heatmap {
  animation-delay: 4.5s;
}

@keyframes floatChart {
  0%, 100% { 
    transform: translateY(0) scale(1); 
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.15)); 
  }
  50% { 
    transform: translateY(-14px) scale(0.965); 
    filter: drop-shadow(0 18px 35px rgba(6, 182, 212, 0.18)); 
  }
}

/* --- Preventive Maintenance Forms ------------------------ */
.mant-form {
  font-family: inherit;
}

.mant-form-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  margin-bottom: 16px;
}

.mant-form-header-icon {
  width: 36px; height: 36px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--accent);
  flex-shrink: 0;
}

.mant-form-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 2px;
}

.mant-form-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin: 0;
}

.mant-section-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  padding: 8px 0 6px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 10px;
  margin-top: 6px;
}

.mant-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 4px;
}

@media (max-width: 600px) {
  .mant-grid-2 { grid-template-columns: 1fr; }
}

.mant-checklist {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 10px;
}

@media (max-width: 600px) {
  .mant-checklist { grid-template-columns: 1fr; }
}

.mant-check-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-size: 0.8rem;
  color: var(--text-primary);
  cursor: pointer;
  user-select: none;
}

.mant-check-item:hover {
  border-color: var(--accent);
}

.mant-check-item input[type="checkbox"] {
  width: 14px; height: 14px;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}

.mant-check-item:has(input:checked) {
  border-color: var(--accent);
  background: var(--bg-hover);
}

/* --- Step Selector (Modal Step 1) ------------------------ */
.mant-step-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
  margin-top: 6px;
}

.mant-step-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  cursor: pointer;
  text-align: center;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
}

.mant-step-card:hover {
  border-color: var(--accent);
  background: var(--bg-hover);
  transform: translateY(-1px);
}

.mant-step-card.selected {
  border-color: var(--accent);
  background: var(--bg-hover);
}

.mant-step-card svg {
  color: var(--accent);
}

.mant-step-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 2px;
}

/* --- Action Buttons in Form ------------------------------ */
.mant-form-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  margin-top: 16px;
}

/* --- Mobile Responsiveness -------------------------------- */
.sidebar-overlay {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 90;
  opacity: 0; visibility: hidden;
  transition: opacity var(--t), visibility var(--t);
}
.sidebar-overlay.active {
  opacity: 1; visibility: visible;
}

@media (min-width: 1025px) {
  body.sidebar-collapsed #sidebar {
    transform: translateX(-110%);
  }
  body.sidebar-collapsed #app {
    margin-left: 0;
  }
}

@media (max-width: 1024px) {
  #app {
    margin-left: 0;
  }
  #sidebar {
    transform: translateX(-110%);
    z-index: 100;
    height: 100vh;
  }
  #sidebar.open {
    transform: translateX(0);
  }
  #topbar {
    padding: 0 16px;
  }
  #page-content {
    padding: 16px;
  }
}

@media (max-width: 768px) {
  html { font-size: 13px; }
  body, #app { height: 100dvh; }
  #page-content { overflow-y: auto; -webkit-overflow-scrolling: touch; }
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; width: 100%; }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }
  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }
  .alert-row {
    grid-template-columns: 1fr;
  }
  .topbar-right {
    gap: 8px;
  }
  .modal {
    width: 100%;
    height: 100%;
    max-height: 100vh;
    border-radius: 0;
    transform: translateY(0);
  }
  .modal-overlay.open .modal {
    transform: translateY(0);
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }
  .topbar-title {
    font-size: 1rem;
  }
  .topbar-subtitle {
    display: none;
  }
  .mant-form-actions {
    flex-direction: column;
  }
  .btn-primary, .btn-secondary {
    width: 100%;
    justify-content: center;
  }
  .table-wrap {
    max-height: calc(100vh - 100px);
  }
  td, th {
    padding: 8px 10px;
    font-size: 0.78rem;
  }
}

/* Webkit calendar picker icon visible in dark mode & dark color scheme */
.dark-mode input[type="datetime-local"]::-webkit-calendar-picker-indicator,
.dark-mode input[type="date"]::-webkit-calendar-picker-indicator,
.dark-mode input[type="time"]::-webkit-calendar-picker-indicator {
  filter: invert(1) brightness(1.2);
  cursor: pointer;
}
.dark-mode input[type="datetime-local"],
.dark-mode input[type="date"],
.dark-mode input[type="time"] {
  color-scheme: dark;
}

/* Custom styling for btn-set-now */
.btn-set-now:hover {
  background: rgba(6, 182, 212, 0.3) !important;
  color: #fff !important;
}

/* Webkit calendar picker icon visible in dark mode (when not in light theme) */
:root:not([data-theme="light"]) input[type="datetime-local"]::-webkit-calendar-picker-indicator,
:root:not([data-theme="light"]) input[type="date"]::-webkit-calendar-picker-indicator,
:root:not([data-theme="light"]) input[type="time"]::-webkit-calendar-picker-indicator {
  filter: invert(1) brightness(1.2);
  cursor: pointer;
}
:root:not([data-theme="light"]) input[type="datetime-local"],
:root:not([data-theme="light"]) input[type="date"],
:root:not([data-theme="light"]) input[type="time"] {
  color-scheme: dark;
}


/* ── Brillo post-guardado ── */
@keyframes tdGlow {
  0%   { background: rgba(16, 185, 129, 0.0); }
  50%  { background: rgba(16, 185, 129, 0.18); }
  100% { background: rgba(16, 185, 129, 0.0); }
}
@keyframes folioGlow {
  0%   { color: #10b981; text-shadow: none; }
  50%  { color: #34d399; text-shadow: 0 0 10px #10b981, 0 0 24px rgba(16,185,129,0.8); }
  100% { color: #10b981; text-shadow: none; }
}
@keyframes glowBorderLeft {
  0%   { box-shadow: inset 3px 0 0 rgba(16,185,129,0.2); }
  50%  { box-shadow: inset 3px 0 0 #10b981, inset 3px 0 20px rgba(16,185,129,0.4); }
  100% { box-shadow: inset 3px 0 0 rgba(16,185,129,0.2); }
}
.row-ticket-glow > td {
  animation: tdGlow 1.4s ease-in-out infinite;
}
.row-ticket-glow > td:first-child {
  animation: glowBorderLeft 1.4s ease-in-out infinite;
}
.folio-glow {
  animation: folioGlow 1.4s ease-in-out infinite;
}

/* ── Timer flotante post-guardado ── */
#ticket-save-timer {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 9999;
  background: rgba(8, 12, 24, 0.92);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(16, 185, 129, 0.5);
  border-radius: 16px;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5), 0 0 24px rgba(16,185,129,0.15);
  animation: timerFadeIn 0.3s ease;
  min-width: 240px;
}
@keyframes timerFadeIn {
  from { opacity:0; transform: translateY(12px) scale(0.95); }
  to   { opacity:1; transform: translateY(0) scale(1); }
}
@keyframes timerFadeOut {
  from { opacity:1; transform: translateY(0) scale(1); }
  to   { opacity:0; transform: translateY(12px) scale(0.95); }
}
#ticket-save-timer.hiding {
  animation: timerFadeOut 0.3s ease forwards;
}
.timer-ring-wrap {
  position: relative;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
}
.timer-ring-bg {
  fill: none;
  stroke: rgba(16,185,129,0.15);
  stroke-width: 4;
}
.timer-ring-arc {
  fill: none;
  stroke: #10b981;
  stroke-width: 4;
  stroke-linecap: round;
  transform-origin: center;
  transform: rotate(-90deg);
  transition: stroke-dashoffset 1s linear;
}
.timer-number {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 800;
  color: #10b981;
}
.timer-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.timer-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: #e2e8f0;
}
.timer-sub {
  font-size: 0.65rem;
  color: #64748b;
}
