:root {
  --bg-color: #f8fafc;
  --card-bg: #ffffff;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --accent-color: #3b82f6;
  --border-color: #e2e8f0;
  --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  font-family: 'Outfit', sans-serif;
  margin: 0;
  background: var(--bg-color);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  padding: 20px 40px;
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.topbar-content {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

.topbar-content h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.5px;
  background: linear-gradient(90deg, #2563eb, #7c3aed);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.topbar-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
  flex-shrink: 0;
}

.task-select-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.task-select {
  appearance: none;
  background: #ffffff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E") no-repeat right 12px center;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 8px 32px 8px 14px;
  font-size: 13px;
  font-family: 'Outfit', sans-serif;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
  width: 260px;
  box-shadow: var(--shadow-sm);
}

.task-select:hover {
  border-color: var(--accent-color);
}

.task-select:focus {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.task-search {
  background: #ffffff 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='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E") no-repeat left 12px center;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 8px 14px 8px 34px;
  font-size: 13px;
  font-family: 'Outfit', sans-serif;
  font-weight: 400;
  color: var(--text-primary);
  transition: border-color 0.2s, box-shadow 0.2s;
  width: 160px;
  box-shadow: var(--shadow-sm);
}

.task-search::placeholder {
  color: var(--text-secondary);
  font-weight: 400;
}

.task-search:hover {
  border-color: var(--accent-color);
}

.task-search:focus {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.topbar-content p {
  margin: 4px 0 0 0;
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 300;
}

.dashboard-root {
  display: flex;
  flex: 1;
  max-width: 100vw;
  overflow: hidden;
  height: calc(100vh - 80px); /* 80px is topbar height */
}

.sidebar {
  width: 320px;
  background: #ffffff;
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 24px 0 24px 24px;
}

.main-content {
  flex: 1;
  padding: 16px;
  overflow: hidden;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: auto 1fr;
  gap: 16px;
}

.sidebar-header {
  margin-bottom: 24px;
  padding-bottom: 16px;
  padding-right: 16px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar > h2.badge {
  align-self: flex-start;
}

.sidebar-header h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 500;
  flex-shrink: 0;
  padding-right: 10px;
}

.sidebar-badge {
  font-size: 10px;
  font-weight: 600;
  color: var(--accent-color);
  background: rgba(59, 130, 246, 0.08);
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: 6px;
  padding: 3px 8px;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  white-space: nowrap;
  flex-shrink: 0;
}

.conv-id-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.conv-id-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}

.conv-id-value {
  display: block;
  flex: 1;
  min-width: 0;
  font-size: 11px;
  font-family: monospace;
  font-style: normal;
  color: var(--text-primary);
  background: rgba(0, 0, 0, 0.04);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 2px 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: default;
}

.task-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex: 1;
  min-height: 0;
  overflow-y: scroll;
  padding-right: 16px;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}

.task-list::-webkit-scrollbar {
  width: 6px;
}

.task-list::-webkit-scrollbar-track {
  background: var(--border-color);
  border-radius: 999px;
}

.task-list::-webkit-scrollbar-thumb {
  background: #94a3b8;
  border-radius: 999px;
  transition: background 0.2s;
}

.task-list::-webkit-scrollbar-thumb:hover {
  background: #64748b;
}

.task-item {
  background: var(--bg-color);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 16px;
  transition: all 0.2s ease;
}

.task-item:hover {
  border-color: var(--accent-color);
  background: #ffffff;
  box-shadow: var(--shadow-sm);
}

.task-item.active {
  border-color: var(--accent-color);
  background: #ffffff;
  box-shadow: var(--shadow-md);
  border-left: 4px solid var(--accent-color);
}

.task-meta {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
}

.task-id {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-color);
}

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

.task-conv-id {
  font-size: 10px;
  font-family: monospace;
  color: var(--text-secondary);
  background: rgba(0, 0, 0, 0.03);
  border-radius: 3px;
  padding: 2px 5px;
  margin-bottom: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-asked {
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 8px;
}

.task-effectuated {
  font-size: 12px;
  color: var(--text-secondary);
  background: rgba(0,0,0,0.03);
  padding: 8px;
  border-radius: 4px;
  margin: 0;
  white-space: pre-wrap;
  font-family: inherit;
}

.no-tasks {
  font-size: 14px;
  color: var(--text-secondary);
  text-align: center;
  margin-top: 40px;
}

@media (max-width: 1024px) {
  .dashboard-root {
    flex-direction: column;
    height: auto;
    overflow: visible;
  }
  .sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
    height: 350px;
    flex: none;
  }
  .main-content {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
    height: auto;
    overflow-y: auto;
  }
  .quality-bar {
    flex-wrap: wrap;
  }
  .chart-container {
    height: auto;
    min-height: 350px;
    max-height: 50vh;
  }
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 16px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  display: flex;
  flex-direction: column;
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
  border-color: #cbd5e1;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 10px;
}

.card-header h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 500;
  color: var(--text-primary);
}

.badge {
  background: rgba(59, 130, 246, 0.1);
  color: #2563eb;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  border: 1px solid rgba(59, 130, 246, 0.2);
}

.chart-container {
  position: relative;
  flex-grow: 1;
  height: auto;
  min-height: 340px;
  max-height: 52vh;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  border-radius: 12px;
  background: #ffffff;
  padding: 16px;
  border: 1px solid var(--border-color);
}

/* Specific fix for elements passed through graph_html */
.chart-container > div, .chart-container > iframe {
  width: 100% !important;
  height: 100% !important;
  border: none;
  border-radius: 8px;
}

/* Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in {
  animation: fadeIn 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  opacity: 0;
}

.hidden {
  display: none !important;
}

.quality-bar {
  grid-column: 1 / -1;
}

.quality-stats {
  display: flex;
  gap: 10px;
  flex: 1;
}

.stat-card {
  flex: 1;
  background: var(--bg-color);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 6px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.stat-value {
  font-size: 18px;
  font-weight: 600;
  color: var(--accent-color);
  letter-spacing: -0.5px;
  white-space: nowrap;
}

.stat-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}