/* ═══════════════════════════════════════════════════════════════════════════
   Inventory Dashboard - Professional Stylesheet
   Clean, Modern, Business-Oriented Design
   ═══════════════════════════════════════════════════════════════════════════ */

/* ──────────────────────────────────────────────────────────────────────────
   CSS Variables (Design Tokens)
   ────────────────────────────────────────────────────────────────────────── */
:root {
  /* Brand Colors */
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #dbeafe;
  --primary-dark: #1e40af;

  /* Semantic Colors */
  --success: #10b981;
  --success-light: #d1fae5;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --info: #0ea5e9;
  --info-light: #e0f2fe;

  /* Neutrals */
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;

  /* Layout */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
  --transition-slow: 350ms ease;
}

/* ──────────────────────────────────────────────────────────────────────────
   Base Styles
   ────────────────────────────────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: linear-gradient(135deg, var(--gray-50) 0%, var(--gray-100) 100%);
  color: var(--gray-800);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.main-content {
  flex: 1;
}

/* ──────────────────────────────────────────────────────────────────────────
   Navigation
   ────────────────────────────────────────────────────────────────────────── */
.navbar {
  background: rgba(255, 255, 255, 0.95) !important;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--gray-200);
  box-shadow: var(--shadow-md);
  padding: 0.75rem 0;
}

.brand-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  border-radius: var(--radius-md);
  font-size: 1.1rem;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.brand-text {
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--gray-800);
  letter-spacing: -0.02em;
}

.navbar .nav-link {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--gray-600);
  padding: 0.6rem 1rem;
  border-radius: var(--radius-md);
  transition: all var(--transition-normal);
  display: flex;
  align-items: center;
}

.navbar .nav-link:hover {
  color: var(--primary);
  background: var(--primary-light);
}

.navbar .nav-link.active {
  color: var(--primary);
  background: var(--primary-light);
  font-weight: 700;
}

.navbar .nav-link i {
  font-size: 1rem;
}

/* ──────────────────────────────────────────────────────────────────────────
   Page Header / Hero Section
   ────────────────────────────────────────────────────────────────────────── */
.page-header {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.page-header .eyebrow {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--primary);
  margin-bottom: 0.25rem;
}

.page-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 0.25rem;
  letter-spacing: -0.02em;
}

.page-header .subtitle {
  font-size: 0.9rem;
  color: var(--gray-500);
  margin: 0;
}

/* ──────────────────────────────────────────────────────────────────────────
   Filter Bar
   ────────────────────────────────────────────────────────────────────────── */
.filter-bar {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
}

.filter-bar .form-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-500);
  margin-bottom: 0.35rem;
}

.filter-bar .form-select,
.filter-bar .form-control {
  font-size: 0.875rem;
  border-radius: var(--radius-sm);
  border-color: var(--gray-300);
  padding: 0.5rem 0.75rem;
}

.filter-bar .form-select:focus,
.filter-bar .form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/* ──────────────────────────────────────────────────────────────────────────
   Cards
   ────────────────────────────────────────────────────────────────────────── */
.card {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-normal);
}

.card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.card-header {
  background: transparent;
  border-bottom: 1px solid var(--gray-100);
  padding: 1rem 1.25rem;
  font-weight: 600;
}

.card-body {
  padding: 1.25rem;
}

/* ──────────────────────────────────────────────────────────────────────────
   KPI Cards
   ────────────────────────────────────────────────────────────────────────── */
.kpi-card {
  position: relative;
  overflow: hidden;
}

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

.kpi-card.kpi-success::before {
  background: var(--success);
}

.kpi-card.kpi-danger::before {
  background: var(--danger);
}

.kpi-card.kpi-info::before {
  background: var(--info);
}

.kpi-card.kpi-warning::before {
  background: var(--warning);
}

.kpi-card.kpi-primary::before {
  background: var(--primary);
}

.kpi-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.kpi-value {
  font-size: 1.85rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.kpi-value.text-success {
  color: var(--success) !important;
}

.kpi-value.text-danger {
  color: var(--danger) !important;
}

.kpi-value.text-info {
  color: var(--info) !important;
}

.kpi-value.text-warning {
  color: var(--warning) !important;
}

.kpi-value.text-primary {
  color: var(--primary) !important;
}

.kpi-hint {
  font-size: 0.75rem;
  color: var(--gray-400);
  margin-top: 0.5rem;
}

/* ──────────────────────────────────────────────────────────────────────────
   Summary Bar (floating metrics)
   ────────────────────────────────────────────────────────────────────────── */
/* Light mode: jasne tło, ciemny tekst */
.summary-bar {
  background: linear-gradient(135deg, #f1f5f9, #e2e8f0);
  color: #1e293b;
  border-radius: var(--radius-lg);
  padding: 0.75rem 1rem;
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.summary-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(0, 0, 0, 0.08);
  color: #1e293b;
}

.summary-pill.green {
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.25);
  color: #065f46;
}

.summary-pill.red {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.25);
  color: #991b1b;
}

.summary-pill strong {
  color: inherit;
}

/* Dark mode: ciemne tło, jasny tekst */
[data-bs-theme="dark"] .summary-bar {
  background: linear-gradient(135deg, #1e293b, #0f172a);
  color: #e2e8f0;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

[data-bs-theme="dark"] .summary-pill {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #e2e8f0;
}

[data-bs-theme="dark"] .summary-pill.green {
  background: rgba(16, 185, 129, 0.2);
  border-color: rgba(16, 185, 129, 0.35);
  color: #6ee7b7;
}

[data-bs-theme="dark"] .summary-pill.red {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.35);
  color: #fca5a5;
}

[data-bs-theme="dark"] .summary-pill strong {
  color: inherit;
}

/* ──────────────────────────────────────────────────────────────────────────
   Tables
   ────────────────────────────────────────────────────────────────────────── */
.table {
  font-size: 0.875rem;
}

.table thead th {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-500);
  border-bottom: 2px solid var(--gray-200);
  padding: 0.875rem 0.75rem;
  white-space: nowrap;
}

.table tbody td {
  padding: 0.875rem 0.75rem;
  vertical-align: middle;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-700);
}

.table tbody tr:hover {
  background: var(--gray-50);
}

.table .fw-medium {
  font-weight: 600;
  color: var(--gray-800);
}

/* ──────────────────────────────────────────────────────────────────────────
   Buttons
   ────────────────────────────────────────────────────────────────────────── */
.btn {
  font-weight: 600;
  font-size: 0.875rem;
  border-radius: var(--radius-sm);
  padding: 0.5rem 1rem;
  transition: all var(--transition-fast);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  border: none;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--primary-hover), var(--primary-dark));
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.35);
  transform: translateY(-1px);
}

.btn-outline-primary {
  color: var(--primary);
  border-color: var(--primary);
}

