/* ============================================================================
   CRM Business Partner Control - Design System
   Modern Premium SaaS UI
   ============================================================================ */

/* ============================================================================
   1. CSS VARIABLES (Design Tokens)
   ============================================================================ */

:root {
  /* Colors - Primary */
  --color-primary: #1E3A8A;
  --color-primary-hover: #1D4ED8;
  --color-primary-light: #3B82F6;
  --color-primary-lighter: #DBEAFE;

  /* Colors - Neutrals */
  --color-bg: #F8FAFC;
  --color-bg-alt: #F1F5F9;
  --color-surface: #FFFFFF;
  --color-border: #E5E7EB;
  --color-border-light: #F3F4F6;

  /* Colors - Text */
  --color-text: #0F172A;
  --color-text-muted: #64748B;
  --color-text-light: #94A3B8;

  /* Colors - Status */
  --color-success: #10B981;
  --color-success-bg: #D1FAE5;
  --color-warning: #F59E0B;
  --color-warning-bg: #FEF3C7;
  --color-danger: #EF4444;
  --color-danger-bg: #FEE2E2;
  --color-info: #3B82F6;
  --color-info-bg: #DBEAFE;

  /* Shadows - Компактный дизайн (легкие тени, border-first подход) */
  --shadow-sm: 0 1px 2px 0 rgba(15, 23, 42, 0.03);
  --shadow-md: 0 2px 6px 0 rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 4px 12px 0 rgba(15, 23, 42, 0.06);
  --shadow-xl: 0 8px 20px 0 rgba(15, 23, 42, 0.08);

  /* Border Radius - Компактный дизайн */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 10px;
  --radius-full: 9999px;

  /* Borders - Компактный дизайн */
  --border-light: 1px solid #E5E7EB;
  --border-medium: 1px solid #D1D5DB;

  /* Spacing - Компактный дизайн */
  --space-2xs: 2px;
  --space-xs: 4px;
  --space-sm: 6px;
  --space-md: 10px;
  --space-lg: 16px;
  --space-xl: 20px;
  --space-2xl: 32px;

  /* Typography - Компактный дизайн */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-size-2xs: 0.6875rem;  /* 11px - новый */
  --font-size-xs: 0.75rem;      /* 12px - без изменений */
  --font-size-sm: 0.8125rem;    /* 13px - было 14px */
  --font-size-base: 0.875rem;   /* 14px - было 16px */
  --font-size-lg: 1rem;         /* 16px - было 18px */
  --font-size-xl: 1.125rem;     /* 18px - было 20px */
  --font-size-2xl: 1.25rem;     /* 20px - было 24px */
  --font-size-3xl: 1.875rem;    /* 30px - без изменений */

  /* Component Sizes - Компактный дизайн */
  --table-row-height: 44px;
  --table-cell-padding-y: 8px;
  --table-cell-padding-x: 12px;
  --card-padding-compact: 12px;

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Sidebar Colors (Light & Airy Theme) */
  --sidebar-bg: #ffffff;
  --sidebar-bg-darker: #f8f9fa;
  --sidebar-text: #495057;
  --sidebar-text-muted: #6c757d;
  --sidebar-active-bg: #e7f1ff;
  --sidebar-hover-bg: rgba(0, 0, 0, 0.04);
  --sidebar-border: #dee2e6;
  --sidebar-submenu-bg: #f8f9fa;

  /* Sidebar Dimensions */
  --sidebar-width: 260px;
  --sidebar-width-collapsed: 60px;
}

/* ============================================================================
   2. BASE STYLES
   ============================================================================ */

* {
  box-sizing: border-box;
}

