/* ==================== Theme Variables ==================== */
:root, [data-theme="light"] {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f5f9;
    --bg-hover: #f0f4ff;
    --border-color: #e2e8f0;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --accent-primary: #6366f1;
    --accent-primary-dark: #4f46e5;
    --accent-primary-light: #818cf8;
    --accent-blue: #3b82f6;
    --accent-green: #10b981;
    --accent-orange: #f59e0b;
    --accent-red: #ef4444;
    --accent-purple: #8b5cf6;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -2px rgba(0,0,0,.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -4px rgba(0,0,0,.1);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
}

[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --bg-hover: #1e2a4a;
    --border-color: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent-primary: #818cf8;
    --accent-primary-dark: #6366f1;
    --accent-primary-light: #a5b4fc;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.3);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,.4);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.5);
}

/* ==================== Base Styles ==================== */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    font-size: 14px;
    line-height: 1.6;
}

/* ==================== Header ==================== */
.header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 0 24px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header h1 {
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-right { display: flex; align-items: center; gap: 16px; }

.theme-toggle {
    display: flex;
    background: var(--bg-tertiary);
    border-radius: 20px;
    padding: 3px;
}

.theme-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: all 0.2s;
}

.theme-btn:hover { color: var(--text-primary); }
.theme-btn.active { background: var(--bg-secondary); color: var(--accent-primary); box-shadow: var(--shadow-sm); }

.user-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: var(--bg-tertiary);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-primary);
    font-size: 13px;
}

.user-btn:hover { background: var(--bg-hover); }

.user-avatar {
    width: 28px;
    height: 28px;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-purple));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 12px;
    font-weight: 600;
}

/* ==================== Page Container ==================== */
.page-container {
    padding: 20px;
    min-height: 100vh;
    overflow: auto;
}

.page-card {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05), 0 4px 12px rgba(0, 0, 0, 0.03);
    border: 1px solid var(--border-color);
    overflow: hidden;
    transition: box-shadow 0.2s ease;
}

.page-card:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06), 0 8px 24px rgba(0, 0, 0, 0.04);
}

[data-theme="dark"] .page-card {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2), 0 4px 12px rgba(0, 0, 0, 0.15);
}

[data-theme="dark"] .page-card:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25), 0 8px 24px rgba(0, 0, 0, 0.2);
}

/* ==================== Page Header ==================== */
.page-header {
    padding: 24px;
    border-bottom: 1px solid var(--border-color);
}

.page-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.page-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
}

/* ==================== Stats Cards ==================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    padding: 24px;
}

.stat-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.stat-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stat-label {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.stat-icon.primary { background: rgba(99, 102, 241, 0.1); color: var(--accent-primary); }
.stat-icon.success { background: rgba(16, 185, 129, 0.1); color: var(--accent-green); }
.stat-icon.warning { background: rgba(245, 158, 11, 0.1); color: var(--accent-orange); }
.stat-icon.danger { background: rgba(239, 68, 68, 0.1); color: var(--accent-red); }

/* ==================== Toolbar ==================== */
.toolbar {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    background: var(--bg-secondary);
}

.toolbar-left { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.toolbar-right { display: flex; align-items: center; gap: 8px; }

/* Search Group - 组合搜索控件 */
.search-group {
    display: flex;
    align-items: center;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    overflow: hidden;
    transition: all 0.2s ease;
}

.search-group:focus-within {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.search-group .filter-select {
    border: none;
    border-right: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    padding: 9px 12px;
    font-size: 13px;
    color: var(--text-secondary);
    min-width: 120px;
    cursor: pointer;
}

.search-group .filter-select:focus {
    outline: none;
}

.search-group .search-input {
    border: none;
    background: transparent;
    min-width: 180px;
    box-shadow: none;
}

.search-group .search-input:focus {
    box-shadow: none;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 8px;
}

.search-input {
    min-width: 220px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    color: var(--text-primary);
    font-size: 13px;
    transition: all 0.2s;
}

.search-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}
.search-input::placeholder { color: var(--text-muted); }

/* Search/Filter buttons */
.search-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.search-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--accent-primary);
}

