@font-face {
    font-family: "Benzin";
    src: url("/static/fonts/Benzin-Regular.woff") format("woff");
    font-weight: 400;
}
@font-face {
    font-family: "Benzin";
    src: url("/static/fonts/Benzin-Bold.woff") format("woff");
    font-weight: 700;
}

:root {
    --bg: #0e0e0d;
    --bg-alt: #070707;
    --panel: #121212;
    --card: #2d2d2d;
    --accent: #600462;
    --accent-light: #8c2f9e;
    --text: #ffffff;
    --text-muted: #cccccc;
    --border: #333333;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "Rubik", Arial, sans-serif;
}

h1, h2, h3 {
    font-family: "Benzin", "Rubik", Arial, sans-serif;
}

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

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 24px;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
}

.topbar .logo { height: 48px; }

.topbar nav { display: flex; gap: 20px; }
.topbar nav a { color: var(--text-muted); }
.topbar nav a:hover { color: var(--text); }

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

main { padding: 20px 24px; }

.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.page-header h1 { margin: 0; }

.board-toolbar { display: flex; justify-content: flex-end; margin-bottom: 14px; }
.btn-add { background: var(--accent); padding: 9px 16px; border-radius: 6px; font-weight: 600; }
.btn-add:hover { background: var(--accent-light); }

.board {
    display: grid;
    grid-template-columns: repeat(6, 1fr) minmax(0, 0.85fr);
    gap: 10px;
    align-items: start;
}

.column {
    background: var(--panel);
    border-radius: 10px;
    min-width: 0;
    padding: 12px 10px;
}

.column h2 {
    font-size: 13px;
    margin: 2px 4px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    letter-spacing: 0.01em;
}

.column .count {
    background: var(--accent);
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
    padding: 2px 7px;
    font-size: 11px;
}

.column-lost { background: #1a0d17; }

.cards {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 40px;
}

.card {
    background: var(--card);
    border-radius: 8px;
    padding: 12px 12px 12px 13px;
    cursor: grab;
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.card:hover {
    border-color: var(--accent-light);
    border-left-color: var(--accent-light);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.45);
    transform: translateY(-2px);
}

.card-number { font-size: 10.5px; color: var(--text-muted); letter-spacing: 0.03em; }
.card-name { font-weight: 700; font-size: 14.5px; margin: 3px 0 4px; }
.card-phone, .card-source { font-size: 12px; color: var(--text-muted); line-height: 1.6; }
.card-amount { font-size: 12.5px; color: var(--accent-light); font-weight: 600; margin-top: 4px; }
.card-reason { font-size: 12px; color: #ff9494; margin-top: 4px; }

.auth-card {
    max-width: 360px;
    margin: 80px auto;
    background: var(--panel);
    padding: 32px;
    border-radius: 8px;
    text-align: center;
}

.logo-big { height: 60px; margin-bottom: 16px; }

.auth-card form { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }
.auth-card label { text-align: left; font-size: 13px; color: var(--text-muted); display: flex; flex-direction: column; gap: 4px; }

input, select, textarea, button {
    background: var(--card);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 8px;
    font-family: inherit;
    font-size: 14px;
}

button {
    background: var(--accent);
    cursor: pointer;
    border: none;
}
button:hover { background: var(--accent-light); }

.error { color: #ff6b6b; }
.hint { color: var(--text-muted); font-size: 13px; }

.lead-detail { max-width: 720px; }
.lead-form, .note-form { display: flex; flex-direction: column; gap: 10px; margin: 16px 0; }
.lead-form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--text-muted); }
.stage-form { display: flex; gap: 8px; margin: 16px 0; }
.back-link { color: var(--text-muted); display: inline-block; margin-bottom: 12px; }
.history, .notes, .answers { list-style: none; padding: 0; }
.history li, .notes li { padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }

.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    align-items: center;
    justify-content: center;
    z-index: 100;
}
.modal.open { display: flex; }
.modal-box {
    background: var(--panel);
    padding: 24px;
    border-radius: 8px;
    width: 320px;
}
.modal-box form { display: flex; flex-direction: column; gap: 10px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; }

