:root {
    --blue: #2f6fed;
    --blue-dark: #1f57c8;
    --blue-soft: rgba(47, 111, 237, 0.1);
    --green: #1f9d6c;
    --green-soft: rgba(31, 157, 108, 0.12);
    --amber: #c4841d;
    --amber-soft: rgba(196, 132, 29, 0.12);
    --red: #d14343;
    --red-soft: rgba(209, 67, 67, 0.1);
    --bg: #e9eef6;
    --surface: rgba(255, 255, 255, 0.58);
    --surface-strong: rgba(255, 255, 255, 0.78);
    --surface-soft: rgba(255, 255, 255, 0.38);
    --border: rgba(255, 255, 255, 0.55);
    --border-soft: rgba(28, 36, 52, 0.08);
    --text: #1c2434;
    --muted: #6b7385;
    --shadow: 0 1px 0 rgba(255, 255, 255, 0.55) inset, 0 10px 30px rgba(28, 36, 52, 0.06);
    --shadow-lg: 0 1px 0 rgba(255, 255, 255, 0.6) inset, 0 24px 60px rgba(28, 36, 52, 0.12);
    --radius: 20px;
    --radius-sm: 14px;
    --radius-pill: 999px;
    --blur: 28px;
    --sidebar-width: 268px;
    --font: "Manrope", system-ui, sans-serif;
    --avito-blue: var(--blue);
    --avito-green: var(--green);
    --avito-bg: transparent;
    --avito-border: var(--border-soft);
    --avito-text: var(--text);
    --avito-text-muted: var(--muted);
    --danger: var(--red);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
    font-family: var(--font);
    color: var(--text);
    font-size: 14px;
    font-weight: 600;
    letter-spacing: -0.01em;
    line-height: 1.45;
    overflow: hidden;
    background:
        radial-gradient(1200px 700px at 8% -10%, rgba(147, 197, 253, 0.45), transparent 55%),
        radial-gradient(900px 600px at 92% 0%, rgba(167, 243, 208, 0.28), transparent 50%),
        radial-gradient(800px 500px at 70% 100%, rgba(191, 219, 254, 0.35), transparent 55%),
        linear-gradient(165deg, #e7edf6 0%, #eef2f7 42%, #e8eef5 100%);
    background-attachment: fixed;
}
button, input, textarea, select { font: inherit; font-weight: 600; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
    outline: 2px solid rgba(47, 111, 237, 0.28);
    outline-offset: 2px;
}

.glass {
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    backdrop-filter: blur(var(--blur)) saturate(160%);
    -webkit-backdrop-filter: blur(var(--blur)) saturate(160%);
}

.app-shell { display: flex; width: 100%; height: 100vh; }
.main-content {
    flex: 1;
    min-width: 0;
    overflow-y: auto;
    padding: 28px 36px 48px;
}
.page { max-width: 1500px; margin: 0 auto; }
.view-section { display: none; animation: viewIn .28s ease; }
.view-section.active { display: block; }
@keyframes viewIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 22px;
}
.page-title, h1 {
    margin: 0;
    font-size: 27px;
    line-height: 1.2;
    letter-spacing: -0.04em;
    font-weight: 700;
}
.page-subtitle {
    margin: 8px 0 0;
    color: var(--muted);
    line-height: 1.55;
    font-weight: 600;
    font-size: 13.5px;
    max-width: 620px;
}
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 22px;
    flex-wrap: wrap;
}
h2 { margin: 0; font-size: 18px; font-weight: 600; letter-spacing: -0.03em; }
h3 { margin: 0 0 12px; font-size: 13px; font-weight: 600; letter-spacing: 0.02em; color: var(--muted); text-transform: uppercase; }

.btn {
    min-height: 38px;
    padding: 8px 15px;
    border-radius: var(--radius-pill);
    border: 1px solid var(--border-soft);
    background: rgba(255, 255, 255, 0.55);
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: -0.01em;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background .18s ease, border-color .18s ease, transform .18s ease, box-shadow .18s ease;
    white-space: nowrap;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.5) inset;
}
.btn:hover {
    background: rgba(255, 255, 255, 0.82);
    border-color: rgba(28, 36, 52, 0.12);
    transform: translateY(-0.5px);
}
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn-primary {
    background: linear-gradient(180deg, #4a84f2 0%, var(--blue) 100%);
    border-color: transparent;
    color: #fff;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.28) inset, 0 8px 18px rgba(47, 111, 237, 0.22);
}
.btn-primary:hover {
    background: linear-gradient(180deg, #3f79ec 0%, var(--blue-dark) 100%);
    color: #fff;
}
.btn-success {
    background: linear-gradient(180deg, #2bb07d 0%, var(--green) 100%);
    border-color: transparent;
    color: #fff;
}
.btn-outline {
    background: rgba(255, 255, 255, 0.42);
    border-color: var(--border-soft);
}
.btn-outline:hover { background: rgba(255, 255, 255, 0.72); }
.btn-danger {
    background: var(--red-soft);
    color: var(--red);
    border-color: rgba(209, 67, 67, 0.18);
}
.btn-sm { min-height: 32px; padding: 5px 12px; font-size: 12px; }
.btn-icon { width: 38px; padding: 0; border-radius: 12px; }
.btn-ghost {
    width: 100%;
    padding: 9px 11px;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
}
.btn-ghost:hover { background: rgba(255, 255, 255, 0.45); color: var(--text); }
.btn-ghost.danger:hover { background: var(--red-soft); color: var(--red); }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    backdrop-filter: blur(var(--blur)) saturate(160%);
    -webkit-backdrop-filter: blur(var(--blur)) saturate(160%);
    padding: 22px;
    margin-bottom: 18px;
}
.card-header {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
    margin-bottom: 16px;
}
.card-title { font-size: 15px; font-weight: 600; letter-spacing: -0.02em; }
.card-hint { color: var(--muted); font-size: 12px; margin-top: 4px; font-weight: 500; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4, .kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.kpi-card {
    background: linear-gradient(165deg, rgba(255, 255, 255, 0.72) 0%, rgba(255, 255, 255, 0.42) 100%);
    border: 1px solid rgba(255, 255, 255, 0.62);
    border-radius: 22px;
    padding: 18px 18px 16px;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.7) inset, 0 12px 28px rgba(28, 36, 52, 0.05);
    backdrop-filter: blur(var(--blur)) saturate(160%);
    -webkit-backdrop-filter: blur(var(--blur)) saturate(160%);
    position: relative;
    overflow: hidden;
    min-height: 132px;
    display: flex;
    flex-direction: column;
}
.kpi-card::after {
    content: "";
    position: absolute;
    right: -28px;
    top: -36px;
    width: 110px;
    height: 110px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.55) 0%, transparent 70%);
    pointer-events: none;
}
.kpi-top {
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;
    z-index: 1;
}
.kpi-icon {
    width: 34px;
    height: 34px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    color: #4b5568;
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(28, 36, 52, 0.06);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8) inset;
}
.kpi-icon svg { width: 17px; height: 17px; }
.kpi-label {
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.01em;
    line-height: 1.3;
}
.kpi-value {
    margin-top: 14px;
    font-size: 28px;
    line-height: 1.05;
    font-weight: 600;
    letter-spacing: -0.045em;
    position: relative;
    z-index: 1;
}
.kpi-meta {
    margin-top: auto;
    padding-top: 10px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 500;
    position: relative;
    z-index: 1;
}

