/* ── Table placeholder ──────────────────────────────────────── */
.table-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    color: var(--text-dim);
    gap: 0.5rem;
    animation: fadeUp 0.5s ease 0.2s both;
}

.ph-icon {
    margin-bottom: 0.5rem;
}

.ph-text {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-mid);
}

.ph-sub {
    font-size: 0.75rem;
    color: var(--text-dim);
    font-family: 'JetBrains Mono', monospace;
}

/* ── DataTable container ────────────────────────────────────── */
.table-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);

    /* Let DataTables internal scroll area control the height */
    max-height: none;
    min-height: 520px;

    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow);
    animation: fadeUp 0.4s ease both;
}

.table-wrap.hidden {
    display: none;
}
/* ── Table busy overlay for server-side paging/filtering/sorting ───────── */

.table-wrap {
    position: relative;
}

.table-busy-overlay {
    position: absolute;
    inset: 0;
    z-index: 60;

    display: flex;
    align-items: center;
    justify-content: center;

    background: rgba(15, 17, 23, 0.58);
    backdrop-filter: blur(2px);

    pointer-events: auto;
}

.table-busy-overlay.hidden {
    display: none !important;
}

.table-busy-card {
    min-width: 260px;
    max-width: 420px;

    padding: 1rem 1.15rem;
    border-radius: 16px;

    background: var(--surface);
    border: 1px solid var(--border-mid);
    box-shadow: var(--shadow);

    text-align: center;
}

.table-busy-spinner {
    width: 34px;
    height: 34px;

    margin: 0 auto 0.75rem;

    border-radius: 999px;
    border: 3px solid var(--surface-3);
    border-top-color: var(--accent);

    animation: tableBusySpin 0.8s linear infinite;
}

@keyframes tableBusySpin {
    to {
        transform: rotate(360deg);
    }
}

.table-busy-title {
    color: var(--text);
    font-weight: 800;
    font-size: 0.86rem;
    margin-bottom: 0.25rem;
}

.table-busy-detail {
    color: var(--text-mid);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.7rem;
    line-height: 1.45;
}

.dataTables_processing {
    z-index: 70 !important;
    border-radius: 999px !important;
    border: 1px solid var(--border-mid) !important;
    background: var(--surface-2) !important;
    color: var(--accent) !important;
    font-family: 'JetBrains Mono', monospace !important;
    font-size: 0.75rem !important;
    padding: 0.45rem 0.8rem !important;
    box-shadow: var(--shadow) !important;
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* DataTables overrides */
.dataTables_wrapper {
    width: 100% !important;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

#csvTable {
    width: 100% !important;
    table-layout: auto;
    border-collapse: collapse;
}

/*#csvTable thead th {*/
/*    background: var(--surface-2) !important;*/
/*    color: var(--text-mid) !important;*/
/*    font-family: 'JetBrains Mono', monospace;*/
/*    font-size: 0.7rem !important;*/
/*    font-weight: 600;*/
/*    text-transform: uppercase;*/
/*    letter-spacing: 0.05em;*/
/*    border-bottom: 1px solid var(--border-mid) !important;*/
/*    white-space: nowrap;*/
/*    padding: 0.55rem 0.75rem !important;*/
/*}*/

#csvTable tbody td {
    white-space: nowrap;
    padding: 0.35rem 0.75rem !important;
    font-size: 0.77rem !important;
    font-family: 'JetBrains Mono', monospace;
    color: var(--text-mid) !important;
    border-bottom: 1px solid var(--border) !important;
    transition: background var(--transition);
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
}

#csvTable.stripe tbody tr:nth-child(even) td {
    background: rgba(255, 255, 255, 0.015) !important;
}

#csvTable.hover tbody tr:hover td {
    background: rgba(63, 239, 180, 0.04) !important;
}

/* DataTables controls */
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter,
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate {
    color: var(--text-mid) !important;
    font-size: 0.75rem !important;
    padding: 0.6rem 1rem;
    background: var(--surface-2);
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
    color: var(--text-mid) !important;
    border-radius: var(--radius-sm) !important;
    transition: all var(--transition) !important;
    padding: 0.2rem 0.55rem !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: var(--surface-3) !important;
    color: var(--text) !important;
    border-color: transparent !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: var(--accent-dim) !important;
    color: var(--accent) !important;
    border: 1px solid rgba(63, 239, 180, 0.3) !important;
}