.users-table, .report-card table { width: 100%; border-collapse: collapse; margin-bottom: 16px; }
.users-table th, .users-table td, .report-card th, .report-card td {
    text-align: left; padding: 8px; border-bottom: 1px solid var(--border); font-size: 13px;
}
.user-form { display: flex; flex-direction: column; gap: 10px; max-width: 360px; }
.user-form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--text-muted); }
.checkbox-label { flex-direction: row !important; align-items: center; gap: 8px !important; }

.report-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.report-card { background: var(--panel); padding: 16px; border-radius: 8px; }
.report-card-wide { grid-column: 1 / -1; }
.chart-wrap { position: relative; height: 220px; }
.chart-wrap-wide { height: 280px; }
.big-number { font-size: 32px; font-weight: bold; color: var(--accent-light); margin: 8px 0; }

.filters-form { display: flex; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.filters-form select { min-width: 140px; }

.section-title { margin: 28px 0 12px; font-size: 18px; }

.table-scroll {
    overflow-x: auto;
    background: var(--panel);
    border-radius: 10px;
    padding: 4px 16px;
    margin-bottom: 32px;
}
.leads-table { width: 100%; border-collapse: collapse; }
.leads-table th {
    text-align: left; padding: 12px 10px; font-size: 11.5px; text-transform: uppercase;
    letter-spacing: 0.04em; color: var(--text-muted); border-bottom: 1px solid var(--border);
}
.leads-table td {
    text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--border); font-size: 13.5px;
}
.leads-table tbody tr { cursor: pointer; transition: background 0.1s ease; }
.leads-table tbody tr:hover { background: var(--card); }
.leads-table tbody tr:last-child td { border-bottom: none; }
.leads-table tr.no-hover { cursor: default; color: var(--text-muted); }
.leads-table .mono { font-variant-numeric: tabular-nums; white-space: nowrap; }
.leads-table .muted { color: var(--text-muted); }
.leads-table .amount-cell { color: var(--accent-light); font-weight: 600; }

.stage-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    white-space: nowrap;
}
.stage-new { background: #333333; color: #fff; }
.stage-qualification { background: #4a2050; color: #fff; }
.stage-meeting { background: #5c2566; color: #fff; }
.stage-contract { background: #6e2b7c; color: #fff; }
.stage-payment { background: #802f93; color: #fff; }
.stage-won { background: #1f7a3f; color: #fff; }
.stage-lost { background: #7a2020; color: #fff; }

.services-panel { padding-bottom: 16px; }
.add-service-form { display: flex; gap: 10px; padding: 14px 10px 4px; }
.add-service-form input { flex: 1; max-width: 320px; }

/* ---------- Мобильная адаптация ---------- */

@media (max-width: 900px) {
    main { padding: 14px 12px; }

    .topbar { padding: 8px 12px; gap: 10px; }
    .topbar .logo { height: 36px; }
    .topbar nav { gap: 14px; overflow-x: auto; }
    .topbar nav a { white-space: nowrap; font-size: 13px; }
    .user-menu { gap: 10px; }
    .user-menu span { display: none; }

    /* канбан — горизонтальный свайп с прилипанием, как в привычных таск-досках */
    .board {
        display: flex;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        padding-bottom: 8px;
    }
    .board::-webkit-scrollbar { height: 4px; }
    .board::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
    .column { flex: 0 0 78vw; scroll-snap-align: start; }

    .report-grid { grid-template-columns: 1fr; }
    .chart-wrap { height: 200px; }
    .chart-wrap-wide { height: 220px; }

    .page-header { flex-direction: column; align-items: stretch; gap: 12px; }
    .filters-form { gap: 8px; }
    .filters-form select { min-width: 0; flex: 1 1 140px; }

    .modal-box { width: min(340px, calc(100vw - 28px)); }

    .lead-form, .user-form { max-width: none; }
    .stage-form { flex-direction: column; align-items: stretch; }
    .add-service-form { flex-direction: column; }
    .add-service-form input { max-width: none; }

    .table-scroll { padding: 4px 10px; }
    .leads-table th, .leads-table td { padding: 10px 8px; font-size: 12.5px; }

    button, .btn-add { min-height: 40px; }
}

@media (max-width: 600px) {
    h1 { font-size: 22px; }
    .section-title { font-size: 16px; }
    .big-number { font-size: 26px; }
    .column { flex: 0 0 85vw; }
    .auth-card { margin: 40px 16px; padding: 24px 20px; }
}