body {
  font-family: var(--font-sans);
  background-color: var(--color-bg);
  color: var(--color-text);
  font-size: var(--font-size-base);
  line-height: 1.6;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ============================================================================
   3. HEADER & NAVIGATION
   ============================================================================ */

.navbar {
  background-color: var(--color-surface) !important;
  border-bottom: 1px solid var(--color-border-light);
  box-shadow: var(--shadow-sm);
  padding: var(--space-md) 0;
}

.navbar-brand {
  font-weight: 700;
  font-size: var(--font-size-lg);
  color: var(--color-text) !important;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.navbar-brand i {
  color: var(--color-primary);
  font-size: var(--font-size-xl);
}

.navbar-text {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted) !important;
  font-weight: 500;
}

/* Main Tabs (Projects, Replenishments, Sync, Logs, Finance) */
.nav-tabs {
  border-bottom: 2px solid var(--color-border-light);
  gap: var(--space-sm);
  margin-bottom: var(--space-xl);
}

.nav-tabs .nav-link {
  color: var(--color-text-muted);
  font-weight: 500;
  font-size: var(--font-size-sm);
  padding: var(--space-md) var(--space-lg);
  border: none;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  transition: all var(--transition-base);
  position: relative;
  background: transparent;
}

.nav-tabs .nav-link:hover:not(.active) {
  color: var(--color-text);
  background-color: var(--color-bg-alt);
}

.nav-tabs .nav-link.active {
  color: var(--color-primary);
  background-color: var(--color-surface);
  font-weight: 600;
  border-bottom: 3px solid var(--color-primary);
}

.nav-tabs .nav-link i {
  margin-right: var(--space-xs);
}

/* Finance Sub-tabs (Pills style) */
.nav-pills {
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
}

.nav-pills .nav-link {
  color: var(--color-text-muted);
  font-weight: 500;
  font-size: var(--font-size-sm);
  padding: var(--space-sm) var(--space-lg);
  border-radius: var(--radius-full);
  transition: all var(--transition-base);
  background: transparent;
}

.nav-pills .nav-link:hover:not(.active) {
  color: var(--color-text);
  background-color: var(--color-bg-alt);
}

.nav-pills .nav-link.active {
  background-color: var(--color-primary);
  color: var(--color-surface);
  box-shadow: var(--shadow-md);
  font-weight: 600;
}

.nav-pills .nav-link i {
  margin-right: var(--space-xs);
}

/* ============================================================================
   4. CARDS & CONTAINERS
   ============================================================================ */

.card {
  background-color: var(--color-surface);
  border: var(--border-light);
  border-radius: var(--radius-md);
  box-shadow: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  overflow: hidden;
}

.card:hover {
  border-color: var(--color-border);
  box-shadow: var(--shadow-sm);
}

.card-header {
  background-color: var(--color-surface);
  border-bottom: 1px solid var(--color-border-light);
  padding: var(--space-md) var(--space-lg);
  font-weight: 600;
  font-size: var(--font-size-base);
  color: var(--color-text);
  line-height: 1.4;
}

.card-body {
  padding: var(--space-lg);
}

/* Metric cards on dashboard */
.card.bg-light,
.card.bg-success,
.card.bg-danger,
.card.bg-info {
  border: none;
}

.card.bg-light {
  background-color: var(--color-bg-alt) !important;
}

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

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

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

.card.bg-success .card-body,
.card.bg-danger .card-body,
.card.bg-info .card-body {
  padding: var(--space-lg);
}

/* ============================================================================
   5. TABLES
   ============================================================================ */

.table-responsive {
  border-radius: var(--radius-md);
  overflow: hidden;
  border: var(--border-light);
}

.table {
  background-color: var(--color-surface);
  margin-bottom: 0;
  font-size: var(--font-size-sm);
}

.table thead th {
  background-color: #F8FAFC;
  border-bottom: 1px solid #E5E7EB;
  font-weight: 600;
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: #64748B;
  padding: var(--space-sm) var(--table-cell-padding-x);
  line-height: 1.3;
  white-space: nowrap;
}

.table tbody tr {
  border-bottom: 1px solid #F3F4F6;
  transition: background-color 0.15s;
}

.table tbody tr:hover {
  background-color: #F8FAFC;
  box-shadow: none;
}

.table tbody tr:last-child {
  border-bottom: none;
}

.table tbody td {
  padding: var(--table-cell-padding-y) var(--table-cell-padding-x);
  font-size: var(--font-size-sm);
  line-height: 1.4;
  vertical-align: middle;
  color: var(--color-text);
}

.table-sm thead th,
.table-sm tbody td {
  padding: var(--space-sm) var(--space-md);
}

/* Table with warning background */
.table-warning {
  background-color: var(--color-warning-bg) !important;
}

.table-warning:hover {
  background-color: #FDE68A !important;
}

/* Sticky table header */
.sticky-top {
  position: sticky;
  top: 0;
  z-index: 10;
}

/* ============================================================================
   6. BUTTONS
   ============================================================================ */

.btn {
  font-weight: 500;
  font-size: var(--font-size-sm);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  transition: all var(--transition-base);
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  line-height: 1.3;
  text-decoration: none;
}

.btn:focus {
  outline: 2px solid var(--color-primary-lighter);
  outline-offset: 2px;
}

/* Primary Button */
.btn-primary {
  background-color: var(--color-primary);
  color: var(--color-surface);
}

.btn-primary:hover {
  background-color: var(--color-primary-hover);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

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

/* Secondary Button */
.btn-secondary {
  background-color: var(--color-bg-alt);
  color: var(--color-text);
}

.btn-secondary:hover {
  background-color: #E2E8F0;
  box-shadow: var(--shadow-sm);
}

/* Success Button */
.btn-success {
  background-color: var(--color-success);
  color: var(--color-surface);
}

.btn-success:hover {
  background-color: #059669;
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

/* Info Button */
.btn-info {
  background-color: var(--color-info);
  color: var(--color-surface);
}

.btn-info:hover {
  background-color: #2563EB;
  box-shadow: var(--shadow-md);
}

/* Danger Button */
.btn-danger {
  background-color: var(--color-danger);
  color: var(--color-surface);
}

.btn-danger:hover {
  background-color: #DC2626;
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

/* Small Button */
.btn-sm {
  padding: var(--space-xs) var(--space-sm);
  font-size: var(--font-size-xs);
  line-height: 1.3;
}

/* Icon buttons in tables */
.btn i.bi {
  font-size: 1em;
}

/* Button close (modals) */
.btn-close {
  filter: none;
  opacity: 0.5;
}

.btn-close:hover {
  opacity: 1;
}

/* ============================================================================
   7. BADGES & STATUS
   ============================================================================ */

.badge {
  padding: var(--space-xs) var(--space-md);
  font-weight: 500;
  font-size: var(--font-size-xs);
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
}

.badge.bg-success,
.text-success {
  background-color: var(--color-success-bg) !important;
  color: #065F46 !important;
}

.badge.bg-warning,
.text-warning {
  background-color: var(--color-warning-bg) !important;
  color: #92400E !important;
}

.badge.bg-danger,
.text-danger {
  background-color: var(--color-danger-bg) !important;
  color: #991B1B !important;
}

.badge.bg-info,
.text-info {
  background-color: var(--color-info-bg) !important;
  color: #1E40AF !important;
}

.badge.bg-primary {
  background-color: var(--color-primary-lighter) !important;
  color: var(--color-primary) !important;
}

.badge.bg-secondary {
  background-color: var(--color-bg-alt) !important;
  color: var(--color-text-muted) !important;
}

/* Text colors */
.text-muted {
  color: var(--color-text-muted) !important;
}

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

/* ============================================================================
   8. FORMS
   ============================================================================ */

.form-label {
  font-weight: 500;
  font-size: var(--font-size-sm);
  color: var(--color-text);
  margin-bottom: var(--space-xs);
  display: block;
}

.form-control,
.form-select {
  font-size: var(--font-size-sm);
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background-color: var(--color-surface);
  color: var(--color-text);
  transition: all var(--transition-base);
}

.form-control:focus,
.form-select:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-lighter);
  outline: none;
}

.form-control::placeholder {
  color: var(--color-text-light);
}

.form-control-sm,
.form-select-sm {
  padding: var(--space-xs) var(--space-sm);
  font-size: var(--font-size-xs);
}

.form-check-input {
  border-color: var(--color-border);
}

.form-check-input:checked {
  background-color: var(--color-primary);
  border-color: var(--color-primary);
}

.form-check-input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-lighter);
}

