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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: #f4f5f7;
  color: #1a1a2e;
  line-height: 1.5;
  min-height: 100vh;
}

.header {
  background: #1a1a2e;
  color: #fff;
  padding: 1.5rem 2rem;
}

.header-content {
  max-width: 1200px;
  margin: 0 auto;
}

.header h1 {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.header-sep {
  color: #555;
}

.header-sub {
  font-weight: 400;
  color: #a0a0b8;
}

.header-desc {
  margin-top: 0.25rem;
  font-size: 0.875rem;
  color: #7a7a94;
}

.main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem 2rem;
}

.section {
  margin-bottom: 1.5rem;
}

.section-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: #1a1a2e;
}

.hidden {
  display: none !important;
}

/* Status message */

.status-message {
  padding: 1.5rem;
  background: #fff3cd;
  border: 1px solid #ffc107;
  border-radius: 8px;
  color: #856404;
  font-size: 0.95rem;
  text-align: center;
}

/* Summary cards */

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.75rem;
}

.summary-card {
  background: #fff;
  border-radius: 8px;
  padding: 1rem;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.summary-card .card-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: #1a1a2e;
  line-height: 1.2;
}

.summary-card .card-label {
  font-size: 0.75rem;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 0.25rem;
}

.summary-card.card-warning .card-value {
  color: #d97706;
}

/* Run card */

.run-card {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  overflow: hidden;
}

.run-status-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  font-weight: 600;
}

.run-status-bar.run-success { background: #d1fae5; color: #065f46; }
.run-status-bar.run-partial { background: #fef3c7; color: #92400e; }
.run-status-bar.run-failed  { background: #fee2e2; color: #991b1b; }
.run-status-bar:not(.run-success):not(.run-partial):not(.run-failed) { background: #e0e7ff; color: #3730a3; }

.run-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.run-success .run-status-dot { background: #059669; }
.run-partial .run-status-dot { background: #d97706; }
.run-failed .run-status-dot  { background: #dc2626; }
.run-status-bar:not(.run-success):not(.run-partial):not(.run-failed) .run-status-dot { background: #4f46e5; }

.run-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.5rem;
  padding: 1rem;
}

.run-item {
  text-align: center;
}

.run-label {
  display: block;
  font-size: 0.7rem;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.run-value {
  display: block;
  font-size: 1.1rem;
  font-weight: 600;
  color: #1a1a2e;
  margin-top: 0.1rem;
}

.run-warnings {
  padding: 0.5rem 1rem 1rem;
  font-size: 0.8rem;
  color: #92400e;
}

.run-warnings div {
  padding: 0.25rem 0;
}

/* Warnings */

/* Candidates */

.candidates-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 0.75rem;
}

.candidate-card {
  background: #fff;
  border-radius: 8px;
  padding: 1rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.candidate-name {
  font-weight: 600;
  font-size: 1rem;
  margin-bottom: 0.25rem;
}

.candidate-meta {
  font-size: 0.8rem;
  color: #6b7280;
  margin-bottom: 0.5rem;
}

.candidate-skills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-bottom: 0.75rem;
}

.tag {
  display: inline-block;
  padding: 0.1rem 0.4rem;
  font-size: 0.7rem;
  background: #e0e7ff;
  color: #3730a3;
  border-radius: 4px;
}

.candidate-actions {
  display: flex;
  gap: 0.5rem;
}

.btn-small {
  padding: 0.3rem 0.75rem;
  font-size: 0.75rem;
}

#matches-table td:first-child {
  font-size: 1.1rem;
  text-align: center;
  width: 60px;
}

/* Warnings */

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

.warnings-list li {
  padding: 0.5rem 0.75rem;
  background: #fff3cd;
  border: 1px solid #ffc107;
  border-radius: 6px;
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
  color: #856404;
}

/* Controls */

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
  background: #fff;
  padding: 1rem;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 160px;
  flex: 1;
}

.control-group label {
  font-size: 0.75rem;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.control-group input,
.control-group select {
  padding: 0.5rem 0.75rem;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.875rem;
  background: #fff;
  color: #1a1a2e;
  outline: none;
  transition: border-color 0.15s;
}

.control-group input:focus,
.control-group select:focus {
  border-color: #4f46e5;
  box-shadow: 0 0 0 2px rgba(79,70,229,0.15);
}

.btn {
  padding: 0.5rem 1.25rem;
  background: #4f46e5;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}

.btn:hover {
  background: #4338ca;
}

.btn:active {
  background: #3730a3;
}

/* Table */

.table-wrapper {
  overflow-x: auto;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

#jobs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

#jobs-table thead {
  background: #f9fafb;
}

#jobs-table th {
  text-align: left;
  padding: 0.75rem 1rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 2px solid #e5e7eb;
  white-space: nowrap;
}

#jobs-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #f3f4f6;
  vertical-align: middle;
}

#jobs-table tbody tr {
  cursor: pointer;
  transition: background 0.1s;
}

#jobs-table tbody tr:hover {
  background: #f0f0ff;
}

#jobs-table tbody tr:last-child td {
  border-bottom: none;
}

#jobs-table .job-title-cell {
  font-weight: 500;
  color: #1a1a2e;
}

#jobs-table .job-link-cell a {
  color: #4f46e5;
  text-decoration: none;
  font-size: 0.8rem;
}

