/* ===== Design Tokens (shadcn/ui inspired) ===== */
html { color-scheme: light; }
:root {
    --bg: #f8fafc;
    --bg-sidebar: #ffffff;
    --bg-card: #ffffff;
    --bg-hover: #f1f5f9;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --text: #0f172a;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #eff6ff;
    --danger: #dc2626;
    --success: #16a34a;
    --warning: #d97706;
    --amber: #f59e0b;
    --radius: 8px;
    --radius-sm: 6px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.08);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08);
    --transition: 150ms ease;
}

/* ===== Dark Theme ===== */
[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0f172a;
    --bg-sidebar: #1e293b;
    --bg-card: #1e293b;
    --bg-hover: #334155;
    --border: #334155;
    --border-light: #1e293b;
    --text: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --primary: #3b82f6;
    --primary-hover: #60a5fa;
    --primary-light: #1e3a5f;
    --danger: #ef4444;
    --success: #22c55e;
    --warning: #f59e0b;
    --amber: #fbbf24;
    --shadow: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.3);
}

/* Smooth theme transition */
*, *::before, *::after {
    transition: background-color var(--transition), border-color var(--transition), color var(--transition), box-shadow var(--transition);
}

/* Disable transition on page load */
html.no-transition *, html.no-transition *::before, html.no-transition *::after {
    transition: none !important;
}

