:root {
    --control-height: 2.35rem;
    --focus-ring: 0 0 0 3px rgba(185, 242, 39, .28);
    --danger-bg: #351414;
    --warning-bg: #342a0b;
}

/* Final UI layer for FORMS-BASELINE-001. It intentionally overrides
   milestone-specific styles without changing page or command semantics. */

.page-shell > h1 { margin-bottom: 1.15rem; }
.page-shell > h2,
.page-shell > .section-heading,
.page-shell > section > h2 { margin-top: 1.75rem; }

.global-nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: .35rem;
    margin-inline: auto;
    padding: 0 1rem;
}

.global-nav a,
.global-nav strong {
    min-height: 2rem;
    display: inline-flex;
    align-items: center;
    padding: .38rem .62rem;
    border: 1px solid transparent;
    border-radius: 8px;
    color: var(--muted);
    font-size: .76rem;
    font-weight: 800;
    text-decoration: none;
}

.global-nav a:hover { border-color: #6e8a32; color: var(--green); }
.global-nav strong { border-color: var(--green); background: var(--green-dark); color: var(--green); }

.parts-nav,
.uro-contour-nav,
.child-page-nav,
.repair-page-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem;
    margin: 0 0 1rem;
    padding: .65rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--panel);
}

.parts-nav a,
.parts-nav strong,
.uro-contour-nav a,
.uro-contour-nav strong,
.child-page-nav a,
.child-page-nav strong,
.repair-page-actions a {
    min-height: 2.15rem;
    display: inline-flex;
    align-items: center;
    padding: .42rem .7rem;
    border: 1px solid #6e8a32;
    border-radius: 8px;
    background: transparent;
    color: var(--text);
    font-size: .78rem;
    font-weight: 800;
    line-height: 1.15;
    text-decoration: none;
}

.parts-nav strong,
.uro-contour-nav strong,
.child-page-nav strong {
    border-color: var(--green);
    background: var(--green-dark);
    color: var(--green);
}

.parts-nav a:hover,
.uro-contour-nav a:hover,
.child-page-nav a:hover {
    background: #263408;
    color: var(--green);
}

.repair-context-back,
.back-link {
    margin: -.35rem 0 .75rem;
}

.repair-context-back a,
.back-link a {
    color: var(--text);
    font-weight: 650;
}

.repair-page-actions {
    justify-content: flex-end;
    margin-top: -.35rem;
    background: transparent;
}

.repair-page-actions::before {
    content: "Actions";
    margin-right: auto;
    color: var(--muted);
    font-size: .7rem;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.repair-page-actions a {
    background: #17231b;
}

.repair-page-actions a:hover {
    background: #263408;
    color: var(--green);
}

.directory-context-back {
    margin: -.35rem 0 .75rem;
}

.directory-context-back a {
    color: var(--text);
    font-weight: 650;
}

.directory-page-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: .5rem;
    margin: 0 0 1rem;
    padding: .65rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: transparent;
}

.directory-page-actions::before {
    content: "Actions";
    margin-right: auto;
    color: var(--muted);
    font-size: .7rem;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.directory-page-actions a {
    min-height: 2.15rem;
    display: inline-flex;
    align-items: center;
    padding: .42rem .7rem;
    border: 1px solid #6e8a32;
    border-radius: 8px;
    background: #17231b;
    color: var(--text);
    font-size: .78rem;
    font-weight: 800;
    line-height: 1.15;
    text-decoration: none;
}

.directory-page-actions a:hover {
    background: #263408;
    color: var(--green);
}

.unavailable-state {
    margin: .5rem 0 0;
    padding: .8rem;
    border: 1px dashed var(--line);
    border-radius: 8px;
    color: var(--muted);
}

.repair-child-card:not(.repair-child-card--unavailable) {
    min-height: 0;
}

.empty-state {
    padding: 1.1rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--panel);
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--green) !important;
    outline-offset: 2px;
    box-shadow: var(--focus-ring);
}

