/**
 * Taleclip Admin Directory Browser
 * Active Directory-style split-panel user browser
 *
 * Glassmorphic Design System (variables from style.css):
 *   --tc-glass-bg           card/panel backgrounds
 *   --tc-glass-bg-hover     hover states
 *   --tc-glass-bg-active    active/selected states
 *   --tc-glass-bg-input     input fields
 *   --tc-glass-bg-sidebar   sidebars
 *   --tc-glass-bg-topbar    top bars
 *   --tc-glass-blur/blur-heavy/blur-light  backdrop blur
 *   --tc-glass-border       standard borders
 *   --tc-glass-border-hover/focus/subtle   border variants
 *   --tc-radius-sm/md/lg/xl               border radii
 *   --tc-shadow-sm/md/lg/2xl              box shadows
 *
 * Accent/Status Colors (preserved):
 *   #7c3aed  accent/purple
 *   #22c55e  success/green
 *   #ef4444  error/red
 *   #f59e0b  warning/amber
 *   #3b82f6  info/blue
 */


/* ============================================================
   1. SPLIT PANEL LAYOUT
   ============================================================ */

.dir-split-panel {
    display: flex;
    flex-direction: row;
    height: calc(100vh - 345px);
    min-height: 400px;
    border: var(--tc-glass-border);
    border-radius: var(--tc-radius-lg);
    overflow: hidden;
    background: var(--tc-glass-bg);
    backdrop-filter: blur(var(--tc-glass-blur));
    -webkit-backdrop-filter: blur(var(--tc-glass-blur));
}


/* ============================================================
   2. TREE PANEL
   ============================================================ */

.dir-tree-panel {
    display: flex;
    flex-direction: column;
    width: 320px;
    min-width: 260px;
    max-width: 400px;
    background: var(--tc-glass-bg-sidebar);
    backdrop-filter: blur(var(--tc-glass-blur));
    -webkit-backdrop-filter: blur(var(--tc-glass-blur));
    border-right: var(--tc-glass-border);
    resize: horizontal;
    overflow: hidden;
    flex-shrink: 0;
}


/* ============================================================
   3. TREE HEADER
   ============================================================ */

.dir-tree-header {
    padding: 1rem;
    border-bottom: var(--tc-glass-border);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    flex-shrink: 0;
}

.dir-domain-badge {
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Mono', monospace;
    font-size: 0.8rem;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(135deg, #7c3aed, #a855f7);
    padding: 0.375rem 0.75rem;
    border-radius: var(--tc-radius-sm);
    text-align: center;
    letter-spacing: 0.02em;
}

.dir-tree-search {
    width: 100%;
    padding: 0.625rem 0.75rem;
    background: var(--tc-glass-bg-input);
    border: var(--tc-glass-border);
    border-radius: var(--tc-radius-sm);
    color: #e2e8f0;
    font-size: 0.875rem;
}

.dir-tree-search::placeholder {
    color: #64748b;
}

.dir-tree-search:focus {
    outline: none;
    border: var(--tc-glass-border-focus);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}


/* ============================================================
   4. TREE CONTAINER (scrollable area)
   ============================================================ */

.dir-tree-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.5rem 0;
    min-height: 0;
    scrollbar-gutter: stable;
}


/* ============================================================
   5. TREE NODES
   ============================================================ */

.dir-tree-node {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.75rem;
    cursor: pointer;
    color: #e2e8f0;
    font-size: 0.875rem;
    transition: background 0.15s ease, color 0.15s ease;
    user-select: none;
    white-space: nowrap;
}

.dir-tree-node:hover {
    background: var(--tc-glass-bg-hover);
}

.dir-tree-node.selected {
    background: var(--tc-glass-bg-active);
    color: #f1f5f9;
}

/* Node type variations */
.dir-tree-root {
    font-weight: 700;
    color: #f1f5f9;
    font-size: 0.9rem;
}

.dir-tree-ou {
    font-weight: 600;
    color: #e2e8f0;
}

.dir-tree-user {
    font-weight: 400;
    color: #94a3b8;
}

.dir-tree-user.selected {
    color: #f1f5f9;
}

/* Icon container */
.dir-tree-icon {
    flex-shrink: 0;
    width: 1.25rem;
    text-align: center;
    font-size: 0.875rem;
}

/* Label */
.dir-tree-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Count badge */
.dir-tree-count {
    flex-shrink: 0;
    background: var(--tc-glass-bg-hover);
    color: #94a3b8;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.1rem 0.4rem;
    border-radius: 9999px;
    min-width: 1.25rem;
    text-align: center;
}

/* Indent levels (applied via inline style or class) */
.dir-tree-indent-1 { padding-left: calc(0.75rem + 16px); }
.dir-tree-indent-2 { padding-left: calc(0.75rem + 32px); }
.dir-tree-indent-3 { padding-left: calc(0.75rem + 48px); }
.dir-tree-indent-4 { padding-left: calc(0.75rem + 64px); }
.dir-tree-indent-5 { padding-left: calc(0.75rem + 80px); }


/* ============================================================
   6. TREE TOGGLE (expand / collapse indicator)
   ============================================================ */

.dir-tree-toggle {
    flex-shrink: 0;
    width: 1rem;
    height: 1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
    color: #64748b;
    transition: transform 0.2s ease;
    transform: rotate(0deg);
}

.dir-tree-toggle.expanded {
    transform: rotate(90deg);
}

/* Placeholder for leaf nodes (no toggle arrow) */
.dir-tree-toggle-placeholder {
    width: 1rem;
    flex-shrink: 0;
}


/* ============================================================
   7. TREE CHILDREN (collapsible groups)
   ============================================================ */

.dir-tree-children {
    overflow: hidden;
    transition: max-height 0.25s ease;
    padding-left: 16px;
}

.dir-tree-children.collapsed {
    max-height: 0 !important;
}


/* ============================================================
   8. TREE FOOTER
   ============================================================ */

.dir-tree-footer {
    padding: 0.625rem 1rem;
    border-top: var(--tc-glass-border);
    color: #64748b;
    font-size: 0.75rem;
    flex-shrink: 0;
    line-height: 1.5;
}

.dir-tree-footer span {
    display: block;
}


/* ============================================================
   9. DETAIL PANEL
   ============================================================ */

.dir-detail-panel {
    flex: 2;
    background: var(--tc-glass-bg);
    backdrop-filter: blur(var(--tc-glass-blur-light));
    -webkit-backdrop-filter: blur(var(--tc-glass-blur-light));
    overflow-y: auto;
    padding: 1.5rem;
    min-width: 0;
}


/* ============================================================
   10. DETAIL EMPTY STATE
   ============================================================ */

.dir-detail-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 1rem;
    text-align: center;
}

.dir-detail-empty-icon {
    font-size: 3rem;
    opacity: 0.4;
    color: #94a3b8;
}

.dir-detail-empty-text {
    color: #94a3b8;
    font-size: 1rem;
    font-weight: 500;
}

.dir-detail-empty-hint {
    color: #64748b;
    font-size: 0.85rem;
}


