/* ==========================================================================
   Threadline CRM - SaaS Design System
   Neutral-led, high-density, Linear/Stripe inspired styling
   ========================================================================== */

:root {
	/* Brand Accent (Threadline Indigo) */
	--brand-50: #eef2ff;
	--brand-100: #e0e7ff;
	--brand-200: #c7d2fe;
	--brand-500: #6366f1;
	--brand-600: #4f46e5;
	--brand-700: #4338ca;
	--brand-800: #3730a3;
	--brand-fg: #4f46e5;
	--brand-bg-subtle: #eef2ff;

	/* Neutrals (Slate) */
	--neutral-0: #ffffff;
	--neutral-50: #f8fafc;
	--neutral-100: #f1f5f9;
	--neutral-200: #e2e8f0;
	--neutral-300: #cbd5e1;
	--neutral-400: #94a3b8;
	--neutral-500: #64748b;
	--neutral-600: #475569;
	--neutral-700: #334155;
	--neutral-800: #1e293b;
	--neutral-900: #0f172a;
	--neutral-950: #020617;

	/* Semantic surfaces */
	--bg-canvas: #f8fafc;
	--bg-surface: #ffffff;
	--bg-elevated: #ffffff;
	--bg-hover: #f1f5f9;

	--text-primary: #0f172a;
	--text-muted: #475569;
	--text-subtle: #94a3b8;

	--border-default: #e2e8f0;
	--border-strong: #cbd5e1;

	/* Status colors */
	--success-fg: #15803d;
	--success-bg: #dcfce7;
	--success-border: #86efac;

	--warning-fg: #a16207;
	--warning-bg: #fef9c3;
	--warning-border: #fde68a;

	--error-fg: #b91c1c;
	--error-bg: #fee2e2;
	--error-border: #fca5a5;

	--info-fg: #1d4ed8;
	--info-bg: #dbeafe;
	--info-border: #93c5fd;

	--purple-fg: #7e22ce;
	--purple-bg: #f3e8ff;
	--purple-border: #d8b4fe;

	/* Shadows */
	--shadow-xs: 0 1px 2px 0 rgba(15, 23, 42, 0.04);
	--shadow-sm: 0 1px 2px 0 rgba(15, 23, 42, 0.05), 0 1px 3px 0 rgba(15, 23, 42, 0.06);
	--shadow-md: 0 2px 4px -1px rgba(15, 23, 42, 0.06), 0 4px 6px -2px rgba(15, 23, 42, 0.04);
	--shadow-lg: 0 4px 6px -2px rgba(15, 23, 42, 0.05), 0 10px 15px -3px rgba(15, 23, 42, 0.08);
	--shadow-xl: 0 8px 10px -4px rgba(15, 23, 42, 0.06), 0 20px 25px -5px rgba(15, 23, 42, 0.10);
	--ring-focus: 0 0 0 3px rgba(79, 70, 229, 0.20);
	--ring-error: 0 0 0 3px rgba(220, 38, 38, 0.16);

	/* Typography & Dimensions */
	--font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
	--font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, monospace;
	--radius-sm: 4px;
	--radius-md: 6px;
	--radius-lg: 8px;
	--radius-xl: 12px;
	--radius-2xl: 16px;
	--radius-full: 9999px;

	--sidebar-w: 240px;
	--topbar-h: 52px;

	--ease-out: cubic-bezier(0.16, 1, 0.3, 1);
	--duration-150: 150ms;
}

[data-theme="dark"],
.dark {
	--bg-canvas: #090d16;
	--bg-surface: #111726;
	--bg-elevated: #182032;
	--bg-hover: rgba(255, 255, 255, 0.05);

	--text-primary: #f1f5f9;
	--text-muted: #94a3b8;
	--text-subtle: #64748b;

	--border-default: #1e293b;
	--border-strong: #334155;

	--brand-fg: #818cf8;
	--brand-bg-subtle: rgba(99, 102, 241, 0.16);

	--success-fg: #4ade80;
	--success-bg: rgba(22, 163, 74, 0.16);
	--success-border: rgba(34, 197, 94, 0.3);

	--warning-fg: #facc15;
	--warning-bg: rgba(202, 138, 4, 0.16);
	--warning-border: rgba(234, 179, 8, 0.3);

	--error-fg: #f87171;
	--error-bg: rgba(220, 38, 38, 0.16);
	--error-border: rgba(239, 68, 68, 0.3);

	--info-fg: #60a5fa;
	--info-bg: rgba(37, 99, 235, 0.16);
	--info-border: rgba(59, 130, 246, 0.3);

	--purple-fg: #c084fc;
	--purple-bg: rgba(168, 85, 247, 0.16);
	--purple-border: rgba(168, 85, 247, 0.3);

	--shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.30);
	--shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.40);
	--shadow-md: 0 4px 8px -2px rgba(0, 0, 0, 0.50);
	--shadow-lg: 0 12px 20px -6px rgba(0, 0, 0, 0.55);
	--shadow-xl: 0 20px 32px -10px rgba(0, 0, 0, 0.60);
}

