/* ===== Grizzly Lab Dashboard — Premium Dark Theme ===== */

:root {
  --bg-primary: #1E1E1E;
  --bg-surface: rgba(37, 37, 38, 0.92);
  --bg-card: rgba(30, 30, 30, 0.92);
  --bg-elevated: rgba(42, 42, 42, 0.95);
  --accent: #22c55e;
  --accent-hover: #16a34a;
  --accent-light: #4ade80;
  --accent-lighter: #86efac;
  --accent-glow: rgba(34, 197, 94, 0.15);
  --accent-glow-strong: rgba(34, 197, 94, 0.35);
  --text-primary: #F1F5F9;
  --text-secondary: #94A3B8;
  --text-muted: #64748B;
  --border: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.15);
  --danger: #ef4444;
  --warning: #f59e0b;
  --info: #3b82f6;
  --sidebar-width: 220px;
  --header-height: 56px;
  --ops-height: 36px;
  --page-body-pad: 1.5rem;
  --glass-bg: linear-gradient(145deg, rgba(37,37,38,0.95) 0%, rgba(30,30,30,0.98) 100%);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-shadow: inset 0 1px 0 rgba(255,255,255,0.03), 0 4px 20px rgba(0,0,0,0.25);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { overflow-x: hidden; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  position: relative;
  overflow-x: hidden;
  width: 100%;
}

/* ===== PARTICLE CANVAS ===== */

#particles-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

a { color: var(--accent-light); text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--accent-lighter); text-decoration: none; }

/* ===== SIDEBAR ===== */

.sidebar {
  width: var(--sidebar-width);
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-right: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
}

.sidebar-logo {
  padding: 1.25rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.logo-mark {
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  color: #fff;
  font-weight: 800;
  font-size: 0.875rem;
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
  letter-spacing: 0.05em;
  box-shadow: 0 2px 8px var(--accent-glow-strong);
}

.logo-text {
  font-weight: 700;
  font-size: 1rem;
  background: linear-gradient(90deg, var(--accent), var(--accent-light), var(--accent-lighter));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.sidebar-nav {
  list-style: none;
  padding: 0.75rem 0.5rem;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  /* тонкий скроллбар чтобы не смещать иконки */
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.sidebar-nav li { margin-bottom: 2px; }

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 0.75rem;
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.2s ease;
  text-decoration: none;
  position: relative;
}

.sidebar-nav a:hover {
  background: var(--accent-glow);
  color: var(--text-primary);
  text-decoration: none;
}

.sidebar-nav a.active {
  background: var(--accent-glow);
  color: var(--accent-light);
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--accent);
}

.sidebar-bottom {
  padding: 1rem;
  border-top: 1px solid var(--border);
}

.btn-logout {
  width: 100%;
  padding: 0.5rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-logout:hover {
  border-color: var(--danger);
  color: var(--danger);
  background: rgba(239, 68, 68, 0.08);
}

/* ===== MAIN CONTENT ===== */

.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-height: calc(100vh - var(--ops-height));
  position: relative;
  z-index: 1;
  max-width: 100%;
  overflow-x: hidden;
}

.page-header {
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  position: sticky;
  top: var(--ops-height);
  z-index: 50;
}

.page-header h1 {
  font-size: 1.125rem;
  font-weight: 700;
}

.page-body {
  padding: 1.5rem;
}

/* ===== CARDS — GLASSMORPHISM ===== */

.card {
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  padding: 1.25rem;
  box-shadow: var(--glass-shadow);
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

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

/* позволяет dropdown-ам выходить за пределы карточки */
.card--allow-overflow {
  overflow: visible !important;
}

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

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

/* ===== KPI CARDS ===== */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.kpi-card {
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  padding: 1.25rem;
  box-shadow: var(--glass-shadow);
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0;
  transition: opacity 0.3s;
}

.kpi-card:hover::before { opacity: 1; }

.kpi-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
  box-shadow: var(--glass-shadow), 0 8px 30px rgba(0,0,0,0.15);
}

.kpi-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

.kpi-value {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.2;
}

.kpi-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.kpi-accent { border-color: rgba(34, 197, 94, 0.3); }
.kpi-accent .kpi-value { color: var(--accent-light); }
.kpi-accent::before { opacity: 1; }

/* ===== TABLES ===== */

.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

th {
  text-align: left;
  padding: 0.75rem 1rem;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
}

td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  transition: background 0.15s;
}