/* Dark overrides for hardcoded colors */
[data-theme="dark"] .logo-icon { filter: invert(1) hue-rotate(180deg) brightness(1.2); }
[data-theme="dark"] .settings-menu { background: var(--bg-card); border-color: var(--border); }
[data-theme="dark"] .btn-primary { color: #f8fafc; }
[data-theme="dark"] .btn-secondary { background: var(--bg-hover); border-color: var(--border); color: var(--text); }
[data-theme="dark"] .btn-danger { color: #f8fafc; }
[data-theme="dark"] .filter-dropdown-trigger { background: var(--bg-card); border-color: var(--border); }
[data-theme="dark"] .filter-dropdown-menu { background: var(--bg-card); border-color: var(--border); }
[data-theme="dark"] .filter-chip { background: var(--bg-card); border-color: var(--border); }
[data-theme="dark"] .filter-chip.active { color: #f8fafc; }
[data-theme="dark"] .kanban-cards { background: var(--bg-hover); }
[data-theme="dark"] .kanban-cards.drag-over { background: rgba(59, 130, 246, 0.12); }
[data-theme="dark"] .kanban-card { background: var(--bg-card); }
[data-theme="dark"] .drawer-overlay { background: rgba(0,0,0,0.6); }
[data-theme="dark"] .modal-overlay { background: rgba(0,0,0,0.6); }
[data-theme="dark"] .modal { background: var(--bg-card); }
[data-theme="dark"] .form-group input,
[data-theme="dark"] .form-group select,
[data-theme="dark"] .form-group textarea { background-color: var(--bg); border-color: var(--border); color: var(--text); }
[data-theme="dark"] .toast { color: #f8fafc; }
[data-theme="dark"] .badge-blue { background: #1e3a5f; color: #93c5fd; }
[data-theme="dark"] .badge-green { background: #14532d; color: #86efac; }
[data-theme="dark"] .badge-red { background: #7f1d1d; color: #fca5a5; }
[data-theme="dark"] .badge-amber { background: #78350f; color: #fcd34d; }
[data-theme="dark"] .badge-gray { background: #334155; color: #94a3b8; }
[data-theme="dark"] .badge-purple { background: #581c87; color: #d8b4fe; }
[data-theme="dark"] .btn-danger:hover { opacity: 0.85; background: var(--danger); border-color: var(--danger); }
[data-theme="dark"] .funnel-filter-chip { background: var(--bg-card); border-color: var(--border); }
[data-theme="dark"] .funnel-fill { color: #f8fafc; }
[data-theme="dark"] .preview-overlay { background: rgba(0,0,0,0.7); }
[data-theme="dark"] .preview-panel { background: var(--bg-card); }
[data-theme="dark"] .payout-table tbody tr:nth-child(even) { background: #1e293b; }
[data-theme="dark"] .artifact-item { background: var(--bg-card); }
[data-theme="dark"] .buddy-assign-input { background: var(--bg); border-color: var(--border); color: var(--text); }
[data-theme="dark"] .buddy-assign-menu { background: var(--bg-card); border-color: var(--border); }
[data-theme="dark"] .funnel-bar { color: #f8fafc; }
[data-theme="dark"] .auth-overlay { background: rgba(0, 0, 0, 0.6); }
[data-theme="dark"] .data-table th { background: var(--bg-hover); }
[data-theme="dark"] .data-table tbody tr:hover { background: var(--bg-hover); }
[data-theme="dark"] .status-select { background: var(--bg); border-color: var(--border); color: var(--text); }
[data-theme="dark"] .page { background: var(--bg); }
[data-theme="dark"] .main { background: var(--bg); }
[data-theme="dark"] .sidebar { background: var(--bg-sidebar); border-color: var(--border); }
[data-theme="dark"] .nav-item:hover { background: var(--bg-hover); }
[data-theme="dark"] .nav-item.active { background: var(--bg-hover); }
[data-theme="dark"] .timeline-item { border-color: var(--border); }
[data-theme="dark"] .archive-item { background: var(--bg-card); }
[data-theme="dark"] .archive-item:hover { background: var(--bg-hover); }
[data-theme="dark"] .kanban-header { background: var(--bg-hover); }
[data-theme="dark"] .board-header { background: var(--bg-hover); }
[data-theme="dark"] .people-list { background: var(--bg-card); }
[data-theme="dark"] .details-grid { background: var(--bg-card); }
[data-theme="dark"] .drawer-section { background: var(--bg-card); }
[data-theme="dark"] .drawer { background: var(--bg-card); }
[data-theme="dark"] .drawer-header { border-color: var(--border); }
[data-theme="dark"] .toast { background: var(--bg-card); border-color: var(--border); color: var(--text); }
[data-theme="dark"] .toast-success { background: #14532d; color: #86efac; }
[data-theme="dark"] .toast-error { background: #7f1d1d; color: #fca5a5; }

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ===== Sidebar ===== */
.sidebar {
    width: 260px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 20px 16px;
    border-bottom: 1px solid var(--border-light);
}

.sidebar-nav {
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
}

.logo {
    display: flex;
    align-items: center;
}

.logo-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    margin-left: -8px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    cursor: pointer;
    transition: background-color 150ms ease;
    color: inherit;
}

.logo-link:hover {
    background-color: var(--bg-hover);
}

.logo-icon {
    width: 32px;
    height: 32px;
    object-fit: contain;
    border-radius: var(--radius-sm);
}

.logo-text {
    font-weight: 700;
    font-size: 16px;
    color: var(--text);
}

.settings-dropdown {
    position: relative;
    margin-left: auto;
}

.settings-btn {
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.settings-btn:hover {
    color: var(--text);
    background: var(--bg);
}

.settings-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    min-width: 180px;
    display: none;
    flex-direction: column;
    padding: 4px;
    z-index: 100;
}

.settings-dropdown.open .settings-menu { display: flex; }

.settings-menu a {
    padding: 8px 12px;
    font-size: 13px;
    color: var(--text);
    text-decoration: none;
    border-radius: var(--radius-sm);
    transition: background var(--transition);
}

.settings-menu a:hover { background: var(--bg); }

.settings-menu a { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

.theme-toggle-indicator {
    width: 32px;
    height: 18px;
    border-radius: 9px;
    background: var(--border);
    position: relative;
    flex-shrink: 0;
    transition: background var(--transition);
}
.theme-toggle-indicator::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: white;
    transition: transform var(--transition);
}
.theme-toggle-indicator.active {
    background: var(--primary);
}
.theme-toggle-indicator.active::after {
    transform: translateX(14px);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: all var(--transition);
}

.nav-item:hover {
    background: var(--bg);
    color: var(--text);
}

.nav-item.active {
    background: var(--primary-light);
    color: var(--primary);
}

.nav-item svg {
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border-light);
    font-size: 12px;
    color: var(--text-muted);
}

.user-card {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 13px;
}

.user-info {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.user-name {
    font-weight: 600;
    color: var(--text);
    font-size: 13px;
}

.user-role {
    font-size: 12px;
    color: var(--text-muted);
}

/* ===== Main ===== */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

.topbar {
    height: 56px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    flex-shrink: 0;
}

.topbar-title {
    font-weight: 600;
    font-size: 16px;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0 12px;
    width: 320px;
    transition: border var(--transition);
}

.search-box:focus-within {
    border-color: var(--primary);
}

.search-box svg {
    color: var(--text-muted);
    flex-shrink: 0;
}

.search-box input {
    border: none;
    background: transparent;
    outline: none;
    font-size: 13px;
    font-family: inherit;
    color: var(--text);
    padding: 7px 0;
    width: 100%;
}

.search-box input::placeholder {
    color: var(--text-muted);
}

.search-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    z-index: 100;
    max-height: 320px;
    overflow: auto;
}

.search-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 13px;
    border-bottom: 1px solid var(--border-light);
}

.search-dropdown-item:last-child {
    border-bottom: none;
}

.search-dropdown-item:hover {
    background: var(--primary-light);
}

.search-dropdown-item .type-badge {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--bg);
    color: var(--text-secondary);
    white-space: nowrap;
}

.search-dropdown-empty {
    padding: 12px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    margin-top: 20px;
    padding-bottom: 8px;
}

.pagination-btn {
    padding: 6px 12px;
    font-size: 13px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text);
    cursor: pointer;
    transition: all var(--transition);
}

.pagination-btn:hover:not(:disabled) {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
}

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

.pagination-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.content {
    flex: 1;
    overflow: auto;
    padding: 24px;
}

.page {
    display: none;
}

.page.active {
    display: block;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.page-header h1 {
    font-size: 20px;
    font-weight: 600;
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all var(--transition);
    font-family: inherit;
    line-height: 1.5;
    background: transparent;
    color: var(--text);
}

.btn-primary {
    background: var(--primary);
    color: var(--bg-card);
    border-color: var(--primary);
}

.btn-primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
}

.btn-secondary {
    background: var(--bg-card);
    border-color: var(--border);
    color: var(--text);
}

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

.btn-ghost {
    background: transparent;
    border-color: transparent;
    color: var(--text-secondary);
}

.btn-ghost:hover {
    background: var(--bg);
    color: var(--text);
}

.btn-danger {
    background: var(--danger);
    color: var(--bg-card);
    border-color: var(--danger);
}

.btn-danger:hover {
    background: var(--danger);
    opacity: 0.85;
    border-color: var(--danger);
}

.btn-sm { padding: 4px 10px; font-size: 12px; }
button:disabled,
.btn-disabled { opacity: 0.5; cursor: not-allowed; }

.mt-2 { margin-top: 8px; }

/* ===== Stats ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    cursor: pointer;
    transition: all var(--transition);
    box-shadow: var(--shadow);
}

.stat-card:hover {
    border-color: var(--primary);
    transform: translateY(-1px);
}

.stat-card.active {
    border-color: var(--primary);
    background: var(--primary-light);
}

.stat-value {
    font-size: 22px;
    font-weight: 700;
    line-height: 1.2;
}

.stat-value.stat-blue { color: var(--primary); }
.stat-value.stat-amber { color: var(--amber); }
.stat-value.stat-green { color: var(--success); }
.stat-value.stat-red { color: var(--danger); }

.stat-label {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ===== Filters ===== */
.filters-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.filter-dropdown {
    position: relative;
}

.filter-dropdown-trigger {
    display: inline-flex;
    align-items: center;
    box-sizing: border-box;
    height: 32px;
    padding: 0 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-card);
    font-size: 13px;
    cursor: pointer;
    transition: all var(--transition);
    font-family: inherit;
    color: var(--text);
}

input.input,
select.input,
.form-group .input {
    box-sizing: border-box;
    height: 32px;
    padding: 0 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-card);
    font-size: 13px;
    font-family: inherit;
    color: var(--text);
    outline: none;
    transition: all var(--transition);
}

input.input:focus,
select.input:focus,
.form-group .input:focus {
    border-color: var(--primary);
}

.filter-dropdown-trigger:hover,
.filter-dropdown-trigger:focus,
.filter-dropdown-trigger:focus-visible {
    border-color: var(--primary);
    outline: none;
}

.filter-dropdown-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    min-width: 180px;
    z-index: 100;
    display: none;
    flex-direction: column;
    padding: 6px;
    gap: 2px;
}

.dropdown-item {
    padding: 8px 12px;
    font-size: 13px;
    color: var(--text);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: background var(--transition), color var(--transition);
}

.dropdown-item:hover,
.dropdown-item:focus,
.dropdown-item:focus-visible {
    background: var(--bg);
    outline: none;
}

.dropdown-item.active {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 500;
}

.filter-dropdown.open .filter-dropdown-menu {
    display: flex;
}

.filter-dropdown-menu label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    font-size: 13px;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: background var(--transition);
    color: var(--text);
    white-space: nowrap;
}

.filter-dropdown-menu label:hover,
.filter-dropdown-menu label:focus-within {
    background: var(--bg);
    outline: none;
}

.filter-group {
    display: flex;
    gap: 6px;
}

.filter-chip {
    padding: 5px 12px;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    font-size: 12px;
    cursor: pointer;
    transition: all var(--transition);
    font-family: inherit;
    color: var(--text);
}

.filter-chip:hover { border-color: var(--primary); }
.filter-chip.active {
    background: var(--primary);
    color: var(--bg-card);
    border-color: var(--primary);
}

/* ===== Table ===== */
.table-container {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table th {
    text-align: left;
    padding: 10px 16px;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
}

.data-table tbody tr { transition: background var(--transition); cursor: pointer; }
.data-table tbody tr:hover { background: var(--bg); }
.data-table tbody tr:last-child td { border-bottom: none; }

/* Drilldown modal table specific styling */
#drilldownModal .modal-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 20px;
    overflow: hidden; /* We want the table container to scroll, not the body */
}

#drilldownModal .table-container {
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

#drilldownModal .data-table {
    table-layout: fixed;
    width: 100%;
}

#drilldownModal .data-table th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--bg); /* To cover rows scrolling underneath */
}

/* Prevent Telegram links from overflowing */
#drilldownModal .data-table td {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cell-main {
    display: flex;
    align-items: center;
    gap: 10px;
}

.cell-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    flex-shrink: 0;
}

.cell-main-title {
    font-weight: 500;
    font-size: 13px;
}

.cell-main-meta {
    font-size: 12px;
    color: var(--text-muted);
}

/* ===== Board (Swimlane) ===== */
.board {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.board-row {
    display: flex;
    gap: 12px;
    align-items: stretch;
    min-height: 140px;
}

.board-column {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.board-cards {
    background: var(--bg);
    border-radius: var(--radius);
    border: 1px solid var(--border-light);
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-height: 80px;
    flex: 1;
}

/* ===== Kanban ===== */
.kanban-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.toggle-leads {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
}

.toggle-leads input {
    cursor: pointer;
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
}

#page-kanban.page.active {
    display: flex;
    flex-direction: column;
    max-width: 100%;
}

.kanban-board {
    display: flex;
    flex-direction: column;
    min-width: 0;
    user-select: none;
}

.kanban-layout {
    display: flex;
    flex-direction: row;
    gap: 16px;
    align-items: flex-start;
    min-width: 0;
}

.kanban-leads-panel {
    width: 256px;
    flex-shrink: 0;
}

.kanban-students-area {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow-x: auto;
}

.kanban-column {
    display: flex;
    flex-direction: column;
}

.kanban-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--bg);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
}

.kanban-count {
    background: var(--bg);
    padding: 1px 7px;
    border-radius: 10px;
    font-size: 11px;
    border: 1px solid var(--border);
    font-weight: 600;
    color: var(--text-secondary);
}

.kanban-col-headers {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
    flex-shrink: 0;
}

.kanban-col-header {
    flex: 1;
    min-width: 140px;
    padding: 0;
}

.kanban-swimlanes {
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    min-width: 0;
    gap: 16px;
}

.kanban-swimlane-wrapper {
    display: grid;
    grid-template-rows: 1fr;
    transition: grid-template-rows 0.3s ease, opacity 0.3s ease, margin 0.3s ease;
    opacity: 1;
}

.kanban-swimlane-wrapper.filtered-out {
    grid-template-rows: 0fr;
    opacity: 0;
    margin-bottom: -16px;
    pointer-events: none;
}

.kanban-swimlane {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    position: relative;
    flex-shrink: 0;
    overflow: hidden;
    min-height: 0;
}

.kanban-swimlane-label {
    margin-bottom: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.kanban-swimlane-cells-wrapper {
    display: grid;
    grid-template-rows: 1fr;
    transition: grid-template-rows 300ms ease;
    width: 100%;
}

.kanban-swimlane.collapsed .kanban-swimlane-cells-wrapper {
    grid-template-rows: 0fr;
}

.kanban-swimlane-cells {
    overflow: hidden;
    min-height: 0;
    display: flex;
    gap: 8px;
    width: 100%;
    min-width: max-content;
}

.kanban-cell {
    flex: 1;
    min-width: 140px;
    padding: 4px;
}

.kanban-cards {
    min-height: 90px;
    border-radius: var(--radius-sm);
    transition: background 150ms ease;
    background: var(--bg-hover);
    border: 1px solid var(--border-light);
    padding: 8px;
}

.kanban-cards.drag-over {
    background: rgba(37, 99, 235, 0.06);
    outline: 2px dashed var(--primary);
    outline-offset: -2px;
}

.kanban-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    margin-bottom: 8px;
    cursor: grab;
    box-shadow: var(--shadow);
    transition: all var(--transition);
    touch-action: none; /* Crucial for pointer events */
    user-select: none;
    position: relative;
}

.kanban-card:active {
    cursor: grabbing;
}

.kanban-card:hover {
    border-color: var(--primary);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.dragging-placeholder {
    opacity: 0.3 !important;
    background: var(--bg-hover) !important;
    border: 1px dashed var(--border) !important;
}

.drag-overlay-clone {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 99999;
    pointer-events: none;
    box-shadow: 0 10px 25px rgba(0,0,0,0.15);
    background: var(--bg-card) !important;
    opacity: 1 !important;
    margin: 0 !important;
    cursor: grabbing;
}

.kanban-card-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--text);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.kanban-card-tg {
    font-size: 13px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: inline-block;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.2s, color 0.2s;
}

.kanban-card-tg:hover {
    color: var(--primary);
    text-decoration: underline;
}

.kanban-card-lead {
    border-left: 3px solid var(--primary);
    padding-left: 9px;
}

.kanban-more {
    margin-top: 4px;
    width: 100%;
}

.kanban-empty {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
    font-size: 14px;
}

/* ===== Drawer ===== */
.drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.35);
    z-index: 50;
    display: none;
}

