/* Сине-белая цветовая схема для RestasystemSyrveBot */

:root {
    --blue-primary: #2563EB;
    --blue-dark: #1E40AF;
    --blue-light: #3B82F6;
    --white: #FFFFFF;
    --gray-bg: #F8FAFC;
    --gray-text: #1F2937;
    --gray-border: #E5E7EB;
    --success: #10B981;
    --error: #EF4444;
    --warning: #F59E0B;
}

/* Темная тема */
[data-theme="dark"] {
    --blue-primary: #3B82F6;
    --blue-dark: #2563EB;
    --blue-light: #60A5FA;
    --white: #1F2937;
    --gray-bg: #111827;
    --gray-text: #F9FAFB;
    --gray-border: #374151;
    --success: #10B981;
    --error: #EF4444;
    --warning: #F59E0B;
}

[data-theme="dark"] body {
    background-color: var(--gray-bg);
    color: var(--gray-text);
}

[data-theme="dark"] .header {
    background: linear-gradient(135deg, #1E3A8A 0%, #1E40AF 100%);
}

[data-theme="dark"] .card,
[data-theme="dark"] .stat-card,
[data-theme="dark"] .report-card {
    background: #1F2937;
    border-color: var(--gray-border);
    color: var(--gray-text);
}

[data-theme="dark"] .form-input,
[data-theme="dark"] select.form-input,
[data-theme="dark"] input[type="text"],
[data-theme="dark"] input[type="number"],
[data-theme="dark"] textarea {
    background: #374151;
    border-color: var(--gray-border);
    color: var(--gray-text);
}

[data-theme="dark"] table {
    background: #1F2937;
    color: var(--gray-text);
}

[data-theme="dark"] table th {
    background: #374151;
    color: var(--gray-text);
}

[data-theme="dark"] table tr {
    border-color: var(--gray-border);
}

[data-theme="dark"] .modal-content {
    background: #1F2937;
    color: var(--gray-text);
}

[data-theme="dark"] .admin-section {
    background: #1F2937;
    border-color: var(--gray-border);
}

[data-theme="dark"] .status-message {
    background: #374151;
    border-color: var(--gray-border);
    color: var(--gray-text);
}

[data-theme="dark"] .status-success {
    background: #064E3B;
    border-color: #10B981;
    color: #D1FAE5;
}

[data-theme="dark"] .status-error {
    background: #7F1D1D;
    border-color: #EF4444;
    color: #FEE2E2;
}

[data-theme="dark"] .status-info {
    background: #1E3A8A;
    border-color: #3B82F6;
    color: #DBEAFE;
}

[data-theme="dark"] .info-box,
[data-theme="dark"] .connection-prompt {
    background: #1F2937;
    border-color: var(--gray-border);
    color: var(--gray-text);
}

[data-theme="dark"] .footer {
    background: #111827;
    color: var(--gray-text);
    border-top: 1px solid var(--gray-border);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--gray-bg);
    color: var(--gray-text);
    line-height: 1.6;
}

.container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    background: linear-gradient(135deg, var(--blue-primary) 0%, var(--blue-dark) 100%);
    color: var(--white);
    padding: 1rem 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: nowrap;
    position: relative;
    gap: 1rem;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
}

.nav {
    display: flex;
    gap: 1.5rem;
    flex-wrap: nowrap;
    align-items: center;
}

.nav-link {
    color: var(--white);
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    transition: background-color 0.2s;
}

.nav-link:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* Кнопки выбора языка */
.language-buttons {
    display: flex;
    gap: 0.25rem;
    align-items: center;
}

.lang-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 0.375rem;
    color: var(--white);
    padding: 0.5rem;
    font-size: 1.25rem;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 36px;
    min-height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.lang-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.lang-btn.active {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.4);
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.3);
}

