:root {
    --bd-deep: #1a3d6b;
    --bd-primary: #2b5ea7;
    --bd-primary-light: #e8f0fa;
    --bd-primary-muted: #c5d8f0;
    --text: #1a1a1a;
    --muted: #5c6670;
    --border: #d0dae6;
    --bg: #f7f9fc;
    --white: #fff;
    --tag-required-bg: #d4edda;
    --tag-required-text: #1e6b3a;
    --tag-optional-bg: #e8dff5;
    --tag-optional-text: #5b3d8a;
    --tag-recommended-bg: #d6ebf7;
    --tag-recommended-text: #1a5f8a;
    --tag-updated-bg: #fff3cd;
    --tag-updated-text: #856404;
    --prereq-bg: #edf7ef;
    --prereq-border: #6db87a;
    --section-accent: #e67e22;
    --row-alt: #f4f8fc;
    --surface-hover: #fafbfc;
    --alert-text: #8b1a1a;
    --alert-bg: #fdf3f3;
    --alert-border: #e8b4b4;
    --caution-text: #7a4f01;
    --caution-border: #e6d9a8;
    --overlay-scrim: rgba(26, 61, 107, 0.4);
}

* { box-sizing: border-box; }

html, body {
    height: 100%;
    margin: 0;
}

body {
    display: flex;
    flex-direction: column;
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

.page {
    flex: 1;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    padding: 2rem 1.5rem 3rem;
}

/* Page header */
.page-header {
    border-bottom: 3px solid var(--bd-deep);
    padding-bottom: 1rem;
    margin-bottom: 1.25rem;
}

.page-overline {
    margin: 0 0 0.25rem;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--bd-deep);
}

.page-header h1 {
    margin: 0 0 0.5rem;
    font-size: 2rem;
    font-weight: 700;
    color: var(--bd-deep);
    letter-spacing: -0.01em;
    line-height: 1.2;
}

.page-header .subtitle {
    margin: 0;
    font-size: 1.1rem;
    font-style: italic;
    color: var(--muted);
    line-height: 1.4;
}

/* Tab layout */
.tab-layout {
    display: flex;
    align-items: flex-start;
    gap: 1.25rem;
}

.tab-nav {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-width: 220px;
    max-width: 240px;
    flex-shrink: 0;
}

.sidebar-disclaimer {
    margin-top: 0.75rem;
    padding: 0.75rem 0.85rem;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 6px;
}

.sidebar-disclaimer-heading {
    margin: 0 0 0.45rem;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--bd-deep);
}

.sidebar-disclaimer-text {
    margin: 0;
    font-size: 0.68rem;
    font-style: italic;
    line-height: 1.45;
    color: var(--muted);
}

.tab-panels {
    flex: 1;
    min-width: 0;
}

.mode-btn {
    padding: 0.55rem 0.9rem;
    font-size: 0.85rem;
    font-weight: 600;
    border: 1px solid var(--bd-primary-muted);
    border-radius: 6px;
    background: var(--bd-primary-light);
    color: var(--bd-deep);
    cursor: pointer;
    text-align: left;
    width: 100%;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.mode-btn.active {
    background: var(--bd-deep);
    color: var(--white);
    border-color: var(--bd-deep);
}

.mode-btn:not(.active):hover {
    background: var(--bd-primary-muted);
}

.tab-content {
    display: none;
}

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

/* Cards / sections */
.card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.25rem 1.5rem;
    margin-bottom: 1rem;
}

.content-heading {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--bd-deep);
    margin: 0 0 1rem;
}

/* Collapsible sections */
details > summary {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--bd-deep);
    cursor: pointer;
    user-select: none;
    padding: 0.25rem 0 0.75rem;
    list-style: none;
    border-radius: 4px;
}

details > summary:hover {
    background: var(--surface-hover);
}

details > summary::-webkit-details-marker { display: none; }

details > summary::before {
    content: "▾ ";
    color: var(--section-accent);
    font-size: 0.85rem;
}

details:not([open]) > summary::before {
    content: "▸ ";
}

details p,
details ul,
details ol {
    font-size: 0.9rem;
    color: var(--text);
}

details h4 {
    color: var(--bd-deep);
    margin: 1rem 0 0.5rem;
    font-size: 0.95rem;
}

/* Forms */
.form-group {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1rem;
    align-items: start;
    width: 100%;
}