#jobs-table .job-link-cell a:hover {
  text-decoration: underline;
}

#jobs-table .badge {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
}

.badge-presencial {
  background: #e0e7ff;
  color: #3730a3;
}

.badge-remoto {
  background: #d1fae5;
  color: #065f46;
}

.badge-hibrido {
  background: #fef3c7;
  color: #92400e;
}

.badge-default {
  background: #f3f4f6;
  color: #4b5563;
}

.no-results {
  text-align: center;
  padding: 2rem;
  color: #6b7280;
  font-size: 0.9rem;
}

/* Mobile cards */

.mobile-cards {
  display: none;
}

.mobile-card {
  background: #fff;
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 0.75rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  cursor: pointer;
  transition: background 0.1s;
}

.mobile-card:hover {
  background: #f0f0ff;
}

.mobile-card-title {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 0.25rem;
}

.mobile-card-meta {
  font-size: 0.8rem;
  color: #6b7280;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.mobile-card-meta span {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

/* Detail panel */

.detail-panel {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  justify-content: flex-end;
}

.detail-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.35);
}

.detail-content {
  position: relative;
  width: 100%;
  max-width: 540px;
  height: 100%;
  background: #fff;
  overflow-y: auto;
  box-shadow: -4px 0 20px rgba(0,0,0,0.12);
  animation: slideIn 0.2s ease-out;
}

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

.detail-close {
  position: sticky;
  top: 0;
  float: right;
  background: none;
  border: none;
  font-size: 1.5rem;
  padding: 0.75rem 1rem;
  cursor: pointer;
  color: #6b7280;
  z-index: 1;
}

.detail-close:hover {
  color: #1a1a2e;
}

.detail-body {
  padding: 0 1.5rem 2rem;
}

.detail-body h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
  padding-right: 2rem;
}

.detail-body .detail-company {
  font-size: 0.95rem;
  color: #4f46e5;
  font-weight: 500;
  margin-bottom: 1rem;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  background: #f9fafb;
  padding: 0.75rem 1rem;
  border-radius: 8px;
}

.detail-grid-item {
  font-size: 0.8rem;
}

.detail-grid-item .label {
  color: #6b7280;
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.1rem;
}

.detail-grid-item .value {
  font-weight: 500;
  color: #1a1a2e;
}

.detail-section {
  margin-bottom: 1rem;
}

.detail-section h3 {
  font-size: 0.85rem;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.375rem;
}

.detail-section p, .detail-section div {
  font-size: 0.875rem;
  color: #374151;
  line-height: 1.6;
  white-space: pre-wrap;
}

.detail-section a {
  color: #4f46e5;
}

.detail-section a:hover {
  text-decoration: underline;
}