.search-btn.primary {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
}

.search-btn.primary:hover {
    background: var(--accent-primary-dark);
}

.reset-btn {
    padding: 8px 12px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.reset-btn:hover {
    color: var(--accent-red);
}

/* ==================== Two Column Layout ==================== */
.main-container {
    display: grid;
    grid-template-columns: 300px 1fr;
    min-height: 100vh;
    gap: 0;
}

/* ==================== Utilities ==================== */
.u-pt-8 { padding-top: 8px; }
.u-mb-8 { margin-bottom: 8px; }
.u-w-full { width: 100%; }
.u-w-50 { width: 50px; }
.u-w-60 { width: 60px; }
.u-w-80 { width: 80px; }
.u-w-100 { width: 100px; }
.u-w-180 { width: 180px; }
.u-w-200 { width: 200px; }

/* ==================== Left Panel - Tree ==================== */
.tree-panel {
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: relative;
}

/* Subtle shadow on the right edge */
.tree-panel::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 4px;
    background: linear-gradient(to right, rgba(0,0,0,0.02), transparent);
    pointer-events: none;
}

[data-theme="dark"] .tree-panel::after {
    background: linear-gradient(to right, rgba(0,0,0,0.1), transparent);
}

.tree-header {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-tertiary);
}

.tree-title {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
}

.tree-search {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-primary);
}

.tree-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 12px;
}

.tree-node {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s;
    margin-bottom: 4px;
}

.tree-node:hover { background: var(--bg-tertiary); }
.tree-node.active { background: var(--bg-hover); color: var(--accent-primary); }

.tree-node-content { flex: 1; min-width: 0; }

.tree-node-label {
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tree-node-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
}

.tree-node-code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    color: var(--text-muted);
}

.tree-node-status {
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 500;
}

.tree-node-status.enabled { background: rgba(16, 185, 129, 0.1); color: var(--accent-green); }
.tree-node-status.disabled { background: rgba(239, 68, 68, 0.1); color: var(--accent-red); }

.tree-node-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.15s;
}

.tree-node:hover .tree-node-actions { opacity: 1; }

/* Tree with children */
.tree-item { margin-bottom: 2px; }

.tree-item-header {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s;
}

.tree-item-header:hover { background: var(--bg-tertiary); }
.tree-item-header.active { background: var(--bg-hover); color: var(--accent-primary); }

.tree-toggle {
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 6px;
    transition: transform 0.2s;
}

.tree-toggle.expanded { transform: rotate(90deg); }
.tree-toggle.empty { visibility: hidden; }

.tree-children {
    padding-left: 28px;
    display: none;
}

.tree-children.expanded { display: block; }

/* ==================== Right Panel - Table ==================== */
.table-panel {
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
}

.table-header {
    padding: 16px 24px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.table-title { font-size: 15px; font-weight: 600; }

/* ==================== Table ==================== */
.table-wrapper { flex: 1; overflow: auto; }

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

.data-table th {
    text-align: left;
    padding: 12px 16px;
    font-weight: 600;
    font-size: 11px;
    color: var(--text-muted);
    background: var(--bg-tertiary);
    border-bottom: 2px solid var(--border-color);
    position: sticky;
    top: 0;
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    z-index: 10;
}

.data-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    font-size: 13px;
    vertical-align: middle;
}

/* 斑马纹效果 */
.data-table tbody tr {
    transition: all 0.2s ease;
}
.data-table tbody tr:nth-child(even) {
    background: var(--bg-tertiary);
}
[data-theme="dark"] .data-table tbody tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.02);
}
.data-table tbody tr:hover {
    background: var(--bg-hover);
    transform: scale(1.001);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.cell-name { font-weight: 500; }

.cell-code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    color: var(--accent-primary);
    background: rgba(99, 102, 241, 0.08);
    padding: 3px 8px;
    border-radius: 4px;
}