main button,
main input,
main select,
main textarea { font: inherit; }

main button,
.button {
    min-height: var(--control-height);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: .48rem .78rem;
    border: 1px solid var(--green);
    border-radius: 8px;
    background: var(--green);
    color: #141a08;
    font-weight: 800;
    line-height: 1.15;
    cursor: pointer;
}

main button:hover,
.button:hover { background: #cffb62; color: #141a08; }
main button:disabled { border-color: var(--line); background: #1c211d; color: #737d75; cursor: not-allowed; }
.button--quiet { background: #17231b !important; color: var(--text) !important; border-color: #6e8a32 !important; }

main input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]),
main select,
main textarea {
    min-height: var(--control-height);
    max-width: 100%;
    padding: .46rem .58rem;
    border: 1px solid #84958a;
    border-radius: 7px;
    background: #f8fbf9;
    color: #111713;
}

main textarea { min-height: 5.5rem; resize: vertical; }
main label { color: var(--text); font-weight: 650; }
main label > input,
main label > select,
main label > textarea { margin-top: .28rem; }

table form {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .4rem;
    margin: 0;
}

table form input:not([type="hidden"]),
table form select { width: auto; min-width: 5rem; }
table form button { min-height: 2rem; padding: .34rem .58rem; font-size: .78rem; }

.command-button {
    min-height: 2rem;
    padding: .34rem .5rem;
    border-color: #6e8a32;
    background: #263408;
    color: var(--green);
    font-size: .7rem;
}

.card,
.stats > div {
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--panel);
}

.card { margin: 0 0 1rem; padding: 1rem 1.1rem; }
.card h2 { margin: 0 0 .65rem; }
.card p:last-child { margin-bottom: 0; }

.stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: .65rem;
    margin: 0 0 1rem;
}

.stats > div { min-width: 0; padding: .8rem .9rem; }
.stats span { display: block; color: var(--muted); font-size: .72rem; }
.stats strong { display: block; margin-top: .2rem; font-size: 1.15rem; font-variant-numeric: tabular-nums; }

.status-pill {
    display: inline-flex;
    width: fit-content;
    padding: 4px 8px;
    border-radius: 999px;
    background: var(--panel-2);
    color: var(--muted);
    font-size: .66rem;
    font-weight: 800;
    letter-spacing: .05em;
    text-transform: uppercase;
}

.empty-state,
td[colspan] { color: var(--muted); }
td[colspan] { padding: 1.35rem; text-align: center; }
.empty-state[role="alert"] { border-color: #6a4a26; }
.empty-state[role="alert"] p:first-child { color: var(--text); font-weight: 700; }

.proof-boundary { line-height: 1.45; }
.source-warning { line-height: 1.5; }

@media (max-width: 900px) {
    .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .detail-hero { align-items: flex-start; flex-direction: column; }
    .detail-hero__total { min-width: 0; text-align: left; }
}

@media (max-width: 640px) {
    .site-header,
    .site-footer,
    .page-shell { width: min(100% - 24px, 1220px); }
    .site-header { align-items: flex-start; flex-wrap: wrap; gap: .75rem; padding: .8rem 0; }
    .global-nav { order: 3; width: 100%; justify-content: flex-start; padding: 0; }
    .identity { align-items: flex-end; flex-direction: column; }
    .parts-nav,
    .uro-contour-nav,
    .child-page-nav { padding: .5rem; }
    .repair-page-actions { justify-content: flex-start; }
    .repair-page-actions::before { width: 100%; }
    .directory-page-actions { justify-content: flex-start; }
    .directory-page-actions::before { width: 100%; }
    .stats { grid-template-columns: 1fr; }
    .summary-strip { grid-template-columns: 1fr; }
    .summary-strip div { border-right: 0; border-bottom: 1px solid var(--line); }
    .summary-strip div:last-child { border-bottom: 0; }
}