.status-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    padding: 10px 14px;
    margin-bottom: 16px;
    border: 1px solid rgba(255, 255, 255, 0.58);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.42);
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.5) inset;
}
.status-bar.success,
.status-bar.warning,
.status-bar.error {
    background: rgba(255, 255, 255, 0.52);
    color: #3f4758;
}
.status-icon {
    width: 28px;
    height: 28px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    color: #6b7385;
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid rgba(28, 36, 52, 0.06);
}
.status-icon svg { width: 15px; height: 15px; }
.status-bar.success .status-icon { color: #3f4758; }
.status-bar.warning .status-icon { color: #5b6478; }
.status-bar.error .status-icon { color: #5b6478; }
.status-dot { display: none; }

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border-radius: var(--radius-pill);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.01em;
    border: 1px solid rgba(28, 36, 52, 0.08);
    background: rgba(255, 255, 255, 0.62);
    color: #4b5568;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.7) inset;
}
.badge::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #94a3b8;
    flex: none;
}
.badge-ok { color: #334155; background: rgba(255, 255, 255, 0.72); }
.badge-ok::before { background: #64748b; }
.badge-wait { color: #64748b; }
.badge-wait::before { background: #cbd5e1; }
.badge-warn { color: #475569; }
.badge-warn::before { background: #94a3b8; }

.table-container {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    backdrop-filter: blur(var(--blur)) saturate(160%);
    -webkit-backdrop-filter: blur(var(--blur)) saturate(160%);
    overflow: auto;
}
.table-container.flat,
.card .table-container { box-shadow: none; background: rgba(255, 255, 255, 0.28); }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td {
    padding: 14px 16px;
    border-bottom: 1px solid rgba(28, 36, 52, 0.06);
    text-align: left;
    vertical-align: middle;
}
th {
    background: rgba(255, 255, 255, 0.35);
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    position: sticky;
    top: 0;
    z-index: 1;
    backdrop-filter: blur(12px);
}
td { font-size: 13px; font-weight: 500; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: rgba(255, 255, 255, 0.35); }
.cell-title { font-weight: 600; line-height: 1.35; letter-spacing: -0.01em; }
.cell-muted { color: var(--muted); font-size: 12px; margin-top: 4px; font-weight: 500; }

.ad-tags {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 2px;
    padding: 10px;
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.35);
}
.ad-tag { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.ad-tag-label {
    color: var(--muted);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.ad-tag .text-input {
    padding: 7px 9px;
    font-size: 12px;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.7);
}
.ad-core-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px 14px;
}

.photo-mode {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 12px;
}
.photo-mode-btn {
    min-height: 40px;
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-pill);
    background: rgba(255, 255, 255, 0.45);
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: .15s;
}
.photo-mode-btn:hover { border-color: rgba(47, 111, 237, 0.25); color: var(--text); }
.photo-mode-btn.active {
    border-color: rgba(28, 36, 52, 0.14);
    background: rgba(255, 255, 255, 0.82);
    color: var(--text);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8) inset;
}
.photo-panel-hint {
    margin: 0 0 10px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.5;
    font-weight: 500;
}
.photo-preview-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
    padding: 5px 10px;
    border-radius: var(--radius-pill);
    border: 1px solid rgba(28, 36, 52, 0.08);
    background: rgba(255, 255, 255, 0.65);
    color: #475569;
    font-size: 11px;
    font-weight: 600;
}
.metric-pair { display: flex; gap: 6px; align-items: baseline; }
.metric-pair strong { font-size: 14px; font-weight: 600; }
.empty-state { padding: 52px 24px; text-align: center; color: var(--muted); font-weight: 500; }
.empty-title { color: var(--text); font-size: 15px; font-weight: 600; margin-bottom: 6px; }

.text-input, .mass-input, select.text-input, .text-textarea, .mass-textarea {
    width: 100%;
    border: 1px solid var(--border-soft);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.62);
    color: var(--text);
    padding: 11px 13px;
    font-size: 13px;
    font-weight: 500;
    transition: .16s;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.45) inset;
}
.text-input:hover, .text-textarea:hover { border-color: rgba(28, 36, 52, 0.14); }
.text-input:focus, .text-textarea:focus {
    border-color: rgba(47, 111, 237, 0.45);
    outline: none;
    box-shadow: 0 0 0 3px rgba(47, 111, 237, 0.12);
    background: rgba(255, 255, 255, 0.88);
}
.text-textarea, .mass-textarea { resize: vertical; line-height: 1.55; }
.form-label {
    display: block;
    margin-bottom: 7px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.form-group { margin-bottom: 15px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 24px; }
.full-width { grid-column: 1 / -1; }
.section-block {
    padding: 18px;
    margin-bottom: 18px;
    background: rgba(255, 255, 255, 0.32);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    backdrop-filter: blur(12px);
}
.dynamic-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.dynamic-key { width: 34%; font-family: var(--font); color: var(--blue); font-weight: 600; }
.dynamic-val { flex: 1; }
.dynamic-del {
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 12px;
    background: var(--red-soft);
    color: var(--red);
    cursor: pointer;
}

.quick-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.quick-action {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px;
    border: 1px solid rgba(28, 36, 52, 0.07);
    border-radius: 18px;
    background: linear-gradient(165deg, rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0.38));
    text-align: left;
    cursor: pointer;
    transition: .18s;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.65) inset;
}
.quick-action:hover {
    border-color: rgba(28, 36, 52, 0.12);
    background: rgba(255, 255, 255, 0.78);
    transform: translateY(-1px);
}
.quick-action-icon {
    width: 36px;
    height: 36px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    color: #4b5568;
    background: rgba(255, 255, 255, 0.75);
    border: 1px solid rgba(28, 36, 52, 0.06);
}
.quick-action-icon svg { width: 17px; height: 17px; }
.quick-action-body { min-width: 0; }
.quick-action strong { display: block; margin-bottom: 4px; font-weight: 600; letter-spacing: -0.02em; }
.quick-action span,
.quick-action-body span { color: var(--muted); font-size: 12px; line-height: 1.45; font-weight: 500; }
.card-title-row { display: flex; align-items: flex-start; gap: 12px; }
.card-title-icon {
    width: 34px;
    height: 34px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    color: #4b5568;
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(28, 36, 52, 0.06);
}
.card-title-icon svg { width: 16px; height: 16px; }
.feed-box { display: flex; gap: 10px; align-items: center; }
.feed-url {
    min-width: 0;
    flex: 1;
    padding: 11px 13px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.4);
    border: 1px solid var(--border-soft);
    color: #4b5568;
    font-family: var(--font);
    font-size: 12px;
    font-weight: 600;
    overflow: hidden;
}