.btn-outline-primary:hover {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

.btn-outline-success {
  color: var(--success);
  border-color: var(--success);
}

.btn-outline-success:hover {
  background: var(--success);
  border-color: var(--success);
  color: white;
}

.btn-outline-danger {
  color: var(--danger);
  border-color: var(--danger);
}

.btn-outline-danger:hover {
  background: var(--danger);
  border-color: var(--danger);
  color: white;
}

/* ──────────────────────────────────────────────────────────────────────────
   Forms
   ────────────────────────────────────────────────────────────────────────── */
.form-control,
.form-select {
  font-size: 0.9rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--gray-300);
  padding: 0.625rem 0.875rem;
  transition: all var(--transition-fast);
}

.form-control:focus,
.form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.form-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 0.375rem;
}

/* ──────────────────────────────────────────────────────────────────────────
   Alerts
   ────────────────────────────────────────────────────────────────────────── */
.alert {
  border-radius: var(--radius-md);
  border: none;
  font-size: 0.9rem;
  font-weight: 500;
}

.alert-success {
  background: var(--success-light);
  color: #065f46;
}

.alert-danger {
  background: var(--danger-light);
  color: #991b1b;
}

.alert-warning {
  background: var(--warning-light);
  color: #92400e;
}

.alert-info {
  background: var(--info-light);
  color: #075985;
}

/* ──────────────────────────────────────────────────────────────────────────
   Badges
   ────────────────────────────────────────────────────────────────────────── */
.badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.35em 0.65em;
  border-radius: var(--radius-sm);
}

/* ──────────────────────────────────────────────────────────────────────────
   Footer
   ────────────────────────────────────────────────────────────────────────── */
.footer {
  background: white;
  border-top: 1px solid var(--gray-200);
  padding: 1.25rem 0;
  margin-top: auto;
}

/* ──────────────────────────────────────────────────────────────────────────
   Utility Classes
   ────────────────────────────────────────────────────────────────────────── */
.text-primary {
  color: var(--primary) !important;
}

.text-success {
  color: var(--success) !important;
}

.text-danger {
  color: var(--danger) !important;
}

.text-warning {
  color: var(--warning) !important;
}

.text-info {
  color: var(--info) !important;
}

.bg-primary-light {
  background: var(--primary-light) !important;
}

.bg-success-light {
  background: var(--success-light) !important;
}

.bg-danger-light {
  background: var(--danger-light) !important;
}

.bg-warning-light {
  background: var(--warning-light) !important;
}

.bg-info-light {
  background: var(--info-light) !important;
}

.hint {
  font-size: 0.75rem;
  color: var(--gray-400);
}

