/* Notion-style Agent Dashboard */
/* Clean, minimal design with generous whitespace */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

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

:root {
  /* Notion color palette */
  --bg-primary: #ffffff;
  --bg-secondary: #f7f6f3;
  --bg-tertiary: #f1f1ef;
  --bg-hover: #efefef;
  --border-color: #e3e2de;
  --border-light: #ebeae6;
  --text-primary: #37352f;
  --text-secondary: #787774;
  --text-tertiary: #9b9a97;
  --accent-blue: #2383e2;
  --accent-green: #0f7b6c;
  --accent-yellow: #dfab01;
  --accent-red: #e03e3e;
  --accent-purple: #9065b0;
  --accent-pink: #d44c8f;
  --accent-orange: #d9730d;
  --accent-brown: #64473a;
  
  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
  
  /* Radius */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
}

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

#app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 48px;
}

/* Header */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 0 32px 0;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 32px;
}

header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.connection-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  padding: 6px 12px;
  background: var(--bg-secondary);
  border-radius: 20px;
}

.connection-status .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-yellow);
  transition: background 0.2s ease;
}

.connection-status.connected .dot {
  background: var(--accent-green);
}

.connection-status.disconnected .dot {
  background: var(--accent-red);
}

/* Stats Section */
.stats-section {
  margin-bottom: 32px;
}

.stats-grid {
  display: flex;
  gap: 8px;
}

.stat-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  transition: all 0.15s ease;
  flex: 1;
  min-width: 0;
}

.stat-card:hover {
  box-shadow: var(--shadow-md);
}

.stat-card.agent-card {
  border-left: 3px solid var(--accent-blue);
  cursor: pointer;
}

.stat-card.agent-card:hover {
  border-color: var(--accent-blue);
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
}

.stat-card h3 {
  font-size: 0.6rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-card .value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.stat-card .breakdown {
  display: flex;
  gap: 6px;
  margin-top: 4px;
  font-size: 0.6rem;
}

.stat-card .breakdown span {
  display: flex;
  align-items: center;
  gap: 6px;
}

.stat-card .breakdown .running { color: var(--accent-orange); }
.stat-card .breakdown .done { color: var(--accent-green); }
.stat-card .breakdown .failed { color: var(--accent-red); }

/* Filters */
.filters-section {
  margin-bottom: 32px;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-end;
  background: var(--bg-secondary);
  padding: 20px;
  border-radius: var(--radius-lg);
}

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

.filter-group label {
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.filter-group select {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 8px 32px 8px 12px;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-family: inherit;
  min-width: 130px;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23787774' d='M3 4.5L6 7.5L9 4.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.filter-group select:hover {
  border-color: var(--text-tertiary);
}

.filter-group select:focus {
  outline: none;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(35, 131, 226, 0.1);
}

.btn-refresh {
  background: var(--accent-blue);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  font-family: inherit;
  transition: all 0.15s ease;
}

.btn-refresh:hover {
  background: #1a73d4;
  transform: translateY(-1px);
}

.btn-refresh:active {
  transform: translateY(0);
}

/* Agent Header */
.agent-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 32px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-light);
}

.agent-header h2 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
}

.btn-back {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 8px 14px;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 0.8125rem;
  font-family: inherit;
  transition: all 0.15s ease;
}

.btn-back:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border-color: var(--text-tertiary);
}

/* Tasks Section */
.tasks-section h2 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text-primary);
}

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

.empty-state {
  text-align: center;
  padding: 64px 32px;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  font-size: 0.875rem;
}

.task-item {
  display: grid;
  grid-template-columns: auto 100px 80px 1fr auto;
  gap: 16px;
  align-items: center;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 14px 18px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.task-item:hover {
  background: var(--bg-hover);
  border-color: var(--text-tertiary);
  box-shadow: var(--shadow-sm);
}

.task-item.new {
  animation: highlight 2s ease-out;
}

@keyframes highlight {
  0% { background: rgba(35, 131, 226, 0.08); }
  100% { background: var(--bg-primary); }
}

.task-agent {
  font-weight: 500;
  color: var(--accent-purple);
  min-width: 80px;
  font-size: 0.875rem;
}

.task-type {
  font-size: 0.6875rem;
  padding: 4px 10px;
  background: var(--bg-secondary);
  border-radius: 20px;
  color: var(--text-secondary);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.task-status {
  font-size: 0.6875rem;
  padding: 4px 10px;
  border-radius: 20px;
  font-weight: 500;
}

.task-status.running {
  background: rgba(217, 115, 13, 0.1);
  color: var(--accent-orange);
}

.task-status.done {
  background: rgba(15, 123, 108, 0.1);
  color: var(--accent-green);
}

.task-status.failed {
  background: rgba(224, 62, 62, 0.1);
  color: var(--accent-red);
}

.task-title {
  font-size: 0.875rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-primary);
}

.task-time {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  white-space: nowrap;
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 15, 15, 0.6);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 24px;
  backdrop-filter: blur(2px);
}