.chart-card { min-height: 330px; }
.chart-wrap { position: relative; height: 255px; }
.chart-wrap-lg { height: 300px; }
.feed-url-main { font-size: 13px; font-weight: 600; word-break: break-all; color: var(--text); }
.feed-url-sub { margin-top: 6px; font-size: 12px; color: var(--muted); font-weight: 500; }
.recommendations { display: grid; gap: 10px; }
.recommendation {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 15px;
    border-radius: 16px;
    border: 1px solid rgba(28, 36, 52, 0.07);
    background: rgba(255, 255, 255, 0.48);
}
.recommendation .rec-icon {
    width: 32px;
    height: 32px;
    border-radius: 11px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    color: #5b6478;
    background: rgba(255, 255, 255, 0.75);
    border: 1px solid rgba(28, 36, 52, 0.06);
}
.recommendation .rec-icon svg { width: 15px; height: 15px; }
.recommendation strong { display: block; margin-bottom: 4px; font-weight: 600; }
.recommendation p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.55; font-weight: 500; }
.recommendation.critical,
.recommendation.warning,
.recommendation.opportunity {
    background: rgba(255, 255, 255, 0.52);
    border-color: rgba(28, 36, 52, 0.08);
}
.analytics-controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.sort-button {
    border: 0;
    background: none;
    padding: 0;
    color: inherit;
    text-transform: inherit;
    font: inherit;
    cursor: pointer;
}

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    padding: 24px;
    background: rgba(28, 36, 52, 0.28);
    backdrop-filter: blur(14px) saturate(140%);
    -webkit-backdrop-filter: blur(14px) saturate(140%);
    align-items: center;
    justify-content: center;
}
.modal-overlay.visible { display: flex; }
.modal {
    width: 920px;
    max-width: 100%;
    max-height: 92vh;
    display: flex;
    flex-direction: column;
    background: rgba(255, 255, 255, 0.78);
    border: 1px solid rgba(255, 255, 255, 0.65);
    border-radius: 24px;
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(36px) saturate(170%);
    -webkit-backdrop-filter: blur(36px) saturate(170%);
    overflow: hidden;
}
.modal-sm { width: 560px; }
.modal-header, .modal-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(28, 36, 52, 0.06);
    background: rgba(255, 255, 255, 0.28);
}
.modal-footer {
    justify-content: flex-end;
    border: 0;
    border-top: 1px solid rgba(28, 36, 52, 0.06);
}
.modal-header h2 { margin: 0; font-size: 17px; font-weight: 600; letter-spacing: -0.02em; }
.modal-body { padding: 20px; overflow-y: auto; }

.toast-container {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 2000;
    display: grid;
    gap: 10px;
    width: min(380px, calc(100vw - 32px));
}
.toast {
    padding: 13px 15px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.78);
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(22px) saturate(160%);
    -webkit-backdrop-filter: blur(22px) saturate(160%);
    animation: toastIn .22s ease;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.45;
}
.toast.success { box-shadow: 0 0 0 1px rgba(31, 157, 108, 0.18), var(--shadow-lg); }
.toast.warning { box-shadow: 0 0 0 1px rgba(196, 132, 29, 0.18), var(--shadow-lg); }
.toast.error { box-shadow: 0 0 0 1px rgba(209, 67, 67, 0.18), var(--shadow-lg); }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } }

