:root {
  color-scheme: light;
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-soft: #eef4f7;
  --surface-muted: #f3f6f8;
  --text: #0f172a;
  --muted: #64748b;
  --border: #d9e2ea;
  --primary: #0f172a;
  --accent: #0d9488;
  --accent-soft: #ecfeff;
  --success: #059669;
  --warning: #d97706;
  --info: #2563eb;
  --slate: #475569;
  --shadow: 0 24px 48px rgba(15, 23, 42, 0.08);
  --radius: 22px;
  --radius-sm: 14px;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(13, 148, 136, 0.08), transparent 28%),
    radial-gradient(circle at top right, rgba(15, 23, 42, 0.06), transparent 26%),
    var(--bg);
  color: var(--text);
}

body {
  font-size: 16px;
  line-height: 1.5;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select {
  font: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px 24px;
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid rgba(217, 226, 234, 0.9);
  backdrop-filter: blur(18px);
}

.brand-wrap {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 0.86rem;
  color: white;
  background: linear-gradient(135deg, var(--primary), #1e3a8a);
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.18);
}

.brand-mark.large {
  width: 58px;
  height: 58px;
  border-radius: 18px;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.brand-title {
  font-size: 0.98rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand-badge,
.env-pill,
.pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  border-radius: 999px;
  border: 1px solid var(--border);
  padding: 4px 10px;
  font-size: 0.73rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.brand-badge,
.pill-muted {
  color: var(--muted);
  background: var(--surface-muted);
}

.env-pill,
.pill-accent {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: rgba(13, 148, 136, 0.18);
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 14px;
}

.user-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
}

.user-name {
  color: var(--text);
  font-weight: 600;
}

.topbar-muted {
  color: var(--muted);
  font-size: 0.95rem;
}

.link-button,
.primary,
.secondary,
.danger {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 11px 16px;
  font-weight: 700;
  cursor: pointer;
  transition:
    transform 0.15s ease,
    box-shadow 0.15s ease,
    background 0.15s ease,
    border-color 0.15s ease;
}

.link-button,
.secondary {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}

.primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 14px 30px rgba(13, 148, 136, 0.18);
}

.danger {
  background: #dc2626;
  color: #fff;
  box-shadow: 0 14px 30px rgba(220, 38, 38, 0.14);
}

.primary:hover,
.secondary:hover,
.danger:hover,
.link-button:hover {
  transform: translateY(-1px);
}

.page-shell {
  width: min(1200px, calc(100% - 48px));
  margin: 0 auto;
  padding: 28px 24px 48px;
}

.hero {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 24px;
  margin-bottom: 18px;
}

.hero h1,
.auth-card h1,
.detail-head h2 {
  margin: 0;
  letter-spacing: -0.03em;
}

.hero h1 {
  font-size: clamp(2.2rem, 4vw, 3.6rem);
}

.lead {
  max-width: 760px;
  margin: 10px 0 0;
  color: var(--muted);
}

.kicker {
  margin: 0;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

.hero-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: end;
  gap: 10px;
}

.card {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(217, 226, 234, 0.95);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.filters {
  padding: 20px;
  margin-bottom: 18px;
}

.filters-grid {
  display: grid;
  grid-template-columns: 2fr repeat(6, 1fr) auto;
  gap: 14px;
  align-items: end;
}

.filters-grid label,
.auth-form label {
  display: grid;
  gap: 7px;
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--text);
}

.search-field {
  min-width: 280px;
}

.span-2 {
  grid-column: span 2;
}

input,
select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 11px 13px;
  background: #fff;
  color: var(--text);
  outline: none;
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}

input:focus,
select:focus {
  border-color: rgba(13, 148, 136, 0.65);
  box-shadow: 0 0 0 4px rgba(13, 148, 136, 0.12);
}

.filters-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: end;
  padding-bottom: 1px;
}

.board,
.detail-hero {
  padding: 20px;
  margin-bottom: 18px;
}

.board-meta {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  color: var(--muted);
  font-size: 0.92rem;
  margin-bottom: 14px;
}

