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

/* ── Переменные ─────────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');

:root {
  --primary:        #ff6839;
  --primary-hover:  #f25b2c;
  --primary-light:  #fff3ef;
  --primary-border: #ffd5c6;

  --dark:           #2d2d2d;
  --dark-2:         #383838;
  --gray:           #949494;
  --gray-light:     #e5e7eb;
  --light:          #f8f9fa;
  --white:          #ffffff;

  --sidebar-bg:     #1e293b;
  --sidebar-hover:  #273549;
  --sidebar-active: rgba(255, 104, 57, 0.15);
  --sidebar-text:   #94a3b8;
  --sidebar-width:  260px;

  --shadow-sm:  0 1px 3px rgba(0,0,0,0.08);
  --shadow:     0 2px 8px rgba(0,0,0,0.10);
  --shadow-lg:  0 8px 24px rgba(0,0,0,0.12);

  --radius-sm:  6px;
  --radius:     10px;
  --radius-lg:  16px;

  --font:       'Poppins', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ── Reset ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 14px; }

body {
  font-family: var(--font);
  background: var(--light);
  color: var(--dark);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }

img { max-width: 100%; }

/* ── Scrollbar ──────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #cbd5e1; }

/* ════════════════════════════════════════════════════════════════════════════
   LAYOUT
══════════════════════════════════════════════════════════════════════════════*/
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform .3s ease;
}

.sidebar-logo {
  padding: 24px 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-logo-icon {
  width: 36px; height: 36px;
  background: var(--primary);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.sidebar-logo-text {
  color: var(--white);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
}

.sidebar-logo-sub {
  color: var(--sidebar-text);
  font-size: 11px;
  font-weight: 400;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
}

.nav-section {
  padding: 8px 16px 4px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #475569;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  color: var(--sidebar-text);
  font-size: 13.5px;
  font-weight: 400;
  cursor: pointer;
  transition: all .2s;
  border-radius: 0;
  position: relative;
}
button.nav-item {
  font-family: inherit;
  font-size: 13.5px;
  color: var(--sidebar-text);
}

.nav-item:hover {
  background: var(--sidebar-hover);
  color: var(--white);
}

.nav-item.active {
  background: var(--sidebar-active);
  color: var(--primary);
  font-weight: 500;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--primary);
  border-radius: 0 3px 3px 0;
}

.nav-item .nav-icon {
  font-size: 18px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.nav-badge {
  margin-left: auto;
  background: var(--primary);
  color: white;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.06);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.sidebar-avatar {
  width: 36px; height: 36px;
  background: var(--primary);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: white;
  font-weight: 600;
  font-size: 14px;
  flex-shrink: 0;
}

.sidebar-user-info { flex: 1; min-width: 0; }

.sidebar-user-name {
  color: var(--white);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  color: var(--sidebar-text);
  font-size: 11px;
}

.btn-logout {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--sidebar-text);
  font-size: 12.5px;
  font-weight: 400;
  padding: 6px 0;
  transition: color .2s;
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font);
}
.btn-logout:hover { color: #ef4444; }

/* ── Push bell ───────────────────────────────────────────────────────────── */
#push-bell {
  font-size: 16px;
  cursor: pointer;
  opacity: 0.6;
  background: none;
  border: none;
  padding: 4px;
  border-radius: 6px;
  transition: opacity .2s, background .2s;
  line-height: 1;
}
#push-bell:hover { opacity: 1; background: rgba(255,255,255,.08); }
#push-bell.push-active { opacity: 0.9; }

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

/* ── Topbar ─────────────────────────────────────────────────────────────── */
.topbar {
  background: var(--white);
  border-bottom: 1px solid var(--gray-light);
  padding: 0 28px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--dark-2);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Page content ────────────────────────────────────────────────────────── */
.page-content {
  padding: 28px;
  flex: 1;
}

/* ════════════════════════════════════════════════════════════════════════════
   CARDS
══════════════════════════════════════════════════════════════════════════════*/
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-light);
}

.card-header {
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--gray-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--dark-2);
}

.card-body {
  padding: 20px 22px;
}