.skeleton {
    border-radius: 10px;
    color: transparent !important;
    background: linear-gradient(90deg, rgba(255,255,255,.35) 25%, rgba(255,255,255,.7) 50%, rgba(255,255,255,.35) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.4s infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }

.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    height: 100vh;
    display: flex;
    flex-direction: column;
    margin: 12px 0 12px 12px;
    padding: 16px 12px;
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.52);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    backdrop-filter: blur(var(--blur)) saturate(170%);
    -webkit-backdrop-filter: blur(var(--blur)) saturate(170%);
    transition: .22s ease;
    z-index: 20;
}
.sidebar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 8px 18px;
}
.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -0.03em;
}
.sidebar-logo span { color: var(--blue); font-weight: 600; }
.sidebar-toggle {
    width: 32px;
    height: 32px;
    border: 1px solid var(--border-soft);
    border-radius: 11px;
    background: rgba(255, 255, 255, 0.5);
    color: var(--muted);
    cursor: pointer;
}
.sidebar-section { margin-top: 14px; }
.sidebar-section-title {
    padding: 0 12px;
    margin-bottom: 7px;
    color: #8b93a7;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}
.sidebar-nav { display: grid; gap: 4px; }
.sidebar-item {
    width: 100%;
    border: 1px solid transparent;
    border-radius: 14px;
    padding: 10px 12px;
    display: flex;
    align-items: center;
    gap: 11px;
    background: transparent;
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
    transition: .15s;
}
.sidebar-item:hover {
    background: rgba(255, 255, 255, 0.45);
    color: var(--text);
}
.sidebar-item.active {
    background: rgba(255, 255, 255, 0.72);
    border-color: rgba(255, 255, 255, 0.7);
    color: var(--text);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.7) inset, 0 6px 16px rgba(28, 36, 52, 0.05);
}
.nav-icon { width: 18px; height: 18px; flex: none; opacity: 0.85; }
.sidebar-footer {
    margin-top: auto;
    padding-top: 14px;
    border-top: 1px solid rgba(28, 36, 52, 0.06);
    display: grid;
    gap: 10px;
}
.sidebar-balance {
    border: 1px solid rgba(47, 111, 237, 0.16);
    border-radius: 16px;
    background: linear-gradient(160deg, rgba(47, 111, 237, 0.1), rgba(255, 255, 255, 0.55));
    padding: 12px;
}
.sidebar-balance-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
}
.sidebar-balance-value {
    margin-top: 4px;
    font-size: 18px;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--text);
}
.sidebar-balance-until,
.sidebar-balance-price {
    margin-top: 6px;
    font-size: 11px;
    color: var(--muted);
    font-weight: 600;
    line-height: 1.35;
}
.sidebar.collapsed .sidebar-balance { display: none; }
.active-account-card {
    width: 100%;
    border: 1px solid var(--border-soft);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.4);
    padding: 12px;
    text-align: left;
    cursor: pointer;
    transition: .15s;
}
.active-account-card:hover {
    border-color: rgba(47, 111, 237, 0.22);
    background: rgba(255, 255, 255, 0.65);
}
.account-caption {
    color: var(--muted);
    font-size: 10px;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.06em;
}
.account-name {
    margin-top: 4px;
    font-size: 13px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.sidebar.collapsed { width: 78px; min-width: 78px; }
.sidebar.collapsed .sidebar-logo-text,
.sidebar.collapsed .sidebar-section-title,
.sidebar.collapsed .nav-label,
.sidebar.collapsed .account-caption,
.sidebar.collapsed .account-name { display: none; }
.sidebar.collapsed .sidebar-head { flex-direction: column; gap: 12px; }
.sidebar.collapsed .sidebar-item { justify-content: center; padding: 10px; }
.sidebar.collapsed .active-account-card { height: 42px; position: relative; }
.sidebar.collapsed .active-account-card::after {
    content: "";
    position: absolute;
    inset: 13px;
    border-radius: 50%;
    background: var(--green);
}

.balance-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.65);
    color: #475569;
    padding: 5px 10px;
    border-radius: var(--radius-pill);
    font-weight: 600;
    font-size: 12px;
    border: 1px solid rgba(28, 36, 52, 0.08);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.7) inset;
}
.balance-badge::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #94a3b8;
}

.dropzone {
    border: 1.5px dashed rgba(28, 36, 52, 0.14);
    padding: 56px 20px;
    text-align: center;
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.28);
}
.dropzone-label {
    cursor: pointer;
    color: var(--blue);
    font-weight: 600;
    font-size: 13px;
    display: inline-flex;
    padding: 11px 22px;
    border: 1px solid rgba(47, 111, 237, 0.28);
    border-radius: var(--radius-pill);
    background: rgba(255, 255, 255, 0.65);
}
.upload-status {
    margin-top: 18px;
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
}
.account-name-cell {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 8px;
    letter-spacing: -0.02em;
}
.account-name-cell.is-active { color: var(--blue); }
.actions-row {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}
.mobile-menu { display: none; margin-bottom: 16px; }

@media (max-width: 1100px) {
    .main-content { padding: 22px 20px 36px; }
    .page-header { flex-direction: column; }
    .grid-4, .kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .grid-3, .quick-actions { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 760px) {
    body { overflow: auto; }
    .app-shell { height: auto; min-height: 100vh; }
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        margin: 0;
        height: 100vh;
        border-radius: 0 20px 20px 0;
        transform: translateX(-105%);
        box-shadow: 16px 0 40px rgba(28, 36, 52, 0.14);
    }
    .sidebar.mobile-open { transform: translateX(0); }
    .main-content { padding: 18px 14px 36px; overflow: visible; }
    .page-header { flex-direction: column; }
    .page-actions, .page-actions .btn { width: 100%; }
    .grid-2, .grid-3, .grid-4, .kpi-grid, .quick-actions, .form-grid, .ad-tags, .ad-core-grid, .photo-mode { grid-template-columns: 1fr; }
    .full-width { grid-column: auto; }
    .mobile-menu { display: inline-flex !important; }
    .modal-overlay { padding: 8px; }
    .modal { max-height: 96vh; border-radius: 20px; }
    .dynamic-row { align-items: stretch; flex-wrap: wrap; }
    .dynamic-key { width: 100%; }
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    .card, .kpi-card, .table-container, .sidebar, .modal, .toast, .status-bar, .chat-shell {
        background: rgba(255, 255, 255, 0.92);
    }
}