.table-wrap {
  overflow-x: auto;
  border-radius: 18px;
  border: 1px solid rgba(217, 226, 234, 0.8);
}

.board-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 900px;
  background: #fff;
}

.board-table th,
.board-table td {
  text-align: left;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(226, 232, 240, 0.9);
  vertical-align: middle;
}

.board-table th {
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  background: #f8fafc;
}

.board-table tbody tr:hover {
  background: rgba(236, 254, 255, 0.68);
}

.lead-link {
  font-weight: 700;
  color: var(--primary);
}

.row-link {
  font-weight: 700;
  color: var(--accent);
}

.mono {
  font-variant-numeric: tabular-nums;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 6px 10px;
  border: 1px solid transparent;
  font-weight: 800;
  font-size: 0.78rem;
}

.status-badge.pendiente {
  background: rgba(245, 158, 11, 0.12);
  color: #b45309;
  border-color: rgba(245, 158, 11, 0.22);
}

.status-badge.nuevo {
  background: rgba(245, 158, 11, 0.12);
  color: #b45309;
  border-color: rgba(245, 158, 11, 0.22);
}

.status-badge.contactado {
  background: rgba(16, 185, 129, 0.12);
  color: #047857;
  border-color: rgba(16, 185, 129, 0.22);
}

.status-badge.prospecto,
.status-badge.asignado {
  background: rgba(13, 148, 136, 0.12);
  color: #0f766e;
  border-color: rgba(13, 148, 136, 0.22);
}

.status-badge.en-evaluacion,
.status-badge.en-evaluación {
  background: rgba(37, 99, 235, 0.12);
  color: #1d4ed8;
  border-color: rgba(37, 99, 235, 0.22);
}

.status-badge.citado,
.status-badge.en-tramite,
.status-badge.expediente,
.status-badge.duplicado,
.status-badge.dormido {
  background: rgba(59, 130, 246, 0.12);
  color: #1d4ed8;
  border-color: rgba(59, 130, 246, 0.22);
}

.status-badge.ficha-generada,
.status-badge.cerrado {
  background: rgba(71, 85, 105, 0.12);
  color: #334155;
  border-color: rgba(71, 85, 105, 0.22);
}

.status-badge.perdido,
.status-badge.no-califica {
  background: rgba(220, 38, 38, 0.12);
  color: #b91c1c;
  border-color: rgba(220, 38, 38, 0.22);
}

.badge-status.nuevo {
  background: rgba(245, 158, 11, 0.12);
  color: #b45309;
  border-color: rgba(245, 158, 11, 0.22);
}

.badge-status.prospecto,
.badge-status.asignado,
.badge-status.contactado {
  background: rgba(13, 148, 136, 0.12);
  color: #0f766e;
  border-color: rgba(13, 148, 136, 0.22);
}

.badge-status.citado,
.badge-status.en-tramite,
.badge-status.expediente,
.badge-status.duplicado,
.badge-status.dormido {
  background: rgba(59, 130, 246, 0.12);
  color: #1d4ed8;
  border-color: rgba(59, 130, 246, 0.22);
}

.badge-status.ficha-generada,
.badge-status.cerrado {
  background: rgba(71, 85, 105, 0.12);
  color: #334155;
  border-color: rgba(71, 85, 105, 0.22);
}

.badge-status.perdido,
.badge-status.no-califica {
  background: rgba(220, 38, 38, 0.12);
  color: #b91c1c;
  border-color: rgba(220, 38, 38, 0.22);
}

.status-badge.cerrado {
  background: rgba(71, 85, 105, 0.12);
  color: #334155;
  border-color: rgba(71, 85, 105, 0.22);
}

.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-top: 14px;
  color: var(--muted);
}

.pagination-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.inline {
  display: inline-flex;
}

.disabled {
  padding: 11px 16px;
  color: #94a3b8;
}

.empty-state {
  display: grid;
  place-items: center;
  text-align: center;
  gap: 8px;
  padding: 56px 24px;
  color: var(--muted);
}

.empty-state h3 {
  margin: 0;
  color: var(--text);
}

.notice,
.alert {
  border-radius: 16px;
  padding: 14px 16px;
  margin: 14px 0;
}

