/* ============================================================
   Class List Editor — Popup Styles
   Accent: orange #ff9671 / rgba(255,150,113,...)
   ============================================================ */

/* ---- Keyframes ---- */
@keyframes cle-pop-in {
    0%   { opacity: 0; transform: scale(0.84) translateY(-8px); }
    65%  { transform: scale(1.03) translateY(1px); }
    100% { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes cle-fade-in {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes cle-spin {
    to { transform: rotate(360deg); }
}

/* ============================================================
   Overlay
   ============================================================ */
.cle-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.52);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    padding: 12px;
}
.cle-overlay.cle-overlay--open { display: flex; }

/* ============================================================
   Modal
   ============================================================ */
.cle-modal {
    position: relative;
    background: #fff;
    border-radius: 18px;
    width: min(520px, 100%);
    max-height: 90vh;
    overflow: hidden;
    box-shadow:
        0 24px 72px rgba(0, 0, 0, 0.20),
        0 2px 8px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    animation: cle-pop-in 0.38s cubic-bezier(.34,1.56,.64,1) both;
}

.cle-body {
    flex: 1 1 auto;
    overflow-y: auto;
    min-height: 0;
}

/* ---- Close button ---- */
.cle-close {
    position: absolute;
    top: 13px;
    right: 15px;
    z-index: 10;
    background: none;
    border: none;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    color: #9ca3af;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.15s ease, color 0.15s ease;
}
.cle-close:hover { background: #f3f4f6; color: #111827; }

/* ============================================================
   Step wrapper
   ============================================================ */
.cle-step {
    padding: 2.2rem 2rem 1.8rem;
    display: flex;
    flex-direction: column;
    gap: 1.4rem;
    animation: cle-fade-in 0.28s ease both;
}

/* ---- Step header ---- */
.cle-step__header {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0.55rem;
}

.cle-step__icon {
    width: 60px;
    height: 60px;
    background: linear-gradient(140deg, #fff3ef 0%, #ffe4d9 100%);
    border: 1px solid rgba(255,150,113,0.30);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.25rem;
}
.cle-step__icon svg {
    width: 28px;
    height: 28px;
    color: #ff9671;
}

.cle-step__icon--success {
    background: linear-gradient(140deg, #f0fdf4 0%, #dcfce7 100%);
    border-color: rgba(34,197,94,0.28);
}
.cle-step__icon--success svg { color: #16a34a; }

.cle-step__icon--warn {
    background: linear-gradient(140deg, #fffbeb 0%, #fef3c7 100%);
    border-color: rgba(245,158,11,0.28);
}
.cle-step__icon--warn svg { color: #d97706; }

.cle-step__title {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 700;
    color: #111827;
    line-height: 1.3;
}

.cle-step__sub {
    margin: 0;
    font-size: 0.875rem;
    color: #6b7280;
    line-height: 1.5;
    max-width: 380px;
}

/* ---- Back row ---- */
.cle-step__back-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding-right: 38px;
    margin-bottom: 0.4rem;
}

.cle-back {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    color: #6b7280;
    padding: 4px 6px;
    border-radius: 6px;
    transition: color 0.15s, background 0.15s;
}
.cle-back svg { width: 16px; height: 16px; }
.cle-back:hover { color: #111827; background: #f3f4f6; }

.cle-step__badge {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #9ca3af;
}

/* ============================================================
   Upload type options (Step 1)
   ============================================================ */
.cle-upload-options {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.cle-upload-option {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1rem 1.1rem;
    border: 1.5px solid #e5e7eb;
    border-radius: 12px;
    background: #fafafa;
    cursor: pointer;
    text-align: left;
    transition:
        border-color 0.18s ease,
        background   0.18s ease,
        transform    0.18s ease,
        box-shadow   0.18s ease;
}
.cle-upload-option:hover {
    border-color: rgba(255,150,113,0.55);
    background: #fff7f4;
    transform: translateY(-2px);
    box-shadow: 0 4px 14px rgba(255,150,113,0.12);
}
.cle-upload-option:active {
    transform: translateY(0);
    box-shadow: none;
}

.cle-upload-option__icon {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    background: linear-gradient(140deg, #fff3ef 0%, #ffe4d9 100%);
    border: 1px solid rgba(255,150,113,0.25);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.cle-upload-option__icon svg {
    width: 22px;
    height: 22px;
    color: #ff9671;
}

.cle-upload-option__label {
    display: block;
    font-size: 0.9rem;
    font-weight: 700;
    color: #111827;
    line-height: 1.3;
}
.cle-upload-option__body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.cle-upload-option__arrow {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    color: #d1d5db;
    transition: color 0.18s ease, transform 0.18s ease;
    align-self: center;
}
.cle-upload-option:hover .cle-upload-option__arrow {
    color: #ff9671;
    transform: translateX(3px);
}

.cle-upload-option__desc {
    display: block;
    font-size: 0.78rem;
    color: #6b7280;
    margin-top: 0.2rem;
    line-height: 1.45;
}

/* ============================================================
   Info note (Step 2 multi)
   ============================================================ */
.cle-note {
    display: flex;
    align-items: flex-start;
    gap: 0.8rem;
    padding: 0.85rem 1rem;
    background: #fffbeb;
    border: 1px solid rgba(245,158,11,0.35);
    border-radius: 10px;
    font-size: 0.82rem;
    color: #92400e;
    line-height: 1.5;
}
.cle-note__icon {
    flex-shrink: 0;
    display: flex;
    align-items: flex-start;
    padding-top: 1px;
}
.cle-note__icon svg {
    width: 18px;
    height: 18px;
    color: #d97706;
}
.cle-note__text { flex: 1; }
.cle-note__text strong { font-weight: 700; color: #78350f; }

/* ============================================================
   Upload zone (Step 2)
   ============================================================ */
.cle-upload-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 2.2rem 1.5rem;
    border: 2px dashed #d1d5db;
    border-radius: 12px;
    background: #fafafa;
    text-align: center;
    transition: border-color 0.2s ease, background 0.2s ease;
    cursor: pointer;
}
.cle-upload-zone:hover {
    border-color: rgba(255,150,113,0.55);
    background: #fff7f4;
}
.cle-upload-zone--drag,
.cle-upload-zone:focus-within {
    border-color: #ff9671;
    background: #fff7f4;
}

.cle-upload-zone__icon svg {
    width: 38px;
    height: 38px;
    color: #d1d5db;
    transition: color 0.2s ease;
}
.cle-upload-zone--drag .cle-upload-zone__icon svg { color: #ff9671; }

.cle-upload-zone__text {
    margin: 0;
    font-size: 0.88rem;
    color: #374151;
}
.cle-upload-zone__browse {
    color: #ff9671;
    font-weight: 600;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
}
.cle-upload-zone__hint {
    margin: 0;
    font-size: 0.75rem;
    color: #9ca3af;
}

.cle-file-input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

/* ---- Selected file chips ---- */
.cle-selected-files {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: -0.4rem;
}
.cle-file-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    background: #fff3ef;
    border: 1px solid rgba(255,150,113,0.35);
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    color: #c2410c;
    max-width: 240px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.cle-file-chip svg {
    width: 13px;
    height: 13px;
    flex-shrink: 0;
    color: #ff9671;
}
.cle-file-chip__remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-left: 2px;
    width: 16px;
    height: 16px;
    background: none;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 0.9rem;
    line-height: 1;
    color: #c2410c;
    opacity: 0.6;
    padding: 0;
}
.cle-file-chip__remove:hover { opacity: 1; background: rgba(194,65,12,0.12); }

/* ============================================================
   Column selection grid (Step 3)
   ============================================================ */
.cle-col-select {
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
}

.cle-col-select__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.55rem 0.85rem;
    background: #f8f9fb;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
}

.cle-col-select__count-wrap {
    display: flex;
    align-items: baseline;
    gap: 0.2rem;
    font-size: 0.82rem;
    color: #6b7280;
}
.cle-col-select__count-val {
    font-size: 1.15rem;
    font-weight: 800;
    color: #ff9671;
    line-height: 1;
}

.cle-col-select__actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.cle-col-select__sep {
    color: #d1d5db;
    font-size: 0.85rem;
    line-height: 1;
}
.cle-col-action-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.78rem;
    font-weight: 600;
    color: #ff9671;
    padding: 3px 8px;
    border-radius: 6px;
    transition: background 0.12s, color 0.12s;
}
.cle-col-action-btn:hover { background: #fff3ef; color: #ea580c; }
.cle-col-action-btn--muted { color: #9ca3af; }
.cle-col-action-btn--muted:hover { background: #f3f4f6; color: #374151; }
.cle-link-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.78rem;
    font-weight: 600;
    color: #ff9671;
    padding: 2px 4px;
    border-radius: 4px;
    transition: background 0.12s, color 0.12s;
}
.cle-link-btn:hover { background: #fff3ef; color: #ea580c; }

.cle-col-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    max-height: 240px;
    overflow-y: auto;
    padding: 0.5rem;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    background: #fafafa;
}

.cle-col-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 11px;
    border: 1.5px solid #e5e7eb;
    border-radius: 999px;
    background: #fff;
    font-size: 0.8rem;
    font-weight: 600;
    color: #374151;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, color 0.15s;
    user-select: none;
}
.cle-col-chip:hover {
    border-color: rgba(255,150,113,0.45);
    background: #fff7f4;
}
.cle-col-chip input { display: none; }
.cle-col-chip:has(input:checked) {
    border-color: #ff9671;
    background: #fff3ef;
    color: #c2410c;
}
.cle-col-chip:has(input:checked) .cle-col-chip__label::before {
    content: '\2713\00a0';
    color: #ff9671;
    font-weight: 700;
}

.cle-warn {
    margin: 0;
    font-size: 0.78rem;
    color: #dc2626;
    font-weight: 600;
}

/* ============================================================
   Result columns (Step 4)
   ============================================================ */
.cle-result-cols {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    max-height: 260px;
    overflow-y: auto;
}

.cle-result-col {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.6rem 0.85rem;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    color: #374151;
}
.cle-result-col svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    color: #16a34a;
}

/* ============================================================
   Loading state
   ============================================================ */
.cle-step--loading {
    align-items: center;
    justify-content: center;
    min-height: 200px;
    gap: 1.2rem;
}
.cle-step--loading__label {
    margin: 0;
    font-size: 0.88rem;
    color: #6b7280;
}
.cle-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #fde8de;
    border-top-color: #ff9671;
    border-radius: 50%;
    animation: cle-spin 0.7s linear infinite;
}

/* ============================================================
   Footer buttons
   ============================================================ */
.cle-step__footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.65rem;
    padding-top: 0.4rem;
    border-top: 1px solid #f3f4f6;
}

.cle-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0.55rem 1.25rem;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 700;
    cursor: pointer;
    border: none;
    transition: background 0.16s, box-shadow 0.16s, transform 0.14s, opacity 0.14s;
}
.cle-btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.cle-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none !important;
}

.cle-btn--primary {
    background: linear-gradient(135deg, #ff9671 0%, #ff7043 100%);
    color: #fff;
    box-shadow: 0 2px 8px rgba(255,112,67,0.25);
}
.cle-btn--primary:not(:disabled):hover {
    box-shadow: 0 4px 16px rgba(255,112,67,0.35);
    transform: translateY(-1px);
}
.cle-btn--primary:not(:disabled):active {
    transform: translateY(0);
    box-shadow: 0 1px 4px rgba(255,112,67,0.2);
}

.cle-btn--secondary {
    background: #f3f4f6;
    color: #374151;
}
.cle-btn--secondary:not(:disabled):hover {
    background: #e5e7eb;
    transform: translateY(-1px);
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 540px) {
    .cle-step {
        padding: 1.6rem 1.2rem 1.4rem;
    }
    .cle-modal {
        border-radius: 14px;
    }
    .cle-step__footer {
        flex-direction: column-reverse;
        align-items: stretch;
    }
    .cle-btn {
        width: 100%;
        justify-content: center;
    }
}

/* ============================================================
   Phase 2 — Step 4 wide modal
   ============================================================ */

/* Body must not scroll in step 4 — only the table-wrap scrolls.
   This keeps the close button, toolbar and footer always visible. */
.cle-body:has(.cle-step--wide) {
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.cle-step--wide {
    padding: 1.2rem 1.4rem 1.2rem;
    gap: 0.85rem;
    flex: 1 1 auto;
    min-height: 0;
}
.cle-modal:has(.cle-step--wide) {
    width: min(920px, 100%);
    max-height: 94vh;
}
/* Table-wrap grows to fill remaining height inside the flex step */
.cle-step--wide .cle-table-wrap {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
}
.cle-step__header--left {
    text-align: left;
    align-items: flex-start;
}
.cle-step__header--left .cle-step__title {
    font-size: 1.05rem;
}
.cle-step__header--left .cle-step__sub {
    max-width: none;
    font-size: 0.82rem;
}

/* ============================================================
   Multi-source info banner
   ============================================================ */
.cle-multi-banner {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    background: rgba(255,150,113,.10);
    border: 1px solid rgba(255,150,113,.30);
    border-radius: 8px;
    padding: 0.6rem 0.9rem;
    font-size: 0.82rem;
    color: #b45309;
    margin-bottom: 0.85rem;
}
.cle-multi-banner svg {
    width: 16px; height: 16px;
    flex-shrink: 0;
    stroke: #ff9671;
}

/* ============================================================
   Toolbar (source selector + action buttons)
   ============================================================ */
.cle-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.7rem;
    background: #f8f9fb;
    border: 1.5px solid #e5e7eb;
    border-radius: 10px;
    padding: 0.5rem 0.75rem;
}
.cle-toolbar__actions {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
    align-items: center;
}
/* Visual separator between toolbar button groups */
.cle-toolbar__actions .cle-btn--teal {
    margin-left: 0.35rem;
    padding-left: 1rem;
    border-left: 1.5px solid rgba(255,112,67,0.25);
}
.cle-toolbar__actions .cle-btn--outline:last-of-type {
    margin-left: 0.35rem;
}
.cle-source-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.82rem;
    color: #6b7280;
}
.cle-source-row__label { font-weight: 600; }
.cle-source-sel {
    padding: 0.3rem 0.6rem;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    font-size: 0.82rem;
    background: #fff;
    color: #111827;
    cursor: pointer;
    outline: none;
}
.cle-source-sel:focus { border-color: #ff9671; box-shadow: 0 0 0 3px rgba(255,150,113,.18); }

/* Small button variants */
.cle-btn--sm {
    padding: 0.38rem 0.85rem;
    font-size: 0.8rem;
    border-radius: 7px;
}
.cle-btn--sm svg { width: 14px; height: 14px; }
.cle-btn--outline {
    background: #fff;
    color: #374151;
    border: 1.5px solid #d1d5db;
}
.cle-btn--outline:not(:disabled):hover {
    border-color: #ff9671;
    color: #ff7043;
    transform: translateY(-1px);
}
.cle-btn--teal {
    background: linear-gradient(135deg, #ff9671 0%, #ff7043 100%);
    color: #fff;
    box-shadow: 0 2px 8px rgba(255,112,67,0.25);
}
.cle-btn--teal:not(:disabled):hover {
    box-shadow: 0 4px 16px rgba(255,112,67,0.35);
    transform: translateY(-1px);
}
.cle-btn--teal:not(:disabled):active { transform: translateY(0); }

/* ============================================================
   Table wrap + preview table
   ============================================================ */
.cle-table-wrap {
    overflow-x: auto;
    border: 1.5px solid #e5e7eb;
    border-radius: 12px;
    margin-bottom: 0.85rem;
    max-height: 52vh;   /* overridden to none inside .cle-step--wide */
    overflow-y: auto;
    box-shadow: 0 2px 10px rgba(0,0,0,0.06);
    background: #fff;
}
.cle-preview-table {
    width: auto;
    border-collapse: collapse;
    font-size: 0.82rem;
    table-layout: fixed;
}
/* Headers scroll with the table — no sticky positioning */
.cle-preview-table thead {
    background: #f8f9fb;
}
.cle-preview-table thead tr {
    border-bottom: 2px solid #e5e7eb;
}
/* Subtle alternating row tint — only on rows without a group colour (no inline style) */
.cle-preview-table tbody tr:nth-child(even):not([style]) > td {
    background: #fafafa;
}
.cle-preview-table tbody tr:hover > td {
    background: rgba(255,150,113,.07) !important;
}
.cle-preview-table td, .cle-preview-table th {
    padding: 0.42rem 0.65rem;
    vertical-align: middle;
    white-space: nowrap;
}

/* Marker column (left coloured stripe) */
.cle-th-marker, .cle-td-marker {
    width: 6px;
    min-width: 6px;
    padding: 0 !important;
}
.cle-td-marker { transition: background 0.2s; }

/* Header cells */
.cle-th {
    background: #f8f9fb;
    cursor: grab;
    user-select: none;
    position: relative;
    border-right: 1px solid #f0f1f3;
}
.cle-th:last-of-type { border-right: none; }
.cle-th:active { cursor: grabbing; }
.cle-th--dragging { opacity: 0.45; }
.cle-th--drag-over { background: rgba(255,150,113,.18) !important; box-shadow: inset 2px 0 0 #ff9671; }
.cle-th-inner {
    display: flex;
    align-items: center;
    position: relative;
}
.cle-th-name {
    flex: 1;
    min-width: 0;
    font-weight: 700;
    color: #374151;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding-right: 4px;
}
/* Control buttons float as an overlay on hover so they never crowd the name */
.cle-th-controls {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    gap: 1px;
    opacity: 0;
    background: rgba(249,250,251,0.96);
    border-radius: 4px;
    padding: 1px 3px;
    transition: opacity 0.15s;
    pointer-events: none;
}
.cle-th:hover .cle-th-controls {
    opacity: 1;
    pointer-events: auto;
}
.cle-th-name--custom {
    color: #111827;
}
.cle-th-name--custom::after {
    content: ' *';
    color: #ff9671;
    opacity: 0.9;
}

/* Column move buttons */
.cle-col-mv {
    background: none;
    border: none;
    padding: 2px 3px;
    cursor: pointer;
    color: #9ca3af;
    font-size: 0.6rem;
    line-height: 1;
    border-radius: 3px;
    transition: color 0.15s;
}
.cle-col-mv:not(:disabled):hover { color: #ff7043; }
.cle-col-mv:disabled { opacity: 0.25; cursor: default; }

/* Add-column header button */
.cle-th-addcol {
    width: 36px;
    text-align: center;
    background: #f8f9fb;
    border-right: none;
}
.cle-th-add-btn {
    background: none;
    border: 1.5px dashed #d1d5db;
    border-radius: 5px;
    padding: 3px 6px;
    cursor: pointer;
    color: #9ca3af;
    transition: color 0.15s, border-color 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.cle-th-add-btn svg { width: 13px; height: 13px; }
.cle-th-add-btn:hover { color: #ff7043; border-color: #ff9671; }

/* Group badge in cell */
.cle-td-group { text-align: center; vertical-align: middle; position: relative; }
.cle-group-badge {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 600;
    line-height: 1.4;
    white-space: nowrap;
}

/* Empty row */
.cle-td-empty {
    text-align: center;
    padding: 2rem !important;
    color: #9ca3af;
    font-style: italic;
}

/* ============================================================
   Step 4 — number stepper (group count)
   ============================================================ */
.cle-stepper-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.4rem;
    padding: 1.4rem 0;
}
.cle-stepper-btn {
    width: 48px; height: 48px;
    border-radius: 50%;
    border: 2px solid #e5e7eb;
    background: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.15s, background 0.15s;
    color: #374151;
}
.cle-stepper-btn svg { width: 18px; height: 18px; }
.cle-stepper-btn:not(:disabled):hover { border-color: #ff9671; background: rgba(255,150,113,.08); }
.cle-stepper-btn:disabled { opacity: 0.35; cursor: default; }
.cle-stepper-val {
    font-size: 3rem;
    font-weight: 800;
    color: #ff7043;
    min-width: 3rem;
    text-align: center;
    line-height: 1;
}

/* ============================================================
   Form fields
   ============================================================ */
.cle-fields-list {
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
    max-height: 46vh;
    overflow-y: auto;
    padding-right: 4px;
}
.cle-field { margin-bottom: 0.6rem; }
.cle-field--mt { margin-top: 1.1rem; }
.cle-field--group { display: flex; flex-direction: column; gap: 0.55rem; }
.cle-field--inline { display: flex; align-items: center; gap: 0.75rem; }
.cle-field--inline .cle-field__label { min-width: 70px; margin-bottom: 0; }
.cle-field__label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 0.25rem;
}
.cle-field__label--strong { font-weight: 700; font-size: 0.85rem; }
.cle-field__input {
    width: 100%;
    padding: 0.45rem 0.75rem;
    border: 1.5px solid #e5e7eb;
    border-radius: 7px;
    font-size: 0.875rem;
    color: #111827;
    background: #fff;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
    box-sizing: border-box;
}
.cle-field__input:focus { border-color: #ff9671; box-shadow: 0 0 0 3px rgba(255,150,113,.18); }
.cle-field__select {
    padding: 0.4rem 0.65rem;
    border: 1.5px solid #e5e7eb;
    border-radius: 7px;
    font-size: 0.875rem;
    color: #111827;
    background: #fff;
    outline: none;
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.cle-field__select:focus { border-color: #ff9671; box-shadow: 0 0 0 3px rgba(255,150,113,.18); }
.cle-field__error {
    color: #ef4444;
    font-size: 0.78rem;
    margin-top: 0.3rem;
}
.cle-indent-wrap {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding-left: 1.6rem;
}
.cle-indent-wrap .cle-field__label { margin-bottom: 0; min-width: 90px; }

/* ============================================================
   Group colour rows
   ============================================================ */
.cle-color-rows {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-height: 34vh;
    overflow-y: auto;
    padding-right: 4px;
    margin-bottom: 0.4rem;
}
.cle-color-row {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    flex-wrap: wrap;
    padding: 0.4rem 0.5rem;
    border-radius: 7px;
    background: #f9fafb;
    border: 1px solid #f3f4f6;
}
.cle-color-row__name {
    font-weight: 700;
    font-size: 0.82rem;
    color: #374151;
    min-width: 80px;
}
.cle-swatch-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}
.cle-swatch {
    width: 22px; height: 22px;
    border-radius: 50%;
    border: 2.5px solid transparent;
    cursor: pointer;
    padding: 0;
    transition: transform 0.12s, border-color 0.12s;
    outline: none;
}
.cle-swatch:hover { transform: scale(1.18); }
.cle-swatch--active {
    border-color: #fff;
    box-shadow: 0 0 0 2.5px rgba(0,0,0,0.55);
    transform: scale(1.12);
}
.cle-custom-color-wrap {
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    color: #6b7280;
    transition: color 0.15s;
}
.cle-custom-color-wrap:hover { color: #374151; }
.cle-custom-color-wrap svg { width: 16px; height: 16px; }
.cle-custom-color-input {
    width: 0; height: 0;
    opacity: 0;
    position: absolute;
    pointer-events: none;
}
.cle-color-preview {
    width: 18px; height: 18px;
    border-radius: 50%;
    border: 2px solid rgba(0,0,0,0.12);
    flex-shrink: 0;
}

/* ============================================================
   Custom radio & checkbox
   ============================================================ */
.cle-radio-label, .cle-checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    cursor: pointer;
    font-size: 0.875rem;
    color: #374151;
    padding: 0.2rem 0;
}
.cle-radio-label input[type="radio"],
.cle-checkbox-label input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    width: 0; height: 0;
}
.cle-radio-custom, .cle-checkbox-custom {
    flex-shrink: 0;
    width: 18px; height: 18px;
    border: 2px solid #d1d5db;
    background: #fff;
    transition: border-color 0.15s, background 0.15s;
    margin-top: 1px;
}
.cle-radio-custom { border-radius: 50%; }
.cle-checkbox-custom { border-radius: 4px; }
.cle-radio-label:has(input:checked) .cle-radio-custom {
    border-color: #ff9671;
    background: radial-gradient(circle, #ff7043 40%, transparent 42%);
    box-shadow: inset 0 0 0 3px #fff, inset 0 0 0 9px #ff7043;
}
.cle-checkbox-label:has(input:checked) .cle-checkbox-custom {
    border-color: #ff7043;
    background: #ff7043;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E");
    background-size: 12px;
    background-position: center;
    background-repeat: no-repeat;
}

/* ============================================================
   Divider
   ============================================================ */
.cle-divider {
    border: none;
    border-top: 1px solid #f3f4f6;
    margin: 0.75rem 0;
}

/* ============================================================
   Step 4 responsive
   ============================================================ */
@media (max-width: 640px) {
    /* Toolbar: stack into two full-width rows */
    .cle-toolbar {
        flex-direction: column;
        align-items: flex-start;
        padding: 0.6rem 0.75rem;
        gap: 0.55rem;
    }
    .cle-toolbar__left,
    .cle-toolbar__actions { width: 100%; }

    /* Left row: heading button expands, font-size control stays compact */
    .cle-toolbar__left { gap: 0.4rem; }
    .cle-toolbar__left .cle-btn {
        flex: 1;
        justify-content: center;
    }

    /* Actions: 2-column grid — all buttons fill evenly */
    .cle-toolbar__actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.4rem;
    }
    .cle-toolbar__actions .cle-btn {
        justify-content: center;
    }
    /* Primary (teal) action spans full width and loses the desktop separator */
    .cle-toolbar__actions .cle-btn--teal {
        grid-column: 1 / -1;
        margin-left: 0;
        border-left: none;
        padding-left: 0.85rem;
        justify-content: center;
    }

    /* Preview overlay: actions row (Download + Close) centred side by side */
    .cle-pv-toolbar__actions {
        width: 100%;
        justify-content: center;
    }

    .cle-th-name { max-width: 100px; }
    .cle-modal:has(.cle-step--wide) { width: 100%; border-radius: 0; min-height: 100dvh; }
    .cle-color-row { flex-wrap: wrap; }
    .cle-color-row__name { min-width: unset; width: 100%; }
    .cle-indent-wrap { padding-left: 0.5rem; flex-wrap: wrap; }
}

/* ============================================================
   Toolbar left group
   ============================================================ */
.cle-toolbar__left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* ---- Font size control ---- */
.cle-fs-ctrl {
    display: inline-flex;
    align-items: center;
    gap: 0;
    border: 1.5px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
}
.cle-fs-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: none;
    border: none;
    cursor: pointer;
    color: #6b7280;
    padding: 0;
    transition: background 0.12s, color 0.12s;
    flex-shrink: 0;
}
.cle-fs-btn:hover:not(:disabled) { background: #fff3ef; color: #ff9671; }
.cle-fs-btn:disabled { opacity: 0.35; cursor: default; }
.cle-fs-btn svg { width: 14px; height: 14px; }
.cle-fs-val {
    min-width: 38px;
    text-align: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: #374151;
    border-left: 1px solid #e5e7eb;
    border-right: 1px solid #e5e7eb;
    padding: 0 4px;
    line-height: 28px;
    pointer-events: none;
}

/* ---- Step icon warn variant ---- */
.cle-step__icon--warn {
    background: linear-gradient(140deg, #fffbeb 0%, #fef3c7 100%);
    border-color: rgba(245,158,11,0.35);
}
.cle-step__icon--warn svg { color: #d97706; }

/* ============================================================
   Delete column button
   ============================================================ */
.cle-col-del {
    background: none;
    border: none;
    padding: 2px 4px;
    cursor: pointer;
    color: #9ca3af;
    font-size: 0.85rem;
    line-height: 1;
    border-radius: 3px;
    transition: color 0.15s, background 0.15s;
    flex-shrink: 0;
}
.cle-col-del:hover { color: #fff; background: #ef4444; }

/* ============================================================
   Preview overlay — A4 paper viewer
   ============================================================ */
.cle-pv-overlay {
    position: fixed;
    inset: 0;
    background: #f0f2f5;
    z-index: 100001;
    display: flex;
    flex-direction: column;
    animation: cle-fade-in 0.18s ease;
}
.cle-pv-a4-modal {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    overflow: hidden;
}
/* Toolbar */
.cle-pv-toolbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.6rem 1.25rem;
    background: #ffffff;
    border-bottom: 1px solid #e5e7eb;
    flex-shrink: 0;
    flex-wrap: wrap;
    box-shadow: 0 1px 4px rgba(0,0,0,0.07);
}
.cle-pv-toolbar__title {
    font-size: 0.88rem;
    font-weight: 700;
    color: #111827;
    display: flex;
    align-items: center;
    gap: 5px;
    flex: 1;
    min-width: 0;
}
.cle-pv-toolbar__actions {
    display: flex;
    gap: 0.4rem;
    align-items: center;
    flex-wrap: wrap;
    flex-shrink: 0;
}
/* Zoom controls */
.cle-pv-zoom-ctrl {
    display: flex;
    align-items: center;
    gap: 0;
    background: #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
}
.cle-pv-zoom-btn {
    background: none;
    border: none;
    color: #374151;
    cursor: pointer;
    padding: 0.35rem 0.7rem;
    font-size: 1rem;
    line-height: 1;
    font-weight: 700;
    transition: background 0.12s, color 0.12s;
}
.cle-pv-zoom-btn:hover { background: #d1d5db; color: #111827; }
.cle-pv-zoom-val {
    font-size: 0.78rem;
    font-weight: 700;
    color: #374151;
    min-width: 42px;
    text-align: center;
    padding: 0 0.2rem;
}
/* Scrollable canvas */
.cle-pv-canvas {
    flex: 1;
    overflow: auto;
    padding: 2.5rem 2rem;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}
/* Scaler — transform-origin top center, margin compensates height change */
.cle-pv-scaler {
    transform-origin: top center;
    display: flex;
    flex-direction: column;
    gap: 2.5rem;
    align-items: center;
}
/* A4 paper — landscape 297mm × 210mm at 96dpi */
.cle-a4-paper {
    width: 794px;
    min-height: 1122px;
    background: #ffffff;
    padding: 54px 53px;
    box-sizing: border-box;
    box-shadow: 0 8px 48px rgba(0,0,0,0.55);
    flex-shrink: 0;
    overflow-x: auto;
}
.cle-a4-heading {
    font-size: 15px;
    font-weight: 800;
    color: #111827;
    margin-bottom: 4px;
    font-family: inherit;
}
.cle-a4-sublabel {
    font-size: 9px;
    color: #6b7280;
    margin-bottom: 10px;
    font-family: inherit;
}
/* Table inside A4 paper */
.cle-a4-table {
    width: auto;
    border-collapse: collapse;
    font-size: 9px;       /* overridden inline when _tableFontScale != 1 */
    font-family: inherit;
    table-layout: fixed;
}
.cle-a4-paper .cle-a4-table-wrap {
    border: 1.5px solid #9ca3af;
    display: inline-block;
}
.cle-a4-table th {
    padding: 0.44em 0.67em;
    text-align: left;
    vertical-align: middle !important;
    font-weight: 700;
    font-size: 0.89em;    /* ~8px at 9px base */
    line-height: 1 !important;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: #f3f4f6;
    color: #111827;
    border: 1px solid #d1d5db;
    white-space: nowrap;
}
.cle-a4-table td {
    padding: 0.39em 0.67em;
    vertical-align: middle !important;
    line-height: 1 !important;
    color: #111827;
    border: 1px solid #e5e7eb;
    white-space: nowrap;
}
.cle-a4-table .cle-group-badge {
    font-size: 0.89em;
    line-height: 1 !important;
    vertical-align: middle !important;
}
.cle-a4-table tbody tr:nth-child(even):not([style]) td { background: #f9fafb; }
.cle-a4-table .cle-th-marker,
.cle-a4-table .cle-td-marker { width: 5px; min-width: 5px; padding: 0 !important; border-color: transparent; }

/* ============================================================
   Download dialog option cards
   ============================================================ */
.cle-dl-options {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    margin-bottom: 0.5rem;
}
.cle-dl-section-label {
    font-size: 0.78rem;
    font-weight: 700;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-top: 0.4rem;
    margin-bottom: 0.1rem;
}
.cle-dl-option {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.85rem 1rem;
    border: 1.5px solid #e5e7eb;
    border-radius: 10px;
    background: #fff;
    cursor: pointer;
    text-align: left;
    transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
    width: 100%;
}
.cle-dl-option:hover {
    border-color: #ff9671;
    background: rgba(255,150,113,.05);
    box-shadow: 0 2px 10px rgba(255,112,67,.12);
}
.cle-dl-option--sm { padding: 0.6rem 0.85rem; }
.cle-dl-option__icon {
    flex-shrink: 0;
    width: 36px; height: 36px;
    border-radius: 8px;
    background: #fff7f5;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ff7043;
}
.cle-dl-option--sm .cle-dl-option__icon { width: 28px; height: 28px; border-radius: 6px; }
.cle-dl-option__icon svg { width: 18px; height: 18px; }
.cle-dl-option--sm .cle-dl-option__icon svg { width: 14px; height: 14px; }
.cle-dl-option__text {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.cle-dl-option__text strong {
    font-size: 0.875rem;
    font-weight: 700;
    color: #111827;
}
.cle-dl-option__text span {
    font-size: 0.78rem;
    color: #6b7280;
}
.cle-dl-option__arrow {
    width: 18px; height: 18px;
    color: #d1d5db;
    flex-shrink: 0;
    transition: color 0.15s;
}
.cle-dl-option:hover .cle-dl-option__arrow { color: #ff7043; }

/* ============================================================
   Toast notifications
   ============================================================ */
.cle-toast {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.7rem 1.4rem;
    border-radius: 10px;
    font-size: 0.875rem;
    font-weight: 600;
    z-index: 200000;
    box-shadow: 0 4px 20px rgba(0,0,0,.18);
    animation: cle-toast-in 0.22s ease;
}
.cle-toast--error { background: #ef4444; color: #fff; }
@keyframes cle-toast-in {
    from { opacity: 0; transform: translateX(-50%) translateY(10px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ============================================================
   Table cell borders — grid lines
   ============================================================ */
.cle-preview-table td,
.cle-preview-table th {
    border: 1px solid #e5e7eb;
}
.cle-preview-table th.cle-th-marker,
.cle-preview-table td.cle-td-marker {
    border-color: transparent;
}
.cle-preview-table { border-collapse: collapse; }

/* table-layout: fixed is set in the base rule; td/th overflow clipped */
.cle-preview-table td,
.cle-preview-table th { overflow: hidden; text-overflow: ellipsis; }

/* ============================================================
   Column resize handle
   ============================================================ */
.cle-col-resize {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 6px;
    cursor: col-resize;
    z-index: 2;
    border-right: 2px solid transparent;
    transition: border-color 0.12s;
}
.cle-col-resize:hover,
.cle-col-resize:active { border-right-color: #ff9671; }
.cle-th { position: relative; }

/* Prevent text selection during resize */
body.cle-resizing * { user-select: none !important; cursor: col-resize !important; }

/* ============================================================
   Column settings button
   ============================================================ */
.cle-col-settings {
    background: none;
    border: none;
    padding: 2px 3px;
    cursor: pointer;
    color: #9ca3af;
    border-radius: 3px;
    transition: color 0.15s, background 0.15s;
    flex-shrink: 0;
    display: flex;
    align-items: center;
}
.cle-col-settings svg { width: 11px; height: 11px; }
.cle-col-settings:hover { color: #fff; background: #6b7280; }

/* ============================================================
   Column settings popover
   ============================================================ */
.cle-col-pop {
    position: absolute;
    z-index: 200001;
    background: #fff;
    border: 1.5px solid #e5e7eb;
    border-radius: 10px;
    box-shadow: 0 8px 28px rgba(0,0,0,.16);
    min-width: 170px;
    padding: 0.65rem 0.85rem 0.75rem;
    animation: cle-fade-in 0.14s ease;
}
.cle-col-pop__title {
    font-size: 0.78rem;
    font-weight: 700;
    color: #374151;
    margin-bottom: 0.55rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 160px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}
.cle-col-pop__close {
    background: none;
    border: none;
    cursor: pointer;
    color: #9ca3af;
    font-size: 1rem;
    line-height: 1;
    padding: 0 2px;
    flex-shrink: 0;
}
.cle-col-pop__close:hover { color: #374151; }
.cle-col-pop__section { margin-bottom: 0.55rem; }
.cle-col-pop__section:last-child { margin-bottom: 0; }
.cle-col-pop__label {
    font-size: 0.72rem;
    font-weight: 700;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.4rem;
}
.cle-col-pop__color-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.3rem;
}
.cle-col-pop__color-lbl {
    font-size: 0.74rem;
    color: #6b7280;
    min-width: 60px;
}
.cle-col-pop__color-input {
    width: 36px;
    height: 24px;
    border: 1.5px solid #e5e7eb;
    border-radius: 5px;
    padding: 1px;
    cursor: pointer;
    background: none;
}
.cle-col-pop__color-reset {
    background: none;
    border: none;
    cursor: pointer;
    color: #9ca3af;
    font-size: 1rem;
    padding: 0 2px;
    line-height: 1;
}
.cle-col-pop__color-reset:hover { color: #ff7043; }
.cle-col-pop__align {
    display: flex;
    gap: 4px;
}
.cle-align-btn {
    flex: 1;
    background: #f9fafb;
    border: 1.5px solid #e5e7eb;
    border-radius: 6px;
    padding: 5px 0;
    cursor: pointer;
    color: #6b7280;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.12s, background 0.12s, color 0.12s;
}
.cle-align-btn svg { width: 14px; height: 14px; }
.cle-align-btn:hover { border-color: #ff9671; color: #ff7043; background: #fff7f5; }
.cle-align-btn--active { border-color: #ff9671; background: #fff7f5; color: #ff7043; }

/* ============================================================
   Sort dialog extras
   ============================================================ */
.cle-sort-sub {
    margin: 0.1rem 0 0.5rem 1.75rem;
    padding: 0.65rem 0.85rem;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
}
.cle-sort-sub__row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}
.cle-sort-sub__label {
    font-size: 0.78rem;
    font-weight: 600;
    color: #6b7280;
    white-space: nowrap;
}
.cle-sort-sub__select { flex: 1; min-width: 120px; }
.cle-sort-dir-btns {
    display: flex;
    border: 1.5px solid #e5e7eb;
    border-radius: 7px;
    overflow: hidden;
    flex-shrink: 0;
}
.cle-sort-dir-btn {
    background: #fff;
    border: none;
    padding: 0.3rem 0.75rem;
    font-size: 0.78rem;
    font-weight: 600;
    color: #6b7280;
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
    white-space: nowrap;
}
.cle-sort-dir-btn + .cle-sort-dir-btn { border-left: 1.5px solid #e5e7eb; }
.cle-sort-dir-btn:hover { background: #f3f4f6; color: #374151; }
.cle-sort-dir-btn--active { background: #ff9671; color: #fff; }
.cle-sort-dir-btn--active:hover { background: #ff7043; }
.cle-radio-label--disabled {
    opacity: 0.45;
    cursor: not-allowed;
}
.cle-radio-label--disabled input { pointer-events: none; }
.cle-muted {
    font-size: 0.78rem;
    color: #9ca3af;
    margin-left: 0.35em;
}

/* ============================================================
   Group column card (GD Step 4)
   ============================================================ */
.cle-group-col-card {
    margin: 0.5rem 0 0 1.75rem;
    background: #f9fafb;
    border: 1.5px solid #e5e7eb;
    border-radius: 10px;
    padding: 0.85rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}
.cle-group-col-card__row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.cle-group-col-card__label {
    font-size: 0.78rem;
    font-weight: 600;
    color: #6b7280;
    white-space: nowrap;
    min-width: 88px;
}
.cle-group-col-card__input {
    flex: 1;
    margin-bottom: 0 !important;
}
.cle-group-col-card__hint {
    font-size: 0.75rem;
    color: #9ca3af;
    margin: 0;
    line-height: 1.4;
}

/* ============================================================
   cle-pv-table (preview overlay) — kept for backward compat
   ============================================================ */
.cle-pv-table td,
.cle-pv-table th {
    border: 1px solid #e5e7eb;
}
.cle-pv-table th.cle-th-marker,
.cle-pv-table td.cle-td-marker { border-color: transparent; }
.cle-pv-table { border-collapse: collapse; }