/* ─── Chats ─── */
.chat-live-pill {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 0 12px;
    border-radius: var(--radius-pill);
    border: 1px solid rgba(28, 36, 52, 0.08);
    background: rgba(255, 255, 255, 0.55);
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
}
.chat-live-pill.is-online { color: #334155; }

.chat-shell {
    display: grid;
    grid-template-columns: minmax(280px, 340px) 1fr;
    gap: 0;
    padding: 0;
    overflow: hidden;
    height: calc(100vh - 168px);
    max-height: calc(100vh - 168px);
    min-height: 520px;
}
body.is-chats .main-content {
    overflow: hidden;
}
body.is-chats #view-chats {
    height: calc(100vh - 64px);
    display: none;
    flex-direction: column;
    min-height: 0;
}
body.is-chats #view-chats.active {
    display: flex;
}
body.is-chats #view-chats .page-header {
    flex: none;
    margin-bottom: 14px;
}
body.is-chats #view-chats .chat-shell {
    flex: 1;
    min-height: 0;
    height: auto;
    max-height: none;
    margin-bottom: 0;
}
.chat-sidebar {
    border-right: 1px solid rgba(28, 36, 52, 0.07);
    display: flex;
    flex-direction: column;
    min-height: 0;
    height: 100%;
    background: rgba(255, 255, 255, 0.28);
    overflow: hidden;
}
.chat-filters {
    padding: 14px;
    display: grid;
    gap: 10px;
    border-bottom: 1px solid rgba(28, 36, 52, 0.06);
}
.chat-unread-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
}
.chat-list {
    overflow-y: auto;
    flex: 1;
    padding: 10px;
    display: grid;
    gap: 8px;
    align-content: start;
}
.chat-list-item {
    width: 100%;
    text-align: left;
    border: 1px solid rgba(255, 255, 255, 0.62);
    background: linear-gradient(165deg, rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0.4));
    border-radius: 18px;
    padding: 12px 13px 13px;
    cursor: pointer;
    position: relative;
    color: inherit;
    transition: .16s ease;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.7) inset, 0 8px 18px rgba(28, 36, 52, 0.04);
    backdrop-filter: blur(12px);
}
.chat-list-item:hover {
    background: rgba(255, 255, 255, 0.82);
    transform: translateY(-1px);
}
.chat-list-item.is-active {
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(47, 111, 237, 0.22);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8) inset, 0 10px 22px rgba(28, 36, 52, 0.07);
}
.chat-list-top {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    align-items: baseline;
}
.chat-list-top strong { font-weight: 600; font-size: 13px; letter-spacing: -0.02em; }
.chat-list-top span { color: var(--muted); font-size: 11px; flex: none; }
.chat-list-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}
.chat-account-tag,
.chat-location-tag,
.chat-price-tag {
    display: inline-flex;
    align-items: center;
    max-width: 100%;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.chat-account-tag {
    color: #334155;
    background: rgba(28, 36, 52, 0.06);
    border: 1px solid rgba(28, 36, 52, 0.08);
}
.chat-location-tag {
    color: #475569;
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(28, 36, 52, 0.08);
}
.chat-location-tag.is-muted { color: var(--muted); opacity: .85; }
.chat-price-tag {
    color: #475569;
    background: rgba(255, 255, 255, 0.55);
    border: 1px solid rgba(28, 36, 52, 0.06);
}
.chat-list-item-title {
    margin-top: 8px;
    font-size: 12px;
    font-weight: 600;
    color: #3f4758;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.chat-list-preview {
    margin-top: 6px;
    color: #64748b;
    font-size: 12px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    padding-right: 28px;
}
.chat-unread {
    position: absolute;
    right: 12px;
    bottom: 12px;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: #334155;
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.chat-main {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    height: 100%;
    overflow: hidden;
}
.chat-thread-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid rgba(28, 36, 52, 0.06);
    background: rgba(255, 255, 255, 0.4);
    flex: none;
}
.chat-thread-heading { min-width: 0; flex: 1; }
.chat-thread-title-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}
.chat-context-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 16px;
    border: 1px solid rgba(28, 36, 52, 0.07);
    background: rgba(255, 255, 255, 0.55);
    max-width: 720px;
}
.chat-context-thumb {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    object-fit: cover;
    flex: none;
    background: rgba(28, 36, 52, 0.06);
    border: 1px solid rgba(28, 36, 52, 0.06);
}
.chat-context-thumb.is-empty { background: linear-gradient(135deg, rgba(255,255,255,.7), rgba(28,36,52,.08)); }
.chat-context-body { min-width: 0; }
.chat-context-title {
    font-size: 13px;
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.35;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.chat-context-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 7px;
}
.chat-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: rgba(255, 255, 255, 0.18);
}
.chat-bubble {
    max-width: min(72%, 520px);
    padding: 11px 13px;
    border-radius: 18px;
    border: 1px solid rgba(28, 36, 52, 0.06);
    background: rgba(255, 255, 255, 0.72);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.7) inset;
}
.chat-bubble.is-in { align-self: flex-start; border-bottom-left-radius: 8px; }
.chat-bubble.is-out {
    align-self: flex-end;
    background: rgba(47, 111, 237, 0.12);
    border-color: rgba(47, 111, 237, 0.14);
    border-bottom-right-radius: 8px;
}
.chat-bubble-text {
    font-size: 13px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}
