/* ═══════════════════════════════════════════════
   MyEstate CRM — Main Stylesheet
   ═══════════════════════════════════════════════ */

/* ── Variables ───────────────────────────────── */
:root {
  --primary:       #1a56db;
  --primary-dark:  #1341b0;
  --primary-light: #ebf1fd;
  --success:       #0d9f6e;
  --success-light: #ecfdf5;
  --warning:       #c27803;
  --warning-light: #fffbeb;
  --danger:        #e02424;
  --danger-light:  #fef2f2;
  --info:          #1c64f2;
  --info-light:    #eff6ff;

  --bg:         #f3f4f6;
  --bg-white:   #ffffff;
  --border:     #e5e7eb;
  --border-dark:#d1d5db;

  --text:       #111827;
  --text-muted: #6b7280;
  --text-light: #9ca3af;

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

  --shadow:    0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.10);
  --shadow-lg: 0 10px 30px rgba(0,0,0,0.12);

  --sidebar-w: 240px;
  --topbar-h:  56px;
}

/* ── Dark Mode ───────────────────────────────── */
:root[data-theme="dark"] {
  --bg:         #111827;
  --bg-white:   #1f2937;
  --border:     #374151;
  --border-dark:#4b5563;
  --text:       #f9fafb;
  --text-muted: #9ca3af;
  --text-light: #6b7280;
  --shadow:     0 1px 3px rgba(0,0,0,0.4);
  --shadow-md:  0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg:  0 10px 30px rgba(0,0,0,0.5);
  --primary-light: #1e3a5f;
  --success-light: #052e16;
  --warning-light: #1c1400;
  --danger-light:  #1f0505;
}

/* ── Reset & Base ────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body { font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); line-height: 1.5; -webkit-font-smoothing: antialiased; overflow-x: hidden; }
html { overflow-x: hidden; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
button { font-family: inherit; }

/* ── Layout ──────────────────────────────────── */
.app-wrapper { display: flex; min-height: 100vh; }
.main-area   { flex: 1; min-width: 0; margin-left: var(--sidebar-w); display: flex; flex-direction: column; transition: margin-left .25s ease; }
.main-content { flex: 1; padding: 24px; max-width: 1920px; width: 100%; }

/* ── Sidebar ─────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  position: fixed; top: 0; left: 0; bottom: 0;
  background: #1e293b;
  display: flex; flex-direction: column;
  z-index: 200;
  overflow: hidden;
  transition: width 0.25s ease;
}
.sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; height: var(--topbar-h);
  border-bottom: 1px solid rgba(255,255,255,0.07);
}
.sidebar-logo { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.logo-img     { height: 32px; border-radius: 6px; object-fit: contain; }
.logo-text    { font-weight: 700; font-size: 1rem; color: #fff; }
.sidebar-close { display: none; background: none; border: none; color: rgba(255,255,255,0.6); cursor: pointer; padding: 4px; }
.sidebar-scroll { flex: 1; overflow-y: auto; padding: 8px 0; }
.sidebar-scroll::-webkit-scrollbar { width: 4px; }
.sidebar-scroll::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

.nav-list    { list-style: none; }
.nav-section-title { padding: 14px 16px 4px; font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: rgba(255,255,255,0.35); }
.nav-item    { margin: 1px 8px; }
.nav-link    { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm); color: rgba(255,255,255,0.72); font-size: 0.875rem; font-weight: 500; text-decoration: none; transition: background 0.15s, color 0.15s; position: relative; }
.nav-link:hover { background: rgba(255,255,255,0.08); color: #fff; text-decoration: none; }
.nav-item.active .nav-link { background: var(--primary); color: #fff; box-shadow: 0 2px 8px rgba(26,86,219,0.4); }
.nav-icon { width: 18px; height: 18px; flex-shrink: 0; }

/* ═══════════════════════════════════════════════════════════
   SIDEBAR — чистая архитектура sb-* классов
   Состояния: нормальный (240px) / collapsed (56px) / open (мобильный слайд)
   ═══════════════════════════════════════════════════════════ */

/* ── Sidebar shell ──────────────────────────── */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: #0f172a;
  display: flex; flex-direction: column;
  z-index: 300;
  overflow: hidden;
  transition: width 0.24s cubic-bezier(.4,0,.2,1);
  box-shadow: 2px 0 12px rgba(0,0,0,.18);
  user-select: none;
}

/* ── Header ─────────────────────────────────── */
.sb-header {
  display: flex; align-items: center; gap: 6px;
  padding: 0 14px 0 14px;
  height: var(--topbar-h);
  border-bottom: 1px solid rgba(255,255,255,.07);
  flex-shrink: 0;
}
.sb-logo {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none; flex: 1; min-width: 0;
  /* overflow managed by children, not parent */
}
.sb-logo-icon {
  width: 36px; height: 36px; border-radius: 9px;
  background: var(--primary); display: flex !important;
  align-items: center; justify-content: center;
  flex-shrink: 0; box-shadow: 0 2px 8px rgba(26,86,219,.4);
  min-width: 36px; /* предотвращает схлопывание */
}
.sb-logo-icon svg { width: 22px; height: 22px; }
.sb-logo-img  { height: 36px; max-width: 130px; object-fit: contain; flex-shrink: 0; border-radius: 6px; }
.sb-logo-text {
  font-size: 0.92rem; font-weight: 700; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: opacity .2s, width .24s;
  flex: 1; min-width: 0;
}

