/* ============================================================
   Информационная система «Делопроизводство»
   Фирменный стиль торговой сети «Пятёрочка»
   ============================================================ */

:root {
    /* Цветовая схема */
    --color-white: #FFFFFF;
    --color-light-gray: #F8F9FA;
    --color-sidebar: #E9ECEF;
    --color-red: #E5252B;
    --color-dark-gray: #212529;
    --color-medium-gray: #6C757D;
    --color-success: #28A745;
    --color-warning: #FFC107;

    /* Типографика */
    --font-family: 'Inter', 'Roboto', 'Open Sans', sans-serif;
    --font-size-h1: 28px;
    --font-size-h2: 20px;
    --font-size-body: 16px;
    --font-size-small: 14px;
    --font-size-caption: 12px;

    /* Скругления */
    --border-radius: 4px;

    /* Тени */
    --shadow-light: 0 2px 4px rgba(0, 0, 0, 0.05);
    --shadow-medium: 0 4px 6px rgba(0, 0, 0, 0.07);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: var(--font-family);
}

body {
    background-color: var(--color-light-gray);
    color: var(--color-dark-gray);
    font-size: var(--font-size-body);
    line-height: 1.5;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    overflow-x: hidden;
}

a {
    color: inherit;
}

.container {
    display: flex;
    flex: 1;
}

/* ---------------- Боковое меню ---------------- */

.sidebar {
    width: 250px;
    flex-shrink: 0;
    background-color: var(--color-sidebar);
    padding: 20px 0;
    transition: all 0.3s ease;
}

.sidebar-header {
    padding: 0 20px 20px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    margin-bottom: 20px;
}

.logo {
    display: flex;
    align-items: center;
    font-weight: 700;
    font-size: 20px;
    color: var(--color-red);
    text-decoration: none;
}

.logo-icon {
    margin-right: 10px;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.logo-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.logo-text {
    font-size: 18px;
    line-height: 1.2;
}

.logo-text small {
    display: block;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--color-medium-gray);
}

.nav-menu {
    display: flex;
    flex-direction: column;
}

.nav-item {
    padding: 12px 20px;
    display: flex;
    align-items: center;
    color: var(--color-dark-gray);
    text-decoration: none;
    transition: all 0.2s ease;
    cursor: pointer;
    border-left: 3px solid transparent;
}

.nav-item:hover {
    background-color: rgba(0, 0, 0, 0.03);
}

.nav-item.active {
    color: var(--color-red);
    border-left: 3px solid var(--color-red);
    background-color: rgba(229, 37, 43, 0.05);
    font-weight: 500;
}

.nav-icon {
    margin-right: 10px;
    width: 24px;
    text-align: center;
    font-size: 18px;
}

/* ---------------- Шапка ---------------- */

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.header {
    background-color: var(--color-white);
    padding: 15px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    box-shadow: var(--shadow-light);
}

.page-title {
    font-size: var(--font-size-h1);
    font-weight: 600;
}

.page-subtitle {
    font-size: var(--font-size-small);
    color: var(--color-medium-gray);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.search-box {
    position: relative;
}

.search-input {
    padding: 8px 15px 8px 35px;
    border: 1px solid var(--color-sidebar);
    border-radius: var(--border-radius);
    font-size: var(--font-size-small);
    width: 210px;
    transition: all 0.2s ease;
}

.search-input:focus {
    outline: none;
    border-color: var(--color-red);
}

.search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-medium-gray);
    font-size: 16px;
}

.notification {
    position: relative;
    cursor: pointer;
    text-decoration: none;
}

.notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background-color: var(--color-red);
    color: white;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.notification-icon {
    font-size: 18px;
}

.profile {
    display: flex;
    align-items: center;
    gap: 12px;
    white-space: nowrap;
}

.avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background-color: var(--color-sidebar);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 13px;
    color: var(--color-dark-gray);
    flex-shrink: 0;
}

.profile-text {
    display: flex;
    flex-direction: column;
    line-height: 1.25;
}

.profile-name {
    font-size: var(--font-size-small);
    font-weight: 500;
}

.profile-role {
    font-size: var(--font-size-caption);
    color: var(--color-medium-gray);
}

.logout {
    font-size: var(--font-size-caption);
    color: var(--color-medium-gray);
    text-decoration: none;
    border-left: 1px solid var(--color-sidebar);
    padding-left: 12px;
    margin-left: 2px;
    white-space: nowrap;
}