/* ──────────────────────────────────────────────────────────────────────────
   Animations
   ────────────────────────────────────────────────────────────────────────── */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(15px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.animate-fade-in-up {
  animation: fadeInUp 0.4s ease-out;
}

/* ──────────────────────────────────────────────────────────────────────────
   Scrollbar
   ────────────────────────────────────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--gray-100);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: var(--gray-300);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--gray-400);
}

/* ──────────────────────────────────────────────────────────────────────────
   DataTables Overrides
   ────────────────────────────────────────────────────────────────────────── */
.dataTables_wrapper .dataTables_filter input {
  border-radius: var(--radius-sm);
  border: 1px solid var(--gray-300);
  padding: 0.5rem 0.75rem;
}

.dataTables_wrapper .dataTables_length select {
  border-radius: var(--radius-sm);
  border: 1px solid var(--gray-300);
  padding: 0.35rem 2rem 0.35rem 0.5rem;
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
  border-radius: var(--radius-sm) !important;
  margin: 0 2px;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current {
  background: var(--primary) !important;
  border-color: var(--primary) !important;
  color: white !important;
}

/* ──────────────────────────────────────────────────────────────────────────
   Responsive
   ────────────────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .page-header {
    padding: 1rem;
  }

  .page-header h1 {
    font-size: 1.25rem;
  }

  .kpi-value {
    font-size: 1.5rem;
  }

  .summary-bar {
    width: 100%;
    justify-content: center;
  }

  .filter-bar {
    padding: 0.875rem;
  }
}

/* ──────────────────────────────────────────────────────────────────────────
   Dark Mode (data-bs-theme="dark")
   ────────────────────────────────────────────────────────────────────────── */
[data-bs-theme="dark"] {
  /* Neutrals – inverted */
  --gray-50: #0f172a;
  --gray-100: #1e293b;
  --gray-200: #334155;
  --gray-300: #475569;
  --gray-400: #64748b;
  --gray-500: #94a3b8;
  --gray-600: #cbd5e1;
  --gray-700: #e2e8f0;
  --gray-800: #f1f5f9;
  --gray-900: #f8fafc;

  /* Brand – slightly lighter for contrast on dark */
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --primary-light: rgba(59, 130, 246, 0.15);
  --primary-dark: #1d4ed8;

  /* Semantic – adjusted for dark bg */
  --success: #34d399;
  --success-light: rgba(52, 211, 153, 0.15);
  --danger: #f87171;
  --danger-light: rgba(248, 113, 113, 0.15);
  --warning: #fbbf24;
  --warning-light: rgba(251, 191, 36, 0.15);
  --info: #38bdf8;
  --info-light: rgba(56, 189, 248, 0.15);

  /* Shadows – darker, more visible */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -2px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -4px rgba(0, 0, 0, 0.3);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.4);

  color-scheme: dark;
}

[data-bs-theme="dark"] body {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  color: var(--gray-800);
}

[data-bs-theme="dark"] .navbar {
  background: rgba(30, 41, 59, 0.95) !important;
  border-bottom-color: var(--gray-200);
}

[data-bs-theme="dark"] .brand-text {
  color: var(--gray-900);
}

[data-bs-theme="dark"] .card {
  background: var(--gray-100);
  border-color: var(--gray-200);
}

[data-bs-theme="dark"] .card-header {
  border-bottom-color: var(--gray-200);
}

[data-bs-theme="dark"] .page-header {
  background: var(--gray-100);
  border-color: var(--gray-200);
}

[data-bs-theme="dark"] .page-header h1 {
  color: var(--gray-900);
}

[data-bs-theme="dark"] .filter-bar {
  background: var(--gray-100);
  border-color: var(--gray-200);
}

[data-bs-theme="dark"] .table thead th {
  color: var(--gray-500);
  border-bottom-color: var(--gray-200);
}

[data-bs-theme="dark"] .table tbody td {
  border-bottom-color: var(--gray-200);
  color: var(--gray-700);
}

[data-bs-theme="dark"] .table tbody tr:hover {
  background: var(--gray-50);
}

[data-bs-theme="dark"] .table-dark {
  --bs-table-bg: var(--gray-200);
  --bs-table-color: var(--gray-800);
}

[data-bs-theme="dark"] .footer {
  background: var(--gray-100);
  border-top-color: var(--gray-200);
}

[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select {
  background-color: var(--gray-50);
  border-color: var(--gray-200);
  color: var(--gray-800);
}

[data-bs-theme="dark"] .form-control:focus,
[data-bs-theme="dark"] .form-select:focus {
  background-color: var(--gray-50);
  border-color: var(--primary);
  color: var(--gray-800);
}

[data-bs-theme="dark"] .form-label {
  color: var(--gray-600);
}

[data-bs-theme="dark"] .modal-content {
  background: var(--gray-100);
  border-color: var(--gray-200);
}

[data-bs-theme="dark"] .modal-header {
  border-bottom-color: var(--gray-200);
}

[data-bs-theme="dark"] .modal-footer {
  border-top-color: var(--gray-200);
}

[data-bs-theme="dark"] .alert-success {
  background: var(--success-light);
  color: var(--success);
}

[data-bs-theme="dark"] .alert-danger {
  background: var(--danger-light);
  color: var(--danger);
}

[data-bs-theme="dark"] .alert-warning {
  background: var(--warning-light);
  color: var(--warning);
}

[data-bs-theme="dark"] .alert-info {
  background: var(--info-light);
  color: var(--info);
}

[data-bs-theme="dark"] .text-muted {
  color: var(--gray-400) !important;
}

[data-bs-theme="dark"] code {
  color: var(--info);
}

[data-bs-theme="dark"] .nav-tabs .nav-link {
  color: var(--gray-500);
}

[data-bs-theme="dark"] .nav-tabs .nav-link.active {
  background: var(--gray-100);
  border-color: var(--gray-200) var(--gray-200) var(--gray-100);
  color: var(--primary);
}

[data-bs-theme="dark"] .btn-outline-secondary {
  color: var(--gray-600);
  border-color: var(--gray-300);
}

[data-bs-theme="dark"] .btn-outline-danger {
  color: var(--danger);
  border-color: var(--danger);
}

[data-bs-theme="dark"] .btn-close {
  filter: invert(1) grayscale(100%) brightness(200%);
}

[data-bs-theme="dark"] ::-webkit-scrollbar-track {
  background: var(--gray-100);
}

[data-bs-theme="dark"] ::-webkit-scrollbar-thumb {
  background: var(--gray-300);
}

[data-bs-theme="dark"] ::-webkit-scrollbar-thumb:hover {
  background: var(--gray-400);
}

/* Theme toggle button */
.theme-toggle {
  background: none;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  color: var(--gray-600);
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: 1.1rem;
}

.theme-toggle:hover {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
}

/* ──────────────────────────────────────────────────────────────────────────
   Analytics Page
   ────────────────────────────────────────────────────────────────────────── */
.analytics-filters {
  background: var(--gray-100);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}

.preset-btn {
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--gray-300);
  background: transparent;
  color: var(--gray-600);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.preset-btn:hover,
.preset-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.chart-card {
  min-height: 320px;
}

.chart-card canvas {
  max-height: 350px;
}

.chart-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 250px;
  color: var(--gray-400);
}

.chart-empty i {
  font-size: 3rem;
  margin-bottom: 0.75rem;
}

[data-bs-theme="dark"] .analytics-filters {
  background: var(--gray-100);
  border-color: var(--gray-200);
}

[data-bs-theme="dark"] .preset-btn {
  border-color: var(--gray-300);
  color: var(--gray-600);
}

[data-bs-theme="dark"] .preset-btn:hover,
[data-bs-theme="dark"] .preset-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* ──────────────────────────────────────────────────────────────────────────
   KPI Cards (Analytics)
   ────────────────────────────────────────────────────────────────────────── */
.kpi-card {
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.kpi-icon {
  font-size: 1.5rem;
  margin-bottom: 0.25rem;
}

.kpi-card .kpi-value {
  font-size: 1.35rem;
}

[data-bs-theme="dark"] .kpi-card {
  background: var(--gray-100);
  border-color: var(--gray-200);
}

/* ──────────────────────────────────────────────────────────────────────────
   Fullscreen Chart Mode & Chart Info
   ────────────────────────────────────────────────────────────────────────── */
.btn-fullscreen,
.btn-chart-info {
  background: none;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  color: var(--gray-500);
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: 0.85rem;
  padding: 0;
  flex-shrink: 0;
}

.btn-fullscreen:hover {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
}

.btn-chart-info:hover {
  background: rgba(var(--bs-info-rgb, 13, 202, 240), 0.1);
  color: var(--bs-info, #0dcaf0);
  border-color: var(--bs-info, #0dcaf0);
}

[data-bs-theme="dark"] .btn-fullscreen,
[data-bs-theme="dark"] .btn-chart-info {
  border-color: var(--gray-300);
  color: var(--gray-500);
}

[data-bs-theme="dark"] .btn-fullscreen:hover {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
}

[data-bs-theme="dark"] .btn-chart-info:hover {
  background: rgba(var(--bs-info-rgb, 13, 202, 240), 0.15);
  color: #67d6f0;
  border-color: #67d6f0;
}

/* ── Chart Info Popup (SweetAlert2) ──────────────────────── */
.chart-info-popup {
  border-radius: 18px !important;
  padding: 0 !important;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.18), 0 0 0 1px rgba(0, 0, 0, 0.05) !important;
  max-height: 85vh;
  overflow-y: auto;
}

.chart-info-popup.chart-info-dark {
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.06) !important;
}

.chart-info-title {
  font-size: 1.2rem !important;
  font-weight: 700 !important;
  padding: 1.5rem 1.75rem 0.75rem !important;
  text-align: left !important;
  border-bottom: none !important;
  line-height: 1.4 !important;
}

.chart-info-close {
  position: absolute !important;
  top: 0.75rem !important;
  right: 0.75rem !important;
  font-size: 1.4rem !important;
  opacity: 0.5 !important;
  transition: opacity 0.2s !important;
}

.chart-info-close:hover {
  opacity: 1 !important;
}

.chart-info-container {
  padding: 0 1.75rem 1.75rem !important;
  text-align: left !important;
}

/* Light mode body */
.chart-info-body {
  font-size: 0.9rem;
  line-height: 1.7;
  color: #334155;
}

/* Dark mode body — set directly since popup is outside [data-bs-theme] */
.chart-info-dark .chart-info-body {
  color: #cbd5e1;
}

.chart-info-section {
  margin-bottom: 1.15rem;
  padding: 0.85rem 1rem;
  border-radius: 10px;
  background: rgba(59, 130, 246, 0.04);
  border-left: 3px solid #3b82f6;
}

.chart-info-dark .chart-info-section {
  background: rgba(59, 130, 246, 0.08);
  border-left-color: #60a5fa;
}

.chart-info-section:last-child {
  margin-bottom: 0;
}

.chart-info-heading {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #3b82f6;
  margin-bottom: 0.5rem;
  padding-bottom: 0;
  border-bottom: none;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.chart-info-heading::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #3b82f6;
  flex-shrink: 0;
}

.chart-info-dark .chart-info-heading {
  color: #60a5fa;
}

.chart-info-dark .chart-info-heading::before {
  background: #60a5fa;
}

.chart-info-text {
  margin-bottom: 0.25rem;
  text-align: justify;
  hyphens: auto;
  color: inherit;
}

.chart-info-list {
  margin: 0.25rem 0 0;
  padding-left: 0;
  list-style: none;
}

.chart-info-list li {
  margin-bottom: 0.35rem;
  position: relative;
  padding-left: 1.35rem;
  color: inherit;
}

.chart-info-list li::before {
  content: '\2713';
  position: absolute;
  left: 0;
  top: 0;
  color: #10b981;
  font-weight: 700;
  font-size: 0.85em;
}

.chart-info-dark .chart-info-list li::before {
  color: #34d399;
}

@media (max-width: 576px) {
  .chart-info-popup {
    border-radius: 12px !important;
    margin: 0.5rem !important;
  }

  .chart-info-title {
    font-size: 1.05rem !important;
    padding: 1rem 1.25rem 0.5rem !important;
  }

  .chart-info-container {
    padding: 0 1.25rem 1.25rem !important;
  }

  .chart-info-section {
    padding: 0.65rem 0.75rem;
  }
}

.fullscreen-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 1040;
  backdrop-filter: blur(4px);
}

[data-bs-theme="dark"] .fullscreen-backdrop {
  background: rgba(0, 0, 0, 0.75);
}

.chart-card.chart-fullscreen {
  position: fixed !important;
  inset: 1.5rem;
  z-index: 1050;
  margin: 0 !important;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  overflow: auto;
  animation: fullscreen-in 0.25s ease-out;
}

.chart-card.chart-fullscreen canvas {
  max-height: none !important;
}

.chart-card.chart-fullscreen .card-body {
  height: calc(100% - 56px);
}

@keyframes fullscreen-in {
  from {
    opacity: 0;
    transform: scale(0.92);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* ABC badge helpers */
.bg-success-subtle {
  background-color: rgba(16, 185, 129, 0.15) !important;
}

.bg-warning-subtle {
  background-color: rgba(245, 158, 11, 0.15) !important;
}

.bg-danger-subtle {
  background-color: rgba(239, 68, 68, 0.15) !important;
}

@media (max-width: 768px) {
  .chart-card.chart-fullscreen {
    inset: 0.5rem;
    border-radius: var(--radius-md);
  }
}

/* ──────────────────────────────────────────────────────────────────────────
   Stock Overview Box (Sales & Purchases pages)
   ────────────────────────────────────────────────────────────────────────── */
.stock-overview {
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  background: var(--gray-50);
  margin-bottom: 1.5rem;
}

.stock-overview .card-header {
  background: transparent;
  border-bottom: 1px solid var(--gray-200);
  font-weight: 600;
}

.stock-cat-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.625rem 1rem;
  border-bottom: 1px solid var(--gray-100);
  transition: background var(--transition-fast);
}

.stock-cat-item:last-child {
  border-bottom: none;
}

.stock-cat-item:hover {
  background: var(--gray-100);
}

.stock-cat-bar {
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--primary), var(--info));
  transition: width 0.6s ease-out;
  min-width: 4px;
}

