﻿/* ═══════════════════════════════════════════════════════════════════════
   Settings window (SettingsModal and its pages).

   .set-*  the window, side menu, and the admin pages.
   .dds-*  the Document Summary layout editor (DocumentLayoutSettingsPane).
   ═══════════════════════════════════════════════════════════════════════ */

/* ── Window ─────────────────────────────────────────────────────────── */

.set-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2300; /* above AddDocumentModal (2200), which can open it */
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: #323130;
}

.set-panel {
    position: relative;
    background: #ffffff;
    border-radius: 4px;
    width: 1120px;
    max-width: 96vw;
    height: 86vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.3);
}

.set-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 18px;
    border-bottom: 1px solid #e1dfdd;
    flex-shrink: 0;
}

.set-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #201f1e;
}

.set-layout {
    display: grid;
    grid-template-columns: 230px minmax(0, 1fr);
    flex: 1;
    min-height: 0;
}

/* ── Side menu ──────────────────────────────────────────────────────── */

.set-nav {
    background: #faf9f8;
    border-right: 1px solid #e1dfdd;
    padding: 10px 8px;
    overflow-y: auto;
}

.set-nav-group {
    padding: 12px 10px 4px;
    font-size: 11.5px;
    font-weight: 600;
    color: #605e5c;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

    .set-nav-group:first-child {
        padding-top: 4px;
    }

.set-nav-note {
    display: block;
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    color: #8a8886;
}

.set-nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 7px 10px;
    border: none;
    border-left: 3px solid transparent;
    border-radius: 2px;
    background: none;
    text-align: left;
    font: inherit;
    font-size: 13px;
    color: #323130;
    cursor: pointer;
}

    .set-nav-item i {
        width: 16px;
        text-align: center;
        color: #605e5c;
    }

    .set-nav-item:hover {
        background: #f3f2f1;
    }

    .set-nav-item.active {
        background: #ffffff;
        border-left-color: #0078d4;
        font-weight: 600;
        color: #201f1e;
    }

.set-dirty-dot {
    width: 7px;
    height: 7px;
    margin-left: auto;
    border-radius: 50%;
    background: #ca5010;
    flex-shrink: 0;
}

/* ── Content ────────────────────────────────────────────────────────── */

.set-content {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
}

.set-content-title {
    margin: 0;
    padding: 12px 18px 0;
    font-size: 15px;
    font-weight: 600;
    color: #201f1e;
    flex-shrink: 0;
}

.set-content-page {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

    .set-content-page[hidden] {
        display: none;
    }

.set-page {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.set-page-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    /* Reserve the scrollbar's space even when the page doesn't scroll, so
       the layout doesn't shift sideways (and rows don't re-wrap) the moment
       content grows tall enough to need one. */
    scrollbar-gutter: stable;
    padding: 10px 18px 18px;
}

.set-pad {
    padding: 14px 18px;
}

.set-intro {
    margin: 0 0 16px;
    font-size: 12.5px;
    line-height: 1.5;
    color: #605e5c;
    max-width: 78ch;
}

.set-section-title {
    margin: 0 0 8px;
    font-size: 13px;
    font-weight: 600;
    color: #201f1e;
}

.set-empty {
    margin: 4px 0 8px;
    font-size: 12px;
    color: #8a8886;
}

.set-meta {
    font-size: 11.5px;
    color: #8a8886;
}

.set-ok {
    color: #107c10;
    font-size: 12.5px;
}

.set-bad {
    color: #a4262c;
    font-size: 12.5px;
}

.set-muted {
    color: #8a8886;
    font-size: 12.5px;
}

.set-visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* ── One setting ────────────────────────────────────────────────────── */
/* A card: a header bar naming the setting with its value-after-saving pill,
   a body with the description and a framed editor, and a source line. The
   left edge carries state (orange unsaved, blue set in the app). */

.set-field {
    margin-bottom: 12px;
    background: #ffffff;
    border: 1px solid #e1dfdd;
    border-left: 4px solid #c8c6c4;
    border-radius: 4px;
    overflow: hidden;
}

    .set-field.inapp {
        border-left-color: #0078d4;
    }

    .set-field.pending {
        border-left-color: #ca5010;
    }

.set-field-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 14px;
    background: #faf9f8;
    border-bottom: 1px solid #edebe9;
}

.set-field.pending .set-field-head {
    background: #fff8f3;
}

.set-field-label {
    min-width: 0;
    font-size: 13.5px;
    font-weight: 600;
    color: #201f1e;
}

.set-field-head-end {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
    flex: 0 0 auto;
}