.form-check-label {
  font-size: var(--font-size-sm);
  color: var(--color-text);
  margin-left: var(--space-xs);
}

.form-text,
small.text-muted {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  display: block;
  margin-top: var(--space-xs);
}

/* ============================================================================
   9. MODALS
   ============================================================================ */

.modal-content {
  border-radius: var(--radius-lg);
  border: none;
  box-shadow: var(--shadow-xl);
}

.modal-header {
  padding: var(--space-xl);
  border-bottom: 1px solid var(--color-border-light);
  background-color: var(--color-surface);
}

.modal-title {
  font-weight: 600;
  font-size: var(--font-size-xl);
  color: var(--color-text);
}

.modal-body {
  padding: var(--space-xl);
}

.modal-footer {
  padding: var(--space-lg) var(--space-xl);
  border-top: 1px solid var(--color-border-light);
  background-color: var(--color-bg);
}

/* ============================================================================
   10. ALERTS
   ============================================================================ */

.alert {
  padding: var(--space-lg);
  border-radius: var(--radius-md);
  border: none;
  font-size: var(--font-size-sm);
}

.alert-success {
  background-color: var(--color-success-bg);
  color: #065F46;
}

.alert-warning {
  background-color: var(--color-warning-bg);
  color: #92400E;
}

.alert-danger {
  background-color: var(--color-danger-bg);
  color: #991B1B;
}

