/* CRM 360°Space — Premium Design v2.0 */

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

:root {
  --accent:          #4361ee;
  --accent-hover:    #3451d1;
  --accent-light:    #eef1fd;
  --accent-ok:       #10b981;
  --accent-ok-bg:    #ecfdf5;
  --accent-warn:     #f59e0b;
  --accent-warn-bg:  #fffbeb;
  --accent-danger:   #ef4444;
  --accent-danger-bg:#fef2f2;
  --sidebar-bg:      #0f172a;
  --sidebar-hover:   rgba(255,255,255,.06);
  --sidebar-active:  rgba(67,97,238,.2);
  --sidebar-border:  rgba(255,255,255,.07);
  --sidebar-w:       248px;
  --bg:              #f1f5f9;
  --card-bg:         #ffffff;
  --card-bg2:        #f8fafc;
  --border:          #e2e8f0;
  --border-light:    #f1f5f9;
  --text:            #0f172a;
  --text-muted:      #64748b;
  --text-light:      #94a3b8;
  --header-h:        60px;
  --mobile-nav-h:    68px;
  --radius:          12px;
  --radius-sm:       8px;
  --radius-lg:       16px;
  --shadow-xs:  0 1px 2px rgba(0,0,0,.05);
  --shadow-sm:  0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow:     0 4px 6px -1px rgba(0,0,0,.07), 0 2px 4px -2px rgba(0,0,0,.05);
  --shadow-md:  0 10px 15px -3px rgba(0,0,0,.08), 0 4px 6px -4px rgba(0,0,0,.04);
  --shadow-lg:  0 20px 25px -5px rgba(0,0,0,.12), 0 8px 10px -6px rgba(0,0,0,.05);
  --shadow-accent: 0 4px 14px rgba(67,97,238,.28);
}

html { scroll-behavior: smooth; }
.hidden { display: none !important; }
/* ── Client cards (mobile-only, hidden on desktop) ── */
.client-cards-list { display: none; }
.client-card-empty { display: none; }

/* ── Kanban card phone ── */
.kanban-card__phone {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
  margin: 4px 0 6px;
  padding: 3px 0;
}
.kanban-card__phone:hover { text-decoration: underline; color: var(--accent-hover); }


body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

/* ── Layout ── */
.crm-layout { display: flex; min-height: 100vh; }

/* ── Sidebar ── */
.crm-sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform .25s cubic-bezier(.4,0,.2,1);
  border-right: 1px solid var(--sidebar-border);
}

.crm-sidebar__logo {
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--sidebar-border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.crm-sidebar__logo-icon {
  width: 34px; height: 34px;
  background: var(--accent);
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  box-shadow: 0 0 0 3px rgba(67,97,238,.22);
}

.crm-sidebar__logo h1 { font-size: 15.5px; font-weight: 700; color: #fff; letter-spacing: -.3px; }
.crm-sidebar__logo span { font-size: 10.5px; color: rgba(255,255,255,.3); display: block; margin-top: 1px; }

.crm-nav {
  flex: 1;
  padding: 10px 0;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.08) transparent;
}

.crm-nav::-webkit-scrollbar { width: 4px; }
.crm-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 2px; }

.crm-nav a {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8.5px 12px 8.5px 14px;
  margin: 1px 8px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,.52);
  font-size: 13.5px;
  font-weight: 450;
  transition: all .15s;
  text-decoration: none;
  position: relative;
}

.crm-nav a:hover { background: var(--sidebar-hover); color: rgba(255,255,255,.88); text-decoration: none; }

.crm-nav a.active {
  background: var(--sidebar-active);
  color: #fff;
  font-weight: 600;
}

.crm-nav a.active::before {
  content: '';
  position: absolute;
  left: -8px; top: 7px; bottom: 7px;
  width: 3px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}

.crm-nav .nav-section {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.3px;
  color: rgba(255,255,255,.18);
  padding: 14px 20px 5px;
  font-weight: 600;
}

.crm-nav .nav-icon { font-size: 14px; min-width: 18px; text-align: center; }

.crm-sidebar__footer {
  padding: 13px 16px;
  border-top: 1px solid var(--sidebar-border);
  color: rgba(255,255,255,.3);
  font-size: 11.5px;
}
.crm-sidebar__footer strong { color: rgba(255,255,255,.65); display: block; margin-bottom: 1px; }

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

