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

/* Форма авторизации */
.login-modal {
    display: flex;
    justify-content: center;
    align-items: center;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    z-index: 1000;
}

.login-container {
    background: white;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    width: 100%;
    max-width: 400px;
}

.login-container 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: 6px;
    font-size: 16px;
    transition: border-color 0.3s;
}

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

.error-message {
    color: #e74c3c;
    background: #ffeaea;
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 20px;
    text-align: center;
}

.user-info {
    color: white;
    font-weight: 500;
    margin-right: 10px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    min-height: -webkit-fill-available; /* Для iOS Safari */
    padding: 15px;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); /* Для iPhone X и новее */
    color: #333;
    font-size: 13px;
}

.container {
    max-width: 1600px;
    margin: 0 auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

header h1 {
    font-size: 18px;
    font-weight: 600;
}

.header-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

.terminal-select {
    padding: 8px 12px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    background: white;
    color: #333;
    cursor: pointer;
    min-width: 180px;
}

.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

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

.btn-primary {
    background: #4CAF50;
    color: white;
}

.btn-primary:hover {
    background: #45a049;
}

.btn-success {
    background: #2196F3;
    color: white;
}

.btn-success:hover {
    background: #0b7dda;
}

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

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

.main-content {
    padding: 20px;
    min-height: 600px;
}

.right-panel {
    display: flex;
    flex-direction: column;
    position: relative;
}

.right-panel.full-width {
    width: 100%;
}

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

.tab-btn {
    padding: 10px 20px;
    border: none;
    background: transparent;
    color: #666;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.3s ease;
    position: relative;
    top: 2px;
}

.tab-btn:hover {
    color: #667eea;
    background: #f8f9fa;
}

.tab-btn.active {
    color: #667eea;
    border-bottom-color: #667eea;
    font-weight: 600;
}

.tab-content {
    display: none;
    flex: 1;
}

.tab-content.active {
    display: flex;
    flex-direction: column;
}

.card {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.card h2 {
    font-size: 16px;
    margin-bottom: 12px;
    color: #333;
    border-bottom: 2px solid #667eea;
    padding-bottom: 8px;
}

.status-content {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.status-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #e0e0e0;
    font-size: 13px;
}

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

.status-label {
    font-weight: 500;
    color: #666;
    font-size: 13px;
}

.status-value {
    font-weight: 600;
    color: #333;
    font-size: 13px;
}

.status-online {
    color: #4CAF50;
}

.status-offline {
    color: #f44336;
}

/* Стили для входов */
.status-item-inputs {
    flex-direction: column;
    align-items: flex-start;
}

.inputs-list {
    width: 100%;
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.input-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px;
    border-radius: 4px;
    background: #f5f5f5;
}

.input-item.input-triggered {
    background: #fff3cd;
    border-left: 3px solid #ffc107;
}

.input-item.input-normal {
    background: #f5f5f5;
    border-left: 3px solid #e0e0e0;
}

.input-number {
    font-weight: 500;
    min-width: 70px;
    color: #666;
}

.input-value {
    flex: 1;
    font-weight: 600;
    color: #333;
    font-size: 0.9em;
}

.input-status {
    font-size: 12px;
    color: #999;
}

.input-triggered .input-status {
    color: #ffc107;
}

.placeholder {
    color: #999;
    font-style: italic;
    text-align: center;
    padding: 20px;
}

.command-form {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}

.command-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 13px;
}

.command-status {
    padding: 10px;
    border-radius: 6px;
    font-size: 13px;
    margin-top: 10px;
    display: none;
}

.command-status.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
    display: block;
}

.command-status.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    display: block;
}

/* Чат команд */
.chat-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 600px;
}

.command-chat {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    background: #f8f9fa;
    border-radius: 6px;
    margin-bottom: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-height: 0;
}

.load-more-container {
    text-align: center;
    margin-bottom: 6px;
    padding: 4px 4px 6px 4px;
}

.load-more-link {
    color: #667eea;
    text-decoration: none;
    font-size: 12px;
    cursor: pointer;
    display: inline-block;
    padding: 2px 4px;
    border-radius: 3px;
    transition: all 0.2s ease;
}

