main:has(.setup-database-editor) { max-width: none; box-sizing: border-box; }
#columnsWrapper {
    overflow-x: auto;
    overflow-y: auto;
    max-height: min(150vh, 1800px);
    max-height: min(150dvh, 1800px);
    max-width: 100%;
    position: relative;
    overscroll-behavior: auto;
    scrollbar-gutter: stable;
    overflow-anchor: none;
}
#columnsWrapper.tnx-table-scroll-viewport[data-tnx-custom-horizontal-scrollbar="1"] {
    overflow-x: hidden;
    touch-action: pan-y pinch-zoom;
}
#setupTableActions { display:contents; }
@media (max-width:719px) {
    .setup-database-editor { width:100% !important; max-width:100% !important; min-width:0; box-sizing:border-box; }
    #columnsWrapper.tnx-table-scroll-viewport[data-tnx-custom-horizontal-scrollbar="1"] { touch-action: pan-x pan-y pinch-zoom; }
    #columnsWrapper.has-row-cards { scrollbar-gutter:auto; }
    .setup-database-editor.is-column-detail-open :is(#setupTableIdDisplay, #setupTableProperties, #addColumnControls, #setupTableActions, .configuration-utility-links) { display:none; }
    #columnsWrapper.has-row-cards.is-row-detail { max-height:none; overflow:visible; }
    #columnsWrapper.has-row-cards:not(.is-row-detail) #columnsTable,
    #columnsWrapper.has-row-cards #columnsTable thead,
    #columnsWrapper.has-row-cards #columnsTable tbody > tr,
    #columnsWrapper.has-row-cards .setup-columns-start-divider-hitbox { display:none; }
    #columnsWrapper.has-row-cards #columnsTable,
    #columnsWrapper.has-row-cards #columnsTable tbody,
    #columnsWrapper.has-row-cards #columnsTable tbody > tr.is-row-card-open { display:block; width:100%; min-width:0; }
    #columnsWrapper.has-row-cards #columnsTable td { display:block; position:static; width:100% !important; min-width:0 !important; max-width:100% !important; padding:0.6rem; border:0; border-bottom:1px solid var(--border-color); white-space:normal; text-align:start; }
    #columnsWrapper.has-row-cards #columnsTable td::before { content:attr(data-mobile-label); display:block; font-weight:600; margin-bottom:0.35rem; }
    #columnsWrapper.has-row-cards #columnsTable :is(input:not([type="checkbox"]):not([type="hidden"]), select, textarea, .column-wide-input, .column-compact-input) { width:100% !important; min-width:0 !important; max-width:100% !important; box-sizing:border-box; }
    #columnsWrapper.has-row-cards #columnsTable input[type="checkbox"] { margin-inline:0; }
}
#columnsTable {
    --column-editor-base-width: 200px;
    --column-editor-wide-width: 240px;
    --column-editor-compact-width: 100px;
    --column-editor-cell-extra-width: 12px;
    /* separate borders (not collapse): collapsed borders are painted on the
       shared grid lines and never move with position:sticky cells, so the
       scrolling content shines through exactly at the border pixels */
    border-collapse: separate;
    border-spacing: 0;
    width: max-content;
}
#columnsTable th,
#columnsTable td {
    border-right: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    padding: 4px;
    white-space: nowrap;
    text-align: center;
    vertical-align: top;
    overflow: visible;
    box-sizing: border-box;
}
#columnsTable thead th {
    position: sticky;
    top: 0;
    z-index: 40;
    border-top: 1px solid var(--border-color);
    background-color: var(--input-bg);
    background-clip: border-box;
}
#columnsTable th:first-child,
#columnsTable td:first-child {
    border-left: 1px solid var(--border-color);
}
/* "type" stays centered over its column, the help link sits on the same line at the right edge.
   The sticky header cell is positioned already, so it anchors the link without a position rule. */
