.admin-page-header {
    display: flex;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 8px 16px;
    margin: 0 0 14px;
}

.admin-page-header-actions {
    margin-left: auto;
}

.admin-page-header h1 {
    margin: 0;
}

.admin-page-header p {
    flex-basis: 100%;
    margin: 0;
}

.admin-inline-form {
    display: inline;
}

.admin-alert {
    margin: 8px 0;
    padding: 8px;
    border: 1px solid #ccc;
}

.item-template-diagnostics {
    margin: 14px 0;
    padding: 10px;
    border: 1px solid #d8dee4;
}

.item-template-diagnostics h2 {
    margin: 0 0 8px;
    font-size: 18px;
    line-height: 24px;
    letter-spacing: 0;
    text-transform: none;
}

.item-template-diagnostics ul {
    margin: 6px 0 0 18px;
    padding: 0;
}

.item-template-editor {
    width: 100%;
    max-width: 1180px;
}

.item-template-macro-panel {
    margin: 14px 0 10px;
    padding: 12px;
    border: 1px solid #cfd8df;
    background: #f8fbfd;
}

.item-template-macro-panel-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.item-template-macro-panel h2 {
    margin: 0 0 6px;
    font-size: 20px;
    line-height: 26px;
    letter-spacing: 0;
    text-transform: none;
}

.item-template-macro-panel p {
    margin: 0;
    color: #526170;
    font-size: 13px;
    line-height: 18px;
}

.item-template-macro-status {
    flex: 0 0 auto;
    padding: 6px 8px;
    background: #fff;
    border: 1px solid #d9e1e7;
    color: #526170;
    font-size: 13px;
    line-height: 18px;
    white-space: nowrap;
}

.item-template-macro-search-row,
.item-template-macro-sticky {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.item-template-macro-search-row {
    margin-top: 12px;
}

.item-template-macro-sticky {
    position: sticky;
    top: 0;
    z-index: 20;
    margin: 0 0 12px;
    padding: 8px 10px;
    background: #eef4f8;
    border: 1px solid #cfd8df;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.item-template-macro-search-row input[type="search"],
.item-template-macro-sticky input[type="search"] {
    box-sizing: border-box;
    width: 260px;
    max-width: 100%;
    height: 32px;
    padding: 5px 8px;
    border: 1px solid #c7d0d8;
    background: #fff;
    font-size: 14px;
    line-height: 20px;
}

.item-template-macro-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 12px;
}

.item-template-macro-tab {
    min-height: 30px;
    padding: 5px 10px;
    border: 1px solid #b9c5cf;
    background: #fff;
    color: #1f5f8b;
    cursor: pointer;
}

.item-template-macro-tab span {
    display: inline-block;
    min-width: 18px;
    margin-left: 6px;
    padding: 0 5px;
    border-radius: 10px;
    background: #e8eef3;
    color: #526170;
    font-size: 12px;
    line-height: 18px;
}

.item-template-macro-tab-active {
    background: #2d7fb8;
    border-color: #2d7fb8;
    color: #fff;
}

.item-template-macro-tab-active span {
    background: rgba(255, 255, 255, 0.22);
    color: #fff;
}

.item-template-macro-tab-panel {
    margin-top: 12px;
}

.item-template-macro-chip-list,
.item-template-macro-quick {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    min-width: 0;
}

.item-template-macro-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 100%;
    min-height: 30px;
    padding: 5px 8px;
    border: 1px solid #b9c5cf;
    background: #fff;
    color: #17212b;
    cursor: pointer;
    text-align: left;
}

.item-template-macro-chip:hover,
.item-template-macro-chip:focus {
    border-color: #2d7fb8;
    box-shadow: 0 0 0 2px rgba(45, 127, 184, 0.14);
    outline: 0;
}

.item-template-macro-chip[hidden] {
    display: none;
}

.item-template-macro-chip-compact {
    min-height: 28px;
    padding: 4px 7px;
}

.item-template-macro-code {
    font-family: Consolas, Monaco, monospace;
    font-size: 12px;
    line-height: 18px;
    overflow-wrap: anywhere;
}

.item-template-macro-label {
    color: #526170;
    font-size: 12px;
    line-height: 18px;
}

