/* Общие стили */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
    overflow: hidden;
}

.header {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    padding: 30px;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    flex-wrap: wrap;
    gap: 20px;
}

.admin-link {
    white-space: nowrap;
    text-decoration: none;
}

.landing-help {
    margin: 16px 0 0;
    padding-top: 14px;
    border-top: 1px solid #d6e8ff;
    color: #004085;
    font-size: 15px;
    line-height: 1.5;
}

.landing-help a {
    color: #0056b3;
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.landing-help a:hover {
    color: #003d80;
}

.reports-btn-success {
    background: #28a745;
    color: #fff;
}

.header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
    font-weight: 300;
}

.header .subtitle {
    font-size: 1.1em;
    opacity: 0.9;
}

.content {
    padding: 40px;
}

.section {
    margin-bottom: 40px;
    padding: 30px;
    background: #f8f9fa;
    border-radius: 15px;
    border-left: 5px solid #667eea;
}

.section h2 {
    color: #333;
    margin-bottom: 20px;
    font-size: 1.5em;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Наборы дизайнов */
.sets-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.set-card {
    background: white;
    border-radius: 15px;
    padding: 20px;
    border: 2px solid #e0e0e0;
    cursor: pointer;
    transition: all 0.3s;
}

.set-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    border-color: #667eea;
}

.set-card.selected {
    border-color: #667eea;
    background: #f0f8ff;
}

.set-card input[type="checkbox"] {
    margin-right: 10px;
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.set-card h3 {
    color: #333;
    margin-bottom: 10px;
    font-size: 1.2em;
}

.set-card p {
    color: #666;
    font-size: 0.9em;
    margin-bottom: 10px;
}

.set-card .file-count {
    color: #999;
    font-size: 0.85em;
}

/* Форма калибровки */
.controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-bottom: 30px;
}

.control-group {
    background: white;
    padding: 20px;
    border-radius: 10px;
    border: 1px solid #e0e0e0;
}

.control-group h3 {
    margin-bottom: 15px;
    color: #333;
    font-size: 1.2em;
}

.input-row {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
}

.input-row:last-child {
    margin-bottom: 0;
}

.input-row label {
    min-width: 140px;
    color: #555;
    font-weight: 500;
}

.input-row input {
    flex: 1;
    padding: 10px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s;
}

.input-row input:focus {
    outline: none;
    border-color: #667eea;
}

.input-row .unit {
    color: #999;
    font-size: 0.9em;
}

.offset-preview {
    background: #f0f8ff;
    padding: 20px;
    border-radius: 10px;
    border: 2px solid #667eea;
    text-align: center;
    font-weight: 600;
    color: #333;
    font-size: 1.1em;
    margin-top: 20px;
}

