:root {
    --border: #d9dee3;
    --text: #1f2933;
    --muted: #6b7785;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --bg: #f7f8fa;
    --surface: #ffffff;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
}

.site-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.site-nav {
    display: flex;
    gap: 1rem;
}

.site-nav a {
    color: var(--muted);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
}

.site-nav a:hover { color: var(--text); }

.site-title {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text);
    text-decoration: none;
}

.container {
    max-width: 1120px;
    margin: 0 auto;
    padding: 1.5rem;
}

.site-nav a.active { color: var(--accent); }

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

.page-header h1 {
    margin: 0;
    font-size: 1.4rem;
}

.page-meta {
    margin: 0.25rem 0 0;
    font-size: 0.8rem;
    color: var(--muted);
}

/* Pipeline stepper */
.pipeline-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.9rem 1.1rem;
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1.25rem;
    flex-wrap: wrap;
}

.pipeline {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    flex: 1 1 420px;
    min-width: 0;
}

.pipeline li {
    position: relative;
    flex: 1 1 0;
    display: flex;
    align-items: center;
    min-width: 0;
}

.pipeline li:not(:last-child)::after {
    content: "";
    flex: 1;
    height: 2px;
    background: var(--border);
    margin: 0 4px;
}

.pipeline li.done:not(:last-child)::after { background: var(--accent); }

.pipeline .step {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 2px solid var(--border);
    background: var(--surface);
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
}