.item-template-macro-type {
    padding: 1px 5px;
    background: #eef4f8;
    color: #526170;
    font-size: 11px;
    line-height: 16px;
}

.item-template-macro-empty {
    padding: 8px;
    background: #fff;
    border-left: 3px solid #b8c4ce;
}

.item-template-macro-problems {
    margin: 0;
    padding: 0;
    list-style: none;
}

.item-template-macro-problems li {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
    padding: 8px;
    background: #fff;
    border-left: 3px solid #d9534f;
}

.item-template-macro-problems li:first-child {
    margin-top: 0;
}

.item-template-macro-problems code {
    font-family: Consolas, Monaco, monospace;
    overflow-wrap: anywhere;
}

.item-template-macro-field-active {
    outline: 2px solid #2d7fb8;
    outline-offset: 1px;
}

.item-template-editor table.form {
    max-width: 100%;
}

.item-template-editor table.form textarea {
    box-sizing: border-box;
    max-width: 100%;
}

.item-template-diagnostic-note {
    margin: 4px 0 0;
    color: #8a4b00;
    font-size: 12px;
    line-height: 16px;
}

.item-template-table-wrap,
.macros-table-wrap,
.macros-edit-table-wrap {
    overflow-x: auto;
}

.item-template-table-wrap .list,
.macros-table-wrap .list,
.macros-edit-table-wrap .list {
    min-width: 980px;
}

.admin-page-header-actions .btn,
.macros-toolbar .btn,
.macros-toolbar button,
.macros-edit-actions button,
.macros-edit-actions a,
.macros-action-form button,
.admin-inline-form button {
    box-sizing: border-box;
}

.admin-page-header-actions .btn,
.macros-toolbar .btn,
.macros-edit-actions a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
}

.catalog-template-page {
    width: 100%;
    max-width: 1180px;
}

.catalog-template-header {
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 18px;
}

.catalog-template-header h1 {
    font-size: 24px;
    line-height: 30px;
    letter-spacing: 0;
    text-transform: uppercase;
}

.catalog-template-header .admin-page-header-actions {
    margin-left: 0;
}

.catalog-template-create-form {
    width: 100%;
}

.catalog-template-form-grid {
    display: grid;
    gap: 12px;
}

.catalog-template-field {
    display: grid;
    grid-template-columns: 230px minmax(0, 1fr);
    gap: 16px;
    align-items: start;
    padding: 0 0 12px;
    border-bottom: 1px solid #d8dee4;
}

.catalog-template-field-label {
    padding-top: 7px;
    font-size: 14px;
    line-height: 20px;
    color: #111;
}

.catalog-template-label-text {
    font-weight: 700;
}

.catalog-template-code {
    margin-top: 2px;
    color: #607080;
    font-family: Consolas, Monaco, monospace;
    font-size: 12px;
    line-height: 18px;
    overflow-wrap: anywhere;
}

.catalog-template-field-control {
    min-width: 0;
}

.catalog-template-field-control input[type="text"],
.catalog-template-field-control input[type="number"],
.catalog-template-field-control input[type="date"],
.catalog-template-field-control select,
.catalog-template-field-control textarea {
    box-sizing: border-box;
    width: 100%;
    max-width: 760px;
    min-height: 34px;
    font-size: 14px;
    line-height: 20px;
}

.catalog-template-field-control-short input[type="text"] {
    max-width: 420px;
}

.catalog-template-field-control input[type="number"],
.catalog-template-field-control input[type="date"] {
    max-width: 260px;
}

.catalog-template-field-control textarea {
    min-height: 58px;
    resize: vertical;
}

.catalog-template-localized-controls {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    max-width: 760px;
}

.catalog-template-localized-control {
    display: grid;
    gap: 4px;
    min-width: 0;
}

.catalog-template-localized-control span {
    color: #53606c;
    font-size: 12px;
    font-weight: 700;
    line-height: 16px;
}

.catalog-template-localized-control textarea {
    max-width: 100%;
}

.catalog-template-help {
    max-width: 760px;
    margin-top: 6px;
    padding: 6px 8px;
    background: #f7fafc;
    border-left: 3px solid #b8c4ce;
}

