.entry-page-header {
    gap: 2rem;
}

.entry-progress {
    display: grid;
    min-width: min(100%, 25rem);
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: .45rem;
    padding: 0;
    margin: 0;
    list-style: none;
}

.entry-progress li {
    display: grid;
    justify-items: center;
    gap: .35rem;
    min-width: 0;
    color: var(--muted);
    font-size: .72rem;
    text-align: center;
}

.entry-progress li::after {
    position: absolute;
    content: "";
}

.entry-progress span {
    display: grid;
    place-items: center;
    width: 2rem;
    height: 2rem;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--surface);
    color: var(--muted);
    font-weight: 900;
}

.entry-progress .is-active {
    color: var(--gold-2);
}

.entry-progress .is-active span {
    border-color: var(--gold);
    background: var(--gold);
    color: #1a1b16;
}

.data-entry-form {
    gap: 1.1rem;
}

.entry-section {
    min-width: 0;
    padding: clamp(1rem, 2.5vw, 1.5rem);
    border: 1px solid var(--border);
    border-radius: 14px;
    background: color-mix(in srgb, var(--surface-2) 50%, transparent);
}

.entry-primary {
    border-color: color-mix(in srgb, var(--gold) 48%, var(--border));
    background: linear-gradient(145deg, color-mix(in srgb, var(--gold) 7%, var(--surface-2)), var(--surface));
}

.entry-template {
    border-color: color-mix(in srgb, var(--gold) 38%, var(--border));
}

.entry-template legend {
    padding: 0 .55rem;
    color: var(--gold-2);
    font: 1.2rem/1.2 var(--serif);
}

.entry-section-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: .45rem;
}

.entry-section-heading h2 {
    margin: 0;
    font: 2rem/1.1 var(--serif);
}

.entry-help {
    margin: 0 0 1.1rem;
    color: var(--muted);
}

.entry-detail-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .25rem .2rem;
}

.entry-detail-toolbar > div {
    display: grid;
}

.entry-details {
    margin: 0;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: color-mix(in srgb, var(--surface) 75%, transparent);
}

.entry-details summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.15rem;
    color: var(--text);
    list-style: none;
}

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

.entry-details summary::after {
    content: "+";
    display: grid;
    place-items: center;
    width: 2rem;
    min-width: 2rem;
    height: 2rem;
    border: 1px solid var(--border);
    border-radius: 50%;
    color: var(--gold-2);
    font-size: 1.3rem;
}

.entry-details[open] summary::after {
    content: "−";
    border-color: var(--gold);
}

.entry-details summary span {
    display: grid;
    gap: .15rem;
}

.entry-details summary strong {
    font-size: 1rem;
}

.entry-details summary small {
    color: var(--muted);
}

.entry-details-body {
    padding: 1.15rem;
    border-top: 1px solid var(--border);
}

.entry-draft-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding-inline: .25rem;
}

.entry-submit-bar {
    position: static;
    justify-content: space-between;
    padding: 1rem 1.1rem;
    border: 1px solid color-mix(in srgb, var(--gold) 48%, var(--border));
    border-radius: 14px;
    background: color-mix(in srgb, var(--bg) 93%, transparent);
    box-shadow: 0 12px 35px rgba(0, 0, 0, .35);
    backdrop-filter: blur(18px);
}

.entry-submit-bar > div:first-child {
    display: grid;
}

.entry-submit-bar small {
    color: var(--muted);
}

.entry-type-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: .7rem;
}

.entry-choice {
    position: relative;
    display: grid;
    align-content: start;
    gap: .25rem;
    min-height: 7.5rem;
    padding: .9rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg);
    cursor: pointer;
}

.entry-choice:hover {
    border-color: var(--gold);
}

.entry-choice:has(input:checked) {
    border-color: var(--gold);
    background: color-mix(in srgb, var(--gold) 10%, var(--surface-2));
    box-shadow: inset 0 0 0 1px var(--gold);
}

.entry-choice input {
    width: 1.1rem;
    height: 1.1rem;
    padding: 0;
    accent-color: var(--gold);
}

.entry-choice strong {
    color: var(--text);
}

.entry-choice small {
    color: var(--muted);
    font-weight: 400;
}