#columnsTable th.setup-columns-type-header .tnx-help-article-link {
    position: absolute;
    top: 4px;
    right: 6px;
}
#columnsTable th {
    background-color: var(--input-bg);
}
#columnsTable td input,
#columnsTable th input {
    display:block;
    margin:0 auto;
}
#columnsTable td select,
#columnsTable td textarea,
#columnsTable th select,
#columnsTable th textarea {
    display:block;
    margin:0 auto;
}
#columnsTable input:not([type="checkbox"]) {
    min-width: var(--column-editor-base-width);
    width: var(--column-editor-base-width);
    text-align:left;
    box-sizing: border-box;
}
#columnsTable select,
#columnsTable textarea {
    min-width: var(--column-editor-base-width);
    width: var(--column-editor-base-width);
    box-sizing: border-box;
}
#columnsTable textarea.column-default-value-input {
    min-width: var(--column-editor-base-width);
    width: var(--column-editor-base-width);
    resize: none;
    overflow-y: auto;
}
#columnsTable th#dropdownOptionsHeader,
#columnsTable th#calculationsHeader,
#columnsTable th#placeholderHeader,
#columnsTable td[data-dropdown-options-cell],
#columnsTable td[data-calculations-cell],
#columnsTable td[data-placeholder-cell] {
    min-width: calc(var(--column-editor-wide-width) + var(--column-editor-cell-extra-width)) !important;
    width: calc(var(--column-editor-wide-width) + var(--column-editor-cell-extra-width)) !important;
    max-width: none !important;
}
#columnsTable th#stepHeader,
#columnsTable th#maxLengthHeader,
#columnsTable td[data-step-cell],
#columnsTable td[data-maxlength-cell] {
    min-width: calc(var(--column-editor-compact-width) + var(--column-editor-cell-extra-width)) !important;
    width: calc(var(--column-editor-compact-width) + var(--column-editor-cell-extra-width)) !important;
    max-width: none !important;
    white-space: normal;
}
#columnsTable td[data-dropdown-options-cell] textarea,
#columnsTable td[data-calculations-cell] textarea,
#columnsTable td[data-placeholder-cell] input,
#columnsTable .column-wide-input {
    min-width: var(--column-editor-wide-width) !important;
    width: var(--column-editor-wide-width) !important;
    max-width: var(--column-editor-wide-width) !important;
}
#columnsTable td[data-dropdown-options-cell] .tnx-scheduling-type-select {
    min-width: var(--column-editor-wide-width) !important;
    width: 100% !important;
    max-width: none !important;
}
#columnsTable td[data-step-cell] input,
#columnsTable td[data-maxlength-cell] input,
#columnsTable .column-compact-input {
    min-width: var(--column-editor-compact-width) !important;
    width: var(--column-editor-compact-width) !important;
    max-width: var(--column-editor-compact-width) !important;
    padding-left: 4px;
    padding-right: 4px;
}
#columnsTable textarea.column-expand-on-focus {
    height: auto;
    min-height: 0;
    max-height: none;
    resize: none;
    overflow-y: auto;
    overflow-x: hidden;
    white-space: pre-wrap;
    line-height: 1.3;
}
#columnsTable textarea.column-expand-on-focus:focus {
    resize: vertical;
}
#columnsTable .column-default-value-input--script {
    font-family: "Segoe Script", "Bradley Hand", "Comic Sans MS", cursive;
    font-style: italic;
}
#columnsTable input.column-label-input {
    font-weight: 700;
}
/* ensure the sticky name column matches other fields */
#columnsTable td.sticky-name input {
    min-width: 200px;
}
#columnsTable input[type="checkbox"] {
    display:block;
    margin:0 auto;
}
#columnsTable input[aria-disabled="true"],
#columnsTable select[aria-disabled="true"],
#columnsTable textarea[aria-disabled="true"],
#columnsTable input:disabled,
#columnsTable select:disabled,
#columnsTable textarea:disabled,
#columnsTable [data-column-interactive="false"] {
    cursor: default !important;
}
/* "depends on what" lists its suggested checkbox columns right after (none) and again at their own
   place, both copies with the same data-twin (setup-databases-core.js). A suggestion whose own place
   comes right after it is listed once, without data-twin. Where the browser draws the
   list in the page, both copies light up together: under the pointer, reached by keyboard and when
   chosen. The closed field keeps the flat look of the other dropdowns, with their normal line
   height instead of the page's. Two twins at most: the checkbox right before and the one the
   column above depends on. */