.chat-bubble-meta {
    margin-top: 6px;
    color: var(--muted);
    font-size: 11px;
}
.chat-composer {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
    padding: 14px 16px;
    border-top: 1px solid rgba(28, 36, 52, 0.06);
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(16px);
    align-items: end;
    flex: none;
    position: sticky;
    bottom: 0;
    z-index: 2;
}
.chat-composer .text-textarea {
    min-height: 54px;
    max-height: 140px;
    resize: vertical;
}

@media (max-width: 960px) {
    .chat-shell {
        grid-template-columns: 1fr;
        min-height: 0;
        height: calc(100vh - 150px);
    }
    body.is-chats #view-chats .chat-shell {
        height: auto;
        max-height: none;
    }
    .chat-sidebar {
        min-height: 240px;
        max-height: 38vh;
        height: auto;
        border-right: 0;
        border-bottom: 1px solid rgba(28, 36, 52, 0.07);
    }
    .chat-main { min-height: 320px; }
}

.cabinet-chip {
    width: 100%;
    margin-top: 10px;
    border: 1px solid rgba(28, 36, 52, 0.08);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.42);
    padding: 11px 12px;
    text-align: left;
    cursor: pointer;
}
.cabinet-chip:hover {
    background: rgba(255, 255, 255, 0.7);
}
.cabinet-security-list {
    margin: 0 0 16px;
    padding-left: 18px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.55;
}
.cabinet-plan-banner {
    margin-bottom: 16px;
    padding: 12px 14px;
    border-radius: 14px;
    font-size: 13px;
    line-height: 1.45;
    background: rgba(255, 255, 255, 0.65);
    border: 1px solid rgba(255, 255, 255, 0.7);
}
.cabinet-plan-banner.is-trial {
    background: rgba(47, 111, 237, 0.08);
}
.cabinet-plan-banner.is-expired {
    background: rgba(209, 67, 67, 0.1);
    color: #8a2f2f;
}
.cabinet-ar-item {
    padding: 12px 0;
    border-top: 1px solid rgba(20, 40, 70, 0.06);
}
.cabinet-tg-link {
    margin-bottom: 12px;
    padding: 12px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.55);
}
.cabinet-managers-list { margin-top: 14px; }
.cabinet-manager-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 0;
    border-top: 1px solid rgba(20, 40, 70, 0.06);
}
.cabinet-manager-row strong { font-weight: 600; }
body.is-manager .owner-only { display: none !important; }

body.landing-body {
    overflow: auto !important;
    height: auto;
    min-height: 100%;
}

.auth-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    overflow: auto;
}
.auth-card {
    width: min(400px, 100%);
    padding: 26px 24px 28px;
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.78);
    border: 1px solid rgba(255, 255, 255, 0.65);
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(28px) saturate(160%);
}
.auth-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 22px;
}
.auth-brand {
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: inherit;
    text-decoration: none;
    margin: 0;
}
.auth-brand:hover { color: var(--blue); }
.auth-nav {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}
.auth-nav-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 7px 12px;
    border-radius: 999px;
    border: 1px solid rgba(28, 36, 52, 0.1);
    background: rgba(255, 255, 255, 0.7);
    color: var(--text);
    text-decoration: none;
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
    transition: border-color .15s ease, background .15s ease, color .15s ease;
}
.auth-nav-btn:hover {
    border-color: rgba(47, 111, 237, 0.35);
    color: var(--blue);
}
.auth-nav-btn-accent {
    background: rgba(47, 111, 237, 0.1);
    border-color: rgba(47, 111, 237, 0.22);
    color: #2f6fed;
}
.auth-nav-btn-accent:hover {
    background: rgba(47, 111, 237, 0.16);
    color: #1f57c8;
}
.auth-title {
    margin: 0;
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -0.04em;
}
.auth-subtitle {
    margin: 6px 0 20px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.45;
    font-weight: 600;
}
.auth-form .form-group { margin-bottom: 12px; }
.auth-main-btn {
    width: 100%;
    margin-top: 4px;
}
.auth-footer-links {
    margin-top: 14px;
    text-align: center;
    font-size: 13px;
}
.auth-footer-links a {
    color: var(--blue);
    text-decoration: none;
}
.auth-footer-links a:hover { text-decoration: underline; }
.auth-error {
    margin-bottom: 12px;
    padding: 10px 12px;
    border-radius: 12px;
    background: rgba(209, 67, 67, 0.08);
    color: #a33333;
    font-size: 13px;
}
.auth-ok {
    margin-bottom: 12px;
    padding: 10px 12px;
    border-radius: 12px;
    background: rgba(46, 160, 67, 0.1);
    color: #1f7a32;
    font-size: 13px;
}
.auth-or {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 18px 0 12px;
    color: var(--muted);
    font-size: 12px;
}
.auth-or::before,
.auth-or::after {
    content: '';
    flex: 1;
    height: 1px;
    background: rgba(28, 36, 52, 0.1);
}
.auth-tg-block { margin-top: 0; }
.auth-tg-btn {
    width: 100%;
    background: transparent;
    border: 1px solid rgba(42, 171, 238, 0.45);
    color: #1a8ec9;
    font-weight: 600;
    box-shadow: none;
}
.auth-tg-btn:hover {
    background: rgba(42, 171, 238, 0.08);
    border-color: #2AABEE;
    color: #1578ad;
}
.auth-tg-btn:disabled {
    opacity: 0.55;
}
.auth-hint {
    margin: 8px 0 0;
    font-size: 12px;
    color: var(--muted);
    text-align: center;
    line-height: 1.45;
}

.chat-thread-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    flex: none;
    align-items: flex-start;
}