.catalog-template-hint {
    color: #58636f;
    font-size: 13px;
    line-height: 18px;
}

.catalog-template-hint + .catalog-template-hint {
    margin-top: 2px;
}

.catalog-template-error {
    color: #b00020;
    margin-top: 6px;
    font-size: 13px;
    line-height: 18px;
}

.catalog-template-checkboxes {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 16px;
    max-width: 760px;
    min-height: 34px;
    align-items: center;
}

.catalog-template-checkbox-option {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    min-height: 24px;
}

.catalog-template-checkbox-option label {
    display: inline-block;
    margin: 0;
}

.catalog-template-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 18px 0 0 246px;
}

.macros-page h1,
.macros-edit-page h1 {
    margin: 0 0 14px;
    font-size: 28px;
    line-height: 34px;
    letter-spacing: 0;
    text-transform: none;
}

.macros-toolbar,
.macros-edit-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin: 0 0 16px;
}

.macros-toolbar {
    align-items: center;
}

.macros-toolbar input[type="text"] {
    width: 360px;
    max-width: 100%;
    height: 32px;
    line-height: 30px;
    font-size: 14px;
}

.macros-toolbar select,
.macros-toolbar button,
.macros-toolbar .btn {
    height: 32px;
    line-height: 30px;
}

.macros-action-form {
    display: inline-block;
    margin: 0;
}

.macros-row-actions {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex-wrap: nowrap;
    white-space: nowrap;
}

.macros-row-action-link,
.macros-row-action-button {
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 28px;
    padding: 4px 8px;
    font-size: 13px;
    line-height: 18px;
    white-space: nowrap;
}

.macros-row-action-link {
    color: #1f6fb2;
    background: #eef6fc;
    border: 1px solid #b8d7ec;
}

.macros-row-action-button {
    color: #fff;
    background: #2fb241;
    border: 1px solid #249136;
    border-radius: 3px;
}

.macros-edit-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    max-width: 1180px;
    margin: 0 0 16px;
}

.macros-edit-header p {
    margin: -8px 0 0;
    color: #53606c;
    font-size: 14px;
    line-height: 20px;
}

.macros-edit-back-link {
    margin-top: 4px;
    white-space: nowrap;
}

.macros-edit-form {
    max-width: 1180px;
}

.macros-edit-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 18px;
    align-items: start;
}

.macros-edit-main {
    min-width: 0;
}

.macros-edit-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(240px, 1fr));
    gap: 12px 16px;
}

.macros-edit-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.macros-edit-field-wide {
    grid-column: 1 / -1;
}

.macros-edit-field span {
    color: #1d2730;
    font-size: 13px;
    font-weight: 700;
    line-height: 18px;
}

.macros-edit-field small,
.macros-edit-inline-help {
    color: #627180;
    font-size: 12px;
    line-height: 17px;
}

.macros-edit-field input[type="text"],
.macros-edit-field select,
.macros-edit-field textarea {
    box-sizing: border-box;
    width: 100%;
    min-height: 32px;
    font-size: 14px;
}

.macros-edit-field textarea {
    min-height: 70px;
}

.macros-edit-section {
    margin: 0 0 18px;
    padding: 0 0 18px;
    border-bottom: 1px solid #d8dee4;
}

.macros-edit-section-muted {
    opacity: 0.82;
}

.macros-edit-section-head {
    margin: 0 0 12px;
}

.macros-edit-section h2,
.macros-edit-card h2 {
    margin: 0 0 10px;
    font-size: 18px;
    line-height: 24px;
    letter-spacing: 0;
    text-transform: none;
}

.macros-edit-section-head p {
    margin: -4px 0 0;
    color: #58636f;
    font-size: 13px;
    line-height: 18px;
}

.macros-edit-table-wrap input,
.macros-edit-table-wrap select {
    width: 100%;
    min-width: 90px;
    box-sizing: border-box;
}

.macros-edit-actions button,
.macros-edit-actions a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 32px;
    padding: 5px 10px;
    border-radius: 3px;
    font-size: 13px;
    line-height: 18px;
    text-decoration: none;
}

.macros-edit-actions button {
    color: #fff;
    background: #2fb241;
    border: 1px solid #249136;
}