.notice-soft {
  background: rgba(13, 148, 136, 0.08);
  border: 1px solid rgba(13, 148, 136, 0.15);
}

.alert-error {
  background: rgba(220, 38, 38, 0.08);
  border: 1px solid rgba(220, 38, 38, 0.16);
  color: #b91c1c;
}

.auth-shell {
  display: grid;
  place-items: center;
  min-height: calc(100vh - 140px);
}

.auth-card {
  width: min(560px, 100%);
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(217, 226, 234, 0.95);
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: 32px;
}

.auth-brand {
  display: flex;
  gap: 18px;
  align-items: center;
  margin-bottom: 24px;
}

.auth-form {
  display: grid;
  gap: 16px;
  margin-top: 18px;
}

.primary-full {
  width: 100%;
  justify-content: center;
}

.detail-back-row,
.detail-head,
.detail-grid {
  display: flex;
  gap: 14px;
  align-items: start;
}

.detail-back-row {
  justify-content: space-between;
  margin-bottom: 16px;
}

.detail-head {
  justify-content: space-between;
  align-items: center;
  padding-bottom: 18px;
  border-bottom: 1px solid rgba(217, 226, 234, 0.7);
}

.detail-title-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.detail-subtitle {
  margin-top: 8px;
}

.detail-grid {
  margin-top: 18px;
  flex-wrap: wrap;
}

.detail-page {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.nav-back-row {
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

.btn-back {
  white-space: nowrap;
}

.lead-hero-card {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px 28px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

.lead-identity {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.title-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.lead-name {
  margin: 0;
  font-size: clamp(1.9rem, 3vw, 2.7rem);
  letter-spacing: -0.03em;
}

.badge-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
  border: 1px solid transparent;
}

.badge-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
}

.lead-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  color: var(--muted);
  font-size: 0.92rem;
  flex-wrap: wrap;
}

.meta-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.meta-item strong {
  color: var(--text);
}

.meta-divider {
  color: var(--border);
}

.lead-hero-actions {
  display: flex;
  align-items: center;
}

.btn-primary-simulator {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background-color: var(--accent);
  color: white;
  font-size: 0.92rem;
  font-weight: 700;
  padding: 12px 22px;
  border-radius: 12px;
  text-decoration: none;
  border: none;
  box-shadow: 0 8px 18px rgba(13, 148, 136, 0.18);
  transition: all 0.15s ease;
  cursor: pointer;
}

.btn-primary-simulator:hover {
  background-color: #0f766e;
  box-shadow: 0 12px 20px rgba(13, 148, 136, 0.24);
  transform: translateY(-1px);
}

.state-control-bar {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  box-shadow: var(--shadow-sm);
  flex-wrap: wrap;
}

.state-info {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.92rem;
}

.state-label {
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  font-size: 0.73rem;
  letter-spacing: 0.06em;
}

.state-action-group {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.select-compact {
  min-width: 180px;
  padding: 11px 14px;
  border-radius: 14px;
}

.btn-save-state {
  appearance: none;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  padding: 12px 18px;
  box-shadow: 0 14px 30px rgba(13, 148, 136, 0.18);
}

.detail-grid-v2 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.info-card-v2,
.story-card,
.dev-tools-card {
  background: linear-gradient(180deg, #fff, #fbfdff);
  border: 1px solid rgba(217, 226, 234, 0.9);
  border-radius: 20px;
  padding: 18px;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.05);
}

.info-card-v2 h3,
.story-card h3,
.dev-tools-card h3 {
  margin: 0 0 14px;
  font-size: 1rem;
  letter-spacing: -0.02em;
}

.info-card-v2 dl {
  display: grid;
  gap: 14px;
  margin: 0;
}

.info-card-v2 dt {
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 4px;
  font-weight: 700;
}

.info-card-v2 dd {
  margin: 0;
  font-weight: 700;
}

.story-card,
.dev-tools-card {
  margin-top: 0;
}

.story-card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
  margin-bottom: 14px;
}

.original-request-box {
  background: #f8fafc;
  border: 1px solid rgba(13, 148, 136, 0.18);
  border-left: 4px solid var(--accent);
  border-radius: 0 16px 16px 0;
  padding: 18px 20px;
  font-size: 0.95rem;
  line-height: 1.7;
  color: #334155;
  white-space: pre-wrap;
}

.empty-inline,
.empty-followup {
  color: var(--muted);
  font-style: italic;
}

.timeline-list {
  display: grid;
  gap: 12px;
}

.timeline-item {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #fff;
  padding: 16px 18px;
}

.timeline-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.84rem;
  font-weight: 800;
  color: var(--muted);
  margin-bottom: 8px;
}