.stock-total-row {
  background: var(--gray-100);
  font-weight: 600;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

[data-bs-theme="dark"] .stock-overview {
  background: var(--gray-100);
  border-color: var(--gray-200);
}

[data-bs-theme="dark"] .stock-cat-item {
  border-bottom-color: var(--gray-200);
}

[data-bs-theme="dark"] .stock-cat-item:hover {
  background: var(--gray-50);
}

[data-bs-theme="dark"] .stock-total-row {
  background: var(--gray-50);
}

/* ──────────────────────────────────────────────────────────────────────────
   Forecast Panel — Full-Screen Overlay
   ────────────────────────────────────────────────────────────────────────── */

/* Open button */
.btn-forecast-open {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  padding: 0.625rem 1.5rem;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.35);
}

.btn-forecast-open:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(16, 185, 129, 0.45);
  color: #fff;
}

[data-bs-theme="dark"] .btn-forecast-open {
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.2);
}

/* Overlay */
.forecast-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: forecastOverlayIn 0.2s ease-out;
}

@keyframes forecastOverlayIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

/* Panel */
.forecast-panel {
  width: calc(100vw - 2rem);
  height: calc(100vh - 2rem);
  max-width: 1600px;
  background: #ffffff;
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: forecastIn 0.3s ease-out;
}

@keyframes forecastIn {
  from {
    opacity: 0;
    transform: scale(0.94) translateY(12px);
  }

  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

[data-bs-theme="dark"] .forecast-panel {
  background: #1e293b;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
}

/* Header */
.forecast-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--gray-200);
  flex-shrink: 0;
  flex-wrap: wrap;
  gap: 0.75rem;
}

/* Forecast tabs */
.forecast-tabs {
  gap: 0.25rem;
}

.forecast-tabs .nav-link {
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-sm);
  color: var(--gray-500);
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  transition: all var(--transition-fast);
}

.forecast-tabs .nav-link:hover {
  color: var(--primary);
  border-color: var(--primary);
}

.forecast-tabs .nav-link.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

[data-bs-theme="dark"] .forecast-tabs .nav-link {
  background: var(--gray-200);
  color: var(--gray-400);
  border-color: var(--gray-300);
}

[data-bs-theme="dark"] .forecast-tabs .nav-link.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* Product forecast table inputs */
#fcProdTable .form-control {
  font-size: 0.82rem;
  padding: 0.2rem 0.4rem;
  border-color: var(--gray-200);
}

#fcProdTable .form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

#fcProdTable thead th {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--gray-500);
  background: var(--gray-50);
  border-bottom: 2px solid var(--gray-200);
  white-space: nowrap;
}

[data-bs-theme="dark"] #fcProdTable thead th {
  background: var(--gray-100);
}

#fcProdTable tbody td {
  vertical-align: middle;
  font-size: 0.85rem;
  padding: 0.4rem 0.5rem;
}

#fcProdTable tfoot td {
  border-top: 2px solid var(--gray-300);
  font-size: 0.85rem;
}

.forecast-header-icon {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  border-radius: var(--radius-md);
  color: #fff;
  font-size: 1.25rem;
}

.btn-close-forecast {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: var(--gray-100);
  border-radius: var(--radius-sm);
  color: var(--gray-500);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-close-forecast:hover {
  background: #ef4444;
  color: #fff;
}

[data-bs-theme="dark"] .btn-close-forecast {
  background: var(--gray-200);
  color: var(--gray-400);
}

/* Body layout */
.forecast-body {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* Sidebar */
.forecast-sidebar {
  width: 320px;
  flex-shrink: 0;
  border-right: 1px solid var(--gray-200);
  overflow-y: auto;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.forecast-sidebar-section {
  background: var(--gray-50);
  border-radius: var(--radius-md);
  padding: 1rem;
}

[data-bs-theme="dark"] .forecast-sidebar-section {
  background: var(--gray-100);
}

.forecast-section-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.85rem;
  color: var(--gray-500);
}

.forecast-field {
  margin-bottom: 1rem;
}

.forecast-field:last-of-type {
  margin-bottom: 0;
}

.forecast-field .form-label {
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.forecast-field .form-range {
  accent-color: var(--primary);
}

/* KPI grid */
.forecast-kpi-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}

.forecast-kpi {
  background: #ffffff;
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--gray-200);
}

[data-bs-theme="dark"] .forecast-kpi {
  background: var(--gray-200);
  border-color: var(--gray-300);
}

.forecast-kpi-label {
  font-size: 0.7rem;
  color: var(--gray-500);
  font-weight: 500;
  margin-bottom: 0.15rem;
}

.forecast-kpi-value {
  font-size: 0.95rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* Legend info */
.forecast-legend-info {
  font-size: 0.8rem;
}

.forecast-legend-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  margin-right: 6px;
  vertical-align: middle;
}

/* Main chart area */
.forecast-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 1.25rem;
  min-width: 0;
}