.pipeline li.done .step { background: var(--accent); border-color: var(--accent); color: #fff; }
.pipeline li.current .step { border-color: var(--accent); color: var(--accent); box-shadow: 0 0 0 4px #dbeafe; }

.pipeline-current {
    flex: 0 0 auto;
    font-size: 0.85rem;
    color: var(--muted);
}

.pipeline-current strong { color: var(--text); }

.status-form-inline select { max-width: 240px; }

/* Section cards */
.section-body {
    padding: 1rem 1.25rem 1.25rem;
}

.section-body > :last-child { margin-bottom: 0; }

.section-body .project-form,
.section-body .comment-form {
    background: none;
    border: none;
    padding: 0;
    margin-bottom: 1rem;
}

.section-body .project-detail {
    background: none;
    border: none;
    padding: 0;
    margin-bottom: 1rem;
    grid-template-columns: 190px 1fr;
}

.subhead-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.subhead-row .fan-chart-heading, .subhead-row .fan-units-toggle { margin: 0; }

.section-body .fan-chart-wrap { margin-bottom: 0; }

.summary-meta {
    font-weight: 400;
    color: var(--muted);
    font-size: 0.85rem;
    margin-left: 0.5rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.badge {
    display: inline-block;
    margin-left: auto;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    background: #eef1f4;
    color: var(--muted);
    flex: 0 0 auto;
}

.badge-accent { background: #dbeafe; color: #1d4ed8; }
.badge-warn { background: #fee2e2; color: #991b1b; }
.badge-ok { background: #dcfce7; color: #166534; }

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

.charts-grid .fan-chart-heading { margin-bottom: 0.4rem; }

/* Derate what-if: the tick and its readout, directly above the two charts */
.derate-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem 1rem;
    margin-bottom: 0.75rem;
    padding: 0.5rem 0.9rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.derate-bar input[type="checkbox"] {
    width: 1.2rem;
    height: 1.2rem;
    margin: 0;
}

.derate-readout {
    font-size: 0.9rem;
    min-width: 0;
}

.derate-heading {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--muted);
}

.derate-limit {
    display: block;
    color: var(--muted);
    font-size: 0.85rem;
}

.derate-chart-block { display: block; margin-bottom: 0.3rem; }
.derate-chart-heading { display: block; font-weight: 600; }

/* "Along the curve": how far the speed falls, folded under the limit lines. */
.derate-fold { display: block; margin: 0.15rem 0 0; }
.derate-span { display: block; color: var(--text); font-size: 0.85rem; }
.derate-none { display: block; color: var(--muted); font-size: 0.85rem; }
/* Key-figure readouts: wrapping row of label/value tiles */
.stat-row {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.stat {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.6rem 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
}

.stat-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--muted);
    font-weight: 600;
    line-height: 1.2;
}

.stat-value {
    font-size: 1.05rem;
    font-weight: 600;
    white-space: nowrap;
}

.stat-value .muted-inline { display: block; margin: 0; font-size: 0.72rem; font-weight: 400; white-space: normal; }

.section-body [data-view-mode] > :last-child { margin-bottom: 0; }

.page-header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.status-form-inline {
    display: flex;
    gap: 0.4rem;
}

.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    background: var(--accent);
    color: #fff;
    text-decoration: none;
    border: none;
    font-size: 0.95rem;
    cursor: pointer;
}

.btn:hover { background: var(--accent-hover); }

.btn-secondary {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover { background: #eef1f4; }

.btn-add { font-weight: 600; }

.project-list {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

.project-list th, .project-list td {
    text-align: left;
    padding: 0.65rem 0.9rem;
    border-bottom: 1px solid var(--border);
}

.project-list th {
    background: #eef1f4;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--muted);
}

.project-list tr:last-child td { border-bottom: none; }

.project-list a { color: var(--accent); text-decoration: none; font-weight: 600; }
.project-list a:hover { text-decoration: underline; }

.empty { color: var(--muted); text-align: center; padding: 2rem 0; }

.status-badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    background: #e2e8f0;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text);
}

.project-form, .comment-form {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-width: 480px;
    margin-bottom: 1.5rem;
}

.project-form label {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.9rem;
    font-weight: 600;
}

.project-form h2, .comments h2 {
    margin: 0;
    font-size: 1rem;
}

.details-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 1rem;
    overflow: hidden;
}

.details-section > summary {
    cursor: pointer;
    font-weight: 700;
    font-size: 1rem;
    padding: 0.8rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    list-style: none;
    user-select: none;
}

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

.details-section > summary::before {
    content: "";
    width: 0.45rem;
    height: 0.45rem;
    border-right: 2px solid var(--muted);
    border-bottom: 2px solid var(--muted);
    transform: rotate(-45deg);
    margin-right: 0.5rem;
    transition: transform 0.15s;
    flex: 0 0 auto;
}

.details-section[open] > summary::before { transform: rotate(45deg); }

.details-section[open] > summary { border-bottom: 1px solid var(--border); }

.details-section > summary:hover { background: #fafbfc; }

.details-section [data-view-mode] .btn {
    margin-top: 0.25rem;
}

.project-form fieldset {
    border: none;
    padding: 0;
    margin: 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.project-form legend {
    padding: 0;
    margin-bottom: 0.6rem;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--muted);
}

.unit-field {
    display: flex;
    gap: 0.75rem;
    align-items: stretch;
}

.unit-field label { flex: 1; }
.unit-field .unit-label { flex: 0 0 100px; }

.checkbox-label {
    flex-direction: row !important;
    align-items: center;
    gap: 0.5rem !important;
}

.checkbox-label input { width: auto; }

input, select, textarea {
    font: inherit;
    padding: 0.5rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    color: var(--text);
    max-width: 100%;
}

input:not([type="checkbox"]), select { height: 2.5rem; }

/* Controls in a row line up at the bottom regardless of label length */
.unit-field label, .field-grid label, .blade-picker-grid label { justify-content: flex-end; }

.form-actions {
    display: flex;
    gap: 0.75rem;
}

.project-detail {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.5rem;
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 0.5rem 1rem;
}

.project-detail dt {
    color: var(--muted);
    font-weight: 600;
}

.project-detail dd {
    margin: 0;
}

.flash {
    background: #dcfce7;
    border: 1px solid #86efac;
    color: #166534;
    padding: 0.6rem 0.9rem;
    border-radius: 6px;
    margin-bottom: 1rem;
}

.error {
    background: #fee2e2;
    border: 1px solid #fca5a5;
    color: #991b1b;
    padding: 0.6rem 0.9rem;
    border-radius: 6px;
    margin-bottom: 1rem;
}

.comments .comment-form { max-width: 640px; }

.comment-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.comment {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.75rem 1rem;
}

.comment-body {
    white-space: pre-line;
}

.comment-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.comment-actions { display: inline-flex; align-items: center; gap: 0.4rem; }
.comment-edit-form { display: flex; flex-direction: column; gap: 0.5rem; }
.comment-edit-form textarea { width: 100%; }

.comment-meta { margin-top: 0.5rem; font-size: 0.8rem; color: var(--muted); }

.fan-select-form {
    max-width: 640px;
}

.blade-picker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 0.75rem 1rem;
}

.blade-picker-grid label {
    min-width: 0;
}

.blade-picker-grid select {
    width: 100%;
}

.fan-units-toggle {
    margin-bottom: 0.75rem;
    font-size: 0.85rem;
    color: var(--muted);
}

.fan-units-toggle a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
}

.fan-units-toggle a.active {
    color: var(--text);
    text-decoration: underline;
}

.fan-chart-heading {
    margin: 0 0 0.5rem;
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--muted);
}

.fan-chart-wrap {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
    overflow-x: auto;
}

.fan-chart {
    width: 100%;
    height: auto;
    display: block;
}

svg[data-fan-hover] {
    cursor: crosshair;
    touch-action: pan-y;
}

.fan-tooltip {
    position: absolute;
    z-index: 2;
    pointer-events: none;
    white-space: pre;
    font-size: 0.8rem;
    line-height: 1.4;
    font-variant-numeric: tabular-nums;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.5rem 0.65rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.fan-note {
    color: var(--muted);
    font-size: 0.9rem;
}

.lock-note {
    margin: 0;
    padding: 0.5rem 0.75rem;
    background: var(--bg);
    border: 1px dashed var(--border);
    border-radius: 6px;
}

.project-form fieldset:disabled {
    opacity: 0.7;
}

.muted-inline {
    color: var(--muted);
    font-weight: 400;
    font-size: 0.85em;
    margin-left: 0.4em;
}

.list-spaced { margin-bottom: 1.25rem; }

.section-heading {
    font-size: 1rem;
    margin: 1.5rem 0 0.75rem;
}

.report-section {
    max-width: none;
}

.table-scroll {
    overflow-x: auto;
    margin-bottom: 0.75rem;
}

.data-table {
    font-size: 0.76rem;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.data-table th, .data-table td {
    padding: 0.3rem 0.45rem;
    text-align: right;
}

.data-table th {
    white-space: normal;
    font-size: 0.68rem;
    line-height: 1.2;
    vertical-align: bottom;
}

.data-table th:first-child, .data-table td:first-child {
    text-align: left;
}

.mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.8rem;
    white-space: pre;
    overflow-x: auto;
}

.report-form { max-width: none; }
.estimate-form { max-width: 720px; }
.estimate-form .unit-field label { flex: 1 1 0; }

.estimate-readout {
    max-width: 480px;
}

/* The Drive Temperature Estimate's verdict line: the figure, the drive's own
   internal maximum beside it and — when it is over — that said in words. */
.estimate-verdict {
    font-weight: 600;
    margin: 0 0 0.25rem;
}
.estimate-verdict.warn { color: #b91c1c; }

/* One drive test report under "Test reports": its heading, its points and the
   form that keeps its measured conditions right. */
.report-block + .report-block {
    border-top: 1px solid var(--border);
    padding-top: 1rem;
}
.report-block .section-heading { margin-top: 0; }
.report-meta-form { max-width: none; }
.report-meta-form .unit-field { margin-bottom: 0.25rem; }

.drive-form {
    max-width: none;
}

.drive-form fieldset + fieldset { margin-top: 0.25rem; }

.field-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0.75rem 1rem;
}

.field-grid label { min-width: 0; }
.field-grid input, .field-grid textarea { width: 100%; box-sizing: border-box; }
.field-grid .field-wide { grid-column: 1 / -1; }

.check-list {
    list-style: none;
    padding: 0;
    margin: 0 0 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.9rem;
}

.check-list li::before {
    content: "\2713";
    color: #16a34a;
    font-weight: 700;
    margin-right: 0.5rem;
}

.check-list li.fail::before {
    content: "\2717";
    color: #dc2626;
}

.check-list li.fail { color: #991b1b; }

.summary-header h1 { font-size: 1.3rem; }
.summary-header .fan-note { margin: 0.25rem 0 0; }

.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(440px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}
.summary-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.summary-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-bottom: 1.5rem; }
.summary-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 1.5rem; margin: -0.25rem 0 1rem; padding: 0.5rem 0.9rem; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; }
@media (max-width: 1024px) { .summary-grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 720px) { .summary-grid-2, .summary-grid-3 { grid-template-columns: 1fr; } }

.summary-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem 1.25rem;
    min-width: 0;
}

.summary-card h2 {
    margin: 0 0 0.6rem;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--muted);
}

