* { box-sizing: border-box; }
:root {
  --bg-card: #141019;
  --border: #2a2632;
  --accent: #7c3aed;
  --accent-light: #a78bfa;
  --text: #ffffff;
  --text-dim: #b8b3c2;
  --text-faint: #7d7788;
  --ok: #4ade80;
  --warn: #fbbf24;
  --danger: #f87171;
  --info: #60a5fa;
}
html, body { margin: 0; min-height: 100vh; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: radial-gradient(circle at top left, #1d1130 0%, #0a0a0a 55%);
  color: var(--text);
}
h1, h2, h3 { font-family: 'Space Grotesk', system-ui, sans-serif; margin: 0; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: .8rem;
  padding: .9rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: rgba(20, 16, 25, .7);
  backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 10;
}
.topbar__brand {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  pointer-events: none; /* el logo no bloquea clics; solo decorativo/centrado */
}
.topbar__brand img { height: 26px; display: block; pointer-events: auto; }
.topbar__user { display: flex; align-items: center; gap: .9rem; font-size: .82rem; color: var(--text-dim); position: relative; }

/* Menú de navegación: burbuja en la esquina (igual patrón que la burbuja de cuenta) */
.nav-menu { position: relative; }
.nav-menu summary { list-style: none; cursor: pointer; }
.nav-menu summary::-webkit-details-marker { display: none; }
.nav-toggle-btn {
  width: 34px; height: 34px; border-radius: 8px;
  border: 1px solid var(--border); color: #fff; font-size: 1.1rem;
  display: flex; align-items: center; justify-content: center; background: transparent;
}
.nav-toggle-btn:hover { border-color: var(--accent); }
.nav-dropdown {
  position: absolute; left: 0; top: calc(100% + .6rem); z-index: 20;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px;
  min-width: 220px; padding: .5rem; display: flex; flex-direction: column; gap: .2rem;
  box-shadow: 0 16px 40px -14px rgba(0, 0, 0, .6);
}
.nav-dropdown a {
  color: var(--text-dim); text-decoration: none; font-size: .85rem;
  padding: .6rem .7rem; border-radius: 8px; white-space: nowrap;
}
.nav-dropdown a:hover { background: var(--border); color: #fff; }
.nav-dropdown a.is-active { background: var(--accent); color: #fff; }

/* Burbuja de cuenta (menú desplegable nativo con <details>, sin JS) */
.cuenta-menu { position: relative; }
.cuenta-menu summary { list-style: none; cursor: pointer; }
.cuenta-menu summary::-webkit-details-marker { display: none; }
.cuenta-bubble {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--accent); color: #fff; font-weight: 700; font-size: .95rem;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--accent-light);
}
.cuenta-bubble:hover { background: #6d28d9; }
.cuenta-dropdown {
  position: absolute; right: 0; top: calc(100% + .6rem); z-index: 20;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px;
  min-width: 200px; padding: .5rem; display: flex; flex-direction: column; gap: .2rem;
  box-shadow: 0 16px 40px -14px rgba(0, 0, 0, .6);
}
.cuenta-dropdown a {
  color: var(--text-dim); text-decoration: none; font-size: .85rem;
  padding: .6rem .7rem; border-radius: 8px;
}
.cuenta-dropdown a:hover { background: var(--border); color: #fff; }
.cuenta-dropdown__logout { color: var(--danger) !important; font-weight: 600; }
.cuenta-dropdown__logout:hover { background: #3a1414 !important; color: var(--danger) !important; }

main { padding: 1.6rem; max-width: 1200px; margin: 0 auto; }

.page-head { margin-bottom: 1.4rem; display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; }
.page-head h1 { font-size: 1.5rem; }
.page-head p { color: var(--text-faint); font-size: .9rem; margin: .3rem 0 0; }

.resumen { display: flex; gap: .6rem; flex-wrap: wrap; margin-bottom: 1.3rem; }
.resumen .pill {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 999px;
  padding: .55rem 1.1rem; font-size: .82rem; color: var(--text-dim);
}
.resumen .pill strong { color: #fff; }

.tabs { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: 1rem; }
.tabs a {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px;
  padding: .5rem .9rem; font-size: .82rem; color: var(--text-dim); text-decoration: none;
}
.tabs a.is-active { background: var(--accent); border-color: var(--accent); color: #fff; }

.count { color: var(--text-faint); font-size: .88rem; margin-bottom: 1rem; }

.lista-toolbar { display: flex; justify-content: space-between; align-items: center; gap: .8rem; margin-bottom: 1rem; flex-wrap: wrap; }
.lista-toolbar .count { margin-bottom: 0; }

/* Botón de filtros: ícono pequeño que despliega el panel de búsqueda (patrón de las burbujas del topbar) */
.filtros-menu { position: relative; }
.filtros-menu summary { list-style: none; cursor: pointer; }
.filtros-menu summary::-webkit-details-marker { display: none; }
.filtros-toggle {
  width: 38px; height: 38px; border-radius: 10px;
  background: var(--bg-card); border: 1px solid var(--border); color: var(--text-dim);
  display: flex; align-items: center; justify-content: center;
}
.filtros-toggle:hover { border-color: var(--accent); color: #fff; }
.filtros-menu[open] .filtros-toggle { border-color: var(--accent); color: #fff; background: var(--accent); }
.filtros-panel {
  position: absolute; right: 0; top: calc(100% + .6rem); z-index: 20;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 14px;
  padding: 1rem; width: 280px; max-width: 90vw;
  box-shadow: 0 16px 40px -14px rgba(0, 0, 0, .6);
  overflow: hidden;
}
.filtros-panel .campo { margin-bottom: .8rem; display: flex; flex-direction: column; }
.filtros-panel .campo input, .filtros-panel .campo select {
  width: 100%; max-width: 100%; min-width: 0; flex: 1 1 auto;
}
.filtros-panel__acciones { display: flex; gap: .5rem; align-items: center; }

.card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 14px;
  padding: 1.3rem; margin-bottom: 1rem;
  box-shadow: 0 10px 30px -18px rgba(124, 58, 237, .35);
  transition: border-color .15s, transform .15s;
}
.card:hover { border-color: #3c3650; }
.card.is-contactada { opacity: .75; }
.card__head { display: flex; justify-content: space-between; align-items: flex-start; gap: .6rem; flex-wrap: wrap; }
.card h2 { font-size: 1.05rem; margin: 0 0 .3rem; color: var(--accent-light); }
.card .fecha { font-size: .78rem; color: var(--text-faint); margin-bottom: .8rem; }

.badge { font-size: .72rem; padding: .25rem .6rem; border-radius: 999px; white-space: nowrap; font-weight: 600; display: inline-flex; align-items: center; }
.badge.pendiente, .badge.invitada { background: #3a2e12; color: var(--warn); }
.badge.contactada, .badge.activa { background: #123a1e; color: var(--ok); }

/* Estados del pipeline de solicitudes */
.badge.estado-nueva { background: #1e2a4a; color: var(--info); }
.badge.estado-contactada { background: #123a1e; color: var(--ok); }
.badge.estado-en_revision { background: #3a2e12; color: var(--warn); }
.badge.estado-documentos_pendientes { background: #3a2412; color: #fb923c; }
.badge.estado-lista_decision { background: #2a1e4a; color: var(--accent-light); }
.badge.estado-aprobada_incorporacion { background: #123a2e; color: var(--ok); }
.badge.estado-incorporada { background: #0f3a1e; color: var(--ok); }
.badge.estado-no_continua { background: #3a1414; color: var(--danger); }

/* Estados de documentos */
.badge.doc-pendiente { background: #3a2e12; color: var(--warn); }
.badge.doc-recibido { background: #1e2a4a; color: var(--info); }
.badge.doc-verificado { background: #123a1e; color: var(--ok); }
.badge.doc-requiere_correccion { background: #3a1414; color: var(--danger); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: .5rem .8rem; font-size: .88rem; margin-bottom: .8rem; }
.grid dt { color: var(--text-faint); font-size: .74rem; text-transform: uppercase; letter-spacing: .03em; }
.grid dd { margin: 0 0 .5rem; }

.fotos { display: flex; gap: .6rem; flex-wrap: wrap; margin-bottom: .8rem; }
.fotos a img { width: 130px; height: 90px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); display: block; }
.fotos a { font-size: .74rem; color: var(--text-dim); text-align: center; display: block; }

.acciones { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.acciones button, .btn {
  background: transparent; border: 1px solid var(--border); color: var(--text-dim);
  border-radius: 8px; padding: .5rem .9rem; font-size: .8rem; cursor: pointer;
  text-decoration: none; display: inline-block; font-family: inherit;
}
.acciones button:hover, .btn:hover { border-color: var(--accent); color: #fff; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
.btn--primary:hover { background: #6d28d9; border-color: #6d28d9; color: #fff; }
.btn--danger:hover { border-color: var(--danger); color: var(--danger); }
.btn--sm { padding: .35rem .7rem; font-size: .75rem; }

.empty { color: var(--text-faint); padding: 2.5rem; text-align: center; }

.aviso { border-radius: 10px; padding: .8rem 1rem; font-size: .85rem; margin-bottom: 1.2rem; }
.aviso.ok { background: #123a1e; color: var(--ok); border: 1px solid #1d5a30; }
.aviso.error { background: #3a1414; color: var(--danger); border: 1px solid #5a1d1d; }

.invite-form, .filtros {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 14px;
  padding: 1.3rem; margin-bottom: 1.6rem;
}
.invite-form h2, .filtros h2 { font-size: 1rem; color: var(--accent-light); margin-bottom: .9rem; }
.invite-form .campos, .filtros .campos { display: flex; gap: .8rem; flex-wrap: wrap; align-items: flex-end; }
.invite-form .campo, .filtros .campo { flex: 1; min-width: 160px; }
label { display: block; font-size: .78rem; color: var(--text-dim); margin-bottom: .3rem; }
input[type="text"], input[type="email"], input[type="password"], input[type="date"], input[type="number"],
select, textarea {
  width: 100%; max-width: 100%; min-width: 0; padding: .65rem .8rem; border-radius: 8px; border: 1px solid var(--border);
  background: #0a0a0a; color: #fff; font-size: .9rem; font-family: inherit;
}
textarea { resize: vertical; min-height: 4.5rem; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Métricas del Resumen */
.metricas { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .9rem; margin-bottom: 1.6rem; }
.metrica {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 14px;
  padding: 1.2rem; text-decoration: none; display: block; transition: border-color .15s;
}
.metrica:hover { border-color: var(--accent); }
.metrica .valor { font-family: 'Space Grotesk', sans-serif; font-size: 2.1rem; font-weight: 700; color: #fff; }
.metrica .etiqueta { font-size: .82rem; color: var(--text-dim); margin-top: .2rem; }

.secciones-resumen { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1.2rem; }
.panel-lista { background: var(--bg-card); border: 1px solid var(--border); border-radius: 14px; padding: 1.2rem; }
.panel-lista h3 { font-size: .95rem; color: var(--accent-light); margin-bottom: .8rem; }
.panel-lista ul { list-style: none; margin: 0; padding: 0; }
.panel-lista li { padding: .6rem 0; border-top: 1px solid var(--border); font-size: .85rem; }
.panel-lista li:first-child { border-top: none; }
.panel-lista li a { color: #fff; text-decoration: none; font-weight: 600; }
.panel-lista li .detalle { color: var(--text-faint); font-size: .78rem; display: block; margin-top: .15rem; }

/* Expediente */
.expediente-grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: 1.2rem; align-items: start; }
.expediente-grid .col { display: flex; flex-direction: column; gap: 1rem; }
.seccion { background: var(--bg-card); border: 1px solid var(--border); border-radius: 14px; padding: 1.2rem; }
.seccion h3 { font-size: .95rem; color: var(--accent-light); margin-bottom: .9rem; }
.seccion form + form { margin-top: .9rem; padding-top: .9rem; border-top: 1px solid var(--border); }

.doc-fila { display: flex; justify-content: space-between; align-items: center; gap: .6rem; flex-wrap: wrap; padding: .7rem 0; border-top: 1px solid var(--border); }
.doc-fila:first-child { border-top: none; }
.doc-fila__nombre { font-weight: 600; font-size: .9rem; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: .6rem 0 .6rem .9rem; border-left: 2px solid var(--border); margin-left: .3rem; position: relative; font-size: .83rem; }
.timeline li::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); position: absolute; left: -5px; top: .75rem; }
.timeline .ts { color: var(--text-faint); font-size: .72rem; display: block; }

.paginacion { display: flex; gap: .4rem; justify-content: center; margin: 1.5rem 0; flex-wrap: wrap; }
.paginacion a, .paginacion span {
  padding: .5rem .85rem; border-radius: 8px; border: 1px solid var(--border); font-size: .82rem;
  color: var(--text-dim); text-decoration: none;
}
.paginacion a:hover { border-color: var(--accent); color: #fff; }
.paginacion .is-active { background: var(--accent); border-color: var(--accent); color: #fff; }

.volver { display: inline-flex; align-items: center; gap: .3rem; color: var(--text-dim); text-decoration: none; font-size: .85rem; margin-bottom: 1rem; }
.volver:hover { color: #fff; }

/* Páginas públicas del propio panel (login / aceptar invitación) */
.auth-shell { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 1.5rem; }
.auth-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 16px;
  padding: 2.2rem; width: 100%; max-width: 380px;
  box-shadow: 0 20px 60px -20px rgba(124, 58, 237, .45);
}
.auth-card img { height: 30px; display: block; margin: 0 auto 1.4rem; }
.auth-card h1 { font-size: 1.15rem; text-align: center; margin-bottom: 1.4rem; }
.auth-card button { width: 100%; padding: .8rem; border: 0; border-radius: 8px; background: var(--accent); color: #fff; font-weight: 700; cursor: pointer; font-size: .95rem; }
.auth-card button:hover { background: #6d28d9; }
.auth-card .hint { font-size: .78rem; color: var(--text-faint); text-align: center; margin-top: 1rem; }

/* Responsive: tablet / móvil */
@media (max-width: 860px) {
  .expediente-grid { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  main { padding: 1rem; }
  .page-head { flex-direction: column; align-items: flex-start; }
  .invite-form .campo, .filtros .campo { min-width: 100%; }
}
