* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: #f4f6f8;
    color: #172033;
    font-family: Arial, Helvetica, sans-serif;
}

a {
    color: #1767c2;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.container {
    width: min(1080px, calc(100% - 32px));
    margin: 40px auto;
}

.narrow {
    max-width: 560px;
}

.app-header {
    border-bottom: 1px solid #d8dee8;
    background: #fff;
}

.app-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    width: min(1080px, calc(100% - 32px));
    min-height: 72px;
    margin: 0 auto;
    padding: 12px 0;
}

.app-brand,
.app-user {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.app-brand-image {
    display: block;
    max-width: 150px;
    max-height: 48px;
    object-fit: contain;
}

.app-title {
    color: #172033;
    font-size: 18px;
    font-weight: 700;
}

.app-user {
    justify-content: flex-end;
    color: #475467;
    font-size: 13px;
}

.app-user span {
    border-right: 1px solid #d8dee8;
    padding-right: 10px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 14px;
}

h1 {
    margin: 0 0 20px;
    font-size: 30px;
}

.topbar h1 {
    margin-bottom: 0;
}

.entity-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
}

.entity-nav a {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 1px solid #c8d0dc;
    border-radius: 6px;
    background: #fff;
    color: #172033;
    padding: 9px 12px;
}

.entity-nav a.active {
    border-color: #1767c2;
    background: #1767c2;
    color: #fff;
}

.entity-nav a:hover {
    text-decoration: none;
}

.entity-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.entity-icon {
    display: inline-block;
    object-fit: contain;
    flex: 0 0 auto;
}

.entity-icon-menu {
    width: 28px;
    height: 28px;
}

.entity-icon-nav {
    width: 18px;
    height: 18px;
}

.entity-icon-title {
    width: 34px;
    height: 34px;
}

.button,
button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    border: 0;
    border-radius: 6px;
    background: #1767c2;
    color: #fff;
    cursor: pointer;
    font: inherit;
    font-weight: 700;
    padding: 10px 16px;
}

.button:hover {
    text-decoration: none;
}

.alert {
    border-left: 4px solid #1f8f62;
    background: #e9f7f0;
    padding: 12px 14px;
}

.alert-danger {
    border-left-color: #b42318;
    background: #fef3f2;
}

.help-panel {
    border-left: 4px solid #1767c2;
    background: #eef6ff;
    color: #344054;
    margin: 0 0 18px;
    padding: 12px 14px;
}

.field-help {
    color: #667085;
    font-size: 13px;
    font-weight: 400;
    line-height: 1.35;
}

.choice-options {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 16px;
    align-items: center;
    min-height: 42px;
    border: 1px solid #c8d0dc;
    border-radius: 6px;
    background: #fff;
    padding: 8px 12px;
}

.choice-options-vertical {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
}

.choice-option {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 28px;
    margin: 0;
    color: #172033;
    font-weight: 400;
}

.choice-option input {
    width: auto;
}

.help-marker {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    margin-left: 4px;
    border-radius: 50%;
    background: #d8eafd;
    color: #1767c2;
    font-size: 11px;
    font-weight: 700;
    text-transform: none;
}

.user-status {
    margin: -10px 0 18px;
    color: #475467;
}

.record-meta {
    margin: 6px 0 0;
    color: #475467;
}

table {
    width: 100%;
    border-collapse: collapse;
    overflow: hidden;
    background: #fff;
    border: 1px solid #d8dee8;
    border-radius: 8px;
}

.list-group-row th {
    background: #e6edf6;
    color: #172033;
    text-align: center;
}

th,
td {
    border-bottom: 1px solid #e5e9f0;
    padding: 12px;
    text-align: left;
}

th {
    background: #eef2f7;
    font-size: 13px;
}

tr:last-child td {
    border-bottom: 0;
}

.align-left {
    text-align: left;
}

.align-center {
    text-align: center;
}

.align-right {
    text-align: right;
}

.actions {
    width: 190px;
    white-space: nowrap;
}

.record-actions {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.record-actions form {
    display: inline-flex;
}

.action-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-height: auto;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: #1767c2;
    font: inherit;
    font-weight: 400;
    padding: 0;
}

.action-link:hover {
    text-decoration: underline;
}

.action-icon {
    width: 16px;
    height: 16px;
    object-fit: contain;
}

.link-danger {
    color: #b42318;
}

.link-danger:hover {
    text-decoration: underline;
}

.muted-action {
    color: #98a2b3;
}

.empty {
    color: #667085;
    text-align: center;
}

.thumb {
    display: block;
    width: 52px;
    height: 52px;
    border-radius: 6px;
    object-fit: cover;
}

.preview {
    width: 160px;
    max-width: 100%;
    border-radius: 8px;
    border: 1px solid #d8dee8;
}

.form {
    display: grid;
    gap: 16px;
    padding: 24px;
    border: 1px solid #d8dee8;
    border-radius: 8px;
    background: #fff;
}

.form-section {
    display: grid;
    gap: 14px;
}

.form-section + .form-section {
    border-top: 1px solid #d8dee8;
    padding-top: 18px;
}

.form-section h2 {
    margin: 0;
    color: #172033;
    font-size: 18px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 14px 16px;
}

