:root {
    --c-navy: #0f2340;
    --c-teal: #0d7a6e;
    --c-teal-light: #13a394;
    --c-orange: #e07b2a;
    --c-bg: #f7f8fa;
    --c-surface: #ffffff;
    --c-border: #dee2e6;
    --c-text: #1a2233;
    --c-muted: #6c757d;
    --c-success: #1a7a4a;
    --c-danger: #b02a37;
    --c-warning: #8a6500;
    --radius-sm: 4px;
    --radius: 6px;
    --radius-lg: 8px;
    --shadow-sm: 0 1px 2px rgba(15, 35, 64, .06);
    --shadow: 0 2px 6px rgba(15, 35, 64, .08);
}

body {
    margin: 0;
    background-color: var(--c-bg);
    color: var(--c-text);
    font-family: "Inter", "Segoe UI", system-ui, sans-serif;
    font-size: .9375rem;
    line-height: 1.5;
}

a {
    color: var(--c-teal);
    text-decoration: none;
}

a:hover {
    color: var(--c-teal-light);
    text-decoration: underline;
}

.navbar {
    background-color: var(--c-navy);
    padding-top: 0;
    padding-bottom: 0;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .2);
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: 1.12rem;
    font-weight: 700;
    color: #fff;
    padding: 14px 0;
}

.navbar-brand:hover {
    color: #fff;
    text-decoration: none;
}

.brand-dot {
    color: var(--c-orange);
}

.navbar-nav .nav-link {
    color: rgba(255, 255, 255, .75);
    font-size: .82rem;
    font-weight: 600;
    padding: 12px 9px;
    border-bottom: 3px solid transparent;
}

.navbar-nav .nav-link:hover,
.navbar-nav .nav-link.active {
    color: #fff;
    border-bottom-color: var(--c-orange);
    text-decoration: none;
}

.nav-status {
    color: rgba(255, 255, 255, .65) !important;
}

.navbar-toggler {
    border-color: rgba(255, 255, 255, .3);
}

.navbar-toggler-icon {
    filter: invert(1);
}

.termoflow-credit {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    white-space: nowrap;
    font-size: .75rem;
    line-height: 1.5;
    text-decoration: none;
}

.termoflow-credit-name {
    font-size: .82rem;
    font-weight: 650;
    letter-spacing: .015em;
}

.termoflow-credit-arrow {
    flex-shrink: 0;
    opacity: .65;
}

.termoflow-credit:hover {
    text-decoration: none;
}

.termoflow-credit:hover .termoflow-credit-name {
    text-decoration: underline;
    text-underline-offset: .2em;
}

.termoflow-credit:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 5px;
    border-radius: 2px;
}

.termoflow-credit-header {
    margin-left: auto;
    padding: .2rem 0 .2rem 1.1rem;
    border-left: 1px solid rgba(255, 255, 255, .2);
    color: #fff;
}

.termoflow-credit-header .termoflow-credit-label {
    color: #c0cddd;
}

.termoflow-credit-header:hover {
    color: #fff;
}

.navbar-toggler {
    order: 1;
}

.navbar-collapse {
    order: 2;
}

.termoflow-credit-header {
    order: 3;
}

.app-content {
    padding-top: .5rem;
    padding-bottom: 3rem;
}

.app-footer {
    border-top: 1px solid var(--c-border);
    color: var(--c-muted);
    font-size: .75rem;
}

.app-footer-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .75rem 1.5rem;
}

.termoflow-credit-footer .termoflow-credit-label {
    color: var(--c-muted);
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.page-kicker {
    margin-bottom: .25rem;
    color: var(--c-muted);
    font-size: .78rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.page-subtitle {
    max-width: 760px;
    color: var(--c-muted);
}

.form-shell,
.section-card {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 1rem;
    margin-bottom: 1rem;
}

.section-title,
.form-section-title {
    margin: 0 0 .85rem;
    color: var(--c-muted);
    font-size: .78rem;
    font-weight: 700;
    letter-spacing: .07em;
    text-transform: uppercase;
}

.form-section-title {
    padding-bottom: .75rem;
    border-bottom: 1px solid var(--c-border);
}

.form-actions,
.action-row,
.table-actions,
.table-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .65rem;
}

.form-actions {
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid var(--c-border);
}

.table-toolbar {
    justify-content: space-between;
    margin-bottom: .85rem;
}

.table-actions {
    justify-content: flex-end;
    flex-wrap: nowrap;
    gap: .4rem;
    white-space: nowrap;
}

.table-action-cell {
    width: 1%;
    white-space: nowrap;
}

.table-actions .btn {
    white-space: nowrap;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    min-height: 38px;
    padding: .5rem .9rem;
    border-radius: var(--radius);
    font-weight: 600;
}

.btn-sm {
    min-height: 32px;
    padding: .35rem .65rem;
    font-size: .875rem;
    border-radius: var(--radius-sm);
}

.btn-primary {
    background-color: var(--c-teal);
    border-color: var(--c-teal);
    color: #fff;
}

.btn-primary:hover,
.btn-primary:focus {
    background-color: var(--c-teal-light);
    border-color: var(--c-teal-light);
    color: #fff;
}

.btn-outline-primary {
    color: var(--c-teal);
    border-color: var(--c-teal);
}

.btn-outline-primary:hover {
    background-color: var(--c-teal);
    border-color: var(--c-teal);
    color: #fff;
}

.btn-outline-secondary {
    color: var(--c-muted);
    border-color: var(--c-border);
}

.btn-outline-secondary:hover {
    background-color: var(--c-border);
    color: var(--c-text);
}

.dropdown-item {
    font-size: .9rem;
    font-weight: 600;
}

.role-metric-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: .75rem;
}