[data-theme="dark"] .lang-btn {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

[data-theme="dark"] .lang-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

[data-theme="dark"] .lang-btn.active {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
}

/* Переключатель темы */
.theme-toggle {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 0.375rem;
    color: var(--white);
    padding: 0.5rem;
    font-size: 1.25rem;
    cursor: pointer;
    transition: background-color 0.2s;
    min-width: 36px;
    min-height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-toggle:hover {
    background: rgba(255, 255, 255, 0.15);
}

.theme-icon {
    display: inline-block;
    transition: transform 0.3s;
    font-size: 1.25rem;
    line-height: 1;
}

/* Main Content */
.main-content {
    flex: 1;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 2rem;
}

.page-header {
    text-align: center;
    margin-bottom: 3rem;
}

.page-header h2 {
    color: var(--blue-dark);
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.subtitle {
    color: var(--gray-text);
    font-size: 1.1rem;
}

/* Cards Grid */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

.card {
    background: var(--white);
    border-radius: 0.5rem;
    padding: 2rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s, box-shadow 0.2s;
    text-align: center;
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

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

.card h3 {
    color: var(--blue-dark);
    margin-bottom: 1rem;
    font-size: 1.25rem;
}

.card p {
    color: var(--gray-text);
    margin-bottom: 1.5rem;
}

/* Buttons */
.btn-primary {
    display: inline-block;
    background-color: var(--blue-primary);
    color: var(--white);
    padding: 0.75rem 1.5rem;
    border-radius: 0.375rem;
    text-decoration: none;
    font-weight: 500;
    transition: background-color 0.2s;
    border: none;
    cursor: pointer;
}

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

.btn-secondary {
    background-color: var(--white);
    color: var(--blue-primary);
    padding: 0.5rem 1rem;
    border: 1px solid var(--blue-primary);
    border-radius: 0.375rem;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
}

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

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--gray-text);
    font-weight: 500;
}

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

.form-input:focus {
    outline: none;
    border-color: var(--blue-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Footer */
.footer {
    background-color: var(--white);
    border-top: 1px solid var(--gray-border);
    padding: 1.5rem;
    text-align: center;
    color: var(--gray-text);
    margin-top: auto;
}

/* Connection Info */
.connection-info {
    margin-bottom: 2rem;
}

.info-card {
    background: var(--white);
    border-radius: 0.5rem;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    margin-bottom: 1rem;
}

.info-card-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.info-card-header h3 {
    margin: 0;
    color: var(--blue-dark);
}

.status-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
}

.status-indicator.status-active {
    background-color: var(--success);
}

.status-indicator.status-inactive {
    background-color: var(--gray-border);
}

.info-card-content {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.info-card-content p {
    margin: 0;
    color: var(--gray-text);
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.info-card-content p strong {
    min-width: fit-content;
}

/* Горизонтальное отображение на больших экранах */
@media (min-width: 768px) {
    .info-card-content p {
        flex-direction: row;
        align-items: baseline;
    }
    
    .info-card-content p strong {
        margin-right: 0.5rem;
        white-space: nowrap;
    }
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.btn-large {
    padding: 1rem 2rem;
    font-size: 1.125rem;
}

/* Connection Prompt */
.connection-prompt {
    text-align: center;
    max-width: 600px;
    margin: 0 auto;
}

.info-box {
    background: var(--white);
    border-radius: 0.5rem;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    text-align: left;
}

.info-box ul {
    margin: 1rem 0;
    padding-left: 1.5rem;
}

.info-box li {
    margin: 0.5rem 0;
}

/* Connection Form */
.connection-form-container {
    max-width: 600px;
    margin: 0 auto;
}

.connection-form {
    background: var(--white);
    border-radius: 0.5rem;
    padding: 2rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.form-hint {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.875rem;
    color: var(--gray-text);
    opacity: 0.7;
}

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
}

/* Status Messages */
.status-message {
    padding: 1rem;
    border-radius: 0.375rem;
    margin: 1rem 0;
    text-align: center;
}

.status-message.status-info {
    background-color: rgba(37, 99, 235, 0.1);
    color: var(--blue-dark);
    border: 1px solid var(--blue-primary);
}

.status-message.status-success {
    background-color: rgba(16, 185, 129, 0.1);
    color: #065f46;
    border: 1px solid var(--success);
}

.status-message.status-error {
    background-color: rgba(239, 68, 68, 0.1);
    color: #991b1b;
    border: 1px solid var(--error);
}

/* Auth Container */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
}

.auth-card {
    background: var(--white);
    border-radius: 0.5rem;
    padding: 2rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    max-width: 500px;
    text-align: center;
}

.auth-card h2 {
    color: var(--blue-dark);
    margin-bottom: 1rem;
}

.auth-card ul {
    text-align: left;
    margin: 1rem 0;
    padding-left: 1.5rem;
}

/* Loading Spinner */
.loading-spinner {
    border: 3px solid rgba(37, 99, 235, 0.1);
    border-top: 3px solid var(--blue-primary);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 2rem auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Servers */
.servers-container {
    max-width: 900px;
    margin: 0 auto;
}

.servers-list {
    margin-bottom: 2rem;
}

.server-card {
    background: var(--white);
    border-radius: 0.5rem;
    padding: 1.5rem;
    margin-bottom: 1rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border: 2px solid transparent;
    transition: all 0.2s;
}

.server-card.server-active {
    border-color: var(--blue-primary);
    background: linear-gradient(to right, rgba(37, 99, 235, 0.05), var(--white));
}

.server-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.server-card-header > div {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.server-card-header h3 {
    margin: 0;
    color: var(--blue-dark);
}

.badge {
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 500;
}

.badge-success {
    background-color: rgba(16, 185, 129, 0.1);
    color: #065f46;
}

.server-card-content p {
    margin: 0.5rem 0;
    color: var(--gray-text);
}

.server-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

.btn-danger {
    background-color: var(--error);
    color: var(--white);
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    border: none;
    cursor: pointer;
    font-weight: 500;
    transition: background-color 0.2s;
}

.btn-danger:hover {
    background-color: #dc2626;
}

.add-server-section {
    text-align: center;
    margin: 2rem 0;
}

/* Admin Panel */
.admin-tabs {
    display: flex;
    gap: 0.5rem;
    margin: 2rem 0;
    border-bottom: 2px solid var(--gray-border);
}

.admin-tabs .tab-btn {
    padding: 0.75rem 1.5rem;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-weight: 500;
    color: var(--gray-text);
    transition: all 0.2s;
}

.admin-tabs .tab-btn:hover {
    color: var(--blue-primary);
}

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

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.admin-section {
    background: var(--white);
    border-radius: 0.5rem;
    padding: 2rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    margin-bottom: 2rem;
}

.admin-section h3 {
    color: var(--blue-dark);
    margin-bottom: 1.5rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--white);
    border-radius: 0.5rem;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.stat-icon {
    font-size: 2.5rem;
}

.stat-content h3 {
    margin: 0;
    font-size: 2rem;
    color: var(--blue-dark);
}

.stat-content p {
    margin: 0.25rem 0 0 0;
    color: var(--gray-text);
    font-size: 0.875rem;
}

.users-table, .licenses-table {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
    table-layout: auto;
}

table thead {
    background: var(--gray-bg);
}

table th, table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--gray-border);
}

table th {
    font-weight: 600;
    color: var(--blue-dark);
}

table tr:hover {
    background: var(--gray-bg);
}

/* Горизонтальное отображение значений в таблицах на больших экранах */
@media (min-width: 768px) {
    /* Для таблиц с данными - предпочитаем горизонтальное отображение */
    .data-table,
    .report-table,
    .references-table table {
        table-layout: fixed;
    }
    
    .data-table th,
    .data-table td,
    .report-table th,
    .report-table td,
    .references-table table th,
    .references-table table td {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    /* Для таблиц с действиями - разрешаем перенос только для длинных текстов */
    .actions-cell {
        white-space: nowrap;
    }
    
    /* Для обычных таблиц - разрешаем перенос для длинных текстов */
    table:not(.data-table):not(.report-table) th,
    table:not(.data-table):not(.report-table) td {
        white-space: normal;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    overflow: auto;
}

.modal-content {
    background-color: var(--white);
    margin: 5% auto;
    padding: 2rem;
    border-radius: 0.5rem;
    width: 90%;
    max-width: 600px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    position: relative;
}

.close {
    color: var(--gray-text);
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    position: absolute;
    right: 1rem;
    top: 1rem;
}

.close:hover {
    color: var(--blue-primary);
}

.error {
    color: var(--error);
}

/* Mobile Menu Toggle */
.mobile-menu-toggle {
    display: none;
    flex-direction: column;
    justify-content: space-around;
    width: 30px;
    height: 30px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 1001;
    min-width: 44px;
    min-height: 44px;
    align-items: center;
}

.mobile-menu-toggle span {
    width: 24px;
    height: 3px;
    background-color: var(--white);
    border-radius: 3px;
    transition: all 0.3s;
    display: block;
}

.mobile-menu-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(8px, 8px);
}

.mobile-menu-toggle.active span:nth-child(2) {
    opacity: 0;
}

.mobile-menu-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -7px);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.username-text {
    display: inline-block;
}

/* Responsive - Mobile First Approach */

/* Extra Small devices (phones, 320px and up) */
@media (max-width: 480px) {
    .header {
        padding: 0.75rem 0;
    }
    
    .header-content {
        padding: 0 1rem;
        flex-wrap: wrap;
    }
    
    .logo {
        font-size: 1.25rem;
    }
    
    .mobile-menu-toggle {
        display: flex;
    }
    
    .nav {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--blue-dark);
        flex-direction: column;
        padding: 1rem;
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
        z-index: 1000;
    }
    
    .nav.active {
        display: flex;
    }
    
    .nav-link {
        padding: 0.75rem 1rem;
        width: 100%;
        text-align: left;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }
    
    .nav-link:last-child {
        border-bottom: none;
    }
    
    .user-menu {
        width: 100%;
        justify-content: space-between;
        margin-top: 0.5rem;
        padding-top: 0.5rem;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
    }
    
    .username-text {
        font-size: 0.875rem;
    }
    
    .btn-mobile {
        padding: 0.5rem 1rem;
        font-size: 0.875rem;
    }
    
    .main-content {
        padding: 1rem;
    }
    
    .page-header h2 {
        font-size: 1.5rem;
    }
    
    .subtitle {
        font-size: 1rem;
    }
    
    .cards-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .card {
        padding: 1.5rem;
    }
    
    .card-icon {
        font-size: 2.5rem;
    }
    
    .card h3 {
        font-size: 1.125rem;
    }
    
    .btn-primary, .btn-secondary {
        width: 100%;
        padding: 0.875rem 1.5rem;
        font-size: 1rem;
    }
    
    .form-actions {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .form-actions button {
        width: 100%;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .stat-card {
        padding: 1rem;
    }
    
    .stat-icon {
        font-size: 2rem;
    }
    
    .stat-content h3 {
        font-size: 1.5rem;
    }
    
    .admin-tabs {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .admin-tabs .tab-btn {
        width: 100%;
        text-align: center;
        padding: 0.875rem 1rem;
    }
    
    .admin-section {
        padding: 1rem;
    }
    
    table {
        font-size: 0.75rem;
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    table thead {
        display: none;
    }
    
    table tbody {
        display: block;
    }
    
    table tr {
        display: block;
        margin-bottom: 1rem;
        border: 1px solid var(--gray-border);
        border-radius: 0.5rem;
        padding: 0.75rem;
        background: var(--white);
    }
    
    table td {
        display: block;
        text-align: right;
        padding: 0.5rem 0;
        border: none;
    }
    
    table td:before {
        content: attr(data-label);
        float: left;
        font-weight: 600;
        color: var(--blue-dark);
    }
    
    .modal-content {
        width: 95%;
        margin: 5% auto;
        padding: 1rem;
        max-height: 90vh;
        overflow-y: auto;
    }
    
    .server-card {
        padding: 1rem;
    }
    
    .server-actions {
        flex-direction: column;
    }
    
    .server-actions button {
        width: 100%;
    }
    
    .info-card {
        padding: 1rem;
    }
    
    .connection-form {
        padding: 1.5rem;
    }
    
    .auth-card {
        padding: 1.5rem;
        margin: 1rem;
    }
    
    .footer {
        padding: 1rem;
        font-size: 0.875rem;
    }
}

/* Small devices (landscape phones, 481px and up) */
@media (min-width: 481px) and (max-width: 768px) {
    .header-content {
        padding: 0 1.5rem;
    }
    
    .mobile-menu-toggle {
        display: flex;
    }
    
    .nav {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--blue-dark);
        flex-direction: column;
        padding: 1rem 1.5rem;
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
        z-index: 1000;
    }
    
    .nav.active {
        display: flex;
    }
    
    .nav-link {
        padding: 0.75rem 1rem;
        width: 100%;
        text-align: left;
    }
    
    .main-content {
        padding: 1.5rem;
    }
    
    .cards-grid {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
        gap: 1.5rem;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
    
    .admin-tabs {
        flex-wrap: wrap;
    }
    
    .admin-tabs .tab-btn {
        flex: 1 1 auto;
        min-width: 120px;
    }
    
    table {
        font-size: 0.875rem;
    }
    
    .modal-content {
        width: 90%;
        margin: 10% auto;
        padding: 1.5rem;
    }
    
    .form-actions {
        flex-direction: row;
    }
    
    .form-actions button {
        flex: 1;
    }
}

/* Medium devices (tablets, 769px and up) */
@media (min-width: 769px) and (max-width: 1024px) {
    .header-content {
        padding: 0 2rem;
    }
    
    .main-content {
        padding: 2rem;
    }
    
    .cards-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .admin-tabs .tab-btn {
        padding: 0.75rem 1.25rem;
        font-size: 0.9rem;
    }
}

/* Large devices (desktops, 1025px and up) */
@media (min-width: 1025px) {
    .header-content {
        padding: 0 2rem;
        flex-wrap: nowrap;
    }
    
    .nav {
        display: flex !important;
        flex-wrap: nowrap;
        gap: 1.5rem;
        position: static;
        background: transparent;
        box-shadow: none;
    }
    
    .mobile-menu-toggle {
        display: none !important;
    }
    
    .main-content {
        padding: 2rem;
    }
    
    .cards-grid {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    }
    
    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    }
}

/* Touch-friendly improvements for all mobile devices */
@media (hover: none) and (pointer: coarse) {
    .btn-primary, .btn-secondary, .btn-danger, .btn-small {
        min-height: 44px; /* Apple's recommended touch target size */
        min-width: 44px;
    }
    
    .nav-link {
        min-height: 44px;
        display: flex;
        align-items: center;
    }
    
    .form-input, select.form-input {
        min-height: 44px;
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    .card {
        cursor: pointer;
    }
    
    .tab-btn {
        min-height: 44px;
    }
}

/* Landscape orientation optimizations */
@media (max-width: 768px) and (orientation: landscape) {
    .header {
        padding: 0.5rem 0;
    }
    
    .logo {
        font-size: 1.125rem;
    }
    
    .main-content {
        padding: 1rem;
    }
    
    .page-header {
        margin-bottom: 1.5rem;
    }
    
    .page-header h2 {
        font-size: 1.25rem;
    }
}

/* Print styles */
@media print {
    .header, .footer, .nav, .user-menu, .mobile-menu-toggle {
        display: none;
    }
    
    .main-content {
        padding: 0;
    }
}

/* References */
.references-table {
    overflow-x: auto;
    margin-top: 1rem;
}

.search-box {
    margin-bottom: 1rem;
}

.text-muted {
    color: var(--gray-text);
    opacity: 0.7;
    font-size: 0.875rem;
    margin-top: 1rem;
}

code {
    background: var(--gray-bg);
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
}


        background: var(--blue-dark);
        flex-direction: column;
        padding: 1rem;
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
        z-index: 1000;
    }
    
    .nav.active {
        display: flex;
    }
    
    .nav-link {
        padding: 0.75rem 1rem;
        width: 100%;
        text-align: left;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }
    
    .nav-link:last-child {
        border-bottom: none;
    }
    
    .user-menu {
        width: 100%;
        justify-content: space-between;
        margin-top: 0.5rem;
        padding-top: 0.5rem;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
    }
    
    .username-text {
        font-size: 0.875rem;
    }
    
    .btn-mobile {
        padding: 0.5rem 1rem;
        font-size: 0.875rem;
    }
    
    .main-content {
        padding: 1rem;
    }
    
    .page-header h2 {
        font-size: 1.5rem;
    }
    
    .subtitle {
        font-size: 1rem;
    }
    
    .cards-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .card {
        padding: 1.5rem;
    }
    
    .card-icon {
        font-size: 2.5rem;
    }
    
    .card h3 {
        font-size: 1.125rem;
    }
    
    .btn-primary, .btn-secondary {
        width: 100%;
        padding: 0.875rem 1.5rem;
        font-size: 1rem;
    }
    
    .form-actions {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .form-actions button {
        width: 100%;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .stat-card {
        padding: 1rem;
    }
    
    .stat-icon {
        font-size: 2rem;
    }
    
    .stat-content h3 {
        font-size: 1.5rem;
    }
    
    .admin-tabs {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .admin-tabs .tab-btn {
        width: 100%;
        text-align: center;
        padding: 0.875rem 1rem;
    }
    
    .admin-section {
        padding: 1rem;
    }
    
    table {
        font-size: 0.75rem;
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    table thead {
        display: none;
    }
    
    table tbody {
        display: block;
    }
    
    table tr {
        display: block;
        margin-bottom: 1rem;
        border: 1px solid var(--gray-border);
        border-radius: 0.5rem;
        padding: 0.75rem;
        background: var(--white);
    }
    
    table td {
        display: block;
        text-align: right;
        padding: 0.5rem 0;
        border: none;
    }
    
    table td:before {
        content: attr(data-label);
        float: left;
        font-weight: 600;
        color: var(--blue-dark);
    }
    
    .modal-content {
        width: 95%;
        margin: 5% auto;
        padding: 1rem;
        max-height: 90vh;
        overflow-y: auto;
    }
    
    .server-card {
        padding: 1rem;
    }
    
    .server-actions {
        flex-direction: column;
    }
    
    .server-actions button {
        width: 100%;
    }
    
    .info-card {
        padding: 1rem;
    }
    
    .connection-form {
        padding: 1.5rem;
    }
    
    .auth-card {
        padding: 1.5rem;
        margin: 1rem;
    }
    
    .footer {
        padding: 1rem;
        font-size: 0.875rem;
    }
}

/* Small devices (landscape phones, 481px and up) */
@media (min-width: 481px) and (max-width: 768px) {
    .header-content {
        padding: 0 1.5rem;
    }
    
    .mobile-menu-toggle {
        display: flex;
    }
    
    .nav {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--blue-dark);
        flex-direction: column;
        padding: 1rem 1.5rem;
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
        z-index: 1000;
    }
    
    .nav.active {
        display: flex;
    }
    
    .nav-link {
        padding: 0.75rem 1rem;
        width: 100%;
        text-align: left;
    }
    
    .main-content {
        padding: 1.5rem;
    }
    
    .cards-grid {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
        gap: 1.5rem;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
    
    .admin-tabs {
        flex-wrap: wrap;
    }
    
    .admin-tabs .tab-btn {
        flex: 1 1 auto;
        min-width: 120px;
    }
    
    table {
        font-size: 0.875rem;
    }
    
    .modal-content {
        width: 90%;
        margin: 10% auto;
        padding: 1.5rem;
    }
    
    .form-actions {
        flex-direction: row;
    }
    
    .form-actions button {
        flex: 1;
    }
}

/* Medium devices (tablets, 769px and up) */
@media (min-width: 769px) and (max-width: 1024px) {
    .header-content {
        padding: 0 2rem;
    }
    
    .main-content {
        padding: 2rem;
    }
    
    .cards-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .admin-tabs .tab-btn {
        padding: 0.75rem 1.25rem;
        font-size: 0.9rem;
    }
}

/* Large devices (desktops, 1025px and up) */
@media (min-width: 1025px) {
    .header-content {
        padding: 0 2rem;
        flex-wrap: nowrap;
    }
    
    .nav {
        display: flex !important;
        flex-wrap: nowrap;
        gap: 1.5rem;
        position: static;
        background: transparent;
        box-shadow: none;
    }
    
    .mobile-menu-toggle {
        display: none !important;
    }
    
    .main-content {
        padding: 2rem;
    }
    
    .cards-grid {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    }
    
    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    }
}

/* Touch-friendly improvements for all mobile devices */
@media (hover: none) and (pointer: coarse) {
    .btn-primary, .btn-secondary, .btn-danger, .btn-small {
        min-height: 44px; /* Apple's recommended touch target size */
        min-width: 44px;
    }
    
    .nav-link {
        min-height: 44px;
        display: flex;
        align-items: center;
    }
    
    .form-input, select.form-input {
        min-height: 44px;
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    .card {
        cursor: pointer;
    }
    
    .tab-btn {
        min-height: 44px;
    }
}

/* Landscape orientation optimizations */
@media (max-width: 768px) and (orientation: landscape) {
    .header {
        padding: 0.5rem 0;
    }
    
    .logo {
        font-size: 1.125rem;
    }
    
    .main-content {
        padding: 1rem;
    }
    
    .page-header {
        margin-bottom: 1.5rem;
    }
    
    .page-header h2 {
        font-size: 1.25rem;
    }
}

/* Print styles */
@media print {
    .header, .footer, .nav, .user-menu, .mobile-menu-toggle {
        display: none;
    }
    
    .main-content {
        padding: 0;
    }
}

/* References */
.references-table {
    overflow-x: auto;
    margin-top: 1rem;
}

.search-box {
    margin-bottom: 1rem;
}

.text-muted {
    color: var(--gray-text);
    opacity: 0.7;
    font-size: 0.875rem;
    margin-top: 1rem;
}

code {
    background: var(--gray-bg);
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
}


/* Admin Panel Styles */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.filters-bar {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    align-items: flex-end;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-width: 150px;
    flex: 1;
}

.filter-group label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray-text);
}

.form-input-small {
    padding: 0.5rem;
    font-size: 0.875rem;
}

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.actions-cell {
    white-space: nowrap;
}

.actions-cell button {
    margin-right: 0.25rem;
    margin-bottom: 0.25rem;
}

.btn-danger {
    background-color: var(--error);
    color: var(--white);
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 0.375rem;
    cursor: pointer;
    font-weight: 500;
    transition: background-color 0.2s;
}

.btn-danger:hover {
    background-color: #DC2626;
}

.btn-small {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
}

.license-details {
    display: grid;
    gap: 0.75rem;
}

.license-details p {
    margin: 0;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--gray-border);
}

.license-details p:last-child {
    border-bottom: none;
}

.license-details strong {
    color: var(--blue-dark);
    display: inline-block;
    min-width: 120px;
}

.loading-spinner {
    text-align: center;
    padding: 2rem;
    color: var(--gray-text);
}

/* Mobile optimizations for admin panel */
@media (max-width: 768px) {
    .section-header {
        flex-direction: column;
        align-items: stretch;
    }
    
    .section-header button {
        width: 100%;
    }
    
    .filters-bar {
        flex-direction: column;
    }
    
    .filter-group {
        min-width: 100%;
    }
    
    .table-responsive {
        margin: 0 -2rem;
        padding: 0 2rem;
    }
    
    table {
        font-size: 0.875rem;
    }
    
    table th, table td {
        padding: 0.5rem;
    }
    
    .actions-cell {
        display: flex;
        flex-direction: column;
        gap: 0.25rem;
    }
    
    .actions-cell button {
        width: 100%;
        margin-right: 0;
    }
    
    .modal-content {
        width: 95%;
        margin: 10% auto;
        padding: 1.5rem;
        max-height: 90vh;
        overflow-y: auto;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .stat-card {
        padding: 1rem;
    }
    
    .stat-icon {
        font-size: 2rem;
    }
    
    .stat-content h3 {
        font-size: 1.5rem;
    }
}

@media (max-width: 480px) {
    .admin-section {
        padding: 1rem;
    }
    
    .admin-section h3 {
        font-size: 1.25rem;
    }
    
    .admin-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    
    .admin-tabs::-webkit-scrollbar {
        display: none;
    }
    
    .admin-tabs .tab-btn {
        white-space: nowrap;
        padding: 0.75rem 1rem;
    }
    
    table {
        font-size: 0.75rem;
    }
    
    table th, table td {
        padding: 0.375rem;
    }
    
    .modal-content {
        width: 100%;
        margin: 0;
        border-radius: 0;
        padding: 1rem;
        max-height: 100vh;
    }
    
    .license-details strong {
        min-width: 100px;
        font-size: 0.875rem;
    }
}

/* Tablet optimizations */
@media (min-width: 481px) and (max-width: 1024px) {
    .filters-bar {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .table-responsive {
        margin: 0 -1rem;
        padding: 0 1rem;
    }
    
    .actions-cell {
        display: flex;
        flex-wrap: wrap;
        gap: 0.25rem;
    }
    
    .actions-cell button {
        flex: 1;
        min-width: calc(50% - 0.125rem);
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .actions-cell button {
        min-height: 44px;
        min-width: 44px;
    }
    
    .filter-group select,
    .filter-group input {
        min-height: 44px;
        font-size: 16px;
    }
    
    .tab-btn {
        min-height: 44px;
        padding: 0.75rem 1rem;
    }
}

/* Дополнительные улучшения для мобильных устройств на всех страницах */

/* Улучшенные стили для форм на всех страницах */
@media (max-width: 768px) {
    /* Формы отчетов */
    .reports-controls {
        margin-bottom: 1.5rem;
    }
    
    .reports-controls .form-group {
        margin-bottom: 1rem;
    }
    
    .reports-controls .form-group > div {
        width: 100%;
        margin-bottom: 1rem;
    }
    
    .reports-controls button {
        width: 100%;
        min-height: 44px;
    }
    
    /* Контейнер отчета */
    #report-container {
        margin-top: 1.5rem;
    }
    
    #report-table-container {
        margin: 1rem 0;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    #report-table {
        min-width: 100%;
        font-size: 0.875rem;
    }
    
    #report-table th,
    #report-table td {
        padding: 0.5rem;
        white-space: nowrap;
    }
    
    #report-summary {
        margin-top: 1.5rem;
        padding: 1rem;
        font-size: 0.875rem;
        word-wrap: break-word;
    }
    
    /* Формы накладных */
    .upload-section {
        padding: 1rem;
    }
    
    .invoice-tabs {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
        margin-bottom: 1.5rem;
    }
    
    .invoice-tabs .tab-btn {
        width: 100%;
        padding: 0.875rem 1rem;
        text-align: center;
        min-height: 44px;
    }
    
    /* Карточки серверов */
    .server-card {
        padding: 1rem;
        margin-bottom: 1rem;
    }
    
    .server-actions {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .server-actions button {
        width: 100%;
        min-height: 44px;
    }
    
    /* Справочники */
    .references-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .reference-card {
        padding: 1rem;
    }
    
    /* Улучшенные модальные окна */
    .modal {
        padding: 0;
        align-items: flex-end;
    }
    
    .modal-content {
        width: 100%;
        max-width: 100%;
        margin: 0;
        border-radius: 1rem 1rem 0 0;
        max-height: 90vh;
        padding: 1.5rem;
    }
    
    /* Улучшенные таблицы */
    .data-table {
        font-size: 0.875rem;
    }
    
    .data-table th,
    .data-table td {
        padding: 0.5rem 0.375rem;
    }
    
    /* Кнопки действий в таблицах */
    .actions-cell {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .actions-cell button {
        width: 100%;
        min-height: 44px;
        margin: 0;
    }
    
    /* Фильтры */
    .filters-bar {
        display: flex;
        flex-direction: column;
        gap: 1rem;
        margin-bottom: 1.5rem;
    }
    
    .filter-group {
        width: 100%;
    }
    
    .filter-group label {
        display: block;
        margin-bottom: 0.5rem;
        font-size: 0.875rem;
        font-weight: 600;
    }
    
    .filter-group select,
    .filter-group input {
        width: 100%;
        min-height: 44px;
    }
    
    /* Заголовки секций */
    .section-header {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }
    
    .section-header button {
        width: 100%;
        min-height: 44px;
    }
    
    /* Улучшенные карточки статистики */
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .stat-card {
        padding: 1rem;
    }
    
    /* Улучшенные карточки */
    .cards-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .card {
        padding: 1.5rem;
    }
    
    /* Улучшенные заголовки страниц */
    .page-header {
        margin-bottom: 2rem;
        text-align: left;
    }
    
    .page-header h2 {
        font-size: 1.5rem;
        margin-bottom: 0.5rem;
    }
    
    .subtitle {
        font-size: 0.875rem;
    }
}

/* Очень маленькие экраны (до 360px) */
@media (max-width: 360px) {
    .main-content {
        padding: 0.75rem;
    }
    
    .page-header h2 {
        font-size: 1.25rem;
    }
    
    .card {
        padding: 1rem;
    }
    
    .stat-card {
        padding: 0.75rem;
    }
    
    table {
        font-size: 0.7rem;
    }
    
    table th,
    table td {
        padding: 0.375rem 0.25rem;
    }
    
    .btn-primary,
    .btn-secondary,
    .btn-danger {
        font-size: 0.875rem;
        padding: 0.625rem 1rem;
    }
}

/* Планшеты в портретной ориентации */
@media (min-width: 481px) and (max-width: 768px) {
    .reports-controls .form-group {
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 1rem;
    }
    
    .reports-controls .form-group > div {
        flex: 1 1 auto;
        min-width: 200px;
    }
    
    .reports-controls button {
        width: auto;
        min-width: 150px;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .cards-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .invoice-tabs {
        flex-direction: row;
        flex-wrap: wrap;
    }
    
    .invoice-tabs .tab-btn {
        flex: 1 1 auto;
        min-width: 150px;
    }
    
    .filters-bar {
        flex-direction: row;
        flex-wrap: wrap;
    }
    
    .filter-group {
        flex: 1 1 auto;
        min-width: 150px;
    }
    
    .actions-cell {
        flex-direction: row;
        flex-wrap: wrap;
    }
    
    .actions-cell button {
        flex: 1 1 auto;
        min-width: 100px;
    }
}

/* Горизонтальная ориентация на мобильных */
@media (max-width: 768px) and (orientation: landscape) {
    .header {
        padding: 0.5rem 0;
    }
    
    .logo {
        font-size: 1.125rem;
    }
    
    .main-content {
        padding: 1rem;
    }
    
    .page-header {
        margin-bottom: 1.5rem;
    }
    
    .page-header h2 {
        font-size: 1.25rem;
    }
    
    .modal-content {
        max-height: 95vh;
    }
}
