/* ═══════════════════════════════════════════════════════════
   CRM ЧЕГРАВА КАСПИЯ — Premium Dark Theme
   ═══════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');


/* ── Variables ─────────────────────────────────────────── */
:root {
  --bg-base:       #070C18;
  --bg-secondary:  #0D1526;
  --bg-card:       #111827;
  --bg-card-hover: #16213A;
  --bg-elevated:   #1A2540;
  --sidebar-bg:    #09111F;
  --sidebar-w:     256px;
  --header-h:      64px;

  --accent:        #4F6EF7;
  --accent-2:      #8B5CF6;
  --accent-grad:   linear-gradient(135deg,#4F6EF7,#8B5CF6);
  --accent-glow:   0 0 20px rgba(79,110,247,0.35);

  --text-1: #F1F5F9;
  --text-2: #94A3B8;
  --text-3: #475569;
  --border: rgba(255,255,255,0.07);
  --border-2: rgba(255,255,255,0.12);

  --green:  #10B981;  --green-bg:  rgba(16,185,129,0.12);
  --yellow: #F59E0B;  --yellow-bg: rgba(245,158,11,0.12);
  --red:    #EF4444;  --red-bg:    rgba(239,68,68,0.12);
  --blue:   #3B82F6;  --blue-bg:   rgba(59,130,246,0.12);
  --purple: #8B5CF6;  --purple-bg: rgba(139,92,246,0.12);
  --cyan:   #06B6D4;  --cyan-bg:   rgba(6,182,212,0.12);
  --orange: #F97316;  --orange-bg: rgba(249,115,22,0.12);
  --pink:   #EC4899;  --pink-bg:   rgba(236,72,153,0.12);

  /* Status colors */
  --s-free:      #10B981;
  --s-reserved:  #F59E0B;
  --s-precon:    #3B82F6;
  --s-ddu:       #8B5CF6;
  --s-fullpaid:  #06B6D4;
  --s-install:   #F97316;
  --s-mortgage:  #6366F1;
  --s-sold:      #EC4899;
  --s-transfer:  #22C55E;
  --s-frozen:    #6B7280;
  --s-dispute:   #EF4444;

  --r-sm: 6px; --r-md: 10px; --r-lg: 16px; --r-xl: 24px;
  --shadow-card:  0 4px 24px rgba(0,0,0,0.4);
  --shadow-modal: 0 24px 64px rgba(0,0,0,0.7);
  --transition:   all 0.2s cubic-bezier(0.4,0,0.2,1);
}

/* ── Reset ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg-base);
  color: var(--text-1);
  line-height: 1.5;
  overflow: hidden;
  height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
button { cursor: pointer; font-family: inherit; border: none; background: none; }
input, select, textarea { font-family: inherit; }
ul, ol { list-style: none; }
img { max-width: 100%; }

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

/* ── Initial Loader ─────────────────────────────────────── */
.initial-loader {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; height: 100vh; gap: 24px;
}
.loader-logo { display: flex; align-items: center; gap: 12px; }
.logo-mark {
  width: 48px; height: 48px; border-radius: var(--r-md);
  background: var(--accent-grad); display: flex; align-items: center;
  justify-content: center; font-size: 18px; font-weight: 800; color: #fff;
  box-shadow: var(--accent-glow);
}
.logo-text { font-size: 20px; font-weight: 700; color: var(--text-1); }
.loader-spinner {
  width: 32px; height: 32px; border-radius: 50%;
  border: 3px solid var(--border); border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

/* ── Layout ─────────────────────────────────────────────── */
.app-layout { display: flex; height: 100vh; overflow: hidden; }

/* ── Sidebar ────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w); min-width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  overflow: hidden; z-index: 100;
}
.sidebar-logo {
  height: var(--header-h); padding: 0 20px;
  display: flex; align-items: center; gap: 12px;
  border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.sidebar-logo .logo-mark { width: 36px; height: 36px; font-size: 14px; border-radius: 8px; }
.sidebar-logo .logo-text { font-size: 13px; font-weight: 700; line-height: 1.2; }
.sidebar-logo .logo-sub { font-size: 10px; color: var(--text-3); font-weight: 400; }

.sidebar-nav { flex: 1; padding: 12px 10px; overflow-y: auto; }
.nav-section-label {
  font-size: 10px; font-weight: 600; letter-spacing: 0.08em;
  color: var(--text-3); text-transform: uppercase;
  padding: 12px 10px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: var(--r-sm);
  color: var(--text-2); font-size: 13.5px; font-weight: 500;
  cursor: pointer; transition: var(--transition);
  margin-bottom: 2px; position: relative;
  white-space: nowrap; user-select: none;
}
.nav-item:hover { background: rgba(255,255,255,0.05); color: var(--text-1); }
.nav-item.active {
  background: rgba(79,110,247,0.15); color: var(--accent);
  box-shadow: inset 3px 0 0 var(--accent);
}
.nav-item .nav-icon { width: 16px; height: 16px; flex-shrink: 0; }
.nav-badge {
  margin-left: auto; min-width: 18px; height: 18px;
  background: var(--red); color: #fff; font-size: 10px;
  font-weight: 700; border-radius: 9px; display: flex;
  align-items: center; justify-content: center; padding: 0 5px;
}

.sidebar-user {
  padding: 14px 16px; border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px; flex-shrink: 0;
}
.user-avatar {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  background: var(--accent-grad); display: flex; align-items: center;
  justify-content: center; font-size: 12px; font-weight: 700; color: #fff;
}
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: var(--text-3); }
.sidebar-logout { color: var(--text-3); transition: var(--transition); padding: 4px; border-radius: 4px; }
.sidebar-logout:hover { color: var(--red); }

/* ── Main Content ───────────────────────────────────────── */
.main-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

/* ── Header ─────────────────────────────────────────────── */
.app-header {
  height: var(--header-h); background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 16px;
  padding: 0 24px; flex-shrink: 0; z-index: 50;
}
.header-title { font-size: 16px; font-weight: 700; white-space: nowrap; }
.header-search {
  flex: 1; max-width: 420px; position: relative;
}
.header-search input {
  width: 100%; background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 8px 12px 8px 36px;
  color: var(--text-1); font-size: 13px;
  transition: var(--transition); outline: none;
}
.header-search input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79,110,247,0.15); }
.header-search input::placeholder { color: var(--text-3); }
.header-search .search-icon {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  color: var(--text-3); width: 16px; height: 16px; pointer-events: none;
}
.search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: var(--bg-elevated); border: 1px solid var(--border-2);
  border-radius: var(--r-lg); box-shadow: var(--shadow-modal);
  max-height: 400px; overflow-y: auto; z-index: 200;
  display: none;
}
.search-results.open { display: block; }
.search-group-label { padding: 10px 14px 4px; font-size: 10px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.06em; }
.search-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 14px;
  cursor: pointer; transition: var(--transition); font-size: 13px;
}
.search-item:hover { background: rgba(255,255,255,0.05); }
.search-item .search-item-icon { width: 28px; height: 28px; border-radius: 6px; background: var(--bg-card); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.search-item .search-item-sub { font-size: 11px; color: var(--text-3); }
.header-spacer { flex: 1; }
.header-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  width: 36px; height: 36px; border-radius: var(--r-sm);
  background: var(--bg-card); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-2); transition: var(--transition); position: relative;
  cursor: pointer;
}
.icon-btn:hover { border-color: var(--border-2); color: var(--text-1); }
.icon-btn .notif-dot {
  position: absolute; top: 6px; right: 6px; width: 8px; height: 8px;
  background: var(--red); border-radius: 50%;
  border: 2px solid var(--bg-secondary);
}
.header-user-btn {
  display: flex; align-items: center; gap: 8px; padding: 4px 10px 4px 4px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 99px; cursor: pointer; transition: var(--transition);
}
.header-user-btn:hover { border-color: var(--border-2); }
.header-user-btn .user-avatar { width: 28px; height: 28px; font-size: 11px; }
.header-user-btn .user-name { font-size: 13px; font-weight: 500; }