.role-metric {
    padding: .8rem;
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    background: #fff;
}

.role-metric-value {
    color: var(--c-navy);
    font-size: 1.25rem;
    font-weight: 800;
    line-height: 1;
}

.role-metric-label {
    margin-top: .25rem;
    color: var(--c-muted);
    font-size: .78rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.task-strip {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: .75rem;
    margin-bottom: 1rem;
}

.task-card {
    display: flex;
    flex-direction: column;
    gap: .2rem;
    min-height: 64px;
    padding: .85rem;
    border: 1px solid var(--c-border);
    border-left: 3px solid var(--c-teal);
    border-radius: var(--radius);
    background: #fff;
    box-shadow: var(--shadow-sm);
}

.task-card:hover,
.task-card:focus {
    border-left-color: var(--c-orange);
    text-decoration: none;
}

.task-card-title {
    color: var(--c-navy);
    font-weight: 800;
}

.task-card-meta {
    color: var(--c-muted);
    font-size: .82rem;
    font-weight: 600;
}

.ui-fieldset {
    min-width: 0;
    padding: 0;
    border: 0;
}

.advanced-panel {
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    background: #fff;
}

.advanced-panel summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    min-height: 42px;
    padding: .65rem .8rem;
    color: var(--c-navy);
    font-weight: 800;
    cursor: pointer;
}

.advanced-panel summary::-webkit-details-marker {
    display: none;
}

.advanced-panel summary::after {
    content: "+";
    color: var(--c-muted);
    font-weight: 800;
}

.advanced-panel[open] summary {
    border-bottom: 1px solid var(--c-border);
}

.advanced-panel[open] summary::after {
    content: "-";
}

.advanced-panel-meta {
    margin-left: auto;
    color: var(--c-muted);
    font-size: .78rem;
    font-weight: 700;
}

.advanced-panel-body {
    padding: .85rem;
}

.table {
    --bs-table-striped-bg: #f8fafc;
}

.table thead th {
    color: var(--c-muted);
    font-size: .76rem;
    font-weight: 800;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.property-table {
    table-layout: fixed;
    width: 100%;
}

.property-table th:first-child,
.property-table td:first-child {
    width: 42%;
}

.property-table th:nth-child(2),
.property-table td:nth-child(2) {
    width: 26%;
}

.property-table th:nth-child(3),
.property-table td:nth-child(3) {
    width: 32%;
}

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

.comparison-table {
    min-width: 860px;
}

.comparison-table th:first-child,
.comparison-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 2;
    background: var(--c-surface);
    box-shadow: 1px 0 0 var(--c-border);
}

.comparison-table thead th:first-child {
    z-index: 3;
}

.property-group {
    padding-top: .75rem;
    border-top: 1px solid var(--c-border);
}

.property-group:first-of-type {
    padding-top: 0;
    border-top: 0;
}

.section-title + .property-group {
    padding-top: 0;
    border-top: 0;
}

.property-group + .property-group {
    margin-top: 1rem;
}

.property-group-title {
    margin-bottom: .45rem;
    color: var(--c-navy);
    font-size: .9rem;
    font-weight: 700;
}

.compare-picker-meta {
    color: var(--c-muted);
    font-size: .82rem;
    font-weight: 800;
    letter-spacing: .03em;
    text-transform: uppercase;
}

.compare-material-list {
    max-height: 360px;
    overflow: auto;
    border: 1px solid var(--c-border);
    border-radius: var(--radius-sm);
    background: #fff;
}

.compare-material-option {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: .75rem;
    align-items: start;
    margin: 0;
    padding: .7rem .85rem;
    border-bottom: 1px solid var(--c-border);
    cursor: pointer;
}