.drawer-overlay.open { display: block; }

.drawer {
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    width: 874px;
    max-width: 95vw;
    background: var(--bg-card);
    border-left: 1px solid var(--border);
    z-index: 51;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 300ms ease;
}

.drawer.open { transform: translateX(0); }

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

.drawer-header h2 {
    font-size: 16px;
    font-weight: 600;
}

.drawer-close {
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color var(--transition);
}

.drawer-close:hover { color: var(--text); }

.drawer-body {
    flex: 1;
    overflow: auto;
    padding: 16px;
}

.drawer-layout {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.drawer-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.drawer-sidebar {
    display: grid;
    grid-template-columns: 1.3fr 1fr;
    gap: 16px;
}

@media (max-width: 520px) {
    .drawer-sidebar {
        grid-template-columns: 1fr;
    }
}

.drawer-section {
    background: var(--bg);
    border-radius: var(--radius);
    padding: 14px;
}

.drawer-section-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 10px;
}

.drawer-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
}

.details-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid var(--border-light);
    font-size: 14px;
    gap: 12px;
}

.detail-row:last-child { border-bottom: none; }

.detail-label { color: var(--text-secondary); flex-shrink: 0; max-width: 55%; }

.info-value { white-space: nowrap; }

.status-select {
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    font-size: 13px;
    font-family: inherit;
    background: var(--bg);
    cursor: pointer;
    outline: none;
}

