/* ============================================================
 * New design for the Forms page (#RegistrationForms).
 * Scoped under #RegistrationForms.newdesign-forms so this never
 * affects other jQuery Mobile collapsibles elsewhere in the app.
 * Source design: html-output/formdesign/styles.css
 * ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

#RegistrationForms.newdesign-forms {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    -webkit-font-smoothing: antialiased;
}
#RegistrationForms.newdesign-forms .ui-content {
    background-color: #F6F7FA;
    padding: 16px;
}

/* ----- Hide jQuery Mobile collapsible chrome we don't want ----- */
#RegistrationForms.newdesign-forms .ui-collapsible-heading-toggle .ui-icon-plus,
#RegistrationForms.newdesign-forms .ui-collapsible-heading-toggle .ui-icon-minus,
#RegistrationForms.newdesign-forms .ui-collapsible-heading-toggle:before,
#RegistrationForms.newdesign-forms .ui-collapsible-heading-toggle:after,
#RegistrationForms.newdesign-forms .ui-collapsible-heading-status {
    display: none !important;
}
#RegistrationForms.newdesign-forms .ui-collapsible-set {
    margin: 0 !important;
    padding: 0 !important;
}
#RegistrationForms.newdesign-forms .ui-collapsible-set > .ui-collapsible {
    margin: 0 !important;
}

/* Top-level collapsible-set wraps all categories — render as ONE white card
   with rounded corners. Each category inside is transparent with only a
   bottom divider between siblings. */
#RegistrationForms.newdesign-forms .ui-content > .ui-collapsible-set {
    background: white !important;
    border: 1px solid #E2E4E9 !important;
    border-radius: 16px !important;
    overflow: hidden !important;
}
/* Hide legacy per-form action-buttons (delete / arrow-d / arrow-u / edit / grid)
   in non-edit-mode. Kept in DOM so the existing handlers still work; a kebab
   will surface them in a follow-up step. */
#RegistrationForms.newdesign-forms .action-buttons {
    display: none !important;
}

/* ----- Category container (.ui-collapsible[data-cat-id]) -----
   Inside the top-level white card, each category is a transparent row
   separated from siblings by a thin bottom divider. */
#RegistrationForms.newdesign-forms .ui-collapsible[data-cat-id] {
    background: transparent !important;
    border: none !important;
    border-bottom: 1px solid #E2E4E9 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: hidden !important;
}
#RegistrationForms.newdesign-forms .ui-content > .ui-collapsible-set > .ui-collapsible[data-cat-id]:last-child {
    border-bottom: none !important;
}
#RegistrationForms.newdesign-forms .ui-collapsible[data-cat-id] > .ui-collapsible-heading {
    margin: 0 !important;
}
#RegistrationForms.newdesign-forms .ui-collapsible[data-cat-id] > .ui-collapsible-heading > .ui-collapsible-heading-toggle {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 12px !important;
    padding: 16px 20px !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    text-shadow: none !important;
    text-decoration: none !important;
    font-size: 18px !important;
    font-weight: 500 !important;
    line-height: 24px !important;
    color: #0A0E14 !important;
    letter-spacing: -0.27px !important;
    border-radius: 0 !important;
    text-align: left !important;
}
#RegistrationForms.newdesign-forms .ui-collapsible[data-cat-id] > .ui-collapsible-heading > .ui-collapsible-heading-toggle:hover {
    background: #FAFBFC !important;
}
/* Title text + actions are injected by the controller as siblings inside h3 > a. */
#RegistrationForms.newdesign-forms .nd-cat-title {
    flex: 1;
    font-size: 18px;
    font-weight: 500;
    line-height: 24px;
    color: #0A0E14;
    letter-spacing: -0.27px;
}
#RegistrationForms.newdesign-forms .nd-cat-actions {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}
/* Category kebab hidden for now — will be wired up when context menu is built. */
#RegistrationForms.newdesign-forms .nd-cat-kebab {
    display: none !important;
}
/* Generic small-icon button — used for category kebab/chevron and per-card kebab. */
#RegistrationForms.newdesign-forms .icon-btn-sm {
    background: white;
    border: 1px solid #E2E4E9;
    border-radius: 10px;
    width: 36px;
    height: 36px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0px 1px 2px rgba(82, 88, 102, 0.06);
    transition: background 0.2s;
}
#RegistrationForms.newdesign-forms .icon-btn-sm:hover { background: #F6F7FA; }
/* Chevron icon rotates 180deg when the category is expanded. */
#RegistrationForms.newdesign-forms .nd-cat-chevron .nd-chevron {
    transition: transform 0.3s;
}
#RegistrationForms.newdesign-forms .ui-collapsible[data-cat-id]:not(.ui-collapsible-collapsed) .nd-cat-chevron .nd-chevron {
    transform: rotate(180deg);
}
#RegistrationForms.newdesign-forms .ui-collapsible[data-cat-id] > .ui-collapsible-content {
    padding: 0 !important;
    border: none !important;
    background: #F3F5F9 !important;
    border-top: 1px solid #E2E4E9 !important;
}

/* Inner collapsible-set inside category — grid of form-cards */
#RegistrationForms.newdesign-forms .ui-collapsible[data-cat-id] .ui-collapsible-set {
    padding: 20px !important;
    background: #F3F5F9 !important;
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)) !important;
    gap: 16px !important;
}

/* ----- Form card (.ui-collapsible[data-id] WITHOUT data-cat-id) ----- */
#RegistrationForms.newdesign-forms .ui-collapsible[data-id]:not([data-cat-id]) {
    background: white !important;
    border: none !important;
    border-radius: 12px !important;
    box-shadow: 0px 1px 3px rgba(0, 0, 0, 0.05) !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: hidden !important;
}
#RegistrationForms.newdesign-forms .ui-collapsible[data-id]:not([data-cat-id]) > .ui-collapsible-heading {
    margin: 0 !important;
}
#RegistrationForms.newdesign-forms .ui-collapsible[data-id]:not([data-cat-id]) > .ui-collapsible-heading > .ui-collapsible-heading-toggle {
    display: block !important;
    padding: 16px !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    text-shadow: none !important;
    text-decoration: none !important;
    border-radius: 0 !important;
    color: #0A0E14 !important;
    font-size: 16px !important;
    font-weight: 500 !important;
    line-height: 22px !important;
    text-align: left !important;
    position: relative !important;
}
#RegistrationForms.newdesign-forms .ui-collapsible[data-id]:not([data-cat-id]) > .ui-collapsible-heading > .ui-collapsible-heading-toggle:hover {
    background: #FAFBFC !important;
}

