/* =============================================
   АСУБ CRM Demo — styles mirroring main CRM
   ============================================= */

:root {
  --bg-main: #E7F7FF;
  --bg-sidebar: #D2E7F6;
  --text-main: #000926;
  --card-bg: #FFFFFF;
  --card-border: rgba(0, 9, 38, 0.06);
  --border-light: rgba(0, 9, 38, 0.08);
  --primary: #2563eb;
  --primary-light: #0ea5e9;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
}

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

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  height: 100vh;
  overflow: hidden;
  padding-top: 36px;
}

/* ========== DEMO BANNER ========== */
.demo-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 36px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  font-size: 13px;
  font-weight: 500;
  z-index: 9999;
}
.demo-banner__link {
  color: white;
  text-decoration: none;
  background: rgba(255,255,255,0.2);
  padding: 3px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  transition: background 0.2s;
}
.demo-banner__link:hover { background: rgba(255,255,255,0.35); }

/* ========== LAYOUT ========== */
.app {
  display: flex;
  height: 100%;
  overflow: hidden;
}

/* ========== SIDEBAR ========== */
.sidebar {
  width: 200px;
  background-color: var(--bg-sidebar);
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  transition: width 0.3s ease;
  overflow: hidden;
  position: relative;
  flex-shrink: 0;
}
.sidebar.collapsed { width: 60px; padding: 16px 8px; }
.sidebar.collapsed .nav-item { justify-content: center; }
.sidebar.collapsed .nav-label { display: none; }
.sidebar.collapsed .sidebar-logo { justify-content: center; }
.sidebar.collapsed .toggle-text { display: none; }
.sidebar.collapsed .sidebar-ai-text { display: none; }
.sidebar.collapsed .sidebar-ai { justify-content: center; padding: 12px 8px; }

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
}
.sidebar-logo-icon {
  width: 32px;
  height: 32px;
  border-radius: 12px;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-toggle {
  width: 100%;
  padding: 10px;
  border-radius: 8px;
  background: #667eea;
  border: none;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  gap: 8px;
  transition: background 0.2s;
}
.sidebar-toggle:hover { background: #5a67d8; }
.sidebar.collapsed .sidebar-toggle { padding: 10px 0; }

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.15) transparent;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.15s;
}
.nav-item--active { background: #fff; }
.nav-item:hover { background: rgba(255,255,255,0.7); }
.nav-icon { width: 24px; height: 24px; flex-shrink: 0; }
.nav-label { font-size: 14px; }

.sidebar-ai {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 10px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 12px;
  cursor: pointer;
  color: white;
  transition: all 0.2s;
}
.sidebar-ai:hover { transform: scale(1.02); box-shadow: 0 4px 15px rgba(102,126,234,0.4); }
.sidebar-ai-icon { font-size: 20px; }
.sidebar-ai-text { font-weight: 600; font-size: 14px; white-space: nowrap; }

/* ========== MAIN ========== */
.main {
  flex: 1;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-height: 0;
  overflow-y: auto;
}

.main-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.main-title {
  font-family: 'Montserrat', system-ui, sans-serif;
  font-size: 22px;
  font-weight: 700;
}
.main-subtitle { font-size: 13px; opacity: 0.8; }

.main-grid {
  display: grid;
  grid-template-columns: 2fr 1.2fr;
  gap: 20px;
  align-items: flex-start;
}

/* ========== CARDS ========== */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.card {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 14px;
  border: 1px solid var(--card-border);
}
.card-title { font-size: 13px; margin-bottom: 6px; color: #64748b; }
.card-value { font-size: 24px; font-weight: 700; margin-bottom: 4px; }
.card-meta { font-size: 12px; opacity: 0.7; }

/* ========== SECTION ========== */
.section {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 16px;
  border: 1px solid var(--card-border);
}
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.section-title {
  font-family: 'Montserrat', system-ui, sans-serif;
  font-size: 15px;
  font-weight: 600;
}

/* ========== TABLE ========== */
.module-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.module-table th {
  text-align: left;
  padding: 10px 12px;
  background: #f8fafc;
  border-bottom: 2px solid var(--border-light);
  font-weight: 600;
  font-size: 11px;
  color: #64748b;
  text-transform: uppercase;
  white-space: nowrap;
}
.module-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}
.module-table tr:hover { background: #f0f9ff; }

/* ========== STATUS BADGES ========== */
.status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-new { background: #dbeafe; color: #1d4ed8; }
.badge-in_progress { background: #fef3c7; color: #92400e; }
.badge-qualified { background: #d1fae5; color: #065f46; }
.badge-disqualified { background: #fee2e2; color: #991b1b; }
.badge-open { background: #dbeafe; color: #1d4ed8; }
.badge-won { background: #d1fae5; color: #065f46; }
.badge-lost { background: #fee2e2; color: #991b1b; }

/* ========== BUTTONS ========== */
.btn-primary {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}
.btn-primary:hover { opacity: 0.9; }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.ai-toggle {
  padding: 8px 16px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}
.ai-toggle:hover { opacity: 0.9; }

.btn-tab {
  padding: 8px 16px;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  background: white;
  color: var(--text-main);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-tab:hover { background: #f0f9ff; }
.btn-tab.active { background: var(--primary); color: white; border-color: var(--primary); }

.btn-icon {
  padding: 6px 10px;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  background: white;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s;
}
.btn-icon:hover { background: #f0f9ff; }

/* ========== SEARCH ========== */
.search-input {
  padding: 8px 14px;
  border: 1px solid var(--border-light);
  border-radius: 10px;
  font-size: 13px;
  outline: none;
  width: 220px;
  transition: border-color 0.2s;
}
.search-input:focus { border-color: var(--primary); }

/* ========== USER INFO ========== */
.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 10px;
}
.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 13px;
  flex-shrink: 0;
}
.user-name { font-size: 14px; font-weight: 500; }

/* ========== DEALS KANBAN ========== */
.deals-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  align-items: start;
  flex: 1;
}
.deals-col {
  background: #f8fafc;
  border-radius: 16px;
  padding: 12px;
  min-height: 200px;
}
.deals-col-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  margin-bottom: 12px;
  letter-spacing: 0.05em;
}
.deals-count {
  background: white;
  border-radius: 20px;
  padding: 2px 8px;
  font-size: 12px;
  border: 1px solid var(--border-light);
}
.deals-col-body { display: flex; flex-direction: column; gap: 8px; }
.deal-card {
  background: white;
  border-radius: 12px;
  padding: 12px;
  border: 1px solid var(--card-border);
  cursor: pointer;
  transition: box-shadow 0.15s, transform 0.15s;
}
.deal-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.08); transform: translateY(-1px); }
.deal-card__title { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.deal-card__client { font-size: 12px; color: #64748b; margin-bottom: 8px; }
.deal-card__amount { font-size: 16px; font-weight: 700; color: var(--primary); }
.deal-card__date { font-size: 11px; color: #94a3b8; margin-top: 4px; }
.deal-card__actions { display: flex; gap: 6px; margin-top: 8px; }

/* ========== FUNNEL ========== */
.funnel-wrap { padding: 8px 0; }
.funnel-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.funnel-label { font-size: 13px; width: 120px; flex-shrink: 0; }
.funnel-bar-wrap { flex: 1; background: #f1f5f9; border-radius: 6px; height: 24px; overflow: hidden; }
.funnel-bar { height: 100%; border-radius: 6px; display: flex; align-items: center; padding-left: 10px; font-size: 12px; font-weight: 600; color: white; transition: width 0.6s ease; }
.funnel-count { font-size: 13px; font-weight: 600; width: 30px; text-align: right; flex-shrink: 0; }

/* ========== DASHBOARD DEAL ITEM ========== */
.dash-deal-item {
  background: #f8fafc;
  border-radius: 12px;
  padding: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid var(--border-light);
}
.dash-deal-item__left { flex: 1; }
.dash-deal-item__title { font-size: 14px; font-weight: 600; margin-bottom: 2px; }
.dash-deal-item__client { font-size: 12px; color: #64748b; }
.dash-deal-item__amount { font-size: 15px; font-weight: 700; color: var(--primary); }

/* ========== MODAL ========== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,9,38,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: 16px;
}
.modal-content {
  background: white;
  border-radius: 16px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border-light);
}
.modal-title { font-family: 'Montserrat', system-ui, sans-serif; font-size: 18px; font-weight: 700; }
.modal-close {
  font-size: 24px;
  cursor: pointer;
  color: #94a3b8;
  line-height: 1;
  background: none;
  border: none;
  padding: 0;
  flex-shrink: 0;
}
.modal-close:hover { color: var(--text-main); }
.modal-body { padding: 20px; }

/* ========== FORM ========== */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 500; }
.form-group input,
.form-group select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border-light);
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.2s;
  outline: none;
}
.form-group input:focus,
.form-group select:focus { border-color: var(--primary); }

/* ========== TOAST ========== */
.toast-container {
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 99999;
  display: flex;
  flex-direction: column-reverse;
  gap: 10px;
}
.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-radius: 12px;
  background: white;
  box-shadow: 0 10px 40px rgba(0,0,0,0.15);
  animation: toastIn 0.3s ease;
  min-width: 280px;
}
.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--danger); }
.toast.info { border-left: 4px solid var(--primary); }
.toast-title { font-weight: 600; font-size: 14px; }
.toast-message { font-size: 13px; color: #64748b; }

@keyframes toastIn {
  from { transform: translateX(-100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ========== LOCKED NAV ITEMS ========== */
.nav-item--locked {
  opacity: 0.6;
  cursor: pointer;
  position: relative;
}
.nav-item--locked:hover { opacity: 0.85; background: rgba(255,255,255,0.5); }
.lock-badge {
  margin-left: auto;
  font-size: 12px;
}

/* ========== LIMIT BAR ========== */
.demo-limit-bar {
  background: #fef3c7;
  border: 1px solid #fcd34d;
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 13px;
  color: #92400e;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}
.demo-limit-bar:empty { display: none; }
.demo-limit-bar button {
  background: #f59e0b;
  color: white;
  border: none;
  border-radius: 8px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.2s;
}
.demo-limit-bar button:hover { opacity: 0.85; }

/* ========== LOCKED BUTTON (small) ========== */
.btn-locked-sm {
  padding: 8px 14px;
  background: #f1f5f9;
  border: 1px dashed #cbd5e1;
  border-radius: 10px;
  font-size: 13px;
  color: #64748b;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-locked-sm:hover { background: #e2e8f0; color: #475569; }

/* ========== RESPONSIVE ========== */
@media (max-width: 900px) {
  .main-grid { grid-template-columns: 1fr; }
  .cards-grid { grid-template-columns: repeat(2, 1fr); }
  .deals-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
  .cards-grid { grid-template-columns: 1fr 1fr; }
  .deals-grid { grid-template-columns: 1fr; }
  .sidebar { width: 60px; padding: 16px 8px; }
  .sidebar .nav-label { display: none; }
  .sidebar .toggle-text { display: none; }
  .sidebar .sidebar-ai-text { display: none; }
  .sidebar .sidebar-logo span { display: none; }
  .main { padding: 12px; }
  .demo-banner { font-size: 11px; gap: 8px; }
  .search-input { width: 150px; }
}