/* Кнопки */
.buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.btn {
    padding: 15px 30px;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(102, 126, 234, 0.3);
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

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

.btn-success {
    background: #28a745;
    color: white;
}

.btn-success:hover:not(:disabled) {
    background: #218838;
    transform: translateY(-2px);
}

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

/* Прогресс */
.progress-container {
    background: white;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    display: none;
}

.progress-container.active {
    display: block;
}

.progress-bar-wrapper {
    background: #e0e0e0;
    border-radius: 10px;
    height: 30px;
    overflow: hidden;
    margin-bottom: 10px;
}

.progress-bar {
    background: linear-gradient(135deg, #667eea, #764ba2);
    height: 100%;
    width: 0%;
    transition: width 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 0.9em;
}

.progress-text {
    text-align: center;
    color: #666;
    font-size: 0.9em;
}

/* Сообщения */
.message {
    padding: 15px 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    display: none;
}

.message.active {
    display: block;
}

.message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.message.info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

/* Админка */
.admin-shell {
    width: 100%;
    min-height: calc(100vh - 40px);
    display: flex;
    flex-direction: column;
}

.admin-topbar {
    position: relative;
    z-index: 20;
    width: 100%;
    background: rgba(255, 255, 255, 0.97);
    border: 1px solid rgba(226, 232, 240, 0.95);
    border-radius: 18px;
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.12);
}

.admin-topbar__inner {
    width: 100%;
    max-width: 1440px;
    min-height: 68px;
    margin: 0 auto;
    padding: 12px 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.admin-topbar h2 {
    margin: 0;
    color: #1e293b;
    font-size: clamp(17px, 2vw, 22px);
    line-height: 1.2;
}

.admin-topbar__actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.admin-topbar__home {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    padding: 0 16px;
    border-radius: 9px;
    background: #667eea;
    color: #fff;
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
}

.admin-topbar__home:hover {
    background: #5268d8;
}

.admin-tabs-bar {
    position: relative;
    z-index: 15;
    width: 100%;
    margin-top: 10px;
    padding: 0;
}

.admin-main {
    width: 100%;
    min-height: 0;
    margin-top: 12px;
    display: flex;
    flex: 1;
}

.admin-main-inner {
    width: 100%;
    min-width: 0;
    margin: 0 auto;
    transition: max-width 0.2s ease, padding 0.2s ease, border-radius 0.2s ease;
}

.admin-main-inner--narrow {
    max-width: 1200px;
    padding: 40px;
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 20px 40px rgba(15, 23, 42, 0.12);
}

.admin-main-inner--full {
    max-width: none;
    padding: 0;
    background: transparent;
    border-radius: 0;
    box-shadow: none;
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 40px;
    background: #f8f9fa;
    border-bottom: 2px solid #e0e0e0;
}

.admin-header h2 {
    color: #333;
}

.logout-btn {
    padding: 10px 20px;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
}

.logout-btn:hover {
    background: #c82333;
}

@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    .admin-shell {
        min-height: calc(100vh - 20px);
    }

    .admin-topbar__inner {
        min-height: 60px;
        padding: 10px 12px;
        gap: 10px;
    }

    .admin-topbar h2 {
        font-size: 15px;
    }

    .admin-topbar__home {
        padding: 0 10px;
        font-size: 0;
    }

    .admin-topbar__home::first-letter {
        font-size: 16px;
    }

    .logout-btn {
        padding: 9px 12px;
    }

    .admin-main-inner--narrow {
        padding: 18px;
        border-radius: 14px;
    }
}

.login-form {
    max-width: 400px;
    margin: 100px auto;
    background: white;
    padding: 40px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.login-form h2 {
    margin-bottom: 30px;
    text-align: center;
    color: #333;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: #555;
    font-weight: 500;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 16px;
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
}

/* Загрузка файлов */
.upload-zone {
    border: 3px dashed #667eea;
    border-radius: 15px;
    padding: 40px;
    text-align: center;
    background: white;
    transition: all 0.3s;
    cursor: pointer;
    margin-bottom: 20px;
}

.upload-zone:hover, .upload-zone.dragover {
    border-color: #764ba2;
    background: #f0f8ff;
    transform: translateY(-2px);
}

.upload-zone .icon {
    font-size: 3em;
    margin-bottom: 15px;
    color: #667eea;
}

.upload-zone .text {
    font-size: 1.2em;
    color: #666;
    margin-bottom: 10px;
}

/* Список файлов */
.files-list {
    background: white;
    border-radius: 10px;
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid #e0e0e0;
}

.file-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    border-bottom: 1px solid #f0f0f0;
}

.file-item:last-child {
    border-bottom: none;
}

.file-item:hover {
    background: #f8f9fa;
}

.file-name {
    font-weight: 500;
    color: #333;
}

.delete-btn {
    padding: 8px 15px;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9em;
}

.delete-btn:hover {
    background: #c82333;
}

/* Спиннеры для кнопок */
.btn.loading,
.delete-btn.loading,
.logout-btn.loading {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}

.btn.loading::before,
.delete-btn.loading::before,
.logout-btn.loading::before {
    content: '';
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 8px;
    vertical-align: middle;
}

.delete-btn.loading::before {
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #ffffff;
}

.logout-btn.loading::before {
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #ffffff;
}

.btn-secondary.loading::before {
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #ffffff;
}

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

/* Вкладки */
.tabs {
    display: flex;
    border-bottom: 2px solid #e0e0e0;
    margin: 0 40px;
    gap: 5px;
    background: white;
}

.tab {
    padding: 15px 30px;
    background: transparent;
    border: none;
    border-radius: 10px 10px 0 0;
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
    color: #666;
    transition: all 0.3s;
    position: relative;
    bottom: -2px;
}

.tab:hover {
    background: #f8f9fa;
    color: #333;
}

.tab.active {
    background: white;
    color: #667eea;
    border-bottom: 3px solid #667eea;
    font-weight: 600;
}

.tab-content {
    display: none;
}

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

/* Стили для системы отчетов (чтобы не конфликтовали с калибратором) */
.reports-container {
    padding: 20px;
}

.reports-status {
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-weight: 600;
}

.reports-status.ready {
    background: #d4edda;
    color: #155724;
}

.reports-status.processing {
    background: #fff3cd;
    color: #856404;
}

.reports-status.error {
    background: #f8d7da;
    color: #721c24;
}

.reports-status.info {
    background: #d1ecf1;
    color: #0c5460;
}

.reports-compact-panel {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
}

.reports-compact-panel h4 {
    margin-bottom: 10px;
    color: #495057;
    font-size: 16px;
}

.reports-device-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
    margin-bottom: 15px;
}

