/* ═══════════════════════════════════════════
   Портал — Адаптивный UI (mobile → tablet → desktop)
   ═══════════════════════════════════════════ */

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #dbeafe;
    --success: #16a34a;
    --warning: #f59e0b;
    --danger: #dc2626;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-500: #6b7280;
    --gray-700: #374151;
    --gray-900: #111827;
    --white: #ffffff;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
    --content-padding: 1rem;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--gray-50);
    color: var(--gray-900);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ─── Утилиты ─── */
.hidden { display: none !important; }
.text-center { text-align: center; }
.text-muted { color: var(--gray-500); }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-2 { margin-bottom: 1rem; }

/* ─── Контейнер приложения — fluid, без жёсткой ширины ─── */
#app {
    width: 100%;
    margin: 0 auto;
    min-height: 100vh;
    background: var(--white);
    position: relative;
}

/* ─── Экран логина ─── */
.login-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem;
}

.login-form {
    width: 100%;
    max-width: 400px;
}

.login-logo {
    width: 80px;
    height: 80px;
    background: var(--primary);
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
}

.login-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.login-subtitle {
    color: var(--gray-500);
    margin-bottom: 2rem;
}

/* ─── Формы ─── */
.form-group {
    width: 100%;
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 0.375rem;
}

.form-group input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: 1rem;
    transition: border-color 0.2s;
    outline: none;
}

.form-group input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--primary);
    color: var(--white);
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.error-message {
    color: var(--danger);
    font-size: 0.875rem;
    margin-top: 0.5rem;
    text-align: center;
}

/* ─── Верхняя панель ─── */
.top-bar {
    position: sticky;
    top: 0;
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    padding: 0.5rem var(--content-padding);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    z-index: 100;
    min-height: 48px;
}

/* KPI-плашки слева */
.top-bar-kpi {
    flex: 1;
    display: flex;
    gap: 0.375rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.top-bar-kpi::-webkit-scrollbar {
    display: none;
}

.kpi-chip {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    border-radius: 8px;
    border: 1px solid var(--gray-200);
    background: var(--white);
    cursor: pointer;
    white-space: nowrap;
    font-size: 0.75rem;
    transition: all 0.2s;
    flex-shrink: 0;
}

.kpi-chip:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.kpi-code {
    font-weight: 600;
    color: var(--gray-700);
}

.kpi-value {
    font-weight: 700;
}

.kpi-green { border-color: #86efac; background: #f0fdf4; }
.kpi-green .kpi-value { color: var(--success); }

.kpi-yellow { border-color: #fde68a; background: #fffbeb; }
.kpi-yellow .kpi-value { color: #d97706; }

.kpi-red { border-color: #fca5a5; background: #fef2f2; }
.kpi-red .kpi-value { color: var(--danger); }

/* Правая часть top-bar */
.top-bar-actions {
    display: flex;
    gap: 0.375rem;
    align-items: center;
    flex-shrink: 0;
}

.notification-btn {
    position: relative;
}

.notification-btn .badge {
    position: absolute;
    top: 0;
    right: 0;
    transform: translate(25%, -25%);
}

.badge {
    background: var(--danger);
    color: var(--white);
    font-size: 0.6rem;
    font-weight: 700;
    padding: 0.1rem 0.3rem;
    border-radius: 9999px;
    min-width: 15px;
    text-align: center;
    line-height: 1.2;
}

.icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    color: var(--gray-700);
    font-size: 1.25rem;
    position: relative;
}

.icon-btn:hover {
    background: var(--gray-100);
}

/* Аватар в top-bar */
.top-bar-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--primary);
    color: var(--white);
    border-radius: 50%;
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 1;
}

.profile-btn {
    padding: 0.25rem;
}

.profile-btn:hover .top-bar-avatar {
    background: var(--primary-dark);
}

/* Заголовок страницы (под top-bar) */
.page-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--gray-900);
}

/* ─── Контент ─── */
.page-content {
    padding: var(--content-padding);
    padding-bottom: 5rem;
}

/* ─── Карточки уведомлений ─── */
.notification-card {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
}

.notification-card:hover {
    box-shadow: var(--shadow-md);
}

.notification-card.unread {
    border-left: 3px solid var(--primary);
    background: var(--primary-light);
}

.notification-card.type-warning {
    border-left-color: var(--warning);
}

.notification-card.type-warning.unread {
    background: #fef3c7;
}

.notification-card.type-action_required {
    border-left-color: var(--danger);
}

.notification-card.type-action_required.unread {
    background: #fee2e2;
}

.notification-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.375rem;
}

.notification-title {
    font-weight: 600;
    font-size: 0.9375rem;
}

.notification-meta {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.notification-source {
    font-size: 0.75rem;
    background: var(--gray-100);
    color: var(--gray-500);
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
}

.notification-time {
    font-size: 0.75rem;
    color: var(--gray-500);
}

.notification-body {
    font-size: 0.875rem;
    color: var(--gray-700);
    line-height: 1.4;
}

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--gray-500);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

/* ─── Меню модулей — auto-fit, сам подстроится ─── */
.modules-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.75rem;
}

