:root {
    /* Light Theme Variables */
    --bg-color: #f5f7fa;
    --container-bg: #ffffff;
    --text-color: #2d3748;
    --heading-color: #1a202c;
    --section-bg: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    --section-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    --card-bg: #ffffff;
    --card-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    --card-hover-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
    --card-header-border: #e2e8f0;
    --request-id-color: #4a5568;
    --request-category-bg: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --request-category-color: #ffffff;
    --paragraph-color: #4a5568;
    --strong-color: #2d3748;
    --rejection-bg: linear-gradient(135deg, #fee 0%, #fdd 100%);
    --rejection-border: #fc8181;
    --rejection-color: #c53030;
    --unarchive-bg: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    --unarchive-border: #fbbf24;
    --unarchive-color: #92400e;
    --error-bg: #fee;
    --error-color: #e53e3e;
    --primary-color: #667eea;
    --primary-hover: #5568d3;
    --success-color: #48bb78;
    --warning-color: #ed8936;
    --danger-color: #f56565;
    --border-radius: 12px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --scrollbar-track: rgba(0, 0, 0, 0.06);
    --scrollbar-thumb: rgba(102, 126, 234, 0.4);
    --scrollbar-thumb-hover: rgba(102, 126, 234, 0.65);
}

body[data-theme="dark"] {
    /* Dark Theme Variables */
    --bg-color: #1a202c;
    --container-bg: #2d3748;
    --text-color: #e2e8f0;
    --heading-color: #f7fafc;
    --section-bg: linear-gradient(135deg, #2d3748 0%, #1a202c 100%);
    --section-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    --card-bg: #2d3748;
    --card-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
    --card-hover-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
    --card-header-border: #4a5568;
    --request-id-color: #cbd5e0;
    --request-category-bg: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --request-category-color: #ffffff;
    --paragraph-color: #cbd5e0;
    --strong-color: #f7fafc;
    --rejection-bg: linear-gradient(135deg, #742a2a 0%, #63171b 100%);
    --rejection-border: #fc8181;
    --rejection-color: #fed7d7;
    --unarchive-bg: linear-gradient(135deg, #744210 0%, #78350f 100%);
    --unarchive-border: #fbbf24;
    --unarchive-color: #fef3c7;
    --error-bg: #742a2a;
    --error-color: #fed7d7;
    --primary-color: #667eea;
    --primary-hover: #764ba2;
    --success-color: #48bb78;
    --warning-color: #ed8936;
    --danger-color: #f56565;
    --scrollbar-track: rgba(255, 255, 255, 0.06);
    --scrollbar-thumb: rgba(160, 174, 192, 0.35);
    --scrollbar-thumb-hover: rgba(160, 174, 192, 0.55);
}

/* Scrollbars — в стиле интерфейса, без стрелок */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

*::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

*::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
    border-radius: 999px;
}

*::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 999px;
}

*::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
}

*::-webkit-scrollbar-button,
*::-webkit-scrollbar-corner {
    display: none;
    width: 0;
    height: 0;
}

/* General Body and Container Styles */
html, body {
    height: 100%;
    width: 100%;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    display: flex;
    flex-direction: column; /* Body is a flex container for direct children */
    min-height: 100vh;
    box-sizing: border-box;
    transition: background-color 0.3s ease, color 0.3s ease;
    padding: 20px; /* Padding for the entire app content */
    overflow: hidden; /* Hide body overflow, main content will manage scroll */
}

.container {
    max-width: 100%;
    width: 100%;
    margin: 0;
    padding: 20px 24px;
    background-color: var(--container-bg);
    background-color: rgba(255, 255, 255, 0.7); /* Полупрозрачный белый для светлой темы */
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.45);
    box-sizing: border-box;
    display: flex;
    flex-direction: column; /* Container is a flex column for h1 and main-sections-layout */
    flex-grow: 1; /* Allow container to take all available space within body */
    min-height: 0; /* Important for flex items to shrink below their content size */
    backdrop-filter: blur(10px); /* Эффект размытия для лучшей видимости фона */
    overflow: hidden;
}

body[data-theme="dark"] .container {
    background-color: rgba(45, 55, 72, 0.7); /* Полупрозрачный для темной темы */
    border-color: rgba(255, 255, 255, 0.08);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}

/* Theme Switcher Button - убран, теперь переключатель темы в настройках */

/* Header Styles */
h1 {
    text-align: center;
    margin-bottom: 20px;
    color: var(--heading-color);
    font-size: 2.8em;
    font-weight: 800;
    position: relative;
    padding-bottom: 15px;
    flex-shrink: 0;
    letter-spacing: -0.5px;
    /* Убираем gradient - используем обычный цвет текста для всего заголовка включая эмодзи */
}

