/* ============================================
   RAZIONAL CRM — Design System
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
  /* Primary */
  --color-primary: #2563eb;
  --color-primary-hover: #1d4ed8;
  --color-primary-light: #dbeafe;
  --color-primary-50: rgba(37, 99, 235, 0.08);

  /* Semantic */
  --color-success: #16a34a;
  --color-success-light: #dcfce7;
  --color-warning: #f59e0b;
  --color-warning-light: #fef3c7;
  --color-danger: #dc2626;
  --color-danger-light: #fee2e2;
  --color-info: #0ea5e9;
  --color-info-light: #e0f2fe;

  /* Surfaces */
  --color-bg: #f8fafc;
  --color-surface: #ffffff;
  --color-surface-hover: #f1f5f9;
  --color-border: #e2e8f0;
  --color-border-light: #f1f5f9;

  /* Text */
  --color-text: #1e293b;
  --color-text-secondary: #64748b;
  --color-text-tertiary: #94a3b8;
  --color-text-inverse: #ffffff;

  /* Sidebar */
  --sidebar-w: 240px;
  --sidebar-w-collapsed: 64px;
  --sidebar-bg: #0f172a;
  --sidebar-text: #94a3b8;
  --sidebar-text-active: #ffffff;
  --sidebar-hover: rgba(255,255,255,0.06);
  --sidebar-active-bg: rgba(37,99,235,0.15);
  --sidebar-active-border: var(--color-primary);

  /* Typography */
  --font: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'SF Mono', 'Cascadia Code', Consolas, monospace;
  --text-xs: 11px;
  --text-sm: 13px;
  --text-base: 14px;
  --text-md: 15px;
  --text-lg: 18px;
  --text-xl: 22px;
  --text-2xl: 28px;

  /* Spacing */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-8: 32px; --sp-10: 40px; --sp-12: 48px;

  /* Borders & Shadows */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.05), 0 2px 4px -2px rgba(0,0,0,0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.06), 0 4px 6px -4px rgba(0,0,0,0.06);

  /* Transitions */
  --ease-fast: 150ms ease;
  --ease: 200ms ease;
  --ease-slow: 300ms ease;
}

/* --- Reset --- */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 14px; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body {
  font-family: var(--font);
  background: var(--color-bg);
  color: var(--color-text);
  min-height: 100vh;
  display: flex;
  line-height: 1.5;
}
a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- Layout: Sidebar + Content --- */
.app-layout { display: flex; min-height: 100vh; width: 100%; }

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: width var(--ease);
  overflow: hidden;
}
.sidebar.collapsed { width: var(--sidebar-w-collapsed); }

.sidebar-logo {
  height: 56px;
  display: flex;
  align-items: center;
  padding: 0 var(--sp-5);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}
.sidebar-logo .logo-text {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--color-primary);
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.sidebar-logo .logo-icon {
  width: 24px; height: 24px;
  flex-shrink: 0;
}
.sidebar.collapsed .logo-text { display: none; }