.module-card {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 1.25rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.module-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.module-card.coming-soon {
    opacity: 0.6;
}

.module-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.module-name {
    font-weight: 600;
    font-size: 0.875rem;
}

.module-badge {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    font-size: 0.625rem;
    background: var(--gray-200);
    color: var(--gray-500);
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
    font-weight: 600;
}

/* ─── Профиль ─── */
.profile-header {
    text-align: center;
    padding: 2rem var(--content-padding) 1rem;
}

.profile-avatar {
    width: 80px;
    height: 80px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-size: 2rem;
    font-weight: 700;
    margin: 0 auto 1rem;
}

.profile-name {
    font-size: 1.25rem;
    font-weight: 700;
}

.profile-role {
    color: var(--gray-500);
    font-size: 0.875rem;
}

.profile-info {
    margin-top: 1.5rem;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}

.profile-actions {
    max-width: 400px;
    margin: 1.5rem auto 0;
}

.info-row {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--gray-100);
}

.info-label {
    color: var(--gray-500);
    font-size: 0.875rem;
}

.info-value {
    font-weight: 500;
    font-size: 0.875rem;
}

/* ─── Нижняя навигация — на всю ширину ─── */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    background: var(--white);
    border-top: 1px solid var(--gray-200);
    display: flex;
    z-index: 100;
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.5rem 0;
    cursor: pointer;
    color: var(--gray-500);
    font-size: 0.6875rem;
    border: none;
    background: none;
    transition: color 0.2s;
    position: relative;
}

.nav-item.active {
    color: var(--primary);
}

.nav-item-icon {
    font-size: 1.375rem;
    margin-bottom: 0.125rem;
}

/* ─── Подчинённые ─── */
.subordinate-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
}

.subordinate-avatar {
    width: 40px;
    height: 40px;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.875rem;
    flex-shrink: 0;
}

.subordinate-info {
    flex: 1;
}

.subordinate-name {
    font-weight: 600;
    font-size: 0.875rem;
}

.subordinate-role {
    font-size: 0.75rem;
    color: var(--gray-500);
}

/* ─── Секции ─── */
.section-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
    margin-top: 1.5rem;
}

.section-title:first-child {
    margin-top: 0;
}

/* ─── Фильтры ─── */
.filter-row {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding-bottom: 0.75rem;
    margin-bottom: 0.75rem;
    -webkit-overflow-scrolling: touch;
}

.filter-chip {
    padding: 0.375rem 0.75rem;
    border-radius: 9999px;
    border: 1px solid var(--gray-200);
    background: var(--white);
    font-size: 0.8125rem;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-chip.active {
    background: var(--primary);
    color: var(--white);
    border-color: var(--primary);
}

/* ─── Загрузка ─── */
.loading {
    text-align: center;
    padding: 2rem;
    color: var(--gray-500);
}

.spinner {
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 3px solid var(--gray-200);
    border-top: 3px solid var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ═══════════════════════════════════════════
   АДАПТИВ — плавно от телефона до десктопа
   ═══════════════════════════════════════════ */

/* ─── Планшет вертикально (600px+) ─── */
@media (min-width: 600px) {
    :root {
        --content-padding: 1.5rem;
    }

    .page-title {
        font-size: 1.375rem;
    }

    .kpi-chip {
        padding: 0.375rem 0.625rem;
        font-size: 0.8125rem;
    }

    .top-bar-avatar {
        width: 36px;
        height: 36px;
        font-size: 0.8125rem;
    }

    .notification-card {
        padding: 1.25rem;
    }

    .subordinate-card {
        padding: 1rem;
        gap: 1rem;
    }

    .subordinate-avatar {
        width: 48px;
        height: 48px;
        font-size: 1rem;
    }

    .subordinate-name {
        font-size: 1rem;
    }

    .subordinate-role {
        font-size: 0.8125rem;
    }

    .nav-item {
        padding: 0.625rem 0;
        font-size: 0.75rem;
    }

    .nav-item-icon {
        font-size: 1.5rem;
    }

    .profile-avatar {
        width: 100px;
        height: 100px;
        font-size: 2.5rem;
    }

    .profile-name {
        font-size: 1.5rem;
    }

    .info-row {
        padding: 1rem 0;
    }

    .info-label,
    .info-value {
        font-size: 1rem;
    }
}

/* ─── Планшет горизонтально (768px+) ─── */
@media (min-width: 768px) {
    :root {
        --content-padding: 2rem;
    }

    .modules-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 1rem;
    }

    .module-card {
        padding: 1.5rem;
    }

    .module-icon {
        font-size: 2.5rem;
        margin-bottom: 0.75rem;
    }

    .module-name {
        font-size: 1rem;
    }

    .notification-title {
        font-size: 1rem;
    }

    .notification-body {
        font-size: 1rem;
    }

    /* Подчинённые в 2 колонки на планшете */
    .subordinates-list {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }

    .subordinates-list .subordinate-card {
        margin-bottom: 0;
    }
}

/* ─── Десктоп (1024px+) ─── */
@media (min-width: 1024px) {
    :root {
        --content-padding: 2.5rem;
    }

    #app {
        max-width: 1200px;
        box-shadow: var(--shadow-md);
    }

    .bottom-nav {
        max-width: 1200px;
        left: 50%;
        transform: translateX(-50%);
    }

    .modules-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
        gap: 1.25rem;
    }

    .profile-info {
        max-width: 600px;
    }
}