h1::after {
    content: '';
    position: absolute;
    left: 50%;
    bottom: 0;
    transform: translateX(-50%);
    width: 100px;
    height: 5px;
    background: linear-gradient(90deg, var(--primary-color) 0%, var(--primary-hover) 100%);
    border-radius: 3px;
}

/* Main Sections Layout (horizontal scrolling for sections) */
.main-sections-layout {
    display: flex;
    flex-direction: row; /* sections go horizontally */
    flex-wrap: nowrap;
    overflow-x: auto; /* Horizontal scroll if not enough space */
    overflow-y: hidden; /* Hide vertical scroll for this container */
    padding-bottom: 10px; /* Space for scrollbar */
    flex-grow: 1; /* Allow it to take all remaining vertical space in container */
    min-height: 0; /* Important for flex items to shrink */
    scroll-behavior: smooth; /* Плавная прокрутка */
    -webkit-overflow-scrolling: touch; /* Плавный скролл на мобильных */
    overflow-anchor: none;
}

/* requests-container is where sections are dynamically added by JS */
#requests-container {
    display: flex;
    flex-direction: row; /* sections go horizontally */
    flex-wrap: nowrap; /* Do not wrap sections */
    flex-grow: 1; /* Allow it to take all remaining space within main-sections-layout */
    /* overflow-x: auto; - Handled by parent .main-sections-layout */
    /* overflow-y: hidden; - Handled by parent .main-sections-layout */
}

/* Section Styles (for each 'Участок') */
.section {
    flex: 0 0 420px;
    margin-right: 24px;
    border-radius: var(--border-radius);
    padding: 24px;
    background: var(--section-bg);
    background: rgba(255, 255, 255, 0.6); /* Полупрозрачный белый */
    box-shadow: var(--section-shadow);
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    height: 100%;
    box-sizing: border-box;
    overflow: hidden;
    border: 1px solid var(--card-header-border);
    position: relative;
    backdrop-filter: blur(8px); /* Эффект размытия */
}

body[data-theme="dark"] .section {
    background: rgba(45, 55, 72, 0.6); /* Полупрозрачный для темной темы */
}

.section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-color) 0%, var(--primary-hover) 100%);
    border-radius: var(--border-radius) var(--border-radius) 0 0;
}

.section:last-child {
    margin-right: 0;
}

.section:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
}

.section h2 {
    margin-top: 0;
    margin-bottom: 16px;
    color: var(--heading-color);
    border-left: 4px solid var(--primary-color);
    padding-left: 16px;
    font-size: 1.25em;
    font-weight: 700;
    flex-shrink: 0;
    display: block;
    line-height: 1.3;
    word-break: break-word;
}

/* Подразделы для участков внутри статусов */
.subsection {
    margin-bottom: 20px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.4);
    border-radius: 8px;
    border-left: 3px solid var(--primary-color);
}

body[data-theme="dark"] .subsection {
    background: rgba(45, 55, 72, 0.4);
}

.subsection:last-child {
    margin-bottom: 0;
}

.subsection h3 {
    margin-top: 0;
    margin-bottom: 15px;
    color: var(--heading-color);
    font-size: 1.2em;
    font-weight: 600;
    padding-left: 12px;
    border-left: 2px solid var(--primary-color);
}

/* Grid/Requests Container Styles - this holds the actual cards and should scroll */
.grid {
    display: flex;
    flex-direction: column;
    gap: 15px;
    flex-grow: 1; /* Allow grid to take remaining space within section */
    overflow-y: auto; /* THIS is where vertical scroll happens for cards */
    overflow-x: hidden; /* Предотвращаем горизонтальный скролл */
    padding-right: 5px; /* Add some padding for scrollbar if it appears */
    scroll-behavior: smooth; /* Плавная прокрутка */
    -webkit-overflow-scrolling: touch; /* Плавный скролл на мобильных */
    overflow-anchor: none;
}

/* Во вкладке "Все" карточки идут в строку с горизонтальной прокруткой */
.grid.grid-horizontal {
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    align-items: stretch;
    padding-right: 0;
    padding-bottom: 8px;
}

.grid.grid-horizontal .request-card {
    width: 380px;
    min-width: 380px;
    max-width: 380px;
}

.section.section-all-tab {
    flex: 1 0 460px;
}

/* Request Card Styles */
.request-card {
    background: var(--card-bg);
    background: rgba(255, 255, 255, 0.8); /* Полупрозрачный белый */
    border-radius: var(--border-radius);
    padding: 20px;
    box-shadow: var(--card-shadow);
    transition: var(--transition);
    width: 100%;
    box-sizing: border-box;
    flex-shrink: 0;
    border: 1px solid var(--card-header-border);
    position: relative;
    overflow: visible;
    backdrop-filter: blur(5px); /* Эффект размытия */
}