/* ── Stat cards ─────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-light);
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat-icon {
  width: 48px; height: 48px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.stat-icon.orange { background: var(--primary-light); }
.stat-icon.blue   { background: #eff6ff; }
.stat-icon.green  { background: #f0fdf4; }
.stat-icon.purple { background: #faf5ff; }

.stat-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--dark-2);
  line-height: 1;
}

.stat-label {
  font-size: 12px;
  color: var(--gray);
  margin-top: 3px;
}

/* ════════════════════════════════════════════════════════════════════════════
   BUTTONS
══════════════════════════════════════════════════════════════════════════════*/
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all .2s;
  border: 1px solid transparent;
  font-family: var(--font);
  text-decoration: none;
  white-space: nowrap;
}

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

.btn-secondary {
  background: var(--white);
  color: var(--dark);
  border-color: var(--gray-light);
}
.btn-secondary:hover {
  background: var(--light);
  color: var(--dark);
}

.btn-danger {
  background: #fef2f2;
  color: #ef4444;
  border-color: #fecaca;
}
.btn-danger:hover {
  background: #fee2e2;
  color: #dc2626;
}

.btn-success {
  background: #f0fdf4;
  color: #16a34a;
  border-color: #bbf7d0;
}
.btn-success:hover {
  background: #dcfce7;
  color: #15803d;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

.btn-icon {
  padding: 7px;
  border-radius: var(--radius-sm);
}

/* ════════════════════════════════════════════════════════════════════════════
   FORMS
══════════════════════════════════════════════════════════════════════════════*/
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--dark);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--gray-light);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-family: var(--font);
  color: var(--dark);
  background: var(--white);
  transition: border-color .2s, box-shadow .2s;
  outline: none;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(255,104,57,0.12);
}

.form-control::placeholder { color: #c0c4cc; }

select.form-control { cursor: pointer; }

textarea.form-control { resize: vertical; min-height: 80px; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-hint {
  font-size: 11.5px;
  color: var(--gray);
  margin-top: 4px;
}

/* ════════════════════════════════════════════════════════════════════════════
   TABLE
══════════════════════════════════════════════════════════════════════════════*/
.table-wrapper {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

thead th {
  background: var(--light);
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--gray);
  border-bottom: 2px solid var(--gray-light);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--gray-light);
  transition: background .15s;
}

tbody tr:hover { background: #fafafa; }

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

td {
  padding: 12px 14px;
  color: var(--dark);
  vertical-align: middle;
}

.td-muted { color: var(--gray); font-size: 12.5px; }

.table-empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--gray);
}

.table-empty-icon {
  font-size: 36px;
  margin-bottom: 8px;
}

/* ════════════════════════════════════════════════════════════════════════════
   BADGES / STATUS
══════════════════════════════════════════════════════════════════════════════*/
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 500;
  white-space: nowrap;
}