.cell-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    color: var(--accent-green);
    background: rgba(16, 185, 129, 0.08);
    padding: 3px 8px;
    border-radius: 4px;
}

.cell-order { font-family: 'JetBrains Mono', monospace; color: var(--text-secondary); }

/* ==================== Status Badge ==================== */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
    text-transform: capitalize;
}

.status-badge.success, .status-badge.active, .status-badge.enabled, .status-badge.on {
    background: rgba(16, 185, 129, 0.1);
    color: var(--accent-green);
}
.status-badge.danger, .status-badge.disabled, .status-badge.off {
    background: rgba(239, 68, 68, 0.1);
    color: var(--accent-red);
}
.status-badge.warning, .status-badge.beta, .status-badge.pending {
    background: rgba(245, 158, 11, 0.1);
    color: var(--accent-orange);
}
.status-badge.info, .status-badge.inbound {
    background: rgba(59, 130, 246, 0.1);
    color: var(--accent-blue);
}
.status-badge.primary {
    background: rgba(99, 102, 241, 0.1);
    color: var(--accent-primary);
}
.status-badge.completed {
    background: rgba(16, 185, 129, 0.1);
    color: var(--accent-green);
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Compact inline status indicator */
.status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-secondary);
}

.status-indicator .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-indicator .dot.active { background: var(--accent-green); }
.status-indicator .dot.inactive { background: var(--accent-red); }
.status-indicator .dot.pending { background: var(--accent-orange); }

/* ==================== Empty State ==================== */
.empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    padding: 60px 40px;
}

.empty-icon { font-size: 48px; margin-bottom: 16px; opacity: 0.5; }
.empty-text { font-size: 15px; margin-bottom: 20px; }

/* ==================== Buttons ==================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 18px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-primary-dark) 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.25);
}
.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
}
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-success { background: var(--accent-green); color: white; }
.btn-success:hover { opacity: 0.9; }

.btn-danger { background: var(--accent-red); color: white; }
.btn-danger:hover { opacity: 0.9; }

.btn-warning { background: var(--accent-orange); color: white; }
.btn-warning:hover { opacity: 0.9; }

.btn-default {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-default:hover { background: var(--bg-tertiary); }

.btn-sm { padding: 6px 12px; font-size: 13px; }

.btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    background: transparent;
    color: var(--text-secondary);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover { background: var(--bg-tertiary); color: var(--accent-primary); }
.btn-icon.danger:hover { color: var(--accent-red); }
.btn-icon.success:hover { color: var(--accent-green); }

.btn-link {
    background: none;
    border: none;
    color: var(--accent-primary);
    font-size: 13px;
    cursor: pointer;
    padding: 4px 8px;
}

.btn-link:hover { opacity: 0.7; }
.btn-link.danger { color: var(--accent-red); }

/* ==================== Table Action Buttons (Icon Style) ==================== */
.table-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    justify-content: flex-start;
}

.action-btn {
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.2s ease;
    position: relative;
}

.action-btn:hover {
    background: var(--bg-tertiary);
    color: var(--accent-primary);
    transform: translateY(-1px);
}

.action-btn.view:hover { color: var(--accent-blue); }
.action-btn.edit:hover { color: var(--accent-green); }
.action-btn.delete:hover {
    color: var(--accent-red);
    background: rgba(239, 68, 68, 0.08);
}
.action-btn.roles:hover { color: var(--accent-purple); }

/* Action Button Icons */
.action-btn svg {
    width: 16px;
    height: 16px;
    stroke-width: 2;
}

/* Tooltip for action buttons */
.action-btn::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(4px);
    padding: 4px 8px;
    background: var(--text-primary);
    color: var(--bg-secondary);
    font-size: 11px;
    white-space: nowrap;
    border-radius: 4px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.15s ease;
    pointer-events: none;
    z-index: 100;
}

.action-btn:hover::after {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(-4px);
}

/* Divider between action groups */
.action-divider {
    width: 1px;
    height: 16px;
    background: var(--border-color);
    margin: 0 4px;
}