body[data-theme="dark"] .request-card {
    background: rgba(45, 55, 72, 0.8); /* Полупрозрачный для темной темы */
}

.request-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--primary-color);
    opacity: 0;
    transition: var(--transition);
    border-radius: var(--border-radius) 0 0 var(--border-radius);
    pointer-events: none;
}

.request-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--card-hover-shadow);
    border-color: var(--primary-color);
}

.request-card:hover::before {
    opacity: 1;
}

.request-card-priority {
    border: 2px solid #e53e3e;
    box-shadow: 0 0 0 1px rgba(229, 62, 62, 0.2), var(--card-shadow);
}

.request-card-priority::before {
    background: #e53e3e;
    opacity: 1;
}

.request-card-priority:hover {
    border-color: #e53e3e;
    box-shadow: 0 0 0 1px rgba(229, 62, 62, 0.35), var(--card-hover-shadow);
}

body[data-theme="dark"] .request-card-priority {
    border-color: #fc8181;
}

body[data-theme="dark"] .request-card-priority::before {
    background: #fc8181;
}

.priority-toggle {
    --priority-accent: #dd6b20;
    --priority-accent-soft: rgba(221, 107, 32, 0.14);
    --priority-accent-border: rgba(221, 107, 32, 0.35);
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
    padding: 4px 10px 4px 4px;
    border-radius: 999px;
    border: 1px solid var(--card-header-border);
    background: rgba(255, 255, 255, 0.55);
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    flex-shrink: 0;
    transition: background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, transform 0.15s ease;
}

body[data-theme="dark"] .priority-toggle {
    background: rgba(255, 255, 255, 0.05);
}

.priority-toggle:hover {
    border-color: var(--priority-accent-border);
    background: var(--priority-accent-soft);
    transform: translateY(-1px);
}

.priority-toggle-input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
    margin: 0;
    pointer-events: none;
}

.priority-toggle-ui {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.05);
    border: 1px solid var(--card-header-border);
    transition: background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

body[data-theme="dark"] .priority-toggle-ui {
    background: rgba(255, 255, 255, 0.06);
}

.priority-toggle-star {
    font-size: 15px;
    line-height: 1;
    color: #a0aec0;
    transition: color 0.18s ease, transform 0.18s ease, text-shadow 0.18s ease;
}

.priority-toggle-label {
    font-size: 0.82em;
    font-weight: 600;
    color: var(--paragraph-color);
    letter-spacing: 0.01em;
    transition: color 0.18s ease;
}

.priority-toggle.is-on,
.priority-toggle:has(.priority-toggle-input:checked) {
    border-color: var(--priority-accent-border);
    background: linear-gradient(135deg, rgba(237, 137, 54, 0.18), rgba(229, 62, 62, 0.12));
    box-shadow: 0 2px 10px rgba(221, 107, 32, 0.16);
}

.priority-toggle.is-on .priority-toggle-ui,
.priority-toggle:has(.priority-toggle-input:checked) .priority-toggle-ui {
    background: linear-gradient(145deg, #ed8936, #e53e3e);
    border-color: transparent;
    box-shadow: 0 2px 8px rgba(229, 62, 62, 0.35);
}

.priority-toggle.is-on .priority-toggle-star,
.priority-toggle:has(.priority-toggle-input:checked) .priority-toggle-star {
    color: #fff7ed;
    transform: scale(1.08);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

.priority-toggle.is-on .priority-toggle-label,
.priority-toggle:has(.priority-toggle-input:checked) .priority-toggle-label {
    color: #c05621;
}

body[data-theme="dark"] .priority-toggle.is-on .priority-toggle-label,
body[data-theme="dark"] .priority-toggle:has(.priority-toggle-input:checked) .priority-toggle-label {
    color: #fbd38d;
}

.priority-toggle-input:focus-visible + .priority-toggle-ui {
    outline: 2px solid var(--priority-accent);
    outline-offset: 2px;
}

.priority-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 0 0 0 auto !important;
    padding: 5px 10px 5px 6px;
    border-radius: 999px;
    background: linear-gradient(135deg, rgba(237, 137, 54, 0.2), rgba(229, 62, 62, 0.14));
    border: 1px solid rgba(221, 107, 32, 0.35);
    color: #c05621 !important;
    font-weight: 700;
    font-size: 0.82em;
    white-space: nowrap;
}

.priority-badge-star {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(145deg, #ed8936, #e53e3e);
    color: #fff7ed;
    font-size: 12px;
    line-height: 1;
    box-shadow: 0 1px 5px rgba(229, 62, 62, 0.35);
}

body[data-theme="dark"] .priority-badge {
    color: #fbd38d !important;
}

.request-card .request-description {
    word-break: break-word;
    overflow-wrap: anywhere;
    line-height: 1.45;
}

.assignees-row {
    margin: 10px 0;
}

.assignees-row-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}

.assignees-row-head strong {
    color: var(--strong-color);
}

.assignee-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.assignee-chip {
    display: inline-flex;
    align-items: center;
    max-width: 100%;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(49, 130, 206, 0.14);
    color: #2b6cb0;
    font-size: 0.85em;
    font-weight: 600;
    line-height: 1.3;
    word-break: break-word;
}

body[data-theme="dark"] .assignee-chip {
    background: rgba(99, 179, 237, 0.18);
    color: #90cdf4;
}

.assignees-empty-inline {
    color: var(--paragraph-color);
    font-size: 0.9em;
}

.btn-assign {
    background: rgba(49, 130, 206, 0.12) !important;
    color: #2b6cb0 !important;
    border: 1px solid rgba(49, 130, 206, 0.35) !important;
    flex-shrink: 0;
}

body[data-theme="dark"] .btn-assign {
    color: #90cdf4 !important;
    border-color: rgba(144, 205, 244, 0.35) !important;
}

.assignees-modal-content {
    width: min(480px, 94vw);
    max-height: 85vh;
    display: flex;
    flex-direction: column;
}

.assignees-modal-hint {
    margin: -8px 0 14px;
    color: var(--paragraph-color);
    font-size: 0.95em;
}

.assignees-modal-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: min(420px, 50vh);
    overflow-y: auto;
    margin-bottom: 12px;
    padding-right: 2px;
}