/* Top row of the form-card: title (h4-ish) + kebab in the top-right. */
#RegistrationForms.newdesign-forms .nd-card-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
}
#RegistrationForms.newdesign-forms .nd-card-title {
    flex: 1;
    /* min-width:0 lets this flex item shrink below its content width so the
       ellipsis can engage (flex items default to min-width:auto). The title
       lives inside a jQuery Mobile .ui-btn (white-space:nowrap), so long names
       would otherwise overflow and get clipped by the card. */
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 16px;
    font-weight: 500;
    line-height: 22px;
    color: #0A0E14;
}
/* The kebab on form-cards sits in the top-right; smaller than the category one
   and without a visible border so it floats inside the card. */
#RegistrationForms.newdesign-forms .nd-form-kebab {
    width: 28px;
    height: 28px;
    border: none !important;
    box-shadow: none !important;
    background: transparent !important;
    flex: none;
}
#RegistrationForms.newdesign-forms .nd-form-kebab:hover { background: #F6F7FA !important; }

/* Meta row under the title: date + tag, separated by spacing. */
#RegistrationForms.newdesign-forms .nd-card-meta-row {
    margin-top: 12px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}
#RegistrationForms.newdesign-forms .form-date,
#RegistrationForms.newdesign-forms .form-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 400;
    line-height: 16px;
    color: #525966;
}

/* The form-card injects extra meta nodes after the title text. */
#RegistrationForms.newdesign-forms .form-card-meta {
    margin-top: 12px;
    display: block;
    font-weight: 400;
}
#RegistrationForms.newdesign-forms .form-progress-bar {
    height: 4px;
    background: #E2E4E9;
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 8px;
}
#RegistrationForms.newdesign-forms .form-progress-fill {
    height: 100%;
    width: 0%;
    background: var(--main-color);
    transition: width 0.3s ease;
}
#RegistrationForms.newdesign-forms .form-progress-bar.yellow .form-progress-fill { background: #F59E0B; }
#RegistrationForms.newdesign-forms .form-progress-bar.green  .form-progress-fill { background: #10B981; }
#RegistrationForms.newdesign-forms .form-progress-bar.blue   .form-progress-fill { background: var(--main-color); }
#RegistrationForms.newdesign-forms .form-stats {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
    font-weight: 400;
    line-height: 16px;
    color: #525966;
}
#RegistrationForms.newdesign-forms .form-stats .percentage {
    font-weight: 500;
    color: #0A0E14;
}

/* Expanded form content area (the legacy .form div populated by collapsibleexpand) */
#RegistrationForms.newdesign-forms .ui-collapsible[data-id]:not([data-cat-id]) > .ui-collapsible-content {
    padding: 0 16px 16px !important;
    border: none !important;
    background: white !important;
    border-top: 1px solid #E2E4E9 !important;
}
#RegistrationForms.newdesign-forms .ui-collapsible[data-id]:not([data-cat-id]).ui-collapsible-collapsed > .ui-collapsible-content {
    border-top: none !important;
}

/* Mobile — single-column grid */
@media (max-width: 640px) {
    #RegistrationForms.newdesign-forms .ui-collapsible[data-cat-id] .ui-collapsible-set {
        grid-template-columns: 1fr !important;
        padding: 16px !important;
        gap: 12px !important;
    }
}

/* ============================================================
 * Phase 2 — Form View / Child View toggle + restyled Child View
 * ============================================================ */

/* ----- View toggle (segmented control at top of page) ----- */
#RegistrationForms.newdesign-forms .nd-view-toggle-wrap {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 16px;
}
/* Left cluster: "Forms" heading + the Form/Child view toggle. */
#RegistrationForms.newdesign-forms .nd-toolbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}
#RegistrationForms.newdesign-forms .nd-forms-title {
    font-size: 22px;
    font-weight: 600;
    line-height: 28px;
    color: #0A0E14;
}
/* Right: primary "Create New Form" action, in the app's main color. */
#RegistrationForms.newdesign-forms .nd-create-form-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 16px;
    border: none;
    border-radius: 10px;
    background: var(--main-color);
    color: #fff;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    line-height: 20px;
    cursor: pointer;
    box-shadow: 0px 6px 10px rgba(27, 28, 29, 0.06), 0px 2px 4px rgba(27, 28, 29, 0.02);
    transition: filter 0.2s;
}
#RegistrationForms.newdesign-forms .nd-create-form-btn:hover { filter: brightness(0.95); }
#RegistrationForms.newdesign-forms .nd-create-form-plus {
    font-size: 18px;
    line-height: 1;
    font-weight: 400;
}
#RegistrationForms.newdesign-forms .nd-view-toggle {
    background: white;
    padding: 4px;
    border-radius: 10px;
    display: inline-flex;
    gap: 4px;
    border: 1px solid #E2E4E9;
}
#RegistrationForms.newdesign-forms .nd-toggle-btn {
    background: transparent;
    border: none;
    padding: 6px 12px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    font-weight: 500;
    line-height: 20px;
    color: #525966;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}
#RegistrationForms.newdesign-forms .nd-toggle-btn:hover { background: #F6F7FA; }
#RegistrationForms.newdesign-forms .nd-toggle-btn.active {
    background: var(--main-color);
    color: white;
    box-shadow: 0px 6px 10px rgba(27, 28, 29, 0.06), 0px 2px 4px rgba(27, 28, 29, 0.02);
}
#RegistrationForms.newdesign-forms .nd-toggle-btn svg { width: 16px; height: 16px; }

/* ----- View visibility — controlled by page-level class ----- */
/* In Form View: hide everything Child-View related (legacy table + action buttons +
   classroom filter row + new design filter bar). Default state, no class needed. */
#RegistrationForms.newdesign-forms:not(.view-child-mode) .table-sticky,
#RegistrationForms.newdesign-forms:not(.view-child-mode) .action-row,
#RegistrationForms.newdesign-forms:not(.view-child-mode) .nd-child-cards,
#RegistrationForms.newdesign-forms:not(.view-child-mode) .nd-child-filter-bar,
#RegistrationForms.newdesign-forms:not(.view-child-mode) #selectClassroom {
    display: none !important;
}
/* In Child View: hide the categories card. */
#RegistrationForms.newdesign-forms.view-child-mode .ui-content > .ui-collapsible-set {
    display: none !important;
}