.dataTables_wrapper .dataTables_length select,
.dataTables_wrapper .dataTables_filter input {
    background: var(--surface-3) !important;
    border: 1px solid var(--border-mid) !important;
    color: var(--text) !important;
    border-radius: var(--radius-sm) !important;
    padding: 0.2rem 0.5rem !important;
    font-size: 0.75rem !important;
}




.cluster-action-btn.twitcher {
    background: rgba(37, 99, 235, 0.15);
    border-color: rgba(59, 130, 246, 0.4);
    color: #93c5fd;
}

.cluster-action-btn.twitcher:hover {
    background: rgba(37, 99, 235, 0.3);
    color: #bfdbfe;
}

.cluster-action-btn.event {
    background: rgba(22, 163, 74, 0.12);
    border-color: rgba(52, 211, 153, 0.3);
    color: #6ee7b7;
}

.cluster-action-btn.event:hover {
    background: rgba(22, 163, 74, 0.25);
}

.cluster-action-btn.igv {
    background: rgba(124, 58, 237, 0.12);
    border-color: rgba(167, 139, 250, 0.3);
    color: #c4b5fd;
}

.cluster-action-btn.igv:hover {
    background: rgba(124, 58, 237, 0.25);
}


/* ── Table action hint ─────────────────────────────────────── */

.table-action-hint {
    display: flex;
    align-items: flex-start;
    gap: 0.55rem;
    padding: 0.65rem 0.85rem;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(
        135deg,
        rgba(63, 239, 180, 0.055),
        rgba(59, 130, 246, 0.035)
    );
    color: var(--text-mid);
    font-size: 0.74rem;
    line-height: 1.45;
}

.table-action-hint strong {
    color: var(--text);
    font-weight: 800;
}

.table-action-hint em {
    color: var(--accent);
    font-style: normal;
    font-weight: 700;
}

.table-action-hint-icon {
    color: var(--accent);
    font-family: 'JetBrains Mono', monospace;
    font-weight: 800;
    line-height: 1.35;
    flex-shrink: 0;
}

.table-action-hint kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.6rem;
    padding: 0.05rem 0.32rem;
    margin: 0 0.08rem;
    border-radius: 5px;
    border: 1px solid var(--border-mid);
    background: var(--surface-3);
    color: var(--text);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.66rem;
    font-weight: 700;
    box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.25);
}

/* ── Repeated-event processing mode ─────────────────────────── */

.duplicate-mode-setting {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    margin: 0.25rem 0 0.8rem;
    padding: 0.8rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface-2);
}

.duplicate-mode-description {
    margin: 0;
    line-height: 1.5;
}

.duplicate-mode-details {
    border-top: 1px solid var(--border);
    padding-top: 0.55rem;
}

.duplicate-mode-details summary {
    color: var(--text-mid);
    cursor: pointer;
    font-size: 0.73rem;
    font-weight: 700;
    user-select: none;
}

.duplicate-mode-details summary:hover {
    color: var(--accent);
}

.duplicate-mode-details-body {
    margin-top: 0.55rem;
    color: var(--text-mid);
    font-size: 0.71rem;
    line-height: 1.55;
}

.duplicate-mode-details-body ul {
    margin: 0.5rem 0;
    padding-left: 1.25rem;
}

.duplicate-mode-details-body li {
    margin-bottom: 0.28rem;
}

.duplicate-mode-details-body p {
    margin: 0.5rem 0 0;
}

.duplicate-mode-details-body code {
    padding: 0.05rem 0.25rem;
    border-radius: 4px;
    background: var(--surface-3);
    color: var(--accent);
    font-family: "JetBrains Mono", monospace;
    font-size: 0.68rem;
}

/* ── Repeated-event group expansion ─────────────────────────── */

.duplicate-group-toggle {
    width: auto;
    min-width: 15rem;
    max-width: var(--duplicate-group-toggle-max-width, 24rem);
    min-height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.32rem;
    flex-shrink: 0;
    padding: 0.14rem 0.48rem;
    overflow: hidden;
    border: 1px solid rgba(56, 189, 248, 0.38);
    border-radius: var(--radius-sm);
    background: rgba(14, 165, 233, 0.11);
    color: #7dd3fc;
    cursor: pointer;
    font-family: "JetBrains Mono", monospace;
    font-size: 0.64rem;
    font-weight: 700;
    white-space: nowrap;
    transition:
        background var(--transition),
        border-color var(--transition),
        color var(--transition),
        transform var(--transition);
}