/* ============================================================
   11. DETAIL HEADER
   ============================================================ */

.dir-detail-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1.25rem;
    border-bottom: var(--tc-glass-border);
}

.dir-detail-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #7c3aed, #a855f7);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    flex-shrink: 0;
}

.dir-detail-identity {
    flex: 1;
    min-width: 0;
}

.dir-detail-name {
    font-size: 1.5rem;
    font-weight: 700;
    color: #f1f5f9;
    margin: 0;
    line-height: 1.3;
}

.dir-detail-email {
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Mono', monospace;
    font-size: 0.85rem;
    color: #94a3b8;
    margin-top: 0.125rem;
    word-break: break-all;
}

.dir-detail-status {
    flex-shrink: 0;
}


/* ============================================================
   12. SUB-TABS (within the detail panel)
   ============================================================ */

.dir-sub-tabs {
    display: flex;
    flex-direction: row;
    gap: 0.25rem;
    border-bottom: var(--tc-glass-border);
    margin-bottom: 1.25rem;
}

.dir-sub-tab {
    background: transparent;
    border: none;
    color: #94a3b8;
    font-size: 0.875rem;
    padding: 0.625rem 1rem;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: color 0.15s ease, border-color 0.15s ease;
    white-space: nowrap;
}

.dir-sub-tab:hover {
    color: #e2e8f0;
}

.dir-sub-tab.active {
    color: #7c3aed;
    border-bottom-color: #7c3aed;
    font-weight: 600;
}


/* ============================================================
   13. SUB-PANELS
   ============================================================ */

.dir-sub-panel {
    display: none;
}

.dir-sub-panel.active {
    display: block;
}


/* ============================================================
   14. OVERVIEW PROPERTIES GRID
   ============================================================ */

.dir-props-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.dir-prop {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.dir-prop-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.dir-prop-value {
    font-size: 0.9rem;
    color: #e2e8f0;
    word-break: break-word;
}


/* ============================================================
   15. STORAGE BARS
   ============================================================ */

.dir-storage-section {
    margin-bottom: 1.5rem;
}

.dir-storage-section h3 {
    font-size: 0.8rem;
    font-weight: 600;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin: 0 0 0.75rem 0;
}

.dir-storage-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.625rem;
}

.dir-storage-label {
    font-size: 0.85rem;
    color: #e2e8f0;
    min-width: 80px;
    flex-shrink: 0;
}

.dir-storage-bar {
    flex: 1;
    height: 8px;
    background: var(--tc-glass-bg-hover);
    border-radius: 4px;
    overflow: hidden;
}

.dir-storage-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.4s ease;
}

.dir-storage-bar-fill.uploads {
    background: #3b82f6;
}

.dir-storage-bar-fill.outputs {
    background: #22c55e;
}

.dir-storage-bar-fill.enhanced {
    background: #f59e0b;
}

.dir-storage-size {
    font-size: 0.8rem;
    color: #94a3b8;
    min-width: 60px;
    text-align: right;
    flex-shrink: 0;
}

/* ============================================================
   16. FILES TABLE
   ============================================================ */

.dir-files-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1.5rem;
}

.dir-files-table thead {
    position: sticky;
    top: 0;
    z-index: 1;
}

.dir-files-table th {
    background: var(--tc-glass-bg);
    backdrop-filter: blur(var(--tc-glass-blur-light));
    -webkit-backdrop-filter: blur(var(--tc-glass-blur-light));
    color: #94a3b8;
    font-weight: 600;
    text-align: left;
    padding: 0.75rem 1rem;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: var(--tc-glass-border);
}

.dir-files-table td {
    padding: 0.625rem 1rem;
    border-bottom: var(--tc-glass-border-subtle);
    color: #e2e8f0;
    font-size: 0.875rem;
}

.dir-files-table tbody tr:nth-child(even) {
    background: var(--tc-glass-bg);
}

.dir-files-table tbody tr:hover {
    background: var(--tc-glass-bg-hover);
}

.dir-files-table .col-size {
    text-align: right;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Mono', monospace;
    font-size: 0.8rem;
    color: #94a3b8;
}

.dir-files-table .col-status {
    text-align: center;
}

.dir-files-table .has-output {
    color: #22c55e;
}

.dir-files-table .no-output {
    color: #64748b;
}


/* ============================================================
   17. PROMPT CARDS
   ============================================================ */

.dir-prompt-card {
    background: var(--tc-glass-bg);
    backdrop-filter: blur(var(--tc-glass-blur));
    -webkit-backdrop-filter: blur(var(--tc-glass-blur));
    border: var(--tc-glass-border);
    border-radius: var(--tc-radius-md);
    padding: 1rem;
    margin-bottom: 0.75rem;
}

.dir-prompt-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 0.5rem;
}

.dir-prompt-type {
    background: var(--tc-glass-bg-hover);
    color: #e2e8f0;
    padding: 0.125rem 0.5rem;
    border-radius: var(--tc-radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.dir-prompt-time {
    color: #64748b;
    font-size: 0.8rem;
    margin-left: auto;
}

.dir-prompt-reveal {
    background: none;
    border: none;
    color: #7c3aed;
    font-size: 0.85rem;
    cursor: pointer;
    padding: 0.25rem 0;
    transition: color 0.15s ease;
}

.dir-prompt-reveal:hover {
    color: #a78bfa;
}

.dir-prompt-text {
    display: none;
    margin-top: 0.625rem;
    padding: 0.75rem;
    background: var(--tc-glass-bg-input);
    border: var(--tc-glass-border);
    border-radius: var(--tc-radius-sm);
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Mono', monospace;
    font-size: 0.825rem;
    color: #e2e8f0;
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.6;
    max-height: 300px;
    overflow-y: auto;
}

.dir-prompt-text.revealed {
    display: block;
}


/* ============================================================
   18. ACTIVITY TIMELINE
   ============================================================ */

.dir-activity-timeline {
    position: relative;
    padding-left: 1.75rem;
    margin-bottom: 1.5rem;
}

/* Vertical line */
.dir-activity-timeline::before {
    content: '';
    position: absolute;
    left: 0.5rem;
    top: 0;
    bottom: 0;
    width: 2px;
    background: rgba(148,163,184,0.08);
}

.dir-activity-event {
    position: relative;
    padding: 0.75rem 0;
}

/* Dot on the line */
.dir-activity-event::before {
    content: '';
    position: absolute;
    left: -1.5rem;
    top: 1rem;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(148,163,184,0.15);
    border: 2px solid rgba(255,255,255,0.06);
    z-index: 1;
}

/* Dot colors by status */
.dir-activity-event.completed::before {
    background: #22c55e;
}

.dir-activity-event.failed::before {
    background: #ef4444;
}

.dir-activity-event.processing::before {
    background: #3b82f6;
}

.dir-activity-event.pending::before {
    background: #f59e0b;
}

.dir-activity-event-content {
    background: var(--tc-glass-bg);
    backdrop-filter: blur(var(--tc-glass-blur));
    -webkit-backdrop-filter: blur(var(--tc-glass-blur));
    border: var(--tc-glass-border);
    border-radius: var(--tc-radius-md);
    padding: 0.75rem 1rem;
}

.dir-activity-event-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.375rem;
    flex-wrap: wrap;
}

.dir-activity-event-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: #e2e8f0;
}