tr:hover td { background: var(--accent-glow); }

/* ===== BADGES ===== */

.badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.badge-hot { background: rgba(239, 68, 68, 0.15); color: #ef4444; }
.badge-warm { background: rgba(245, 158, 11, 0.15); color: #f59e0b; }
.badge-cold { background: rgba(59, 130, 246, 0.15); color: #3b82f6; }
.badge-new { background: rgba(34, 197, 94, 0.15); color: var(--accent-light); }
.badge-contacted { background: rgba(59, 130, 246, 0.15); color: #3b82f6; }
.badge-in_work { background: rgba(245, 158, 11, 0.15); color: #f59e0b; }
.badge-done { background: rgba(34, 197, 94, 0.15); color: var(--accent-light); }
.badge-negotiation { background: rgba(245, 158, 11, 0.15); color: #f59e0b; }
.badge-kp_sent { background: rgba(59, 130, 246, 0.15); color: #3b82f6; }
.badge-contract { background: rgba(139, 92, 246, 0.15); color: #8b5cf6; }
.badge-paid { background: rgba(34, 197, 94, 0.15); color: var(--accent-light); }
.badge-rejected { background: rgba(239, 68, 68, 0.1); color: #f87171; }
.badge-queued { background: rgba(59, 130, 246, 0.15); color: #3b82f6; }
.badge-posted { background: rgba(34, 197, 94, 0.15); color: var(--accent-light); }
.badge-failed { background: rgba(239, 68, 68, 0.15); color: #ef4444; }

/* ===== KANBAN ===== */

.kanban {
  display: flex;
  gap: 1rem;
  overflow-x: auto;
  padding-bottom: 1rem;
  scroll-snap-type: x mandatory;
}

.kanban-col {
  min-width: 250px;
  max-width: 290px;
  flex-shrink: 0;
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  padding: 0.75rem;
  scroll-snap-align: start;
  transition: border-color 0.3s, box-shadow 0.3s;
}

.kanban-col.drag-over {
  border-color: var(--accent);
  box-shadow: 0 0 20px var(--accent-glow-strong), inset 0 0 20px var(--accent-glow);
}

.kanban-col-header {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.5rem 0.25rem;
  margin-bottom: 0.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
}

.kanban-col-total {
  font-size: 0.7rem;
  color: var(--accent-light);
  font-weight: 700;
}

.kanban-count {
  background: var(--bg-elevated);
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
  font-size: 0.7rem;
}

.kanban-cards {
  min-height: 60px;
}

.kanban-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem;
  margin-bottom: 0.5rem;
  cursor: grab;
  transition: all 0.2s ease;
  position: relative;
}

.kanban-card:active { cursor: grabbing; }

.kanban-card:hover {
  border-color: var(--border-hover);
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  transform: translateY(-1px);
}

.kanban-card-name {
  font-weight: 600;
  font-size: 0.875rem;
  margin-bottom: 0.35rem;
}

.kanban-card-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.kanban-card-amount {
  font-weight: 700;
  color: var(--accent-light);
  font-size: 0.9rem;
  margin-top: 0.35rem;
  text-shadow: 0 0 10px var(--accent-glow);
}

/* ===== SEARCH & FILTERS ===== */

.search-bar {
  position: relative;
  margin-bottom: 1rem;
}

.search-bar input {
  width: 100%;
  padding: 0.625rem 0.75rem 0.625rem 2.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-primary);
  font-size: 0.875rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-bar input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.search-bar svg {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  width: 16px;
  height: 16px;
  max-width: 16px;
  max-height: 16px;
  pointer-events: none;
  flex-shrink: 0;
}

.filter-bar {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  align-items: center;
}

.filter-chip {
  padding: 0.3rem 0.7rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 500;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.filter-chip:hover {
  border-color: var(--accent);
  color: var(--accent-light);
}

.filter-chip.active {
  background: var(--accent-glow);
  border-color: var(--accent);
  color: var(--accent-light);
}

/* ===== FUNNEL ===== */

.funnel { margin-bottom: 1.5rem; }

.funnel-step {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.2rem;
}

.funnel-dropoff {
  padding-left: 128px;
  margin-bottom: 0.15rem;
  line-height: 1;
  opacity: 0.8;
}

.funnel-label {
  width: 120px;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: right;
  flex-shrink: 0;
}

.funnel-bar-wrap {
  flex: 1;
  background: rgba(255,255,255,0.04);
  border-radius: 6px;
  height: 26px;
  overflow: hidden;
}

.funnel-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-light));
  border-radius: 6px;
  display: flex;
  align-items: center;
  padding-left: 0.5rem;
  font-size: 0.7rem;
  font-weight: 600;
  color: #fff;
  min-width: 32px;
  transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 0 8px var(--accent-glow);
}

/* ===== BUTTONS ===== */

.btn-primary {
  display: inline-block;
  padding: 0.625rem 1.25rem;
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  color: #fff;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 2px 8px var(--accent-glow-strong);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px var(--accent-glow-strong);
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.75rem;
  border-radius: 6px;
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-ghost:hover {
  border-color: var(--accent);
  color: var(--accent-light);
  background: var(--accent-glow);
}

/* ===== FORMS ===== */

.form-group { margin-bottom: 1rem; }

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

input[type="text"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="datetime-local"],
textarea,
select {
  width: 100%;
  padding: 0.625rem 0.75rem;
  background: rgba(30,30,30,0.8);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 0.875rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* ===== TABS ===== */

.tabs {
  display: flex;
  gap: 0.25rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}

.tab {
  padding: 0.625rem 1rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
}

.tab:hover { color: var(--text-primary); }
.tab.active {
  color: var(--accent-light);
  border-bottom-color: var(--accent);
}

/* ===== SECTION GRID ===== */

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }

/* ===== LOGIN PAGE ===== */

.login-page {
  justify-content: center;
  align-items: center;
  background: var(--bg-primary);
}

.login-card {
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--glass-shadow), 0 20px 60px rgba(0,0,0,0.3);
  position: relative;
  z-index: 10;
}

.login-logo {
  text-align: center;
  margin-bottom: 2rem;
}

.login-logo h2 {
  margin-top: 0.75rem;
  font-size: 1.25rem;
  background: linear-gradient(90deg, var(--accent), var(--accent-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.alert-error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #f87171;
  padding: 0.625rem 0.75rem;
  border-radius: 8px;
  font-size: 0.8rem;
  margin-bottom: 1rem;
}

/* ===== TOAST ===== */

.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  background: var(--bg-elevated);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  font-size: 0.8rem;
  color: var(--text-primary);
  animation: slideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  max-width: 320px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.3);
}

.toast-success { border-left: 3px solid var(--accent); }
.toast-error { border-left: 3px solid var(--danger); }

@keyframes slideIn {
  from { transform: translateX(100%) scale(0.95); opacity: 0; }
  to { transform: translateX(0) scale(1); opacity: 1; }
}

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

/* ===== CONTENT CARDS ===== */

.post-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  margin-bottom: 0.75rem;
  transition: border-color 0.2s;
}

.post-card:hover { border-color: var(--border-hover); }

.post-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.post-title {
  font-weight: 600;
  font-size: 0.875rem;
}

.post-preview {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.4;
  max-height: 3.5em;
  overflow: hidden;
}

.post-score {
  font-weight: 700;
  font-size: 0.8rem;
}

.score-high { color: var(--accent-light); }
.score-mid { color: var(--warning); }
.score-low { color: var(--danger); }

/* ===== CHART CONTAINER ===== */

.chart-container {
  position: relative;
  height: 300px;
}

/* ===== EMPTY STATE ===== */

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

.empty-state h3 {
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

/* ===== SECTION DIVIDERS ===== */

.divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(34,197,94,0.35) 50%, transparent);
  margin: 1.5rem 0;
}

/* ===== GLOW TEXT ===== */

.glow-text {
  text-shadow: 0 0 10px rgba(34,197,94,0.5), 0 0 20px rgba(34,197,94,0.2);
}

/* ===== ANIMATIONS ===== */

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

.animate-in {
  animation: fadeUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.kpi-grid .kpi-card:nth-child(1) { animation-delay: 0s; }
.kpi-grid .kpi-card:nth-child(2) { animation-delay: 0.05s; }
.kpi-grid .kpi-card:nth-child(3) { animation-delay: 0.1s; }
.kpi-grid .kpi-card:nth-child(4) { animation-delay: 0.15s; }

/* ===== SPARKLINES ===== */

.sparkline {
  margin-top: 0.5rem;
  height: 36px;
  opacity: 0.8;
  transition: opacity 0.2s;
}

.kpi-card:hover .sparkline { opacity: 1; }

.sparkline svg { display: block; }

.spark-dot { transition: opacity 0.15s; }
.sparkline:hover .spark-dot { opacity: 1; }

/* ===== INLINE EDIT ===== */

.inline-editable {
  cursor: pointer;
  border-bottom: 1px dashed rgba(255,255,255,0.15);
  transition: border-color 0.2s;
  padding-bottom: 1px;
}

.inline-editable:hover {
  border-color: var(--accent);
}

.inline-edit-input {
  background: var(--bg-elevated);
  border: 1px solid var(--accent);
  border-radius: 4px;
  color: var(--text-primary);
  padding: 0.2rem 0.4rem;
  font-size: inherit;
  font-weight: inherit;
  outline: none;
  width: 100%;
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* ===== DRAWER (slide-over panel) ===== */

.drawer-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.drawer-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 480px;
  max-width: 90vw;
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-left: 1px solid var(--glass-border);
  z-index: 210;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  box-shadow: -10px 0 40px rgba(0,0,0,0.3);
}

.drawer.open {
  transform: translateX(0);
}

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

.drawer-title {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-primary);
}

.drawer-close {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  font-size: 1.25rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.drawer-close:hover {
  border-color: var(--danger);
  color: var(--danger);
  background: rgba(239, 68, 68, 0.08);
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
}

.drawer-loading {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

.drawer-table {
  width: 100%;
}

.drawer-table td {
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid var(--border);
}

/* Lead row hover */
.lead-row:hover td {
  background: var(--accent-glow);
}

.lead-row td:first-child {
  color: var(--text-primary);
}

/* ===== FOCUS VISIBLE ===== */

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ===== SCROLLBAR ===== */

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* ===== REDUCED MOTION ===== */

@media (prefers-reduced-motion: reduce) {
  .kpi-card, .card, .kanban-card, .toast, .drawer, .drawer-overlay {
    animation: none !important;
    transition-duration: 0.01ms !important;
  }
}

/* ===== HAMBURGER TOGGLE ===== */

.sidebar-toggle {
  display: none;
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 300;
  width: 40px;
  height: 40px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.sidebar-toggle:hover {
  border-color: var(--accent);
  color: var(--accent-light);
}

.sidebar-toggle svg { width: 20px; height: 20px; }

.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  z-index: 100; /* блокирует клики через overlay */
  opacity: 0;
  transition: opacity 0.3s;
}

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

/* ===== RESPONSIVE ===== */

@media (max-width: 768px) {
  .sidebar-toggle { display: flex; }
  .sidebar-overlay { display: block; }

  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    width: var(--sidebar-width);
    z-index: 150;
  }
  .sidebar.open {
    transform: translateX(0);
  }

  .main-content {
    margin-left: 0;
    width: 100%;
    min-width: 0;
  }
  .page-header {
    padding: 0 1rem;
    padding-left: 3.5rem;
  }
  .page-body {
    padding: 1rem;
    max-width: 100vw;
    overflow-x: hidden;
  }

  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }

  /* Kanban — stack columns */
  .kanban {
    flex-direction: column;
    overflow-x: hidden;
  }
  .kanban-col { min-width: 100%; max-width: 100%; }

  /* Drawer full-width */
  .drawer { width: 100%; max-width: 100%; }

  /* Tables — scrollable, compact */
  table { font-size: 0.8rem; }
  th, td { padding: 0.5rem 0.5rem; }
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* Funnel — narrow labels */
  .funnel-label { width: 70px; font-size: 0.65rem; }
  .funnel-dropoff { padding-left: 78px; }
  .funnel-step { gap: 0.5rem; }

  /* Search bars — allow shrink */
  .search-bar[style*="min-width"] { min-width: 0 !important; }

  /* Toasts — full width */
  .toast-container { left: 1rem; right: 1rem; bottom: 1rem; }
  .toast { max-width: 100%; }

  /* Filter bars — wrap properly */
  .filter-bar { flex-wrap: wrap; }

  /* Hide columns on tablet */
  .hide-mobile { display: none !important; }

  /* Chart container — reduce height */
  .chart-container { height: 220px; }

  /* Touch-friendly: min tap target 44px */
  .sidebar-nav a { min-height: 44px; }
  .filter-chip { min-height: 36px; display: inline-flex; align-items: center; }
  .btn-ghost, .btn-primary { min-height: 36px; }
  .lead-row td { padding: 0.65rem 0.5rem; }

  /* Prevent content from pushing page wider */
  .page-body * { max-width: 100%; }
  img, svg, canvas, video { max-width: 100%; height: auto; }

  /* Cards with inline max-width — expand to full width on mobile */
  .card[style*="max-width"] { max-width: 100% !important; }
}

@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .page-header h1 { font-size: 1rem; }
  .page-body { padding: 0.75rem; }
  .kpi-value { font-size: 1.25rem; }

  .filter-bar { gap: 0.25rem; }
  .filter-chip { font-size: 0.65rem; padding: 0.25rem 0.5rem; }

  .card { padding: 0.75rem; border-radius: 10px; }
  .kpi-card { padding: 0.75rem; border-radius: 10px; }

  .tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .tab { font-size: 0.7rem; padding: 0.5rem 0.6rem; white-space: nowrap; }

  /* Hide columns on smallest screens */
  .hide-xs { display: none !important; }
  .hide-mobile { display: none !important; }

  /* Funnel even more compact */
  .funnel-label { width: 55px; font-size: 0.6rem; }
  .funnel-dropoff { padding-left: 63px; }
  .funnel-bar { font-size: 0.6rem; min-width: 24px; }

  /* Cards with inline max-width — handled in 768px breakpoint */

  /* Chart even smaller */
  .chart-container { height: 180px; }

  /* Form grids collapse */
  .grid-3 { grid-template-columns: 1fr !important; }

  /* Logs table — compact on smallest screens */
  .log-data-cell { max-width: 120px; }
}

/* ===== TOGGLE SWITCH ===== */

.toggle-input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  flex-shrink: 0;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.toggle-slider::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: transform 0.2s, background 0.2s;
}

.toggle-input:checked + .toggle-slider {
  background: var(--accent-glow);
  border-color: var(--accent);
}

.toggle-input:checked + .toggle-slider::after {
  transform: translateX(20px);
  background: var(--accent-light);
}

/* ===== TOAST INFO ===== */

.toast-info { border-left: 3px solid var(--info); }

/* ===== SNACKBAR (Sprint B) ===== */
.snackbar {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: var(--bg-card);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  display: flex;
  gap: 1rem;
  align-items: center;
  z-index: 9999;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  animation: snackbar-in 0.2s ease-out;
  max-width: 420px;
}
.snackbar__msg { color: var(--text-primary, #e2e8f0); font-size: 0.9rem; }
.snackbar__btn {
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
  padding: 0.25rem 0.75rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
  white-space: nowrap;
  transition: background 0.15s;
}
.snackbar__btn:hover { background: var(--accent-glow); }
@keyframes snackbar-in {
  from { transform: translateY(100%); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* ===== CONFIRM MODAL (Sprint B) ===== */
.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}
.confirm-modal {
  background: var(--bg-card);
  border: 1px solid var(--border-hover);
  border-radius: 12px;
  padding: 2rem;
  max-width: 420px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
.confirm-modal__msg {
  font-size: 1rem;
  margin-bottom: 1.5rem;
  line-height: 1.5;
  color: var(--text-primary, #e2e8f0);
}
.confirm-modal__actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
}
.confirm-modal__btn--cancel {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: border-color 0.15s;
}
.confirm-modal__btn--cancel:hover { border-color: var(--border-hover); }
.confirm-modal__btn--confirm {
  background: var(--danger);
  border: 1px solid var(--danger);
  color: white;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: opacity 0.15s;
}
.confirm-modal__btn--confirm:hover { opacity: 0.85; }
