:root {
  --bg-primary: #0b0f19;
  --bg-secondary: #111827;
  --bg-card: rgba(17, 24, 39, 0.75);
  --bg-card-hover: rgba(24, 34, 53, 0.85);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-color-glow: rgba(59, 130, 246, 0.4);
  
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --text-dim: #6b7280;
  
  --primary: #3b82f6;
  --primary-glow: rgba(59, 130, 246, 0.25);
  --accent-emerald: #10b981;
  --accent-emerald-glow: rgba(16, 185, 129, 0.2);
  --accent-amber: #f59e0b;
  --accent-amber-glow: rgba(245, 158, 11, 0.2);
  --accent-indigo: #6366f1;
  --accent-rose: #f43f5e;
  
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --shadow-card: 0 10px 25px -5px rgba(0, 0, 0, 0.4), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
  --shadow-glow: 0 0 20px -3px var(--primary-glow);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

/* Background Ambient Orbs */
body::before, body::after {
  content: '';
  position: fixed;
  width: 500px;
  height: 500px;
  border-radius: 50%;
  filter: blur(140px);
  z-index: -1;
  pointer-events: none;
  opacity: 0.25;
}

body::before {
  top: -150px;
  left: 10%;
  background: radial-gradient(circle, #2563eb, transparent);
}

body::after {
  bottom: -150px;
  right: 5%;
  background: radial-gradient(circle, #7c3aed, transparent);
}

/* Header Navbar */
.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 40px;
  border-bottom: 1px solid var(--border-color);
  background: rgba(11, 15, 25, 0.85);
  backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 50;
}

.brand-wrap {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-icon {
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
}

.brand-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #fff;
}

.brand-badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  background: rgba(59, 130, 246, 0.15);
  border: 1px solid rgba(59, 130, 246, 0.3);
  color: #60a5fa;
  margin-left: 8px;
  vertical-align: middle;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.date-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  color: var(--text-muted);
}

.date-picker-input {
  background: transparent;
  border: none;
  color: var(--text-main);
  font-family: inherit;
  font-weight: 600;
  font-size: 0.88rem;
  outline: none;
  cursor: pointer;
}

/* Container */
.main-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 32px 24px 60px;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

/* Glassmorphism Card */
.glass-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-card);
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.glass-card:hover {
  border-color: rgba(255, 255, 255, 0.14);
}