@supports (appearance: base-select) {
    #columnsTable select[name="col_OnlyShowIfThisIsTrue[]"],
    #columnsTable select[name="col_OnlyShowIfThisIsTrue[]"]::picker(select) {
        appearance: base-select;
    }
    #columnsTable select[name="col_OnlyShowIfThisIsTrue[]"] {
        line-height: normal;
        white-space: nowrap;
        overflow: hidden;
    }
    #columnsTable select[name="col_OnlyShowIfThisIsTrue[]"]:open {
        opacity: 1 !important;
        border-color: var(--primary-color);
        background-color: var(--bg-color);
    }
    #columnsTable select[name="col_OnlyShowIfThisIsTrue[]"]::picker-icon,
    #columnsTable select[name="col_OnlyShowIfThisIsTrue[]"] option::checkmark {
        display: none;
    }
    #columnsTable select[name="col_OnlyShowIfThisIsTrue[]"]::picker(select) {
        border: 1px solid var(--border-color);
        border-radius: var(--ds-radius-control, 4px);
        background-color: var(--input-bg);
        color: var(--text-color);
    }
    #columnsTable select[name="col_OnlyShowIfThisIsTrue[]"] option {
        padding: 4px 10px;
    }
    #columnsTable select[name="col_OnlyShowIfThisIsTrue[]"] option:checked,
    #columnsTable select[name="col_OnlyShowIfThisIsTrue[]"]:has(option[data-twin="1"]:checked) option[data-twin="1"],
    #columnsTable select[name="col_OnlyShowIfThisIsTrue[]"]:has(option[data-twin="2"]:checked) option[data-twin="2"] {
        background-color: color-mix(in srgb, var(--primary-color) 18%, var(--input-bg));
    }
    #columnsTable select[name="col_OnlyShowIfThisIsTrue[]"] option:is(:hover, :focus-visible),
    #columnsTable select[name="col_OnlyShowIfThisIsTrue[]"]:has(option[data-twin="1"]:is(:hover, :focus-visible)) option[data-twin="1"],
    #columnsTable select[name="col_OnlyShowIfThisIsTrue[]"]:has(option[data-twin="2"]:is(:hover, :focus-visible)) option[data-twin="2"] {
        background-color: color-mix(in srgb, var(--primary-color) 40%, var(--input-bg));
    }
}
#columnsTable th.sticky:not(.sticky-name),
#columnsTable td.sticky:not(.sticky-name) {
    --setup-column-sticky-overlay: transparent;
    position: sticky;
    left: 0;
    background-color: var(--bg-color);
    background-image: linear-gradient(var(--setup-column-sticky-overlay), var(--setup-column-sticky-overlay));
    background-position: left top;
    background-repeat: no-repeat;
    background-size: 100% 100%;
    background-clip: border-box;
    z-index: 30;
    width: 50px;
    min-width: 50px;
    max-width: 50px;
    overflow:hidden;
}
#columnsTable th.sticky,
#columnsTable th.sticky-name {
    background-color: var(--input-bg);
}
#columnsTable th.sticky-name,
#columnsTable td.sticky-name {
    --setup-column-sticky-overlay: transparent;
    position: sticky;
    left: 50px;
    z-index: 31;
    background-color: var(--bg-color);
    background-image: linear-gradient(var(--setup-column-sticky-overlay), var(--setup-column-sticky-overlay));
    background-position: left top;
    background-repeat: no-repeat;
    background-size: 100% 100%;
    background-clip: border-box;
    overflow:hidden;
    box-shadow: none;
}
#columnsTable th.sticky-name {
    background-color: var(--input-bg);
}
#columnsTable thead th.sticky:not(.sticky-name) {
    z-index: 50;
}
#columnsTable thead th.sticky-name {
    z-index: 51;
}
#columnsTable td.sticky,
#columnsTable td.sticky-name,
#columnsTable td.sticky-name input {
    font-weight: bold;
}
.setup-columns-start-divider-hitbox {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 8;
    display: none;
    width: 10px;
    cursor: pointer;
}
.setup-columns-start-divider-hitbox::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 4px;
    background: var(--border-color);
}
#columnsWrapper[data-scrolled-x="1"] #columnsTable th.sticky-name > .setup-columns-start-divider-hitbox,
#columnsWrapper[data-scrolled-x="1"] #columnsTable td.sticky-name > .setup-columns-start-divider-hitbox {
    display: block;
}
.form-group {
    margin-bottom: 1.5rem;
}
.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-color);
}
.form-control {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--input-bg);
    color: var(--text-color);
    font-size: 1rem;
}
.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    background-color: var(--bg-color);
}
#further_information:focus,
#column_groups:focus {
    opacity: 1 !important;
}
.human-primary .form-control {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--text-color);
}
#columnsTable th.selected,
#columnsTable td.selected,
#columnsTable td.selected input,
#columnsTable td.selected select,
#columnsTable td.selected textarea {
    color: var(--accent-color);
}
#columnsTable tr.is-column-row-selected td {
    background-color: rgba(66, 133, 244, 0.12);
    box-shadow: inset 0 1px 0 var(--primary-color), inset 0 -1px 0 var(--primary-color);
}
#columnsTable tr.is-column-row-selected td.sticky,
#columnsTable tr.is-column-row-selected td.sticky-name {
    --setup-column-sticky-overlay: rgba(66, 133, 244, 0.18);
    background-color: var(--bg-color);
}
#columnsTable.has-column-row-multi-selection tr.is-column-row-selected input,
#columnsTable.has-column-row-multi-selection tr.is-column-row-selected select,
#columnsTable.has-column-row-multi-selection tr.is-column-row-selected textarea {
    border-color: var(--border-color) !important;
    outline: none !important;
    outline-color: transparent !important;
    box-shadow: none !important;
}
#columnsTable tr.is-column-row-group-dragging td {
    opacity: 0.55;
}
/* Give menu views spacing without adding borders */
.containerWithoutBorder:has(.menu-nav) {
    padding: 2rem;
    overflow-x: auto;
}

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