.reports-info-item {
    background: white;
    padding: 10px;
    border-radius: 5px;
    border-left: 4px solid #007bff;
}

.reports-info-item label {
    display: block;
    font-size: 12px;
    color: #6c757d;
    margin-bottom: 5px;
}

.reports-info-item value {
    display: block;
    font-size: 18px;
    font-weight: bold;
    color: #333;
}

.reports-button-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 15px;
}

.reports-button-group button {
    flex: 1;
    min-width: 150px;
}

.reports-btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.3s;
    background: #007bff;
    color: white;
    margin-right: 10px;
    margin-bottom: 10px;
}

.reports-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

.reports-btn.success {
    background: #28a745;
}

.reports-btn.danger {
    background: #dc3545;
}

.reports-btn.warning {
    background: #ffc107;
    color: #333;
}

.reports-btn.info {
    background: #17a2b8;
    color: white;
}

.reports-btn:disabled {
    background: #6c757d !important;
    color: #ffffff !important;
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

.reports-btn.loading {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}

.reports-btn.loading::before {
    content: '';
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: reports-spin 0.8s linear infinite;
    margin-right: 8px;
    vertical-align: middle;
}

.reports-btn.warning.loading::before {
    border: 2px solid rgba(0, 0, 0, 0.2);
    border-top-color: #333;
}

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

.reports-stats-compact {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 10px;
}

.reports-stat-compact {
    background: white;
    padding: 10px;
    border-radius: 6px;
    text-align: center;
    border-left: 3px solid #007bff;
}

.reports-stat-compact label {
    display: block;
    font-size: 11px;
    color: #6c757d;
    margin-bottom: 5px;
}

.reports-stat-compact value {
    display: block;
    font-size: 20px;
    font-weight: 600;
    color: #333;
}

.reports-form-group {
    margin-bottom: 15px;
}

.reports-form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: #495057;
}

.reports-form-group input,
.reports-form-group textarea {
    width: 100%;
    padding: 10px;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    font-size: 16px;
}

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

.reports-log-panel {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 20px;
    margin-top: 20px;
    max-height: 400px;
    overflow-y: auto;
}

.reports-collapsible {
    cursor: pointer;
    user-select: none;
}

.reports-collapsible::before {
    content: '▼ ';
    display: inline-block;
    transition: transform 0.3s;
    margin-right: 5px;
}

.reports-collapsible.collapsed::before {
    transform: rotate(-90deg);
}

.reports-collapsible-content {
    max-height: 1000px;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
}

.reports-collapsible-content.collapsed {
    max-height: 0;
}

.reports-log-entry {
    padding: 8px;
    margin-bottom: 5px;
    border-radius: 5px;
    font-size: 14px;
    font-family: 'Courier New', monospace;
}

.reports-log-entry.info {
    background: #e7f3ff;
    color: #004085;
}

.reports-log-entry.success {
    background: #d4edda;
    color: #155724;
}

.reports-log-entry.warning {
    background: #fff3cd;
    color: #856404;
}

.reports-log-entry.error {
    background: #f8d7da;
    color: #721c24;
}

.reports-hidden {
    display: none;
}

/* Адаптивность */
@media (max-width: 768px) {
    .controls {
        grid-template-columns: 1fr;
    }
    
    .sets-grid {
        grid-template-columns: 1fr;
    }
    
    .buttons {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
        justify-content: center;
    }
    
    .tabs {
        margin: 0 20px;
        flex-wrap: wrap;
    }
    
    .tab {
        padding: 12px 20px;
        font-size: 14px;
    }
}