/* ----- Filter bar above the Child View table (search + classroom + Column) ----- */
#RegistrationForms.newdesign-forms .nd-child-filter-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 0;
    flex-wrap: wrap;
}
#RegistrationForms.newdesign-forms .nd-search-wrap {
    flex: 1;
    min-width: 240px;
    max-width: 480px;
    background: white;
    border: 1px solid #E2E4E9;
    border-radius: 10px;
    padding: 0 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0px 1px 2px rgba(82,88,102,0.06);
}
#RegistrationForms.newdesign-forms .nd-search-wrap svg { flex: none; }
#RegistrationForms.newdesign-forms .nd-child-search {
    flex: 1;
    border: none;
    outline: none;
    padding: 10px 0;
    font-size: 14px;
    font-family: inherit;
    background: transparent;
    color: #0A0E14;
}
#RegistrationForms.newdesign-forms .nd-child-search::placeholder { color: #6B7381; }
#RegistrationForms.newdesign-forms .nd-filter-actions {
    display: inline-flex;
    align-items: center;
    gap: 12px;
}
#RegistrationForms.newdesign-forms .nd-classroom-select {
    background: white url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 20 20' fill='none'><path d='M6 8L10 12L14 8' stroke='%23525966' stroke-width='1.33' stroke-linecap='round' stroke-linejoin='round'/></svg>") no-repeat right 10px center;
    border: 1px solid #E2E4E9;
    border-radius: 10px;
    padding: 10px 36px 10px 14px;
    font-size: 14px;
    font-weight: 500;
    color: #525966;
    font-family: inherit;
    cursor: pointer;
    box-shadow: 0px 1px 2px rgba(82,88,102,0.06);
    appearance: none;
    -webkit-appearance: none;
}
#RegistrationForms.newdesign-forms .nd-column-btn {
    background: white;
    border: 1px solid #E2E4E9;
    border-radius: 10px;
    padding: 10px 14px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    font-weight: 500;
    color: #525966;
    cursor: pointer;
    font-family: inherit;
    box-shadow: 0px 1px 2px rgba(82,88,102,0.06);
}
#RegistrationForms.newdesign-forms .nd-column-btn:hover { background: #F6F7FA; }

/* Hide the legacy classroom-filter row (we replaced it with .nd-child-filter-bar).
   jQuery Mobile wraps the <select> in extra .ui-select / #selectClassroom-button
   nodes, so we hide the select itself, its JQM wrapper, and the parent row div. */
#RegistrationForms.newdesign-forms #selectClassroom,
#RegistrationForms.newdesign-forms #selectClassroom-button,
#RegistrationForms.newdesign-forms .ui-select:has(#selectClassroom),
#RegistrationForms.newdesign-forms .ui-content > div:has(#selectClassroom) {
    display: none !important;
}

/* ----- Desktop child-table restyle -----
   Mirrors the pixel-perfect design: white rounded wrapper, light-gray header
   row, no vertical cell borders, only subtle horizontal row dividers. */
#RegistrationForms.newdesign-forms .table-sticky {
    background: white;
    border: 1px solid #E2E4E9;
    border-radius: 16px;
    overflow-x: auto;
    /* Scroll the table internally instead of growing past the viewport (which gave a
       second, page-level scrollbar). Height is refined per-viewport in JS
       (sizeChildViewTable); this calc is a sensible fallback. */
    overflow-y: auto;
    max-height: calc(100vh - 220px);
    margin-top: 0;
}
#RegistrationForms.newdesign-forms .table-sticky > table {
    width: 100%;
    border-collapse: collapse !important;
    border-spacing: 0 !important;
    font-family: 'Inter', sans-serif;
}
#RegistrationForms.newdesign-forms .table-sticky > table tr,
#RegistrationForms.newdesign-forms .table-sticky > table td,
#RegistrationForms.newdesign-forms .table-sticky > table th {
    border: none !important;
}
/* Header row: keep background on the <td>s (not the <tr>) so it paints
   correctly when the row is sticky-positioned during vertical scroll. */
#RegistrationForms.newdesign-forms .table-sticky > table tr:first-child td {
    padding: 14px 20px !important;
    text-align: left;
    font-size: 13px;
    font-weight: 500;
    line-height: 18px;
    color: #6B7381;
    background: #F8F9FA !important;
    border-bottom: 1px solid #E2E4E9 !important;
    white-space: nowrap;     /* keep each column header on a single line */
    vertical-align: middle;
    height: auto !important;
    min-height: 0 !important;
    position: sticky;
    top: 0;
    z-index: 2;
}
/* Centre every header except the first "Child" column. */
#RegistrationForms.newdesign-forms .table-sticky > table tr:first-child td:not(:first-child) {
    text-align: center;
}
#RegistrationForms.newdesign-forms .table-sticky > table tr:not(:first-child) {
    transition: background 0.2s;
}
#RegistrationForms.newdesign-forms .table-sticky > table tr:not(:first-child) td {
    border-bottom: 1px solid #E2E4E9 !important;
}
#RegistrationForms.newdesign-forms .table-sticky > table tr:not(:first-child):last-child td {
    border-bottom: none !important;
}
#RegistrationForms.newdesign-forms .table-sticky > table tr:not(:first-child):hover {
    background: #FAFBFC;
}
#RegistrationForms.newdesign-forms .table-sticky > table td {
    padding: 14px 20px !important;
    font-size: 14px;
    font-weight: 400;
    line-height: 20px;
    color: #0A0E14;
    background-color: transparent !important;
    vertical-align: middle;
    white-space: nowrap;
}
/* First column (Child) stays put when scrolling horizontally — sticky to the
   left with an opaque background so it paints over the columns sliding past
   underneath. */
#RegistrationForms.newdesign-forms .table-sticky > table td:first-child {
    min-width: 200px;
    position: sticky;
    left: 0;
    background: white !important;
    z-index: 1;
    border-right: 1px solid #E2E4E9 !important;
}
/* Header corner cell (first column AND first row): sticky in both directions,
   higher z-index than the rest of the sticky header so it stays on top. */
#RegistrationForms.newdesign-forms .table-sticky > table tr:first-child td:first-child {
    background: #F8F9FA !important;
    z-index: 3;
}

/* First-column "Child" cell: avatar + name layout. */
#RegistrationForms.newdesign-forms .nd-child-cell {
    display: flex;
    align-items: center;
    gap: 12px;
}
#RegistrationForms.newdesign-forms .nd-child-cell .nd-child-name {
    font-size: 15px;
    font-weight: 500;
    color: #0A0E14;
    white-space: nowrap;
}

