.system-layout {
    display: grid;
    gap: 0.8rem;
    padding: 1rem;
    border: 1px solid rgba(44, 36, 22, 0.18);
    border-radius: 0;
    background: var(--parchment, #f4f1e8);
    color: var(--ink, #2c2416);
}

.system-layout__header,
.system-layout-preview-heading,
.system-layout-section-heading,
.system-layout-form-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.system-layout__header h3,
.system-layout-section h4 {
    margin: 0;
}

.system-layout-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 0.6rem;
}

.system-layout-field {
    display: grid;
    gap: 0.25rem;
    min-width: 0;
    padding: 0.7rem;
    border: 1px solid rgba(44, 36, 22, 0.12);
    border-radius: 9px;
    background: rgba(255, 255, 255, 0.78);
}

.system-layout-field--featured {
    padding: 1rem;
    border-color: rgba(201, 162, 39, 0.45);
    background: rgba(201, 162, 39, 0.08);
}

.system-layout-field__label {
    color: var(--ink-light, #5c4a2e);
    font-size: 0.75rem;
}

.system-layout-field__value {
    overflow-wrap: anywhere;
    font-size: 1.15rem;
}

.system-layout-field--featured .system-layout-field__value {
    font-size: 1.7rem;
}

.system-layout-section {
    display: grid;
    gap: 0.6rem;
}

.system-layout-section h4 {
    color: var(--ink-light, #5c4a2e);
    font-size: 0.85rem;
}

.system-badge--custom-color {
    background: var(--system-badge-bg, var(--accent, #8b4513));
    border-color: var(--system-badge-bg, var(--accent, #8b4513));
    color: var(--system-badge-fg, #fff);
}

.systems-admin-panel {
    display: grid;
    gap: 0.8rem;
}

.systems-panel-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding-bottom: 0.45rem;
    border-bottom: 1px solid var(--ink-light, #5c4a2e);
}

.systems-panel-heading h2 {
    margin: 0;
    color: var(--ink, #2c2416);
    font-size: 1.2rem;
}

.systems-panel-heading p,
.system-layout-sample h3,
.system-layout-fields-section h3,
.system-layout-preview-heading h3 {
    margin-top: 0;
}

.systems-panel-heading p,
.system-layout-sample p,
.system-layout-section-heading p {
    margin-bottom: 0;
    color: #71685d;
}

.systems-slot-summary {
    flex: 0 0 auto;
    padding: 0.25rem 0.55rem;
    border: 1px solid rgba(44, 36, 22, 0.12);
    background: rgba(44, 36, 22, 0.03);
    color: var(--ink-light, #5c4a2e);
    font-size: 0.82rem;
}

.systems-config-box {
    display: grid;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    border: 1px solid rgba(44, 36, 22, 0.12);
    border-radius: 0;
    background: #fff;
}

.systems-config-box > .system-layout-section-heading {
    padding-bottom: 0.4rem;
    border-bottom: 1px solid rgba(44, 36, 22, 0.14);
}

.systems-config-box > .system-layout-section-heading h3 {
    margin: 0;
    color: var(--ink, #2c2416);
    font-size: 1rem;
}

.systems-config-box > .system-layout-section-heading span {
    color: var(--ink-light, #5c4a2e);
    font-size: 0.82rem;
}

.systems-control-panel,
.systems-editor-panel {
    min-width: 0;
    border: 1px solid rgba(44, 36, 22, 0.12);
    border-radius: 0;
    background: #fff;
}

.systems-control-panel {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0.7rem;
    padding: 0.8rem;
}

.systems-example-row {
    display: grid;
    grid-template-columns: minmax(220px, 0.8fr) auto minmax(180px, 1fr);
    align-items: end;
    gap: 0.7rem;
}

.systems-example-label {
    display: grid;
    gap: 0.3rem;
    color: var(--accent-dark, #5c2d0e);
    font-size: 0.88rem;
    font-weight: 700;
}

.systems-example-label input,
.systems-system-row select {
    min-width: 0;
    padding: 0.48rem 0.6rem;
    border: 1px solid var(--ink-light, #5c4a2e);
    border-radius: 0;
    background: var(--parchment, #f4f1e8);
    color: var(--ink, #2c2416);
    font: inherit;
}

.systems-example-status {
    color: var(--ink-light, #5c4a2e);
    font-size: 0.82rem;
}

.systems-system-row {
    display: grid;
    grid-template-columns: auto minmax(160px, 1fr) auto auto auto;
    align-items: end;
    gap: 0.65rem;
    padding-top: 0.7rem;
    border-top: 1px solid rgba(44, 36, 22, 0.12);
}

.systems-control-label {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--accent-dark, #5c2d0e);
}

.systems-system-row .systems-slot-summary {
    margin-left: 0.25rem;
}

.systems-editor-panel {
    padding: 0.9rem 1rem;
}

.systems-new-btn {
    min-height: 2.45rem;
    padding: 0.45rem 0.85rem;
    border: 1px solid #1e3d22;
    border-top: 2px solid #6ec475;
    border-bottom: 3px solid #1e3d22;
    border-radius: 0;
    background: #3d7a44;
    color: #f4f1e8;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.systems-new-btn:hover {
    background: #4a9152;
    color: #fff;
}

.systems-primary-btn,
.systems-secondary-btn {
    min-height: 2.35rem;
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--ink-light, #5c4a2e);
    border-radius: 0;
    background: var(--parchment-dark, #e8e4d8);
    color: var(--ink, #2c2416);
    font: inherit;
    font-size: 0.88rem;
    font-weight: 700;
    cursor: pointer;
}

.systems-primary-btn {
    border-color: var(--accent-dark, #5c2d0e);
    background: var(--accent, #8b4513);
    color: var(--parchment, #f4f1e8);
}

.systems-primary-btn:hover {
    background: var(--accent-dark, #5c2d0e);
}

.systems-primary-btn:disabled,
.systems-secondary-btn:disabled,
.systems-new-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.system-layout-form {
    display: grid;
    gap: 0.8rem;
}

.system-layout-form label {
    display: grid;
    gap: 0.35rem;
    color: var(--ink-light, #5c4a2e);
    font-size: 0.88rem;
    font-weight: 700;
}

.system-layout-form input,
.system-layout-form select,
.system-layout-form textarea {
    width: 100%;
    min-width: 0;
    padding: 0.55rem 0.65rem;
    border: 1px solid var(--ink-light, #5c4a2e);
    border-radius: 0;
    background: var(--parchment, #f4f1e8);
    color: var(--ink, #2c2416);
    font: inherit;
}

.system-layout-identity {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.8rem;
}

.system-tag-config {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) minmax(220px, 0.8fr);
    align-items: center;
    gap: 1.25rem;
}

.system-tag-fields {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    gap: 0.7rem;
}

.system-tag-fields > label {
    grid-column: 1 / -1;
}

.system-tag-color-row {
    grid-column: 1 / -1;
    display: flex;
    align-items: end;
    gap: 0.6rem;
}

.system-tag-color-row label {
    min-width: 90px;
}

.system-layout-form input[type="color"] {
    width: 3.25rem;
    height: 2.45rem;
    padding: 0.15rem;
    cursor: pointer;
}

.system-layout-color-hex {
    width: 6.2rem !important;
    font-family: monospace !important;
    text-align: center;
}

.system-tag-preview-panel {
    display: grid;
    gap: 0.45rem;
    align-content: center;
    min-height: 76px;
    padding: 0.75rem 0.9rem;
    border-left: 2px solid rgba(201, 162, 39, 0.6);
    background: rgba(139, 69, 19, 0.04);
}

.system-tag-preview-name {
    color: var(--ink, #2c2416);
    font-size: 0.9rem;
    font-weight: 700;
}

.system-layout-template-row {
    max-width: 360px;
}

.system-layout-sample,
.system-layout-fields-section {
    display: grid;
    gap: 0.65rem;
    padding: 0.85rem;
    border: 1px solid rgba(44, 36, 22, 0.12);
    border-radius: 0;
    background: rgba(139, 69, 19, 0.035);
}

.system-layout-fields-section h3,
.system-layout-preview-heading h3 {
    margin-bottom: 0;
    font-size: 1rem;
}

.system-layout-sample-details > summary {
    color: var(--accent-dark, #5c2d0e);
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
}

.system-layout-sample-details[open] > summary {
    margin-bottom: 0.55rem;
}

.system-layout-sample-details > .system-layout-sample {
    padding: 0;
    border: 0;
    background: transparent;
}

.system-layout-sample-fetch {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    gap: 0.7rem;
}

.system-layout-sample-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.system-layout-sample-actions [role="status"],
.system-layout-form-status {
    color: var(--ink-light, #5c4a2e);
    font-size: 0.86rem;
}

.system-layout-fields {
    display: grid;
    gap: 0.5rem;
}

.system-layout-field-row {
    display: grid;
    grid-template-columns: minmax(100px, 1.1fr) minmax(90px, 0.8fr) minmax(100px, 0.8fr) minmax(90px, 0.7fr) auto;
    align-items: end;
    gap: 0.5rem;
    padding: 0.65rem;
    border: 1px solid rgba(44, 36, 22, 0.12);
    border-radius: 0;
    background: #fff;
}

.system-layout-preview {
    min-height: 80px;
    padding: 0.85rem;
    border: 1px dashed rgba(44, 36, 22, 0.25);
    border-radius: 0;
    background: rgba(44, 36, 22, 0.025);
}

.system-layout-history {
    display: grid;
    gap: 0.4rem;
    color: var(--ink-light, #5c4a2e);
    font-size: 0.85rem;
}

.system-layout-history-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
}

.system-layout-form-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
}

.system-layout-form-status {
    flex: 1 1 100%;
    text-align: right;
}

.system-layout-form-status.is-error {
    color: #a32020;
}

@media (max-width: 760px) {
    .system-layout-identity,
    .system-tag-config {
        grid-template-columns: 1fr;
    }

    .systems-panel-heading {
        align-items: flex-start;
    }

    .systems-example-row {
        grid-template-columns: minmax(0, 1fr) auto;
    }

    .systems-example-status,
    .systems-system-row .systems-control-label {
        grid-column: 1 / -1;
    }

    .systems-system-row {
        grid-template-columns: minmax(0, 1fr) auto;
    }

    .systems-system-row select {
        grid-column: 1 / -1;
    }

    .systems-system-row .systems-slot-summary {
        grid-column: 1 / -1;
        margin-left: 0;
    }

    .system-tag-fields {
        grid-template-columns: minmax(0, 1fr) auto;
    }

    .system-tag-preview-panel {
        border-left: 0;
        border-top: 2px solid rgba(201, 162, 39, 0.6);
    }

    .system-layout-sample-fetch {
        grid-template-columns: 1fr;
    }

    .system-layout-field-row {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .system-layout-field-row button {
        justify-self: start;
    }
}