.logout:hover {
    color: var(--color-red);
}

/* ---------------- Рабочая область ---------------- */

.content {
    padding: 30px;
    flex: 1;
    min-width: 0;
}

.card {
    min-width: 0;
    background-color: var(--color-white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-light);
    padding: 20px;
    margin-bottom: 20px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
    margin-bottom: 15px;
}

.card-title {
    font-size: var(--font-size-h2);
    font-weight: 600;
}

/* ---------------- Показатели ---------------- */

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.kpi-card {
    background-color: var(--color-white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-light);
    padding: 20px;
    text-align: center;
    border-left: 4px solid var(--color-medium-gray);
}

.kpi-card.urgent {
    border-left-color: var(--color-red);
}

.kpi-card.success {
    border-left-color: var(--color-success);
}

.kpi-value {
    font-size: 28px;
    font-weight: 700;
    margin: 10px 0;
}

.kpi-card.urgent .kpi-value {
    color: var(--color-red);
}

.kpi-label {
    font-size: var(--font-size-small);
    color: var(--color-medium-gray);
}

/* ---------------- Таблицы ---------------- */

.table-container {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th {
    background-color: var(--color-sidebar);
    padding: 12px 15px;
    text-align: left;
    font-weight: 600;
    font-size: var(--font-size-small);
    color: var(--color-dark-gray);
    white-space: nowrap;
}

.table td {
    padding: 12px 15px;
    border-bottom: 1px solid var(--color-sidebar);
    vertical-align: middle;
}

.table tbody tr:nth-child(even) {
    background-color: rgba(0, 0, 0, 0.01);
}

.table tbody tr:hover {
    background-color: rgba(0, 0, 0, 0.03);
}

.table .num {
    white-space: nowrap;
    font-weight: 500;
}

.table .muted {
    color: var(--color-medium-gray);
    font-size: var(--font-size-small);
}

.status {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: var(--font-size-caption);
    font-weight: 500;
    white-space: nowrap;
}

.status-pending {
    background-color: rgba(255, 193, 7, 0.15);
    color: #856404;
}

.status-completed {
    background-color: rgba(40, 167, 69, 0.15);
    color: #155724;
}

.status-overdue {
    background-color: rgba(229, 37, 43, 0.15);
    color: var(--color-red);
}

.status-archive {
    background-color: rgba(108, 117, 125, 0.15);
    color: #495057;
}

/* ---------------- Кнопки ---------------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border-radius: var(--border-radius);
    font-size: var(--font-size-small);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    text-decoration: none;
    line-height: 1.2;
}

.btn-primary {
    background-color: var(--color-red);
    color: white;
}

.btn-primary:hover {
    background-color: #c41e23;
}

.btn-secondary {
    background-color: transparent;
    color: var(--color-red);
    border: 1px solid var(--color-medium-gray);
}

.btn-secondary:hover {
    background-color: rgba(0, 0, 0, 0.03);
}

.btn-text {
    background-color: transparent;
    color: var(--color-red);
    text-decoration: underline;
    padding: 5px 8px;
}

.btn-text:hover {
    color: #c41e23;
}

.btn-icon {
    margin-right: 8px;
    font-size: 16px;
}

.btn[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
}

.action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: var(--border-radius);
    text-decoration: none;
    border: 1px solid transparent;
    transition: all 0.2s ease;
}

.action:hover {
    background-color: rgba(0, 0, 0, 0.05);
    border-color: var(--color-sidebar);
}

/* ---------------- Формы ---------------- */

.form-group {
    margin-bottom: 18px;
}

.form-label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: var(--font-size-small);
}

.form-label .req {
    color: var(--color-red);
}

.form-control {
    width: 100%;
    padding: 10px 15px;
    border: 1px solid var(--color-sidebar);
    border-radius: var(--border-radius);
    font-size: var(--font-size-body);
    transition: all 0.2s ease;
    background-color: var(--color-white);
    color: var(--color-dark-gray);
}

.form-control:focus {
    outline: none;
    border-color: var(--color-red);
}

textarea.form-control {
    resize: vertical;
    min-height: 80px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 15px;
}

.form-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.form-hint {
    font-size: var(--font-size-caption);
    color: var(--color-medium-gray);
    margin-top: 4px;
}

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 20px;
    align-items: flex-end;
}