.set-field-value {
    display: inline-block;
    max-width: 260px;
    padding: 2px 10px;
    border-radius: 11px;
    background: #edebe9;
    color: #323130;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

    .set-field-value.on {
        background: #dff6dd;
        color: #0b5a0b;
    }

    .set-field-value.off {
        background: #f3f2f1;
        color: #605e5c;
    }

.set-field-body {
    padding: 10px 14px 12px;
}

.set-field-desc {
    margin: 0 0 10px;
    font-size: 12px;
    line-height: 1.5;
    color: #605e5c;
    max-width: 78ch;
}

/* The control itself: its own framed area, so the eye lands on what changes. */
.set-field-editor {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 10px 12px;
    background: #f8f9fb;
    border: 1px solid #e6e9ef;
    border-radius: 4px;
}

    .set-field-editor > .set-field-desc {
        margin: 2px 0 0;
    }

    .set-field-editor .set-inline {
        margin-top: 0;
        padding-left: 12px;
        border-left: 2px solid #c7e0f4;
    }

.set-field-warn {
    margin: 10px 0 0;
    padding: 6px 8px;
    background: #fff4ce;
    border-radius: 2px;
    font-size: 12px;
    color: #323130;
    max-width: 78ch;
}

    .set-field-warn i {
        color: #8a6d00;
        margin-right: 4px;
    }

.set-field-source {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 7px 14px;
    border-top: 1px solid #f3f2f1;
    font-size: 12px;
}

.set-badge {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 10px;
    background: #f3f2f1;
    color: #605e5c;
    font-size: 11px;
    white-space: nowrap;
}

.set-badge-app {
    background: #deecf9;
    color: #004578;
}

.set-badge-pending {
    background: #fed9cc;
    color: #8a3707;
}

.set-badge-sdx {
    background: #dff6dd;
    color: #0b5a0b;
}

/* ── Inputs and buttons ─────────────────────────────────────────────── */

.set-input {
    min-width: 0;
    max-width: 100%;
    padding: 5px 8px;
    border: 1px solid #8a8886;
    border-radius: 2px;
    background: #ffffff;
    font: inherit;
    font-size: 13px;
    color: #323130;
}

    .set-input:focus {
        outline: none;
        border-color: #0078d4;
        box-shadow: 0 0 0 1px #0078d4;
    }

select.set-input {
    width: 520px;
}

.set-number {
    width: 90px;
}

.set-uid {
    width: 420px;
    font-family: Consolas, 'Courier New', monospace;
    font-size: 12.5px;
}

.set-textarea {
    width: 100%;
    max-width: 640px;
    resize: vertical;
}

/* On/off settings draw their checkbox as a switch, with the state in words beside it. */
.set-toggle {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    cursor: pointer;
    user-select: none;
}

    .set-toggle input[type="checkbox"] {
        appearance: none;
        -webkit-appearance: none;
        position: relative;
        flex: 0 0 auto;
        width: 36px;
        height: 20px;
        margin: 0;
        border: 1px solid #8a8886;
        border-radius: 10px;
        background: #ffffff;
        cursor: pointer;
        transition: background-color 0.15s, border-color 0.15s;
    }

        .set-toggle input[type="checkbox"]::after {
            content: "";
            position: absolute;
            top: 3px;
            left: 3px;
            width: 12px;
            height: 12px;
            border-radius: 50%;
            background: #605e5c;
            transition: transform 0.15s, background-color 0.15s;
        }

        .set-toggle input[type="checkbox"]:checked {
            background: #0078d4;
            border-color: #0078d4;
        }

            .set-toggle input[type="checkbox"]:checked::after {
                transform: translateX(16px);
                background: #ffffff;
            }

        .set-toggle input[type="checkbox"]:focus-visible {
            outline: 2px solid #0078d4;
            outline-offset: 2px;
        }

        .set-toggle input[type="checkbox"]:disabled {
            opacity: 0.5;
            cursor: default;
        }

        .set-toggle input[type="checkbox"] + span {
            color: #605e5c;
        }

        .set-toggle input[type="checkbox"]:checked + span {
            color: #005a9e;
            font-weight: 600;
        }

.set-link-btn {
    border: none;
    background: none;
    padding: 2px 0;
    color: #0078d4;
    font: inherit;
    font-size: 12.5px;
    cursor: pointer;
    text-align: left;
}

    .set-link-btn:hover:not(:disabled) {
        text-decoration: underline;
    }

    .set-link-btn:disabled {
        color: #a19f9d;
        cursor: default;
    }

    .set-link-btn i {
        margin-right: 4px;
        font-size: 11px;
    }

.set-primary-btn,
.set-secondary-btn {
    padding: 6px 16px;
    border-radius: 2px;
    font: inherit;
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
}

.set-primary-btn {
    border: 1px solid #0078d4;
    background: #0078d4;
    color: #ffffff;
}

    .set-primary-btn:hover:not(:disabled) {
        background: #106ebe;
    }

.set-secondary-btn {
    border: 1px solid #8a8886;
    background: #ffffff;
    color: #323130;
}

    .set-secondary-btn:hover:not(:disabled) {
        background: #f3f2f1;
    }

    .set-secondary-btn i {
        margin-right: 4px;
        font-size: 11px;
    }

    .set-primary-btn:disabled,
    .set-secondary-btn:disabled {
        opacity: 0.55;
        cursor: default;
    }

.set-spinner {
    display: inline-block;
    width: 11px;
    height: 11px;
    margin-right: 4px;
    border: 2px solid #c8c6c4;
    border-top-color: #0078d4;
    border-radius: 50%;
    vertical-align: -1px;
    animation: set-spin 0.8s linear infinite;
}

@keyframes set-spin {
    to {
        transform: rotate(360deg);
    }
}

@media (prefers-reduced-motion: reduce) {
    .set-spinner {
        animation-duration: 2.4s;
    }
}

/* ── Footer, errors, confirm ────────────────────────────────────────── */

.set-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 18px;
    border-top: 1px solid #e1dfdd;
    flex-shrink: 0;
}

