
.tsh-relationship-board,
.tsh-dashboard-builder {
    display: block;
    border: 1px solid var(--line-1, var(--tsh-border, #dbe3ef));
    border-radius: 12px;
    background: var(--surface-1, #fff);
    padding: 14px;
    box-shadow: var(--shadow-sm, 0 8px 24px rgba(15,23,42,.06));
}
.tsh-rel-header,
.tsh-dashboard-builder-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--line-1, var(--tsh-border, #dbe3ef));
}
.tsh-rel-header strong,
.tsh-dashboard-builder-head strong { display: block; font-size: 15px; letter-spacing: -.01em; color: var(--text-1, #172033); }
.tsh-rel-header small,
.tsh-dashboard-builder-head small { display: block; color: var(--text-2, #667085); margin-top: 3px; line-height: 1.45; }
.tsh-rel-grid { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr) minmax(300px,1.1fr); gap: 12px; }
.tsh-rel-column {
    min-width: 0;
    border: 1px solid var(--line-1, var(--tsh-border, #dbe3ef));
    border-radius: 10px;
    background: var(--surface-2, #f8fafc);
    padding: 10px;
}
.tsh-rel-column h4,
.tsh-dashboard-palette h4 {
    margin: 0 0 9px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--text-3, #7b8798);
}
.tsh-rel-list { display: grid; gap: 7px; max-height: 380px; overflow: auto; padding-right: 2px; scrollbar-width: thin; }
.tsh-rel-node {
    display: grid;
    grid-template-columns: 24px minmax(0,1fr);
    gap: 3px 9px;
    width: 100%;
    text-align: left;
    align-items: center;
    border: 1px solid var(--line-1, #dbe3ef);
    border-radius: 9px;
    background: #fff;
    color: var(--text-1, #172033);
    padding: 9px 10px;
    cursor: grab;
    box-shadow: 0 1px 2px rgba(15,23,42,.03);
}
.tsh-rel-node:active { cursor: grabbing; }
.tsh-rel-node:hover,
.tsh-rel-node:focus-visible {
    border-color: var(--brand, #2563eb);
    background: var(--ah-blue-weak, #eef4ff);
    outline: none;
    box-shadow: 0 0 0 3px var(--ah-blue-ring, rgba(37,99,235,.16));
}
.tsh-rel-node span { grid-row: 1/3; display: grid; place-items: center; }
.tsh-rel-node .btn-ico { width: 18px; height: 18px; }
.tsh-rel-node strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.tsh-rel-node small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2, #667085); font-size: 11px; }
.tsh-rel-column.drop-target { outline: 1px dashed transparent; outline-offset: 3px; }
.tsh-relationship-board.is-dragging .drop-target { outline-color: var(--brand, #2563eb); background: #f0f6ff; }
.tsh-rel-edge {
    display: grid;
    grid-template-columns: minmax(0,1fr) 22px minmax(0,1fr) 34px;
    gap: 8px;
    align-items: center;
    border: 1px solid var(--line-1, #dbe3ef);
    border-radius: 9px;
    background: #fff;
    padding: 8px;
    margin-bottom: 7px;
    box-shadow: 0 1px 2px rgba(15,23,42,.03);
}
.tsh-rel-edge strong,
.tsh-rel-edge small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tsh-rel-edge small { color: var(--text-2, #667085); font-size: 11px; }
.tsh-rel-arrow { text-align: center; color: var(--text-3, #7b8798); }
.tsh-rel-empty {
    border: 1px dashed var(--line-2, #cbd5e1);
    border-radius: 9px;
    padding: 14px;
    color: var(--text-2, #667085);
    font-size: 13px;
    background: #fff;
}
.tsh-dashboard-grid { display: grid; grid-template-columns: repeat(12,minmax(0,1fr)); gap: 10px; margin-bottom: 14px; }
.tsh-dashboard-palette { border-top: 1px solid var(--line-1, #dbe3ef); padding-top: 12px; }
.tsh-dashboard-palette > div { display: grid; grid-template-columns: repeat(auto-fit,minmax(240px,1fr)); gap: 10px; }
.tsh-dashboard-widget {
    grid-column: span 4;
    min-width: 0;
    border: 1px solid var(--line-1, #dbe3ef);
    border-radius: 10px;
    background: #fff;
    padding: 11px;
    cursor: grab;
    box-shadow: 0 1px 2px rgba(15,23,42,.03);
}
.tsh-dashboard-widget:hover { border-color: #b8c6dc; box-shadow: var(--shadow-xs, 0 2px 8px rgba(15,23,42,.08)); }
.tsh-dashboard-widget:active { cursor: grabbing; }
.tsh-dashboard-widget.is-hidden { opacity: .72; background: #f8fafc; }
.tsh-widget-title { display: flex; align-items: center; gap: 10px; }
.tsh-widget-title span { min-width: 0; }
.tsh-widget-title strong,
.tsh-widget-title small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tsh-widget-title strong { color: var(--text-1, #172033); font-size: 13px; }
.tsh-widget-title small { color: var(--text-2, #667085); font-size: 11px; margin-top: 2px; }
.tsh-widget-grip { float: right; color: var(--text-3, #7b8798); font-weight: 700; letter-spacing: -2px; }
.tsh-widget-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 11px; }
.tsh-widget-controls label { display: flex; align-items: center; gap: 5px; color: var(--text-2, #667085); font-size: 12px; }
.tsh-widget-controls input { width: 64px; }
.tsh-dashboard-builder.is-dragging .tsh-dashboard-grid,
.tsh-dashboard-builder.is-dragging [data-dashboard-hidden] { outline: 1px dashed var(--brand, #2563eb); outline-offset: 4px; border-radius: 10px; }
.tsh-widget-span-2 { grid-column: span 2; }
.tsh-widget-span-3 { grid-column: span 3; }
.tsh-widget-span-4 { grid-column: span 4; }
.tsh-widget-span-5 { grid-column: span 5; }
.tsh-widget-span-6 { grid-column: span 6; }
.tsh-widget-span-7 { grid-column: span 7; }
.tsh-widget-span-8 { grid-column: span 8; }
.tsh-widget-span-9 { grid-column: span 9; }
.tsh-widget-span-10 { grid-column: span 10; }
.tsh-widget-span-11 { grid-column: span 11; }
.tsh-widget-span-12 { grid-column: span 12; }
@media (max-width:1100px) {
    .tsh-rel-grid { grid-template-columns: 1fr; }
    .tsh-dashboard-grid { grid-template-columns: 1fr; }
    .tsh-dashboard-widget { grid-column: auto; }
}

/* Iter2 Hotfix 3 — full-height relationship board and optimistic transitions. */
.tsh-relationship-board {
    display: flex;
    flex-direction: column;
    min-height: min(680px, calc(100vh - 230px));
}
.tsh-rel-grid {
    flex: 1 1 auto;
    min-height: 0;
    align-items: stretch;
}
.tsh-rel-column {
    display: flex;
    flex-direction: column;
    min-height: 420px;
}
.tsh-rel-column > .tsh-rel-list,
.tsh-rel-edge-list {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    overflow: auto;
}
.tsh-rel-node,
.tsh-rel-edge {
    transition: transform 160ms cubic-bezier(.16,1,.3,1), opacity 160ms ease, border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}
.tsh-rel-node.is-drag-source { opacity: .62; transform: scale(.985); }
.tsh-rel-node.is-drag-over {
    border-color: var(--brand, #2563eb);
    background: var(--brand-weak, #eef4ff);
    box-shadow: 0 0 0 3px var(--brand-line, rgba(37,99,235,.16));
}
.tsh-rel-edge.is-new { animation: tshRelSlideIn 210ms cubic-bezier(.16,1,.3,1) both; }
.tsh-rel-edge.is-pending { opacity: .72; filter: saturate(.9); }
.tsh-rel-edge.is-saved { border-color: rgba(22,163,74,.42); }
.tsh-rel-edge.is-removing,
.tsh-rel-edge.is-reverting { opacity: 0; transform: translateX(12px) scale(.985); }
@keyframes tshRelSlideIn {
    from { opacity: 0; transform: translateY(-8px) scale(.985); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
@media (max-width:1100px) {
    .tsh-relationship-board { min-height: auto; }
    .tsh-rel-column { min-height: 280px; }
}

/* Iteration 5.4 — checkbox relationship board, no stretched source rows. */
.tsh-rel-grid.checkbox-mode { grid-template-columns: minmax(260px, .75fr) minmax(360px, 1.25fr); align-items: start; }
.tsh-rel-grid.checkbox-mode .tsh-rel-column { min-height: 0; align-self: start; }
.tsh-rel-grid.checkbox-mode .tsh-rel-list { max-height: min(560px, calc(100vh - 360px)); flex: 0 1 auto; }
.tsh-rel-grid.checkbox-mode .tsh-rel-node { cursor: pointer; min-height: 52px; grid-template-columns: 26px minmax(0, 1fr); align-content: center; }
.tsh-rel-grid.checkbox-mode .tsh-rel-node strong { white-space: normal; line-height: 1.25; }
.tsh-rel-grid.checkbox-mode .tsh-rel-node small { white-space: normal; line-height: 1.25; }
.tsh-rel-check-row { grid-template-columns: 22px 26px minmax(0, 1fr) !important; position: relative; }
.tsh-rel-check-row input[type="checkbox"] { width: 18px; height: 18px; margin: 0; accent-color: var(--brand, #2563eb); }
.tsh-rel-check-row span { grid-row: 1/3; grid-column: 2; }
.tsh-rel-check-row strong { grid-column: 3; }
.tsh-rel-check-row small { grid-column: 3; }
.tsh-rel-check-row.is-assigned { border-color: rgba(22,163,74,.36); background: rgba(240,253,244,.8); }
.tsh-rel-check-row.is-pending { opacity: .65; }
@media (max-width: 1100px) { .tsh-rel-grid.checkbox-mode { grid-template-columns: 1fr; } }

/* Iteration 5.10 — firmer checkbox assignment UX for user↔TV and group↔channel mapping. */
.tsh-rel-grid.checkbox-mode .tsh-rel-column {
    max-height: min(680px, calc(100vh - 300px));
    overflow: hidden;
}
.tsh-rel-grid.checkbox-mode .tsh-rel-list {
    min-height: 120px;
    max-height: min(560px, calc(100vh - 390px));
}
.tsh-rel-grid.checkbox-mode .tsh-rel-node {
    height: auto;
    min-height: 54px;
    align-items: center;
}
.tsh-rel-grid.checkbox-mode .tsh-rel-node.is-active {
    border-color: var(--brand, #2563eb);
    box-shadow: 0 0 0 3px var(--brand-line, rgba(37,99,235,.16));
    background: var(--brand-weak, #eef4ff);
}
.tsh-rel-check-row input[type="checkbox"] {
    border-radius: 6px;
    cursor: pointer;
}
.tsh-rel-check-row strong,
.tsh-rel-check-row small {
    overflow-wrap: anywhere;
}
