body {
    font-family: 'Roboto', sans-serif;
    margin: 0;
    background-color: #f0f2f5;
    color: #333;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    line-height: 1.4;
}

header {
    background-color: #2c3e50;
    color: #fff;
    padding: 1em;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

header nav {
    margin-top: 10px;
}

header nav a {
    color: #fff;
    margin: 0 10px;
    text-decoration: none;
}

header nav a:hover {
    text-decoration: underline;
}

main {
    display: flex;
    flex-grow: 1;
    padding: 20px;
    gap: 20px;
}

.sorted-main {
    display: block;
}

#side-panels {
    display: flex;
    flex-direction: column;
    gap: 20px;
    flex: 1;
}

#tech-tree-container {
    flex: 3; /* Takes more space */
    border: 1px solid #ddd;
    border-radius: 8px;
    background-color: #fff;
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
    overflow: auto; /* For pan/scroll if tree is big */
    position: relative; /* For positioning nodes absolutely if doing manually */
/* min-height: 0 allows the container to shrink correctly if its own content tries to overflow. */
    min-height: 0;
    height: 80vh; /* Ensure the canvas has some initial height */
}

#sorted-tech-container {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 8px;
    background-color: #fff;
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
    overflow: auto;
    padding: 15px;
}

.sorted-toolbar {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) minmax(145px, 170px) minmax(160px, 210px) minmax(180px, 230px) minmax(140px, 170px) minmax(150px, 190px);
    gap: 10px;
    position: sticky;
    top: 0;
    z-index: 2;
    padding-bottom: 12px;
    background: #fff;
}

.sorted-toolbar input,
.sorted-toolbar select {
    width: 100%;
    box-sizing: border-box;
    padding: 9px 10px;
    border: 1px solid #c9d0d8;
    border-radius: 4px;
    background: #fff;
    color: #26313d;
    font: inherit;
}

.sorted-summary {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
    color: #5c6670;
    font-size: 14px;
}

.sorted-era-section {
    margin-bottom: 22px;
}

.sorted-era-section h2 {
    margin: 0 0 8px;
    padding-left: 10px;
    border-left: 5px solid var(--era-color);
    font-size: 20px;
}

.sorted-table {
    width: 100%;
    min-width: 980px;
    border-collapse: collapse;
    table-layout: fixed;
    font-size: 14px;
}

.sorted-table th,
.sorted-table td {
    padding: 8px 10px;
    border-bottom: 1px solid #e4e8ed;
    vertical-align: top;
    text-align: left;
}

.sorted-table thead th {
    position: sticky;
    top: 52px;
    z-index: 1;
    background: #f8fafc;
    color: #3a4652;
    font-size: 12px;
    text-transform: uppercase;
}

.sorted-table tbody tr:hover {
    background: #f8fafc;
}

.sorted-table th:nth-child(1) {
    width: 19%;
}

.sorted-table th:nth-child(2) {
    width: 9%;
}

.sorted-table th:nth-child(3) {
    width: 6%;
}

.sorted-table th:nth-child(4),
.sorted-table th:nth-child(5) {
    width: 20%;
}

.sorted-table a {
    color: #1f5f91;
    text-decoration: none;
    font-weight: 700;
}

.sorted-table a:hover {
    text-decoration: underline;
}

.tech-id {
    display: block;
    margin-top: 2px;
    overflow-wrap: anywhere;
    color: #6d7780;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
    font-weight: 400;
}

.maturity-badge {
    display: inline-flex;
    margin-top: 5px;
    padding: 2px 6px;
    border: 1px solid #c8d2dc;
    border-radius: 4px;
    background: #f7f9fb;
    color: #46515d;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
}

.maturity-approved {
    border-color: #8fc19b;
    background: #edf8f0;
    color: #256236;
}

.maturity-forecast {
    border-color: #c9b06f;
    background: #fff8e5;
    color: #765a08;
}

.era-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.era-badge::before {
    content: '';
    width: 10px;
    height: 10px;
    border-radius: 2px;
    background: var(--era-color);
}

.relationship-cell {
    color: #4b5662;
}

.sorted-empty {
    padding: 20px 0;
    color: #65717d;
}

.sorted-more {
    display: block;
    margin: 8px auto 0;
}

.branch-section {
    margin-bottom: 18px;
    border: 1px solid #e2e7ec;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
}

.branch-section h2 {
    margin: 0;
    padding: 10px 12px;
    background: #f7f9fb;
    border-bottom: 1px solid #e2e7ec;
    font-size: 16px;
}

.branch-era-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(150px, 1fr));
    min-width: 1120px;
}

.branch-era-column {
    min-height: 90px;
    padding: 8px;
    border-right: 1px solid #edf0f3;
}

.branch-era-column:last-child {
    border-right: 0;
}

.branch-era-column h3 {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0 0 8px;
    color: #46515d;
    font-size: 12px;
    text-transform: uppercase;
}