.assignee-pick {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    column-gap: 10px;
    row-gap: 2px;
    align-items: center;
    width: 100%;
    text-align: left;
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid var(--card-header-border);
    background: rgba(255, 255, 255, 0.55);
    color: inherit;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

body[data-theme="dark"] .assignee-pick {
    background: rgba(255, 255, 255, 0.04);
}

.assignee-pick:hover {
    border-color: var(--primary-color);
}

.assignee-pick.is-selected {
    border-color: #3182ce;
    background: rgba(49, 130, 206, 0.12);
    box-shadow: inset 0 0 0 1px rgba(49, 130, 206, 0.2);
}

.assignee-pick-main {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 6px 8px;
    min-width: 0;
}

.assignee-pick-name {
    font-weight: 600;
    color: var(--strong-color);
}

.assignee-pick-role {
    font-size: 0.8em;
    color: var(--paragraph-color);
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.06);
}

body[data-theme="dark"] .assignee-pick-role {
    background: rgba(255, 255, 255, 0.08);
}

.assignee-pick-phone {
    grid-column: 1;
    font-size: 0.85em;
    color: var(--paragraph-color);
}

.assignee-pick-mark {
    grid-column: 2;
    grid-row: 1 / span 2;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: #2b6cb0;
    background: rgba(49, 130, 206, 0.12);
}

.assignee-pick:not(.is-selected) .assignee-pick-mark {
    background: transparent;
    color: transparent;
    border: 1px dashed var(--card-header-border);
}

.assignees-empty {
    color: var(--paragraph-color);
    font-size: 0.9em;
    margin: 8px 0;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px dashed var(--card-header-border);
}

.request-id {
    font-size: 1.1em;
    font-weight: 700;
    color: var(--request-id-color);
}

.request-category {
    background: var(--request-category-bg);
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.85em;
    color: var(--request-category-color);
    font-weight: 500;
    text-transform: uppercase;
}

.request-card p {
    margin: 8px 0;
    color: var(--paragraph-color);
}

.request-card p strong {
    color: var(--strong-color);
    margin-right: 5px;
}

/* Status Styles */
.status {
    font-weight: 600;
    padding: 6px 14px;
    border-radius: 20px;
    display: inline-block;
    min-width: 100px;
    text-align: center;
    font-size: 0.9em;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: var(--transition);
}

.status:hover {
    transform: scale(1.05);
}