.form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text);
    text-align: left;
}

.unit-text {
    text-transform: none;
    letter-spacing: normal;
}

.input-field {
    border: 1px solid var(--border);
    outline: none;
    padding: 0.5rem 0.65rem;
    width: 100%;
    border-radius: 6px;
    font-size: 0.875rem;
    background: var(--white);
    color: var(--text);
    transition: border-color 0.15s;
}

.input-field:focus {
    border-color: var(--bd-primary);
}

.input-details {
    font-size: 0.8rem;
    color: var(--alert-text);
    width: 100%;
}

.checkbox-row {
    margin: 0.5rem 0;
}

.checkbox-row label {
    font-size: 0.9rem;
    font-weight: 400;
    text-transform: none;
    letter-spacing: normal;
}

.brand-highlight {
    color: var(--bd-primary);
    font-weight: 600;
}

.alert-note {
    font-size: 0.85rem;
    color: var(--alert-text);
    background: var(--alert-bg);
    border: 1px solid var(--alert-border);
    border-radius: 6px;
    padding: 0.6rem 0.85rem;
    margin: 0.5rem 0;
}

.alert-note ul {
    margin: 0.25rem 0;
    padding-left: 1.25rem;
}

.msg-warning,
.msg-instruction,
.msg-caution,
.msg-recommendation {
    font-size: 0.875rem;
    border-radius: 6px;
    padding: 0.6rem 0.85rem;
    margin: 0.75rem 0 0;
}

.msg-warning {
    color: var(--alert-text);
    background: var(--alert-bg);
    border: 1px solid var(--alert-border);
}

.msg-instruction {
    color: var(--bd-deep);
    background: var(--bd-primary-light);
    border: 1px solid var(--bd-primary-muted);
}

.msg-caution {
    color: var(--caution-text);
    background: var(--tag-updated-bg);
    border: 1px solid var(--caution-border);
}

.msg-recommendation {
    color: var(--tag-recommended-text);
    background: var(--tag-recommended-bg);
    border: 1px solid var(--bd-primary-muted);
}

#libraryDilutionTable tbody tr td.indexed-vol-low {
    background: var(--alert-bg) !important;
    color: var(--alert-text) !important;
    font-weight: 700;
    box-shadow: inset 0 0 0 2px var(--alert-border);
    vertical-align: top;
}

#libraryDilutionTable tbody tr td.indexed-vol-low--span-step1 {
    min-width: 18rem;
}

#libraryDilutionTable tbody tr.low-indexed-prep-data-row td.prep-row-spacer {
    background: transparent;
    box-shadow: none;
}

.low-indexed-prep {
    margin: 0.5rem 0 1rem;
}

.low-indexed-prep--in-cell {
    margin: 0;
}

.low-indexed-prep table {
    width: auto;
    margin-top: 0.5rem;
}

.low-indexed-prep--in-cell table {
    width: 100%;
    margin-top: 0.25rem;
    font-size: 0.72rem;
}

.low-indexed-prep--in-cell th,
.low-indexed-prep--in-cell td {
    padding: 0.25rem 0.4rem;
    white-space: nowrap;
}

.prep-table-label {
    margin: 0.75rem 0 0;
    color: var(--bd-deep);
    font-size: 0.8rem;
    font-weight: 700;
}

.low-indexed-prep--in-cell .prep-table-label {
    margin: 0;
    font-size: 0.7rem;
}

.warning-guide-img {
    display: block;
    max-width: min(720px, 100%);
    height: auto;
    margin-top: 0.75rem;
    border: 1px solid var(--bd-border, #d0d9e4);
    border-radius: 6px;
}

/* Tables */
.table-wrap {
    overflow-x: auto;
    margin-bottom: 1rem;
}

.table-wrap--fit {
    overflow: visible;
}

#tableContainer .card,
#tableContainer {
    overflow: visible;
}

caption {
    caption-side: top;
    text-align: left;
    margin-bottom: 0.5rem;
    font-weight: 700;
    font-size: 1rem;
    color: var(--bd-deep);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
    margin-bottom: 1.25rem;
}

th {
    background: var(--bd-deep);
    color: var(--white);
    text-align: left;
    padding: 0.55rem 0.75rem;
    font-weight: 600;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border: none;
    vertical-align: bottom;
}

th .th-unit {
    text-transform: none;
    letter-spacing: normal;
}

