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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #333;
    background: #f5f5f5;
}

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 2rem;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

header p {
    font-size: 1.1rem;
    opacity: 0.95;
}

.tabs {
    display: flex;
    justify-content: center;
    background: white;
    border-bottom: 2px solid #e0e0e0;
    padding: 0;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.tab-button {
    padding: 1rem 2rem;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    color: #666;
    transition: all 0.3s ease;
    border-bottom: 3px solid transparent;
}

.tab-button:hover {
    background: #f8f8f8;
    color: #667eea;
}

.tab-button.active {
    color: #667eea;
    border-bottom-color: #667eea;
}

main {
    max-width: 1400px;
    margin: 2rem auto;
    padding: 0 1rem;
}

.tab-content {
    display: none;
    background: white;
    border-radius: 8px;
    padding: 2rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.tab-content.active {
    display: block;
}

/* Models Directory Styles */
.controls {
    margin-bottom: 1.5rem;
}

.search-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    align-items: center;
}

#searchBox {
    flex: 1;
    padding: 0.75rem;
    font-size: 1rem;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    transition: border-color 0.3s ease;
}

#searchBox:focus {
    outline: none;
    border-color: #667eea;
}

.action-buttons {
    display: flex;
    gap: 0.5rem;
}

.action-btn {
    padding: 0.75rem 1rem;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.3s ease;
    white-space: nowrap;
}

.action-btn:hover {
    background: #5568d3;
}

.filter-controls {
    display: flex;
    gap: 1.5rem;
}

.filter-controls label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.filter-controls input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.table-wrapper {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
}

thead {
    background: #f8f8f8;
}

th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    color: #555;
    cursor: pointer;
    user-select: none;
    position: relative;
    border-bottom: 2px solid #e0e0e0;
}

th:hover {
    background: #efefef;
}

.sort-arrow {
    font-size: 0.8rem;
    margin-left: 0.5rem;
    opacity: 0.3;
}

th.sorted .sort-arrow {
    opacity: 1;
}

td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #f0f0f0;
}

tbody tr:hover {
    background: #f9f9f9;
}

.free-badge {
    display: inline-block;
    background: #4caf50;
    color: white;
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 500;
}

.table-info {
    text-align: center;
    color: #666;
    font-size: 0.9rem;
    padding: 1rem 0;
}

/* Genealogy Styles */
.genealogy-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.path-controls {
    background: #f8f8f8;
    padding: 1rem;
    border-radius: 8px;
    border: 2px solid #e0e0e0;
}

.path-arrow {
    font-size: 1.5rem;
    color: #667eea;
    font-weight: bold;
    padding: 0 0.5rem;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.control-group label {
    font-weight: 500;
    color: #555;
}

#modelSelect,
#modelSelectFrom,
#modelSelectTo {
    padding: 0.5rem 1rem;
    font-size: 1rem;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    min-width: 250px;
    cursor: pointer;
}

#modelSelect:focus,
#modelSelectFrom:focus,
#modelSelectTo:focus {
    outline: none;
    border-color: #667eea;
}

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

.secondary-btn:hover {
    background: #5a6268;
}

button {
    padding: 0.5rem 1rem;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background 0.3s ease;
}

button:hover {
    background: #5568d3;
}

.info-panel {
    background: #f8f8f8;
    padding: 1rem;
    border-radius: 6px;
    margin-bottom: 1.5rem;
    color: #666;
}

.genealogy-container {
    width: 100%;
    height: 600px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    overflow: hidden;
    position: relative;
    background: #fafafa;
}

#genealogySvg {
    width: 100%;
    height: 100%;
}

/* Legend */
.legend {
    margin-top: 1.5rem;
    padding: 1rem;
    background: #f8f8f8;
    border-radius: 6px;
}

.legend h3 {
    margin-bottom: 0.75rem;
    font-size: 1rem;
    color: #555;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.legend-color {
    width: 30px;
    height: 20px;
    border-radius: 4px;
    border: 1px solid #ddd;
}

.legend-color.foundation {
    background: #ff6b6b;
}

.legend-color.commercial {
    background: #4ecdc4;
}

.legend-color.open {
    background: #95e1d3;
}

.legend-color.research {
    background: #ffd93d;
}

/* Node styles for genealogy graph */
.node circle {
    stroke: #fff;
    stroke-width: 2px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.node:hover circle {
    stroke-width: 3px;
    filter: brightness(1.1);
}

.node text {
    font-size: 12px;
    font-weight: 500;
    pointer-events: none;
}

.link {
    fill: none;
    stroke: #999;
    stroke-width: 2px;
    stroke-opacity: 0.6;
}

.link.highlighted {
    stroke: #667eea;
    stroke-width: 3px;
    stroke-opacity: 1;
}

.node.highlighted circle {
    stroke: #667eea;
    stroke-width: 4px;
}

.node.dimmed {
    opacity: 0.3;
}

.link.dimmed {
    opacity: 0.1;
}

.node.path-start circle {
    stroke: #4caf50;
    stroke-width: 5px;
    filter: drop-shadow(0 0 8px #4caf50);
}

.node.path-end circle {
    stroke: #f44336;
    stroke-width: 5px;
    filter: drop-shadow(0 0 8px #f44336);
}

.path-description {
    margin-top: 0.5rem;
    font-style: italic;
    color: #666;
    font-size: 0.95rem;
}

/* Footer */
footer {
    text-align: center;
    padding: 2rem;
    background: white;
    margin-top: 2rem;
    color: #666;
    font-size: 0.9rem;
    border-top: 1px solid #e0e0e0;
}

/* Notification */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #4caf50;
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    opacity: 0;
    transform: translateX(400px);
    transition: all 0.3s ease;
    z-index: 10000;
    font-weight: 500;
}

.notification.show {
    opacity: 1;
    transform: translateX(0);
}

/* Responsive Design */
@media (max-width: 768px) {
    header h1 {
        font-size: 1.8rem;
    }

    .tabs {
        flex-direction: column;
    }

    .tab-button {
        width: 100%;
        text-align: left;
    }

    .search-row {
        flex-direction: column;
        align-items: stretch;
    }

    #searchBox {
        width: 100%;
    }

    .action-buttons {
        flex-wrap: wrap;
        justify-content: stretch;
    }

    .action-btn {
        flex: 1;
        min-width: 120px;
    }

    .genealogy-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .path-controls {
        flex-direction: column;
    }

    .path-arrow {
        text-align: center;
        padding: 0.5rem 0;
        transform: rotate(90deg);
    }

    .control-group {
        flex-direction: column;
        align-items: stretch;
    }

    #modelSelect,
    #modelSelectFrom,
    #modelSelectTo {
        width: 100%;
    }

    table {
        font-size: 0.85rem;
    }

    th, td {
        padding: 0.5rem;
    }
}