.status-ожидает { 
    background: linear-gradient(135deg, #a0aec0 0%, #718096 100%);
    color: #ffffff;
}
.status-в-очереди { 
    background: linear-gradient(135deg, #4299e1 0%, #3182ce 100%);
    color: #ffffff;
}
.status-в-работе { 
    background: linear-gradient(135deg, #ed8936 0%, #dd6b20 100%);
    color: #ffffff;
}
.status-завершено { 
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
    color: #ffffff;
}
.status-отклонена { 
    background: linear-gradient(135deg, #f56565 0%, #e53e3e 100%);
    color: #ffffff;
}
.status-закрыта { 
    background: linear-gradient(135deg, #718096 0%, #4a5568 100%);
    color: #ffffff;
}

/* Rejection Comment Styles */
.rejection {
    margin-top: 20px;
    padding: 12px;
    background: var(--rejection-bg);
    border-left: 4px solid var(--rejection-border);
    border-radius: 8px;
    color: var(--rejection-color);
    font-size: 0.95em;
    font-style: italic;
}

/* Unarchive Comment Styles */
.unarchive-comment {
    margin-top: 20px;
    padding: 12px;
    background: var(--unarchive-bg);
    border-left: 4px solid var(--unarchive-border);
    border-radius: 8px;
    color: var(--unarchive-color);
    font-size: 0.95em;
    font-style: italic;
}

/* Error Message Styles */
.error {
    text-align: center;
    color: var(--error-color);
    font-size: 1.1em;
    padding: 20px;
    background-color: var(--error-bg);
    border-radius: 8px;
    margin-top: 30px;
}

/* Responsive Adjustments */
@media (max-width: 1200px) {
    .section {
        flex: 0 0 300px;
    }
}

@media (max-width: 992px) {
    .section {
        flex: 0 0 280px;
    }
}

@media (max-width: 768px) {
    html, body {
        overflow: auto; /* Allow full page scroll on mobile */
    }
    body {
        padding: 15px;
    }
    .container {
        height: auto;
        min-height: unset; /* Allow container to shrink */
        padding: 16px;
        border-radius: 14px;
    }

    .header-bar {
        flex-wrap: wrap;
        padding: 12px 14px;
        border-radius: 12px;
    }

    .header-bar h1 {
        font-size: 1.45em;
        width: 100%;
    }

    .header-actions {
        width: 100%;
        justify-content: flex-end;
    }
    .main-sections-layout {
        flex-direction: column;
        overflow-x: hidden;
        overflow-y: auto; /* Allow main layout to scroll vertically on mobile */
        padding-bottom: 0;
        min-height: 0; /* Important for flex items */
    }

    #requests-container {
        flex-direction: column;
        overflow-x: hidden;
        min-height: 0;
    }

    .section {
        flex: 0 0 auto; /* Auto height */
        margin-right: 0;
        margin-bottom: 20px;
        width: 100%;
        height: auto; /* Auto height */
        max-height: 500px; /* Limit height for scroll within section */
        overflow: hidden; /* Hide section's overflow on mobile, grid will handle */
    }

    h1 {
        font-size: 2em;
        margin-bottom: 20px;
    }

    .section h2 {
        font-size: 1.5em;
        margin-bottom: 15px;
    }

    .grid {
        overflow-y: auto; /* Keep inner grid scroll */
    }

    .grid.grid-horizontal {
        overflow-x: auto;
        overflow-y: hidden;
    }

    .grid.grid-horizontal .request-card {
        width: 340px;
        min-width: 340px;
        max-width: 340px;
    }

    .request-card {
        padding: 15px;
        width: 100%;
    }

    .card-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .request-category {
        margin-top: 8px;
    }
}

@media (max-width: 480px) {
    body {
        padding: 10px;
    }
    h1 {
        font-size: 1.8em;
        margin-bottom: 15px;
    }

    .section {
        padding: 15px;
        margin-bottom: 15px;
        max-height: 400px;
    }

    .section h2 {
        font-size: 1.3em;
        margin-bottom: 10px;
    }

    .request-card {
        padding: 12px;
    }
}

/* Header Bar */
.header-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
    flex-shrink: 0;
    padding: 14px 18px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.42);
    border: 1px solid var(--card-header-border);
}

body[data-theme="dark"] .header-bar {
    background: rgba(26, 32, 44, 0.55);
}

.header-bar h1 {
    text-align: left;
    margin: 0;
    padding-bottom: 0;
    font-size: 1.75em;
    line-height: 1.2;
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1 1 auto;
    min-width: 0;
}

.header-bar h1::after {
    display: none;
}

.header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
}

.header-actions .btn {
    padding: 10px 16px;
    min-height: 42px;
    font-size: 0.9em;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    white-space: nowrap;
    box-shadow: none;
}

.header-actions .btn::before {
    display: none;
}

.header-actions #settings-btn,
.header-actions #bot-settings-btn {
    min-width: 42px;
    padding: 10px 12px;
}

.settings-modal-content .settings-number-input {
    -moz-appearance: textfield;
    appearance: textfield;
}

.settings-modal-content .settings-number-input::-webkit-outer-spin-button,
.settings-modal-content .settings-number-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.admin-bot-settings-modal h2 {
    margin-top: 0;
}

/* Tabs */
.tabs-container {
    margin-bottom: 24px;
    flex-shrink: 0;
    overflow-x: auto;
    padding-bottom: 4px;
}

