/* ============================================================
   LiveKad CRM — стили кабинетов
   Светлая тема в стиле livekad.ru (Manrope), функциональный
   табличный интерфейс — приоритет читаемости данных.
   ============================================================ */

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

:root {
    --bg:            #f4f6f9;
    --surface:       #ffffff;
    --surface-alt:   #eef1f6;
    --border:        #dde3ea;
    --text:          #1a222c;
    --text-muted:    #5c6b7c;
    --accent:        #1f9c8c;
    --accent-dark:   #167a6d;
    --warning:       #b5730f;
    --error:         #c8442a;
    --success:       #1f8a52;
    --radius:        10px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: 'Manrope', -apple-system, Segoe UI, sans-serif;
    font-size: 15px;
    line-height: 1.5;
}

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

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ---------- Топбар / навигация ---------- */

.topbar {
    display: flex;
    align-items: center;
    gap: 32px;
    padding: 16px 32px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 1px 2px rgba(16, 22, 29, 0.04);
}

.topbar-brand {
    font-weight: 800;
    font-size: 18px;
    letter-spacing: 0.02em;
    color: var(--text);
}

.topbar-nav {
    display: flex;
    gap: 24px;
    flex: 1;
}

.topbar-nav a {
    color: var(--text-muted);
    font-weight: 600;
    font-size: 17px;
    padding: 6px 2px;
    border-bottom: 2px solid transparent;
}

.topbar-nav a.active,
.topbar-nav a:hover {
    color: var(--text);
    border-bottom-color: var(--accent);
    text-decoration: none;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 16px;
    color: var(--text-muted);
    font-size: 14px;
}

.logout-link { color: var(--text-muted); }
.logout-link:hover { color: var(--error); }

/* ---------- Контейнер / заголовок страницы ---------- */

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 32px 24px 64px;
}

.page-header h1 {
    font-size: 24px;
    font-weight: 700;
    margin: 0 0 20px;
    color: var(--text);
}

/* ---------- Карточки / сводка ---------- */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
    margin-bottom: 24px;
    box-shadow: 0 1px 3px rgba(16, 22, 29, 0.04);
}

.card h2 {
    font-size: 15px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    margin: 0 0 10px;
}

.block-summary p { margin: 4px 0; color: var(--text); }

.summary-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 28px;
}

.summary-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    box-shadow: 0 1px 3px rgba(16, 22, 29, 0.04);
}

.summary-card-warning { border-color: var(--warning); }

.summary-label {
    color: var(--text-muted);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.summary-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
}

/* ---------- Фильтры ---------- */

.filter-bar {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.filter-bar label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 13px;
    color: var(--text-muted);
}

/* ---------- Формы / инпуты ---------- */

input, select, button {
    font-family: inherit;
    font-size: 14px;
}

select, input[type="email"], input[type="password"], input[type="text"] {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 6px;
    padding: 8px 10px;
}

select { cursor: pointer; }

button {
    background: var(--accent);
    color: #ffffff;
    border: none;
    border-radius: 6px;
    padding: 9px 18px;
    font-weight: 700;
    cursor: pointer;
}

button:hover { background: var(--accent-dark); }

.inline-form {
    display: flex;
    gap: 6px;
    align-items: center;
}

.inline-form noscript button { padding: 4px 8px; font-size: 12px; }

.amounts-form {
    display: flex;
    gap: 8px;
    align-items: center;
}

.amount-input {
    width: 100px;
}

.finance-note {
    margin-top: 16px;
    font-size: 13px;
    max-width: 640px;
    color: var(--text-muted);
}

/* ---------- Дашборд ---------- */

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
}

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

.mini-table td {
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
}

.mini-table td:last-child {
    text-align: right;
    font-weight: 700;
}

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

/* ---------- Формы админки (импорт, блоки, ссылки) ---------- */

.upload-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 420px;
}

.result-box {
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-top: 16px;
}

.result-box p { margin: 4px 0; }

.link-box {
    display: flex;
    gap: 8px;
    align-items: center;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 10px 12px;
    font-family: monospace;
    font-size: 13px;
    word-break: break-all;
}

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

.badge-free { background: rgba(31, 138, 82, 0.12); color: var(--success); }
.badge-in_progress { background: rgba(181, 115, 15, 0.12); color: var(--warning); }
.badge-done { background: rgba(92, 107, 124, 0.12); color: var(--text-muted); }

/* ---------- Баннер impersonation ---------- */

.impersonation-banner {
    background: rgba(181, 115, 15, 0.12);
    border-bottom: 1px solid var(--warning);
    color: var(--warning);
    padding: 10px 32px;
    font-size: 13px;
    text-align: center;
}

.impersonation-banner a {
    color: var(--warning);
    font-weight: 700;
    text-decoration: underline;
    margin-left: 8px;
}

/* ---------- Таблица лидов ---------- */

.leads-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.leads-table th {
    text-align: left;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #3d4a59;
    background: #e4e9f0;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
}

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

.leads-table tr:last-child td { border-bottom: none; }
.leads-table tr:hover td { background: var(--surface-alt); }

/* ---------- Компактные строки редактирования (companies.php) ---------- */

.table-scroll {
    overflow-x: auto;
    max-width: 100%;
    border-radius: var(--radius);
}

.table-scroll .leads-table {
    min-width: 900px;
}

.col-narrow {
    width: 110px;
    max-width: 110px;
    font-size: 16px;
}

.col-phone {
    width: 170px;
    max-width: 170px;
    font-size: 16px;
}

.status-select {
    font-size: 16px;
}

.stacked-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.col-save {
    padding: 9px 12px;
    white-space: nowrap;
}

.muted { color: var(--text-muted); font-size: 13px; }
.text-warning { color: var(--warning); font-weight: 600; }

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

/* ---------- Уведомления ---------- */

.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    font-size: 14px;
}

.alert-success { background: rgba(31, 138, 82, 0.10); border: 1px solid var(--success); color: var(--success); }
.alert-error   { background: rgba(200, 68, 42, 0.10);  border: 1px solid var(--error);   color: var(--error); }

/* ---------- Страница входа ---------- */

.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
}

.auth-card {
    width: 100%;
    max-width: 360px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow: 0 4px 16px rgba(16, 22, 29, 0.06);
}

.auth-card h1 { margin: 0; font-size: 20px; color: var(--text); }
.auth-subtitle { margin: 0 0 8px; color: var(--text-muted); font-size: 14px; }

.auth-card label { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.auth-card button { margin-top: 16px; }

/* Honeypot: физически на странице, но невидимо и недоступимо для
   людей и скринридеров — боты, заполняющие все поля формы, попадаются */
.hp-field {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* ---------- Адаптивность ---------- */

@media (max-width: 720px) {
    .topbar { flex-wrap: wrap; gap: 12px; padding: 14px 16px; }
    .container { padding: 20px 14px 48px; }
    .summary-cards { grid-template-columns: 1fr; }
    .leads-table, .leads-table thead, .leads-table tbody, .leads-table th, .leads-table td, .leads-table tr {
        display: block;
    }
    .leads-table thead { display: none; }
    .leads-table tr { border-bottom: 1px solid var(--border); padding: 10px 0; }
    .leads-table td { border: none; padding: 4px 14px; }
}