.project-detail.compact {
    background: none;
    border: none;
    padding: 0;
    margin: 0 0 0.75rem;
    grid-template-columns: 130px 1fr;
    gap: 0.3rem 0.75rem;
    font-size: 0.9rem;
}

.duty-table { width: 100%; table-layout: fixed; white-space: normal; }
.duty-table td:first-child, .duty-table th:first-child { text-align: left; color: var(--muted); width: 45%; }

.summary-charts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.warn { color: #b91c1c; }

@media print {
    .no-print, .site-header, .flash { display: none !important; }
    .container { max-width: none; padding: 0; }
    .summary-grid, .summary-grid-2 { grid-template-columns: 1fr 1fr; }
    .summary-grid-3 { grid-template-columns: 1fr 1fr 1fr; }
    .summary-toolbar { display: none; }
    .summary-charts { grid-template-columns: 1fr 1fr; }
    .summary-card, .fan-chart-wrap { break-inside: avoid; }
    .data-table { font-size: 0.7rem; }
    .table-scroll { overflow: visible; }
    a { color: inherit; text-decoration: none; }
}

.site-user {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.9rem;
}

.site-user > a { color: var(--text); text-decoration: none; font-weight: 600; }
.site-user > a.active { color: var(--accent); }
.logout-form { margin: 0; }

.btn-sm { min-height: 36px; padding: 0.35rem 0.8rem; font-size: 0.85rem; }

.login-wrap { display: flex; justify-content: center; padding-top: 3rem; }
.login-form { width: 100%; max-width: 380px; }
.login-form h1 { margin: 0 0 0.5rem; font-size: 1.3rem; }

.inline-form { display: inline-flex; align-items: center; gap: 0.5rem; margin: 0; flex-wrap: wrap; }
.inline-form select, .inline-form input { height: 36px; font-size: 0.9rem; padding: 0.25rem 0.5rem; }
.inline-details summary { list-style: none; cursor: pointer; }
.inline-details summary::-webkit-details-marker { display: none; }
.inline-details[open] summary { margin-bottom: 0.5rem; }

.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: flex-end;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.9rem 1.1rem;
    margin-bottom: 1rem;
}