.filters > .form-group {
    margin-bottom: 0;
    flex: 1 1 130px;
    min-width: 0;
}

.filters > .form-group:last-child {
    flex: 0 0 auto;
}

.filters .form-actions {
    flex-wrap: nowrap;
}

.filters .form-actions .btn {
    padding: 10px 14px;
}

/* ---------------- Вкладки ---------------- */

.tabs {
    display: flex;
    border-bottom: 1px solid var(--color-sidebar);
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.tab {
    padding: 10px 20px;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    text-decoration: none;
    color: var(--color-dark-gray);
    font-size: var(--font-size-small);
}

.tab:hover {
    color: var(--color-red);
}

.tab.active {
    border-bottom: 3px solid var(--color-red);
    color: var(--color-red);
    font-weight: 500;
}

/* ---------------- Сообщения ---------------- */

.alert {
    padding: 12px 15px;
    border-radius: var(--border-radius);
    margin-bottom: 15px;
    font-size: var(--font-size-small);
}

.alert-success {
    background-color: rgba(40, 167, 69, 0.15);
    color: #155724;
    border: 1px solid rgba(40, 167, 69, 0.3);
}

.alert-error {
    background-color: rgba(229, 37, 43, 0.15);
    color: var(--color-red);
    border: 1px solid rgba(229, 37, 43, 0.3);
}

/* ---------------- Документы ---------------- */

.document-form {
    display: none;
    background-color: var(--color-white);
    border: 1px solid var(--color-sidebar);
    border-radius: var(--border-radius);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-light);
}

.document-form.open {
    display: block;
}

.doc-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.doc-number {
    font-size: 22px;
    font-weight: 700;
}

.doc-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.doc-field-label {
    font-size: var(--font-size-caption);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--color-medium-gray);
    margin-bottom: 4px;
}

.doc-field-value {
    font-size: var(--font-size-body);
}

.doc-text {
    background-color: var(--color-light-gray);
    border-radius: var(--border-radius);
    padding: 15px;
    margin-bottom: 20px;
    white-space: pre-line;
}

.timeline {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.timeline-item {
    display: flex;
    gap: 15px;
    font-size: var(--font-size-small);
}

.timeline-time {
    color: var(--color-medium-gray);
    min-width: 110px;
}

.empty {
    padding: 30px;
    text-align: center;
    color: var(--color-medium-gray);
    font-size: var(--font-size-small);
}

/* ---------------- Архив и отчёты ---------------- */

.split {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 30px;
    align-items: start;
}

.tree-item {
    padding: 10px;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: var(--color-dark-gray);
    font-size: var(--font-size-small);
}

.tree-item:hover {
    background-color: rgba(0, 0, 0, 0.03);
}

.tree-item.active {
    background-color: rgba(229, 37, 43, 0.08);
    color: var(--color-red);
    font-weight: 500;
}

.tree-item.sub {
    padding-left: 25px;
}

.report-item {
    padding: 15px;
    border: 1px solid var(--color-sidebar);
    border-radius: var(--border-radius);
    cursor: pointer;
    display: block;
    text-decoration: none;
    color: inherit;
    margin-bottom: 10px;
}

.report-item strong {
    display: block;
    margin-bottom: 4px;
}

.report-item span {
    font-size: var(--font-size-small);
    color: var(--color-medium-gray);
}

.report-item.active {
    border-color: var(--color-red);
    background-color: rgba(229, 37, 43, 0.04);
}

/* ---------------- Авторизация ---------------- */

.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 30px 15px;
    background:
        radial-gradient(circle at 15% 20%, rgba(229, 37, 43, 0.12), transparent 45%),
        radial-gradient(circle at 85% 80%, rgba(229, 37, 43, 0.08), transparent 45%),
        var(--color-light-gray);
}

.auth-card {
    width: 100%;
    max-width: 460px;
    background-color: var(--color-white);
    border-radius: 8px;
    box-shadow: var(--shadow-medium);
    padding: 30px;
}

.auth-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 6px;
    color: var(--color-red);
    font-weight: 700;
    font-size: 22px;
}

.auth-logo img {
    width: 42px;
    height: 42px;
    object-fit: contain;
}