.sidebar-nav {
  flex: 1;
  padding: var(--sp-3) 0;
  overflow-y: auto;
}
.sidebar-group-label {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(255,255,255,0.3);
  padding: var(--sp-4) var(--sp-5) var(--sp-2);
  white-space: nowrap;
}
.sidebar.collapsed .sidebar-group-label { display: none; }

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 0 var(--sp-5);
  height: 40px;
  color: var(--sidebar-text);
  font-size: var(--text-base);
  font-weight: 450;
  cursor: pointer;
  transition: all var(--ease-fast);
  border-left: 3px solid transparent;
  text-decoration: none;
  white-space: nowrap;
}
.nav-item:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-text-active);
  text-decoration: none;
}
.nav-item.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-text-active);
  border-left-color: var(--sidebar-active-border);
  font-weight: 500;
}
.nav-item svg {
  width: 20px; height: 20px;
  flex-shrink: 0;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.nav-item .nav-label { white-space: nowrap; }
.sidebar.collapsed .nav-label { display: none; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 0; }

/* Sidebar User Section */
.sidebar-user {
  padding: var(--sp-3) var(--sp-4);
  border-top: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}
.sidebar-user .team-selector { margin-bottom: var(--sp-2); }
.sidebar-user .team-selector select {
  width: 100%;
  padding: 6px 8px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-sm);
  color: var(--sidebar-text-active);
  font-size: var(--text-xs);
  cursor: pointer;
  outline: none;
}
.sidebar-user .team-selector select:hover { background: rgba(255,255,255,0.1); }
.sidebar-user .team-selector select option { background: var(--sidebar-bg); color: #fff; }
.sidebar-user .team-label {
  font-size: var(--text-xs);
  color: var(--sidebar-text);
  padding: 4px 0;
  margin-bottom: var(--sp-1);
}
.sidebar-user .user-info {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}
.sidebar-user .user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-sm);
  font-weight: 600;
  flex-shrink: 0;
}
.sidebar-user .user-details { flex: 1; min-width: 0; }
.sidebar-user .user-name {
  font-size: var(--text-sm);
  color: var(--sidebar-text-active);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user .user-role {
  font-size: var(--text-xs);
  color: var(--sidebar-text);
}
.sidebar-user .logout-btn {
  width: 28px;
  height: 28px;
  border: none;
  background: none;
  color: var(--sidebar-text);
  cursor: pointer;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--ease-fast);
}
.sidebar-user .logout-btn:hover { background: rgba(255,255,255,0.1); color: var(--color-danger); }
.sidebar-user .logout-btn svg { stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.sidebar.collapsed .sidebar-user .user-details,
.sidebar.collapsed .sidebar-user .team-selector,
.sidebar.collapsed .sidebar-user .team-label { display: none; }
.sidebar.collapsed .sidebar-user .user-info { justify-content: center; }
.sidebar.collapsed .sidebar-user .logout-btn { display: none; }

.sidebar-footer {
  padding: var(--sp-3) var(--sp-4);
  border-top: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}
.sidebar-collapse-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  width: 100%;
  height: 36px;
  background: none;
  border: none;
  color: var(--sidebar-text);
  cursor: pointer;
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  transition: all var(--ease-fast);
}
.sidebar-collapse-btn:hover { background: var(--sidebar-hover); color: var(--sidebar-text-active); }
.sidebar-collapse-btn svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.sidebar.collapsed .sidebar-collapse-btn .collapse-label { display: none; }

/* Main Content */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  transition: margin-left var(--ease);
}
.sidebar.collapsed ~ .main-content { margin-left: var(--sidebar-w-collapsed); }

.page-wrapper {
  max-width: 1280px;
  margin: 0 auto;
  padding: var(--sp-8);
}

/* Page Header */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-6);
  flex-wrap: wrap;
  gap: var(--sp-3);
}
.page-header h1 {
  font-size: var(--text-xl);
  font-weight: 600;
  color: var(--color-text);
}
.page-header-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

/* Breadcrumb */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--text-sm);
  color: var(--color-text-tertiary);
  margin-bottom: var(--sp-2);
}
.breadcrumb a { color: var(--color-text-secondary); text-decoration: none; }
.breadcrumb a:hover { color: var(--color-primary); }
.breadcrumb .sep { color: var(--color-text-tertiary); }

/* --- Mobile hamburger --- */
.mobile-header {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 48px;
  background: var(--sidebar-bg);
  z-index: 99;
  align-items: center;
  padding: 0 var(--sp-4);
}
.hamburger-btn {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  width: 36px; height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.hamburger-btn svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; }
.mobile-header .logo-text { font-size: var(--text-md); font-weight: 700; color: var(--color-primary); margin-left: var(--sp-3); }
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99;
}

@media (max-width: 768px) {
  .mobile-header { display: flex; }
  .sidebar {
    transform: translateX(-100%);
    z-index: 200;
  }
  .sidebar.mobile-open { transform: translateX(0); }
  .sidebar-overlay.active { display: block; z-index: 150; }
  .main-content { margin-left: 0; padding-top: 48px; }
  .sidebar.collapsed ~ .main-content { margin-left: 0; }
  .page-wrapper { padding: var(--sp-5); }
}

/* --- Card --- */
.card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-xs);
  padding: var(--sp-6);
  margin-bottom: var(--sp-5);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-4);
}
.card-title {
  font-size: var(--text-md);
  font-weight: 600;
  color: var(--color-text);
}
.card-subtitle {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
}

/* KPI Card */
.kpi-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-xs);
  padding: var(--sp-5);
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}
.kpi-icon {
  width: 40px; height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--sp-2);
}
.kpi-icon svg { width: 20px; height: 20px; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; fill: none; }
.kpi-value {
  font-size: var(--text-2xl);
  font-weight: 700;
  line-height: 1.1;
}
.kpi-label {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
}
.kpi-change {
  font-size: var(--text-xs);
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 2px;
}
.kpi-change.up { color: var(--color-success); }
.kpi-change.down { color: var(--color-danger); }