.set-footer-left,
.set-footer-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.set-footer-right {
    justify-content: flex-end;
}

.set-error {
    margin: 0 18px 10px;
    padding: 8px 10px;
    background: #fde7e9;
    border: 1px solid #f1bbbc;
    color: #a4262c;
    font-size: 12.5px;
    flex-shrink: 0;
}

.set-confirm-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.7);
}

.set-confirm {
    position: absolute;
    top: 30%;
    left: 50%;
    transform: translateX(-50%);
    width: 460px;
    max-width: calc(100% - 32px);
    padding: 16px 18px;
    background: #ffffff;
    border: 1px solid #c8c6c4;
    border-radius: 4px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
}

    .set-confirm p {
        margin: 0 0 14px;
        font-size: 13px;
        line-height: 1.5;
    }

/* ── Value lists (task names, reasons) ──────────────────────────────── */

.vle {
    width: 100%;
}

.vle-chips {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0 0 8px;
    padding: 0;
}

.vle-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 4px 3px 10px;
    border: 1px solid #c8c6c4;
    border-radius: 14px;
    background: #faf9f8;
    font-size: 12.5px;
}

    .vle-chip.unknown {
        border-color: #d8b000;
        background: #fff9e0;
    }

        .vle-chip.unknown > i {
            color: #8a6d00;
            font-size: 11px;
        }

.vle-flag {
    font-size: 11px;
    color: #8a6d00;
}

.vle-remove {
    width: 20px;
    height: 20px;
    border: none;
    border-radius: 50%;
    background: none;
    color: #605e5c;
    font-size: 11px;
    cursor: pointer;
}

    .vle-remove:hover {
        background: #edebe9;
        color: #201f1e;
    }

.vle-add {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

select.vle-select {
    width: 420px;
}

.vle-type {
    width: 280px;
}

/* ── Tables and previews ────────────────────────────────────────────── */

.set-preview,
.set-history,
.set-check-group {
    margin-top: 18px;
}

.set-preview-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.set-preview-summary {
    margin: 0 0 10px;
    font-size: 12.5px;
    line-height: 1.5;
    max-width: 90ch;
}

.set-filter {
    display: inline-flex;
    margin-bottom: 8px;
    border: 1px solid #c8c6c4;
    border-radius: 2px;
}

.set-filter-btn {
    padding: 4px 12px;
    border: none;
    background: #ffffff;
    font: inherit;
    font-size: 12px;
    cursor: pointer;
}

    .set-filter-btn + .set-filter-btn {
        border-left: 1px solid #c8c6c4;
    }

    .set-filter-btn.active {
        background: #deecf9;
        font-weight: 600;
    }

.set-table-wrap {
    overflow-x: auto;
    border: 1px solid #e1dfdd;
}

.set-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12.5px;
}

    .set-table th {
        position: sticky;
        top: 0;
        padding: 6px 10px;
        background: #f3f2f1;
        text-align: left;
        font-weight: 600;
        color: #323130;
        white-space: nowrap;
    }

    .set-table td {
        padding: 6px 10px;
        border-top: 1px solid #edebe9;
        vertical-align: top;
    }

    .set-table .num {
        text-align: right;
        font-variant-numeric: tabular-nums;
    }

    .set-table .nowrap {
        white-space: nowrap;
    }

    .set-table tr.hidden-row td {
        color: #605e5c;
    }

    .set-table tr.changed td:first-child {
        box-shadow: inset 3px 0 0 #ca5010;
    }

    .set-table tr.set-subrow td {
        background: #faf9f8;
    }

