:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #eff6ff;
  --primary-ring: rgba(37, 99, 235, 0.12);
  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-hover: #f8fafc;
  --border: #e5e7eb;
  --border-light: #f1f5f9;
  --text: #0f172a;
  --muted: #64748b;
  --danger: #dc2626;
  --danger-dark: #b91c1c;
  --green: #15803d;
  --green-light: #dcfce7;
  --amber: #b45309;
  --amber-light: #fef3c7;
  --red-light: #fee2e2;
  --blue-light: #dbeafe;
  --gray-light: #f1f5f9;
  --wa: #128c7e;
  --wa-dark: #0e7268;
  --call: #16a34a;
  --call-dark: #15803d;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.06), 0 2px 4px rgba(15, 23, 42, 0.04);
}

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

html,
body {
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

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

/* ============ layout ============ */

.layout {
  display: flex;
  min-height: 100vh;
}

/* ---------- sidebar ---------- */

.sidebar {
  width: 252px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  z-index: 30;
}

.sidebar-brand {
  height: 64px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 22px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-brand .logo {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 16px;
}

.sidebar-brand .logo-text {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.3px;
  color: var(--text);
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-section {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding: 14px 12px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-weight: 500;
  min-height: 44px;
  transition: background 0.12s, color 0.12s;
}

.nav-item:hover {
  background: var(--surface-hover);
}

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

.nav-item .nav-icon {
  width: 20px;
  text-align: center;
  font-size: 16px;
}

.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  background: var(--surface);
}

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

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

.sidebar-user-name {
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.icon-btn {
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--muted);
  font-size: 15px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.12s, border-color 0.12s;
  flex-shrink: 0;
}

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

/* burger + mobile drawer backdrop */

.burger {
  display: none;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 25;
}

.sidebar-backdrop.open {
  display: block;
}

/* ---------- main ---------- */

.main {
  flex: 1;
  margin-left: 252px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
}

.topbar {
  height: 64px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-title {
  font-size: 18px;
  font-weight: 700;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.bell {
  position: relative;
  display: inline-flex;
}

.bell-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.content {
  padding: 28px;
  width: 100%;
  max-width: 1320px;
  margin: 0 auto;
}

/* ============ buttons ============ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  min-height: 42px;
  transition: background 0.12s, box-shadow 0.12s, transform 0.05s, color 0.12s;
  text-decoration: none;
  background: transparent;
  line-height: 1.2;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

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

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover {
  background: var(--danger-dark);
}

.btn-ghost {
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.btn-block {
  width: 100%;
}

.btn-sm {
  padding: 7px 12px;
  font-size: 13px;
  min-height: 36px;
}

.btn-lg {
  padding: 12px 22px;
  font-size: 15px;
}

/* contact buttons */

.btn-call {
  background: var(--call);
  color: #fff;
}

.btn-call:hover {
  background: var(--call-dark);
}

.btn-wa {
  background: var(--wa);
  color: #fff;
}

.btn-wa:hover {
  background: var(--wa-dark);
}

.btn-icon {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  flex-shrink: 0;
  transition: color 0.12s, border-color 0.12s, transform 0.05s;
}

.btn-icon:active {
  transform: translateY(1px);
}

.btn-icon.btn-call {
  color: var(--call);
  border-color: #bbf7d0;
  background: #f0fdf4;
}

.btn-icon.btn-call:hover {
  border-color: var(--call);
}

.btn-icon.btn-wa {
  color: var(--wa);
  border-color: #a7f3d0;
  background: #ecfdf5;
}

.btn-icon.btn-wa:hover {
  border-color: var(--wa);
}

.btn-icon.btn-copy:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.btn-icon svg {
  display: block;
}

/* phone actions */

.phone-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.ph-num {
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.ph-link {
  color: var(--primary);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
  word-break: break-word;
}

/* ============ badges ============ */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.badge-active { background: var(--blue-light); color: var(--primary-dark); }
.badge-waiting { background: var(--amber-light); color: var(--amber); }
.badge-closed { background: var(--gray-light); color: var(--muted); }
.badge-contract { background: var(--green-light); color: var(--green); }
.badge-pending { background: var(--gray-light); color: var(--muted); }
.badge-meeting { background: #cffafe; color: #0e7490; }
.badge-hot { background: #fee2e2; color: #dc2626; }
.badge-medium { background: #fff7ed; color: #ea580c; }
.badge-cold { background: #fef9c3; color: #ca8a04; }

/* row background by status */
.table tbody tr.row-closed { background: #fff; }
.table tbody tr.row-closed:hover { background: #f8fafc; }
.table tbody tr.row-contract { background: #bbf7d0; }
.table tbody tr.row-contract:hover { background: #86efac; }
.table tbody tr.row-meeting { background: #a5f3fc; }
.table tbody tr.row-meeting:hover { background: #67e8f9; }
.table tbody tr.row-hot { background: #fca5a5; }
.table tbody tr.row-hot:hover { background: #f87171; }
.table tbody tr.row-medium { background: #fdba74; }
.table tbody tr.row-medium:hover { background: #fb923c; }
.table tbody tr.row-cold { background: #fef08a; }
.table tbody tr.row-cold:hover { background: #fde047; }
.table tbody tr.row-active { background: #bfdbfe; }
.table tbody tr.row-active:hover { background: #93c5fd; }
.table tbody tr.row-pending { background: #e2e8f0; }
.table tbody tr.row-pending:hover { background: #cbd5e1; }

.stat-icon.purple { background: #ede9fe; }

/* ============ cards ============ */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
}

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

.card-header h3 {
  font-size: 15px;
  font-weight: 700;
}

.card-body {
  padding: 20px;
}

.card-body.pad0 {
  padding: 0;
}

.card-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.empty-state {
  padding: 40px 20px;
  text-align: center;
  color: var(--muted);
}

.empty-state .empty-icon {
  font-size: 34px;
  margin-bottom: 10px;
  display: block;
}

.empty-state p {
  margin-top: 4px;
}

/* ============ stats ============ */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.12s, box-shadow 0.12s, transform 0.12s;
}

a.stat-card {
  color: var(--text);
}

a.stat-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.stat-icon {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.stat-icon.blue { background: var(--primary-light); }
.stat-icon.green { background: var(--green-light); }
.stat-icon.amber { background: var(--amber-light); }
.stat-icon.red { background: var(--red-light); }
.stat-icon.gray { background: var(--gray-light); }

.stat-info {
  min-width: 0;
}

.stat-num {
  font-size: 24px;
  font-weight: 800;
  line-height: 1.1;
}

.stat-label {
  color: var(--muted);
  font-size: 13px;
}

/* ============ tabs ============ */

.tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.tab {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-weight: 600;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  transition: border-color 0.12s, color 0.12s, background 0.12s;
}

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

.tab.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.tab-count {
  background: rgba(0, 0, 0, 0.06);
  border-radius: 999px;
  padding: 1px 7px;
  font-size: 11px;
  font-weight: 700;
}

.tab.active .tab-count {
  background: rgba(255, 255, 255, 0.22);
}

.tab-sm {
  padding: 5px 10px;
  font-size: 12px;
  min-height: 30px;
}

/* ============ tables ============ */

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

.table {
  width: 100%;
  border-collapse: collapse;
}

.table thead th {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  text-align: left;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: #fafbfc;
  white-space: nowrap;
}

.table tbody td {
  padding: 13px 20px;
  border-bottom: 1px solid var(--border-light);
  font-size: 14px;
  vertical-align: middle;
}

.table tbody tr {
  transition: background 0.1s;
}

.table tbody tr:hover {
  background: var(--surface-hover);
}

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

.lead-name {
  font-weight: 600;
}

.lead-phone {
  color: var(--muted);
}

.muted {
  color: var(--muted);
}

.actions-cell {
  text-align: right;
  white-space: nowrap;
}

.table td.actions-cell form {
  display: inline-flex;
}

.text-right {
  text-align: right;
}

/* ============ lead detail ============ */

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 16px;
}

.back-link:hover {
  color: var(--primary);
}

.lead-header {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 24px;
  margin-bottom: 20px;
  display: block;
}

.lead-header .lead-id-chip {
  font-size: 12px;
  font-weight: 700;
  color: var(--primary);
  background: var(--primary-light);
  padding: 3px 9px;
  border-radius: 7px;
}

.lead-header h2 {
  font-size: 22px;
  font-weight: 800;
  margin-top: 6px;
  margin-bottom: 4px;
  word-break: break-word;
}

.lead-header .lead-phone-big {
  color: var(--text);
  font-size: 17px;
  font-weight: 700;
}

.lead-header-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.lead-header-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.lead-phone-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
  padding: 12px 14px;
  background: var(--primary-light);
  border: 1px solid var(--blue-light);
  border-radius: var(--radius-sm);
}

.lead-contact-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.lead-details {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 18px;
}

.detail-item {
  padding: 14px 16px;
  background: var(--surface);
  min-width: 0;
}

@media (max-width: 1200px) {
  .lead-details { grid-template-columns: repeat(4, 1fr); }
}

@media (max-width: 992px) {
  .lead-details { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 768px) {
  .lead-details { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 480px) {
  .lead-details { grid-template-columns: 1fr; }
}

.detail-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}

.detail-item b {
  font-weight: 600;
  font-size: 15px;
  word-break: break-word;
  line-height: 1.4;
}

.current-lead-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.current-lead-main h2 {
  font-size: 20px;
  margin: 6px 0 2px;
  word-break: break-word;
}

.current-lead-side {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.lead-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border-light);
}

.lead-actions form {
  display: inline-flex;
}

.lead-id-chip {
  font-size: 12px;
  font-weight: 700;
  color: var(--primary);
  background: var(--primary-light);
  padding: 4px 10px;
  border-radius: 7px;
  margin-right: 6px;
  display: inline-block;
  margin-bottom: 6px;
}

.lead-grid {
  display: grid;
  grid-template-columns: 5fr 6fr;
  gap: 20px;
  align-items: start;
}

.lead-grid > * {
  min-width: 0;
}

.lead-info {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.lead-info .info-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border-light);
}

.lead-info .info-row:last-child {
  border-bottom: none;
}

.lead-info .info-row .info-label {
  color: var(--muted);
  font-size: 13px;
  flex-shrink: 0;
}

.lead-info .info-row .info-value {
  font-weight: 600;
  text-align: right;
  word-break: break-word;
}

/* timeline */

.timeline {
  display: flex;
  flex-direction: column;
  padding: 4px 4px 4px 0;
}

.tl-item {
  position: relative;
  padding: 0 0 20px 26px;
}

.tl-item:last-child {
  padding-bottom: 4px;
}

.tl-item::before {
  content: "";
  position: absolute;
  left: 7px;
  top: 18px;
  bottom: -2px;
  width: 2px;
  background: var(--border);
}

.tl-item:last-child::before {
  display: none;
}

.tl-dot {
  position: absolute;
  left: 0;
  top: 4px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 8px;
}

.tl-item[data-action="recommendation"] .tl-dot {
  border-color: var(--amber);
}

.tl-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.tl-label {
  font-weight: 700;
  font-size: 14px;
}

.tl-time {
  color: var(--muted);
  font-size: 12px;
}

.tl-text {
  margin-top: 4px;
  white-space: pre-wrap;
  background: var(--surface-hover);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 14px;
}

.tl-actor {
  color: var(--muted);
  font-size: 12px;
  margin-top: 6px;
}

/* ============ forms ============ */

.form-wrap {
  max-width: 640px;
}

.field {
  margin-bottom: 18px;
}

.field label {
  display: block;
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 7px;
}

.field input,
.field textarea,
.field select,
input[type="datetime-local"] {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.12s, box-shadow 0.12s;
}

.field input:focus,
.field textarea:focus,
.field select:focus,
input[type="datetime-local"]:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-ring);
}

.field textarea {
  resize: vertical;
  min-height: 96px;
}

.field-hint {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 22px;
}

.form-actions .btn {
  flex: 1;
}

.hint {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
  background: var(--primary-light);
  border: 1px solid var(--blue-light);
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 18px;
}

.hint .hint-icon {
  font-size: 15px;
}

/* ============ notifications ============ */

.notif-list {
  display: flex;
  flex-direction: column;
}

.notif-item {
  padding: 14px 20px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  border-bottom: 1px solid var(--border-light);
}

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

.notif-item.unread {
  background: var(--primary-light);
}

.notif-text {
  white-space: pre-wrap;
}

.notif-time {
  color: var(--muted);
  font-size: 12px;
  flex-shrink: 0;
  white-space: nowrap;
}

/* ============ flash ============ */

.flash {
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 18px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
}

.flash-error {
  background: var(--red-light);
  border: 1px solid #fca5a5;
  color: var(--danger-dark);
}

.flash-success {
  background: var(--green-light);
  border: 1px solid #86efac;
  color: var(--green);
}

/* ============ login ============ */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(160deg, #eff6ff 0%, #f1f5f9 55%, #e2e8f0 100%);
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 40px 36px;
  width: 400px;
  max-width: 100%;
  box-shadow: 0 20px 45px rgba(15, 23, 42, 0.1);
}

.login-logo-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 22px;
}

.login-logo-row .logo {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 19px;
}

.login-logo-row .logo-text {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.login-card h1 {
  font-size: 19px;
  text-align: center;
  margin-bottom: 4px;
}

.login-sub {
  color: var(--muted);
  text-align: center;
  font-size: 14px;
  margin-bottom: 22px;
}

/* ============ responsive ============ */

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

@media (max-width: 820px) {
  .burger {
    display: inline-flex;
  }

  .sidebar {
    width: 280px;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: 0 0 40px rgba(15, 23, 42, 0.18);
  }

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

  .sidebar-brand {
    height: 56px;
  }

  .nav-item {
    min-height: 48px;
    padding: 12px 14px;
  }

  .main {
    margin-left: 0;
  }

  .topbar {
    height: 56px;
    padding: 0 14px;
    gap: 12px;
  }

  .topbar-title {
    font-size: 16px;
  }

  .icon-btn {
    width: 38px;
    height: 38px;
  }

  .content {
    padding: 14px 12px 32px;
  }

  .card-header {
    padding: 14px 16px;
  }

  .card-body {
    padding: 16px;
  }

  .card-footer {
    padding: 12px 16px;
  }
}

@media (max-width: 600px) {
  .stats {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 16px;
  }

  .stat-card {
    padding: 14px;
    gap: 10px;
  }

  .stat-icon {
    width: 40px;
    height: 40px;
    border-radius: 11px;
    font-size: 18px;
  }

  .stat-num {
    font-size: 20px;
  }

  .lead-header {
    padding: 18px 16px;
  }

  .lead-header h2 {
    font-size: 20px;
  }

  .lead-phone-big {
    font-size: 15px;
  }

  .lead-contact-actions {
    width: 100%;
  }

  .lead-contact-actions .btn {
    flex: 1;
  }

  .lead-actions .btn {
    flex: 1 1 45%;
  }

  .field input,
  .field textarea,
  .field select,
  input[type="datetime-local"] {
    font-size: 16px;
  }

  .form-actions {
    flex-direction: column;
  }

  .form-actions .btn {
    flex: none;
    width: 100%;
  }

  .login-card {
    padding: 28px 20px;
  }

  /* таблицы превращаются в карточки */
  .table-wrap {
    overflow: visible;
  }

  .table thead {
    display: none;
  }

  .table,
  .table tbody,
  .table tr,
  .table td {
    display: block;
    width: 100%;
  }

  .table tbody tr {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 12px 14px;
    margin-bottom: 12px;
  }

  .table tbody tr.row-closed   { background: #fff; }
  .table tbody tr.row-contract { background: #bbf7d0; }
  .table tbody tr.row-meeting  { background: #a5f3fc; }
  .table tbody tr.row-hot      { background: #fca5a5; }
  .table tbody tr.row-medium   { background: #fdba74; }
  .table tbody tr.row-cold     { background: #fef08a; }
  .table tbody tr.row-active  { background: #bfdbfe; }
  .table tbody tr.row-pending { background: #e2e8f0; }

  .table tbody tr:hover {
    background: var(--surface);
  }

  .table tbody td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-light);
    font-size: 14px;
    text-align: right;
  }

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

  .table tbody td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    flex-shrink: 0;
  }

  .table tbody td[data-label=""]::before {
    display: none;
  }

  .table tbody td.actions-cell {
    border-top: 1px solid var(--border-light);
    margin-top: 6px;
    padding-top: 12px;
  }

  .table tbody td.actions-cell form,
  .table tbody td.actions-cell .btn,
  .table tbody td.actions-cell a.btn {
    width: 100%;
  }

  .table tbody td.actions-cell form {
    display: block;
  }

  .table tbody td.actions-cell .btn {
    min-height: 44px;
    justify-content: center;
  }

  .table tbody td.actions-cell form .btn {
    min-height: 44px;
    justify-content: center;
  }

  .phone-actions {
    justify-content: flex-end;
  }

  .actions-cell {
    text-align: right;
  }
}

@media (max-width: 380px) {
  .stats {
    grid-template-columns: 1fr 1fr;
  }

  .ph-num {
    white-space: normal;
  }
}

/* ============ call pages ============ */

.call-page {
  min-height: 100vh;
  background: #0f172a;
  color: #e2e8f0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* join screen */

.call-join {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.call-join-card {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 20px;
  padding: 40px 36px;
  max-width: 460px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}

.call-join-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  border-radius: 16px;
  background: #2563eb;
  color: #fff;
  margin-bottom: 16px;
}

.call-join-card h1 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 6px;
  color: #f8fafc;
}

.call-join-lead {
  color: #94a3b8;
  font-size: 14px;
  margin-bottom: 2px;
}

.call-join-info {
  color: #64748b;
  font-size: 12px;
  margin-bottom: 24px;
}

.call-join-error {
  background: #7f1d1d;
  border: 1px solid #b91c1c;
  color: #fecaca;
  padding: 10px 14px;
  border-radius: 10px;
  margin-bottom: 16px;
  font-size: 13px;
}

.call-join-form {
  margin-bottom: 20px;
}

.call-field {
  margin-bottom: 14px;
  text-align: left;
}

.call-field label {
  display: block;
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 6px;
  color: #cbd5e1;
}

.call-field input {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid #475569;
  border-radius: 10px;
  font-size: 15px;
  font-family: inherit;
  background: #0f172a;
  color: #e2e8f0;
  outline: none;
  transition: border-color 0.15s;
}

.call-field input:focus {
  border-color: #3b82f6;
}

.call-preview {
  margin-bottom: 20px;
}

.call-preview-video-wrap {
  position: relative;
  width: 100%;
  padding-top: 56.25%;
  background: #0f172a;
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 10px;
}

.call-preview-video-wrap video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #0f172a;
}

.call-preview-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #64748b;
}

.call-preview-placeholder p {
  margin-top: 8px;
  font-size: 13px;
}

.call-avatar-fallback {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #334155;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
  color: #94a3b8;
}

.call-preview-controls {
  display: flex;
  justify-content: center;
  gap: 10px;
}

.call-device-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid #475569;
  background: #1e293b;
  color: #94a3b8;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.call-device-btn.active {
  background: #dc2626;
  border-color: #dc2626;
  color: #fff;
}

.call-device-btn:hover {
  border-color: #3b82f6;
  color: #e2e8f0;
}

.call-join-hint {
  color: #64748b;
  font-size: 12px;
  margin-top: 12px;
}

/* room screen */

.call-room {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  position: relative;
  overflow: hidden;
}

.call-room-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: rgba(15,23,42,0.9);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 10;
  transition: opacity 0.3s;
}

.call-room-lead {
  font-weight: 600;
  font-size: 14px;
  color: #cbd5e1;
}

.call-room-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #94a3b8;
}

.call-conn-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.call-conn-good {
  background: #22c55e;
  box-shadow: 0 0 6px rgba(34,197,94,0.5);
}

.call-conn-poor {
  background: #f59e0b;
  box-shadow: 0 0 6px rgba(245,158,11,0.5);
}

.call-conn-lost {
  background: #ef4444;
  box-shadow: 0 0 6px rgba(239,68,68,0.5);
}

.call-participants-icon {
  font-size: 14px;
}

/* video grid */

.call-grid {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.call-main {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px;
  min-height: 0;
  align-content: center;
  justify-content: center;
}

.call-main > .call-tile {
  flex: 1 1 280px;
  min-width: 240px;
  max-width: 100%;
  min-height: 180px;
}

.call-strip {
  display: flex;
  gap: 8px;
  padding: 0 12px 12px 12px;
  justify-content: center;
  flex-shrink: 0;
}

.call-strip > .call-tile {
  flex: 0 0 160px;
  height: 120px;
}

/* pinned tile */
.call-tile-pinned {
  flex: 1 1 100% !important;
  height: auto !important;
  min-height: 300px !important;
}

/* padding at bottom for controls */
.call-strip:last-child {
  padding-bottom: 8px;
}

/* tiles */

.call-tile {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  background: #1e293b;
  border: 2px solid #334155;
  transition: border-color 0.35s ease, box-shadow 0.35s ease;
  min-width: 0;
  min-height: 0;
}

.call-tile.speaking {
  border-color: #3b82f6 !important;
  box-shadow: 0 0 30px rgba(59,130,246,0.5), 0 0 0 3px rgba(59,130,246,0.3);
}

.call-tile.call-tile-bad-conn {
  border-color: #f59e0b;
  box-shadow: 0 0 12px rgba(245,158,11,0.3);
}

.call-tile.call-tile-needs-tap::after {
  content: "Нажмите чтобы услышать";
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(239,68,68,0.85);
  color: #fff;
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 6px;
  z-index: 5;
  pointer-events: none;
}

.call-tile-pin {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 5;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.call-tile:hover .call-tile-pin,
.call-tile-pinned .call-tile-pin {
  opacity: 1;
}

@media (hover: none) {
  .call-tile:active .call-tile-pin {
    opacity: 1;
  }
}

.call-tile-speaker {
  border-color: #22c55e;
  box-shadow: 0 0 16px rgba(34,197,94,0.35);
}

.call-tile-video {
  width: 100%;
  height: 100%;
  position: relative;
}

.call-tile-video-el {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #0f172a;
}

.call-tile-avatar {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: #334155;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 700;
  color: #94a3b8;
}

.call-tile-name {
  position: absolute;
  bottom: 8px;
  left: 8px;
  right: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: #f8fafc;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 8px;
  z-index: 2;
  max-width: fit-content;
}

.call-tile-mic {
  font-size: 11px;
  opacity: 0.8;
}

/* controls bar */

.call-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  background: rgba(15,23,42,0.9);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 10;
  transition: opacity 0.3s;
}

.call-ctrl-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: transparent;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  padding: 8px;
  border-radius: 12px;
  min-width: 60px;
  font-family: inherit;
  transition: color 0.15s, background 0.15s;
}

.call-ctrl-btn:hover {
  color: #e2e8f0;
  background: rgba(255,255,255,0.06);
}

.call-ctrl-btn .call-ctrl-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  background: #334155;
  transition: background 0.15s;
}

.call-ctrl-btn.active .call-ctrl-icon {
  background: #dc2626;
}

.call-ctrl-btn.call-ctrl-leave .call-ctrl-icon {
  background: #dc2626;
}

.call-ctrl-btn.call-ctrl-leave:hover .call-ctrl-icon {
  background: #ef4444;
}

.call-ctrl-label {
  font-size: 11px;
  font-weight: 500;
}

/* participants panel */

.call-participants-panel {
  position: absolute;
  right: 16px;
  bottom: 100px;
  width: 280px;
  max-height: 50vh;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.4);
  z-index: 20;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.call-participants-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid #334155;
  font-weight: 600;
  font-size: 14px;
}

.call-participants-close {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 16px;
  cursor: pointer;
  padding: 4px;
}

.call-participants-list {
  padding: 8px;
  overflow-y: auto;
}

.call-part-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 14px;
}

.call-part-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #334155;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #94a3b8;
  flex-shrink: 0;
}

/* mobile */
@media (max-width: 768px) {
  .call-join-card {
    padding: 28px 20px;
    border-radius: 16px;
  }

  .call-main {
    gap: 6px;
    padding: 8px;
  }

  .call-main > .call-tile {
    flex: 1 1 200px;
    min-width: 150px;
  }

  .call-strip > .call-tile {
    flex: 0 0 120px;
    height: 90px;
  }

  .call-tile {
    border-radius: 12px;
  }

  .call-tile-avatar {
    width: 48px;
    height: 48px;
    font-size: 18px;
  }

  .call-tile-name {
    font-size: 11px;
    padding: 3px 8px;
    bottom: 6px;
    left: 6px;
  }

  .call-controls {
    gap: 10px;
    padding: 10px 12px;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
  }

  .call-ctrl-btn {
    min-width: 48px;
    padding: 6px;
  }

  .call-ctrl-btn .call-ctrl-icon {
    width: 42px;
    height: 42px;
    font-size: 18px;
  }

  .call-ctrl-label {
    font-size: 10px;
  }

  .call-participants-panel {
    width: 240px;
    right: 8px;
    bottom: 90px;
  }

  .call-room-header {
    padding: 10px 14px;
  }
}

@media (max-width: 480px) {
  .call-main {
    gap: 4px;
    padding: 4px;
  }

  .call-main > .call-tile {
    flex: 1 1 100%;
    min-width: 100px;
    min-height: 100px;
  }

  .call-strip > .call-tile {
    flex: 0 0 100px;
    height: 75px;
  }

  .call-tile {
    border-radius: 10px;
    border-width: 1px;
  }

  .call-tile-avatar {
    width: 40px;
    height: 40px;
    font-size: 15px;
  }

  .call-tile-name {
    font-size: 10px;
  }

  .call-controls {
    gap: 6px;
    padding: 8px 8px;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
  }

  .call-ctrl-btn {
    min-width: 44px;
    padding: 4px;
  }

  .call-ctrl-btn .call-ctrl-icon {
    width: 38px;
    height: 38px;
    font-size: 16px;
  }

  .call-ctrl-label {
    font-size: 9px;
  }
}