.status-select:focus { border-color: var(--primary); }

.people-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.people-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    padding: 5px 0;
}

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

.timeline {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.timeline-item {
    padding-left: 12px;
    border-left: 2px solid var(--border);
    position: relative;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -5px;
    top: 4px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--border);
}

.timeline-date {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.timeline-text {
    font-size: 13px;
}

/* ===== Modal ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.35);
    z-index: 60;
    display: none;
}

.modal-overlay.open { display: block; }

.modal {
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%) scale(0.96);
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 640px;
    max-width: 92vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    z-index: 61;
    opacity: 0;
    pointer-events: none;
    transition: all 200ms ease;
}

.modal.open {
    opacity: 1;
    pointer-events: auto;
    transform: translate(-50%, -50%) scale(1);
    display: flex !important;
}

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

.modal-header h3 {
    font-size: 15px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color var(--transition);
}

.modal-close:hover { color: var(--text); }

.modal-body {
    padding: 20px;
    overflow-y: auto;
    scrollbar-gutter: stable;
    flex: 1;
    min-height: 0;
}

#usersModal .modal-body {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border-light);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* ===== Form ===== */
.form-group { margin-bottom: 12px; }
.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: inherit;
    outline: none;
    transition: border var(--transition);
    background: var(--bg);
    color: var(--text);
}

.form-group input,
.form-group select {
    height: 36px;
}

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

.form-group select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23555' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 32px;
}

.form-group input[type="date"] {
    position: relative;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23555' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='18' rx='2' ry='2'%3E%3C/rect%3E%3Cline x1='16' y1='2' x2='16' y2='6'%3E%3C/line%3E%3Cline x1='8' y1='2' x2='8' y2='6'%3E%3C/line%3E%3Cline x1='3' y1='10' x2='21' y2='10'%3E%3C/line%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 32px;
}