.entry-inline-note {
    padding: .8rem 1rem;
    border-left: 3px solid var(--gold);
    border-radius: 0 10px 10px 0;
    background: var(--bg);
    color: var(--muted);
}

.location-filter {
    grid-template-columns: 2fr 1fr 1fr auto;
}

.location-records {
    margin-top: 2rem;
}

.planning-hub-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: .8rem;
    margin-bottom: 1.5rem;
}

.planning-hub-grid a {
    display: grid;
    gap: .3rem;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
    color: var(--text);
    text-decoration: none;
}

.planning-hub-grid a:hover {
    border-color: var(--gold);
}

.planning-hub-grid span {
    color: var(--muted);
    font-size: .82rem;
}

.location-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1rem;
}

.location-card {
    display: grid;
    align-content: start;
    gap: 1rem;
    min-width: 0;
    padding: 1.15rem;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--surface);
}

.location-card-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: .75rem;
}

.location-card-heading h3 {
    margin: .55rem 0 .2rem;
    font: 1.45rem/1.15 var(--serif);
}

.location-card-heading p {
    margin: 0;
    color: var(--muted);
}

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

.location-facts div {
    padding: .7rem;
    border-radius: 10px;
    background: var(--bg);
}

.location-facts dt {
    color: var(--muted);
    font-size: .68rem;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.location-facts dd {
    margin: .2rem 0 0;
    overflow-wrap: anywhere;
}

.machine-list {
    display: grid;
    gap: .45rem;
    padding-top: .75rem;
    border-top: 1px solid var(--border);
}

.machine-list > div {
    display: flex;
    justify-content: space-between;
    gap: .65rem;
}

.machine-list small {
    color: var(--muted);
}

.location-card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .55rem;
    padding-top: .75rem;
    border-top: 1px solid var(--border);
}

.location-card-actions form {
    margin: 0;
}

.entry-field-action {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: .55rem;
}

.entry-duplicate-warning {
    padding: .85rem 1rem;
    border: 1px solid #8f6f2b;
    border-radius: 10px;
    background: #392b16;
    color: #f2ca76;
}

.entry-duplicate-warning a {
    color: #fff;
}

@media (max-width: 900px) {
    .entry-page-header {
        align-items: stretch;
    }

    .entry-type-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .location-filter {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .planning-hub-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 650px) {
    .entry-progress {
        min-width: 0;
    }

    .entry-progress strong {
        font-size: .65rem;
    }

    .entry-detail-toolbar,
    .entry-draft-row,
    .entry-submit-bar {
        align-items: stretch;
        flex-direction: column;
    }

    .entry-submit-bar {
        position: static;
    }

    .entry-submit-bar .actions,
    .entry-submit-bar .button {
        width: 100%;
    }

    .entry-type-grid {
        grid-template-columns: 1fr;
    }

    .entry-choice {
        min-height: 0;
    }

    .location-filter,
    .location-card-grid,
    .location-facts,
    .planning-hub-grid {
        grid-template-columns: 1fr;
    }

    .entry-field-action {
        grid-template-columns: 1fr;
    }
}
.reference-transfer-picker {
    display: grid;
    grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr);
    gap: .8rem;
}

.reference-search-filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 10rem), 1fr));
    gap: .65rem;
    align-items: end;
    padding: .75rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-small, 10px);
    background: color-mix(in srgb, var(--surface-2) 80%, transparent);
}

.reference-search-filters label {
    min-width: 0;
}

.bulk-record-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr));
    gap: .65rem;
    max-height: min(48rem, 55vh);
    overflow: auto;
    overscroll-behavior: contain;
    padding: .25rem;
}

.bulk-record {
    align-items: flex-start;
    padding: .75rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-small, 10px);
    background: var(--surface-2);
}

.reference-search-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: .6rem;
    min-height: 1.7rem;
    margin-top: .2rem;
}

.reference-search-meta small {
    color: var(--muted);
}

.reference-search-meta .link-button {
    width: auto;
    min-height: 0;
    padding: .15rem 0;
    white-space: nowrap;
}

