/* ── Fields module — grid layout (polished) ──────────────────────────── */
#fieldGridContainer {
    background: var(--fields-surface);
    border: 1px solid var(--fields-line);
    border-radius: 14px;
    box-shadow: var(--fields-shadow);
    padding: .85rem 1.1rem 1rem;
}

/* ── Device segmented tabs (centered) ── */
.fld-device-bar { display: flex; justify-content: center; margin: 0 0 .35rem; }
.fld-device-tabs {
    display: inline-flex; gap: 4px; padding: 3px;
    background: var(--fields-surface-soft); border-radius: 11px;
}
.fld-device-tab {
    display: inline-flex; align-items: center; gap: 7px;
    border: 0; background: transparent; cursor: pointer;
    padding: 6px 18px; border-radius: 9px;
    font-size: .84rem; font-weight: 600; color: var(--fields-muted);
    transition: color .15s, background .15s, box-shadow .15s;
}
.fld-device-tab i { font-size: 1rem; }
.fld-device-tab:hover { color: var(--fields-ink); }
.fld-device-tab.active {
    background: var(--fields-surface-raised); color: var(--fields-primary);
    box-shadow: 0 1px 4px var(--fields-shadow-color);
}

.fld-hint {
    text-align: center; color: var(--fields-muted); font-size: .76rem;
    margin: 0 0 .7rem;
}
.fld-hint i { color: var(--fields-muted); }

/* ── Grid ── */
.fld-grid-wrap {
    overflow-x: auto; border: 1px solid var(--fields-line); border-radius: 12px;
    -webkit-overflow-scrolling: touch;
}
.fld-grid {
    width: 100%; border-collapse: separate; border-spacing: 0;
    font-size: .85rem;
}
.fld-grid thead th {
    position: sticky; top: 0; z-index: 2;
    background: var(--fields-surface-soft); border-bottom: 2px solid var(--fields-line);
    padding: .4rem .35rem .3rem; text-align: center; vertical-align: bottom;
    white-space: nowrap;
}
.fld-th-field {
    text-align: left !important; min-width: 200px;
    position: sticky; left: 0; z-index: 3; background: var(--fields-surface-soft);
}
.fld-th-page { width: 54px; }
.fld-th-ic { display: block; font-size: .98rem; color: var(--fields-muted); line-height: 1; }
.fld-th-lbl {
    display: block; font-size: .58rem; font-weight: 800;
    text-transform: uppercase; letter-spacing: .03em; color: var(--fields-muted);
    margin: 2px 0 3px;
}
.fld-th-search { min-width: 86px; }

.fld-grid tbody td {
    padding: .2rem .35rem; text-align: center; vertical-align: middle;
    border-bottom: 1px solid var(--fields-line);
}
.fld-grid tbody tr:last-child td { border-bottom: 0; }
.fld-grid tbody tr:hover td { background: var(--fields-hover); }
.fld-td-field {
    text-align: left !important;
    position: sticky; left: 0; z-index: 1; background: var(--fields-surface);
}
.fld-grid tbody tr:hover .fld-td-field { background: var(--fields-hover); }
.fld-fname { font-weight: 600; color: var(--fields-ink); }
.fld-ftype { color: var(--fields-muted); font-size: .72rem; font-weight: 400; }

/* checkboxes */
.fld-chk { width: 16px; height: 16px; cursor: pointer; accent-color: var(--fields-primary); margin: 0; vertical-align: middle; }
.fld-chk-wrap { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; margin: 0; }
.fld-chk-col, .fld-chk-row, .fld-chk-master { accent-color: var(--fields-primary); }
.fld-th-page .fld-chk-col { display: block; margin: 0 auto; }

/* search pill */
.fld-search-pill {
    display: inline-flex; align-items: center; gap: 5px;
    border: 1px solid var(--fields-line); background: var(--fields-surface-raised); border-radius: 999px;
    padding: 2px 11px; font-size: .74rem; font-weight: 600; color: var(--fields-muted);
    cursor: pointer; transition: all .15s;
}
.fld-search-pill i { font-size: .78rem; }
.fld-search-pill:hover { border-color: var(--fields-primary); color: var(--fields-primary); background: var(--fields-hover); }
.fld-search-pill.is-on { background: var(--fields-primary-soft); border-color: var(--fields-primary); color: var(--fields-primary); }
.fld-search-pill.is-filter { background: var(--fields-filter-soft); border-color: var(--fields-filter); color: var(--fields-filter); }
.fld-search-pill.is-off { color: var(--fields-muted); }