.alert-info {
  background-color: var(--color-info-bg);
  color: #1E40AF;
}

/* ============================================================================
   11. SPINNERS
   ============================================================================ */

.spinner-border {
  width: 3rem;
  height: 3rem;
  margin: var(--space-2xl) auto;
  border-width: 3px;
  color: var(--color-primary);
}

.spinner-border-sm {
  width: 1rem;
  height: 1rem;
  border-width: 2px;
}

/* ============================================================================
   12. UTILITY CLASSES
   ============================================================================ */

.fw-bold {
  font-weight: 700 !important;
}

.fw-semibold {
  font-weight: 600 !important;
}

.small {
  font-size: var(--font-size-xs);
}

code {
  background-color: var(--color-bg-alt);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-size: var(--font-size-xs);
  color: var(--color-primary);
  font-family: 'Courier New', monospace;
}

/* Divider */
hr {
  border: none;
  height: 1px;
  background-color: var(--color-border-light);
  margin: var(--space-xl) 0;
}

/* ============================================================================
   13. SIDEBAR NAVIGATION
   ============================================================================ */

/* App Wrapper - Flex container for sidebar + main content */
.app-wrapper {
  display: flex;
  min-height: 100vh;
  background-color: var(--color-bg);
}

/* Sidebar Container */
.sidebar {
  width: var(--sidebar-width);
  background-color: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  box-shadow: 2px 0 12px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  transition: transform var(--transition-base);
}

/* Scrollbar styling for sidebar */
.sidebar::-webkit-scrollbar {
  width: 6px;
}

.sidebar::-webkit-scrollbar-track {
  background: var(--sidebar-bg-darker);
}