/* --- Grid --- */
.grid { display: grid; gap: var(--sp-5); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-7-5 { grid-template-columns: 7fr 5fr; }
@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-7-5 { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* --- Data Table --- */
.table-wrapper {
  overflow-x: auto;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
}
.data-table th {
  text-align: left;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}
.data-table td {
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--color-border-light);
  font-size: var(--text-base);
  vertical-align: middle;
}
.data-table tbody tr {
  cursor: pointer;
  transition: background var(--ease-fast);
}
.data-table tbody tr:hover { background: var(--color-surface-hover); }
.data-table .cell-main {
  font-weight: 500;
  color: var(--color-text);
}
.data-table .cell-sub {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
}
.data-table .cell-meta, .cell-meta {
  font-size: var(--text-xs);
  color: var(--color-text-tertiary);
  margin-top: 2px;
}
.data-table .cell-mono {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
}

/* --- Badge --- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 500;
  white-space: nowrap;
  line-height: 1.6;
}
.badge-success { background: var(--color-success-light); color: var(--color-success); }
.badge-warning { background: var(--color-warning-light); color: #b45309; }
.badge-danger { background: var(--color-danger-light); color: var(--color-danger); }
.badge-info { background: var(--color-info-light); color: #0369a1; }
.badge-primary { background: var(--color-primary-light); color: var(--color-primary); }
.badge-neutral { background: var(--color-border-light); color: var(--color-text-secondary); }

/* --- Dot indicator --- */
.dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot-success { background: var(--color-success); }
.dot-warning { background: var(--color-warning); }
.dot-danger { background: var(--color-danger); }
.dot-info { background: var(--color-info); }
.dot-neutral { background: var(--color-text-tertiary); }

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  transition: all var(--ease-fast);
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.4;
}
.btn:hover { text-decoration: none; }
.btn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.btn-primary { background: var(--color-primary); color: var(--color-text-inverse); }
.btn-primary:hover { background: var(--color-primary-hover); }
.btn-success { background: var(--color-success); color: var(--color-text-inverse); }
.btn-success:hover { background: #15803d; }
.btn-danger { background: var(--color-danger); color: var(--color-text-inverse); }
.btn-danger:hover { background: #b91c1c; }
.btn-secondary { background: var(--color-border-light); color: var(--color-text); border: 1px solid var(--color-border); }
.btn-secondary:hover { background: var(--color-border); }
.btn-ghost { background: transparent; color: var(--color-text-secondary); }
.btn-ghost:hover { background: var(--color-surface-hover); color: var(--color-text); }
.btn-sm { padding: 4px 10px; font-size: var(--text-sm); }
.btn-lg { padding: 12px 24px; font-size: var(--text-md); }
.btn-icon { width: 36px; height: 36px; padding: 0; justify-content: center; border-radius: var(--radius-md); }
.btn-icon.sm { width: 28px; height: 28px; }

/* --- Form Controls --- */
.form-group { margin-bottom: var(--sp-4); }
.form-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-secondary);
  margin-bottom: var(--sp-1);
}
.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  font-family: var(--font);
  color: var(--color-text);
  transition: border-color var(--ease-fast), box-shadow var(--ease-fast);
  outline: none;
  background: var(--color-surface);
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-50);
}
.form-textarea { resize: vertical; line-height: 1.5; }
.form-input::placeholder { color: var(--color-text-tertiary); }

/* --- Search Bar --- */
.search-bar {
  display: flex;
  align-items: center;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 0 12px;
  max-width: 320px;
  transition: border-color var(--ease-fast), box-shadow var(--ease-fast);
}
.search-bar:focus-within { border-color: var(--color-primary); box-shadow: 0 0 0 3px var(--color-primary-50); }
.search-bar svg { width: 16px; height: 16px; stroke: var(--color-text-tertiary); fill: none; stroke-width: 2; flex-shrink: 0; }
.search-bar input {
  border: none;
  outline: none;
  padding: 8px;
  font-size: var(--text-base);
  flex: 1;
  background: transparent;
  font-family: var(--font);
  color: var(--color-text);
}
.search-bar input::placeholder { color: var(--color-text-tertiary); }