.branch-era-column h3::before {
    content: '';
    width: 9px;
    height: 9px;
    border-radius: 2px;
    background: var(--era-color);
}

.branch-tech-chip {
    display: block;
    margin-bottom: 5px;
    padding: 4px 6px;
    border-left: 3px solid var(--era-color);
    border-radius: 4px;
    background: #f9fbfd;
    color: #26313d;
    font-size: 12px;
    line-height: 1.25;
    text-decoration: none;
}

.branch-tech-chip[data-maturity='forecast'] {
    background: #fff8e5;
}

.branch-tech-chip[data-maturity='approved'] {
    background: #edf8f0;
}

.branch-tech-chip:hover {
    background: #eef5fb;
    color: #174b73;
}

.branch-empty {
    color: #a0a8b0;
}


#tech-info-panel {
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 15px;
    background-color: #fff;
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
    height: fit-content; /* So it doesn't stretch full height initially */
}

#tech-info-panel button {
    margin-right: 5px;
    margin-top: 10px;
}

#search-tech {
    width: 100%;
    margin-bottom: 10px;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
}

#era-filter,
#field-filter {
    width: 100%;
    margin-bottom: 10px;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
}

.graph-focus-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 10px;
    color: #46515d;
    font-size: 14px;
}

.graph-focus-toggle input {
    width: 16px;
    height: 16px;
    margin: 0;
}

.graph-context-summary {
    margin: 0 0 12px;
    color: #64707c;
    font-size: 13px;
}

#tech-name {
    margin: 0 0 4px;
    color: #26313d;
    font-size: 18px;
    font-weight: 700;
}

#tech-era,
#tech-description,
#tech-prerequisites {
    margin: 0 0 8px;
}

.tech-relationships {
    display: grid;
    gap: 10px;
    margin: 12px 0 4px;
    padding-top: 10px;
    border-top: 1px solid #e2e7ec;
}

.tech-metadata {
    display: grid;
    gap: 7px;
    margin: 10px 0;
    padding: 10px 0;
    border-top: 1px solid #e2e7ec;
    border-bottom: 1px solid #e2e7ec;
    color: #46515d;
    font-size: 13px;
}

.tech-metadata[hidden] {
    display: none;
}

.tech-metadata p {
    margin: 0;
}

.tech-metadata h3 {
    margin: 0 0 4px;
    color: #46515d;
    font-size: 12px;
    text-transform: uppercase;
}

.tech-metadata ul {
    margin: 0;
    padding-left: 18px;
}

.tech-metadata a {
    color: #1f5f91;
}

.tech-relationships[hidden] {
    display: none;
}

.tech-relationships h3 {
    margin: 0 0 6px;
    color: #46515d;
    font-size: 12px;
    text-transform: uppercase;
}

.relationship-chip-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.relationship-chip {
    max-width: 100%;
    margin: 0;
    padding: 5px 7px;
    border: 1px solid #c8d2dc;
    border-radius: 4px;
    background: #f7f9fb;
    color: #26313d;
    overflow-wrap: anywhere;
    text-align: left;
    font-size: 12px;
    line-height: 1.2;
}

#tech-info-panel .relationship-chip {
    margin: 0;
}

.relationship-chip:hover {
    background: #e9f1f8;
    color: #174b73;
}

.relationship-empty {
    color: #8a949e;
    font-size: 13px;
}

#tech-add-panel {
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 15px;
    background-color: #fff;
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
    height: fit-content;
}

#era-legend {
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 15px;
    background-color: #fff;
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
    height: fit-content;
}

.legend-item {
    display: flex;
    align-items: center;
    margin-bottom: 6px;
    font-size: 14px;
}

.legend-swatch {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    margin-right: 6px;
    display: inline-block;
}

#tech-add-panel input,
#tech-add-panel textarea {
    width: 100%;
    margin-bottom: 10px;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
}

#tech-info-panel h2 {
    margin-top: 0;
}

button {
    background-color: #2c3e50;
    color: #fff;
    border: none;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
}

button:disabled {
    background-color: #bbb;
    cursor: not-allowed;
}

button:hover:not(:disabled) {
    background-color: #1a252f;
}

@media (max-width: 900px) {
    main {
        flex-direction: column;
        padding: 12px;
    }

    #tech-tree-container {
        flex: none;
        height: 62vh;
    }

    .sorted-toolbar {
        grid-template-columns: 1fr;
    }

    .sorted-table thead th {
        top: 150px;
    }
}

/* Basic Node Styling (if rendering manually - Vis.js/D3 will have their own ways) */
.tech-node {
    position: absolute; /* Example for manual layout */
    border: 1px solid #2c3e50;
    background-color: #e8f1fa;
    padding: 5px 10px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.8em;
    text-align: center;
    min-width: 80px; /* Ensure some width */
}

.tech-node:hover {
    background-color: #cde0f2;
}

/* Line styling (very tricky to do well with just CSS/HTML for complex graphs) */
/* This is where a library shines. */