.sidebar::-webkit-scrollbar-thumb {
  background: var(--sidebar-border);
  border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Sidebar Brand/Logo */
.sidebar-brand {
  padding: var(--space-xl) var(--space-lg);
  border-bottom: 1px solid var(--sidebar-border);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.sidebar-brand i {
  font-size: var(--font-size-2xl);
  color: #1d4ed8;
}

.sidebar-brand-text {
  font-weight: 700;
  font-size: var(--font-size-base);
  color: var(--sidebar-text);
  line-height: 1.3;
}

/* Sidebar Navigation */
.sidebar-nav {
  flex: 1;
  padding: var(--space-lg) 0;
}

.sidebar-menu {
  list-style: none;
  padding: 0;
  margin: 0;
}

/* Sidebar Menu Item */
.sidebar-item {
  margin-bottom: var(--space-xs);
  padding: 0 var(--space-md);
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  color: var(--sidebar-text-muted);
  text-decoration: none;
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  font-weight: 500;
  transition: all var(--transition-base);
  cursor: pointer;
  position: relative;
}

.sidebar-link i {
  font-size: var(--font-size-lg);
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-link span {
  flex: 1;
}

.sidebar-link:hover {
  color: var(--sidebar-text);
  background-color: var(--sidebar-hover-bg);
}

.sidebar-link.active {
  color: #1d4ed8;
  background-color: var(--sidebar-active-bg);
  font-weight: 600;
}

/* Toggle icon for submenu */
.toggle-icon {
  font-size: var(--font-size-sm);
  transition: transform var(--transition-base);
  margin-left: auto;
}

.sidebar-link.expanded .toggle-icon {
  transform: rotate(180deg);
}

/* Submenu */
.sidebar-submenu {
  list-style: none;
  padding: 0;
  margin: 0;
  max-height: 0;
  overflow: hidden;
  transition: max-height var(--transition-slow);
  background-color: var(--sidebar-submenu-bg);
  border-radius: var(--radius-md);
  margin-top: var(--space-xs);
}

.sidebar-submenu.expanded {
  max-height: 1000px;
  padding: var(--space-xs) 0;
}

.sidebar-submenu li {
  padding: 0;
}

.sidebar-submenu a {
  display: flex;
  align-items: center;
  padding: var(--space-sm) var(--space-lg) var(--space-sm) calc(var(--space-lg) + 32px);
  color: var(--sidebar-text-muted);
  text-decoration: none;
  font-size: var(--font-size-sm);
  transition: all var(--transition-fast);
  border-radius: var(--radius-sm);
}

.sidebar-submenu a:hover {
  color: var(--sidebar-text);
  background-color: var(--sidebar-hover-bg);
  padding-left: calc(var(--space-lg) + 36px);
}

.sidebar-submenu a.active {
  color: #1d4ed8;
  background-color: var(--sidebar-active-bg);
  border-left: 3px solid #1d4ed8;
  padding-left: calc(var(--space-lg) + 29px);
  font-weight: 600;
}

/* Main Content Area */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left var(--transition-base);
}

.content-area {
  flex: 1;
  padding: var(--space-lg);
}

/* Content Sections */
.content-section {
  display: none;
}

.content-section[style*="display: block"],
.content-section[style*="display:block"] {
  display: block !important;
}

/* Finance Subsections */
.finance-subsection {
  display: none;
}

.finance-subsection[style*="display: block"],
.finance-subsection[style*="display:block"] {
  display: block !important;
}

/* Mobile Toggle Button */
.sidebar-toggle {
  display: none;
  position: fixed;
  bottom: var(--space-lg);
  right: var(--space-lg);
  width: 56px;
  height: 56px;
  background-color: #1d4ed8;
  color: white;
  border: none;
  border-radius: 50%;
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  z-index: 999;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-xl);
  transition: all var(--transition-base);
}

.sidebar-toggle:hover {
  transform: scale(1.1);
  box-shadow: var(--shadow-xl);
}

/* Overlay for mobile when sidebar is open */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 999;
  opacity: 0;
  transition: opacity var(--transition-base);
}

.sidebar-overlay.active {
  opacity: 1;
}

/* ============================================================================
   14. RESPONSIVE - SIDEBAR
   ============================================================================ */

/* Tablet */
@media (max-width: 1024px) {
  :root {
    --sidebar-width: 220px;
  }

  .sidebar-brand {
    padding: var(--space-lg) var(--space-md);
  }

  .sidebar-item {
    padding: 0 var(--space-sm);
  }

  .sidebar-link {
    padding: var(--space-sm) var(--space-md);
    gap: var(--space-sm);
  }
}

/* Mobile */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

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

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

  .sidebar-toggle {
    display: flex;
  }

  .sidebar-overlay {
    display: block;
  }
}

/* Hide old tabs on mobile when sidebar is active */
@media (max-width: 768px) {
  .nav-tabs {
    display: none;
  }
}