.detail-raw-toggle {
  background: none;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 0.375rem 0.75rem;
  font-size: 0.8rem;
  cursor: pointer;
  color: #6b7280;
  margin-bottom: 0.5rem;
}

.detail-raw-toggle:hover {
  background: #f3f4f6;
}

.detail-raw-block {
  background: #1a1a2e;
  color: #e5e7eb;
  padding: 0.75rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 300px;
  overflow-y: auto;
}

/* Responsive */

@media (max-width: 768px) {
  .header {
    padding: 1rem;
  }
  .main {
    padding: 1rem;
  }
  .summary-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .controls {
    flex-direction: column;
  }
  .control-group {
    min-width: 100%;
  }
  .table-wrapper {
    display: none;
  }
  .mobile-cards {
    display: block;
  }
  .detail-content {
    max-width: 100%;
  }
  .detail-grid {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 769px) {
  .table-wrapper {
    display: block;
  }
  .mobile-cards {
    display: none;
  }
}

/* ===== CHATS IA ===== */

.chat-threads-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 0.75rem;
}

.chat-thread-card {
  background: #fff;
  border-radius: 8px;
  padding: 1rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  cursor: pointer;
  transition: background 0.1s, box-shadow 0.1s;
}

.chat-thread-card:hover {
  background: #f0f0ff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.12);
}

.chat-thread-card .thread-name {
  font-weight: 600;
  font-size: 1rem;
  margin-bottom: 0.25rem;
}

.chat-thread-card .thread-meta {
  font-size: 0.8rem;
  color: #6b7280;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.chat-thread-card .thread-meta span {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.chat-thread-card .thread-badge {
  display: inline-block;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
}

.thread-badge-active {
  background: #d1fae5;
  color: #065f46;
}

.thread-badge-closed {
  background: #f3f4f6;
  color: #4b5563;
}

/* Chat messages view */

.chat-messages-container {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  padding: 1rem;
  max-height: 70vh;
  overflow-y: auto;
}

.chat-message {
  display: flex;
  margin-bottom: 0.75rem;
  gap: 0.75rem;
}

.chat-message-user {
  flex-direction: row-reverse;
}

.chat-message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}

.chat-message-user .chat-message-avatar {
  background: #4f46e5;
  color: #fff;
}

.chat-message-assistant .chat-message-avatar {
  background: #10b981;
  color: #fff;
}

.chat-message-system .chat-message-avatar {
  background: #f59e0b;
  color: #fff;
}

.chat-message-bubble {
  max-width: 75%;
  padding: 0.6rem 0.9rem;
  border-radius: 12px;
  font-size: 0.875rem;
  line-height: 1.5;
}

.chat-message-user .chat-message-bubble {
  background: #4f46e5;
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-message-assistant .chat-message-bubble {
  background: #f0f0ff;
  color: #1a1a2e;
  border-bottom-left-radius: 4px;
}

.chat-message-system .chat-message-bubble {
  background: #fffbeb;
  color: #92400e;
  border-bottom-left-radius: 4px;
  font-style: italic;
  font-size: 0.8rem;
}

.chat-message-time {
  font-size: 0.65rem;
  color: #9ca3af;
  margin-top: 0.2rem;
}

.chat-message-user .chat-message-time {
  text-align: right;
}

.chat-message-metadata {
  margin-top: 0.3rem;
  padding-top: 0.3rem;
  border-top: 1px dashed #d1d5db;
}

.chat-message-metadata summary {
  font-size: 0.7rem;
  color: #6b7280;
  cursor: pointer;
  font-weight: 600;
}

.chat-message-metadata pre {
  font-size: 0.65rem;
  background: #f9fafb;
  padding: 0.4rem;
  border-radius: 4px;
  margin-top: 0.25rem;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 120px;
  overflow-y: auto;
}

.chat-empty {
  text-align: center;
  padding: 2rem;
  color: #6b7280;
  font-size: 0.9rem;
}

.chat-loading {
  text-align: center;
  padding: 1rem;
  color: #6b7280;
  font-size: 0.85rem;
}