/* --- Filter Pills --- */
.filter-bar {
  display: flex;
  gap: var(--sp-2);
  flex-wrap: wrap;
  align-items: center;
}
.filter-pill {
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  font-weight: 500;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  cursor: pointer;
  transition: all var(--ease-fast);
  color: var(--color-text-secondary);
  font-family: var(--font);
}
.filter-pill:hover { border-color: var(--color-primary); color: var(--color-primary); }
.filter-pill.active {
  background: var(--color-primary-light);
  border-color: var(--color-primary);
  color: var(--color-primary);
}

/* --- Toolbar --- */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  margin-bottom: var(--sp-5);
  flex-wrap: wrap;
}
.toolbar-left { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }
.toolbar-right { display: flex; align-items: center; gap: var(--sp-3); }

/* --- Modal --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--ease);
}
.modal-overlay.active { opacity: 1; pointer-events: all; }
.modal {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  max-width: 560px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-header {
  padding: var(--sp-6) var(--sp-6) 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h2 { font-size: var(--text-lg); font-weight: 600; }
.modal-body { padding: var(--sp-6); }
.modal-footer {
  padding: 0 var(--sp-6) var(--sp-6);
  display: flex;
  gap: var(--sp-3);
  justify-content: flex-end;
}

/* --- Empty State --- */
.empty-state {
  text-align: center;
  padding: var(--sp-12) var(--sp-6);
  color: var(--color-text-tertiary);
}
.empty-state svg {
  width: 48px; height: 48px;
  margin: 0 auto var(--sp-4);
  opacity: 0.4;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.5;
}
.empty-state h3 {
  font-size: var(--text-lg);
  color: var(--color-text-secondary);
  margin-bottom: var(--sp-2);
}
.empty-state p {
  font-size: var(--text-base);
  color: var(--color-text-tertiary);
  margin-bottom: var(--sp-5);
}

/* --- Skeleton Loader --- */
.skeleton {
  background: linear-gradient(90deg, var(--color-border-light) 25%, #e8edf2 50%, var(--color-border-light) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.skeleton-line { height: 14px; margin-bottom: var(--sp-3); }
.skeleton-line.w-75 { width: 75%; }
.skeleton-line.w-50 { width: 50%; }
.skeleton-line.w-25 { width: 25%; }

/* --- Toast --- */
.toast-container {
  position: fixed;
  bottom: var(--sp-6);
  right: var(--sp-6);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.toast {
  background: var(--color-text);
  color: var(--color-text-inverse);
  padding: var(--sp-3) var(--sp-5);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toast-in 0.3s ease;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}
.toast.toast-success { background: var(--color-success); }
.toast.toast-danger { background: var(--color-danger); }
@keyframes toast-in {
  from { transform: translateY(10px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* --- Progress Bar --- */
.progress-bar {
  height: 6px;
  background: var(--color-border-light);
  border-radius: var(--radius-full);
  overflow: hidden;
  width: 60px;
  display: inline-block;
  vertical-align: middle;
}
.progress-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: var(--color-primary);
  transition: width var(--ease);
}

/* --- Timeline --- */
.timeline { position: relative; }
.timeline::before {
  content: '';
  position: absolute;
  left: 15px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: var(--color-border);
}
.timeline-item {
  display: flex;
  gap: var(--sp-4);
  padding: var(--sp-3) 0;
  position: relative;
}
.timeline-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--color-primary);
  flex-shrink: 0;
  margin-top: 5px;
  position: relative;
  z-index: 1;
  border: 2px solid var(--color-bg);
  margin-left: 10px;
}
.timeline-dot.success { background: var(--color-success); }
.timeline-dot.warning { background: var(--color-warning); }
.timeline-dot.neutral { background: var(--color-text-tertiary); }
.timeline-content { flex: 1; }
.timeline-text { font-size: var(--text-base); color: var(--color-text); }
.timeline-time { font-size: var(--text-xs); color: var(--color-text-tertiary); margin-top: 2px; }

/* --- Tabs --- */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: var(--sp-6);
}
.tab {
  padding: var(--sp-3) var(--sp-5);
  font-size: var(--text-base);
  font-weight: 500;
  color: var(--color-text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--ease-fast);
  font-family: var(--font);
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
}
.tab:hover { color: var(--color-text); }
.tab.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}
.tab-content { display: none; }
.tab-content.active { display: block; }

/* --- Info Grid --- */
.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-4);
}
.info-item {}
.info-item .info-label {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 2px;
}
.info-item .info-value {
  font-size: var(--text-base);
  color: var(--color-text);
}