.forecast-chart-wrapper {
  flex: 1;
  position: relative;
  min-height: 0;
}

.forecast-chart-wrapper canvas {
  width: 100% !important;
  height: 100% !important;
}

/* Responsive */
@media (max-width: 992px) {
  .forecast-body {
    flex-direction: column;
  }

  .forecast-sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--gray-200);
    max-height: 45vh;
    overflow-y: auto;
  }

  .forecast-main {
    min-height: 40vh;
  }
}

@media (max-width: 768px) {
  .forecast-panel {
    width: 100vw;
    height: 100vh;
    border-radius: 0;
  }

  .forecast-kpi-grid {
    grid-template-columns: 1fr;
  }
}

/* ══════════════════════════════════════════════════════════════════════════
   AI ADVISOR — Config, Report & Chat
   ══════════════════════════════════════════════════════════════════════════ */

/* ── AI Advisor Button on Analytics page ─────────────────────────────────── */
.btn-ai-advisor-open {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  background: linear-gradient(135deg, #8b5cf6 0%, #6d28d9 100%);
  color: #fff !important;
  border: none;
  border-radius: var(--radius-md);
  padding: 0.625rem 1.5rem;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: 0 2px 8px rgba(139, 92, 246, 0.35);
  text-decoration: none;
}

.btn-ai-advisor-open:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(139, 92, 246, 0.45);
  color: #fff !important;
  text-decoration: none;
}

[data-bs-theme="dark"] .btn-ai-advisor-open {
  box-shadow: 0 2px 8px rgba(139, 92, 246, 0.2);
}

/* ── Config Card ─────────────────────────────────────────────────────────── */
.ai-config-card .card-header {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.08) 0%, rgba(59, 130, 246, 0.06) 100%);
  font-weight: 600;
}

[data-bs-theme="dark"] .ai-config-card .card-header {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.15) 0%, rgba(59, 130, 246, 0.1) 100%);
}

/* ── Generate Button ─────────────────────────────────────────────────────── */
.btn-ai-generate {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #a855f7 100%);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  padding: 0.625rem 1.5rem;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.35);
  position: relative;
  overflow: hidden;
}

.btn-ai-generate:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-ai-generate:not(:disabled):hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(139, 92, 246, 0.5);
  color: #fff;
}

.btn-ai-generate.ai-unlocked {
  animation: aiPulse 2s infinite;
}

@keyframes aiPulse {

  0%,
  100% {
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.35);
  }

  50% {
    box-shadow: 0 4px 24px rgba(139, 92, 246, 0.55);
  }
}

/* ── Report Card ─────────────────────────────────────────────────────────── */
.ai-report-card .card-header {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.08) 0%, rgba(16, 185, 129, 0.06) 100%);
  font-weight: 600;
}

[data-bs-theme="dark"] .ai-report-card .card-header {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.15) 0%, rgba(16, 185, 129, 0.1) 100%);
}

.ai-report-body {
  max-height: 70vh;
  overflow-y: auto;
  padding: 1.5rem;
  line-height: 1.7;
}

.ai-report-body h3 {
  color: var(--bs-primary);
  border-bottom: 2px solid rgba(59, 130, 246, 0.15);
  padding-bottom: 0.5rem;
  margin-top: 1.5rem;
  margin-bottom: 1rem;
}

.ai-report-body h5 {
  color: var(--bs-body-color);
  margin-top: 1rem;
}

.ai-report-body .alert {
  border-radius: var(--radius-md);
}

.ai-report-body table {
  font-size: 0.9rem;
}

.ai-report-body .card {
  border-radius: var(--radius-md);
  border: 1px solid rgba(0, 0, 0, 0.05);
}

[data-bs-theme="dark"] .ai-report-body .card {
  border-color: rgba(255, 255, 255, 0.05);
}

/* ── Chat Card ───────────────────────────────────────────────────────────── */
.ai-chat-card {
  border: 1px solid rgba(139, 92, 246, 0.15);
}

.ai-chat-card .card-header {
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.08) 0%, rgba(139, 92, 246, 0.06) 100%);
  font-weight: 600;
}

[data-bs-theme="dark"] .ai-chat-card .card-header {
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.15) 0%, rgba(139, 92, 246, 0.1) 100%);
}

.ai-chat-messages {
  height: 450px;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  background: rgba(0, 0, 0, 0.02);
  scroll-behavior: smooth;
}

[data-bs-theme="dark"] .ai-chat-messages {
  background: rgba(0, 0, 0, 0.15);
}

/* Chat message layout */
.chat-message {
  display: flex;
  gap: 0.75rem;
  max-width: 85%;
  animation-duration: 0.3s;
}

.chat-message.chat-user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.chat-message.chat-assistant {
  align-self: flex-start;
}

.chat-message.chat-error {
  align-self: center;
  max-width: 100%;
}

/* Avatar */
.chat-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1rem;
}

.chat-user .chat-avatar {
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  color: #fff;
}

.chat-assistant .chat-avatar {
  background: linear-gradient(135deg, #8b5cf6, #6d28d9);
  color: #fff;
}

.chat-error .chat-avatar {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: #fff;
}

/* Bubble */
.chat-bubble {
  padding: 0.75rem 1rem;
  border-radius: 1rem;
  line-height: 1.6;
  word-break: break-word;
}

.chat-user .chat-bubble {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: #fff;
  border-bottom-right-radius: 0.25rem;
}

.chat-assistant .chat-bubble {
  background: #fff;
  color: #1e293b;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-bottom-left-radius: 0.25rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

[data-bs-theme="dark"] .chat-assistant .chat-bubble {
  background: #1e293b;
  color: #e2e8f0;
  border-color: rgba(255, 255, 255, 0.08);
}

.chat-error .chat-bubble {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.2);
  width: 100%;
  text-align: center;
  border-radius: var(--radius-md);
}

.chat-sender {
  font-size: 0.75rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
  opacity: 0.7;
}

.chat-user .chat-sender {
  text-align: right;
}

.chat-content h3,
.chat-content h5 {
  font-size: 1rem;
  margin-top: 0.5rem;
}

.chat-content ul,
.chat-content ol {
  padding-left: 1.25rem;
  margin-bottom: 0.5rem;
}

.chat-content p {
  margin-bottom: 0.4rem;
}

.chat-content p:last-child {
  margin-bottom: 0;
}

.chat-content .alert {
  margin: 0.5rem 0;
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
  border-radius: 0.5rem;
}

.chat-content table {
  font-size: 0.85rem;
  margin: 0.5rem 0;
}

/* Typing indicator */
.typing-dots {
  display: flex;
  gap: 4px;
  padding: 4px 0;
}

.typing-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #8b5cf6;
  animation: typingBounce 1.4s infinite;
}