.save-buttons button {
    width: 220px;
    display: inline-block;
}

.save-buttons button + button {
    margin-left: 10px;
}

.save-buttons button[name="save_table"] {
    opacity: 0.5;
}

.menu-nav {
    --menu-icon-container-size: 64px;
}

.menu-icon-box {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--menu-icon-container-size, 64px);
    height: var(--menu-icon-container-size, 64px);
    aspect-ratio: 1 / 1;
    border-radius: 12px;
    border: 2px solid var(--border-color);
    background-color: var(--menu-icon-bg, var(--input-bg));
}

.menu-icon-emoji {
    font-size: 2.2rem;
    line-height: 1;
}
.setup-table-dashboard-type-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}
.setup-special-table-actions {
    margin-top: 2rem;
    text-align: center;
}
.setup-special-table-actions a {
    opacity: 0.5;
}
/* Creating a second buying pair, selling pair or absences table stays fully
   possible, but such a link is dimmed by another 50% once a corresponding
   table already exists, since one is usually enough. */
.setup-special-table-actions a.setup-special-table-action-dimmed {
    opacity: 0.25;
}
.setup-special-table-actions a.setup-special-table-action-highlighted {
    opacity: 1;
    font-weight: 700;
}
.setup-special-table-actions span {
    opacity: 0.25;
}

#columnsTable :is([data-calculations-cell], [data-search-calculations-cell]) textarea[hidden] { display: none; }
#columnsTable :is([data-calculations-cell], [data-search-calculations-cell]) .tnx-executable-preview {
    height: var(--calculation-field-height, 32px);
    min-height: var(--calculation-field-height, 32px);
    max-height: var(--calculation-field-height, 32px);
    width: var(--column-editor-wide-width);
    padding: 0;
    justify-content: center;
    overflow: hidden;
}
#columnsTable :is([data-calculations-cell], [data-search-calculations-cell]) .tnx-executable-preview .api-node {
    transform: scale(var(--calculation-preview-scale, .4));
    transform-origin: left center;
    max-width: none;
    width: max-content;
}
#columnsTable :is([data-calculations-cell], [data-search-calculations-cell]) .tnx-executable-preview[hidden] { display: none; }