.filter-bar label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.8rem; font-weight: 600; color: var(--muted); }
.filter-bar input, .filter-bar select { height: 40px; font-size: 0.9rem; min-width: 120px; }
.filter-bar .filter-grow { flex: 1 1 260px; }
.filter-bar .filter-grow input { min-width: 0; width: 100%; }
.filter-actions { display: flex; gap: 0.5rem; }
.filter-bar .filter-check { flex-direction: row; align-items: center; gap: 0.5rem; height: 44px; color: var(--text); font-weight: 600; }
.archived-banner { margin-top: -0.25rem; }
.page-header .inline-form { margin: 0; }
.filter-actions .btn { min-height: 40px; }

.audit-table { white-space: normal; }
.audit-table td { text-align: left; vertical-align: top; }
.audit-table th { text-align: left; }
.audit-table .nowrap { white-space: nowrap; }
.audit-details { font-size: 0.78rem; line-height: 1.45; max-width: 520px; }
.badge-action { margin-left: 0; text-transform: none; letter-spacing: 0; background: #eef1f4; }

.pager { display: flex; align-items: center; gap: 1rem; justify-content: center; margin: 1rem 0; }

.curve-chart { max-width: 720px; margin-bottom: 1rem; }
.curve-chart .fan-chart { max-width: 100%; }

.option-tile {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    gap: 0.4rem;
    font-weight: 500 !important;
}
.option-tile.has-icon {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.6rem;
    background: var(--surface);
    align-items: center;
    text-align: center;
}
.option-tile.has-icon:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 2px #dbeafe; }
.option-icon { width: 96px; height: 96px; object-fit: contain; }
.option-row { display: inline-flex; align-items: center; gap: 0.5rem; min-height: 44px; }
.option-row input[type="checkbox"] { width: 22px; height: 22px; margin: 0; }

.qty-row { display: flex; gap: 0.4rem; }
.qty-row input { flex: 1 1 auto; min-width: 0; }
.qty-row .unit-select { flex: 0 0 96px; }

.yes { color: #166534; font-weight: 600; }
.no-margin { margin-left: 0; }

.import-bar {
    display: flex;
    align-items: flex-end;
    gap: 0.75rem;
    flex-wrap: wrap;
    padding: 0.75rem 0.9rem;
    margin-bottom: 1rem;
    background: var(--bg);
    border: 1px dashed var(--border);
    border-radius: 8px;
}
.import-file { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.85rem; font-weight: 600; color: var(--muted); }
.import-file input[type="file"] { height: auto; padding: 0.4rem; font-size: 0.9rem; background: var(--surface); }
.import-apply { margin-bottom: 1rem; }
.row-changed td { background: #fffbeb; }

.missing-note ul { margin: 0.4rem 0 0 1.2rem; padding: 0; columns: 2; column-gap: 2rem; }
.missing-note li { font-size: 0.85rem; break-inside: avoid; }

.application-form legend { margin-top: 0.5rem; }

.attachment-list { list-style: none; margin: 0 0 1rem; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.attachment { display: flex; align-items: center; gap: 0.75rem; padding: 0.5rem 0.6rem; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.attachment-thumb img { width: 56px; height: 56px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); display: block; }
.attachment-icon { width: 56px; height: 56px; border-radius: 6px; background: var(--bg); border: 1px solid var(--border); display: inline-flex; align-items: center; justify-content: center; font-size: 0.7rem; font-weight: 700; color: var(--muted); flex: 0 0 auto; }
.attachment-body { flex: 1 1 auto; min-width: 0; }
.attachment-body > a { font-weight: 600; color: var(--accent); text-decoration: none; word-break: break-all; }
.attachment-body .comment-meta { margin-top: 0.2rem; }
.attachment-form { margin-bottom: 0; }

.duty-point-form { max-width: none; }
.duty-point-form .field-grid { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.data-table .nowrap { white-space: nowrap; }
.data-table td { vertical-align: top; }
.badge.no-margin { margin-left: 0; }

.compliance-form { max-width: none; margin-top: 1rem; }

.summary-action { margin-left: auto; text-transform: none; letter-spacing: 0; }
.details-section > summary .summary-action + .badge { margin-left: 0.5rem; }

.approvals-block { margin-top: 1rem; }

.summary-approvals { margin: 1rem 0; }

.doc-badge { margin-left: 0; margin-right: 0.4rem; vertical-align: middle; }
.release-banner { margin-bottom: 1rem; display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 1.25rem; background: #fffbeb; border-color: #fcd34d; }
.release-banner.is-revision { background: #eff6ff; border-color: #bfdbfe; }
.release-banner > div { flex: 1 1 320px; }
.banner-form { flex: 1 1 420px; display: flex; gap: 0.5rem; }
.banner-form input[type="text"] { flex: 1 1 auto; min-width: 0; }
.banner-form .btn { white-space: nowrap; }
.release-form { max-width: none; margin-top: 0.75rem; }
.page-meta a { color: var(--accent); text-decoration: none; font-weight: 600; }
.diff-table td:nth-child(2), .diff-table td:nth-child(3) { word-break: break-word; }
.diff-group { margin: 1rem 0 0.4rem; }

.revision-table td { text-align: left; }
.revision-table td:first-child { font-weight: 700; }

/* Application Report form groups */
.form-group { border-top: 1px solid var(--border) !important; padding-top: 1rem !important; margin-top: 0.5rem !important; }
.form-group:first-child { border-top: none !important; padding-top: 0 !important; margin-top: 0 !important; }
.form-group > legend { font-size: 0.95rem; text-transform: none; letter-spacing: 0; color: var(--text); font-weight: 700; margin-bottom: 0.15rem; }
.form-group > legend .req { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: #b45309; margin-left: 0.4rem; }
.group-hint { margin: 0 0 0.7rem; font-size: 0.85rem; color: var(--muted); }
.option-list { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 0.9rem; }
.option-list .option-tile {
    flex: 0 1 auto;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    padding: 0 0.9rem 0 0.6rem;
    min-height: 44px;
    justify-content: center;
    cursor: pointer;
    transition: border-color 0.1s, background 0.1s;
}
.option-list .option-tile:has(input:checked) { border-color: var(--accent); background: #eff6ff; box-shadow: 0 0 0 2px #dbeafe; }
.option-list .option-tile .option-row { min-height: 42px; }
.option-list.option-list-icons { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.option-list.option-list-icons .option-tile { border-radius: 10px; padding: 0.6rem; flex-direction: column; align-items: center; text-align: center; }
.option-list.option-list-icons .option-tile .option-row { min-height: 0; }
.option-text { line-height: 1.25; }
.form-group.is-disabled { opacity: 0.5; }
.form-group.is-disabled .field-grid, .form-group.is-disabled .option-list { pointer-events: none; }
.chip-row { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 1rem; }
.chip { display: inline-flex; align-items: center; padding: 0.25rem 0.7rem; border-radius: 999px; background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; font-size: 0.85rem; font-weight: 600; }

.danger-form { margin-top: 1rem; padding-top: 1rem; border-top: 1px dashed var(--border); }

.section-body .catalog-view {
    grid-template-columns: minmax(200px, 260px) 1fr minmax(200px, 260px) 1fr;
    column-gap: 1.5rem;
    margin-bottom: 1.25rem;
}
.catalog-view dd { word-break: break-word; }
.section-body .catalog-view dd:nth-of-type(odd) { padding-right: 1rem; }

@media (max-width: 900px) {
    .section-body .catalog-view { grid-template-columns: minmax(160px, 220px) 1fr; }
}

.btn-danger {
    color: #991b1b;
    border-color: #fca5a5;
}

.btn-danger:hover { background: #fee2e2; }

@media (max-width: 480px) {
    .project-detail { grid-template-columns: 1fr; }
    .page-header { flex-direction: column; align-items: flex-start; }
    .unit-field { flex-direction: column; align-items: stretch; }
    .unit-field .unit-label { flex: none; }
}

/* ---------- Touch / tablet ---------- */

html { -webkit-text-size-adjust: 100%; }
body { touch-action: manipulation; }

/* Comfortable tap targets everywhere; 16px inputs stop iOS zooming on focus */
.btn {
    min-height: 44px;
    padding: 0.6rem 1.1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

input:not([type="checkbox"]), select { height: 44px; font-size: 16px; }
textarea { font-size: 16px; }
input[type="checkbox"] { width: 22px; height: 22px; }

.site-header { padding: 0.75rem 1.25rem; }
.site-nav a { padding: 0.6rem 0.4rem; display: inline-flex; align-items: center; min-height: 44px; }

.details-section > summary { min-height: 52px; }

.project-list td, .project-list th { padding: 0.8rem 0.9rem; }
.project-list td a { display: inline-block; padding: 0.2rem 0; }

.fan-units-toggle { display: inline-flex; align-items: center; gap: 0.35rem; }
.fan-units-toggle a {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    padding: 0 0.8rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    text-decoration: none;
    color: var(--muted);
    font-weight: 600;
}
.fan-units-toggle a.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.fan-units-toggle a:hover { text-decoration: none; }

.table-scroll { -webkit-overflow-scrolling: touch; }

/* Chart readout on touch: tooltip stays until dismissed; copy via button */
.fan-chart-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
    flex-wrap: wrap;
}

.fan-chart-actions .btn { min-height: 40px; padding: 0.4rem 0.9rem; font-size: 0.9rem; }

.fan-tooltip { max-width: calc(100% - 2rem); }

@media (pointer: coarse) {
    .fan-tooltip { font-size: 0.9rem; padding: 0.65rem 0.8rem; }
    .pipeline .step { width: 30px; height: 30px; font-size: 0.78rem; }
    .comment-form textarea { min-height: 96px; }
}

/* Tablet widths: stack the pipeline controls, single-column charts, wider forms */
@media (max-width: 1024px) {
    .container { padding: 1rem; }
    .pipeline { flex-basis: 100%; }
    .pipeline-current { flex: 1 1 auto; }
    .status-form-inline { flex: 1 1 auto; justify-content: flex-end; }
    .status-form-inline select { flex: 1 1 auto; max-width: none; }
    .charts-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .summary-grid, .summary-charts { grid-template-columns: 1fr; }
    .project-form, .fan-select-form, .estimate-form, .comments .comment-form { max-width: none; }
    .blade-picker-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .field-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .stat-row { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
}

@media (max-width: 900px) {
    .charts-grid { grid-template-columns: 1fr; }
    .charts-grid .fan-chart { max-width: 720px; margin: 0 auto; }
}

@media (max-width: 768px) {
    .page-header { flex-direction: column; align-items: stretch; }
    .page-header-actions { justify-content: flex-start; }
    .page-header-actions .btn { flex: 1 1 auto; }
    .status-form-inline { width: 100%; }
    .status-form-inline .btn { flex: 0 0 auto; }
    .pipeline li:not(.current):not(.done) .step { width: 20px; height: 20px; font-size: 0; }
    .section-body { padding: 0.9rem 1rem 1rem; }
    .details-section > summary { padding: 0.75rem 1rem; }
    .summary-meta { display: none; }
    .project-detail, .section-body .project-detail { grid-template-columns: 1fr; gap: 0.15rem 0; }
    .project-detail dt { margin-top: 0.5rem; }
    .subhead-row { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
    .lock-note { font-size: 0.85rem; }
}

.filter-bar input, .filter-bar select, .filter-actions .btn { height: 44px; min-height: 44px; box-sizing: border-box; }
.filter-bar input[type="search"] { -webkit-appearance: none; appearance: none; }

.project-list a.btn { color: var(--text); text-decoration: none; font-weight: 600; }
.project-list a.btn:hover { text-decoration: none; background: #eef1f4; }
.data-table .btn-sm { min-height: 32px; padding: 0.2rem 0.6rem; font-size: 0.8rem; white-space: nowrap; display: inline-flex; margin: 0.1rem 0.15rem 0.1rem 0; }

/* Release lock: editors replaced by this note while the project is frozen */
.lock-note.frozen-note { background: #fffbeb; border-color: #fcd34d; }

/* Stall region rows / notes */
.row-stall td { background: #fef2f2; }
.stall-note { background: #fef2f2; border-color: #fecaca; margin-bottom: 0.75rem; }

.plain-list { margin: 0; padding-left: 1.2rem; }
.plain-list li { margin: 0.25rem 0; }

/* Additional duty point rows inside the Application Report form */
.dp-row { display: grid; grid-template-columns: minmax(0, 1.1fr) repeat(4, minmax(0, 1fr)) auto; gap: 0.5rem 0.75rem; align-items: end; padding: 0.5rem 0; border-bottom: 1px dashed var(--border); }
.dp-row:last-child { border-bottom: 0; }
.dp-row label { margin: 0; min-width: 0; }
.dp-row input, .dp-row select { min-width: 0; width: 100%; }
.dp-row .qty-row { display: flex; gap: 0.35rem; min-width: 0; }
.dp-row .qty-row input { flex: 1 1 3rem; }
.dp-row .qty-row select { flex: 0 0 auto; width: auto; max-width: 5.5rem; }
.dp-row .btn { margin-bottom: 2px; white-space: nowrap; }
@media (max-width: 1024px) { .dp-row { grid-template-columns: repeat(2, minmax(0, 1fr)); } .dp-row .btn { grid-column: 1 / -1; justify-self: start; } }

/* Operating-point table + collapsed drive checks inside the Fan section */
.cases-table .row-primary td { background: #f8fafc; }
.checks-table td.check-ok { color: #15803d; }
.checks-table td.check-fail { color: #b91c1c; font-weight: 600; }
.nested-section { margin-top: 1rem; }
.checks-table td.check-unknown { color: #b45309; }

/* Long text in catalog views spans the full row */
.section-body .catalog-view dt.wide { grid-column: 1; }
.section-body .catalog-view dd.wide { grid-column: 2 / -1; }
.value-list { margin: 0; padding-left: 1.1rem; columns: 2; column-gap: 2rem; }
.value-list li { margin: 0.15rem 0; break-inside: avoid; }
.value-table { font-size: 0.9rem; width: 100%; table-layout: auto; }
.value-table th, .value-table td { text-align: left; white-space: normal; vertical-align: top; }
.value-table td:first-child { white-space: nowrap; font-weight: 600; }
@media (max-width: 900px) { .value-list { columns: 1; } }
.matrix-table { width: auto; min-width: 50%; margin-bottom: 1.25rem; }
.matrix-table th, .matrix-table td { text-align: left; }
.matrix-table td:first-child { font-weight: 600; color: var(--muted, #64748b); }
.matrix-table input { width: 8rem; }
.check-inline { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.9rem; white-space: nowrap; }
.check-inline input[type="checkbox"] { width: 1.1rem; height: 1.1rem; margin: 0; }

/* Project page: compact sticky bar once the header scrolls away */
.sticky-bar { position: fixed; top: 0; left: 0; right: 0; z-index: 50; background: var(--surface); border-bottom: 1px solid var(--border); box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
.sticky-bar-inner { max-width: 1120px; margin: 0 auto; padding: 0.4rem 1.5rem; display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.sticky-name { font-size: 1rem; }
.sticky-meta { color: var(--muted); font-size: 0.9rem; white-space: nowrap; }
.sticky-spacer { flex: 1; }
.sticky-bar .btn-sm { min-height: 34px; padding: 0.3rem 0.7rem; }
/* Folds (includes/fold.php): a short title, closed on every load, a tap
   opens it. "Help" explains, "Why" sits beside a warning's headline. */
.inline-help { margin: 0.5rem 0 0; }
.inline-help > summary { cursor: pointer; color: var(--muted); font-size: 0.9rem; list-style: none; display: inline-flex; align-items: center; min-height: 32px; }
.inline-help > summary::-webkit-details-marker { display: none; }
.inline-help > summary::before { content: '▸'; margin-right: 0.3rem; }
.inline-help[open] > summary::before { content: '▾'; }
.inline-help .fan-note, .inline-help .group-hint { margin-top: 0.4rem; }
.fold-body { display: block; }
.fold-topic { font-weight: 400; }
/* A headline with its fold on the same line ("Motor figures estimated from
   the nameplate ▸ Why"); the fold's text takes the full width once opened. */
.fold-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.2rem 0.75rem; }
.fold-line > .inline-help { margin: 0; }
.fold-line > .inline-help[open] { flex-basis: 100%; }
.error .inline-help > summary { color: inherit; }
.audit-count { display: block; }
@media (pointer: coarse) { .inline-help > summary { min-height: 44px; } }
@media print {
    /* Every fold and collapsed section prints open (app.js opens them on
       beforeprint too); the fold arrows are left off the paper. */
    details::details-content { content-visibility: visible; display: contents; }
    .inline-help > summary::before { content: ''; margin: 0; }
}
@media print { .sticky-bar { display: none; } }
@media (max-width: 768px) { .sticky-meta { display: none; } .sticky-bar-inner { padding: 0.35rem 0.75rem; } }

/* Catalog lists split into active / passive */
.catalog-split { margin-bottom: 1.25rem; }
.catalog-split-title { font-size: 1rem; margin: 0 0 0.5rem; }
details.catalog-split > summary.catalog-split-title { cursor: pointer; list-style: none; }
details.catalog-split > summary.catalog-split-title::before { content: '▸ '; color: var(--muted); }
details.catalog-split[open] > summary.catalog-split-title::before { content: '▾ '; }
.table-filter { display: block; width: 100%; max-width: 360px; margin: 0.25rem 0 0.6rem; }

/* Bill of materials & cost sheet (Release 1.0) — internal cost, never a
   sales price; the printable cost sheet hides its controls. */
.bom-block { margin-top: 1.25rem; }
.bom-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; margin: 0.5rem 0; }
.bom-toolbar .fan-chart-heading { margin: 0; flex: 1 1 100%; }
.bom-currency-form { display: inline-flex; align-items: center; gap: 0.35rem; margin: 0; }
.bom-currency-form label { display: inline-flex; align-items: center; gap: 0.35rem; }
.bom-rate-line { color: var(--muted); margin: 0.2rem 0; }
.bom-lines { list-style: none; padding: 0; margin: 0.5rem 0; }
.bom-lines li { padding: 0.35rem 0; border-bottom: 1px solid var(--border); }
.bom-total { font-size: 1.05rem; margin: 0.4rem 0; }
.bom-notes { color: var(--muted); margin: 0.25rem 0 0.6rem; padding-left: 1.1rem; }
.bom-table .bom-total-row td { border-top: 2px solid var(--border); }
.cost-sheet-header h1 { margin-bottom: 0.15rem; }
.cost-sheet-body { margin-top: 1rem; }
.cost-sheet-footer { margin-top: 2rem; border-top: 1px solid var(--border); padding-top: 0.5rem; color: var(--muted); font-size: 0.85rem; }
.cost-sheet-restricted { font-weight: 600; color: #a15c00; }
@media print {
    .cost-sheet-footer { break-inside: avoid; }
    .bom-table { font-size: 0.72rem; }
    .cost-sheet-meta, .cost-sheet-body { break-inside: avoid; }
}

/* Lists page (Release 1.1): the countries we buy parts in / assemble fans in
   and the currencies we buy in. */
.lists-list { list-style: none; padding: 0; margin: 0 0 1rem; }
.list-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 0.75rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
}
.list-entry { font-weight: 600; }
.list-note {
    font-size: 0.8rem;
    color: #a15c00;
    background: #fff7e6;
    border: 1px solid #f0d9a8;
    border-radius: 6px;
    padding: 0.15rem 0.5rem;
}
.list-remove { margin: 0 0 0 auto; }
.list-add {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.6rem;
    margin-top: 0.75rem;
}
.list-add-label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.8rem; font-weight: 600; color: var(--muted); }
.list-add-label select, .list-add-label input { height: 40px; font-size: 0.9rem; min-width: 180px; }
@media (max-width: 768px) {
    .list-remove { margin-left: 0; }
    .list-add-label, .list-add-label select, .list-add-label input { width: 100%; min-width: 0; }
}

/* ---- Propose a fan (Release 1.4) ---------------------------------------- */
.proposal-form .field-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.proposal-summary { margin: 1rem 0 0.5rem; }
.proposal-summary p { margin: 0.2rem 0; }
.proposal-heading { margin: 1.25rem 0 0.5rem; font-size: 1.15rem; }
.proposal-picks { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.75rem; margin-bottom: 0.75rem; }
.proposal-pick { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 0.75rem 0.9rem; display: flex; flex-direction: column; gap: 0.5rem; }
.proposal-pick h3 { margin: 0; font-size: 1rem; }
.proposal-pick-name { margin: 0; font-size: 0.9rem; line-height: 1.4; }
.proposal-pick .stat-row { margin: 0; }
.proposal-pick .btn { align-self: flex-start; }
.proposal-question { background: #fff8e6; border: 1px solid #f0c36d; border-radius: 8px; padding: 0.75rem 0.9rem; margin: 0.75rem 0; }
.proposal-question p { margin: 0.2rem 0; }
.proposal-table th a { color: inherit; text-decoration: underline dotted; }
.proposal-table th a.active { color: var(--accent); text-decoration: underline; }
.proposal-table td .inline-help { margin-top: 0.3rem; }
.proposal-cases { font-size: 0.85rem; margin: 0.3rem 0 0; }
.proposal-nearby { margin: 0.75rem 0; }
@media (max-width: 1024px) { .proposal-picks { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 768px) {
    .proposal-picks, .proposal-form .field-grid { grid-template-columns: 1fr; }
}

/* A one-line note under a form field (never folded) */
.field-hint { display: block; margin-top: 0.25rem; font-size: 0.85rem; font-weight: 400; color: var(--muted); }
.check-info { color: var(--text); }

/* Derate legend: inside each chart's frame, above the plotted area (Release 1.6) */
.fan-chart-wrap { box-sizing: border-box; max-width: 100%; }
.derate-legend { display: block; box-sizing: border-box; max-width: 100%; padding: 0.35rem 0.6rem; margin: 0 0 0.3rem; background: var(--surface); border: 1px solid var(--border); border-radius: 4px; font-size: 0.85rem; }
.derate-legend .derate-headline { display: inline-block; margin-right: 0.8rem; }
.derate-legend .derate-keys { display: inline-flex; flex-wrap: wrap; gap: 0.2rem 0.9rem; vertical-align: middle; }
.derate-key { display: inline-flex; align-items: center; gap: 0.3rem; }
.derate-key-line { display: inline-block; width: 22px; border-top: 2px solid #2563eb; }
.derate-key-line.dashed { border-top-style: dashed; }
.derate-note, .derate-case { display: block; color: var(--muted); font-size: 0.85rem; }

/* A value the page works out (Fan array: number of fans, arrangement): shown like a field, but plain */
.field-computed { display: flex; flex-direction: column; justify-content: flex-end; gap: 0.25rem; min-height: 44px; }
.field-computed-label { font-size: 0.9rem; color: var(--muted); }
.field-computed-value { font-weight: 600; min-height: 1.5rem; }