/* ── Responsiveness ── */
@media (max-width: 767.98px) {
    .main-area { flex-direction: column !important; }
    .left-panel {
        width: 100% !important; max-height: 40vh; overflow-y: auto;
        flex-shrink: 0; transition: max-height 0.3s ease;
    }
    .left-panel.collapsed { max-height: 0; overflow: hidden; }
    .right-workspace { flex: 1 1 auto; width: 100% !important; }
    .workspace-content { padding: 0.5rem; }
    #fieldGridContainer { padding: .75rem; border-radius: 10px; }
    .fld-device-tab { padding: 7px 13px; font-size: .8rem; gap: 5px; }
    .fld-hint { font-size: .72rem; }
    .fld-grid { font-size: .8rem; }
    .fld-th-field, .fld-td-field { min-width: 150px; }
}

/* Fields module colour-mode bridge. Scoped to avoid changing generated page
   themes or any other project module. */
.fields-module {
    --fields-header-height: 66px;
    --fields-ink: var(--pp-text);
    --fields-muted: var(--pp-text-muted);
    --fields-line: var(--pp-border);
    --fields-line-strong: var(--pp-border-strong);
    --fields-surface: var(--pp-surface);
    --fields-surface-soft: var(--pp-surface-soft);
    --fields-surface-raised: var(--pp-surface-raised);
    --fields-canvas: var(--pp-app-bg);
    --fields-input: var(--pp-input-bg);
    --fields-hover: var(--pp-surface-muted);
    --fields-primary: var(--pp-accent);
    --fields-primary-soft: var(--pp-accent-soft);
    --fields-primary-contrast: var(--pp-accent-contrast);
    --fields-filter: var(--pp-success, #059669);
    --fields-filter-soft: color-mix(in srgb, var(--fields-filter) 16%, var(--fields-surface));
    --fields-danger: var(--pp-danger, #dc3545);
    --fields-shadow-color: var(--pp-shadow-color);
    --fields-shadow: 0 12px 30px var(--fields-shadow-color);
    background: var(--fields-canvas);
    color: var(--fields-ink);
}

.fields-module .main-area,
.fields-module .right-workspace,
.fields-module .workspace-content,
.fields-module #fieldsWorkspace {
    background: var(--fields-canvas) !important;
    color: var(--fields-ink);
}

.fields-module .fields-table-panel {
    color: var(--fields-ink);
    background: var(--fields-surface) !important;
    border-color: var(--fields-line) !important;
}

/* Both context rows share the same fixed geometry and baseline. */
.fields-module .fields-panel-header,
.fields-module #fieldsToolbar {
    box-sizing: border-box;
    flex: 0 0 var(--fields-header-height);
    width: 100%;
    height: var(--fields-header-height);
    min-height: var(--fields-header-height);
    max-height: var(--fields-header-height);
    margin: 0;
    padding: 10px 14px !important;
    align-items: center;
    color: var(--fields-ink);
    background: var(--fields-surface) !important;
    border-color: var(--fields-line) !important;
}

.fields-module .fields-panel-header {
    display: flex;
    justify-content: space-between;
}
.fields-module .fields-panel-header > div,
.fields-module .fields-toolbar-context { display: grid; min-width: 0; line-height: 1.05; }
.fields-module .fields-panel-header strong,
.fields-module .fields-toolbar-context strong { color: var(--fields-ink); font-size: .84rem; }
.fields-module .fields-panel-kicker,
.fields-module .fields-toolbar-context small {
    margin-bottom: 5px;
    color: var(--fields-muted);
    font-size: .64rem;
    font-weight: 800;
    letter-spacing: .07em;
    text-transform: uppercase;
}
.fields-module .fields-table-count {
    min-width: 28px;
    height: 24px;
    padding: 0 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--fields-muted);
    background: var(--fields-surface-soft);
    border: 1px solid var(--fields-line);
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 800;
}
.fields-module .fields-toolbar-icon {
    width: 34px;
    height: 34px;
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    color: var(--fields-primary);
    background: var(--fields-primary-soft);
    border-radius: 10px;
}
.fields-module .fields-toolbar-hint { color: var(--fields-muted); font-size: .7rem; }
.fields-module .fields-toolbar-hint i { margin-right: 5px; color: var(--fields-filter); }