/* "Completed" summary column (count + progress bar) per child row. */
#RegistrationForms.newdesign-forms .table-sticky > table td.nd-completed-col {
    min-width: 130px;
}
#RegistrationForms.newdesign-forms .nd-completed-cell {
    display: flex;
    align-items: center;
    gap: 10px;
}
#RegistrationForms.newdesign-forms .nd-completed-count {
    font-size: 14px;
    font-weight: 500;
    color: #0A0E14;
    white-space: nowrap;
}
#RegistrationForms.newdesign-forms .nd-completed-bar {
    flex: 1;
    height: 6px;
    min-width: 48px;
    background: #E2E4E9;
    border-radius: 999px;
    overflow: hidden;
}
#RegistrationForms.newdesign-forms .nd-completed-fill {
    height: 100%;
    background: var(--main-color);
    border-radius: 999px;
}
/* Hidden form column (deselected in the column picker). */
#RegistrationForms.newdesign-forms .table-sticky > table td.nd-col-hidden { display: none !important; }

/* ===== "Select Forms to Display" slide-in panel ===== */
.nd-col-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(10, 14, 20, 0.35);
    opacity: 0; transition: opacity 0.2s ease;
    z-index: 11500;
}
.nd-col-overlay.active { opacity: 1; }
.nd-col-panel {
    position: fixed; top: 0; right: 0; bottom: 0;
    width: 420px; max-width: 92vw;
    background: #fff;
    box-shadow: -8px 0 32px rgba(10, 14, 20, 0.16);
    z-index: 11501;
    transform: translateX(100%);
    transition: transform 0.22s ease;
    display: flex; flex-direction: column;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
.nd-col-panel.active { transform: translateX(0); }
.nd-col-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 20px 22px 12px;
}
.nd-col-title { font-size: 18px; font-weight: 600; color: #0A0E14; }
.nd-col-close {
    width: 32px; height: 32px; border: none; background: transparent;
    border-radius: 8px; cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.nd-col-close:hover { background: #F6F7FA; }
.nd-col-reset {
    display: inline-flex; align-items: center; gap: 6px;
    margin: 0 22px 8px; padding: 0;
    border: none; background: transparent; cursor: pointer;
    color: var(--main-color); font-size: 14px; font-weight: 500; font-family: inherit;
}
.nd-col-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 8px 12px 12px; border-top: 1px solid #E2E4E9; }
.nd-col-section {
    padding: 16px 10px 6px; font-size: 12px; font-weight: 600;
    letter-spacing: 0.04em; text-transform: uppercase; color: #868C98;
}
.nd-col-item {
    display: flex !important; align-items: center; gap: 10px;
    width: 100%; box-sizing: border-box; min-width: 0;
    padding: 11px 10px; border-radius: 8px; cursor: pointer;
}
.nd-col-item:hover { background: #F6F7FA; }
.nd-col-item.nd-col-fixed { cursor: default; }
.nd-col-grip { flex: 0 0 auto; display: inline-flex; cursor: grab; }
.nd-col-name {
    /* Canonical flexbox truncation: basis 0 so the track takes the leftover width, and
       min-width:0 so it may shrink below the text's intrinsic width → ellipsis kicks in.
       !important guards against the app-wide span/label styling. */
    flex: 1 1 0% !important;
    min-width: 0 !important;
    font-size: 15px; font-weight: 500; line-height: 20px; color: #0A0E14;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}
.nd-col-item .nd-col-check, .nd-col-item input[type="checkbox"] {
    flex: 0 0 auto;
    margin-left: auto; /* pin every checkbox to the right edge → one aligned column */
    width: 18px; height: 18px; accent-color: var(--main-color); cursor: pointer;
}
.nd-col-empty { padding: 11px 10px; color: #868C98; font-size: 14px; }
.nd-col-actions {
    flex: none;
    display: flex; gap: 12px; padding: 16px 22px;
    border-top: 1px solid #E2E4E9;
    background: #fff;
}
.nd-col-actions button {
    flex: 1; padding: 11px 16px; border-radius: 10px;
    font-size: 14px; font-weight: 600; font-family: inherit; cursor: pointer;
}
/* !important to beat the app-wide button styling (otherwise the fill is dropped and the
   white label sits on a white button). */
.nd-col-cancel { background: #fff !important; border: 1px solid #E2E4E9 !important; color: #0A0E14 !important; }
.nd-col-cancel:hover { background: #F6F7FA !important; }
.nd-col-apply { background: var(--main-color) !important; border: 1px solid var(--main-color) !important; color: #fff !important; }
.nd-col-apply:hover { filter: brightness(0.95); }

/* Status badges injected into cells */
#RegistrationForms.newdesign-forms .nd-status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    line-height: 18px;
    white-space: nowrap;
}
#RegistrationForms.newdesign-forms .nd-status-badge a {
    color: inherit !important;
    text-decoration: none !important;
}
#RegistrationForms.newdesign-forms .nd-status-badge.completed {
    background: #D1FAE5;
    color: #065F46;
}
#RegistrationForms.newdesign-forms .nd-status-badge.in-progress {
    background: #FED7AA;
    color: #9A3412;
}
#RegistrationForms.newdesign-forms .nd-status-badge.not-started {
    background: #E2E4E9;
    color: #525966;
}
#RegistrationForms.newdesign-forms .nd-status-badge.not-applicable {
    background: transparent;
    color: #6B7381;
    font-weight: 400;
}

/* ----- Mobile child-cards (built alongside the table) ----- */
#RegistrationForms.newdesign-forms .nd-child-cards { display: none; }
@media (max-width: 768px) {
    #RegistrationForms.newdesign-forms .table-sticky { display: none !important; }
    #RegistrationForms.newdesign-forms.view-child-mode .nd-child-cards { display: flex !important; }
    #RegistrationForms.newdesign-forms .nd-child-cards {
        flex-direction: column;
        gap: 12px;
        margin-top: 16px;
    }
}
#RegistrationForms.newdesign-forms .nd-child-card {
    background: white;
    border: 1px solid #E2E4E9;
    border-radius: 12px;
    overflow: hidden;
}
#RegistrationForms.newdesign-forms .nd-child-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    cursor: pointer;
}
#RegistrationForms.newdesign-forms .nd-child-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #D3E0F8;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--main-color);
    text-transform: uppercase;
    position: relative;
    overflow: hidden;
}
/* Child photo overlays the initials; removes itself (onerror in markup) on a bad URL,
   revealing the initials underneath. Applies in every avatar context. */