.compare-material-option:last-child {
    border-bottom: 0;
}

.compare-material-option:hover {
    background: #f8fafc;
}

.compare-material-option.is-selected {
    background: #eef8f6;
    box-shadow: inset 3px 0 0 var(--c-teal);
}

.compare-material-main {
    min-width: 0;
}

.compare-material-name {
    display: block;
    color: var(--c-navy);
    font-weight: 800;
}

.compare-material-summary {
    display: block;
    color: var(--c-muted);
    font-size: .82rem;
}

.missing-value {
    color: var(--c-muted);
    font-weight: 700;
}

.missing-reason {
    color: var(--c-muted);
    font-size: .78rem;
}

.standard-card-list,
.standard-link-list,
.standard-chip-list {
    display: grid;
    gap: .5rem;
}

.standard-card-item {
    padding: .65rem 0;
    border-top: 1px solid var(--c-border);
}

.standard-card-item:first-child {
    padding-top: 0;
    border-top: 0;
}

.standard-card-title {
    color: var(--c-navy);
    font-weight: 800;
}

.standard-card-text,
.standard-card-meta {
    color: var(--c-muted);
    font-size: .86rem;
}

.standard-list {
    margin: 0;
    padding-left: 1.2rem;
}

.standard-list li + li {
    margin-top: .3rem;
}

.requirement-block + .requirement-block {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--c-border);
}

.standard-requirement-table-wrap {
    max-height: 620px;
    overflow: auto;
    border: 1px solid var(--c-border);
    border-radius: var(--radius-sm);
}

.standard-requirement-table {
    min-width: 980px;
}

.standard-requirement-table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--c-surface);
}

.standard-requirement-table td,
.standard-requirement-table th {
    white-space: nowrap;
}

.standard-chip-list {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
}

.range-layout {
    display: grid;
    grid-template-columns: minmax(260px, 320px) 1fr;
    gap: 1rem;
}

.range-controls {
    border-right: 1px solid var(--c-border);
    padding-right: 1rem;
}

.range-group {
    margin-bottom: 1rem;
}

.range-output {
    min-width: 0;
}

.range-chart-panel {
    min-height: 430px;
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    background: #fff;
    padding: .75rem;
}

.range-chart-panel canvas {
    display: block;
    width: 100%;
    height: 420px;
}

.badge.bg-secondary {
    background-color: var(--c-muted) !important;
}

.file-chip {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: .25rem .55rem;
    border-radius: 999px;
    background: rgba(13, 122, 110, .11);
    color: var(--c-teal);
    font-size: .76rem;
    font-weight: 800;
    letter-spacing: .04em;
}

.release-state-badge {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    border-radius: 999px;
    padding: .18rem .55rem;
    font-size: .75rem;
    font-weight: 700;
    white-space: nowrap;
}

.release-state-badge::before {
    content: "";
    width: .45rem;
    height: .45rem;
    border-radius: 999px;
    background: currentColor;
}

.release-state-working {
    background: #fff4e6;
    color: #9a5800;
    border: 1px solid rgba(217, 119, 6, .22);
}

.release-state-ready {
    background: #e7f6f3;
    color: var(--c-teal);
    border: 1px solid rgba(0, 116, 111, .2);
}

.source-quality-badge {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    border-radius: 999px;
    padding: .18rem .55rem;
    font-size: .74rem;
    font-weight: 800;
    white-space: nowrap;
}

.source-quality-badge::before {
    content: "";
    width: .45rem;
    height: .45rem;
    border-radius: 999px;
    background: currentColor;
}

.source-quality-reference {
    background: #e7f6f3;
    color: var(--c-teal);
    border: 1px solid rgba(0, 116, 111, .2);
}

.source-quality-engineering {
    background: #fff4e6;
    color: #9a5800;
    border: 1px solid rgba(217, 119, 6, .22);
}

.source-quality-project {
    background: #fff4e6;
    color: #9a5800;
    border: 1px solid rgba(217, 119, 6, .22);
}

.source-quality-approximate {
    background: #fff0f0;
    color: #9b1c1c;
    border: 1px solid rgba(185, 28, 28, .22);
}

.source-quality-approved-estimate {
    background: #fff4e6;
    color: #9a5800;
    border: 1px solid rgba(217, 119, 6, .22);
}

.source-quality-standard {
    background: #edf2ff;
    color: #2f4f8f;
    border: 1px solid rgba(47, 79, 143, .22);
}

.source-quality-supplier {
    background: #f0f7eb;
    color: #4a711f;
    border: 1px solid rgba(74, 113, 31, .22);
}

.source-quality-neutral {
    background: #f1f4f7;
    color: #42526b;
    border: 1px solid rgba(66, 82, 107, .2);
}