/* Compact table rail for large schemas. */
.fields-module .fields-table-panel .table-list { padding: 7px 6px 10px; }
.fields-module .fields-table-panel .table-list li {
    min-height: 34px;
    margin: 1px 0;
    padding: 4px 8px;
    gap: 7px;
    color: var(--fields-ink);
    background: transparent;
    border: 0;
    border-radius: 8px;
    font-size: .76rem;
}
.fields-module .fields-table-panel .table-list li > i {
    width: 23px;
    height: 23px;
    margin: 0 !important;
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
    color: var(--fields-muted);
    background: var(--fields-surface-soft);
    border-radius: 7px;
    font-size: .7rem;
}
.fields-module .fields-table-panel .table-list li:hover { color: var(--fields-ink); background: var(--fields-hover); }
.fields-module .fields-table-panel .table-list li.active {
    color: var(--fields-primary-contrast) !important;
    background: var(--fields-primary) !important;
    box-shadow: 0 5px 14px color-mix(in srgb, var(--fields-primary) 28%, transparent);
}
.fields-module .fields-table-panel .table-list li.active > i { color: var(--fields-primary-contrast); background: color-mix(in srgb, var(--fields-primary-contrast) 18%, transparent); }

.fields-module #fieldGridContainer {
    color: var(--fields-ink);
    background: var(--fields-surface) !important;
    border-color: var(--fields-line) !important;
    box-shadow: var(--fields-shadow);
}
.fields-module #fieldGridContainer h1,
.fields-module #fieldGridContainer h2,
.fields-module #fieldGridContainer h3,
.fields-module #fieldGridContainer h4,
.fields-module #fieldGridContainer h5,
.fields-module #fieldGridContainer h6,
.fields-module #fieldGridContainer label { color: var(--fields-ink); }
.fields-module .text-muted,
.fields-module .text-secondary,
.fields-module .form-text,
.fields-module .fld-hint,
.fields-module .fld-ftype { color: var(--fields-muted) !important; }

.fields-module .fld-device-tabs { background: var(--fields-surface-soft); border: 1px solid var(--fields-line); }
.fields-module .fld-device-tab { color: var(--fields-muted); }
.fields-module .fld-device-tab:hover { color: var(--fields-ink); background: var(--fields-hover); }
.fields-module .fld-device-tab.active {
    color: var(--fields-primary);
    background: var(--fields-surface-raised);
    box-shadow: 0 1px 5px var(--fields-shadow-color);
}

.fields-module .fld-grid-wrap { background: var(--fields-surface); border-color: var(--fields-line); }
.fields-module .fld-grid { color: var(--fields-ink); }
.fields-module .fld-grid thead th,
.fields-module .fld-th-field {
    color: var(--fields-ink);
    background: var(--fields-surface-soft);
    border-color: var(--fields-line);
}
.fields-module .fld-th-ic { color: var(--fields-muted); }
.fields-module .fld-th-lbl { color: var(--fields-muted); }
.fields-module .fld-grid tbody td { color: var(--fields-ink); background: var(--fields-surface); border-color: var(--fields-line); }
.fields-module .fld-td-field { background: var(--fields-surface); }
.fields-module .fld-grid tbody tr:hover td,
.fields-module .fld-grid tbody tr:hover .fld-td-field { background: var(--fields-hover); }
.fields-module .fld-fname { color: var(--fields-ink); }

.fields-module .fld-chk {
    background-color: var(--fields-input);
    border-color: var(--fields-line-strong);
}
.fields-module .fld-search-pill {
    color: var(--fields-muted);
    background: var(--fields-surface-raised);
    border-color: var(--fields-line);
}
.fields-module .fld-search-pill:hover { color: var(--fields-primary); background: var(--fields-hover); border-color: var(--fields-primary); }
.fields-module .fld-search-pill.is-on { color: var(--fields-primary); background: var(--fields-primary-soft); border-color: var(--fields-primary); }
.fields-module .fld-search-pill.is-filter { color: var(--fields-filter); background: var(--fields-filter-soft); border-color: var(--fields-filter); }
.fields-module .fld-search-pill.is-off { color: var(--fields-muted); background: var(--fields-surface-soft); }

.fields-module :where(.form-control, .form-select, textarea, input[type="text"], input[type="search"], input[type="number"]) {
    color: var(--fields-ink) !important;
    background-color: var(--fields-input) !important;
    border-color: var(--fields-line-strong) !important;
}
.fields-module :where(.form-control, textarea, input)::placeholder { color: var(--fields-muted) !important; opacity: .82; }
.fields-module :where(.form-control, .form-select):focus { border-color: var(--fields-primary) !important; box-shadow: 0 0 0 .2rem color-mix(in srgb, var(--fields-primary) 18%, transparent) !important; }
.fields-module .form-check-input { background-color: var(--fields-input); border-color: var(--fields-line-strong); }
.fields-module .form-check-input:checked { background-color: var(--fields-primary); border-color: var(--fields-primary); }