/* Collapse button (desktop only) */
.sb-collapse-btn {
  width: 28px; height: 28px; border-radius: 7px;
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.1);
  color: rgba(255,255,255,.55);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0;
  transition: background .15s, color .15s;
}
.sb-collapse-btn:hover { background: rgba(255,255,255,.14); color: #fff; }
#sbCollapseIcon { transition: transform .24s cubic-bezier(.4,0,.2,1); }

/* Close button (mobile only) */
.sb-close-btn {
  display: none;
  width: 28px; height: 28px; border-radius: 7px;
  background: rgba(255,255,255,.07); border: none;
  color: rgba(255,255,255,.6); cursor: pointer;
  align-items: center; justify-content: center;
  flex-shrink: 0;
}

/* ── Scroll area ────────────────────────────── */
.sb-scroll {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  padding: 8px 0;
}
.sb-scroll::-webkit-scrollbar { width: 3px; }
.sb-scroll::-webkit-scrollbar-thumb { background: rgba(255,255,255,.08); border-radius: 3px; }

/* ── Nav ─────────────────────────────────────── */
.sb-nav { list-style: none; padding: 0; margin: 0; }

/* Section titles */
.sb-section {
  font-size: .62rem; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase;
  color: rgba(255,255,255,.28);
  padding: 14px 16px 4px;
  white-space: nowrap; overflow: hidden;
  transition: opacity .2s, height .2s;
}

/* Nav item */
.sb-item { margin: 1px 8px; }
.sb-link {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 8px;
  color: rgba(255,255,255,.68); font-size: .85rem; font-weight: 500;
  text-decoration: none;
  transition: background .14s, color .14s;
  white-space: nowrap; overflow: hidden;
  position: relative;
}
.sb-link:hover { background: rgba(255,255,255,.09); color: #fff; text-decoration: none; }
.sb-item.active .sb-link {
  background: var(--primary); color: #fff;
  box-shadow: 0 2px 10px rgba(26,86,219,.4);
}
.sb-icon {
  width: 18px; height: 18px; flex-shrink: 0;
  opacity: .85;
}
.sb-item.active .sb-icon { opacity: 1; }
.sb-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }

/* Badges */
.sb-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; border-radius: 9px; padding: 0 5px;
  font-size: .65rem; font-weight: 700; line-height: 1;
  background: rgba(255,255,255,.2); color: #fff;
}
.sb-badge-red { background: var(--danger); }

/* ── Footer ─────────────────────────────────── */
.sb-footer {
  display: flex; align-items: center; gap: 6px;
  padding: 10px 12px;
  border-top: 1px solid rgba(255,255,255,.07);
  flex-shrink: 0; overflow: hidden;
}
.sb-user {
  display: flex; align-items: center; gap: 9px;
  flex: 1; min-width: 0; text-decoration: none;
  padding: 5px 6px; border-radius: 8px;
  transition: background .14s;
}
.sb-user:hover { background: rgba(255,255,255,.07); text-decoration: none; }
.sb-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  object-fit: cover; flex-shrink: 0;
  border: 1.5px solid rgba(255,255,255,.2);
}
.sb-avatar-ph {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: .85rem; font-weight: 700; flex-shrink: 0;
  border: 1.5px solid rgba(255,255,255,.2);
}
.sb-user-info { min-width: 0; overflow: hidden; }
.sb-user-name { font-size: .78rem; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-user-role { font-size: .65rem; color: rgba(255,255,255,.38); }
.sb-logout {
  color: rgba(255,255,255,.4); padding: 6px; border-radius: 7px;
  display: flex; align-items: center; flex-shrink: 0;
  transition: color .15s, background .15s;
}
.sb-logout:hover { color: var(--danger); background: rgba(224,36,36,.15); }

/* ── Overlay ─────────────────────────────────── */
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.45); z-index: 299;
  opacity: 0; transition: opacity .28s;
}
.sidebar-overlay.open { opacity: 1; pointer-events: auto; }

/* ── Sidebar toggle btn in topbar ───────────── */
.sidebar-toggle { display: none; background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 6px; border-radius: var(--radius-sm); }
.sidebar-toggle:hover { background: var(--bg); }

/* ═══════════════════════════════════════════════
   COLLAPSED STATE (width 56px, desktop only)
   ═══════════════════════════════════════════════ */
.sidebar.collapsed                { width: 56px; }
.sidebar.collapsed .sb-logo-text  { opacity: 0; width: 0; overflow: hidden; }
.sidebar.collapsed .sb-logo       { justify-content: center; }
.sidebar.collapsed .sb-logo-icon::after {
  content: attr(data-name);
  position: absolute; left: 60px; top: 50%; transform: translateY(-50%);
  background: #1e293b; color: #fff; padding: 4px 10px; border-radius: 6px;
  font-size: .78rem; font-weight: 600; white-space: nowrap;
  opacity: 0; pointer-events: none; transition: opacity .15s; z-index: 999;
}
.sidebar.collapsed .sb-logo-icon:hover::after { opacity: 1; }
.sidebar.collapsed .sb-collapse-btn { margin: 0 auto; }
.sidebar.collapsed #sbCollapseIcon { transform: rotate(180deg); }
.sidebar.collapsed .sb-section     { opacity: 0; height: 0; padding: 0; overflow: hidden; }
.sidebar.collapsed .sb-item        { margin: 2px 6px; }
.sidebar.collapsed .sb-link        { justify-content: center; padding: 9px; gap: 0; border-radius: 8px; }
.sidebar.collapsed .sb-label       { opacity: 0; width: 0; overflow: hidden; }
.sidebar.collapsed .sb-icon        { width: 20px; height: 20px; }
.sidebar.collapsed .sb-badge       { position: absolute; top: 4px; right: 4px; min-width: 14px; height: 14px; font-size: .55rem; }
.sidebar.collapsed .sb-footer      { justify-content: center; padding: 10px 0; }
.sidebar.collapsed .sb-user        { justify-content: center; padding: 5px; flex: none; }
.sidebar.collapsed .sb-user-info   { opacity: 0; width: 0; overflow: hidden; }
.sidebar.collapsed .sb-logout      { display: none; }

