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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, 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: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: 30px;
}

h1 {
    color: #333;
    margin-bottom: 30px;
    text-align: center;
}

.db-loader {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    border: 1px solid #dee2e6;
    text-align: center;
}

.db-loader input[type="file"] {
    padding: 10px;
    margin-bottom: 10px;
}

.db-status {
    color: #6c757d;
    font-size: 14px;
    margin-top: 10px;
}

.db-status.loaded {
    color: #28a745;
    font-weight: 600;
}

.progress-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.progress-label {
    font-weight: 600;
    color: #495057;
    font-size: 14px;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: #e9ecef;
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 4px;
}

.progress-text {
    text-align: center;
    font-size: 12px;
    color: #6c757d;
    font-weight: 600;
}

.control-panel {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 30px;
    border: 1px solid #dee2e6;
    display: none;
}

.control-panel.active {
    display: block;
}

.control-panel h2 {
    font-size: 18px;
    color: #495057;
    margin-bottom: 20px;
    font-weight: 600;
}

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

.form-group {
    display: flex;
    flex-direction: column;
}

label {
    font-weight: 600;
    color: #495057;
    margin-bottom: 8px;
    font-size: 14px;
}

input[type="text"],
input[type="number"],
select {
    padding: 10px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.2s;
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.button-group {
    display: flex;
    gap: 10px;
    justify-content: center;
}

button {
    padding: 10px 30px;
    font-size: 16px;
    font-weight: 600;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s;
}

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

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

.btn-generate:active {
    transform: translateY(0);
}

.params-display {
    background: #e7f3ff;
    padding: 15px;
    border-radius: 4px;
    margin-bottom: 20px;
    border-left: 4px solid #2196F3;
    display: none;
}

.params-display.active {
    display: block;
}

.params-display h3 {
    color: #1565c0;
    font-size: 14px;
    margin-bottom: 10px;
}

.params-display p {
    color: #0d47a1;
    font-size: 13px;
    font-family: 'Courier New', monospace;
    line-height: 1.6;
}

.chart-container {
    position: relative;
    height: 500px;
    margin-bottom: 30px;
    display: none;
    background: white;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #dee2e6;
}

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

.error-message {
    background: #fee;
    color: #c33;
    padding: 15px;
    border-radius: 4px;
    margin-bottom: 20px;
    border-left: 4px solid #c33;
    display: none;
}

.error-message.active {
    display: block;
}

.success-message {
    background: #efe;
    color: #3c3;
    padding: 15px;
    border-radius: 4px;
    margin-bottom: 20px;
    border-left: 4px solid #3c3;
    display: none;
}

.success-message.active {
    display: block;
}

.loading {
    text-align: center;
    color: #667eea;
    font-weight: 600;
    display: none;
    margin: 20px 0;
}

.loading.active {
    display: block;
}

.loading::after {
    content: '';
    animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
    0%, 20% { content: ''; }
    40% { content: '.'; }
    60% { content: '..'; }
    80%, 100% { content: '...'; }
}

.help-text {
    color: #6c757d;
    font-size: 12px;
    margin-top: 5px;
    font-style: italic;
}

.conditional-group {
    display: none;
}

.conditional-group.visible {
    display: block;
}

/* View Management Styles */
.view-container {
    display: none;
    animation: slideInFromRight 0.5s ease-in-out;
}

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

.view-container.exiting {
    animation: slideOutToLeft 0.5s ease-in-out forwards;
}

.view-header {
    margin-bottom: 20px;
}

.view-header h2 {
    color: #333;
    font-size: 24px;
}

@keyframes slideInFromRight {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideOutToLeft {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(-100%);
    }
}

/* Machine Overview Styles */
.branch-selector-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 30px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #dee2e6;
}

@media (max-width: 800px) {
    .branch-selector-container {
        grid-template-columns: 1fr;
        gap: 15px;
    }
}

.branch-selector-group {
    display: flex;
    flex-direction: column;
}

.branch-selector-group label {
    font-weight: 600;
    color: #495057;
    margin-bottom: 8px;
    font-size: 14px;
}

.branch-select {
    padding: 10px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
    background: white;
    color: #333;
    transition: border-color 0.2s;
    cursor: pointer;
}

.branch-select:hover {
    border-color: #667eea;
}

.branch-select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Machine Overview Styles */
.machines-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    margin-top: 20px;
}

.machine-card {
    background: white;
    border: 2px solid #dee2e6;
    border-radius: 12px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
}

@media (min-width: 800px) {
    .machine-card {
        flex-direction: row;
        gap: 20px;
        align-items: center;
    }
}

.machine-card:hover {
    border-color: #667eea;
    box-shadow: 0 8px 24px rgba(102, 126, 234, 0.2);
    transform: translateY(-4px);
}

.machine-card:active {
    transform: translateY(-2px);
}

.machine-name {
    font-size: 20px;
    font-weight: 700;
    color: #333;
    margin-bottom: 12px;
}

.machine-info {
    flex-shrink: 0;
}

.machine-stats {
    display: grid;
    gap: 8px;
    margin-bottom: 15px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    gap: 15px;
    font-size: 13px;
    color: #666;
    padding: 6px 0;
    border-bottom: 1px solid #f0f0f0;
}

.stat-label {
    font-weight: 600;
    color: #495057;
}

.stat-value {
    color: #667eea;
    font-weight: 500;
    font-family: 'Courier New', monospace;
}

.machine-card-chart {
    background: white;
    border-radius: 6px;
    padding: 10px 0;
    margin-top: 15px;
    position: relative;
    height: 200px;
    flex-grow: 1;
}

.machine-card-chart canvas {
    max-width: 100%;
    max-height: 100%;
}

/* Machine Detail Styles */
.machine-detail-header {
    margin-bottom: 30px;
}

.machine-detail-header h2 {
    color: #333;
    margin-bottom: 10px;
}

.machine-detail-header p {
    color: #6c757d;
    font-size: 14px;
}

.btn-back {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: transparent;
    color: #667eea;
    border: 1px solid #667eea;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.3s;
    margin-bottom: 20px;
}

.btn-back:hover {
    background: #667eea;
    color: white;
}

.back-arrow {
    font-size: 18px;
}

.historical-data-container {
    display: grid;
    gap: 20px;
}

.historical-operation-group {
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #dee2e6;
    overflow: hidden;
}

.operation-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 16px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    font-size: 16px;
    transition: all 0.3s;
    user-select: none;
}

.operation-header:hover {
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
}

.expand-icon {
    display: inline-block;
    transition: transform 0.3s;
    font-size: 14px;
}

.expand-icon.expanded {
    transform: rotate(180deg);
}

.operation-content {
    display: none;
    padding: 16px;
    background: white;
}

.operation-content.expanded {
    display: block;
}

.thread-data-group {
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid #dee2e6;
}

.thread-data-group:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.thread-label {
    font-weight: 600;
    color: #495057;
    margin-bottom: 10px;
    font-size: 14px;
}

.dt-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 12px;
    background: #f8f9fa;
    border-radius: 4px;
    margin-bottom: 6px;
    font-size: 13px;
}

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

.dt-label {
    color: #495057;
    font-weight: 500;
}

.dt-value {
    color: #667eea;
    font-weight: 600;
    font-family: 'Courier New', monospace;
}