.crm-topbar {
  height: var(--header-h);
  background: rgba(255,255,255,.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.crm-topbar h2 { font-size: 17px; font-weight: 700; letter-spacing: -.3px; }
.crm-topbar__actions { display: flex; align-items: center; gap: 10px; }

.crm-content { flex: 1; padding: 24px 28px; }

/* ── Cards ── */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  margin-bottom: 20px;
  transition: box-shadow .2s;
}

.card:hover { box-shadow: var(--shadow); }

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

.card__header h3 { font-size: 14.5px; font-weight: 700; letter-spacing: -.2px; }
.card__body { padding: 20px; }

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

.stat-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 5px;
  position: relative;
  overflow: hidden;
  transition: all .2s;
}

.stat-card::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 3px;
  background: var(--accent);
  border-radius: 0 0 var(--radius) var(--radius);
}

.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.stat-card.warn::after  { background: var(--accent-warn); }
.stat-card.danger::after{ background: var(--accent-danger); }
.stat-card.ok::after    { background: var(--accent-ok); }

.stat-card__value { font-size: 30px; font-weight: 800; color: var(--accent); line-height: 1; letter-spacing: -1px; }
.stat-card__label { font-size: 12.5px; color: var(--text-muted); font-weight: 500; }
.stat-card.warn   .stat-card__value { color: var(--accent-warn); }
.stat-card.danger .stat-card__value { color: var(--accent-danger); }
.stat-card.ok     .stat-card__value { color: var(--accent-ok); }

/* ── Tables ── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

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

table th {
  text-align: left;
  padding: 10px 16px;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .7px;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  background: var(--card-bg2);
  white-space: nowrap;
}

table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

table tr:last-child td { border-bottom: none; }
table tbody tr { transition: background .1s; }
table tbody tr:hover td { background: #f8faff; }
table .row-danger td { background: #fff5f5; }
table .row-warn td   { background: #fffbf0; }

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

.badge-ok      { background: var(--accent-ok-bg);    color: #059669; }
.badge-warn    { background: var(--accent-warn-bg);   color: #d97706; }
.badge-danger  { background: var(--accent-danger-bg); color: #dc2626; }
.badge-info    { background: var(--accent-light);     color: var(--accent); }
.badge-neutral { background: #f1f5f9; color: #475569; }
.badge-team    { background: #ede9fe; color: #7c3aed; }
.badge-client  { background: #fff7ed; color: #c2410c; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all .15s;
  text-decoration: none;
  min-height: 36px;
  letter-spacing: -.1px;
  white-space: nowrap;
  font-family: inherit;
}

.btn:hover { text-decoration: none; }
.btn:active { transform: scale(.98); }

.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 2px 8px rgba(67,97,238,.28); }
.btn-primary:hover { background: var(--accent-hover); color: #fff; box-shadow: var(--shadow-accent); }

.btn-danger  { background: var(--accent-danger); color: #fff; box-shadow: 0 2px 8px rgba(239,68,68,.22); }
.btn-danger:hover  { background: #dc2626; color: #fff; }

.btn-success { background: var(--accent-ok); color: #fff; }
.btn-success:hover { background: #059669; color: #fff; }

.btn-outline {
  background: #fff;
  border: 1.5px solid var(--border);
  color: var(--text);
  box-shadow: var(--shadow-xs);
}
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }

.btn-ghost { background: transparent; border: none; color: var(--text-muted); box-shadow: none; }
.btn-ghost:hover { background: var(--border-light); color: var(--text); }

.btn-sm  { padding: 5px 12px; font-size: 12.5px; min-height: 30px; }
.btn-lg  { padding: 11px 24px; font-size: 15px; min-height: 44px; border-radius: 10px; }
.btn-icon{ padding: 7px 9px; min-width: 36px; justify-content: center; }
.w-100   { width: 100%; justify-content: center; }

/* ── Forms ── */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.form-hint  { font-size: 12px; color: var(--text-muted); margin-top: 5px; }

.form-control {
  display: block;
  width: 100%;
  padding: 9px 13px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text);
  background: #fff;
  transition: all .15s;
  appearance: none;
  font-family: inherit;
}

.form-control:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(67,97,238,.1); }
.form-control::placeholder { color: var(--text-light); }
.form-control:disabled { background: var(--card-bg2); color: var(--text-muted); cursor: not-allowed; }

select.form-control {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%2364748b' d='M5 6L0 0h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 34px;
}

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
.form-grid .span2 { grid-column: span 2; }