td {
    padding: 0.55rem 0.75rem;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
    background: var(--white);
}

tbody tr:nth-child(even) td {
    background: var(--row-alt);
}

tbody tr:last-child td {
    border-bottom: none;
}

table input[type="text"],
table input[type="number"],
table select {
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.35rem 0.5rem;
    font-size: 0.82rem;
    width: 100%;
    max-width: 8rem;
    background: var(--white);
    color: var(--text);
}

table input[type="button"] {
    font-size: 0.75rem;
    padding: 0.3rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bd-primary-light);
    color: var(--bd-deep);
    cursor: pointer;
}

table input[type="button"]:hover {
    background: var(--bd-primary-muted);
}

.text-highlight {
    color: var(--bd-primary);
    font-weight: 700;
}

.footnote {
    font-size: 0.85rem;
    color: var(--muted);
    margin-top: 0.5rem;
}

/* Pills (design-system badges) */
.pill,
th .req-required,
th .req-optional {
    display: inline-block;
    margin-top: 0.3rem;
    padding: 0.12rem 0.4rem;
    border-radius: 4px;
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    line-height: 1.3;
    white-space: nowrap;
}

.pill.required,
th .req-required {
    background: var(--tag-required-bg);
    color: var(--tag-required-text);
}

.pill.optional,
th .req-optional {
    background: var(--tag-optional-bg);
    color: var(--tag-optional-text);
}

/* Input table — fit full width without horizontal scroll */
.input-table {
    table-layout: fixed;
    width: 100%;
    font-size: 0.75rem;
}

.input-table th,
.input-table td {
    padding: 0.35rem 0.3rem;
}

.input-table th {
    white-space: normal;
    line-height: 1.25;
    letter-spacing: 0.02em;
    font-size: 0.65rem;
    overflow: visible;
}

.input-table td {
    overflow: visible;
    vertical-align: middle;
}

.input-table col.col-lib { width: 12%; }
.input-table col.col-idx { width: 8%; }
.input-table col.col-assay { width: 11%; }
.input-table col.col-qubit { width: 13%; }
.input-table col.col-size { width: 13%; }
.input-table col.col-cells { width: 9%; }
.input-table col.col-reads { width: 13%; }
.input-table col.col-action { width: 11%; }

.input-table input[type="text"],
.input-table input[type="number"],
.input-table select {
    width: 100%;
    max-width: none;
    min-width: 0;
    padding: 0.25rem 0.3rem;
    font-size: 0.75rem;
    box-sizing: border-box;
}

.input-table select {
    padding-right: 1.25rem;
}

.input-table .cell-input-wrap {
    display: flex;
    align-items: center;
    gap: 0.15rem;
    min-width: 0;
}

.input-table .cell-input-wrap input {
    flex: 1;
    min-width: 0;
    width: auto;
}

.input-table .info-button {
    flex-shrink: 0;
    margin: 0;
    width: 0.8rem;
    height: 0.8rem;
    font-size: 0.55rem;
}

.input-table input[type="button"] {
    width: 100%;
    max-width: none;
    font-size: 0.65rem;
    padding: 0.25rem 0.2rem;
    white-space: normal;
    line-height: 1.2;
    text-align: center;
}

/* Buttons */
.btn-download {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--white);
    background: var(--bd-deep);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    margin: 0.5rem 0;
    transition: background 0.15s;
}

.btn-download:hover {
    background: var(--bd-primary);
}

.project-actions,
.export-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 0.65rem;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border, #d7dee8);
}

.export-actions {
    border-top: none;
    padding-top: 0;
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    padding: 0.4rem 0.85rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--bd-deep);
    background: #fff;
    border: 1.5px solid var(--bd-deep);
    border-radius: 6px;
    cursor: pointer;
    margin: 0;
}