/* --- Contact Box (tinted) --- */
.contact-box {
  background: var(--color-primary-50);
  border-radius: var(--radius-md);
  padding: var(--sp-4);
  border: 1px solid var(--color-primary-light);
}

/* --- Transcript --- */
.transcript-box {
  background: var(--color-bg);
  border-radius: var(--radius-md);
  padding: var(--sp-4);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: 1.7;
  max-height: 400px;
  overflow-y: auto;
  white-space: pre-wrap;
  border: 1px solid var(--color-border);
}

/* --- Task List --- */
.task-list { list-style: none; }
.task-item {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-3) 0;
  border-bottom: 1px solid var(--color-border-light);
}
.task-item:last-child { border-bottom: none; }
.task-checkbox {
  width: 18px; height: 18px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--color-border);
  flex-shrink: 0;
  margin-top: 1px;
  cursor: pointer;
  transition: all var(--ease-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-surface);
}
.task-checkbox.checked {
  background: var(--color-success);
  border-color: var(--color-success);
}
.task-checkbox.checked::after {
  content: '';
  width: 5px; height: 9px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
  margin-bottom: 2px;
}
.task-body { flex: 1; }
.task-title { font-size: var(--text-base); font-weight: 500; }
.task-meta { font-size: var(--text-sm); color: var(--color-text-secondary); margin-top: 2px; }
.task-item.completed .task-title { text-decoration: line-through; color: var(--color-text-tertiary); }
.priority-indicator {
  width: 3px;
  border-radius: var(--radius-full);
  align-self: stretch;
  flex-shrink: 0;
}
.priority-hoch { background: var(--color-danger); }
.priority-normal { background: var(--color-warning); }
.priority-niedrig { background: var(--color-success); }

/* --- Dropzone --- */
.dropzone {
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--sp-8) var(--sp-5);
  text-align: center;
  cursor: pointer;
  transition: all var(--ease-fast);
  color: var(--color-text-secondary);
}
.dropzone:hover, .dropzone.dragover {
  border-color: var(--color-primary);
  background: var(--color-primary-50);
  color: var(--color-primary);
}
.dropzone svg {
  width: 36px; height: 36px;
  margin: 0 auto var(--sp-3);
  stroke: currentColor;
  fill: none;
  stroke-width: 1.5;
  display: block;
}
.dropzone p { font-size: var(--text-base); }
.dropzone .hint { font-size: var(--text-sm); color: var(--color-text-tertiary); margin-top: var(--sp-2); }

/* --- Record Button --- */
.record-btn {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  border: none;
  background: var(--color-primary);
  color: white;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: var(--font);
  font-size: var(--text-sm);
  font-weight: 600;
  transition: all var(--ease-fast);
  margin: 0 auto;
}
.record-btn:hover { background: var(--color-primary-hover); transform: scale(1.05); }
.record-btn.recording {
  background: var(--color-danger);
  animation: pulse 2s infinite;
}
.record-btn svg { width: 32px; height: 32px; margin-bottom: var(--sp-1); stroke: currentColor; fill: none; stroke-width: 1.75; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(220,38,38,0.4); }
  70% { box-shadow: 0 0 0 20px rgba(220,38,38,0); }
  100% { box-shadow: 0 0 0 0 rgba(220,38,38,0); }
}

/* --- Timer --- */
.timer-display {
  font-size: 36px;
  font-weight: 300;
  font-variant-numeric: tabular-nums;
  text-align: center;
  color: var(--color-text);
  margin-top: var(--sp-4);
}