.typing-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typingBounce {

  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.4;
  }

  30% {
    transform: translateY(-6px);
    opacity: 1;
  }
}

/* Chat input area */
.ai-chat-input-area {
  padding: 1rem;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  background: rgba(0, 0, 0, 0.01);
}

[data-bs-theme="dark"] .ai-chat-input-area {
  border-top-color: rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.1);
}

.ai-chat-input-area textarea {
  resize: none;
  border-radius: 1rem;
  padding: 0.625rem 1rem;
  min-height: 42px;
  max-height: 120px;
}

.ai-chat-input-area .btn-primary {
  border-radius: 50%;
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.chat-suggestions {
  font-size: 0.8rem;
}

.chat-suggestions a {
  color: var(--bs-primary);
  text-decoration: none;
}

.chat-suggestions a:hover {
  text-decoration: underline;
}

/* ── AI Loading Overlay ──────────────────────────────────────────────────── */
.ai-loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 3000;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  display: none;
  align-items: center;
  justify-content: center;
}

.ai-loading-overlay.active {
  display: flex;
  animation: fadeInOverlay .25s ease;
}

@keyframes fadeInOverlay {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

/* ── Glass card ── */
.ai-loading-card {
  position: relative;
  background: linear-gradient(145deg, rgba(22, 27, 45, 0.95), rgba(35, 25, 65, 0.95));
  border: 1px solid rgba(139, 92, 246, 0.3);
  border-radius: 1.25rem;
  padding: 2.5rem 2.5rem 2rem;
  text-align: center;
  max-width: 400px;
  width: 92%;
  box-shadow:
    0 24px 64px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(139, 92, 246, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
  animation: slideUpCard .35s cubic-bezier(.22, .61, .36, 1);
}

@keyframes slideUpCard {
  from {
    opacity: 0;
    transform: translateY(24px) scale(0.96);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ── Spinner circle background ── */
.ai-loading-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: rgba(139, 92, 246, 0.1);
  border: 1px solid rgba(139, 92, 246, 0.15);
}

/* ── Minimize button (top-right) ── */
.ai-loading-minimize-btn {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all .2s ease;
  font-size: 1.1rem;
  padding: 0;
  line-height: 1;
}

.ai-loading-minimize-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.28);
  transform: scale(1.05);
}

/* ── Step progress ── */
.ai-loading-steps {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  text-align: left;
  max-width: 290px;
  margin: 0 auto;
}

.ai-loading-steps .step {
  display: flex;
  align-items: center;
  padding: 0.55rem 0.85rem;
  border-radius: 0.6rem;
  color: rgba(255, 255, 255, 0.3);
  font-size: 0.85rem;
  transition: all 0.35s ease;
  border: 1px solid transparent;
  font-weight: 500;
}

.ai-loading-steps .step i {
  font-size: 0.95rem;
  min-width: 20px;
}

.ai-loading-steps .step.active {
  color: #f0ecff;
  background: rgba(139, 92, 246, 0.15);
  border-color: rgba(139, 92, 246, 0.3);
}

.ai-loading-steps .step.active .step-status::after {
  content: '';
  display: inline-block;
  width: 15px;
  height: 15px;
  border: 2px solid rgba(139, 92, 246, 0.35);
  border-top-color: #a78bfa;
  border-radius: 50%;
  animation: stepSpin 0.75s linear infinite;
}

.ai-loading-steps .step.done {
  color: #34d399;
  background: rgba(16, 185, 129, 0.08);
  border-color: rgba(16, 185, 129, 0.18);
}

.ai-loading-steps .step.done .step-status::after {
  content: '✓';
  font-weight: 700;
  font-size: 0.9rem;
  color: #34d399;
  animation: none;
  border: none;
  width: auto;
  height: auto;
  display: inline;
}

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

/* ── Floating mini pill (bottom-right) ───────────────────────────────────── */
.ai-loading-mini {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 3001;
  display: none;
  align-items: center;
  gap: 0.6rem;
  padding: 0.65rem 1.3rem 0.65rem 0.9rem;
  background: linear-gradient(135deg, #161b2d 0%, #2a1a52 100%);
  border: 1px solid rgba(139, 92, 246, 0.3);
  border-radius: 2rem;
  color: #ddd8ff;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow:
    0 8px 28px rgba(0, 0, 0, 0.45),
    0 0 16px rgba(139, 92, 246, 0.12);
  transition: all 0.2s ease;
}

.ai-loading-mini.active {
  display: flex;
  animation: slideInMini .35s cubic-bezier(.22, .61, .36, 1);
}

@keyframes slideInMini {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.95);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.ai-loading-mini:hover {
  background: linear-gradient(135deg, #1e2440 0%, #3a2878 100%);
  box-shadow:
    0 12px 36px rgba(0, 0, 0, 0.55),
    0 0 20px rgba(139, 92, 246, 0.2);
  transform: translateY(-2px);
}

.ai-mini-spinner-ring {
  width: 18px;
  height: 18px;
  border: 2.5px solid rgba(139, 92, 246, 0.25);
  border-top-color: #a78bfa;
  border-radius: 50%;
  animation: stepSpin 0.75s linear infinite;
  flex-shrink: 0;
}

.ai-mini-label {
  white-space: nowrap;
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .ai-chat-messages {
    height: 350px;
  }

  .chat-message {
    max-width: 95%;
  }

  .ai-report-body {
    max-height: 50vh;
    padding: 1rem;
  }
}

/* ══════════════════════════════════════════════════════════════════════════
   Nagłówek (v2.5): górny pasek + rząd zakładek z podpisami
   ══════════════════════════════════════════════════════════════════════════ */
.hdr {
  z-index: 1030;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--gray-200);
  box-shadow: 0 4px 14px -10px rgba(15, 23, 42, 0.35);
}
[data-bs-theme="dark"] .hdr { background: rgba(15, 23, 42, 0.96); }

.hdr-top { padding: 0.5rem 0; }
.hdr-brand { display: flex; align-items: center; gap: 0.6rem; text-decoration: none; flex-shrink: 0; }
.hdr-brand .brand-icon { width: 34px; height: 34px; font-size: 1rem; }
.hdr-brand-name { font-weight: 700; font-size: 1.08rem; letter-spacing: -0.02em; color: var(--gray-900); white-space: nowrap; }

.hdr-actions { display: flex; align-items: center; gap: 0.35rem; }
.hdr-btn {
  display: inline-flex; align-items: center; gap: 0.35rem; white-space: nowrap;
  padding: 0.32rem 0.8rem; border-radius: 999px;
  font-size: 0.83rem; font-weight: 600; text-decoration: none;
  color: var(--gray-700); background: var(--gray-100); border: 1px solid var(--gray-200);
  transition: all var(--transition-fast);
}
.hdr-btn:hover { color: var(--primary); border-color: var(--primary); background: var(--primary-light); }
.hdr-btn-primary { color: #fff; background: var(--primary); border-color: var(--primary); }
.hdr-btn-primary:hover { color: #fff; background: var(--primary-hover); border-color: var(--primary-hover); }

.hdr-tools { display: flex; align-items: center; gap: 0.15rem; padding-left: 0.6rem; border-left: 1px solid var(--gray-200); }
.hdr-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 8px; border: 0; background: transparent;
  color: var(--gray-500); font-size: 1.08rem; text-decoration: none; transition: all var(--transition-fast);
}
.hdr-icon:hover, .hdr-icon.active { color: var(--primary); background: var(--primary-light); }
.hdr-icon-danger:hover { color: var(--danger); background: var(--danger-light); }
.hdr-menu { display: none; }

.hdr-nav { border-top: 1px solid var(--gray-200); }
.hdr-tabs { display: flex; align-items: center; gap: 0.1rem; }
.hdr-sep { width: 1px; height: 18px; background: var(--gray-200); margin: 0 0.35rem; flex-shrink: 0; }
.hdr-push { margin-left: auto; }
.hdr-tab {
  position: relative; display: inline-flex; align-items: center; gap: 0.4rem; white-space: nowrap;
  padding: 0.62rem 0.62rem; font-size: 0.88rem; font-weight: 600; text-decoration: none;
  color: var(--gray-600); transition: color var(--transition-fast);
}
.hdr-tab i { font-size: 0.95rem; opacity: 0.8; }
.hdr-tab::after {
  content: ""; position: absolute; left: 0.5rem; right: 0.5rem; bottom: -1px; height: 3px;
  border-radius: 3px 3px 0 0; background: transparent; transition: background var(--transition-fast);
}
.hdr-tab:hover { color: var(--primary); }
.hdr-tab:hover::after { background: var(--gray-300); }
.hdr-tab.active { color: var(--primary); }
.hdr-tab.active i { opacity: 1; }
.hdr-tab.active::after { background: var(--primary); }

/* Dopasowanie do szerokości okna — podpisy zostają zawsze widoczne */
@media (max-width: 1399.98px) { .hdr-tab i { display: none; } .hdr-tab { padding: 0.62rem 0.55rem; } }
@media (max-width: 1199.98px) { .hdr-tab { padding: 0.62rem 0.42rem; font-size: 0.82rem; } .hdr-sep { margin: 0 0.15rem; } }
@media (max-width: 1099.98px) { .hdr-btn span { display: none; } .hdr-btn { padding: 0.32rem 0.55rem; } }

/* Wąskie okno: zakładki jako rozwijana lista */
@media (max-width: 991.98px) {
  .hdr-menu { display: inline-flex; }
  .hdr-actions { display: none; }
  .hdr-tabs { display: none; flex-direction: column; align-items: stretch; padding: 0.4rem 0 0.6rem; }
  .hdr-tabs.show, .hdr-tabs.collapsing { display: flex; }
  .hdr-tab i { display: inline; }
  .hdr-tab { padding: 0.55rem 0.6rem; border-radius: 8px; font-size: 0.9rem; }
  .hdr-tab::after { display: none; }
  .hdr-tab.active { background: var(--primary-light); }
  .hdr-sep { width: auto; height: 1px; margin: 0.3rem 0; }
  .hdr-push { margin-left: 0; }
}

/* ══════════════════════════════════════════════════════════════════════════
   Motyw „premium” (v2.5) — spójne tła, karty, tabele, formularze i statusy
   dla jasnego i ciemnego motywu. Wszystko w jednym bloku (łatwe do wycofania).
   ══════════════════════════════════════════════════════════════════════════ */
:root {
  --surface-0: #f4f6fa;          /* tło aplikacji */
  --surface-1: #ffffff;          /* karty */
  --surface-2: #f8fafc;          /* nagłówki tabel, pola wyróżnione */
  --line: rgba(15, 23, 42, 0.08);
  --line-strong: rgba(15, 23, 42, 0.14);
  --text-1: #0f172a;
  --text-2: #334155;
  --text-3: #64748b;
  --card-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 6px 20px -12px rgba(15, 23, 42, 0.12);
  --row-hover: rgba(37, 99, 235, 0.035);
}
[data-bs-theme="dark"] {
  --surface-0: #0a0f1c;
  --surface-1: #111827;
  --surface-2: #162033;
  --line: rgba(148, 163, 184, 0.12);
  --line-strong: rgba(148, 163, 184, 0.22);
  --text-1: #f1f5f9;
  --text-2: #cbd5e1;
  --text-3: #94a3b8;
  --card-shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 10px 28px -16px rgba(0, 0, 0, 0.6);
  --row-hover: rgba(148, 163, 184, 0.06);
  /* zmienne Bootstrapa — bez czarnych teł tabel i list */
  --bs-body-bg: var(--surface-0);
  --bs-body-color: var(--text-2);
  --bs-emphasis-color: var(--text-1);
  --bs-secondary-color: var(--text-3);
  --bs-tertiary-bg: var(--surface-2);
  --bs-border-color: var(--line-strong);
  --bs-border-color-translucent: var(--line);
}

/* Tło */
body { background: var(--surface-0); color: var(--text-2); font-feature-settings: "cv11", "ss01"; }
[data-bs-theme="dark"] body {
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(59, 130, 246, 0.08), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(139, 92, 246, 0.05), transparent 60%),
    var(--surface-0);
  background-attachment: fixed;
}
::selection { background: rgba(37, 99, 235, 0.2); }
.text-muted { color: var(--text-3) !important; }
h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 { color: var(--text-1); }

/* Nagłówek okna w ciemnym motywie — w tonie tła */
[data-bs-theme="dark"] .hdr { background: rgba(10, 15, 28, 0.88); border-bottom-color: var(--line); }
[data-bs-theme="dark"] .hdr-nav, [data-bs-theme="dark"] .hdr-tools { border-color: var(--line); }
[data-bs-theme="dark"] .hdr-btn { background: rgba(148, 163, 184, 0.08); border-color: var(--line); color: var(--text-2); }
[data-bs-theme="dark"] .hdr-btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }

/* Karty i nagłówki stron */
.card, .page-header {
  background: var(--surface-1) !important;
  border: 1px solid var(--line) !important;
  border-radius: 14px;
  box-shadow: var(--card-shadow) !important;
}
.card:hover { transform: none; box-shadow: var(--card-shadow) !important; }
.card .card-body { color: var(--text-2); }
.page-header h1 { color: var(--text-1); font-weight: 800; letter-spacing: -0.025em; }
.page-header .subtitle { color: var(--text-3); }
.page-header .filter-bar, .filter-bar, .card .card { background: var(--surface-2) !important; border-color: var(--line) !important; box-shadow: none !important; }

/* Kafelki z liczbami (KPI) */
.card .h4, .card .h5, .kpi-value { font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.card .h4 { font-weight: 700; color: var(--text-1); }
.card .h4.text-danger, .card .h5.text-danger { color: var(--danger) !important; }
.card .h4.text-success, .card .h5.text-success { color: var(--success) !important; }
.card-body > .text-muted.small:first-child { text-transform: uppercase; font-size: 0.7rem !important; font-weight: 700; letter-spacing: 0.06em; }
.kpi-card .kpi-label, .kpi-card .text-uppercase { color: var(--text-3); }

/* Tabele */
.table { --bs-table-bg: transparent; --bs-table-color: var(--text-2); --bs-table-hover-bg: var(--row-hover); --bs-table-active-bg: var(--primary-light); color: var(--text-2); }
.table > :not(caption) > * > * { background-color: transparent; border-bottom-color: var(--line); }
.table thead th, .table > thead > tr > th {
  background: var(--surface-2) !important; color: var(--text-3);
  border-bottom: 1px solid var(--line-strong) !important;
  font-size: 0.68rem; letter-spacing: 0.07em;
}
.table thead th:first-child { border-top-left-radius: 8px; }
.table thead th:last-child { border-top-right-radius: 8px; }
.table tbody td { color: var(--text-2); border-bottom: 1px solid var(--line) !important; font-variant-numeric: tabular-nums; }
.table tbody tr:hover, .table tbody tr:hover > td { background: var(--row-hover) !important; }
.table .fw-medium, .table .fw-semibold { color: var(--text-1); }
.table td a { color: var(--primary); text-decoration: none; }
.table td a:hover { text-decoration: underline; }
.table-active, .table tbody tr.table-active > td { background: var(--primary-light) !important; }
.table tfoot td { border-top: 1px solid var(--line-strong); color: var(--text-2); }

/* Formularze */
.form-control, .form-select {
  background-color: var(--surface-1); color: var(--text-1);
  border-color: var(--line-strong); border-radius: 9px;
}
.form-control::placeholder { color: var(--text-3); opacity: 0.8; }
.form-control:focus, .form-select:focus {
  background-color: var(--surface-1); color: var(--text-1);
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.16);
}
[data-bs-theme="dark"] .form-control, [data-bs-theme="dark"] .form-select { background-color: #0d1424; }
[data-bs-theme="dark"] .form-control:focus, [data-bs-theme="dark"] .form-select:focus { background-color: #0d1424; box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.28); }
.form-label, label.form-label { color: var(--text-2); font-weight: 600; }
.form-text { color: var(--text-3); }
.input-group-text { background: var(--surface-2); border-color: var(--line-strong); color: var(--text-3); }

/* Przyciski */
.btn { border-radius: 9px; font-weight: 600; }
.btn-primary { box-shadow: 0 1px 2px rgba(15, 23, 42, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.12); }
.btn-outline-secondary { color: var(--text-2); border-color: var(--line-strong); background: var(--surface-1); }
.btn-outline-secondary:hover { color: var(--text-1); background: var(--surface-2); border-color: var(--line-strong); }

/* Statusy — stonowane plakietki zamiast jaskrawych */
.badge { font-weight: 600; letter-spacing: 0.01em; border-radius: 6px; padding: 0.38em 0.62em; }
.badge.bg-success { background: rgba(16, 185, 129, 0.14) !important; color: #047857 !important; }
.badge.bg-danger { background: rgba(239, 68, 68, 0.13) !important; color: #b91c1c !important; }
.badge.bg-warning { background: rgba(245, 158, 11, 0.17) !important; color: #92400e !important; }
.badge.bg-primary { background: rgba(37, 99, 235, 0.12) !important; color: #1d4ed8 !important; }
.badge.bg-info { background: rgba(14, 165, 233, 0.14) !important; color: #0369a1 !important; }
.badge.bg-secondary { background: rgba(100, 116, 139, 0.14) !important; color: #475569 !important; }
[data-bs-theme="dark"] .badge.bg-success { color: #6ee7b7 !important; background: rgba(16, 185, 129, 0.16) !important; }
[data-bs-theme="dark"] .badge.bg-danger { color: #fca5a5 !important; background: rgba(239, 68, 68, 0.17) !important; }
[data-bs-theme="dark"] .badge.bg-warning { color: #fcd34d !important; background: rgba(245, 158, 11, 0.17) !important; }
[data-bs-theme="dark"] .badge.bg-primary { color: #93c5fd !important; background: rgba(59, 130, 246, 0.18) !important; }
[data-bs-theme="dark"] .badge.bg-info { color: #7dd3fc !important; background: rgba(14, 165, 233, 0.17) !important; }
[data-bs-theme="dark"] .badge.bg-secondary { color: #cbd5e1 !important; background: rgba(148, 163, 184, 0.16) !important; }

/* Komunikaty */
.alert { border-radius: 12px; border: 1px solid var(--line); }
[data-bs-theme="dark"] .alert-info { background: rgba(14, 165, 233, 0.10); color: #bae6fd; border-color: rgba(14, 165, 233, 0.25); }
[data-bs-theme="dark"] .alert-warning { background: rgba(245, 158, 11, 0.10); color: #fde68a; border-color: rgba(245, 158, 11, 0.25); }
[data-bs-theme="dark"] .alert-danger { background: rgba(239, 68, 68, 0.10); color: #fecaca; border-color: rgba(239, 68, 68, 0.25); }
[data-bs-theme="dark"] .alert-success { background: rgba(16, 185, 129, 0.10); color: #a7f3d0; border-color: rgba(16, 185, 129, 0.25); }
[data-bs-theme="dark"] .alert-secondary { background: rgba(148, 163, 184, 0.08); color: var(--text-2); border-color: var(--line-strong); }

/* Okna dialogowe, listy rozwijane, paski postępu */
.modal-content { background: var(--surface-1); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 30px 60px -20px rgba(15, 23, 42, 0.35); }
.dropdown-menu { background: var(--surface-1); border-color: var(--line); border-radius: 10px; }
.progress { background: var(--surface-2); }
hr { border-color: var(--line-strong); opacity: 1; }
details summary { color: var(--text-1); }

/* Stopka */
.footer { background: transparent; border-top: 1px solid var(--line); }

/* Pasek przewijania w ciemnym motywie */
[data-bs-theme="dark"] ::-webkit-scrollbar { width: 11px; height: 11px; }
[data-bs-theme="dark"] ::-webkit-scrollbar-track { background: transparent; }
[data-bs-theme="dark"] ::-webkit-scrollbar-thumb { background: rgba(148, 163, 184, 0.22); border-radius: 10px; border: 3px solid transparent; background-clip: content-box; }