.badge-new           { background: #eff6ff; color: #2563eb; }
.badge-progress      { background: #fffbeb; color: #d97706; }
.badge-docs          { background: #faf5ff; color: #7c3aed; }
.badge-review        { background: #f0f9ff; color: #0284c7; }
.badge-approved      { background: #f0fdf4; color: #16a34a; }
.badge-rejected      { background: #fef2f2; color: #dc2626; }
.badge-completed     { background: #f8fafc; color: #64748b; }

.priority-low    { color: #16a34a; }
.priority-medium { color: #d97706; }
.priority-high   { color: #dc2626; }

/* ════════════════════════════════════════════════════════════════════════════
   MODAL
══════════════════════════════════════════════════════════════════════════════*/
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(16px);
  transition: transform .25s;
}

.modal-overlay.open .modal {
  transform: translateY(0);
}

.modal-header {
  padding: 22px 24px 16px;
  border-bottom: 1px solid var(--gray-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--dark-2);
}

.modal-close {
  width: 30px; height: 30px;
  border: none;
  background: var(--light);
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  transition: background .2s;
  color: var(--gray);
}
.modal-close:hover { background: var(--gray-light); color: var(--dark); }

.modal-body { padding: 22px 24px; }

.modal-footer {
  padding: 14px 24px 20px;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* ════════════════════════════════════════════════════════════════════════════
   LOGIN PAGE
══════════════════════════════════════════════════════════════════════════════*/
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 400px;
  padding: 40px;
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo-icon {
  width: 54px; height: 54px;
  background: var(--primary);
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  margin-bottom: 12px;
}

.login-logo-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--dark-2);
}

.login-logo-sub {
  font-size: 12.5px;
  color: var(--gray);
  margin-top: 2px;
}

.login-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #dc2626;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 16px;
}

/* ════════════════════════════════════════════════════════════════════════════
   DASHBOARD SPECIFIC
══════════════════════════════════════════════════════════════════════════════*/
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 20px;
}

/* Task items */
.task-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--gray-light);
}

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

.task-check {
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 2px solid var(--gray-light);
  flex-shrink: 0;
  margin-top: 2px;
  cursor: pointer;
  transition: all .2s;
  display: flex; align-items: center; justify-content: center;
}

.task-check:hover { border-color: var(--primary); }
.task-check.done  { background: var(--primary); border-color: var(--primary); }

.task-title {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--dark);
}

.task-title.done {
  text-decoration: line-through;
  color: var(--gray);
}

.task-meta {
  font-size: 11.5px;
  color: var(--gray);
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
}

.task-priority {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

/* Filters bar */
.filters-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.filters-bar .form-control {
  width: auto;
  min-width: 140px;
}

.search-input-wrap {
  position: relative;
  flex: 1;
  max-width: 300px;
}

.search-input-wrap .search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gray);
  font-size: 14px;
}

.search-input-wrap .form-control {
  padding-left: 32px;
}

/* Application timeline */
.app-status-bar {
  display: flex;
  align-items: center;
  gap: 0;
  margin: 24px 0;
  flex-wrap: wrap;
}

.app-status-step {
  display: flex;
  align-items: center;
  font-size: 12px;
  font-weight: 500;
}

.app-status-step .step-dot {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 2px solid var(--gray-light);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px;
  background: var(--white);
  color: var(--gray);
  z-index: 1;
}

.app-status-step.active .step-dot {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

.app-status-step.done .step-dot {
  background: #f0fdf4;
  border-color: #16a34a;
  color: #16a34a;
}

.app-status-step .step-label {
  margin: 0 6px;
  color: var(--gray);
  font-size: 11.5px;
}

.app-status-step.active .step-label { color: var(--primary); font-weight: 600; }

.step-line {
  flex: 1;
  height: 2px;
  background: var(--gray-light);
  min-width: 20px;
}

/* Info grid */
.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.info-item label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray);
  font-weight: 600;
  margin-bottom: 3px;
}

.info-item span {
  font-size: 14px;
  color: var(--dark);
  font-weight: 400;
}

/* Alert / Notice */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.alert-success {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #16a34a;
}

.alert-info {
  background: var(--primary-light);
  border: 1px solid var(--primary-border);
  color: #b04822;
}

.alert-warning {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
}

/* Page header */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-header h1 {
  font-size: 20px;
  font-weight: 600;
  color: var(--dark-2);
}

/* Breadcrumb */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--gray);
  margin-bottom: 8px;
}

.breadcrumb a { color: var(--gray); }
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb .sep { color: var(--gray-light); }
.breadcrumb .current { color: var(--dark); font-weight: 500; }

/* ── Password reveal box ────────────────────────────────────────────────── */
.password-box {
  background: var(--primary-light);
  border: 1px solid var(--primary-border);
  border-radius: var(--radius);
  padding: 18px 22px;
  margin-bottom: 20px;
}

.password-box h4 {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--dark-2);
  margin-bottom: 4px;
}

.password-box p {
  font-size: 12.5px;
  color: var(--gray);
  margin-bottom: 10px;
}

.password-value {
  font-family: 'Courier New', monospace;
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: 2px;
}

/* ── Client status timeline ────────────────────────────────────────────── */
.timeline {
  position: relative;
  padding-left: 24px;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 6px; top: 6px; bottom: 6px;
  width: 2px;
  background: var(--gray-light);
}

.timeline-item {
  position: relative;
  padding-bottom: 20px;
}

.timeline-dot {
  position: absolute;
  left: -20px;
  top: 4px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--gray-light);
  border: 2px solid var(--white);
}

.timeline-dot.active { background: var(--primary); }
.timeline-dot.done   { background: #16a34a; }

.timeline-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--dark);
}

.timeline-date {
  font-size: 11.5px;
  color: var(--gray);
}

/* ── Misc ────────────────────────────────────────────────────────────────── */
.text-muted  { color: var(--gray); }
.text-primary { color: var(--primary); }
.text-sm { font-size: 12.5px; }
.fw-600 { font-weight: 600; }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.ml-auto { margin-left: auto; }

/* ════════════════════════════════════════════════════════════════════════════
   CHAT
══════════════════════════════════════════════════════════════════════════════*/
.chat-layout {
  display: flex;
  height: calc(100vh - 64px);
  overflow: hidden;
  margin: -28px;
}