/* Tooltip при hover на collapsed link */
.sidebar.collapsed .sb-link:hover::after {
  content: attr(title);
  position: fixed; left: 62px;
  background: #0f172a; color: #fff;
  padding: 5px 11px; border-radius: 7px;
  font-size: .78rem; font-weight: 500;
  white-space: nowrap; pointer-events: none;
  z-index: 9999;
  box-shadow: 0 4px 16px rgba(0,0,0,.3);
  border: 1px solid rgba(255,255,255,.1);
}
.topbar {
  position: sticky; top: 0; z-index: 100;
  height: var(--topbar-h);
  background: var(--bg-white);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px;
  box-shadow: var(--shadow);
  overflow: visible;
}
.topbar-search { position: relative; flex: 1; max-width: 380px; }
.topbar-search input { width: 100%; padding: 7px 10px 7px 34px; border: 1.5px solid var(--border); border-radius: var(--radius-sm); font-size: 0.85rem; background: var(--bg); color: var(--text); outline: none; transition: border-color 0.2s, box-shadow 0.2s; }
.topbar-search input:focus { border-color: var(--primary); background: var(--bg-white); box-shadow: 0 0 0 3px var(--primary-light); }
.topbar-search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-muted); pointer-events: none; }
#searchResults { display: none; position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: var(--bg-white); border: 1.5px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); z-index: 300; max-height: 360px; overflow-y: auto; }
#searchResults a:last-child { border-bottom: none !important; }
.topbar-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.topbar-btn { position: relative; width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; background: none; border: 1.5px solid var(--border); border-radius: var(--radius-sm); color: var(--text-muted); cursor: pointer; transition: background 0.15s, color 0.15s; text-decoration: none; }
.topbar-btn:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.notif-badge { position: absolute; top: -5px; right: -5px; background: var(--danger); color: #fff; font-size: 0.62rem; font-weight: 800; min-width: 17px; height: 17px; border-radius: 10px; display: flex; align-items: center; justify-content: center; padding: 0 4px; border: 2px solid var(--bg-white); }
.lang-select { background: none; border: 1.5px solid var(--border); border-radius: var(--radius-sm); padding: 5px 8px; font-size: 0.8rem; color: var(--text); cursor: pointer; }

/* ── Page header ─────────────────────────────── */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 24px; flex-wrap: wrap; }
.page-title  { font-size: 1.35rem; font-weight: 800; color: var(--text); line-height: 1.2; }
.page-subtitle { font-size: 0.875rem; color: var(--text-muted); margin-top: 2px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ── Cards ───────────────────────────────────── */
.card { background: var(--bg-white); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; gap: 8px; flex-wrap: wrap; }
.card-title  { font-size: 0.9rem; font-weight: 700; color: var(--text); }

/* ── Buttons ─────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius-sm);
  font-size: 0.875rem; font-weight: 600; line-height: 1.25;
  cursor: pointer; border: 1.5px solid transparent;
  text-decoration: none; white-space: nowrap;
  transition: background 0.15s, box-shadow 0.15s, opacity 0.15s, transform 0.1s;
  font-family: inherit;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn-primary   { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); box-shadow: 0 4px 12px rgba(26,86,219,0.3); }
.btn-secondary { background: var(--bg-white); color: var(--text); border-color: var(--border-dark); }
.btn-secondary:hover { background: var(--bg); }
.btn-success   { background: var(--success); color: #fff; border-color: var(--success); }
.btn-success:hover { opacity: 0.9; box-shadow: 0 4px 10px rgba(13,159,110,0.3); }
.btn-danger    { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { opacity: 0.9; }
.btn-warning   { background: var(--warning); color: #fff; border-color: var(--warning); }
.btn-sm  { padding: 5px 11px; font-size: 0.8rem; }
.btn-lg  { padding: 11px 22px; font-size: 1rem; }
.btn-icon { width: 34px; height: 34px; padding: 0; justify-content: center; }
.btn-group { display: flex; gap: 2px; background: var(--bg); border: 1.5px solid var(--border); border-radius: var(--radius-sm); padding: 2px; }
.btn-group .btn { border-radius: calc(var(--radius-sm) - 2px); border: none; }

/* ── Forms ───────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-row   { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; min-width: 0; }
.form-label { display: block; font-size: 0.83rem; font-weight: 600; color: var(--text); margin-bottom: 5px; }
.form-control {
  width: 100%; padding: 9px 12px;
  border: 1.5px solid var(--border-dark); border-radius: var(--radius-sm);
  font-size: 0.875rem; color: var(--text); background: var(--bg-white);
  transition: border-color 0.2s, box-shadow 0.2s;
  font-family: inherit;
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.form-control::placeholder { color: var(--text-light); }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-hint { font-size: 0.75rem; color: var(--text-muted); margin-top: 4px; }
.form-hint a { color: var(--primary); }
.form-hint code { background: var(--bg); padding: 1px 5px; border-radius: 3px; font-family: monospace; }
.required { color: var(--danger); }

/* ── Stats grid ──────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.stat-card {
  background: var(--bg-white); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.stat-card::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; }
.stat-card.primary::before { background: var(--primary); }
.stat-card.success::before { background: var(--success); }
.stat-card.warning::before { background: var(--warning); }
.stat-card.danger::before  { background: var(--danger); }
.stat-card.info::before    { background: var(--info); }
.stat-label { font-size: 0.78rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 6px; }
.stat-value { font-size: 1.75rem; font-weight: 800; line-height: 1; }
.stat-change { font-size: 0.78rem; color: var(--text-muted); margin-top: 6px; }
.stat-change.up   { color: var(--success); }
.stat-change.down { color: var(--danger); }
.stat-icon  { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); opacity: 0.1; }

/* ── Tables ──────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead tr { background: var(--bg); }
th { padding: 10px 14px; text-align: left; font-size: 0.75rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; white-space: nowrap; border-bottom: 1.5px solid var(--border); }
td { padding: 11px 14px; font-size: 0.875rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(0,0,0,0.015); }
.fw-600  { font-weight: 600; }
.fw-700  { font-weight: 700; }
.fs-sm   { font-size: 0.8rem; }
.text-muted { color: var(--text-muted); }

/* ── Badges & Status ─────────────────────────── */
.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 10px; font-size: 0.72rem; font-weight: 700; }
.badge-primary   { background: var(--primary-light); color: var(--primary); }
.badge-success   { background: var(--success-light); color: var(--success); }
.badge-warning   { background: var(--warning-light); color: var(--warning); }
.badge-danger    { background: var(--danger-light);  color: var(--danger); }
.badge-info      { background: var(--info-light);    color: var(--info); }
.badge-secondary { background: var(--border-dark); color: var(--text); }