.form-group input[type="date"]::-webkit-calendar-picker-indicator {
    opacity: 0;
    position: absolute;
    right: 8px;
    left: auto;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    cursor: pointer;
    background: transparent;
    color: transparent;
    border: none;
    outline: none;
}

.form-group input[type="date"]::-webkit-calendar-picker-indicator:hover,
.form-group input[type="date"]::-webkit-calendar-picker-indicator:focus,
.form-group input[type="date"]::-webkit-calendar-picker-indicator:active {
    background: transparent;
    color: transparent;
    opacity: 0;
}

[data-theme="dark"] .form-group select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23aaa' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}

[data-theme="dark"] .form-group input[type="date"] {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23aaa' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='18' rx='2' ry='2'%3E%3C/rect%3E%3Cline x1='16' y1='2' x2='16' y2='6'%3E%3C/line%3E%3Cline x1='8' y1='2' x2='8' y2='6'%3E%3C/line%3E%3Cline x1='3' y1='10' x2='21' y2='10'%3E%3C/line%3E%3C/svg%3E");
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--primary);
}

.form-group.required-empty input,
.form-group.required-empty select,
.form-group.required-empty textarea {
    border-color: var(--amber) !important;
    box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.25);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

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

.toast {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    padding: 12px 16px;
    border-radius: 12px;
    background: #1F2937;
    color: #ffffff;
    font-size: 13px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    opacity: 0;
    transform: translateX(100%);
    transition: opacity 300ms ease-out, transform 300ms ease-out;
}

.toast.show {
    opacity: 1;
    transform: translateX(0);
}

.toast svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.toast-success svg { color: #10B981; }
.toast-error svg { color: #EF4444; }

/* ===== Badges ===== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}

.badge-blue { background: #dbeafe; color: #1e40af; }
.badge-green { background: #dcfce7; color: #166534; }
.badge-red { background: #fee2e2; color: #991b1b; }
.badge-amber { background: #fef3c7; color: #92400e; }
.badge-gray { background: #f1f5f9; color: #475569; }

/* Larger badges for kanban/board headers */
.kanban-header .badge,
.board-title .badge {
    font-size: 14px;
    padding: 4px 12px;
    border-radius: 6px;
}

/* ===== Archive ===== */
.archive-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.archive-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition);
}

.archive-item:hover { background: var(--border-light); }

/* ===== Analytics ===== */
.analytics-layout {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.analytics-tabs {
    display: flex;
    gap: 4px;
}

.analytics-tab {
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-secondary);
    transition: all var(--transition);
    font-family: inherit;
}

.analytics-tab:hover { background: var(--bg); }
.analytics-tab.active {
    background: var(--primary-light);
    color: var(--primary);
    border-color: var(--primary);
}

.chart-tabs {
    display: flex;
    gap: 4px;
}

.chart-tab {
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-secondary);
    transition: all var(--transition);
    font-family: inherit;
}

.chart-tab:hover { background: var(--bg); }
.chart-tab.active {
    background: var(--primary-light);
    color: var(--primary);
    border-color: var(--primary);
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
    max-width: 720px;
    margin: 0 auto;
}

.oe-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.oe-total {
    margin-top: 16px;
    font-size: 16px;
    font-weight: 600;
    text-align: right;
    color: var(--text);
}

.metric-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.metric-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.metric-value {
    font-size: 36px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.2;
}

.metric-sub {
    font-size: 12px;
    color: var(--text-muted);
}

/* ===== Chart ===== */
.funnel-container {
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 28px 32px;
}

.view-toggle-container {
    max-width: 800px;
    margin: 0 auto 16px;
    display: flex;
    justify-content: flex-start;
}

.view-toggle {
    display: inline-flex;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 4px;
}