/* The "after <column>" insertion point next to the add-column links. It has to
   sit on the same baseline and keep the same height as the plain text links in
   that line, so the shell is height-locked to the line's own em size and the
   select itself is stripped of the global padded input look. */
.add-column-anchor {
    --add-column-anchor-height: 1.5em;
    display: inline-flex;
    align-items: center;
    gap: 0.35em;
    margin-right: 0.25em;
    vertical-align: middle;
    line-height: inherit;
}
.add-column-anchor[hidden] {
    display: none;
}
.add-column-anchor-label {
    opacity: 0.5;
}
.add-column-anchor-shell {
    display: inline-flex;
    align-items: center;
    min-height: var(--add-column-anchor-height);
    height: var(--add-column-anchor-height);
    max-height: var(--add-column-anchor-height);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--input-bg);
    box-sizing: border-box;
    overflow: hidden;
}
.add-column-anchor-select {
    display: block;
    width: auto;
    min-width: 0;
    max-width: min(18rem, 60vw);
    margin: 0;
    padding: 0 0.25em;
    min-height: 100%;
    height: 100%;
    max-height: 100%;
    border: none;
    border-radius: 0;
    background-color: transparent;
    background-image: none;
    color: var(--text-color);
    font: inherit;
    font-size: inherit;
    line-height: inherit;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    cursor: pointer;
    overflow: hidden;
    text-overflow: ellipsis;
}
.add-column-anchor-shell:focus-within {
    border-color: var(--primary-color);
}
.add-column-anchor-select:focus {
    outline: none;
    background-color: transparent;
}

/* Default values: the color swatch is exactly the plain browser swatch of the company accent
   color on UI/SetupCompany.php (the table's input rules would stretch it), and it and the
   symbol picker sit horizontally centered in their cell. */
#columnsTable td[data-role="default-value"] .tnx-structured-field { display: flex; justify-content: center; align-items: center; width: 100%; }
/* A default link is an input with its results below it, exactly like a link in an interactive table. */
#columnsTable td[data-role="default-value"] .tnx-structured-field:is([data-structured-type="table_link"], [data-structured-type="multiple_table_links"]) { display: block; text-align: start; }
#columnsTable td[data-role="default-value"] .linked-entry-search-results { margin-top: 4px; max-height: 120px; overflow-y: auto; border-left: 2px solid var(--border-color); padding-left: 8px; text-align: start; }
#columnsTable td[data-role="default-value"] .linked-entry-search-results button.search-select { background: none; border: none; color: var(--link-color); padding: 0; font: inherit; text-align: left; cursor: pointer; }
#columnsTable td[data-role="default-value"] .tnx-structured-field input[type="color"] { all: revert; padding: 0; cursor: pointer; }
#columnsTable td[data-role="default-value"] .tnx-symbol-picker { margin-left: auto; margin-right: auto; }

/* Columns whose controls only exist in some rows (team member roles, notify) or whose label length
   varies (linked tables) keep one fixed width, so the table never changes width while rows scroll
   in and out of view. */
#columnsTable th:nth-child(10),
#columnsTable td[data-role="linked-table"],
#columnsTable #linkedFieldHeader,
#columnsTable td[data-role="linked-field"],
#columnsTable #notifyHeader,
#columnsTable td[data-role="notify"] {
    min-width: calc(var(--column-editor-base-width) + var(--column-editor-cell-extra-width));
    width: calc(var(--column-editor-base-width) + var(--column-editor-cell-extra-width));
    max-width: calc(var(--column-editor-base-width) + var(--column-editor-cell-extra-width));
}
#columnsTable td[data-role="linked-table"] .tnx-linked-selection-trigger {
    max-width: var(--column-editor-base-width);
    margin: 0 auto;
}