.modal.show {
  display: flex;
}

.modal-content {
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  max-width: 720px;
  width: 100%;
  max-height: 85vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(0, 0, 0, 0.05);
}

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

.modal-header h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-tertiary);
  font-size: 1.25rem;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
}

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

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

.detail-row {
  display: flex;
  margin-bottom: 16px;
}

.detail-label {
  width: 90px;
  color: var(--text-secondary);
  font-size: 0.8125rem;
  flex-shrink: 0;
  font-weight: 500;
}

.detail-value {
  font-size: 0.875rem;
  word-break: break-word;
  color: var(--text-primary);
}

.detail-value.result {
  background: var(--bg-secondary);
  padding: 16px;
  border-radius: var(--radius-md);
  white-space: pre-wrap;
  margin-top: 8px;
  width: 100%;
  font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
  font-size: 0.8125rem;
  line-height: 1.7;
}

/* Responsive */
@media (max-width: 768px) {
  #app {
    padding: 20px;
  }
  
  .task-item {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  
  .task-item > * {
    justify-self: start;
  }
  
  .filters {
    flex-direction: column;
    align-items: stretch;
  }
  
  .filter-group select {
    width: 100%;
  }
  
  .researcher-table {
    font-size: 0.75rem;
  }
  
  .researcher-header {
    display: none;
  }
  
  .researcher-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }
  
  .researcher-row .col-title {
    font-weight: 600;
  }
  
  .researcher-row .col-summary {
    -webkit-line-clamp: 2;
  }
}