.view-toggle-btn {
    padding: 6px 16px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    background: transparent;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.view-toggle-btn.active {
    background: var(--bg);
    color: var(--text);
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.funnel-chart-wrapper {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.funnel-row {
    display: flex;
    gap: 20px;
    align-items: center;
    min-height: 56px;
}

.funnel-metric {
    width: 280px;
    flex: 0 0 280px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.funnel-visual {
    flex-grow: 1;
    display: flex;
    justify-content: center;
    transition: justify-content 0.3s ease;
}

.mode-pipeline .funnel-visual {
    justify-content: flex-start;
}

.funnel-pill {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 44px;
    border-radius: 10px;
    color: #fff;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    box-shadow: inset 0 0 0 1px rgba(0,0,0,0.05);
    white-space: nowrap;
    overflow: hidden;
    min-width: 90px;
    transition: width 0.3s ease, justify-content 0.3s ease, background 0.3s ease, opacity 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.funnel-pill:hover {
    opacity: 0.9;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    transform: translateY(-1px);
}

.funnel-pill:active {
    transform: translateY(1px);
    opacity: 1;
    box-shadow: inset 0 0 0 2px rgba(0,0,0,0.2);
}

.funnel-filters {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.funnel-filter-title {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

.funnel-filter-group {
    display: flex;
    gap: 8px;
}

.funnel-filter-chip {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    font-size: 12px;
    cursor: pointer;
    font-family: inherit;
}

.funnel-filter-chip input {
    cursor: pointer;
}

.funnel-chart {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
    width: 100%;
}

.funnel-label {
    width: 140px;
    font-size: 12px;
    font-weight: 500;
    text-align: right;
    flex-shrink: 0;
}

.funnel-track {
    flex: 1;
    height: 28px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    overflow: hidden;
    position: relative;
}

.funnel-fill {
    height: 100%;
    border-radius: var(--radius-sm);
    transition: width 600ms ease;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 10px;
    color: var(--bg-card);
    font-size: 12px;
    font-weight: 600;
}

/* ===== Preview overlay ===== */
.preview-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 70;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.preview-overlay.open { display: flex; }

.preview-panel {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 80vw;
    height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: all 300ms ease;
}

.preview-panel.expanded {
    width: 98vw;
    height: 94vh;
}

.preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
    flex-shrink: 0;
}

.preview-title {
    font-weight: 600;
    font-size: 14px;
}

.preview-actions {
    display: flex;
    gap: 6px;
}

.preview-close {
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color var(--transition);
}

.preview-close:hover { color: var(--text); }

.preview-body {
    flex: 1;
    overflow: auto;
    padding: 20px;
}

/* ===== Utilities ===== */
.hidden { display: none !important; }

/* ===== Payouts page ===== */
.payout-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

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

.date-range label {
    font-size: 13px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.date-range input[type="date"] {
    padding: 5px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: inherit;
    outline: none;
}

.date-range input[type="date"]:focus {
    border-color: var(--primary);
}

.metric-card-sm {
    padding: 16px;
    gap: 4px;
}

.metric-card-sm .metric-value {
    font-size: 24px;
}

.metric-card-sm .metric-label {
    font-size: 11px;
}

.payout-summary-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 20px;
    max-width: 720px;
}

.payout-table-wrap {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.payout-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    table-layout: fixed;
}

.payout-table thead {
    display: table;
    width: 100%;
    table-layout: fixed;
}

.payout-table tbody {
    display: block;
    max-height: calc(100vh - 300px);
    overflow-y: auto;
    width: 100%;
}

.payout-table tbody tr {
    display: table;
    width: 100%;
    table-layout: fixed;
    transition: background var(--transition);
    cursor: pointer;
}

.payout-table tbody tr:nth-child(even) {
    background: var(--border-light);
}

.payout-table tbody tr:hover {
    background: var(--bg);
}

.payout-table th {
    text-align: left;
    padding: 10px 12px;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
}

.payout-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.payout-table th:last-child,
.payout-table td:last-child {
    text-align: right;
}

.text-right { text-align: right !important; }
.text-mono {
    font-variant-numeric: tabular-nums;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

/* ===== Missing styles restored ===== */

/* Archive */
.archive-item-main {
    display: flex;
    align-items: center;
    gap: 10px;
}

.archive-item-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.archive-item-name {
    font-weight: 500;
    font-size: 13px;
}

.archive-item-meta {
    font-size: 12px;
    color: var(--text-muted);
}

/* Artifacts */
.artifact-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.artifact-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition);
}

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

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

.artifact-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    background: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    flex-shrink: 0;
}

.artifact-name {
    font-size: 13px;
    font-weight: 500;
}

/* Attachment dropzone */
.attachment-dropzone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 24px;
    text-align: center;
    cursor: pointer;
    transition: border-color var(--transition);
    background: var(--bg);
}

.attachment-dropzone:hover {
    border-color: var(--primary);
}

/* Badge purple */
.badge-purple {
    background: #e9d5ff;
    color: #6b21a8;
}

/* Board (used in forms/yandex) */
.board-title {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 4px;
}

.board-count {
    font-size: 12px;
    color: var(--text-muted);
}

/* Buddy assign dropdown */
.buddy-assign {
    position: relative;
}

.buddy-assign-input {
    width: 100%;
    padding: 5px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: inherit;
    outline: none;
    background: var(--bg);
}

.buddy-assign-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text);
    cursor: pointer;
    font-size: 13px;
    height: 32px;
    user-select: none;
    transition: border-color var(--transition), background-color var(--transition);
}

.buddy-assign-trigger:hover {
    border-color: var(--primary);
    background: var(--bg-hover);
}

.buddy-assign-chevron {
    color: var(--text-secondary);
    flex-shrink: 0;
    transition: transform var(--transition);
}

.buddy-assign-current-value {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.buddy-assign-menu {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    width: 240px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    z-index: 100;
    display: flex;
    flex-direction: column;
    max-height: 280px;
    overflow: hidden;
}

.buddy-search-container {
    padding: 8px;
    border-bottom: 1px solid var(--border-light);
    background: var(--bg-card);
    flex-shrink: 0;
}

.buddy-search-input {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    outline: none;
    background: var(--bg);
    color: var(--text);
}

.buddy-search-input:focus {
    border-color: var(--primary);
}

.buddy-options-list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
}

.buddy-assign-item {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 13px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    transition: background var(--transition);
    border-bottom: 1px solid var(--border-light);
}

.buddy-assign-item:last-child {
    border-bottom: none;
}

.buddy-assign-item:hover,
.buddy-assign-item:focus,
.buddy-assign-item:focus-visible {
    background: var(--bg-hover);
    outline: none;
}

.buddy-assign-name {
    font-weight: 500;
    color: var(--text);
}

.buddy-assign-tg {
    font-size: 11px;
    color: var(--text-muted);
}

/* Cell variants */
.cell-name {
    font-weight: 500;
    font-size: 13px;
}

.cell-meta {
    font-size: 12px;
    color: var(--text-muted);
}

.cell-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* Funnel (actual JS structure) */
.funnel-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    max-width: 100%;
}

.funnel-bar {
    height: auto;
    min-height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    color: var(--bg-card);
    font-size: 14px;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0,0,0,0.15);
    transition: width 600ms ease, transform 150ms ease, box-shadow 150ms ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.08);
    min-width: 140px;
    flex-shrink: 0;
    max-width: calc(100% - 52px);
    text-align: center;
    flex-wrap: wrap;
}