.reference-transfer-panel {
    padding: 1rem;
    border: 1px solid var(--line);
    border-radius: var(--radius, 14px);
    background: color-mix(in srgb, var(--panel) 92%, var(--accent) 8%);
}

.reference-transfer-heading,
.reference-transfer-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: .8rem;
    flex-wrap: wrap;
}

.reference-transfer-heading small {
    display: block;
    margin-top: .2rem;
    color: var(--muted);
}

.reference-transfer-fields {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: .55rem;
    margin: 1rem 0;
}

.reference-transfer-field {
    display: flex;
    gap: .65rem;
    align-items: flex-start;
    padding: .7rem;
    border: 1px solid var(--line);
    border-radius: 10px;
}

.reference-transfer-field input {
    width: auto;
    margin-top: .15rem;
}

.reference-transfer-field small {
    display: block;
    margin-top: .2rem;
    color: var(--muted);
    overflow-wrap: anywhere;
}

@media (max-width: 680px) {
    .reference-transfer-picker {
        grid-template-columns: 1fr;
    }
}

.regional-enrichment {
    min-width: 0;
    padding: clamp(1rem, 2vw, 1.5rem);
    border: 1px solid var(--line);
    border-radius: var(--radius, 14px);
    background: color-mix(in srgb, var(--panel) 92%, var(--accent) 8%);
}

.regional-field-grid { margin-bottom: 1rem; }

.regional-enrichment-actions {
    display: flex;
    align-items: end;
    flex-wrap: wrap;
    gap: .75rem;
}

.regional-enrichment-actions label { min-width: min(12rem, 100%); }
.regional-preview { margin-top: 1rem; }
.regional-preview table { table-layout: fixed; }
.regional-preview th,
.regional-preview td { overflow-wrap: anywhere; }
.regional-preview th:first-child,
.regional-preview td:first-child { width: 6.5rem; }

.regional-nearby-results {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(16rem, 100%), 1fr));
    gap: .5rem;
    margin-top: 1rem;
}

.regional-locks,
.regional-sources { margin-top: 1rem; }
.location-batch-bar { margin-bottom: 1rem; }
.location-card-select { display: inline-flex; align-items: center; gap: .5rem; }

.field-info {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-self: end;
    vertical-align: middle;
    margin-left: 0;
}

/* Labels are grids throughout the application. Keep the label text and its
   help control in one row instead of treating the help control as a separate
   row between the caption and the input. */
label:has(> .field-info) {
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: .4rem;
    align-items: center;
}

label:has(> .field-info) > :is(input, select, textarea, small, .speech-field) {
    grid-column: 1 / -1;
}

.field-info-button {
    display: inline-grid;
    place-items: center;
    width: 1.35rem;
    height: 1.35rem;
    min-width: 1.35rem;
    min-height: 1.35rem;
    padding: 0;
    border: 1px solid var(--accent);
    border-radius: 999px;
    background: color-mix(in srgb, var(--surface) 88%, var(--accent) 12%);
    color: var(--accent);
    appearance: none;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: .78rem;
    font-weight: 900;
    line-height: 1;
    cursor: help;
}

.field-info-button:hover,
.field-info-button:focus-visible,
.field-info-button[aria-expanded="true"] {
    border-color: var(--gold, var(--accent));
    color: var(--gold-2, var(--text));
    outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent);
    outline-offset: 2px;
}

.field-info-popover {
    position: absolute;
    z-index: 45;
    left: 50%;
    top: calc(100% + .55rem);
    width: min(19rem, calc(100vw - 3rem));
    padding: .7rem .8rem;
    border: 1px solid var(--accent);
    border-radius: .65rem;
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 12px 32px rgb(0 0 0 / 38%);
    font-size: .86rem;
    font-weight: 500;
    line-height: 1.45;
    transform: translateX(-50%);
}

/* Keep popovers inside narrow viewports when the help button is aligned at
   the right edge of a form column. */
label:has(> .field-info) > .field-info .field-info-popover {
    right: 0;
    left: auto;
    transform: none;
}

.field-info-popover[hidden] { display: none; }

@media (max-width: 640px) {
    .regional-enrichment-actions > * { width: 100%; }
    .regional-preview th:first-child,
    .regional-preview td:first-child { width: 4.75rem; }
}