/* Researcher Table */
.researcher-table {
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.researcher-header {
  display: grid;
  grid-template-columns: 2fr 100px 120px 80px 2fr;
  gap: 12px;
  padding: 12px 18px;
  background: var(--bg-secondary);
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.researcher-row {
  display: grid;
  grid-template-columns: 2fr 100px 120px 80px 2fr;
  gap: 12px;
  padding: 14px 18px;
  background: var(--bg-primary);
  font-size: 0.875rem;
  cursor: pointer;
  transition: background 0.15s ease;
  border-top: 1px solid var(--border-light);
}

.researcher-row:first-of-type {
  border-top: none;
}

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

.researcher-row.new {
  animation: highlight 2s ease-out;
}

.researcher-row .col-title {
  color: var(--accent-blue);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}

.researcher-row .col-title.clickable:hover {
  text-decoration: underline;
}

.researcher-row .col-category {
  color: var(--accent-purple);
  font-size: 0.75rem;
}

.researcher-row .col-time {
  color: var(--text-tertiary);
  font-size: 0.75rem;
}

.researcher-row .col-summary {
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Report content in modal */
.report-content {
  line-height: 1.8;
  max-height: 400px;
  overflow-y: auto;
}

.report-content strong {
  color: var(--accent-blue);
  font-weight: 600;
}

.report-content em {
  color: var(--accent-purple);
}

/* Structured Report Styles */
.report-section {
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-light);
}

.report-section:last-child {
  border-bottom: none;
}

.section-title {
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 14px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title::before {
  content: '';
  width: 3px;
  height: 16px;
  background: var(--accent-blue);
  border-radius: 2px;
}

/* Meta Section */
.meta-section {
  background: var(--bg-secondary);
  padding: 18px;
  border-radius: var(--radius-lg);
  margin-bottom: 24px;
}

.meta-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
}

.meta-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.meta-label {
  font-size: 0.625rem;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 500;
}

.meta-value {
  font-size: 0.875rem;
  color: var(--text-primary);
}

.meta-item.tags .meta-value {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  background: var(--bg-primary);
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.6875rem;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.priority-high, .priority-critical {
  color: var(--accent-red);
}

.priority-medium {
  color: var(--accent-orange);
}

.priority-low {
  color: var(--accent-green);
}

/* Executive Summary */
.one-liner {
  font-size: 1rem;
  font-weight: 500;
  margin-bottom: 14px;
  color: var(--text-primary);
  line-height: 1.6;
}

.takeaways {
  list-style: none;
  padding: 0;
}

.takeaways li {
  padding: 10px 0 10px 28px;
  position: relative;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-primary);
  font-size: 0.875rem;
}

.takeaways li:last-child {
  border-bottom: none;
}

.takeaways li::before {
  content: "→";
  position: absolute;
  left: 0;
  color: var(--accent-blue);
  font-weight: 500;
}

/* KPI Cards */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}

.kpi-card {
  background: var(--bg-secondary);
  padding: 16px;
  border-radius: var(--radius-lg);
  text-align: center;
}

.kpi-metric {
  font-size: 0.6875rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.kpi-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.kpi-change {
  font-size: 0.75rem;
  margin-top: 6px;
  font-weight: 500;
}

.kpi-change.positive {
  color: var(--accent-green);
}

.kpi-change.negative {
  color: var(--accent-red);
}

/* Findings */
.finding-card {
  background: var(--bg-secondary);
  padding: 16px;
  border-radius: var(--radius-lg);
  margin-bottom: 10px;
  border-left: 3px solid var(--accent-blue);
}

.finding-card.opportunity {
  border-left-color: var(--accent-green);
}

.finding-card.risk {
  border-left-color: var(--accent-red);
}

.finding-card.anomaly {
  border-left-color: var(--accent-orange);
}

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

.finding-title {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.875rem;
}

.finding-importance {
  font-size: 0.6875rem;
  color: var(--text-tertiary);
  text-transform: uppercase;
}

.finding-desc {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* Metrics Table */
.metrics-table {
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.metric-row {
  display: grid;
  grid-template-columns: 2fr 1fr 80px 1fr;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg-primary);
  font-size: 0.8125rem;
  border-bottom: 1px solid var(--border-light);
}

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

.metric-name {
  font-weight: 500;
  color: var(--text-primary);
}

.metric-value {
  color: var(--accent-blue);
  font-weight: 500;
}

.metric-source {
  color: var(--text-tertiary);
  font-size: 0.75rem;
}

/* Price Grid */
.price-grid {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  margin: 14px 0;
}

.price-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.price-item span:first-child {
  font-size: 0.6875rem;
  color: var(--text-tertiary);
  text-transform: uppercase;
}

.positive {
  color: var(--accent-green);
}

.negative {
  color: var(--accent-red);
}

/* Events */
.events-list {
  margin-top: 14px;
}

.event-item {
  padding: 10px 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 0.8125rem;
}

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

.event-date {
  color: var(--text-tertiary);
  margin-right: 10px;
  font-weight: 500;
}

.event-impact {
  color: var(--text-tertiary);
  font-size: 0.75rem;
}

/* Risk */
.risk-level {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 500;
}

.risk-low {
  background: rgba(15, 123, 108, 0.1);
  color: var(--accent-green);
}

.risk-medium {
  background: rgba(217, 115, 13, 0.1);
  color: var(--accent-orange);
}

.risk-high, .risk-extreme {
  background: rgba(224, 62, 62, 0.1);
  color: var(--accent-red);
}

.risk-card {
  background: var(--bg-secondary);
  padding: 16px;
  border-radius: var(--radius-lg);
  margin-bottom: 10px;
}

.risk-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
}

.risk-category {
  font-weight: 500;
  text-transform: capitalize;
  color: var(--text-primary);
  font-size: 0.875rem;
}

.risk-impact {
  font-size: 0.6875rem;
  padding: 3px 8px;
  border-radius: 20px;
  font-weight: 500;
}

.impact-high {
  background: rgba(224, 62, 62, 0.1);
  color: var(--accent-red);
}

.impact-medium {
  background: rgba(217, 115, 13, 0.1);
  color: var(--accent-orange);
}

.impact-low {
  background: rgba(15, 123, 108, 0.1);
  color: var(--accent-green);
}

.risk-desc {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.risk-mitigation {
  margin-top: 10px;
  font-size: 0.8125rem;
  color: var(--accent-green);
}

/* Conclusion */
.conclusion-section {
  background: var(--bg-secondary);
  padding: 20px;
  border-radius: var(--radius-lg);
}

.exec-summary {
  font-size: 0.9375rem;
  margin-bottom: 18px;
  line-height: 1.7;
  color: var(--text-primary);
}

.insights ul {
  margin: 10px 0 18px 20px;
  color: var(--text-primary);
}

.insights ul li {
  margin-bottom: 6px;
  font-size: 0.875rem;
}

.outlook {
  margin: 18px 0;
}

.outlook p {
  margin-bottom: 10px;
  font-size: 0.875rem;
  color: var(--text-primary);
}

/* Actions */
.action-list {
  margin-top: 10px;
}

.action-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-light);
}

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

.action-priority {
  font-size: 0.625rem;
  padding: 3px 8px;
  border-radius: 20px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  text-transform: uppercase;
  font-weight: 500;
}

.action-text {
  flex: 1;
  font-size: 0.875rem;
  color: var(--text-primary);
}

.action-timeline {
  font-size: 0.75rem;
  color: var(--text-tertiary);
}

/* Alerts */
.alerts-section {
  padding: 0;
  border: none;
}

.alert {
  padding: 14px 18px;
  border-radius: var(--radius-lg);
  margin-bottom: 10px;
  font-size: 0.8125rem;
  line-height: 1.6;
}

.alert-info {
  background: rgba(35, 131, 226, 0.08);
  border-left: 3px solid var(--accent-blue);
  color: var(--text-primary);
}

.alert-warning {
  background: rgba(217, 115, 13, 0.08);
  border-left: 3px solid var(--accent-orange);
  color: var(--text-primary);
}

.alert-critical {
  background: rgba(224, 62, 62, 0.08);
  border-left: 3px solid var(--accent-red);
  color: var(--text-primary);
}