/* ── Список бесед ────────────────────────────────────────────────────────── */
.chat-sidebar {
  width: 300px;
  flex-shrink: 0;
  border-right: 1px solid var(--gray-light);
  background: var(--white);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-sidebar-header {
  padding: 18px 16px 12px;
  border-bottom: 1px solid var(--gray-light);
  font-size: 14px;
  font-weight: 600;
  color: var(--dark-2);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-search {
  padding: 10px 12px;
  border-bottom: 1px solid var(--gray-light);
}

.chat-search input {
  width: 100%;
  padding: 7px 12px;
  border: 1px solid var(--gray-light);
  border-radius: 20px;
  font-size: 13px;
  font-family: var(--font);
  outline: none;
  background: var(--light);
}

.chat-search input:focus {
  border-color: var(--primary);
  background: white;
}

.chat-user-list {
  flex: 1;
  overflow-y: auto;
}

.chat-section-label {
  padding: 8px 14px 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #94a3b8;
  background: var(--light);
}

.chat-user-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  transition: background .15s;
  border-bottom: 1px solid #f1f5f9;
  text-decoration: none;
}

.chat-user-item:hover { background: var(--light); }
.chat-user-item.active { background: var(--primary-light); border-left: 3px solid var(--primary); }

.chat-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 15px;
  flex-shrink: 0;
  position: relative;
}

.chat-avatar.manager-av { background: #ede9fe; color: #7c3aed; }
.chat-avatar.client-av  { background: #e0f2fe; color: #0284c7; }
.chat-avatar.admin-av   { background: #fce7f3; color: #be185d; }

.online-dot {
  position: absolute;
  bottom: 1px; right: 1px;
  width: 10px; height: 10px;
  background: #22c55e;
  border-radius: 50%;
  border: 2px solid white;
}

.chat-user-info { flex: 1; min-width: 0; }

.chat-user-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-user-preview {
  font-size: 11.5px;
  color: var(--gray);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.chat-unread {
  background: var(--primary);
  color: white;
  font-size: 10px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 5px;
  flex-shrink: 0;
}

/* ── Окно чата ───────────────────────────────────────────────────────────── */
.chat-window {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #f8fafc;
  min-width: 0;
}

.chat-window-header {
  background: var(--white);
  border-bottom: 1px solid var(--gray-light);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-window-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--dark-2);
}

.chat-window-status {
  font-size: 11.5px;
  color: var(--gray);
  margin-top: 1px;
}

.chat-online { color: #16a34a; }

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chat-date-sep {
  text-align: center;
  font-size: 11px;
  color: var(--gray);
  margin: 12px 0 8px;
  position: relative;
}

.chat-date-sep::before, .chat-date-sep::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 30%;
  height: 1px;
  background: var(--gray-light);
}

.chat-date-sep::before { left: 0; }
.chat-date-sep::after  { right: 0; }

.chat-bubble-wrap {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin: 2px 0;
}

.chat-bubble-wrap.own {
  flex-direction: row-reverse;
}

.bubble-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600;
  flex-shrink: 0;
  background: var(--primary-light);
  color: var(--primary);
}

.chat-bubble {
  max-width: 60%;
  padding: 9px 14px;
  border-radius: 16px;
  font-size: 13.5px;
  line-height: 1.5;
  word-break: break-word;
  position: relative;
}

.chat-bubble.other {
  background: var(--white);
  color: var(--dark);
  border-radius: 4px 16px 16px 16px;
  box-shadow: var(--shadow-sm);
}

.chat-bubble.own {
  background: var(--primary);
  color: white;
  border-radius: 16px 4px 16px 16px;
}

.bubble-time {
  font-size: 10px;
  margin-top: 4px;
  opacity: 0.65;
  text-align: right;
}

.chat-bubble.own .bubble-time { color: rgba(255,255,255,0.8); }
.chat-bubble.other .bubble-time { color: var(--gray); }

/* ── Поле ввода ──────────────────────────────────────────────────────────── */
.chat-input-bar {
  background: var(--white);
  border-top: 1px solid var(--gray-light);
  padding: 14px 16px;
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

.chat-input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--gray-light);
  border-radius: 22px;
  font-size: 13.5px;
  font-family: var(--font);
  outline: none;
  resize: none;
  max-height: 120px;
  overflow-y: auto;
  transition: border-color .2s;
  line-height: 1.5;
}

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

.chat-send-btn {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: var(--primary);
  border: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  transition: background .2s, transform .15s;
}

.chat-send-btn:hover { background: var(--primary-hover); transform: scale(1.05); }
.chat-send-btn:disabled { background: var(--gray-light); cursor: default; transform: none; }

/* ── Пустое состояние чата ───────────────────────────────────────────────── */
.chat-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--gray);
  gap: 12px;
}