.set-doclist {
    margin: 0;
    padding-left: 18px;
    columns: 2;
    font-size: 12px;
}

.set-check {
    font-size: 12.5px;
    max-width: 78ch;
}

/* ── Configuration check ────────────────────────────────────────────── */

.set-check-summary {
    margin: 0 0 6px;
    padding: 8px 10px;
    font-size: 13px;
    border-left: 3px solid;
}

    .set-check-summary.ok {
        background: #dff6dd;
        border-color: #107c10;
    }

    .set-check-summary.warn {
        background: #fff4ce;
        border-color: #8a6d00;
    }

    .set-check-summary.bad {
        background: #fde7e9;
        border-color: #a4262c;
    }

.set-check-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.set-check-item {
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr);
    gap: 10px;
    padding: 7px 0;
    border-top: 1px solid #edebe9;
    font-size: 12.5px;
}

    .set-check-item > i {
        margin-top: 2px;
    }

    .set-check-item.ok > i {
        color: #107c10;
    }

    .set-check-item.warning > i {
        color: #8a6d00;
    }

    .set-check-item.problem > i {
        color: #a4262c;
    }

    .set-check-item.notchecked > i {
        color: #a19f9d;
    }

.set-check-name {
    font-weight: 600;
    color: #201f1e;
}

.set-check-detail {
    color: #605e5c;
    line-height: 1.45;
    overflow-wrap: anywhere;
}

@media (max-width: 760px) {
    .set-layout {
        grid-template-columns: 1fr;
        grid-template-rows: auto minmax(0, 1fr);
    }

    .set-nav {
        display: flex;
        flex-wrap: wrap;
        gap: 4px;
        border-right: none;
        border-bottom: 1px solid #e1dfdd;
        max-height: 40vh;
    }

    .set-nav-group {
        width: 100%;
    }

    .set-nav-item {
        width: auto;
    }

    select.set-input,
    select.vle-select,
    .set-uid {
        width: 100%;
    }
}

/* ═══════════════════════════════════════════════════════════════════════
   Document Summary layout editor (DocumentLayoutSettingsPane)
   ═══════════════════════════════════════════════════════════════════════ */