.dir-activity-event-time {
    color: #64748b;
    font-size: 0.75rem;
    margin-left: auto;
}

.dir-activity-event-body {
    font-size: 0.825rem;
    color: #94a3b8;
    line-height: 1.5;
}


/* ============================================================
   19. BADGES & TAGS
   ============================================================ */

.dir-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 9999px;
    font-size: 0.7rem;
    font-weight: 600;
    white-space: nowrap;
    vertical-align: middle;
}

/* Role badges */
.dir-badge-admin {
    background: rgba(124, 58, 237, 0.25);
    color: #a78bfa;
}

/* Status badges */
.dir-badge-active {
    background: rgba(34, 197, 94, 0.2);
    color: #22c55e;
}

.dir-badge-inactive {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

/* Tier badges */
.dir-badge-tier-0 {
    background: rgba(100, 116, 139, 0.2);
    color: #94a3b8;
}

.dir-badge-tier-1 {
    background: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
}

.dir-badge-tier-2 {
    background: rgba(124, 58, 237, 0.2);
    color: #a78bfa;
}

.dir-badge-tier-3 {
    background: rgba(245, 158, 11, 0.2);
    color: #f59e0b;
}

/* Job status badges */
.dir-badge-status-completed {
    background: rgba(34, 197, 94, 0.2);
    color: #22c55e;
}

.dir-badge-status-failed {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.dir-badge-status-pending {
    background: rgba(245, 158, 11, 0.2);
    color: #f59e0b;
}

.dir-badge-status-processing {
    background: rgba(59, 130, 246, 0.2);
    color: #3b82f6;
}


/* ============================================================
   20. SEARCH WITHIN PROMPTS
   ============================================================ */

.dir-prompt-search {
    width: 100%;
    padding: 0.625rem 0.75rem;
    background: var(--tc-glass-bg-input);
    border: var(--tc-glass-border);
    border-radius: var(--tc-radius-sm);
    color: #e2e8f0;
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.dir-prompt-search::placeholder {
    color: #64748b;
}

.dir-prompt-search:focus {
    outline: none;
    border: var(--tc-glass-border-focus);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}


/* ============================================================
   21. SCROLLBAR STYLING (tree panel)
   ============================================================ */

/* Tree panel scrollbar — always visible, high contrast */
.dir-tree-container::-webkit-scrollbar {
    width: 10px;
    background: #0f172a;
}

.dir-tree-container::-webkit-scrollbar-track {
    background: #0f172a;
    border-radius: 5px;
}

.dir-tree-container::-webkit-scrollbar-thumb {
    background: #7c3aed;
    border-radius: 5px;
    border: 2px solid #0f172a;
}

.dir-tree-container::-webkit-scrollbar-thumb:hover {
    background: #a78bfa;
}

/* Firefox scrollbar */
.dir-tree-container {
    scrollbar-width: auto;
    scrollbar-color: #7c3aed #0f172a;
}

/* Detail panel scrollbar */
.dir-detail-panel::-webkit-scrollbar {
    width: 6px;
}

.dir-detail-panel::-webkit-scrollbar-track {
    background: transparent;
}

.dir-detail-panel::-webkit-scrollbar-thumb {
    background: #334155;
    border-radius: 3px;
}

.dir-detail-panel::-webkit-scrollbar-thumb:hover {
    background: #475569;
}

.dir-detail-panel {
    scrollbar-width: thin;
    scrollbar-color: #334155 transparent;
}

/* Prompt text scrollbar */
.dir-prompt-text::-webkit-scrollbar {
    width: 5px;
}

.dir-prompt-text::-webkit-scrollbar-track {
    background: transparent;
}

.dir-prompt-text::-webkit-scrollbar-thumb {
    background: #334155;
    border-radius: 3px;
}

.dir-prompt-text {
    scrollbar-width: thin;
    scrollbar-color: #334155 transparent;
}


/* ============================================================
   22. CONTEXT MENU
   ============================================================ */

.dir-context-menu {
    position: fixed;
    z-index: 10000;
    background: var(--tc-glass-bg);
    backdrop-filter: blur(var(--tc-glass-blur-heavy));
    -webkit-backdrop-filter: blur(var(--tc-glass-blur-heavy));
    border: var(--tc-glass-border);
    border-radius: var(--tc-radius-md);
    box-shadow: var(--tc-shadow-2xl);
    min-width: 180px;
    padding: 0.375rem 0;
    overflow: hidden;
}

.dir-context-menu-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    color: #e2e8f0;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.12s ease;
    white-space: nowrap;
}

.dir-context-menu-item:hover {
    background: var(--tc-glass-bg-hover);
}

.dir-context-menu-item .icon {
    width: 1rem;
    text-align: center;
    flex-shrink: 0;
    font-size: 0.85rem;
}

.dir-context-menu-item.danger {
    color: #ef4444;
}

.dir-context-menu-item.danger:hover {
    background: rgba(239, 68, 68, 0.1);
}

.dir-context-menu-divider {
    height: 1px;
    background: rgba(148,163,184,0.08);
    margin: 0.25rem 0;
}


/* ============================================================
   23. LOADING STATES
   ============================================================ */

.dir-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    gap: 0.75rem;
    color: #94a3b8;
    font-size: 0.9rem;
}

.dir-loading-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid rgba(148,163,184,0.08);
    border-top-color: #7c3aed;
    border-radius: 50%;
    animation: dir-spin 0.7s linear infinite;
}

@keyframes dir-spin {
    to { transform: rotate(360deg); }
}

.dir-loading-text {
    animation: dir-pulse 1.5s ease-in-out infinite;
}

@keyframes dir-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* Skeleton placeholders */
.dir-skeleton {
    background: linear-gradient(
        90deg,
        rgba(255,255,255,0.06) 25%,
        rgba(255,255,255,0.10) 50%,
        rgba(255,255,255,0.06) 75%
    );
    background-size: 200% 100%;
    animation: dir-skeleton-shimmer 1.5s ease-in-out infinite;
    border-radius: var(--tc-radius-sm);
}

@keyframes dir-skeleton-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.dir-skeleton-line {
    height: 0.875rem;
    margin-bottom: 0.625rem;
}

.dir-skeleton-line:last-child {
    margin-bottom: 0;
}

.dir-skeleton-line.short {
    width: 60%;
}

.dir-skeleton-line.medium {
    width: 80%;
}

.dir-skeleton-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
}

.dir-skeleton-block {
    height: 4rem;
    margin-bottom: 0.75rem;
}


/* ============================================================
   24. RESPONSIVE (below 900px)
   ============================================================ */