/* —— Ведение клиента (kanban) —— */
body.is-clients .main-content {
    overflow: auto;
}
body.is-clients #view-clients {
    height: auto;
    min-height: calc(100vh - 64px);
    display: none;
    flex-direction: column;
    gap: 10px;
}
body.is-clients #view-clients.active {
    display: flex;
}
.leads-page-header {
    flex: none;
    margin-bottom: 0 !important;
}
.leads-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}
.leads-toolbar .text-input {
    min-width: 160px;
    max-width: 220px;
}
.leads-stage-tabs {
    display: none;
    flex: none;
    gap: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 2px 2px 6px;
    scrollbar-width: none;
}
.leads-stage-tabs::-webkit-scrollbar { display: none; }
.leads-stage-tab {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 1px solid rgba(28, 36, 52, 0.1);
    background: rgba(255, 255, 255, 0.72);
    border-radius: 999px;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    cursor: pointer;
    white-space: nowrap;
}
.leads-stage-tab i {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}
.leads-stage-tab em {
    font-style: normal;
    font-size: 11px;
    color: var(--muted);
    background: rgba(28, 36, 52, 0.06);
    border-radius: 999px;
    padding: 1px 7px;
}
.leads-stage-tab.is-active {
    border-color: rgba(47, 111, 237, 0.45);
    box-shadow: 0 0 0 3px rgba(47, 111, 237, 0.12);
    background: #fff;
}
.leads-workspace {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(300px, 360px);
    gap: 14px;
    align-items: start;
}
.leads-board {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    overflow-y: visible;
    min-height: 0;
    height: auto;
    padding-bottom: 4px;
    scroll-snap-type: x proximity;
    align-items: flex-start;
}
.leads-column {
    flex: 1 1 0;
    min-width: 148px;
    max-width: 188px;
    width: auto;
    display: flex;
    flex-direction: column;
    height: auto;
    min-height: 0;
    padding: 8px;
    border-radius: 14px;
    border: 1px solid rgba(28, 36, 52, 0.07);
    background: rgba(255, 255, 255, 0.42);
    scroll-snap-align: start;
    transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
}
.leads-column.is-drop {
    border-color: rgba(47, 111, 237, 0.55);
    background: rgba(47, 111, 237, 0.08);
    box-shadow: inset 0 0 0 1px rgba(47, 111, 237, 0.2);
}
.leads-column-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 2px 2px 10px;
    flex: none;
}
.leads-column-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex: none;
}
.leads-column-title {
    font-size: 13px;
    font-weight: 700;
    letter-spacing: -0.02em;
}
.leads-column-count {
    margin-left: auto;
    font-size: 11px;
    color: var(--muted);
    background: rgba(28, 36, 52, 0.06);
    border-radius: 999px;
    padding: 2px 8px;
}
.leads-column-body {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: none;
    height: auto;
    overflow: visible;
    padding-right: 2px;
}
.leads-column-empty {
    font-size: 12px;
    color: var(--muted);
    padding: 10px 8px;
    text-align: center;
    border: 1px dashed rgba(28, 36, 52, 0.12);
    border-radius: 12px;
}
.leads-detail {
    position: sticky;
    top: 12px;
    min-height: 0;
    max-height: calc(100vh - 100px);
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    padding: 16px;
    border-radius: 18px;
    border: 1px solid rgba(28, 36, 52, 0.07);
    background: rgba(255, 255, 255, 0.72);
}
.lead-card {
    position: relative;
    text-align: left;
    border: 1px solid rgba(28, 36, 52, 0.08);
    background: rgba(255, 255, 255, 0.88);
    border-radius: 14px;
    padding: 10px 12px 10px 16px;
    cursor: grab;
    transition: border-color .15s ease, box-shadow .15s ease, opacity .15s ease;
    touch-action: manipulation;
    user-select: none;
}
.lead-card:active { cursor: grabbing; }
.lead-card-grip {
    position: absolute;
    left: 6px;
    top: 12px;
    bottom: 12px;
    width: 3px;
    border-radius: 2px;
    background: repeating-linear-gradient(
        to bottom,
        rgba(28, 36, 52, 0.22) 0 2px,
        transparent 2px 4px
    );
    opacity: 0.55;
}
.lead-card:hover {
    border-color: rgba(47, 111, 237, 0.35);
}
.lead-card.is-active {
    border-color: rgba(47, 111, 237, 0.55);
    box-shadow: 0 0 0 3px rgba(47, 111, 237, 0.12);
}
.lead-card.is-dragging {
    opacity: 0.45;
}
.lead-card-name {
    font-size: 13px;
    font-weight: 700;
    letter-spacing: -0.02em;
}
.lead-card-meta,
.lead-card-phone {
    margin-top: 4px;
    font-size: 12px;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.lead-card-foot {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin-top: 8px;
    font-size: 11px;
    color: var(--muted);
}
.lead-card-chat {
    color: #2f6fed;
    font-weight: 600;
}
.leads-detail-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
}
.leads-sheet-close {
    display: none;
}
.lead-stage-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 14px;
}
.lead-stage-chip {
    border: 1px solid color-mix(in srgb, var(--c) 35%, transparent);
    background: color-mix(in srgb, var(--c) 10%, #fff);
    color: var(--text);
    border-radius: 999px;
    padding: 6px 10px;
    font-size: 12px;
    cursor: pointer;
}
.lead-stage-chip.is-on {
    background: var(--c);
    color: #fff;
    border-color: transparent;
}
.lead-pattern-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.lead-pattern-chip {
    border: 1px solid rgba(28, 36, 52, 0.1);
    background: rgba(47, 111, 237, 0.06);
    color: #2f6fed;
    border-radius: 10px;
    padding: 7px 10px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}
.lead-detail-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
}
.lead-history {
    border-top: 1px solid rgba(28, 36, 52, 0.06);
    padding-top: 12px;
}
.lead-history-item {
    display: grid;
    grid-template-columns: 90px 1fr;
    gap: 8px;
    font-size: 12px;
    padding: 6px 0;
    color: var(--muted);
}
.leads-sheet-backdrop {
    display: none;
}
.leads-modal {
    border: none;
    border-radius: 18px;
    padding: 0;
    max-width: min(720px, calc(100vw - 24px));
    width: 100%;
    background: transparent;
}
.leads-modal::backdrop {
    background: rgba(16, 22, 34, 0.45);
}
.leads-modal-card {
    margin: 0;
    padding: 16px;
    border-radius: 18px;
    background: #fff;
    border: 1px solid rgba(28, 36, 52, 0.08);
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: min(80vh, 640px);
}
.leads-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.leads-patterns-card {
    flex: none;
    margin-top: 4px;
}
.leads-patterns-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}
.leads-patterns {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 12px;
    overflow: visible;
    max-height: none;
}
.lead-pattern-row {
    display: grid;
    grid-template-columns: minmax(120px, 160px) 1fr minmax(140px, 170px) 40px;
    gap: 8px;
    align-items: start;
}
.leads-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    flex: none;
}