.nd-child-avatar { position: relative; overflow: hidden; }
.nd-child-avatar .nd-avatar-img {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: inherit;
    display: block;
}
#RegistrationForms.newdesign-forms .nd-child-info {
    flex: 1;
    min-width: 0;
}
#RegistrationForms.newdesign-forms .nd-child-name {
    display: block;
    font-size: 15px;
    font-weight: 600;
    color: #1A1D26;
    margin-bottom: 6px;
}
#RegistrationForms.newdesign-forms .nd-child-progress-info {
    display: flex;
    align-items: center;
    gap: 8px;
}
#RegistrationForms.newdesign-forms .nd-completion-text {
    font-size: 13px;
    color: #6B7381;
    white-space: nowrap;
}
#RegistrationForms.newdesign-forms .nd-progress-mini {
    flex: 1;
    height: 6px;
    background: #E2E4E9;
    border-radius: 3px;
    overflow: hidden;
    max-width: 120px;
}
#RegistrationForms.newdesign-forms .nd-progress-mini .nd-progress-fill {
    height: 100%;
    width: 0%;
    background: var(--main-color);
    border-radius: 3px;
    transition: width 0.3s ease;
}
#RegistrationForms.newdesign-forms .nd-progress-mini.orange .nd-progress-fill { background: #F59E0B; }
#RegistrationForms.newdesign-forms .nd-progress-mini.green  .nd-progress-fill { background: #10B981; }
#RegistrationForms.newdesign-forms .nd-expand-child {
    padding: 8px;
    background: transparent;
    border: none;
    cursor: pointer;
    flex-shrink: 0;
    transition: transform 0.2s;
}
#RegistrationForms.newdesign-forms .nd-child-card.expanded .nd-expand-child {
    transform: rotate(180deg);
}
#RegistrationForms.newdesign-forms .nd-child-card-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}
#RegistrationForms.newdesign-forms .nd-child-card.expanded .nd-child-card-content {
    max-height: 1500px;
    border-top: 1px solid #E2E4E9;
}
#RegistrationForms.newdesign-forms .nd-form-item-mobile {
    padding: 12px 16px;
    border-bottom: 1px solid #F5F6F7;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
#RegistrationForms.newdesign-forms .nd-form-item-mobile:last-child { border-bottom: none; }
/* tappable rows (open Fill & Submit / View-Edit) - a chevron after the badge; "—" (not applicable) rows stay plain */
#RegistrationForms.newdesign-forms .nd-form-item-mobile:has(.nd-status-badge:not(.not-applicable)) { cursor: pointer; -webkit-tap-highlight-color: transparent; }
#RegistrationForms.newdesign-forms .nd-form-item-mobile:has(.nd-status-badge:not(.not-applicable)):active { background: #F6F7FA; }
#RegistrationForms.newdesign-forms .nd-form-item-mobile:has(.nd-status-badge:not(.not-applicable))::after {
    content: '';
    flex: none;
    width: 7px;
    height: 7px;
    margin-left: -4px;
    border-right: 1.5px solid #868C98;
    border-bottom: 1.5px solid #868C98;
    transform: rotate(-45deg);
}
#RegistrationForms.newdesign-forms .nd-form-item-mobile .nd-status-badge.not-applicable { margin-right: 15px; }
#RegistrationForms.newdesign-forms .nd-form-item-mobile .nd-form-item-name {
    font-size: 14px;
    color: #20252D;
    flex: 1;
}

/* ============================================================
 * Phase 3 — Form Detail drawer (opens on form-card click)
 * The drawer lives in main.html outside #RegistrationForms so it
 * overlays the whole viewport. Rules below are not scoped to
 * #RegistrationForms — they target the drawer ids/classes directly.
 * ============================================================ */
.nd-form-detail-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    z-index: 1090;
}
.nd-form-detail-overlay.active { opacity: 1; visibility: visible; }

.nd-form-detail-page {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 720px;
    max-width: 100vw;
    background: white;
    z-index: 1100;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    -webkit-font-smoothing: antialiased;
    box-shadow: -8px 0 20px rgba(0, 0, 0, 0.08);
}
.nd-form-detail-page.active { transform: translateX(0); }
@media (max-width: 768px) {
    .nd-form-detail-page { width: 100vw; }
}

.nd-form-detail-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    border-bottom: 1px solid #E2E4E9;
    background: white;
}
.nd-back-btn {
    background: white;
    border: 1px solid #E2E4E9;
    border-radius: 10px;
    width: 36px;
    height: 36px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.2s;
}
.nd-back-btn:hover { background: #F6F7FA; }
.nd-form-detail-title-wrap { flex: 1; min-width: 0; }
.nd-form-detail-title-wrap h2 {
    margin: 0 0 6px;
    font-size: 18px;
    font-weight: 600;
    line-height: 24px;
    color: #0A0E14;
    letter-spacing: -0.27px;
    word-wrap: break-word;
}
.nd-form-detail-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.nd-form-detail-meta .form-date,
.nd-form-detail-meta .form-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 400;
    line-height: 16px;
    color: #525966;
}
.nd-preview-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: 1px solid #E2E4E9;
    border-radius: 10px;
    background: white;
    color: #525966;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.2s;
}
.nd-preview-btn:hover { background: #F6F7FA; }
@media (max-width: 768px) {
    .nd-preview-btn span { display: none; }
}

/* Status cards: clean white card with a status-coloured icon on the left,
   count + label stacked on the right. Matches the pixel-perfect design. */
.nd-status-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    padding: 20px;
}
.nd-status-card {
    background: white;
    border: 1px solid #E2E4E9;
    border-radius: 12px;
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}
/* Form status slide-in: the cards filter the tracking table (FormsController applyFormDetailFilter) */
#ndFormDetailPage .nd-status-card {
    cursor: pointer;
    user-select: none;
    transition: border-color .15s, box-shadow .15s, opacity .15s;
}
#ndFormDetailPage .nd-status-card:hover { border-color: #CDD0D5; box-shadow: 0 1px 3px rgba(16, 24, 40, 0.08); }
#ndFormDetailPage .nd-status-cards.nd-filtering .nd-status-card:not(.nd-filter-active) { opacity: .55; }
#ndFormDetailPage .nd-status-card.completed-card.nd-filter-active { border-color: #10B981; box-shadow: 0 0 0 1px #10B981; background: #F0FDF8; }
#ndFormDetailPage .nd-status-card.not-started-card.nd-filter-active { border-color: #868C98; box-shadow: 0 0 0 1px #868C98; background: #F6F7FA; }
.nd-status-card .nd-status-icon { flex: none; }
.nd-status-card .nd-status-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.nd-status-card .nd-status-count {
    font-size: 28px;
    font-weight: 700;
    line-height: 36px;
    color: #0A0E14;
}
.nd-status-card .nd-status-label {
    font-size: 13px;
    font-weight: 500;
    color: #525966;
}
@media (max-width: 480px) {
    .nd-status-cards { grid-template-columns: 1fr; gap: 8px; padding: 16px; }
}