.tabs {
    display: flex;
    gap: 8px;
    border-bottom: 2px solid var(--card-header-border);
    padding-bottom: 0;
}

.tab-btn {
    padding: 12px 24px;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    color: var(--text-color);
    font-size: 0.95em;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    position: relative;
    border-radius: var(--border-radius) var(--border-radius) 0 0;
}

.tab-btn::before {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary-color) 0%, var(--primary-hover) 100%);
    transform: scaleX(0);
    transition: transform 0.3s ease;
}

.tab-btn:hover {
    color: var(--primary-color);
    background: rgba(102, 126, 234, 0.1);
}

.tab-btn.active {
    color: var(--primary-color);
    background: rgba(102, 126, 234, 0.1);
}

.tab-btn.active::before {
    transform: scaleX(1);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

#confirm-modal {
    z-index: 3000;
}

.modal-content {
    background: var(--container-bg);
    padding: 32px;
    border-radius: var(--border-radius);
    max-width: 520px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    border: 1px solid var(--card-header-border);
    animation: modalFadeIn 0.3s ease;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-content h2 {
    margin-top: 0;
    color: var(--heading-color);
}

.modal-buttons {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    justify-content: flex-end;
}

.reject-modal-content {
    max-width: 480px;
    width: min(92vw, 480px);
    padding: 28px 28px 24px;
    overflow: hidden;
    border-radius: 16px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45);
    position: relative;
}

.reject-modal-content::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    border-radius: 16px 16px 0 0;
    background: linear-gradient(90deg, #f56565 0%, #e53e3e 100%);
}

.reject-modal-content h2 {
    margin: 0 0 8px;
    font-size: 1.45rem;
}

.reject-modal-hint {
    margin: 0 0 20px;
    color: var(--paragraph-color);
    font-size: 0.92em;
    line-height: 1.5;
}

.reject-form-group {
    margin-bottom: 0;
}

.reject-form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-color);
    font-weight: 600;
    font-size: 0.9em;
}

.reject-comment-input {
    width: 100%;
    min-height: 120px;
    padding: 14px 16px;
    border: 2px solid var(--card-header-border);
    border-radius: 12px;
    background: var(--card-bg);
    color: var(--text-color);
    font-size: 0.95em;
    font-family: inherit;
    line-height: 1.5;
    box-sizing: border-box;
    resize: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.reject-comment-input::placeholder {
    color: var(--paragraph-color);
    opacity: 0.65;
}

.reject-comment-input:focus {
    outline: none;
    border-color: #f56565;
    box-shadow: 0 0 0 4px rgba(245, 101, 101, 0.15);
}

.reject-modal-buttons {
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid var(--card-header-border);
}

.reject-modal-buttons .btn {
    min-width: 110px;
    padding: 10px 20px;
    box-shadow: none;
}

.reject-modal-buttons .btn::before {
    display: none;
}

.reject-modal-content .error-message {
    margin-top: 14px;
}

.confirm-modal-content {
    max-width: 440px;
    width: min(92vw, 440px);
    padding: 28px 28px 24px;
    overflow: hidden;
    border-radius: 16px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45);
    position: relative;
}

.confirm-modal-content::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    border-radius: 16px 16px 0 0;
    background: linear-gradient(90deg, var(--primary-color) 0%, var(--primary-hover) 100%);
}

.confirm-modal-content.confirm-modal-danger::before {
    background: linear-gradient(90deg, #f56565 0%, #e53e3e 100%);
}

.confirm-modal-content h2 {
    margin: 0 0 12px;
    font-size: 1.35rem;
}

.confirm-modal-message {
    margin: 0;
    color: var(--paragraph-color);
    font-size: 0.95em;
    line-height: 1.55;
    white-space: pre-line;
}

.confirm-modal-checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 18px;
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid var(--card-header-border);
    background: var(--card-bg);
    cursor: pointer;
    user-select: none;
}

.confirm-modal-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin: 0;
    accent-color: var(--primary-color);
    cursor: pointer;
    flex-shrink: 0;
}

.confirm-modal-content.confirm-modal-danger .confirm-modal-checkbox input[type="checkbox"] {
    accent-color: #e53e3e;
}

.confirm-modal-checkbox span {
    color: var(--heading-color);
    font-size: 0.95em;
    line-height: 1.4;
}

.confirm-modal-buttons {
    margin-top: 22px;
    padding-top: 18px;
    border-top: 1px solid var(--card-header-border);
}

.confirm-modal-buttons .btn {
    min-width: 110px;
    padding: 10px 20px;
    box-shadow: none;
}

.confirm-modal-buttons .btn::before {
    display: none;
}