.duplicate-group-toggle:hover {
    transform: translateY(-1px);
    background: rgba(14, 165, 233, 0.22);
    border-color: rgba(56, 189, 248, 0.65);
    color: #bae6fd;
}

.duplicate-group-toggle.is-disabled,
.duplicate-group-toggle:disabled {
    border-color: rgba(148, 163, 184, 0.22);
    background: rgba(148, 163, 184, 0.07);
    color: rgba(148, 163, 184, 0.68);
    cursor: default;
    opacity: 0.78;
    box-shadow: none;
}

.duplicate-group-toggle.is-disabled:hover,
.duplicate-group-toggle:disabled:hover {
    transform: none;
    border-color: rgba(148, 163, 184, 0.22);
    background: rgba(148, 163, 184, 0.07);
    color: rgba(148, 163, 184, 0.68);
}

.duplicate-group-toggle.is-disabled .duplicate-group-toggle-arrow {
    color: rgba(148, 163, 184, 0.55);
}

.duplicate-group-toggle-arrow {
    width: 0.8rem;
    flex-shrink: 0;
    color: currentColor;
    text-align: center;
}

.duplicate-group-toggle-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Repeated-event group "may differ" indicator ────────────── */

.duplicate-group-toggle.has-differences {
    border-color: rgba(56, 189, 248, 0.65);
    background: rgba(14, 165, 233, 0.22);
    color: #fcd34d;
}

.duplicate-group-toggle.has-differences:hover {
    border-color: rgba(251, 191, 36, 0.85);
    background: rgba(245, 158, 11, 0.22);
    color: #fde68a;
}

.duplicate-group-toggle-diff-dot {
    width: 0.25rem;
    height: 0.25rem;
    flex-shrink: 0;
    border-radius: 50%;
    background: #fbbf24;
    box-shadow: 0 0 0 2px rgba(251, 191, 36, 0.25);
}

/* ── Dataset-wide label-presence strip ──────────────────────── */

.sample-presence-strip {
    min-width: 0;
    display: inline-flex;
    align-items: center;
    gap: 0.48rem;
    overflow-x: auto;
    overflow-y: hidden;
}

.sample-presence-item {
    min-width: 0;
    display: inline-flex;
    align-items: center;
    gap: 0.22rem;
    flex-shrink: 0;
}

.sample-presence-label {
    max-width: 78px;
    overflow: hidden;
    color: var(--text-mid);
    font-family: "JetBrains Mono", monospace;
    font-size: 0.6rem;
    font-weight: 750;
    line-height: 1;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sample-presence-svg {
    width: 18px;
    height: 18px;
    display: block;
    flex-shrink: 0;
    overflow: visible;
    transition: transform var(--transition);
}

.sample-presence-item:hover .sample-presence-svg {
    transform: scale(1.1);
}

/* A disabled toggle (single-retained-observation events) has nothing to
   expand/collapse and already resets its own hover transform to none below
   -- the per-icon hover zoom must be neutralized the same way, otherwise
   hovering a presence icon inside a non-interactive toggle still visibly
   scales it up, implying interactivity that isn't there. */
.duplicate-group-toggle.is-disabled .sample-presence-item:hover .sample-presence-svg,
.duplicate-group-toggle:disabled .sample-presence-item:hover .sample-presence-svg {
    transform: none;
}

.sample-presence-item.is-absent {
    opacity: 0.52;
}

.sample-presence-item.is-absent .sample-presence-background {
    fill: transparent;
}

.sample-presence-item.is-absent .sample-presence-outline {
    stroke: var(--text-dim);
    stroke-dasharray: 2.2 1.7;
}

.duplicate-group-toggle.is-disabled .sample-presence-strip {
    opacity: 0.82;
}

.duplicate-group-toggle.is-disabled .sample-presence-item.is-single,
.duplicate-group-toggle.is-disabled .sample-presence-item.is-multiple {
    opacity: 0.9;
}

/* ── Expanded DataTables child row ──────────────────────────── */
#csvTable tbody tr.duplicate-group-row-expanded > td {
    background: rgba(14, 165, 233, 0.07) !important;
    border-bottom-color: rgba(56, 189, 248, 0.28) !important;
}