/* ── Page Content ───────────────────────────────────────── */
#page-content {
  flex: 1; overflow-y: auto; padding: 24px;
  background: var(--bg-base);
}
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px; flex-wrap: wrap; gap: 12px;
}
.page-header h1 { font-size: 22px; font-weight: 700; }
.page-subtitle { font-size: 13px; color: var(--text-3); margin-top: 2px; }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 16px; border-radius: var(--r-sm);
  font-size: 13px; font-weight: 500; transition: var(--transition);
  white-space: nowrap; cursor: pointer;
}
.btn-primary {
  background: var(--accent-grad); color: #fff; border: none;
  box-shadow: 0 4px 12px rgba(79,110,247,0.3);
}
.btn-primary:hover { opacity: 0.9; box-shadow: 0 6px 16px rgba(79,110,247,0.4); transform: translateY(-1px); }
.btn-secondary {
  background: var(--bg-card); color: var(--text-1);
  border: 1px solid var(--border-2);
}
.btn-secondary:hover { background: var(--bg-elevated); border-color: var(--accent); }
.btn-ghost { background: transparent; color: var(--text-2); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg-card); color: var(--text-1); }
.btn-danger { background: var(--red-bg); color: var(--red); border: 1px solid rgba(239,68,68,0.25); }
.btn-danger:hover { background: rgba(239,68,68,0.2); }
.btn-success { background: var(--green-bg); color: var(--green); border: 1px solid rgba(16,185,129,0.25); }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-xs { padding: 3px 8px; font-size: 11px; border-radius: 4px; }
.btn svg { width: 14px; height: 14px; }

/* ── Cards ───────────────────────────────────────────────── */
.card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 20px;
  box-shadow: var(--shadow-card);
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.card-title { font-size: 14px; font-weight: 600; }

/* KPI cards */
.kpi-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px; margin-bottom: 20px;
}
.kpi-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 20px;
  position: relative; overflow: hidden;
  transition: var(--transition);
}
.kpi-card::before {
  content: ''; position: absolute; inset: 0;
  background: var(--accent-grad); opacity: 0; transition: var(--transition);
}
.kpi-card:hover { transform: translateY(-2px); box-shadow: 0 8px 32px rgba(0,0,0,0.5); }
.kpi-card:hover::before { opacity: 0.04; }
.kpi-label { font-size: 12px; color: var(--text-3); font-weight: 500; margin-bottom: 8px; }
.kpi-value { font-size: 28px; font-weight: 800; line-height: 1; margin-bottom: 6px; }
.kpi-sub { font-size: 12px; color: var(--text-3); }
.kpi-icon {
  position: absolute; right: 16px; top: 16px;
  width: 40px; height: 40px; border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  opacity: 0.7;
}
.kpi-trend { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; margin-top: 4px; }
.kpi-trend.up { color: var(--green); }
.kpi-trend.down { color: var(--red); }

