/* --- Глобальные переменные и сброс --- */
:root {
    --sidebar-bg: #1e293b;
    --sidebar-text: #cbd5e1;
    --sidebar-text-hover: #ffffff;
    --sidebar-active-bg: #3b82f6;
    --content-bg: #f1f5f9;
    --content-header-bg: #ffffff;
    --card-bg: #ffffff;
    --primary-color: #3b82f6;
    --primary-color-hover: #2563eb;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --text-color: #0f172a;
    --text-light-color: #64748b;
    --border-color: #e2e8f0;
}

* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
    margin: 0;
    background-color: var(--content-bg);
    color: var(--text-color);
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- Основной макет приложения --- */
.app-layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    height: 100vh;
    width: 100vw;
}

/* --- Боковая панель (Sidebar) --- */
.sidebar {
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.5rem;
    color: #ffffff;
    text-decoration: none;
    border-bottom: 1px solid #334155;
}

.sidebar-header h1 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
}

.sidebar-menu {
    list-style: none;
    padding: 1rem;
    margin: 0;
    flex-grow: 1;
}

.sidebar-menu li a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.8rem 1rem;
    text-decoration: none;
    color: var(--sidebar-text);
    border-radius: 6px;
    font-weight: 500;
    transition: background-color 0.2s, color 0.2s;
}

.sidebar-menu li a:hover {
    background-color: #334155;
    color: var(--sidebar-text-hover);
}

.sidebar-menu li.active a {
    background-color: var(--sidebar-active-bg);
    color: #ffffff;
}

.sidebar-footer {
    padding: 1rem;
    font-size: 0.8rem;
    text-align: center;
    color: var(--text-light-color);
    border-top: 1px solid #334155;
}

/* --- Основной контент --- */
.content {
    overflow-y: auto;
}

.content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--content-header-bg);
    padding: 1rem 2rem;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 10;
}

.content-header h1 {
    margin: 0;
    font-size: 1.75rem;
    font-weight: 600;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
     font-size: 0.75rem;
}

.user-inn {
    color: var(--text-light-color);
}

.logout-btn {
    background-color: var(--danger-color);
    color: white;
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

.logout-btn:hover {
    background-color: #c53030;
}

.content-body {
    padding: 2rem;
}

/* --- Стили формы --- */
.form-container {
    max-width: 500px;
    margin: 2rem auto;
}

.step {
    background-color: var(--card-bg);
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border-color);
}

.step h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0 0 1.5rem 0;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.form-group {
    margin-bottom: 1rem;
}

input[type="text"],
input[type="tel"],
input[type="email"],
input[type="number"],
textarea {
    width: 100%;
    padding: 0.3rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.3);
}

textarea {
    resize: vertical;
    min-height: 80px;
}

.captcha-container {
    margin: 1.5rem 0;
    display: flex;
    justify-content: center;
}

.button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 0.8rem 1.5rem;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
    width: 100%;
}

.button:hover {
    background-color: var(--primary-color-hover);
}

.button.large {
    padding: 1rem;
    font-size: 1.1rem;
}

.button.success {
    background-color: var(--success-color);
}

.file-input-wrapper {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.file-input-wrapper .button {
    width: auto;
}

#file-name-display {
    color: var(--text-light-color);
    font-style: italic;
}

.table-container {
    max-height: 250px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 6px;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 0.8rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

th {
    background-color: #f8fafc;
    font-weight: 600;
    position: sticky;
    top: 0;
}

tr:last-child td {
    border-bottom: none;
}

.settings-grid {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.settings-grid label {
    margin-right: 0.5rem;
}

.spinner {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.hidden {
    display: none !important;
}

.status-message {
    margin-top: 1rem;
    text-align: center;
    font-weight: 500;
    padding: 0.75rem;
    border-radius: 6px;
}

.status-message.error {
    color: #fff;
    background-color: var(--danger-color);
}

.status-message.success {
    color: #fff;
    background-color: var(--success-color);
}

.status-message.pending {
    color: var(--text-color);
    background-color: #e2e8f0;
}

/* --- Стили для страницы ошибки --- */
.error-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem;
    background-color: var(--content-bg);
}

.error-container .sidebar-header {
    position: absolute;
    top: 2rem;
    left: 2rem;
    color: var(--text-light-color);
    /* Делаем логотип менее навязчивым */
    border: none;
}

.error-container .sidebar-header h1 {
    color: var(--text-light-color);
}


.error-card {
    background-color: var(--card-bg);
    padding: 2rem 3rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    max-width: 500px;
    text-align: center;
}

.error-card .mif-warning {
    color: var(--danger-color);
    margin-bottom: 1rem;
}

.error-card h2 {
    font-size: 1.75rem;
    margin: 0 0 0.5rem 0;
    font-weight: 600;
}

.error-card p {
    font-size: 1.1rem;
    color: var(--text-light-color);
    margin: 0;
}

.error-container .sidebar-footer {
    position: absolute;
    bottom: 1rem;
    width: 100%;
    text-align: center;
}

.error-container .sidebar-footer a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}

/* Кастомные уведомления toast */
.custom-toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background-color: #333;
    color: white;
    padding: 10px 20px;
    border-radius: 5px;
    opacity: 0;
    transition: opacity 0.3s ease, bottom 0.3s ease;
    z-index: 9999;
}

