:root {
    --tools-container-max-width: 1400px;
    --viewer-blue: #005fcc;
    --viewer-blue-dark: #004a99;
    --viewer-green: #1f7a35;
    --viewer-green-dark: #17672c;
}

.controls {
    padding: 20px 0;
    border-bottom: 1px solid #ddd;
}

.search-box {
    position: relative;
    margin-bottom: 15px;
}

.search-box input {
    width: 100%;
    padding: 10px 12px;
    padding-right: 38px;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 1rem;
    box-sizing: border-box;
}

.search-box input:focus {
    outline: none;
    border-color: var(--viewer-blue);
    box-shadow: 0 0 0 3px rgba(0, 95, 204, 0.16);
}

.clear-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 1.2rem;
    color: #555;
    cursor: pointer;
    padding: 4px 8px;
    opacity: 0;
    transition: opacity 0.2s ease, color 0.2s ease;
    width: auto;
    margin: 0;
}

.clear-btn.visible {
    opacity: 1;
}

.clear-btn:hover {
    color: var(--viewer-blue);
}

.filter-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.filter-btn {
    padding: 8px 12px;
    background: white;
    border: 2px solid #ddd;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
    width: auto;
    margin: 0;
    color: #333;
}

.filter-btn:hover {
    border-color: var(--viewer-blue);
    color: var(--viewer-blue);
}

.filter-btn.active {
    background: var(--viewer-blue);
    color: white;
    border-color: var(--viewer-blue);
}

.stats-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 0;
    border-bottom: 1px solid #ddd;
    font-size: 0.9rem;
    color: #555;
}

.export-btn {
    padding: 8px 16px;
    background: var(--viewer-green);
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
    width: auto;
    margin: 0;
}

.export-btn:hover {
    background: var(--viewer-green-dark);
    transform: translateY(-1px);
    box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.1);
}

.content {
    padding: 30px 0;
}

.code-section {
    margin-bottom: 40px;
}

.code-section.hidden {
    display: none;
}

.code-section h2 {
    font-size: 1.5rem;
    margin-bottom: 20px;
    color: #1e3a8a;
    border-bottom: 2px solid var(--viewer-blue);
    padding-bottom: 8px;
    text-align: left;
}

.codes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.code-card {
    background: white;
    border: 1px solid #ddd;
    border-radius: 5px;
    padding: 15px;
    transition: all 0.2s ease;
    cursor: pointer;
}

.code-card:hover {
    box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.1);
    border-color: var(--viewer-blue);
    transform: translateY(-2px);
}

.code-card.hidden {
    display: none;
}

.code-header {
    display: flex;
    align-items: baseline;
    margin-bottom: 10px;
    gap: 8px;
}

.code-number {
    background: var(--viewer-blue);
    color: white;
    padding: 4px 10px;
    border-radius: 4px;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.code-name {
    font-weight: 600;
    color: #222;
    font-size: 0.95rem;
    flex: 1;
}

.code-description {
    color: #555;
    font-size: 0.9rem;
    margin-bottom: 10px;
    line-height: 1.5;
}

.hierarchy-block {
    margin-bottom: 10px;
    padding: 8px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    font-size: 0.85rem;
}

.hierarchy-item + .hierarchy-item {
    margin-top: 6px;
}

.hierarchy-item a {
    color: #1d4ed8;
    text-decoration: underline;
}

.code-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    font-size: 0.8rem;
}

.meta-tag {
    background: #f0f0f0;
    padding: 4px 8px;
    border-radius: 4px;
    color: #555;
    border-left: 3px solid #ddd;
}

.meta-tag.validity {
    border-left-color: #ffc107;
}

.meta-tag.flag {
    background: #fff3cd;
    border-left-color: #ffc107;
}

.meta-tag.funding {
    background: #edf8ef;
    border-left-color: var(--viewer-green);
    color: #155724;
}

.no-results {
    grid-column: 1 / -1;
    text-align: center;
    padding: 30px 20px;
    color: #555;
}

.no-results h3 {
    font-size: 1.1rem;
    margin-bottom: 8px;
}

.no-results p {
    font-size: 0.9rem;
}

@media (max-width: 768px) {
    .codes-grid {
        grid-template-columns: 1fr;
    }

    .stats-bar {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }

    .filter-controls {
        gap: 6px;
    }

    .filter-btn {
        padding: 6px 10px;
        font-size: 0.8rem;
    }

    .code-section h2 {
        font-size: 1.2rem;
    }
}