/* Tracking section */
.nd-tracking-section {
    flex: 1;
    overflow-y: auto;
    padding: 0 20px 20px;
}
.nd-tracking-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 8px 0 12px;
}
.nd-tracking-title-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
}
.nd-tracking-title-wrap h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #0A0E14;
}
.nd-tracking-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--main-color);
}
.nd-filter-btn-detail {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border: 1px solid #E2E4E9;
    border-radius: 8px;
    background: white;
    color: #525966;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.2s;
}
.nd-filter-btn-detail:hover { background: #F6F7FA; }

.nd-tracking-table-wrapper {
    background: white;
    border: 1px solid #E2E4E9;
    border-radius: 12px;
    overflow: hidden;
}
.nd-tracking-table {
    width: 100%;
    border-collapse: collapse;
    font-family: inherit;
}
.nd-tracking-table thead { background: #F8F9FA; }
.nd-tracking-table th {
    padding: 12px 16px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.4px;
    color: #6B7381;
    border-bottom: 1px solid #E2E4E9;
    text-transform: uppercase;
}
.nd-tracking-table tbody tr { border-bottom: 1px solid #E2E4E9; }
.nd-tracking-table tbody tr:last-child { border-bottom: none; }
.nd-tracking-table td {
    padding: 14px 16px;
    font-size: 14px;
    color: #0A0E14;
    vertical-align: middle;
}

/* Child cell: checkbox + avatar + name */
.nd-tracking-table .nd-child-cell-drawer {
    display: flex;
    align-items: center;
    gap: 12px;
}
.nd-tracking-table .nd-child-cell-drawer input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--main-color);
    flex: none;
}
.nd-tracking-table .nd-child-cell-drawer .nd-child-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #D3E0F8;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    font-size: 12px;
    font-weight: 600;
    color: var(--main-color);
    text-transform: uppercase;
    position: relative;
    overflow: hidden;
}
.nd-tracking-table .nd-child-cell-drawer .nd-child-name {
    font-size: 14px;
    font-weight: 500;
    color: #0A0E14;
}
.nd-tracking-table .nd-activity-date {
    font-size: 14px;
    color: #525966;
}
.nd-tracking-table .nd-activity-date.muted {
    color: #9CA3AF;
    font-style: italic;
}
.nd-tracking-table .nd-action-kebab {
    padding: 6px;
    background: transparent;
    border: none;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.2s;
}
.nd-tracking-table .nd-action-kebab:hover { background: #F6F7FA; }

.nd-tracking-table .nd-status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    line-height: 18px;
    white-space: nowrap;
}
.nd-tracking-table .nd-status-badge.completed   { background: #D1FAE5; color: #065F46; }
.nd-tracking-table .nd-status-badge.in-progress { background: #FED7AA; color: #9A3412; }
.nd-tracking-table .nd-status-badge.not-started { background: #E2E4E9; color: #525966; }

/* ============================================================
 * Form-card kebab dropdown (Preview / Edit / Duplicate / Change
 * Category). Appended to <body>, so it is NOT scoped under
 * #RegistrationForms. Positioned via JS (fixed, near the kebab).
 * ============================================================ */
.nd-form-card-menu {
    position: fixed;
    z-index: 10050;
    min-width: 208px;
    background: #fff;
    border: 1px solid #E2E4E9;
    border-radius: 12px;
    box-shadow: 0px 12px 32px rgba(10, 14, 20, 0.16);
    padding: 6px;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
.nd-form-card-menu .nd-menu-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px 12px;
    border: none;
    background: transparent;
    border-radius: 8px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    line-height: 20px;
    color: #0A0E14;
    text-align: left;
    cursor: pointer;
    box-sizing: border-box;
}
.nd-form-card-menu { max-height: 80vh; overflow-y: auto; }
.nd-form-card-menu .nd-menu-item:hover { background: #F6F7FA; }
.nd-form-card-menu .nd-menu-item > svg { flex: none; }
.nd-form-card-menu .nd-submenu-chevron { margin-left: auto; transition: transform 0.15s ease; }

/* Change Category → category list that expands INLINE (accordion) within the menu.
   Inline (not a side flyout) so it never gets clipped at the screen edge on the
   narrow Forms layout. The menu itself scrolls if the list is long. */
.nd-form-card-menu .nd-submenu {
    display: none;
    margin: 2px 0;
    max-height: 220px;
    overflow-y: auto;
}
.nd-form-card-menu .nd-cat-group.nd-submenu-open .nd-submenu { display: block; }
.nd-form-card-menu .nd-cat-group.nd-submenu-open .nd-submenu-chevron { transform: rotate(90deg); }
.nd-form-card-menu .nd-submenu .nd-cat-option { padding-left: 42px; } /* indent under the icon column */
.nd-form-card-menu .nd-cat-option { font-weight: 400; }
.nd-form-card-menu .nd-cat-option.nd-cat-current { background: #EEF3FD; font-weight: 600; }
/* "No category" (clear) — separated from the real categories below it. */
.nd-form-card-menu .nd-cat-none {
    color: #B42318;
    border-bottom: 1px solid #EEF0F3;
    border-radius: 8px 8px 0 0;
    margin-bottom: 2px;
}
.nd-form-card-menu .nd-submenu-empty { padding: 10px 12px; color: #6B7381; font-size: 13px; }

/* ============================================================
 * Form preview modal (kebab → Preview). Appended to <body>.
 * ============================================================ */
.nd-form-preview {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 11000;
    background: rgba(10, 14, 20, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    box-sizing: border-box;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
.nd-form-preview-card {
    background: #fff;
    width: 100%;
    max-width: 760px;
    max-height: 90vh;
    border-radius: 16px;
    box-shadow: 0px 24px 64px rgba(10, 14, 20, 0.28);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.nd-form-preview-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 22px;
    border-bottom: 1px solid #E2E4E9;
    flex: none;
}
.nd-form-preview-titles { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.nd-form-preview-eyebrow {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #2563D7;
}
.nd-form-preview-title {
    font-size: 19px;
    font-weight: 600;
    line-height: 26px;
    color: #0A0E14;
}
.nd-form-preview-close {
    flex: none;
    width: 36px;
    height: 36px;
    border: none;
    background: #F6F7FA;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.nd-form-preview-close:hover { background: #ECEEF2; }
.nd-form-preview-body {
    flex: 1;
    overflow-y: auto;
    padding: 22px;
    background: #F6F7FA;
}
.nd-form-preview-body.is-iframe { padding: 0; overflow: hidden; }
.nd-form-preview-iframe { width: 100%; height: 70vh; border: none; display: block; background: #fff; }
.nd-form-preview-content {
    background: #fff;
    border: 1px solid #E2E4E9;
    border-radius: 12px;
    padding: 22px;
}
.nd-form-preview-content img { max-width: 100%; height: auto; }
.nd-form-preview-empty { padding: 40px 20px; text-align: center; color: #6B7381; font-size: 14px; }
/* Read-only preview: never show the in-form print/submit controls. */
.nd-form-preview .ui-icon-print,
.nd-form-preview .submitForm { display: none !important; }
/* Signature box (Remini.css only styles it inside #RegistrationForms; the preview sits on body).
   Shown with its signing line, but read-only - nothing drawn here is ever saved. */
.nd-form-preview-content .signature {
    display: inline-block;
    width: fit-content;
    margin: 6px 0;
    padding: 1px;
    background: #fff;
    border: 1px solid #E2E4E9;
    border-radius: 8px;
}
.nd-form-preview-content .signature canvas { display: block; pointer-events: none; }

/* Forms that embed a viewer (htmlForms iframe / PDF embed): the card needs an
   explicit tall height so the embedded viewer has room to fill — a content-sized
   card collapses flex:1 and the viewer renders as a thin strip. */
.nd-form-preview-card.nd-preview-tall {
    height: 88vh;
    max-height: 88vh;
}
.nd-form-preview-card.nd-preview-tall .nd-form-preview-body { min-height: 0; }
.nd-form-preview-card.nd-preview-tall .nd-form-preview-iframe { height: 100%; }
.nd-form-preview-card.nd-preview-tall .nd-form-preview-content { min-height: 100%; box-sizing: border-box; }
.nd-form-preview-card.nd-preview-tall .nd-form-preview-content iframe,
.nd-form-preview-card.nd-preview-tall .nd-form-preview-content embed,
.nd-form-preview-card.nd-preview-tall .nd-form-preview-content object {
    width: 100%;
    min-height: 72vh;
    border: none;
}

/* ============================================================
 * Per-child form modal (drawer kebab → Fill / View-Edit / Print).
 * The form is rendered in place by the legacy view() and the whole
 * collapsible is floated as a centered modal — it is NEVER moved out
 * of #RegistrationForms, so the legacy submit/print/PDF handlers keep
 * working (they walk up to [data-role=collapsible]).
 * ============================================================ */
.nd-child-form-backdrop {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(10, 14, 20, 0.45);
    z-index: 11100;
}
/* While the modal is open, show ONLY the modal — hide the rest of the page content so
   the forced-visible ancestor chain (needed for Child View) doesn't reveal the Form View
   cards / Child View table behind the backdrop. visibility (not display) keeps the forced
   display:block chain laid out so the fixed modal still renders. The backdrop is a sibling
   of .ui-content, so it stays visible. */
body.nd-child-form-open #RegistrationForms.newdesign-forms > .ui-content { visibility: hidden !important; }
body.nd-child-form-open #RegistrationForms.newdesign-forms .ui-collapsible.nd-child-form-target,
body.nd-child-form-open #RegistrationForms.newdesign-forms .ui-collapsible.nd-child-form-target * { visibility: visible !important; }
/* …but the off-screen measurement span must stay hidden — the broad rule above would
   otherwise reveal it as a stray value after the form. */
body.nd-child-form-open #RegistrationForms.newdesign-forms .ui-collapsible.nd-child-form-target .testSpan { visibility: hidden !important; }
#RegistrationForms.newdesign-forms .ui-collapsible.nd-child-form-target {
    position: fixed !important;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 760px;
    max-width: 94vw;
    max-height: 88vh;
    z-index: 11101;
    margin: 0 !important;
    background: #fff !important;
    border-radius: 16px !important;
    box-shadow: 0 24px 64px rgba(10, 14, 20, 0.28) !important;
    /* Column layout: the heading stays put while the form area scrolls. */
    display: flex !important;
    flex-direction: column;
    overflow: hidden;
}
#RegistrationForms.newdesign-forms .ui-collapsible.nd-child-form-target > .ui-collapsible-heading {
    position: relative;
    flex: 0 0 auto;
}
/* Force the form content visible (jQM/new design would otherwise keep it collapsed)
   and make IT the scroll container. min-height:0 lets this flex child shrink below
   its content height so overflow-y can actually engage. */
#RegistrationForms.newdesign-forms .ui-collapsible.nd-child-form-target > .ui-collapsible-content {
    display: block !important;
    visibility: visible !important;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
#RegistrationForms.newdesign-forms .ui-collapsible.nd-child-form-target .nd-form-kebab,
#RegistrationForms.newdesign-forms .ui-collapsible.nd-child-form-target .nd-card-meta-row,
#RegistrationForms.newdesign-forms .ui-collapsible.nd-child-form-target .form-card-meta,
#RegistrationForms.newdesign-forms .ui-collapsible.nd-child-form-target .action-buttons {
    display: none !important;
}
/* Print is its own kebab action now, so hide the in-form print button inside the
   modal. It stays in the DOM (just hidden) so the Print action can still trigger it. */
#RegistrationForms.newdesign-forms .ui-collapsible.nd-child-form-target .form .ui-icon-print {
    display: none !important;
}
/* "Filling for <child>" line under the form title in the modal header. */
#RegistrationForms.newdesign-forms .ui-collapsible.nd-child-form-target > .ui-collapsible-heading > .nd-child-form-who {
    padding: 0 44px 12px 16px;
    margin-top: -2px;
    font-size: 14px;
    line-height: 20px;
    color: #525966;
}
#RegistrationForms.newdesign-forms .ui-collapsible.nd-child-form-target > .ui-collapsible-heading > .nd-child-form-who strong {
    color: #0A0E14;
    font-weight: 600;
}
/* Direct child of the fixed modal, pinned to its top-right above the heading. */
#RegistrationForms.newdesign-forms .ui-collapsible.nd-child-form-target > .nd-child-form-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    border: none;
    background: #F6F7FA;
    border-radius: 8px;
    font-size: 22px;
    line-height: 30px;
    text-align: center;
    color: #525966;
    cursor: pointer;
    z-index: 20;
}
#RegistrationForms.newdesign-forms .ui-collapsible.nd-child-form-target > .nd-child-form-close:hover { background: #ECEEF2; }

/* Printing the per-child form. The form is already visibility:visible from the on-screen
   modal rules above; those rules use #RegistrationForms (high specificity) and would beat
   any lower-specificity print rule — so these print rules MATCH that specificity to win.
   Strategy: DISPLAY:NONE everything that isn't the form (collapses page height → no blank
   pages) and flow the modal as a plain static block at the top (not the fixed/centred
   position, which printed in the bottom-right). Scoped to the open child-form modal. */
@media print {
    /* Page chrome + everything in the page that isn't the modal's own chain. */
    body.nd-child-form-open .head,
    body.nd-child-form-open #sideMenu,
    body.nd-child-form-open #ndSidebarReopen,
    body.nd-child-form-open #ndFormDetailOverlay,
    body.nd-child-form-open #ndFormDetailPage,
    body.nd-child-form-open .nd-child-form-backdrop,
    body.nd-child-form-open #RegistrationForms.newdesign-forms .nd-view-toggle-wrap,
    body.nd-child-form-open #RegistrationForms.newdesign-forms .nd-child-filter-bar,
    body.nd-child-form-open #RegistrationForms.newdesign-forms .table-sticky,
    body.nd-child-form-open #RegistrationForms.newdesign-forms .nd-child-cards,
    body.nd-child-form-open #RegistrationForms.newdesign-forms .ui-collapsible[data-id]:not([data-cat-id]):not(.nd-child-form-target),
    body.nd-child-form-open #RegistrationForms.newdesign-forms .ui-collapsible[data-cat-id]:not(.nd-cf-forced),
    body.nd-child-form-open #RegistrationForms.newdesign-forms .ui-collapsible[data-cat-id] > .ui-collapsible-heading {
        display: none !important;
    }
    /* The modal → plain static block at the top of the page. */
    body.nd-child-form-open #RegistrationForms.newdesign-forms .ui-collapsible.nd-child-form-target {
        position: static !important;
        transform: none !important;
        width: auto !important;
        max-width: none !important;
        max-height: none !important;
        overflow: visible !important;
        margin: 0 !important;
        border: none !important;
        border-radius: 0 !important;
        box-shadow: none !important;
    }
    body.nd-child-form-open #RegistrationForms.newdesign-forms .ui-collapsible.nd-child-form-target > .ui-collapsible-content {
        max-height: none !important;
        overflow: visible !important;
        border: none !important;
        padding: 0 !important;
    }
    /* Keep only the form itself — drop the modal's heading / "Filling for…" / close / print
       button, and the off-screen measurement span. */
    body.nd-child-form-open #RegistrationForms.newdesign-forms .ui-collapsible.nd-child-form-target > .ui-collapsible-heading,
    body.nd-child-form-open #RegistrationForms.newdesign-forms .ui-collapsible.nd-child-form-target > .nd-child-form-close,
    body.nd-child-form-open #RegistrationForms.newdesign-forms .ui-collapsible.nd-child-form-target .form .ui-icon-print,
    body.nd-child-form-open #RegistrationForms.newdesign-forms .ui-collapsible.nd-child-form-target .testSpan {
        display: none !important;
    }
}

/* ============================================================
 * Child-View status badge popover (form / child / status + actions).
 * Appended to <body>, positioned in JS near the clicked badge.
 * ============================================================ */
.nd-status-pop {
    position: fixed;
    z-index: 11400;
    width: 300px;
    max-width: 92vw;
    background: #fff;
    border: 1px solid #E2E4E9;
    border-radius: 14px;
    box-shadow: 0 12px 32px rgba(10, 14, 20, 0.18);
    padding: 16px;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
.nd-status-pop-head {
    display: flex; align-items: flex-start; justify-content: space-between; gap: 10px;
}
.nd-status-pop-title { font-size: 17px; font-weight: 600; color: #0A0E14; line-height: 22px; }
.nd-status-pop-close {
    flex: none; width: 26px; height: 26px; border: none; background: transparent;
    border-radius: 6px; cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.nd-status-pop-close:hover { background: #F6F7FA; }
.nd-status-pop-divider { height: 1px; background: #E2E4E9; margin: 14px 0; }
.nd-status-pop-child { font-size: 15px; font-weight: 500; color: #0A0E14; margin-bottom: 12px; }
.nd-status-pop-row {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    margin-bottom: 10px;
}
.nd-status-pop-label { font-size: 14px; color: #6B7381; }
.nd-status-pop-value { font-size: 14px; font-weight: 500; color: #0A0E14; }
.nd-status-pop-actions-title {
    font-size: 13px; font-weight: 600; color: #6B7381; margin-bottom: 4px;
}
.nd-status-pop-action {
    display: flex; align-items: center; gap: 10px;
    width: 100%; padding: 10px 6px;
    border: none; background: transparent; cursor: pointer;
    font-family: inherit; font-size: 15px; font-weight: 500; color: #2563D7;
    text-align: left;
}
.nd-status-pop-action:hover { background: #F6F7FA; border-radius: 8px; }
.nd-status-pop-action > svg { flex: none; }
.nd-status-pop-action > span { flex: 1 1 auto; min-width: 0; }
.nd-status-pop-chev { margin-left: auto; }
/* The popover sits on <body>, so the site-wide button styles (green fill, white hover text) reach its
   buttons - pin them to the design: plain rows, light grey on hover, text always readable. */
body .nd-status-pop button.nd-status-pop-action,
body .nd-status-pop button.nd-status-pop-action:focus {
    background: transparent !important;
    color: #2563D7 !important;
    border: none !important;
    border-radius: 8px !important;
    box-shadow: none !important;
    text-shadow: none !important;
    outline: none;
    margin: 0 !important;
    min-height: 0 !important;
    height: auto !important;
}
body .nd-status-pop button.nd-status-pop-action:hover,
body .nd-status-pop button.nd-status-pop-action:active { background: #EEF3FD !important; color: #1D4FB0 !important; }
body .nd-status-pop button.nd-status-pop-action + button.nd-status-pop-action { margin-top: 2px !important; }
body .nd-status-pop button.nd-status-pop-close {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
}
body .nd-status-pop button.nd-status-pop-close:hover { background: #F6F7FA !important; }
/* status pill (the table's badge styles are scoped to #RegistrationForms) */
.nd-status-pop .nd-status-badge {
    display: inline-flex; align-items: center; padding: 4px 12px; border-radius: 6px;
    font-size: 13px; font-weight: 500; line-height: 18px; white-space: nowrap;
}
.nd-status-pop .nd-status-badge.completed { background: #D1FAE5; color: #065F46; }
.nd-status-pop .nd-status-badge.not-started { background: #E2E4E9; color: #525966; }