.auth-subtitle {
    text-align: center;
    color: var(--color-medium-gray);
    font-size: var(--font-size-small);
    margin-bottom: 20px;
}

.auth-tabs {
    display: flex;
    background-color: var(--color-light-gray);
    border-radius: var(--border-radius);
    padding: 4px;
    margin-bottom: 22px;
}

.auth-tab {
    flex: 1;
    text-align: center;
    padding: 9px;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: var(--font-size-small);
    font-weight: 500;
    color: var(--color-medium-gray);
    border: none;
    background: transparent;
}

.auth-tab.active {
    background-color: var(--color-white);
    color: var(--color-red);
    box-shadow: var(--shadow-light);
}

.auth-form {
    display: none;
}

.auth-form.active {
    display: block;
}

.auth-hint {
    font-size: var(--font-size-caption);
    color: var(--color-medium-gray);
    text-align: center;
    margin-top: 18px;
    line-height: 1.6;
}

.auth-hint code {
    background-color: var(--color-light-gray);
    padding: 1px 5px;
    border-radius: 3px;
    font-family: ui-monospace, Consolas, monospace;
}

/* ---------------- Подвал ---------------- */

.footer {
    background-color: var(--color-dark-gray);
    color: var(--color-white);
    padding: 20px 30px;
    margin-top: auto;
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

.footer-links {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.footer-link {
    color: var(--color-white);
    text-decoration: none;
    font-size: var(--font-size-small);
    transition: color 0.2s ease;
}

.footer-link:hover {
    color: var(--color-red);
}

.social-links {
    display: flex;
    gap: 15px;
}

.social-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.92);
    transition: all 0.2s ease;
}

.social-link:hover {
    background-color: var(--color-red);
    transform: translateY(-2px);
}

.social-icon {
    width: 22px;
    height: 22px;
    object-fit: contain;
    border-radius: 4px;
}

.copyright {
    font-size: var(--font-size-small);
    color: #ADB5BD;
    width: 100%;
    text-align: center;
    margin-top: 15px;
}

/* ---------------- Адаптивность ---------------- */

@media (max-width: 1200px) {
    .profile-text {
        display: none;
    }
    .search-input {
        width: 180px;
    }
}

@media (max-width: 992px) {
    .sidebar {
        width: 70px;
    }

    .nav-text {
        display: none;
    }

    .nav-icon {
        margin-right: 0;
        font-size: 18px;
    }

    .logo-text {
        display: none;
    }

    .footer-content {
        flex-direction: column;
        text-align: center;
    }

    .split {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        padding: 10px 0;
    }

    .sidebar-header {
        padding: 0 15px 10px;
        margin-bottom: 5px;
        border-bottom: none;
    }

    .nav-menu {
        flex-direction: row;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .nav-menu::-webkit-scrollbar {
        display: none;
    }

    .nav-item {
        padding: 10px 15px;
        white-space: nowrap;
        border-left: none;
        border-bottom: 3px solid transparent;
    }

    .nav-item.active {
        border-left: none;
        border-bottom: 3px solid var(--color-red);
    }

    .nav-text {
        display: inline;
    }

    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .header {
        padding: 15px 20px;
        flex-wrap: wrap;
    }

    .header-actions {
        gap: 12px;
    }

    .search-input {
        width: 150px;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .filters > .form-group {
        flex: 1 1 100%;
    }

    .table th {
        white-space: normal;
    }

    .profile-text {
        display: none;
    }

    /* Выход из системы должен оставаться доступным с телефона:
       раньше .logout скрывался вместе с .profile-text, и на экранах
       до 768 px выйти из аккаунта было нечем. */
    .logout {
        display: inline-flex;
        align-items: center;
        min-height: 36px;
        padding: 6px 10px;
        margin-left: 4px;
        border-left: none;
        border: 1px solid var(--color-sidebar);
        border-radius: 8px;
        font-size: var(--font-size-caption);
        color: var(--color-medium-gray);
        text-decoration: none;
    }

    .footer {
        padding: 15px 20px;
    }
}

@media (max-width: 576px) {
    .kpi-grid {
        grid-template-columns: 1fr;
    }

    .header-actions {
        gap: 10px;
    }

    .search-box {
        display: none;
    }

    .content {
        padding: 20px 15px;
    }

    .social-links {
        justify-content: center;
    }

    .page-title {
        font-size: 22px;
    }
}