/* ── Tables ──────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; border-radius: var(--r-lg); border: 1px solid var(--border); }
.crm-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.crm-table th {
  background: var(--bg-secondary); padding: 11px 14px;
  font-size: 11px; font-weight: 600; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.05em;
  text-align: left; white-space: nowrap; cursor: pointer;
  user-select: none; transition: var(--transition);
  border-bottom: 1px solid var(--border);
}
.crm-table th:hover { color: var(--text-1); }
.crm-table td {
  padding: 12px 14px; border-bottom: 1px solid var(--border);
  color: var(--text-1); vertical-align: middle;
}
.crm-table tbody tr { transition: var(--transition); cursor: pointer; }
.crm-table tbody tr:hover { background: var(--bg-card-hover); }
.crm-table tbody tr:last-child td { border-bottom: none; }

/* ── Badges ──────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 99px;
  font-size: 11px; font-weight: 600; white-space: nowrap;
}
.badge-dot { width: 6px; height: 6px; border-radius: 50%; }
.badge-free    { background: var(--green-bg);  color: var(--green); }
.badge-reserved{ background: var(--yellow-bg); color: var(--yellow); }
.badge-precon  { background: var(--blue-bg);   color: var(--blue); }
.badge-ddu     { background: var(--purple-bg); color: var(--purple); }
.badge-fullpaid{ background: var(--cyan-bg);   color: var(--cyan); }
.badge-install { background: var(--orange-bg); color: var(--orange); }
.badge-mortgage{ background: rgba(99,102,241,0.12); color: #818CF8; }
.badge-sold    { background: var(--pink-bg);   color: var(--pink); }
.badge-transfer{ background: rgba(34,197,94,0.12); color: #4ADE80; }
.badge-frozen  { background: rgba(107,114,128,0.15); color: #9CA3AF; }
.badge-dispute { background: var(--red-bg);    color: var(--red); }

.badge-role-admin     { background: var(--red-bg);    color: var(--red); }
.badge-role-director  { background: var(--purple-bg); color: var(--purple); }
.badge-role-manager   { background: var(--blue-bg);   color: var(--blue); }
.badge-role-lawyer    { background: var(--green-bg);  color: var(--green); }
.badge-role-accountant{ background: var(--yellow-bg); color: var(--yellow); }

.badge-paid      { background: var(--green-bg);  color: var(--green); }
.badge-scheduled { background: var(--blue-bg);   color: var(--blue); }
.badge-pending   { background: var(--yellow-bg); color: var(--yellow); }
.badge-overdue   { background: var(--red-bg);    color: var(--red); }
.badge-cancelled { background: rgba(107,114,128,0.15); color: #9CA3AF; }
.badge-vip       { background: rgba(251,191,36,0.15); color: #FBBF24; }

.tag {
  display: inline-flex; padding: 2px 8px; border-radius: 4px;
  font-size: 11px; background: var(--bg-elevated);
  color: var(--text-2); margin: 2px;
}

/* ── Forms ───────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 12px; font-weight: 500; color: var(--text-2); margin-bottom: 6px; }
.form-label.required::after { content: ' *'; color: var(--red); }
.form-input, .form-select, .form-textarea {
  width: 100%; background: var(--bg-secondary);
  border: 1px solid var(--border-2); border-radius: var(--r-sm);
  padding: 9px 12px; color: var(--text-1); font-size: 13px;
  transition: var(--transition); outline: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79,110,247,0.12);
}
.form-input::placeholder, .form-textarea::placeholder { color: var(--text-3); }
.form-select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394A3B8' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 32px; cursor: pointer; }
.form-select option { background: var(--bg-elevated); color: var(--text-1); }
.form-textarea { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-error { font-size: 11px; color: var(--red); margin-top: 4px; }
.form-hint { font-size: 11px; color: var(--text-3); margin-top: 4px; }

/* ── Modal ───────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px); z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn 0.15s ease;
}
.modal {
  background: var(--bg-card); border: 1px solid var(--border-2);
  border-radius: var(--r-xl); box-shadow: var(--shadow-modal);
  width: 90%; max-width: 560px; max-height: 90vh;
  overflow-y: auto; animation: slideUp 0.2s ease;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px; border-bottom: 1px solid var(--border); position: sticky; top: 0;
  background: var(--bg-card); z-index: 1;
}
.modal-title { font-size: 16px; font-weight: 700; }
.modal-close {
  width: 30px; height: 30px; border-radius: 6px; display: flex;
  align-items: center; justify-content: center; color: var(--text-3);
  background: var(--bg-secondary); transition: var(--transition); cursor: pointer;
}
.modal-close:hover { color: var(--text-1); background: var(--bg-elevated); }
.modal-body { padding: 24px; }
.modal-footer {
  padding: 16px 24px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 10px;
}

/* ── Drawer (right side panel) ──────────────────────────── */
.drawer-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  backdrop-filter: blur(3px); z-index: 900;
  animation: fadeIn 0.15s ease;
}
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(640px, 95vw); background: var(--bg-card);
  border-left: 1px solid var(--border-2);
  box-shadow: -24px 0 64px rgba(0,0,0,0.6);
  z-index: 901; display: flex; flex-direction: column;
  animation: slideRight 0.25s ease;
  overflow: hidden;
}
.drawer-header {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 20px 24px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.drawer-header .close-btn {
  margin-left: auto; width: 30px; height: 30px;
  border-radius: 6px; display: flex; align-items: center;
  justify-content: center; color: var(--text-3);
  background: var(--bg-secondary); cursor: pointer;
  transition: var(--transition); flex-shrink: 0;
}
.drawer-header .close-btn:hover { color: var(--text-1); }
.drawer-body { flex: 1; overflow-y: auto; padding: 20px 24px; }

/* ── Tabs ────────────────────────────────────────────────── */
.crm-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tab-btn {
  padding: 10px 16px; font-size: 13px; font-weight: 500;
  color: var(--text-3); border-bottom: 2px solid transparent;
  transition: var(--transition); cursor: pointer; margin-bottom: -1px;
  white-space: nowrap;
}
.tab-btn:hover { color: var(--text-1); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ── Chess Board ─────────────────────────────────────────── */
.chessboard-container { width: 100%; overflow-x: auto; }
.chess-floor-row {
  display: flex; align-items: stretch; gap: 4px; margin-bottom: 4px;
}
.chess-floor-label {
  width: 36px; min-width: 36px; display: flex; align-items: center;
  justify-content: center; font-size: 11px; font-weight: 600;
  color: var(--text-3); flex-shrink: 0;
}
.chess-cells { display: flex; gap: 4px; flex-wrap: nowrap; }
.chess-cell {
  width: 120px; min-width: 120px; height: 76px;
  border-radius: var(--r-sm); padding: 8px;
  cursor: pointer; transition: var(--transition);
  border: 1px solid transparent; position: relative;
  overflow: hidden; display: flex; flex-direction: column;
  justify-content: space-between; flex-shrink: 0;
}
.chess-cell:hover { transform: scale(1.04); box-shadow: 0 6px 20px rgba(0,0,0,0.5); z-index: 10; }
.chess-cell-num { font-size: 13px; font-weight: 700; }
.chess-cell-area { font-size: 10px; color: rgba(255,255,255,0.6); }
.chess-cell-price { font-size: 11px; font-weight: 600; }
.chess-cell-type { font-size: 9px; opacity: 0.7; }

.cell-free      { background: rgba(16,185,129,0.15);  border-color: rgba(16,185,129,0.3);  border-left: 3px solid var(--s-free); }
.cell-reserved  { background: rgba(245,158,11,0.15);  border-color: rgba(245,158,11,0.3);  border-left: 3px solid var(--s-reserved); }
.cell-precon    { background: rgba(59,130,246,0.15);  border-color: rgba(59,130,246,0.3);  border-left: 3px solid var(--s-precon); }
.cell-ddu       { background: rgba(139,92,246,0.15);  border-color: rgba(139,92,246,0.3);  border-left: 3px solid var(--s-ddu); }
.cell-fullpaid  { background: rgba(6,182,212,0.15);   border-color: rgba(6,182,212,0.3);   border-left: 3px solid var(--s-fullpaid); }
.cell-install   { background: rgba(249,115,22,0.15);  border-color: rgba(249,115,22,0.3);  border-left: 3px solid var(--s-install); }
.cell-mortgage  { background: rgba(99,102,241,0.15);  border-color: rgba(99,102,241,0.3);  border-left: 3px solid var(--s-mortgage); }
.cell-sold      { background: rgba(236,72,153,0.15);  border-color: rgba(236,72,153,0.3);  border-left: 3px solid var(--s-sold); }
.cell-transfer  { background: rgba(34,197,94,0.15);   border-color: rgba(34,197,94,0.3);   border-left: 3px solid var(--s-transfer); }
.cell-frozen    { background: rgba(107,114,128,0.15); border-color: rgba(107,114,128,0.3); border-left: 3px solid var(--s-frozen); }
.cell-dispute   { background: rgba(239,68,68,0.15);   border-color: rgba(239,68,68,0.3);   border-left: 3px solid var(--s-dispute); }

.chess-legend {
  display: flex; flex-wrap: wrap; gap: 8px 16px;
  padding: 14px 0; margin-bottom: 12px;
}
.legend-item {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--text-2); white-space: nowrap;
}
.legend-dot { width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0; }

.block-tabs { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.block-tab {
  padding: 7px 18px; border-radius: var(--r-sm); font-size: 13px;
  font-weight: 500; background: var(--bg-card);
  border: 1px solid var(--border); color: var(--text-2);
  cursor: pointer; transition: var(--transition);
}
.block-tab:hover { border-color: var(--accent); color: var(--accent); }
.block-tab.active { background: rgba(79,110,247,0.15); border-color: var(--accent); color: var(--accent); }
.block-tab .block-tab-count { font-size: 11px; color: var(--text-3); margin-left: 4px; }

.chess-filters {
  display: flex; align-items: center; gap: 10px;
  flex-wrap: wrap; margin-bottom: 12px; padding: 12px;
  background: var(--bg-card); border-radius: var(--r-md);
  border: 1px solid var(--border);
}
.chess-filters label { font-size: 12px; color: var(--text-3); }
.chess-filters .form-select { width: auto; min-width: 140px; padding: 6px 28px 6px 10px; font-size: 12px; }
.chess-filters .form-input { width: 110px; padding: 6px 10px; font-size: 12px; }

.chess-stats {
  display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 12px;
}
.chess-stat {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text-2);
}
.chess-stat strong { color: var(--text-1); }

/* ── Kanban Board ────────────────────────────────────────── */
.kanban-board {
  display: flex; gap: 12px; overflow-x: auto;
  padding-bottom: 12px; min-height: 500px;
}
.kanban-col {
  min-width: 220px; max-width: 220px;
  background: var(--bg-secondary);
  border-radius: var(--r-lg); border: 1px solid var(--border);
  display: flex; flex-direction: column; overflow: hidden;
}
.kanban-col-header {
  padding: 12px 14px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px; flex-shrink: 0;
}
.kanban-col-title { font-size: 13px; font-weight: 600; flex: 1; }
.kanban-col-count {
  width: 20px; height: 20px; border-radius: 99px;
  background: var(--bg-elevated); font-size: 11px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; color: var(--text-2);
}
.kanban-col-sum { font-size: 10px; color: var(--text-3); padding: 0 14px 8px; }
.kanban-cards { padding: 8px; flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.kanban-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 12px; cursor: pointer;
  transition: var(--transition);
}
.kanban-card:hover { border-color: var(--accent); box-shadow: 0 4px 16px rgba(0,0,0,0.3); transform: translateY(-1px); }
.kanban-card-apt { font-size: 12px; color: var(--text-3); margin-bottom: 4px; }
.kanban-card-client { font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.kanban-card-price { font-size: 13px; color: var(--accent); font-weight: 600; }
.kanban-card-footer { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }
.kanban-card-days { font-size: 11px; color: var(--text-3); }
.kanban-card-mgr { width: 22px; height: 22px; border-radius: 50%; background: var(--accent-grad); display: flex; align-items: center; justify-content: center; font-size: 9px; font-weight: 700; color: #fff; }

/* ── Timeline (audit history) ────────────────────────────── */
.timeline { position: relative; padding-left: 24px; }
.timeline::before { content: ''; position: absolute; left: 7px; top: 0; bottom: 0; width: 2px; background: var(--border); }
.timeline-item { position: relative; margin-bottom: 20px; }
.timeline-item::before {
  content: ''; position: absolute; left: -20px; top: 4px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--bg-card);
}
.timeline-date { font-size: 11px; color: var(--text-3); margin-bottom: 4px; }
.timeline-content {
  background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 12px;
}
.timeline-title { font-size: 13px; font-weight: 500; margin-bottom: 4px; }
.timeline-user { font-size: 11px; color: var(--text-3); }
.timeline-change { display: flex; align-items: center; gap: 8px; margin-top: 6px; font-size: 12px; }
.timeline-change .arrow { color: var(--text-3); }

/* ── Upload Zone ─────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--border-2); border-radius: var(--r-lg);
  padding: 32px 20px; text-align: center; cursor: pointer;
  transition: var(--transition); background: var(--bg-secondary);
}
.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--accent); background: rgba(79,110,247,0.05);
}
.upload-zone-icon { color: var(--text-3); margin-bottom: 12px; }
.upload-zone-text { font-size: 13px; color: var(--text-2); }
.upload-zone-hint { font-size: 11px; color: var(--text-3); margin-top: 4px; }

/* ── Progress Bar ────────────────────────────────────────── */
.progress-bar { height: 6px; background: var(--bg-elevated); border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--accent-grad); border-radius: 3px; transition: width 0.5s ease; }
.progress-fill.green  { background: var(--green); }
.progress-fill.yellow { background: var(--yellow); }
.progress-fill.red    { background: var(--red); }

/* ── Charts ──────────────────────────────────────────────── */
.chart-container { position: relative; }
.charts-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 20px; }
.charts-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; margin-bottom: 20px; }

