.loadout-editor-page {
    width: min(1500px, calc(100% - 32px));
    margin: 0 auto;
    padding: 24px 0 56px;
}

.loadout-page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 18px;
}

.loadout-page-header h1 {
    margin: 0 0 4px;
}

.loadout-page-header p {
    margin: 0;
    opacity: 0.78;
}

.loadout-browser-panel,
.loadout-editor-panel {
    border: 1px solid #555;
    background: rgba(16, 16, 16, 0.94);
    padding: 16px;
}

.loadout-browser-panel h2,
.loadout-editor-panel h2 {
    margin: 0 0 14px;
}

.loadout-filter-bar {
    display: flex;
    flex-direction: row;
    align-items: end;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.filter-control {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 180px;
}

.filter-control span {
    font-weight: 700;
}

.loadout-filter-bar select,
.loadout-filter-bar button,
.loadout-editor-panel select,
.loadout-editor-panel input,
.loadout-editor-panel textarea,
.loadout-editor-panel button {
    min-height: 40px;
    font: inherit;
}

.loadout-filter-bar select {
    min-width: 180px;
}

.loadout-filter-bar button {
    min-width: 90px;
    padding: 7px 16px;
}

.primary-action {
    font-weight: 700;
}

.loadout-list-status {
    min-height: 1.4em;
    margin: 8px 0;
    opacity: 0.85;
}

.loadout-table-wrap {
    overflow-x: auto;
    border: 1px solid #555;
}

.loadout-list-table {
    width: 100%;
    min-width: 760px;
    border-collapse: collapse;
}

.loadout-list-table th,
.loadout-list-table td {
    border-bottom: 1px solid #444;
    padding: 9px 10px;
    text-align: left;
    vertical-align: middle;
}

.loadout-list-table th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #252525;
    white-space: nowrap;
}

.loadout-list-table tbody tr {
    cursor: pointer;
}

.loadout-list-table tbody tr:hover,
.loadout-list-table tbody tr:focus-within {
    background: #282828;
}

.loadout-list-table tbody tr.is-selected {
    outline: 2px solid #d9b545;
    outline-offset: -2px;
    background: #302b1e;
}

.loadout-list-table .action-col,
.loadout-list-table td:last-child {
    width: 1%;
    white-space: nowrap;
}

.loadout-list-table .edit-row-button {
    min-height: 34px;
    padding: 5px 12px;
}

.table-message {
    text-align: center !important;
    padding: 24px !important;
    opacity: 0.8;
}

.loadout-editor-panel {
    margin-top: 20px;
}

.editor-heading-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    flex-wrap: wrap;
    padding-bottom: 12px;
    border-bottom: 1px solid #444;
}

.selected-loadout-identity {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    font-size: 1.05rem;
}

.editor-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.editor-actions button {
    padding: 8px 16px;
}

.editor-message {
    min-height: 1.4em;
    margin: 10px 0;
}

.editor-message.is-error {
    color: #ffb0a8;
}

.editor-message.is-success {
    color: #b9e9b9;
}

.editor-overview-grid {
    display: grid;
    grid-template-columns: minmax(180px, 250px) repeat(2, minmax(280px, 1fr));
    gap: 14px;
    align-items: start;
}

.mech-image-panel,
.editor-card,
.equipment-section,
.notes-card {
    border: 1px solid #4c4c4c;
    background: #1d1d1d;
}

.mech-image-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 220px;
    padding: 12px;
}

.mech-image-panel img {
    display: block;
    max-width: 100%;
    max-height: 300px;
    object-fit: contain;
}

.editor-card {
    padding: 12px;
}

.editor-card h3 {
    margin: 0 0 10px;
}

.field-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(130px, 1fr));
    gap: 10px;
}

.field-grid label,
.notes-card {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.field-grid label > span,
.notes-card > span {
    font-weight: 700;
}

.field-grid input,
.field-grid select {
    width: 100%;
}

.subsystem-grid {
    display: grid;
    gap: 8px;
}

.subsystem-grid label {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 36px;
}

.subsystem-grid input[type="checkbox"] {
    min-height: auto;
    width: 20px;
    height: 20px;
}

.equipment-editor {
    margin-top: 18px;
}

.equipment-section {
    margin-top: 10px;
}

.equipment-section summary {
    cursor: pointer;
    padding: 11px 13px;
    font-weight: 700;
    background: #252525;
}

.weapon-slot-list {
    padding: 8px 12px 12px;
}

.weapon-slot-row {
    display: grid;
    grid-template-columns: 120px minmax(220px, 2fr) minmax(90px, 0.65fr) minmax(140px, 1fr) minmax(92px, auto);
    gap: 8px;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid #343434;
}

.weapon-slot-row:last-child {
    border-bottom: 0;
}

.weapon-slot-label {
    font-weight: 700;
}

.weapon-slot-row select,
.weapon-slot-row input[type="number"] {
    width: 100%;
    min-width: 0;
}

.rear-control {
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.rear-control input {
    min-height: auto;
    width: 20px;
    height: 20px;
}

.rear-control.is-placeholder {
    visibility: hidden;
}

.editor-notes-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(260px, 1fr));
    gap: 14px;
    margin-top: 16px;
}

.notes-card {
    padding: 12px;
}

.notes-card textarea {
    width: 100%;
    resize: vertical;
}

.editor-actions-bottom {
    justify-content: flex-end;
    margin-top: 14px;
}

@media (max-width: 1050px) {
    .editor-overview-grid {
        grid-template-columns: minmax(180px, 240px) 1fr;
    }

    .editor-overview-grid .editor-card:last-child {
        grid-column: 1 / -1;
    }

    .weapon-slot-row {
        grid-template-columns: 105px minmax(190px, 2fr) 90px minmax(130px, 1fr) auto;
    }
}

@media (max-width: 760px) {
    .loadout-editor-page {
        width: min(100% - 20px, 1500px);
        padding-top: 12px;
    }

    .loadout-filter-bar {
        align-items: stretch;
    }

    .filter-control {
        min-width: min(100%, 210px);
        flex: 1 1 160px;
    }

    .loadout-filter-bar select {
        min-width: 0;
        width: 100%;
    }

    .editor-overview-grid,
    .editor-notes-grid {
        grid-template-columns: 1fr;
    }

    .editor-overview-grid .editor-card:last-child {
        grid-column: auto;
    }

    .field-grid {
        grid-template-columns: 1fr;
    }

    .weapon-slot-row {
        grid-template-columns: 1fr;
        padding: 10px 0;
    }

    .weapon-slot-label {
        padding-bottom: 2px;
    }

    .rear-control.is-placeholder {
        display: none;
    }
}