/* Hero KPI Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.kpi-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
}

.kpi-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.kpi-title {
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.kpi-icon-pill {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.kpi-value {
  font-family: 'Outfit', sans-serif;
  font-size: 1.95rem;
  font-weight: 700;
  line-height: 1.1;
  color: #fff;
}

.kpi-subtext {
  font-size: 0.8rem;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 6px;
}

.kpi-subtext strong {
  color: var(--text-muted);
}

/* KPI Variant Accents */
.kpi-card.cpl .kpi-icon-pill { background: rgba(16, 185, 129, 0.15); color: #34d399; }
.kpi-card.cpl .kpi-value { color: #34d399; }

.kpi-card.month-cpl .kpi-icon-pill { background: rgba(99, 102, 241, 0.18); color: #818cf8; }
.kpi-card.month-cpl .kpi-value { color: #818cf8; }

.kpi-card.month-leads .kpi-icon-pill { background: rgba(14, 165, 233, 0.18); color: #38bdf8; }
.kpi-card.month-leads .kpi-value { color: #38bdf8; }

.kpi-card.day-cost .kpi-icon-pill { background: rgba(59, 130, 246, 0.15); color: #60a5fa; }
.kpi-card.day-cost .kpi-value { color: #60a5fa; }

.kpi-card.month-cost .kpi-icon-pill { background: rgba(139, 92, 246, 0.15); color: #a78bfa; }
.kpi-card.month-cost .kpi-value { color: #a78bfa; }

.kpi-card.leads .kpi-icon-pill { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }
.kpi-card.leads .kpi-value { color: #fbbf24; }

/* Section Header */
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.section-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.25rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Two-column Layout for Breakdown & Management */
.content-grid-2 {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 24px;
}

@media (max-width: 1024px) {
  .content-grid-2 {
    grid-template-columns: 1fr;
  }
}

/* Breakdown List */
.breakdown-group {
  margin-bottom: 20px;
}

.breakdown-group-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.breakdown-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  font-size: 0.88rem;
  transition: var(--transition);
}

.breakdown-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.breakdown-item-name {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-main);
}

.breakdown-item-val {
  font-family: 'Outfit', sans-serif;
  font-weight: 600;
  color: #fff;
}

.badge-tag {
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid transparent;
  outline: none;
}

.btn-primary {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}

.btn-primary:hover {
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.5);
  transform: translateY(-1px);
}

.btn-telegram {
  background: linear-gradient(135deg, #0284c7, #0369a1);
  color: #fff;
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.35);
}

.btn-telegram:hover {
  box-shadow: 0 6px 18px rgba(2, 132, 199, 0.5);
  transform: translateY(-1px);
}

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

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
}

.btn-danger-sm {
  background: rgba(244, 63, 94, 0.15);
  color: #fb7185;
  border: 1px solid rgba(244, 63, 94, 0.3);
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 0.78rem;
  cursor: pointer;
}

.btn-danger-sm:hover {
  background: rgba(244, 63, 94, 0.3);
}

/* Expenses Table */
.expenses-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.expenses-table th {
  text-align: left;
  padding: 10px 14px;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border-color);
}

.expenses-table td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.expenses-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: var(--transition);
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 480px;
  padding: 28px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
  transform: scale(0.95);
  transition: var(--transition);
}

.modal-overlay.active .modal-content {
  transform: scale(1);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.modal-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.2rem;
  font-weight: 600;
}

.close-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 1.2rem;
}

.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  padding: 10px 14px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: #fff;
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
  transition: var(--transition);
}

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

.checkbox-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

.checkbox-wrap input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  padding: 14px 20px;
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.88rem;
  animation: slideIn 0.3s ease;
}

.toast.success { border-color: rgba(16, 185, 129, 0.4); color: #34d399; }
.toast.error { border-color: rgba(244, 63, 94, 0.4); color: #fb7185; }

@keyframes slideIn {
  from { transform: translateX(50px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Telegram Preview Box */
.tg-preview {
  background: #182232;
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: var(--radius-md);
  padding: 18px;
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.82rem;
  white-space: pre-wrap;
  color: #e2e8f0;
  line-height: 1.4;
  max-height: 420px;
  overflow-y: auto;
}

/* ========================================================
   TAB 2: MARKETING METRICS & SPREADSHEET STYLES
   ======================================================== */

/* Nav Tabs in Header */
.nav-tabs {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  padding: 4px;
  border-radius: 12px;
  gap: 4px;
}

.nav-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  background: transparent;
  border: none;
  border-radius: 9px;
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}

.nav-tab-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
}

.nav-tab-btn.active {
  color: #ffffff;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.3), rgba(124, 58, 237, 0.3));
  border: 1px solid rgba(59, 130, 246, 0.4);
  box-shadow: 0 2px 10px rgba(37, 99, 235, 0.25);
  font-weight: 600;
}

/* Filter Toolbar */
.filter-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 22px;
  margin-bottom: 24px;
  background: rgba(17, 24, 39, 0.7);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
}

.preset-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.preset-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 0.84rem;
  cursor: pointer;
  transition: var(--transition);
}

.preset-btn:hover {
  background: rgba(255, 255, 255, 0.09);
  color: var(--text-main);
}

.preset-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 0 12px var(--primary-glow);
}

.date-range-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.range-input {
  background: rgba(31, 41, 55, 0.9);
  border: 1px solid var(--border-color);
  color: #fff;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 0.84rem;
  outline: none;
}

.range-input:focus {
  border-color: var(--primary);
}

/* Save Batch Floating Indicator */
.save-batch-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.3);
  transition: var(--transition);
}

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

/* Spreadsheet Tables */
.spreadsheet-section {
  margin-bottom: 30px;
}

.spreadsheet-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: rgba(11, 15, 25, 0.6);
  position: relative;
  max-width: 100%;
}

.spreadsheet-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.84rem;
}

.spreadsheet-table th,
.spreadsheet-table td {
  padding: 9px 12px;
  text-align: right;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  border-right: 1px solid rgba(255, 255, 255, 0.05);
  white-space: nowrap;
}