.timeline-author {
  color: var(--primary);
}

.timeline-text {
  white-space: pre-wrap;
  line-height: 1.65;
  color: #334155;
}

.note-form {
  margin-top: 16px;
  display: grid;
  gap: 12px;
}

.note-label {
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--text);
}

.note-form textarea {
  min-height: 156px;
  width: 100%;
}

.note-actions {
  display: flex;
  justify-content: end;
}

.note-submit {
  background: linear-gradient(135deg, var(--accent), #128b7f);
}

.dev-tools-card {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.modal-card-dev {
  width: min(560px, 100%);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.ops-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 18px;
}

.ops-card {
  display: grid;
  gap: 14px;
  background: linear-gradient(180deg, #fff, #fbfdff);
  border: 1px solid rgba(217, 226, 234, 0.9);
  border-radius: 18px;
  padding: 18px;
}

.ops-card h3 {
  margin: 0;
  font-size: 0.95rem;
}

.ops-card textarea {
  min-height: 132px;
  resize: vertical;
}

.comment-history {
  white-space: pre-wrap;
  color: #334155;
}

.info-card,
.comment-card {
  flex: 1 1 280px;
  background: linear-gradient(180deg, #fff, #fbfdff);
  border: 1px solid rgba(217, 226, 234, 0.9);
  border-radius: 18px;
  padding: 18px;
}

.info-card h3,
.comment-card h3 {
  margin: 0 0 14px;
  font-size: 0.95rem;
}

.info-card dl {
  display: grid;
  gap: 14px;
  margin: 0;
}

.info-card dt {
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 4px;
}

.info-card dd {
  margin: 0;
  font-weight: 700;
}

.comment-card {
  margin-top: 18px;
}

.comment-card p {
  margin: 0;
  color: #334155;
}

.toast-container {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 60;
  display: grid;
  gap: 10px;
}

.toast {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 14px;
  padding: 12px 16px;
  background: #0f172a;
  color: #fff;
  box-shadow: 0 18px 35px rgba(15, 23, 42, 0.24);
}

.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(15, 23, 42, 0.48);
  backdrop-filter: blur(4px);
  z-index: 70;
  padding: 20px;
}

.modal[hidden] {
  display: none;
}

.modal-card {
  width: min(480px, 100%);
  background: #fff;
  border-radius: 24px;
  border: 1px solid rgba(217, 226, 234, 0.95);
  box-shadow: var(--shadow);
  padding: 24px;
}

.modal-actions {
  margin-top: 20px;
  display: flex;
  justify-content: end;
  gap: 12px;
}

@media (max-width: 1200px) {
  .filters-grid {
    grid-template-columns: 1fr 1fr;
  }

  .span-2 {
    grid-column: auto;
  }
}

@media (max-width: 800px) {
  .topbar,
  .page-shell {
    width: min(100% - 24px, 1380px);
  }

  .hero,
  .board-meta,
  .pagination,
  .detail-head,
  .detail-back-row {
    flex-direction: column;
    align-items: start;
  }

  .filters-grid {
    grid-template-columns: 1fr;
  }

  .ops-grid {
    grid-template-columns: 1fr;
  }

  .lead-hero-card,
  .state-control-bar,
  .dev-tools-card {
    display: grid;
    grid-template-columns: 1fr;
  }

  .lead-hero-actions,
  .nav-back-row {
    justify-self: start;
  }

  .detail-grid-v2 {
    grid-template-columns: 1fr;
  }

  .filters-actions {
    justify-content: start;
  }
}