/* Form Elements */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    color: var(--text-color);
    font-weight: 500;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--card-header-border);
    border-radius: var(--border-radius);
    background: var(--card-bg);
    color: var(--text-color);
    font-size: 1em;
    font-family: inherit;
    box-sizing: border-box;
    transition: var(--transition);
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
    transform: translateY(-1px);
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: var(--border-radius);
    font-size: 0.95em;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn:hover::before {
    width: 300px;
    height: 300px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-hover) 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: var(--card-header-border);
    color: var(--text-color);
}

.btn-secondary:hover {
    background: #cbd5e0;
    transform: translateY(-2px);
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger-color) 0%, #e53e3e 100%);
    color: white;
}

.btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(245, 101, 101, 0.4);
}

/* Admin Actions */
.admin-actions {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px dashed var(--card-header-border);
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.btn-action {
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    font-size: 0.85em;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-status {
    background: linear-gradient(135deg, #4299e1 0%, #3182ce 100%);
    color: white;
    box-shadow: 0 2px 6px rgba(66, 153, 225, 0.3);
}

.btn-status:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(66, 153, 225, 0.4);
}

.btn-reject {
    background: linear-gradient(135deg, var(--danger-color) 0%, #e53e3e 100%);
    color: white;
    box-shadow: 0 2px 6px rgba(245, 101, 101, 0.3);
}

.btn-reject:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(245, 101, 101, 0.4);
}

.btn-archive {
    background: linear-gradient(135deg, #718096 0%, #4a5568 100%);
    color: white;
    box-shadow: 0 2px 6px rgba(113, 128, 150, 0.3);
}

.btn-archive:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(113, 128, 150, 0.4);
}

.btn-unarchive {
    background: linear-gradient(135deg, var(--warning-color) 0%, #dd6b20 100%);
    color: white;
    box-shadow: 0 2px 6px rgba(237, 137, 54, 0.3);
}

.btn-unarchive:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(237, 137, 54, 0.4);
}

/* Error Message */
.error-message {
    color: var(--error-color);
    background: var(--error-bg);
    padding: 10px;
    border-radius: 6px;
    margin-top: 10px;
    font-size: 0.9em;
}

/* Auth Tabs */
.auth-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--card-header-border);
}

.auth-tab-btn {
    padding: 10px 20px;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    color: var(--text-color);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.auth-tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.auth-form {
    display: block;
}

/* Стили для шагов авторизации */
#login-step-1,
#login-step-2 {
    display: block;
}

#login-step-2 {
    display: none; /* Скрыт по умолчанию, показывается после запроса кода */
}

.form-control {
    width: 100%;
    padding: 10px;
    border: 2px solid var(--card-header-border);
    border-radius: var(--border-radius);
    background: var(--card-bg);
    color: var(--text-color);
    font-size: 1em;
    font-family: inherit;
    box-sizing: border-box;
}

/* Tab Count */
.tab-count {
    background: var(--primary-color);
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.85em;
    font-weight: 700;
    margin-left: 5px;
}

/* Logs */
.logs-container {
    margin-top: 20px;
    max-height: 400px;
    overflow-y: auto;
}

.logs-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.log-entry {
    padding: 12px;
    background: var(--card-bg);
    border-radius: var(--border-radius);
    border-left: 4px solid var(--primary-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.log-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-weight: 600;
}

.log-time {
    font-size: 0.85em;
    color: var(--paragraph-color);
    font-weight: normal;
}

.log-comment {
    margin-top: 8px;
    padding: 8px;
    background: rgba(102, 126, 234, 0.1);
    border-radius: 6px;
    font-style: italic;
}

.btn-info {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 2px 6px rgba(102, 126, 234, 0.3);
}

.btn-info:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(102, 126, 234, 0.4);
}

.users-modal-content {
    max-width: min(98vw, 1180px);
    width: min(98vw, 1180px);
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding: 24px 28px;
}

.users-modal-content h2,
.users-modal-hint,
.users-filter-tabs,
.users-modal-content .modal-buttons {
    flex-shrink: 0;
}

.users-modal-hint {
    margin-top: -8px;
    margin-bottom: 16px;
    color: var(--paragraph-color);
}

.users-filter-tabs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.users-filter-btn {
    padding: 8px 14px;
    border: 1px solid var(--card-header-border);
    border-radius: 999px;
    background: transparent;
    color: var(--text-color);
    cursor: pointer;
    font-weight: 600;
    transition: var(--transition);
}

