:root {
    --primary: #315fd6;
    --bg: #f5f7fb;
    --surface: #ffffff;
    --card-bg: #ffffff;
    --border: #e5eaf1;
    --text: #17243a;
    --muted: #718096;
    --radius: 16px;
}

body { background: var(--bg); color: var(--text); }
header {
    height: 72px;
    padding: 0 28px;
    background: #ffffff;
    color: var(--text);
    border-bottom: 1px solid var(--border);
    box-shadow: none;
}
.brand-mark {
    width: 38px;
    height: 38px;
    background: #315fd6;
    border: 0;
    border-radius: 12px;
    color: #ffffff;
    font-size: 13px;
    box-shadow: 0 5px 12px rgba(49, 95, 214, .2);
}
.header-title { gap: 11px; }
.header-title h1 { font-size: 17px; letter-spacing: -.035em; }
.brand-copy small { color: var(--muted); opacity: 1; font-size: 11px; }
.user-badge { margin-left: 10px; background: #edf2ff; color: #3154a0; padding: 6px 10px; }
header .btn-outline { color: #3c4b63; border-color: var(--border); background: #ffffff; }
header .btn-outline:hover { background: #f6f8fc; }

.bottom-nav {
    position: fixed;
    top: 72px;
    bottom: 0;
    left: 0;
    right: auto;
    width: 218px;
    height: auto;
    transform: none;
    padding: 25px 12px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 6px;
    background: #1c2b49;
    border: 0;
    border-radius: 0;
    box-shadow: none;
}
.bottom-nav::before {
    content: 'МЕНЮ';
    color: #8d9bb4;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .13em;
    padding: 0 16px 10px;
}
.nav-btn {
    width: 100%;
    min-height: 46px;
    padding: 0 15px;
    display: flex;
    flex-direction: row;
    justify-content: flex-start;
    gap: 12px;
    border-radius: 10px;
    color: #b8c5d8;
    text-align: left;
    font-size: 13px;
    font-weight: 650;
}
.nav-btn .icon { width: 18px; color: #98add0; font-size: 20px; line-height: 1; }
.nav-btn.active { color: #ffffff; background: #34527d; }
.nav-btn.active .icon { color: #ffffff; }
.nav-btn:hover { background: #293d5f; color: #ffffff; }
.nav-badge {
    position: static;
    margin-left: auto;
    padding: 3px 7px;
    background: rgba(255,255,255,.14) !important;
    color: #ffffff;
    border-radius: 8px;
    font-size: 11px;
}

.controls-bar {
    margin-left: 218px;
    padding: 24px 32px 17px;
    gap: 17px;
    background: var(--bg);
    border: 0;
    max-width: none;
}
.workspace-heading { display: flex; align-items: end; justify-content: space-between; gap: 16px; }
.eyebrow { color: #7990ad; font-size: 10px; font-weight: 800; letter-spacing: .14em; margin-bottom: 5px; }
.workspace-heading h2 { margin: 0; font-size: clamp(22px, 2.3vw, 29px); font-weight: 800; letter-spacing: -.04em; line-height: 1.1; }
.workspace-heading p { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.results-count { color: #596c86; font-size: 12px; font-weight: 650; white-space: nowrap; }
.toolbar { display: flex; align-items: stretch; gap: 10px; }
.search-box { flex: 1; min-width: 0; }
.search-box input {
    height: 43px;
    padding-left: 39px;
    background: #ffffff;
    border: 1px solid #dce3ee;
    border-radius: 10px;
    font-size: 13px;
    box-shadow: 0 1px 2px rgba(20,39,75,.02);
}
.search-box input:focus { border-color: #6485e7; box-shadow: 0 0 0 3px rgba(49,95,214,.12); }
.search-box .search-icon { left: 13px; font-size: 22px; line-height: 1; }
.advanced-filters { position: relative; flex: 0 0 auto; }
.advanced-filters summary {
    height: 43px;
    min-width: 104px;
    padding: 0 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: 1px solid #dce3ee;
    border-radius: 10px;
    background: #ffffff;
    color: #40516c;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    list-style: none;
}
.advanced-filters summary::-webkit-details-marker { display: none; }
.advanced-filters summary::before { content: '☷'; font-size: 17px; line-height: 1; }
.advanced-filters[open] summary { border-color: #8da8ee; color: #315fd6; }
.filter-panel {
    position: absolute;
    top: 50px;
    right: 0;
    width: 380px;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 15px 40px rgba(25,40,65,.15);
    z-index: 20;
}
.filter-label { margin: 17px 14px 8px; color: #697b94; font-size: 11px; font-weight: 750; text-transform: uppercase; letter-spacing: .07em; }
.advanced-filters .chip-scroll { width: 380px; padding: 0 14px; overflow-x: visible; flex-wrap: wrap; }
.advanced-filters #source-chips { padding-bottom: 16px; }
#filter-summary { display: inline-flex; width: 6px; height: 6px; border-radius: 50%; }
#filter-summary.has-filter { background: #315fd6; }
.quick-filters { gap: 7px; }
body[data-view="bookings"] .quick-filters,
body[data-view="analytics"] .toolbar,
body[data-view="analytics"] .quick-filters,
body[data-view="analytics"] .results-count { display: none; }
.chip {
    padding: 8px 14px;
    border-radius: 9px;
    background: #ffffff;
    border: 1px solid #e1e6ef;
    color: #62718a;
    font-size: 12px;
    font-weight: 700;
}
.chip:hover { border-color: #9fb5e9; color: #315fd6; }
.chip.active { background: #e9efff; color: #2858cb; border-color: #cad8fc; }
.quick-filters .chip.active { background: #315fd6; color: #ffffff; border-color: #315fd6; }
.chip-sm { padding: 7px 11px; font-size: 11px; }

.main-container {
    margin-left: 218px;
    min-height: 0;
    padding: 0 32px 30px;
    background: var(--bg);
}
.tab-pane { max-width: none; padding: 0; }
.summary-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 13px; margin-bottom: 24px; }
.summary-card {
    min-width: 0;
    padding: 16px 19px 15px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #ffffff;
    box-shadow: 0 2px 8px rgba(20,39,75,.025);
    color: var(--text);
    cursor: pointer;
}
.summary-card:hover { border-color: #a4b7e3; box-shadow: 0 6px 18px rgba(20,39,75,.07); }
.summary-label { color: #667891; font-size: 12px; font-weight: 700; }
.summary-card strong { margin: 8px 0 3px; font-size: 27px; font-weight: 800; letter-spacing: -.04em; line-height: 1; }
.summary-hint { width: 100%; color: #8a99ab; font-size: 11px; }
.summary-hint span { float: right; color: #a7b3c2; font-size: 17px; line-height: .6; }
.summary-new { border-top: 3px solid #f4b44a; }
.summary-work { border-top: 3px solid #5d82e6; }
.summary-closed { border-top: 3px solid #a4b2c8; }
.list-heading { display: flex; align-items: baseline; justify-content: space-between; margin: 0 0 11px; }
.list-heading h3 { margin: 0; font-size: 15px; font-weight: 800; letter-spacing: -.015em; }
.list-heading span { color: #91a0b1; font-size: 11px; }
#leads-list, #bookings-list { gap: 12px; }
.card {
    padding: 18px 19px;
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 2px 8px rgba(20,39,75,.025);
}
.lead-card { display: flex; flex-direction: column; min-height: 255px; border-left-width: 1px; }
.lead-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 18px; }
.lead-person { display: flex; align-items: center; gap: 10px; min-width: 0; }
.lead-avatar { width: 38px; height: 38px; display: grid; flex: 0 0 38px; place-items: center; border-radius: 11px; background: #eaf0ff; color: #315fd6; font-size: 14px; font-weight: 800; }
.lead-identity { display: flex; flex-direction: column; min-width: 0; gap: 5px; }
.lead-identity strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; font-weight: 800; }
.lead-identity small { color: #99a5b5; font-size: 10px; white-space: nowrap; }
.lead-identity .source-tag { margin-right: 1px; text-transform: none; }
.card-footer { margin-top: auto; padding-top: 13px; border-top: 1px solid #eef1f6; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.card-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.card-footer .btn { min-height: 31px; padding: 6px 10px; border-radius: 8px; font-size: 11px; white-space: nowrap; }
.card-primary-action { background: #315fd6; }
.card-detail { margin-left: auto; padding-right: 0 !important; background: transparent; color: #315fd6; font-weight: 750; }
.card-detail span { font-size: 15px; line-height: 0; }
.booking-card { display: flex; flex-direction: column; min-height: 245px; }
.booking-info { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 1px 0 11px; }
.booking-info > div { display: flex; flex-direction: column; gap: 4px; padding: 10px 11px; background: #f6f8fc; border-radius: 9px; }
.booking-info span { color: #8594a9; font-size: 10px; }
.booking-info strong { color: #243551; font-size: 12px; }
.booking-meta { display: flex; flex-wrap: wrap; gap: 7px 13px; margin-bottom: 12px; color: #718096; font-size: 11px; }
.booking-meta span + span::before { content: '·'; margin-right: 12px; color: #b3becd; }
.load-more-row { grid-column: 1 / -1; }
.load-more-row .btn { width: 100%; justify-content: center; padding: 11px; }
.card:hover { transform: none; box-shadow: 0 5px 16px rgba(20,39,75,.065); }
.card-header { margin-bottom: 11px; gap: 10px; }
.passenger-name { min-width: 0; flex-wrap: wrap; gap: 7px; font-size: 15px; font-weight: 800; }
.source-tag { padding: 4px 7px; font-size: 9px; letter-spacing: .035em; border-radius: 6px; }
.status-badge { flex: 0 0 auto; padding: 5px 8px; border-radius: 7px; font-size: 10px; }
.route-line { margin: 0 0 12px; color: #1c2f4b; font-size: 15px; font-weight: 750; }
.route-arrow { margin: 0 6px; color: #7891b3; }
.meta-line { margin: 0 0 12px; gap: 6px; }
.meta-pill { padding: 4px 7px; color: #64748b; background: #f3f6fa; border-radius: 6px; font-size: 11px; }
.text-snippet { padding: 10px 11px; color: #62718a; background: #f8fafd; font-size: 12px; line-height: 1.45; border-radius: 8px; }
.btn-row { padding-top: 5px; }
.btn-row .btn { font-size: 11px; border-radius: 8px; padding: 6px 9px; }
.empty-state { padding: 48px 18px; border: 1px dashed #cfd8e7; border-radius: 14px; background: #ffffff; color: #718096; text-align: center; font-size: 13px; }
.analytics-period { display: flex; align-items: end; flex-wrap: wrap; gap: 10px 14px; margin-bottom: 15px; padding: 16px 18px; border: 1px solid #e2e9f3; border-radius: 14px; background: #fff; }
.analytics-period label { display: grid; gap: 5px; color: #64748b; font-size: 11px; font-weight: 700; }
.analytics-period select, .analytics-period input { min-height: 38px; padding: 7px 10px; border: 1px solid #d7e0ed; border-radius: 8px; background: #fff; color: #183153; font: inherit; font-size: 13px; }
.analytics-period select:focus-visible, .analytics-period input:focus-visible { outline: 2px solid #315fd6; outline-offset: 2px; }
.analytics-period-note { flex-basis: 100%; margin: 0; color: #8391a4; font-size: 11px; line-height: 1.45; }
#analytics-period-error { flex-basis: 100%; margin: 0; color: #b42318; font-size: 12px; }
#analytics-content { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
#analytics-content > .comm-card, #analytics-content > .stat-grid { grid-column: 1 / -1; margin: 0; }
#analytics-content > .card { margin: 0; min-height: 180px; }
#analytics-content > .card h3 { font-size: 14px !important; border-bottom-color: #edf1f6 !important; padding-bottom: 11px !important; }
.comm-card { background: linear-gradient(135deg, #203b83, #315fd6); border-radius: 15px; box-shadow: 0 8px 22px rgba(37,82,176,.14); padding: 23px 26px; }
.comm-title { font-size: 11px; font-weight: 750; letter-spacing: .08em; }
.comm-val { font-size: 27px; }
.comm-sub { font-size: 12px; }
.stat-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 13px; }
.stat-box { min-height: 105px; padding: 18px 14px; border-radius: 13px; text-align: left; }
.stat-num { margin: 0 0 8px; font-size: 24px; }
.stat-label { font-size: 10px; letter-spacing: .05em; }
.analytics-empty { margin: 15px 0; color: #91a0b1; font-size: 12px; }

.auth-mode .bottom-nav,
.auth-mode .controls-bar,
.auth-mode .user-badge,
.auth-mode .header-actions { display: none !important; }
.auth-mode .main-container { margin-left: 0; padding: 24px; display: grid; place-items: center; }
.auth-gate { width: min(100%, 430px); padding: 38px 35px; border: 1px solid var(--border); border-radius: 18px; background: #ffffff; box-shadow: 0 15px 50px rgba(25,40,65,.08); text-align: center; }
.auth-icon { width: 54px; height: 54px; margin: 0 auto 20px; display: grid; place-items: center; background: #315fd6; color: #ffffff; border-radius: 16px; font-size: 18px; font-weight: 850; }
.auth-gate h2 { margin: 0 0 9px; font-size: 21px; letter-spacing: -.03em; }
.auth-gate p { margin: 0 0 23px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.auth-button { justify-content: center; min-height: 42px; }

@media (min-width: 1180px) {
    #leads-list, #bookings-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
    header { height: 60px; padding: 0 15px; }
    .brand-mark { width: 34px; height: 34px; }
    .brand-copy small, .user-badge { display: none; }
    .header-title h1 { font-size: 15px; }
    .header-actions .btn { font-size: 11px; padding: 6px 8px; }
    .bottom-nav {
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        height: calc(60px + env(safe-area-inset-bottom));
        padding: 5px 4px env(safe-area-inset-bottom);
        flex-direction: row;
        align-items: center;
        justify-content: space-around;
        background: #ffffff;
        border-top: 1px solid var(--border);
        border-radius: 0;
        box-shadow: 0 -5px 20px rgba(25,40,65,.04);
    }
    .bottom-nav::before { display: none; }
    .nav-btn { width: auto; min-width: 80px; height: 50px; padding: 5px 7px; flex-direction: column; justify-content: center; gap: 3px; font-size: 10px; color: #8795a9; text-align: center; border-radius: 8px; }
    .nav-btn .icon { width: auto; font-size: 19px; color: inherit; }
    .nav-btn.active { color: #315fd6; background: #eef3ff; }
    .nav-btn.active .icon { color: #315fd6; }
    .nav-badge { position: absolute; top: 1px; right: 1px; margin: 0; padding: 1px 4px; background: #315fd6 !important; color: #ffffff; font-size: 9px; }
    .controls-bar { margin-left: 0; padding: 18px 16px 13px; gap: 13px; }
    .workspace-heading h2 { font-size: 24px; }
    .workspace-heading p { font-size: 12px; }
    .main-container { margin-left: 0; padding: 0 16px 78px; }
    .filter-panel { width: min(380px, calc(100vw - 32px)); }
    .advanced-filters .chip-scroll { width: min(380px, calc(100vw - 32px)); }
    .analytics-period label:first-child { flex-basis: 100%; }
    .analytics-period label:nth-child(2), .analytics-period label:nth-child(3) { flex: 1 1 calc(50% - 7px); min-width: 0; }
    .analytics-period select, .analytics-period input { width: 100%; box-sizing: border-box; }
    #analytics-content { grid-template-columns: 1fr; }
    #analytics-content > .comm-card, #analytics-content > .stat-grid { grid-column: auto; }
    .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
    .summary-grid { gap: 8px; margin-bottom: 20px; }
    .summary-card { padding: 12px; }
    .summary-card strong { font-size: 24px; }
    .summary-label { font-size: 10px; }
    .summary-hint { display: none; }
}
@media (max-width: 420px) {
    .header-actions .btn:first-child { font-size: 0; gap: 0; }
    .header-actions .btn:first-child::before { content: '↻'; font-size: 18px; }
    .header-actions .btn:last-child { font-size: 0; gap: 0; }
    .header-actions .btn:last-child::before { content: 'CSV'; font-size: 10px; }
    .controls-bar { padding-left: 13px; padding-right: 13px; }
    .main-container { padding-left: 13px; padding-right: 13px; }
    .workspace-heading p { max-width: 200px; }
    .results-count { font-size: 10px; }
    .advanced-filters summary { min-width: 42px; padding: 0 11px; font-size: 0; }
    .advanced-filters summary::before { font-size: 19px; }
    .quick-filters { width: 100%; }
    .quick-filters .chip { flex: 1; padding: 8px 5px; text-align: center; }
    .card { padding: 15px; }
}