@media (max-width: 900px) {
    .dir-split-panel {
        flex-direction: column;
        height: auto;
        min-height: 0;
    }

    .dir-tree-panel {
        width: 100% !important;
        max-width: none;
        min-width: 0;
        max-height: 300px;
        border-right: none;
        border-bottom: var(--tc-glass-border);
        resize: none;
    }

    .dir-detail-panel {
        width: 100%;
        min-height: 400px;
        padding: 1rem;
    }

    .dir-detail-header {
        flex-wrap: wrap;
    }

    .dir-props-grid {
        grid-template-columns: 1fr;
    }

    .dir-sub-tabs {
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
    }

    .dir-prompt-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .dir-prompt-time {
        margin-left: 0;
    }
}

@media (max-width: 600px) {
    .dir-detail-panel {
        padding: 0.75rem;
    }

    .dir-detail-name {
        font-size: 1.25rem;
    }

    .dir-detail-avatar {
        width: 44px;
        height: 44px;
        font-size: 1rem;
    }

    .dir-files-table th,
    .dir-files-table td {
        padding: 0.5rem 0.625rem;
        font-size: 0.8rem;
    }
}

/* ============================================================
   25. UTILITY CLASSES
   ============================================================ */

.dir-mono {
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Mono', monospace;
}

.dir-small {
    font-size: 0.8rem;
}

.dir-muted {
    color: #64748b;
}

.dir-error {
    color: #ef4444;
    padding: 1.5rem;
    text-align: center;
    font-size: 0.9rem;
}

.dir-empty-state {
    color: #64748b;
    text-align: center;
    padding: 2.5rem 1rem;
    font-size: 0.9rem;
    font-style: italic;
}

.dir-section-title {
    font-size: 1rem;
    font-weight: 700;
    color: #f1f5f9;
    margin-bottom: 1rem;
}

.dir-section-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.75rem;
}


/* ============================================================
   26. DETAIL HEADER (JS-rendered)
   ============================================================ */

.dir-detail-header-inner {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.dir-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.dir-avatar-initials {
    color: #fff;
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 0.05em;
}

.dir-header-info {
    flex: 1;
    min-width: 0;
}

.dir-header-name {
    font-size: 1.5rem;
    font-weight: 700;
    color: #f1f5f9;
    line-height: 1.3;
}

.dir-header-email {
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Mono', monospace;
    font-size: 0.85rem;
    color: #94a3b8;
    margin-top: 0.125rem;
    word-break: break-all;
}

.dir-header-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    margin-top: 0.5rem;
}


/* ============================================================
   27. BADGE VARIANTS (status/role)
   ============================================================ */

.dir-badge-success {
    background: rgba(34, 197, 94, 0.2);
    color: #22c55e;
}

.dir-badge-danger {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.dir-badge-warning {
    background: rgba(245, 158, 11, 0.2);
    color: #f59e0b;
}

.dir-badge-info {
    background: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
}

.dir-badge-muted {
    background: rgba(100, 116, 139, 0.2);
    color: #94a3b8;
}

.dir-badge-credits {
    background: rgba(168, 85, 247, 0.2);
    color: #c084fc;
}


/* ============================================================
   28. OVERVIEW: STORAGE MINI BAR + CREDITS
   ============================================================ */

.dir-overview-storage {
    margin-bottom: 1.25rem;
}

.dir-overview-credits {
    margin-bottom: 1.25rem;
}

.dir-storage-bar-mini {
    display: flex;
    height: 10px;
    border-radius: 5px;
    overflow: hidden;
    background: var(--tc-glass-bg-hover);
    margin-bottom: 0.5rem;
}

.dir-sbar-segment {
    height: 100%;
    transition: width 0.4s ease;
}

.dir-sbar-uploads {
    background: #3b82f6;
}

.dir-sbar-outputs {
    background: #22c55e;
}

.dir-sbar-enhanced {
    background: #f59e0b;
}

.dir-storage-legend-mini {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.dir-legend-item {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.75rem;
    color: #94a3b8;
}

.dir-legend-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.dir-storage-total {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 1rem;
}

.dir-storage-total-size {
    font-size: 2rem;
    font-weight: 700;
    color: #f1f5f9;
}

.dir-storage-total-label {
    font-size: 0.85rem;
    color: #94a3b8;
}

.dir-credit-stats {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.dir-credit-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.dir-credit-val {
    font-size: 1.5rem;
    font-weight: 700;
    color: #f1f5f9;
}

.dir-credit-lbl {
    font-size: 0.75rem;
    font-weight: 600;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}


/* ============================================================
   29. PROPERTIES ROW
   ============================================================ */

.dir-prop-row {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}


/* ============================================================
   30. GENERIC TABLE
   ============================================================ */

.dir-table-wrapper {
    overflow-x: auto;
    border: var(--tc-glass-border);
    border-radius: var(--tc-radius-md);
    margin-bottom: 1rem;
}

.dir-table {
    width: 100%;
    border-collapse: collapse;
}

.dir-table thead th {
    background: var(--tc-glass-bg);
    backdrop-filter: blur(var(--tc-glass-blur-light));
    -webkit-backdrop-filter: blur(var(--tc-glass-blur-light));
    color: #94a3b8;
    font-weight: 600;
    text-align: left;
    padding: 0.625rem 0.875rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: var(--tc-glass-border);
}

.dir-table tbody td {
    padding: 0.5rem 0.875rem;
    border-bottom: var(--tc-glass-border-subtle);
    color: #e2e8f0;
    font-size: 0.85rem;
}

.dir-table tbody tr:nth-child(even) {
    background: var(--tc-glass-bg);
}

.dir-table tbody tr:hover {
    background: var(--tc-glass-bg-hover);
}

.dir-file-link {
    color: var(--tc-accent, #a78bfa);
    text-decoration: none;
}
.dir-file-link:hover {
    text-decoration: underline;
    color: var(--tc-accent-hover, #c4b5fd);
}

.dir-file-delete-btn {
    background: none;
    border: 1px solid transparent;
    color: #64748b;
    cursor: pointer;
    font-size: 0.85rem;
    padding: 0.2rem 0.45rem;
    border-radius: 4px;
    transition: all 0.15s ease;
}
.dir-file-delete-btn:hover {
    color: #ef4444;
    border-color: #ef444444;
    background: #ef444418;
}


/* ============================================================
   31. FILES LIST (job-scoped file listing)
   ============================================================ */

.dir-files-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.dir-file-job {
    border: var(--tc-glass-border);
    border-radius: var(--tc-radius-md);
    overflow: hidden;
}

.dir-file-job-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--tc-glass-bg);
    backdrop-filter: blur(var(--tc-glass-blur-light));
    -webkit-backdrop-filter: blur(var(--tc-glass-blur-light));
    cursor: pointer;
    flex-wrap: wrap;
    transition: background 0.15s ease;
}

.dir-file-job-header:hover {
    background: var(--tc-glass-bg-hover);
}

.dir-file-job-toggle {
    font-size: 0.6rem;
    color: #64748b;
    transition: transform 0.2s ease;
    display: inline-block;
}

.dir-file-job-toggle.expanded {
    transform: rotate(90deg);
}

.dir-file-job-body {
    padding: 0.75rem 1rem;
    background: var(--tc-glass-bg-input);
    border-top: var(--tc-glass-border);
}

.dir-file-job-body.collapsed {
    display: none;
}

.dir-file-output {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0;
}

.dir-file-icon {
    flex-shrink: 0;
}

.dir-file-error {
    color: #ef4444;
    font-size: 0.85rem;
    padding: 0.375rem 0;
}

.dir-file-timestamps {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: var(--tc-glass-border-subtle);
}


/* ============================================================
   32. PROMPTS LIST
   ============================================================ */

.dir-prompt-search-wrap {
    margin-bottom: 1rem;
}

.dir-prompts-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.dir-prompt-preview {
    font-size: 0.85rem;
    line-height: 1.5;
    max-height: 3rem;
    overflow: hidden;
}

.dir-prompt-reveal-toggle {
    color: #7c3aed;
    font-size: 0.85rem;
    cursor: pointer;
    padding: 0.375rem 0;
    transition: color 0.15s ease;
    user-select: none;
}

.dir-prompt-reveal-toggle:hover {
    color: #a78bfa;
}

.dir-prompt-full {
    margin-top: 0.625rem;
    padding: 0.75rem;
    background: var(--tc-glass-bg-input);
    border: var(--tc-glass-border);
    border-radius: var(--tc-radius-sm);
    line-height: 1.6;
}

.dir-prompt-full.collapsed {
    display: none;
}

.dir-prompt-field {
    font-size: 0.85rem;
    color: #e2e8f0;
    margin-bottom: 0.375rem;
}

.dir-prompt-field strong {
    color: #94a3b8;
}

.dir-prompt-json-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-top: 0.75rem;
    margin-bottom: 0.375rem;
}

.dir-prompt-json {
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Mono', monospace;
    font-size: 0.8rem;
    color: #e2e8f0;
    white-space: pre-wrap;
    word-break: break-word;
    background: var(--tc-glass-bg);
    backdrop-filter: blur(var(--tc-glass-blur-light));
    -webkit-backdrop-filter: blur(var(--tc-glass-blur-light));
    padding: 0.75rem;
    border-radius: var(--tc-radius-sm);
    max-height: 300px;
    overflow-y: auto;
    margin: 0;
}


/* ============================================================
   33. ACTIVITY TIMELINE (JS-rendered)
   ============================================================ */

.dir-timeline {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.dir-timeline-date {
    margin-bottom: 0.25rem;
}

.dir-timeline-date-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: #94a3b8;
    padding: 0.5rem 0;
    border-bottom: var(--tc-glass-border-subtle);
    margin-bottom: 0.5rem;
}

.dir-timeline-item {
    display: flex;
    gap: 0.75rem;
    padding: 0.625rem 0;
    padding-left: 0.5rem;
}

.dir-timeline-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 0.25rem;
}

.dir-timeline-content {
    flex: 1;
    min-width: 0;
}

.dir-timeline-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 0.25rem;
}