.chat-empty-icon { font-size: 48px; }
.chat-empty-text { font-size: 14px; }

/* ── Toast-уведомления ───────────────────────────────────────────────────── */
#crm-toast-container {
  position: fixed; bottom: 80px; right: 24px; z-index: 9999;
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.crm-toast {
  display: flex; align-items: flex-start; gap: 10px;
  background: #1e293b; color: #fff;
  padding: 12px 14px; border-radius: 10px;
  max-width: 320px; min-width: 240px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
  pointer-events: all;
  transform: translateX(120%);
  transition: transform 0.3s cubic-bezier(.4,0,.2,1);
  border-left: 3px solid var(--primary);
}
.crm-toast.toast-show { transform: translateX(0); }
.toast-icon { font-size: 17px; flex-shrink: 0; margin-top: 1px; }
.toast-content { flex: 1; min-width: 0; }
.toast-title { font-weight: 600; font-size: 13px; margin-bottom: 2px; }
.toast-body  { font-size: 12px; opacity: 0.75; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.toast-close { background: none; border: none; color: #94a3b8; cursor: pointer;
               font-size: 13px; padding: 0; flex-shrink: 0; line-height: 1; }
.toast-close:hover { color: #fff; }

/* ── Панель уведомлений ──────────────────────────────────────────────────── */
.notif-overlay {
  display: none; position: fixed; inset: 0; z-index: 1100;
  background: rgba(0,0,0,0.35);
}
.notif-overlay.open { display: block; }

.notif-panel {
  position: fixed; top: 0; right: -420px; width: 400px; max-width: 95vw;
  height: 100vh; z-index: 1101; background: #fff;
  box-shadow: -4px 0 32px rgba(0,0,0,0.15);
  display: flex; flex-direction: column;
  transition: right 0.28s cubic-bezier(.4,0,.2,1);
}
.notif-panel.open { right: 0; }

.notif-panel-header {
  display: flex; align-items: center; gap: 8px;
  padding: 16px 20px; border-bottom: 1px solid var(--gray-light);
  flex-shrink: 0;
}
.notif-panel-header h3 {
  flex: 1; margin: 0; font-size: 16px; font-weight: 700; color: var(--dark);
}
.notif-panel-body {
  flex: 1; overflow-y: auto; padding: 8px 0;
}
.notif-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 20px; cursor: pointer;
  border-bottom: 1px solid var(--gray-light);
  transition: background 0.12s;
}
.notif-item:hover { background: var(--light); }
.notif-item.unread { background: var(--primary-light); }
.notif-item.unread:hover { background: #fde8df; }
.notif-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--primary); flex-shrink: 0; margin-top: 5px;
}
.notif-item.read .notif-dot { background: transparent; }
.notif-item-content { flex: 1; min-width: 0; }
.notif-item-title { font-size: 13px; font-weight: 600; color: var(--dark); margin-bottom: 2px; }
.notif-item-body  { font-size: 12px; color: var(--gray); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.notif-item-time  { font-size: 11px; color: var(--gray); margin-top: 3px; }
.notif-empty {
  padding: 48px 20px; text-align: center;
  color: var(--gray); font-size: 14px;
}
.nav-badge {
  margin-left: auto; background: var(--primary); color: #fff;
  font-size: 10px; font-weight: 700; border-radius: 10px;
  padding: 1px 6px; min-width: 18px; text-align: center; line-height: 16px;
}

/* ── EIS Card ───────────────────────────────────────────────────────────────── */
.eis-card {
  background: #f0fdf4; border: 1px solid #86efac; border-radius: 10px;
  padding: 12px 14px; margin-bottom: 4px; font-size: 13px;
}
.eis-card.eis-error {
  background: #fef2f2; border-color: #fca5a5; color: #b91c1c;
}
.eis-card-header {
  display: flex; align-items: center; gap: 8px;
  font-weight: 600; color: #15803d; margin-bottom: 8px; font-size: 13px;
}
.eis-card-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px 16px;
}
.eis-row label { color: var(--gray); font-size: 11px; display: block; }
.eis-row span  { color: var(--dark); font-weight: 500; }
