/* Мобилна версия + PWA */

:root {
    --bottom-nav-h: 64px;
    --fab-size: 56px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* Login screen */
.auth-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(160deg, #0f1419 0%, #1a2e24 100%);
}

.auth-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 28px 24px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow);
}

.auth-card h2 { text-align: center; margin-bottom: 8px; }

.auth-subtitle {
    text-align: center;
    color: var(--muted);
    font-size: .85rem;
    margin-bottom: 20px;
}

.auth-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    background: var(--bg);
    border-radius: 8px;
    padding: 4px;
}

.auth-tab {
    flex: 1;
    padding: 8px;
    border: none;
    background: transparent;
    color: var(--muted);
    border-radius: 6px;
    cursor: pointer;
    font-size: .9rem;
}

.auth-tab.active { background: var(--primary); color: #fff; }

.user-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
    font-size: .85rem;
}

.user-bar .username { color: var(--accent); }

/* Bottom navigation (mobile) */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(var(--bottom-nav-h) + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    background: var(--surface);
    border-top: 1px solid var(--border);
    z-index: 150;
    justify-content: space-around;
    align-items: center;
}

.bottom-nav-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    background: none;
    border: none;
    color: var(--muted);
    font-size: .65rem;
    cursor: pointer;
    padding: 6px 12px;
    min-width: 56px;
    min-height: 44px;
}

.bottom-nav-btn .icon { font-size: 1.3rem; }
.bottom-nav-btn.active { color: var(--primary); }

/* FAB quick actions */
.fab-container {
    display: none;
    position: fixed;
    bottom: calc(var(--bottom-nav-h) + var(--safe-bottom) + 16px);
    right: 16px;
    z-index: 140;
}

.fab-main {
    width: var(--fab-size);
    height: var(--fab-size);
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    border: none;
    font-size: 1.6rem;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(61, 154, 106, .5);
    transition: transform .2s;
}

.fab-main.open { transform: rotate(45deg); }

.fab-menu {
    position: absolute;
    bottom: calc(var(--fab-size) + 8px);
    right: 0;
    display: none;
    flex-direction: column;
    gap: 8px;
    align-items: flex-end;
}

.fab-menu.open { display: flex; }

.fab-action {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 10px 14px;
    border-radius: 24px;
    cursor: pointer;
    font-size: .85rem;
    white-space: nowrap;
    box-shadow: var(--shadow);
}

/* Mobile quick panel */
.mobile-quick {
    display: none;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 16px;
}

.quick-btn {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px 12px;
    text-align: center;
    cursor: pointer;
    color: var(--text);
    font-size: .85rem;
    min-height: 72px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.quick-btn .q-icon { font-size: 1.5rem; }
.quick-btn:active { background: var(--primary); transform: scale(.97); }

/* Compare view */
.compare-filters {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 10px;
    margin-bottom: 16px;
    align-items: end;
}

.compare-chart {
    background: var(--bg);
    border-radius: 8px;
    padding: 16px;
    margin: 12px 0;
    overflow-x: auto;
}

.bar-chart {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    min-height: 180px;
    padding: 10px 0;
}

.bar-group {
    flex: 1;
    min-width: 60px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.bar {
    width: 100%;
    max-width: 48px;
    background: linear-gradient(to top, var(--primary), #6dd99a);
    border-radius: 4px 4px 0 0;
    min-height: 4px;
    transition: height .3s;
}

.bar-label {
    font-size: .7rem;
    color: var(--muted);
    text-align: center;
    word-break: break-word;
}

.bar-value {
    font-size: .75rem;
    font-weight: 700;
    color: var(--accent);
}

.compare-table td.best { color: var(--accent); font-weight: 700; }

.export-btns {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.btn-export {
    background: var(--surface2);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 8px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: .85rem;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-export:hover { border-color: var(--primary); }

/* Hide desktop nav on mobile */
@media (max-width: 768px) {
    .header .nav { display: none; }

    .user-bar {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    .user-bar h1 { font-size: .95rem; }

    .bottom-nav { display: flex; }

    .fab-container { display: block; }

    .mobile-quick { display: grid; }

    .main {
        padding-bottom: calc(var(--bottom-nav-h) + var(--safe-bottom) + 24px);
    }

    .header h1 { font-size: 1rem; }

    .form-grid { grid-template-columns: 1fr; }

    .compare-filters { grid-template-columns: 1fr; }

    .view-header { flex-direction: column; align-items: stretch; }

    .view-header .btn { width: 100%; text-align: center; }

    input, select, textarea, .btn {
        font-size: 16px; /* prevent iOS zoom */
        min-height: 44px;
    }

    .btn-sm { min-height: 36px; }

    .modal-content {
        width: 100%;
        max-width: 100%;
        margin: 0;
        border-radius: 16px 16px 0 0;
        position: fixed;
        bottom: 0;
        max-height: 85vh;
    }

    .tabs { overflow-x: auto; flex-wrap: nowrap; }

    .tab-btn { white-space: nowrap; flex-shrink: 0; }

    table { font-size: .8rem; }

    .session-actions { grid-template-columns: repeat(2, 1fr); }

    .segmented-control { -webkit-overflow-scrolling: touch; }

    #view-session .main { padding-bottom: calc(var(--bottom-nav-h) + var(--safe-bottom) + 24px); }

    .toast {
        left: 16px;
        right: 16px;
        bottom: calc(var(--bottom-nav-h) + var(--safe-bottom) + 16px);
        text-align: center;
    }
}

/* Standalone PWA */
@media (display-mode: standalone) {
    .header { padding-top: env(safe-area-inset-top, 0px); }
}