/* ── Activity Feed ───────────────────────────────────────── */
.activity-feed { display: flex; flex-direction: column; gap: 12px; }
.activity-item { display: flex; align-items: flex-start; gap: 10px; }
.activity-avatar {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  background: var(--bg-elevated); display: flex; align-items: center;
  justify-content: center; font-size: 11px; font-weight: 700;
}
.activity-body { flex: 1; }
.activity-text { font-size: 13px; line-height: 1.4; }
.activity-text strong { color: var(--accent); }
.activity-time { font-size: 11px; color: var(--text-3); margin-top: 2px; }

/* ── Notification Items ──────────────────────────────────── */
.notif-list { display: flex; flex-direction: column; gap: 6px; }
.notif-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 16px; border-radius: var(--r-md);
  background: var(--bg-card); border: 1px solid var(--border);
  cursor: pointer; transition: var(--transition);
  position: relative;
}
.notif-item.unread { background: rgba(79,110,247,0.06); border-color: rgba(79,110,247,0.2); }
.notif-item.unread::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; border-radius: 3px 0 0 3px; background: var(--accent); }
.notif-item:hover { background: var(--bg-card-hover); }
.notif-icon-wrap {
  width: 36px; height: 36px; border-radius: var(--r-sm); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.notif-body { flex: 1; }
.notif-title { font-size: 13px; font-weight: 500; margin-bottom: 3px; }
.notif-text { font-size: 12px; color: var(--text-2); }
.notif-time { font-size: 11px; color: var(--text-3); margin-top: 4px; }

/* ── Info Grid (detail views) ───────────────────────────── */
.info-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
}
.info-grid-3 { grid-template-columns: 1fr 1fr 1fr; }
.info-item {}
.info-label { font-size: 11px; color: var(--text-3); font-weight: 500; margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.04em; }
.info-value { font-size: 13px; color: var(--text-1); font-weight: 500; }
.info-value.large { font-size: 18px; font-weight: 700; color: var(--accent); }

/* ── Stat Cards Row ──────────────────────────────────────── */
.stat-cards { display: flex; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.stat-card {
  flex: 1; min-width: 120px; background: var(--bg-secondary);
  border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 12px 16px; text-align: center;
}
.stat-card-val { font-size: 22px; font-weight: 800; }
.stat-card-label { font-size: 11px; color: var(--text-3); margin-top: 2px; }

/* ── Filters Bar ─────────────────────────────────────────── */
.filters-bar {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
  margin-bottom: 16px;
}
.filters-bar .form-select { width: auto; min-width: 150px; }
.filters-bar .form-input  { width: auto; min-width: 200px; }

/* ── Empty State ─────────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 60px 20px; color: var(--text-3);
}
.empty-state-icon { margin-bottom: 16px; opacity: 0.5; }
.empty-state-text { font-size: 15px; font-weight: 500; margin-bottom: 6px; color: var(--text-2); }
.empty-state-sub  { font-size: 13px; }

/* ── Toast ───────────────────────────────────────────────── */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px;
  border-radius: var(--r-md); box-shadow: var(--shadow-modal);
  min-width: 280px; max-width: 380px; animation: slideUp 0.2s ease;
  font-size: 13px; font-weight: 500;
}
.toast-success { background: #064E3B; border: 1px solid rgba(16,185,129,0.4); color: #6EE7B7; }
.toast-error   { background: #450A0A; border: 1px solid rgba(239,68,68,0.4);  color: #FCA5A5; }
.toast-warning { background: #422006; border: 1px solid rgba(245,158,11,0.4); color: #FCD34D; }
.toast-info    { background: #0C1A4E; border: 1px solid rgba(79,110,247,0.4); color: #93C5FD; }
.toast-icon { flex-shrink: 0; }
.toast-close { margin-left: auto; cursor: pointer; opacity: 0.6; }
.toast-close:hover { opacity: 1; }

/* ── Login Page ──────────────────────────────────────────── */
.login-page {
  min-height: 100vh; display: flex; align-items: center;
  justify-content: center; background: var(--bg-base);
  position: relative; overflow: hidden;
}
.login-bg {
  position: absolute; inset: 0; pointer-events: none;
  overflow: hidden;
}
.login-orb {
  position: absolute; border-radius: 50%; filter: blur(80px);
  opacity: 0.18; animation: float 8s ease-in-out infinite;
}
.login-orb-1 { width: 600px; height: 600px; background: var(--accent); top: -200px; left: -100px; }
.login-orb-2 { width: 400px; height: 400px; background: var(--accent-2); bottom: -100px; right: -50px; animation-delay: -4s; }
.login-card {
  position: relative; width: 420px; max-width: 95vw;
  background: rgba(17,24,39,0.85); backdrop-filter: blur(20px);
  border: 1px solid var(--border-2); border-radius: var(--r-xl);
  padding: 40px; box-shadow: var(--shadow-modal);
}
.login-logo { text-align: center; margin-bottom: 32px; }
.login-logo .logo-mark { width: 56px; height: 56px; font-size: 22px; margin: 0 auto 12px; }
.login-logo h1 { font-size: 20px; font-weight: 700; }
.login-logo p  { font-size: 13px; color: var(--text-3); margin-top: 4px; }
.login-demo { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--r-md); padding: 10px 14px; margin-bottom: 20px; font-size: 12px; color: var(--text-3); }
.login-demo strong { color: var(--text-2); }
.login-error { background: var(--red-bg); border: 1px solid rgba(239,68,68,0.3); border-radius: var(--r-sm); padding: 10px 14px; font-size: 13px; color: var(--red); margin-bottom: 16px; display: none; }
.login-error.show { display: block; }

/* ── Docs ────────────────────────────────────────────────── */
.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.doc-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 16px; cursor: pointer;
  transition: var(--transition);
}
.doc-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,0.4); }
.doc-card-icon { width: 40px; height: 40px; border-radius: var(--r-sm); display: flex; align-items: center; justify-content: center; margin-bottom: 12px; }
.doc-card-title { font-size: 13px; font-weight: 600; margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-card-meta { font-size: 11px; color: var(--text-3); }
.doc-card-footer { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; }
.doc-version-badge { font-size: 11px; padding: 2px 8px; background: var(--purple-bg); color: var(--purple); border-radius: 99px; }

.doc-versions { display: flex; flex-direction: column; gap: 10px; }
.doc-version-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px; border-radius: var(--r-md);
  background: var(--bg-secondary); border: 1px solid var(--border);
  transition: var(--transition);
}
.doc-version-item.current { border-color: rgba(79,110,247,0.4); background: rgba(79,110,247,0.06); }
.doc-version-num { font-size: 12px; font-weight: 700; min-width: 32px; }
.doc-version-info { flex: 1; }
.doc-version-user { font-size: 12px; font-weight: 500; }
.doc-version-date { font-size: 11px; color: var(--text-3); }
.doc-version-comment { font-size: 12px; color: var(--text-2); margin-top: 2px; }