/* --- Spinner --- */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Document Grid --- */
.doc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--sp-4);
}
.doc-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  transition: all var(--ease-fast);
}
.doc-card:hover { border-color: var(--color-primary); box-shadow: var(--shadow-sm); }
.doc-card-preview {
  height: 120px;
  background: var(--color-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid var(--color-border);
}
.doc-card-preview svg { width: 40px; height: 40px; stroke: var(--color-text-tertiary); fill: none; stroke-width: 1.25; }
.doc-card-body { padding: var(--sp-3); }
.doc-card-name { font-size: var(--text-sm); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-card-meta { font-size: var(--text-xs); color: var(--color-text-tertiary); margin-top: 2px; }

/* --- Split Panel Layout --- */
.split-layout {
  display: flex;
  min-height: 480px;
}
.split-list {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  max-height: calc(100vh - 240px);
}
.split-panel {
  width: 420px;
  flex-shrink: 0;
  background: var(--color-surface);
  overflow-y: auto;
  max-height: calc(100vh - 240px);
  display: none;
  border-left: 1px solid var(--color-border);
}
.split-panel.open {
  display: flex;
  flex-direction: column;
}
.split-panel-header {
  padding: var(--sp-4) var(--sp-5);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  border-bottom: 1px solid var(--color-border-light);
  flex-shrink: 0;
}
.split-panel-body {
  padding: var(--sp-5);
  flex: 1;
  overflow-y: auto;
}
.split-panel-section {
  margin-bottom: var(--sp-5);
}
.split-panel-section-label {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-tertiary);
  margin-bottom: var(--sp-2);
}
.split-panel-footer {
  padding: var(--sp-4) var(--sp-5);
  border-top: 1px solid var(--color-border);
  display: flex;
  gap: var(--sp-3);
  justify-content: space-between;
  flex-shrink: 0;
  background: var(--color-surface);
}

/* Task list items (compact) */
.task-list-compact {}
.task-list-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  cursor: pointer;
  border-bottom: 1px solid var(--color-border-light);
  transition: background var(--ease-fast);
  min-height: 48px;
}
.task-list-item:hover { background: var(--color-surface-hover); }
.task-list-item.active {
  background: var(--color-primary-50);
  border-left: 3px solid var(--color-primary);
  padding-left: calc(var(--sp-4) - 3px);
}
.task-list-item.done .task-list-title {
  text-decoration: line-through;
  color: var(--color-text-tertiary);
}
.task-list-body { flex: 1; min-width: 0; }
.task-list-title {
  font-size: var(--text-base);
  font-weight: 500;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.task-list-meta {
  font-size: var(--text-xs);
  color: var(--color-text-tertiary);
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

/* Priority bar in task list */
.task-list-item .priority-indicator {
  height: 28px;
  width: 3px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

/* Task origin badge */
.origin-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.6;
  white-space: nowrap;
  vertical-align: middle;
}
.origin-badge-ki {
  background: linear-gradient(135deg, rgba(139,92,246,0.12), rgba(59,130,246,0.12));
  color: #7c3aed;
  border: 1px solid rgba(139,92,246,0.2);
}
.origin-badge-ki svg {
  width: 10px;
  height: 10px;
  stroke: #7c3aed;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.origin-badge-manual {
  background: var(--color-border-light);
  color: var(--color-text-tertiary);
  border: 1px solid var(--color-border);
}

/* Task group headers use inline styles (see aufgaben.html renderList) */

/* Protocol embed card */
.protocol-embed {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--sp-4);
  cursor: pointer;
  transition: border-color var(--ease-fast);
}
.protocol-embed:hover { border-color: var(--color-primary); }
.protocol-embed-header {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-bottom: var(--sp-2);
}
.protocol-embed-summary {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  line-height: 1.5;
}

@media (max-width: 1024px) {
  .split-panel {
    position: fixed;
    right: 0; top: 0; bottom: 0;
    z-index: 500;
    box-shadow: var(--shadow-lg);
    width: 400px;
    max-height: none;
    border-left: none;
  }
}
@media (max-width: 768px) {
  .split-panel { width: 100%; }
  .split-list { max-height: none; }
}

/* --- Utils --- */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-sm { font-size: var(--text-sm); }
.text-xs { font-size: var(--text-xs); }
.text-secondary { color: var(--color-text-secondary); }
.text-tertiary { color: var(--color-text-tertiary); }
.text-success { color: var(--color-success); }
.text-danger { color: var(--color-danger); }
.text-warning { color: var(--color-warning); }
.font-mono { font-family: var(--font-mono); }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.mt-1 { margin-top: var(--sp-1); }
.mt-2 { margin-top: var(--sp-2); }
.mt-3 { margin-top: var(--sp-3); }
.mt-4 { margin-top: var(--sp-4); }
.mt-6 { margin-top: var(--sp-6); }
.mb-2 { margin-bottom: var(--sp-2); }
.mb-3 { margin-bottom: var(--sp-3); }
.mb-4 { margin-bottom: var(--sp-4); }
.mb-6 { margin-bottom: var(--sp-6); }
.gap-2 { gap: var(--sp-2); }
.gap-3 { gap: var(--sp-3); }
.gap-4 { gap: var(--sp-4); }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-1 { flex: 1; }
.flex-wrap { flex-wrap: wrap; }
.hidden { display: none; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.w-full { width: 100%; }
.cursor-pointer { cursor: pointer; }