.dir-timeline-times {
    margin-bottom: 0.25rem;
}

.dir-timeline-duration {
    color: #94a3b8;
}

.dir-timeline-error {
    color: #ef4444;
    font-size: 0.85rem;
    margin-top: 0.25rem;
    padding: 0.375rem 0.5rem;
    background: rgba(239, 68, 68, 0.1);
    border-radius: var(--tc-radius-sm);
}

.dir-timeline-output {
    color: #94a3b8;
    margin-top: 0.25rem;
}


/* ============================================================
   34. BUTTONS
   ============================================================ */

.dir-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: var(--tc-radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
    border: 1px solid transparent;
}

.dir-btn-secondary {
    background: var(--tc-glass-bg);
    backdrop-filter: blur(var(--tc-glass-blur-light));
    -webkit-backdrop-filter: blur(var(--tc-glass-blur-light));
    color: #e2e8f0;
    border: var(--tc-glass-border);
}

.dir-btn-secondary:hover {
    background: var(--tc-glass-bg-hover);
    border: var(--tc-glass-border-hover);
}

.dir-load-more {
    display: flex;
    justify-content: center;
    padding: 1rem 0;
}


/* ============================================================
   35. CONTEXT MENU ITEM (JS-rendered)
   ============================================================ */

.dir-ctx-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    color: #e2e8f0;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.12s ease;
    white-space: nowrap;
}

.dir-ctx-item:hover {
    background: var(--tc-glass-bg-hover);
}


/* ============================================================
   36. TREE NODE VARIANTS (empty, group, badge, stub)
   ============================================================ */

.dir-tree-empty {
    cursor: default;
}

.dir-tree-empty:hover {
    background: transparent;
}

.dir-tree-group {
    color: #94a3b8;
}

/* Drag and drop */
.dir-tree-user[draggable="true"] {
    cursor: grab;
}
.dir-tree-user.dir-dragging {
    opacity: 0.4;
}
.dir-drop-zone.dir-drop-highlight {
    background: rgba(167, 139, 250, 0.15);
    outline: 2px dashed #a78bfa;
    outline-offset: -2px;
    border-radius: 6px;
}

/* Group management buttons */
.dir-group-add-btn {
    margin-left: auto;
    background: none;
    border: 1px solid #334155;
    color: #94a3b8;
    cursor: pointer;
    font-size: 0.85rem;
    width: 22px;
    height: 22px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: all 0.15s ease;
}
.dir-group-add-btn:hover {
    color: #a78bfa;
    border-color: #a78bfa;
    background: rgba(167, 139, 250, 0.1);
}
.dir-group-delete-btn,
.dir-group-remove-btn {
    margin-left: auto;
    background: none;
    border: none;
    color: #475569;
    cursor: pointer;
    font-size: 0.7rem;
    padding: 2px 4px;
    border-radius: 3px;
    opacity: 0;
    transition: all 0.15s ease;
}
.dir-tree-node:hover > .dir-group-delete-btn,
.dir-tree-node:hover > .dir-group-remove-btn {
    opacity: 1;
}
.dir-group-delete-btn:hover,
.dir-group-remove-btn:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

/* Group member nodes */
.dir-tree-group-member {
    cursor: pointer;
}
.dir-tree-group-member:hover {
    background: var(--tc-glass-bg-hover, rgba(255,255,255,0.04));
}

.dir-tree-letter-ou {
    font-weight: 500;
}

.dir-tree-badge {
    font-size: 0.65rem;
    padding: 1px 6px;
    border-radius: 9999px;
    font-weight: 600;
    margin-left: 0.25rem;
}

.dir-tree-stub {
    padding: 0.3rem 0.75rem;
    font-size: 0.8rem;
    color: #64748b;
    font-style: italic;
}


/* ─── 3D Pie Chart ─── */
.dir-pie-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2rem;
    padding: 1.5rem;
    background: var(--tc-glass-bg);
    backdrop-filter: blur(var(--tc-glass-blur));
    -webkit-backdrop-filter: blur(var(--tc-glass-blur));
    border: var(--tc-glass-border);
    border-radius: var(--tc-radius-md);
    margin-bottom: 1.25rem;
    position: relative;
}