/* ── Role matrix ─────────────────────────────────────────── */
.role-matrix { overflow-x: auto; }
.role-matrix table { width: 100%; border-collapse: collapse; font-size: 12px; }
.role-matrix th, .role-matrix td { padding: 10px 14px; border: 1px solid var(--border); text-align: center; }
.role-matrix th:first-child, .role-matrix td:first-child { text-align: left; font-weight: 500; }
.role-matrix th { background: var(--bg-secondary); color: var(--text-2); }
.check-yes { color: var(--green); }
.check-no  { color: var(--border-2); }

/* ── Finance ─────────────────────────────────────────────── */
.finance-summary {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px;
}
.deal-stage-bar {
  display: flex; height: 8px; border-radius: 4px; overflow: hidden; gap: 2px; margin: 12px 0;
}
.stage-segment { height: 100%; border-radius: 2px; transition: var(--transition); }

/* ── Animations ──────────────────────────────────────────── */
@keyframes fadeIn  { from { opacity: 0; }             to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideRight { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: translateX(0); } }
@keyframes spin    { to { transform: rotate(360deg); } }
@keyframes float   { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-20px); } }
@keyframes pulse   { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }

.skeleton {
  background: linear-gradient(90deg, var(--bg-card) 0%, var(--bg-elevated) 50%, var(--bg-card) 100%);
  background-size: 200% 100%; animation: skeleton 1.5s infinite;
  border-radius: var(--r-sm);
}
@keyframes skeleton { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ── Misc Utilities ──────────────────────────────────────── */
.flex         { display: flex; }
.flex-col     { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mb-2  { margin-bottom: 8px; }
.mb-3  { margin-bottom: 12px; }
.mb-4  { margin-bottom: 16px; }
.mb-5  { margin-bottom: 20px; }
.mt-4  { margin-top: 16px; }
.text-muted   { color: var(--text-3); }
.text-accent  { color: var(--accent); }
.text-green   { color: var(--green); }
.text-red     { color: var(--red); }
.text-yellow  { color: var(--yellow); }
.font-bold    { font-weight: 700; }
.font-mono    { font-family: 'JetBrains Mono', 'Fira Code', monospace; }
.truncate     { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.w-full       { width: 100%; }
.divider      { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.section-title { font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 12px; text-transform: uppercase; letter-spacing: 0.05em; }

/* ── Pagination ──────────────────────────────────────────── */
.pagination { display: flex; gap: 4px; align-items: center; margin-top: 16px; }
.page-btn {
  width: 32px; height: 32px; border-radius: var(--r-sm); font-size: 12px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-card); border: 1px solid var(--border);
  color: var(--text-2); cursor: pointer; transition: var(--transition);
}
.page-btn:hover { border-color: var(--accent); color: var(--accent); }
.page-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Initial Loading Screen ─────────────────────────────── */
.initial-loading {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-base); flex-direction: column; gap: 24px;
}
.initial-loading__inner {
  display: flex; flex-direction: column; align-items: center; gap: 20px;
  position: relative; z-index: 2;
}
.initial-loading__logo { display: flex; align-items: center; gap: 14px; }
.initial-loading__logo-icon {
  width: 52px; height: 52px; border-radius: 14px;
  background: var(--accent-grad); display: flex; align-items: center;
  justify-content: center; font-size: 22px; font-weight: 800; color: #fff;
  box-shadow: var(--accent-glow);
}
.initial-loading__logo-text { display: flex; flex-direction: column; }
.initial-loading__logo-title { font-size: 22px; font-weight: 800; color: var(--text-1); }
.initial-loading__logo-subtitle { font-size: 13px; color: var(--text-3); }
.initial-loading__spinner { display: flex; justify-content: center; }
.initial-loading__message { font-size: 13px; color: var(--text-3); }
.initial-loading__orb {
  position: absolute; border-radius: 50%; filter: blur(80px);
  opacity: 0.12; animation: float 8s ease-in-out infinite;
}
.initial-loading__orb--1 { width: 500px; height: 500px; background: var(--accent); top: -200px; left: -150px; }
.initial-loading__orb--2 { width: 400px; height: 400px; background: var(--accent-2); bottom: -150px; right: -100px; animation-delay: -4s; }
.initial-loading__orb--3 { width: 300px; height: 300px; background: #06B6D4; top: 50%; right: 10%; animation-delay: -2s; }

/* ── Spinner ────────────────────────────────────────────── */
.spinner {
  border-radius: 50%;
  border: 3px solid var(--border-2);
  border-top-color: var(--accent);
  animation: spin 0.75s linear infinite;
}
.spinner--sm { width: 18px; height: 18px; border-width: 2px; }
.spinner--md { width: 28px; height: 28px; }
.spinner--lg { width: 40px; height: 40px; border-width: 4px; }

/* ── Additional Utilities ───────────────────────────────── */
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-5 { margin-top: 20px; }
.gap-1 { gap: 4px; }
.gap-5 { gap: 20px; }
.pl-2 { padding-left: 8px; }
.opacity-50 { opacity: 0.5; }
.rounded   { border-radius: var(--r-md); }
.rounded-lg{ border-radius: var(--r-lg); }
.text-sm   { font-size: 12px; }
.text-xs   { font-size: 11px; }
.border-t  { border-top: 1px solid var(--border); }
.min-w-0   { min-width: 0; }

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 900px) {
  :root { --sidebar-w: 60px; }
  .sidebar-logo { justify-content: center; }
  .sidebar-logo .logo-text,
  .sidebar-logo .logo-sub,
  .nav-section-label,
  .user-info,
  .sidebar-logout,
  .nav-item span:not(.nav-badge) { display: none; }
  .nav-item { justify-content: center; padding: 10px; }
  .sidebar-user { padding: 10px; justify-content: center; }
  .charts-row { grid-template-columns: 1fr; }
  .finance-summary { grid-template-columns: 1fr 1fr; }
  .info-grid { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .form-row { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  #page-content { padding: 16px; }
  .chess-cell { width: 90px; min-width: 90px; height: 68px; font-size: 11px; }
  .kanban-board { gap: 8px; }
  .kanban-col { min-width: 180px; }
  .kpi-grid { grid-template-columns: 1fr; }
  .finance-summary { grid-template-columns: 1fr; }
  .charts-row { grid-template-columns: 1fr; }
}

/* ═══════════════════════════════════════════════════════════
   BUILDINGS EDITOR — Редактор корпусов
   ═══════════════════════════════════════════════════════════ */

.buildings-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 20px;
  min-height: calc(100vh - 180px);
  align-items: start;
}
.buildings-sidebar {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  position: sticky;
  top: 20px;
}
.buildings-sidebar-title {
  padding: 14px 18px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
}
.buildings-list {
  overflow-y: auto;
  max-height: calc(100vh - 220px);
}
.building-card {
  padding: 14px 18px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: var(--transition);
}
.building-card:last-child { border-bottom: none; }
.building-card:hover { background: var(--bg-elevated); }
.building-card.active {
  background: rgba(79,110,247,0.1);
  border-left: 3px solid var(--accent);
}
.building-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.building-card-icon {
  width: 36px; height: 36px;
  border-radius: 8px;
  background: var(--accent-grad);
  color: #fff;
  font-weight: 800;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  letter-spacing: -0.5px;
}
.building-card-info { flex: 1; min-width: 0; }
.building-card-name { font-size: 13px; font-weight: 600; color: var(--text-1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.building-card-meta { font-size: 11px; color: var(--text-3); margin-top: 2px; }
.building-card-badge { font-size: 11px; color: var(--text-2); white-space: nowrap; flex-shrink: 0; }
.building-card-badge .text-green { color: var(--green); font-weight: 600; }
.building-progress-bar { height: 3px; background: var(--border-2); border-radius: 2px; overflow: hidden; }
.building-progress-fill { height: 100%; background: var(--accent-grad); border-radius: 2px; transition: width 0.4s ease; }

.buildings-detail {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.detail-header {
  padding: 24px 24px 0;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
}
.detail-title-row {
  display: flex; align-items: center; gap: 16px; margin-bottom: 20px;
}
.detail-icon {
  width: 52px; height: 52px;
  border-radius: 12px;
  background: var(--accent-grad);
  color: #fff;
  font-weight: 900;
  font-size: 18px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  letter-spacing: -1px;
  box-shadow: 0 4px 16px rgba(79,110,247,0.35);
}
.detail-title { font-size: 20px; font-weight: 700; color: var(--text-1); margin: 0 0 4px; }
.detail-subtitle { font-size: 13px; color: var(--text-3); }
.detail-actions { margin-left: auto; }

.detail-kpis { display: flex; gap: 24px; padding: 16px 0; flex-wrap: wrap; }
.detail-kpi { text-align: center; }
.detail-kpi-val { font-size: 26px; font-weight: 800; color: var(--text-1); line-height: 1.1; }
.detail-kpi-label { font-size: 11px; color: var(--text-3); margin-top: 2px; white-space: nowrap; }
.detail-kpi.text-green  .detail-kpi-val { color: var(--green); }
.detail-kpi.text-yellow .detail-kpi-val { color: var(--yellow); }
.detail-kpi.text-accent .detail-kpi-val { color: var(--accent); }
.detail-kpi.text-red    .detail-kpi-val { color: var(--red); }

.detail-body { padding: 24px; overflow-y: auto; max-height: calc(100vh - 300px); }

/* Overview */
.overview-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.status-distribution { display: flex; flex-direction: column; gap: 8px; }
.status-dist-row { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.status-dist-dot { width: 8px; height: 8px; border-radius: 2px; flex-shrink: 0; }
.status-dist-label { width: 110px; color: var(--text-2); flex-shrink: 0; }
.status-dist-bar-wrap { flex: 1; height: 6px; background: var(--border-2); border-radius: 3px; overflow: hidden; }
.status-dist-bar { height: 100%; border-radius: 3px; transition: width 0.4s; min-width: 3px; }
.status-dist-cnt { width: 24px; text-align: right; font-weight: 600; color: var(--text-1); flex-shrink: 0; }

/* Floor summary */
.floor-summary-list { display: flex; flex-direction: column; gap: 4px; }
.floor-summary-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 8px;
  background: var(--bg-secondary);
  font-size: 12px; transition: var(--transition);
}
.floor-summary-row:hover { background: var(--bg-elevated); }
.floor-summary-row.comm-floor { background: rgba(245,158,11,0.06); }
.floor-num-badge {
  width: 26px; height: 26px; border-radius: 6px;
  background: var(--bg-elevated); color: var(--text-1);
  font-weight: 700; font-size: 12px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; border: 1px solid var(--border-2);
}
.floor-type-tag { min-width: 80px; }
.floor-units-info { flex: 1; color: var(--text-2); }
.floor-units-info .text-green { color: var(--green); font-weight: 600; }

/* Floors tab */
.floors-editor { display: flex; flex-direction: column; gap: 20px; }
.floors-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: var(--bg-elevated);
  border-radius: 10px; border: 1px solid var(--border);
}
.floor-section { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.floor-section-header {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
}
.floor-section-num { font-weight: 700; font-size: 14px; color: var(--text-1); min-width: 60px; }
.floor-section-count { font-size: 12px; color: var(--text-3); }
.floor-section-actions { margin-left: auto; }

/* Unit cells */
.units-grid { display: flex; flex-wrap: wrap; gap: 8px; padding: 16px; background: var(--bg-secondary); }
.unit-cell {
  width: 90px; min-height: 80px;
  border-radius: 10px; border: 1px solid;
  padding: 10px 8px; cursor: pointer;
  transition: var(--transition);
  display: flex; flex-direction: column; justify-content: space-between;
  text-align: center;
}
.unit-cell:hover { transform: translateY(-2px); filter: brightness(1.15); }
.unit-cell-num { font-weight: 800; font-size: 15px; color: var(--text-1); line-height: 1; }
.unit-cell-area { font-size: 11px; color: var(--text-2); font-weight: 500; }
.unit-cell-type { font-size: 10px; color: var(--text-3); margin-top: 2px; }
.unit-add-btn {
  width: 90px; min-height: 80px;
  border-radius: 10px; border: 2px dashed var(--border-2);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text-3); transition: var(--transition); font-size: 20px;
}
.unit-add-btn:hover { border-color: var(--accent); color: var(--accent); background: rgba(79,110,247,0.06); }
.unit-add-btn i { width: 20px; height: 20px; }

/* Settings */
.settings-form { display: flex; flex-direction: column; gap: 16px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.comm-floors-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.comm-floor-toggle {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 12px 16px; border-radius: 10px;
  border: 2px solid var(--border-2); cursor: pointer; transition: var(--transition); min-width: 80px;
}
.comm-floor-toggle input[type="checkbox"] { display: none; }
.comm-floor-toggle:hover { border-color: var(--accent); background: rgba(79,110,247,0.06); }
.comm-floor-toggle.active { border-color: var(--yellow); background: rgba(245,158,11,0.1); }
.comm-floor-label { font-weight: 700; font-size: 13px; color: var(--text-1); }
.comm-floor-tag { font-size: 10px; color: var(--text-3); }
.comm-floor-toggle.active .comm-floor-tag { color: var(--yellow); }

.sizes-editor { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.size-tag {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px; border-radius: 20px;
  background: var(--bg-elevated); border: 1px solid var(--border-2);
  font-size: 12px; font-weight: 500; color: var(--text-1); transition: var(--transition);
}
.size-tag:hover { border-color: var(--red); }
.size-remove { background: none; border: none; color: var(--text-3); cursor: pointer; font-size: 14px; line-height: 1; padding: 0; transition: var(--transition); }
.size-remove:hover { color: var(--red); }
.size-add-wrap { display: flex; align-items: center; gap: 6px; }
.size-add-input { width: 90px !important; padding: 5px 10px !important; font-size: 12px !important; }

/* Card header helper */
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-title { font-size: 14px; font-weight: 600; color: var(--text-1); }

/* Info grid */
.info-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px,1fr)); gap: 12px; }
.info-label { font-size: 11px; color: var(--text-3); margin-bottom: 3px; text-transform: uppercase; letter-spacing: 0.05em; }
.info-value { font-size: 13px; font-weight: 500; color: var(--text-1); }
.info-value.large { font-size: 16px; font-weight: 700; color: var(--accent); }

/* Stat cards (finance drawer) */
.stat-cards { display: flex; gap: 12px; flex-wrap: wrap; }
.stat-card { flex: 1; min-width: 100px; padding: 14px; border-radius: 10px; background: var(--bg-elevated); border: 1px solid var(--border); text-align: center; }
.stat-card-val { font-size: 18px; font-weight: 700; color: var(--text-1); }
.stat-card-label { font-size: 11px; color: var(--text-3); margin-top: 4px; }
.stat-card-val.text-accent { color: var(--accent); }
.stat-card-val.text-green  { color: var(--green); }
.stat-card-val.text-red    { color: var(--red); }

.divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.mb-4 { margin-bottom: 16px; }
.mt-4 { margin-top: 16px; }

/* Text utilities */
.text-green  { color: var(--green)  !important; }
.text-yellow { color: var(--yellow) !important; }
.text-red    { color: var(--red)    !important; }
.text-accent { color: var(--accent) !important; }
.text-muted  { color: var(--text-3) !important; }

/* Badge variants */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 20px;
  font-size: 11px; font-weight: 600;
  background: var(--bg-elevated); color: var(--text-2);
  border: 1px solid var(--border-2);
}
.badge-warning { background: rgba(245,158,11,0.15); color: var(--yellow); border-color: rgba(245,158,11,0.3); }

/* ═══════════════════════════════════════════════════════════
   UPDATED CHESSBOARD — 11 корпусов
   ═══════════════════════════════════════════════════════════ */

.chess-building-tabs {
  display: flex; gap: 6px;
  overflow-x: auto; padding-bottom: 4px; margin-bottom: 16px;
  scrollbar-width: thin; scrollbar-color: var(--border-2) transparent;
}
.chess-building-tabs::-webkit-scrollbar { height: 4px; }
.chess-building-tabs::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 2px; }

.chess-btab {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 10px 16px; border-radius: 10px;
  border: 1px solid var(--border-2); background: var(--bg-card);
  cursor: pointer; transition: var(--transition);
  white-space: nowrap; flex-shrink: 0; min-width: 64px;
}
.chess-btab:hover { border-color: var(--accent); background: rgba(79,110,247,0.06); }
.chess-btab.active { border-color: var(--accent); background: rgba(79,110,247,0.14); box-shadow: 0 0 12px rgba(79,110,247,0.2); }
.chess-btab-code { font-weight: 800; font-size: 16px; color: var(--text-1); line-height: 1; }
.chess-btab.active .chess-btab-code { color: var(--accent); }
.chess-btab-free { font-size: 10px; font-weight: 500; color: var(--green); }
.chess-btab-free.zero { color: var(--text-3); }

.chess-stats {
  display: flex; align-items: center; flex-wrap: wrap; gap: 12px;
  padding: 10px 16px; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: 10px;
  margin-bottom: 16px; font-size: 12px;
}
.chess-stats-building {
  display: flex; align-items: center; gap: 8px;
  font-weight: 600; color: var(--text-1);
  padding-right: 12px; border-right: 1px solid var(--border-2); flex-shrink: 0;
}
.chess-stats-counts { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; flex: 1; }
.chess-stat { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text-2); }
.chess-stat strong { color: var(--text-1); font-weight: 600; }

.chess-floor-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.chess-floor-comm { opacity: 0.9; }
.chess-floor-label {
  display: flex; flex-direction: column; align-items: center;
  width: 44px; flex-shrink: 0; font-size: 12px; font-weight: 700; color: var(--text-3); gap: 2px;
}
.chess-comm-tag { font-size: 9px; font-weight: 700; color: var(--yellow); letter-spacing: 0.03em; line-height: 1; }
.chess-cell-comm { opacity: 0.88; border-style: dashed !important; }
.chess-cell-comm .chess-cell-type { color: var(--yellow) !important; }

/* Responsive */
@media (max-width: 900px) {
  .buildings-layout { grid-template-columns: 1fr; }
  .buildings-sidebar { position: static; max-height: 280px; overflow-y: auto; }
  .detail-body { max-height: none; }
  .overview-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .form-row-2 { grid-template-columns: 1fr; }
  .chess-btab { padding: 8px 10px; min-width: 52px; }
  .chess-btab-code { font-size: 13px; }
}

/* ══════════════════════════════════════════════════════════
   STORAGE / DOCUMENTS — compression badge, drag-over
   ══════════════════════════════════════════════════════════ */

.compression-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 700;
  background: rgba(16,185,129,0.15);
  color: var(--green);
  border: 1px solid rgba(16,185,129,0.3);
  margin-left: 4px;
}