.custom-toast.visible {
    opacity: 1;
    bottom: 30px;
}

.custom-toast.success {
    background-color: #28a745;
}

.custom-toast.error {
    background-color: #dc3545;
}

.custom-toast.info {
    background-color: #17a2b8;
}

.by-bitcell {
    color: #fff !important;
}

.modal {
    position: fixed;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    background: rgba(16, 24, 32, 0.54); /* или хотя бы rgba(0,0,0,0.50) */
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow-y: auto;
}


.modal.hidden {
    display: none !important;
}

.modal-content {
    background: #fff;
    border-radius: 6px;
    padding: 2rem;
    min-width: 300px;
    max-width: 90vw;
    max-height: 90vh;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
    overflow-y: auto;
}

.modal-actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
    justify-content: flex-end;
}

#delete-files-modal-message ul {
    font-size: 0.52em;
    margin: 0.5em 0 0.5em 1em;
    padding-left: 1.5em;
    max-height: 220px;
    overflow-y: auto;
}

#delete-files-modal-message li {
    font-size: 1.5em;
    margin: 0.1em 0;
    list-style-type: disc;
}


button:disabled,
.button[disabled] {
    background: #e5e9f2 !important;
    color: #aaa !important;
    border-color: #e5e9f2 !important;
    cursor: not-allowed !important;
    box-shadow: none !important;
    opacity: 0.65;
}

input[type="checkbox"] {
    -webkit-appearance: none;
    appearance: none;
    background: #fff;
    border: 2px solid #2979ff;
    border-radius: 4px;
    width: 20px;
    height: 20px;
    display: inline-block;
    position: relative;
    cursor: pointer;
    vertical-align: middle;
    margin: 0;
    transition: border-color 0.5s, background 0.5s;
}

input[type="checkbox"]:checked {
    background: #2979ff;
    border-color: #2979ff;
}

input[type="checkbox"]:focus {
    outline: none;
    box-shadow: 0 0 0 2px #90caf9;
}

input[type="checkbox"]::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 8px;
    height: 13px;
    border: solid #fff;
    border-width: 0 3px 3px 0;
    border-radius: 1px;
    opacity: 0;
    pointer-events: none;
    /* Центрирование через transform: сдвиг и scale для анимации */
    transform: translate(-50%, -60%) scale(0.3) rotate(45deg);
    transition: opacity 0.16s, transform 0.18s;
}

input[type="checkbox"]:checked::after {
    opacity: 1;
    transform: translate(-50%, -60%) scale(1) rotate(45deg);
    transition: opacity 0.14s, transform 0.14s;
}

input[type="checkbox"]:disabled {
    background: #f4f8fb;
    border-color: #cfd8dc;
    opacity: 0.55;
    cursor: not-allowed;
}

/* --- Mobile adaptation --- */
@media (max-width: 900px) {
    .app-layout {
        grid-template-columns: 95px 1fr !important;
    }

    .sidebar-header span.text-leader {
        display: none !important;
    }

    .sidebar-header {
        padding: 1rem !important;
    }

    .content-header,
    .content-body {
        padding: 1rem !important;
    }
}

@media (max-width: 600px) {
    .app-layout {
        grid-template-columns: 1fr !important;
    }

    .sidebar {
        width: 100vw !important;
        min-width: 100vw !important;
        max-width: 100vw !important;
        height: 60px !important;
        position: sticky;
        top: 0;
        left: 0;
        right: 0;
        z-index: 50;
        flex-direction: row !important;
        align-items: center !important;
        justify-content: flex-start !important;
        padding: 0 !important;
        overflow-y: auto;
    }

    .sidebar-header,
    .sidebar-footer {
        display: none !important;
    }

    .sidebar-menu {
        display: flex !important;
        flex-direction: row !important;
        width: 100vw !important;
        gap: 0;
        padding: 0 0.5em !important;
    }

    .sidebar-menu li {
        margin: 0 !important;
        flex: 1 1 0 !important;
        text-align: center !important;
    }

    .sidebar-menu li a {
        justify-content: center !important;
        padding: 0.7em 0 !important;
        font-size: 0 !important;
    }

    .sidebar-menu li a span {
        font-size: 1.5rem !important;
        margin-right: 0 !important;
    }
}

@media (max-width: 480px) {
    body {
        font-size: 15px !important;
    }

    .content-header,
    .content-body {
        padding: 0.6em !important;
    }

    .step {
        padding: 0.6em !important;
    }
}

@media (max-width: 900px) {
    .sidebar-menu li a {
        font-size: 0 !important;
    }

    .sidebar-menu li a span {
        font-size: 1.7rem !important;
        /* оставляем иконки нормального размера */
        margin-right: 0 !important;
    }
}