* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 1600px;
    margin: 0 auto;
    background: white;
    min-height: 100vh;
}

header {
    background: #2c3e50;
    color: white;
    padding: 20px 30px;
    border-bottom: 3px solid #34495e;
}

header h1 {
    font-size: 1.8em;
    font-weight: 600;
}

main {
    padding: 20px 30px;
}

.input-section {
    margin-bottom: 30px;
    padding: 20px;
    background: #fafafa;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
}

.input-controls {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.input-group label {
    font-weight: 500;
    color: #555;
    font-size: 0.9em;
}

select {
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 3px;
    font-size: 0.95em;
    background: white;
    cursor: pointer;
    width: 150px;
}

select:focus {
    outline: none;
    border-color: #3498db;
}

textarea {
    width: 100%;
    min-height: 120px;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
    resize: vertical;
    background: white;
}

textarea:focus {
    outline: none;
    border-color: #3498db;
}

input[type="file"] {
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 3px;
    background: white;
    cursor: pointer;
    font-size: 0.9em;
}

input[type="file"]:focus {
    outline: none;
    border-color: #3498db;
}

.button-group {
    display: flex;
    gap: 10px;
}

.btn-primary, .btn-secondary {
    padding: 10px 20px;
    border: none;
    border-radius: 3px;
    font-size: 0.95em;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-primary {
    background: #3498db;
    color: white;
}

.btn-primary:hover {
    background: #2980b9;
}

.btn-secondary {
    background: #95a5a6;
    color: white;
}

.btn-secondary:hover {
    background: #7f8c8d;
}

.error-message {
    background: #fee;
    color: #c33;
    padding: 12px;
    border-radius: 3px;
    margin-top: 15px;
    border-left: 4px solid #c33;
    font-size: 0.9em;
}

.results-section {
    margin-top: 20px;
}

.results-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.result-panel {
    background: #fafafa;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    padding: 15px;
}

.tree-panel {
    min-width: 0;
}

.hex-panel {
    min-width: 0;
}

.result-panel h2 {
    font-size: 1.2em;
    margin-bottom: 15px;
    padding-bottom: 8px;
    border-bottom: 2px solid #e0e0e0;
    color: #2c3e50;
    font-weight: 600;
}

.tree-content {
    font-family: 'Courier New', monospace;
    font-size: 0.85em;
    line-height: 1.8;
    max-height: 600px;
    overflow: auto;
    background: white;
    padding: 10px;
    border: 1px solid #e0e0e0;
    border-radius: 3px;
}

.tree-node {
    margin-left: 20px;
    padding: 2px 4px;
    white-space: pre-wrap;
    cursor: pointer;
    border-radius: 2px;
    transition: background 0.15s;
    position: relative;
}

.tree-node:hover {
    background: #e3f2fd;
}

.tree-node.highlight {
    background: #fff3cd;
}

.tree-node-level-0 {
    margin-left: 0;
}

.tree-label {
    font-weight: 600;
    color: #2980b9;
}

.tree-value {
    color: #333;
}

.details-content {
    max-height: 500px;
    overflow: auto;
    background: white;
    padding: 10px;
    border: 1px solid #e0e0e0;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 0.85em;
}

.detail-item {
    margin-bottom: 12px;
    padding: 8px;
    background: #f9f9f9;
    border-left: 3px solid #3498db;
    border-radius: 2px;
}

.detail-label {
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 4px;
}

.detail-value {
    color: #555;
    white-space: pre-wrap;
    word-break: break-all;
}

.hex-viewer {
    border: 1px solid #e0e0e0;
    border-radius: 3px;
    overflow: auto;
    max-height: 600px;
    font-family: 'Courier New', monospace;
    font-size: 0.85em;
    background: white;
}

.hex-header {
    display: grid;
    grid-template-columns: 100px 1fr 200px;
    gap: 15px;
    padding: 8px 15px;
    background: #f8f8f8;
    font-weight: 600;
    border-bottom: 1px solid #ddd;
    position: sticky;
    top: 0;
    z-index: 10;
    color: #666;
    font-size: 0.9em;
}

.hex-row {
    display: grid;
    grid-template-columns: 100px 1fr 200px;
    gap: 15px;
    padding: 4px 15px;
    border-bottom: 1px solid #f5f5f5;
    transition: background 0.1s;
}

.hex-row:hover {
    background: #fafafa;
}

.hex-row.highlight {
    background: #fff9e6;
}

.offset-label, .hex-label, .ascii-label {
    padding: 0 5px;
}

.offset {
    color: #7f8c8d;
    font-weight: 500;
    font-size: 0.9em;
}

.hex-bytes {
    color: #2c3e50;
    word-break: break-all;
    letter-spacing: 0.5px;
}

.hex-byte {
    display: inline-block;
    padding: 0 2px;
    margin: 0;
    cursor: default;
    transition: background 0.1s;
}

.hex-byte:hover {
    background: #e8e8e8;
}

.hex-byte.highlight {
    background: #ffeb3b;
    font-weight: bold;
}

.ascii {
    color: #95a5a6;
    font-size: 0.85em;
    font-family: 'Courier New', monospace;
    letter-spacing: 1px;
}

.asn1-info {
    color: #2980b9;
    font-size: 0.8em;
    line-height: 1.4;
}

.asn1-tag {
    font-weight: 600;
    color: #8e44ad;
}

.asn1-oid {
    color: #27ae60;
    font-weight: 500;
}

/* Certificate annotation styles */
.cert-annotation {
    color: #e67e22;
    font-weight: 600;
    margin-left: 8px;
    font-style: normal;
}

.cert-label {
    color: #3498db;
    font-weight: 500;
}

.cert-value-important {
    color: #e74c3c;
    font-weight: 600;
}

/* Tree collapse/expand styles */
.tree-children {
    display: block;
}

.collapse-icon {
    display: inline-block;
    width: 16px;
    color: #7f8c8d;
    font-size: 0.9em;
    transition: transform 0.2s ease;
}

.tree-node[data-collapsed="true"] .collapse-icon {
    transform: rotate(-90deg);
}

.tree-node:hover .collapse-icon {
    color: #2c3e50;
}

.hex-byte.highlight-range {
    background: #ffeb3b;
    font-weight: bold;
}

.hex-row.highlight-range {
    background: #fff9e6;
}

.tooltip {
    position: fixed;
    background: #2c3e50;
    color: white;
    padding: 12px 16px;
    border-radius: 4px;
    font-size: 0.85em;
    font-family: 'Courier New', monospace;
    z-index: 10000;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    max-width: 450px;
    line-height: 1.6;
    white-space: pre-wrap;
}

.tooltip::after {
    content: '';
    position: absolute;
    top: -6px;
    left: 20px;
    border: 6px solid transparent;
    border-bottom-color: #2c3e50;
}

.tooltip-title {
    font-weight: 600;
    margin-bottom: 8px;
    color: #3498db;
    font-size: 1em;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    padding-bottom: 6px;
}

.tooltip-content {
    font-size: 0.9em;
    color: #ecf0f1;
}

footer {
    background: #f5f5f5;
    padding: 15px 30px;
    text-align: center;
    color: #666;
    border-top: 1px solid #e0e0e0;
    margin-top: 20px;
}

footer p {
    margin: 0;
    font-size: 0.9em;
}

@media (max-width: 1200px) {
    .results-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    main {
        padding: 15px;
    }
    
    .hex-header, .hex-row {
        grid-template-columns: 80px 1fr 150px;
        font-size: 0.8em;
        gap: 10px;
    }
    
    header h1 {
        font-size: 1.5em;
    }
}