/* ==========================================================================
   Base resets
   ========================================================================== */
*, *::before, *::after {
	box-sizing: border-box;
}

html, body {
	margin: 0;
	padding: 0;
	height: 100%;
	background-color: var(--bg-canvas);
	color: var(--text-primary);
	font-family: var(--font-sans);
	font-size: 14px;
	line-height: 1.45;
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
}

#root {
	height: 100%;
	display: flex;
	flex-direction: column;
}

a {
	color: var(--brand-fg);
	text-decoration: none;
}
a:hover {
	text-decoration: underline;
}

button, input, select, textarea {
	font-family: inherit;
	font-size: inherit;
	color: inherit;
}

/* Tabular numbers for clean stats & dates */
.numeric, [data-numeric] {
	font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	height: 32px;
	padding: 0 12px;
	border-radius: var(--radius-md);
	font-size: 13px;
	font-weight: 500;
	cursor: pointer;
	border: 1px solid transparent;
	background: var(--brand-600);
	color: #ffffff;
	transition: background-color var(--duration-150) var(--ease-out), border-color var(--duration-150) var(--ease-out), box-shadow var(--duration-150) var(--ease-out);
	white-space: nowrap;
	user-select: none;
}

.btn:hover {
	background: var(--brand-700);
}

.btn:active {
	background: var(--brand-800);
}

.btn:focus-visible {
	outline: none;
	box-shadow: var(--ring-focus);
}

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

.btn-secondary {
	background: var(--bg-surface);
	color: var(--text-primary);
	border: 1px solid var(--border-default);
}
.btn-secondary:hover {
	background: var(--bg-hover);
	border-color: var(--border-strong);
}
.btn-secondary:active {
	background: var(--neutral-200);
}

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

.btn-destructive {
	background: #dc2626;
	color: #ffffff;
}
.btn-destructive:hover {
	background: #b91c1c;
}
.btn-destructive:focus-visible {
	box-shadow: var(--ring-error);
}

.btn-sm {
	height: 26px;
	padding: 0 8px;
	font-size: 12px;
	border-radius: var(--radius-sm);
}

.btn-lg {
	height: 38px;
	padding: 0 16px;
	font-size: 14px;
	border-radius: var(--radius-md);
}

.btn-icon {
	width: 32px;
	height: 32px;
	padding: 0;
	border-radius: var(--radius-md);
}
.btn-icon.btn-sm {
	width: 26px;
	height: 26px;
}

/* ==========================================================================
   Form inputs & fields
   ========================================================================== */
.field {
	display: flex;
	flex-direction: column;
	gap: 5px;
	margin-bottom: 14px;
}

.field label {
	font-size: 12px;
	font-weight: 500;
	color: var(--text-muted);
}

.input, .select, .textarea {
	width: 100%;
	height: 34px;
	padding: 0 10px;
	border-radius: var(--radius-md);
	border: 1px solid var(--border-default);
	background: var(--bg-surface);
	color: var(--text-primary);
	font-size: 13px;
	transition: border-color var(--duration-150) var(--ease-out), box-shadow var(--duration-150) var(--ease-out);
}

.input:focus, .select:focus, .textarea:focus {
	outline: none;
	border-color: var(--brand-fg);
	box-shadow: var(--ring-focus);
}

.input::placeholder, .textarea::placeholder {
	color: var(--text-subtle);
}

.textarea {
	height: auto;
	min-height: 72px;
	padding: 8px 10px;
	resize: vertical;
}