.load-more-link:hover {
    color: #764ba2;
    background: #f0f0f0;
    text-decoration: underline;
}

.chat-message {
    background: white;
    border-radius: 4px;
    padding: 6px 8px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
    font-size: 12px;
}

.chat-command {
    border-left: 3px solid #667eea;
}

.chat-response {
    border-left: 3px solid #4CAF50;
    margin-left: 15px;
    background: #f0f9f4;
}

.chat-message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
    font-size: 10px;
    color: #666;
}

.chat-time {
    font-weight: 500;
}

.chat-status {
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 600;
}

.chat-status.status-pending {
    background: #fff3cd;
    color: #856404;
}

.chat-status.status-sent {
    background: #d1ecf1;
    color: #0c5460;
}

.chat-status.status-failed {
    background: #f8d7da;
    color: #721c24;
}

.chat-message-content {
    color: #333;
}

.chat-command-text {
    font-weight: 600;
    padding: 4px 6px;
    background: #f8f9fa;
    border-radius: 3px;
    word-break: break-word;
    font-size: 12px;
}

.chat-response-text {
    padding: 4px 6px;
    word-break: break-word;
    white-space: pre-wrap;
    font-size: 12px;
}

.chat-responses {
    margin-top: 6px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.chat-waiting {
    margin-top: 4px;
    padding: 4px 6px;
    font-size: 10px;
    color: #999;
    font-style: italic;
}

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

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

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

.command-time {
    font-size: 12px;
    color: #999;
}

.map-card {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 600px;
}

.track-filters {
    margin-bottom: 15px;
    padding: 15px;
    background: white;
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.track-filters label {
    font-weight: 500;
    color: #333;
    font-size: 14px;
}

.track-period-select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    background: white;
    cursor: pointer;
}

.custom-period {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
}

.time-input {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    flex: 1;
}

.map-container {
    height: 500px;
    width: 100%;
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 10px;
}

.map-controls {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

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

.btn-warning:hover {
    background: #e0a800;
}

/* Адаптивность */
@media (max-width: 1200px) {
    .main-content {
        padding: 15px;
    }
}

@media (max-width: 768px) {
    header {
        flex-direction: column;
        align-items: stretch;
    }
    
    .header-controls {
        flex-direction: column;
    }
    
    .terminal-select {
        width: 100%;
    }
}

/* Скроллбар */
.commands-list::-webkit-scrollbar {
    width: 6px;
}

.commands-list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.commands-list::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Маркер терминала на карте - SVG треугольник */
.terminal-marker-svg {
    background: transparent !important;
    border: none !important;
}

.terminal-marker-svg svg {
    display: block;
    transition: transform 0.5s ease-out;
}

.marker-dot {
    position: absolute;
    width: 12px;
    height: 12px;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    background: inherit;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Модальные окна */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
    background-color: #fefefe;
    margin: 5% auto;
    padding: 30px;
    border: 1px solid #888;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    position: relative;
}

.modal-close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    position: absolute;
    right: 20px;
    top: 15px;
    cursor: pointer;
}

.modal-close:hover,
.modal-close:focus {
    color: #000;
    text-decoration: none;
}

/* Списки пользователей и привязок */
.users-list, .assignments-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.user-item, .assignment-item {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.user-item-info, .assignment-item-info {
    flex: 1;
}

.user-item-info h4, .assignment-item-info h4 {
    margin: 0 0 5px 0;
    color: #333;
}

.user-item-info p, .assignment-item-info p {
    margin: 5px 0;
    color: #666;
    font-size: 12px;
}

.user-item-actions, .assignment-item-actions {
    display: flex;
    gap: 10px;
}

.btn-small {
    padding: 6px 12px;
    font-size: 12px;
}

.badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
    margin-left: 8px;
}

.badge-admin {
    background: #667eea;
    color: white;
}

.badge-active {
    background: #4CAF50;
    color: white;
}

.badge-inactive {
    background: #f44336;
    color: white;
}

.badge-default {
    background: #ff9800;
    color: white;
}

.settings-section {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #e0e0e0;
}

.settings-section h3 {
    margin-bottom: 15px;
    color: #333;
}

small {
    display: block;
    color: #666;
    font-size: 11px;
    margin-top: 5px;
}