.macros-edit-actions a {
    color: #1f6fb2;
    background: #eef6fc;
    border: 1px solid #b8d7ec;
}

.macros-edit-add-row {
    margin: 8px 0 0;
    min-height: 30px;
    padding: 4px 10px;
    color: #1f6fb2;
    background: #eef6fc;
    border: 1px solid #b8d7ec;
    border-radius: 3px;
    font-size: 13px;
    line-height: 18px;
}

.macros-edit-remove-row {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    min-height: 26px;
    padding: 0;
    color: #8a1f1f;
    background: #fff5f5;
    border: 1px solid #e3b2b2;
    border-radius: 3px;
    font-size: 20px;
    font-weight: 700;
    line-height: 1;
}

.macros-edit-main .macros-edit-table-wrap .list {
    width: 100%;
    min-width: 0;
    table-layout: fixed;
}

.macros-edit-action-cell {
    width: 34px;
}

.macros-edit-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.macros-edit-main .macros-edit-table-wrap th,
.macros-edit-main .macros-edit-table-wrap td {
    padding-right: 6px;
    padding-left: 6px;
}

.macros-edit-main .macros-edit-table-wrap input,
.macros-edit-main .macros-edit-table-wrap select {
    min-width: 0;
}

.macros-edit-inline-help {
    margin: 8px 0 0;
    padding: 7px 9px;
    background: #f7fafc;
    border-left: 3px solid #b8c4ce;
}

.macros-edit-sidebar {
    display: grid;
    gap: 12px;
}

.macros-edit-card {
    padding: 12px 14px;
    background: #fff;
    border: 1px solid #d8dee4;
}

.macros-edit-preview-label {
    font-size: 14px;
    font-weight: 700;
    line-height: 20px;
}

.macros-edit-preview-label [data-macro-preview-required] {
    color: #b00020;
}

.macros-edit-preview-code {
    margin: 2px 0 8px;
    color: #607080;
    font-family: Consolas, Monaco, monospace;
    font-size: 12px;
    line-height: 18px;
    overflow-wrap: anywhere;
}

.macros-edit-preview-control {
    box-sizing: border-box;
    min-height: 34px;
    padding: 8px;
    background: #f7fafc;
    border: 1px solid #cfd7df;
    color: #53606c;
    font-size: 13px;
    line-height: 18px;
}

.macros-edit-preview-hint {
    margin: 7px 0 0;
    color: #58636f;
    font-size: 12px;
    line-height: 17px;
}

.macros-edit-preview-rules,
.macros-edit-checks ul {
    margin: 9px 0 0;
    padding: 0;
    list-style: none;
}

.macros-edit-preview-rules:empty,
.macros-edit-preview-options:empty {
    display: none;
}

.macros-edit-preview-rules li {
    margin: 4px 0;
    color: #3f4a55;
    font-size: 12px;
    line-height: 17px;
}

.macros-edit-preview-options {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 9px;
}

.macros-edit-preview-options span {
    padding: 3px 6px;
    background: #eef6fc;
    border: 1px solid #c7dfef;
    color: #245d83;
    font-size: 12px;
    line-height: 16px;
}

.macros-edit-summary dl {
    margin: 0;
}

.macros-edit-summary dl div {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 6px 0;
    border-bottom: 1px solid #edf0f3;
}

.macros-edit-summary dl div:last-child {
    border-bottom: 0;
}

.macros-edit-summary dt {
    color: #64717e;
    font-size: 12px;
    line-height: 17px;
}

.macros-edit-summary dd {
    margin: 0;
    color: #1d2730;
    font-size: 12px;
    font-weight: 700;
    line-height: 17px;
    text-align: right;
    overflow-wrap: anywhere;
}

.macros-edit-check {
    margin: 6px 0 0;
    padding: 7px 8px;
    font-size: 12px;
    line-height: 17px;
}

.macros-edit-check-success,
.macros-edit-check-info {
    background: #f0f8f1;
    border-left: 3px solid #2fb241;
    color: #2f6336;
}

.macros-edit-check-warning {
    background: #fff8e6;
    border-left: 3px solid #d8a300;
    color: #6a5518;
}

.macros-edit-check-error {
    background: #fff5f6;
    border-left: 3px solid #d6455d;
    color: #8a1025;
}