.input-error {
	border-color: #dc2626 !important;
}
.input-error:focus {
	box-shadow: var(--ring-error) !important;
}

.field-error {
	font-size: 11px;
	color: #dc2626;
	margin-top: 2px;
}

/* ==========================================================================
   Badges & Status Tags
   ========================================================================== */
.badge {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	padding: 2px 7px;
	border-radius: var(--radius-sm);
	font-size: 11px;
	font-weight: 500;
	line-height: 1.3;
	border: 1px solid transparent;
	white-space: nowrap;
}

.badge-dot {
	width: 6px;
	height: 6px;
	border-radius: var(--radius-full);
}

.badge-lead {
	background: var(--info-bg);
	color: var(--info-fg);
	border-color: var(--info-border);
}
.badge-lead .badge-dot { background: var(--info-fg); }

.badge-contacted, .badge-in_discussion {
	background: var(--purple-bg);
	color: var(--purple-fg);
	border-color: var(--purple-border);
}
.badge-contacted .badge-dot, .badge-in_discussion .badge-dot { background: var(--purple-fg); }

.badge-active {
	background: var(--success-bg);
	color: var(--success-fg);
	border-color: var(--success-border);
}
.badge-active .badge-dot { background: var(--success-fg); }

.badge-follow_up_needed {
	background: var(--warning-bg);
	color: var(--warning-fg);
	border-color: var(--warning-border);
}
.badge-follow_up_needed .badge-dot { background: var(--warning-fg); }

.badge-nurture {
	background: var(--brand-bg-subtle);
	color: var(--brand-fg);
	border-color: var(--brand-200);
}
.badge-nurture .badge-dot { background: var(--brand-fg); }

.badge-archived {
	background: var(--neutral-100);
	color: var(--neutral-600);
	border-color: var(--neutral-200);
}
.badge-archived .badge-dot { background: var(--neutral-400); }

.badge-priority-high {
	background: var(--error-bg);
	color: var(--error-fg);
	border-color: var(--error-border);
}

.badge-priority-medium {
	background: var(--warning-bg);
	color: var(--warning-fg);
	border-color: var(--warning-border);
}

.badge-priority-low {
	background: var(--neutral-100);
	color: var(--neutral-600);
	border-color: var(--neutral-200);
}

.tag-chip {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	padding: 1px 6px;
	border-radius: var(--radius-sm);
	font-size: 11px;
	background: var(--neutral-100);
	color: var(--text-muted);
	border: 1px solid var(--border-default);
}

/* ==========================================================================
   Cards & Panels
   ========================================================================== */
.card {
	background: var(--bg-surface);
	border: 1px solid var(--border-default);
	border-radius: var(--radius-lg);
	padding: 16px;
	box-shadow: var(--shadow-xs);
}

.kpi-card {
	background: var(--bg-surface);
	border: 1px solid var(--border-default);
	border-radius: var(--radius-lg);
	padding: 14px 16px;
	display: flex;
	flex-direction: column;
	justify-content: space-between;
	position: relative;
	overflow: hidden;
}
.kpi-card::before {
	content: '';
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	height: 2px;
	background: transparent;
}
.kpi-card.kpi-alert::before {
	background: #ca8a04;
}
.kpi-card.kpi-accent::before {
	background: var(--brand-600);
}
.kpi-card.kpi-success::before {
	background: #16a34a;
}

.kpi-title {
	font-size: 11px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: var(--text-muted);
	margin-bottom: 6px;
	display: flex;
	align-items: center;
	justify-content: space-between;
}

.kpi-value {
	font-size: 26px;
	font-weight: 700;
	line-height: 1.1;
	letter-spacing: -0.02em;
	color: var(--text-primary);
	font-variant-numeric: tabular-nums;
}

.kpi-subtext {
	font-size: 11px;
	color: var(--text-subtle);
	margin-top: 4px;
}

/* ==========================================================================
   Application Shell Layout
   ========================================================================== */
.app-layout {
	display: flex;
	height: 100vh;
	width: 100vw;
	overflow: hidden;
}

.sidebar {
	width: var(--sidebar-w);
	background: var(--bg-surface);
	border-right: 1px solid var(--border-default);
	display: flex;
	flex-direction: column;
	flex-shrink: 0;
	z-index: 20;
	transition: transform var(--duration-150) var(--ease-out);
}