/* ── Alerts ── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 13.5px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border-left: 3px solid;
}

.alert-success { background: var(--accent-ok-bg);    color: #065f46; border-color: var(--accent-ok); }
.alert-danger  { background: var(--accent-danger-bg); color: #991b1b; border-color: var(--accent-danger); }
.alert-error   { background: var(--accent-danger-bg); color: #991b1b; border-color: var(--accent-danger); }
.alert-warn    { background: var(--accent-warn-bg);   color: #92400e; border-color: var(--accent-warn); }
.alert-info    { background: var(--accent-light);     color: #1e40af; border-color: var(--accent); }

/* ── Progress ── */
.progress-bar-wrap { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; margin: 8px 0; }
.progress-bar { height: 100%; background: linear-gradient(90deg, var(--accent), #818cf8); border-radius: 3px; transition: width .4s ease; }

/* ── Stage timeline ── */
.stage-timeline { display: flex; flex-direction: column; }

.stage-item { display: flex; gap: 14px; padding: 10px 0; position: relative; }

.stage-item::before {
  content: ''; position: absolute;
  left: 13px; top: 40px; bottom: -10px;
  width: 2px; background: var(--border);
}
.stage-item:last-child::before { display: none; }

.stage-dot {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; flex-shrink: 0; margin-top: 4px;
}

.stage-dot.done   { background: var(--accent-ok); color: #fff; }
.stage-dot.active { background: var(--accent); color: #fff; box-shadow: 0 0 0 4px rgba(67,97,238,.16); }
.stage-dot.pending{ background: var(--border); color: var(--text-muted); }

.stage-info { flex: 1; }
.stage-name { font-weight: 600; font-size: 13.5px; }
.stage-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.stage-duration { font-size: 12px; color: var(--text-muted); font-style: italic; }

/* ── Funnel ── */
.funnel-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(88px, 1fr)); gap: 8px; }

.funnel-item {
  text-align: center;
  padding: 14px 8px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  transition: all .15s;
  cursor: pointer;
  text-decoration: none;
}

.funnel-item:hover, .funnel-item.active {
  border-color: var(--accent);
  background: var(--accent-light);
  text-decoration: none;
  box-shadow: var(--shadow-sm);
}

.funnel-count { font-size: 26px; font-weight: 800; color: var(--accent); letter-spacing: -1px; }
.funnel-label { font-size: 11px; color: var(--text-muted); margin-top: 3px; line-height: 1.3; }

/* ── Search bar ── */
.search-bar { display: flex; gap: 8px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.search-bar .form-control { max-width: 280px; }

/* ── Hosting colors ── */
.hosting-ok     { color: var(--accent-ok);     font-weight: 600; }
.hosting-warn   { color: var(--accent-warn);   font-weight: 700; }
.hosting-danger { color: var(--accent-danger); font-weight: 700; }

/* ── Login ── */
.login-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: var(--sidebar-bg);
  background-image:
    radial-gradient(at 20% 80%, rgba(67,97,238,.22) 0, transparent 55%),
    radial-gradient(at 80% 20%, rgba(139,92,246,.18) 0, transparent 50%);
}

.login-card {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 40px 36px;
  width: 380px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}

.login-card h1 { font-size: 24px; font-weight: 800; margin-bottom: 4px; letter-spacing: -.5px; }
.login-card .subtitle { color: var(--text-muted); font-size: 13.5px; margin-bottom: 28px; }

/* ── Hamburger ── */
.menu-toggle {
  display: none;
  background: none; border: none; cursor: pointer;
  padding: 6px; font-size: 20px; color: var(--text-muted);
  border-radius: var(--radius-sm); transition: background .15s;
}
.menu-toggle:hover { background: var(--border-light); }

/* ── Notes ── */
.notes-list { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }

.note-item {
  background: var(--card-bg2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}

.note-item__meta { font-size: 11.5px; color: var(--text-muted); margin-bottom: 5px; }
.note-item__text { font-size: 13.5px; line-height: 1.55; white-space: pre-wrap; }

/* ── Quick search ── */
.quick-search-form { display: flex; gap: 8px; max-width: 500px; }
.quick-search-form .form-control { font-size: 15px; }

/* ── Text utils ── */
.text-muted { color: var(--text-muted) !important; }
.text-sm    { font-size: 12px; }
.text-xs    { font-size: 11px; }

/* ── Change password form ── */
.change-pass-form { max-width: 400px; }

/* ── Kanban filters ── */
.kanban-filters { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; padding: 10px 14px; background: var(--card-bg); border-radius: var(--radius-sm); border: 1px solid var(--border); }
.kanban-filter-checkbox { display: flex; align-items: center; gap: 6px; font-size: 13.5px; color: var(--text-muted); cursor: pointer; user-select: none; }
.kanban-filter-search { display: flex; gap: 6px; align-items: center; margin-left: auto; }

/* ── Kanban board ── */
.kanban-board { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 20px; align-items: flex-start; -webkit-overflow-scrolling: touch; min-height: calc(100vh - 200px); }
.kanban-board::-webkit-scrollbar { height: 6px; }
.kanban-board::-webkit-scrollbar-track { background: var(--border-light); border-radius: 3px; }
.kanban-board::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.kanban-board::-webkit-scrollbar-thumb:hover { background: var(--text-light); }

/* ── Kanban column ── */
.kanban-col { min-width: 240px; max-width: 260px; background: var(--card-bg2); border-radius: var(--radius); border: 1px solid var(--border); flex-shrink: 0; display: flex; flex-direction: column; }
.kanban-col--empty { opacity: .72; }
.kanban-col__header { padding: 10px 12px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; border-top: 3px solid var(--col-color, var(--accent)); border-radius: var(--radius) var(--radius) 0 0; }
.kanban-col__title { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: var(--text); }
.kanban-col__count { background: var(--col-color, var(--accent)); color: #fff; border-radius: 20px; padding: 1px 8px; font-size: 11px; font-weight: 700; min-width: 22px; text-align: center; transition: background .15s; }
.kanban-col--empty .kanban-col__count { background: var(--border); color: var(--text-light); }
.kanban-col__body { padding: 8px; flex: 1; min-height: 80px; display: flex; flex-direction: column; }
.kanban-col__empty-msg { flex: 1; display: flex; align-items: center; justify-content: center; font-size: 12px; color: var(--text-light); padding: 24px 0; text-align: center; }

/* ── Kanban card ── */
.kanban-card { background: #fff; border-radius: var(--radius-sm); border: 1px solid var(--border); padding: 10px 12px; margin-bottom: 7px; cursor: grab; transition: box-shadow .15s, border-color .15s, transform .1s; box-shadow: var(--shadow-xs); user-select: none; }
.kanban-card:hover { box-shadow: var(--shadow-md); border-color: #c7d2fe; transform: translateY(-1px); }
.kanban-card:active { cursor: grabbing; }
.kanban-card__title { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; color: var(--text); }
.kanban-card__icon { font-size: 13px; flex-shrink: 0; }
.kanban-card__company { font-size: 11.5px; color: var(--text-muted); margin: 3px 0 0 19px; }
.kanban-card__meta { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border-light); display: flex; flex-direction: column; gap: 3px; }
.kanban-card__row { display: flex; align-items: center; gap: 5px; font-size: 11.5px; color: var(--text-muted); }
.kanban-card__label { font-size: 11px; flex-shrink: 0; }
.kanban-card__amount { font-weight: 600; color: var(--text); }
.kanban-card__days--warn span { color: var(--accent-danger) !important; font-weight: 600; }
.kanban-card--loading { opacity: .45; pointer-events: none; }

/* ── SortableJS states ── */
.sortable-ghost { opacity: .3; background: var(--accent-light) !important; border: 2px dashed var(--accent) !important; }
.sortable-chosen { box-shadow: 0 12px 28px rgba(67,97,238,.22) !important; border-color: var(--accent) !important; z-index: 10; }
.sortable-drag { opacity: 1; box-shadow: 0 20px 40px rgba(0,0,0,.15) !important; }

/* Mobile-only kanban elements — hidden on desktop */
.kanban-mobile-stages { display: none; }
.kanban-card__move     { display: none; }

details summary { cursor: pointer; user-select: none; }
details summary:focus { outline: none; }

/* ══════════════════════════════════════
   МОБИЛЬНАЯ НАВИГАЦИЯ
══════════════════════════════════════ */

.crm-mobile-topbar {
  display: none;
  height: 56px;
  background: var(--sidebar-bg);
  position: sticky; top: 0; z-index: 150;
  align-items: center; justify-content: center;
  padding: 0 16px;
  box-shadow: 0 2px 12px rgba(0,0,0,.2);
  width: 100%;
}

.crm-mobile-topbar__logo { font-size: 18px; font-weight: 800; color: #fff; letter-spacing: -.4px; display: flex; align-items: center; gap: 8px; justify-content: center; }
.crm-mobile-topbar__page { font-size: 13px; font-weight: 500; color: rgba(255,255,255,.5); }
.crm-mobile-topbar__page { font-size: 13px; font-weight: 500; color: rgba(255,255,255,.5); }

.crm-mobile-topbar__right { display: flex; align-items: center; gap: 8px; }

.crm-mobile-topbar__user { font-size: 12px; color: rgba(255,255,255,.45); max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.crm-mobile-topbar__logout {
  font-size: 11px; color: rgba(255,255,255,.4);
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 6px; padding: 5px 9px;
  text-decoration: none; transition: all .15s;
}
.crm-mobile-topbar__logout:hover { color: #fff; border-color: rgba(255,255,255,.35); text-decoration: none; }

.mobile-bottom-nav {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0;
  height: 68px;
  background: var(--sidebar-bg);
  border-top: 1px solid rgba(255,255,255,.1);
  z-index: 200;
  flex-direction: row; align-items: stretch;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  box-shadow: 0 -6px 24px rgba(0,0,0,.3);
}

.mobile-bottom-nav__item {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: rgba(255,255,255,.45); text-decoration: none; gap: 3px;
  padding: 8px 4px; border: none; background: none; cursor: pointer;
  transition: color .15s; min-height: 52px; position: relative;
}

.mobile-bottom-nav__item:hover, .mobile-bottom-nav__item.active { color: #fff; text-decoration: none; }
.mobile-bottom-nav__item.active { color: #7c9df5; }

.mobile-bottom-nav__item.active::before {
  content: ''; position: absolute;
  top: 0; left: 20%; right: 20%;
  height: 3px; background: var(--accent);
  border-radius: 0 0 4px 4px;
}

.mobile-bottom-nav__icon  { font-size: 26px; line-height: 1; }
.mobile-bottom-nav__label { font-size: 11.5px; white-space: nowrap; font-weight: 600; }

.mobile-drawer-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.48); z-index: 290; }
.mobile-drawer-overlay.show { display: block; }

.mobile-drawer {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--sidebar-bg);
  border-radius: 20px 20px 0 0;
  z-index: 300;
  padding: 0 0 env(safe-area-inset-bottom, 0px);
  transform: translateY(100%);
  transition: transform .28s cubic-bezier(.4,0,.2,1);
  max-height: 72vh; overflow-y: auto;
}

.mobile-drawer.open { transform: translateY(0); }

.mobile-drawer__userblock { padding: 14px 20px 10px; border-bottom: 1px solid rgba(255,255,255,.08); margin-bottom: 4px; }
.mobile-drawer__username { font-size: 15px; font-weight: 700; color: #fff; }
.mobile-drawer__userrole { font-size: 12px; color: rgba(255,255,255,.4); margin-top: 2px; }
.mobile-drawer__handle { width: 40px; height: 4px; background: rgba(255,255,255,.18); border-radius: 2px; margin: 14px auto 6px; }
.mobile-drawer__title { font-size: 11px; text-transform: uppercase; letter-spacing: 1.2px; color: rgba(255,255,255,.18); padding: 8px 20px 4px; font-weight: 600; }
.mobile-drawer__links { display: flex; flex-direction: column; padding: 4px 0 16px; }

.mobile-drawer__link {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 20px;
  color: rgba(255,255,255,.68); text-decoration: none; font-size: 15px;
  transition: background .12s;
}
.mobile-drawer__link:hover, .mobile-drawer__link.active { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.mobile-drawer__link.active { color: #7c9df5; }
.mobile-drawer__icon { font-size: 20px; }

/* ══════════════════════════════════════
   АДАПТИВ
══════════════════════════════════════ */
@media (max-width: 768px) {
  /* Убираем flex-row — топбар, сайдбар и main в вертикальный поток */
  .crm-layout { display: block; }

  .crm-sidebar { display: none; }
  .crm-sidebar.open { display: flex; position: fixed; top: 0; left: 0; bottom: 0; transform: none; box-shadow: var(--shadow-lg); z-index: 200; }
  .crm-sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 190; }
  .crm-sidebar-overlay.show { display: block; }

  .crm-mobile-topbar { display: flex; width: 100%; }
  .mobile-bottom-nav  { display: flex; }

  .crm-main {
    display: block;
    margin-left: 0 !important;
    width: 100%;
    min-width: 0;
    padding-bottom: calc(var(--mobile-nav-h) + env(safe-area-inset-bottom, 0px));
  }

  .crm-content  { padding: 14px 14px 20px; }
  .crm-topbar   { display: none; }
  .menu-toggle  { display: inline-flex; }

  .table-wrap { margin: 0 -14px; border-radius: 0; }
  table th, table td { padding: 9px 12px; font-size: 12.5px; }

  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span2 { grid-column: span 1; }

  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }

  .form-control { padding: 11px 13px; font-size: 16px; }
  select.form-control { font-size: 16px; }

  .card { border-radius: var(--radius-sm); }
  .card__body { padding: 14px; }
  .card__header { padding: 12px 14px; }

  /* Mobile kanban */
  .kanban-mobile-stages { display: flex; gap: 7px; overflow-x: auto; padding-bottom: 12px; margin-bottom: 2px; scrollbar-width: none; -ms-overflow-style: none; }
  .kanban-mobile-stages::-webkit-scrollbar { display: none; }
  .kanban-stage-pill { flex-shrink: 0; display: inline-flex; align-items: center; gap: 5px; padding: 7px 12px; border-radius: 20px; border: 2px solid var(--pill-color, var(--accent)); background: #fff; color: var(--pill-color, var(--accent)); font-size: 12px; font-weight: 600; cursor: pointer; transition: all .15s; }
  .kanban-stage-pill span { background: var(--pill-color, var(--accent)); color: #fff; border-radius: 10px; padding: 1px 6px; font-size: 10.5px; font-weight: 700; }
  .kanban-stage-pill.active { background: var(--pill-color, var(--accent)); color: #fff; }
  .kanban-stage-pill.active span { background: rgba(255,255,255,.25); color: #fff; }
  .kanban-board { flex-direction: column !important; overflow-x: visible !important; min-height: unset !important; gap: 0 !important; padding-bottom: 80px; }
  .kanban-col { min-width: 100% !important; max-width: 100% !important; display: none !important; }
  .kanban-col.mobile-active { display: flex !important; }
  .kanban-card { cursor: default; }
  .kanban-card:hover { transform: none; box-shadow: var(--shadow-xs); border-color: var(--border); }
  .kanban-card__move { display: flex; align-items: center; gap: 8px; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border-light); }
  .kanban-card__move-label { font-size: 11.5px; color: var(--text-muted); white-space: nowrap; font-weight: 500; }
  .kanban-card__stage-select { flex: 1; padding: 8px 10px; border-radius: 7px; border: 1.5px solid var(--border); font-size: 14px; background: var(--bg); color: var(--text); font-family: inherit; }

  .search-bar .form-control,
  .search-bar select { max-width: 100% !important; width: 100% !important; min-width: 0 !important; }
  .search-bar { flex-direction: column; align-items: stretch; }

  .stat-card:hover, .card:hover { transform: none; }
  .btn:hover { transform: none; }

  /* Stat cards мобиле */
  .stat-card { padding: 14px 16px; gap: 4px; }
  .stat-card__value { font-size: 34px; }
  .stat-card__label { font-size: 12px; }
  .stats-grid { margin-bottom: 16px; }

  /* Analytics card — убрать лишние отступы */
  .analytics-widget { padding: 12px !important; }

  /* ── Контент сразу под шапкой без лишних отступов ── */
  .crm-content { padding: 12px 14px 20px; }


  /* ── Client cards мобиле ── */
  .card--table-wrap { display: none !important; }
  .client-cards-list { display: flex; flex-direction: column; gap: 10px; }
  .client-card-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 40px 20px; color: var(--text-muted); font-size: 14px; }
  .client-card-empty span { font-size: 40px; }

  .client-card {
    display: flex;
    gap: 12px;
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 14px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-xs);
  }
  .client-card__avatar {
    width: 46px; height: 46px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 15px; font-weight: 700;
    flex-shrink: 0; letter-spacing: -.5px;
  }
  .client-card__body { flex: 1; min-width: 0; }
  .client-card__header {
    display: flex; align-items: center; gap: 8px;
    flex-wrap: wrap; margin-bottom: 3px;
  }
  .client-card__name {
    font-size: 15px; font-weight: 700;
    color: var(--text); text-decoration: none;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    max-width: calc(100% - 80px);
  }
  .client-card__stage { font-size: 11px; padding: 2px 8px; flex-shrink: 0; }
  .client-card__company { font-size: 12.5px; color: var(--text-muted); margin-bottom: 6px; }
  .client-card__details { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; align-items: center; }
  .client-card__detail { font-size: 13px; color: var(--text); }
  .client-card__detail--muted { color: var(--text-muted); font-size: 12px; }
  .client-card__meta {
    display: flex; gap: 10px; flex-wrap: wrap;
    font-size: 11.5px; color: var(--text-muted); margin-bottom: 8px;
  }
  .client-card__actions { display: flex; gap: 8px; flex-wrap: wrap; }
  .client-card__call-btn {
    background: #ecfdf5; color: #059669;
    border: 1.5px solid #a7f3d0;
    font-weight: 600; font-size: 12.5px;
  }

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

  /* ── Kanban content wrapper ── */
  .crm-content--kanban { padding-bottom: 0; overflow-x: hidden; }

  /* ── Kanban filters: stack vertically ── */
  .kanban-filters { flex-direction: column; gap: 8px; padding: 10px 12px; }
  .kanban-filters select,
  .kanban-filters input[type=search] { width: 100% !important; max-width: 100% !important; min-width: 0 !important; }
  .kanban-filter-search { width: 100%; margin-left: 0; flex-wrap: wrap; }
  .kanban-filter-search .form-control { flex: 1; min-width: 0; }
  .kanban-filter-checkbox { font-size: 14px; }

  /* ── Tables → card layout ── */
  .table-wrap { border-radius: 0; overflow-x: visible; }
  table { display: block; width: 100%; }
  table thead { display: none; }
  table tbody tr {
    display: block;
    background: var(--card-bg);
    border-radius: var(--radius-sm);
    margin: 0 14px 10px;
    padding: 12px 14px;
    box-shadow: var(--shadow-xs);
    border: 1px solid var(--border);
  }
  table tbody tr.row-danger { background: #fff5f5; }
  table tbody tr.row-warn   { background: #fffbf0; }
  table tbody td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 0;
    border: none !important;
    font-size: 13.5px;
    gap: 8px;
    min-height: 0;
  }
  table tbody td:empty { display: none; }
  table tbody td::before {
    content: attr(data-label);
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .5px;
    font-weight: 600;
    flex-shrink: 0;
    min-width: 80px;
  }
  table tbody td:not([data-label])::before { display: none; }
  table tbody td:last-child {
    justify-content: flex-end;
    padding-top: 10px;
    margin-top: 4px;
    border-top: 1px solid var(--border-light) !important;
  }

  /* ── Dashboard quick search full-width ── */
  .quick-search-form { flex-direction: row; max-width: 100%; gap: 8px; }
  .quick-search-form .form-control { flex: 1; min-width: 0; font-size: 15px; }
  .quick-search-form .btn { flex-shrink: 0; white-space: nowrap; padding: 11px 20px; }

  /* ── Dashboard analytics grid: single column ── */
  .analytics-grid { grid-template-columns: 1fr !important; }
  .analytics-widget { padding: 14px !important; }

  /* ── Funnel: 4 cols on mobile ── */
  .funnel-grid { grid-template-columns: repeat(4, 1fr); gap: 6px; }
  .funnel-count { font-size: 20px; }
  .funnel-label { font-size: 10px; }

  /* ── Stage timeline: tighter ── */
  .stage-item { padding: 7px 0; }

  /* ── Notes full width ── */
  .notes-list { gap: 8px; }

  /* ── Form grids: always single column ── */
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span2 { grid-column: span 1; }

  /* ── Topbar: minimal padding ── */
  .crm-topbar { padding: 0 14px; }

  /* ── Cards: no extra padding ── */
  .card__header { padding: 12px 14px; }
  .card__body   { padding: 12px 14px; }

  /* ── Target form: full width ── */
  #target-form input[type=number] { width: 100% !important; }
  #target-form { flex-direction: column; }

  /* ── Buttons in topbar ── */
  .crm-topbar__actions .btn { font-size: 12.5px; padding: 6px 12px; }

  /* ── Hosting table: hide less important cols ── */
  .col-hide-mobile { display: none !important; }
}

@media (min-width: 769px) {
  .crm-mobile-topbar { display: none; }
  .mobile-bottom-nav  { display: none; }
  .menu-toggle        { display: none; }
}