.macros-edit-help-panel {
    margin: 0 0 18px;
    padding: 10px 12px;
    background: #f7fafc;
    border: 1px solid #d8dee4;
}

.macros-edit-help-panel summary {
    cursor: pointer;
    color: #1f6fb2;
    font-weight: 700;
}

.macros-edit-help-section {
    margin-top: 12px;
}

.macros-edit-help-section h3 {
    margin: 0 0 5px;
    font-size: 14px;
    line-height: 18px;
}

.macros-edit-help-section ul {
    margin: 0 0 0 18px;
    padding: 0;
}

.macros-edit-help-section li {
    margin: 3px 0;
    color: #53606c;
    font-size: 12px;
    line-height: 17px;
}

@media (max-width: 640px) {
    .item-template-macro-panel-head,
    .item-template-macro-search-row,
    .item-template-macro-sticky {
        align-items: stretch;
        flex-direction: column;
    }

    .item-template-macro-status {
        white-space: normal;
    }

    .item-template-macro-search-row input[type="search"],
    .item-template-macro-sticky input[type="search"] {
        width: 100%;
    }

    .item-template-macro-chip {
        width: 100%;
    }

    .item-template-macro-chip-compact {
        width: auto;
    }

    .item-template-macro-quick {
        max-width: 100%;
        overflow-x: auto;
        flex-wrap: nowrap;
        padding-bottom: 2px;
    }

    .catalog-template-header {
        flex-direction: column;
        align-items: stretch;
    }

    .catalog-template-field {
        grid-template-columns: 1fr;
        gap: 6px;
        padding-bottom: 14px;
    }

    .catalog-template-field-label {
        padding-top: 0;
    }

    .catalog-template-field-control input[type="text"],
    .catalog-template-field-control input[type="number"],
    .catalog-template-field-control input[type="date"],
    .catalog-template-field-control select,
    .catalog-template-field-control textarea,
    .catalog-template-field-control-short input[type="text"] {
        max-width: 100%;
    }

    .catalog-template-localized-controls {
        grid-template-columns: 1fr;
    }

    .catalog-template-actions {
        margin-left: 0;
    }

    .macros-toolbar {
        align-items: stretch;
        flex-direction: column;
    }

    .macros-edit-header,
    .macros-edit-layout,
    .macros-edit-grid {
        grid-template-columns: 1fr;
    }

    .macros-edit-header {
        display: grid;
    }

    .macros-toolbar input[type="text"],
    .macros-toolbar select,
    .macros-toolbar button,
    .macros-toolbar .btn,
    .macros-edit-field,
    .macros-edit-field-wide,
    .macros-edit-back-link {
        width: 100%;
    }

    .macros-edit-back-link {
        min-height: 38px;
    }

    .macros-edit-actions {
        align-items: stretch;
    }

    .macros-edit-actions button,
    .macros-edit-actions a,
    .macros-edit-add-row {
        min-height: 38px;
        min-width: 120px;
    }

    .macros-edit-add-row {
        width: 100%;
    }

    .macros-edit-main .macros-edit-table-wrap {
        overflow-x: visible;
    }

    .macros-edit-main .macros-edit-table-wrap .list {
        min-width: 0;
        width: 100%;
        table-layout: auto;
    }

    .macros-edit-main .macros-edit-table-wrap .list tr:first-child {
        display: none;
    }

    .macros-edit-main .macros-edit-table-wrap .list tr {
        display: grid;
        gap: 8px;
        margin: 0 0 10px;
        padding: 10px;
        background: #fff;
        border: 1px solid #d8dee4;
    }

    .macros-edit-main .macros-edit-table-wrap .list td {
        display: grid;
        grid-template-columns: 118px minmax(0, 1fr);
        gap: 8px;
        align-items: center;
        padding: 0;
        border: 0;
        text-align: left;
    }

    .macros-edit-main .macros-edit-table-wrap td::before {
        content: attr(data-label);
        color: #53606c;
        font-size: 12px;
        font-weight: 700;
        line-height: 16px;
    }

    .macros-edit-main .macros-edit-table-wrap input,
    .macros-edit-main .macros-edit-table-wrap select {
        min-height: 32px;
    }
}