/* ==================== Modal ==================== */
.modal-mask {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 23, 42, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.25s;
    backdrop-filter: blur(4px);
}

.modal-mask.active { opacity: 1; visibility: visible; }

.modal-dialog {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    width: 560px;
    max-width: 90vw;
    max-height: 90vh;
    box-shadow: var(--shadow-lg);
    transform: translateY(-20px) scale(0.95);
    transition: transform 0.25s;
    display: flex;
    flex-direction: column;
}

.modal-dialog.lg { width: 720px; }
.modal-dialog.sm { width: 420px; }

.modal-mask.active .modal-dialog { transform: translateY(0) scale(1); }

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.modal-title { font-size: 18px; font-weight: 600; }

.modal-close {
    width: 32px; height: 32px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}

.modal-close:hover { background: var(--bg-tertiary); color: var(--text-primary); }

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    flex-shrink: 0;
}

/* ==================== Form ==================== */
.form-item { margin-bottom: 20px; }
.form-item:last-child { margin-bottom: 0; }

.form-label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.form-label::after { content: ':'; }
.form-label .required { color: var(--accent-red); margin-right: 4px; }

.form-input, .form-select, .form-textarea {
    width: 100%;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    transition: all 0.2s;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.form-input:disabled, .form-select:disabled, .form-textarea:disabled {
    background: var(--bg-tertiary);
    color: var(--text-muted);
    cursor: not-allowed;
}

.form-textarea {
    min-height: 100px;
    resize: vertical;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-row-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 16px;
}

.form-radio-group { display: flex; gap: 20px; }

.form-radio {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
}

.form-radio input { accent-color: var(--accent-primary); width: 16px; height: 16px; }

.form-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
}

.form-checkbox input { accent-color: var(--accent-primary); width: 16px; height: 16px; }

.form-hint {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 6px;
}

/* ==================== Toast ==================== */
.toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 20px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease;
    font-size: 14px;
    border-left: 4px solid var(--accent-primary);
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.toast.success { border-left-color: var(--accent-green); }
.toast.success .toast-icon { color: var(--accent-green); }
.toast.error { border-left-color: var(--accent-red); }
.toast.error .toast-icon { color: var(--accent-red); }
.toast.warning { border-left-color: var(--accent-orange); }
.toast.warning .toast-icon { color: var(--accent-orange); }

/* ==================== Loading ==================== */
.loading-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    display: inline-block;
}

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

.loading-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

[data-theme="dark"] .loading-overlay {
    background: rgba(15, 23, 42, 0.8);
}

/* ==================== Table Footer / Pagination ==================== */
.table-footer {
    padding: 16px 24px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.page-info { font-size: 14px; color: var(--text-secondary); }

.pagination {
    display: flex;
    align-items: center;
    gap: 8px;
}

.page-btn {
    padding: 8px 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 13px;
    cursor: pointer;
    color: var(--text-primary);
    transition: all 0.15s;
}

.page-btn:hover:not(:disabled) { background: var(--bg-hover); border-color: var(--accent-primary); }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ==================== Tabs ==================== */
.tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    padding: 0 24px;
    background: var(--bg-secondary);
}

.tab-item {
    padding: 14px 20px;
    font-size: 14px;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
    margin-bottom: -1px;
}

.tab-item:hover { color: var(--accent-primary); }
.tab-item.active { color: var(--accent-primary); border-bottom-color: var(--accent-primary); font-weight: 500; }

/* ==================== Filter Tabs ==================== */
.filter-tabs {
    display: flex;
    gap: 4px;
    background: var(--bg-tertiary);
    padding: 4px;
    border-radius: var(--radius-sm);
}

.filter-tab {
    padding: 6px 14px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
    background: transparent;
    border: none;
}

.filter-tab:hover { color: var(--text-primary); }
.filter-tab.active { background: var(--bg-secondary); color: var(--accent-primary); font-weight: 500; box-shadow: var(--shadow-sm); }

/* ==================== Transfer / Checkbox List ==================== */
.checkbox-list {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    max-height: 300px;
    overflow-y: auto;
}