.spreadsheet-table th {
  background: rgba(24, 34, 53, 0.95);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  position: sticky;
  top: 0;
  z-index: 2;
}

/* Sticky First Column (Metric Name) */
.col-metric-name {
  text-align: left !important;
  font-weight: 600;
  color: #e5e7eb;
  min-width: 260px;
  max-width: 320px;
  position: sticky;
  left: 0;
  z-index: 3;
  background: #121826 !important;
  border-right: 2px solid rgba(255, 255, 255, 0.1) !important;
}

/* Sticky Second Column (Summary Period) */
.col-metric-total {
  min-width: 110px;
  font-weight: 700;
  color: #38bdf8;
  background: rgba(30, 41, 59, 0.6) !important;
  border-right: 2px solid rgba(255, 255, 255, 0.08) !important;
  font-family: 'Outfit', sans-serif;
}

.col-metric-avg {
  min-width: 100px;
  color: #94a3b8;
  background: rgba(30, 41, 59, 0.4) !important;
  border-right: 2px solid rgba(255, 255, 255, 0.08) !important;
  font-family: 'Outfit', sans-serif;
}

/* Cell Types */
.calc-cell {
  background: rgba(255, 255, 255, 0.02);
  color: #a5b4fc;
  font-weight: 500;
  font-family: 'Outfit', sans-serif;
}

.api-cell {
  color: #e2e8f0;
  font-family: 'Outfit', sans-serif;
}

.manual-input-cell {
  padding: 3px 6px !important;
  background: rgba(255, 255, 255, 0.015);
}

.cell-input {
  width: 100%;
  min-width: 75px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  color: #fff;
  text-align: right;
  padding: 4px 6px;
  font-family: 'Outfit', sans-serif;
  font-size: 0.84rem;
  transition: var(--transition);
}

.cell-input:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.15);
}

.cell-input:focus {
  background: rgba(31, 41, 55, 0.95);
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 6px var(--primary-glow);
}

.cell-input.modified {
  border-color: #f59e0b;
  background: rgba(245, 158, 11, 0.1);
}

/* Rejection Classifiers Grid */
.rejection-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 20px;
  margin-top: 14px;
}

.rejection-card {
  background: rgba(17, 24, 39, 0.7);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 18px;
}

.rejection-list {
  list-style: none;
  margin-top: 12px;
}

.rejection-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  font-size: 0.85rem;
}

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

.rejection-item .count-badge {
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.85rem;
}

.badge-target-reject {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
}

.badge-junk {
  background: rgba(244, 63, 94, 0.15);
  color: #fb7185;
}

/* Tab 2 KPI cards */
.kpi-card-tab2 {
  padding: 16px 20px;
}

/* ========================================================
   TAB 3: PAYROLL (ФОТ) & ADJUSTMENTS STYLES
   ======================================================== */

.dmitry-adjustment-card {
  border: 1px solid rgba(96, 165, 250, 0.25) !important;
  background: radial-gradient(circle at top right, rgba(59, 130, 246, 0.06), transparent 70%), var(--card-bg) !important;
}

.payroll-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.88rem;
}

.payroll-table th {
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-dim);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.payroll-table td {
  padding: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  vertical-align: middle;
  color: var(--text-main);
  transition: background 0.15s ease;
}

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

.payroll-table .emp-name {
  font-weight: 600;
  color: #ffffff;
  font-size: 0.95rem;
  display: block;
}

.payroll-table .emp-role {
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-top: 2px;
  display: block;
}

.payroll-table .num-cell {
  font-family: 'Outfit', sans-serif;
  font-weight: 600;
  font-size: 0.95rem;
}

.payroll-table tfoot tr td {
  padding: 18px 16px;
  background: rgba(59, 130, 246, 0.08);
  border-top: 2px solid rgba(59, 130, 246, 0.3);
  border-bottom: none;
  font-weight: 700;
  color: #ffffff;
}

.payroll-table tfoot .num-cell {
  font-size: 1.08rem;
}

.btn-icon-sm {
  transition: background 0.2s, transform 0.1s;
}

.btn-icon-sm:hover {
  background: rgba(255, 255, 255, 0.1) !important;
  transform: scale(1.1);
}

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

.spinning {
  display: inline-block;
  animation: spin 1s linear infinite;
}