.btn-secondary:hover {
    background: var(--bd-primary-light, #e8f0fa);
}

.btn-secondary--muted {
    color: #5c6670;
    border-color: #b9c4ce;
}

.btn-file {
    cursor: pointer;
}

.project-status {
    font-size: 0.8rem;
    color: #5c6670;
}

.project-hint {
    margin: 0.35rem 0 0;
    font-size: 0.78rem;
    color: #5c6670;
}

.draft-banner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 0.75rem;
    margin: 0 0 1rem;
    padding: 0.75rem 1rem;
    background: var(--bd-primary-light, #e8f0fa);
    border: 1px solid var(--bd-primary, #2b5ea7);
    border-radius: 6px;
    font-size: 0.9rem;
    color: var(--bd-deep);
}

.draft-banner[hidden] {
    display: none;
}

/* Tooltips */
.tooltip {
    position: relative;
}

.tooltip .tooltiptext {
    visibility: hidden;
    width: 8rem;
    font-size: 0.7rem;
    background: var(--bd-deep);
    color: var(--white);
    text-align: center;
    border-radius: 6px;
    padding: 0.35rem 0.5rem;
    position: absolute;
    z-index: 1;
    bottom: 150%;
    left: 50%;
    margin-left: -4rem;
    text-transform: none;
    letter-spacing: normal;
    font-weight: 400;
}

.tooltip .tooltiptext::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -0.3rem;
    border-width: 0.3rem;
    border-style: solid;
    border-color: var(--bd-deep) transparent transparent transparent;
}

.tooltip:hover .tooltiptext {
    visibility: visible;
}

.info-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--bd-primary);
    color: var(--white);
    border: none;
    border-radius: 50%;
    font-size: 0.6rem;
    line-height: 1;
    position: relative;
    cursor: pointer;
    width: 0.9rem;
    height: 0.9rem;
    padding: 0;
}

.info-button--active {
    background: var(--bd-deep);
}

.info-popover {
    display: none;
    position: fixed;
    z-index: 2000;
    background: var(--bd-deep);
    color: var(--white);
    padding: 0.5rem 0.65rem;
    border-radius: 6px;
    font-size: 0.75rem;
    line-height: 1.45;
    text-align: left;
    white-space: normal;
    box-shadow: 0 4px 12px color-mix(in srgb, var(--bd-deep) 25%, transparent);
    pointer-events: none;
}

.info-popover.visible {
    display: block;
    pointer-events: auto;
}

/* Status / info banners */
.submitInfoDisplay {
    display: none;
    background: var(--bd-primary-light);
    color: var(--bd-deep);
    border: 1px solid var(--bd-primary-muted);
    border-radius: 8px;
    font-size: 0.875rem;
    padding: 0.75rem 1.25rem;
    margin-bottom: 0.75rem;
}

/* Initially hidden panels (shown by JS) */
#novaseqMessage,
#avitiMessage,
#tableContainer,
#resultsContainer,
#recommendationContainer {
    display: none;
}

/* Links */
a {
    color: var(--bd-primary);
}

a:hover {
    color: var(--bd-deep);
}

strong, h3, h4 {
    color: var(--bd-deep);
}

h3 {
    font-size: 1.15rem;
    font-weight: 700;
    margin: 0 0 1rem;
}

/* Images */
.card img {
    max-width: 80%;
    height: auto;
}

.card iframe {
    display: block;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--white);
}

.input-table .row-spacer td {
    height: 1.25rem;
    padding: 0;
    border: none;
    background: transparent;
}

/* Footer */
footer {
    margin-top: auto;
    color: var(--muted);
    text-align: center;
    padding: 0.75rem 1rem;
    width: 100%;
    background: var(--white);
    border-top: 1px solid var(--border);
    font-size: 0.85rem;
}

/* Overlay (legacy) */
.overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--overlay-scrim);
    z-index: 100;
    align-items: center;
    justify-content: center;
}

.overlayContent {
    background: var(--white);
    border-radius: 8px;
    padding: 1.5rem;
    max-width: 90%;
    border: 1px solid var(--border);
}

/* Responsive */
@media (max-width: 750px) {
    .page {
        padding: 1.25rem 1rem 2rem;
    }

    .page-header h1 {
        font-size: 1.5rem;
    }

    .page-header .subtitle {
        font-size: 0.95rem;
    }

    .tab-layout {
        flex-direction: column;
    }

    .tab-nav {
        flex-direction: row;
        flex-wrap: wrap;
        min-width: 0;
        max-width: none;
        width: 100%;
    }

    .sidebar-disclaimer {
        flex-basis: 100%;
        order: 10;
        margin-top: 0.5rem;
    }

    .mode-btn {
        width: auto;
        flex: 1 1 auto;
        text-align: center;
        font-size: 0.8rem;
    }

    .form-group {
        grid-template-columns: 1fr;
    }

    .table-wrap--fit {
        overflow-x: auto;
    }
}
