.tb-overlay-backdrop {
    position: fixed;
    inset: 0;
    z-index: 9000;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(2px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.tb-overlay-backdrop.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.tb-dialog {
    position: fixed;
    z-index: 9010;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.tb-dialog.is-open {
    opacity: 1;
    pointer-events: auto;
}

.tb-dialog-panel {
    width: 100%;
    max-width: 32rem;
    max-height: 90vh;
    background: var(--admin-overlay-bg, #fff);
    border-radius: 1rem;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    transform: scale(0.96) translateY(8px);
    transition: transform 0.2s ease;
    color: var(--admin-text, #0f172a);
}

.tb-dialog.is-open .tb-dialog-panel {
    transform: scale(1) translateY(0);
}

.tb-dialog-panel.tb-dialog-lg {
    max-width: 42rem;
}

.tb-drawer {
    position: fixed;
    z-index: 9010;
    inset: 0;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.tb-drawer.is-open {
    opacity: 1;
    pointer-events: auto;
}

.tb-drawer-panel {
    position: absolute;
    top: 0;
    bottom: 0;
    right: 0;
    width: min(100%, 42rem);
    background: var(--admin-overlay-bg, #fff);
    box-shadow: -8px 0 30px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.25s ease;
    color: var(--admin-text, #0f172a);
}

.tb-drawer.is-open .tb-drawer-panel {
    transform: translateX(0);
}

.tb-popover {
    position: fixed;
    z-index: 9020;
    width: min(20rem, calc(100vw - 2rem));
    background: var(--admin-popover-bg, #fff);
    border: 1px solid var(--admin-popover-border, #e5e7eb);
    border-radius: 0.75rem;
    box-shadow: var(--admin-popover-shadow, 0 12px 28px rgba(0, 0, 0, 0.12));
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 0.15s ease, transform 0.15s ease;
    pointer-events: none;
    color: var(--admin-text, #0f172a);
}

.tb-popover.is-open {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.tb-row-actions {
    display: inline-flex;
    justify-content: flex-end;
}

/* Rows with "..." actions support right-click context menu */
table tbody tr:has(.tb-row-actions) {
    cursor: context-menu;
}

table tbody tr:has(.tb-row-actions) a,
table tbody tr:has(.tb-row-actions) button,
table tbody tr:has(.tb-row-actions) input,
table tbody tr:has(.tb-row-actions) select,
table tbody tr:has(.tb-row-actions) textarea {
    cursor: pointer;
}

.tb-row-menu-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 0.5rem;
    border: 1px solid var(--admin-border, #e5e7eb);
    background: var(--admin-surface, #fff);
    color: var(--admin-muted, #6b7280);
    cursor: pointer;
    padding: 0;
    transition: color 0.15s, background 0.15s, border-color 0.15s;
}

.tb-row-menu-btn:hover,
.tb-row-menu-btn[data-tb-popover-open="true"] {
    color: var(--admin-accent, #6d28d9);
    background: var(--admin-accent-soft, #f5f3ff);
    border-color: var(--admin-border, #ddd6fe);
}

.tb-row-menu-list {
    list-style: none;
    margin: 0;
    padding: 0.35rem 0;
    min-width: 9rem;
}

.tb-row-menu-list a,
.tb-row-menu-list button {
    display: block;
    width: 100%;
    text-align: right;
    padding: 0.55rem 1rem;
    font-size: 0.8125rem;
    color: var(--admin-text, #374151);
    text-decoration: none;
    border: none;
    background: transparent;
    cursor: pointer;
}

.tb-row-menu-list a:hover,
.tb-row-menu-list button:hover,
.tb-row-menu-list form button:hover {
    background: var(--admin-table-row-hover, #f9fafb);
    color: var(--admin-accent, #6d28d9);
}

.tb-row-menu-list form {
    margin: 0;
}

.tb-row-menu-list form button {
    width: 100%;
    text-align: right;
    padding: 0.55rem 1rem;
    font-size: 0.8125rem;
    color: var(--admin-text, #374151);
    border: none;
    background: transparent;
    cursor: pointer;
}

.tb-row-menu-list .is-danger {
    color: var(--admin-danger-text, #dc2626);
}

.tb-row-menu-list .is-danger:hover {
    background: var(--admin-danger-bg, #fef2f2);
    color: var(--admin-danger-text, #b91c1c);
}

.tb-overlay-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--admin-border, #f3f4f6);
    flex-shrink: 0;
}

.tb-overlay-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--admin-text, #1f2937);
    min-width: 0;
    flex: 1 1 auto;
}

.tb-overlay-header-end {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.tb-overlay-header-actions {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.tb-overlay-header-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 2rem;
    padding: 0 0.75rem;
    border-radius: 0.5rem;
    border: 1px solid var(--admin-border, #e5e7eb);
    background: var(--admin-surface, #fff);
    color: var(--admin-brand, #4f46e5);
    font-size: 0.8125rem;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.tb-overlay-header-btn:hover {
    background: var(--admin-surface-muted, #f3f4f6);
    border-color: var(--admin-brand, #4f46e5);
}

.tb-overlay-close {
    width: 2rem;
    height: 2rem;
    border-radius: 0.5rem;
    border: none;
    background: var(--admin-surface-muted, #f3f4f6);
    color: var(--admin-muted, #6b7280);
    cursor: pointer;
    font-size: 1.25rem;
    line-height: 1;
    transition: background 0.15s;
}

.tb-overlay-close:hover {
    background: var(--admin-surface-variant, #e5e7eb);
    color: var(--admin-text, #374151);
}

.tb-overlay-body {
    padding: 1.25rem;
    overflow-y: auto;
    flex: 1;
}

.tb-overlay-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: var(--admin-muted, #6b7280);
    gap: 0.5rem;
}

/* Confirm dialog — replaces window.confirm() */
.tb-confirm-dialog {
    position: fixed;
    z-index: 9020;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.tb-confirm-dialog.is-open {
    opacity: 1;
    pointer-events: auto;
}

.tb-confirm-backdrop.is-open {
    z-index: 9015;
}

.tb-confirm-dialog__panel {
    width: 100%;
    max-width: 24rem;
    background: var(--admin-overlay-bg, #fff);
    border-radius: 1rem;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.22);
    padding: 1.5rem;
    text-align: center;
    transform: scale(0.96) translateY(8px);
    transition: transform 0.2s ease;
    color: var(--admin-text, #0f172a);
}

.tb-confirm-dialog.is-open .tb-confirm-dialog__panel {
    transform: scale(1) translateY(0);
}

.tb-confirm-dialog__icon {
    width: 3rem;
    height: 3rem;
    margin: 0 auto 1rem;
    border-radius: 9999px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    font-weight: 700;
    background: var(--admin-primary-soft, #f0f9ff);
    color: var(--admin-primary, #0369a1);
}

.tb-confirm-dialog__panel[data-variant="danger"] .tb-confirm-dialog__icon {
    background: #fef2f2;
    color: #dc2626;
}

.tb-confirm-dialog__title {
    font-size: 1.125rem;
    font-weight: 700;
    margin: 0 0 0.5rem;
    color: var(--admin-text, #0f172a);
}

.tb-confirm-dialog__message {
    font-size: 0.875rem;
    line-height: 1.6;
    color: var(--admin-muted, #64748b);
    margin: 0 0 1.25rem;
}

.tb-confirm-dialog__actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
}

.tb-confirm-dialog__btn {
    flex: 1;
    min-height: 2.75rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background 0.15s ease, color 0.15s ease;
}

.tb-confirm-dialog__btn--cancel {
    background: #fff;
    border-color: var(--admin-border, #e2e8f0);
    color: var(--admin-text, #334155);
}

.tb-confirm-dialog__btn--cancel:hover {
    background: var(--admin-surface-variant, #f8fafc);
}

.tb-confirm-dialog__btn--confirm {
    background: var(--admin-primary, #0369a1);
    color: #fff;
}

.tb-confirm-dialog__btn--confirm:hover {
    filter: brightness(1.05);
}

.tb-confirm-dialog__btn--danger {
    background: #dc2626;
}

.tb-confirm-dialog__btn--danger:hover {
    background: #b91c1c;
}

[data-theme="dark"] .tb-confirm-dialog__panel {
    background: var(--admin-overlay-bg, #1e293b);
    color: var(--admin-text, #f1f5f9);
}

[data-theme="dark"] .tb-confirm-dialog__title {
    color: var(--admin-text, #f1f5f9);
}

[data-theme="dark"] .tb-confirm-dialog__message {
    color: var(--admin-muted, #94a3b8);
}

[data-theme="dark"] .tb-confirm-dialog__btn--cancel {
    background: var(--admin-surface-variant, #334155);
    border-color: var(--admin-border, #475569);
    color: var(--admin-text, #f1f5f9);
}

[data-theme="dark"] .tb-confirm-dialog__panel[data-variant="danger"] .tb-confirm-dialog__icon {
    background: rgba(220, 38, 38, 0.15);
    color: #f87171;
}

[data-theme="dark"] .tb-confirm-dialog__panel:not([data-variant="danger"]) .tb-confirm-dialog__icon {
    background: rgba(56, 189, 248, 0.12);
    color: #38bdf8;
}

/* Stored file preview */
.tb-file-preview {
    border: 1px solid var(--admin-border, #e2e8f0);
    border-radius: 0.75rem;
    overflow: hidden;
    background: var(--admin-surface, #fff);
    max-width: 18rem;
}

.tb-file-preview__frame {
    position: relative;
    aspect-ratio: 4 / 3;
    background: #f8fafc;
}

.tb-file-preview__image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.tb-file-preview__placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    color: #64748b;
}

.tb-file-preview__placeholder--pdf {
    background: linear-gradient(135deg, #fee2e2, #fecaca);
    color: #b91c1c;
}

.tb-file-preview__icon {
    font-size: 1.25rem;
    font-weight: 700;
}

.tb-file-preview__zoom {
    position: absolute;
    inset: auto 0.5rem 0.5rem auto;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.35rem 0.65rem;
    border: none;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.75);
    color: #fff;
    font-size: 0.75rem;
    cursor: pointer;
    transition: background 0.15s ease;
}

.tb-file-preview__zoom:hover {
    background: rgba(15, 23, 42, 0.9);
}

.tb-file-preview__meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.65rem 0.75rem;
    font-size: 0.8125rem;
}

.tb-file-preview__title {
    font-weight: 600;
    color: var(--admin-text, #1e293b);
}

.tb-file-preview__download {
    color: var(--brand-600, #0284c7);
    text-decoration: none;
    white-space: nowrap;
}

.tb-file-preview__download:hover {
    text-decoration: underline;
}

.tb-file-lightbox {
    position: fixed;
    inset: 0;
    z-index: 9100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.tb-file-lightbox.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.tb-file-lightbox__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.72);
    backdrop-filter: blur(2px);
}

.tb-file-lightbox__panel {
    position: relative;
    width: min(56rem, 100%);
    max-height: 92vh;
    display: flex;
    flex-direction: column;
    background: var(--admin-surface, #fff);
    border-radius: 0.875rem;
    overflow: hidden;
    box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.35);
}

.tb-file-lightbox__toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--admin-border, #e2e8f0);
    background: var(--admin-surface-variant, #f8fafc);
}

.tb-file-lightbox__title {
    font-size: 0.9375rem;
    color: var(--admin-text, #1e293b);
}

.tb-file-lightbox__actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.tb-file-lightbox__download {
    font-size: 0.8125rem;
    color: var(--brand-600, #0284c7);
    text-decoration: none;
}

.tb-file-lightbox__close {
    width: 2rem;
    height: 2rem;
    border: none;
    border-radius: 999px;
    background: transparent;
    color: #64748b;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
}

.tb-file-lightbox__close:hover {
    background: rgba(100, 116, 139, 0.12);
}

.tb-file-lightbox__body {
    flex: 1;
    min-height: 12rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #0f172a;
    overflow: auto;
}

.tb-file-lightbox__image {
    max-width: 100%;
    max-height: calc(92vh - 4rem);
    object-fit: contain;
}

.tb-file-lightbox__iframe {
    width: 100%;
    height: calc(92vh - 4rem);
    border: none;
    background: #fff;
}

.tb-file-lightbox__loading,
.tb-file-lightbox__error {
    color: #e2e8f0;
    padding: 2rem;
    text-align: center;
    font-size: 0.875rem;
}

.tb-file-lightbox__error a {
    color: #38bdf8;
}

[data-theme="dark"] .tb-file-preview {
    background: var(--admin-surface, #1e293b);
    border-color: var(--admin-border, #475569);
}

[data-theme="dark"] .tb-file-preview__frame {
    background: #0f172a;
}

[data-theme="dark"] .tb-file-lightbox__panel {
    background: var(--admin-surface, #1e293b);
}

[data-theme="dark"] .tb-file-lightbox__toolbar {
    background: var(--admin-surface-variant, #334155);
    border-color: var(--admin-border, #475569);
}