.users-filter-btn:hover,
.users-filter-btn.active {
    background: rgba(102, 126, 234, 0.15);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.users-list {
    flex: 1 1 auto;
    min-height: 0;
    margin-bottom: 12px;
    overflow: hidden;
}

.users-loading,
.users-empty {
    text-align: center;
    color: var(--paragraph-color);
    padding: 24px 12px;
}

.users-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.users-table th,
.users-table td {
    padding: 10px 8px;
    border-bottom: 1px solid var(--card-header-border);
    text-align: left;
    vertical-align: middle;
    overflow: hidden;
}

.users-table th {
    color: var(--paragraph-color);
    font-size: 0.85em;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.users-table .col-name {
    width: 18%;
}

.users-table .col-phone {
    width: 13%;
    text-align: center;
}

.users-table .col-max-id {
    width: 10%;
    text-align: center;
}

.users-table .col-role {
    width: 11%;
    text-align: center;
}

.users-table .col-requests {
    width: 8%;
    text-align: center;
}

.users-table .col-actions {
    width: 40%;
}

.user-actions {
    display: flex;
    flex-wrap: nowrap;
    gap: 6px;
    align-items: center;
    justify-content: flex-start;
}

.user-role-select {
    flex: 1 1 auto;
    width: auto;
    min-width: 10em;
    max-width: none;
    padding: 8px 2rem 8px 10px;
    display: inline-block;
    margin: 0;
    font-size: 0.88em;
}

.users-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 12px;
}

.users-page-info {
    color: var(--paragraph-color);
    font-size: 0.9em;
    font-weight: 600;
    white-space: nowrap;
}

.users-page-btn {
    padding: 8px 14px;
    font-size: 0.85em;
    min-height: auto;
}

.users-page-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
}

.btn-save-role,
.btn-delete-user {
    padding: 8px 10px;
    font-size: 0.85em;
    white-space: nowrap;
    flex-shrink: 0;
}

.user-name-cell {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    min-width: 0;
}

.user-name-text {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-edit-name {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 0.95em;
    line-height: 1;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    opacity: 0.75;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.btn-edit-name:hover {
    opacity: 1;
    transform: scale(1.08);
}

.btn-icon-delete {
    width: 34px;
    height: 34px;
    min-width: 34px;
    flex-shrink: 0;
    padding: 0;
    border: none;
    border-radius: 6px;
    background: #dc3545;
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    line-height: 1;
    transition: background 0.2s ease, transform 0.2s ease;
}

.btn-icon-delete:hover {
    background: #c82333;
    transform: scale(1.04);
}

.admin-bot-settings {
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color, rgba(0, 0, 0, 0.1));
}

.admin-bot-settings h3 {
    margin: 0 0 12px;
    font-size: 1.05rem;
}

.maintenance-toggle .toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.toggle-label-text {
    font-weight: 600;
    color: var(--heading-color);
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: var(--card-header-border);
    border-radius: 999px;
    transition: var(--transition);
}

.toggle-slider::before {
    content: "";
    position: absolute;
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background: #fff;
    border-radius: 50%;
    transition: var(--transition);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--primary-color);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(22px);
}

.toggle-switch input:focus-visible + .toggle-slider {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.maintenance-admin-banner {
    margin-bottom: 16px;
    padding: 12px 16px;
    border-radius: 12px;
    background: rgba(237, 137, 54, 0.18);
    border: 1px solid rgba(237, 137, 54, 0.45);
    color: var(--warning-color);
    font-weight: 600;
}

.maintenance-overlay {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 320px;
    margin-bottom: 16px;
    padding: 24px;
    border-radius: 16px;
    background: rgba(0, 0, 0, 0.08);
    border: 1px dashed var(--card-header-border);
}

.maintenance-card {
    max-width: 520px;
    text-align: center;
    padding: 28px 24px;
    border-radius: 16px;
    background: var(--card-bg);
    box-shadow: var(--card-shadow);
    border: 1px solid var(--card-header-border);
}

.maintenance-card h2 {
    margin: 0 0 12px;
    color: var(--heading-color);
}

.maintenance-card p {
    margin: 0;
    color: var(--paragraph-color);
    line-height: 1.6;
}

.role-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.85em;
    font-weight: 700;
}

.role-admin {
    background: rgba(102, 126, 234, 0.18);
    color: var(--primary-color);
}

.role-operator {
    background: rgba(49, 130, 206, 0.18);
    color: #2b6cb0;
}

.role-user {
    background: rgba(72, 187, 120, 0.18);
    color: var(--success-color);
}

.role-pending {
    background: rgba(237, 137, 54, 0.18);
    color: var(--warning-color);
}

@media (max-width: 768px) {
    .users-modal-content {
        width: 96vw;
        max-width: 96vw;
        padding: 18px 16px;
    }

    .users-table .col-actions {
        width: 42%;
    }

    .user-actions {
        flex-wrap: wrap;
    }

    .user-role-select {
        width: 100%;
        flex: 1 1 100%;
    }
}