#csvTable tbody tr.duplicate-group-row-expanded > td:first-child {
    box-shadow: inset 3px 0 0 rgba(56, 189, 248, 0.8);
}

/*
 * The child row still spans the complete wide DataTables table. The panel is
 * sized in JavaScript to the visible scroll viewport and shifted right by the
 * current scrollLeft. This keeps the whole expanded UI visible without adding
 * another horizontal scrolling surface.
 */
#csvTable tbody tr.child {
    width: auto !important;
}

#csvTable tbody tr.child > td {
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    padding: 0 !important;
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: clip !important;
    background: var(--surface-2) !important;
    border-bottom: 1px solid var(--border-mid) !important;
}

#csvTable tbody tr.child .duplicate-group-panel {
    position: relative !important;
    left: var(--duplicate-panel-left, 0px) !important;
    width: var(--duplicate-panel-visible-width, 100%) !important;
    min-width: 0 !important;
    max-width: var(--duplicate-panel-visible-width, 100%) !important;
    box-sizing: border-box;
    transform: none !important;
    overflow-x: clip !important;
    overflow-y: visible;
    contain: inline-size;
}

#csvTable tbody tr.child .duplicate-group-panel,
#csvTable tbody tr.child .duplicate-group-panel *,
#csvTable tbody tr.child .duplicate-group-panel *::before,
#csvTable tbody tr.child .duplicate-group-panel *::after {
    box-sizing: border-box;
}

#csvTable tbody tr.child .duplicate-group-panel > *,
#csvTable tbody tr.child .duplicate-group-panel-header,
#csvTable tbody tr.child .duplicate-group-presence-summary,
#csvTable tbody tr.child .duplicate-group-signature,
#csvTable tbody tr.child .duplicate-diff-section,
#csvTable tbody tr.child .duplicate-diff-header,
#csvTable tbody tr.child .duplicate-diff-fields,
#csvTable tbody tr.child .duplicate-diff-field-card,
#csvTable tbody tr.child .duplicate-diff-field-header,
#csvTable tbody tr.child .duplicate-diff-values-grid,
#csvTable tbody tr.child .duplicate-diff-observation-value,
#csvTable tbody tr.child .duplicate-group-members,
#csvTable tbody tr.child .duplicate-member-card,
#csvTable tbody tr.child .duplicate-member-all-details,
#csvTable tbody tr.child .duplicate-member-all-grid,
#csvTable tbody tr.child .duplicate-member-all-field {
    inline-size: 100%;
    width: 100%;
    min-inline-size: 0;
    min-width: 0;
    max-inline-size: 100%;
    max-width: 100%;
}

.duplicate-group-panel {
    width: 96vw;
    min-width: 0;
    box-sizing: border-box;
    padding: 1rem;
    color: var(--text);
    background:
        linear-gradient(
            135deg,
            rgba(14, 165, 233, 0.045),
            rgba(59, 130, 246, 0.025)
        ),
        var(--surface-2);
}

.duplicate-group-panel.loading,
.duplicate-group-panel.error {
    min-height: 92px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    color: var(--text-mid);
    font-size: 0.76rem;
}

.duplicate-group-panel.error {
    color: #fca5a5;
}

.duplicate-group-loading-spinner {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    border: 3px solid var(--surface-3);
    border-top-color: #38bdf8;
    border-radius: 999px;
    animation: duplicateGroupSpin 0.8s linear infinite;
}

@keyframes duplicateGroupSpin {
    to {
        transform: rotate(360deg);
    }
}

.duplicate-group-panel-header {
    width: 100%;
    min-width: 0;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.8rem;
}

.duplicate-group-panel-header > div {
    min-width: 0;
}