.source-quality-unknown {
    background: #f1f3f5;
    color: #5f6b7a;
    border: 1px solid rgba(95, 107, 122, .22);
}

.source-quality-note {
    display: block;
    margin-top: .25rem;
    color: var(--c-muted);
    font-size: .72rem;
    font-weight: 700;
}

.detail-list {
    display: grid;
    gap: .85rem;
    margin: 0;
}

.detail-list dt {
    color: var(--c-muted);
    font-size: .78rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.detail-list dd {
    margin: .15rem 0 0;
}

.empty-state {
    padding: 1.25rem;
    color: var(--c-muted);
    background: #f8fafc;
    border: 1px dashed var(--c-border);
    border-radius: var(--radius-lg);
    text-align: center;
}

.empty-state h1,
.empty-state h2,
.empty-state h3,
.empty-state h4 {
    color: var(--c-navy);
}

.empty-state-actions {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: .65rem;
    margin-top: 1rem;
}

.code-block {
    padding: 1rem;
    background: #0f172a;
    color: #e5edf6;
    border-radius: var(--radius);
    overflow-x: auto;
}

.doc-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: .75rem;
}

.doc-card {
    display: flex;
    min-height: 112px;
    flex-direction: column;
    gap: .45rem;
    padding: .95rem;
    color: var(--c-text);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    background: #fff;
}

.doc-card:hover {
    border-color: rgba(13, 122, 110, .45);
    box-shadow: var(--shadow-sm);
    text-decoration: none;
}

.doc-card-title {
    color: var(--c-navy);
    font-weight: 700;
}

.doc-card-summary {
    color: var(--c-muted);
    font-size: .88rem;
}

.docs-layout {
    display: grid;
    grid-template-columns: minmax(190px, 240px) minmax(0, 1fr);
    gap: 1rem;
    align-items: start;
}

.docs-sidebar {
    position: sticky;
    top: 1rem;
}

.docs-nav {
    display: flex;
    flex-direction: column;
    gap: .25rem;
}

.docs-nav a {
    padding: .45rem .55rem;
    color: var(--c-text);
    border-radius: var(--radius-sm);
}

.docs-nav a:hover,
.docs-nav a.active {
    color: var(--c-teal);
    background: #eef7f5;
    text-decoration: none;
}

.doc-content {
    max-width: 920px;
}

.doc-content h1,
.doc-content h2,
.doc-content h3 {
    color: var(--c-navy);
}

.doc-content h1 {
    margin-bottom: .75rem;
    font-size: 1.85rem;
}

.doc-content h2 {
    margin-top: 1.4rem;
    padding-top: .2rem;
    font-size: 1.25rem;
}

.doc-content h3 {
    margin-top: 1rem;
    font-size: 1.05rem;
}

.doc-content p,
.doc-content ul,
.doc-content ol,
.doc-content pre {
    margin-bottom: .95rem;
}

.doc-content li + li {
    margin-top: .25rem;
}

@media (max-width: 991.98px) {
    .termoflow-credit-header {
        width: 100%;
        justify-content: flex-end;
        margin: 0;
        padding: 0 0 .65rem;
        border-left: 0;
    }

    .navbar-collapse {
        order: 4;
    }

    .page-header {
        flex-direction: column;
    }

    .page-header .action-row,
    .table-toolbar,
    .action-row {
        align-items: flex-start;
        justify-content: flex-start;
    }

    .range-layout {
        grid-template-columns: 1fr;
    }

    .range-controls {
        border-right: 0;
        border-bottom: 1px solid var(--c-border);
        padding-right: 0;
        padding-bottom: 1rem;
    }

    .navbar-nav .nav-link {
        padding: 9px 0;
    }

    .docs-layout {
        grid-template-columns: 1fr;
    }

    .docs-sidebar {
        position: static;
    }
}

@media (max-width: 575.98px) {
    .navbar-brand {
        width: 100%;
        gap: .35rem;
        margin-right: 0;
        font-size: clamp(.84rem, 3.8vw, 1.05rem);
    }

    .navbar-toggler {
        margin-bottom: .65rem;
    }

    .termoflow-credit-header {
        width: auto;
        margin: 0 0 .65rem auto;
        padding: .2rem 0;
    }

    .app-footer-inner {
        justify-content: center;
    }

    .app-content {
        padding-top: .25rem;
    }

    .form-shell,
    .section-card {
        padding: .85rem;
    }

    .form-actions,
    .action-row {
        width: 100%;
    }

    .form-actions .btn,
    .action-row .btn,
    .action-row .dropdown {
        width: 100%;
    }

    .property-table {
        min-width: 520px;
    }
}