@media (max-width: 900px) {
    .leads-desktop-only { display: none !important; }
    .leads-stage-tabs { display: flex; }
    body.is-clients .app-shell {
        height: auto;
        min-height: 100dvh;
        overflow: visible;
    }
    body.is-clients .main-content {
        overflow: auto;
        padding-bottom: 12px;
    }
    body.is-clients .page-actions,
    body.is-clients .page-actions .btn {
        width: auto;
    }
    body.is-clients #view-clients {
        height: auto;
        min-height: calc(100dvh - 56px);
        padding-bottom: env(safe-area-inset-bottom, 0);
    }
    .leads-workspace {
        grid-template-columns: 1fr;
        position: relative;
    }
    .leads-board {
        overflow-x: hidden;
        overflow-y: visible;
        height: auto;
    }
    .leads-column {
        flex: 1 1 auto;
        width: 100%;
        min-width: 0;
        max-width: none;
        height: auto;
    }
    .leads-detail {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        top: auto;
        z-index: 60;
        height: min(88dvh, 720px);
        max-height: 88dvh;
        border-radius: 20px 20px 0 0;
        transform: translateY(110%);
        transition: transform .22s ease;
        box-shadow: 0 -12px 40px rgba(16, 22, 34, 0.18);
        padding-bottom: calc(16px + env(safe-area-inset-bottom, 0));
    }
    .leads-detail.is-open {
        transform: translateY(0);
    }
    .leads-sheet-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 55;
        background: rgba(16, 22, 34, 0.4);
    }
    .leads-sheet-backdrop[hidden] { display: none; }
    .leads-sheet-close {
        display: inline-flex;
        border: 0;
        background: rgba(28, 36, 52, 0.06);
        border-radius: 999px;
        padding: 8px 12px;
        font-size: 13px;
        margin-bottom: 8px;
        cursor: pointer;
    }
    .leads-detail-top {
        flex-wrap: wrap;
    }
    .leads-toolbar .text-input {
        flex: 1;
        min-width: 0;
        max-width: none;
    }
    .lead-card {
        cursor: pointer;
        padding: 12px 14px;
    }
    .lead-card-grip { display: none; }
    .lead-pattern-row {
        grid-template-columns: 1fr;
    }
}


.staff-perm-grid,
.staff-accounts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 8px 12px;
    margin-top: 8px;
}
.staff-accounts-grid.is-disabled { opacity: 0.45; }
.staff-check {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}
.staff-form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 4px;
}
.staff-row-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* Billing */
.billing-stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 14px;
}
.billing-stat {
    border: 1px solid var(--border-soft);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.45);
    padding: 12px;
}
.billing-stat-value {
    margin-top: 6px;
    font-size: 18px;
    font-weight: 800;
    letter-spacing: -0.03em;
}
.billing-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 8px 0 16px;
}
.billing-topup {
    border-top: 1px solid rgba(28, 36, 52, 0.06);
    padding-top: 14px;
}
.billing-ledger {
    display: grid;
    gap: 8px;
    max-height: 360px;
    overflow: auto;
}
.billing-ledger-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid var(--border-soft);
    background: rgba(255, 255, 255, 0.42);
}
.billing-ledger-main {
    display: grid;
    gap: 2px;
    min-width: 0;
}
.billing-ledger-main strong {
    font-weight: 700;
}
.billing-ledger-amounts {
    display: grid;
    justify-items: end;
    gap: 2px;
    flex: none;
}
.billing-amount { font-weight: 800; white-space: nowrap; }
.billing-amount.is-plus { color: var(--green); }
.billing-amount.is-minus { color: var(--red); }

@media (max-width: 760px) {
    .billing-stats { grid-template-columns: 1fr 1fr; }
    .billing-ledger-row {
        flex-direction: column;
        align-items: stretch;
    }
    .billing-ledger-amounts {
        justify-items: start;
        flex-direction: row;
        display: flex;
        gap: 10px;
        align-items: baseline;
    }
    .billing-actions .btn,
    .billing-topup .btn { width: 100%; }
    .sidebar-balance-top { flex-direction: column; }
    .sidebar-balance-top .btn { width: 100%; }
    .chat-shell {
        height: auto;
        max-height: none;
        min-height: 0;
        grid-template-columns: 1fr;
    }
    body.is-chats .main-content { overflow: auto; }
    body.is-chats #view-chats { height: auto; min-height: calc(100dvh - 56px); }
    .table-container { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .page-title { font-size: 22px; }
    .form-grid { grid-template-columns: 1fr !important; }
    .staff-form-actions .btn { width: 100%; }
    .cabinet-chip, .active-account-card { width: 100%; }
}