/* ============================================================================
   15. RESPONSIVE (Original)
   ============================================================================ */

@media (max-width: 768px) {
  .nav-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .nav-tabs .nav-link {
    white-space: nowrap;
    padding: var(--space-sm) var(--space-md);
  }

  .nav-pills {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .nav-pills .nav-link {
    white-space: nowrap;
  }

  .card-header {
    padding: var(--space-md) var(--space-lg);
    font-size: var(--font-size-base);
  }

  .card-body {
    padding: var(--space-lg);
  }

  .modal-body {
    padding: var(--space-lg);
  }

  .table {
    font-size: var(--font-size-xs);
  }

  .table thead th,
  .table tbody td {
    padding: var(--space-sm);
  }
}

/* ============================================================================
   14. ANIMATIONS
   ============================================================================ */

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

.fade-in {
  animation: fadeIn var(--transition-base);
}

/* ============================================================================
   15. ACCESSIBILITY
   ============================================================================ */

:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ============================================================================
   Task Name Link (Clickable task names in table)
   ============================================================================ */
/* Tasks table layout */
.tasks-table {
  table-layout: fixed;
  width: 100%;
}

.tasks-table .th-id { width: 6%; }
.tasks-table .th-name { width: auto; }
.tasks-table .th-status { width: 13%; text-align: center; }
.tasks-table .th-hours { width: 8%; text-align: center; }
.tasks-table .th-date { width: 10%; text-align: center; }
.tasks-table .th-date-created { width: 13%; text-align: center; }
.tasks-table .th-actions { width: 5%; text-align: center; }

/* Task table cell alignment */
.tasks-table td.text-center {
  text-align: center;
  vertical-align: middle;
}

.tasks-table .status-cell,
.tasks-table .hours-cell,
.tasks-table .date-created-cell,
.tasks-table .actions-cell {
  text-align: center;
  vertical-align: middle;
}

/* Task type under status badge */
.tasks-table .status-cell small {
  font-size: 11px;
  line-height: 1.2;
  color: var(--color-text-muted);
  margin-top: 4px;
}

.tasks-table .hours-cell .badge {
  white-space: nowrap;
  min-width: 45px;
}

/* Date cell with 2 lines (date + time) */
.tasks-table .date-cell {
  line-height: 1.3;
  text-align: center;
}

.tasks-table .date-cell .date-line {
  display: block;
  font-weight: 500;
  color: var(--color-text);
}

.tasks-table .date-cell .time-line {
  display: block;
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.tasks-table .task-id-cell {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tasks-table .task-name-cell {
  max-width: 0;
}

.tasks-table .task-name-cell .task-name-link {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: var(--font-size-sm);
  line-height: 1.4;
}

.task-name-link {
  color: var(--color-text);
  cursor: pointer;
  transition: color 0.2s ease;
}

.task-name-link:hover {
  color: var(--color-primary);
  text-decoration: underline !important;
}

/* ============================================================================
   Stats Dashboard (Task Statistics Cards)
   ============================================================================ */

.stats-filters {
  padding: var(--space-sm) var(--space-md);
  background: var(--color-bg-alt);
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border-light);
}

.stats-filters .form-control,
.stats-filters .form-select {
  background: var(--color-surface);
}

.stat-card {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  box-shadow: var(--shadow-sm);
  border-left: 4px solid var(--color-primary);
  transition: all var(--transition-fast);
  height: 100%;
}

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

.stat-card-total {
  border-left-color: var(--color-primary);
}

.stat-card-open {
  border-left-color: var(--color-success);
}

.stat-card-closed {
  border-left-color: var(--color-info);
}

.stat-card-hours {
  border-left-color: var(--color-warning);
}

.stat-value {
  font-size: var(--font-size-2xl);
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.2;
}

.stat-label {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: var(--space-xs);
}

.stat-breakdown {
  font-size: 11px;
  color: var(--color-text-muted);
  margin-top: var(--space-sm);
  line-height: 1.5;
  max-height: 60px;
  overflow-y: auto;
}

.stat-breakdown-item {
  display: block;
  white-space: nowrap;
  padding: 1px 0;
}

/* Task types multi-select dropdown */
.task-types-dropdown {
  min-width: 200px;
  max-height: 250px;
  overflow-y: auto;
}

.task-types-dropdown .form-check {
  padding: var(--space-xs) var(--space-sm);
  margin: 0;
  border-radius: var(--radius-sm);
}

.task-types-dropdown .form-check:hover {
  background: var(--color-bg-alt);
}

.task-types-dropdown .form-check-label {
  font-size: var(--font-size-sm);
  cursor: pointer;
  width: 100%;
}
/* ============================================================================
   COMPACT DESIGN COMPONENTS
   ============================================================================ */

/* ========================================
   Dot Status Indicator
   ======================================== */
.status-dot {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--font-size-xs);
  font-weight: 500;
  line-height: 1;
}

.status-dot .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-dot-success .dot { background-color: var(--color-success); }
.status-dot-success .label { color: #065F46; }

.status-dot-danger .dot { background-color: var(--color-danger); }
.status-dot-danger .label { color: #991B1B; }

.status-dot-secondary .dot { background-color: #94A3B8; }
.status-dot-secondary .label { color: #64748B; }

.status-dot-info .dot { background-color: var(--color-info); }
.status-dot-info .label { color: #1E40AF; }

/* ========================================
   Kebab Menu
   ======================================== */
.kebab-menu {
  position: relative;
  display: inline-block;
}

.kebab-btn {
  background: transparent;
  border: none;
  padding: 4px 8px;
  color: #64748B;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
  font-size: 1.125rem;
  line-height: 1;
}

.kebab-btn:hover {
  background-color: #F1F5F9;
  color: #334155;
}

.kebab-menu .dropdown-menu {
  min-width: 180px;
  padding: 4px;
  border: var(--border-light);
  box-shadow: var(--shadow-lg);
  border-radius: var(--radius-md);
}

.kebab-menu .dropdown-item {
  padding: 6px 12px;
  font-size: var(--font-size-sm);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 8px;
}

.kebab-menu .dropdown-item i {
  font-size: 14px;
  width: 16px;
  text-align: center;
}

.kebab-menu .dropdown-item:hover {
  background-color: #F1F5F9;
}

/* ========================================
   Inline Metrics Bar
   ======================================== */
.metrics-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 10px 16px;
  background-color: #F8FAFC;
  border-radius: var(--radius-md);
  border: var(--border-light);
  margin-bottom: 16px;
}

.metric-item {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  font-size: 0.8125rem;
}

.metric-label {
  color: #64748B;
  font-weight: 500;
}

.metric-value {
  font-weight: 700;
  font-size: 1rem;
  color: #1E293B;
}

.metric-value-primary { color: #1E3A8A; }
.metric-value-success { color: #10B981; }
.metric-value-danger { color: #EF4444; }
.metric-value-info { color: #0EA5E9; }
.metric-value-warning { color: #F59E0B; }
.metric-value-secondary { color: #6B7280; }

.metric-secondary {
  font-size: 0.8125rem;
  color: #64748B;
  font-weight: 500;
}

.metrics-divider {
  color: #CBD5E1;
  font-weight: 300;
}

/* ========================================
   Compact Table
   ======================================== */
.table-compact thead th {
  padding: 6px 12px !important;
  font-size: 0.75rem !important;
  font-weight: 600;
  line-height: 1.3;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.table-compact tbody td {
  padding: 8px 12px !important;
  font-size: 0.8125rem !important;
  line-height: 1.4;
  vertical-align: middle;
}

.table-compact tbody tr {
  height: 44px;
}

/* ========================================
   Checkbox Selection
   ======================================== */
.task-checkbox {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: #1E3A8A;
}

.row-selected {
  background-color: #EFF6FF !important;
}

/* ========================================
   Compact Filter Bar
   ======================================== */
.filters-bar {
  display: flex;
  align-items: end;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 16px;
  background-color: white;
  border: var(--border-light);
  border-radius: var(--radius-md);
  margin-bottom: 16px;
}

.filter-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.filter-label {
  font-size: 0.75rem;
  color: #64748B;
  font-weight: 500;
  line-height: 1;
}

.filter-input,
.filter-select {
  font-size: 0.8125rem;
  padding: 6px 10px;
  border: 1px solid #D1D5DB;
  border-radius: var(--radius-sm);
  background: white;
  color: var(--color-text);
  line-height: 1.4;
}

.filter-input:focus,
.filter-select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.1);
}

.filter-btn {
  padding: 6px 12px;
  font-size: 0.8125rem;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  line-height: 1.4;
  transition: all 0.15s;
}

.filter-btn-primary {
  background-color: var(--color-primary);
  color: white;
}

.filter-btn-primary:hover {
  background-color: var(--color-primary-hover);
}

.filter-btn-secondary {
  background-color: #F3F4F6;
  color: #1F2937;
  border: 1px solid #D1D5DB;
}

.filter-btn-secondary:hover {
  background-color: #E5E7EB;
}

/* ========================================
   Bulk Delete Button
   ======================================== */
.bulk-delete-btn {
  padding: 6px 12px;
  font-size: 0.8125rem;
  border-radius: var(--radius-sm);
  border: none;
  background: #EF4444;
  color: white;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s;
}

.bulk-delete-btn:hover {
  background: #DC2626;
}

.bulk-delete-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ========================================
   Sortable Headers
   ======================================== */
.sortable-header {
  cursor: pointer;
  user-select: none;
}

.sortable-header:hover {
  background-color: #F1F5F9 !important;
}

.sort-icon {
  font-size: 0.75rem;
  color: #94A3B8;
  margin-left: 4px;
}

.sortable-header:hover .sort-icon {
  color: #64748B;
}

/* ========================================
   Utility Classes (Compact Design)
   ======================================== */

/* Компактные отступы */
.p-compact { padding: var(--card-padding-compact) !important; }
.py-compact {
  padding-top: var(--card-padding-compact) !important;
  padding-bottom: var(--card-padding-compact) !important;
}
.px-compact {
  padding-left: var(--card-padding-compact) !important;
  padding-right: var(--card-padding-compact) !important;
}

/* Микро-текст */
.text-micro {
  font-size: var(--font-size-2xs) !important;
  line-height: 1.4;
}

/* Карточка с границей (вместо тени) */
.card-bordered {
  border: var(--border-light);
  box-shadow: none !important;
  background: var(--color-surface);
}

.card-bordered:hover {
  border-color: var(--color-border);
  box-shadow: var(--shadow-sm) !important;
}

/* Компактное значение статистики */
.stat-value-compact {
  font-size: var(--font-size-xl) !important;
  font-weight: 700;
  line-height: 1;
}

.stat-label-compact {
  font-size: var(--font-size-2xs) !important;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: #64748B;
}

/* Разделители */
.divider-y {
  border-right: 1px solid var(--color-border-light);
}

.divider-x {
  border-bottom: 1px solid var(--color-border-light);
}

/* ========================================
   Bootstrap Tooltips (Custom Style)
   ======================================== */
.tooltip {
  --bs-tooltip-max-width: 320px;
  --bs-tooltip-bg: #1E293B;
  --bs-tooltip-color: #F8FAFC;
  --bs-tooltip-opacity: 1;
  font-size: 0.8125rem;
}

.tooltip-inner {
  padding: 10px 14px;
  text-align: left;
  line-height: 1.5;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.tooltip-inner strong {
  color: #93C5FD;
  display: block;
  margin-bottom: 4px;
}

.tooltip-inner em {
  color: #A5B4FC;
  font-style: normal;
}

.tooltip-inner br + br {
  display: block;
  content: "";
  margin-top: 8px;
}

/* ========================================
   Help Icons (Иконки подсказок)
   ======================================== */
.help-icon {
  color: #94A3B8 !important;
  font-size: 0.75rem !important;
  cursor: help;
  opacity: 0.7;
  transition: opacity 0.15s;
  margin-left: 4px;
}

.help-icon:hover {
  opacity: 1;
}