.duplicate-group-panel-kicker,
.duplicate-member-kicker {
    margin-bottom: 0.16rem;
    color: #38bdf8;
    font-family: "JetBrains Mono", monospace;
    font-size: 0.62rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.duplicate-group-panel-title {
    color: var(--text);
    font-family: "Syne", sans-serif;
    font-size: 0.96rem;
    font-weight: 800;
}

.duplicate-group-id {
    min-width: 0;
    max-width: 260px;
    overflow: hidden;
    color: var(--text-dim);
    font-family: "JetBrains Mono", monospace;
    font-size: 0.62rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.duplicate-group-presence-summary {
    width: 100%;
    min-width: 0;
    display: flex;
    align-items: flex-start;
    gap: 0.8rem;
    flex-wrap: wrap;
    margin-bottom: 0.85rem;
    padding: 0.58rem 0.68rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
}

.duplicate-group-presence-title {
    flex-shrink: 0;
    color: var(--text-dim);
    font-family: "JetBrains Mono", monospace;
    font-size: 0.61rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.duplicate-group-presence-summary .sample-presence-strip {
    min-width: 0;
    flex: 1 1 320px;
    display: flex;
    flex-wrap: wrap;
    overflow: visible;
}

.duplicate-group-presence-summary .sample-presence-label {
    max-width: 130px;
    font-size: 0.65rem;
}

.duplicate-group-presence-summary .sample-presence-svg {
    width: 20px;
    height: 20px;
}

.duplicate-group-signature {
    width: 100%;
    min-width: 0;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(170px, 100%), 1fr));
    gap: 0.55rem;
    margin-bottom: 0.9rem;
}

.duplicate-group-signature > div {
    min-width: 0;
    padding: 0.52rem 0.62rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
}

.duplicate-group-signature span {
    display: block;
    margin-bottom: 0.26rem;
    color: var(--text-dim);
    font-size: 0.61rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.duplicate-group-signature code {
    display: block;
    min-width: 0;
    overflow: hidden;
    color: var(--accent);
    font-family: "JetBrains Mono", monospace;
    font-size: 0.68rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Difference-first repeated-event comparison ─────────────── */

.duplicate-diff-section {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    margin-bottom: 0.9rem;
    overflow-x: hidden;
    border: 1px solid var(--border-mid);
    border-radius: var(--radius-md);
    background: var(--surface);
}

/*
 * Difference summary header. Inline-size containment is important here:
 * DataTables places this content inside a table cell whose containing table is
 * much wider than the visible viewport. The title must never contribute an
 * intrinsic width back to that table.
 */
.duplicate-diff-header {
    inline-size: 100%;
    width: 100%;
    min-inline-size: 0;
    min-width: 0;
    max-inline-size: 100%;
    max-width: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0.35rem;
    padding: 0.72rem 0.8rem;
    overflow: clip;
    contain: inline-size;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(
        135deg,
        rgba(168, 85, 247, 0.07),
        rgba(59, 130, 246, 0.04)
    );
}

.duplicate-diff-header > div {
    inline-size: 100%;
    width: 100%;
    min-inline-size: 0;
    min-width: 0;
    max-inline-size: 100%;
    max-width: 100%;
    margin: 0;
    padding: 0;
    overflow: clip;
    contain: inline-size;
}

.duplicate-diff-kicker,
.duplicate-diff-title,
.duplicate-diff-help {
    display: block;
    inline-size: 100% !important;
    width: 100% !important;
    min-inline-size: 0 !important;
    min-width: 0 !important;
    max-inline-size: 100% !important;
    max-width: 100% !important;
    margin: 0;
    padding: 0;
    overflow: clip !important;
    white-space: normal !important;
    overflow-wrap: anywhere !important;
    word-break: break-word !important;
    contain: inline-size;
}

.duplicate-diff-kicker {
    margin-bottom: 0.14rem;
    color: #c084fc;
    font-family: "JetBrains Mono", monospace;
    font-size: 0.59rem;
    font-weight: 850;
    letter-spacing: 0.07em;
    line-height: 1.3;
    text-transform: uppercase;
}

.duplicate-diff-title {
    color: var(--text);
    font-size: 0.77rem;
    font-weight: 800;
    line-height: 1.4;
}

.duplicate-diff-help {
    color: var(--text-dim);
    font-size: 0.62rem;
    line-height: 1.4;
    text-align: left;
}

.duplicate-diff-fields {
    width: 100%;
    min-width: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0.65rem;
    padding: 0.72rem;
}

.duplicate-diff-field-card {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
}

.duplicate-diff-field-header {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 0.3rem;
    padding: 0.5rem 0.62rem;
    border-bottom: 1px solid var(--border);
    background: rgba(148, 163, 184, 0.035);
}

.duplicate-diff-field-header > div {
    min-width: 0;
    max-width: 100%;
}

.duplicate-diff-field-name {
    min-width: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--text);
    font-family: "JetBrains Mono", monospace;
    font-size: 0.67rem;
    font-weight: 800;
    line-height: 1.35;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.duplicate-diff-field-column-name {
    min-width: 0;
    margin-top: 0.12rem;
    color: var(--text-dim);
    font-family: "JetBrains Mono", monospace;
    font-size: 0.54rem;
    line-height: 1.3;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.duplicate-diff-distinct-count {
    max-width: 100%;
    align-self: flex-start;
    padding: 0.12rem 0.4rem;
    border: 1px solid var(--border-mid);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text-dim);
    font-family: "JetBrains Mono", monospace;
    font-size: 0.55rem;
    font-weight: 750;
    white-space: normal;
}

.duplicate-diff-values-grid {
    width: 100%;
    min-width: 0;
    max-width: 100%;

    display: grid;

    /*
     * Use at least two equal columns on normal screens.
     * minmax(0, 1fr) is important because it allows long
     * genomic values to shrink and wrap inside each card.
     */
    grid-template-columns:
        repeat(
            2,
            minmax(0, 1fr)
        );

    gap: 0.55rem;
    padding: 0.55rem;

    overflow: hidden;
}

.duplicate-diff-observation-value {
    width: 100%;
    min-width: 0;
    max-width: 100%;

    overflow: hidden;

    padding: 0.45rem;

    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
}

.duplicate-diff-value-header {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 0.32rem;
    margin-bottom: 0.32rem;
}

.duplicate-diff-label-dot {
    width: 9px;
    height: 9px;
    flex-shrink: 0;
    border: 1px solid var(--diff-label-border);
    border-radius: 999px;
    background: var(--diff-label-bg);
    box-shadow: inset 0 0 0 3px var(--diff-label-border);
}

.duplicate-diff-label-text {
    min-width: 0;
    max-width: 100%;
    overflow: visible;
    color: var(--diff-label-text);
    font-family: "JetBrains Mono", monospace;
    font-size: 0.85rem;
    font-weight: 800;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.duplicate-diff-value-content {
    min-width: 0;
    max-width: 100%;
    color: var(--text-mid);
    font-family: "JetBrains Mono", monospace;
    font-size: 0.83rem;
    line-height: 1.42;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.duplicate-diff-observation-value.differs-from-baseline {
    border-color: rgba(251, 191, 36, 0.55);
    background: rgba(251, 191, 36, 0.1);
    box-shadow: inset 3px 0 0 rgba(251, 191, 36, 0.8);
}

.duplicate-diff-observation-value.matches-baseline {
    border-color: var(--border);
    background: var(--surface);
}

.duplicate-diff-empty {
    width: 100%;
    min-width: 0;
    margin-bottom: 0.9rem;
    padding: 0.8rem;
    border: 1px dashed var(--border-mid);
    border-radius: var(--radius-md);
    background: var(--surface);
    color: var(--text-dim);
    font-size: 0.7rem;
    text-align: center;
    white-space: normal;
    overflow-wrap: anywhere;
}

/* ── Compact observation cards and full-field details ───────── */

.duplicate-group-members {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0.7rem;
}

.duplicate-member-card {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    padding: 0.78rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
}

.duplicate-member-card.compact {
    padding: 0.7rem;
}

.duplicate-member-card.matches-filters {
    border-color: rgba(34, 197, 94, 0.38);
}

.duplicate-member-header {
    width: 100%;
    min-width: 0;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.7rem;
    margin-bottom: 0.45rem;
}

.duplicate-member-header > div {
    min-width: 0;
}

.duplicate-member-title,
.duplicate-member-event-id {
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    font-family: "JetBrains Mono", monospace;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.duplicate-member-title {
    color: var(--text);
    font-size: 0.72rem;
    font-weight: 700;
}

.duplicate-member-event-id {
    margin-top: 0.18rem;
    color: var(--text-dim);
    font-size: 0.59rem;
}

.duplicate-member-badges {
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.32rem;
    flex-wrap: wrap;
}

.duplicate-member-badge {
    display: inline-flex;
    align-items: center;
    min-height: 20px;
    max-width: 100%;
    padding: 0.08rem 0.38rem;
    border: 1px solid var(--border-mid);
    border-radius: 999px;
    color: var(--text-mid);
    font-family: "JetBrains Mono", monospace;
    font-size: 0.58rem;
    font-weight: 700;
    white-space: normal;
}

.duplicate-member-badge.representative {
    border-color: rgba(56, 189, 248, 0.45);
    background: rgba(14, 165, 233, 0.12);
    color: #7dd3fc;
}

.duplicate-member-badge.matches {
    border-color: rgba(34, 197, 94, 0.45);
    background: rgba(34, 197, 94, 0.12);
    color: #86efac;
}

.duplicate-member-badge.filtered-out {
    border-color: rgba(148, 163, 184, 0.35);
    background: rgba(148, 163, 184, 0.08);
    color: var(--text-dim);
}

.duplicate-member-actions {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 0.34rem;
    flex-wrap: wrap;
    margin-top: 0.72rem;
}

.duplicate-member-all-details {
    width: 100%;
    min-width: 0;
    margin-top: 0.68rem;
    padding-top: 0.55rem;
    border-top: 1px solid var(--border);
}

.duplicate-member-all-details summary {
    color: var(--text-mid);
    cursor: pointer;
    font-size: 0.66rem;
    font-weight: 700;
}

.duplicate-member-all-details summary:hover {
    color: var(--accent);
}

.duplicate-member-all-grid {
    width: 100%;
    min-width: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0.3rem;
    margin-top: 0.55rem;
}

.duplicate-member-all-field {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    display: grid;
    grid-template-columns: minmax(110px, 0.35fr) minmax(0, 0.65fr);
    gap: 0.45rem;
    padding: 0.28rem 0;
    border-bottom: 1px solid var(--border);
}

.duplicate-member-all-name {
    min-width: 0;
    overflow: visible;
    color: var(--text-dim);
    font-family: "JetBrains Mono", monospace;
    font-size: 0.58rem;
    font-weight: 700;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.duplicate-member-all-value {
    min-width: 0;
    overflow: visible;
    color: var(--text-mid);
    font-family: "JetBrains Mono", monospace;
    font-size: 0.6rem;
    line-height: 1.4;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.duplicate-group-empty {
    width: 100%;
    min-width: 0;
    padding: 1rem;
    color: var(--text-dim);
    text-align: center;
    font-size: 0.72rem;
    white-space: normal;
}

/* ── Saved-event row highlight ──────────────────────────────── */

#csvTable tbody tr.row-highlighted-event td {
    background: rgba(250, 204, 21, 0.18) !important;
    color: var(--text) !important;
    box-shadow:
        inset 0 1px 0 rgba(250, 204, 21, 0.22),
        inset 0 -1px 0 rgba(250, 204, 21, 0.22);
}

#csvTable tbody tr.row-highlighted-event td:first-child {
    border-left: 3px solid #facc15 !important;
}

/* ── Read-label modal ───────────────────────────────────────── */

.read-label-modal {
    position: fixed !important;
    inset: 0 !important;
    z-index: 10000 !important;
    width: 100vw;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 1rem;
    box-sizing: border-box;
}

.read-label-modal.hidden {
    display: none !important;
}

.read-label-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(2, 6, 23, 0.68);
    backdrop-filter: blur(3px);
}

.read-label-dialog {
    position: relative;
    z-index: 1;
    width: min(520px, calc(100vw - 2rem));
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
    margin: 0;
    border: 1px solid var(--border-mid);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.read-label-dialog-header,
.read-label-dialog-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.9rem 1rem;
}

.read-label-dialog-header {
    border-bottom: 1px solid var(--border);
}

.read-label-dialog-actions {
    justify-content: flex-end;
    border-top: 1px solid var(--border);
}

.read-label-dialog-title {
    margin: 0;
    color: var(--text);
    font-size: 1rem;
    font-weight: 800;
}

.read-label-dialog-body {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    padding: 1rem;
}

.read-label-raw-id {
    max-height: 90px;
    overflow: auto;
    padding: 0.55rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--text-mid);
    font-family: "JetBrains Mono", monospace;
    font-size: 0.68rem;
    overflow-wrap: anywhere;
}

/* ── Light theme ────────────────────────────────────────────── */

:root[data-theme="light"] .duplicate-group-toggle {
    border-color: #0284c7;
    background: #e0f2fe;
    color: #0369a1;
}

:root[data-theme="light"] .duplicate-group-toggle:hover {
    background: #bae6fd;
    color: #075985;
}

:root[data-theme="light"] .duplicate-group-toggle.is-disabled,
:root[data-theme="light"] .duplicate-group-toggle:disabled {
    border-color: #cbd5e1;
    background: #f1f5f9;
    color: #64748b;
    opacity: 1;
}

:root[data-theme="light"] .duplicate-group-toggle.is-disabled:hover,
:root[data-theme="light"] .duplicate-group-toggle:disabled:hover {
    transform: none;
    border-color: #cbd5e1;
    background: #f1f5f9;
    color: #64748b;
}

:root[data-theme="light"] .duplicate-group-toggle.has-differences {
    border-color: #d97706;
    background: #fef3c7;
    color: #92400e;
}

:root[data-theme="light"] .duplicate-group-toggle.has-differences:hover {
    background: #fde68a;
    color: #78350f;
}

:root[data-theme="light"] .duplicate-group-toggle-diff-dot {
    background: #f59e0b;
    box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.3);
}

:root[data-theme="light"] #csvTable tbody tr.duplicate-group-row-expanded > td {
    background: #f0f9ff !important;
}

:root[data-theme="light"] .duplicate-group-panel,
:root[data-theme="light"] .duplicate-diff-field-card {
    background: #f8fafc;
    color: #0f172a;
}

:root[data-theme="light"] .duplicate-member-card,
:root[data-theme="light"] .duplicate-group-presence-summary,
:root[data-theme="light"] .duplicate-diff-section,
:root[data-theme="light"] .duplicate-diff-observation-value {
    background: #ffffff;
    border-color: #dbe3ec;
}

:root[data-theme="light"] .duplicate-member-badge.representative {
    border-color: #0284c7;
    background: #e0f2fe;
    color: #0369a1;
}

:root[data-theme="light"] .duplicate-member-badge.matches {
    border-color: #16a34a;
    background: #dcfce7;
    color: #15803d;
}

:root[data-theme="light"] .sample-presence-label {
    color: #334155;
}

:root[data-theme="light"] .sample-presence-item.is-absent .sample-presence-outline {
    stroke: #94a3b8;
}

:root[data-theme="light"] .duplicate-diff-header {
    background: linear-gradient(135deg, #faf5ff, #eff6ff);
}

:root[data-theme="light"] .duplicate-diff-field-name {
    background: transparent;
    color: #0f172a;
}

:root[data-theme="light"] .duplicate-diff-observation-value.differs-from-baseline {
    border-color: #d97706;
    background: #fef3c7;
    color: #92400e;
    box-shadow: inset 3px 0 0 #d97706;
}

:root[data-theme="light"] .duplicate-diff-empty {
    background: #f8fafc;
    color: #64748b;
}

:root[data-theme="light"] #csvTable tbody tr.row-highlighted-event td {
    background: #fef3c7 !important;
    color: #111827 !important;
    box-shadow:
        inset 0 1px 0 rgba(180, 83, 9, 0.22),
        inset 0 -1px 0 rgba(180, 83, 9, 0.22);
}

:root[data-theme="light"] #csvTable tbody tr.row-highlighted-event td:first-child {
    border-left: 3px solid #d97706 !important;
}

/* ── Responsive refinements ─────────────────────────────────── */
@media (min-width: 1400px) {
    .duplicate-diff-values-grid {
        grid-template-columns:
            repeat(
                3,
                minmax(0, 1fr)
            );
    }
}
@media (max-width: 900px) {
.duplicate-group-panel-header,
.duplicate-member-header {
        flex-direction: column;
        align-items: stretch;
        gap: 0.4rem;
    }

.duplicate-group-id,
.duplicate-member-title,
.duplicate-member-event-id {
        max-width: 100%;
        white-space: normal;
        overflow-wrap: anywhere;
        word-break: break-word;
    }
}

@media (max-width: 700px) {
.duplicate-member-all-field {
        grid-template-columns: minmax(0, 1fr);
        gap: 0.18rem;
    }
    .duplicate-diff-values-grid {
        grid-template-columns:
            minmax(0, 1fr);
    }
}
@media (max-width: 560px) {
.duplicate-group-panel {
        padding: 0.65rem;
    }

.duplicate-group-presence-summary {
        flex-direction: column;
        align-items: stretch;
    }

.duplicate-group-presence-summary .sample-presence-strip {
        flex-basis: auto;
    }
}