.checkbox-list-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    cursor: pointer;
    transition: background 0.15s;
}

.checkbox-list-item:hover { background: var(--bg-tertiary); }
.checkbox-list-item input { accent-color: var(--accent-primary); width: 16px; height: 16px; }

/* Tree Checkbox */
.tree-checkbox-list {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    max-height: 350px;
    overflow-y: auto;
    padding: 12px;
}

.tree-checkbox-item {
    padding: 4px 0;
}

.tree-checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
}

.tree-checkbox-label:hover { background: var(--bg-tertiary); }
.tree-checkbox-label input { accent-color: var(--accent-primary); width: 16px; height: 16px; }

.tree-checkbox-children {
    padding-left: 28px;
}

/* ==================== Agent/Item Card ==================== */
.item-row {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.15s;
}

.item-row:hover { background: var(--bg-hover); }

.item-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 14px;
    font-size: 18px;
}

.item-icon.green { background: linear-gradient(135deg, #10b981, #059669); color: white; }
.item-icon.orange { background: linear-gradient(135deg, #f59e0b, #d97706); color: white; }
.item-icon.blue { background: linear-gradient(135deg, #3b82f6, #2563eb); color: white; }
.item-icon.purple { background: linear-gradient(135deg, #8b5cf6, #7c3aed); color: white; }
.item-icon.red { background: linear-gradient(135deg, #ef4444, #dc2626); color: white; }

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

.item-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.item-desc {
    font-size: 13px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ==================== Progress Bar ==================== */
.progress-bar {
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--accent-green);
    border-radius: 3px;
    transition: width 0.3s;
}

.progress-fill.warning { background: var(--accent-orange); }
.progress-fill.danger { background: var(--accent-red); }

/* ==================== Scrollbar ==================== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ==================== Responsive ==================== */
@media (max-width: 768px) {
    .main-container { grid-template-columns: 1fr; }
    .tree-panel { height: 35vh; border-right: none; border-bottom: 1px solid var(--border-color); }
    .table-panel { height: calc(65vh - 56px); }
    .toolbar { flex-direction: column; align-items: stretch; }
    .toolbar-left, .toolbar-right { width: 100%; }
    .search-input { width: 100%; min-width: auto; }
    .form-row { grid-template-columns: 1fr; }
    .form-row-3 { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
}

/* ==================== Accessibility Helpers ==================== */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Focus styles for keyboard navigation */
*:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

/* Skip to main content link */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    padding: 8px 16px;
    background: var(--accent-primary);
    color: white;
    z-index: 9999;
    transition: top 0.2s;
}

.skip-link:focus {
    top: 0;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --border-color: #000;
        --text-muted: #333;
    }

    .btn-primary {
        background: var(--accent-primary);
        border: 2px solid var(--text-primary);
    }

    .status-badge {
        border: 1px solid currentColor;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ==================== Additional Utility Classes ==================== */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.flex { display: flex; }
.flex-1 { flex: 1; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-4 { gap: 4px; }
.gap-8 { gap: 8px; }
.gap-16 { gap: 16px; }

.m-0 { margin: 0; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }

.p-0 { padding: 0; }
.p-8 { padding: 8px; }
.p-16 { padding: 16px; }
.p-24 { padding: 24px; }

/* Status dot inline variant */
.status-dot-inline {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    margin-right: 4px;
}

.status-dot-inline.success { background: var(--accent-green); }
.status-dot-inline.danger { background: var(--accent-red); }
.status-dot-inline.warning { background: var(--accent-orange); }

/* Loading placeholder */
.loading-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: var(--text-muted);
    gap: 8px;
}

/* No data state */
.no-data {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: var(--text-muted);
}

.no-data-icon {
    font-size: 32px;
    margin-bottom: 8px;
    opacity: 0.5;
}

/* Empty hint for checkbox lists */
.empty-hint {
    padding: 16px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}

/* Assign user info display */
.assign-user-info {
    padding: 10px 14px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--text-primary);
}