.funnel-bar:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.12);
    z-index: 1;
}

.funnel-bar-text {
    line-height: 1.3;
}

.funnel-pct {
    font-size: 14px;
    color: var(--text-muted);
    font-weight: 500;
    min-width: 40px;
    text-align: left;
    flex-shrink: 0;
}

.funnel-bottleneck {
    box-shadow: 0 0 0 3px #f59e0b, 0 2px 4px rgba(0,0,0,0.08) !important;
}

/* Info value (drawer) */
.info-value {
    font-weight: 600;
    font-size: 14px;
    color: var(--text);
    text-align: right;
    word-break: break-word;
    min-width: 80px;
}

/* People value */
.people-value {
    font-weight: 500;
    font-size: 14px;
    color: var(--text);
}

.people-value.text-muted {
    color: var(--text-muted);
    font-weight: 400;
}


/* ===== Auth Overlay ===== */
.auth-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    backdrop-filter: blur(4px);
}

.auth-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 32px;
    width: 100%;
    max-width: 360px;
    border: 1px solid var(--border);
}

.auth-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    background: var(--bg);
    color: var(--text);
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.auth-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.auth-toggle {
    font-size: 13px;
    color: var(--text-secondary);
}

.auth-toggle a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.auth-toggle a:hover {
    text-decoration: underline;
}

/* User card logout button */
#userCard {
    align-items: center;
}

/* Disabled toggle for mentor */
.disabled-toggle {
    opacity: 0.5;
    cursor: not-allowed;
    color: var(--text-muted);
}

.disabled-toggle input {
    cursor: not-allowed;
}


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

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    display: inline-block;
}

.loading-text {
    color: var(--text-muted);
    font-size: 14px;
}

#kanbanBuddyFilterMenu {
    min-width: 240px;
}

/* ===== Custom DatePicker (Flatpickr) Overrides ===== */
.flatpickr-calendar {
    background: var(--bg-card) !important;
    border: 1px solid var(--border) !important;
    border-radius: 12px !important;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08) !important;
    font-family: 'Inter', sans-serif !important;
    width: 284px !important;
    padding: 16px !important;
    box-sizing: content-box !important;
    z-index: 999999 !important;
    transition: none !important;
}

[data-theme="dark"] .flatpickr-calendar {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3) !important;
}

/* Minimalist Header (Month / Year / Arrows) */
.flatpickr-months {
    display: flex !important;
    align-items: center !important;
    position: relative !important;
    margin-bottom: 12px !important;
    height: 32px !important;
}

.flatpickr-current-month {
    font-size: 15px !important;
    font-weight: 600 !important;
    color: var(--text) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 4px !important;
    width: 100% !important;
    left: 0 !important;
    position: static !important;
    padding: 0 !important;
}

.flatpickr-current-month .flatpickr-monthDropdown-months {
    font-weight: 600 !important;
    color: var(--text) !important;
    font-size: 15px !important;
    background: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E") no-repeat right 4px center !important;
    border: none !important;
    padding: 0 20px 0 4px !important;
    cursor: pointer !important;
    margin: 0 !important;
    appearance: none !important;
    -webkit-appearance: none !important;
    border-radius: 4px !important;
    transition: background 0.2s !important;
}

.flatpickr-current-month .flatpickr-monthDropdown-months:hover {
    color: var(--primary) !important;
    background-color: rgba(0, 0, 0, 0.05) !important;
}

[data-theme="dark"] .flatpickr-current-month .flatpickr-monthDropdown-months:hover {
    background-color: rgba(255, 255, 255, 0.1) !important;
}

.flatpickr-current-month input.cur-year {
    font-weight: 600 !important;
    color: var(--text) !important;
    font-size: 15px !important;
    background: transparent !important;
    border: none !important;
    padding: 0 4px !important;
    margin: 0 !important;
    width: 52px !important;
    cursor: text !important;
    border-radius: 4px !important;
}

.flatpickr-current-month input.cur-year:focus {
    outline: none !important;
    background: var(--primary) !important;
    color: white !important;
}

.flatpickr-current-month .numInputWrapper span {
    display: none !important; /* Hide default spin buttons */
}

/* Calendar Arrow Buttons */
.flatpickr-prev-month,
.flatpickr-next-month {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 32px !important;
    height: 32px !important;
    padding: 0 !important;
    border-radius: 8px !important;
    transition: background-color var(--transition) !important;
    color: var(--text-secondary) !important;
    top: 0px !important;
}

.flatpickr-prev-month:hover,
.flatpickr-next-month:hover {
    background: var(--bg-hover) !important;
    color: var(--text) !important;
}

.flatpickr-prev-month svg,
.flatpickr-next-month svg {
    width: 10px !important;
    height: 10px !important;
    fill: currentColor !important;
    stroke: none !important;
}

/* Weekday Labels Grid */
.flatpickr-weekdays {
    display: flex !important;
    background: transparent !important;
    margin-bottom: 8px !important;
    width: auto !important;
}

.flatpickr-weekdaycontainer {
    display: grid !important;
    grid-template-columns: repeat(7, 36px) !important;
    gap: 5px !important;
    width: auto !important;
}

span.flatpickr-weekday {
    color: var(--text-muted) !important;
    font-size: 12px !important;
    font-weight: 500 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    height: 24px !important;
    width: 36px !important;
}

/* Days Container Grid */
.flatpickr-days {
    width: auto !important;
}