/* Search-settings dialog. */
.fields-module #searchSettingsModal .modal-content {
    overflow: hidden;
    color: var(--fields-ink) !important;
    background: var(--fields-surface-raised) !important;
    border: 1px solid var(--fields-line) !important;
    border-radius: 14px;
    box-shadow: 0 24px 60px var(--fields-shadow-color) !important;
}
.fields-module #searchSettingsModal .modal-header {
    min-height: 54px;
    padding: .65rem .85rem !important;
    color: var(--fields-primary-contrast);
    background: linear-gradient(135deg, var(--fields-primary), color-mix(in srgb, var(--fields-primary) 72%, var(--fields-surface-raised))) !important;
    border-color: color-mix(in srgb, var(--fields-primary) 65%, var(--fields-line)) !important;
}
.fields-module .fields-search-modal-icon {
    width: 34px;
    height: 34px;
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
    color: var(--fields-primary-contrast);
    background: color-mix(in srgb, var(--fields-primary-contrast) 14%, transparent);
    border: 1px solid color-mix(in srgb, var(--fields-primary-contrast) 28%, transparent);
    border-radius: 10px;
}
.fields-module .fields-search-modal-title {
    display: grid;
    min-width: 0;
    margin-left: 10px;
    line-height: 1.15;
}
.fields-module .fields-search-modal-title small {
    color: color-mix(in srgb, var(--fields-primary-contrast) 75%, transparent);
    font-size: .58rem;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
}
.fields-module .fields-search-modal-title strong {
    color: var(--fields-primary-contrast);
    font-size: .88rem;
}
.fields-module #searchSettingsModal .btn-close {
    box-sizing: border-box;
    width: 32px;
    height: 32px;
    margin: 0 0 0 auto;
    padding: 8px;
    border-radius: 9px;
    color: var(--fields-primary-contrast);
    background: none;
    border: 1px solid color-mix(in srgb, var(--fields-primary-contrast) 36%, transparent);
    opacity: .85;
    position: relative;
}
.fields-module #searchSettingsModal .btn-close::before,
.fields-module #searchSettingsModal .btn-close::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 15px;
    height: 2px;
    border-radius: 99px;
    background: currentColor;
}
.fields-module #searchSettingsModal .btn-close::before { transform: translate(-50%, -50%) rotate(45deg); }
.fields-module #searchSettingsModal .btn-close::after { transform: translate(-50%, -50%) rotate(-45deg); }
.fields-module #searchSettingsModal .btn-close:hover { background-color: color-mix(in srgb, var(--fields-primary-contrast) 14%, transparent); opacity: 1; }
.fields-module #searchSettingsModal .modal-body,
.fields-module #searchSettingsModal .modal-footer {
    color: var(--fields-ink) !important;
    background: var(--fields-surface-raised) !important;
    border-color: var(--fields-line) !important;
}
.fields-module #searchSettingsModal .modal-body { padding: .9rem !important; }
.fields-module #searchSettingsModal .modal-footer { padding: .7rem .9rem !important; }
.fields-module #searchSettingsModal .form-check {
    min-height: 32px;
    margin: 0 !important;
    padding: 6px 8px 6px 34px;
    border-radius: 8px;
}
.fields-module #searchSettingsModal .form-check:hover { background: var(--fields-hover); }
.fields-module #searchSettingsModal .form-check-label { color: var(--fields-ink); cursor: pointer; }
.fields-module #searchSettingsModal .btn-secondary {
    color: var(--fields-ink);
    background: var(--fields-surface-soft);
    border-color: var(--fields-line-strong);
}
.fields-module #searchSettingsModal .btn-primary {
    color: var(--fields-primary-contrast);
    background: var(--fields-primary);
    border-color: var(--fields-primary);
}
.fields-module .modal-backdrop.show { opacity: .62; background: var(--pp-navbar-bg, #080d17); }

@media (max-width: 767.98px) {
    .fields-module { --fields-header-height: 60px; }
    .fields-module .fields-panel-header,
    .fields-module #fieldsToolbar { padding: 8px 10px !important; }
    .fields-module .fields-table-panel .table-list li { min-height: 36px; }
}

@media (prefers-reduced-motion: reduce) {
    .fields-module *,
    .fields-module *::before,
    .fields-module *::after { transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