.status { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 12px; font-size: 0.75rem; font-weight: 700; white-space: nowrap; }
.status-active, .status-paid      { background: var(--success-light); color: var(--success); }
.status-pending, .status-new      { background: var(--warning-light); color: var(--warning); }
.status-in_progress                { background: var(--info-light); color: var(--info); }
.status-completed, .status-sent    { background: #ede9fe; color: #7c3aed; }
.status-cancelled, .status-failed  { background: var(--danger-light); color: var(--danger); }
.status-overdue                    { background: var(--danger-light); color: var(--danger); }
.status-inactive                   { background: var(--bg); color: var(--text-muted); border: 1px solid var(--border); }
.status-sold        { background: #fee2e2; color: #b91c1c; border-color: #fca5a5; }
.status-converted   { background: #ede9fe; color: #7c3aed; }
.status-reserved                   { background: var(--warning-light); color: var(--warning); }
.status-available                  { background: var(--success-light); color: var(--success); }
.status-blacklisted                { background: var(--danger-light); color: var(--danger); }
.status-qualified                  { background: var(--primary-light); color: var(--primary); }
.status-lost                       { background: var(--bg); color: var(--text-muted); border: 1px solid var(--border); }

/* ── Alerts ──────────────────────────────────── */
.alert { display: flex; align-items: flex-start; gap: 10px; padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 0.875rem; line-height: 1.5; }
.alert svg { flex-shrink: 0; margin-top: 1px; }
.alert-success { background: var(--success-light); border: 1px solid #6ee7b7; color: #065f46; }
.alert-danger  { background: var(--danger-light);  border: 1px solid #fca5a5; color: #991b1b; }
.alert-warning { background: var(--warning-light); border: 1px solid #fcd34d; color: #92400e; }
.alert-info    { background: var(--info-light);    border: 1px solid #93c5fd; color: #1e40af; }
.alert-close   { background: none; border: none; cursor: pointer; color: inherit; margin-left: auto; opacity: 0.6; font-size: 1.1rem; line-height: 1; }
.alert-close:hover { opacity: 1; }
@keyframes slideInDown { from { opacity:0; transform:translateY(-12px); } to { opacity:1; transform:translateY(0); } }

/* ── Progress ────────────────────────────────── */
.progress { height: 6px; background: var(--border); border-radius: 4px; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 4px; transition: width 0.5s ease; background: var(--primary); }
.progress-bar.success { background: var(--success); }
.progress-bar.warning { background: var(--warning); }
.progress-bar.danger  { background: var(--danger); }
.progress-bar.primary { background: var(--primary); }

/* ── Modals ──────────────────────────────────── */
.modal { display: none; position: fixed; inset: 0; z-index: 500; align-items: center; justify-content: center; padding: 20px; }
.modal.open { display: flex; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.5); backdrop-filter: blur(2px); }
.modal-dialog   { position: relative; background: var(--bg-white); border-radius: var(--radius-lg); width: 100%; max-width: 560px; max-height: 90vh; overflow: hidden; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; }
.modal-header   { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.modal-title    { font-size: 1rem; font-weight: 700; }
.modal-close    { background: none; border: none; font-size: 1.3rem; cursor: pointer; color: var(--text-muted); line-height: 1; }
.modal-body     { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer   { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }

/* ── Dropdown ────────────────────────────────── */
.dropdown         { position: relative; display: inline-block; }
.dropdown-menu    { display: none; position: fixed; min-width: 180px; background: var(--bg-white); border: 1.5px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); z-index: 1500; overflow: hidden; }
.dropdown-menu.open { display: block; animation: slideInDown 0.15s ease; }
.dropdown-item    { display: flex; align-items: center; gap: 8px; width: 100%; padding: 9px 16px; font-size: 0.875rem; color: var(--text); background: none; border: none; cursor: pointer; text-align: left; text-decoration: none; }
.dropdown-item:hover { background: var(--bg); text-decoration: none; }
.dropdown-item.danger { color: var(--danger); }
.dropdown-divider { height: 1px; background: var(--border); margin: 4px 0; }

/* ── Pagination ──────────────────────────────── */
.pagination { display: flex; align-items: center; gap: 4px; justify-content: center; margin-top: 24px; flex-wrap: wrap; }
.pagination a, .pagination span { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: var(--radius-sm); font-size: 0.85rem; font-weight: 600; border: 1.5px solid var(--border); background: var(--bg-white); color: var(--text); text-decoration: none; transition: background 0.15s; }
.pagination a:hover  { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination .current { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ── Grid helpers ────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; }

/* ── Tabs ────────────────────────────────────── */
.tabs { display: flex; border-bottom: 2px solid var(--border); margin-bottom: 20px; flex-wrap: wrap; gap: 2px; }
.tab-btn { display: flex; align-items: center; gap: 6px; padding: 10px 16px; border: none; background: none; font-size: 0.875rem; font-weight: 500; color: var(--text-muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; white-space: nowrap; transition: color 0.15s; font-family: inherit; }
.tab-btn:hover  { color: var(--primary); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 700; }
.tab-content    { display: none; }
.tab-content:first-of-type, .tab-content[style*="display"]:not([style*="none"]) { display: block; }

/* ── Timeline ────────────────────────────────── */
.timeline { display: flex; flex-direction: column; }
.timeline-item { display: flex; gap: 12px; padding: 10px 0 10px 20px; border-left: 2px solid var(--border); margin-left: 8px; position: relative; }
.timeline-dot  { position: absolute; left: -5px; top: 14px; width: 8px; height: 8px; border-radius: 50%; background: var(--primary); border: 2px solid var(--bg-white); }
.timeline-time    { font-size: 0.75rem; color: var(--text-muted); white-space: nowrap; min-width: 100px; }
.timeline-content { font-size: 0.85rem; flex: 1; }

/* ── Properties ──────────────────────────────── */
.property-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.property-card { background: var(--bg-white); border: 1.5px solid var(--border); border-radius: var(--radius); overflow: hidden; transition: box-shadow 0.2s, transform 0.15s; position: relative; }
.property-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.property-img { width: 100%; height: 180px; object-fit: cover; display: block; }
.property-img-placeholder { width: 100%; height: 180px; background: var(--bg); display: flex; align-items: center; justify-content: center; }
.property-body  { padding: 14px; }
.property-code  { font-size: 0.7rem; font-family: monospace; color: var(--text-muted); background: var(--bg); padding: 2px 6px; border-radius: 4px; }
.property-title { font-weight: 700; font-size: 0.9rem; margin: 6px 0 4px; line-height: 1.3; }
.property-title a { color: var(--text); }
.property-price { font-size: 1.05rem; font-weight: 800; color: var(--primary); }
.property-meta  { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.property-meta-item { display: flex; align-items: center; gap: 4px; font-size: 0.75rem; color: var(--text-muted); }
.property-card-actions { position: absolute; top: 8px; right: 8px; display: flex; gap: 4px; opacity: 0; transition: opacity 0.2s; }
.property-card:hover .property-card-actions { opacity: 1; }
.property-card-actions .btn { background: rgba(255,255,255,0.95); border: 1px solid rgba(0,0,0,0.1); box-shadow: 0 1px 4px rgba(0,0,0,0.1); }
.property-card-actions .btn:hover { background: var(--primary); color: #fff; }

/* ── Calendar ────────────────────────────────── */
.cal-grid    { display: grid; grid-template-columns: repeat(7,1fr); }
.cal-day-name { text-align: center; font-size: 0.72rem; font-weight: 700; color: var(--text-muted); padding: 6px 4px; }
.cal-day     { min-height: 80px; padding: 4px; border: 1px solid var(--border); border-radius: 4px; }
.cal-day.today { background: var(--primary-light); border-color: var(--primary); }
.cal-day.other-month { opacity: 0.3; }
.cal-day-num { font-weight: 700; font-size: 0.8rem; color: var(--text-muted); margin-bottom: 3px; }
.cal-event   { padding: 2px 5px; border-radius: 3px; margin-bottom: 2px; font-size: 0.68rem; background: var(--primary-light); color: var(--primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.cal-event.success { background: var(--success-light); color: var(--success); }
.cal-event.danger  { background: var(--danger-light); color: var(--danger); }

/* ── Empty state ─────────────────────────────── */
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 48px 20px; text-align: center; }
.empty-state svg { width: 52px; height: 52px; color: var(--text-light); margin-bottom: 14px; }
.empty-state-title { font-size: 1rem; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.empty-state-text  { font-size: 0.875rem; color: var(--text-muted); margin-bottom: 16px; }

/* ── Toast ───────────────────────────────────── */
@keyframes slideInRight { from { opacity:0; transform:translateX(20px); } to { opacity:1; transform:translateX(0); } }
.toast { animation: slideInRight 0.3s ease; }

/* ── Print ───────────────────────────────────── */
@media print {
  .sidebar, .topbar, .page-actions, .btn, .modal, .flash-auto, .property-card-actions,
  .no-print, form[method="POST"] { display: none !important; }
  .main-area { margin-left: 0 !important; }
  .main-content { padding: 0 !important; }
  .card { box-shadow: none !important; border: 1px solid #ccc !important; }
  body { background: #fff !important; }
}

/* ═══════════════════════════════════════════════
   RESPONSIVE SYSTEM
   ─ Desktop:  > 1280px  (full layout)
   ─ Laptop:   1025-1279px
   ─ Tablet:   769-1024px
   ─ Mobile:   ≤ 768px
   ─ Small:    ≤ 480px
   ═══════════════════════════════════════════════ */

/* ── Desktop base (> 1280px) ──────────────────── */

/* ── Laptop (1025–1279px) ─────────────────────── */
@media (min-width: 1025px) and (max-width: 1279px) {
  :root { --sidebar-w: 220px; }
  .main-content { padding: 20px; }
  .stats-grid   { grid-template-columns: repeat(4, 1fr); gap: 12px; }
}

/* ── Tablet (769–1024px) ──────────────────────── */
@media (min-width: 769px) and (max-width: 1024px) {
  :root { --sidebar-w: 0px; }

  /* Sidebar — мобильный/планшет: слайд поверх контента */
  .sidebar          { transform: translateX(-100%); transition: transform 0.26s cubic-bezier(.4,0,.2,1), width 0s; width: 260px !important; }
  .sidebar.open     { transform: translateX(0); box-shadow: 4px 0 24px rgba(0,0,0,.35); }
  .sidebar-overlay  { display: block; pointer-events: none; }
  .sidebar-toggle   { display: flex !important; }
  .sb-close-btn     { display: flex !important; }
  .sb-collapse-btn  { display: none !important; }
  .main-area        { margin-left: 0 !important; }

  /* Layout */
  .main-content  { padding: 18px; }
  .page-title    { font-size: 1.2rem; }

  /* Grids */
  .stats-grid    { grid-template-columns: repeat(2, 1fr) !important; gap: 10px !important; }
  .dash-grid     { grid-template-columns: 1fr 1fr !important; }
  .dash-grid [style*="grid-column:span 2"],
  .dash-grid [style*="grid-column: span 2"] { grid-column: span 2 !important; }
  .property-grid  { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
  /* Show page grids на планшете */
  .client-show-grid   { grid-template-columns: 320px 1fr !important; }
  .deal-show-grid     { grid-template-columns: 1fr 320px !important; }
  .employee-show-grid { grid-template-columns: 300px 1fr !important; }
  .building-show-grid { grid-template-columns: 1fr 300px !important; }

  /* Tables */
  .table-wrap    { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table          { min-width: 580px; }
}

/* ── Mobile (≤ 768px) ─────────────────────────── */
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; --topbar-h: 52px; }

  /* Sidebar */
  .sidebar         { transform: translateX(-100%); transition: transform 0.28s ease; z-index: 400; width: 260px; }
  .sidebar.open    { transform: translateX(0); box-shadow: 4px 0 24px rgba(0,0,0,.3); }
  .sidebar-close   { display: flex !important; }
  .sidebar-toggle  { display: flex !important; }
  .sidebar-overlay { display: block; opacity: 0; transition: opacity 0.28s; pointer-events: none; }
  .sidebar-overlay.open { opacity: 1; pointer-events: auto; }
  .main-area       { margin-left: 0 !important; }
  #sidebarCollapseBtn { display: none; }

  /* Topbar */
  .topbar           { padding: 0 12px; gap: 6px; }
  .topbar-search    { display: none; } /* убираем поиск на мобильных */
  .lang-select      { display: none; }
  .topbar-btn       { width: 34px; height: 34px; }
  .topbar-actions   { gap: 4px; }

  /* Layout */
  .main-content   { padding: 12px; }
  .page-header    { flex-direction: column; align-items: flex-start; gap: 10px; margin-bottom: 16px; }
  .page-title     { font-size: 1.1rem; }
  .page-actions                  { width: 100%; flex-wrap: wrap; gap: 6px; }
  .page-actions > .btn           { flex: 1 1 auto; min-width: calc(50% - 3px); justify-content: center; text-align: center; }
  .page-actions > .btn:only-child { flex: 0 0 auto; min-width: unset; }
  .page-actions > .btn-group     { flex: 0 0 100%; display: flex; }
  .page-actions > .btn-group .btn { flex: 1; justify-content: center; }

  /* Stats grid */
  .stats-grid     { grid-template-columns: repeat(2, 1fr) !important; gap: 8px !important; }

  /* Dash grid */
  .dash-grid      { grid-template-columns: 1fr !important; }
  .dash-grid [style*="grid-column"] { grid-column: span 1 !important; }

  /* Forms */
  .form-row       { flex-direction: column; gap: 0; }
  .form-group     { margin-bottom: 12px; }
  .form-control   { font-size: 16px; } /* prevents iOS zoom */

  /* Cards */
  .card           { padding: 12px; border-radius: 8px; }
  .card-header    { margin-bottom: 10px; flex-wrap: wrap; gap: 8px; }
  .card-title     { font-size: 0.9rem; }

  /* Tables — scroll on mobile, never overflow screen */
  .table-wrap     { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 8px; max-width: 100vw; }
  table           { min-width: 480px; width: max-content; }
  th, td          { padding: 8px 10px; font-size: 0.8rem; white-space: nowrap; }
  /* Long text in cells */
  td.wrap         { white-space: normal; min-width: 120px; }

  /* Buttons */
  .btn            { font-size: 0.82rem; padding: 7px 12px; }
  .btn-sm         { font-size: 0.75rem; padding: 4px 8px; }

  /* Modals */
  .modal          { padding: 10px; }
  .modal-dialog   { max-height: calc(100vh - 20px); }
  .modal-body     { max-height: calc(100vh - 180px); overflow-y: auto; }
  .modal-footer   { flex-wrap: wrap; gap: 8px; }
  .modal-footer .btn { flex: 1; justify-content: center; }

  /* Property grid */
  .property-grid  { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }

  /* Floor plan */
  #mainGrid       { grid-template-columns: 52px 1fr !important; gap: 8px !important; }
  #floorNav       { max-height: 60vh; }

  /* Buildings index */
  .buildings-grid { grid-template-columns: 1fr !important; }

  /* Payments calendar */
  .payments-calendar { grid-template-columns: repeat(2, 1fr) !important; }

  /* User card in topbar */
  .topbar-user-name { display: none; }

  /* Hide non-essential table columns */
  .col-hide-mobile { display: none !important; }

  /* Show page grids — в одну колонку на мобильных */
  .client-show-grid,
  .deal-show-grid,
  .employee-show-grid,
  .building-show-grid { grid-template-columns: 1fr !important; }

  /* Минимальная ширина table — меньше на мобильных */
  table { min-width: 480px; }
  th, td { padding: 7px 8px; }

  /* Статистика клиента */
  .client-stats-grid { grid-template-columns: 1fr 1fr !important; }

  /* Топбар — скрыть некоторые элементы */
  .topbar-btn + .topbar-btn { /* оставить только нотификации */ }

  /* Quick create btn */
  .quick-create-label { display: none; }

  /* Buildings/Properties index grids */
  #buildingsGrid { grid-template-columns: 1fr !important; }
  .property-grid { grid-template-columns: 1fr !important; }

  /* Buildings/Properties form layout */
  .building-form-grid,
  .property-form-grid { grid-template-columns: 1fr !important; }

  /* Floor plan */
  #fpGrid { grid-template-columns: 48px 1fr !important; gap: 8px !important; }
  .fp-toolbar { gap: 6px; padding: 8px 10px; }
  #floorNav { max-height: 55vh; }
  .fn-btn { padding: 6px 2px; }
  #fpSummary { grid-template-columns: repeat(2, 1fr) !important; gap: 6px; }
  #fpPopup { width: calc(100vw - 16px) !important; left: 8px !important; right: 8px; }

  /* Stats-4 → 2 cols */
  .stats-4 { grid-template-columns: 1fr 1fr !important; }

  /* Property show */
  .property-show-grid { grid-template-columns: 1fr !important; }
  /* Правая колонка (цена) показывается первой на мобильных */
  .property-show-grid > div:nth-child(2) { order: -1; }
  /* Галерея — полная ширина */
  .property-show-grid .card img { max-height: 260px; }
}

/* ── Small mobile (≤ 480px) ───────────────────── */
@media (max-width: 480px) {
  .stats-grid     { grid-template-columns: 1fr 1fr !important; gap: 6px !important; }
  .main-content   { padding: 10px; }
  .page-title     { font-size: 1rem; }
  .card           { padding: 10px; }
  .btn-group      { flex-wrap: wrap; }

  /* One column property grid */
  .property-grid  { grid-template-columns: 1fr; }

  /* Full width modals */
  .modal          { padding: 6px; }
  .modal-dialog   { border-radius: 10px; }

  /* Stack page actions */
  .page-actions .btn { min-width: 100%; }
  .page-actions      { gap: 5px; }
}

/* ── Touch targets (всегда) ───────────────────── */
@media (hover: none) and (pointer: coarse) {
  .btn       { min-height: 42px; }
  .btn-sm    { min-height: 34px; }
  .nav-link  { min-height: 44px; }
  .form-control { min-height: 44px; }
  select.form-control { min-height: 44px; }
  .topbar-btn { min-height: 42px; min-width: 42px; }
}

/* ── Adaptive Dashboard Grid ──────────────────────────────────────── */
.dash-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 20px;
}

/* Old mobile block removed - consolidated above */

/* ── Tablet: 769–1024px ───────────────────────────────────────────── */
@media (min-width: 769px) and (max-width: 1024px) {
  :root { --sidebar-w: 200px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr) !important; }
  .dash-grid { grid-template-columns: 1fr 1fr !important; }
  .dash-grid [style*="grid-column:span 2"],
  .dash-grid [style*="grid-column: span 2"] { grid-column: span 2 !important; }
}

/* ── Sidebar collapsed ────────────────────────────────────────────── */
.sidebar.collapsed { width: 56px; }

/* Скрываем всё текстовое */
.sidebar.collapsed .nav-label,
.sidebar.collapsed .sidebar-section-title,
.sidebar.collapsed .logo-text,
.sidebar.collapsed .user-info { display: none; }

/* Nav links: только иконки по центру */
.sidebar.collapsed .sidebar-nav      { padding: 8px 4px; }
.sidebar.collapsed .nav-link         { justify-content: center; padding: 10px; gap: 0; border-radius: 8px; }
.sidebar.collapsed .nav-link svg     { flex-shrink: 0; width: 20px; height: 20px; }
.sidebar.collapsed .nav-link .nav-badge { display: none; }
.sidebar.collapsed .nav-item         { margin-bottom: 2px; }

/* Заголовки секций — тонкая линия-разделитель */
.sidebar.collapsed .sidebar-section-title-wrap {
  border-top: 1px solid rgba(255,255,255,.08);
  margin: 6px 8px;
  padding: 0;
  height: 1px;
}

/* Логотип — только иконка */
.sidebar.collapsed .sidebar-logo     { justify-content: center; gap: 0; overflow: hidden; }

/* Кнопка collapse */
.sidebar.collapsed #sidebarCollapseBtn  { justify-content: center; width: 100%; padding: 10px 0; }
.sidebar.collapsed #sidebarCollapseIcon { transform: rotate(180deg); }
.sidebar.collapsed .sidebar-collapse-label { display: none; }

/* User footer */
.sidebar.collapsed .user-card           { justify-content: center; padding: 8px 0; gap: 0; }
.sidebar.collapsed .user-avatar,
.sidebar.collapsed .user-avatar-placeholder { margin: 0; flex-shrink: 0; }
.sidebar.collapsed .logout-btn          { display: none; }

/* Кнопка свернуть */
#sidebarCollapseBtn {
  background: transparent;
  border: none;
  border-top: 1px solid rgba(255,255,255,.08);
  cursor: pointer;
  width: 100%;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: rgba(255,255,255,.5);
  font-size: .8rem;
  transition: background .15s, color .15s;
}
#sidebarCollapseBtn:hover { background: rgba(255,255,255,.07); color: rgba(255,255,255,.85); }
#sidebarCollapseIcon { transition: transform .25s ease; flex-shrink: 0; }
.sidebar-collapse-label { font-size: .8rem; }

/* margin-left managed by JS toggleSidebar() */


/* ═══════════════════════════════════════════════
   PAGE-SPECIFIC RESPONSIVE CLASSES
   ═══════════════════════════════════════════════ */

/* Deals form */
.deals-form-grid     { display: grid; grid-template-columns: 1fr 360px; gap: 20px; align-items: start; }

/* SMS page */
.sms-main-grid       { display: grid; grid-template-columns: 1fr 380px; gap: 20px; align-items: start; }

/* Reports */
.reports-stats-grid  { display: grid; grid-template-columns: repeat(4,1fr); gap: 12px; margin-bottom: 20px; }
.reports-charts-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; margin-bottom: 20px; }
.reports-agents-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 16px; }

/* Settings */
.settings-2col       { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.settings-5col       { display: grid; grid-template-columns: repeat(5,1fr); gap: 12px; }

/* Payments stats */
.payments-stats-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 12px; margin-bottom: 16px; }

/* Properties show */
.property-show-grid  { display: grid; grid-template-columns: 1fr 340px; gap: 20px; align-items: start; }

/* Deal payments metrics */
.deal-metrics-grid   { display: grid; grid-template-columns: repeat(4,1fr); gap: 0; text-align: center; }
.deal-payments-meta  { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-bottom: 14px; }

@media (max-width: 1024px) {
  .deals-form-grid     { grid-template-columns: 1fr 320px; }
  .sms-main-grid       { grid-template-columns: 1fr 320px; }
  .reports-stats-grid  { grid-template-columns: repeat(2,1fr); }
  .reports-charts-grid { grid-template-columns: 1fr 1fr; }
  .reports-agents-grid { grid-template-columns: repeat(2,1fr); }
  .settings-5col       { grid-template-columns: repeat(3,1fr); }
  .payments-stats-grid { grid-template-columns: repeat(3,1fr); }
  .property-show-grid  { grid-template-columns: 1fr 300px; }
  .deal-metrics-grid   { grid-template-columns: repeat(2,1fr); }
}

@media (max-width: 768px) {
  .deals-form-grid     { grid-template-columns: 1fr !important; }
  .sms-main-grid       { grid-template-columns: 1fr !important; }
  .reports-stats-grid  { grid-template-columns: repeat(2,1fr) !important; }
  .reports-charts-grid { grid-template-columns: 1fr !important; }
  .reports-agents-grid { grid-template-columns: repeat(2,1fr) !important; }
  .settings-2col       { grid-template-columns: 1fr !important; }
  .settings-5col       { grid-template-columns: repeat(2,1fr) !important; }
  .payments-stats-grid { grid-template-columns: repeat(2,1fr) !important; }
  .property-show-grid  { grid-template-columns: 1fr !important; }
  .deal-metrics-grid   { grid-template-columns: repeat(2,1fr) !important; }
  .deal-payments-meta  { grid-template-columns: 1fr 1fr !important; }
}

@media (max-width: 480px) {
  .reports-stats-grid  { grid-template-columns: 1fr 1fr !important; }
  .deal-metrics-grid   { grid-template-columns: 1fr 1fr !important; }
  .payments-stats-grid { grid-template-columns: 1fr 1fr !important; }
}

/* ── Filter bars ─────────────────────────────── */
.filter-bar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.filter-bar .form-control { min-width: 140px; flex: 1; }
.filter-bar .btn          { flex-shrink: 0; }

@media (max-width: 768px) {
  .filter-bar              { gap: 6px; }
  .filter-bar .form-control { min-width: calc(50% - 3px); }
  .filter-bar select        { min-width: calc(50% - 3px); }
}

/* ── Card list mobile (clients, employees, leads) */
@media (max-width: 640px) {
  /* Скрыть вторичные колонки в таблицах */
  .hide-sm { display: none !important; }
}

/* ── Deal/Payment status badges */
.badge { display: inline-flex; align-items: center; gap: 3px; padding: 3px 8px; border-radius: 10px; font-size: 0.72rem; font-weight: 700; white-space: nowrap; }

/* ── SMS page client list */
@media (max-width: 768px) {
  .sms-main-grid { grid-template-columns: 1fr !important; }
  .sms-main-grid > div:first-child { max-height: 300px; overflow-y: auto; }
}

/* ── Calendar payments */
@media (max-width: 640px) {
  .cal-grid { grid-template-columns: repeat(1,1fr) !important; }
}

/* ── Deals show payments table */
@media (max-width: 768px) {
  .deal-payments-meta { grid-template-columns: 1fr 1fr !important; }
  .deal-metrics-grid  { grid-template-columns: repeat(2,1fr) !important; border-radius: var(--radius); overflow: hidden; }
}

/* ═══════════════════════════════════════════════
   ADAPTIVE FILTER PANEL
   ═══════════════════════════════════════════════ */

/* ── Десктоп: горизонтальная строка ── */
.prop-filter-desktop {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  padding: 12px 16px;
}
.prop-filter-desktop .form-control {
  flex: 1;
  min-width: 0;
  font-size: 0.84rem;
  height: 36px;
  padding: 5px 10px;
}
.prop-filter-desktop input[type=number] {
  flex: 0 0 auto;
}
.prop-filter-desktop .btn {
  flex-shrink: 0;
  height: 36px;
  white-space: nowrap;
}

/* ── Мобильный блок — скрыт на десктопе ── */
.prop-filter-mobile  { display: none; }

/* ── Toggle header ── */
.prop-filter-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 14px;
  cursor: pointer;
  user-select: none;
  border-radius: var(--radius);
}
.prop-filter-toggle:hover { background: var(--bg); }

/* ── Collapsible body ── */
.prop-filter-body {
  display: none;
  padding: 0 14px 14px;
  border-top: 1px solid var(--border);
}
.prop-filter-body.open { display: block; animation: fSlide .18s ease; }
@keyframes fSlide { from { opacity:0; transform:translateY(-4px); } to { opacity:1; transform:translateY(0); } }

/* ── 2-column rows in mobile filter ── */
.pfr { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-bottom: 7px; }
.pfr .form-control { width: 100%; font-size: 0.83rem; min-width: 0; }

/* Статусы и вид на десктопе */
.prop-status-bar .btn { font-size: 0.82rem; }
.prop-view-bar select { font-size: 0.82rem; }

@media (max-width: 1024px) {
  /* Планшет: фильтр можно слегка сжать */
  .prop-filter-desktop .form-control { font-size: 0.8rem; }
  .prop-filter-desktop input[style*="width:90px"] { width: 75px !important; min-width: 60px; }
  .prop-filter-desktop input[style*="width:80px"] { width: 65px !important; min-width: 55px; }
}

@media (max-width: 768px) {
  /* Скрываем десктоп-фильтр, показываем мобильный */
  .prop-filter-desktop  { display: none !important; }
  .prop-filter-mobile   { display: block; }
  .prop-filter-card     { padding: 0 !important; }

  /* Статус-кнопки */
  .prop-status-bar      { gap: 5px !important; }
  .prop-status-bar .btn { font-size: 0.74rem; padding: 4px 9px; }

  /* Вид+сортировка */
  .prop-view-bar { gap: 5px !important; }
  .prop-view-bar select { max-width: 115px !important; font-size: 0.78rem; }

  /* Верхняя строка статусов + вид — 2 ряда если тесно */
  .prop-top-row { flex-wrap: wrap; gap: 8px !important; }
  .prop-top-row > div:last-child { margin-left: auto; }
}

@media (max-width: 480px) {
  .prop-status-bar      { gap: 4px !important; }
  .prop-status-bar .btn { font-size: 0.72rem; padding: 3px 8px; }
  .pfr { gap: 5px; }
  .pfr .form-control { font-size: 0.8rem; }
}

/* ── Sold property card ─────────────────────── */
.property-card[data-status="sold"] .property-img,
.property-card[data-status="sold"] .property-img-placeholder {
  filter: grayscale(40%);
}
.property-card[data-status="sold"]::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: #b91c1c;
  border-radius: var(--radius) var(--radius) 0 0;
}

/* ── Sidebar collapsed tooltips ─────────────────── */
.sidebar.collapsed .nav-link { position: relative; }
.sidebar.collapsed .nav-link:hover::after {
  content: attr(title);
  position: fixed;
  left: 66px;
  background: #1e293b;
  color: #fff;
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 0.78rem;
  white-space: nowrap;
  z-index: 9999;
  box-shadow: 0 4px 12px rgba(0,0,0,.25);
  pointer-events: none;
}

/* ── Sidebar transition улучшение ───────────────── */
.sidebar { transition: width 0.22s cubic-bezier(.4,0,.2,1); }
.sidebar * { transition: opacity 0.15s ease; }
.sidebar.collapsed .nav-label,
.sidebar.collapsed .sidebar-collapse-label,
.sidebar.collapsed .logo-text,
.sidebar.collapsed .user-info { opacity: 0; pointer-events: none; }

/* Без transition для overflow:hidden элементов */
.sidebar .sidebar-header,
.sidebar .sidebar-footer,
.sidebar .sidebar-scroll { overflow: hidden; }

/* ── Settings layout ─────────────────────────────── */
@media (max-width: 768px) {
  .settings-layout { grid-template-columns: 1fr !important; }
}

/* ── Property List View ──────────────────────────────── */
.property-grid--list {
  display: flex !important;
  flex-direction: column;
  gap: 8px;
}
.property-grid--list .property-card {
  display: flex !important;
  flex-direction: row !important;
  align-items: stretch;
  min-height: 96px;
}
/* Картинка слева */
.property-grid--list .property-card > a:first-child {
  flex-shrink: 0;
  width: 140px;
  display: block;
  position: relative;
}
.property-grid--list .property-img,
.property-grid--list .property-img-placeholder {
  width: 140px !important;
  height: 100% !important;
  min-height: 96px;
  object-fit: cover;
  border-radius: var(--radius) 0 0 var(--radius);
}
/* Actions поверх картинки */
.property-grid--list .property-card-actions {
  top: 6px; right: 6px;
}
/* Body занимает остаток */
.property-grid--list .property-body {
  flex: 1;
  min-width: 0;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
}
.property-grid--list .property-title {
  font-size: .9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.property-grid--list .property-price {
  font-size: 1rem;
}
.property-grid--list .property-meta {
  flex-wrap: nowrap;
  overflow: hidden;
}
/* Цена справа на десктопе */
@media (min-width: 769px) {
  .property-grid--list .property-body {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    column-gap: 16px;
    align-items: center;
  }
  .property-grid--list .property-body > div:first-child { /* код + статус */
    grid-column: 1 / -1;
  }
  .property-grid--list .property-title {
    grid-column: 1;
    align-self: center;
  }
  .property-grid--list .property-price {
    grid-column: 2;
    text-align: right;
    white-space: nowrap;
    align-self: center;
  }
  .property-grid--list .property-meta {
    grid-column: 1 / -1;
  }
}