/* The pane fills the content area; the field picker is positioned against it. */
.dds-pane {
    position: relative;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.dds-body {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    min-height: 0;
    flex: 1;
    overflow: hidden;
}

.dds-editor {
    overflow-y: auto;
    padding: 14px 18px 18px;
}

.dds-intro {
    margin: 0 0 14px;
    font-size: 12.5px;
    line-height: 1.5;
    color: #605e5c;
    max-width: 70ch;
}

.dds-section + .dds-section {
    margin-top: 20px;
}

.dds-section-title {
    margin: 0 0 8px;
    font-size: 13px;
    font-weight: 600;
    color: #201f1e;
}

.dds-hint {
    margin: -2px 0 8px;
    font-size: 12px;
    color: #605e5c;
    max-width: 70ch;
}

.dds-empty {
    margin: 4px 0 8px;
    font-size: 12px;
    color: #8a8886;
}

/* Fallback chain: ordered, so an ordered list; the order is the meaning. */
.dds-chain {
    list-style: none;
    margin: 0 0 6px;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.dds-chip {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 5px 6px 5px 10px;
    border: 1px solid #e1dfdd;
    border-radius: 2px;
    background: #faf9f8;
}

/* Between chained fields: says what the order means. */
.dds-chain-then {
    padding-left: 10px;
    font-size: 11px;
    color: #8a8886;
}

.dds-chip-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.dds-chip-name {
    font-size: 12.5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dds-chip-source {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: #8a8886;
}

.dds-chip-tools,
.dds-row-tools {
    display: flex;
    gap: 2px;
    flex-shrink: 0;
}

.dds-row {
    padding: 10px;
    border: 1px solid #e1dfdd;
    border-radius: 2px;
    margin-bottom: 8px;
}

.dds-row-head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.dds-row-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.dds-input {
    flex: 1;
    min-width: 0;
    padding: 5px 8px;
    border: 1px solid #8a8886;
    border-radius: 2px;
    font: inherit;
    font-size: 13px;
}

    .dds-input:focus {
        outline: none;
        border-color: #0078d4;
        box-shadow: 0 0 0 1px #0078d4;
    }

.dds-check {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #605e5c;
    cursor: pointer;
}

.dds-icon-btn {
    border: none;
    background: none;
    color: #605e5c;
    width: 28px;
    height: 28px;
    border-radius: 2px;
    cursor: pointer;
}

    .dds-icon-btn.small {
        width: 24px;
        height: 24px;
        font-size: 11px;
    }

    .dds-icon-btn:hover:not(:disabled) {
        background: #f3f2f1;
        color: #201f1e;
    }

    .dds-icon-btn:disabled {
        color: #c8c6c4;
        cursor: default;
    }

.dds-link-btn {
    border: none;
    background: none;
    padding: 4px 0;
    color: #0078d4;
    font-size: 12.5px;
    cursor: pointer;
}

    .dds-link-btn:hover:not(:disabled) {
        text-decoration: underline;
    }

    .dds-link-btn i {
        margin-right: 4px;
        font-size: 11px;
    }

.dds-primary-btn,
.dds-secondary-btn {
    padding: 6px 16px;
    border-radius: 2px;
    font-size: 13px;
    cursor: pointer;
}

.dds-primary-btn {
    border: 1px solid #0078d4;
    background: #0078d4;
    color: #ffffff;
}

    .dds-primary-btn:hover:not(:disabled) {
        background: #106ebe;
    }

.dds-secondary-btn {
    border: 1px solid #8a8886;
    background: #ffffff;
    color: #323130;
}

    .dds-secondary-btn:hover:not(:disabled) {
        background: #f3f2f1;
    }

    .dds-secondary-btn i {
        margin-right: 4px;
        font-size: 11px;
    }

    .dds-primary-btn:disabled,
    .dds-secondary-btn:disabled,
    .dds-link-btn:disabled {
        opacity: 0.55;
        cursor: default;
    }

.set-overlay button:focus-visible,
.set-overlay input:focus-visible,
.set-overlay select:focus-visible,
.set-overlay textarea:focus-visible {
    outline: 2px solid #0078d4;
    outline-offset: 1px;
}

/* Preview mirrors the side panel's own field rows. */
.dds-preview {
    border-left: 1px solid #e1dfdd;
    background: #faf9f8;
    padding: 14px 16px;
    overflow-y: auto;
}

.dds-preview-note {
    margin: -4px 0 12px;
    font-size: 11.5px;
    color: #8a8886;
}

.dds-preview-tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    margin-bottom: 14px;
    background: #ffffff;
    border: 1px solid #e1dfdd;
    border-bottom: 2px solid #0078d4;
    font-size: 12.5px;
    overflow: hidden;
}

    .dds-preview-tab span {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

/* Mirrors the viewer's file tab strip. */
.dds-preview-files {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin: -8px 0 14px;
}

.dds-preview-file {
    max-width: 100%;
    padding: 3px 8px;
    background: #ffffff;
    border: 1px solid #e1dfdd;
    font-size: 11.5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dds-preview-row {
    display: flex;
    flex-direction: column;
    margin-bottom: 10px;
    font-size: 13px;
}

.dds-preview-label {
    color: #605e5c;
}

.dds-preview-value {
    color: #201f1e;
    overflow-wrap: anywhere;
}

    .dds-preview-value.empty {
        color: #a19f9d;
    }

.dds-error {
    margin: 0 18px 10px;
    padding: 8px 10px;
    background: #fde7e9;
    border: 1px solid #f1bbbc;
    color: #a4262c;
    font-size: 12.5px;
}

.dds-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 18px;
    border-top: 1px solid #e1dfdd;
}

.dds-footer-left,
.dds-footer-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.dds-meta {
    font-size: 11.5px;
    color: #8a8886;
}

/* Saved layouts (admins). */
.dds-storage {
    overflow-y: auto;
    padding: 14px 18px 18px;
    flex: 1;
    min-height: 0;
}

.dds-facts {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 6px 16px;
    margin: 0;
    font-size: 12.5px;
}

    .dds-facts dt {
        color: #605e5c;
    }

    .dds-facts dd {
        margin: 0;
        overflow-wrap: anywhere;
    }

        .dds-facts dd.dds-warn {
            color: #a4262c;
        }

.dds-layout {
    padding: 8px 10px;
    border: 1px solid #e1dfdd;
    border-radius: 2px;
    margin-bottom: 6px;
}

.dds-layout-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.dds-layout-who {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.dds-layout .dds-row-tools {
    gap: 14px;
}

.dds-confirm {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
    padding: 8px 10px;
    background: #fff4ce;
    font-size: 12.5px;
}

    .dds-confirm span {
        flex: 1;
    }

.dds-json {
    margin: 8px 0 0;
    padding: 10px;
    max-height: 260px;
    overflow: auto;
    background: #faf9f8;
    border: 1px solid #edebe9;
    font-size: 11.5px;
    line-height: 1.45;
}

/* Field picker: a panel over the editor, inside the modal. */
.dds-picker-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.6);
}

.dds-picker {
    position: absolute;
    top: 40px;
    left: 50%;
    transform: translateX(-50%);
    width: 680px;
    max-width: calc(100% - 32px);
    max-height: calc(100% - 80px);
    display: flex;
    flex-direction: column;
    background: #ffffff;
    border: 1px solid #c8c6c4;
    border-radius: 4px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
}

.dds-picker-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px;
    border-bottom: 1px solid #e1dfdd;
}

.dds-picker-list {
    overflow-y: auto;
    padding: 0 0 8px;
}

/* ── Sources: one colour and icon each, used on tabs, headings, badges ── */

.dds-src-column {
    --src: #0063b1;
    --src-bg: #e5f1fb;
}

.dds-src-form {
    --src: #6b4fa0;
    --src-bg: #efeaf7;
}

.dds-src-step {
    --src: #026b6e;
    --src-bg: #e1f3f3;
}

.dds-src-todo {
    --src: #a94206;
    --src-bg: #fbeee6;
}

.dds-src-file {
    --src: #4a4846;
    --src-bg: #f0efee;
}

.dds-src-other {
    --src: #605e5c;
    --src-bg: #f3f2f1;
}

.dds-src-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 10px;
    border-bottom: 1px solid #e1dfdd;
}