.dayContainer {
    display: grid !important;
    grid-template-columns: repeat(7, 36px) !important;
    gap: 5px !important;
    width: auto !important;
    min-width: auto !important;
    max-width: auto !important;
}

/* Day Cells */
.flatpickr-day {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    color: var(--text) !important;
    font-weight: 400 !important;
    font-size: 13px !important;
    height: 36px !important;
    width: 36px !important;
    max-width: 36px !important;
    margin: 0 !important;
    border: 1px solid transparent !important;
    border-radius: 50% !important;
    transition: background-color var(--transition), color var(--transition) !important;
}

/* Hover state */
.flatpickr-day:hover,
.flatpickr-day:focus {
    background: var(--bg-hover) !important;
    border-color: transparent !important;
    color: var(--text) !important;
}

/* Today state (light bg + primary blue dot underneath, no borders) */
.flatpickr-day.today {
    font-weight: 600 !important;
    color: var(--primary) !important;
    background: var(--bg-hover) !important;
    border-color: transparent !important;
    position: relative !important;
}

.flatpickr-day.today::after {
    content: '' !important;
    position: absolute !important;
    bottom: 4px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    width: 4px !important;
    height: 4px !important;
    background-color: var(--primary) !important;
    border-radius: 50% !important;
}

/* Selected state */
.flatpickr-day.selected,
.flatpickr-day.selected:hover,
.flatpickr-day.selected:focus {
    background: var(--primary) !important;
    border-color: var(--primary) !important;
    color: #ffffff !important;
}

.flatpickr-day.selected::after {
    background-color: #ffffff !important;
}

/* Muted non-current-month days */
.flatpickr-day.prevMonthDay,
.flatpickr-day.nextMonthDay {
    color: var(--text-muted) !important;
    background: transparent !important;
}

.flatpickr-day.prevMonthDay:hover,
.flatpickr-day.nextMonthDay:hover {
    background: var(--bg-hover) !important;
    color: var(--text) !important;
}

/* Custom Footer */
.flatpickr-footer {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    padding-top: 12px !important;
    margin-top: 12px !important;
    border-top: 1px solid var(--border) !important;
    background-color: var(--bg-card) !important;
}

.flatpickr-footer-btn {
    color: var(--primary) !important;
    cursor: pointer !important;
    font-weight: 500 !important;
    font-size: 13px !important;
    padding: 6px 12px !important;
    border-radius: 6px !important;
    transition: background-color var(--transition), color var(--transition) !important;
    user-select: none !important;
}

.flatpickr-footer-btn:hover {
    background-color: var(--bg-hover) !important;
    color: var(--primary-hover) !important;
}

/* User Roles and Table styles */
#page-users .table-container {
    max-width: 960px;
    margin: 0 auto;
}

#usersTable th:nth-child(1) { width: 40%; }
#usersTable th:nth-child(2) { width: 40%; }
#usersTable th:nth-child(3) { width: 15%; }
#usersTable th:nth-child(4) { width: 60px; text-align: center; }

#usersTable td {
    vertical-align: middle;
}

#usersTable tbody tr {
    transition: background-color 0.2s ease;
}
#usersTable tbody tr:hover {
    background-color: #F9FAFB;
}
[data-theme="dark"] #usersTable tbody tr:hover {
    background-color: rgba(255, 255, 255, 0.03);
}

.role-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}
.role-admin { background: #EDE9FE; color: #5B21B6; }
.role-founder { background: #DBEAFE; color: #1E40AF; }
.role-mentor { background: #D1FAE5; color: #065F46; }

.dark .role-admin { background: rgba(168, 85, 247, 0.2); color: #d8b4fe; }
.dark .role-founder { background: rgba(96, 165, 250, 0.2); color: #bfdbfe; }
.dark .role-mentor { background: rgba(52, 211, 153, 0.2); color: #a7f3d0; }

.user-avatar-sm {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    flex-shrink: 0;
}

.dropdown-item:hover {
    background-color: var(--bg-hover) !important;
}

.table-action-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.table-action-btn:hover {
    color: var(--text);
    background: var(--bg-hover);
}

/* Collapsible rule cards */
.card-body {
    overflow: hidden;
    transition: max-height 300ms ease, opacity 300ms ease;
    max-height: 2000px;
    opacity: 1;
}
.card-body.collapsed {
    max-height: 0;
    opacity: 0;
}

/* ===== Payment Links & Dropdown ===== */
.payment-dropdown {
    position: relative;
    display: inline-flex;
}

.payment-dropdown-content {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    background-color: var(--bg-card);
    min-width: 160px;
    box-shadow: 0px 8px 24px rgba(0,0,0,0.12);
    z-index: 1000;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    overflow: hidden;
}

.payment-dropdown-content a {
    color: var(--text);
    padding: 10px 16px;
    text-decoration: none;
    display: block;
    font-size: 13px;
    transition: background var(--transition);
    cursor: pointer;
}

.payment-dropdown-content a:hover {
    background-color: var(--bg-hover);
    color: var(--primary);
}

.payment-dropdown.show .payment-dropdown-content {
    display: block;
}

.payment-link-box {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
}
.payment-link-box input {
    flex: 1;
    border: none;
    background: transparent;
    color: var(--text);
    font-family: monospace;
    font-size: 13px;
    outline: none;
}



.glow-success {
    animation: glowSuccess 2s ease-out;
}
@keyframes glowSuccess {
    0% { box-shadow: 0 0 15px rgba(46, 204, 113, 0.6); border-color: #2ecc71; }
    100% { box-shadow: 0 0 0 rgba(46, 204, 113, 0); border-color: var(--border); }
}

