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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: white;
    min-height: 100vh;
    padding: 20px;
    color: #333;
    max-width: 1200px;
    margin: 0 auto;
}

header {
    text-align: center;
    margin-bottom: 40px;
    padding-bottom: 20px;
    border-bottom: 2px solid #e0e0e0;
}

h1 {
    font-size: 2.5em;
    color: #667eea;
    margin-bottom: 10px;
}

.subtitle {
    color: #666;
    font-size: 1.1em;
}

.controls {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.btn {
    padding: 12px 30px;
    font-size: 16px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

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

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

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

.btn-secondary {
    background: #f0f0f0;
    color: #333;
}

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

.status {
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    display: none;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

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

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

.device-list {
    margin-bottom: 30px;
}

.device-item {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.device-item:hover {
    background: #e9ecef;
    border-color: #667eea;
}

.device-item.selected {
    background: #e7eaff;
    border-color: #667eea;
}

.device-name {
    font-weight: 600;
    font-size: 1.1em;
    color: #667eea;
    margin-bottom: 5px;
}

.device-info {
    color: #666;
    font-size: 0.9em;
}

.device-details {
    display: none;
}

.device-details.visible {
    display: block;
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.detail-section {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
}

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

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
}

.detail-item {
    background: white;
    padding: 15px;
    border-radius: 6px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.detail-label {
    font-weight: 600;
    color: #555;
    margin-bottom: 5px;
    font-size: 0.9em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.detail-value {
    color: #333;
    font-family: 'Courier New', monospace;
    word-break: break-all;
    font-size: 0.95em;
}

.config-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    background: white;
    border-radius: 6px;
    overflow: hidden;
}

.config-table th,
.config-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #e0e0e0;
}

.config-table th {
    background: #667eea;
    color: white;
    font-weight: 600;
}

.config-table tr:hover {
    background: #f5f5f5;
}

.interface-section {
    background: white;
    padding: 0;
    border-radius: 8px;
    margin-bottom: 15px;
    border: 1px solid #e0e0e0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    overflow: hidden;
}

.interface-header {
    font-weight: 600;
    color: #667eea;
    padding: 15px;
    font-size: 1.1em;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    border-bottom: 1px solid #e0e0e0;
}

.interface-header.collapsible {
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: background 0.2s ease;
}

.interface-header.collapsible:hover {
    background: linear-gradient(135deg, #e8ebf0 0%, #b8c5d8 100%);
}

.collapse-icon {
    display: inline-block;
    transition: transform 0.2s ease;
    font-size: 0.8em;
    min-width: 20px;
}

.interface-content {
    padding: 15px;
    display: block;
    animation: slideDown 0.2s ease;
}

.alternate-section {
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px dashed #e0e0e0;
}

.alternate-section:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.alternate-title {
    color: #764ba2;
    font-size: 1em;
    margin-bottom: 15px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 4px;
    border-left: 3px solid #764ba2;
}

.language-section {
    margin-bottom: 25px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
}

.language-title {
    color: #667eea;
    font-size: 1.1em;
    margin-bottom: 15px;
    padding: 10px;
    background: white;
    border-radius: 6px;
    border-left: 4px solid #667eea;
}

@keyframes slideDown {
    from {
        opacity: 0;
        max-height: 0;
    }
    to {
        opacity: 1;
        max-height: 1000px;
    }
}

.endpoint-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 10px;
}

.endpoint-item {
    background: #f8f9fa;
    padding: 10px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}

.note {
    text-align: center;
    color: #666;
    font-size: 0.9em;
    margin-top: 30px;
    padding: 15px;
    background: #fff3cd;
    border-radius: 8px;
    border: 1px solid #ffc107;
}

.loading {
    text-align: center;
    padding: 40px;
    color: #666;
}

.loading::after {
    content: '...';
    animation: dots 1.5s infinite;
}

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

.hex-dump {
    background: #2d2d2d;
    color: #00ff00;
    padding: 15px;
    border-radius: 6px;
    font-family: 'Courier New', monospace;
    font-size: 0.85em;
    overflow-x: auto;
    max-height: 400px;
    overflow-y: auto;
}

.badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.8em;
    font-weight: 600;
    margin-left: 8px;
}

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

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

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

/* Control Transfer Styles */
.control-transfer-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.control-transfer-buttons,
.control-transfer-custom,
.control-transfer-result {
    background: white;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
}

.control-transfer-buttons h3,
.control-transfer-custom h3,
.control-transfer-result h3 {
    color: #667eea;
    margin-bottom: 15px;
    font-size: 1.1em;
}

.control-transfer-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.control-transfer-buttons button {
    width: 100%;
    max-width: 300px;
}

.custom-transfer-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.form-row label {
    display: flex;
    flex-direction: column;
    gap: 5px;
    font-weight: 600;
    color: #555;
}

.form-row input,
.form-row select {
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}

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

.transfer-result-box {
    min-height: 100px;
    background: #f8f9fa;
    padding: 15px;
    border-radius: 6px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
    color: #666;
}

.transfer-result {
    background: white;
}

.result-header {
    padding: 10px 15px;
    border-radius: 6px;
    margin-bottom: 15px;
    font-size: 1em;
}

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

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

.result-details {
    padding: 10px;
    background: #f8f9fa;
    border-radius: 4px;
}

.result-details.error {
    background: #fff3cd;
    color: #856404;
}

.result-details p {
    margin: 5px 0;
}

.hex-line {
    display: flex;
    gap: 20px;
    font-family: 'Courier New', monospace;
    font-size: 0.85em;
    padding: 2px 0;
    background: #2d2d2d;
    color: #00ff00;
    padding: 2px 10px;
}

.hex-bytes {
    flex: 0 0 400px;
    letter-spacing: 1px;
}

.ascii-chars {
    color: #88ff88;
    letter-spacing: 1px;
}

.raw-bytes {
    background: #2d2d2d;
    color: #00ff00;
    padding: 10px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.85em;
    overflow-x: auto;
    word-break: break-all;
}

@media (max-width: 768px) {
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .hex-line {
        flex-direction: column;
        gap: 5px;
    }
    
    .hex-bytes {
        flex: none;
    }
}