.dds-src-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border: 1px solid #c8c6c4;
    border-radius: 14px;
    background: #ffffff;
    font: inherit;
    font-size: 12px;
    color: #323130;
    cursor: pointer;
}

    .dds-src-tab i {
        color: var(--src, #605e5c);
        font-size: 11px;
    }

    .dds-src-tab:hover:not(.active) {
        background: var(--src-bg, #f3f2f1);
    }

    .dds-src-tab.active {
        border-color: var(--src, #323130);
        background: var(--src, #323130);
        color: #ffffff;
        font-weight: 600;
    }

        .dds-src-tab.active i {
            color: #ffffff;
        }

.dds-src-count {
    min-width: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: rgba(0, 0, 0, 0.07);
    font-size: 11px;
    font-weight: 600;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.dds-src-tab.active .dds-src-count {
    background: rgba(255, 255, 255, 0.25);
}

.dds-picker-tools {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 6px 12px;
    border-bottom: 1px solid #edebe9;
    font-size: 12px;
}

.dds-picker-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #323130;
    cursor: pointer;
}

/* Group headings stay pinned at the top of the list while it scrolls. */
.dds-picker-group {
    position: sticky;
    top: 0;
    z-index: 1;
    padding: 8px 12px 6px;
    background: var(--src-bg, #f3f2f1);
    border-top: 1px solid #e1dfdd;
    border-bottom: 1px solid #e1dfdd;
    border-left: 4px solid var(--src, #605e5c);
}

.dds-picker-group-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 0;
    border: none;
    background: none;
    font: inherit;
    font-size: 12.5px;
    font-weight: 600;
    color: #201f1e;
    text-align: left;
    cursor: pointer;
}

.dds-picker-chevron {
    width: 10px;
    font-size: 10px;
    color: #605e5c;
}

.dds-src-icon {
    color: var(--src, #605e5c);
}

.dds-picker-group-explain {
    margin: 2px 0 0 18px;
    font-size: 11.5px;
    font-weight: 400;
    color: #605e5c;
}

/* Badge naming a field's source, on picker items and on fields in a row. */
.dds-src-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 0 6px;
    border-radius: 3px;
    background: var(--src-bg, #f3f2f1);
    color: var(--src, #605e5c);
    font-size: 10.5px;
    font-weight: 600;
    white-space: nowrap;
    vertical-align: 1px;
}

    .dds-src-badge i {
        font-size: 9.5px;
    }

.dds-picker-item {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 16px;
    width: 100%;
    padding: 6px 12px;
    border: none;
    background: none;
    text-align: left;
    font: inherit;
    font-size: 12.5px;
    cursor: pointer;
}

    .dds-picker-item:hover:not(:disabled) {
        background: #f3f2f1;
    }

    .dds-picker-item:disabled {
        cursor: default;
        opacity: 0.55;
    }

.dds-picker-name {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    column-gap: 8px;
    row-gap: 1px;
    min-width: 0;
    color: #201f1e;
}

.dds-picker-label {
    font-weight: 600;
}

/* The key goes on its own line under the badge and name. */
.dds-picker-key {
    flex-basis: 100%;
    font-size: 11px;
    color: #8a8886;
    font-family: Consolas, 'Courier New', monospace;
}

.dds-picker-value {
    flex-shrink: 0;
    max-width: 45%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #605e5c;
}

    .dds-picker-value.empty {
        color: #a19f9d;
        font-style: italic;
    }

@media (max-width: 720px) {
    .dds-body {
        grid-template-columns: 1fr;
        overflow-y: auto;
    }

    .dds-preview {
        border-left: none;
        border-top: 1px solid #e1dfdd;
    }
}

/* ── A window that failed (ModalErrorBoundary, see DocViewerShell) ─────── */

.set-crash {
    width: 560px;
    max-width: 94vw;
    padding: 18px 20px;
    background: #ffffff;
    border-radius: 4px;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.3);
}

    .set-crash .set-title i {
        color: #a4262c;
        margin-right: 6px;
    }

    .set-crash p {
        margin: 10px 0;
        font-size: 13px;
        line-height: 1.5;
    }

.set-crash-detail {
    margin: 0 0 14px;
    padding: 8px 10px;
    max-height: 160px;
    overflow: auto;
    background: #faf9f8;
    border: 1px solid #edebe9;
    font-size: 12px;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

/* ── Grouping and inline editors on admin pages ───────────────────────── */

/* Group headings: a ruled line that clearly starts a new block of cards. */
.set-group-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 26px 0 10px;
    font-size: 12px;
    font-weight: 700;
    color: #323130;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

    .set-group-title::after {
        content: "";
        flex: 1 1 auto;
        height: 1px;
        background: #e1dfdd;
    }

.set-intro + .set-group-title {
    margin-top: 4px;
}

.set-inline {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
    font-size: 13px;
}

/* ── Fields made irrelevant by another setting (kept, greyed out) ─────── */

.set-field.disabled .set-field-label,
.set-field.disabled .set-field-desc,
.set-field.disabled .set-field-editor {
    opacity: 0.55;
}

.set-field-off {
    margin: 0 0 8px;
    padding: 5px 8px;
    background: #f3f2f1;
    font-size: 12px;
    color: #605e5c;
    max-width: 78ch;
}

    .set-field-off i {
        margin-right: 5px;
        font-size: 11px;
    }

/* ── SDx identifiers page ─────────────────────────────────────────────── */

.set-id-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 14px;
    margin-bottom: 10px;
}

.set-id-searchbox {
    position: relative;
    flex: 1 1 240px;
    max-width: 360px;
}

    .set-id-searchbox i {
        position: absolute;
        left: 9px;
        top: 50%;
        transform: translateY(-50%);
        font-size: 11px;
        color: #8a8886;
        pointer-events: none;
    }

.set-id-search {
    width: 100%;
    padding-left: 26px;
}

.set-id-views {
    margin-bottom: 0;
}

/* Always its own line, right-aligned, so the toolbar has one layout at
   every width instead of re-flowing as the panel narrows. */
.set-id-actions {
    display: flex;
    flex-wrap: wrap;
    flex-basis: 100%;
    justify-content: flex-end;
    align-items: center;
    gap: 8px 14px;
}

    .set-id-actions .set-secondary-btn i {
        margin-right: 5px;
    }

/* Group bar */

.set-id-groups {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 6px;
}

.set-id-group {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    padding: 7px 10px;
    border: 1px solid #e1dfdd;
    border-radius: 2px;
    background: #ffffff;
    font: inherit;
    font-size: 12.5px;
    color: #323130;
    text-align: left;
    cursor: pointer;
}

    .set-id-group:hover {
        background: #f3f2f1;
    }

    .set-id-group.active {
        border-color: #0078d4;
        box-shadow: inset 0 -2px 0 #0078d4;
        background: #f3f9fd;
        font-weight: 600;
    }

    .set-id-group > i {
        width: 14px;
        text-align: center;
        color: #605e5c;
    }

    .set-id-group.active > i {
        color: #0078d4;
    }

.set-id-group-name {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.set-id-group-badges {
    display: inline-flex;
    gap: 3px;
    flex: 0 0 auto;
}

.set-id-count {
    display: inline-block;
    min-width: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: #f3f2f1;
    color: #605e5c;
    font-size: 11px;
    font-weight: 600;
    line-height: 17px;
    text-align: center;
}

    .set-id-count.app {
        background: #deecf9;
        color: #004578;
    }

    .set-id-count.pending {
        background: #fed9cc;
        color: #8a3707;
    }

    .set-id-count.bad {
        background: #fde7e9;
        color: #a4262c;
    }

.set-id-legend {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 6px;
    margin: 6px 0 4px;
    font-size: 11.5px;
}

    .set-id-legend .set-id-count {
        margin-left: 6px;
    }

        .set-id-legend .set-id-count:first-child {
            margin-left: 0;
        }

/* Rows */

.set-id-section {
    margin-top: 6px;
}

.set-id-section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
}

    .set-id-section-head .set-group-title {
        margin-top: 16px;
    }

.set-id-rows {
    border: 1px solid #e1dfdd;
    border-radius: 2px;
}

.set-id-row {
    display: grid;
    grid-template-columns: 20px minmax(170px, 1fr) minmax(200px, 1.5fr) 64px 28px;
    align-items: center;
    column-gap: 10px;
    padding: 6px 8px 6px 10px;
    border-left: 3px solid transparent;
}

    .set-id-row + .set-id-row {
        border-top: 1px solid #edebe9;
    }

    .set-id-row:hover {
        background: #faf9f8;
    }

    .set-id-row.open {
        background: #faf9f8;
    }

    .set-id-row.pending {
        border-left-color: #ca5010;
    }

    .set-id-row.problem:not(.pending) {
        border-left-color: #a4262c;
    }

.set-id-status {
    display: flex;
    justify-content: center;
    font-size: 13px;
}

    .set-id-status .st-ok {
        color: #107c10;
    }

    .set-id-status .st-bad {
        color: #a4262c;
    }

    .set-id-status .st-warn {
        color: #8a6d00;
    }

    .set-id-status .st-none {
        color: #c8c6c4;
    }

.set-id-name {
    display: flex;
    flex-direction: column;
    min-width: 0;
    cursor: pointer;
}

.set-id-label {
    font-size: 13px;
    font-weight: 600;
    color: #201f1e;
}

.set-id-key {
    align-self: flex-start;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 0 4px;
    background: #f3f2f1;
    border-radius: 2px;
    font-family: Consolas, 'Courier New', monospace;
    font-size: 11px;
    color: #605e5c;
}

.set-id-editor {
    min-width: 0;
}

.set-id-input {
    width: 100%;
}

.set-id-mono {
    font-family: Consolas, 'Courier New', monospace;
    font-size: 12.5px;
}

textarea.set-id-input {
    resize: vertical;
}

.set-id-source {
    text-align: right;
}

.set-id-toggle {
    justify-self: end;
}

/* Lines and details under a row span the name, editor and source columns. */

.set-id-inline,
.set-id-details {
    grid-column: 2 / 5;
}

.set-id-inline {
    margin: 4px 0 0;
    font-size: 12px;
    overflow-wrap: anywhere;
}

    .set-id-inline.bad {
        color: #a4262c;
    }

.set-id-details {
    margin-top: 6px;
    padding: 8px 0 2px;
    border-top: 1px dashed #e1dfdd;
}

    .set-id-details .set-field-desc {
        margin-top: 0;
    }

    .set-id-details > .set-meta {
        margin: 0 0 6px;
        font-size: 12px;
    }

.set-id-result {
    margin: 4px 0 6px;
    max-width: 90ch;
    border-top: none;
    padding: 0;
    overflow-wrap: anywhere;
}

    .set-id-result.stale {
        opacity: 0.6;
    }

.set-id-detail-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 18px;
    font-size: 12px;
}

/* Narrow panels: the editor drops under the name. */

@media (max-width: 900px) {
    .set-id-row {
        grid-template-columns: 20px minmax(0, 1fr) 64px 28px;
        row-gap: 6px;
    }

    .set-id-editor {
        grid-column: 2 / 4;
        grid-row: 2;
    }

    .set-id-inline,
    .set-id-details {
        grid-column: 2 / 4;
    }
}

/* Export and save confirmation */

.set-id-export {
    margin: 0 0 10px;
}

.set-id-pre {
    margin: 4px 0 0;
    padding: 8px 10px;
    max-width: 100%;
    overflow-x: auto;
    background: #f3f2f1;
    border: 1px solid #e1dfdd;
    font-family: Consolas, 'Courier New', monospace;
    font-size: 12px;
    user-select: all;
}

.set-id-confirm {
    margin: 0 20px 8px;
    padding: 10px 12px;
    background: #fff4ce;
    border: 1px solid #f2c94c;
    font-size: 13px;
}

    .set-id-confirm p {
        margin: 0 0 8px;
    }

    .set-id-confirm i {
        margin-right: 6px;
        color: #8a6d00;
    }

.set-id-inline i {
    margin-right: 4px;
}

.set-id-inline.good {
    color: #107c10;
}

.set-id-inline.suggest {
    color: #323130;
}

    .set-id-inline.suggest > i {
        color: #8764b8;
    }

    .set-id-inline.suggest .set-link-btn {
        margin-left: 6px;
        font-weight: 600;
    }

.set-id-inline.muted {
    color: #8a8886;
}

/* SDx identifiers: values read from SDx */

.set-id-count.sdx {
    background: #dff6dd;
    color: #0b5a0b;
}

.set-id-found {
    display: flex;
    gap: 8px;
    margin: 0 0 6px;
    font-size: 12px;
    color: #323130;
    overflow-wrap: anywhere;
}

    .set-id-found > i {
        margin-top: 2px;
        color: #107c10;
    }

    .set-id-found.muted,
    .set-id-found.muted > i {
        color: #8a8886;
    }

.set-id-refresh-note {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