#dirStoragePieChart {
    flex-shrink: 0;
    border-radius: var(--tc-radius-sm);
}

.dir-pie-legend {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    flex: 0 1 auto;
    min-width: 0;
}

.dir-pie-legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: #cbd5e1;
    line-height: 1.4;
}

.dir-pie-swatch {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 3px;
    flex-shrink: 0;
    border: 1px solid rgba(255,255,255,0.15);
}

.dir-pie-legend-label {
    font-weight: 600;
    color: #e2e8f0;
    white-space: nowrap;
}

.dir-pie-legend-val {
    color: #94a3b8;
    font-size: 0.8rem;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.dir-pie-total {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 0.8rem;
    color: #94a3b8;
    padding: 0.5rem 0;
    border-top: var(--tc-glass-border);
}

.dir-pie-container { padding-bottom: 2.5rem; }

@media (max-width: 700px) {
    .dir-pie-container {
        flex-direction: column;
        align-items: center;
    }
    .dir-pie-legend {
        width: 100%;
    }
    .dir-pie-total {
        position: relative;
        bottom: auto;
    }
    .dir-pie-container { padding-bottom: 1.25rem; }
}


/* ============================================================
   37. EDIT PROFILE FORM
   ============================================================ */

.dir-overview-actions {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 1rem;
}

.dir-btn-edit {
    background: linear-gradient(135deg, #7c3aed, #a855f7);
    color: #fff;
    border: none;
    padding: 0.5rem 1.25rem;
    border-radius: var(--tc-radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.dir-btn-edit:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.dir-btn-primary {
    background: linear-gradient(135deg, #7c3aed, #a855f7);
    color: #fff;
    border: none;
}

.dir-btn-primary:hover {
    opacity: 0.9;
}

.dir-btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.dir-edit-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background: var(--tc-glass-bg);
    backdrop-filter: blur(var(--tc-glass-blur));
    -webkit-backdrop-filter: blur(var(--tc-glass-blur));
    border: var(--tc-glass-border);
    border-radius: var(--tc-radius-lg);
    padding: 1.5rem;
    margin-bottom: 1.25rem;
}

.dir-edit-row {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.dir-edit-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.dir-edit-input,
.dir-edit-select {
    padding: 0.625rem 0.75rem;
    background: var(--tc-glass-bg-input);
    border: var(--tc-glass-border);
    border-radius: var(--tc-radius-sm);
    color: #e2e8f0;
    font-size: 0.9rem;
    font-family: inherit;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.dir-edit-input:focus,
.dir-edit-select:focus {
    outline: none;
    border: var(--tc-glass-border-focus);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

.dir-edit-narrow {
    max-width: 200px;
}

.dir-edit-select {
    cursor: pointer;
    max-width: 280px;
}

.dir-edit-select option {
    background: #1e293b; /* options don't support glass transparency */
    color: #e2e8f0;
}

.dir-edit-toggles {
    flex-direction: row !important;
    flex-wrap: wrap;
    gap: 1.25rem !important;
}

.dir-edit-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #e2e8f0;
    font-size: 0.9rem;
    cursor: pointer;
    user-select: none;
}

.dir-edit-toggle input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #7c3aed;
    cursor: pointer;
}

.dir-edit-actions {
    display: flex;
    gap: 0.75rem;
    padding-top: 0.5rem;
    border-top: var(--tc-glass-border-subtle);
    margin-top: 0.25rem;
}

.dir-edit-error {
    color: #ef4444;
    font-size: 0.85rem;
    padding: 0.5rem 0.75rem;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--tc-radius-sm);
    margin-top: 0.25rem;
}


/* ============================================================
   38. USER PROFILE PANEL (Modern Dark Theme)
   ============================================================ */

/* ── Detail panel override when profile is open ── */
.dir-detail-panel--dialog {
    padding: 0 !important;
    overflow: hidden !important;
}

/* ── Profile container ── */
.up-profile {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    background: var(--tc-glass-bg);
    backdrop-filter: blur(var(--tc-glass-blur));
    -webkit-backdrop-filter: blur(var(--tc-glass-blur));
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: #e2e8f0;
}

/* Reset buttons inside profile */
.up-profile button {
    all: unset;
    box-sizing: border-box;
    cursor: pointer;
    font-family: inherit;
    color: inherit;
}

/* ── Profile header ── */
.up-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem 1.5rem;
    background: var(--tc-glass-bg);
    backdrop-filter: blur(var(--tc-glass-blur));
    -webkit-backdrop-filter: blur(var(--tc-glass-blur));
    border-bottom: var(--tc-glass-border);
    flex-shrink: 0;
}

.up-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #7c3aed, #a855f7);
    color: #fff;
    font-size: 1.25rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.up-header-info {
    flex: 1;
    min-width: 0;
}

.up-name-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.up-name {
    font-size: 1.25rem;
    font-weight: 700;
    color: #f1f5f9;
    margin: 0 0 2px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.up-copy-all-btn {
    width: 28px;
    height: 28px;
    border-radius: var(--tc-radius-sm);
    border: var(--tc-glass-border);
    flex-shrink: 0;
}
.up-copy-all-btn.loading {
    opacity: 0.5;
    pointer-events: none;
    animation: copyPulse 0.8s ease-in-out infinite;
}
@keyframes copyPulse {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.7; }
}

.up-email {
    font-size: 0.8rem;
    color: #94a3b8;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.up-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}

.up-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.up-badge-admin { background: rgba(239,68,68,0.15); color: #f87171; border: 1px solid rgba(239,68,68,0.3); }
.up-badge-active { background: rgba(34,197,94,0.15); color: #4ade80; border: 1px solid rgba(34,197,94,0.3); }
.up-badge-inactive { background: rgba(239,68,68,0.15); color: #f87171; border: 1px solid rgba(239,68,68,0.3); }
.up-badge-verified { background: rgba(59,130,246,0.15); color: #60a5fa; border: 1px solid rgba(59,130,246,0.3); }
.up-badge-tier { background: rgba(124,58,237,0.15); color: #a78bfa; border: 1px solid rgba(124,58,237,0.3); }

.up-close-btn {
    width: 32px;
    height: 32px;
    border-radius: var(--tc-radius-sm);
    display: flex !important;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
    font-size: 1.1rem;
    flex-shrink: 0;
    transition: all 0.15s;
}

.up-close-btn:hover {
    background: rgba(239,68,68,0.15);
    color: #f87171;
}

/* ── Tab navigation ── */
.up-tabs {
    display: flex;
    gap: 0;
    background: var(--tc-glass-bg-topbar);
    backdrop-filter: blur(var(--tc-glass-blur));
    -webkit-backdrop-filter: blur(var(--tc-glass-blur));
    border-bottom: var(--tc-glass-border);
    padding: 0 1rem;
    flex-shrink: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.up-tabs::-webkit-scrollbar { display: none; }

.up-profile .up-tab {
    display: inline-flex !important;
    align-items: center;
    padding: 0.75rem 1.25rem !important;
    font-size: 0.8rem;
    font-weight: 500;
    color: #94a3b8;
    border-bottom: 2px solid transparent !important;
    white-space: nowrap;
    transition: all 0.15s;
    position: relative;
}

.up-profile .up-tab:hover {
    color: #e2e8f0;
    background: rgba(255,255,255,0.03);
}

.up-profile .up-tab.active {
    color: #a78bfa;
    border-bottom-color: #7c3aed !important;
    font-weight: 600;
}

/* ── Tab body ── */
.up-tab-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1.25rem 1.5rem;
    min-height: 0;
}

.up-tab-panel {
    display: none;
}

.up-tab-panel.active {
    display: block;
}

/* ── Action bar (save/close) ── */
.up-action-bar {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: var(--tc-glass-bg);
    backdrop-filter: blur(var(--tc-glass-blur));
    -webkit-backdrop-filter: blur(var(--tc-glass-blur));
    border-top: var(--tc-glass-border);
    flex-shrink: 0;
}

.up-btn {
    padding: 0.5rem 1.25rem !important;
    font-size: 0.8rem;
    font-weight: 600;
    border-radius: var(--tc-radius-sm);
    transition: all 0.15s;
    display: inline-flex !important;
    align-items: center;
    gap: 0.5rem;
}

.up-btn-primary {
    background: #7c3aed;
    color: #fff;
}

.up-btn-primary:hover {
    background: #6d28d9;
}

.up-btn-primary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.up-btn-secondary {
    background: var(--tc-glass-bg-hover);
    color: #e2e8f0;
}

.up-btn-secondary:hover {
    background: var(--tc-glass-bg-active);
}

.up-profile .up-btn-danger {
    background: #dc2626 !important;
    color: #fff !important;
    padding: 0.5rem 1.25rem !important;
    font-size: 0.8rem;
    font-weight: 600;
    border-radius: var(--tc-radius-sm);
    display: inline-flex !important;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.15s;
    cursor: pointer;
}

.up-profile .up-btn-danger:hover {
    background: #b91c1c !important;
}

.up-profile .up-btn-danger:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.up-pw-status {
    font-size: 0.8rem;
    font-weight: 500;
}

/* ── Form fields (used in General, Account tabs) ── */
.up-section {
    margin-bottom: 1.5rem;
}

.up-section-title {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #64748b;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: var(--tc-glass-border-subtle);
}

.up-field-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.up-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.up-field.full-width {
    grid-column: 1 / -1;
}

.up-field-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.up-field-input {
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
    font-family: inherit;
    color: #e2e8f0;
    background: var(--tc-glass-bg-input);
    border: var(--tc-glass-border);
    border-radius: var(--tc-radius-sm);
    outline: none;
    transition: border-color 0.15s;
    width: 100%;
    box-sizing: border-box;
}

.up-field-input:focus {
    border: var(--tc-glass-border-focus);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

.up-field-input:read-only {
    background: var(--tc-glass-bg-input);
    color: #64748b;
    border: var(--tc-glass-border-subtle);
    cursor: default;
}

.up-field-input.mono {
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 0.75rem;
}

.up-field-input-wrap {
    display: flex;
    align-items: stretch;
    gap: 0;
    position: relative;
}

.up-field-input-wrap .up-field-input,
.up-field-input-wrap .up-field-select {
    flex: 1;
    min-width: 0;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.up-copy-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    flex-shrink: 0;
    background: var(--tc-glass-bg);
    border: var(--tc-glass-border);
    border-left: none;
    border-radius: 0 var(--tc-radius-sm) var(--tc-radius-sm) 0;
    color: #64748b;
    cursor: pointer;
    transition: color 0.15s, background 0.15s;
    padding: 0;
}

.up-copy-btn:hover {
    color: #e2e8f0;
    background: var(--tc-glass-bg-hover);
}

.ipf-copy-btn {
    width: 26px;
    height: 26px;
    border-radius: var(--tc-radius-sm);
    border: var(--tc-glass-border);
    margin-right: 6px;
    flex-shrink: 0;
}

.up-copy-btn.copied {
    color: #00b894;
    background: rgba(0, 184, 148, 0.2);
    border-color: #00b894;
    transform: scale(1.1);
    transition: all 0.15s;
}

.up-field-select {
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
    font-family: inherit;
    color: #e2e8f0;
    background: var(--tc-glass-bg-input);
    border: var(--tc-glass-border);
    border-radius: var(--tc-radius-sm);
    outline: none;
    cursor: pointer;
    width: 100%;
    box-sizing: border-box;
}

.up-field-select:focus {
    border: var(--tc-glass-border-focus);
}

/* ── Toggle switch (checkboxes) ── */
.up-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 0.75rem;
    background: var(--tc-glass-bg);
    border-radius: var(--tc-radius-sm);
    margin-bottom: 0.5rem;
}

.up-toggle-label {
    font-size: 0.85rem;
    color: #e2e8f0;
}

.up-toggle-switch {
    position: relative;
    width: 40px;
    height: 22px;
    appearance: none;
    -webkit-appearance: none;
    background: #475569;
    border-radius: 11px;
    cursor: pointer;
    transition: background 0.2s;
    border: none;
    flex-shrink: 0;
}

.up-toggle-switch:checked {
    background: #7c3aed;
}

.up-toggle-switch::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s;
}

.up-toggle-switch:checked::after {
    transform: translateX(18px);
}

/* ── Stat cards (Profile tab) ── */
.up-stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.up-stat-card {
    background: var(--tc-glass-bg);
    backdrop-filter: blur(var(--tc-glass-blur));
    -webkit-backdrop-filter: blur(var(--tc-glass-blur));
    border: var(--tc-glass-border);
    border-radius: var(--tc-radius-md);
    padding: 1rem;
    text-align: center;
}

.up-stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #f1f5f9;
    line-height: 1.2;
}

.up-stat-label {
    font-size: 0.7rem;
    color: #94a3b8;
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.up-stat-card.purple .up-stat-value { color: #a78bfa; }
.up-stat-card.green .up-stat-value { color: #4ade80; }
.up-stat-card.red .up-stat-value { color: #f87171; }
.up-stat-card.amber .up-stat-value { color: #fbbf24; }
.up-stat-card.blue .up-stat-value { color: #60a5fa; }

/* ── Scrollbar for tab body ── */
.up-tab-body::-webkit-scrollbar { width: 6px; }
.up-tab-body::-webkit-scrollbar-track { background: transparent; }
.up-tab-body::-webkit-scrollbar-thumb { background: #334155; border-radius: 3px; }
.up-tab-body::-webkit-scrollbar-thumb:hover { background: #475569; }

/* ── Responsive: mobile ── */
@media (max-width: 768px) {
    .up-header {
        padding: 0.75rem;
        gap: 0.5rem;
    }
    .up-avatar {
        width: 40px;
        height: 40px;
        font-size: 0.95rem;
    }
    .up-name { font-size: 0.95rem; }
    .up-email { font-size: 0.75rem; }
    .up-badges { gap: 4px; }
    .up-badge { font-size: 0.6rem; padding: 0.125rem 0.35rem; }

    /* Make sub-tabs horizontally scrollable */
    .up-tabs {
        padding: 0;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .up-tabs::-webkit-scrollbar { display: none; }
    .up-tab {
        padding: 0.5rem 0.65rem;
        font-size: 0.7rem;
        white-space: nowrap;
        flex-shrink: 0;
    }

    .up-tab-body { padding: 0.75rem; }
    .up-field-grid { grid-template-columns: 1fr; }
    .up-stat-grid { grid-template-columns: repeat(2, 1fr); }
    .up-action-bar { padding: 0.6rem 0.75rem; }
    .up-action-bar .up-btn { padding: 0.5rem 0.75rem; font-size: 0.8rem; }

    /* Field rows */
    .up-field { padding: 0.5rem; }
    .up-field-label { font-size: 0.65rem; }
    .up-field-input { font-size: 0.8rem; padding: 0.35rem 0.5rem; }
    .up-copy-btn { width: 24px; height: 24px; }
}

@media (max-width: 480px) {
    .up-stat-grid { grid-template-columns: 1fr 1fr; }
    .up-header {
        flex-wrap: wrap;
        position: relative;
    }
    .up-close-btn {
        position: absolute;
        top: 0.5rem;
        right: 0.5rem;
    }
    .up-header-info { max-width: calc(100% - 60px); }
    .up-name { font-size: 0.9rem; word-break: break-word; }
}


/* ============================================================
   IP FORENSICS – VISIT HISTORY
   ============================================================ */

.ipf-visit-history {
    margin-top: 12px;
    border-top: var(--tc-glass-border);
    padding-top: 10px;
}
.ipf-visit-title {
    font-weight: 600;
    font-size: 0.8em;
    color: #b2bec3;
    margin-bottom: 8px;
}
.ipf-visit-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    font-size: 0.82em;
    border-left: 2px solid rgba(148,163,184,0.15);
    padding-left: 10px;
    margin-left: 4px;
}
.ipf-visit-ua {
    color: #636e72;
    font-size: 0.85em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 300px;
}
.ipf-visit-count {
    background: var(--tc-glass-bg-hover);
    color: #94a3b8;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.75em;
    font-weight: 600;
    margin-left: 4px;
}


/* ============================================================
   AVATAR PICKER MODAL
   ============================================================ */

.avpick-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    backdrop-filter: blur(4px);
    animation: avpickFadeIn 0.15s ease-out;
}

@keyframes avpickFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.avpick-modal {
    background: var(--tc-glass-bg);
    backdrop-filter: blur(var(--tc-glass-blur-heavy));
    -webkit-backdrop-filter: blur(var(--tc-glass-blur-heavy));
    border: var(--tc-glass-border);
    border-radius: var(--tc-radius-lg);
    width: 420px;
    max-width: 95vw;
    max-height: 85vh;
    overflow-y: auto;
    padding: 1.25rem;
    box-shadow: var(--tc-shadow-2xl);
}

.avpick-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.avpick-header h3 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 600;
    color: #f1f5f9;
}

.avpick-close {
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    border-radius: 4px;
    transition: color 0.15s, background 0.15s;
}

.avpick-close:hover {
    color: #f1f5f9;
    background: var(--tc-glass-bg-hover);
}

.avpick-section-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
}

.avpick-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.6rem;
    margin-bottom: 1rem;
}

.avpick-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 0.5rem 0.25rem;
    border: 2px solid transparent;
    border-radius: var(--tc-radius-md);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, transform 0.1s;
    background: transparent;
}

.avpick-item:hover {
    border-color: rgba(148,163,184,0.15);
    background: var(--tc-glass-bg-hover);
    transform: translateY(-1px);
}

.avpick-item.selected {
    border-color: #7c3aed;
    background: var(--tc-glass-bg-active);
}

.avpick-svg {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--tc-glass-bg-input);
}

.avpick-svg svg {
    width: 100%;
    height: 100%;
}

.avpick-label {
    font-size: 0.65rem;
    color: #94a3b8;
    text-align: center;
    line-height: 1.2;
    max-width: 64px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.avpick-divider {
    height: 1px;
    background: rgba(148,163,184,0.08);
    margin: 0.75rem 0;
}

.avpick-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.avpick-upload-btn {
    display: block;
    width: 100%;
    padding: 0.6rem 1rem;
    background: #7c3aed;
    color: #fff;
    border: none;
    border-radius: var(--tc-radius-md);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
    text-align: center;
}

.avpick-upload-btn:hover {
    background: #6d28d9;
}

.avpick-remove-btn {
    display: block;
    width: 100%;
    padding: 0.5rem 1rem;
    background: transparent;
    color: #ef4444;
    border: 1px solid #ef4444;
    border-radius: var(--tc-radius-md);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    text-align: center;
}

.avpick-remove-btn:hover:not(:disabled) {
    background: rgba(239, 68, 68, 0.15);
}

.avpick-remove-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    border-color: #475569;
    color: #475569;
}

/* Clickable avatar hover state in profile header */
#upAvatar[style*="cursor: pointer"]:hover {
    opacity: 0.85;
    filter: brightness(1.1);
}


/* ============================================================
   MOBILE: SIEM USER PROFILE PANEL OVERLAY
   ============================================================ */

@media (max-width: 768px) {
    /* Profile side panel — full-width on mobile */
    .sec-dashboard > .dir-detail-panel,
    .dir-detail-panel {
        width: 100% !important;
    }

    /* Tables in storage tab — scroll horizontally */
    .dir-table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .dir-table { font-size: 0.75rem; }
    .dir-table th, .dir-table td { padding: 0.4rem 0.5rem; white-space: nowrap; }

    /* Pie chart — stack vertically */
    .dir-pie-container {
        flex-direction: column;
        align-items: center;
    }

    /* Section labels */
    .dir-section-label { font-size: 0.8rem; }

    /* Tree drag hint */
    .dir-tree-user[draggable="true"] { cursor: default; }

    /* Group buttons more touch-friendly */
    .dir-group-add-btn { width: 28px; height: 28px; font-size: 1rem; }
    .dir-group-remove-btn,
    .dir-group-delete-btn { opacity: 1; padding: 4px 6px; font-size: 0.75rem; }

    /* File delete buttons always visible on mobile */
    .dir-file-delete-btn { opacity: 1; }
}

@media (max-width: 480px) {
    .dir-detail-panel { padding: 0.5rem !important; }

    .dir-section-label { font-size: 0.75rem; margin-top: 1rem !important; }

    .dir-table th, .dir-table td { padding: 0.3rem 0.4rem; font-size: 0.7rem; }

    /* IP forensics cards */
    .ipf-visit-row { font-size: 0.75em; gap: 4px; }
}