.sidebar-header {
	height: var(--topbar-h);
	padding: 0 16px;
	display: flex;
	align-items: center;
	gap: 10px;
	border-bottom: 1px solid var(--border-default);
}

.app-brand {
	display: flex;
	align-items: center;
	gap: 8px;
	font-weight: 700;
	font-size: 15px;
	letter-spacing: -0.01em;
	color: var(--text-primary);
}

.brand-icon {
	width: 26px;
	height: 26px;
	background: linear-gradient(135deg, var(--brand-600), #7c3aed);
	border-radius: var(--radius-md);
	display: flex;
	align-items: center;
	justify-content: center;
	color: #fff;
	font-weight: 800;
	font-size: 13px;
	box-shadow: 0 2px 4px rgba(79, 70, 229, 0.3);
}

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

.nav-section-label {
	font-size: 11px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	color: var(--text-subtle);
	padding: 10px 8px 4px;
}

.nav-item {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 7px 10px;
	border-radius: var(--radius-md);
	font-size: 13px;
	font-weight: 500;
	color: var(--text-muted);
	cursor: pointer;
	border: none;
	background: transparent;
	width: 100%;
	text-align: left;
	transition: background-color var(--duration-150) var(--ease-out), color var(--duration-150) var(--ease-out);
}

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

.nav-item.active {
	background: var(--brand-bg-subtle);
	color: var(--brand-fg);
	font-weight: 600;
}

.nav-item .badge-count {
	margin-left: auto;
	font-size: 11px;
	background: var(--neutral-200);
	color: var(--neutral-700);
	padding: 1px 6px;
	border-radius: var(--radius-full);
}

.dark .nav-item .badge-count {
	background: var(--neutral-800);
	color: var(--neutral-300);
}

.nav-item.active .badge-count {
	background: var(--brand-200);
	color: var(--brand-800);
}
.dark .nav-item.active .badge-count {
	background: rgba(99, 102, 241, 0.3);
	color: #c7d2fe;
}

.sidebar-footer {
	padding: 12px;
	border-top: 1px solid var(--border-default);
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.user-profile-bar {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 6px 8px;
	border-radius: var(--radius-md);
	background: var(--bg-canvas);
	border: 1px solid var(--border-default);
}

.user-avatar {
	width: 30px;
	height: 30px;
	border-radius: var(--radius-full);
	background: linear-gradient(135deg, #4f46e5, #06b6d4);
	color: #ffffff;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 12px;
	font-weight: 600;
	flex-shrink: 0;
}

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

.user-name {
	font-size: 12px;
	font-weight: 600;
	color: var(--text-primary);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.user-email {
	font-size: 11px;
	color: var(--text-subtle);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

/* Content Area */
.main-wrapper {
	flex: 1;
	display: flex;
	flex-direction: column;
	min-width: 0;
	overflow: hidden;
}

.topbar {
	height: var(--topbar-h);
	background: var(--bg-surface);
	border-bottom: 1px solid var(--border-default);
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 0 20px;
	flex-shrink: 0;
	gap: 12px;
}

.topbar-left {
	display: flex;
	align-items: center;
	gap: 12px;
	flex: 1;
	max-width: 480px;
}

.search-input-wrap {
	position: relative;
	width: 100%;
	display: flex;
	align-items: center;
}

.search-input-wrap svg {
	position: absolute;
	left: 10px;
	color: var(--text-subtle);
	pointer-events: none;
}

.search-input-wrap input {
	padding-left: 32px;
	padding-right: 28px;
	height: 32px;
	font-size: 13px;
	background: var(--bg-canvas);
}

.search-input-wrap .clear-btn {
	position: absolute;
	right: 6px;
	background: none;
	border: none;
	color: var(--text-subtle);
	cursor: pointer;
	padding: 4px;
	border-radius: var(--radius-sm);
}
.search-input-wrap .clear-btn:hover {
	color: var(--text-primary);
}

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

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

/* ==========================================================================
   Page Headers & Controls
   ========================================================================== */
.page-header {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 16px;
	margin-bottom: 20px;
	flex-wrap: wrap;
}

.page-title {
	font-size: 20px;
	font-weight: 700;
	letter-spacing: -0.02em;
	color: var(--text-primary);
	margin: 0;
}

.page-description {
	font-size: 13px;
	color: var(--text-muted);
	margin-top: 2px;
}

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

.view-tabs {
	display: inline-flex;
	background: var(--bg-surface);
	border: 1px solid var(--border-default);
	border-radius: var(--radius-md);
	padding: 2px;
	gap: 2px;
}

.view-tab-btn {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	padding: 4px 10px;
	font-size: 12px;
	font-weight: 500;
	color: var(--text-muted);
	background: transparent;
	border: none;
	border-radius: var(--radius-sm);
	cursor: pointer;
	transition: all var(--duration-150) var(--ease-out);
}

.view-tab-btn:hover {
	color: var(--text-primary);
}

.view-tab-btn.active {
	background: var(--bg-hover);
	color: var(--text-primary);
	font-weight: 600;
	box-shadow: var(--shadow-xs);
}

/* ==========================================================================
   Filters Bar
   ========================================================================== */
.filters-bar {
	display: flex;
	align-items: center;
	gap: 8px;
	margin-bottom: 16px;
	flex-wrap: wrap;
	background: var(--bg-surface);
	border: 1px solid var(--border-default);
	border-radius: var(--radius-lg);
	padding: 8px 12px;
}

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

.filter-select {
	height: 30px;
	font-size: 12px;
	padding: 0 8px;
	background: var(--bg-canvas);
	border: 1px solid var(--border-default);
	border-radius: var(--radius-md);
	color: var(--text-primary);
}

.filter-chip-clear {
	font-size: 12px;
	color: var(--brand-fg);
	background: none;
	border: none;
	cursor: pointer;
	padding: 4px 6px;
	border-radius: var(--radius-sm);
}
.filter-chip-clear:hover {
	background: var(--brand-bg-subtle);
}

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

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

.data-table th {
	background: var(--bg-canvas);
	padding: 10px 14px;
	text-align: left;
	font-size: 11px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: var(--text-muted);
	border-bottom: 1px solid var(--border-default);
	white-space: nowrap;
}

.data-table td {
	padding: 12px 14px;
	border-bottom: 1px solid var(--border-default);
	color: var(--text-primary);
	vertical-align: middle;
}

.data-table tbody tr {
	transition: background-color var(--duration-150) var(--ease-out);
}

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

.data-table tbody tr:last-child td {
	border-bottom: none;
}

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

.avatar-sm {
	width: 32px;
	height: 32px;
	border-radius: var(--radius-full);
	background: var(--neutral-100);
	color: var(--neutral-700);
	border: 1px solid var(--border-default);
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 12px;
	font-weight: 600;
	flex-shrink: 0;
}
.dark .avatar-sm {
	background: var(--neutral-800);
	color: var(--neutral-200);
}

.contact-name-title {
	font-weight: 600;
	color: var(--text-primary);
	line-height: 1.2;
}

.contact-sub-title {
	font-size: 11px;
	color: var(--text-subtle);
	margin-top: 2px;
}

/* ==========================================================================
   Pipeline / Kanban View
   ========================================================================== */
.pipeline-board {
	display: flex;
	gap: 14px;
	overflow-x: auto;
	padding-bottom: 16px;
	min-height: 520px;
}

.pipeline-col {
	flex: 1;
	min-width: 260px;
	max-width: 320px;
	background: var(--bg-canvas);
	border: 1px solid var(--border-default);
	border-radius: var(--radius-lg);
	display: flex;
	flex-direction: column;
	max-height: calc(100vh - 220px);
}

.pipeline-col-header {
	padding: 10px 12px;
	border-bottom: 1px solid var(--border-default);
	display: flex;
	align-items: center;
	justify-content: space-between;
	background: var(--bg-surface);
	border-top-left-radius: var(--radius-lg);
	border-top-right-radius: var(--radius-lg);
}

.pipeline-col-title {
	font-size: 12px;
	font-weight: 600;
	display: flex;
	align-items: center;
	gap: 6px;
}

.pipeline-cards-list {
	flex: 1;
	overflow-y: auto;
	padding: 10px;
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.contact-card-kanban {
	background: var(--bg-surface);
	border: 1px solid var(--border-default);
	border-radius: var(--radius-md);
	padding: 12px;
	cursor: pointer;
	box-shadow: var(--shadow-xs);
	transition: all var(--duration-150) var(--ease-out);
}

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

/* ==========================================================================
   Follow-Up Indicators
   ========================================================================== */
.followup-badge {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	font-size: 11px;
	font-weight: 500;
	padding: 2px 6px;
	border-radius: var(--radius-sm);
}

.followup-overdue {
	background: var(--error-bg);
	color: var(--error-fg);
	border: 1px solid var(--error-border);
}

.followup-today {
	background: var(--warning-bg);
	color: var(--warning-fg);
	border: 1px solid var(--warning-border);
}

.followup-upcoming {
	background: var(--neutral-100);
	color: var(--text-muted);
	border: 1px solid var(--border-default);
}

/* ==========================================================================
   Timeline / Interactions list
   ========================================================================== */
.timeline {
	position: relative;
	padding-left: 20px;
	display: flex;
	flex-direction: column;
	gap: 16px;
}

.timeline::before {
	content: '';
	position: absolute;
	left: 7px;
	top: 6px;
	bottom: 6px;
	width: 2px;
	background: var(--border-default);
}

.timeline-item {
	position: relative;
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.timeline-dot {
	position: absolute;
	left: -20px;
	top: 3px;
	width: 16px;
	height: 16px;
	border-radius: var(--radius-full);
	background: var(--bg-surface);
	border: 2px solid var(--brand-600);
	display: flex;
	align-items: center;
	justify-content: center;
}

.timeline-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
}

.timeline-title {
	font-size: 13px;
	font-weight: 600;
	color: var(--text-primary);
}

.timeline-date {
	font-size: 11px;
	color: var(--text-subtle);
}

.timeline-content {
	font-size: 12px;
	color: var(--text-muted);
	background: var(--bg-canvas);
	border: 1px solid var(--border-default);
	border-radius: var(--radius-md);
	padding: 10px 12px;
	white-space: pre-wrap;
}

.timeline-actions-tag {
	margin-top: 6px;
	font-size: 11px;
	background: var(--neutral-100);
	padding: 4px 8px;
	border-radius: var(--radius-sm);
	color: var(--text-muted);
	border-left: 2px solid var(--brand-600);
}
.dark .timeline-actions-tag {
	background: var(--neutral-800);
}

/* ==========================================================================
   Modals & Drawers
   ========================================================================== */
.modal-overlay {
	position: fixed;
	inset: 0;
	background: rgba(15, 23, 42, 0.5);
	backdrop-filter: blur(2px);
	z-index: 50;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 16px;
	animation: fadeIn 150ms var(--ease-out);
}

.modal-content {
	background: var(--bg-elevated);
	border: 1px solid var(--border-default);
	border-radius: var(--radius-xl);
	box-shadow: var(--shadow-xl);
	width: 100%;
	max-width: 540px;
	max-height: 90vh;
	display: flex;
	flex-direction: column;
	overflow: hidden;
	animation: scaleUp 180ms var(--ease-out);
}

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

.modal-title {
	font-size: 16px;
	font-weight: 700;
	color: var(--text-primary);
	margin: 0;
}

.modal-body {
	padding: 20px;
	overflow-y: auto;
}

.modal-footer {
	padding: 14px 20px;
	border-top: 1px solid var(--border-default);
	display: flex;
	align-items: center;
	justify-content: flex-end;
	gap: 8px;
	background: var(--bg-canvas);
}

/* Drawer Detail Panel */
.drawer-panel {
	position: fixed;
	top: 0;
	right: 0;
	bottom: 0;
	width: 100%;
	max-width: 580px;
	background: var(--bg-elevated);
	border-left: 1px solid var(--border-default);
	box-shadow: var(--shadow-xl);
	z-index: 50;
	display: flex;
	flex-direction: column;
	animation: slideInRight 200ms var(--ease-out);
}

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

.drawer-body {
	flex: 1;
	overflow-y: auto;
	padding: 20px;
	display: flex;
	flex-direction: column;
	gap: 20px;
}

/* ==========================================================================
   Auth Surface
   ========================================================================== */
.auth-page-container {
	min-height: 100vh;
	display: flex;
	align-items: center;
	justify-content: center;
	background: var(--bg-canvas);
	padding: 24px;
}

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

.auth-brand-head {
	display: flex;
	flex-direction: column;
	align-items: center;
	text-align: center;
	margin-bottom: 24px;
}

.auth-brand-logo {
	width: 44px;
	height: 44px;
	background: linear-gradient(135deg, var(--brand-600), #7c3aed);
	border-radius: var(--radius-lg);
	display: flex;
	align-items: center;
	justify-content: center;
	color: #fff;
	font-weight: 800;
	font-size: 20px;
	margin-bottom: 12px;
	box-shadow: 0 4px 10px rgba(79, 70, 229, 0.35);
}

.auth-tabs {
	display: grid;
	grid-template-columns: 1fr 1fr;
	background: var(--bg-canvas);
	border: 1px solid var(--border-default);
	border-radius: var(--radius-md);
	padding: 3px;
	margin-bottom: 20px;
}

.auth-tab-btn {
	padding: 6px;
	font-size: 13px;
	font-weight: 500;
	color: var(--text-muted);
	background: transparent;
	border: none;
	border-radius: var(--radius-sm);
	cursor: pointer;
	text-align: center;
	transition: all var(--duration-150) var(--ease-out);
}

.auth-tab-btn.active {
	background: var(--bg-surface);
	color: var(--text-primary);
	font-weight: 600;
	box-shadow: var(--shadow-xs);
}

.auth-alert-error {
	background: var(--error-bg);
	color: var(--error-fg);
	border: 1px solid var(--error-border);
	padding: 8px 12px;
	border-radius: var(--radius-md);
	font-size: 12px;
	margin-bottom: 16px;
}

/* ==========================================================================
   Toasts
   ========================================================================== */
.toast-container {
	position: fixed;
	bottom: 20px;
	right: 20px;
	z-index: 100;
	display: flex;
	flex-direction: column-reverse;
	gap: 8px;
	pointer-events: none;
}

.toast {
	pointer-events: auto;
	background: var(--bg-elevated);
	border: 1px solid var(--border-default);
	border-radius: var(--radius-lg);
	padding: 10px 14px;
	box-shadow: var(--shadow-lg);
	display: flex;
	align-items: center;
	gap: 10px;
	font-size: 13px;
	font-weight: 500;
	color: var(--text-primary);
	animation: toastEnter 180ms var(--ease-out);
	min-width: 260px;
	max-width: 380px;
}

.toast-success { border-left: 3px solid #16a34a; }
.toast-error { border-left: 3px solid #dc2626; }
.toast-info { border-left: 3px solid var(--brand-600); }

/* ==========================================================================
   Grid & Form Row Helpers
   ========================================================================== */
.grid-2 {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 12px;
}

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

.grid-4 {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
	gap: 12px;
}

.empty-state {
	padding: 40px 20px;
	text-align: center;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
}

.empty-state-icon {
	width: 48px;
	height: 48px;
	color: var(--text-subtle);
	margin-bottom: 12px;
}

.empty-state-title {
	font-size: 15px;
	font-weight: 600;
	color: var(--text-primary);
	margin: 0 0 4px;
}

.empty-state-desc {
	font-size: 13px;
	color: var(--text-muted);
	max-width: 340px;
	margin-bottom: 16px;
}

/* Animations */
@keyframes fadeIn {
	from { opacity: 0; }
	to { opacity: 1; }
}

@keyframes scaleUp {
	from { opacity: 0; transform: scale(0.96); }
	to { opacity: 1; transform: scale(1); }
}

@keyframes slideInRight {
	from { transform: translateX(100%); }
	to { transform: translateX(0); }
}

@keyframes toastEnter {
	from { opacity: 0; transform: translateY(8px); }
	to { opacity: 1; transform: translateY(0); }
}

/* Responsive */
@media (max-width: 768px) {
	.sidebar {
		position: fixed;
		top: 0;
		bottom: 0;
		left: 0;
		transform: translateX(-100%);
	}
	.sidebar.open {
		transform: translateX(0);
	}
	.sidebar-overlay {
		position: fixed;
		inset: 0;
		background: rgba(0, 0, 0, 0.4);
		z-index: 15;
	}
	.grid-2, .grid-3 {
		grid-template-columns: 1fr;
	}
	.main-content {
		padding: 16px;
	}
	.drawer-panel {
		max-width: 100%;
	}
}