.compression-info {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 8px;
  background: rgba(79,110,247,0.08);
  border: 1px solid rgba(79,110,247,0.2);
  font-size: 12px;
  color: var(--text-2);
  margin-bottom: 4px;
}

.upload-zone.drag-over {
  border-color: var(--accent);
  background: rgba(79,110,247,0.08);
  transform: scale(1.01);
}

.upload-zone {
  transition: var(--transition), transform 0.15s ease;
}

/* ══════════════════════════════════════════════════════════
   LOGIN PAGE — 2FA styles
   ══════════════════════════════════════════════════════════ */

.login-page { min-height:100vh; display:flex; align-items:center; justify-content:center; position:relative; overflow:hidden; background:var(--bg-base); }
.login-bg { position:absolute; inset:0; pointer-events:none; }
.login-bg-orb { position:absolute; border-radius:50%; filter:blur(80px); opacity:0.18; animation:orbFloat 8s ease-in-out infinite; }
.orb1 { width:500px; height:500px; background:var(--accent); top:-100px; left:-100px; animation-delay:0s; }
.orb2 { width:400px; height:400px; background:var(--accent-2); bottom:-80px; right:-80px; animation-delay:3s; }
.orb3 { width:300px; height:300px; background:#06B6D4; top:50%; left:50%; transform:translate(-50%,-50%); animation-delay:1.5s; }
@keyframes orbFloat { 0%,100%{transform:translateY(0) scale(1)} 50%{transform:translateY(-20px) scale(1.05)} }

.login-card {
  position:relative; z-index:1;
  background:rgba(17,24,39,0.85);
  backdrop-filter:blur(20px);
  border:1px solid rgba(255,255,255,0.1);
  border-radius:24px;
  padding:40px 36px;
  width:100%; max-width:420px;
  box-shadow:0 24px 64px rgba(0,0,0,0.5);
  animation:slideUpFade 0.4s ease;
}
@keyframes slideUpFade { from{opacity:0;transform:translateY(20px)} to{opacity:1;transform:translateY(0)} }

.login-logo { display:flex; align-items:center; gap:14px; margin-bottom:28px; }
.login-logo-mark {
  width:48px; height:48px; border-radius:14px;
  background:var(--accent-grad);
  color:#fff; font-weight:900; font-size:16px;
  display:flex; align-items:center; justify-content:center;
  box-shadow:0 4px 16px rgba(79,110,247,0.4);
  flex-shrink:0;
}
.login-logo-name { font-size:16px; font-weight:700; color:var(--text-1); }
.login-logo-sub  { font-size:12px; color:var(--text-3); }
.login-title  { font-size:22px; font-weight:800; color:var(--text-1); margin-bottom:6px; }
.login-subtitle { font-size:13px; color:var(--text-3); margin-bottom:24px; }

.input-icon-wrap { position:relative; }
.input-icon { position:absolute; left:12px; top:50%; transform:translateY(-50%); width:16px; height:16px; color:var(--text-3); pointer-events:none; }
.form-input.with-icon { padding-left:38px; }
.input-toggle-pass { position:absolute; right:10px; top:50%; transform:translateY(-50%); background:none; border:none; cursor:pointer; color:var(--text-3); padding:4px; transition:var(--transition); }
.input-toggle-pass:hover { color:var(--text-1); }

.login-btn { width:100%; margin-top:8px; justify-content:center; font-size:15px; padding:12px; }
.login-error {
  display:flex; align-items:center; gap:8px;
  padding:10px 14px; border-radius:10px;
  background:rgba(239,68,68,0.12); border:1px solid rgba(239,68,68,0.3);
  color:#FCA5A5; font-size:13px; margin-bottom:12px; margin-top:8px;
}
.login-footer { text-align:center; font-size:11px; color:var(--text-3); margin-top:28px; }

.twofa-icon { text-align:center; padding:20px 0; }
.twofa-input {
  text-align:center; letter-spacing:0.5em;
  font-size:28px; font-weight:700; font-family:monospace;
  padding:16px; border-radius:14px;
}
.twofa-input::placeholder { letter-spacing:0.2em; font-size:18px; }

.shake { animation:shake 0.4s ease; }
@keyframes shake { 0%,100%{transform:translateX(0)} 20%,60%{transform:translateX(-6px)} 40%,80%{transform:translateX(6px)} }

.spinner-sm {
  display:inline-block; width:14px; height:14px;
  border:2px solid rgba(255,255,255,0.3);
  border-top-color:#fff;
  border-radius:50%;
  animation:spin 0.7s linear infinite;
  vertical-align:middle;
}
@keyframes spin { to{transform:rotate(360deg)} }

/* ══════════════════════════════════════════════════════════
   MOBILE RESPONSIVE — полная адаптация
   ══════════════════════════════════════════════════════════ */

/* ── Mobile sidebar toggle button ─────────────────────── */
.sidebar-toggle {
  display:none;
  position:fixed; top:14px; left:14px; z-index:200;
  width:40px; height:40px; border-radius:10px;
  background:var(--bg-card); border:1px solid var(--border);
  align-items:center; justify-content:center;
  cursor:pointer; transition:var(--transition);
  box-shadow:0 2px 12px rgba(0,0,0,0.3);
}
.sidebar-toggle:hover { background:var(--bg-elevated); border-color:var(--accent); }
.sidebar-toggle i { width:18px; height:18px; color:var(--text-1); }

/* Overlay when sidebar is open on mobile */
.sidebar-overlay {
  display:none;
  position:fixed; inset:0; z-index:98;
  background:rgba(0,0,0,0.55);
  backdrop-filter:blur(2px);
}
.sidebar-overlay.active { display:block; }

@media (max-width: 768px) {
  /* ── Sidebar mobile ─────────────────────────── */
  .sidebar {
    position:fixed; left:-100%; top:0; bottom:0; z-index:99;
    transform:translateX(0);
    transition:left 0.28s cubic-bezier(0.4,0,0.2,1);
    width:260px !important;
    box-shadow:4px 0 24px rgba(0,0,0,0.4);
  }
  .sidebar.open { left:0; }
  .sidebar-toggle { display:flex; }

  /* ── Main content ───────────────────────────── */
  .main-content { margin-left:0 !important; }
  .app-header { padding-left:60px !important; }

  /* ── Header ─────────────────────────────────── */
  .header-search { display:none; }
  .header-title  { font-size:16px; }

  /* ── Page content ───────────────────────────── */
  .page-content { padding:12px !important; }
  .page-header  { flex-direction:column; align-items:flex-start; gap:10px; margin-bottom:16px; }
  .page-header h1 { font-size:20px; }
  .page-header .btn { width:100%; justify-content:center; }

  /* ── KPI grid ───────────────────────────────── */
  .kpi-grid { grid-template-columns:1fr 1fr !important; gap:10px; }
  .kpi-card  { padding:14px; }
  .kpi-value { font-size:22px; }

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

  /* ── Cards ──────────────────────────────────── */
  .card { padding:14px; }

  /* ── Charts ─────────────────────────────────── */
  .charts-row { grid-template-columns:1fr !important; }

  /* ── Finance ────────────────────────────────── */
  .finance-summary { grid-template-columns:1fr 1fr !important; }

  /* ── Deals kanban ───────────────────────────── */
  .kanban-board { overflow-x:auto; gap:8px; }
  .kanban-col   { min-width:220px; }

  /* ── Chessboard ─────────────────────────────── */
  .chess-building-tabs { gap:4px; }
  .chess-btab { padding:8px 10px; min-width:50px; }
  .chess-btab-code { font-size:13px; }
  .chess-cell { width:36px !important; min-height:44px !important; font-size:10px !important; }
  .chess-cell-num { font-size:11px !important; }
  .chess-cell-area { display:none; }
  .chess-floor-label { width:30px; font-size:10px; }

  /* ── Buildings editor ───────────────────────── */
  .buildings-layout { grid-template-columns:1fr !important; }
  .buildings-sidebar { position:static !important; max-height:220px; overflow-y:auto; }
  .detail-kpis { gap:12px; }
  .detail-kpi-val { font-size:20px; }
  .overview-grid { grid-template-columns:1fr !important; }
  .form-grid { grid-template-columns:1fr !important; }
  .form-row-2 { grid-template-columns:1fr !important; }

  /* ── Docs ───────────────────────────────────── */
  .doc-grid { grid-template-columns:1fr 1fr !important; }

  /* ── Drawers ────────────────────────────────── */
  .drawer {
    width:100% !important;
    max-width:100% !important;
    border-radius:20px 20px 0 0;
    top:auto !important;
    bottom:0;
    max-height:92vh;
  }

  /* ── Modal ──────────────────────────────────── */
  .modal { width:calc(100% - 24px) !important; margin:12px; max-height:90vh; overflow-y:auto; }

  /* ── Login ──────────────────────────────────── */
  .login-card { padding:28px 20px; margin:12px; max-width:100%; border-radius:20px; }

  /* ── Unit cells (buildings editor) ─────────── */
  .unit-cell { width:72px !important; min-height:66px !important; }
  .unit-add-btn { width:72px !important; min-height:66px !important; }

  /* ── Clients/deals table rows ───────────────── */
  .client-card, .deal-card { padding:12px; }
}

@media (max-width: 480px) {
  /* Even smaller screens */
  .kpi-grid { grid-template-columns:1fr !important; }
  .finance-summary { grid-template-columns:1fr !important; }
  .doc-grid { grid-template-columns:1fr !important; }
  .chess-cell { width:28px !important; min-height:38px !important; }
  .chess-btab { min-width:40px; padding:6px 8px; }
  .chess-btab-code { font-size:11px; }
  .chess-btab-free { display:none; }
  .stat-cards { flex-direction:column; }
}