.form-field {
    grid-column: span 6;
    align-content: start;
}

.form-field-xs {
    grid-column: span 2;
}

.form-field-sm {
    grid-column: span 3;
}

.form-field-md {
    grid-column: span 4;
}

.form-field-lg {
    grid-column: span 6;
}

.form-field-full {
    grid-column: 1 / -1;
}

.menu-panel {
    display: grid;
    gap: 18px;
    padding: 24px;
    border: 1px solid #d8dee8;
    border-radius: 8px;
    background: #fff;
}

.menu-form {
    display: grid;
    gap: 16px;
}

.menu-links {
    display: grid;
    gap: 8px;
}

.menu-links a {
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid #d8dee8;
    border-radius: 6px;
    background: #f8fafc;
    color: #172033;
    padding: 10px 12px;
}

.menu-links a:hover {
    background: #eef2f7;
    text-decoration: none;
}

label {
    display: grid;
    gap: 8px;
    font-weight: 700;
}

input,
select,
textarea {
    width: 100%;
    min-height: 42px;
    border: 1px solid #c8d0dc;
    border-radius: 6px;
    color: #172033;
    font: inherit;
    padding: 10px 12px;
}

input[type="number"],
.form-field.align-right input,
.form-field.align-right select,
.form-field.align-right textarea,
.measurement-field.align-right strong {
    text-align: right;
}

input[readonly],
textarea[readonly],
select:disabled {
    background: #eef2f7;
    color: #667085;
    cursor: not-allowed;
}

textarea {
    min-height: 110px;
    resize: vertical;
}

.search-form {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) minmax(160px, 220px) auto;
    align-items: end;
    gap: 14px;
    margin-bottom: 20px;
    padding: 16px;
    border: 1px solid #d8dee8;
    border-radius: 8px;
    background: #fff;
}

.search-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 42px;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-top: 18px;
    color: #475467;
}

.pagination-jump {
    display: flex;
    align-items: end;
    gap: 8px;
}

.pagination-jump label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #475467;
    font-weight: 400;
}

.pagination-jump input {
    width: 84px;
    min-height: 36px;
    padding: 7px 8px;
}

.pagination-jump button {
    min-height: 36px;
    padding: 7px 12px;
}

.pagination-links {
    display: flex;
    align-items: center;
    gap: 6px;
}

.pagination-links a {
    min-width: 36px;
    border: 1px solid #c8d0dc;
    border-radius: 6px;
    background: #fff;
    color: #172033;
    padding: 8px 10px;
    text-align: center;
}

.pagination-links a.active {
    border-color: #1767c2;
    background: #1767c2;
    color: #fff;
}

.form-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 16px;
}

.measurement-form {
    display: grid;
    gap: 18px;
}

.measurement-section {
    border: 1px solid #d8dee8;
    border-radius: 8px;
    background: #fff;
    overflow: hidden;
}

.measurement-section h2 {
    margin: 0;
    background: #eef2f7;
    color: #172033;
    font-size: 18px;
    padding: 14px 16px;
}

.measurement-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px 16px;
    padding: 16px;
}

.measurement-field {
    display: grid;
    gap: 6px;
    color: #344054;
    font-weight: 700;
}

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

.measurement-readonly strong {
    min-height: 40px;
    border: 1px solid #d8dee8;
    border-radius: 6px;
    background: #f8fafc;
    color: #172033;
    font-weight: 400;
    padding: 10px 12px;
}

.measurement-field-error select,
.measurement-field-error input,
.measurement-field-error textarea {
    border-color: #b42318;
}

.field-error {
    color: #b42318;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.35;
}

.measurement-subtitle {
    grid-column: 1 / -1;
    border-top: 1px solid #e5e9f0;
    color: #1767c2;
    font-weight: 700;
    padding-top: 8px;
}

.layout-builder-form {
    margin-bottom: 20px;
}

.code-editor {
    min-height: 520px;
    font-family: Consolas, "Courier New", monospace;
    font-size: 14px;
    line-height: 1.45;
    white-space: pre;
}

.layout-builder-note h2 {
    margin: 0;
    font-size: 20px;
}

.layout-builder-note p {
    margin: 0;
    color: #475467;
}

@media (max-width: 720px) {
    table,
    thead,
    tbody,
    tr,
    th,
    td {
        display: block;
    }

    thead {
        display: none;
    }

    tr {
        border-bottom: 1px solid #d8dee8;
        padding: 10px 0;
    }

    td {
        border: 0;
    }

    .actions {
        width: auto;
    }

    .search-form {
        grid-template-columns: 1fr;
    }

    .form-field,
    .form-field-xs,
    .form-field-sm,
    .form-field-md,
    .form-field-lg,
    .form-field-full {
        grid-column: 1 / -1;
    }

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

    .search-actions {
        justify-content: flex-start;
    }

    .pagination {
        align-items: flex-start;
        flex-direction: column;
    }

    .pagination-jump {
        align-items: flex-start;
        flex-wrap: wrap;
    }

    .app-header-inner {
        align-items: flex-start;
        flex-direction: column;
    }

    .app-user {
        justify-content: flex-start;
    }
}
